fix(number-input): support floating point values (#1555)

Fixes #233, fixes #486, fixes #1554
This commit is contained in:
Jonathan Quintin 2022-12-07 23:06:29 -05:00 committed by GitHub
commit e6f5766e46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 10 deletions

View file

@ -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}"
>