@zag-js/number-input 0.0.0-dev-20220508184419 → 0.0.0-dev-20220510084727
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 +14 -23
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +14 -23
- package/dist/index.mjs.map +2 -2
- package/dist/number-input.connect.d.ts.map +1 -1
- package/dist/number-input.machine.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -58,6 +58,12 @@ function nextTick(fn) {
|
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
function raf(fn) {
|
|
62
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
63
|
+
return function cleanup() {
|
|
64
|
+
globalThis.cancelAnimationFrame(id);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
61
67
|
var noop = () => {
|
|
62
68
|
};
|
|
63
69
|
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
@@ -275,7 +281,7 @@ var __spreadValues2 = (a, b) => {
|
|
|
275
281
|
return a;
|
|
276
282
|
};
|
|
277
283
|
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
278
|
-
var nf = new Intl.NumberFormat("en-US", { style: "decimal" });
|
|
284
|
+
var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
|
|
279
285
|
function formatter(n) {
|
|
280
286
|
return parseFloat(nf.format(n));
|
|
281
287
|
}
|
|
@@ -524,10 +530,8 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
524
530
|
send({ type: "SET_VALUE", value: state.context.min });
|
|
525
531
|
},
|
|
526
532
|
focus() {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
(_a = dom.getInputEl(state.context)) == null ? void 0 : _a.focus();
|
|
530
|
-
});
|
|
533
|
+
var _a;
|
|
534
|
+
(_a = dom.getInputEl(state.context)) == null ? void 0 : _a.focus();
|
|
531
535
|
},
|
|
532
536
|
rootProps: normalize.element({
|
|
533
537
|
id: dom.getRootId(state.context),
|
|
@@ -778,7 +782,7 @@ function machine(ctx = {}) {
|
|
|
778
782
|
actions: "setToMax"
|
|
779
783
|
},
|
|
780
784
|
CHANGE: {
|
|
781
|
-
actions: ["setValue", "
|
|
785
|
+
actions: ["setValue", "setHint"]
|
|
782
786
|
},
|
|
783
787
|
BLUR: [
|
|
784
788
|
{
|
|
@@ -792,6 +796,7 @@ function machine(ctx = {}) {
|
|
|
792
796
|
actions: ["clampValue", "clearHint"]
|
|
793
797
|
},
|
|
794
798
|
{
|
|
799
|
+
target: "idle",
|
|
795
800
|
actions: ["roundValue"]
|
|
796
801
|
}
|
|
797
802
|
]
|
|
@@ -812,7 +817,7 @@ function machine(ctx = {}) {
|
|
|
812
817
|
on: {
|
|
813
818
|
PRESS_UP: {
|
|
814
819
|
target: "focused",
|
|
815
|
-
actions:
|
|
820
|
+
actions: "clearHint"
|
|
816
821
|
}
|
|
817
822
|
}
|
|
818
823
|
},
|
|
@@ -834,7 +839,7 @@ function machine(ctx = {}) {
|
|
|
834
839
|
on: {
|
|
835
840
|
PRESS_UP: {
|
|
836
841
|
target: "focused",
|
|
837
|
-
actions:
|
|
842
|
+
actions: "clearHint"
|
|
838
843
|
}
|
|
839
844
|
}
|
|
840
845
|
},
|
|
@@ -946,7 +951,7 @@ function machine(ctx = {}) {
|
|
|
946
951
|
if (!ctx2.focusInputOnChange)
|
|
947
952
|
return;
|
|
948
953
|
const input = dom.getInputEl(ctx2);
|
|
949
|
-
|
|
954
|
+
raf(() => input == null ? void 0 : input.focus());
|
|
950
955
|
},
|
|
951
956
|
increment(ctx2, evt) {
|
|
952
957
|
ctx2.value = utils.increment(ctx2, evt.step);
|
|
@@ -983,20 +988,6 @@ function machine(ctx = {}) {
|
|
|
983
988
|
setHintToSet(ctx2) {
|
|
984
989
|
ctx2.hint = "set";
|
|
985
990
|
},
|
|
986
|
-
setSelectionRange(ctx2, evt) {
|
|
987
|
-
ctx2.inputSelection = {
|
|
988
|
-
start: evt.target.selectionStart,
|
|
989
|
-
end: evt.target.selectionEnd
|
|
990
|
-
};
|
|
991
|
-
},
|
|
992
|
-
restoreSelection(ctx2) {
|
|
993
|
-
var _a, _b, _c;
|
|
994
|
-
const input = dom.getInputEl(ctx2);
|
|
995
|
-
if (!input || !ctx2.inputSelection)
|
|
996
|
-
return;
|
|
997
|
-
input.selectionStart = (_b = ctx2.inputSelection.start) != null ? _b : (_a = input.value) == null ? void 0 : _a.length;
|
|
998
|
-
input.selectionEnd = (_c = ctx2.inputSelection.end) != null ? _c : input.selectionStart;
|
|
999
|
-
},
|
|
1000
991
|
invokeOnChange(ctx2) {
|
|
1001
992
|
var _a;
|
|
1002
993
|
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value, valueAsNumber: ctx2.valueAsNumber });
|