@zag-js/number-input 0.1.5 → 0.1.8
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 +24 -17
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +24 -17
- package/dist/index.mjs.map +3 -3
- package/dist/number-input.machine.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -108,17 +108,6 @@ function getNativeEvent(event) {
|
|
|
108
108
|
var _a;
|
|
109
109
|
return (_a = event.nativeEvent) != null ? _a : event;
|
|
110
110
|
}
|
|
111
|
-
var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
|
|
112
|
-
var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
|
|
113
|
-
function getEventStep(event) {
|
|
114
|
-
if (event.ctrlKey || event.metaKey) {
|
|
115
|
-
return 0.1;
|
|
116
|
-
} else {
|
|
117
|
-
const isPageKey = PAGE_KEYS.has(event.key);
|
|
118
|
-
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
|
|
119
|
-
return isSkipKey ? 10 : 1;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
111
|
function observeAttributes(node, attributes, fn) {
|
|
123
112
|
if (!node)
|
|
124
113
|
return noop;
|
|
@@ -134,6 +123,17 @@ function observeAttributes(node, attributes, fn) {
|
|
|
134
123
|
obs.observe(node, { attributes: true, attributeFilter: attrs });
|
|
135
124
|
return () => obs.disconnect();
|
|
136
125
|
}
|
|
126
|
+
var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
|
|
127
|
+
var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
|
|
128
|
+
function getEventStep(event) {
|
|
129
|
+
if (event.ctrlKey || event.metaKey) {
|
|
130
|
+
return 0.1;
|
|
131
|
+
} else {
|
|
132
|
+
const isPageKey = PAGE_KEYS.has(event.key);
|
|
133
|
+
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
|
|
134
|
+
return isSkipKey ? 10 : 1;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
137
|
function itemById(v, id) {
|
|
138
138
|
return v.find((node) => node.id === id);
|
|
139
139
|
}
|
|
@@ -304,7 +304,11 @@ function getEventPoint(e, t2 = "page") {
|
|
|
304
304
|
|
|
305
305
|
// ../../types/dist/index.mjs
|
|
306
306
|
function createNormalizer(fn) {
|
|
307
|
-
return {
|
|
307
|
+
return new Proxy({}, {
|
|
308
|
+
get() {
|
|
309
|
+
return fn;
|
|
310
|
+
}
|
|
311
|
+
});
|
|
308
312
|
}
|
|
309
313
|
var normalizeProp = createNormalizer((v) => v);
|
|
310
314
|
|
|
@@ -319,6 +323,7 @@ var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
|
|
|
319
323
|
var isIos = () => isIPhone() || isIPad();
|
|
320
324
|
var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
|
|
321
325
|
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
326
|
+
var isLeftClick = (v) => v.button === 0;
|
|
322
327
|
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
323
328
|
|
|
324
329
|
// src/number-input.dom.ts
|
|
@@ -583,7 +588,7 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
583
588
|
onPointerDown(event) {
|
|
584
589
|
if (isDecrementDisabled)
|
|
585
590
|
return;
|
|
586
|
-
send({ type: "PRESS_DOWN", hint: "decrement" });
|
|
591
|
+
send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "decrement" } : { type: "FOCUS" });
|
|
587
592
|
event.preventDefault();
|
|
588
593
|
},
|
|
589
594
|
onPointerUp() {
|
|
@@ -606,10 +611,10 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
606
611
|
tabIndex: -1,
|
|
607
612
|
"aria-controls": dom.getInputId(state.context),
|
|
608
613
|
onPointerDown(event) {
|
|
609
|
-
event.preventDefault();
|
|
610
614
|
if (isIncrementDisabled)
|
|
611
615
|
return;
|
|
612
|
-
send({ type: "PRESS_DOWN", hint: "increment" });
|
|
616
|
+
send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "increment" } : { type: "FOCUS" });
|
|
617
|
+
event.preventDefault();
|
|
613
618
|
},
|
|
614
619
|
onPointerUp() {
|
|
615
620
|
send({ type: "PRESS_UP", hint: "increment" });
|
|
@@ -727,6 +732,7 @@ function machine(ctx = {}) {
|
|
|
727
732
|
},
|
|
728
733
|
focused: {
|
|
729
734
|
tags: ["focus"],
|
|
735
|
+
entry: "focusInput",
|
|
730
736
|
activities: "attachWheelListener",
|
|
731
737
|
on: {
|
|
732
738
|
PRESS_DOWN: {
|
|
@@ -765,13 +771,14 @@ function machine(ctx = {}) {
|
|
|
765
771
|
},
|
|
766
772
|
{
|
|
767
773
|
target: "idle",
|
|
768
|
-
actions:
|
|
774
|
+
actions: "roundValue"
|
|
769
775
|
}
|
|
770
776
|
]
|
|
771
777
|
}
|
|
772
778
|
},
|
|
773
779
|
"before:spin": {
|
|
774
780
|
tags: ["focus"],
|
|
781
|
+
activities: "trackButtonDisabled",
|
|
775
782
|
entry: choose([
|
|
776
783
|
{ guard: "isIncrementHint", actions: "increment" },
|
|
777
784
|
{ guard: "isDecrementHint", actions: "decrement" }
|
|
@@ -819,7 +826,7 @@ function machine(ctx = {}) {
|
|
|
819
826
|
on: {
|
|
820
827
|
POINTER_UP_SCRUBBER: {
|
|
821
828
|
target: "focused",
|
|
822
|
-
actions:
|
|
829
|
+
actions: "clearCursorPoint"
|
|
823
830
|
},
|
|
824
831
|
POINTER_MOVE_SCRUBBER: [
|
|
825
832
|
{
|