mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
fix(number-input): support floating point values (#1555)
Fixes #233, fixes #486, fixes #1554
This commit is contained in:
parent
e7fe8ca85b
commit
e6f5766e46
3 changed files with 35 additions and 10 deletions
|
@ -113,16 +113,13 @@
|
|||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function updateValue(direction) {
|
||||
const nextValue = (value += direction * step);
|
||||
|
||||
if (nextValue < min) {
|
||||
value = min;
|
||||
} else if (nextValue > max) {
|
||||
value = max;
|
||||
function updateValue(isIncrementing) {
|
||||
if (isIncrementing) {
|
||||
ref.stepUp();
|
||||
} else {
|
||||
value = nextValue;
|
||||
ref.stepDown();
|
||||
}
|
||||
value = ref.value;
|
||||
|
||||
dispatch("input", value);
|
||||
dispatch("change", value);
|
||||
|
@ -235,7 +232,7 @@
|
|||
class:bx--number__control-btn="{true}"
|
||||
class:down-icon="{true}"
|
||||
on:click="{() => {
|
||||
updateValue(-1);
|
||||
updateValue(false);
|
||||
}}"
|
||||
disabled="{disabled}"
|
||||
>
|
||||
|
@ -250,7 +247,7 @@
|
|||
class:bx--number__control-btn="{true}"
|
||||
class:up-icon="{true}"
|
||||
on:click="{() => {
|
||||
updateValue(1);
|
||||
updateValue(true);
|
||||
}}"
|
||||
disabled="{disabled}"
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue