@zag-js/number-input 0.0.0-dev-20220521182600 → 0.0.0-dev-20220522174316

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.js CHANGED
@@ -131,17 +131,6 @@ function getNativeEvent(event) {
131
131
  var _a;
132
132
  return (_a = event.nativeEvent) != null ? _a : event;
133
133
  }
134
- var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
135
- var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
136
- function getEventStep(event) {
137
- if (event.ctrlKey || event.metaKey) {
138
- return 0.1;
139
- } else {
140
- const isPageKey = PAGE_KEYS.has(event.key);
141
- const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
142
- return isSkipKey ? 10 : 1;
143
- }
144
- }
145
134
  function observeAttributes(node, attributes, fn) {
146
135
  if (!node)
147
136
  return noop;
@@ -157,6 +146,17 @@ function observeAttributes(node, attributes, fn) {
157
146
  obs.observe(node, { attributes: true, attributeFilter: attrs });
158
147
  return () => obs.disconnect();
159
148
  }
149
+ var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
150
+ var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
151
+ function getEventStep(event) {
152
+ if (event.ctrlKey || event.metaKey) {
153
+ return 0.1;
154
+ } else {
155
+ const isPageKey = PAGE_KEYS.has(event.key);
156
+ const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
157
+ return isSkipKey ? 10 : 1;
158
+ }
159
+ }
160
160
  function itemById(v, id) {
161
161
  return v.find((node) => node.id === id);
162
162
  }
@@ -342,6 +342,7 @@ var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
342
342
  var isIos = () => isIPhone() || isIPad();
343
343
  var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
344
344
  var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
345
+ var isLeftClick = (v) => v.button === 0;
345
346
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
346
347
 
347
348
  // src/number-input.dom.ts
@@ -606,7 +607,7 @@ function connect(state, send, normalize = normalizeProp) {
606
607
  onPointerDown(event) {
607
608
  if (isDecrementDisabled)
608
609
  return;
609
- send({ type: "PRESS_DOWN", hint: "decrement" });
610
+ send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "decrement" } : { type: "FOCUS" });
610
611
  event.preventDefault();
611
612
  },
612
613
  onPointerUp() {
@@ -629,10 +630,10 @@ function connect(state, send, normalize = normalizeProp) {
629
630
  tabIndex: -1,
630
631
  "aria-controls": dom.getInputId(state.context),
631
632
  onPointerDown(event) {
632
- event.preventDefault();
633
633
  if (isIncrementDisabled)
634
634
  return;
635
- send({ type: "PRESS_DOWN", hint: "increment" });
635
+ send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "increment" } : { type: "FOCUS" });
636
+ event.preventDefault();
636
637
  },
637
638
  onPointerUp() {
638
639
  send({ type: "PRESS_UP", hint: "increment" });
@@ -750,6 +751,7 @@ function machine(ctx = {}) {
750
751
  },
751
752
  focused: {
752
753
  tags: ["focus"],
754
+ entry: "focusInput",
753
755
  activities: "attachWheelListener",
754
756
  on: {
755
757
  PRESS_DOWN: {
@@ -788,13 +790,14 @@ function machine(ctx = {}) {
788
790
  },
789
791
  {
790
792
  target: "idle",
791
- actions: ["roundValue"]
793
+ actions: "roundValue"
792
794
  }
793
795
  ]
794
796
  }
795
797
  },
796
798
  "before:spin": {
797
799
  tags: ["focus"],
800
+ activities: "trackButtonDisabled",
798
801
  entry: (0, import_core.choose)([
799
802
  { guard: "isIncrementHint", actions: "increment" },
800
803
  { guard: "isDecrementHint", actions: "decrement" }
@@ -842,7 +845,7 @@ function machine(ctx = {}) {
842
845
  on: {
843
846
  POINTER_UP_SCRUBBER: {
844
847
  target: "focused",
845
- actions: ["clearCursorPoint"]
848
+ actions: "clearCursorPoint"
846
849
  },
847
850
  POINTER_MOVE_SCRUBBER: [
848
851
  {