@zag-js/color-picker 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
@@ -835,7 +835,7 @@ var machine = core.createMachine({
835
835
  const open = prop("open") || prop("defaultOpen");
836
836
  return open ? "open" : "idle";
837
837
  },
838
- context({ prop, bindable, getContext, scope }) {
838
+ context({ prop, bindable, getContext }) {
839
839
  return {
840
840
  value: bindable(() => ({
841
841
  defaultValue: prop("defaultValue"),
@@ -850,7 +850,6 @@ var machine = core.createMachine({
850
850
  const ctx = getContext();
851
851
  const valueAsString = value.toString(ctx.get("format"));
852
852
  prop("onValueChange")?.({ value, valueAsString });
853
- domQuery.dispatchInputValueEvent(getHiddenInputEl(scope), { value: valueAsString });
854
853
  }
855
854
  })),
856
855
  format: bindable(() => ({
@@ -883,7 +882,7 @@ var machine = core.createMachine({
883
882
  effects: ["trackFormControl"],
884
883
  watch({ prop, context, action, track }) {
885
884
  track([() => context.hash("value")], () => {
886
- action(["syncInputElements"]);
885
+ action(["syncInputElements", "dispatchChangeEvent"]);
887
886
  });
888
887
  track([() => context.get("format")], () => {
889
888
  action(["syncFormatSelectElement"]);
@@ -1280,8 +1279,11 @@ var machine = core.createMachine({
1280
1279
  setFormat({ context, event }) {
1281
1280
  context.set("format", event.format);
1282
1281
  },
1282
+ dispatchChangeEvent({ scope, computed }) {
1283
+ domQuery.dispatchInputValueEvent(getHiddenInputEl(scope), { value: computed("valueAsString") });
1284
+ },
1283
1285
  syncInputElements({ context, scope }) {
1284
- syncInputs(scope, context.get("value"));
1286
+ syncChannelInputs(scope, context.get("value"));
1285
1287
  },
1286
1288
  invokeOnChangeEnd({ context, prop, computed }) {
1287
1289
  prop("onValueChangeEnd")?.({
@@ -1307,7 +1309,7 @@ var machine = core.createMachine({
1307
1309
  const valueAsNumber = Number.isNaN(value) ? current.getChannelValue(channel) : value;
1308
1310
  color = current.withChannelValue(channel, valueAsNumber);
1309
1311
  }
1310
- syncInputs(scope, context.get("value"), color);
1312
+ syncChannelInputs(scope, context.get("value"), color);
1311
1313
  context.set("value", color);
1312
1314
  },
1313
1315
  incrementChannel({ context, event }) {
@@ -1390,7 +1392,7 @@ var machine = core.createMachine({
1390
1392
  }
1391
1393
  }
1392
1394
  });
1393
- function syncInputs(scope, currentValue, nextValue) {
1395
+ function syncChannelInputs(scope, currentValue, nextValue) {
1394
1396
  const channelInputEls = getChannelInputEls(scope);
1395
1397
  domQuery.raf(() => {
1396
1398
  channelInputEls.forEach((inputEl) => {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createAnatomy } from '@zag-js/anatomy';
2
2
  import { parseColor, normalizeColor, getColorAreaGradient } from '@zag-js/color-utils';
3
- import { dispatchInputValueEvent, trackFormControl, trackPointerMove, disableTextSelection, raf, getInitialFocus, setElementValue, getRelativePoint, queryAll, dataAttr, query, isLeftClick, isModifierKey, getEventPoint, getEventStep, getEventKey, visuallyHiddenStyle } from '@zag-js/dom-query';
3
+ import { trackFormControl, trackPointerMove, disableTextSelection, dispatchInputValueEvent, raf, getInitialFocus, setElementValue, getRelativePoint, queryAll, dataAttr, query, isLeftClick, isModifierKey, getEventPoint, getEventStep, getEventKey, visuallyHiddenStyle } from '@zag-js/dom-query';
4
4
  import { getPlacement, getPlacementStyles } from '@zag-js/popper';
5
5
  import { createGuards, createMachine } from '@zag-js/core';
6
6
  import { trackDismissableElement } from '@zag-js/dismissable';
@@ -833,7 +833,7 @@ var machine = createMachine({
833
833
  const open = prop("open") || prop("defaultOpen");
834
834
  return open ? "open" : "idle";
835
835
  },
836
- context({ prop, bindable, getContext, scope }) {
836
+ context({ prop, bindable, getContext }) {
837
837
  return {
838
838
  value: bindable(() => ({
839
839
  defaultValue: prop("defaultValue"),
@@ -848,7 +848,6 @@ var machine = createMachine({
848
848
  const ctx = getContext();
849
849
  const valueAsString = value.toString(ctx.get("format"));
850
850
  prop("onValueChange")?.({ value, valueAsString });
851
- dispatchInputValueEvent(getHiddenInputEl(scope), { value: valueAsString });
852
851
  }
853
852
  })),
854
853
  format: bindable(() => ({
@@ -881,7 +880,7 @@ var machine = createMachine({
881
880
  effects: ["trackFormControl"],
882
881
  watch({ prop, context, action, track }) {
883
882
  track([() => context.hash("value")], () => {
884
- action(["syncInputElements"]);
883
+ action(["syncInputElements", "dispatchChangeEvent"]);
885
884
  });
886
885
  track([() => context.get("format")], () => {
887
886
  action(["syncFormatSelectElement"]);
@@ -1278,8 +1277,11 @@ var machine = createMachine({
1278
1277
  setFormat({ context, event }) {
1279
1278
  context.set("format", event.format);
1280
1279
  },
1280
+ dispatchChangeEvent({ scope, computed }) {
1281
+ dispatchInputValueEvent(getHiddenInputEl(scope), { value: computed("valueAsString") });
1282
+ },
1281
1283
  syncInputElements({ context, scope }) {
1282
- syncInputs(scope, context.get("value"));
1284
+ syncChannelInputs(scope, context.get("value"));
1283
1285
  },
1284
1286
  invokeOnChangeEnd({ context, prop, computed }) {
1285
1287
  prop("onValueChangeEnd")?.({
@@ -1305,7 +1307,7 @@ var machine = createMachine({
1305
1307
  const valueAsNumber = Number.isNaN(value) ? current.getChannelValue(channel) : value;
1306
1308
  color = current.withChannelValue(channel, valueAsNumber);
1307
1309
  }
1308
- syncInputs(scope, context.get("value"), color);
1310
+ syncChannelInputs(scope, context.get("value"), color);
1309
1311
  context.set("value", color);
1310
1312
  },
1311
1313
  incrementChannel({ context, event }) {
@@ -1388,7 +1390,7 @@ var machine = createMachine({
1388
1390
  }
1389
1391
  }
1390
1392
  });
1391
- function syncInputs(scope, currentValue, nextValue) {
1393
+ function syncChannelInputs(scope, currentValue, nextValue) {
1392
1394
  const channelInputEls = getChannelInputEls(scope);
1393
1395
  raf(() => {
1394
1396
  channelInputEls.forEach((inputEl) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/color-picker",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Core logic for the color-picker widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,14 +27,14 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/core": "1.0.1",
31
- "@zag-js/anatomy": "1.0.1",
32
- "@zag-js/dom-query": "1.0.1",
33
- "@zag-js/dismissable": "1.0.1",
34
- "@zag-js/utils": "1.0.1",
35
- "@zag-js/color-utils": "1.0.1",
36
- "@zag-js/popper": "1.0.1",
37
- "@zag-js/types": "1.0.1"
30
+ "@zag-js/core": "1.0.2",
31
+ "@zag-js/anatomy": "1.0.2",
32
+ "@zag-js/dom-query": "1.0.2",
33
+ "@zag-js/dismissable": "1.0.2",
34
+ "@zag-js/utils": "1.0.2",
35
+ "@zag-js/color-utils": "1.0.2",
36
+ "@zag-js/popper": "1.0.2",
37
+ "@zag-js/types": "1.0.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "clean-package": "2.2.0"