mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-24 06:49:21 -05:00
69ddf6b02f
* feat: Add min/max props into InputNumber Adding range into InputNumber component with min/max props * refactor: InputNumber component * docs: Add Min / Max section into InputNumber * docs: Improvement InputNumber - Change min/max insertion position. - Change the crate that is added to T impl for conciseness. - Uniformity of expression: maximum for minimum.
68 lines
1.9 KiB
Markdown
68 lines
1.9 KiB
Markdown
# Input Number
|
|
|
|
```rust demo
|
|
let value = create_rw_signal(0);
|
|
let value_f64 = create_rw_signal(0.0);
|
|
|
|
view! {
|
|
<Space vertical=true>
|
|
<InputNumber value step=1/>
|
|
<InputNumber value=value_f64 step=1.0/>
|
|
</Space>
|
|
}
|
|
```
|
|
|
|
### Min / Max
|
|
|
|
```rust demo
|
|
let value = create_rw_signal(0);
|
|
|
|
view! {
|
|
<InputNumber value step=1 min=-1 max=2/>
|
|
}
|
|
```
|
|
|
|
### Disabled
|
|
|
|
```rust demo
|
|
let value = create_rw_signal(0);
|
|
|
|
view! {
|
|
<InputNumber value step=1 disabled=true/>
|
|
}
|
|
```
|
|
|
|
### Invalid
|
|
|
|
```rust demo
|
|
let value = create_rw_signal(0);
|
|
|
|
view! {
|
|
<InputNumber value step=1 invalid=true/>
|
|
}
|
|
```
|
|
|
|
### InputNumber Props
|
|
|
|
| Name | Type | Default | Description |
|
|
| --- | --- | --- | --- |
|
|
| class | `OptionalProp<MaybeSignal<String>>` | `Default::default()` | Addtional classes for the input element. |
|
|
| value | `Model<T>` | `T::default()` | Set the input value. |
|
|
| placeholder | `OptionalProp<MaybeSignal<String>>` | `Default::default()` | Placeholder of input number. |
|
|
| step | `MaybeSignal<T>` | | The number which the current value is increased or decreased on key or button press. |
|
|
| min | `MaybeSignal<T>` | `T::min_value()` | The minimum number that the input value can take. |
|
|
| max | `MaybeSignal<T>` | `T::max_value()` | The maximum number that the input value can take. |
|
|
| disabled | `MaybeSignal<bool>` | `false` | Whether the input is disabled. |
|
|
| invalid | `MaybeSignal<bool>` | `false` | Whether the input is invalid. |
|
|
| attr: | `Vec<(&'static str, Attribute)>` | `Default::default()` | The dom attrs of the input element inside the component. |
|
|
|
|
#### T impl
|
|
|
|
`T: Add<Output = T> + Sub<Output = T> + PartialOrd + num::Bounded + Default + Clone + FromStr + ToString + 'static`
|
|
|
|
### InputNumber Ref
|
|
|
|
| Name | Type | Description |
|
|
| ----- | ----------- | ------------------------ |
|
|
| focus | `Fn(&self)` | Focus the input element. |
|
|
| blur | `Fn(&self)` | Blur the input element. |
|