@zag-js/slider 0.1.6 → 0.1.9
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 +286 -349
- package/dist/index.mjs +285 -349
- package/dist/slider.connect.d.ts +2 -3
- package/dist/slider.dom.d.ts +10 -12
- package/dist/slider.machine.d.ts +1 -2
- package/dist/slider.style.d.ts +23 -0
- package/dist/slider.types.d.ts +11 -1
- package/dist/slider.utils.d.ts +1 -2
- package/package.json +5 -6
- 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.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -47,196 +48,47 @@ var __pow = Math.pow;
|
|
|
47
48
|
var dataAttr = (guard) => {
|
|
48
49
|
return guard ? "" : void 0;
|
|
49
50
|
};
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
set.forEach(function(fn2) {
|
|
59
|
-
fn2();
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function raf(fn) {
|
|
64
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
65
|
-
return function cleanup() {
|
|
66
|
-
globalThis.cancelAnimationFrame(id);
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
var noop = () => {
|
|
51
|
+
var runIfFn = (v, ...a) => {
|
|
52
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
53
|
+
return res != null ? res : void 0;
|
|
54
|
+
};
|
|
55
|
+
var callAll = (...fns) => (...a) => {
|
|
56
|
+
fns.forEach(function(fn) {
|
|
57
|
+
fn == null ? void 0 : fn(...a);
|
|
58
|
+
});
|
|
70
59
|
};
|
|
71
|
-
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
72
|
-
var platform = (v) => isDom() && v.test(navigator.platform);
|
|
73
|
-
var isDom = () => !!(typeof window !== "undefined");
|
|
74
|
-
var isMac = () => platform(/^Mac/);
|
|
75
|
-
var isIPhone = () => platform(/^iPhone/);
|
|
76
|
-
var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
|
|
77
|
-
var isIos = () => isIPhone() || isIPad();
|
|
78
60
|
var isArray = (v) => Array.isArray(v);
|
|
79
61
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
function
|
|
83
|
-
;
|
|
84
|
-
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
85
|
-
return globalThis.__listenerElements__;
|
|
86
|
-
}
|
|
87
|
-
function getListenerCache() {
|
|
88
|
-
;
|
|
89
|
-
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
90
|
-
return globalThis.__listenerCache__;
|
|
91
|
-
}
|
|
92
|
-
function globalEventBus(node, type, handler, options) {
|
|
62
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
63
|
+
var isDom = () => typeof window !== "undefined";
|
|
64
|
+
function getPlatform() {
|
|
93
65
|
var _a;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const hash = JSON.stringify({ type, options });
|
|
97
|
-
const listenerElements = getListenerElements();
|
|
98
|
-
const listenerCache = getListenerCache();
|
|
99
|
-
const group = listenerElements.get(node);
|
|
100
|
-
if (!listenerElements.has(node)) {
|
|
101
|
-
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
|
|
102
|
-
listenerElements.set(node, group2);
|
|
103
|
-
} else if (group == null ? void 0 : group.has(hash)) {
|
|
104
|
-
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
|
|
105
|
-
} else {
|
|
106
|
-
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
|
|
107
|
-
}
|
|
108
|
-
function attach(node2) {
|
|
109
|
-
var _a2, _b;
|
|
110
|
-
function listener(event) {
|
|
111
|
-
var _a3;
|
|
112
|
-
const group2 = listenerElements.get(node2);
|
|
113
|
-
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
114
|
-
}
|
|
115
|
-
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
116
|
-
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
|
|
117
|
-
node2.addEventListener(type, listener, options);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
|
|
121
|
-
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
|
|
122
|
-
node2.addEventListener(type, listener, options);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
attach(node);
|
|
126
|
-
return function remove() {
|
|
127
|
-
var _a2, _b, _c, _d;
|
|
128
|
-
if (!listenerElements.has(node))
|
|
129
|
-
return;
|
|
130
|
-
const group2 = listenerElements.get(node);
|
|
131
|
-
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
132
|
-
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
133
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
134
|
-
node.removeEventListener(type, listener, options);
|
|
135
|
-
group2 == null ? void 0 : group2.delete(hash);
|
|
136
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
137
|
-
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
138
|
-
listenerElements.delete(node);
|
|
139
|
-
listenerCache.delete(node);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
};
|
|
66
|
+
const agent = navigator.userAgentData;
|
|
67
|
+
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
143
68
|
}
|
|
144
|
-
var
|
|
145
|
-
var
|
|
146
|
-
var
|
|
147
|
-
var
|
|
148
|
-
var
|
|
149
|
-
function
|
|
150
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
|
|
151
|
-
return {
|
|
152
|
-
point: {
|
|
153
|
-
x: point[`${type}X`],
|
|
154
|
-
y: point[`${type}Y`]
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
function addDomEvent(target, event, listener, options) {
|
|
159
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
160
|
-
return globalEventBus(node, event, listener, options);
|
|
161
|
-
}
|
|
162
|
-
function addPointerEvent(target, event, listener, options) {
|
|
163
|
-
var _a;
|
|
164
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
165
|
-
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
166
|
-
}
|
|
167
|
-
function wrapHandler(fn, filter = false) {
|
|
168
|
-
const listener = (event) => {
|
|
169
|
-
fn(event, extractInfo(event));
|
|
170
|
-
};
|
|
171
|
-
return filter ? filterPrimaryPointer(listener) : listener;
|
|
172
|
-
}
|
|
173
|
-
function filterPrimaryPointer(fn) {
|
|
174
|
-
return (event) => {
|
|
175
|
-
var _a;
|
|
176
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
177
|
-
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
178
|
-
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
179
|
-
if (isPrimary)
|
|
180
|
-
fn(event);
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
var supportsPointerEvent = () => typeof window !== "undefined" && window.onpointerdown === null;
|
|
184
|
-
var supportsTouchEvent = () => typeof window !== "undefined" && window.ontouchstart === null;
|
|
185
|
-
var supportsMouseEvent = () => typeof window !== "undefined" && window.onmousedown === null;
|
|
186
|
-
var mouseEventNames = {
|
|
187
|
-
pointerdown: "mousedown",
|
|
188
|
-
pointermove: "mousemove",
|
|
189
|
-
pointerup: "mouseup",
|
|
190
|
-
pointercancel: "mousecancel",
|
|
191
|
-
pointerover: "mouseover",
|
|
192
|
-
pointerout: "mouseout",
|
|
193
|
-
pointerenter: "mouseenter",
|
|
194
|
-
pointerleave: "mouseleave"
|
|
195
|
-
};
|
|
196
|
-
var touchEventNames = {
|
|
197
|
-
pointerdown: "touchstart",
|
|
198
|
-
pointermove: "touchmove",
|
|
199
|
-
pointerup: "touchend",
|
|
200
|
-
pointercancel: "touchcancel"
|
|
201
|
-
};
|
|
202
|
-
function getEventName(evt) {
|
|
203
|
-
if (supportsPointerEvent())
|
|
204
|
-
return evt;
|
|
205
|
-
if (supportsTouchEvent())
|
|
206
|
-
return touchEventNames[evt];
|
|
207
|
-
if (supportsMouseEvent())
|
|
208
|
-
return mouseEventNames[evt];
|
|
209
|
-
return evt;
|
|
210
|
-
}
|
|
211
|
-
function getOwnerWindow(el) {
|
|
69
|
+
var pt = (v) => isDom() && v.test(getPlatform());
|
|
70
|
+
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
71
|
+
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
72
|
+
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
73
|
+
var isIos = () => isApple() && !isMac();
|
|
74
|
+
function getWindow(el) {
|
|
212
75
|
var _a;
|
|
213
76
|
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
214
77
|
}
|
|
215
|
-
function
|
|
216
|
-
var _a;
|
|
217
|
-
const { type, property } = options;
|
|
218
|
-
const win = getOwnerWindow(el);
|
|
219
|
-
const _type = type === "input" ? "HTMLInputElement" : "HTMLTextAreaElement";
|
|
220
|
-
const proto = win[_type].prototype;
|
|
221
|
-
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
222
|
-
}
|
|
223
|
-
function dispatchInputValueEvent(el, value) {
|
|
224
|
-
var _a;
|
|
225
|
-
const win = getOwnerWindow(el);
|
|
226
|
-
if (!(el instanceof win.HTMLInputElement))
|
|
227
|
-
return;
|
|
228
|
-
const desc = getDescriptor(el, { type: "input", property: "value" });
|
|
229
|
-
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
230
|
-
const event = new win.Event("input", { bubbles: true });
|
|
231
|
-
el.dispatchEvent(event);
|
|
232
|
-
}
|
|
233
|
-
function getNativeEvent(event) {
|
|
78
|
+
function getNativeEvent(e) {
|
|
234
79
|
var _a;
|
|
235
|
-
return (_a =
|
|
80
|
+
return (_a = e.nativeEvent) != null ? _a : e;
|
|
236
81
|
}
|
|
82
|
+
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
83
|
+
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
84
|
+
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
85
|
+
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
86
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
87
|
+
var isLeftClick = (v) => v.button === 0;
|
|
88
|
+
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
237
89
|
function observeAttributes(node, attributes, fn) {
|
|
238
90
|
if (!node)
|
|
239
|
-
return
|
|
91
|
+
return;
|
|
240
92
|
const attrs = Array.isArray(attributes) ? attributes : [attributes];
|
|
241
93
|
const win = node.ownerDocument.defaultView || window;
|
|
242
94
|
const obs = new win.MutationObserver((changes) => {
|
|
@@ -274,6 +126,61 @@ function trackFieldsetDisabled(el, callback) {
|
|
|
274
126
|
callback(fieldset.disabled);
|
|
275
127
|
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
|
|
276
128
|
}
|
|
129
|
+
function getElementOffset(element) {
|
|
130
|
+
let left = 0;
|
|
131
|
+
let top = 0;
|
|
132
|
+
let el = element;
|
|
133
|
+
if (el.parentNode) {
|
|
134
|
+
do {
|
|
135
|
+
left += el.offsetLeft;
|
|
136
|
+
top += el.offsetTop;
|
|
137
|
+
} while ((el = el.offsetParent) && el.nodeType < 9);
|
|
138
|
+
el = element;
|
|
139
|
+
do {
|
|
140
|
+
left -= el.scrollLeft;
|
|
141
|
+
top -= el.scrollTop;
|
|
142
|
+
} while ((el = el.parentNode) && !/body/i.test(el.nodeName));
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
top,
|
|
146
|
+
right: innerWidth - left - element.offsetWidth,
|
|
147
|
+
bottom: innerHeight - top - element.offsetHeight,
|
|
148
|
+
left
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
var fallback = {
|
|
152
|
+
pageX: 0,
|
|
153
|
+
pageY: 0,
|
|
154
|
+
clientX: 0,
|
|
155
|
+
clientY: 0
|
|
156
|
+
};
|
|
157
|
+
function getEventPoint(event, type = "page") {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
|
|
160
|
+
return { x: point[`${type}X`], y: point[`${type}Y`] };
|
|
161
|
+
}
|
|
162
|
+
function getPointRelativeToNode(point, element) {
|
|
163
|
+
const offset = getElementOffset(element);
|
|
164
|
+
const x = point.x - offset.left;
|
|
165
|
+
const y = point.y - offset.top;
|
|
166
|
+
return { x, y };
|
|
167
|
+
}
|
|
168
|
+
function getDescriptor(el, options) {
|
|
169
|
+
var _a;
|
|
170
|
+
const { type, property } = options;
|
|
171
|
+
const proto = getWindow(el)[type].prototype;
|
|
172
|
+
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
173
|
+
}
|
|
174
|
+
function dispatchInputValueEvent(el, value) {
|
|
175
|
+
var _a;
|
|
176
|
+
const win = getWindow(el);
|
|
177
|
+
if (!(el instanceof win.HTMLInputElement))
|
|
178
|
+
return;
|
|
179
|
+
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
180
|
+
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
181
|
+
const event = new win.Event("input", { bubbles: true });
|
|
182
|
+
el.dispatchEvent(event);
|
|
183
|
+
}
|
|
277
184
|
var rtlKeyMap = {
|
|
278
185
|
ArrowLeft: "ArrowRight",
|
|
279
186
|
ArrowRight: "ArrowLeft",
|
|
@@ -311,29 +218,88 @@ function getEventStep(event) {
|
|
|
311
218
|
return isSkipKey ? 10 : 1;
|
|
312
219
|
}
|
|
313
220
|
}
|
|
314
|
-
|
|
315
|
-
|
|
221
|
+
var isRef = (v) => hasProp(v, "current");
|
|
222
|
+
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
223
|
+
function extractInfo(event, type = "page") {
|
|
224
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
225
|
+
return {
|
|
226
|
+
point: {
|
|
227
|
+
x: point[`${type}X`],
|
|
228
|
+
y: point[`${type}Y`]
|
|
229
|
+
}
|
|
230
|
+
};
|
|
316
231
|
}
|
|
317
|
-
function
|
|
318
|
-
const
|
|
319
|
-
|
|
232
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
233
|
+
const node = isRef(target) ? target.current : runIfFn(target);
|
|
234
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
235
|
+
return () => {
|
|
236
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
237
|
+
};
|
|
320
238
|
}
|
|
321
|
-
|
|
322
|
-
var _a
|
|
323
|
-
|
|
239
|
+
function addPointerEvent(target, event, listener, options) {
|
|
240
|
+
var _a;
|
|
241
|
+
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
242
|
+
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
243
|
+
}
|
|
244
|
+
function wrapHandler(fn, filter = false) {
|
|
245
|
+
const listener = (event) => {
|
|
246
|
+
fn(event, extractInfo(event));
|
|
247
|
+
};
|
|
248
|
+
return filter ? filterPrimaryPointer(listener) : listener;
|
|
249
|
+
}
|
|
250
|
+
function filterPrimaryPointer(fn) {
|
|
251
|
+
return (event) => {
|
|
252
|
+
var _a;
|
|
253
|
+
const win = (_a = event.view) != null ? _a : window;
|
|
254
|
+
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
255
|
+
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
256
|
+
if (isPrimary)
|
|
257
|
+
fn(event);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
var mouseEventNames = {
|
|
261
|
+
pointerdown: "mousedown",
|
|
262
|
+
pointermove: "mousemove",
|
|
263
|
+
pointerup: "mouseup",
|
|
264
|
+
pointercancel: "mousecancel",
|
|
265
|
+
pointerover: "mouseover",
|
|
266
|
+
pointerout: "mouseout",
|
|
267
|
+
pointerenter: "mouseenter",
|
|
268
|
+
pointerleave: "mouseleave"
|
|
324
269
|
};
|
|
325
|
-
var
|
|
326
|
-
|
|
327
|
-
|
|
270
|
+
var touchEventNames = {
|
|
271
|
+
pointerdown: "touchstart",
|
|
272
|
+
pointermove: "touchmove",
|
|
273
|
+
pointerup: "touchend",
|
|
274
|
+
pointercancel: "touchcancel"
|
|
328
275
|
};
|
|
329
|
-
function
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
276
|
+
function getEventName(evt) {
|
|
277
|
+
if (supportsPointerEvent())
|
|
278
|
+
return evt;
|
|
279
|
+
if (supportsTouchEvent())
|
|
280
|
+
return touchEventNames[evt];
|
|
281
|
+
if (supportsMouseEvent())
|
|
282
|
+
return mouseEventNames[evt];
|
|
283
|
+
return evt;
|
|
284
|
+
}
|
|
285
|
+
function nextTick(fn) {
|
|
286
|
+
const set = /* @__PURE__ */ new Set();
|
|
287
|
+
function raf2(fn2) {
|
|
288
|
+
const id = globalThis.requestAnimationFrame(fn2);
|
|
289
|
+
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
335
290
|
}
|
|
336
|
-
|
|
291
|
+
raf2(() => raf2(fn));
|
|
292
|
+
return function cleanup() {
|
|
293
|
+
set.forEach(function(fn2) {
|
|
294
|
+
fn2();
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function raf(fn) {
|
|
299
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
300
|
+
return function cleanup() {
|
|
301
|
+
globalThis.cancelAnimationFrame(id);
|
|
302
|
+
};
|
|
337
303
|
}
|
|
338
304
|
var state = "default";
|
|
339
305
|
var savedUserSelect = "";
|
|
@@ -396,44 +362,16 @@ function trackPointerMove(opts) {
|
|
|
396
362
|
}
|
|
397
363
|
onPointerMove(info, event);
|
|
398
364
|
};
|
|
399
|
-
return
|
|
365
|
+
return callAll(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
|
|
400
366
|
}
|
|
401
|
-
function findByTypeahead(_items, options) {
|
|
402
|
-
const { state: state2, activeId, key, timeout = 350 } = options;
|
|
403
|
-
const search = state2.keysSoFar + key;
|
|
404
|
-
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
405
|
-
const query2 = isRepeated ? search[0] : search;
|
|
406
|
-
let items = _items.slice();
|
|
407
|
-
const next = findByText(items, query2, activeId);
|
|
408
|
-
function cleanup() {
|
|
409
|
-
clearTimeout(state2.timer);
|
|
410
|
-
state2.timer = -1;
|
|
411
|
-
}
|
|
412
|
-
function update(value) {
|
|
413
|
-
state2.keysSoFar = value;
|
|
414
|
-
cleanup();
|
|
415
|
-
if (value !== "") {
|
|
416
|
-
state2.timer = +setTimeout(() => {
|
|
417
|
-
update("");
|
|
418
|
-
cleanup();
|
|
419
|
-
}, timeout);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
update(search);
|
|
423
|
-
return next;
|
|
424
|
-
}
|
|
425
|
-
findByTypeahead.defaultOptions = {
|
|
426
|
-
keysSoFar: "",
|
|
427
|
-
timer: -1
|
|
428
|
-
};
|
|
429
367
|
|
|
430
368
|
// ../../utilities/number/dist/index.mjs
|
|
431
369
|
var __pow2 = Math.pow;
|
|
432
|
-
function round(v,
|
|
370
|
+
function round(v, t) {
|
|
433
371
|
let num = valueOf(v);
|
|
434
|
-
const p = __pow2(10,
|
|
372
|
+
const p = __pow2(10, t != null ? t : 10);
|
|
435
373
|
num = Math.round(num * p) / p;
|
|
436
|
-
return
|
|
374
|
+
return t ? num.toFixed(t) : v.toString();
|
|
437
375
|
}
|
|
438
376
|
var valueToPercent = (v, r) => (valueOf(v) - r.min) * 100 / (r.max - r.min);
|
|
439
377
|
var percentToValue = (v, r) => r.min + (r.max - r.min) * valueOf(v);
|
|
@@ -487,47 +425,7 @@ var transform = (a, b) => {
|
|
|
487
425
|
};
|
|
488
426
|
};
|
|
489
427
|
|
|
490
|
-
//
|
|
491
|
-
var isArray2 = (v) => Array.isArray(v);
|
|
492
|
-
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
|
|
493
|
-
var isTouchEvent2 = (v) => isObject2(v) && "touches" in v;
|
|
494
|
-
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
495
|
-
function getEventPoint(e, t2 = "page") {
|
|
496
|
-
const p = isTouchEvent2(e) ? e.touches[0] || e.changedTouches[0] || fallback2 : e;
|
|
497
|
-
return { x: p[`${t2}X`], y: p[`${t2}Y`] };
|
|
498
|
-
}
|
|
499
|
-
function relativeToNode(p, el) {
|
|
500
|
-
const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft;
|
|
501
|
-
const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop;
|
|
502
|
-
return {
|
|
503
|
-
point: { x: dx, y: dy },
|
|
504
|
-
progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight }
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// src/slider.utils.ts
|
|
509
|
-
var utils = {
|
|
510
|
-
fromPercent(ctx, percent) {
|
|
511
|
-
percent = clamp(percent, { min: 0, max: 1 });
|
|
512
|
-
return parseFloat(snapToStep(percentToValue(percent, ctx), ctx.step));
|
|
513
|
-
},
|
|
514
|
-
clamp(ctx, value) {
|
|
515
|
-
return clamp(value, ctx);
|
|
516
|
-
},
|
|
517
|
-
convert(ctx, value) {
|
|
518
|
-
return clamp(parseFloat(snapToStep(value, ctx.step)), ctx);
|
|
519
|
-
},
|
|
520
|
-
decrement(ctx, step) {
|
|
521
|
-
let value = decrement(ctx.value, step != null ? step : ctx.step);
|
|
522
|
-
return utils.convert(ctx, value);
|
|
523
|
-
},
|
|
524
|
-
increment(ctx, step) {
|
|
525
|
-
let value = increment(ctx.value, step != null ? step : ctx.step);
|
|
526
|
-
return utils.convert(ctx, value);
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
// src/slider.dom.ts
|
|
428
|
+
// src/slider.style.ts
|
|
531
429
|
function getVerticalThumbOffset(ctx) {
|
|
532
430
|
var _a;
|
|
533
431
|
const { height = 0 } = (_a = ctx.thumbSize) != null ? _a : {};
|
|
@@ -544,54 +442,119 @@ function getHorizontalThumbOffset(ctx) {
|
|
|
544
442
|
const getValue = transform([ctx.min, ctx.max], [-width / 2, width / 2]);
|
|
545
443
|
return parseFloat(getValue(ctx.value).toFixed(2));
|
|
546
444
|
}
|
|
547
|
-
function
|
|
445
|
+
function getThumbOffset(ctx) {
|
|
548
446
|
const percent = valueToPercent(ctx.value, ctx);
|
|
447
|
+
if (ctx.thumbAlignment === "center")
|
|
448
|
+
return `${percent}%`;
|
|
549
449
|
const offset = ctx.isVertical ? getVerticalThumbOffset(ctx) : getHorizontalThumbOffset(ctx);
|
|
550
|
-
|
|
450
|
+
return `calc(${percent}% - ${offset}px)`;
|
|
451
|
+
}
|
|
452
|
+
function getThumbStyle(ctx) {
|
|
453
|
+
const placementProp = ctx.isVertical ? "bottom" : ctx.isRtl ? "right" : "left";
|
|
454
|
+
return {
|
|
551
455
|
visibility: ctx.hasMeasuredThumbSize ? "visible" : "hidden",
|
|
552
456
|
position: "absolute",
|
|
553
457
|
transform: "var(--slider-thumb-transform)",
|
|
554
|
-
"--slider-thumb-
|
|
458
|
+
[placementProp]: "var(--slider-thumb-offset)"
|
|
555
459
|
};
|
|
556
|
-
if (ctx.isVertical) {
|
|
557
|
-
style.bottom = "var(--slider-thumb-placement)";
|
|
558
|
-
} else {
|
|
559
|
-
style[ctx.isRtl ? "right" : "left"] = "var(--slider-thumb-placement)";
|
|
560
|
-
}
|
|
561
|
-
return style;
|
|
562
460
|
}
|
|
563
|
-
function
|
|
461
|
+
function getRangeOffsets(ctx) {
|
|
564
462
|
const percent = valueToPercent(ctx.value, ctx);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
};
|
|
568
|
-
let startValue = "0%";
|
|
569
|
-
let endValue = `${100 - percent}%`;
|
|
463
|
+
let start = "0%";
|
|
464
|
+
let end = `${100 - percent}%`;
|
|
570
465
|
if (ctx.origin === "center") {
|
|
571
466
|
const isNegative = percent < 50;
|
|
572
|
-
|
|
573
|
-
|
|
467
|
+
start = isNegative ? `${percent}%` : "50%";
|
|
468
|
+
end = isNegative ? "50%" : end;
|
|
574
469
|
}
|
|
470
|
+
return { start, end };
|
|
471
|
+
}
|
|
472
|
+
function getRangeStyle(ctx) {
|
|
575
473
|
if (ctx.isVertical) {
|
|
576
|
-
return
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
474
|
+
return {
|
|
475
|
+
position: "absolute",
|
|
476
|
+
bottom: "var(--slider-range-start)",
|
|
477
|
+
top: "var(--slider-range-end)"
|
|
478
|
+
};
|
|
580
479
|
}
|
|
581
|
-
return
|
|
582
|
-
|
|
583
|
-
[ctx.isRtl ? "
|
|
584
|
-
|
|
480
|
+
return {
|
|
481
|
+
position: "absolute",
|
|
482
|
+
[ctx.isRtl ? "right" : "left"]: "var(--slider-range-start)",
|
|
483
|
+
[ctx.isRtl ? "left" : "right"]: "var(--slider-range-end)"
|
|
484
|
+
};
|
|
585
485
|
}
|
|
586
|
-
function getControlStyle(
|
|
486
|
+
function getControlStyle() {
|
|
587
487
|
return {
|
|
588
488
|
touchAction: "none",
|
|
589
489
|
userSelect: "none",
|
|
490
|
+
position: "relative"
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
function getRootStyle(ctx) {
|
|
494
|
+
const range = getRangeOffsets(ctx);
|
|
495
|
+
return {
|
|
590
496
|
"--slider-thumb-transform": ctx.isVertical ? "translateY(50%)" : "translateX(-50%)",
|
|
497
|
+
"--slider-thumb-offset": getThumbOffset(ctx),
|
|
498
|
+
"--slider-range-start": range.start,
|
|
499
|
+
"--slider-range-end": range.end
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function getMarkerStyle(ctx, percent) {
|
|
503
|
+
return {
|
|
504
|
+
position: "absolute",
|
|
505
|
+
pointerEvents: "none",
|
|
506
|
+
[ctx.isHorizontal ? "left" : "bottom"]: `${ctx.isRtl ? 100 - percent : percent}%`
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function getLabelStyle() {
|
|
510
|
+
return { userSelect: "none" };
|
|
511
|
+
}
|
|
512
|
+
function getTrackStyle() {
|
|
513
|
+
return { position: "relative" };
|
|
514
|
+
}
|
|
515
|
+
function getMarkerGroupStyle() {
|
|
516
|
+
return {
|
|
517
|
+
userSelect: "none",
|
|
518
|
+
pointerEvents: "none",
|
|
591
519
|
position: "relative"
|
|
592
520
|
};
|
|
593
521
|
}
|
|
594
|
-
var
|
|
522
|
+
var styles = {
|
|
523
|
+
getThumbOffset,
|
|
524
|
+
getControlStyle,
|
|
525
|
+
getThumbStyle,
|
|
526
|
+
getRangeStyle,
|
|
527
|
+
getRootStyle,
|
|
528
|
+
getMarkerStyle,
|
|
529
|
+
getLabelStyle,
|
|
530
|
+
getTrackStyle,
|
|
531
|
+
getMarkerGroupStyle
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
// src/slider.utils.ts
|
|
535
|
+
var utils = {
|
|
536
|
+
fromPercent(ctx, percent) {
|
|
537
|
+
percent = clamp(percent, { min: 0, max: 1 });
|
|
538
|
+
return parseFloat(snapToStep(percentToValue(percent, ctx), ctx.step));
|
|
539
|
+
},
|
|
540
|
+
clamp(ctx, value) {
|
|
541
|
+
return clamp(value, ctx);
|
|
542
|
+
},
|
|
543
|
+
convert(ctx, value) {
|
|
544
|
+
return clamp(parseFloat(snapToStep(value, ctx.step)), ctx);
|
|
545
|
+
},
|
|
546
|
+
decrement(ctx, step) {
|
|
547
|
+
let value = decrement(ctx.value, step != null ? step : ctx.step);
|
|
548
|
+
return utils.convert(ctx, value);
|
|
549
|
+
},
|
|
550
|
+
increment(ctx, step) {
|
|
551
|
+
let value = increment(ctx.value, step != null ? step : ctx.step);
|
|
552
|
+
return utils.convert(ctx, value);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// src/slider.dom.ts
|
|
557
|
+
var dom = __spreadProps(__spreadValues({}, styles), {
|
|
595
558
|
getDoc: (ctx) => {
|
|
596
559
|
var _a;
|
|
597
560
|
return (_a = ctx.doc) != null ? _a : document;
|
|
@@ -619,7 +582,7 @@ var dom = {
|
|
|
619
582
|
},
|
|
620
583
|
getTrackId: (ctx) => {
|
|
621
584
|
var _a, _b;
|
|
622
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider
|
|
585
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.uid}track`;
|
|
623
586
|
},
|
|
624
587
|
getRangeId: (ctx) => {
|
|
625
588
|
var _a, _b;
|
|
@@ -634,19 +597,18 @@ var dom = {
|
|
|
634
597
|
getThumbEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getThumbId(ctx)),
|
|
635
598
|
getControlEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getControlId(ctx)),
|
|
636
599
|
getInputEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getInputId(ctx)),
|
|
637
|
-
getControlStyle,
|
|
638
|
-
getThumbStyle,
|
|
639
|
-
getRangeStyle,
|
|
640
600
|
getValueFromPoint(ctx, point) {
|
|
641
|
-
const
|
|
642
|
-
if (!
|
|
601
|
+
const el = dom.getControlEl(ctx);
|
|
602
|
+
if (!el)
|
|
643
603
|
return;
|
|
644
|
-
const
|
|
604
|
+
const relativePoint = getPointRelativeToNode(point, el);
|
|
605
|
+
const percentX = relativePoint.x / el.offsetWidth;
|
|
606
|
+
const percentY = relativePoint.y / el.offsetHeight;
|
|
645
607
|
let percent;
|
|
646
608
|
if (ctx.isHorizontal) {
|
|
647
|
-
percent = ctx.isRtl ? 1 -
|
|
609
|
+
percent = ctx.isRtl ? 1 - percentX : percentX;
|
|
648
610
|
} else {
|
|
649
|
-
percent = 1 -
|
|
611
|
+
percent = 1 - percentY;
|
|
650
612
|
}
|
|
651
613
|
return utils.fromPercent(ctx, percent);
|
|
652
614
|
},
|
|
@@ -655,38 +617,11 @@ var dom = {
|
|
|
655
617
|
if (!input)
|
|
656
618
|
return;
|
|
657
619
|
dispatchInputValueEvent(input, ctx.value);
|
|
658
|
-
},
|
|
659
|
-
getMarkerStyle(ctx, percent) {
|
|
660
|
-
const style = {
|
|
661
|
-
position: "absolute",
|
|
662
|
-
pointerEvents: "none"
|
|
663
|
-
};
|
|
664
|
-
if (ctx.isHorizontal) {
|
|
665
|
-
percent = ctx.isRtl ? 100 - percent : percent;
|
|
666
|
-
style.left = `${percent}%`;
|
|
667
|
-
} else {
|
|
668
|
-
style.bottom = `${percent}%`;
|
|
669
|
-
}
|
|
670
|
-
return style;
|
|
671
620
|
}
|
|
672
|
-
};
|
|
673
|
-
|
|
674
|
-
// ../../types/dist/index.mjs
|
|
675
|
-
function createNormalizer(fn) {
|
|
676
|
-
return new Proxy({}, {
|
|
677
|
-
get() {
|
|
678
|
-
return fn;
|
|
679
|
-
}
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
683
|
-
|
|
684
|
-
// ../../utilities/core/dist/index.mjs
|
|
685
|
-
var isLeftClick2 = (v) => v.button === 0;
|
|
686
|
-
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
621
|
+
});
|
|
687
622
|
|
|
688
623
|
// src/slider.connect.ts
|
|
689
|
-
function connect(state2, send, normalize
|
|
624
|
+
function connect(state2, send, normalize) {
|
|
690
625
|
var _a, _b;
|
|
691
626
|
const ariaLabel = state2.context["aria-label"];
|
|
692
627
|
const ariaLabelledBy = state2.context["aria-labelledby"];
|
|
@@ -720,14 +655,18 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
720
655
|
rootProps: normalize.element({
|
|
721
656
|
"data-part": "root",
|
|
722
657
|
"data-disabled": dataAttr(isDisabled),
|
|
658
|
+
"data-focus": dataAttr(isFocused),
|
|
723
659
|
"data-orientation": state2.context.orientation,
|
|
660
|
+
"data-invalid": dataAttr(isInvalid),
|
|
724
661
|
id: dom.getRootId(state2.context),
|
|
725
|
-
dir: state2.context.dir
|
|
662
|
+
dir: state2.context.dir,
|
|
663
|
+
style: dom.getRootStyle(state2.context)
|
|
726
664
|
}),
|
|
727
665
|
labelProps: normalize.label({
|
|
728
666
|
"data-part": "label",
|
|
729
667
|
"data-disabled": dataAttr(isDisabled),
|
|
730
668
|
"data-invalid": dataAttr(isInvalid),
|
|
669
|
+
"data-focus": dataAttr(isFocused),
|
|
731
670
|
id: dom.getLabelId(state2.context),
|
|
732
671
|
htmlFor: dom.getInputId(state2.context),
|
|
733
672
|
onClick(event) {
|
|
@@ -737,9 +676,7 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
737
676
|
event.preventDefault();
|
|
738
677
|
(_a2 = dom.getThumbEl(state2.context)) == null ? void 0 : _a2.focus();
|
|
739
678
|
},
|
|
740
|
-
style:
|
|
741
|
-
userSelect: "none"
|
|
742
|
-
}
|
|
679
|
+
style: dom.getLabelStyle()
|
|
743
680
|
}),
|
|
744
681
|
thumbProps: normalize.element({
|
|
745
682
|
"data-part": "thumb",
|
|
@@ -836,14 +773,15 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
836
773
|
"data-part": "track",
|
|
837
774
|
id: dom.getTrackId(state2.context),
|
|
838
775
|
"data-disabled": dataAttr(isDisabled),
|
|
776
|
+
"data-focus": dataAttr(isFocused),
|
|
839
777
|
"data-invalid": dataAttr(isInvalid),
|
|
840
778
|
"data-orientation": state2.context.orientation,
|
|
841
|
-
|
|
842
|
-
style: { position: "relative" }
|
|
779
|
+
style: dom.getTrackStyle()
|
|
843
780
|
}),
|
|
844
781
|
rangeProps: normalize.element({
|
|
845
782
|
"data-part": "range",
|
|
846
783
|
id: dom.getRangeId(state2.context),
|
|
784
|
+
"data-focus": dataAttr(isFocused),
|
|
847
785
|
"data-invalid": dataAttr(isInvalid),
|
|
848
786
|
"data-disabled": dataAttr(isDisabled),
|
|
849
787
|
"data-orientation": state2.context.orientation,
|
|
@@ -860,25 +798,21 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
860
798
|
if (!isInteractive)
|
|
861
799
|
return;
|
|
862
800
|
const evt = getNativeEvent(event);
|
|
863
|
-
if (!
|
|
801
|
+
if (!isLeftClick(evt) || isModifiedEvent(evt))
|
|
864
802
|
return;
|
|
865
803
|
const point = getEventPoint(evt);
|
|
866
804
|
send({ type: "POINTER_DOWN", point });
|
|
867
805
|
event.preventDefault();
|
|
868
806
|
event.stopPropagation();
|
|
869
807
|
},
|
|
870
|
-
style: dom.getControlStyle(
|
|
808
|
+
style: dom.getControlStyle()
|
|
871
809
|
}),
|
|
872
810
|
markerGroupProps: normalize.element({
|
|
873
811
|
"data-part": "marker-group",
|
|
874
812
|
role: "presentation",
|
|
875
813
|
"aria-hidden": true,
|
|
876
814
|
"data-orientation": state2.context.orientation,
|
|
877
|
-
style:
|
|
878
|
-
userSelect: "none",
|
|
879
|
-
pointerEvents: "none",
|
|
880
|
-
position: "relative"
|
|
881
|
-
}
|
|
815
|
+
style: dom.getMarkerGroupStyle()
|
|
882
816
|
}),
|
|
883
817
|
getMarkerProps({ value }) {
|
|
884
818
|
const percent = valueToPercent(value, state2.context);
|
|
@@ -886,6 +820,7 @@ function connect(state2, send, normalize = normalizeProp) {
|
|
|
886
820
|
const markerState = value > state2.context.value ? "over-value" : value < state2.context.value ? "under-value" : "at-value";
|
|
887
821
|
return normalize.element({
|
|
888
822
|
"data-part": "marker",
|
|
823
|
+
role: "presentation",
|
|
889
824
|
"data-orientation": state2.context.orientation,
|
|
890
825
|
id: dom.getMarkerId(state2.context, value),
|
|
891
826
|
"data-value": value,
|
|
@@ -905,6 +840,7 @@ function machine(ctx = {}) {
|
|
|
905
840
|
initial: "unknown",
|
|
906
841
|
context: __spreadValues({
|
|
907
842
|
thumbSize: null,
|
|
843
|
+
thumbAlignment: "contain",
|
|
908
844
|
uid: "",
|
|
909
845
|
disabled: false,
|
|
910
846
|
threshold: 5,
|
|
@@ -1019,7 +955,7 @@ function machine(ctx = {}) {
|
|
|
1019
955
|
let cleanup;
|
|
1020
956
|
nextTick(() => {
|
|
1021
957
|
cleanup = trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
|
|
1022
|
-
if (disabled
|
|
958
|
+
if (disabled) {
|
|
1023
959
|
ctx2.disabled = disabled;
|
|
1024
960
|
}
|
|
1025
961
|
});
|
|
@@ -1077,6 +1013,8 @@ function machine(ctx = {}) {
|
|
|
1077
1013
|
dom.dispatchChangeEvent(ctx2);
|
|
1078
1014
|
},
|
|
1079
1015
|
setThumbSize(ctx2) {
|
|
1016
|
+
if (ctx2.thumbAlignment !== "contain")
|
|
1017
|
+
return;
|
|
1080
1018
|
raf(() => {
|
|
1081
1019
|
const el = dom.getThumbEl(ctx2);
|
|
1082
1020
|
if (!el)
|
|
@@ -1114,4 +1052,3 @@ function machine(ctx = {}) {
|
|
|
1114
1052
|
}
|
|
1115
1053
|
});
|
|
1116
1054
|
}
|
|
1117
|
-
//# sourceMappingURL=index.js.map
|