@zag-js/slider 0.1.9 → 0.1.10
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 +73 -49
- package/dist/index.mjs +74 -50
- package/dist/slider.dom.d.ts +24 -10
- package/dist/slider.machine.d.ts +1 -1
- package/dist/slider.types.d.ts +3 -3
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -44,7 +44,23 @@ __export(src_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(src_exports);
|
|
45
45
|
|
|
46
46
|
// ../../utilities/dom/dist/index.mjs
|
|
47
|
+
var __defProp2 = Object.defineProperty;
|
|
48
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
49
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
50
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
47
51
|
var __pow = Math.pow;
|
|
52
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
53
|
+
var __spreadValues2 = (a, b) => {
|
|
54
|
+
for (var prop in b || (b = {}))
|
|
55
|
+
if (__hasOwnProp2.call(b, prop))
|
|
56
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
57
|
+
if (__getOwnPropSymbols2)
|
|
58
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
59
|
+
if (__propIsEnum2.call(b, prop))
|
|
60
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
61
|
+
}
|
|
62
|
+
return a;
|
|
63
|
+
};
|
|
48
64
|
var dataAttr = (guard) => {
|
|
49
65
|
return guard ? "" : void 0;
|
|
50
66
|
};
|
|
@@ -71,10 +87,40 @@ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
|
71
87
|
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
72
88
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
73
89
|
var isIos = () => isApple() && !isMac();
|
|
90
|
+
function isDocument(el) {
|
|
91
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
92
|
+
}
|
|
93
|
+
function isWindow(value) {
|
|
94
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
95
|
+
}
|
|
96
|
+
function getDocument(el) {
|
|
97
|
+
var _a;
|
|
98
|
+
if (isWindow(el))
|
|
99
|
+
return el.document;
|
|
100
|
+
if (isDocument(el))
|
|
101
|
+
return el;
|
|
102
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
103
|
+
}
|
|
74
104
|
function getWindow(el) {
|
|
75
105
|
var _a;
|
|
76
106
|
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
77
107
|
}
|
|
108
|
+
function defineDomHelpers(helpers) {
|
|
109
|
+
const dom2 = {
|
|
110
|
+
getRootNode: (ctx) => {
|
|
111
|
+
var _a, _b;
|
|
112
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
113
|
+
},
|
|
114
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
115
|
+
getWin: (ctx) => {
|
|
116
|
+
var _a;
|
|
117
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
118
|
+
},
|
|
119
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
120
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
121
|
+
};
|
|
122
|
+
return __spreadValues2(__spreadValues2({}, dom2), helpers);
|
|
123
|
+
}
|
|
78
124
|
function getNativeEvent(e) {
|
|
79
125
|
var _a;
|
|
80
126
|
return (_a = e.nativeEvent) != null ? _a : e;
|
|
@@ -173,6 +219,8 @@ function getDescriptor(el, options) {
|
|
|
173
219
|
}
|
|
174
220
|
function dispatchInputValueEvent(el, value) {
|
|
175
221
|
var _a;
|
|
222
|
+
if (!el)
|
|
223
|
+
return;
|
|
176
224
|
const win = getWindow(el);
|
|
177
225
|
if (!(el instanceof win.HTMLInputElement))
|
|
178
226
|
return;
|
|
@@ -554,49 +602,41 @@ var utils = {
|
|
|
554
602
|
};
|
|
555
603
|
|
|
556
604
|
// src/slider.dom.ts
|
|
557
|
-
var dom = __spreadProps(__spreadValues({}, styles), {
|
|
558
|
-
getDoc: (ctx) => {
|
|
559
|
-
var _a;
|
|
560
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
561
|
-
},
|
|
562
|
-
getRootNode: (ctx) => {
|
|
563
|
-
var _a;
|
|
564
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
565
|
-
},
|
|
605
|
+
var dom = defineDomHelpers(__spreadProps(__spreadValues({}, styles), {
|
|
566
606
|
getRootId: (ctx) => {
|
|
567
607
|
var _a, _b;
|
|
568
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `slider:${ctx.
|
|
608
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `slider:${ctx.id}`;
|
|
569
609
|
},
|
|
570
610
|
getThumbId: (ctx) => {
|
|
571
611
|
var _a, _b;
|
|
572
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.thumb) != null ? _b : `slider:${ctx.
|
|
612
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.thumb) != null ? _b : `slider:${ctx.id}:thumb`;
|
|
573
613
|
},
|
|
574
614
|
getControlId: (ctx) => {
|
|
575
615
|
var _a, _b;
|
|
576
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.control) != null ? _b : `slider:${ctx.
|
|
616
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.control) != null ? _b : `slider:${ctx.id}:control`;
|
|
577
617
|
},
|
|
578
|
-
getInputId: (ctx) => `slider:${ctx.
|
|
618
|
+
getInputId: (ctx) => `slider:${ctx.id}:input`,
|
|
579
619
|
getOutputId: (ctx) => {
|
|
580
620
|
var _a, _b;
|
|
581
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.output) != null ? _b : `slider:${ctx.
|
|
621
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.output) != null ? _b : `slider:${ctx.id}:output`;
|
|
582
622
|
},
|
|
583
623
|
getTrackId: (ctx) => {
|
|
584
624
|
var _a, _b;
|
|
585
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.
|
|
625
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.id}track`;
|
|
586
626
|
},
|
|
587
627
|
getRangeId: (ctx) => {
|
|
588
628
|
var _a, _b;
|
|
589
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.
|
|
629
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.id}:range`;
|
|
590
630
|
},
|
|
591
631
|
getLabelId: (ctx) => {
|
|
592
632
|
var _a, _b;
|
|
593
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `slider:${ctx.
|
|
633
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `slider:${ctx.id}:label`;
|
|
594
634
|
},
|
|
595
|
-
getMarkerId: (ctx, value) => `slider:${ctx.
|
|
596
|
-
getRootEl: (ctx) => dom.
|
|
597
|
-
getThumbEl: (ctx) => dom.
|
|
598
|
-
getControlEl: (ctx) => dom.
|
|
599
|
-
getInputEl: (ctx) => dom.
|
|
635
|
+
getMarkerId: (ctx, value) => `slider:${ctx.id}:marker:${value}`,
|
|
636
|
+
getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
|
|
637
|
+
getThumbEl: (ctx) => dom.getById(ctx, dom.getThumbId(ctx)),
|
|
638
|
+
getControlEl: (ctx) => dom.getById(ctx, dom.getControlId(ctx)),
|
|
639
|
+
getInputEl: (ctx) => dom.getById(ctx, dom.getInputId(ctx)),
|
|
600
640
|
getValueFromPoint(ctx, point) {
|
|
601
641
|
const el = dom.getControlEl(ctx);
|
|
602
642
|
if (!el)
|
|
@@ -618,7 +658,7 @@ var dom = __spreadProps(__spreadValues({}, styles), {
|
|
|
618
658
|
return;
|
|
619
659
|
dispatchInputValueEvent(input, ctx.value);
|
|
620
660
|
}
|
|
621
|
-
});
|
|
661
|
+
}));
|
|
622
662
|
|
|
623
663
|
// src/slider.connect.ts
|
|
624
664
|
function connect(state2, send, normalize) {
|
|
@@ -834,14 +874,13 @@ function connect(state2, send, normalize) {
|
|
|
834
874
|
|
|
835
875
|
// src/slider.machine.ts
|
|
836
876
|
var import_core = require("@zag-js/core");
|
|
837
|
-
function machine(ctx
|
|
877
|
+
function machine(ctx) {
|
|
838
878
|
return (0, import_core.createMachine)({
|
|
839
879
|
id: "slider",
|
|
840
880
|
initial: "unknown",
|
|
841
881
|
context: __spreadValues({
|
|
842
882
|
thumbSize: null,
|
|
843
883
|
thumbAlignment: "contain",
|
|
844
|
-
uid: "",
|
|
845
884
|
disabled: false,
|
|
846
885
|
threshold: 5,
|
|
847
886
|
dir: "ltr",
|
|
@@ -880,7 +919,7 @@ function machine(ctx = {}) {
|
|
|
880
919
|
on: {
|
|
881
920
|
SETUP: {
|
|
882
921
|
target: "idle",
|
|
883
|
-
actions: ["
|
|
922
|
+
actions: ["setThumbSize", "checkValue"]
|
|
884
923
|
}
|
|
885
924
|
}
|
|
886
925
|
},
|
|
@@ -952,26 +991,18 @@ function machine(ctx = {}) {
|
|
|
952
991
|
},
|
|
953
992
|
activities: {
|
|
954
993
|
trackFieldsetDisabled(ctx2) {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
ctx2.disabled = disabled;
|
|
960
|
-
}
|
|
961
|
-
});
|
|
994
|
+
return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
995
|
+
if (disabled) {
|
|
996
|
+
ctx2.disabled = disabled;
|
|
997
|
+
}
|
|
962
998
|
});
|
|
963
|
-
return () => cleanup == null ? void 0 : cleanup();
|
|
964
999
|
},
|
|
965
1000
|
trackFormReset(ctx2) {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
ctx2.value = ctx2.initialValue;
|
|
971
|
-
}
|
|
972
|
-
});
|
|
1001
|
+
return trackFormReset(dom.getInputEl(ctx2), () => {
|
|
1002
|
+
if (ctx2.initialValue != null) {
|
|
1003
|
+
ctx2.value = ctx2.initialValue;
|
|
1004
|
+
}
|
|
973
1005
|
});
|
|
974
|
-
return () => cleanup == null ? void 0 : cleanup();
|
|
975
1006
|
},
|
|
976
1007
|
trackPointerMove(ctx2, _evt, { send }) {
|
|
977
1008
|
return trackPointerMove({
|
|
@@ -986,13 +1017,6 @@ function machine(ctx = {}) {
|
|
|
986
1017
|
}
|
|
987
1018
|
},
|
|
988
1019
|
actions: {
|
|
989
|
-
setupDocument(ctx2, evt) {
|
|
990
|
-
if (evt.doc)
|
|
991
|
-
ctx2.doc = (0, import_core.ref)(evt.doc);
|
|
992
|
-
if (evt.root)
|
|
993
|
-
ctx2.rootNode = (0, import_core.ref)(evt.root);
|
|
994
|
-
ctx2.uid = evt.id;
|
|
995
|
-
},
|
|
996
1020
|
checkValue(ctx2) {
|
|
997
1021
|
const value = utils.convert(ctx2, ctx2.value);
|
|
998
1022
|
Object.assign(ctx2, { value, initialValue: value });
|
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,23 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
21
|
// ../../utilities/dom/dist/index.mjs
|
|
22
|
+
var __defProp2 = Object.defineProperty;
|
|
23
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
24
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
25
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
22
26
|
var __pow = Math.pow;
|
|
27
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
28
|
+
var __spreadValues2 = (a, b) => {
|
|
29
|
+
for (var prop in b || (b = {}))
|
|
30
|
+
if (__hasOwnProp2.call(b, prop))
|
|
31
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
32
|
+
if (__getOwnPropSymbols2)
|
|
33
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
34
|
+
if (__propIsEnum2.call(b, prop))
|
|
35
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
36
|
+
}
|
|
37
|
+
return a;
|
|
38
|
+
};
|
|
23
39
|
var dataAttr = (guard) => {
|
|
24
40
|
return guard ? "" : void 0;
|
|
25
41
|
};
|
|
@@ -46,10 +62,40 @@ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
|
46
62
|
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
47
63
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
48
64
|
var isIos = () => isApple() && !isMac();
|
|
65
|
+
function isDocument(el) {
|
|
66
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
67
|
+
}
|
|
68
|
+
function isWindow(value) {
|
|
69
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
70
|
+
}
|
|
71
|
+
function getDocument(el) {
|
|
72
|
+
var _a;
|
|
73
|
+
if (isWindow(el))
|
|
74
|
+
return el.document;
|
|
75
|
+
if (isDocument(el))
|
|
76
|
+
return el;
|
|
77
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
78
|
+
}
|
|
49
79
|
function getWindow(el) {
|
|
50
80
|
var _a;
|
|
51
81
|
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
52
82
|
}
|
|
83
|
+
function defineDomHelpers(helpers) {
|
|
84
|
+
const dom2 = {
|
|
85
|
+
getRootNode: (ctx) => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
88
|
+
},
|
|
89
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
90
|
+
getWin: (ctx) => {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
93
|
+
},
|
|
94
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
95
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
96
|
+
};
|
|
97
|
+
return __spreadValues2(__spreadValues2({}, dom2), helpers);
|
|
98
|
+
}
|
|
53
99
|
function getNativeEvent(e) {
|
|
54
100
|
var _a;
|
|
55
101
|
return (_a = e.nativeEvent) != null ? _a : e;
|
|
@@ -148,6 +194,8 @@ function getDescriptor(el, options) {
|
|
|
148
194
|
}
|
|
149
195
|
function dispatchInputValueEvent(el, value) {
|
|
150
196
|
var _a;
|
|
197
|
+
if (!el)
|
|
198
|
+
return;
|
|
151
199
|
const win = getWindow(el);
|
|
152
200
|
if (!(el instanceof win.HTMLInputElement))
|
|
153
201
|
return;
|
|
@@ -529,49 +577,41 @@ var utils = {
|
|
|
529
577
|
};
|
|
530
578
|
|
|
531
579
|
// src/slider.dom.ts
|
|
532
|
-
var dom = __spreadProps(__spreadValues({}, styles), {
|
|
533
|
-
getDoc: (ctx) => {
|
|
534
|
-
var _a;
|
|
535
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
536
|
-
},
|
|
537
|
-
getRootNode: (ctx) => {
|
|
538
|
-
var _a;
|
|
539
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
540
|
-
},
|
|
580
|
+
var dom = defineDomHelpers(__spreadProps(__spreadValues({}, styles), {
|
|
541
581
|
getRootId: (ctx) => {
|
|
542
582
|
var _a, _b;
|
|
543
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `slider:${ctx.
|
|
583
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `slider:${ctx.id}`;
|
|
544
584
|
},
|
|
545
585
|
getThumbId: (ctx) => {
|
|
546
586
|
var _a, _b;
|
|
547
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.thumb) != null ? _b : `slider:${ctx.
|
|
587
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.thumb) != null ? _b : `slider:${ctx.id}:thumb`;
|
|
548
588
|
},
|
|
549
589
|
getControlId: (ctx) => {
|
|
550
590
|
var _a, _b;
|
|
551
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.control) != null ? _b : `slider:${ctx.
|
|
591
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.control) != null ? _b : `slider:${ctx.id}:control`;
|
|
552
592
|
},
|
|
553
|
-
getInputId: (ctx) => `slider:${ctx.
|
|
593
|
+
getInputId: (ctx) => `slider:${ctx.id}:input`,
|
|
554
594
|
getOutputId: (ctx) => {
|
|
555
595
|
var _a, _b;
|
|
556
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.output) != null ? _b : `slider:${ctx.
|
|
596
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.output) != null ? _b : `slider:${ctx.id}:output`;
|
|
557
597
|
},
|
|
558
598
|
getTrackId: (ctx) => {
|
|
559
599
|
var _a, _b;
|
|
560
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.
|
|
600
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.id}track`;
|
|
561
601
|
},
|
|
562
602
|
getRangeId: (ctx) => {
|
|
563
603
|
var _a, _b;
|
|
564
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.
|
|
604
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.id}:range`;
|
|
565
605
|
},
|
|
566
606
|
getLabelId: (ctx) => {
|
|
567
607
|
var _a, _b;
|
|
568
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `slider:${ctx.
|
|
608
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `slider:${ctx.id}:label`;
|
|
569
609
|
},
|
|
570
|
-
getMarkerId: (ctx, value) => `slider:${ctx.
|
|
571
|
-
getRootEl: (ctx) => dom.
|
|
572
|
-
getThumbEl: (ctx) => dom.
|
|
573
|
-
getControlEl: (ctx) => dom.
|
|
574
|
-
getInputEl: (ctx) => dom.
|
|
610
|
+
getMarkerId: (ctx, value) => `slider:${ctx.id}:marker:${value}`,
|
|
611
|
+
getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
|
|
612
|
+
getThumbEl: (ctx) => dom.getById(ctx, dom.getThumbId(ctx)),
|
|
613
|
+
getControlEl: (ctx) => dom.getById(ctx, dom.getControlId(ctx)),
|
|
614
|
+
getInputEl: (ctx) => dom.getById(ctx, dom.getInputId(ctx)),
|
|
575
615
|
getValueFromPoint(ctx, point) {
|
|
576
616
|
const el = dom.getControlEl(ctx);
|
|
577
617
|
if (!el)
|
|
@@ -593,7 +633,7 @@ var dom = __spreadProps(__spreadValues({}, styles), {
|
|
|
593
633
|
return;
|
|
594
634
|
dispatchInputValueEvent(input, ctx.value);
|
|
595
635
|
}
|
|
596
|
-
});
|
|
636
|
+
}));
|
|
597
637
|
|
|
598
638
|
// src/slider.connect.ts
|
|
599
639
|
function connect(state2, send, normalize) {
|
|
@@ -808,15 +848,14 @@ function connect(state2, send, normalize) {
|
|
|
808
848
|
}
|
|
809
849
|
|
|
810
850
|
// src/slider.machine.ts
|
|
811
|
-
import { createMachine
|
|
812
|
-
function machine(ctx
|
|
851
|
+
import { createMachine } from "@zag-js/core";
|
|
852
|
+
function machine(ctx) {
|
|
813
853
|
return createMachine({
|
|
814
854
|
id: "slider",
|
|
815
855
|
initial: "unknown",
|
|
816
856
|
context: __spreadValues({
|
|
817
857
|
thumbSize: null,
|
|
818
858
|
thumbAlignment: "contain",
|
|
819
|
-
uid: "",
|
|
820
859
|
disabled: false,
|
|
821
860
|
threshold: 5,
|
|
822
861
|
dir: "ltr",
|
|
@@ -855,7 +894,7 @@ function machine(ctx = {}) {
|
|
|
855
894
|
on: {
|
|
856
895
|
SETUP: {
|
|
857
896
|
target: "idle",
|
|
858
|
-
actions: ["
|
|
897
|
+
actions: ["setThumbSize", "checkValue"]
|
|
859
898
|
}
|
|
860
899
|
}
|
|
861
900
|
},
|
|
@@ -927,26 +966,18 @@ function machine(ctx = {}) {
|
|
|
927
966
|
},
|
|
928
967
|
activities: {
|
|
929
968
|
trackFieldsetDisabled(ctx2) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
ctx2.disabled = disabled;
|
|
935
|
-
}
|
|
936
|
-
});
|
|
969
|
+
return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
970
|
+
if (disabled) {
|
|
971
|
+
ctx2.disabled = disabled;
|
|
972
|
+
}
|
|
937
973
|
});
|
|
938
|
-
return () => cleanup == null ? void 0 : cleanup();
|
|
939
974
|
},
|
|
940
975
|
trackFormReset(ctx2) {
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
ctx2.value = ctx2.initialValue;
|
|
946
|
-
}
|
|
947
|
-
});
|
|
976
|
+
return trackFormReset(dom.getInputEl(ctx2), () => {
|
|
977
|
+
if (ctx2.initialValue != null) {
|
|
978
|
+
ctx2.value = ctx2.initialValue;
|
|
979
|
+
}
|
|
948
980
|
});
|
|
949
|
-
return () => cleanup == null ? void 0 : cleanup();
|
|
950
981
|
},
|
|
951
982
|
trackPointerMove(ctx2, _evt, { send }) {
|
|
952
983
|
return trackPointerMove({
|
|
@@ -961,13 +992,6 @@ function machine(ctx = {}) {
|
|
|
961
992
|
}
|
|
962
993
|
},
|
|
963
994
|
actions: {
|
|
964
|
-
setupDocument(ctx2, evt) {
|
|
965
|
-
if (evt.doc)
|
|
966
|
-
ctx2.doc = ref(evt.doc);
|
|
967
|
-
if (evt.root)
|
|
968
|
-
ctx2.rootNode = ref(evt.root);
|
|
969
|
-
ctx2.uid = evt.id;
|
|
970
|
-
},
|
|
971
995
|
checkValue(ctx2) {
|
|
972
996
|
const value = utils.convert(ctx2, ctx2.value);
|
|
973
997
|
Object.assign(ctx2, { value, initialValue: value });
|
package/dist/slider.dom.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import type { MachineContext as Ctx, Point } from "./slider.types";
|
|
2
2
|
export declare const dom: {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
getRootNode: (ctx: {
|
|
4
|
+
getRootNode?: () => Node | Document | ShadowRoot;
|
|
5
|
+
}) => Document | ShadowRoot;
|
|
6
|
+
getDoc: (ctx: {
|
|
7
|
+
getRootNode?: () => Node | Document | ShadowRoot;
|
|
8
|
+
}) => Document;
|
|
9
|
+
getWin: (ctx: {
|
|
10
|
+
getRootNode?: () => Node | Document | ShadowRoot;
|
|
11
|
+
}) => Window & typeof globalThis;
|
|
12
|
+
getActiveElement: (ctx: {
|
|
13
|
+
getRootNode?: () => Node | Document | ShadowRoot;
|
|
14
|
+
}) => HTMLElement;
|
|
15
|
+
getById: <T_1 = HTMLElement>(ctx: {
|
|
16
|
+
getRootNode?: () => Node | Document | ShadowRoot;
|
|
17
|
+
}, id: string) => T_1;
|
|
18
|
+
} & {
|
|
5
19
|
getRootId: (ctx: Ctx) => string;
|
|
6
20
|
getThumbId: (ctx: Ctx) => string;
|
|
7
21
|
getControlId: (ctx: Ctx) => string;
|
|
@@ -18,12 +32,12 @@ export declare const dom: {
|
|
|
18
32
|
getValueFromPoint(ctx: Ctx, point: Point): number | undefined;
|
|
19
33
|
dispatchChangeEvent(ctx: Ctx): void;
|
|
20
34
|
getThumbOffset: (ctx: import("./slider.types").SharedContext) => string;
|
|
21
|
-
getControlStyle: () => JSX.CSSProperties;
|
|
22
|
-
getThumbStyle: (ctx: import("./slider.types").SharedContext) => JSX.CSSProperties;
|
|
23
|
-
getRangeStyle: (ctx: Pick<import("./slider.types").SharedContext, "isVertical" | "isRtl">) => JSX.CSSProperties;
|
|
24
|
-
getRootStyle: (ctx: Ctx) => JSX.CSSProperties;
|
|
25
|
-
getMarkerStyle: (ctx: Pick<import("./slider.types").SharedContext, "isHorizontal" | "isRtl">, percent: number) => JSX.CSSProperties;
|
|
26
|
-
getLabelStyle: () => JSX.CSSProperties;
|
|
27
|
-
getTrackStyle: () => JSX.CSSProperties;
|
|
28
|
-
getMarkerGroupStyle: () => JSX.CSSProperties;
|
|
35
|
+
getControlStyle: () => import("@zag-js/types").JSX.CSSProperties;
|
|
36
|
+
getThumbStyle: (ctx: import("./slider.types").SharedContext) => import("@zag-js/types").JSX.CSSProperties;
|
|
37
|
+
getRangeStyle: (ctx: Pick<import("./slider.types").SharedContext, "isVertical" | "isRtl">) => import("@zag-js/types").JSX.CSSProperties;
|
|
38
|
+
getRootStyle: (ctx: Ctx) => import("@zag-js/types").JSX.CSSProperties;
|
|
39
|
+
getMarkerStyle: (ctx: Pick<import("./slider.types").SharedContext, "isHorizontal" | "isRtl">, percent: number) => import("@zag-js/types").JSX.CSSProperties;
|
|
40
|
+
getLabelStyle: () => import("@zag-js/types").JSX.CSSProperties;
|
|
41
|
+
getTrackStyle: () => import("@zag-js/types").JSX.CSSProperties;
|
|
42
|
+
getMarkerGroupStyle: () => import("@zag-js/types").JSX.CSSProperties;
|
|
29
43
|
};
|
package/dist/slider.machine.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { MachineContext, MachineState, UserDefinedContext } from "./slider.types";
|
|
2
|
-
export declare function machine(ctx
|
|
2
|
+
export declare function machine(ctx: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
|
package/dist/slider.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StateMachine as S } from "@zag-js/core";
|
|
2
|
-
import type { Context, DirectionProperty } from "@zag-js/types";
|
|
2
|
+
import type { CommonProperties, Context, DirectionProperty, RequiredBy } from "@zag-js/types";
|
|
3
3
|
declare type ElementIds = Partial<{
|
|
4
4
|
root: string;
|
|
5
5
|
thumb: string;
|
|
@@ -9,7 +9,7 @@ declare type ElementIds = Partial<{
|
|
|
9
9
|
label: string;
|
|
10
10
|
output: string;
|
|
11
11
|
}>;
|
|
12
|
-
declare type PublicContext = DirectionProperty & {
|
|
12
|
+
declare type PublicContext = DirectionProperty & CommonProperties & {
|
|
13
13
|
/**
|
|
14
14
|
* The ids of the elements in the slider. Useful for composition.
|
|
15
15
|
*/
|
|
@@ -96,7 +96,7 @@ declare type PublicContext = DirectionProperty & {
|
|
|
96
96
|
*/
|
|
97
97
|
thumbAlignment?: "contain" | "center";
|
|
98
98
|
};
|
|
99
|
-
export declare type UserDefinedContext =
|
|
99
|
+
export declare type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
100
100
|
declare type ComputedContext = Readonly<{
|
|
101
101
|
/**
|
|
102
102
|
* @computed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/slider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Core logic for the slider widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,10 +29,12 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.1.
|
|
33
|
-
"@zag-js/
|
|
32
|
+
"@zag-js/core": "0.1.8",
|
|
33
|
+
"@zag-js/types": "0.2.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@zag-js/dom-utils": "0.1.7",
|
|
34
37
|
"@zag-js/number-utils": "0.1.2",
|
|
35
|
-
"@zag-js/types": "0.2.1",
|
|
36
38
|
"@zag-js/utils": "0.1.2"
|
|
37
39
|
},
|
|
38
40
|
"scripts": {
|