@zag-js/number-input 0.1.4 → 0.1.7

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.
package/dist/index.mjs CHANGED
@@ -103,11 +103,11 @@ function addDomEvent(target, event, listener, options) {
103
103
  const node = isRef(target) ? target.current : runIfFn(target);
104
104
  return globalEventBus(node, event, listener, options);
105
105
  }
106
+ var MAX_Z_INDEX = 2147483647;
106
107
  function getNativeEvent(event) {
107
108
  var _a;
108
109
  return (_a = event.nativeEvent) != null ? _a : event;
109
110
  }
110
- var MAX_Z_INDEX = 2147483647;
111
111
  var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
112
112
  var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
113
113
  function getEventStep(event) {
@@ -319,6 +319,7 @@ var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
319
319
  var isIos = () => isIPhone() || isIPad();
320
320
  var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
321
321
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
322
+ var isLeftClick = (v) => v.button === 0;
322
323
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
323
324
 
324
325
  // src/number-input.dom.ts
@@ -572,6 +573,7 @@ function connect(state, send, normalize = normalizeProp) {
572
573
  }),
573
574
  decrementButtonProps: normalize.button({
574
575
  "data-part": "spin-button",
576
+ "data-type": "decrement",
575
577
  id: dom.getDecButtonId(state.context),
576
578
  disabled: isDecrementDisabled,
577
579
  "data-disabled": dataAttr(isDecrementDisabled),
@@ -582,7 +584,7 @@ function connect(state, send, normalize = normalizeProp) {
582
584
  onPointerDown(event) {
583
585
  if (isDecrementDisabled)
584
586
  return;
585
- send({ type: "PRESS_DOWN", hint: "decrement" });
587
+ send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "decrement" } : { type: "FOCUS" });
586
588
  event.preventDefault();
587
589
  },
588
590
  onPointerUp() {
@@ -596,6 +598,7 @@ function connect(state, send, normalize = normalizeProp) {
596
598
  }),
597
599
  incrementButtonProps: normalize.button({
598
600
  "data-part": "spin-button",
601
+ "data-type": "increment",
599
602
  id: dom.getIncButtonId(state.context),
600
603
  disabled: isIncrementDisabled,
601
604
  "data-disabled": dataAttr(isIncrementDisabled),
@@ -604,10 +607,10 @@ function connect(state, send, normalize = normalizeProp) {
604
607
  tabIndex: -1,
605
608
  "aria-controls": dom.getInputId(state.context),
606
609
  onPointerDown(event) {
607
- event.preventDefault();
608
610
  if (isIncrementDisabled)
609
611
  return;
610
- send({ type: "PRESS_DOWN", hint: "increment" });
612
+ send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "increment" } : { type: "FOCUS" });
613
+ event.preventDefault();
611
614
  },
612
615
  onPointerUp() {
613
616
  send({ type: "PRESS_UP", hint: "increment" });
@@ -725,6 +728,7 @@ function machine(ctx = {}) {
725
728
  },
726
729
  focused: {
727
730
  tags: ["focus"],
731
+ entry: "focusInput",
728
732
  activities: "attachWheelListener",
729
733
  on: {
730
734
  PRESS_DOWN: {
@@ -763,13 +767,14 @@ function machine(ctx = {}) {
763
767
  },
764
768
  {
765
769
  target: "idle",
766
- actions: ["roundValue"]
770
+ actions: "roundValue"
767
771
  }
768
772
  ]
769
773
  }
770
774
  },
771
775
  "before:spin": {
772
776
  tags: ["focus"],
777
+ activities: "trackButtonDisabled",
773
778
  entry: choose([
774
779
  { guard: "isIncrementHint", actions: "increment" },
775
780
  { guard: "isDecrementHint", actions: "decrement" }
@@ -817,7 +822,7 @@ function machine(ctx = {}) {
817
822
  on: {
818
823
  POINTER_UP_SCRUBBER: {
819
824
  target: "focused",
820
- actions: ["clearCursorPoint"]
825
+ actions: "clearCursorPoint"
821
826
  },
822
827
  POINTER_MOVE_SCRUBBER: [
823
828
  {