@zag-js/slider 0.1.7 → 0.1.8

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.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -23,25 +24,6 @@ var __pow = Math.pow;
23
24
  var dataAttr = (guard) => {
24
25
  return guard ? "" : void 0;
25
26
  };
26
- function nextTick(fn) {
27
- const set = /* @__PURE__ */ new Set();
28
- function raf2(fn2) {
29
- const id = globalThis.requestAnimationFrame(fn2);
30
- set.add(() => globalThis.cancelAnimationFrame(id));
31
- }
32
- raf2(() => raf2(fn));
33
- return function cleanup() {
34
- set.forEach(function(fn2) {
35
- fn2();
36
- });
37
- };
38
- }
39
- function raf(fn) {
40
- const id = globalThis.requestAnimationFrame(fn);
41
- return function cleanup() {
42
- globalThis.cancelAnimationFrame(id);
43
- };
44
- }
45
27
  var isDom = () => typeof window !== "undefined";
46
28
  var isArray = (v) => Array.isArray(v);
47
29
  var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
@@ -52,7 +34,7 @@ function getPlatform() {
52
34
  return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
53
35
  }
54
36
  var pt = (v) => isDom() && v.test(getPlatform());
55
- var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
37
+ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
56
38
  var isMac = () => pt(/^Mac/) && !isTouchDevice;
57
39
  var isApple = () => pt(/mac|iphone|ipad|ipod/i);
58
40
  var isIos = () => isApple() && !isMac();
@@ -69,68 +51,6 @@ var runIfFn = (v, ...a) => {
69
51
  var noop = () => {
70
52
  };
71
53
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
72
- function getListenerElements() {
73
- ;
74
- globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
75
- return globalThis.__listenerElements__;
76
- }
77
- function getListenerCache() {
78
- ;
79
- globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
80
- return globalThis.__listenerCache__;
81
- }
82
- function addGlobalEventListener(node, type, handler, options) {
83
- var _a;
84
- if (!node)
85
- return noop;
86
- const hash = JSON.stringify({ type, options });
87
- const listenerElements = getListenerElements();
88
- const listenerCache = getListenerCache();
89
- const group = listenerElements.get(node);
90
- if (!listenerElements.has(node)) {
91
- const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
92
- listenerElements.set(node, group2);
93
- } else if (group == null ? void 0 : group.has(hash)) {
94
- (_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
95
- } else {
96
- group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
97
- }
98
- function attach(node2) {
99
- var _a2, _b;
100
- function listener(event) {
101
- var _a3;
102
- const group2 = listenerElements.get(node2);
103
- (_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
104
- }
105
- if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
106
- listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
107
- node2.addEventListener(type, listener, options);
108
- return;
109
- }
110
- if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
111
- (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
112
- node2.addEventListener(type, listener, options);
113
- }
114
- }
115
- attach(node);
116
- return function remove() {
117
- var _a2, _b, _c, _d;
118
- if (!listenerElements.has(node))
119
- return;
120
- const group2 = listenerElements.get(node);
121
- (_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
122
- if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
123
- const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
124
- node.removeEventListener(type, listener, options);
125
- group2 == null ? void 0 : group2.delete(hash);
126
- (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
127
- if ((group2 == null ? void 0 : group2.size) === 0) {
128
- listenerElements.delete(node);
129
- listenerCache.delete(node);
130
- }
131
- }
132
- };
133
- }
134
54
  var isRef = (v) => hasProp(v, "current");
135
55
  var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
136
56
  function extractInfo(event, type = "page") {
@@ -142,9 +62,12 @@ function extractInfo(event, type = "page") {
142
62
  }
143
63
  };
144
64
  }
145
- function addDomEvent(target, event, listener, options) {
65
+ function addDomEvent(target, eventName, handler, options) {
146
66
  const node = isRef(target) ? target.current : runIfFn(target);
147
- return addGlobalEventListener(node, event, listener, options);
67
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
68
+ return () => {
69
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
70
+ };
148
71
  }
149
72
  function addPointerEvent(target, event, listener, options) {
150
73
  var _a;
@@ -192,6 +115,25 @@ function getEventName(evt) {
192
115
  return mouseEventNames[evt];
193
116
  return evt;
194
117
  }
118
+ function nextTick(fn) {
119
+ const set = /* @__PURE__ */ new Set();
120
+ function raf2(fn2) {
121
+ const id = globalThis.requestAnimationFrame(fn2);
122
+ set.add(() => globalThis.cancelAnimationFrame(id));
123
+ }
124
+ raf2(() => raf2(fn));
125
+ return function cleanup() {
126
+ set.forEach(function(fn2) {
127
+ fn2();
128
+ });
129
+ };
130
+ }
131
+ function raf(fn) {
132
+ const id = globalThis.requestAnimationFrame(fn);
133
+ return function cleanup() {
134
+ globalThis.cancelAnimationFrame(id);
135
+ };
136
+ }
195
137
  function getOwnerWindow(el) {
196
138
  var _a;
197
139
  return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
@@ -295,30 +237,6 @@ function getEventStep(event) {
295
237
  return isSkipKey ? 10 : 1;
296
238
  }
297
239
  }
298
- function itemById(v, id) {
299
- return v.find((node) => node.id === id);
300
- }
301
- function indexOfId(v, id) {
302
- const item = itemById(v, id);
303
- return item ? v.indexOf(item) : -1;
304
- }
305
- var getValueText = (item) => {
306
- var _a, _b;
307
- return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
308
- };
309
- var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
310
- var wrap = (v, idx) => {
311
- return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
312
- };
313
- function findByText(v, text, currentId) {
314
- const index = currentId ? indexOfId(v, currentId) : -1;
315
- let items = currentId ? wrap(v, index) : v;
316
- const isSingleKey = text.length === 1;
317
- if (isSingleKey) {
318
- items = items.filter((item) => item.id !== currentId);
319
- }
320
- return items.find((item) => match(getValueText(item), text));
321
- }
322
240
  var state = "default";
323
241
  var savedUserSelect = "";
324
242
  var modifiedElementMap = /* @__PURE__ */ new WeakMap();
@@ -382,34 +300,25 @@ function trackPointerMove(opts) {
382
300
  };
383
301
  return pipe(addPointerEvent(doc, "pointermove", handlePointerMove, false), addPointerEvent(doc, "pointerup", onPointerUp, false), addPointerEvent(doc, "pointercancel", onPointerUp, false), addPointerEvent(doc, "contextmenu", onPointerUp, false), disableTextSelection({ doc }));
384
302
  }
385
- function findByTypeahead(_items, options) {
386
- const { state: state2, activeId, key, timeout = 350 } = options;
387
- const search = state2.keysSoFar + key;
388
- const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
389
- const query2 = isRepeated ? search[0] : search;
390
- let items = _items.slice();
391
- const next = findByText(items, query2, activeId);
392
- function cleanup() {
393
- clearTimeout(state2.timer);
394
- state2.timer = -1;
395
- }
396
- function update(value) {
397
- state2.keysSoFar = value;
398
- cleanup();
399
- if (value !== "") {
400
- state2.timer = +setTimeout(() => {
401
- update("");
402
- cleanup();
403
- }, timeout);
404
- }
405
- }
406
- update(search);
407
- return next;
303
+
304
+ // ../../utilities/rect/dist/index.mjs
305
+ var isArray2 = (v) => Array.isArray(v);
306
+ var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
307
+ var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
308
+ var isTouchEvent2 = (v) => isObject2(v) && hasProp2(v, "touches");
309
+ var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
310
+ function getEventPoint(e, t = "page") {
311
+ const p = isTouchEvent2(e) ? e.touches[0] || e.changedTouches[0] || fallback2 : e;
312
+ return { x: p[`${t}X`], y: p[`${t}Y`] };
313
+ }
314
+ function relativeToNode(p, el) {
315
+ const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft;
316
+ const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop;
317
+ return {
318
+ point: { x: dx, y: dy },
319
+ progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight }
320
+ };
408
321
  }
409
- findByTypeahead.defaultOptions = {
410
- keysSoFar: "",
411
- timer: -1
412
- };
413
322
 
414
323
  // ../../utilities/number/dist/index.mjs
415
324
  var __pow2 = Math.pow;
@@ -471,50 +380,7 @@ var transform = (a, b) => {
471
380
  };
472
381
  };
473
382
 
474
- // ../../utilities/rect/dist/index.mjs
475
- var isDom2 = () => typeof window !== "undefined";
476
- var isArray2 = (v) => Array.isArray(v);
477
- var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
478
- var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
479
- var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
480
- var isTouchEvent2 = (v) => isObject2(v) && hasProp2(v, "touches");
481
- var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
482
- function getEventPoint(e, t = "page") {
483
- const p = isTouchEvent2(e) ? e.touches[0] || e.changedTouches[0] || fallback2 : e;
484
- return { x: p[`${t}X`], y: p[`${t}Y`] };
485
- }
486
- function relativeToNode(p, el) {
487
- const dx = p.x - el.offsetLeft - el.clientLeft + el.scrollLeft;
488
- const dy = p.y - el.offsetTop - el.clientTop + el.scrollTop;
489
- return {
490
- point: { x: dx, y: dy },
491
- progress: { x: dx / el.offsetWidth, y: dy / el.offsetHeight }
492
- };
493
- }
494
-
495
- // src/slider.utils.ts
496
- var utils = {
497
- fromPercent(ctx, percent) {
498
- percent = clamp(percent, { min: 0, max: 1 });
499
- return parseFloat(snapToStep(percentToValue(percent, ctx), ctx.step));
500
- },
501
- clamp(ctx, value) {
502
- return clamp(value, ctx);
503
- },
504
- convert(ctx, value) {
505
- return clamp(parseFloat(snapToStep(value, ctx.step)), ctx);
506
- },
507
- decrement(ctx, step) {
508
- let value = decrement(ctx.value, step != null ? step : ctx.step);
509
- return utils.convert(ctx, value);
510
- },
511
- increment(ctx, step) {
512
- let value = increment(ctx.value, step != null ? step : ctx.step);
513
- return utils.convert(ctx, value);
514
- }
515
- };
516
-
517
- // src/slider.dom.ts
383
+ // src/slider.style.ts
518
384
  function getVerticalThumbOffset(ctx) {
519
385
  var _a;
520
386
  const { height = 0 } = (_a = ctx.thumbSize) != null ? _a : {};
@@ -531,54 +397,119 @@ function getHorizontalThumbOffset(ctx) {
531
397
  const getValue = transform([ctx.min, ctx.max], [-width / 2, width / 2]);
532
398
  return parseFloat(getValue(ctx.value).toFixed(2));
533
399
  }
534
- function getThumbStyle(ctx) {
400
+ function getThumbOffset(ctx) {
535
401
  const percent = valueToPercent(ctx.value, ctx);
402
+ if (ctx.thumbAlignment === "center")
403
+ return `${percent}%`;
536
404
  const offset = ctx.isVertical ? getVerticalThumbOffset(ctx) : getHorizontalThumbOffset(ctx);
537
- const style = {
405
+ return `calc(${percent}% - ${offset}px)`;
406
+ }
407
+ function getThumbStyle(ctx) {
408
+ const placementProp = ctx.isVertical ? "bottom" : ctx.isRtl ? "right" : "left";
409
+ return {
538
410
  visibility: ctx.hasMeasuredThumbSize ? "visible" : "hidden",
539
411
  position: "absolute",
540
412
  transform: "var(--slider-thumb-transform)",
541
- "--slider-thumb-placement": `calc(${percent}% - ${offset}px)`
413
+ [placementProp]: "var(--slider-thumb-offset)"
542
414
  };
543
- if (ctx.isVertical) {
544
- style.bottom = "var(--slider-thumb-placement)";
545
- } else {
546
- style[ctx.isRtl ? "right" : "left"] = "var(--slider-thumb-placement)";
547
- }
548
- return style;
549
415
  }
550
- function getRangeStyle(ctx) {
416
+ function getRangeOffsets(ctx) {
551
417
  const percent = valueToPercent(ctx.value, ctx);
552
- const style = {
553
- position: "absolute"
554
- };
555
- let startValue = "0%";
556
- let endValue = `${100 - percent}%`;
418
+ let start = "0%";
419
+ let end = `${100 - percent}%`;
557
420
  if (ctx.origin === "center") {
558
421
  const isNegative = percent < 50;
559
- startValue = isNegative ? `${percent}%` : "50%";
560
- endValue = isNegative ? "50%" : endValue;
422
+ start = isNegative ? `${percent}%` : "50%";
423
+ end = isNegative ? "50%" : end;
561
424
  }
425
+ return { start, end };
426
+ }
427
+ function getRangeStyle(ctx) {
562
428
  if (ctx.isVertical) {
563
- return __spreadProps(__spreadValues({}, style), {
564
- bottom: startValue,
565
- top: endValue
566
- });
429
+ return {
430
+ position: "absolute",
431
+ bottom: "var(--slider-range-start)",
432
+ top: "var(--slider-range-end)"
433
+ };
567
434
  }
568
- return __spreadProps(__spreadValues({}, style), {
569
- [ctx.isRtl ? "right" : "left"]: startValue,
570
- [ctx.isRtl ? "left" : "right"]: endValue
571
- });
435
+ return {
436
+ position: "absolute",
437
+ [ctx.isRtl ? "right" : "left"]: "var(--slider-range-start)",
438
+ [ctx.isRtl ? "left" : "right"]: "var(--slider-range-end)"
439
+ };
572
440
  }
573
- function getControlStyle(ctx) {
441
+ function getControlStyle() {
574
442
  return {
575
443
  touchAction: "none",
576
444
  userSelect: "none",
445
+ position: "relative"
446
+ };
447
+ }
448
+ function getRootStyle(ctx) {
449
+ const range = getRangeOffsets(ctx);
450
+ return {
577
451
  "--slider-thumb-transform": ctx.isVertical ? "translateY(50%)" : "translateX(-50%)",
452
+ "--slider-thumb-offset": getThumbOffset(ctx),
453
+ "--slider-range-start": range.start,
454
+ "--slider-range-end": range.end
455
+ };
456
+ }
457
+ function getMarkerStyle(ctx, percent) {
458
+ return {
459
+ position: "absolute",
460
+ pointerEvents: "none",
461
+ [ctx.isHorizontal ? "left" : "bottom"]: `${ctx.isRtl ? 100 - percent : percent}%`
462
+ };
463
+ }
464
+ function getLabelStyle() {
465
+ return { userSelect: "none" };
466
+ }
467
+ function getTrackStyle() {
468
+ return { position: "relative" };
469
+ }
470
+ function getMarkerGroupStyle() {
471
+ return {
472
+ userSelect: "none",
473
+ pointerEvents: "none",
578
474
  position: "relative"
579
475
  };
580
476
  }
581
- var dom = {
477
+ var styles = {
478
+ getThumbOffset,
479
+ getControlStyle,
480
+ getThumbStyle,
481
+ getRangeStyle,
482
+ getRootStyle,
483
+ getMarkerStyle,
484
+ getLabelStyle,
485
+ getTrackStyle,
486
+ getMarkerGroupStyle
487
+ };
488
+
489
+ // src/slider.utils.ts
490
+ var utils = {
491
+ fromPercent(ctx, percent) {
492
+ percent = clamp(percent, { min: 0, max: 1 });
493
+ return parseFloat(snapToStep(percentToValue(percent, ctx), ctx.step));
494
+ },
495
+ clamp(ctx, value) {
496
+ return clamp(value, ctx);
497
+ },
498
+ convert(ctx, value) {
499
+ return clamp(parseFloat(snapToStep(value, ctx.step)), ctx);
500
+ },
501
+ decrement(ctx, step) {
502
+ let value = decrement(ctx.value, step != null ? step : ctx.step);
503
+ return utils.convert(ctx, value);
504
+ },
505
+ increment(ctx, step) {
506
+ let value = increment(ctx.value, step != null ? step : ctx.step);
507
+ return utils.convert(ctx, value);
508
+ }
509
+ };
510
+
511
+ // src/slider.dom.ts
512
+ var dom = __spreadProps(__spreadValues({}, styles), {
582
513
  getDoc: (ctx) => {
583
514
  var _a;
584
515
  return (_a = ctx.doc) != null ? _a : document;
@@ -606,7 +537,7 @@ var dom = {
606
537
  },
607
538
  getTrackId: (ctx) => {
608
539
  var _a, _b;
609
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:-${ctx.uid}track`;
540
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.track) != null ? _b : `slider:${ctx.uid}track`;
610
541
  },
611
542
  getRangeId: (ctx) => {
612
543
  var _a, _b;
@@ -621,9 +552,6 @@ var dom = {
621
552
  getThumbEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getThumbId(ctx)),
622
553
  getControlEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getControlId(ctx)),
623
554
  getInputEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getInputId(ctx)),
624
- getControlStyle,
625
- getThumbStyle,
626
- getRangeStyle,
627
555
  getValueFromPoint(ctx, point) {
628
556
  const control = dom.getControlEl(ctx);
629
557
  if (!control)
@@ -642,21 +570,8 @@ var dom = {
642
570
  if (!input)
643
571
  return;
644
572
  dispatchInputValueEvent(input, ctx.value);
645
- },
646
- getMarkerStyle(ctx, percent) {
647
- const style = {
648
- position: "absolute",
649
- pointerEvents: "none"
650
- };
651
- if (ctx.isHorizontal) {
652
- percent = ctx.isRtl ? 100 - percent : percent;
653
- style.left = `${percent}%`;
654
- } else {
655
- style.bottom = `${percent}%`;
656
- }
657
- return style;
658
573
  }
659
- };
574
+ });
660
575
 
661
576
  // ../../types/dist/index.mjs
662
577
  function createNormalizer(fn) {
@@ -669,8 +584,6 @@ function createNormalizer(fn) {
669
584
  var normalizeProp = createNormalizer((v) => v);
670
585
 
671
586
  // ../../utilities/core/dist/index.mjs
672
- var isDom3 = () => typeof window !== "undefined";
673
- var isTouchDevice3 = isDom3() && !!navigator.maxTouchPoints;
674
587
  var isLeftClick2 = (v) => v.button === 0;
675
588
  var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
676
589
 
@@ -709,14 +622,18 @@ function connect(state2, send, normalize = normalizeProp) {
709
622
  rootProps: normalize.element({
710
623
  "data-part": "root",
711
624
  "data-disabled": dataAttr(isDisabled),
625
+ "data-focus": dataAttr(isFocused),
712
626
  "data-orientation": state2.context.orientation,
627
+ "data-invalid": dataAttr(isInvalid),
713
628
  id: dom.getRootId(state2.context),
714
- dir: state2.context.dir
629
+ dir: state2.context.dir,
630
+ style: dom.getRootStyle(state2.context)
715
631
  }),
716
632
  labelProps: normalize.label({
717
633
  "data-part": "label",
718
634
  "data-disabled": dataAttr(isDisabled),
719
635
  "data-invalid": dataAttr(isInvalid),
636
+ "data-focus": dataAttr(isFocused),
720
637
  id: dom.getLabelId(state2.context),
721
638
  htmlFor: dom.getInputId(state2.context),
722
639
  onClick(event) {
@@ -726,9 +643,7 @@ function connect(state2, send, normalize = normalizeProp) {
726
643
  event.preventDefault();
727
644
  (_a2 = dom.getThumbEl(state2.context)) == null ? void 0 : _a2.focus();
728
645
  },
729
- style: {
730
- userSelect: "none"
731
- }
646
+ style: dom.getLabelStyle()
732
647
  }),
733
648
  thumbProps: normalize.element({
734
649
  "data-part": "thumb",
@@ -825,14 +740,15 @@ function connect(state2, send, normalize = normalizeProp) {
825
740
  "data-part": "track",
826
741
  id: dom.getTrackId(state2.context),
827
742
  "data-disabled": dataAttr(isDisabled),
743
+ "data-focus": dataAttr(isFocused),
828
744
  "data-invalid": dataAttr(isInvalid),
829
745
  "data-orientation": state2.context.orientation,
830
- "data-focus": dataAttr(isFocused),
831
- style: { position: "relative" }
746
+ style: dom.getTrackStyle()
832
747
  }),
833
748
  rangeProps: normalize.element({
834
749
  "data-part": "range",
835
750
  id: dom.getRangeId(state2.context),
751
+ "data-focus": dataAttr(isFocused),
836
752
  "data-invalid": dataAttr(isInvalid),
837
753
  "data-disabled": dataAttr(isDisabled),
838
754
  "data-orientation": state2.context.orientation,
@@ -856,18 +772,14 @@ function connect(state2, send, normalize = normalizeProp) {
856
772
  event.preventDefault();
857
773
  event.stopPropagation();
858
774
  },
859
- style: dom.getControlStyle(state2.context)
775
+ style: dom.getControlStyle()
860
776
  }),
861
777
  markerGroupProps: normalize.element({
862
778
  "data-part": "marker-group",
863
779
  role: "presentation",
864
780
  "aria-hidden": true,
865
781
  "data-orientation": state2.context.orientation,
866
- style: {
867
- userSelect: "none",
868
- pointerEvents: "none",
869
- position: "relative"
870
- }
782
+ style: dom.getMarkerGroupStyle()
871
783
  }),
872
784
  getMarkerProps({ value }) {
873
785
  const percent = valueToPercent(value, state2.context);
@@ -875,6 +787,7 @@ function connect(state2, send, normalize = normalizeProp) {
875
787
  const markerState = value > state2.context.value ? "over-value" : value < state2.context.value ? "under-value" : "at-value";
876
788
  return normalize.element({
877
789
  "data-part": "marker",
790
+ role: "presentation",
878
791
  "data-orientation": state2.context.orientation,
879
792
  id: dom.getMarkerId(state2.context, value),
880
793
  "data-value": value,
@@ -894,6 +807,7 @@ function machine(ctx = {}) {
894
807
  initial: "unknown",
895
808
  context: __spreadValues({
896
809
  thumbSize: null,
810
+ thumbAlignment: "contain",
897
811
  uid: "",
898
812
  disabled: false,
899
813
  threshold: 5,
@@ -1008,7 +922,7 @@ function machine(ctx = {}) {
1008
922
  let cleanup;
1009
923
  nextTick(() => {
1010
924
  cleanup = trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
1011
- if (disabled != ctx2.disabled) {
925
+ if (disabled) {
1012
926
  ctx2.disabled = disabled;
1013
927
  }
1014
928
  });
@@ -1066,6 +980,8 @@ function machine(ctx = {}) {
1066
980
  dom.dispatchChangeEvent(ctx2);
1067
981
  },
1068
982
  setThumbSize(ctx2) {
983
+ if (ctx2.thumbAlignment !== "contain")
984
+ return;
1069
985
  raf(() => {
1070
986
  const el = dom.getThumbEl(ctx2);
1071
987
  if (!el)
@@ -1108,4 +1024,3 @@ export {
1108
1024
  machine,
1109
1025
  dom as unstable__dom
1110
1026
  };
1111
- //# sourceMappingURL=index.mjs.map
@@ -23,4 +23,3 @@ export declare function connect<T extends PropTypes = ReactPropTypes>(state: Sta
23
23
  value: number;
24
24
  }): T["element"];
25
25
  };
26
- //# sourceMappingURL=slider.connect.d.ts.map
@@ -1,9 +1,5 @@
1
1
  import type { Point } from "@zag-js/rect-utils";
2
- import type { Style } from "@zag-js/types";
3
- import type { MachineContext as Ctx, SharedContext } from "./slider.types";
4
- declare function getThumbStyle(ctx: SharedContext): Style;
5
- declare function getRangeStyle(ctx: Ctx): Style;
6
- declare function getControlStyle(ctx: Pick<Ctx, "isVertical">): Style;
2
+ import type { MachineContext as Ctx } from "./slider.types";
7
3
  export declare const dom: {
8
4
  getDoc: (ctx: Ctx) => Document;
9
5
  getRootNode: (ctx: Ctx) => Document | ShadowRoot;
@@ -20,12 +16,15 @@ export declare const dom: {
20
16
  getThumbEl: (ctx: Ctx) => HTMLElement;
21
17
  getControlEl: (ctx: Ctx) => HTMLElement;
22
18
  getInputEl: (ctx: Ctx) => HTMLInputElement;
23
- getControlStyle: typeof getControlStyle;
24
- getThumbStyle: typeof getThumbStyle;
25
- getRangeStyle: typeof getRangeStyle;
26
19
  getValueFromPoint(ctx: Ctx, point: Point): number | undefined;
27
20
  dispatchChangeEvent(ctx: Ctx): void;
28
- getMarkerStyle(ctx: Ctx, percent: number): Style;
21
+ getThumbOffset: (ctx: import("./slider.types").SharedContext) => string;
22
+ getControlStyle: () => import("@zag-js/types").Style;
23
+ getThumbStyle: (ctx: import("./slider.types").SharedContext) => import("@zag-js/types").Style;
24
+ getRangeStyle: (ctx: Pick<import("./slider.types").SharedContext, "isVertical" | "isRtl">) => import("@zag-js/types").Style;
25
+ getRootStyle: (ctx: Ctx) => import("@zag-js/types").Style;
26
+ getMarkerStyle: (ctx: Pick<import("./slider.types").SharedContext, "isHorizontal" | "isRtl">, percent: number) => import("@zag-js/types").Style;
27
+ getLabelStyle: () => import("@zag-js/types").Style;
28
+ getTrackStyle: () => import("@zag-js/types").Style;
29
+ getMarkerGroupStyle: () => import("@zag-js/types").Style;
29
30
  };
30
- export {};
31
- //# sourceMappingURL=slider.dom.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import { MachineContext, MachineState, UserDefinedContext } from "./slider.types";
2
2
  export declare function machine(ctx?: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
3
- //# sourceMappingURL=slider.machine.d.ts.map
@@ -0,0 +1,23 @@
1
+ import type { Style } from "@zag-js/types";
2
+ import type { MachineContext as Ctx, SharedContext } from "./slider.types";
3
+ declare function getThumbOffset(ctx: SharedContext): string;
4
+ declare function getThumbStyle(ctx: SharedContext): Style;
5
+ declare function getRangeStyle(ctx: Pick<SharedContext, "isVertical" | "isRtl">): Style;
6
+ declare function getControlStyle(): Style;
7
+ declare function getRootStyle(ctx: Ctx): Style;
8
+ declare function getMarkerStyle(ctx: Pick<SharedContext, "isHorizontal" | "isRtl">, percent: number): Style;
9
+ declare function getLabelStyle(): Style;
10
+ declare function getTrackStyle(): Style;
11
+ declare function getMarkerGroupStyle(): Style;
12
+ export declare const styles: {
13
+ getThumbOffset: typeof getThumbOffset;
14
+ getControlStyle: typeof getControlStyle;
15
+ getThumbStyle: typeof getThumbStyle;
16
+ getRangeStyle: typeof getRangeStyle;
17
+ getRootStyle: typeof getRootStyle;
18
+ getMarkerStyle: typeof getMarkerStyle;
19
+ getLabelStyle: typeof getLabelStyle;
20
+ getTrackStyle: typeof getTrackStyle;
21
+ getMarkerGroupStyle: typeof getMarkerGroupStyle;
22
+ };
23
+ export {};
@@ -89,6 +89,12 @@ declare type PublicContext = DirectionProperty & {
89
89
  onChangeStart?(details: {
90
90
  value: number;
91
91
  }): void;
92
+ /**
93
+ * The alignment of the slider thumb relative to the track
94
+ * - `center`: the thumb will extend beyond the bounds of the slider track.
95
+ * - `contain`: the thumb will be contained within the bounds of the track.
96
+ */
97
+ thumbAlignment?: "contain" | "center";
92
98
  };
93
99
  export declare type UserDefinedContext = Partial<PublicContext>;
94
100
  declare type ComputedContext = Readonly<{
@@ -156,8 +162,8 @@ export declare type SharedContext = {
156
162
  width: number;
157
163
  height: number;
158
164
  } | null;
165
+ thumbAlignment?: "contain" | "center";
159
166
  orientation?: "horizontal" | "vertical";
160
167
  readonly hasMeasuredThumbSize: boolean;
161
168
  };
162
169
  export {};
163
- //# sourceMappingURL=slider.types.d.ts.map
@@ -6,4 +6,3 @@ export declare const utils: {
6
6
  decrement(ctx: Ctx, step?: number): number;
7
7
  increment(ctx: Ctx, step?: number): number;
8
8
  };
9
- //# sourceMappingURL=slider.utils.d.ts.map