@zag-js/slider 0.2.6 → 0.2.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 CHANGED
@@ -43,10 +43,12 @@ var anatomy = (0, import_anatomy.createAnatomy)("slider").parts(
43
43
  );
44
44
  var parts = anatomy.build();
45
45
 
46
- // ../../utilities/dom/dist/index.mjs
46
+ // ../../utilities/dom/src/attrs.ts
47
47
  var dataAttr = (guard) => {
48
48
  return guard ? "" : void 0;
49
49
  };
50
+
51
+ // ../../utilities/core/src/functions.ts
50
52
  var runIfFn = (v, ...a) => {
51
53
  const res = typeof v === "function" ? v(...a) : v;
52
54
  return res != null ? res : void 0;
@@ -56,9 +58,22 @@ var callAll = (...fns) => (...a) => {
56
58
  fn == null ? void 0 : fn(...a);
57
59
  });
58
60
  };
61
+
62
+ // ../../utilities/core/src/guard.ts
59
63
  var isArray = (v) => Array.isArray(v);
60
64
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
61
65
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
66
+
67
+ // ../../utilities/core/src/object.ts
68
+ function compact(obj) {
69
+ if (obj === void 0)
70
+ return obj;
71
+ return Object.fromEntries(
72
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
73
+ );
74
+ }
75
+
76
+ // ../../utilities/dom/src/platform.ts
62
77
  var isDom = () => typeof window !== "undefined";
63
78
  function getPlatform() {
64
79
  var _a;
@@ -70,6 +85,8 @@ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
70
85
  var isMac = () => pt(/^Mac/) && !isTouchDevice;
71
86
  var isApple = () => pt(/mac|iphone|ipad|ipod/i);
72
87
  var isIos = () => isApple() && !isMac();
88
+
89
+ // ../../utilities/dom/src/query.ts
73
90
  function isDocument(el) {
74
91
  return el.nodeType === Node.DOCUMENT_NODE;
75
92
  }
@@ -84,6 +101,10 @@ function getDocument(el) {
84
101
  return el;
85
102
  return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
86
103
  }
104
+ function getWindow(el) {
105
+ var _a;
106
+ return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
107
+ }
87
108
  function defineDomHelpers(helpers) {
88
109
  const dom2 = {
89
110
  getRootNode: (ctx) => {
@@ -121,6 +142,8 @@ function defineDomHelpers(helpers) {
121
142
  ...helpers
122
143
  };
123
144
  }
145
+
146
+ // ../../utilities/dom/src/event.ts
124
147
  function getNativeEvent(e) {
125
148
  var _a;
126
149
  return (_a = e.nativeEvent) != null ? _a : e;
@@ -132,6 +155,8 @@ var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
132
155
  var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
133
156
  var isLeftClick = (v) => v.button === 0;
134
157
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
158
+
159
+ // ../../utilities/dom/src/get-element-offset.ts
135
160
  function getElementOffset(element) {
136
161
  let left = 0;
137
162
  let top = 0;
@@ -154,6 +179,8 @@ function getElementOffset(element) {
154
179
  left
155
180
  };
156
181
  }
182
+
183
+ // ../../utilities/dom/src/get-event-point.ts
157
184
  var fallback = {
158
185
  pageX: 0,
159
186
  pageY: 0,
@@ -165,12 +192,16 @@ function getEventPoint(event, type = "page") {
165
192
  const point = isTouchEvent(event) ? (_b = (_a = event.touches[0]) != null ? _a : event.changedTouches[0]) != null ? _b : fallback : event;
166
193
  return { x: point[`${type}X`], y: point[`${type}Y`] };
167
194
  }
195
+
196
+ // ../../utilities/dom/src/get-point-relative-to-element.ts
168
197
  function getPointRelativeToNode(point, element) {
169
198
  const offset = getElementOffset(element);
170
199
  const x = point.x - offset.left;
171
200
  const y = point.y - offset.top;
172
201
  return { x, y };
173
202
  }
203
+
204
+ // ../../utilities/dom/src/keyboard-event.ts
174
205
  var rtlKeyMap = {
175
206
  ArrowLeft: "ArrowRight",
176
207
  ArrowRight: "ArrowLeft"
@@ -206,6 +237,8 @@ function getEventStep(event) {
206
237
  return isSkipKey ? 10 : 1;
207
238
  }
208
239
  }
240
+
241
+ // ../../utilities/dom/src/listener.ts
209
242
  var isRef = (v) => hasProp(v, "current");
210
243
  var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
211
244
  function extractInfo(event, type = "page") {
@@ -270,6 +303,25 @@ function getEventName(evt) {
270
303
  return mouseEventNames[evt];
271
304
  return evt;
272
305
  }
306
+
307
+ // ../../utilities/dom/src/mutation-observer.ts
308
+ function observeAttributes(node, attributes, fn) {
309
+ if (!node)
310
+ return;
311
+ const attrs = Array.isArray(attributes) ? attributes : [attributes];
312
+ const win = node.ownerDocument.defaultView || window;
313
+ const obs = new win.MutationObserver((changes) => {
314
+ for (const change of changes) {
315
+ if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
316
+ fn(change);
317
+ }
318
+ }
319
+ });
320
+ obs.observe(node, { attributes: true, attributeFilter: attrs });
321
+ return () => obs.disconnect();
322
+ }
323
+
324
+ // ../../utilities/dom/src/next-tick.ts
273
325
  function nextTick(fn) {
274
326
  const set = /* @__PURE__ */ new Set();
275
327
  function raf2(fn2) {
@@ -289,6 +341,8 @@ function raf(fn) {
289
341
  globalThis.cancelAnimationFrame(id);
290
342
  };
291
343
  }
344
+
345
+ // ../../utilities/dom/src/text-selection.ts
292
346
  var state = "default";
293
347
  var savedUserSelect = "";
294
348
  var modifiedElementMap = /* @__PURE__ */ new WeakMap();
@@ -336,6 +390,8 @@ function restoreTextSelection({ target, doc } = {}) {
336
390
  }
337
391
  }
338
392
  }
393
+
394
+ // ../../utilities/dom/src/pointer-event.ts
339
395
  var THRESHOLD = 5;
340
396
  function trackPointerMove(doc, opts) {
341
397
  const { onPointerMove, onPointerUp } = opts;
@@ -359,7 +415,7 @@ function trackPointerMove(doc, opts) {
359
415
  );
360
416
  }
361
417
 
362
- // ../../utilities/number/dist/index.mjs
418
+ // ../../utilities/number/src/number.ts
363
419
  function round(v, t) {
364
420
  let num = valueOf(v);
365
421
  const p = 10 ** (t != null ? t : 10);
@@ -406,7 +462,8 @@ function decimalOperation(a, op, b) {
406
462
  }
407
463
  return result;
408
464
  }
409
- var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
465
+
466
+ // ../../utilities/number/src/transform.ts
410
467
  var transform = (a, b) => {
411
468
  const i = { min: a[0], max: a[1] };
412
469
  const o = { min: b[0], max: b[1] };
@@ -418,26 +475,7 @@ var transform = (a, b) => {
418
475
  };
419
476
  };
420
477
 
421
- // ../../utilities/form-utils/dist/index.mjs
422
- function getWindow(el) {
423
- var _a;
424
- return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
425
- }
426
- function observeAttributes(node, attributes, fn) {
427
- if (!node)
428
- return;
429
- const attrs = Array.isArray(attributes) ? attributes : [attributes];
430
- const win = node.ownerDocument.defaultView || window;
431
- const obs = new win.MutationObserver((changes) => {
432
- for (const change of changes) {
433
- if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
434
- fn(change);
435
- }
436
- }
437
- });
438
- obs.observe(node, { attributes: true, attributeFilter: attrs });
439
- return () => obs.disconnect();
440
- }
478
+ // ../../utilities/form-utils/src/input-event.ts
441
479
  function getDescriptor(el, options) {
442
480
  var _a;
443
481
  const { type, property = "value" } = options;
@@ -456,6 +494,8 @@ function dispatchInputValueEvent(el, value) {
456
494
  const event = new win.Event("input", { bubbles: true });
457
495
  el.dispatchEvent(event);
458
496
  }
497
+
498
+ // ../../utilities/form-utils/src/form.ts
459
499
  function getClosestForm(el) {
460
500
  if (isFormElement(el))
461
501
  return el.form;
@@ -901,19 +941,6 @@ function connect(state2, send, normalize) {
901
941
  // src/slider.machine.ts
902
942
  var import_core = require("@zag-js/core");
903
943
  var import_element_size = require("@zag-js/element-size");
904
-
905
- // ../../utilities/core/dist/index.mjs
906
- var isArray2 = (v) => Array.isArray(v);
907
- var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
908
- function compact(obj) {
909
- if (obj === void 0)
910
- return obj;
911
- return Object.fromEntries(
912
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject2(value) ? compact(value) : value])
913
- );
914
- }
915
-
916
- // src/slider.machine.ts
917
944
  function machine(userContext) {
918
945
  const ctx = compact(userContext);
919
946
  return (0, import_core.createMachine)(