@zag-js/slider 0.0.0-dev-20220628115342 → 0.0.0-dev-20220703193942
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 +118 -114
- package/dist/index.mjs +118 -114
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -48,115 +48,7 @@ var __pow = Math.pow;
|
|
|
48
48
|
var dataAttr = (guard) => {
|
|
49
49
|
return guard ? "" : void 0;
|
|
50
50
|
};
|
|
51
|
-
|
|
52
|
-
var isArray = (v) => Array.isArray(v);
|
|
53
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
54
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
55
|
-
function getPlatform() {
|
|
56
|
-
var _a;
|
|
57
|
-
const agent = navigator.userAgentData;
|
|
58
|
-
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
59
|
-
}
|
|
60
|
-
var pt = (v) => isDom() && v.test(getPlatform());
|
|
61
|
-
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
62
|
-
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
63
|
-
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
64
|
-
var isIos = () => isApple() && !isMac();
|
|
65
|
-
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
66
|
-
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
67
|
-
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
68
|
-
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
69
|
-
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
70
|
-
var isLeftClick = (v) => v.button === 0;
|
|
71
|
-
var runIfFn = (v, ...a) => {
|
|
72
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
73
|
-
return res != null ? res : void 0;
|
|
74
|
-
};
|
|
75
|
-
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
76
|
-
var isRef = (v) => hasProp(v, "current");
|
|
77
|
-
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
78
|
-
function extractInfo(event, type = "page") {
|
|
79
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
|
|
80
|
-
return {
|
|
81
|
-
point: {
|
|
82
|
-
x: point[`${type}X`],
|
|
83
|
-
y: point[`${type}Y`]
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
88
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
89
|
-
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
90
|
-
return () => {
|
|
91
|
-
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function addPointerEvent(target, event, listener, options) {
|
|
95
|
-
var _a;
|
|
96
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
97
|
-
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
98
|
-
}
|
|
99
|
-
function wrapHandler(fn, filter = false) {
|
|
100
|
-
const listener = (event) => {
|
|
101
|
-
fn(event, extractInfo(event));
|
|
102
|
-
};
|
|
103
|
-
return filter ? filterPrimaryPointer(listener) : listener;
|
|
104
|
-
}
|
|
105
|
-
function filterPrimaryPointer(fn) {
|
|
106
|
-
return (event) => {
|
|
107
|
-
var _a;
|
|
108
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
109
|
-
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
110
|
-
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
111
|
-
if (isPrimary)
|
|
112
|
-
fn(event);
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
var mouseEventNames = {
|
|
116
|
-
pointerdown: "mousedown",
|
|
117
|
-
pointermove: "mousemove",
|
|
118
|
-
pointerup: "mouseup",
|
|
119
|
-
pointercancel: "mousecancel",
|
|
120
|
-
pointerover: "mouseover",
|
|
121
|
-
pointerout: "mouseout",
|
|
122
|
-
pointerenter: "mouseenter",
|
|
123
|
-
pointerleave: "mouseleave"
|
|
124
|
-
};
|
|
125
|
-
var touchEventNames = {
|
|
126
|
-
pointerdown: "touchstart",
|
|
127
|
-
pointermove: "touchmove",
|
|
128
|
-
pointerup: "touchend",
|
|
129
|
-
pointercancel: "touchcancel"
|
|
130
|
-
};
|
|
131
|
-
function getEventName(evt) {
|
|
132
|
-
if (supportsPointerEvent())
|
|
133
|
-
return evt;
|
|
134
|
-
if (supportsTouchEvent())
|
|
135
|
-
return touchEventNames[evt];
|
|
136
|
-
if (supportsMouseEvent())
|
|
137
|
-
return mouseEventNames[evt];
|
|
138
|
-
return evt;
|
|
139
|
-
}
|
|
140
|
-
function nextTick(fn) {
|
|
141
|
-
const set = /* @__PURE__ */ new Set();
|
|
142
|
-
function raf2(fn2) {
|
|
143
|
-
const id = globalThis.requestAnimationFrame(fn2);
|
|
144
|
-
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
145
|
-
}
|
|
146
|
-
raf2(() => raf2(fn));
|
|
147
|
-
return function cleanup() {
|
|
148
|
-
set.forEach(function(fn2) {
|
|
149
|
-
fn2();
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function raf(fn) {
|
|
154
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
155
|
-
return function cleanup() {
|
|
156
|
-
globalThis.cancelAnimationFrame(id);
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function getOwnerWindow(el) {
|
|
51
|
+
function getWindow(el) {
|
|
160
52
|
var _a;
|
|
161
53
|
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
162
54
|
}
|
|
@@ -226,7 +118,36 @@ function getElementOffset(element) {
|
|
|
226
118
|
left
|
|
227
119
|
};
|
|
228
120
|
}
|
|
229
|
-
var
|
|
121
|
+
var isDom = () => typeof window !== "undefined";
|
|
122
|
+
var isArray = (v) => Array.isArray(v);
|
|
123
|
+
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
124
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
125
|
+
function getPlatform() {
|
|
126
|
+
var _a;
|
|
127
|
+
const agent = navigator.userAgentData;
|
|
128
|
+
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
129
|
+
}
|
|
130
|
+
var pt = (v) => isDom() && v.test(getPlatform());
|
|
131
|
+
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
132
|
+
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
133
|
+
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
134
|
+
var isIos = () => isApple() && !isMac();
|
|
135
|
+
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
136
|
+
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
137
|
+
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
138
|
+
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
139
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
140
|
+
var isLeftClick = (v) => v.button === 0;
|
|
141
|
+
var runIfFn = (v, ...a) => {
|
|
142
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
143
|
+
return res != null ? res : void 0;
|
|
144
|
+
};
|
|
145
|
+
var callAll = (...fns) => (...a) => {
|
|
146
|
+
fns.forEach(function(fn) {
|
|
147
|
+
fn == null ? void 0 : fn(...a);
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
var fallback = {
|
|
230
151
|
pageX: 0,
|
|
231
152
|
pageY: 0,
|
|
232
153
|
clientX: 0,
|
|
@@ -234,7 +155,7 @@ var fallback2 = {
|
|
|
234
155
|
};
|
|
235
156
|
function getEventPoint(event, type = "page") {
|
|
236
157
|
var _a, _b;
|
|
237
|
-
const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b :
|
|
158
|
+
const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
|
|
238
159
|
return { x: point[`${type}X`], y: point[`${type}Y`] };
|
|
239
160
|
}
|
|
240
161
|
function getPointRelativeToNode(point, element) {
|
|
@@ -246,12 +167,12 @@ function getPointRelativeToNode(point, element) {
|
|
|
246
167
|
function getDescriptor(el, options) {
|
|
247
168
|
var _a;
|
|
248
169
|
const { type, property } = options;
|
|
249
|
-
const proto =
|
|
170
|
+
const proto = getWindow(el)[type].prototype;
|
|
250
171
|
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
251
172
|
}
|
|
252
173
|
function dispatchInputValueEvent(el, value) {
|
|
253
174
|
var _a;
|
|
254
|
-
const win =
|
|
175
|
+
const win = getWindow(el);
|
|
255
176
|
if (!(el instanceof win.HTMLInputElement))
|
|
256
177
|
return;
|
|
257
178
|
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
@@ -296,6 +217,89 @@ function getEventStep(event) {
|
|
|
296
217
|
return isSkipKey ? 10 : 1;
|
|
297
218
|
}
|
|
298
219
|
}
|
|
220
|
+
var isRef = (v) => hasProp(v, "current");
|
|
221
|
+
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
222
|
+
function extractInfo(event, type = "page") {
|
|
223
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
224
|
+
return {
|
|
225
|
+
point: {
|
|
226
|
+
x: point[`${type}X`],
|
|
227
|
+
y: point[`${type}Y`]
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
232
|
+
const node = isRef(target) ? target.current : runIfFn(target);
|
|
233
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
234
|
+
return () => {
|
|
235
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function addPointerEvent(target, event, listener, options) {
|
|
239
|
+
var _a;
|
|
240
|
+
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
241
|
+
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
242
|
+
}
|
|
243
|
+
function wrapHandler(fn, filter = false) {
|
|
244
|
+
const listener = (event) => {
|
|
245
|
+
fn(event, extractInfo(event));
|
|
246
|
+
};
|
|
247
|
+
return filter ? filterPrimaryPointer(listener) : listener;
|
|
248
|
+
}
|
|
249
|
+
function filterPrimaryPointer(fn) {
|
|
250
|
+
return (event) => {
|
|
251
|
+
var _a;
|
|
252
|
+
const win = (_a = event.view) != null ? _a : window;
|
|
253
|
+
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
254
|
+
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
255
|
+
if (isPrimary)
|
|
256
|
+
fn(event);
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
var mouseEventNames = {
|
|
260
|
+
pointerdown: "mousedown",
|
|
261
|
+
pointermove: "mousemove",
|
|
262
|
+
pointerup: "mouseup",
|
|
263
|
+
pointercancel: "mousecancel",
|
|
264
|
+
pointerover: "mouseover",
|
|
265
|
+
pointerout: "mouseout",
|
|
266
|
+
pointerenter: "mouseenter",
|
|
267
|
+
pointerleave: "mouseleave"
|
|
268
|
+
};
|
|
269
|
+
var touchEventNames = {
|
|
270
|
+
pointerdown: "touchstart",
|
|
271
|
+
pointermove: "touchmove",
|
|
272
|
+
pointerup: "touchend",
|
|
273
|
+
pointercancel: "touchcancel"
|
|
274
|
+
};
|
|
275
|
+
function getEventName(evt) {
|
|
276
|
+
if (supportsPointerEvent())
|
|
277
|
+
return evt;
|
|
278
|
+
if (supportsTouchEvent())
|
|
279
|
+
return touchEventNames[evt];
|
|
280
|
+
if (supportsMouseEvent())
|
|
281
|
+
return mouseEventNames[evt];
|
|
282
|
+
return evt;
|
|
283
|
+
}
|
|
284
|
+
function nextTick(fn) {
|
|
285
|
+
const set = /* @__PURE__ */ new Set();
|
|
286
|
+
function raf2(fn2) {
|
|
287
|
+
const id = globalThis.requestAnimationFrame(fn2);
|
|
288
|
+
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
289
|
+
}
|
|
290
|
+
raf2(() => raf2(fn));
|
|
291
|
+
return function cleanup() {
|
|
292
|
+
set.forEach(function(fn2) {
|
|
293
|
+
fn2();
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function raf(fn) {
|
|
298
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
299
|
+
return function cleanup() {
|
|
300
|
+
globalThis.cancelAnimationFrame(id);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
299
303
|
var state = "default";
|
|
300
304
|
var savedUserSelect = "";
|
|
301
305
|
var modifiedElementMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -357,7 +361,7 @@ function trackPointerMove(opts) {
|
|
|
357
361
|
}
|
|
358
362
|
onPointerMove(info, event);
|
|
359
363
|
};
|
|
360
|
-
return
|
|
364
|
+
return callAll(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
|
|
361
365
|
}
|
|
362
366
|
|
|
363
367
|
// ../../utilities/number/dist/index.mjs
|
package/dist/index.mjs
CHANGED
|
@@ -24,115 +24,7 @@ var __pow = Math.pow;
|
|
|
24
24
|
var dataAttr = (guard) => {
|
|
25
25
|
return guard ? "" : void 0;
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
var isArray = (v) => Array.isArray(v);
|
|
29
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
30
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
31
|
-
function getPlatform() {
|
|
32
|
-
var _a;
|
|
33
|
-
const agent = navigator.userAgentData;
|
|
34
|
-
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
35
|
-
}
|
|
36
|
-
var pt = (v) => isDom() && v.test(getPlatform());
|
|
37
|
-
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
38
|
-
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
39
|
-
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
40
|
-
var isIos = () => isApple() && !isMac();
|
|
41
|
-
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
42
|
-
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
43
|
-
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
44
|
-
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
45
|
-
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
46
|
-
var isLeftClick = (v) => v.button === 0;
|
|
47
|
-
var runIfFn = (v, ...a) => {
|
|
48
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
49
|
-
return res != null ? res : void 0;
|
|
50
|
-
};
|
|
51
|
-
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
52
|
-
var isRef = (v) => hasProp(v, "current");
|
|
53
|
-
var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
54
|
-
function extractInfo(event, type = "page") {
|
|
55
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
|
|
56
|
-
return {
|
|
57
|
-
point: {
|
|
58
|
-
x: point[`${type}X`],
|
|
59
|
-
y: point[`${type}Y`]
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
64
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
65
|
-
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
66
|
-
return () => {
|
|
67
|
-
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function addPointerEvent(target, event, listener, options) {
|
|
71
|
-
var _a;
|
|
72
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
73
|
-
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
74
|
-
}
|
|
75
|
-
function wrapHandler(fn, filter = false) {
|
|
76
|
-
const listener = (event) => {
|
|
77
|
-
fn(event, extractInfo(event));
|
|
78
|
-
};
|
|
79
|
-
return filter ? filterPrimaryPointer(listener) : listener;
|
|
80
|
-
}
|
|
81
|
-
function filterPrimaryPointer(fn) {
|
|
82
|
-
return (event) => {
|
|
83
|
-
var _a;
|
|
84
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
85
|
-
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
86
|
-
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
87
|
-
if (isPrimary)
|
|
88
|
-
fn(event);
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
var mouseEventNames = {
|
|
92
|
-
pointerdown: "mousedown",
|
|
93
|
-
pointermove: "mousemove",
|
|
94
|
-
pointerup: "mouseup",
|
|
95
|
-
pointercancel: "mousecancel",
|
|
96
|
-
pointerover: "mouseover",
|
|
97
|
-
pointerout: "mouseout",
|
|
98
|
-
pointerenter: "mouseenter",
|
|
99
|
-
pointerleave: "mouseleave"
|
|
100
|
-
};
|
|
101
|
-
var touchEventNames = {
|
|
102
|
-
pointerdown: "touchstart",
|
|
103
|
-
pointermove: "touchmove",
|
|
104
|
-
pointerup: "touchend",
|
|
105
|
-
pointercancel: "touchcancel"
|
|
106
|
-
};
|
|
107
|
-
function getEventName(evt) {
|
|
108
|
-
if (supportsPointerEvent())
|
|
109
|
-
return evt;
|
|
110
|
-
if (supportsTouchEvent())
|
|
111
|
-
return touchEventNames[evt];
|
|
112
|
-
if (supportsMouseEvent())
|
|
113
|
-
return mouseEventNames[evt];
|
|
114
|
-
return evt;
|
|
115
|
-
}
|
|
116
|
-
function nextTick(fn) {
|
|
117
|
-
const set = /* @__PURE__ */ new Set();
|
|
118
|
-
function raf2(fn2) {
|
|
119
|
-
const id = globalThis.requestAnimationFrame(fn2);
|
|
120
|
-
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
121
|
-
}
|
|
122
|
-
raf2(() => raf2(fn));
|
|
123
|
-
return function cleanup() {
|
|
124
|
-
set.forEach(function(fn2) {
|
|
125
|
-
fn2();
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function raf(fn) {
|
|
130
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
131
|
-
return function cleanup() {
|
|
132
|
-
globalThis.cancelAnimationFrame(id);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function getOwnerWindow(el) {
|
|
27
|
+
function getWindow(el) {
|
|
136
28
|
var _a;
|
|
137
29
|
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
138
30
|
}
|
|
@@ -202,7 +94,36 @@ function getElementOffset(element) {
|
|
|
202
94
|
left
|
|
203
95
|
};
|
|
204
96
|
}
|
|
205
|
-
var
|
|
97
|
+
var isDom = () => typeof window !== "undefined";
|
|
98
|
+
var isArray = (v) => Array.isArray(v);
|
|
99
|
+
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
100
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
101
|
+
function getPlatform() {
|
|
102
|
+
var _a;
|
|
103
|
+
const agent = navigator.userAgentData;
|
|
104
|
+
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
105
|
+
}
|
|
106
|
+
var pt = (v) => isDom() && v.test(getPlatform());
|
|
107
|
+
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
108
|
+
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
109
|
+
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
110
|
+
var isIos = () => isApple() && !isMac();
|
|
111
|
+
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
112
|
+
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
113
|
+
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
114
|
+
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
|
|
115
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
116
|
+
var isLeftClick = (v) => v.button === 0;
|
|
117
|
+
var runIfFn = (v, ...a) => {
|
|
118
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
119
|
+
return res != null ? res : void 0;
|
|
120
|
+
};
|
|
121
|
+
var callAll = (...fns) => (...a) => {
|
|
122
|
+
fns.forEach(function(fn) {
|
|
123
|
+
fn == null ? void 0 : fn(...a);
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
var fallback = {
|
|
206
127
|
pageX: 0,
|
|
207
128
|
pageY: 0,
|
|
208
129
|
clientX: 0,
|
|
@@ -210,7 +131,7 @@ var fallback2 = {
|
|
|
210
131
|
};
|
|
211
132
|
function getEventPoint(event, type = "page") {
|
|
212
133
|
var _a, _b;
|
|
213
|
-
const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b :
|
|
134
|
+
const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
|
|
214
135
|
return { x: point[`${type}X`], y: point[`${type}Y`] };
|
|
215
136
|
}
|
|
216
137
|
function getPointRelativeToNode(point, element) {
|
|
@@ -222,12 +143,12 @@ function getPointRelativeToNode(point, element) {
|
|
|
222
143
|
function getDescriptor(el, options) {
|
|
223
144
|
var _a;
|
|
224
145
|
const { type, property } = options;
|
|
225
|
-
const proto =
|
|
146
|
+
const proto = getWindow(el)[type].prototype;
|
|
226
147
|
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
|
|
227
148
|
}
|
|
228
149
|
function dispatchInputValueEvent(el, value) {
|
|
229
150
|
var _a;
|
|
230
|
-
const win =
|
|
151
|
+
const win = getWindow(el);
|
|
231
152
|
if (!(el instanceof win.HTMLInputElement))
|
|
232
153
|
return;
|
|
233
154
|
const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
|
|
@@ -272,6 +193,89 @@ function getEventStep(event) {
|
|
|
272
193
|
return isSkipKey ? 10 : 1;
|
|
273
194
|
}
|
|
274
195
|
}
|
|
196
|
+
var isRef = (v) => hasProp(v, "current");
|
|
197
|
+
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
198
|
+
function extractInfo(event, type = "page") {
|
|
199
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
200
|
+
return {
|
|
201
|
+
point: {
|
|
202
|
+
x: point[`${type}X`],
|
|
203
|
+
y: point[`${type}Y`]
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
208
|
+
const node = isRef(target) ? target.current : runIfFn(target);
|
|
209
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
210
|
+
return () => {
|
|
211
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function addPointerEvent(target, event, listener, options) {
|
|
215
|
+
var _a;
|
|
216
|
+
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
217
|
+
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
218
|
+
}
|
|
219
|
+
function wrapHandler(fn, filter = false) {
|
|
220
|
+
const listener = (event) => {
|
|
221
|
+
fn(event, extractInfo(event));
|
|
222
|
+
};
|
|
223
|
+
return filter ? filterPrimaryPointer(listener) : listener;
|
|
224
|
+
}
|
|
225
|
+
function filterPrimaryPointer(fn) {
|
|
226
|
+
return (event) => {
|
|
227
|
+
var _a;
|
|
228
|
+
const win = (_a = event.view) != null ? _a : window;
|
|
229
|
+
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
230
|
+
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
231
|
+
if (isPrimary)
|
|
232
|
+
fn(event);
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
var mouseEventNames = {
|
|
236
|
+
pointerdown: "mousedown",
|
|
237
|
+
pointermove: "mousemove",
|
|
238
|
+
pointerup: "mouseup",
|
|
239
|
+
pointercancel: "mousecancel",
|
|
240
|
+
pointerover: "mouseover",
|
|
241
|
+
pointerout: "mouseout",
|
|
242
|
+
pointerenter: "mouseenter",
|
|
243
|
+
pointerleave: "mouseleave"
|
|
244
|
+
};
|
|
245
|
+
var touchEventNames = {
|
|
246
|
+
pointerdown: "touchstart",
|
|
247
|
+
pointermove: "touchmove",
|
|
248
|
+
pointerup: "touchend",
|
|
249
|
+
pointercancel: "touchcancel"
|
|
250
|
+
};
|
|
251
|
+
function getEventName(evt) {
|
|
252
|
+
if (supportsPointerEvent())
|
|
253
|
+
return evt;
|
|
254
|
+
if (supportsTouchEvent())
|
|
255
|
+
return touchEventNames[evt];
|
|
256
|
+
if (supportsMouseEvent())
|
|
257
|
+
return mouseEventNames[evt];
|
|
258
|
+
return evt;
|
|
259
|
+
}
|
|
260
|
+
function nextTick(fn) {
|
|
261
|
+
const set = /* @__PURE__ */ new Set();
|
|
262
|
+
function raf2(fn2) {
|
|
263
|
+
const id = globalThis.requestAnimationFrame(fn2);
|
|
264
|
+
set.add(() => globalThis.cancelAnimationFrame(id));
|
|
265
|
+
}
|
|
266
|
+
raf2(() => raf2(fn));
|
|
267
|
+
return function cleanup() {
|
|
268
|
+
set.forEach(function(fn2) {
|
|
269
|
+
fn2();
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function raf(fn) {
|
|
274
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
275
|
+
return function cleanup() {
|
|
276
|
+
globalThis.cancelAnimationFrame(id);
|
|
277
|
+
};
|
|
278
|
+
}
|
|
275
279
|
var state = "default";
|
|
276
280
|
var savedUserSelect = "";
|
|
277
281
|
var modifiedElementMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -333,7 +337,7 @@ function trackPointerMove(opts) {
|
|
|
333
337
|
}
|
|
334
338
|
onPointerMove(info, event);
|
|
335
339
|
};
|
|
336
|
-
return
|
|
340
|
+
return callAll(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
|
|
337
341
|
}
|
|
338
342
|
|
|
339
343
|
// ../../utilities/number/dist/index.mjs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/slider",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20220703193942",
|
|
4
4
|
"description": "Core logic for the slider widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.0.0-dev-
|
|
33
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
32
|
+
"@zag-js/core": "0.0.0-dev-20220703193942",
|
|
33
|
+
"@zag-js/dom-utils": "0.0.0-dev-20220703193942",
|
|
34
34
|
"@zag-js/number-utils": "0.1.2",
|
|
35
|
-
"@zag-js/types": "0.0.0-dev-
|
|
35
|
+
"@zag-js/types": "0.0.0-dev-20220703193942",
|
|
36
36
|
"@zag-js/utils": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|