@zag-js/slider 0.1.7 → 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.d.ts +0 -1
- package/dist/index.js +323 -375
- package/dist/index.mjs +323 -376
- package/dist/slider.connect.d.ts +2 -3
- package/dist/slider.dom.d.ts +26 -14
- package/dist/slider.machine.d.ts +2 -3
- package/dist/slider.style.d.ts +23 -0
- package/dist/slider.types.d.ts +14 -4
- package/dist/slider.utils.d.ts +1 -2
- package/package.json +6 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -7
- package/dist/index.mjs.map +0 -7
- package/dist/slider.connect.d.ts.map +0 -1
- package/dist/slider.dom.d.ts.map +0 -1
- package/dist/slider.machine.d.ts.map +0 -1
- package/dist/slider.types.d.ts.map +0 -1
- package/dist/slider.utils.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -19,190 +19,97 @@ 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
|
};
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fn2();
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function raf(fn) {
|
|
40
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
41
|
-
return function cleanup() {
|
|
42
|
-
globalThis.cancelAnimationFrame(id);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
var isDom = () => typeof window !== "undefined";
|
|
42
|
+
var runIfFn = (v, ...a) => {
|
|
43
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
44
|
+
return res != null ? res : void 0;
|
|
45
|
+
};
|
|
46
|
+
var callAll = (...fns) => (...a) => {
|
|
47
|
+
fns.forEach(function(fn) {
|
|
48
|
+
fn == null ? void 0 : fn(...a);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
46
51
|
var isArray = (v) => Array.isArray(v);
|
|
47
52
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
48
53
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
54
|
+
var isDom = () => typeof window !== "undefined";
|
|
49
55
|
function getPlatform() {
|
|
50
56
|
var _a;
|
|
51
57
|
const agent = navigator.userAgentData;
|
|
52
58
|
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
53
59
|
}
|
|
54
60
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
55
|
-
var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
|
|
61
|
+
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
56
62
|
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
57
63
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
58
64
|
var isIos = () => isApple() && !isMac();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
62
|
-
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
63
|
-
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
64
|
-
var isLeftClick = (v) => v.button === 0;
|
|
65
|
-
var runIfFn = (v, ...a) => {
|
|
66
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
67
|
-
return res != null ? res : void 0;
|
|
68
|
-
};
|
|
69
|
-
var noop = () => {
|
|
70
|
-
};
|
|
71
|
-
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
72
|
-
function getListenerElements() {
|
|
73
|
-
;
|
|
74
|
-
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
75
|
-
return globalThis.__listenerElements__;
|
|
65
|
+
function isDocument(el) {
|
|
66
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
76
67
|
}
|
|
77
|
-
function
|
|
78
|
-
;
|
|
79
|
-
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
80
|
-
return globalThis.__listenerCache__;
|
|
68
|
+
function isWindow(value) {
|
|
69
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
81
70
|
}
|
|
82
|
-
function
|
|
71
|
+
function getDocument(el) {
|
|
83
72
|
var _a;
|
|
84
|
-
if (
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const group = listenerElements.get(node);
|
|
90
|
-
if (!listenerElements.has(node)) {
|
|
91
|
-
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
|
|
92
|
-
listenerElements.set(node, group2);
|
|
93
|
-
} else if (group == null ? void 0 : group.has(hash)) {
|
|
94
|
-
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
|
|
95
|
-
} else {
|
|
96
|
-
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
|
|
97
|
-
}
|
|
98
|
-
function attach(node2) {
|
|
99
|
-
var _a2, _b;
|
|
100
|
-
function listener(event) {
|
|
101
|
-
var _a3;
|
|
102
|
-
const group2 = listenerElements.get(node2);
|
|
103
|
-
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
104
|
-
}
|
|
105
|
-
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
106
|
-
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
|
|
107
|
-
node2.addEventListener(type, listener, options);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
|
|
111
|
-
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
|
|
112
|
-
node2.addEventListener(type, listener, options);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
attach(node);
|
|
116
|
-
return function remove() {
|
|
117
|
-
var _a2, _b, _c, _d;
|
|
118
|
-
if (!listenerElements.has(node))
|
|
119
|
-
return;
|
|
120
|
-
const group2 = listenerElements.get(node);
|
|
121
|
-
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
122
|
-
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
123
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
124
|
-
node.removeEventListener(type, listener, options);
|
|
125
|
-
group2 == null ? void 0 : group2.delete(hash);
|
|
126
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
127
|
-
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
128
|
-
listenerElements.delete(node);
|
|
129
|
-
listenerCache.delete(node);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
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;
|
|
133
78
|
}
|
|
134
|
-
|
|
135
|
-
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
136
|
-
function extractInfo(event, type = "page") {
|
|
137
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
|
|
138
|
-
return {
|
|
139
|
-
point: {
|
|
140
|
-
x: point[`${type}X`],
|
|
141
|
-
y: point[`${type}Y`]
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function addDomEvent(target, event, listener, options) {
|
|
146
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
147
|
-
return addGlobalEventListener(node, event, listener, options);
|
|
148
|
-
}
|
|
149
|
-
function addPointerEvent(target, event, listener, options) {
|
|
79
|
+
function getWindow(el) {
|
|
150
80
|
var _a;
|
|
151
|
-
|
|
152
|
-
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
153
|
-
}
|
|
154
|
-
function wrapHandler(fn, filter = false) {
|
|
155
|
-
const listener = (event) => {
|
|
156
|
-
fn(event, extractInfo(event));
|
|
157
|
-
};
|
|
158
|
-
return filter ? filterPrimaryPointer(listener) : listener;
|
|
81
|
+
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
159
82
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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)
|
|
168
96
|
};
|
|
169
|
-
}
|
|
170
|
-
var mouseEventNames = {
|
|
171
|
-
pointerdown: "mousedown",
|
|
172
|
-
pointermove: "mousemove",
|
|
173
|
-
pointerup: "mouseup",
|
|
174
|
-
pointercancel: "mousecancel",
|
|
175
|
-
pointerover: "mouseover",
|
|
176
|
-
pointerout: "mouseout",
|
|
177
|
-
pointerenter: "mouseenter",
|
|
178
|
-
pointerleave: "mouseleave"
|
|
179
|
-
};
|
|
180
|
-
var touchEventNames = {
|
|
181
|
-
pointerdown: "touchstart",
|
|
182
|
-
pointermove: "touchmove",
|
|
183
|
-
pointerup: "touchend",
|
|
184
|
-
pointercancel: "touchcancel"
|
|
185
|
-
};
|
|
186
|
-
function getEventName(evt) {
|
|
187
|
-
if (supportsPointerEvent())
|
|
188
|
-
return evt;
|
|
189
|
-
if (supportsTouchEvent())
|
|
190
|
-
return touchEventNames[evt];
|
|
191
|
-
if (supportsMouseEvent())
|
|
192
|
-
return mouseEventNames[evt];
|
|
193
|
-
return evt;
|
|
194
|
-
}
|
|
195
|
-
function getOwnerWindow(el) {
|
|
196
|
-
var _a;
|
|
197
|
-
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
97
|
+
return __spreadValues2(__spreadValues2({}, dom2), helpers);
|
|
198
98
|
}
|
|
199
99
|
function getNativeEvent(e) {
|
|
200
100
|
var _a;
|
|
201
101
|
return (_a = e.nativeEvent) != null ? _a : e;
|
|
202
102
|
}
|
|
103
|
+
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
104
|
+
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
105
|
+
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
106
|
+
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
107
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
108
|
+
var isLeftClick = (v) => v.button === 0;
|
|
109
|
+
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
203
110
|
function observeAttributes(node, attributes, fn) {
|
|
204
111
|
if (!node)
|
|
205
|
-
return
|
|
112
|
+
return;
|
|
206
113
|
const attrs = Array.isArray(attributes) ? attributes : [attributes];
|
|
207
114
|
const win = node.ownerDocument.defaultView || window;
|
|
208
115
|
const obs = new win.MutationObserver((changes) => {
|
|
@@ -240,20 +147,59 @@ function trackFieldsetDisabled(el, callback) {
|
|
|
240
147
|
callback(fieldset.disabled);
|
|
241
148
|
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
|
|
242
149
|
}
|
|
150
|
+
function getElementOffset(element) {
|
|
151
|
+
let left = 0;
|
|
152
|
+
let top = 0;
|
|
153
|
+
let el = element;
|
|
154
|
+
if (el.parentNode) {
|
|
155
|
+
do {
|
|
156
|
+
left += el.offsetLeft;
|
|
157
|
+
top += el.offsetTop;
|
|
158
|
+
} while ((el = el.offsetParent) && el.nodeType < 9);
|
|
159
|
+
el = element;
|
|
160
|
+
do {
|
|
161
|
+
left -= el.scrollLeft;
|
|
162
|
+
top -= el.scrollTop;
|
|
163
|
+
} while ((el = el.parentNode) && !/body/i.test(el.nodeName));
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
top,
|
|
167
|
+
right: innerWidth - left - element.offsetWidth,
|
|
168
|
+
bottom: innerHeight - top - element.offsetHeight,
|
|
169
|
+
left
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
var fallback = {
|
|
173
|
+
pageX: 0,
|
|
174
|
+
pageY: 0,
|
|
175
|
+
clientX: 0,
|
|
176
|
+
clientY: 0
|
|
177
|
+
};
|
|
178
|
+
function getEventPoint(event, type = "page") {
|
|
179
|
+
var _a, _b;
|
|
180
|
+
const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
|
|
181
|
+
return { x: point[`${type}X`], y: point[`${type}Y`] };
|
|
182
|
+
}
|
|
183
|
+
function getPointRelativeToNode(point, element) {
|
|
184
|
+
const offset = getElementOffset(element);
|
|
185
|
+
const x = point.x - offset.left;
|
|
186
|
+
const y = point.y - offset.top;
|
|
187
|
+
return { x, y };
|
|
188
|
+
}
|
|
243
189
|
function getDescriptor(el, options) {
|
|
244
190
|
var _a;
|
|
245
191
|
const { type, property } = options;
|
|
246
|
-
const
|
|
247
|
-
const _type = type === "input" ? "HTMLInputElement" : "HTMLTextAreaElement";
|
|
248
|
-
const proto = win[_type].prototype;
|
|
192
|
+
const proto = getWindow(el)[type].prototype;
|
|
249
193
|
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
250
194
|
}
|
|
251
195
|
function dispatchInputValueEvent(el, value) {
|
|
252
196
|
var _a;
|
|
253
|
-
|
|
197
|
+
if (!el)
|
|
198
|
+
return;
|
|
199
|
+
const win = getWindow(el);
|
|
254
200
|
if (!(el instanceof win.HTMLInputElement))
|
|
255
201
|
return;
|
|
256
|
-
const desc = getDescriptor(el, { type: "
|
|
202
|
+
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
257
203
|
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
258
204
|
const event = new win.Event("input", { bubbles: true });
|
|
259
205
|
el.dispatchEvent(event);
|
|
@@ -295,29 +241,88 @@ function getEventStep(event) {
|
|
|
295
241
|
return isSkipKey ? 10 : 1;
|
|
296
242
|
}
|
|
297
243
|
}
|
|
298
|
-
|
|
299
|
-
|
|
244
|
+
var isRef = (v) => hasProp(v, "current");
|
|
245
|
+
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
246
|
+
function extractInfo(event, type = "page") {
|
|
247
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
248
|
+
return {
|
|
249
|
+
point: {
|
|
250
|
+
x: point[`${type}X`],
|
|
251
|
+
y: point[`${type}Y`]
|
|
252
|
+
}
|
|
253
|
+
};
|
|
300
254
|
}
|
|
301
|
-
function
|
|
302
|
-
const
|
|
303
|
-
|
|
255
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
256
|
+
const node = isRef(target) ? target.current : runIfFn(target);
|
|
257
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
258
|
+
return () => {
|
|
259
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
260
|
+
};
|
|
304
261
|
}
|
|
305
|
-
|
|
306
|
-
var _a
|
|
307
|
-
|
|
262
|
+
function addPointerEvent(target, event, listener, options) {
|
|
263
|
+
var _a;
|
|
264
|
+
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
265
|
+
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
266
|
+
}
|
|
267
|
+
function wrapHandler(fn, filter = false) {
|
|
268
|
+
const listener = (event) => {
|
|
269
|
+
fn(event, extractInfo(event));
|
|
270
|
+
};
|
|
271
|
+
return filter ? filterPrimaryPointer(listener) : listener;
|
|
272
|
+
}
|
|
273
|
+
function filterPrimaryPointer(fn) {
|
|
274
|
+
return (event) => {
|
|
275
|
+
var _a;
|
|
276
|
+
const win = (_a = event.view) != null ? _a : window;
|
|
277
|
+
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
278
|
+
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
279
|
+
if (isPrimary)
|
|
280
|
+
fn(event);
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
var mouseEventNames = {
|
|
284
|
+
pointerdown: "mousedown",
|
|
285
|
+
pointermove: "mousemove",
|
|
286
|
+
pointerup: "mouseup",
|
|
287
|
+
pointercancel: "mousecancel",
|
|
288
|
+
pointerover: "mouseover",
|
|
289
|
+
pointerout: "mouseout",
|
|
290
|
+
pointerenter: "mouseenter",
|
|
291
|
+
pointerleave: "mouseleave"
|
|
308
292
|
};
|
|
309
|
-
var
|
|
310
|
-
|
|
311
|
-
|
|
293
|
+
var touchEventNames = {
|
|
294
|
+
pointerdown: "touchstart",
|
|
295
|
+
pointermove: "touchmove",
|
|
296
|
+
pointerup: "touchend",
|
|
297
|
+
pointercancel: "touchcancel"
|
|
312
298
|
};
|
|
313
|
-
function
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
299
|
+
function getEventName(evt) {
|
|
300
|
+
if (supportsPointerEvent())
|
|
301
|
+
return evt;
|
|
302
|
+
if (supportsTouchEvent())
|
|
303
|
+
return touchEventNames[evt];
|
|
304
|
+
if (supportsMouseEvent())
|
|
305
|
+
return mouseEventNames[evt];
|
|
306
|
+
return evt;
|
|
307
|
+
}
|
|
308
|
+
function nextTick(fn) {
|
|
309
|
+
const set = /* @__PURE__ */ new Set();
|
|
310
|
+
function raf2(fn2) {
|
|
311
|
+
const id = globalThis.requestAnimationFrame(fn2);
|
|
312
|
+
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
319
313
|
}
|
|
320
|
-
|
|
314
|
+
raf2(() => raf2(fn));
|
|
315
|
+
return function cleanup() {
|
|
316
|
+
set.forEach(function(fn2) {
|
|
317
|
+
fn2();
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function raf(fn) {
|
|
322
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
323
|
+
return function cleanup() {
|
|
324
|
+
globalThis.cancelAnimationFrame(id);
|
|
325
|
+
};
|
|
321
326
|
}
|
|
322
327
|
var state = "default";
|
|
323
328
|
var savedUserSelect = "";
|
|
@@ -380,36 +385,8 @@ function trackPointerMove(opts) {
|
|
|
380
385
|
}
|
|
381
386
|
onPointerMove(info, event);
|
|
382
387
|
};
|
|
383
|
-
return
|
|
388
|
+
return callAll(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
|
|
384
389
|
}
|
|
385
|
-
function findByTypeahead(_items, options) {
|
|
386
|
-
const { state: state2, activeId, key, timeout = 350 } = options;
|
|
387
|
-
const search = state2.keysSoFar + key;
|
|
388
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
389
|
-
const query2 = isRepeated ? search[0] : search;
|
|
390
|
-
let items = _items.slice();
|
|
391
|
-
const next = findByText(items, query2, activeId);
|
|
392
|
-
function cleanup() {
|
|
393
|
-
clearTimeout(state2.timer);
|
|
394
|
-
state2.timer = -1;
|
|
395
|
-
}
|
|
396
|
-
function update(value) {
|
|
397
|
-
state2.keysSoFar = value;
|
|
398
|
-
cleanup();
|
|
399
|
-
if (value !== "") {
|
|
400
|
-
state2.timer = +setTimeout(() => {
|
|
401
|
-
update("");
|
|
402
|
-
cleanup();
|
|
403
|
-
}, timeout);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
update(search);
|
|
407
|
-
return next;
|
|
408
|
-
}
|
|
409
|
-
findByTypeahead.defaultOptions = {
|
|
410
|
-
keysSoFar: "",
|
|
411
|
-
timer: -1
|
|
412
|
-
};
|
|
413
390
|
|
|
414
391
|
// ../../utilities/number/dist/index.mjs
|
|
415
392
|
var __pow2 = Math.pow;
|
|
@@ -471,50 +448,7 @@ var transform = (a, b) => {
|
|
|
471
448
|
};
|
|
472
449
|
};
|
|
473
450
|
|
|
474
|
-
//
|
|
475
|
-
var isDom2 = () => typeof window !== "undefined";
|
|
476
|
-
var isArray2 = (v) => Array.isArray(v);
|
|
477
|
-
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
|
|
478
|
-
var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
479
|
-
var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
|
|
480
|
-
var isTouchEvent2 = (v) => isObject2(v) && hasProp2(v, "touches");
|
|
481
|
-
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
482
|
-
function getEventPoint(e, t = "page") {
|
|
483
|
-
const p = isTouchEvent2(e) ? e.touches[0] || e.changedTouches[0] || fallback2 : e;
|
|
484
|
-
return { x: p[`${t}X`], y: p[`${t}Y`] };
|
|
485
|
-
}
|
|
486
|
-
function relativeToNode(p, el) {
|
|
487
|
-
const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft;
|
|
488
|
-
const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop;
|
|
489
|
-
return {
|
|
490
|
-
point: { x: dx, y: dy },
|
|
491
|
-
progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight }
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
// src/slider.utils.ts
|
|
496
|
-
var utils = {
|
|
497
|
-
fromPercent(ctx, percent) {
|
|
498
|
-
percent = clamp(percent, { min: 0, max: 1 });
|
|
499
|
-
return parseFloat(snapToStep(percentToValue(percent, ctx), ctx.step));
|
|
500
|
-
},
|
|
501
|
-
clamp(ctx, value) {
|
|
502
|
-
return clamp(value, ctx);
|
|
503
|
-
},
|
|
504
|
-
convert(ctx, value) {
|
|
505
|
-
return clamp(parseFloat(snapToStep(value, ctx.step)), ctx);
|
|
506
|
-
},
|
|
507
|
-
decrement(ctx, step) {
|
|
508
|
-
let value = decrement(ctx.value, step != null ? step : ctx.step);
|
|
509
|
-
return utils.convert(ctx, value);
|
|
510
|
-
},
|
|
511
|
-
increment(ctx, step) {
|
|
512
|
-
let value = increment(ctx.value, step != null ? step : ctx.step);
|
|
513
|
-
return utils.convert(ctx, value);
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
// src/slider.dom.ts
|
|
451
|
+
// src/slider.style.ts
|
|
518
452
|
function getVerticalThumbOffset(ctx) {
|
|
519
453
|
var _a;
|
|
520
454
|
const { height = 0 } = (_a = ctx.thumbSize) != null ? _a : {};
|
|
@@ -531,109 +465,165 @@ function getHorizontalThumbOffset(ctx) {
|
|
|
531
465
|
const getValue = transform([ctx.min, ctx.max], [-width / 2, width / 2]);
|
|
532
466
|
return parseFloat(getValue(ctx.value).toFixed(2));
|
|
533
467
|
}
|
|
534
|
-
function
|
|
468
|
+
function getThumbOffset(ctx) {
|
|
535
469
|
const percent = valueToPercent(ctx.value, ctx);
|
|
470
|
+
if (ctx.thumbAlignment === "center")
|
|
471
|
+
return `${percent}%`;
|
|
536
472
|
const offset = ctx.isVertical ? getVerticalThumbOffset(ctx) : getHorizontalThumbOffset(ctx);
|
|
537
|
-
|
|
473
|
+
return `calc(${percent}% - ${offset}px)`;
|
|
474
|
+
}
|
|
475
|
+
function getThumbStyle(ctx) {
|
|
476
|
+
const placementProp = ctx.isVertical ? "bottom" : ctx.isRtl ? "right" : "left";
|
|
477
|
+
return {
|
|
538
478
|
visibility: ctx.hasMeasuredThumbSize ? "visible" : "hidden",
|
|
539
479
|
position: "absolute",
|
|
540
480
|
transform: "var(--slider-thumb-transform)",
|
|
541
|
-
"--slider-thumb-
|
|
481
|
+
[placementProp]: "var(--slider-thumb-offset)"
|
|
542
482
|
};
|
|
543
|
-
if (ctx.isVertical) {
|
|
544
|
-
style.bottom = "var(--slider-thumb-placement)";
|
|
545
|
-
} else {
|
|
546
|
-
style[ctx.isRtl ? "right" : "left"] = "var(--slider-thumb-placement)";
|
|
547
|
-
}
|
|
548
|
-
return style;
|
|
549
483
|
}
|
|
550
|
-
function
|
|
484
|
+
function getRangeOffsets(ctx) {
|
|
551
485
|
const percent = valueToPercent(ctx.value, ctx);
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
};
|
|
555
|
-
let startValue = "0%";
|
|
556
|
-
let endValue = `${100 - percent}%`;
|
|
486
|
+
let start = "0%";
|
|
487
|
+
let end = `${100 - percent}%`;
|
|
557
488
|
if (ctx.origin === "center") {
|
|
558
489
|
const isNegative = percent < 50;
|
|
559
|
-
|
|
560
|
-
|
|
490
|
+
start = isNegative ? `${percent}%` : "50%";
|
|
491
|
+
end = isNegative ? "50%" : end;
|
|
561
492
|
}
|
|
493
|
+
return { start, end };
|
|
494
|
+
}
|
|
495
|
+
function getRangeStyle(ctx) {
|
|
562
496
|
if (ctx.isVertical) {
|
|
563
|
-
return
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
497
|
+
return {
|
|
498
|
+
position: "absolute",
|
|
499
|
+
bottom: "var(--slider-range-start)",
|
|
500
|
+
top: "var(--slider-range-end)"
|
|
501
|
+
};
|
|
567
502
|
}
|
|
568
|
-
return
|
|
569
|
-
|
|
570
|
-
[ctx.isRtl ? "
|
|
571
|
-
|
|
503
|
+
return {
|
|
504
|
+
position: "absolute",
|
|
505
|
+
[ctx.isRtl ? "right" : "left"]: "var(--slider-range-start)",
|
|
506
|
+
[ctx.isRtl ? "left" : "right"]: "var(--slider-range-end)"
|
|
507
|
+
};
|
|
572
508
|
}
|
|
573
|
-
function getControlStyle(
|
|
509
|
+
function getControlStyle() {
|
|
574
510
|
return {
|
|
575
511
|
touchAction: "none",
|
|
576
512
|
userSelect: "none",
|
|
513
|
+
position: "relative"
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function getRootStyle(ctx) {
|
|
517
|
+
const range = getRangeOffsets(ctx);
|
|
518
|
+
return {
|
|
577
519
|
"--slider-thumb-transform": ctx.isVertical ? "translateY(50%)" : "translateX(-50%)",
|
|
520
|
+
"--slider-thumb-offset": getThumbOffset(ctx),
|
|
521
|
+
"--slider-range-start": range.start,
|
|
522
|
+
"--slider-range-end": range.end
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function getMarkerStyle(ctx, percent) {
|
|
526
|
+
return {
|
|
527
|
+
position: "absolute",
|
|
528
|
+
pointerEvents: "none",
|
|
529
|
+
[ctx.isHorizontal ? "left" : "bottom"]: `${ctx.isRtl ? 100 - percent : percent}%`
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
function getLabelStyle() {
|
|
533
|
+
return { userSelect: "none" };
|
|
534
|
+
}
|
|
535
|
+
function getTrackStyle() {
|
|
536
|
+
return { position: "relative" };
|
|
537
|
+
}
|
|
538
|
+
function getMarkerGroupStyle() {
|
|
539
|
+
return {
|
|
540
|
+
userSelect: "none",
|
|
541
|
+
pointerEvents: "none",
|
|
578
542
|
position: "relative"
|
|
579
543
|
};
|
|
580
544
|
}
|
|
581
|
-
var
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
545
|
+
var styles = {
|
|
546
|
+
getThumbOffset,
|
|
547
|
+
getControlStyle,
|
|
548
|
+
getThumbStyle,
|
|
549
|
+
getRangeStyle,
|
|
550
|
+
getRootStyle,
|
|
551
|
+
getMarkerStyle,
|
|
552
|
+
getLabelStyle,
|
|
553
|
+
getTrackStyle,
|
|
554
|
+
getMarkerGroupStyle
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
// src/slider.utils.ts
|
|
558
|
+
var utils = {
|
|
559
|
+
fromPercent(ctx, percent) {
|
|
560
|
+
percent = clamp(percent, { min: 0, max: 1 });
|
|
561
|
+
return parseFloat(snapToStep(percentToValue(percent, ctx), ctx.step));
|
|
585
562
|
},
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
563
|
+
clamp(ctx, value) {
|
|
564
|
+
return clamp(value, ctx);
|
|
589
565
|
},
|
|
566
|
+
convert(ctx, value) {
|
|
567
|
+
return clamp(parseFloat(snapToStep(value, ctx.step)), ctx);
|
|
568
|
+
},
|
|
569
|
+
decrement(ctx, step) {
|
|
570
|
+
let value = decrement(ctx.value, step != null ? step : ctx.step);
|
|
571
|
+
return utils.convert(ctx, value);
|
|
572
|
+
},
|
|
573
|
+
increment(ctx, step) {
|
|
574
|
+
let value = increment(ctx.value, step != null ? step : ctx.step);
|
|
575
|
+
return utils.convert(ctx, value);
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
// src/slider.dom.ts
|
|
580
|
+
var dom = defineDomHelpers(__spreadProps(__spreadValues({}, styles), {
|
|
590
581
|
getRootId: (ctx) => {
|
|
591
582
|
var _a, _b;
|
|
592
|
-
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}`;
|
|
593
584
|
},
|
|
594
585
|
getThumbId: (ctx) => {
|
|
595
586
|
var _a, _b;
|
|
596
|
-
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`;
|
|
597
588
|
},
|
|
598
589
|
getControlId: (ctx) => {
|
|
599
590
|
var _a, _b;
|
|
600
|
-
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`;
|
|
601
592
|
},
|
|
602
|
-
getInputId: (ctx) => `slider:${ctx.
|
|
593
|
+
getInputId: (ctx) => `slider:${ctx.id}:input`,
|
|
603
594
|
getOutputId: (ctx) => {
|
|
604
595
|
var _a, _b;
|
|
605
|
-
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`;
|
|
606
597
|
},
|
|
607
598
|
getTrackId: (ctx) => {
|
|
608
599
|
var _a, _b;
|
|
609
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider
|
|
600
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.id}track`;
|
|
610
601
|
},
|
|
611
602
|
getRangeId: (ctx) => {
|
|
612
603
|
var _a, _b;
|
|
613
|
-
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`;
|
|
614
605
|
},
|
|
615
606
|
getLabelId: (ctx) => {
|
|
616
607
|
var _a, _b;
|
|
617
|
-
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`;
|
|
618
609
|
},
|
|
619
|
-
getMarkerId: (ctx, value) => `slider:${ctx.
|
|
620
|
-
getRootEl: (ctx) => dom.
|
|
621
|
-
getThumbEl: (ctx) => dom.
|
|
622
|
-
getControlEl: (ctx) => dom.
|
|
623
|
-
getInputEl: (ctx) => dom.
|
|
624
|
-
getControlStyle,
|
|
625
|
-
getThumbStyle,
|
|
626
|
-
getRangeStyle,
|
|
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)),
|
|
627
615
|
getValueFromPoint(ctx, point) {
|
|
628
|
-
const
|
|
629
|
-
if (!
|
|
616
|
+
const el = dom.getControlEl(ctx);
|
|
617
|
+
if (!el)
|
|
630
618
|
return;
|
|
631
|
-
const
|
|
619
|
+
const relativePoint = getPointRelativeToNode(point, el);
|
|
620
|
+
const percentX = relativePoint.x / el.offsetWidth;
|
|
621
|
+
const percentY = relativePoint.y / el.offsetHeight;
|
|
632
622
|
let percent;
|
|
633
623
|
if (ctx.isHorizontal) {
|
|
634
|
-
percent = ctx.isRtl ? 1 -
|
|
624
|
+
percent = ctx.isRtl ? 1 - percentX : percentX;
|
|
635
625
|
} else {
|
|
636
|
-
percent = 1 -
|
|
626
|
+
percent = 1 - percentY;
|
|
637
627
|
}
|
|
638
628
|
return utils.fromPercent(ctx, percent);
|
|
639
629
|
},
|
|
@@ -642,40 +632,11 @@ var dom = {
|
|
|
642
632
|
if (!input)
|
|
643
633
|
return;
|
|
644
634
|
dispatchInputValueEvent(input, ctx.value);
|
|
645
|
-
},
|
|
646
|
-
getMarkerStyle(ctx, percent) {
|
|
647
|
-
const style = {
|
|
648
|
-
position: "absolute",
|
|
649
|
-
pointerEvents: "none"
|
|
650
|
-
};
|
|
651
|
-
if (ctx.isHorizontal) {
|
|
652
|
-
percent = ctx.isRtl ? 100 - percent : percent;
|
|
653
|
-
style.left = `${percent}%`;
|
|
654
|
-
} else {
|
|
655
|
-
style.bottom = `${percent}%`;
|
|
656
|
-
}
|
|
657
|
-
return style;
|
|
658
635
|
}
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
// ../../types/dist/index.mjs
|
|
662
|
-
function createNormalizer(fn) {
|
|
663
|
-
return new Proxy({}, {
|
|
664
|
-
get() {
|
|
665
|
-
return fn;
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
670
|
-
|
|
671
|
-
// ../../utilities/core/dist/index.mjs
|
|
672
|
-
var isDom3 = () => typeof window !== "undefined";
|
|
673
|
-
var isTouchDevice3 = isDom3() && !!navigator.maxTouchPoints;
|
|
674
|
-
var isLeftClick2 = (v) => v.button === 0;
|
|
675
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
636
|
+
}));
|
|
676
637
|
|
|
677
638
|
// src/slider.connect.ts
|
|
678
|
-
function connect(state2, send, normalize
|
|
639
|
+
function connect(state2, send, normalize) {
|
|
679
640
|
var _a, _b;
|
|
680
641
|
const ariaLabel = state2.context["aria-label"];
|
|
681
642
|
const ariaLabelledBy = state2.context["aria-labelledby"];
|
|
@@ -709,14 +670,18 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
709
670
|
rootProps: normalize.element({
|
|
710
671
|
"data-part": "root",
|
|
711
672
|
"data-disabled": dataAttr(isDisabled),
|
|
673
|
+
"data-focus": dataAttr(isFocused),
|
|
712
674
|
"data-orientation": state2.context.orientation,
|
|
675
|
+
"data-invalid": dataAttr(isInvalid),
|
|
713
676
|
id: dom.getRootId(state2.context),
|
|
714
|
-
dir: state2.context.dir
|
|
677
|
+
dir: state2.context.dir,
|
|
678
|
+
style: dom.getRootStyle(state2.context)
|
|
715
679
|
}),
|
|
716
680
|
labelProps: normalize.label({
|
|
717
681
|
"data-part": "label",
|
|
718
682
|
"data-disabled": dataAttr(isDisabled),
|
|
719
683
|
"data-invalid": dataAttr(isInvalid),
|
|
684
|
+
"data-focus": dataAttr(isFocused),
|
|
720
685
|
id: dom.getLabelId(state2.context),
|
|
721
686
|
htmlFor: dom.getInputId(state2.context),
|
|
722
687
|
onClick(event) {
|
|
@@ -726,9 +691,7 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
726
691
|
event.preventDefault();
|
|
727
692
|
(_a2 = dom.getThumbEl(state2.context)) == null ? void 0 : _a2.focus();
|
|
728
693
|
},
|
|
729
|
-
style:
|
|
730
|
-
userSelect: "none"
|
|
731
|
-
}
|
|
694
|
+
style: dom.getLabelStyle()
|
|
732
695
|
}),
|
|
733
696
|
thumbProps: normalize.element({
|
|
734
697
|
"data-part": "thumb",
|
|
@@ -825,14 +788,15 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
825
788
|
"data-part": "track",
|
|
826
789
|
id: dom.getTrackId(state2.context),
|
|
827
790
|
"data-disabled": dataAttr(isDisabled),
|
|
791
|
+
"data-focus": dataAttr(isFocused),
|
|
828
792
|
"data-invalid": dataAttr(isInvalid),
|
|
829
793
|
"data-orientation": state2.context.orientation,
|
|
830
|
-
|
|
831
|
-
style: { position: "relative" }
|
|
794
|
+
style: dom.getTrackStyle()
|
|
832
795
|
}),
|
|
833
796
|
rangeProps: normalize.element({
|
|
834
797
|
"data-part": "range",
|
|
835
798
|
id: dom.getRangeId(state2.context),
|
|
799
|
+
"data-focus": dataAttr(isFocused),
|
|
836
800
|
"data-invalid": dataAttr(isInvalid),
|
|
837
801
|
"data-disabled": dataAttr(isDisabled),
|
|
838
802
|
"data-orientation": state2.context.orientation,
|
|
@@ -849,25 +813,21 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
849
813
|
if (!isInteractive)
|
|
850
814
|
return;
|
|
851
815
|
const evt = getNativeEvent(event);
|
|
852
|
-
if (!
|
|
816
|
+
if (!isLeftClick(evt) || isModifiedEvent(evt))
|
|
853
817
|
return;
|
|
854
818
|
const point = getEventPoint(evt);
|
|
855
819
|
send({ type: "POINTER_DOWN", point });
|
|
856
820
|
event.preventDefault();
|
|
857
821
|
event.stopPropagation();
|
|
858
822
|
},
|
|
859
|
-
style: dom.getControlStyle(
|
|
823
|
+
style: dom.getControlStyle()
|
|
860
824
|
}),
|
|
861
825
|
markerGroupProps: normalize.element({
|
|
862
826
|
"data-part": "marker-group",
|
|
863
827
|
role: "presentation",
|
|
864
828
|
"aria-hidden": true,
|
|
865
829
|
"data-orientation": state2.context.orientation,
|
|
866
|
-
style:
|
|
867
|
-
userSelect: "none",
|
|
868
|
-
pointerEvents: "none",
|
|
869
|
-
position: "relative"
|
|
870
|
-
}
|
|
830
|
+
style: dom.getMarkerGroupStyle()
|
|
871
831
|
}),
|
|
872
832
|
getMarkerProps({ value }) {
|
|
873
833
|
const percent = valueToPercent(value, state2.context);
|
|
@@ -875,6 +835,7 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
875
835
|
const markerState = value > state2.context.value ? "over-value" : value < state2.context.value ? "under-value" : "at-value";
|
|
876
836
|
return normalize.element({
|
|
877
837
|
"data-part": "marker",
|
|
838
|
+
role: "presentation",
|
|
878
839
|
"data-orientation": state2.context.orientation,
|
|
879
840
|
id: dom.getMarkerId(state2.context, value),
|
|
880
841
|
"data-value": value,
|
|
@@ -887,14 +848,14 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
887
848
|
}
|
|
888
849
|
|
|
889
850
|
// src/slider.machine.ts
|
|
890
|
-
import { createMachine
|
|
891
|
-
function machine(ctx
|
|
851
|
+
import { createMachine } from "@zag-js/core";
|
|
852
|
+
function machine(ctx) {
|
|
892
853
|
return createMachine({
|
|
893
854
|
id: "slider",
|
|
894
855
|
initial: "unknown",
|
|
895
856
|
context: __spreadValues({
|
|
896
857
|
thumbSize: null,
|
|
897
|
-
|
|
858
|
+
thumbAlignment: "contain",
|
|
898
859
|
disabled: false,
|
|
899
860
|
threshold: 5,
|
|
900
861
|
dir: "ltr",
|
|
@@ -933,7 +894,7 @@ function machine(ctx = {}) {
|
|
|
933
894
|
on: {
|
|
934
895
|
SETUP: {
|
|
935
896
|
target: "idle",
|
|
936
|
-
actions: ["
|
|
897
|
+
actions: ["setThumbSize", "checkValue"]
|
|
937
898
|
}
|
|
938
899
|
}
|
|
939
900
|
},
|
|
@@ -1005,26 +966,18 @@ function machine(ctx = {}) {
|
|
|
1005
966
|
},
|
|
1006
967
|
activities: {
|
|
1007
968
|
trackFieldsetDisabled(ctx2) {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
ctx2.disabled = disabled;
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
969
|
+
return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
970
|
+
if (disabled) {
|
|
971
|
+
ctx2.disabled = disabled;
|
|
972
|
+
}
|
|
1015
973
|
});
|
|
1016
|
-
return () => cleanup == null ? void 0 : cleanup();
|
|
1017
974
|
},
|
|
1018
975
|
trackFormReset(ctx2) {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
ctx2.value = ctx2.initialValue;
|
|
1024
|
-
}
|
|
1025
|
-
});
|
|
976
|
+
return trackFormReset(dom.getInputEl(ctx2), () => {
|
|
977
|
+
if (ctx2.initialValue != null) {
|
|
978
|
+
ctx2.value = ctx2.initialValue;
|
|
979
|
+
}
|
|
1026
980
|
});
|
|
1027
|
-
return () => cleanup == null ? void 0 : cleanup();
|
|
1028
981
|
},
|
|
1029
982
|
trackPointerMove(ctx2, _evt, { send }) {
|
|
1030
983
|
return trackPointerMove({
|
|
@@ -1039,13 +992,6 @@ function machine(ctx = {}) {
|
|
|
1039
992
|
}
|
|
1040
993
|
},
|
|
1041
994
|
actions: {
|
|
1042
|
-
setupDocument(ctx2, evt) {
|
|
1043
|
-
if (evt.doc)
|
|
1044
|
-
ctx2.doc = ref(evt.doc);
|
|
1045
|
-
if (evt.root)
|
|
1046
|
-
ctx2.rootNode = ref(evt.root);
|
|
1047
|
-
ctx2.uid = evt.id;
|
|
1048
|
-
},
|
|
1049
995
|
checkValue(ctx2) {
|
|
1050
996
|
const value = utils.convert(ctx2, ctx2.value);
|
|
1051
997
|
Object.assign(ctx2, { value, initialValue: value });
|
|
@@ -1066,6 +1012,8 @@ function machine(ctx = {}) {
|
|
|
1066
1012
|
dom.dispatchChangeEvent(ctx2);
|
|
1067
1013
|
},
|
|
1068
1014
|
setThumbSize(ctx2) {
|
|
1015
|
+
if (ctx2.thumbAlignment !== "contain")
|
|
1016
|
+
return;
|
|
1069
1017
|
raf(() => {
|
|
1070
1018
|
const el = dom.getThumbEl(ctx2);
|
|
1071
1019
|
if (!el)
|
|
@@ -1108,4 +1056,3 @@ export {
|
|
|
1108
1056
|
machine,
|
|
1109
1057
|
dom as unstable__dom
|
|
1110
1058
|
};
|
|
1111
|
-
//# sourceMappingURL=index.mjs.map
|