@zag-js/slider 0.2.12 → 0.2.14

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,410 +43,15 @@ var anatomy = (0, import_anatomy.createAnatomy)("slider").parts(
43
43
  );
44
44
  var parts = anatomy.build();
45
45
 
46
- // ../../utilities/dom/src/attrs.ts
47
- var dataAttr = (guard) => {
48
- return guard ? "" : void 0;
49
- };
50
-
51
- // ../../utilities/core/src/functions.ts
52
- var runIfFn = (v, ...a) => {
53
- const res = typeof v === "function" ? v(...a) : v;
54
- return res ?? void 0;
55
- };
56
- var callAll = (...fns) => (...a) => {
57
- fns.forEach(function(fn) {
58
- fn?.(...a);
59
- });
60
- };
61
-
62
- // ../../utilities/core/src/guard.ts
63
- var isArray = (v) => Array.isArray(v);
64
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
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
77
- var isDom = () => typeof window !== "undefined";
78
- function getPlatform() {
79
- const agent = navigator.userAgentData;
80
- return agent?.platform ?? navigator.platform;
81
- }
82
- var pt = (v) => isDom() && v.test(getPlatform());
83
- var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
84
- var isMac = () => pt(/^Mac/) && !isTouchDevice;
85
- var isApple = () => pt(/mac|iphone|ipad|ipod/i);
86
- var isIos = () => isApple() && !isMac();
87
-
88
- // ../../utilities/dom/src/query.ts
89
- function isDocument(el) {
90
- return el.nodeType === Node.DOCUMENT_NODE;
91
- }
92
- function isWindow(value) {
93
- return value?.toString() === "[object Window]";
94
- }
95
- function getDocument(el) {
96
- if (isWindow(el))
97
- return el.document;
98
- if (isDocument(el))
99
- return el;
100
- return el?.ownerDocument ?? document;
101
- }
102
- function getWindow(el) {
103
- return el?.ownerDocument.defaultView ?? window;
104
- }
105
- function defineDomHelpers(helpers) {
106
- const dom2 = {
107
- getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
108
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
109
- getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
110
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
111
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
112
- };
113
- return {
114
- ...dom2,
115
- ...helpers
116
- };
117
- }
118
-
119
- // ../../utilities/dom/src/event.ts
120
- function getNativeEvent(e) {
121
- return e.nativeEvent ?? e;
122
- }
123
- var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
124
- var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
125
- var supportsMouseEvent = () => isDom() && window.onmousedown === null;
126
- var isMouseEvent = (v) => isObject(v) && hasProp(v, "button");
127
- var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
128
- var isLeftClick = (v) => v.button === 0;
129
- var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
130
-
131
- // ../../utilities/dom/src/get-element-offset.ts
132
- function getElementOffset(element) {
133
- let left = 0;
134
- let top = 0;
135
- let el = element;
136
- if (el.parentNode) {
137
- do {
138
- left += el.offsetLeft;
139
- top += el.offsetTop;
140
- } while ((el = el.offsetParent) && el.nodeType < 9);
141
- el = element;
142
- do {
143
- left -= el.scrollLeft;
144
- top -= el.scrollTop;
145
- } while ((el = el.parentNode) && !/body/i.test(el.nodeName));
146
- }
147
- return {
148
- top,
149
- right: innerWidth - left - element.offsetWidth,
150
- bottom: innerHeight - top - element.offsetHeight,
151
- left
152
- };
153
- }
154
-
155
- // ../../utilities/dom/src/get-event-point.ts
156
- var fallback = {
157
- pageX: 0,
158
- pageY: 0,
159
- clientX: 0,
160
- clientY: 0
161
- };
162
- function getEventPoint(event, type = "page") {
163
- const point = isTouchEvent(event) ? event.touches[0] ?? event.changedTouches[0] ?? fallback : event;
164
- return { x: point[`${type}X`], y: point[`${type}Y`] };
165
- }
166
-
167
- // ../../utilities/dom/src/get-point-relative-to-element.ts
168
- function getPointRelativeToNode(point, element) {
169
- const offset = getElementOffset(element);
170
- const x = point.x - offset.left;
171
- const y = point.y - offset.top;
172
- return { x, y };
173
- }
174
-
175
- // ../../utilities/dom/src/keyboard-event.ts
176
- var rtlKeyMap = {
177
- ArrowLeft: "ArrowRight",
178
- ArrowRight: "ArrowLeft"
179
- };
180
- var sameKeyMap = {
181
- Up: "ArrowUp",
182
- Down: "ArrowDown",
183
- Esc: "Escape",
184
- " ": "Space",
185
- ",": "Comma",
186
- Left: "ArrowLeft",
187
- Right: "ArrowRight"
188
- };
189
- function getEventKey(event, options = {}) {
190
- const { dir = "ltr", orientation = "horizontal" } = options;
191
- let { key } = event;
192
- key = sameKeyMap[key] ?? key;
193
- const isRtl = dir === "rtl" && orientation === "horizontal";
194
- if (isRtl && key in rtlKeyMap) {
195
- key = rtlKeyMap[key];
196
- }
197
- return key;
198
- }
199
- var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
200
- var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
201
- function getEventStep(event) {
202
- if (event.ctrlKey || event.metaKey) {
203
- return 0.1;
204
- } else {
205
- const isPageKey = PAGE_KEYS.has(event.key);
206
- const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
207
- return isSkipKey ? 10 : 1;
208
- }
209
- }
210
-
211
- // ../../utilities/dom/src/listener.ts
212
- var isRef = (v) => hasProp(v, "current");
213
- var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
214
- function extractInfo(event, type = "page") {
215
- const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
216
- return {
217
- point: {
218
- x: point[`${type}X`],
219
- y: point[`${type}Y`]
220
- }
221
- };
222
- }
223
- function addDomEvent(target, eventName, handler, options) {
224
- const node = isRef(target) ? target.current : runIfFn(target);
225
- node?.addEventListener(eventName, handler, options);
226
- return () => {
227
- node?.removeEventListener(eventName, handler, options);
228
- };
229
- }
230
- function addPointerEvent(target, event, listener, options) {
231
- const type = getEventName(event) ?? event;
232
- return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
233
- }
234
- function wrapHandler(fn, filter = false) {
235
- const listener = (event) => {
236
- fn(event, extractInfo(event));
237
- };
238
- return filter ? filterPrimaryPointer(listener) : listener;
239
- }
240
- function filterPrimaryPointer(fn) {
241
- return (event) => {
242
- const win = event.view ?? window;
243
- const isMouseEvent2 = event instanceof win.MouseEvent;
244
- const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
245
- if (isPrimary)
246
- fn(event);
247
- };
248
- }
249
- var mouseEventNames = {
250
- pointerdown: "mousedown",
251
- pointermove: "mousemove",
252
- pointerup: "mouseup",
253
- pointercancel: "mousecancel",
254
- pointerover: "mouseover",
255
- pointerout: "mouseout",
256
- pointerenter: "mouseenter",
257
- pointerleave: "mouseleave"
258
- };
259
- var touchEventNames = {
260
- pointerdown: "touchstart",
261
- pointermove: "touchmove",
262
- pointerup: "touchend",
263
- pointercancel: "touchcancel"
264
- };
265
- function getEventName(evt) {
266
- if (supportsPointerEvent())
267
- return evt;
268
- if (supportsTouchEvent())
269
- return touchEventNames[evt];
270
- if (supportsMouseEvent())
271
- return mouseEventNames[evt];
272
- return evt;
273
- }
274
-
275
- // ../../utilities/dom/src/mutation-observer.ts
276
- function observeAttributes(node, attributes, fn) {
277
- if (!node)
278
- return;
279
- const attrs = Array.isArray(attributes) ? attributes : [attributes];
280
- const win = node.ownerDocument.defaultView || window;
281
- const obs = new win.MutationObserver((changes) => {
282
- for (const change of changes) {
283
- if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
284
- fn(change);
285
- }
286
- }
287
- });
288
- obs.observe(node, { attributes: true, attributeFilter: attrs });
289
- return () => obs.disconnect();
290
- }
291
-
292
- // ../../utilities/dom/src/next-tick.ts
293
- function nextTick(fn) {
294
- const set = /* @__PURE__ */ new Set();
295
- function raf2(fn2) {
296
- const id = globalThis.requestAnimationFrame(fn2);
297
- set.add(() => globalThis.cancelAnimationFrame(id));
298
- }
299
- raf2(() => raf2(fn));
300
- return function cleanup() {
301
- set.forEach(function(fn2) {
302
- fn2();
303
- });
304
- };
305
- }
306
- function raf(fn) {
307
- const id = globalThis.requestAnimationFrame(fn);
308
- return function cleanup() {
309
- globalThis.cancelAnimationFrame(id);
310
- };
311
- }
312
-
313
- // ../../utilities/dom/src/text-selection.ts
314
- var state = "default";
315
- var savedUserSelect = "";
316
- var modifiedElementMap = /* @__PURE__ */ new WeakMap();
317
- function disableTextSelection({ target, doc } = {}) {
318
- const _document = doc ?? document;
319
- if (isIos()) {
320
- if (state === "default") {
321
- savedUserSelect = _document.documentElement.style.webkitUserSelect;
322
- _document.documentElement.style.webkitUserSelect = "none";
323
- }
324
- state = "disabled";
325
- } else if (target) {
326
- modifiedElementMap.set(target, target.style.userSelect);
327
- target.style.userSelect = "none";
328
- }
329
- return () => restoreTextSelection({ target, doc: _document });
330
- }
331
- function restoreTextSelection({ target, doc } = {}) {
332
- const _document = doc ?? document;
333
- if (isIos()) {
334
- if (state !== "disabled")
335
- return;
336
- state = "restoring";
337
- setTimeout(() => {
338
- nextTick(() => {
339
- if (state === "restoring") {
340
- if (_document.documentElement.style.webkitUserSelect === "none") {
341
- _document.documentElement.style.webkitUserSelect = savedUserSelect || "";
342
- }
343
- savedUserSelect = "";
344
- state = "default";
345
- }
346
- });
347
- }, 300);
348
- } else {
349
- if (target && modifiedElementMap.has(target)) {
350
- let targetOldUserSelect = modifiedElementMap.get(target);
351
- if (target.style.userSelect === "none") {
352
- target.style.userSelect = targetOldUserSelect ?? "";
353
- }
354
- if (target.getAttribute("style") === "") {
355
- target.removeAttribute("style");
356
- }
357
- modifiedElementMap.delete(target);
358
- }
359
- }
360
- }
361
-
362
- // ../../utilities/dom/src/pointer-event.ts
363
- var THRESHOLD = 5;
364
- function trackPointerMove(doc, opts) {
365
- const { onPointerMove, onPointerUp } = opts;
366
- const handlePointerMove = (event, info) => {
367
- const { point: p } = info;
368
- const distance = Math.sqrt(p.x ** 2 + p.y ** 2);
369
- if (distance < THRESHOLD)
370
- return;
371
- if (isMouseEvent(event) && isLeftClick(event)) {
372
- onPointerUp();
373
- return;
374
- }
375
- onPointerMove(info, event);
376
- };
377
- return callAll(
378
- addPointerEvent(doc, "pointermove", handlePointerMove, false),
379
- addPointerEvent(doc, "pointerup", onPointerUp, false),
380
- addPointerEvent(doc, "pointercancel", onPointerUp, false),
381
- addPointerEvent(doc, "contextmenu", onPointerUp, false),
382
- disableTextSelection({ doc })
383
- );
384
- }
385
-
386
46
  // src/slider.connect.ts
47
+ var import_dom_event2 = require("@zag-js/dom-event");
48
+ var import_dom_query2 = require("@zag-js/dom-query");
387
49
  var import_numeric_range3 = require("@zag-js/numeric-range");
388
50
 
389
- // ../../utilities/form-utils/src/input-event.ts
390
- function getDescriptor(el, options) {
391
- const { type, property = "value" } = options;
392
- const proto = getWindow(el)[type].prototype;
393
- return Object.getOwnPropertyDescriptor(proto, property) ?? {};
394
- }
395
- function dispatchInputValueEvent(el, value) {
396
- if (!el)
397
- return;
398
- const win = getWindow(el);
399
- if (!(el instanceof win.HTMLInputElement))
400
- return;
401
- const desc = getDescriptor(el, { type: "HTMLInputElement", property: "value" });
402
- desc.set?.call(el, value);
403
- const event = new win.Event("input", { bubbles: true });
404
- el.dispatchEvent(event);
405
- }
406
-
407
- // ../../utilities/form-utils/src/form.ts
408
- function getClosestForm(el) {
409
- if (isFormElement(el))
410
- return el.form;
411
- else
412
- return el.closest("form");
413
- }
414
- function isFormElement(el) {
415
- return el.matches("textarea, input, select, button");
416
- }
417
- function trackFormReset(el, callback) {
418
- if (!el)
419
- return;
420
- const form = getClosestForm(el);
421
- form?.addEventListener("reset", callback, { passive: true });
422
- return () => {
423
- form?.removeEventListener("reset", callback);
424
- };
425
- }
426
- function trackFieldsetDisabled(el, callback) {
427
- const fieldset = el?.closest("fieldset");
428
- if (!fieldset)
429
- return;
430
- callback(fieldset.disabled);
431
- return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
432
- }
433
- function trackFormControl(el, options) {
434
- if (!el)
435
- return;
436
- const { onFieldsetDisabled, onFormReset } = options;
437
- const cleanups = [
438
- trackFormReset(el, onFormReset),
439
- trackFieldsetDisabled(el, (disabled) => {
440
- if (disabled)
441
- onFieldsetDisabled();
442
- })
443
- ];
444
- return () => {
445
- cleanups.forEach((cleanup) => cleanup?.());
446
- };
447
- }
448
-
449
51
  // src/slider.dom.ts
52
+ var import_dom_query = require("@zag-js/dom-query");
53
+ var import_dom_event = require("@zag-js/dom-event");
54
+ var import_form_utils = require("@zag-js/form-utils");
450
55
  var import_numeric_range2 = require("@zag-js/numeric-range");
451
56
 
452
57
  // src/slider.style.ts
@@ -562,7 +167,7 @@ var styles = {
562
167
  };
563
168
 
564
169
  // src/slider.dom.ts
565
- var dom = defineDomHelpers({
170
+ var dom = (0, import_dom_query.createScope)({
566
171
  ...styles,
567
172
  getRootId: (ctx) => ctx.ids?.root ?? `slider:${ctx.id}`,
568
173
  getThumbId: (ctx) => ctx.ids?.thumb ?? `slider:${ctx.id}:thumb`,
@@ -581,7 +186,7 @@ var dom = defineDomHelpers({
581
186
  const el = dom.getControlEl(ctx);
582
187
  if (!el)
583
188
  return;
584
- const relativePoint = getPointRelativeToNode(point, el);
189
+ const relativePoint = (0, import_dom_event.getRelativePointValue)(point, el);
585
190
  const percentX = relativePoint.x / el.offsetWidth;
586
191
  const percentY = relativePoint.y / el.offsetHeight;
587
192
  let percent;
@@ -596,86 +201,116 @@ var dom = defineDomHelpers({
596
201
  const input = dom.getHiddenInputEl(ctx);
597
202
  if (!input)
598
203
  return;
599
- dispatchInputValueEvent(input, ctx.value);
204
+ (0, import_form_utils.dispatchInputValueEvent)(input, ctx.value);
600
205
  }
601
206
  });
602
207
 
603
208
  // src/slider.connect.ts
604
- function connect(state2, send, normalize) {
605
- const ariaLabel = state2.context["aria-label"];
606
- const ariaLabelledBy = state2.context["aria-labelledby"];
607
- const ariaValueText = state2.context.getAriaValueText?.(state2.context.value);
608
- const isFocused = state2.matches("focus");
609
- const isDragging = state2.matches("dragging");
610
- const isDisabled = state2.context.disabled;
611
- const isInteractive = state2.context.isInteractive;
612
- const isInvalid = state2.context.invalid;
209
+ function connect(state, send, normalize) {
210
+ const ariaLabel = state.context["aria-label"];
211
+ const ariaLabelledBy = state.context["aria-labelledby"];
212
+ const ariaValueText = state.context.getAriaValueText?.(state.context.value);
213
+ const isFocused = state.matches("focus");
214
+ const isDragging = state.matches("dragging");
215
+ const isDisabled = state.context.disabled;
216
+ const isInteractive = state.context.isInteractive;
217
+ const isInvalid = state.context.invalid;
613
218
  function getPercentValueFn(percent) {
614
- return (0, import_numeric_range3.getPercentValue)(percent, state2.context.min, state2.context.max, state2.context.step);
219
+ return (0, import_numeric_range3.getPercentValue)(percent, state.context.min, state.context.max, state.context.step);
615
220
  }
616
221
  function getValuePercentFn(value) {
617
- return (0, import_numeric_range3.getValuePercent)(value, state2.context.min, state2.context.max);
222
+ return (0, import_numeric_range3.getValuePercent)(value, state.context.min, state.context.max);
618
223
  }
619
224
  return {
225
+ /**
226
+ * Whether the slider is focused.
227
+ */
620
228
  isFocused,
229
+ /**
230
+ * Whether the slider is being dragged.
231
+ */
621
232
  isDragging,
622
- value: state2.context.value,
623
- percent: (0, import_numeric_range3.getValuePercent)(state2.context.value, state2.context.min, state2.context.max),
233
+ /**
234
+ * The value of the slider.
235
+ */
236
+ value: state.context.value,
237
+ /**
238
+ * The value of the slider as a percent.
239
+ */
240
+ percent: (0, import_numeric_range3.getValuePercent)(state.context.value, state.context.min, state.context.max),
241
+ /**
242
+ * Function to set the value of the slider.
243
+ */
624
244
  setValue(value) {
625
245
  send({ type: "SET_VALUE", value });
626
246
  },
247
+ /**
248
+ * Returns the value of the slider at the given percent.
249
+ */
627
250
  getPercentValue: getPercentValueFn,
251
+ /**
252
+ * Returns the percent of the slider at the given value.
253
+ */
628
254
  getValuePercent: getValuePercentFn,
255
+ /**
256
+ * Function to focus the slider.
257
+ */
629
258
  focus() {
630
- dom.getThumbEl(state2.context)?.focus();
259
+ dom.getThumbEl(state.context)?.focus();
631
260
  },
261
+ /**
262
+ * Function to increment the value of the slider by the step.
263
+ */
632
264
  increment() {
633
265
  send("INCREMENT");
634
266
  },
267
+ /**
268
+ * Function to decrement the value of the slider by the step.
269
+ */
635
270
  decrement() {
636
271
  send("DECREMENT");
637
272
  },
638
273
  rootProps: normalize.element({
639
274
  ...parts.root.attrs,
640
- "data-disabled": dataAttr(isDisabled),
641
- "data-focus": dataAttr(isFocused),
642
- "data-orientation": state2.context.orientation,
643
- "data-invalid": dataAttr(isInvalid),
644
- id: dom.getRootId(state2.context),
645
- dir: state2.context.dir,
646
- style: dom.getRootStyle(state2.context)
275
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
276
+ "data-focus": (0, import_dom_query2.dataAttr)(isFocused),
277
+ "data-orientation": state.context.orientation,
278
+ "data-invalid": (0, import_dom_query2.dataAttr)(isInvalid),
279
+ id: dom.getRootId(state.context),
280
+ dir: state.context.dir,
281
+ style: dom.getRootStyle(state.context)
647
282
  }),
648
283
  labelProps: normalize.label({
649
284
  ...parts.label.attrs,
650
- "data-disabled": dataAttr(isDisabled),
651
- "data-invalid": dataAttr(isInvalid),
652
- "data-focus": dataAttr(isFocused),
653
- id: dom.getLabelId(state2.context),
654
- htmlFor: dom.getHiddenInputId(state2.context),
285
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
286
+ "data-invalid": (0, import_dom_query2.dataAttr)(isInvalid),
287
+ "data-focus": (0, import_dom_query2.dataAttr)(isFocused),
288
+ id: dom.getLabelId(state.context),
289
+ htmlFor: dom.getHiddenInputId(state.context),
655
290
  onClick(event) {
656
291
  if (!isInteractive)
657
292
  return;
658
293
  event.preventDefault();
659
- dom.getThumbEl(state2.context)?.focus();
294
+ dom.getThumbEl(state.context)?.focus();
660
295
  },
661
296
  style: dom.getLabelStyle()
662
297
  }),
663
298
  thumbProps: normalize.element({
664
299
  ...parts.thumb.attrs,
665
- id: dom.getThumbId(state2.context),
666
- "data-disabled": dataAttr(isDisabled),
667
- "data-orientation": state2.context.orientation,
668
- "data-focus": dataAttr(isFocused),
300
+ id: dom.getThumbId(state.context),
301
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
302
+ "data-orientation": state.context.orientation,
303
+ "data-focus": (0, import_dom_query2.dataAttr)(isFocused),
669
304
  draggable: false,
670
- "aria-invalid": isInvalid || void 0,
671
- "data-invalid": dataAttr(isInvalid),
672
- "aria-disabled": isDisabled || void 0,
305
+ "aria-invalid": (0, import_dom_query2.ariaAttr)(isInvalid),
306
+ "data-invalid": (0, import_dom_query2.dataAttr)(isInvalid),
307
+ "aria-disabled": (0, import_dom_query2.ariaAttr)(isDisabled),
673
308
  "aria-label": ariaLabel,
674
- "aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ?? dom.getLabelId(state2.context),
675
- "aria-orientation": state2.context.orientation,
676
- "aria-valuemax": state2.context.max,
677
- "aria-valuemin": state2.context.min,
678
- "aria-valuenow": state2.context.value,
309
+ "aria-labelledby": ariaLabel ? void 0 : ariaLabelledBy ?? dom.getLabelId(state.context),
310
+ "aria-orientation": state.context.orientation,
311
+ "aria-valuemax": state.context.max,
312
+ "aria-valuemin": state.context.min,
313
+ "aria-valuenow": state.context.value,
679
314
  "aria-valuetext": ariaValueText,
680
315
  role: "slider",
681
316
  tabIndex: isDisabled ? void 0 : 0,
@@ -692,24 +327,24 @@ function connect(state2, send, normalize) {
692
327
  onKeyDown(event) {
693
328
  if (!isInteractive)
694
329
  return;
695
- const step = getEventStep(event) * state2.context.step;
330
+ const step = (0, import_dom_event2.getEventStep)(event) * state.context.step;
696
331
  let prevent = true;
697
332
  const keyMap = {
698
333
  ArrowUp() {
699
334
  send({ type: "ARROW_UP", step });
700
- prevent = state2.context.isVertical;
335
+ prevent = state.context.isVertical;
701
336
  },
702
337
  ArrowDown() {
703
338
  send({ type: "ARROW_DOWN", step });
704
- prevent = state2.context.isVertical;
339
+ prevent = state.context.isVertical;
705
340
  },
706
341
  ArrowLeft() {
707
342
  send({ type: "ARROW_LEFT", step });
708
- prevent = state2.context.isHorizontal;
343
+ prevent = state.context.isHorizontal;
709
344
  },
710
345
  ArrowRight() {
711
346
  send({ type: "ARROW_RIGHT", step });
712
- prevent = state2.context.isHorizontal;
347
+ prevent = state.context.isHorizontal;
713
348
  },
714
349
  PageUp() {
715
350
  send({ type: "PAGE_UP", step });
@@ -724,7 +359,7 @@ function connect(state2, send, normalize) {
724
359
  send("END");
725
360
  }
726
361
  };
727
- const key = getEventKey(event, state2.context);
362
+ const key = (0, import_dom_event2.getEventKey)(event, state.context);
728
363
  const exec = keyMap[key];
729
364
  if (!exec)
730
365
  return;
@@ -733,57 +368,57 @@ function connect(state2, send, normalize) {
733
368
  event.preventDefault();
734
369
  }
735
370
  },
736
- style: dom.getThumbStyle(state2.context)
371
+ style: dom.getThumbStyle(state.context)
737
372
  }),
738
373
  hiddenInputProps: normalize.input({
739
374
  ...parts.hiddenInput.attrs,
740
375
  type: "text",
741
- defaultValue: state2.context.value,
742
- name: state2.context.name,
743
- form: state2.context.form,
744
- id: dom.getHiddenInputId(state2.context),
376
+ defaultValue: state.context.value,
377
+ name: state.context.name,
378
+ form: state.context.form,
379
+ id: dom.getHiddenInputId(state.context),
745
380
  hidden: true
746
381
  }),
747
382
  outputProps: normalize.output({
748
383
  ...parts.output.attrs,
749
- "data-disabled": dataAttr(isDisabled),
750
- "data-invalid": dataAttr(isInvalid),
751
- id: dom.getOutputId(state2.context),
752
- htmlFor: dom.getHiddenInputId(state2.context),
384
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
385
+ "data-invalid": (0, import_dom_query2.dataAttr)(isInvalid),
386
+ id: dom.getOutputId(state.context),
387
+ htmlFor: dom.getHiddenInputId(state.context),
753
388
  "aria-live": "off"
754
389
  }),
755
390
  trackProps: normalize.element({
756
391
  ...parts.track.attrs,
757
- id: dom.getTrackId(state2.context),
758
- "data-disabled": dataAttr(isDisabled),
759
- "data-focus": dataAttr(isFocused),
760
- "data-invalid": dataAttr(isInvalid),
761
- "data-orientation": state2.context.orientation,
392
+ id: dom.getTrackId(state.context),
393
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
394
+ "data-focus": (0, import_dom_query2.dataAttr)(isFocused),
395
+ "data-invalid": (0, import_dom_query2.dataAttr)(isInvalid),
396
+ "data-orientation": state.context.orientation,
762
397
  style: dom.getTrackStyle()
763
398
  }),
764
399
  rangeProps: normalize.element({
765
400
  ...parts.range.attrs,
766
- id: dom.getRangeId(state2.context),
767
- "data-focus": dataAttr(isFocused),
768
- "data-invalid": dataAttr(isInvalid),
769
- "data-disabled": dataAttr(isDisabled),
770
- "data-orientation": state2.context.orientation,
771
- style: dom.getRangeStyle(state2.context)
401
+ id: dom.getRangeId(state.context),
402
+ "data-focus": (0, import_dom_query2.dataAttr)(isFocused),
403
+ "data-invalid": (0, import_dom_query2.dataAttr)(isInvalid),
404
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
405
+ "data-orientation": state.context.orientation,
406
+ style: dom.getRangeStyle(state.context)
772
407
  }),
773
408
  controlProps: normalize.element({
774
409
  ...parts.control.attrs,
775
- id: dom.getControlId(state2.context),
776
- "data-disabled": dataAttr(isDisabled),
777
- "data-invalid": dataAttr(isInvalid),
778
- "data-orientation": state2.context.orientation,
779
- "data-focus": dataAttr(isFocused),
410
+ id: dom.getControlId(state.context),
411
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
412
+ "data-invalid": (0, import_dom_query2.dataAttr)(isInvalid),
413
+ "data-orientation": state.context.orientation,
414
+ "data-focus": (0, import_dom_query2.dataAttr)(isFocused),
780
415
  onPointerDown(event) {
781
416
  if (!isInteractive)
782
417
  return;
783
- const evt = getNativeEvent(event);
784
- if (!isLeftClick(evt) || isModifiedEvent(evt))
418
+ const evt = (0, import_dom_event2.getNativeEvent)(event);
419
+ if (!(0, import_dom_event2.isLeftClick)(evt) || (0, import_dom_event2.isModifiedEvent)(evt))
785
420
  return;
786
- const point = getEventPoint(evt);
421
+ const point = { x: evt.clientX, y: evt.clientY };
787
422
  send({ type: "POINTER_DOWN", point });
788
423
  event.preventDefault();
789
424
  event.stopPropagation();
@@ -794,20 +429,20 @@ function connect(state2, send, normalize) {
794
429
  ...parts.markerGroup.attrs,
795
430
  role: "presentation",
796
431
  "aria-hidden": true,
797
- "data-orientation": state2.context.orientation,
432
+ "data-orientation": state.context.orientation,
798
433
  style: dom.getMarkerGroupStyle()
799
434
  }),
800
435
  getMarkerProps({ value }) {
801
436
  const percent = getValuePercentFn(value);
802
- const style = dom.getMarkerStyle(state2.context, percent);
803
- const markerState = value > state2.context.value ? "over-value" : value < state2.context.value ? "under-value" : "at-value";
437
+ const style = dom.getMarkerStyle(state.context, percent);
438
+ const markerState = value > state.context.value ? "over-value" : value < state.context.value ? "under-value" : "at-value";
804
439
  return normalize.element({
805
440
  ...parts.marker.attrs,
806
441
  role: "presentation",
807
- "data-orientation": state2.context.orientation,
808
- id: dom.getMarkerId(state2.context, value),
442
+ "data-orientation": state.context.orientation,
443
+ id: dom.getMarkerId(state.context, value),
809
444
  "data-value": value,
810
- "data-disabled": dataAttr(isDisabled),
445
+ "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
811
446
  "data-state": markerState,
812
447
  style
813
448
  });
@@ -817,8 +452,12 @@ function connect(state2, send, normalize) {
817
452
 
818
453
  // src/slider.machine.ts
819
454
  var import_core = require("@zag-js/core");
455
+ var import_dom_event3 = require("@zag-js/dom-event");
456
+ var import_dom_query3 = require("@zag-js/dom-query");
820
457
  var import_element_size = require("@zag-js/element-size");
458
+ var import_form_utils2 = require("@zag-js/form-utils");
821
459
  var import_numeric_range5 = require("@zag-js/numeric-range");
460
+ var import_utils = require("@zag-js/utils");
822
461
 
823
462
  // src/slider.utils.ts
824
463
  var import_numeric_range4 = require("@zag-js/numeric-range");
@@ -847,7 +486,7 @@ function increment(ctx, step) {
847
486
 
848
487
  // src/slider.machine.ts
849
488
  function machine(userContext) {
850
- const ctx = compact(userContext);
489
+ const ctx = (0, import_utils.compact)(userContext);
851
490
  return (0, import_core.createMachine)(
852
491
  {
853
492
  id: "slider",
@@ -961,7 +600,7 @@ function machine(userContext) {
961
600
  },
962
601
  activities: {
963
602
  trackFormControlState(ctx2) {
964
- return trackFormControl(dom.getHiddenInputEl(ctx2), {
603
+ return (0, import_form_utils2.trackFormControl)(dom.getHiddenInputEl(ctx2), {
965
604
  onFieldsetDisabled() {
966
605
  ctx2.disabled = true;
967
606
  },
@@ -973,7 +612,7 @@ function machine(userContext) {
973
612
  });
974
613
  },
975
614
  trackPointerMove(ctx2, _evt, { send }) {
976
- return trackPointerMove(dom.getDoc(ctx2), {
615
+ return (0, import_dom_event3.trackPointerMove)(dom.getDoc(ctx2), {
977
616
  onPointerMove(info) {
978
617
  send({ type: "POINTER_MOVE", point: info.point });
979
618
  },
@@ -1016,7 +655,7 @@ function machine(userContext) {
1016
655
  ctx2.value = (0, import_numeric_range5.clampValue)(value, ctx2.min, ctx2.max);
1017
656
  },
1018
657
  focusThumb(ctx2) {
1019
- raf(() => dom.getThumbEl(ctx2)?.focus());
658
+ (0, import_dom_query3.raf)(() => dom.getThumbEl(ctx2)?.focus());
1020
659
  },
1021
660
  decrement(ctx2, evt) {
1022
661
  ctx2.value = decrement(ctx2, evt.step);