@zag-js/slider 1.0.1 → 1.0.2

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
@@ -542,13 +542,13 @@ var machine = core.createMachine({
542
542
  origin: "start",
543
543
  orientation: "horizontal",
544
544
  minStepsBetweenThumbs: 0,
545
- ...utils.compact(props2)
545
+ ...props2
546
546
  };
547
547
  },
548
548
  initialState() {
549
549
  return "idle";
550
550
  },
551
- context({ prop, bindable, getContext, scope }) {
551
+ context({ prop, bindable, getContext }) {
552
552
  return {
553
553
  thumbSize: bindable(() => ({
554
554
  defaultValue: prop("thumbSize") || null
@@ -556,9 +556,11 @@ var machine = core.createMachine({
556
556
  value: bindable(() => ({
557
557
  defaultValue: prop("defaultValue"),
558
558
  value: prop("value"),
559
+ hash(a) {
560
+ return a.join(",");
561
+ },
559
562
  onChange(value) {
560
563
  prop("onValueChange")?.({ value });
561
- dispatchChangeEvent(scope, value);
562
564
  }
563
565
  })),
564
566
  focusedIndex: bindable(() => ({
@@ -585,11 +587,10 @@ var machine = core.createMachine({
585
587
  }
586
588
  },
587
589
  watch({ track, action, context }) {
588
- track([() => context.get("value").join(",")], () => {
589
- action(["syncInputElements"]);
590
+ track([() => context.hash("value")], () => {
591
+ action(["syncInputElements", "dispatchChangeEvent"]);
590
592
  });
591
593
  },
592
- entry: ["coarseValue"],
593
594
  effects: ["trackFormControlState", "trackThumbsSize"],
594
595
  on: {
595
596
  SET_VALUE: [
@@ -706,6 +707,9 @@ var machine = core.createMachine({
706
707
  }
707
708
  },
708
709
  actions: {
710
+ dispatchChangeEvent({ context, scope }) {
711
+ dispatchChangeEvent(scope, context.get("value"));
712
+ },
709
713
  syncInputElements({ context, scope }) {
710
714
  context.get("value").forEach((value, index) => {
711
715
  const inputEl = getHiddenInputEl(scope, index);
@@ -766,11 +770,6 @@ var machine = core.createMachine({
766
770
  const { max } = getRangeAtIndex(params, index);
767
771
  context.set("value", (prev) => utils.setValueAtIndex(prev, index, max));
768
772
  },
769
- coarseValue(params) {
770
- const { context } = params;
771
- const value = normalizeValues(params, context.get("value"));
772
- context.set("value", value);
773
- },
774
773
  setValueAtIndex(params) {
775
774
  const { context, event } = params;
776
775
  const value = constrainValue(params, event.value, event.index);
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createAnatomy } from '@zag-js/anatomy';
2
2
  import { trackFormControl, trackPointerMove, setElementValue, raf, queryAll, getRelativePoint, dispatchInputValueEvent, dataAttr, ariaAttr, getEventStep, getEventKey, isLeftClick, isModifierKey, getEventPoint } from '@zag-js/dom-query';
3
- import { compact, getValuePercent, setValueAtIndex, createSplitProps, getPercentValue, getValueRanges, snapValueToStep, clampValue, getPreviousStepValue, getNextStepValue, getClosestValueIndex, first, last, getValueTransformer } from '@zag-js/utils';
3
+ import { getValuePercent, setValueAtIndex, createSplitProps, getPercentValue, getValueRanges, snapValueToStep, clampValue, getPreviousStepValue, getNextStepValue, getClosestValueIndex, first, last, getValueTransformer } from '@zag-js/utils';
4
4
  import { createMachine } from '@zag-js/core';
5
5
  import { trackElementsSize } from '@zag-js/element-size';
6
6
  import { createProps } from '@zag-js/types';
@@ -540,13 +540,13 @@ var machine = createMachine({
540
540
  origin: "start",
541
541
  orientation: "horizontal",
542
542
  minStepsBetweenThumbs: 0,
543
- ...compact(props2)
543
+ ...props2
544
544
  };
545
545
  },
546
546
  initialState() {
547
547
  return "idle";
548
548
  },
549
- context({ prop, bindable, getContext, scope }) {
549
+ context({ prop, bindable, getContext }) {
550
550
  return {
551
551
  thumbSize: bindable(() => ({
552
552
  defaultValue: prop("thumbSize") || null
@@ -554,9 +554,11 @@ var machine = createMachine({
554
554
  value: bindable(() => ({
555
555
  defaultValue: prop("defaultValue"),
556
556
  value: prop("value"),
557
+ hash(a) {
558
+ return a.join(",");
559
+ },
557
560
  onChange(value) {
558
561
  prop("onValueChange")?.({ value });
559
- dispatchChangeEvent(scope, value);
560
562
  }
561
563
  })),
562
564
  focusedIndex: bindable(() => ({
@@ -583,11 +585,10 @@ var machine = createMachine({
583
585
  }
584
586
  },
585
587
  watch({ track, action, context }) {
586
- track([() => context.get("value").join(",")], () => {
587
- action(["syncInputElements"]);
588
+ track([() => context.hash("value")], () => {
589
+ action(["syncInputElements", "dispatchChangeEvent"]);
588
590
  });
589
591
  },
590
- entry: ["coarseValue"],
591
592
  effects: ["trackFormControlState", "trackThumbsSize"],
592
593
  on: {
593
594
  SET_VALUE: [
@@ -704,6 +705,9 @@ var machine = createMachine({
704
705
  }
705
706
  },
706
707
  actions: {
708
+ dispatchChangeEvent({ context, scope }) {
709
+ dispatchChangeEvent(scope, context.get("value"));
710
+ },
707
711
  syncInputElements({ context, scope }) {
708
712
  context.get("value").forEach((value, index) => {
709
713
  const inputEl = getHiddenInputEl(scope, index);
@@ -764,11 +768,6 @@ var machine = createMachine({
764
768
  const { max } = getRangeAtIndex(params, index);
765
769
  context.set("value", (prev) => setValueAtIndex(prev, index, max));
766
770
  },
767
- coarseValue(params) {
768
- const { context } = params;
769
- const value = normalizeValues(params, context.get("value"));
770
- context.set("value", value);
771
- },
772
771
  setValueAtIndex(params) {
773
772
  const { context, event } = params;
774
773
  const value = constrainValue(params, event.value, event.index);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/slider",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Core logic for the slider widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,12 +27,12 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/anatomy": "1.0.1",
31
- "@zag-js/core": "1.0.1",
32
- "@zag-js/dom-query": "1.0.1",
33
- "@zag-js/utils": "1.0.1",
34
- "@zag-js/element-size": "1.0.1",
35
- "@zag-js/types": "1.0.1"
30
+ "@zag-js/anatomy": "1.0.2",
31
+ "@zag-js/core": "1.0.2",
32
+ "@zag-js/dom-query": "1.0.2",
33
+ "@zag-js/utils": "1.0.2",
34
+ "@zag-js/element-size": "1.0.2",
35
+ "@zag-js/types": "1.0.2"
36
36
  },
37
37
  "devDependencies": {
38
38
  "clean-package": "2.2.0"