@zag-js/slider 0.2.2 → 0.2.4

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
@@ -20,12 +20,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ anatomy: () => anatomy,
23
24
  connect: () => connect,
24
25
  machine: () => machine,
25
26
  unstable__dom: () => dom
26
27
  });
27
28
  module.exports = __toCommonJS(src_exports);
28
29
 
30
+ // src/slider.anatomy.ts
31
+ var import_anatomy = require("@zag-js/anatomy");
32
+ var anatomy = (0, import_anatomy.createAnatomy)("slider").parts(
33
+ "root",
34
+ "label",
35
+ "thumb",
36
+ "input",
37
+ "output",
38
+ "track",
39
+ "range",
40
+ "control",
41
+ "markerGroup",
42
+ "marker"
43
+ );
44
+ var parts = anatomy.build();
45
+
29
46
  // ../../utilities/dom/dist/index.mjs
30
47
  var dataAttr = (guard) => {
31
48
  return guard ? "" : void 0;
@@ -342,6 +359,65 @@ function trackPointerMove(doc, opts) {
342
359
  );
343
360
  }
344
361
 
362
+ // ../../utilities/number/dist/index.mjs
363
+ function round(v, t) {
364
+ let num = valueOf(v);
365
+ const p = 10 ** (t != null ? t : 10);
366
+ num = Math.round(num * p) / p;
367
+ return t ? num.toFixed(t) : v.toString();
368
+ }
369
+ var valueToPercent = (v, r) => (valueOf(v) - r.min) * 100 / (r.max - r.min);
370
+ var percentToValue = (v, r) => r.min + (r.max - r.min) * valueOf(v);
371
+ function clamp(v, o) {
372
+ return Math.min(Math.max(valueOf(v), o.min), o.max);
373
+ }
374
+ function countDecimals(value) {
375
+ if (!Number.isFinite(value))
376
+ return 0;
377
+ let e = 1, p = 0;
378
+ while (Math.round(value * e) / e !== value) {
379
+ e *= 10;
380
+ p += 1;
381
+ }
382
+ return p;
383
+ }
384
+ var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
385
+ var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
386
+ function snapToStep(value, step) {
387
+ const num = valueOf(value);
388
+ const p = countDecimals(step);
389
+ const v = Math.round(num / step) * step;
390
+ return round(v, p);
391
+ }
392
+ function valueOf(v) {
393
+ if (typeof v === "number")
394
+ return v;
395
+ const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
396
+ return !Number.isNaN(num) ? num : 0;
397
+ }
398
+ function decimalOperation(a, op, b) {
399
+ let result = op === "+" ? a + b : a - b;
400
+ if (a % 1 !== 0 || b % 1 !== 0) {
401
+ const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
402
+ a = Math.round(a * multiplier);
403
+ b = Math.round(b * multiplier);
404
+ result = op === "+" ? a + b : a - b;
405
+ result /= multiplier;
406
+ }
407
+ return result;
408
+ }
409
+ var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
410
+ var transform = (a, b) => {
411
+ const i = { min: a[0], max: a[1] };
412
+ const o = { min: b[0], max: b[1] };
413
+ return (v) => {
414
+ if (i.min === i.max || o.min === o.max)
415
+ return o.min;
416
+ const ratio = (o.max - o.min) / (i.max - i.min);
417
+ return o.min + ratio * (v - i.min);
418
+ };
419
+ };
420
+
345
421
  // ../../utilities/form-utils/dist/index.mjs
346
422
  function getWindow(el) {
347
423
  var _a;
@@ -405,65 +481,21 @@ function trackFieldsetDisabled(el, callback) {
405
481
  callback(fieldset.disabled);
406
482
  return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
407
483
  }
408
-
409
- // ../../utilities/number/dist/index.mjs
410
- function round(v, t) {
411
- let num = valueOf(v);
412
- const p = 10 ** (t != null ? t : 10);
413
- num = Math.round(num * p) / p;
414
- return t ? num.toFixed(t) : v.toString();
415
- }
416
- var valueToPercent = (v, r) => (valueOf(v) - r.min) * 100 / (r.max - r.min);
417
- var percentToValue = (v, r) => r.min + (r.max - r.min) * valueOf(v);
418
- function clamp(v, o) {
419
- return Math.min(Math.max(valueOf(v), o.min), o.max);
420
- }
421
- function countDecimals(value) {
422
- if (!Number.isFinite(value))
423
- return 0;
424
- let e = 1, p = 0;
425
- while (Math.round(value * e) / e !== value) {
426
- e *= 10;
427
- p += 1;
428
- }
429
- return p;
430
- }
431
- var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
432
- var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
433
- function snapToStep(value, step) {
434
- const num = valueOf(value);
435
- const p = countDecimals(step);
436
- const v = Math.round(num / step) * step;
437
- return round(v, p);
438
- }
439
- function valueOf(v) {
440
- if (typeof v === "number")
441
- return v;
442
- const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
443
- return !Number.isNaN(num) ? num : 0;
444
- }
445
- function decimalOperation(a, op, b) {
446
- let result = op === "+" ? a + b : a - b;
447
- if (a % 1 !== 0 || b % 1 !== 0) {
448
- const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
449
- a = Math.round(a * multiplier);
450
- b = Math.round(b * multiplier);
451
- result = op === "+" ? a + b : a - b;
452
- result /= multiplier;
453
- }
454
- return result;
455
- }
456
- var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
457
- var transform = (a, b) => {
458
- const i = { min: a[0], max: a[1] };
459
- const o = { min: b[0], max: b[1] };
460
- return (v) => {
461
- if (i.min === i.max || o.min === o.max)
462
- return o.min;
463
- const ratio = (o.max - o.min) / (i.max - i.min);
464
- return o.min + ratio * (v - i.min);
484
+ function trackFormControl(el, options) {
485
+ if (!el)
486
+ return;
487
+ const { onFieldsetDisabled, onFormReset } = options;
488
+ const cleanups = [
489
+ trackFormReset(el, onFormReset),
490
+ trackFieldsetDisabled(el, (disabled) => {
491
+ if (disabled)
492
+ onFieldsetDisabled();
493
+ })
494
+ ];
495
+ return () => {
496
+ cleanups.forEach((cleanup) => cleanup == null ? void 0 : cleanup());
465
497
  };
466
- };
498
+ }
467
499
 
468
500
  // src/slider.style.ts
469
501
  function getVerticalThumbOffset(ctx) {
@@ -686,7 +718,7 @@ function connect(state2, send, normalize) {
686
718
  send("DECREMENT");
687
719
  },
688
720
  rootProps: normalize.element({
689
- "data-part": "root",
721
+ ...parts.root.attrs,
690
722
  "data-disabled": dataAttr(isDisabled),
691
723
  "data-focus": dataAttr(isFocused),
692
724
  "data-orientation": state2.context.orientation,
@@ -696,7 +728,7 @@ function connect(state2, send, normalize) {
696
728
  style: dom.getRootStyle(state2.context)
697
729
  }),
698
730
  labelProps: normalize.label({
699
- "data-part": "label",
731
+ ...parts.label.attrs,
700
732
  "data-disabled": dataAttr(isDisabled),
701
733
  "data-invalid": dataAttr(isInvalid),
702
734
  "data-focus": dataAttr(isFocused),
@@ -712,7 +744,7 @@ function connect(state2, send, normalize) {
712
744
  style: dom.getLabelStyle()
713
745
  }),
714
746
  thumbProps: normalize.element({
715
- "data-part": "thumb",
747
+ ...parts.thumb.attrs,
716
748
  id: dom.getThumbId(state2.context),
717
749
  "data-disabled": dataAttr(isDisabled),
718
750
  "data-orientation": state2.context.orientation,
@@ -787,15 +819,16 @@ function connect(state2, send, normalize) {
787
819
  style: dom.getThumbStyle(state2.context)
788
820
  }),
789
821
  inputProps: normalize.input({
790
- "data-part": "input",
822
+ ...parts.input.attrs,
791
823
  type: "text",
792
824
  defaultValue: state2.context.value,
793
825
  name: state2.context.name,
826
+ form: state2.context.form,
794
827
  id: dom.getInputId(state2.context),
795
828
  hidden: true
796
829
  }),
797
830
  outputProps: normalize.output({
798
- "data-part": "output",
831
+ ...parts.output.attrs,
799
832
  "data-disabled": dataAttr(isDisabled),
800
833
  "data-invalid": dataAttr(isInvalid),
801
834
  id: dom.getOutputId(state2.context),
@@ -803,7 +836,7 @@ function connect(state2, send, normalize) {
803
836
  "aria-live": "off"
804
837
  }),
805
838
  trackProps: normalize.element({
806
- "data-part": "track",
839
+ ...parts.track.attrs,
807
840
  id: dom.getTrackId(state2.context),
808
841
  "data-disabled": dataAttr(isDisabled),
809
842
  "data-focus": dataAttr(isFocused),
@@ -812,7 +845,7 @@ function connect(state2, send, normalize) {
812
845
  style: dom.getTrackStyle()
813
846
  }),
814
847
  rangeProps: normalize.element({
815
- "data-part": "range",
848
+ ...parts.range.attrs,
816
849
  id: dom.getRangeId(state2.context),
817
850
  "data-focus": dataAttr(isFocused),
818
851
  "data-invalid": dataAttr(isInvalid),
@@ -821,7 +854,7 @@ function connect(state2, send, normalize) {
821
854
  style: dom.getRangeStyle(state2.context)
822
855
  }),
823
856
  controlProps: normalize.element({
824
- "data-part": "control",
857
+ ...parts.control.attrs,
825
858
  id: dom.getControlId(state2.context),
826
859
  "data-disabled": dataAttr(isDisabled),
827
860
  "data-invalid": dataAttr(isInvalid),
@@ -841,7 +874,7 @@ function connect(state2, send, normalize) {
841
874
  style: dom.getControlStyle()
842
875
  }),
843
876
  markerGroupProps: normalize.element({
844
- "data-part": "marker-group",
877
+ ...parts.markerGroup.attrs,
845
878
  role: "presentation",
846
879
  "aria-hidden": true,
847
880
  "data-orientation": state2.context.orientation,
@@ -852,7 +885,7 @@ function connect(state2, send, normalize) {
852
885
  const style = dom.getMarkerStyle(state2.context, percent);
853
886
  const markerState = value > state2.context.value ? "over-value" : value < state2.context.value ? "under-value" : "at-value";
854
887
  return normalize.element({
855
- "data-part": "marker",
888
+ ...parts.marker.attrs,
856
889
  role: "presentation",
857
890
  "data-orientation": state2.context.orientation,
858
891
  id: dom.getMarkerId(state2.context, value),
@@ -906,13 +939,13 @@ function machine(userContext) {
906
939
  isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
907
940
  isVertical: (ctx2) => ctx2.orientation === "vertical",
908
941
  isRtl: (ctx2) => ctx2.orientation === "horizontal" && ctx2.dir === "rtl",
909
- isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readonly),
942
+ isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readOnly),
910
943
  hasMeasuredThumbSize: (ctx2) => ctx2.thumbSize !== null
911
944
  },
912
945
  watch: {
913
946
  value: ["invokeOnChange", "dispatchChangeEvent"]
914
947
  },
915
- activities: ["trackFormReset", "trackFieldsetDisabled", "trackThumbSize"],
948
+ activities: ["trackFormControlState", "trackThumbSize"],
916
949
  on: {
917
950
  SET_VALUE: {
918
951
  actions: "setValue"
@@ -1001,17 +1034,15 @@ function machine(userContext) {
1001
1034
  isVertical: (ctx2) => ctx2.isVertical
1002
1035
  },
1003
1036
  activities: {
1004
- trackFieldsetDisabled(ctx2) {
1005
- return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
1006
- if (disabled) {
1007
- ctx2.disabled = disabled;
1008
- }
1009
- });
1010
- },
1011
- trackFormReset(ctx2) {
1012
- return trackFormReset(dom.getInputEl(ctx2), () => {
1013
- if (ctx2.initialValue != null) {
1014
- ctx2.value = ctx2.initialValue;
1037
+ trackFormControlState(ctx2) {
1038
+ return trackFormControl(dom.getInputEl(ctx2), {
1039
+ onFieldsetDisabled() {
1040
+ ctx2.disabled = true;
1041
+ },
1042
+ onFormReset() {
1043
+ if (ctx2.initialValue != null) {
1044
+ ctx2.value = ctx2.initialValue;
1045
+ }
1015
1046
  }
1016
1047
  });
1017
1048
  },
@@ -1088,6 +1119,7 @@ function machine(userContext) {
1088
1119
  }
1089
1120
  // Annotate the CommonJS export names for ESM import in node:
1090
1121
  0 && (module.exports = {
1122
+ anatomy,
1091
1123
  connect,
1092
1124
  machine,
1093
1125
  unstable__dom
package/dist/index.mjs CHANGED
@@ -1,3 +1,19 @@
1
+ // src/slider.anatomy.ts
2
+ import { createAnatomy } from "@zag-js/anatomy";
3
+ var anatomy = createAnatomy("slider").parts(
4
+ "root",
5
+ "label",
6
+ "thumb",
7
+ "input",
8
+ "output",
9
+ "track",
10
+ "range",
11
+ "control",
12
+ "markerGroup",
13
+ "marker"
14
+ );
15
+ var parts = anatomy.build();
16
+
1
17
  // ../../utilities/dom/dist/index.mjs
2
18
  var dataAttr = (guard) => {
3
19
  return guard ? "" : void 0;
@@ -314,6 +330,65 @@ function trackPointerMove(doc, opts) {
314
330
  );
315
331
  }
316
332
 
333
+ // ../../utilities/number/dist/index.mjs
334
+ function round(v, t) {
335
+ let num = valueOf(v);
336
+ const p = 10 ** (t != null ? t : 10);
337
+ num = Math.round(num * p) / p;
338
+ return t ? num.toFixed(t) : v.toString();
339
+ }
340
+ var valueToPercent = (v, r) => (valueOf(v) - r.min) * 100 / (r.max - r.min);
341
+ var percentToValue = (v, r) => r.min + (r.max - r.min) * valueOf(v);
342
+ function clamp(v, o) {
343
+ return Math.min(Math.max(valueOf(v), o.min), o.max);
344
+ }
345
+ function countDecimals(value) {
346
+ if (!Number.isFinite(value))
347
+ return 0;
348
+ let e = 1, p = 0;
349
+ while (Math.round(value * e) / e !== value) {
350
+ e *= 10;
351
+ p += 1;
352
+ }
353
+ return p;
354
+ }
355
+ var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
356
+ var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
357
+ function snapToStep(value, step) {
358
+ const num = valueOf(value);
359
+ const p = countDecimals(step);
360
+ const v = Math.round(num / step) * step;
361
+ return round(v, p);
362
+ }
363
+ function valueOf(v) {
364
+ if (typeof v === "number")
365
+ return v;
366
+ const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
367
+ return !Number.isNaN(num) ? num : 0;
368
+ }
369
+ function decimalOperation(a, op, b) {
370
+ let result = op === "+" ? a + b : a - b;
371
+ if (a % 1 !== 0 || b % 1 !== 0) {
372
+ const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
373
+ a = Math.round(a * multiplier);
374
+ b = Math.round(b * multiplier);
375
+ result = op === "+" ? a + b : a - b;
376
+ result /= multiplier;
377
+ }
378
+ return result;
379
+ }
380
+ var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
381
+ var transform = (a, b) => {
382
+ const i = { min: a[0], max: a[1] };
383
+ const o = { min: b[0], max: b[1] };
384
+ return (v) => {
385
+ if (i.min === i.max || o.min === o.max)
386
+ return o.min;
387
+ const ratio = (o.max - o.min) / (i.max - i.min);
388
+ return o.min + ratio * (v - i.min);
389
+ };
390
+ };
391
+
317
392
  // ../../utilities/form-utils/dist/index.mjs
318
393
  function getWindow(el) {
319
394
  var _a;
@@ -377,65 +452,21 @@ function trackFieldsetDisabled(el, callback) {
377
452
  callback(fieldset.disabled);
378
453
  return observeAttributes(fieldset, ["disabled"], () => callback(fieldset.disabled));
379
454
  }
380
-
381
- // ../../utilities/number/dist/index.mjs
382
- function round(v, t) {
383
- let num = valueOf(v);
384
- const p = 10 ** (t != null ? t : 10);
385
- num = Math.round(num * p) / p;
386
- return t ? num.toFixed(t) : v.toString();
387
- }
388
- var valueToPercent = (v, r) => (valueOf(v) - r.min) * 100 / (r.max - r.min);
389
- var percentToValue = (v, r) => r.min + (r.max - r.min) * valueOf(v);
390
- function clamp(v, o) {
391
- return Math.min(Math.max(valueOf(v), o.min), o.max);
392
- }
393
- function countDecimals(value) {
394
- if (!Number.isFinite(value))
395
- return 0;
396
- let e = 1, p = 0;
397
- while (Math.round(value * e) / e !== value) {
398
- e *= 10;
399
- p += 1;
400
- }
401
- return p;
402
- }
403
- var increment = (v, s) => decimalOperation(valueOf(v), "+", s);
404
- var decrement = (v, s) => decimalOperation(valueOf(v), "-", s);
405
- function snapToStep(value, step) {
406
- const num = valueOf(value);
407
- const p = countDecimals(step);
408
- const v = Math.round(num / step) * step;
409
- return round(v, p);
410
- }
411
- function valueOf(v) {
412
- if (typeof v === "number")
413
- return v;
414
- const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
415
- return !Number.isNaN(num) ? num : 0;
416
- }
417
- function decimalOperation(a, op, b) {
418
- let result = op === "+" ? a + b : a - b;
419
- if (a % 1 !== 0 || b % 1 !== 0) {
420
- const multiplier = 10 ** Math.max(countDecimals(a), countDecimals(b));
421
- a = Math.round(a * multiplier);
422
- b = Math.round(b * multiplier);
423
- result = op === "+" ? a + b : a - b;
424
- result /= multiplier;
425
- }
426
- return result;
427
- }
428
- var nf = new Intl.NumberFormat("en-US", { style: "decimal", maximumFractionDigits: 20 });
429
- var transform = (a, b) => {
430
- const i = { min: a[0], max: a[1] };
431
- const o = { min: b[0], max: b[1] };
432
- return (v) => {
433
- if (i.min === i.max || o.min === o.max)
434
- return o.min;
435
- const ratio = (o.max - o.min) / (i.max - i.min);
436
- return o.min + ratio * (v - i.min);
455
+ function trackFormControl(el, options) {
456
+ if (!el)
457
+ return;
458
+ const { onFieldsetDisabled, onFormReset } = options;
459
+ const cleanups = [
460
+ trackFormReset(el, onFormReset),
461
+ trackFieldsetDisabled(el, (disabled) => {
462
+ if (disabled)
463
+ onFieldsetDisabled();
464
+ })
465
+ ];
466
+ return () => {
467
+ cleanups.forEach((cleanup) => cleanup == null ? void 0 : cleanup());
437
468
  };
438
- };
469
+ }
439
470
 
440
471
  // src/slider.style.ts
441
472
  function getVerticalThumbOffset(ctx) {
@@ -658,7 +689,7 @@ function connect(state2, send, normalize) {
658
689
  send("DECREMENT");
659
690
  },
660
691
  rootProps: normalize.element({
661
- "data-part": "root",
692
+ ...parts.root.attrs,
662
693
  "data-disabled": dataAttr(isDisabled),
663
694
  "data-focus": dataAttr(isFocused),
664
695
  "data-orientation": state2.context.orientation,
@@ -668,7 +699,7 @@ function connect(state2, send, normalize) {
668
699
  style: dom.getRootStyle(state2.context)
669
700
  }),
670
701
  labelProps: normalize.label({
671
- "data-part": "label",
702
+ ...parts.label.attrs,
672
703
  "data-disabled": dataAttr(isDisabled),
673
704
  "data-invalid": dataAttr(isInvalid),
674
705
  "data-focus": dataAttr(isFocused),
@@ -684,7 +715,7 @@ function connect(state2, send, normalize) {
684
715
  style: dom.getLabelStyle()
685
716
  }),
686
717
  thumbProps: normalize.element({
687
- "data-part": "thumb",
718
+ ...parts.thumb.attrs,
688
719
  id: dom.getThumbId(state2.context),
689
720
  "data-disabled": dataAttr(isDisabled),
690
721
  "data-orientation": state2.context.orientation,
@@ -759,15 +790,16 @@ function connect(state2, send, normalize) {
759
790
  style: dom.getThumbStyle(state2.context)
760
791
  }),
761
792
  inputProps: normalize.input({
762
- "data-part": "input",
793
+ ...parts.input.attrs,
763
794
  type: "text",
764
795
  defaultValue: state2.context.value,
765
796
  name: state2.context.name,
797
+ form: state2.context.form,
766
798
  id: dom.getInputId(state2.context),
767
799
  hidden: true
768
800
  }),
769
801
  outputProps: normalize.output({
770
- "data-part": "output",
802
+ ...parts.output.attrs,
771
803
  "data-disabled": dataAttr(isDisabled),
772
804
  "data-invalid": dataAttr(isInvalid),
773
805
  id: dom.getOutputId(state2.context),
@@ -775,7 +807,7 @@ function connect(state2, send, normalize) {
775
807
  "aria-live": "off"
776
808
  }),
777
809
  trackProps: normalize.element({
778
- "data-part": "track",
810
+ ...parts.track.attrs,
779
811
  id: dom.getTrackId(state2.context),
780
812
  "data-disabled": dataAttr(isDisabled),
781
813
  "data-focus": dataAttr(isFocused),
@@ -784,7 +816,7 @@ function connect(state2, send, normalize) {
784
816
  style: dom.getTrackStyle()
785
817
  }),
786
818
  rangeProps: normalize.element({
787
- "data-part": "range",
819
+ ...parts.range.attrs,
788
820
  id: dom.getRangeId(state2.context),
789
821
  "data-focus": dataAttr(isFocused),
790
822
  "data-invalid": dataAttr(isInvalid),
@@ -793,7 +825,7 @@ function connect(state2, send, normalize) {
793
825
  style: dom.getRangeStyle(state2.context)
794
826
  }),
795
827
  controlProps: normalize.element({
796
- "data-part": "control",
828
+ ...parts.control.attrs,
797
829
  id: dom.getControlId(state2.context),
798
830
  "data-disabled": dataAttr(isDisabled),
799
831
  "data-invalid": dataAttr(isInvalid),
@@ -813,7 +845,7 @@ function connect(state2, send, normalize) {
813
845
  style: dom.getControlStyle()
814
846
  }),
815
847
  markerGroupProps: normalize.element({
816
- "data-part": "marker-group",
848
+ ...parts.markerGroup.attrs,
817
849
  role: "presentation",
818
850
  "aria-hidden": true,
819
851
  "data-orientation": state2.context.orientation,
@@ -824,7 +856,7 @@ function connect(state2, send, normalize) {
824
856
  const style = dom.getMarkerStyle(state2.context, percent);
825
857
  const markerState = value > state2.context.value ? "over-value" : value < state2.context.value ? "under-value" : "at-value";
826
858
  return normalize.element({
827
- "data-part": "marker",
859
+ ...parts.marker.attrs,
828
860
  role: "presentation",
829
861
  "data-orientation": state2.context.orientation,
830
862
  id: dom.getMarkerId(state2.context, value),
@@ -878,13 +910,13 @@ function machine(userContext) {
878
910
  isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
879
911
  isVertical: (ctx2) => ctx2.orientation === "vertical",
880
912
  isRtl: (ctx2) => ctx2.orientation === "horizontal" && ctx2.dir === "rtl",
881
- isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readonly),
913
+ isInteractive: (ctx2) => !(ctx2.disabled || ctx2.readOnly),
882
914
  hasMeasuredThumbSize: (ctx2) => ctx2.thumbSize !== null
883
915
  },
884
916
  watch: {
885
917
  value: ["invokeOnChange", "dispatchChangeEvent"]
886
918
  },
887
- activities: ["trackFormReset", "trackFieldsetDisabled", "trackThumbSize"],
919
+ activities: ["trackFormControlState", "trackThumbSize"],
888
920
  on: {
889
921
  SET_VALUE: {
890
922
  actions: "setValue"
@@ -973,17 +1005,15 @@ function machine(userContext) {
973
1005
  isVertical: (ctx2) => ctx2.isVertical
974
1006
  },
975
1007
  activities: {
976
- trackFieldsetDisabled(ctx2) {
977
- return trackFieldsetDisabled(dom.getRootEl(ctx2), (disabled) => {
978
- if (disabled) {
979
- ctx2.disabled = disabled;
980
- }
981
- });
982
- },
983
- trackFormReset(ctx2) {
984
- return trackFormReset(dom.getInputEl(ctx2), () => {
985
- if (ctx2.initialValue != null) {
986
- ctx2.value = ctx2.initialValue;
1008
+ trackFormControlState(ctx2) {
1009
+ return trackFormControl(dom.getInputEl(ctx2), {
1010
+ onFieldsetDisabled() {
1011
+ ctx2.disabled = true;
1012
+ },
1013
+ onFormReset() {
1014
+ if (ctx2.initialValue != null) {
1015
+ ctx2.value = ctx2.initialValue;
1016
+ }
987
1017
  }
988
1018
  });
989
1019
  },
@@ -1059,6 +1089,7 @@ function machine(userContext) {
1059
1089
  );
1060
1090
  }
1061
1091
  export {
1092
+ anatomy,
1062
1093
  connect,
1063
1094
  machine,
1064
1095
  dom as unstable__dom
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/slider",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Core logic for the slider widget implemented as a state machine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,15 +29,16 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
+ "@zag-js/anatomy": "0.1.1",
32
33
  "@zag-js/core": "0.2.2",
33
34
  "@zag-js/element-size": "0.3.0",
34
35
  "@zag-js/types": "0.3.1"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@zag-js/dom-utils": "0.2.1",
38
- "@zag-js/form-utils": "0.2.1",
39
+ "@zag-js/form-utils": "0.2.2",
39
40
  "@zag-js/utils": "0.3.1",
40
- "@zag-js/number-utils": "0.2.0"
41
+ "@zag-js/number-utils": "0.2.1"
41
42
  },
42
43
  "scripts": {
43
44
  "build-fast": "tsup src/index.ts --format=esm,cjs",