@zag-js/slider 0.1.6 → 0.1.7
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 +58 -45
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +58 -45
- package/dist/index.mjs.map +3 -3
- package/dist/slider.types.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -66,19 +66,33 @@ function raf(fn) {
|
|
|
66
66
|
globalThis.cancelAnimationFrame(id);
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
var
|
|
70
|
-
};
|
|
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();
|
|
69
|
+
var isDom = () => typeof window !== "undefined";
|
|
78
70
|
var isArray = (v) => Array.isArray(v);
|
|
79
71
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
80
|
-
var
|
|
72
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
73
|
+
function getPlatform() {
|
|
74
|
+
var _a;
|
|
75
|
+
const agent = navigator.userAgentData;
|
|
76
|
+
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
77
|
+
}
|
|
78
|
+
var pt = (v) => isDom() && v.test(getPlatform());
|
|
79
|
+
var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
|
|
80
|
+
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
81
|
+
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
82
|
+
var isIos = () => isApple() && !isMac();
|
|
83
|
+
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
84
|
+
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
85
|
+
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
86
|
+
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
87
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
81
88
|
var isLeftClick = (v) => v.button === 0;
|
|
89
|
+
var runIfFn = (v, ...a) => {
|
|
90
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
91
|
+
return res != null ? res : void 0;
|
|
92
|
+
};
|
|
93
|
+
var noop = () => {
|
|
94
|
+
};
|
|
95
|
+
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
82
96
|
function getListenerElements() {
|
|
83
97
|
;
|
|
84
98
|
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
@@ -89,7 +103,7 @@ function getListenerCache() {
|
|
|
89
103
|
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
90
104
|
return globalThis.__listenerCache__;
|
|
91
105
|
}
|
|
92
|
-
function
|
|
106
|
+
function addGlobalEventListener(node, type, handler, options) {
|
|
93
107
|
var _a;
|
|
94
108
|
if (!node)
|
|
95
109
|
return noop;
|
|
@@ -141,10 +155,7 @@ function globalEventBus(node, type, handler, options) {
|
|
|
141
155
|
}
|
|
142
156
|
};
|
|
143
157
|
}
|
|
144
|
-
var
|
|
145
|
-
var isRef = (v) => t(v) === "Object" && "current" in v;
|
|
146
|
-
var runIfFn = (fn) => t(fn) === "Function" ? fn() : fn;
|
|
147
|
-
var isTouchEvent = (v) => t(v) === "Object" && !!v.touches;
|
|
158
|
+
var isRef = (v) => hasProp(v, "current");
|
|
148
159
|
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
149
160
|
function extractInfo(event, type = "page") {
|
|
150
161
|
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
|
|
@@ -157,7 +168,7 @@ function extractInfo(event, type = "page") {
|
|
|
157
168
|
}
|
|
158
169
|
function addDomEvent(target, event, listener, options) {
|
|
159
170
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
160
|
-
return
|
|
171
|
+
return addGlobalEventListener(node, event, listener, options);
|
|
161
172
|
}
|
|
162
173
|
function addPointerEvent(target, event, listener, options) {
|
|
163
174
|
var _a;
|
|
@@ -180,9 +191,6 @@ function filterPrimaryPointer(fn) {
|
|
|
180
191
|
fn(event);
|
|
181
192
|
};
|
|
182
193
|
}
|
|
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
194
|
var mouseEventNames = {
|
|
187
195
|
pointerdown: "mousedown",
|
|
188
196
|
pointermove: "mousemove",
|
|
@@ -212,27 +220,9 @@ function getOwnerWindow(el) {
|
|
|
212
220
|
var _a;
|
|
213
221
|
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
214
222
|
}
|
|
215
|
-
function
|
|
223
|
+
function getNativeEvent(e) {
|
|
216
224
|
var _a;
|
|
217
|
-
|
|
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) {
|
|
234
|
-
var _a;
|
|
235
|
-
return (_a = event.nativeEvent) != null ? _a : event;
|
|
225
|
+
return (_a = e.nativeEvent) != null ? _a : e;
|
|
236
226
|
}
|
|
237
227
|
function observeAttributes(node, attributes, fn) {
|
|
238
228
|
if (!node)
|
|
@@ -274,6 +264,24 @@ function trackFieldsetDisabled(el, callback) {
|
|
|
274
264
|
callback(fieldset.disabled);
|
|
275
265
|
return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
|
|
276
266
|
}
|
|
267
|
+
function getDescriptor(el, options) {
|
|
268
|
+
var _a;
|
|
269
|
+
const { type, property } = options;
|
|
270
|
+
const win = getOwnerWindow(el);
|
|
271
|
+
const _type = type === "input" ? "HTMLInputElement" : "HTMLTextAreaElement";
|
|
272
|
+
const proto = win[_type].prototype;
|
|
273
|
+
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
274
|
+
}
|
|
275
|
+
function dispatchInputValueEvent(el, value) {
|
|
276
|
+
var _a;
|
|
277
|
+
const win = getOwnerWindow(el);
|
|
278
|
+
if (!(el instanceof win.HTMLInputElement))
|
|
279
|
+
return;
|
|
280
|
+
const desc = getDescriptor(el, { type: "input", property: "value" });
|
|
281
|
+
(_a = desc.set) == null ? void 0 : _a.call(el, value);
|
|
282
|
+
const event = new win.Event("input", { bubbles: true });
|
|
283
|
+
el.dispatchEvent(event);
|
|
284
|
+
}
|
|
277
285
|
var rtlKeyMap = {
|
|
278
286
|
ArrowLeft: "ArrowRight",
|
|
279
287
|
ArrowRight: "ArrowLeft",
|
|
@@ -429,11 +437,11 @@ findByTypeahead.defaultOptions = {
|
|
|
429
437
|
|
|
430
438
|
// ../../utilities/number/dist/index.mjs
|
|
431
439
|
var __pow2 = Math.pow;
|
|
432
|
-
function round(v,
|
|
440
|
+
function round(v, t) {
|
|
433
441
|
let num = valueOf(v);
|
|
434
|
-
const p = __pow2(10,
|
|
442
|
+
const p = __pow2(10, t != null ? t : 10);
|
|
435
443
|
num = Math.round(num * p) / p;
|
|
436
|
-
return
|
|
444
|
+
return t ? num.toFixed(t) : v.toString();
|
|
437
445
|
}
|
|
438
446
|
var valueToPercent = (v, r) => (valueOf(v) - r.min) * 100 / (r.max - r.min);
|
|
439
447
|
var percentToValue = (v, r) => r.min + (r.max - r.min) * valueOf(v);
|
|
@@ -488,13 +496,16 @@ var transform = (a, b) => {
|
|
|
488
496
|
};
|
|
489
497
|
|
|
490
498
|
// ../../utilities/rect/dist/index.mjs
|
|
499
|
+
var isDom2 = () => typeof window !== "undefined";
|
|
491
500
|
var isArray2 = (v) => Array.isArray(v);
|
|
492
501
|
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
|
|
493
|
-
var
|
|
502
|
+
var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
503
|
+
var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
|
|
504
|
+
var isTouchEvent2 = (v) => isObject2(v) && hasProp2(v, "touches");
|
|
494
505
|
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
495
|
-
function getEventPoint(e,
|
|
506
|
+
function getEventPoint(e, t = "page") {
|
|
496
507
|
const p = isTouchEvent2(e) ? e.touches[0] || e.changedTouches[0] || fallback2 : e;
|
|
497
|
-
return { x: p[`${
|
|
508
|
+
return { x: p[`${t}X`], y: p[`${t}Y`] };
|
|
498
509
|
}
|
|
499
510
|
function relativeToNode(p, el) {
|
|
500
511
|
const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft;
|
|
@@ -682,6 +693,8 @@ function createNormalizer(fn) {
|
|
|
682
693
|
var normalizeProp = createNormalizer((v) => v);
|
|
683
694
|
|
|
684
695
|
// ../../utilities/core/dist/index.mjs
|
|
696
|
+
var isDom3 = () => typeof window !== "undefined";
|
|
697
|
+
var isTouchDevice3 = isDom3() && !!navigator.maxTouchPoints;
|
|
685
698
|
var isLeftClick2 = (v) => v.button === 0;
|
|
686
699
|
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
|
|
687
700
|
|