@zag-js/number-input 0.0.0-dev-20220415160434 → 0.0.0-dev-20220417135151
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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +393 -373
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +399 -376
- package/dist/index.mjs.map +2 -2
- package/dist/number-input.dom.d.ts +1 -1
- package/dist/number-input.dom.d.ts.map +1 -1
- package/dist/number-input.machine.d.ts +2 -2
- package/dist/number-input.machine.d.ts.map +1 -1
- package/dist/number-input.types.d.ts +50 -33
- package/dist/number-input.types.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
1
21
|
// ../../utilities/dom/dist/index.mjs
|
|
2
22
|
var dataAttr = (guard) => {
|
|
3
23
|
return guard ? "" : void 0;
|
|
@@ -160,26 +180,26 @@ function requestPointerLock(doc, handlers = {}) {
|
|
|
160
180
|
}
|
|
161
181
|
|
|
162
182
|
// ../../utilities/number/dist/index.mjs
|
|
163
|
-
var
|
|
164
|
-
var
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
var
|
|
168
|
-
var
|
|
183
|
+
var __defProp2 = Object.defineProperty;
|
|
184
|
+
var __defProps2 = Object.defineProperties;
|
|
185
|
+
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
186
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
187
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
188
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
169
189
|
var __pow = Math.pow;
|
|
170
|
-
var
|
|
171
|
-
var
|
|
190
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
191
|
+
var __spreadValues2 = (a, b) => {
|
|
172
192
|
for (var prop in b || (b = {}))
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
for (var prop of
|
|
177
|
-
if (
|
|
178
|
-
|
|
193
|
+
if (__hasOwnProp2.call(b, prop))
|
|
194
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
195
|
+
if (__getOwnPropSymbols2)
|
|
196
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
197
|
+
if (__propIsEnum2.call(b, prop))
|
|
198
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
179
199
|
}
|
|
180
200
|
return a;
|
|
181
201
|
};
|
|
182
|
-
var
|
|
202
|
+
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
183
203
|
var nf = new Intl.NumberFormat("en-US", { style: "decimal" });
|
|
184
204
|
function formatter(n) {
|
|
185
205
|
return parseFloat(nf.format(n));
|
|
@@ -223,7 +243,7 @@ function getMaxPrecision(o) {
|
|
|
223
243
|
return Math.max(valuePrecision, (_a = o.precision) != null ? _a : 0);
|
|
224
244
|
}
|
|
225
245
|
function roundToPrecision(v, o) {
|
|
226
|
-
return round(v, getMaxPrecision(
|
|
246
|
+
return round(v, getMaxPrecision(__spreadProps2(__spreadValues2({}, o), { value: v })));
|
|
227
247
|
}
|
|
228
248
|
function isAtMax(v, o) {
|
|
229
249
|
const val = valueOf(v);
|
|
@@ -264,30 +284,30 @@ var dom = {
|
|
|
264
284
|
var _a;
|
|
265
285
|
return (_a = dom.getDoc(ctx).defaultView) != null ? _a : window;
|
|
266
286
|
},
|
|
287
|
+
getRootId: (ctx) => {
|
|
288
|
+
var _a, _b;
|
|
289
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input:${ctx.uid}`;
|
|
290
|
+
},
|
|
267
291
|
getInputId: (ctx) => {
|
|
268
292
|
var _a, _b;
|
|
269
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input
|
|
293
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input:${ctx.uid}:input`;
|
|
270
294
|
},
|
|
271
295
|
getIncButtonId: (ctx) => {
|
|
272
296
|
var _a, _b;
|
|
273
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.incBtn) != null ? _b : `number-input
|
|
297
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.incBtn) != null ? _b : `number-input:${ctx.uid}:inc-btn`;
|
|
274
298
|
},
|
|
275
299
|
getDecButtonId: (ctx) => {
|
|
276
300
|
var _a, _b;
|
|
277
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.decBtn) != null ? _b : `number-input
|
|
301
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.decBtn) != null ? _b : `number-input:${ctx.uid}:dec-btn`;
|
|
278
302
|
},
|
|
279
303
|
getScrubberId: (ctx) => {
|
|
280
304
|
var _a, _b;
|
|
281
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input
|
|
305
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input:${ctx.uid}:scrubber`;
|
|
282
306
|
},
|
|
283
|
-
getCursorId: (ctx) => `number-input
|
|
307
|
+
getCursorId: (ctx) => `number-input:${ctx.uid}:cursor`,
|
|
284
308
|
getLabelId: (ctx) => {
|
|
285
309
|
var _a, _b;
|
|
286
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input
|
|
287
|
-
},
|
|
288
|
-
getRootId: (ctx) => {
|
|
289
|
-
var _a, _b;
|
|
290
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input-${ctx.uid}-root`;
|
|
310
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input:${ctx.uid}:label`;
|
|
291
311
|
},
|
|
292
312
|
getInputEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getInputId(ctx)),
|
|
293
313
|
getIncButtonEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getIncButtonId(ctx)),
|
|
@@ -576,382 +596,385 @@ var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
|
576
596
|
|
|
577
597
|
// src/number-input.machine.ts
|
|
578
598
|
var { not, and } = guards;
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
watch: {
|
|
622
|
-
value: ["invokeOnChange"],
|
|
623
|
-
isOutOfRange: ["invokeOnInvalid"]
|
|
624
|
-
},
|
|
625
|
-
entry: ["syncInputValue"],
|
|
626
|
-
on: {
|
|
627
|
-
SET_VALUE: {
|
|
628
|
-
actions: ["setValue", "setHintToSet"]
|
|
629
|
-
},
|
|
630
|
-
INCREMENT: { actions: ["increment"] },
|
|
631
|
-
DECREMENT: { actions: ["decrement"] }
|
|
632
|
-
},
|
|
633
|
-
states: {
|
|
634
|
-
unknown: {
|
|
635
|
-
on: {
|
|
636
|
-
SETUP: {
|
|
637
|
-
target: "idle",
|
|
638
|
-
actions: "setupDocument"
|
|
639
|
-
}
|
|
599
|
+
function machine(ctx = {}) {
|
|
600
|
+
return createMachine({
|
|
601
|
+
id: "number-input",
|
|
602
|
+
initial: "unknown",
|
|
603
|
+
context: __spreadProps(__spreadValues({
|
|
604
|
+
uid: "",
|
|
605
|
+
dir: "ltr",
|
|
606
|
+
focusInputOnChange: true,
|
|
607
|
+
clampValueOnBlur: true,
|
|
608
|
+
allowOverflow: false,
|
|
609
|
+
inputMode: "decimal",
|
|
610
|
+
pattern: "[0-9]*(.[0-9]+)?",
|
|
611
|
+
hint: null,
|
|
612
|
+
value: "",
|
|
613
|
+
step: 1,
|
|
614
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
615
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
616
|
+
precision: 0,
|
|
617
|
+
inputSelection: null,
|
|
618
|
+
scrubberCursorPoint: null,
|
|
619
|
+
invalid: false
|
|
620
|
+
}, ctx), {
|
|
621
|
+
messages: __spreadValues({
|
|
622
|
+
incrementLabel: "increment value",
|
|
623
|
+
decrementLabel: "decrease value"
|
|
624
|
+
}, ctx.messages)
|
|
625
|
+
}),
|
|
626
|
+
computed: {
|
|
627
|
+
isRtl: (ctx2) => ctx2.dir === "rtl",
|
|
628
|
+
valueAsNumber: (ctx2) => valueOf(ctx2.value),
|
|
629
|
+
isAtMin: (ctx2) => isAtMin(ctx2.value, ctx2),
|
|
630
|
+
isAtMax: (ctx2) => isAtMax(ctx2.value, ctx2),
|
|
631
|
+
isOutOfRange: (ctx2) => !isWithinRange(ctx2.value, ctx2),
|
|
632
|
+
canIncrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMax,
|
|
633
|
+
canDecrement: (ctx2) => ctx2.allowOverflow || !ctx2.isAtMin,
|
|
634
|
+
valueText: (ctx2) => {
|
|
635
|
+
var _a, _b;
|
|
636
|
+
return (_b = (_a = ctx2.messages).valueText) == null ? void 0 : _b.call(_a, ctx2.value);
|
|
637
|
+
},
|
|
638
|
+
formattedValue: (ctx2) => {
|
|
639
|
+
var _a, _b;
|
|
640
|
+
return (_b = (_a = ctx2.format) == null ? void 0 : _a.call(ctx2, ctx2.value).toString()) != null ? _b : ctx2.value;
|
|
640
641
|
}
|
|
641
642
|
},
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
target: "before:spin",
|
|
646
|
-
actions: ["focusInput", "setHint"]
|
|
647
|
-
},
|
|
648
|
-
PRESS_DOWN_SCRUBBER: {
|
|
649
|
-
target: "scrubbing",
|
|
650
|
-
actions: ["focusInput", "setHint", "setCursorPoint"]
|
|
651
|
-
},
|
|
652
|
-
FOCUS: "focused"
|
|
653
|
-
}
|
|
643
|
+
watch: {
|
|
644
|
+
value: ["invokeOnChange"],
|
|
645
|
+
isOutOfRange: ["invokeOnInvalid"]
|
|
654
646
|
},
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
ARROW_UP: {
|
|
668
|
-
actions: "increment"
|
|
669
|
-
},
|
|
670
|
-
ARROW_DOWN: {
|
|
671
|
-
actions: "decrement"
|
|
672
|
-
},
|
|
673
|
-
HOME: {
|
|
674
|
-
actions: "setToMin"
|
|
675
|
-
},
|
|
676
|
-
END: {
|
|
677
|
-
actions: "setToMax"
|
|
678
|
-
},
|
|
679
|
-
CHANGE: {
|
|
680
|
-
actions: ["setValue", "setSelectionRange", "setHint"]
|
|
681
|
-
},
|
|
682
|
-
BLUR: [
|
|
683
|
-
{
|
|
684
|
-
guard: "isInvalidExponential",
|
|
647
|
+
entry: ["syncInputValue"],
|
|
648
|
+
on: {
|
|
649
|
+
SET_VALUE: {
|
|
650
|
+
actions: ["setValue", "setHintToSet"]
|
|
651
|
+
},
|
|
652
|
+
INCREMENT: { actions: ["increment"] },
|
|
653
|
+
DECREMENT: { actions: ["decrement"] }
|
|
654
|
+
},
|
|
655
|
+
states: {
|
|
656
|
+
unknown: {
|
|
657
|
+
on: {
|
|
658
|
+
SETUP: {
|
|
685
659
|
target: "idle",
|
|
686
|
-
actions:
|
|
660
|
+
actions: "setupDocument"
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
idle: {
|
|
665
|
+
on: {
|
|
666
|
+
PRESS_DOWN: {
|
|
667
|
+
target: "before:spin",
|
|
668
|
+
actions: ["focusInput", "setHint"]
|
|
687
669
|
},
|
|
688
|
-
{
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
actions: ["clampValue", "clearHint"]
|
|
670
|
+
PRESS_DOWN_SCRUBBER: {
|
|
671
|
+
target: "scrubbing",
|
|
672
|
+
actions: ["focusInput", "setHint", "setCursorPoint"]
|
|
692
673
|
},
|
|
693
|
-
|
|
694
|
-
actions: ["roundValue"]
|
|
695
|
-
}
|
|
696
|
-
]
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
"before:spin": {
|
|
700
|
-
tags: ["focus"],
|
|
701
|
-
entry: choose([
|
|
702
|
-
{ guard: "isIncrementHint", actions: "increment" },
|
|
703
|
-
{ guard: "isDecrementHint", actions: "decrement" }
|
|
704
|
-
]),
|
|
705
|
-
after: {
|
|
706
|
-
CHANGE_DELAY: {
|
|
707
|
-
target: "spinning",
|
|
708
|
-
guard: "isInRange"
|
|
674
|
+
FOCUS: "focused"
|
|
709
675
|
}
|
|
710
676
|
},
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
677
|
+
focused: {
|
|
678
|
+
tags: ["focus"],
|
|
679
|
+
activities: "attachWheelListener",
|
|
680
|
+
on: {
|
|
681
|
+
PRESS_DOWN: {
|
|
682
|
+
target: "before:spin",
|
|
683
|
+
actions: ["focusInput", "setHint"]
|
|
684
|
+
},
|
|
685
|
+
PRESS_DOWN_SCRUBBER: {
|
|
686
|
+
target: "scrubbing",
|
|
687
|
+
actions: ["focusInput", "setHint", "setCursorPoint"]
|
|
688
|
+
},
|
|
689
|
+
ARROW_UP: {
|
|
690
|
+
actions: "increment"
|
|
691
|
+
},
|
|
692
|
+
ARROW_DOWN: {
|
|
693
|
+
actions: "decrement"
|
|
694
|
+
},
|
|
695
|
+
HOME: {
|
|
696
|
+
actions: "setToMin"
|
|
697
|
+
},
|
|
698
|
+
END: {
|
|
699
|
+
actions: "setToMax"
|
|
700
|
+
},
|
|
701
|
+
CHANGE: {
|
|
702
|
+
actions: ["setValue", "setSelectionRange", "setHint"]
|
|
703
|
+
},
|
|
704
|
+
BLUR: [
|
|
705
|
+
{
|
|
706
|
+
guard: "isInvalidExponential",
|
|
707
|
+
target: "idle",
|
|
708
|
+
actions: ["clearValue", "clearHint"]
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
guard: and("clampOnBlur", not("isInRange")),
|
|
712
|
+
target: "idle",
|
|
713
|
+
actions: ["clampValue", "clearHint"]
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
actions: ["roundValue"]
|
|
717
|
+
}
|
|
718
|
+
]
|
|
715
719
|
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
720
|
+
},
|
|
721
|
+
"before:spin": {
|
|
722
|
+
tags: ["focus"],
|
|
723
|
+
entry: choose([
|
|
724
|
+
{ guard: "isIncrementHint", actions: "increment" },
|
|
725
|
+
{ guard: "isDecrementHint", actions: "decrement" }
|
|
726
|
+
]),
|
|
727
|
+
after: {
|
|
728
|
+
CHANGE_DELAY: {
|
|
729
|
+
target: "spinning",
|
|
730
|
+
guard: "isInRange"
|
|
731
|
+
}
|
|
726
732
|
},
|
|
727
|
-
{
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
],
|
|
733
|
-
on: {
|
|
734
|
-
PRESS_UP: {
|
|
735
|
-
target: "focused",
|
|
736
|
-
actions: ["clearHint", "restoreSelection"]
|
|
733
|
+
on: {
|
|
734
|
+
PRESS_UP: {
|
|
735
|
+
target: "focused",
|
|
736
|
+
actions: ["clearHint", "restoreSelection"]
|
|
737
|
+
}
|
|
737
738
|
}
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
exit: ["removeCustomCursor", "restoreTextSelection"],
|
|
744
|
-
activities: ["activatePointerLock", "trackMousemove"],
|
|
745
|
-
on: {
|
|
746
|
-
POINTER_UP_SCRUBBER: {
|
|
747
|
-
target: "focused",
|
|
748
|
-
actions: ["clearCursorPoint"]
|
|
749
|
-
},
|
|
750
|
-
POINTER_MOVE_SCRUBBER: [
|
|
739
|
+
},
|
|
740
|
+
spinning: {
|
|
741
|
+
tags: ["focus"],
|
|
742
|
+
activities: "trackButtonDisabled",
|
|
743
|
+
every: [
|
|
751
744
|
{
|
|
752
|
-
|
|
753
|
-
|
|
745
|
+
delay: "CHANGE_INTERVAL",
|
|
746
|
+
guard: and(not("isAtMin"), "isIncrementHint"),
|
|
747
|
+
actions: "increment"
|
|
754
748
|
},
|
|
755
749
|
{
|
|
756
|
-
|
|
757
|
-
|
|
750
|
+
delay: "CHANGE_INTERVAL",
|
|
751
|
+
guard: and(not("isAtMax"), "isDecrementHint"),
|
|
752
|
+
actions: "decrement"
|
|
758
753
|
}
|
|
759
|
-
]
|
|
754
|
+
],
|
|
755
|
+
on: {
|
|
756
|
+
PRESS_UP: {
|
|
757
|
+
target: "focused",
|
|
758
|
+
actions: ["clearHint", "restoreSelection"]
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
scrubbing: {
|
|
763
|
+
tags: ["focus"],
|
|
764
|
+
entry: ["addCustomCursor", "disableTextSelection"],
|
|
765
|
+
exit: ["removeCustomCursor", "restoreTextSelection"],
|
|
766
|
+
activities: ["activatePointerLock", "trackMousemove"],
|
|
767
|
+
on: {
|
|
768
|
+
POINTER_UP_SCRUBBER: {
|
|
769
|
+
target: "focused",
|
|
770
|
+
actions: ["clearCursorPoint"]
|
|
771
|
+
},
|
|
772
|
+
POINTER_MOVE_SCRUBBER: [
|
|
773
|
+
{
|
|
774
|
+
guard: "isIncrementHint",
|
|
775
|
+
actions: ["increment", "setCursorPoint", "updateCursor"]
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
guard: "isDecrementHint",
|
|
779
|
+
actions: ["decrement", "setCursorPoint", "updateCursor"]
|
|
780
|
+
}
|
|
781
|
+
]
|
|
782
|
+
}
|
|
760
783
|
}
|
|
761
784
|
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
isInvalidExponential: (ctx) => ctx.value.toString().startsWith("e")
|
|
782
|
-
},
|
|
783
|
-
activities: {
|
|
784
|
-
trackButtonDisabled(ctx, _evt, { send }) {
|
|
785
|
-
let btnEl = null;
|
|
786
|
-
if (ctx.hint === "increment") {
|
|
787
|
-
btnEl = dom.getIncButtonEl(ctx);
|
|
788
|
-
}
|
|
789
|
-
if (ctx.hint === "decrement") {
|
|
790
|
-
btnEl = dom.getDecButtonEl(ctx);
|
|
791
|
-
}
|
|
792
|
-
return observeAttributes(btnEl, "disabled", function onDisable() {
|
|
793
|
-
send("PRESS_UP");
|
|
794
|
-
});
|
|
785
|
+
}, {
|
|
786
|
+
delays: {
|
|
787
|
+
CHANGE_INTERVAL: 50,
|
|
788
|
+
CHANGE_DELAY: 300
|
|
789
|
+
},
|
|
790
|
+
guards: {
|
|
791
|
+
clampOnBlur: (ctx2) => !!ctx2.clampValueOnBlur,
|
|
792
|
+
isAtMin: (ctx2) => ctx2.isAtMin,
|
|
793
|
+
isAtMax: (ctx2) => ctx2.isAtMax,
|
|
794
|
+
isInRange: (ctx2) => !ctx2.isOutOfRange,
|
|
795
|
+
isDecrementHint: (ctx2, evt) => {
|
|
796
|
+
var _a;
|
|
797
|
+
return ((_a = evt.hint) != null ? _a : ctx2.hint) === "decrement";
|
|
798
|
+
},
|
|
799
|
+
isIncrementHint: (ctx2, evt) => {
|
|
800
|
+
var _a;
|
|
801
|
+
return ((_a = evt.hint) != null ? _a : ctx2.hint) === "increment";
|
|
802
|
+
},
|
|
803
|
+
isInvalidExponential: (ctx2) => ctx2.value.toString().startsWith("e")
|
|
795
804
|
},
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
805
|
+
activities: {
|
|
806
|
+
trackButtonDisabled(ctx2, _evt, { send }) {
|
|
807
|
+
let btnEl = null;
|
|
808
|
+
if (ctx2.hint === "increment") {
|
|
809
|
+
btnEl = dom.getIncButtonEl(ctx2);
|
|
810
|
+
}
|
|
811
|
+
if (ctx2.hint === "decrement") {
|
|
812
|
+
btnEl = dom.getDecButtonEl(ctx2);
|
|
813
|
+
}
|
|
814
|
+
return observeAttributes(btnEl, "disabled", function onDisable() {
|
|
815
|
+
send("PRESS_UP");
|
|
816
|
+
});
|
|
817
|
+
},
|
|
818
|
+
attachWheelListener(ctx2) {
|
|
819
|
+
const cleanups = [];
|
|
820
|
+
cleanups.push(nextTick(() => {
|
|
821
|
+
const input = dom.getInputEl(ctx2);
|
|
822
|
+
if (!input)
|
|
823
|
+
return;
|
|
824
|
+
function onWheel(event) {
|
|
825
|
+
const isInputFocused = dom.getDoc(ctx2).activeElement === input;
|
|
826
|
+
if (!ctx2.allowMouseWheel || !isInputFocused)
|
|
827
|
+
return;
|
|
828
|
+
event.preventDefault();
|
|
829
|
+
const dir = Math.sign(event.deltaY) * -1;
|
|
830
|
+
if (dir === 1)
|
|
831
|
+
ctx2.value = utils.increment(ctx2);
|
|
832
|
+
else if (dir === -1)
|
|
833
|
+
ctx2.value = utils.decrement(ctx2);
|
|
834
|
+
}
|
|
835
|
+
cleanups.push(addDomEvent(input, "wheel", onWheel, { passive: false }));
|
|
836
|
+
}));
|
|
837
|
+
return () => cleanups.forEach((c) => c());
|
|
838
|
+
},
|
|
839
|
+
activatePointerLock(ctx2) {
|
|
840
|
+
if (isSafari() || !supportsPointerEvent())
|
|
801
841
|
return;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
842
|
+
return requestPointerLock(dom.getDoc(ctx2));
|
|
843
|
+
},
|
|
844
|
+
trackMousemove(ctx2, _evt, { send }) {
|
|
845
|
+
const doc = dom.getDoc(ctx2);
|
|
846
|
+
function onMousemove(event) {
|
|
847
|
+
if (!ctx2.scrubberCursorPoint)
|
|
805
848
|
return;
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
else if (dir === -1)
|
|
811
|
-
ctx.value = utils.decrement(ctx);
|
|
849
|
+
const value = dom.getMousementValue(ctx2, event);
|
|
850
|
+
if (!value.hint)
|
|
851
|
+
return;
|
|
852
|
+
send({ type: "POINTER_MOVE_SCRUBBER", hint: value.hint, point: value.point });
|
|
812
853
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
if (isSafari() || !supportsPointerEvent())
|
|
819
|
-
return;
|
|
820
|
-
return requestPointerLock(dom.getDoc(ctx));
|
|
854
|
+
function onMouseup() {
|
|
855
|
+
send("POINTER_UP_SCRUBBER");
|
|
856
|
+
}
|
|
857
|
+
return pipe2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
|
|
858
|
+
}
|
|
821
859
|
},
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
860
|
+
actions: {
|
|
861
|
+
setupDocument: (ctx2, evt) => {
|
|
862
|
+
if (evt.doc)
|
|
863
|
+
ctx2.doc = ref(evt.doc);
|
|
864
|
+
ctx2.uid = evt.id;
|
|
865
|
+
},
|
|
866
|
+
focusInput(ctx2) {
|
|
867
|
+
if (!ctx2.focusInputOnChange)
|
|
826
868
|
return;
|
|
827
|
-
const
|
|
828
|
-
|
|
869
|
+
const input = dom.getInputEl(ctx2);
|
|
870
|
+
nextTick(() => input == null ? void 0 : input.focus());
|
|
871
|
+
},
|
|
872
|
+
increment(ctx2, evt) {
|
|
873
|
+
ctx2.value = utils.increment(ctx2, evt.step);
|
|
874
|
+
},
|
|
875
|
+
decrement(ctx2, evt) {
|
|
876
|
+
ctx2.value = utils.decrement(ctx2, evt.step);
|
|
877
|
+
},
|
|
878
|
+
clampValue(ctx2) {
|
|
879
|
+
ctx2.value = utils.clamp(ctx2);
|
|
880
|
+
},
|
|
881
|
+
roundValue(ctx2) {
|
|
882
|
+
ctx2.value = utils.round(ctx2);
|
|
883
|
+
},
|
|
884
|
+
setValue(ctx2, evt) {
|
|
885
|
+
var _a, _b;
|
|
886
|
+
const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
|
|
887
|
+
ctx2.value = utils.sanitize(ctx2, utils.parse(ctx2, value));
|
|
888
|
+
},
|
|
889
|
+
clearValue(ctx2) {
|
|
890
|
+
ctx2.value = "";
|
|
891
|
+
},
|
|
892
|
+
setToMax(ctx2) {
|
|
893
|
+
ctx2.value = ctx2.max.toString();
|
|
894
|
+
},
|
|
895
|
+
setToMin(ctx2) {
|
|
896
|
+
ctx2.value = ctx2.min.toString();
|
|
897
|
+
},
|
|
898
|
+
setHint(ctx2, evt) {
|
|
899
|
+
ctx2.hint = evt.hint;
|
|
900
|
+
},
|
|
901
|
+
clearHint(ctx2) {
|
|
902
|
+
ctx2.hint = null;
|
|
903
|
+
},
|
|
904
|
+
setHintToSet(ctx2) {
|
|
905
|
+
ctx2.hint = "set";
|
|
906
|
+
},
|
|
907
|
+
setSelectionRange(ctx2, evt) {
|
|
908
|
+
ctx2.inputSelection = {
|
|
909
|
+
start: evt.target.selectionStart,
|
|
910
|
+
end: evt.target.selectionEnd
|
|
911
|
+
};
|
|
912
|
+
},
|
|
913
|
+
restoreSelection(ctx2) {
|
|
914
|
+
var _a, _b, _c;
|
|
915
|
+
const input = dom.getInputEl(ctx2);
|
|
916
|
+
if (!input || !ctx2.inputSelection)
|
|
829
917
|
return;
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
918
|
+
input.selectionStart = (_b = ctx2.inputSelection.start) != null ? _b : (_a = input.value) == null ? void 0 : _a.length;
|
|
919
|
+
input.selectionEnd = (_c = ctx2.inputSelection.end) != null ? _c : input.selectionStart;
|
|
920
|
+
},
|
|
921
|
+
invokeOnChange(ctx2) {
|
|
922
|
+
var _a;
|
|
923
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value, valueAsNumber: ctx2.valueAsNumber });
|
|
924
|
+
},
|
|
925
|
+
invokeOnInvalid(ctx2) {
|
|
926
|
+
var _a;
|
|
927
|
+
if (!ctx2.isOutOfRange)
|
|
928
|
+
return;
|
|
929
|
+
const reason = ctx2.valueAsNumber > ctx2.max ? "rangeOverflow" : "rangeUnderflow";
|
|
930
|
+
(_a = ctx2.onInvalid) == null ? void 0 : _a.call(ctx2, { reason, value: ctx2.formattedValue, valueAsNumber: ctx2.valueAsNumber });
|
|
931
|
+
},
|
|
932
|
+
syncInputValue(ctx2) {
|
|
933
|
+
const input = dom.getInputEl(ctx2);
|
|
934
|
+
if (!input || input.value == ctx2.value)
|
|
935
|
+
return;
|
|
936
|
+
const value = utils.parse(ctx2, input.value);
|
|
937
|
+
ctx2.value = utils.sanitize(ctx2, value);
|
|
938
|
+
},
|
|
939
|
+
setCursorPoint(ctx2, evt) {
|
|
940
|
+
ctx2.scrubberCursorPoint = evt.point;
|
|
941
|
+
},
|
|
942
|
+
clearCursorPoint(ctx2) {
|
|
943
|
+
ctx2.scrubberCursorPoint = null;
|
|
944
|
+
},
|
|
945
|
+
updateCursor(ctx2) {
|
|
946
|
+
const cursor = dom.getCursorEl(ctx2);
|
|
947
|
+
if (!cursor || !ctx2.scrubberCursorPoint)
|
|
948
|
+
return;
|
|
949
|
+
cursor.style.transform = `translate3d(${ctx2.scrubberCursorPoint.x}px, ${ctx2.scrubberCursorPoint.y}px, 0px)`;
|
|
950
|
+
},
|
|
951
|
+
addCustomCursor(ctx2) {
|
|
952
|
+
if (isSafari() || !supportsPointerEvent())
|
|
953
|
+
return;
|
|
954
|
+
dom.createVirtualCursor(ctx2);
|
|
955
|
+
},
|
|
956
|
+
removeCustomCursor(ctx2) {
|
|
957
|
+
if (isSafari() || !supportsPointerEvent())
|
|
958
|
+
return;
|
|
959
|
+
const doc = dom.getDoc(ctx2);
|
|
960
|
+
const el = doc.getElementById(dom.getCursorId(ctx2));
|
|
961
|
+
el == null ? void 0 : el.remove();
|
|
962
|
+
},
|
|
963
|
+
disableTextSelection(ctx2) {
|
|
964
|
+
const doc = dom.getDoc(ctx2);
|
|
965
|
+
doc.body.style.pointerEvents = "none";
|
|
966
|
+
doc.documentElement.style.userSelect = "none";
|
|
967
|
+
doc.documentElement.style.cursor = "ew-resize";
|
|
968
|
+
},
|
|
969
|
+
restoreTextSelection(ctx2) {
|
|
970
|
+
const doc = dom.getDoc(ctx2);
|
|
971
|
+
doc.body.style.pointerEvents = "";
|
|
972
|
+
doc.documentElement.style.userSelect = "";
|
|
973
|
+
doc.documentElement.style.cursor = "";
|
|
834
974
|
}
|
|
835
|
-
return pipe2(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
|
|
836
975
|
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
setupDocument: (ctx, evt) => {
|
|
840
|
-
if (evt.doc)
|
|
841
|
-
ctx.doc = ref(evt.doc);
|
|
842
|
-
ctx.uid = evt.id;
|
|
843
|
-
},
|
|
844
|
-
focusInput(ctx) {
|
|
845
|
-
if (!ctx.focusInputOnChange)
|
|
846
|
-
return;
|
|
847
|
-
const input = dom.getInputEl(ctx);
|
|
848
|
-
nextTick(() => input == null ? void 0 : input.focus());
|
|
849
|
-
},
|
|
850
|
-
increment(ctx, evt) {
|
|
851
|
-
ctx.value = utils.increment(ctx, evt.step);
|
|
852
|
-
},
|
|
853
|
-
decrement(ctx, evt) {
|
|
854
|
-
ctx.value = utils.decrement(ctx, evt.step);
|
|
855
|
-
},
|
|
856
|
-
clampValue(ctx) {
|
|
857
|
-
ctx.value = utils.clamp(ctx);
|
|
858
|
-
},
|
|
859
|
-
roundValue(ctx) {
|
|
860
|
-
ctx.value = utils.round(ctx);
|
|
861
|
-
},
|
|
862
|
-
setValue(ctx, evt) {
|
|
863
|
-
var _a, _b;
|
|
864
|
-
const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
|
|
865
|
-
ctx.value = utils.sanitize(ctx, utils.parse(ctx, value));
|
|
866
|
-
},
|
|
867
|
-
clearValue(ctx) {
|
|
868
|
-
ctx.value = "";
|
|
869
|
-
},
|
|
870
|
-
setToMax(ctx) {
|
|
871
|
-
ctx.value = ctx.max.toString();
|
|
872
|
-
},
|
|
873
|
-
setToMin(ctx) {
|
|
874
|
-
ctx.value = ctx.min.toString();
|
|
875
|
-
},
|
|
876
|
-
setHint(ctx, evt) {
|
|
877
|
-
ctx.hint = evt.hint;
|
|
878
|
-
},
|
|
879
|
-
clearHint(ctx) {
|
|
880
|
-
ctx.hint = null;
|
|
881
|
-
},
|
|
882
|
-
setHintToSet(ctx) {
|
|
883
|
-
ctx.hint = "set";
|
|
884
|
-
},
|
|
885
|
-
setSelectionRange(ctx, evt) {
|
|
886
|
-
ctx.inputSelection = {
|
|
887
|
-
start: evt.target.selectionStart,
|
|
888
|
-
end: evt.target.selectionEnd
|
|
889
|
-
};
|
|
890
|
-
},
|
|
891
|
-
restoreSelection(ctx) {
|
|
892
|
-
var _a, _b, _c;
|
|
893
|
-
const input = dom.getInputEl(ctx);
|
|
894
|
-
if (!input || !ctx.inputSelection)
|
|
895
|
-
return;
|
|
896
|
-
input.selectionStart = (_b = ctx.inputSelection.start) != null ? _b : (_a = input.value) == null ? void 0 : _a.length;
|
|
897
|
-
input.selectionEnd = (_c = ctx.inputSelection.end) != null ? _c : input.selectionStart;
|
|
898
|
-
},
|
|
899
|
-
invokeOnChange(ctx) {
|
|
900
|
-
var _a;
|
|
901
|
-
(_a = ctx.onChange) == null ? void 0 : _a.call(ctx, { value: ctx.value, valueAsNumber: ctx.valueAsNumber });
|
|
902
|
-
},
|
|
903
|
-
invokeOnInvalid(ctx) {
|
|
904
|
-
var _a;
|
|
905
|
-
if (!ctx.isOutOfRange)
|
|
906
|
-
return;
|
|
907
|
-
const reason = ctx.valueAsNumber > ctx.max ? "rangeOverflow" : "rangeUnderflow";
|
|
908
|
-
(_a = ctx.onInvalid) == null ? void 0 : _a.call(ctx, { reason, value: ctx.formattedValue, valueAsNumber: ctx.valueAsNumber });
|
|
909
|
-
},
|
|
910
|
-
syncInputValue(ctx) {
|
|
911
|
-
const input = dom.getInputEl(ctx);
|
|
912
|
-
if (!input || input.value == ctx.value)
|
|
913
|
-
return;
|
|
914
|
-
const value = utils.parse(ctx, input.value);
|
|
915
|
-
ctx.value = utils.sanitize(ctx, value);
|
|
916
|
-
},
|
|
917
|
-
setCursorPoint(ctx, evt) {
|
|
918
|
-
ctx.scrubberCursorPoint = evt.point;
|
|
919
|
-
},
|
|
920
|
-
clearCursorPoint(ctx) {
|
|
921
|
-
ctx.scrubberCursorPoint = null;
|
|
922
|
-
},
|
|
923
|
-
updateCursor(ctx) {
|
|
924
|
-
const cursor = dom.getCursorEl(ctx);
|
|
925
|
-
if (!cursor || !ctx.scrubberCursorPoint)
|
|
926
|
-
return;
|
|
927
|
-
cursor.style.transform = `translate3d(${ctx.scrubberCursorPoint.x}px, ${ctx.scrubberCursorPoint.y}px, 0px)`;
|
|
928
|
-
},
|
|
929
|
-
addCustomCursor(ctx) {
|
|
930
|
-
if (isSafari() || !supportsPointerEvent())
|
|
931
|
-
return;
|
|
932
|
-
dom.createVirtualCursor(ctx);
|
|
933
|
-
},
|
|
934
|
-
removeCustomCursor(ctx) {
|
|
935
|
-
if (isSafari() || !supportsPointerEvent())
|
|
936
|
-
return;
|
|
937
|
-
const doc = dom.getDoc(ctx);
|
|
938
|
-
const el = doc.getElementById(dom.getCursorId(ctx));
|
|
939
|
-
el == null ? void 0 : el.remove();
|
|
940
|
-
},
|
|
941
|
-
disableTextSelection(ctx) {
|
|
942
|
-
const doc = dom.getDoc(ctx);
|
|
943
|
-
doc.body.style.pointerEvents = "none";
|
|
944
|
-
doc.documentElement.style.userSelect = "none";
|
|
945
|
-
doc.documentElement.style.cursor = "ew-resize";
|
|
946
|
-
},
|
|
947
|
-
restoreTextSelection(ctx) {
|
|
948
|
-
const doc = dom.getDoc(ctx);
|
|
949
|
-
doc.body.style.pointerEvents = "";
|
|
950
|
-
doc.documentElement.style.userSelect = "";
|
|
951
|
-
doc.documentElement.style.cursor = "";
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
});
|
|
976
|
+
});
|
|
977
|
+
}
|
|
955
978
|
export {
|
|
956
979
|
connect,
|
|
957
980
|
machine
|