diff --git a/src/shared/ui/ComboControl/ComboControl.stories.svelte b/src/shared/ui/ComboControl/ComboControl.stories.svelte index bdaf27f..09ef682 100644 --- a/src/shared/ui/ComboControl/ComboControl.stories.svelte +++ b/src/shared/ui/ComboControl/ComboControl.stories.svelte @@ -1,7 +1,7 @@ , +): NumericControl { + let value = $state(init.value); + const clamp = (v: number) => Math.min(Math.max(v, init.min), init.max); + + return { + get value() { + return value; + }, + set value(v) { + value = clamp(v); + }, + get min() { + return init.min; + }, + get max() { + return init.max; + }, + get step() { + return init.step; + }, + get isAtMin() { + return value <= init.min; + }, + get isAtMax() { + return value >= init.max; + }, + increase() { + value = clamp(value + init.step); + }, + decrease() { + value = clamp(value - init.step); + }, + }; +}