@zag-js/number-input 0.0.0-dev-20220730094117 → 0.0.0-dev-20220823143115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +396 -359
  2. package/dist/index.mjs +398 -361
  3. package/package.json +5 -4
package/dist/index.js CHANGED
@@ -52,11 +52,8 @@ function getPlatform() {
52
52
  }
53
53
  var pt = (v) => isDom() && v.test(getPlatform());
54
54
  var vn = (v) => isDom() && v.test(navigator.vendor);
55
- var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
56
- var isMac = () => pt(/^Mac/) && !isTouchDevice;
57
55
  var isSafari = () => isApple() && vn(/apple/i);
58
56
  var isApple = () => pt(/mac|iphone|ipad|ipod/i);
59
- var isIos = () => isApple() && !isMac();
60
57
  function isDocument(el) {
61
58
  return el.nodeType === Node.DOCUMENT_NODE;
62
59
  }
@@ -93,21 +90,6 @@ var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
93
90
  var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
94
91
  var isLeftClick = (v) => v.button === 0;
95
92
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
96
- function observeAttributes(node, attributes, fn) {
97
- if (!node)
98
- return;
99
- const attrs = Array.isArray(attributes) ? attributes : [attributes];
100
- const win = node.ownerDocument.defaultView || window;
101
- const obs = new win.MutationObserver((changes) => {
102
- for (const change of changes) {
103
- if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
104
- fn(change);
105
- }
106
- }
107
- });
108
- obs.observe(node, { attributes: true, attributeFilter: attrs });
109
- return () => obs.disconnect();
110
- }
111
93
  var fallback = {
112
94
  pageX: 0,
113
95
  pageY: 0,
@@ -137,6 +119,21 @@ function addDomEvent(target, eventName, handler, options) {
137
119
  node == null ? void 0 : node.removeEventListener(eventName, handler, options);
138
120
  };
139
121
  }
122
+ function observeAttributes(node, attributes, fn) {
123
+ if (!node)
124
+ return;
125
+ const attrs = Array.isArray(attributes) ? attributes : [attributes];
126
+ const win = node.ownerDocument.defaultView || window;
127
+ const obs = new win.MutationObserver((changes) => {
128
+ for (const change of changes) {
129
+ if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
130
+ fn(change);
131
+ }
132
+ }
133
+ });
134
+ obs.observe(node, { attributes: true, attributeFilter: attrs });
135
+ return () => obs.disconnect();
136
+ }
140
137
  function raf(fn) {
141
138
  const id = globalThis.requestAnimationFrame(fn);
142
139
  return function cleanup() {
@@ -175,7 +172,10 @@ function requestPointerLock(doc, handlers = {}) {
175
172
  if (!supported)
176
173
  return;
177
174
  body.requestPointerLock();
178
- const cleanup = callAll(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
175
+ const cleanup = callAll(
176
+ addPointerlockChangeListener(doc, onPointerChange),
177
+ addPointerlockErrorListener(doc, onPointerError)
178
+ );
179
179
  return function dispose() {
180
180
  if (!supported)
181
181
  return;
@@ -470,7 +470,7 @@ function connect(state, send, normalize) {
470
470
  name: state.context.name,
471
471
  id: dom.getInputId(state.context),
472
472
  role: "spinbutton",
473
- value: state.context.formattedValue,
473
+ defaultValue: state.context.formattedValue,
474
474
  pattern: state.context.pattern,
475
475
  inputMode: state.context.inputMode,
476
476
  "aria-invalid": isInvalid || void 0,
@@ -482,7 +482,7 @@ function connect(state, send, normalize) {
482
482
  autoCorrect: "off",
483
483
  spellCheck: "false",
484
484
  type: "text",
485
- "aria-roledescription": !isIos() ? "number field" : void 0,
485
+ "aria-roledescription": "numberfield",
486
486
  "aria-valuemin": state.context.min,
487
487
  "aria-valuemax": state.context.max,
488
488
  "aria-valuenow": isNaN(state.context.valueAsNumber) ? void 0 : state.context.valueAsNumber,
@@ -608,379 +608,416 @@ var callAll2 = (...fns) => (...a) => {
608
608
  });
609
609
  };
610
610
 
611
+ // ../../utilities/form-utils/dist/index.mjs
612
+ function getWindow(el) {
613
+ return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
614
+ }
615
+ function getDescriptor(el, options) {
616
+ const { type, property } = options;
617
+ const proto = getWindow(el)[type].prototype;
618
+ return Object.getOwnPropertyDescriptor(proto, property) ?? {};
619
+ }
620
+ function dispatchInputValueEvent(el, value) {
621
+ var _a;
622
+ if (!el)
623
+ return;
624
+ const win = getWindow(el);
625
+ if (!(el instanceof win.HTMLInputElement))
626
+ return;
627
+ const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
628
+ (_a = desc.set) == null ? void 0 : _a.call(el, value);
629
+ const event = new win.Event("input", { bubbles: true });
630
+ el.dispatchEvent(event);
631
+ }
632
+
611
633
  // src/number-input.machine.ts
612
634
  var { not, and } = import_core.guards;
613
635
  function machine(ctx) {
614
- return (0, import_core.createMachine)({
615
- id: "number-input",
616
- initial: "unknown",
617
- context: {
618
- dir: "ltr",
619
- focusInputOnChange: true,
620
- clampValueOnBlur: true,
621
- allowOverflow: false,
622
- inputMode: "decimal",
623
- pattern: "[0-9]*(.[0-9]+)?",
624
- hint: null,
625
- value: "",
626
- step: 1,
627
- min: Number.MIN_SAFE_INTEGER,
628
- max: Number.MAX_SAFE_INTEGER,
629
- scrubberCursorPoint: null,
630
- invalid: false,
631
- spinOnPress: true,
632
- ...ctx,
633
- messages: {
634
- incrementLabel: "increment value",
635
- decrementLabel: "decrease value",
636
- ...ctx.messages
637
- }
638
- },
639
- computed: {
640
- isRtl: (ctx2) => ctx2.dir === "rtl",
641
- valueAsNumber: (ctx2) => valueOf(ctx2.value),
642
- isAtMin: (ctx2) => isAtMin(ctx2.value, ctx2),
643
- isAtMax: (ctx2) => isAtMax(ctx2.value, ctx2),
644
- isOutOfRange: (ctx2) => !isWithinRange(ctx2.value, ctx2),
645
- isValueEmpty: (ctx2) => ctx2.value === "",
646
- canIncrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMax,
647
- canDecrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMin,
648
- valueText: (ctx2) => {
649
- var _a, _b;
650
- return (_b = (_a = ctx2.messages).valueText) == null ? void 0 : _b.call(_a, ctx2.value);
651
- },
652
- formattedValue: (ctx2) => {
653
- var _a;
654
- return ((_a = ctx2.format) == null ? void 0 : _a.call(ctx2, ctx2.value).toString()) ?? ctx2.value;
655
- }
656
- },
657
- watch: {
658
- value: ["invokeOnChange"],
659
- isOutOfRange: ["invokeOnInvalid"],
660
- scrubberCursorPoint: ["setVirtualCursorPosition"]
661
- },
662
- on: {
663
- SET_VALUE: {
664
- actions: ["setValue", "setHintToSet"]
665
- },
666
- CLEAR_VALUE: {
667
- actions: ["clearValue"]
668
- },
669
- INCREMENT: {
670
- actions: ["increment"]
636
+ return (0, import_core.createMachine)(
637
+ {
638
+ id: "number-input",
639
+ initial: "unknown",
640
+ context: {
641
+ dir: "ltr",
642
+ focusInputOnChange: true,
643
+ clampValueOnBlur: true,
644
+ allowOverflow: false,
645
+ inputMode: "decimal",
646
+ pattern: "[0-9]*(.[0-9]+)?",
647
+ hint: null,
648
+ value: "",
649
+ step: 1,
650
+ min: Number.MIN_SAFE_INTEGER,
651
+ max: Number.MAX_SAFE_INTEGER,
652
+ scrubberCursorPoint: null,
653
+ invalid: false,
654
+ spinOnPress: true,
655
+ ...ctx,
656
+ messages: {
657
+ incrementLabel: "increment value",
658
+ decrementLabel: "decrease value",
659
+ ...ctx.messages
660
+ }
671
661
  },
672
- DECREMENT: {
673
- actions: ["decrement"]
674
- }
675
- },
676
- states: {
677
- unknown: {
678
- on: {
679
- SETUP: {
680
- target: "idle",
681
- actions: "syncInputValue"
682
- }
662
+ computed: {
663
+ isRtl: (ctx2) => ctx2.dir === "rtl",
664
+ valueAsNumber: (ctx2) => valueOf(ctx2.value),
665
+ isAtMin: (ctx2) => isAtMin(ctx2.value, ctx2),
666
+ isAtMax: (ctx2) => isAtMax(ctx2.value, ctx2),
667
+ isOutOfRange: (ctx2) => !isWithinRange(ctx2.value, ctx2),
668
+ isValueEmpty: (ctx2) => ctx2.value === "",
669
+ canIncrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMax,
670
+ canDecrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMin,
671
+ valueText: (ctx2) => {
672
+ var _a, _b;
673
+ return (_b = (_a = ctx2.messages).valueText) == null ? void 0 : _b.call(_a, ctx2.value);
674
+ },
675
+ formattedValue: (ctx2) => {
676
+ var _a;
677
+ return ((_a = ctx2.format) == null ? void 0 : _a.call(ctx2, ctx2.value).toString()) ?? ctx2.value;
683
678
  }
684
679
  },
685
- idle: {
686
- exit: "invokeOnFocus",
687
- on: {
688
- PRESS_DOWN: {
689
- target: "before:spin",
690
- actions: ["focusInput", "setHint"]
691
- },
692
- PRESS_DOWN_SCRUBBER: {
693
- target: "scrubbing",
694
- actions: ["focusInput", "setHint", "setCursorPoint"]
680
+ watch: {
681
+ value: ["invokeOnChange", "dispatchChangeEvent"],
682
+ isOutOfRange: ["invokeOnInvalid"],
683
+ scrubberCursorPoint: ["setVirtualCursorPosition"]
684
+ },
685
+ on: {
686
+ SET_VALUE: [
687
+ {
688
+ guard: "clampOnBlur",
689
+ actions: ["setValue", "clampValue", "setHintToSet"]
695
690
  },
696
- FOCUS: "focused"
691
+ {
692
+ actions: ["setValue", "setHintToSet"]
693
+ }
694
+ ],
695
+ CLEAR_VALUE: {
696
+ actions: ["clearValue"]
697
+ },
698
+ INCREMENT: {
699
+ actions: ["increment"]
700
+ },
701
+ DECREMENT: {
702
+ actions: ["decrement"]
697
703
  }
698
704
  },
699
- focused: {
700
- tags: "focus",
701
- entry: "focusInput",
702
- activities: "attachWheelListener",
703
- on: {
704
- PRESS_DOWN: {
705
- target: "before:spin",
706
- actions: ["focusInput", "setHint"]
707
- },
708
- PRESS_DOWN_SCRUBBER: {
709
- target: "scrubbing",
710
- actions: ["focusInput", "setHint", "setCursorPoint"]
711
- },
712
- ARROW_UP: {
713
- actions: "increment"
714
- },
715
- ARROW_DOWN: {
716
- actions: "decrement"
717
- },
718
- HOME: {
719
- actions: "setToMin"
720
- },
721
- END: {
722
- actions: "setToMax"
723
- },
724
- CHANGE: {
725
- actions: ["setValue", "setHint"]
726
- },
727
- BLUR: [
728
- {
729
- guard: "isInvalidExponential",
705
+ states: {
706
+ unknown: {
707
+ on: {
708
+ SETUP: {
730
709
  target: "idle",
731
- actions: ["clearValue", "clearHint", "invokeOnBlur"]
710
+ actions: "syncInputValue"
711
+ }
712
+ }
713
+ },
714
+ idle: {
715
+ exit: "invokeOnFocus",
716
+ on: {
717
+ PRESS_DOWN: {
718
+ target: "before:spin",
719
+ actions: ["focusInput", "setHint"]
732
720
  },
733
- {
734
- guard: and("clampOnBlur", not("isInRange"), not("isEmptyValue")),
735
- target: "idle",
736
- actions: ["clampValue", "clearHint", "invokeOnBlur"]
721
+ PRESS_DOWN_SCRUBBER: {
722
+ target: "scrubbing",
723
+ actions: ["focusInput", "setHint", "setCursorPoint"]
737
724
  },
738
- {
739
- target: "idle",
740
- actions: ["roundValue", "invokeOnBlur"]
741
- }
742
- ]
743
- }
744
- },
745
- "before:spin": {
746
- tags: "focus",
747
- activities: "trackButtonDisabled",
748
- entry: (0, import_core.choose)([
749
- { guard: "isIncrementHint", actions: "increment" },
750
- { guard: "isDecrementHint", actions: "decrement" }
751
- ]),
752
- after: {
753
- CHANGE_DELAY: {
754
- target: "spinning",
755
- guard: and("isInRange", "spinOnPress")
725
+ FOCUS: "focused"
756
726
  }
757
727
  },
758
- on: {
759
- PRESS_UP: {
760
- target: "focused",
761
- actions: "clearHint"
728
+ focused: {
729
+ tags: "focus",
730
+ entry: "focusInput",
731
+ activities: "attachWheelListener",
732
+ on: {
733
+ PRESS_DOWN: {
734
+ target: "before:spin",
735
+ actions: ["focusInput", "setHint"]
736
+ },
737
+ PRESS_DOWN_SCRUBBER: {
738
+ target: "scrubbing",
739
+ actions: ["focusInput", "setHint", "setCursorPoint"]
740
+ },
741
+ ARROW_UP: {
742
+ actions: "increment"
743
+ },
744
+ ARROW_DOWN: {
745
+ actions: "decrement"
746
+ },
747
+ HOME: {
748
+ actions: "setToMin"
749
+ },
750
+ END: {
751
+ actions: "setToMax"
752
+ },
753
+ CHANGE: {
754
+ actions: ["setValue", "setHint"]
755
+ },
756
+ BLUR: [
757
+ {
758
+ guard: "isInvalidExponential",
759
+ target: "idle",
760
+ actions: ["clearValue", "clearHint", "invokeOnBlur"]
761
+ },
762
+ {
763
+ guard: and("clampOnBlur", not("isInRange"), not("isEmptyValue")),
764
+ target: "idle",
765
+ actions: ["clampValue", "clearHint", "invokeOnBlur"]
766
+ },
767
+ {
768
+ target: "idle",
769
+ actions: ["roundValue", "invokeOnBlur"]
770
+ }
771
+ ]
762
772
  }
763
- }
764
- },
765
- spinning: {
766
- tags: "focus",
767
- activities: "trackButtonDisabled",
768
- every: [
769
- {
770
- delay: "CHANGE_INTERVAL",
771
- guard: and(not("isAtMin"), "isIncrementHint"),
772
- actions: "increment"
773
+ },
774
+ "before:spin": {
775
+ tags: "focus",
776
+ activities: "trackButtonDisabled",
777
+ entry: (0, import_core.choose)([
778
+ { guard: "isIncrementHint", actions: "increment" },
779
+ { guard: "isDecrementHint", actions: "decrement" }
780
+ ]),
781
+ after: {
782
+ CHANGE_DELAY: {
783
+ target: "spinning",
784
+ guard: and("isInRange", "spinOnPress")
785
+ }
773
786
  },
774
- {
775
- delay: "CHANGE_INTERVAL",
776
- guard: and(not("isAtMax"), "isDecrementHint"),
777
- actions: "decrement"
778
- }
779
- ],
780
- on: {
781
- PRESS_UP: {
782
- target: "focused",
783
- actions: "clearHint"
787
+ on: {
788
+ PRESS_UP: {
789
+ target: "focused",
790
+ actions: "clearHint"
791
+ }
784
792
  }
785
- }
786
- },
787
- scrubbing: {
788
- tags: "focus",
789
- exit: "clearCursorPoint",
790
- activities: ["activatePointerLock", "trackMousemove", "setupVirtualCursor", "preventTextSelection"],
791
- on: {
792
- POINTER_UP_SCRUBBER: "focused",
793
- POINTER_MOVE_SCRUBBER: [
793
+ },
794
+ spinning: {
795
+ tags: "focus",
796
+ activities: "trackButtonDisabled",
797
+ every: [
794
798
  {
795
- guard: "isIncrementHint",
796
- actions: ["increment", "setCursorPoint"]
799
+ delay: "CHANGE_INTERVAL",
800
+ guard: and(not("isAtMin"), "isIncrementHint"),
801
+ actions: "increment"
797
802
  },
798
803
  {
799
- guard: "isDecrementHint",
800
- actions: ["decrement", "setCursorPoint"]
804
+ delay: "CHANGE_INTERVAL",
805
+ guard: and(not("isAtMax"), "isDecrementHint"),
806
+ actions: "decrement"
807
+ }
808
+ ],
809
+ on: {
810
+ PRESS_UP: {
811
+ target: "focused",
812
+ actions: "clearHint"
801
813
  }
802
- ]
814
+ }
815
+ },
816
+ scrubbing: {
817
+ tags: "focus",
818
+ exit: "clearCursorPoint",
819
+ activities: ["activatePointerLock", "trackMousemove", "setupVirtualCursor", "preventTextSelection"],
820
+ on: {
821
+ POINTER_UP_SCRUBBER: "focused",
822
+ POINTER_MOVE_SCRUBBER: [
823
+ {
824
+ guard: "isIncrementHint",
825
+ actions: ["increment", "setCursorPoint"]
826
+ },
827
+ {
828
+ guard: "isDecrementHint",
829
+ actions: ["decrement", "setCursorPoint"]
830
+ }
831
+ ]
832
+ }
803
833
  }
804
834
  }
805
- }
806
- }, {
807
- delays: {
808
- CHANGE_INTERVAL: 50,
809
- CHANGE_DELAY: 300
810
- },
811
- guards: {
812
- clampOnBlur: (ctx2) => !!ctx2.clampValueOnBlur,
813
- isAtMin: (ctx2) => ctx2.isAtMin,
814
- spinOnPress: (ctx2) => !!ctx2.spinOnPress,
815
- isAtMax: (ctx2) => ctx2.isAtMax,
816
- isInRange: (ctx2) => !ctx2.isOutOfRange,
817
- isDecrementHint: (ctx2, evt) => (evt.hint ?? ctx2.hint) === "decrement",
818
- isEmptyValue: (ctx2) => ctx2.isValueEmpty,
819
- isIncrementHint: (ctx2, evt) => (evt.hint ?? ctx2.hint) === "increment",
820
- isInvalidExponential: (ctx2) => ctx2.value.toString().startsWith("e")
821
835
  },
822
- activities: {
823
- setupVirtualCursor(ctx2) {
824
- return dom.setupVirtualCursor(ctx2);
836
+ {
837
+ delays: {
838
+ CHANGE_INTERVAL: 50,
839
+ CHANGE_DELAY: 300
825
840
  },
826
- preventTextSelection(ctx2) {
827
- return dom.preventTextSelection(ctx2);
841
+ guards: {
842
+ clampOnBlur: (ctx2) => !!ctx2.clampValueOnBlur,
843
+ isAtMin: (ctx2) => ctx2.isAtMin,
844
+ spinOnPress: (ctx2) => !!ctx2.spinOnPress,
845
+ isAtMax: (ctx2) => ctx2.isAtMax,
846
+ isInRange: (ctx2) => !ctx2.isOutOfRange,
847
+ isDecrementHint: (ctx2, evt) => (evt.hint ?? ctx2.hint) === "decrement",
848
+ isEmptyValue: (ctx2) => ctx2.isValueEmpty,
849
+ isIncrementHint: (ctx2, evt) => (evt.hint ?? ctx2.hint) === "increment",
850
+ isInvalidExponential: (ctx2) => ctx2.value.toString().startsWith("e")
828
851
  },
829
- trackButtonDisabled(ctx2, _evt, { send }) {
830
- const btn = dom.getActiveButton(ctx2, ctx2.hint);
831
- return observeAttributes(btn, "disabled", () => send("PRESS_UP"));
832
- },
833
- attachWheelListener(ctx2, _evt, { send }) {
834
- const input = dom.getInputEl(ctx2);
835
- if (!input)
836
- return;
837
- function onWheel(event) {
838
- const isInputFocused = dom.getDoc(ctx2).activeElement === input;
839
- if (!ctx2.allowMouseWheel || !isInputFocused)
852
+ activities: {
853
+ setupVirtualCursor(ctx2) {
854
+ return dom.setupVirtualCursor(ctx2);
855
+ },
856
+ preventTextSelection(ctx2) {
857
+ return dom.preventTextSelection(ctx2);
858
+ },
859
+ trackButtonDisabled(ctx2, _evt, { send }) {
860
+ const btn = dom.getActiveButton(ctx2, ctx2.hint);
861
+ return observeAttributes(btn, "disabled", () => send("PRESS_UP"));
862
+ },
863
+ attachWheelListener(ctx2, _evt, { send }) {
864
+ const input = dom.getInputEl(ctx2);
865
+ if (!input)
840
866
  return;
841
- event.preventDefault();
842
- const dir = Math.sign(event.deltaY) * -1;
843
- if (dir === 1) {
844
- send("INCREMENT");
845
- } else if (dir === -1) {
846
- send("DECREMENT");
867
+ function onWheel(event) {
868
+ const isInputFocused = dom.getDoc(ctx2).activeElement === input;
869
+ if (!ctx2.allowMouseWheel || !isInputFocused)
870
+ return;
871
+ event.preventDefault();
872
+ const dir = Math.sign(event.deltaY) * -1;
873
+ if (dir === 1) {
874
+ send("INCREMENT");
875
+ } else if (dir === -1) {
876
+ send("DECREMENT");
877
+ }
847
878
  }
879
+ return addDomEvent(input, "wheel", onWheel, { passive: false });
880
+ },
881
+ activatePointerLock(ctx2) {
882
+ if (isSafari() || !supportsPointerEvent())
883
+ return;
884
+ return requestPointerLock(dom.getDoc(ctx2));
885
+ },
886
+ trackMousemove(ctx2, _evt, { send }) {
887
+ const doc = dom.getDoc(ctx2);
888
+ function onMousemove(event) {
889
+ if (!ctx2.scrubberCursorPoint)
890
+ return;
891
+ const value = dom.getMousementValue(ctx2, event);
892
+ if (!value.hint)
893
+ return;
894
+ send({
895
+ type: "POINTER_MOVE_SCRUBBER",
896
+ hint: value.hint,
897
+ point: value.point
898
+ });
899
+ }
900
+ function onMouseup() {
901
+ send("POINTER_UP_SCRUBBER");
902
+ }
903
+ return callAll2(
904
+ addDomEvent(doc, "mousemove", onMousemove, false),
905
+ addDomEvent(doc, "mouseup", onMouseup, false)
906
+ );
848
907
  }
849
- return addDomEvent(input, "wheel", onWheel, { passive: false });
850
- },
851
- activatePointerLock(ctx2) {
852
- if (isSafari() || !supportsPointerEvent())
853
- return;
854
- return requestPointerLock(dom.getDoc(ctx2));
855
908
  },
856
- trackMousemove(ctx2, _evt, { send }) {
857
- const doc = dom.getDoc(ctx2);
858
- function onMousemove(event) {
859
- if (!ctx2.scrubberCursorPoint)
909
+ actions: {
910
+ focusInput(ctx2) {
911
+ if (!ctx2.focusInputOnChange)
860
912
  return;
861
- const value = dom.getMousementValue(ctx2, event);
862
- if (!value.hint)
913
+ const input = dom.getInputEl(ctx2);
914
+ raf(() => input == null ? void 0 : input.focus());
915
+ },
916
+ increment(ctx2, evt) {
917
+ ctx2.value = utils.increment(ctx2, evt.step);
918
+ },
919
+ decrement(ctx2, evt) {
920
+ ctx2.value = utils.decrement(ctx2, evt.step);
921
+ },
922
+ clampValue(ctx2) {
923
+ ctx2.value = utils.clamp(ctx2);
924
+ },
925
+ roundValue(ctx2) {
926
+ if (ctx2.value !== "") {
927
+ ctx2.value = utils.round(ctx2);
928
+ }
929
+ },
930
+ setValue(ctx2, evt) {
931
+ var _a;
932
+ const value = ((_a = evt.target) == null ? void 0 : _a.value) ?? evt.value;
933
+ ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
934
+ },
935
+ clearValue(ctx2) {
936
+ ctx2.value = "";
937
+ },
938
+ setToMax(ctx2) {
939
+ ctx2.value = ctx2.max.toString();
940
+ },
941
+ setToMin(ctx2) {
942
+ ctx2.value = ctx2.min.toString();
943
+ },
944
+ setHint(ctx2, evt) {
945
+ ctx2.hint = evt.hint;
946
+ },
947
+ clearHint(ctx2) {
948
+ ctx2.hint = null;
949
+ },
950
+ setHintToSet(ctx2) {
951
+ ctx2.hint = "set";
952
+ },
953
+ invokeOnChange(ctx2) {
954
+ var _a;
955
+ (_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, {
956
+ value: ctx2.value,
957
+ valueAsNumber: ctx2.valueAsNumber
958
+ });
959
+ },
960
+ invokeOnFocus(ctx2, evt) {
961
+ var _a;
962
+ let srcElement = null;
963
+ if (evt.type === "PRESS_DOWN") {
964
+ srcElement = dom.getActiveButton(ctx2, evt.hint);
965
+ } else if (evt.type === "FOCUS") {
966
+ srcElement = dom.getInputEl(ctx2);
967
+ } else if (evt.type === "PRESS_DOWN_SCRUBBER") {
968
+ srcElement = dom.getScrubberEl(ctx2);
969
+ }
970
+ (_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, {
971
+ value: ctx2.value,
972
+ valueAsNumber: ctx2.valueAsNumber,
973
+ srcElement
974
+ });
975
+ },
976
+ invokeOnBlur(ctx2) {
977
+ var _a;
978
+ (_a = ctx2.onBlur) == null ? void 0 : _a.call(ctx2, {
979
+ value: ctx2.value,
980
+ valueAsNumber: ctx2.valueAsNumber
981
+ });
982
+ },
983
+ invokeOnInvalid(ctx2) {
984
+ var _a;
985
+ if (!ctx2.isOutOfRange)
863
986
  return;
864
- send({
865
- type: "POINTER_MOVE_SCRUBBER",
866
- hint: value.hint,
867
- point: value.point
987
+ const reason = ctx2.valueAsNumber > ctx2.max ? "rangeOverflow" : "rangeUnderflow";
988
+ (_a = ctx2.onInvalid) == null ? void 0 : _a.call(ctx2, {
989
+ reason,
990
+ value: ctx2.formattedValue,
991
+ valueAsNumber: ctx2.valueAsNumber
868
992
  });
993
+ },
994
+ syncInputValue(ctx2) {
995
+ const input = dom.getInputEl(ctx2);
996
+ if (!input || input.value == ctx2.value)
997
+ return;
998
+ const value = utils.parse(ctx2, input.value);
999
+ ctx2.value = utils.sanitize(ctx2, value);
1000
+ },
1001
+ setCursorPoint(ctx2, evt) {
1002
+ ctx2.scrubberCursorPoint = evt.point;
1003
+ },
1004
+ clearCursorPoint(ctx2) {
1005
+ ctx2.scrubberCursorPoint = null;
1006
+ },
1007
+ setVirtualCursorPosition(ctx2) {
1008
+ const cursor = dom.getCursorEl(ctx2);
1009
+ if (!cursor || !ctx2.scrubberCursorPoint)
1010
+ return;
1011
+ const { x, y } = ctx2.scrubberCursorPoint;
1012
+ cursor.style.transform = `translate3d(${x}px, ${y}px, 0px)`;
1013
+ },
1014
+ dispatchChangeEvent(ctx2) {
1015
+ dispatchInputValueEvent(dom.getInputEl(ctx2), ctx2.formattedValue);
869
1016
  }
870
- function onMouseup() {
871
- send("POINTER_UP_SCRUBBER");
872
- }
873
- return callAll2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
874
- }
875
- },
876
- actions: {
877
- focusInput(ctx2) {
878
- if (!ctx2.focusInputOnChange)
879
- return;
880
- const input = dom.getInputEl(ctx2);
881
- raf(() => input == null ? void 0 : input.focus());
882
- },
883
- increment(ctx2, evt) {
884
- ctx2.value = utils.increment(ctx2, evt.step);
885
- },
886
- decrement(ctx2, evt) {
887
- ctx2.value = utils.decrement(ctx2, evt.step);
888
- },
889
- clampValue(ctx2) {
890
- ctx2.value = utils.clamp(ctx2);
891
- },
892
- roundValue(ctx2) {
893
- if (ctx2.value !== "") {
894
- ctx2.value = utils.round(ctx2);
895
- }
896
- },
897
- setValue(ctx2, evt) {
898
- var _a;
899
- const value = ((_a = evt.target) == null ? void 0 : _a.value) ?? evt.value;
900
- ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value.toString()));
901
- },
902
- clearValue(ctx2) {
903
- ctx2.value = "";
904
- },
905
- setToMax(ctx2) {
906
- ctx2.value = ctx2.max.toString();
907
- },
908
- setToMin(ctx2) {
909
- ctx2.value = ctx2.min.toString();
910
- },
911
- setHint(ctx2, evt) {
912
- ctx2.hint = evt.hint;
913
- },
914
- clearHint(ctx2) {
915
- ctx2.hint = null;
916
- },
917
- setHintToSet(ctx2) {
918
- ctx2.hint = "set";
919
- },
920
- invokeOnChange(ctx2) {
921
- var _a;
922
- (_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, {
923
- value: ctx2.value,
924
- valueAsNumber: ctx2.valueAsNumber
925
- });
926
- },
927
- invokeOnFocus(ctx2, evt) {
928
- var _a;
929
- let srcElement = null;
930
- if (evt.type === "PRESS_DOWN") {
931
- srcElement = dom.getActiveButton(ctx2, evt.hint);
932
- } else if (evt.type === "FOCUS") {
933
- srcElement = dom.getInputEl(ctx2);
934
- } else if (evt.type === "PRESS_DOWN_SCRUBBER") {
935
- srcElement = dom.getScrubberEl(ctx2);
936
- }
937
- (_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, {
938
- value: ctx2.value,
939
- valueAsNumber: ctx2.valueAsNumber,
940
- srcElement
941
- });
942
1017
  },
943
- invokeOnBlur(ctx2) {
944
- var _a;
945
- (_a = ctx2.onBlur) == null ? void 0 : _a.call(ctx2, {
946
- value: ctx2.value,
947
- valueAsNumber: ctx2.valueAsNumber
948
- });
949
- },
950
- invokeOnInvalid(ctx2) {
951
- var _a;
952
- if (!ctx2.isOutOfRange)
953
- return;
954
- const reason = ctx2.valueAsNumber > ctx2.max ? "rangeOverflow" : "rangeUnderflow";
955
- (_a = ctx2.onInvalid) == null ? void 0 : _a.call(ctx2, {
956
- reason,
957
- value: ctx2.formattedValue,
958
- valueAsNumber: ctx2.valueAsNumber
959
- });
960
- },
961
- syncInputValue(ctx2) {
962
- const input = dom.getInputEl(ctx2);
963
- if (!input || input.value == ctx2.value)
964
- return;
965
- const value = utils.parse(ctx2, input.value);
966
- ctx2.value = utils.sanitize(ctx2, value);
967
- },
968
- setCursorPoint(ctx2, evt) {
969
- ctx2.scrubberCursorPoint = evt.point;
970
- },
971
- clearCursorPoint(ctx2) {
972
- ctx2.scrubberCursorPoint = null;
973
- },
974
- setVirtualCursorPosition(ctx2) {
975
- const cursor = dom.getCursorEl(ctx2);
976
- if (!cursor || !ctx2.scrubberCursorPoint)
977
- return;
978
- const { x, y } = ctx2.scrubberCursorPoint;
979
- cursor.style.transform = `translate3d(${x}px, ${y}px, 0px)`;
980
- }
981
- },
982
- hookSync: true
983
- });
1018
+ hookSync: true
1019
+ }
1020
+ );
984
1021
  }
985
1022
  // Annotate the CommonJS export names for ESM import in node:
986
1023
  0 && (module.exports = {