@zag-js/number-input 0.1.6 → 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
@@ -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
@@ -583,7 +584,7 @@ function connect(state, send, normalize = normalizeProp) {
583
584
  onPointerDown(event) {
584
585
  if (isDecrementDisabled)
585
586
  return;
586
- send({ type: "PRESS_DOWN", hint: "decrement" });
587
+ send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "decrement" } : { type: "FOCUS" });
587
588
  event.preventDefault();
588
589
  },
589
590
  onPointerUp() {
@@ -606,10 +607,10 @@ function connect(state, send, normalize = normalizeProp) {
606
607
  tabIndex: -1,
607
608
  "aria-controls": dom.getInputId(state.context),
608
609
  onPointerDown(event) {
609
- event.preventDefault();
610
610
  if (isIncrementDisabled)
611
611
  return;
612
- send({ type: "PRESS_DOWN", hint: "increment" });
612
+ send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "increment" } : { type: "FOCUS" });
613
+ event.preventDefault();
613
614
  },
614
615
  onPointerUp() {
615
616
  send({ type: "PRESS_UP", hint: "increment" });
@@ -727,6 +728,7 @@ function machine(ctx = {}) {
727
728
  },
728
729
  focused: {
729
730
  tags: ["focus"],
731
+ entry: "focusInput",
730
732
  activities: "attachWheelListener",
731
733
  on: {
732
734
  PRESS_DOWN: {
@@ -765,7 +767,7 @@ function machine(ctx = {}) {
765
767
  },
766
768
  {
767
769
  target: "idle",
768
- actions: ["roundValue"]
770
+ actions: "roundValue"
769
771
  }
770
772
  ]
771
773
  }
@@ -820,7 +822,7 @@ function machine(ctx = {}) {
820
822
  on: {
821
823
  POINTER_UP_SCRUBBER: {
822
824
  target: "focused",
823
- actions: ["clearCursorPoint"]
825
+ actions: "clearCursorPoint"
824
826
  },
825
827
  POINTER_MOVE_SCRUBBER: [
826
828
  {