@zag-js/slider 0.1.11 → 0.1.14
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 +256 -247
- package/dist/index.mjs +256 -247
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -65,9 +65,6 @@ function getDocument(el) {
|
|
|
65
65
|
return el;
|
|
66
66
|
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
67
67
|
}
|
|
68
|
-
function getWindow(el) {
|
|
69
|
-
return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
|
|
70
|
-
}
|
|
71
68
|
function defineDomHelpers(helpers) {
|
|
72
69
|
const dom2 = {
|
|
73
70
|
getRootNode: (ctx) => {
|
|
@@ -94,46 +91,6 @@ var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
|
94
91
|
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
95
92
|
var isLeftClick = (v) => v.button === 0;
|
|
96
93
|
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
97
|
-
function observeAttributes(node, attributes, fn) {
|
|
98
|
-
if (!node)
|
|
99
|
-
return;
|
|
100
|
-
const attrs = Array.isArray(attributes) ? attributes : [attributes];
|
|
101
|
-
const win = node.ownerDocument.defaultView || window;
|
|
102
|
-
const obs = new win.MutationObserver((changes) => {
|
|
103
|
-
for (const change of changes) {
|
|
104
|
-
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
|
|
105
|
-
fn(change);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
obs.observe(node, { attributes: true, attributeFilter: attrs });
|
|
110
|
-
return () => obs.disconnect();
|
|
111
|
-
}
|
|
112
|
-
function getClosestForm(el) {
|
|
113
|
-
if (isFormElement(el))
|
|
114
|
-
return el.form;
|
|
115
|
-
else
|
|
116
|
-
return el.closest("form");
|
|
117
|
-
}
|
|
118
|
-
function isFormElement(el) {
|
|
119
|
-
return el.matches("textarea, input, select, button");
|
|
120
|
-
}
|
|
121
|
-
function trackFormReset(el, callback) {
|
|
122
|
-
if (!el)
|
|
123
|
-
return;
|
|
124
|
-
const form = getClosestForm(el);
|
|
125
|
-
form == null ? void 0 : form.addEventListener("reset", callback, { passive: true });
|
|
126
|
-
return () => {
|
|
127
|
-
form == null ? void 0 : form.removeEventListener("reset", callback);
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function trackFieldsetDisabled(el, callback) {
|
|
131
|
-
const fieldset = el == null ? void 0 : el.closest("fieldset");
|
|
132
|
-
if (!fieldset)
|
|
133
|
-
return;
|
|
134
|
-
callback(fieldset.disabled);
|
|
135
|
-
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
|
|
136
|
-
}
|
|
137
94
|
function getElementOffset(element) {
|
|
138
95
|
let left = 0;
|
|
139
96
|
let top = 0;
|
|
@@ -172,28 +129,9 @@ function getPointRelativeToNode(point, element) {
|
|
|
172
129
|
const y = point.y - offset.top;
|
|
173
130
|
return { x, y };
|
|
174
131
|
}
|
|
175
|
-
function getDescriptor(el, options) {
|
|
176
|
-
const { type, property } = options;
|
|
177
|
-
const proto = getWindow(el)[type].prototype;
|
|
178
|
-
return Object.getOwnPropertyDescriptor(proto, property) ?? {};
|
|
179
|
-
}
|
|
180
|
-
function dispatchInputValueEvent(el, value) {
|
|
181
|
-
var _a;
|
|
182
|
-
if (!el)
|
|
183
|
-
return;
|
|
184
|
-
const win = getWindow(el);
|
|
185
|
-
if (!(el instanceof win.HTMLInputElement))
|
|
186
|
-
return;
|
|
187
|
-
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
188
|
-
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
189
|
-
const event = new win.Event("input", { bubbles: true });
|
|
190
|
-
el.dispatchEvent(event);
|
|
191
|
-
}
|
|
192
132
|
var rtlKeyMap = {
|
|
193
133
|
ArrowLeft: "ArrowRight",
|
|
194
|
-
ArrowRight: "ArrowLeft"
|
|
195
|
-
Home: "End",
|
|
196
|
-
End: "Home"
|
|
134
|
+
ArrowRight: "ArrowLeft"
|
|
197
135
|
};
|
|
198
136
|
var sameKeyMap = {
|
|
199
137
|
Up: "ArrowUp",
|
|
@@ -367,7 +305,75 @@ function trackPointerMove(doc, opts) {
|
|
|
367
305
|
}
|
|
368
306
|
onPointerMove(info, event);
|
|
369
307
|
};
|
|
370
|
-
return callAll(
|
|
308
|
+
return callAll(
|
|
309
|
+
addPointerEvent(doc, "pointermove", handlePointerMove, false),
|
|
310
|
+
addPointerEvent(doc, "pointerup", onPointerUp, false),
|
|
311
|
+
addPointerEvent(doc, "pointercancel", onPointerUp, false),
|
|
312
|
+
addPointerEvent(doc, "contextmenu", onPointerUp, false),
|
|
313
|
+
disableTextSelection({ doc })
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ../../utilities/form-utils/dist/index.mjs
|
|
318
|
+
function getWindow(el) {
|
|
319
|
+
return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
|
|
320
|
+
}
|
|
321
|
+
function observeAttributes(node, attributes, fn) {
|
|
322
|
+
if (!node)
|
|
323
|
+
return;
|
|
324
|
+
const attrs = Array.isArray(attributes) ? attributes : [attributes];
|
|
325
|
+
const win = node.ownerDocument.defaultView || window;
|
|
326
|
+
const obs = new win.MutationObserver((changes) => {
|
|
327
|
+
for (const change of changes) {
|
|
328
|
+
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
|
|
329
|
+
fn(change);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
obs.observe(node, { attributes: true, attributeFilter: attrs });
|
|
334
|
+
return () => obs.disconnect();
|
|
335
|
+
}
|
|
336
|
+
function getDescriptor(el, options) {
|
|
337
|
+
const { type, property } = options;
|
|
338
|
+
const proto = getWindow(el)[type].prototype;
|
|
339
|
+
return Object.getOwnPropertyDescriptor(proto, property) ?? {};
|
|
340
|
+
}
|
|
341
|
+
function dispatchInputValueEvent(el, value) {
|
|
342
|
+
var _a;
|
|
343
|
+
if (!el)
|
|
344
|
+
return;
|
|
345
|
+
const win = getWindow(el);
|
|
346
|
+
if (!(el instanceof win.HTMLInputElement))
|
|
347
|
+
return;
|
|
348
|
+
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
349
|
+
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
350
|
+
const event = new win.Event("input", { bubbles: true });
|
|
351
|
+
el.dispatchEvent(event);
|
|
352
|
+
}
|
|
353
|
+
function getClosestForm(el) {
|
|
354
|
+
if (isFormElement(el))
|
|
355
|
+
return el.form;
|
|
356
|
+
else
|
|
357
|
+
return el.closest("form");
|
|
358
|
+
}
|
|
359
|
+
function isFormElement(el) {
|
|
360
|
+
return el.matches("textarea, input, select, button");
|
|
361
|
+
}
|
|
362
|
+
function trackFormReset(el, callback) {
|
|
363
|
+
if (!el)
|
|
364
|
+
return;
|
|
365
|
+
const form = getClosestForm(el);
|
|
366
|
+
form == null ? void 0 : form.addEventListener("reset", callback, { passive: true });
|
|
367
|
+
return () => {
|
|
368
|
+
form == null ? void 0 : form.removeEventListener("reset", callback);
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function trackFieldsetDisabled(el, callback) {
|
|
372
|
+
const fieldset = el == null ? void 0 : el.closest("fieldset");
|
|
373
|
+
if (!fieldset)
|
|
374
|
+
return;
|
|
375
|
+
callback(fieldset.disabled);
|
|
376
|
+
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
|
|
371
377
|
}
|
|
372
378
|
|
|
373
379
|
// ../../utilities/number/dist/index.mjs
|
|
@@ -829,207 +835,210 @@ function connect(state2, send, normalize) {
|
|
|
829
835
|
|
|
830
836
|
// src/slider.machine.ts
|
|
831
837
|
var import_core = require("@zag-js/core");
|
|
838
|
+
var import_element_size = require("@zag-js/element-size");
|
|
832
839
|
function machine(ctx) {
|
|
833
|
-
return (0, import_core.createMachine)(
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
computed: {
|
|
852
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
853
|
-
isVertical: (ctx2) => ctx2.orientation === "vertical",
|
|
854
|
-
isRtl: (ctx2) => ctx2.orientation === "horizontal" && ctx2.dir === "rtl",
|
|
855
|
-
isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readonly),
|
|
856
|
-
hasMeasuredThumbSize: (ctx2) => ctx2.thumbSize !== null
|
|
857
|
-
},
|
|
858
|
-
watch: {
|
|
859
|
-
value: ["invokeOnChange", "dispatchChangeEvent"]
|
|
860
|
-
},
|
|
861
|
-
activities: ["trackFormReset", "trackFieldsetDisabled"],
|
|
862
|
-
on: {
|
|
863
|
-
SET_VALUE: {
|
|
864
|
-
actions: "setValue"
|
|
840
|
+
return (0, import_core.createMachine)(
|
|
841
|
+
{
|
|
842
|
+
id: "slider",
|
|
843
|
+
initial: "unknown",
|
|
844
|
+
context: {
|
|
845
|
+
thumbSize: null,
|
|
846
|
+
thumbAlignment: "contain",
|
|
847
|
+
disabled: false,
|
|
848
|
+
threshold: 5,
|
|
849
|
+
dir: "ltr",
|
|
850
|
+
origin: "start",
|
|
851
|
+
orientation: "horizontal",
|
|
852
|
+
initialValue: null,
|
|
853
|
+
value: 0,
|
|
854
|
+
step: 1,
|
|
855
|
+
min: 0,
|
|
856
|
+
max: 100,
|
|
857
|
+
...ctx
|
|
865
858
|
},
|
|
866
|
-
|
|
867
|
-
|
|
859
|
+
computed: {
|
|
860
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
861
|
+
isVertical: (ctx2) => ctx2.orientation === "vertical",
|
|
862
|
+
isRtl: (ctx2) => ctx2.orientation === "horizontal" && ctx2.dir === "rtl",
|
|
863
|
+
isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readonly),
|
|
864
|
+
hasMeasuredThumbSize: (ctx2) => ctx2.thumbSize !== null
|
|
868
865
|
},
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
states: {
|
|
874
|
-
unknown: {
|
|
875
|
-
on: {
|
|
876
|
-
SETUP: {
|
|
877
|
-
target: "idle",
|
|
878
|
-
actions: ["setThumbSize", "checkValue"]
|
|
879
|
-
}
|
|
880
|
-
}
|
|
866
|
+
watch: {
|
|
867
|
+
value: ["invokeOnChange", "dispatchChangeEvent"]
|
|
881
868
|
},
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
869
|
+
activities: ["trackFormReset", "trackFieldsetDisabled", "trackThumbSize"],
|
|
870
|
+
on: {
|
|
871
|
+
SET_VALUE: {
|
|
872
|
+
actions: "setValue"
|
|
873
|
+
},
|
|
874
|
+
INCREMENT: {
|
|
875
|
+
actions: "increment"
|
|
876
|
+
},
|
|
877
|
+
DECREMENT: {
|
|
878
|
+
actions: "decrement"
|
|
889
879
|
}
|
|
890
880
|
},
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
ARROW_LEFT: {
|
|
899
|
-
guard: "isHorizontal",
|
|
900
|
-
actions: "decrement"
|
|
901
|
-
},
|
|
902
|
-
ARROW_RIGHT: {
|
|
903
|
-
guard: "isHorizontal",
|
|
904
|
-
actions: "increment"
|
|
905
|
-
},
|
|
906
|
-
ARROW_UP: {
|
|
907
|
-
guard: "isVertical",
|
|
908
|
-
actions: "increment"
|
|
909
|
-
},
|
|
910
|
-
ARROW_DOWN: {
|
|
911
|
-
guard: "isVertical",
|
|
912
|
-
actions: "decrement"
|
|
913
|
-
},
|
|
914
|
-
PAGE_UP: {
|
|
915
|
-
actions: "increment"
|
|
916
|
-
},
|
|
917
|
-
PAGE_DOWN: {
|
|
918
|
-
actions: "decrement"
|
|
919
|
-
},
|
|
920
|
-
HOME: {
|
|
921
|
-
actions: "setToMin"
|
|
922
|
-
},
|
|
923
|
-
END: {
|
|
924
|
-
actions: "setToMax"
|
|
925
|
-
},
|
|
926
|
-
BLUR: "idle"
|
|
927
|
-
}
|
|
928
|
-
},
|
|
929
|
-
dragging: {
|
|
930
|
-
entry: "focusThumb",
|
|
931
|
-
activities: "trackPointerMove",
|
|
932
|
-
on: {
|
|
933
|
-
POINTER_UP: {
|
|
934
|
-
target: "focus",
|
|
935
|
-
actions: "invokeOnChangeEnd"
|
|
936
|
-
},
|
|
937
|
-
POINTER_MOVE: {
|
|
938
|
-
actions: "setPointerValue"
|
|
881
|
+
states: {
|
|
882
|
+
unknown: {
|
|
883
|
+
on: {
|
|
884
|
+
SETUP: {
|
|
885
|
+
target: "idle",
|
|
886
|
+
actions: ["checkValue"]
|
|
887
|
+
}
|
|
939
888
|
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
activities: {
|
|
949
|
-
trackFieldsetDisabled(ctx2) {
|
|
950
|
-
return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
951
|
-
if (disabled) {
|
|
952
|
-
ctx2.disabled = disabled;
|
|
889
|
+
},
|
|
890
|
+
idle: {
|
|
891
|
+
on: {
|
|
892
|
+
POINTER_DOWN: {
|
|
893
|
+
target: "dragging",
|
|
894
|
+
actions: ["setPointerValue", "invokeOnChangeStart", "focusThumb"]
|
|
895
|
+
},
|
|
896
|
+
FOCUS: "focus"
|
|
953
897
|
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
898
|
+
},
|
|
899
|
+
focus: {
|
|
900
|
+
entry: "focusThumb",
|
|
901
|
+
on: {
|
|
902
|
+
POINTER_DOWN: {
|
|
903
|
+
target: "dragging",
|
|
904
|
+
actions: ["setPointerValue", "invokeOnChangeStart", "focusThumb"]
|
|
905
|
+
},
|
|
906
|
+
ARROW_LEFT: {
|
|
907
|
+
guard: "isHorizontal",
|
|
908
|
+
actions: "decrement"
|
|
909
|
+
},
|
|
910
|
+
ARROW_RIGHT: {
|
|
911
|
+
guard: "isHorizontal",
|
|
912
|
+
actions: "increment"
|
|
913
|
+
},
|
|
914
|
+
ARROW_UP: {
|
|
915
|
+
guard: "isVertical",
|
|
916
|
+
actions: "increment"
|
|
917
|
+
},
|
|
918
|
+
ARROW_DOWN: {
|
|
919
|
+
guard: "isVertical",
|
|
920
|
+
actions: "decrement"
|
|
921
|
+
},
|
|
922
|
+
PAGE_UP: {
|
|
923
|
+
actions: "increment"
|
|
924
|
+
},
|
|
925
|
+
PAGE_DOWN: {
|
|
926
|
+
actions: "decrement"
|
|
927
|
+
},
|
|
928
|
+
HOME: {
|
|
929
|
+
actions: "setToMin"
|
|
930
|
+
},
|
|
931
|
+
END: {
|
|
932
|
+
actions: "setToMax"
|
|
933
|
+
},
|
|
934
|
+
BLUR: "idle"
|
|
960
935
|
}
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
936
|
+
},
|
|
937
|
+
dragging: {
|
|
938
|
+
entry: "focusThumb",
|
|
939
|
+
activities: "trackPointerMove",
|
|
940
|
+
on: {
|
|
941
|
+
POINTER_UP: {
|
|
942
|
+
target: "focus",
|
|
943
|
+
actions: "invokeOnChangeEnd"
|
|
944
|
+
},
|
|
945
|
+
POINTER_MOVE: {
|
|
946
|
+
actions: "setPointerValue"
|
|
947
|
+
}
|
|
970
948
|
}
|
|
971
|
-
}
|
|
949
|
+
}
|
|
972
950
|
}
|
|
973
951
|
},
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
},
|
|
979
|
-
invokeOnChangeStart(ctx2) {
|
|
980
|
-
var _a;
|
|
981
|
-
(_a = ctx2.onChangeStart) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
982
|
-
},
|
|
983
|
-
invokeOnChangeEnd(ctx2) {
|
|
984
|
-
var _a;
|
|
985
|
-
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
986
|
-
},
|
|
987
|
-
invokeOnChange(ctx2) {
|
|
988
|
-
var _a;
|
|
989
|
-
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
952
|
+
{
|
|
953
|
+
guards: {
|
|
954
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
955
|
+
isVertical: (ctx2) => ctx2.isVertical
|
|
990
956
|
},
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
957
|
+
activities: {
|
|
958
|
+
trackFieldsetDisabled(ctx2) {
|
|
959
|
+
return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
960
|
+
if (disabled) {
|
|
961
|
+
ctx2.disabled = disabled;
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
},
|
|
965
|
+
trackFormReset(ctx2) {
|
|
966
|
+
return trackFormReset(dom.getInputEl(ctx2), () => {
|
|
967
|
+
if (ctx2.initialValue != null) {
|
|
968
|
+
ctx2.value = ctx2.initialValue;
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
},
|
|
972
|
+
trackPointerMove(ctx2, _evt, { send }) {
|
|
973
|
+
return trackPointerMove(dom.getDoc(ctx2), {
|
|
974
|
+
onPointerMove(info) {
|
|
975
|
+
send({ type: "POINTER_MOVE", point: info.point });
|
|
976
|
+
},
|
|
977
|
+
onPointerUp() {
|
|
978
|
+
send("POINTER_UP");
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
},
|
|
982
|
+
trackThumbSize(ctx2, _evt) {
|
|
983
|
+
if (ctx2.thumbAlignment !== "contain")
|
|
1000
984
|
return;
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
if (value == null)
|
|
1007
|
-
return;
|
|
1008
|
-
ctx2.value = utils.clamp(ctx2, value);
|
|
985
|
+
return (0, import_element_size.trackElementSize)(dom.getThumbEl(ctx2), (size) => {
|
|
986
|
+
if (size)
|
|
987
|
+
ctx2.thumbSize = size;
|
|
988
|
+
});
|
|
989
|
+
}
|
|
1009
990
|
},
|
|
1010
|
-
|
|
1011
|
-
|
|
991
|
+
actions: {
|
|
992
|
+
checkValue(ctx2) {
|
|
993
|
+
const value = utils.convert(ctx2, ctx2.value);
|
|
994
|
+
ctx2.value = value;
|
|
995
|
+
ctx2.initialValue = value;
|
|
996
|
+
},
|
|
997
|
+
invokeOnChangeStart(ctx2) {
|
|
1012
998
|
var _a;
|
|
1013
|
-
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
ctx2
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
ctx2
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
999
|
+
(_a = ctx2.onChangeStart) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
1000
|
+
},
|
|
1001
|
+
invokeOnChangeEnd(ctx2) {
|
|
1002
|
+
var _a;
|
|
1003
|
+
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
1004
|
+
},
|
|
1005
|
+
invokeOnChange(ctx2) {
|
|
1006
|
+
var _a;
|
|
1007
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
1008
|
+
},
|
|
1009
|
+
dispatchChangeEvent(ctx2) {
|
|
1010
|
+
dom.dispatchChangeEvent(ctx2);
|
|
1011
|
+
},
|
|
1012
|
+
setPointerValue(ctx2, evt) {
|
|
1013
|
+
const value = dom.getValueFromPoint(ctx2, evt.point);
|
|
1014
|
+
if (value == null)
|
|
1015
|
+
return;
|
|
1016
|
+
ctx2.value = utils.clamp(ctx2, value);
|
|
1017
|
+
},
|
|
1018
|
+
focusThumb(ctx2) {
|
|
1019
|
+
raf(() => {
|
|
1020
|
+
var _a;
|
|
1021
|
+
return (_a = dom.getThumbEl(ctx2)) == null ? void 0 : _a.focus();
|
|
1022
|
+
});
|
|
1023
|
+
},
|
|
1024
|
+
decrement(ctx2, evt) {
|
|
1025
|
+
ctx2.value = utils.decrement(ctx2, evt.step);
|
|
1026
|
+
},
|
|
1027
|
+
increment(ctx2, evt) {
|
|
1028
|
+
ctx2.value = utils.increment(ctx2, evt.step);
|
|
1029
|
+
},
|
|
1030
|
+
setToMin(ctx2) {
|
|
1031
|
+
ctx2.value = ctx2.min;
|
|
1032
|
+
},
|
|
1033
|
+
setToMax(ctx2) {
|
|
1034
|
+
ctx2.value = ctx2.max;
|
|
1035
|
+
},
|
|
1036
|
+
setValue(ctx2, evt) {
|
|
1037
|
+
ctx2.value = utils.convert(ctx2, evt.value);
|
|
1038
|
+
}
|
|
1030
1039
|
}
|
|
1031
1040
|
}
|
|
1032
|
-
|
|
1041
|
+
);
|
|
1033
1042
|
}
|
|
1034
1043
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1035
1044
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -37,9 +37,6 @@ function getDocument(el) {
|
|
|
37
37
|
return el;
|
|
38
38
|
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
39
39
|
}
|
|
40
|
-
function getWindow(el) {
|
|
41
|
-
return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
|
|
42
|
-
}
|
|
43
40
|
function defineDomHelpers(helpers) {
|
|
44
41
|
const dom2 = {
|
|
45
42
|
getRootNode: (ctx) => {
|
|
@@ -66,46 +63,6 @@ var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
|
66
63
|
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
67
64
|
var isLeftClick = (v) => v.button === 0;
|
|
68
65
|
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
69
|
-
function observeAttributes(node, attributes, fn) {
|
|
70
|
-
if (!node)
|
|
71
|
-
return;
|
|
72
|
-
const attrs = Array.isArray(attributes) ? attributes : [attributes];
|
|
73
|
-
const win = node.ownerDocument.defaultView || window;
|
|
74
|
-
const obs = new win.MutationObserver((changes) => {
|
|
75
|
-
for (const change of changes) {
|
|
76
|
-
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
|
|
77
|
-
fn(change);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
obs.observe(node, { attributes: true, attributeFilter: attrs });
|
|
82
|
-
return () => obs.disconnect();
|
|
83
|
-
}
|
|
84
|
-
function getClosestForm(el) {
|
|
85
|
-
if (isFormElement(el))
|
|
86
|
-
return el.form;
|
|
87
|
-
else
|
|
88
|
-
return el.closest("form");
|
|
89
|
-
}
|
|
90
|
-
function isFormElement(el) {
|
|
91
|
-
return el.matches("textarea, input, select, button");
|
|
92
|
-
}
|
|
93
|
-
function trackFormReset(el, callback) {
|
|
94
|
-
if (!el)
|
|
95
|
-
return;
|
|
96
|
-
const form = getClosestForm(el);
|
|
97
|
-
form == null ? void 0 : form.addEventListener("reset", callback, { passive: true });
|
|
98
|
-
return () => {
|
|
99
|
-
form == null ? void 0 : form.removeEventListener("reset", callback);
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function trackFieldsetDisabled(el, callback) {
|
|
103
|
-
const fieldset = el == null ? void 0 : el.closest("fieldset");
|
|
104
|
-
if (!fieldset)
|
|
105
|
-
return;
|
|
106
|
-
callback(fieldset.disabled);
|
|
107
|
-
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
|
|
108
|
-
}
|
|
109
66
|
function getElementOffset(element) {
|
|
110
67
|
let left = 0;
|
|
111
68
|
let top = 0;
|
|
@@ -144,28 +101,9 @@ function getPointRelativeToNode(point, element) {
|
|
|
144
101
|
const y = point.y - offset.top;
|
|
145
102
|
return { x, y };
|
|
146
103
|
}
|
|
147
|
-
function getDescriptor(el, options) {
|
|
148
|
-
const { type, property } = options;
|
|
149
|
-
const proto = getWindow(el)[type].prototype;
|
|
150
|
-
return Object.getOwnPropertyDescriptor(proto, property) ?? {};
|
|
151
|
-
}
|
|
152
|
-
function dispatchInputValueEvent(el, value) {
|
|
153
|
-
var _a;
|
|
154
|
-
if (!el)
|
|
155
|
-
return;
|
|
156
|
-
const win = getWindow(el);
|
|
157
|
-
if (!(el instanceof win.HTMLInputElement))
|
|
158
|
-
return;
|
|
159
|
-
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
160
|
-
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
161
|
-
const event = new win.Event("input", { bubbles: true });
|
|
162
|
-
el.dispatchEvent(event);
|
|
163
|
-
}
|
|
164
104
|
var rtlKeyMap = {
|
|
165
105
|
ArrowLeft: "ArrowRight",
|
|
166
|
-
ArrowRight: "ArrowLeft"
|
|
167
|
-
Home: "End",
|
|
168
|
-
End: "Home"
|
|
106
|
+
ArrowRight: "ArrowLeft"
|
|
169
107
|
};
|
|
170
108
|
var sameKeyMap = {
|
|
171
109
|
Up: "ArrowUp",
|
|
@@ -339,7 +277,75 @@ function trackPointerMove(doc, opts) {
|
|
|
339
277
|
}
|
|
340
278
|
onPointerMove(info, event);
|
|
341
279
|
};
|
|
342
|
-
return callAll(
|
|
280
|
+
return callAll(
|
|
281
|
+
addPointerEvent(doc, "pointermove", handlePointerMove, false),
|
|
282
|
+
addPointerEvent(doc, "pointerup", onPointerUp, false),
|
|
283
|
+
addPointerEvent(doc, "pointercancel", onPointerUp, false),
|
|
284
|
+
addPointerEvent(doc, "contextmenu", onPointerUp, false),
|
|
285
|
+
disableTextSelection({ doc })
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// ../../utilities/form-utils/dist/index.mjs
|
|
290
|
+
function getWindow(el) {
|
|
291
|
+
return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
|
|
292
|
+
}
|
|
293
|
+
function observeAttributes(node, attributes, fn) {
|
|
294
|
+
if (!node)
|
|
295
|
+
return;
|
|
296
|
+
const attrs = Array.isArray(attributes) ? attributes : [attributes];
|
|
297
|
+
const win = node.ownerDocument.defaultView || window;
|
|
298
|
+
const obs = new win.MutationObserver((changes) => {
|
|
299
|
+
for (const change of changes) {
|
|
300
|
+
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
|
|
301
|
+
fn(change);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
obs.observe(node, { attributes: true, attributeFilter: attrs });
|
|
306
|
+
return () => obs.disconnect();
|
|
307
|
+
}
|
|
308
|
+
function getDescriptor(el, options) {
|
|
309
|
+
const { type, property } = options;
|
|
310
|
+
const proto = getWindow(el)[type].prototype;
|
|
311
|
+
return Object.getOwnPropertyDescriptor(proto, property) ?? {};
|
|
312
|
+
}
|
|
313
|
+
function dispatchInputValueEvent(el, value) {
|
|
314
|
+
var _a;
|
|
315
|
+
if (!el)
|
|
316
|
+
return;
|
|
317
|
+
const win = getWindow(el);
|
|
318
|
+
if (!(el instanceof win.HTMLInputElement))
|
|
319
|
+
return;
|
|
320
|
+
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
321
|
+
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
322
|
+
const event = new win.Event("input", { bubbles: true });
|
|
323
|
+
el.dispatchEvent(event);
|
|
324
|
+
}
|
|
325
|
+
function getClosestForm(el) {
|
|
326
|
+
if (isFormElement(el))
|
|
327
|
+
return el.form;
|
|
328
|
+
else
|
|
329
|
+
return el.closest("form");
|
|
330
|
+
}
|
|
331
|
+
function isFormElement(el) {
|
|
332
|
+
return el.matches("textarea, input, select, button");
|
|
333
|
+
}
|
|
334
|
+
function trackFormReset(el, callback) {
|
|
335
|
+
if (!el)
|
|
336
|
+
return;
|
|
337
|
+
const form = getClosestForm(el);
|
|
338
|
+
form == null ? void 0 : form.addEventListener("reset", callback, { passive: true });
|
|
339
|
+
return () => {
|
|
340
|
+
form == null ? void 0 : form.removeEventListener("reset", callback);
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function trackFieldsetDisabled(el, callback) {
|
|
344
|
+
const fieldset = el == null ? void 0 : el.closest("fieldset");
|
|
345
|
+
if (!fieldset)
|
|
346
|
+
return;
|
|
347
|
+
callback(fieldset.disabled);
|
|
348
|
+
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
|
|
343
349
|
}
|
|
344
350
|
|
|
345
351
|
// ../../utilities/number/dist/index.mjs
|
|
@@ -801,207 +807,210 @@ function connect(state2, send, normalize) {
|
|
|
801
807
|
|
|
802
808
|
// src/slider.machine.ts
|
|
803
809
|
import { createMachine } from "@zag-js/core";
|
|
810
|
+
import { trackElementSize } from "@zag-js/element-size";
|
|
804
811
|
function machine(ctx) {
|
|
805
|
-
return createMachine(
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
computed: {
|
|
824
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
825
|
-
isVertical: (ctx2) => ctx2.orientation === "vertical",
|
|
826
|
-
isRtl: (ctx2) => ctx2.orientation === "horizontal" && ctx2.dir === "rtl",
|
|
827
|
-
isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readonly),
|
|
828
|
-
hasMeasuredThumbSize: (ctx2) => ctx2.thumbSize !== null
|
|
829
|
-
},
|
|
830
|
-
watch: {
|
|
831
|
-
value: ["invokeOnChange", "dispatchChangeEvent"]
|
|
832
|
-
},
|
|
833
|
-
activities: ["trackFormReset", "trackFieldsetDisabled"],
|
|
834
|
-
on: {
|
|
835
|
-
SET_VALUE: {
|
|
836
|
-
actions: "setValue"
|
|
812
|
+
return createMachine(
|
|
813
|
+
{
|
|
814
|
+
id: "slider",
|
|
815
|
+
initial: "unknown",
|
|
816
|
+
context: {
|
|
817
|
+
thumbSize: null,
|
|
818
|
+
thumbAlignment: "contain",
|
|
819
|
+
disabled: false,
|
|
820
|
+
threshold: 5,
|
|
821
|
+
dir: "ltr",
|
|
822
|
+
origin: "start",
|
|
823
|
+
orientation: "horizontal",
|
|
824
|
+
initialValue: null,
|
|
825
|
+
value: 0,
|
|
826
|
+
step: 1,
|
|
827
|
+
min: 0,
|
|
828
|
+
max: 100,
|
|
829
|
+
...ctx
|
|
837
830
|
},
|
|
838
|
-
|
|
839
|
-
|
|
831
|
+
computed: {
|
|
832
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
833
|
+
isVertical: (ctx2) => ctx2.orientation === "vertical",
|
|
834
|
+
isRtl: (ctx2) => ctx2.orientation === "horizontal" && ctx2.dir === "rtl",
|
|
835
|
+
isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readonly),
|
|
836
|
+
hasMeasuredThumbSize: (ctx2) => ctx2.thumbSize !== null
|
|
840
837
|
},
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
}
|
|
844
|
-
},
|
|
845
|
-
states: {
|
|
846
|
-
unknown: {
|
|
847
|
-
on: {
|
|
848
|
-
SETUP: {
|
|
849
|
-
target: "idle",
|
|
850
|
-
actions: ["setThumbSize", "checkValue"]
|
|
851
|
-
}
|
|
852
|
-
}
|
|
838
|
+
watch: {
|
|
839
|
+
value: ["invokeOnChange", "dispatchChangeEvent"]
|
|
853
840
|
},
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
841
|
+
activities: ["trackFormReset", "trackFieldsetDisabled", "trackThumbSize"],
|
|
842
|
+
on: {
|
|
843
|
+
SET_VALUE: {
|
|
844
|
+
actions: "setValue"
|
|
845
|
+
},
|
|
846
|
+
INCREMENT: {
|
|
847
|
+
actions: "increment"
|
|
848
|
+
},
|
|
849
|
+
DECREMENT: {
|
|
850
|
+
actions: "decrement"
|
|
861
851
|
}
|
|
862
852
|
},
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
ARROW_LEFT: {
|
|
871
|
-
guard: "isHorizontal",
|
|
872
|
-
actions: "decrement"
|
|
873
|
-
},
|
|
874
|
-
ARROW_RIGHT: {
|
|
875
|
-
guard: "isHorizontal",
|
|
876
|
-
actions: "increment"
|
|
877
|
-
},
|
|
878
|
-
ARROW_UP: {
|
|
879
|
-
guard: "isVertical",
|
|
880
|
-
actions: "increment"
|
|
881
|
-
},
|
|
882
|
-
ARROW_DOWN: {
|
|
883
|
-
guard: "isVertical",
|
|
884
|
-
actions: "decrement"
|
|
885
|
-
},
|
|
886
|
-
PAGE_UP: {
|
|
887
|
-
actions: "increment"
|
|
888
|
-
},
|
|
889
|
-
PAGE_DOWN: {
|
|
890
|
-
actions: "decrement"
|
|
891
|
-
},
|
|
892
|
-
HOME: {
|
|
893
|
-
actions: "setToMin"
|
|
894
|
-
},
|
|
895
|
-
END: {
|
|
896
|
-
actions: "setToMax"
|
|
897
|
-
},
|
|
898
|
-
BLUR: "idle"
|
|
899
|
-
}
|
|
900
|
-
},
|
|
901
|
-
dragging: {
|
|
902
|
-
entry: "focusThumb",
|
|
903
|
-
activities: "trackPointerMove",
|
|
904
|
-
on: {
|
|
905
|
-
POINTER_UP: {
|
|
906
|
-
target: "focus",
|
|
907
|
-
actions: "invokeOnChangeEnd"
|
|
908
|
-
},
|
|
909
|
-
POINTER_MOVE: {
|
|
910
|
-
actions: "setPointerValue"
|
|
853
|
+
states: {
|
|
854
|
+
unknown: {
|
|
855
|
+
on: {
|
|
856
|
+
SETUP: {
|
|
857
|
+
target: "idle",
|
|
858
|
+
actions: ["checkValue"]
|
|
859
|
+
}
|
|
911
860
|
}
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
activities: {
|
|
921
|
-
trackFieldsetDisabled(ctx2) {
|
|
922
|
-
return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
923
|
-
if (disabled) {
|
|
924
|
-
ctx2.disabled = disabled;
|
|
861
|
+
},
|
|
862
|
+
idle: {
|
|
863
|
+
on: {
|
|
864
|
+
POINTER_DOWN: {
|
|
865
|
+
target: "dragging",
|
|
866
|
+
actions: ["setPointerValue", "invokeOnChangeStart", "focusThumb"]
|
|
867
|
+
},
|
|
868
|
+
FOCUS: "focus"
|
|
925
869
|
}
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
870
|
+
},
|
|
871
|
+
focus: {
|
|
872
|
+
entry: "focusThumb",
|
|
873
|
+
on: {
|
|
874
|
+
POINTER_DOWN: {
|
|
875
|
+
target: "dragging",
|
|
876
|
+
actions: ["setPointerValue", "invokeOnChangeStart", "focusThumb"]
|
|
877
|
+
},
|
|
878
|
+
ARROW_LEFT: {
|
|
879
|
+
guard: "isHorizontal",
|
|
880
|
+
actions: "decrement"
|
|
881
|
+
},
|
|
882
|
+
ARROW_RIGHT: {
|
|
883
|
+
guard: "isHorizontal",
|
|
884
|
+
actions: "increment"
|
|
885
|
+
},
|
|
886
|
+
ARROW_UP: {
|
|
887
|
+
guard: "isVertical",
|
|
888
|
+
actions: "increment"
|
|
889
|
+
},
|
|
890
|
+
ARROW_DOWN: {
|
|
891
|
+
guard: "isVertical",
|
|
892
|
+
actions: "decrement"
|
|
893
|
+
},
|
|
894
|
+
PAGE_UP: {
|
|
895
|
+
actions: "increment"
|
|
896
|
+
},
|
|
897
|
+
PAGE_DOWN: {
|
|
898
|
+
actions: "decrement"
|
|
899
|
+
},
|
|
900
|
+
HOME: {
|
|
901
|
+
actions: "setToMin"
|
|
902
|
+
},
|
|
903
|
+
END: {
|
|
904
|
+
actions: "setToMax"
|
|
905
|
+
},
|
|
906
|
+
BLUR: "idle"
|
|
932
907
|
}
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
908
|
+
},
|
|
909
|
+
dragging: {
|
|
910
|
+
entry: "focusThumb",
|
|
911
|
+
activities: "trackPointerMove",
|
|
912
|
+
on: {
|
|
913
|
+
POINTER_UP: {
|
|
914
|
+
target: "focus",
|
|
915
|
+
actions: "invokeOnChangeEnd"
|
|
916
|
+
},
|
|
917
|
+
POINTER_MOVE: {
|
|
918
|
+
actions: "setPointerValue"
|
|
919
|
+
}
|
|
942
920
|
}
|
|
943
|
-
}
|
|
921
|
+
}
|
|
944
922
|
}
|
|
945
923
|
},
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
},
|
|
951
|
-
invokeOnChangeStart(ctx2) {
|
|
952
|
-
var _a;
|
|
953
|
-
(_a = ctx2.onChangeStart) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
954
|
-
},
|
|
955
|
-
invokeOnChangeEnd(ctx2) {
|
|
956
|
-
var _a;
|
|
957
|
-
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
958
|
-
},
|
|
959
|
-
invokeOnChange(ctx2) {
|
|
960
|
-
var _a;
|
|
961
|
-
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
924
|
+
{
|
|
925
|
+
guards: {
|
|
926
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
927
|
+
isVertical: (ctx2) => ctx2.isVertical
|
|
962
928
|
},
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
929
|
+
activities: {
|
|
930
|
+
trackFieldsetDisabled(ctx2) {
|
|
931
|
+
return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
932
|
+
if (disabled) {
|
|
933
|
+
ctx2.disabled = disabled;
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
},
|
|
937
|
+
trackFormReset(ctx2) {
|
|
938
|
+
return trackFormReset(dom.getInputEl(ctx2), () => {
|
|
939
|
+
if (ctx2.initialValue != null) {
|
|
940
|
+
ctx2.value = ctx2.initialValue;
|
|
941
|
+
}
|
|
942
|
+
});
|
|
943
|
+
},
|
|
944
|
+
trackPointerMove(ctx2, _evt, { send }) {
|
|
945
|
+
return trackPointerMove(dom.getDoc(ctx2), {
|
|
946
|
+
onPointerMove(info) {
|
|
947
|
+
send({ type: "POINTER_MOVE", point: info.point });
|
|
948
|
+
},
|
|
949
|
+
onPointerUp() {
|
|
950
|
+
send("POINTER_UP");
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
},
|
|
954
|
+
trackThumbSize(ctx2, _evt) {
|
|
955
|
+
if (ctx2.thumbAlignment !== "contain")
|
|
972
956
|
return;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
if (value == null)
|
|
979
|
-
return;
|
|
980
|
-
ctx2.value = utils.clamp(ctx2, value);
|
|
957
|
+
return trackElementSize(dom.getThumbEl(ctx2), (size) => {
|
|
958
|
+
if (size)
|
|
959
|
+
ctx2.thumbSize = size;
|
|
960
|
+
});
|
|
961
|
+
}
|
|
981
962
|
},
|
|
982
|
-
|
|
983
|
-
|
|
963
|
+
actions: {
|
|
964
|
+
checkValue(ctx2) {
|
|
965
|
+
const value = utils.convert(ctx2, ctx2.value);
|
|
966
|
+
ctx2.value = value;
|
|
967
|
+
ctx2.initialValue = value;
|
|
968
|
+
},
|
|
969
|
+
invokeOnChangeStart(ctx2) {
|
|
984
970
|
var _a;
|
|
985
|
-
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
ctx2
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
ctx2
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
971
|
+
(_a = ctx2.onChangeStart) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
972
|
+
},
|
|
973
|
+
invokeOnChangeEnd(ctx2) {
|
|
974
|
+
var _a;
|
|
975
|
+
(_a = ctx2.onChangeEnd) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
976
|
+
},
|
|
977
|
+
invokeOnChange(ctx2) {
|
|
978
|
+
var _a;
|
|
979
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
980
|
+
},
|
|
981
|
+
dispatchChangeEvent(ctx2) {
|
|
982
|
+
dom.dispatchChangeEvent(ctx2);
|
|
983
|
+
},
|
|
984
|
+
setPointerValue(ctx2, evt) {
|
|
985
|
+
const value = dom.getValueFromPoint(ctx2, evt.point);
|
|
986
|
+
if (value == null)
|
|
987
|
+
return;
|
|
988
|
+
ctx2.value = utils.clamp(ctx2, value);
|
|
989
|
+
},
|
|
990
|
+
focusThumb(ctx2) {
|
|
991
|
+
raf(() => {
|
|
992
|
+
var _a;
|
|
993
|
+
return (_a = dom.getThumbEl(ctx2)) == null ? void 0 : _a.focus();
|
|
994
|
+
});
|
|
995
|
+
},
|
|
996
|
+
decrement(ctx2, evt) {
|
|
997
|
+
ctx2.value = utils.decrement(ctx2, evt.step);
|
|
998
|
+
},
|
|
999
|
+
increment(ctx2, evt) {
|
|
1000
|
+
ctx2.value = utils.increment(ctx2, evt.step);
|
|
1001
|
+
},
|
|
1002
|
+
setToMin(ctx2) {
|
|
1003
|
+
ctx2.value = ctx2.min;
|
|
1004
|
+
},
|
|
1005
|
+
setToMax(ctx2) {
|
|
1006
|
+
ctx2.value = ctx2.max;
|
|
1007
|
+
},
|
|
1008
|
+
setValue(ctx2, evt) {
|
|
1009
|
+
ctx2.value = utils.convert(ctx2, evt.value);
|
|
1010
|
+
}
|
|
1002
1011
|
}
|
|
1003
1012
|
}
|
|
1004
|
-
|
|
1013
|
+
);
|
|
1005
1014
|
}
|
|
1006
1015
|
export {
|
|
1007
1016
|
connect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/slider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Core logic for the slider widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,13 +29,14 @@
|
|
|
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.10",
|
|
33
|
+
"@zag-js/element-size": "0.2.1",
|
|
34
|
+
"@zag-js/types": "0.2.5"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@zag-js/dom-utils": "0.1.
|
|
37
|
-
"@zag-js/
|
|
38
|
-
"@zag-js/utils": "0.1.
|
|
37
|
+
"@zag-js/dom-utils": "0.1.11",
|
|
38
|
+
"@zag-js/form-utils": "0.1.1",
|
|
39
|
+
"@zag-js/number-utils": "0.1.4"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build-fast": "tsup src/index.ts --format=esm,cjs",
|