@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.js +11 -6
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +11 -6
- package/dist/index.mjs.map +3 -3
- package/dist/number-input.connect.d.ts.map +1 -1
- package/dist/number-input.machine.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -126,11 +126,11 @@ function addDomEvent(target, event, listener, options) {
|
|
|
126
126
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
127
127
|
return globalEventBus(node, event, listener, options);
|
|
128
128
|
}
|
|
129
|
+
var MAX_Z_INDEX = 2147483647;
|
|
129
130
|
function getNativeEvent(event) {
|
|
130
131
|
var _a;
|
|
131
132
|
return (_a = event.nativeEvent) != null ? _a : event;
|
|
132
133
|
}
|
|
133
|
-
var MAX_Z_INDEX = 2147483647;
|
|
134
134
|
var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
|
|
135
135
|
var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
|
|
136
136
|
function getEventStep(event) {
|
|
@@ -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
|
|
@@ -595,6 +596,7 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
595
596
|
}),
|
|
596
597
|
decrementButtonProps: normalize.button({
|
|
597
598
|
"data-part": "spin-button",
|
|
599
|
+
"data-type": "decrement",
|
|
598
600
|
id: dom.getDecButtonId(state.context),
|
|
599
601
|
disabled: isDecrementDisabled,
|
|
600
602
|
"data-disabled": dataAttr(isDecrementDisabled),
|
|
@@ -605,7 +607,7 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
605
607
|
onPointerDown(event) {
|
|
606
608
|
if (isDecrementDisabled)
|
|
607
609
|
return;
|
|
608
|
-
send({ type: "PRESS_DOWN", hint: "decrement" });
|
|
610
|
+
send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "decrement" } : { type: "FOCUS" });
|
|
609
611
|
event.preventDefault();
|
|
610
612
|
},
|
|
611
613
|
onPointerUp() {
|
|
@@ -619,6 +621,7 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
619
621
|
}),
|
|
620
622
|
incrementButtonProps: normalize.button({
|
|
621
623
|
"data-part": "spin-button",
|
|
624
|
+
"data-type": "increment",
|
|
622
625
|
id: dom.getIncButtonId(state.context),
|
|
623
626
|
disabled: isIncrementDisabled,
|
|
624
627
|
"data-disabled": dataAttr(isIncrementDisabled),
|
|
@@ -627,10 +630,10 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
627
630
|
tabIndex: -1,
|
|
628
631
|
"aria-controls": dom.getInputId(state.context),
|
|
629
632
|
onPointerDown(event) {
|
|
630
|
-
event.preventDefault();
|
|
631
633
|
if (isIncrementDisabled)
|
|
632
634
|
return;
|
|
633
|
-
send({ type: "PRESS_DOWN", hint: "increment" });
|
|
635
|
+
send(isLeftClick(event) ? { type: "PRESS_DOWN", hint: "increment" } : { type: "FOCUS" });
|
|
636
|
+
event.preventDefault();
|
|
634
637
|
},
|
|
635
638
|
onPointerUp() {
|
|
636
639
|
send({ type: "PRESS_UP", hint: "increment" });
|
|
@@ -748,6 +751,7 @@ function machine(ctx = {}) {
|
|
|
748
751
|
},
|
|
749
752
|
focused: {
|
|
750
753
|
tags: ["focus"],
|
|
754
|
+
entry: "focusInput",
|
|
751
755
|
activities: "attachWheelListener",
|
|
752
756
|
on: {
|
|
753
757
|
PRESS_DOWN: {
|
|
@@ -786,13 +790,14 @@ function machine(ctx = {}) {
|
|
|
786
790
|
},
|
|
787
791
|
{
|
|
788
792
|
target: "idle",
|
|
789
|
-
actions:
|
|
793
|
+
actions: "roundValue"
|
|
790
794
|
}
|
|
791
795
|
]
|
|
792
796
|
}
|
|
793
797
|
},
|
|
794
798
|
"before:spin": {
|
|
795
799
|
tags: ["focus"],
|
|
800
|
+
activities: "trackButtonDisabled",
|
|
796
801
|
entry: (0, import_core.choose)([
|
|
797
802
|
{ guard: "isIncrementHint", actions: "increment" },
|
|
798
803
|
{ guard: "isDecrementHint", actions: "decrement" }
|
|
@@ -840,7 +845,7 @@ function machine(ctx = {}) {
|
|
|
840
845
|
on: {
|
|
841
846
|
POINTER_UP_SCRUBBER: {
|
|
842
847
|
target: "focused",
|
|
843
|
-
actions:
|
|
848
|
+
actions: "clearCursorPoint"
|
|
844
849
|
},
|
|
845
850
|
POINTER_MOVE_SCRUBBER: [
|
|
846
851
|
{
|