@zag-js/color-picker 1.43.2 → 1.44.0

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.
@@ -86,9 +86,7 @@ function connect(service, normalize) {
86
86
  inline: !!prop("inline"),
87
87
  setOpen(nextOpen) {
88
88
  if (prop("inline")) return;
89
- const open2 = state.hasTag("open");
90
- if (open2 === nextOpen) return;
91
- send({ type: nextOpen ? "OPEN" : "CLOSE" });
89
+ send({ type: nextOpen ? "OPEN" : "CLOSE", replaces: "open" });
92
90
  },
93
91
  setValue(value2) {
94
92
  send({ type: "VALUE.SET", value: (0, import_color_utils.normalizeColor)(value2), src: "set-color" });
@@ -288,6 +286,7 @@ function connect(service, normalize) {
288
286
  "data-invalid": (0, import_dom_query2.dataAttr)(invalid),
289
287
  "data-readonly": (0, import_dom_query2.dataAttr)(readOnly),
290
288
  role: "slider",
289
+ "aria-disabled": (0, import_dom_query2.ariaAttr)(disabled),
291
290
  "aria-valuemin": 0,
292
291
  "aria-valuemax": 100,
293
292
  "aria-valuenow": xValue,
@@ -446,7 +445,7 @@ function connect(service, normalize) {
446
445
  "data-channel": channel,
447
446
  "data-disabled": (0, import_dom_query2.dataAttr)(disabled),
448
447
  "data-orientation": orientation,
449
- "aria-disabled": (0, import_dom_query2.dataAttr)(disabled),
448
+ "aria-disabled": (0, import_dom_query2.ariaAttr)(disabled),
450
449
  "aria-orientation": orientation,
451
450
  "aria-valuemax": channelRange.maxValue,
452
451
  "aria-valuemin": channelRange.minValue,
@@ -1,7 +1,14 @@
1
1
  // src/color-picker.connect.ts
2
2
  import { getColorAreaGradient, normalizeColor } from "@zag-js/color-utils";
3
- import { getEventKey, getEventPoint, getEventStep, isComposingEvent, isLeftClick, isModifierKey } from "@zag-js/dom-query";
4
- import { dataAttr, query, visuallyHiddenStyle } from "@zag-js/dom-query";
3
+ import {
4
+ getEventKey,
5
+ getEventPoint,
6
+ getEventStep,
7
+ isComposingEvent,
8
+ isLeftClick,
9
+ isModifierKey
10
+ } from "@zag-js/dom-query";
11
+ import { ariaAttr, dataAttr, query, visuallyHiddenStyle } from "@zag-js/dom-query";
5
12
  import { getPlacementSide, getPlacementStyles } from "@zag-js/popper";
6
13
  import { parts } from "./color-picker.anatomy.mjs";
7
14
  import * as dom from "./color-picker.dom.mjs";
@@ -52,9 +59,7 @@ function connect(service, normalize) {
52
59
  inline: !!prop("inline"),
53
60
  setOpen(nextOpen) {
54
61
  if (prop("inline")) return;
55
- const open2 = state.hasTag("open");
56
- if (open2 === nextOpen) return;
57
- send({ type: nextOpen ? "OPEN" : "CLOSE" });
62
+ send({ type: nextOpen ? "OPEN" : "CLOSE", replaces: "open" });
58
63
  },
59
64
  setValue(value2) {
60
65
  send({ type: "VALUE.SET", value: normalizeColor(value2), src: "set-color" });
@@ -254,6 +259,7 @@ function connect(service, normalize) {
254
259
  "data-invalid": dataAttr(invalid),
255
260
  "data-readonly": dataAttr(readOnly),
256
261
  role: "slider",
262
+ "aria-disabled": ariaAttr(disabled),
257
263
  "aria-valuemin": 0,
258
264
  "aria-valuemax": 100,
259
265
  "aria-valuenow": xValue,
@@ -412,7 +418,7 @@ function connect(service, normalize) {
412
418
  "data-channel": channel,
413
419
  "data-disabled": dataAttr(disabled),
414
420
  "data-orientation": orientation,
415
- "aria-disabled": dataAttr(disabled),
421
+ "aria-disabled": ariaAttr(disabled),
416
422
  "aria-orientation": orientation,
417
423
  "aria-valuemax": channelRange.maxValue,
418
424
  "aria-valuemin": channelRange.minValue,
@@ -4,7 +4,7 @@ import { Service, EventObject, Machine } from '@zag-js/core';
4
4
  import { InteractOutsideHandlers } from '@zag-js/dismissable';
5
5
  import { PositioningOptions } from '@zag-js/popper';
6
6
  export { PositioningOptions } from '@zag-js/popper';
7
- import { RequiredBy, CommonProperties, DirectionProperty, Partial, Orientation, PropTypes } from '@zag-js/types';
7
+ import { RequiredBy, CommonProperties, DirectionProperty, Orientation, PropTypes } from '@zag-js/types';
8
8
 
9
9
  type ExtendedColorChannel = ColorChannel | "hex" | "css";
10
10
  interface EyeDropper {
@@ -32,23 +32,23 @@ interface OpenChangeDetails {
32
32
  interface FormatChangeDetails {
33
33
  format: ColorFormat;
34
34
  }
35
- type ElementIds = Partial<{
36
- root: string;
37
- control: string;
38
- trigger: string;
39
- label: string;
40
- input: string;
41
- hiddenInput: string;
42
- content: string;
43
- area: string;
44
- areaGradient: string;
45
- positioner: string;
46
- formatSelect: string;
47
- areaThumb: string;
48
- channelInput: (id: string) => string;
49
- channelSliderTrack: (id: ColorChannel) => string;
50
- channelSliderThumb: (id: ColorChannel) => string;
51
- }>;
35
+ interface ElementIds {
36
+ root?: string | undefined;
37
+ control?: string | undefined;
38
+ trigger?: string | undefined;
39
+ label?: string | undefined;
40
+ input?: string | undefined;
41
+ hiddenInput?: string | undefined;
42
+ content?: string | undefined;
43
+ area?: string | undefined;
44
+ areaGradient?: string | undefined;
45
+ positioner?: string | undefined;
46
+ formatSelect?: string | undefined;
47
+ areaThumb?: string | undefined;
48
+ channelInput?: ((id: string) => string) | undefined;
49
+ channelSliderTrack?: ((id: ColorChannel) => string) | undefined;
50
+ channelSliderThumb?: ((id: ColorChannel) => string) | undefined;
51
+ }
52
52
  interface ColorPickerProps extends CommonProperties, DirectionProperty, InteractOutsideHandlers {
53
53
  /**
54
54
  * The ids of the elements in the color picker. Useful for composition.
@@ -4,7 +4,7 @@ import { Service, EventObject, Machine } from '@zag-js/core';
4
4
  import { InteractOutsideHandlers } from '@zag-js/dismissable';
5
5
  import { PositioningOptions } from '@zag-js/popper';
6
6
  export { PositioningOptions } from '@zag-js/popper';
7
- import { RequiredBy, CommonProperties, DirectionProperty, Partial, Orientation, PropTypes } from '@zag-js/types';
7
+ import { RequiredBy, CommonProperties, DirectionProperty, Orientation, PropTypes } from '@zag-js/types';
8
8
 
9
9
  type ExtendedColorChannel = ColorChannel | "hex" | "css";
10
10
  interface EyeDropper {
@@ -32,23 +32,23 @@ interface OpenChangeDetails {
32
32
  interface FormatChangeDetails {
33
33
  format: ColorFormat;
34
34
  }
35
- type ElementIds = Partial<{
36
- root: string;
37
- control: string;
38
- trigger: string;
39
- label: string;
40
- input: string;
41
- hiddenInput: string;
42
- content: string;
43
- area: string;
44
- areaGradient: string;
45
- positioner: string;
46
- formatSelect: string;
47
- areaThumb: string;
48
- channelInput: (id: string) => string;
49
- channelSliderTrack: (id: ColorChannel) => string;
50
- channelSliderThumb: (id: ColorChannel) => string;
51
- }>;
35
+ interface ElementIds {
36
+ root?: string | undefined;
37
+ control?: string | undefined;
38
+ trigger?: string | undefined;
39
+ label?: string | undefined;
40
+ input?: string | undefined;
41
+ hiddenInput?: string | undefined;
42
+ content?: string | undefined;
43
+ area?: string | undefined;
44
+ areaGradient?: string | undefined;
45
+ positioner?: string | undefined;
46
+ formatSelect?: string | undefined;
47
+ areaThumb?: string | undefined;
48
+ channelInput?: ((id: string) => string) | undefined;
49
+ channelSliderTrack?: ((id: ColorChannel) => string) | undefined;
50
+ channelSliderThumb?: ((id: ColorChannel) => string) | undefined;
51
+ }
52
52
  interface ColorPickerProps extends CommonProperties, DirectionProperty, InteractOutsideHandlers {
53
53
  /**
54
54
  * The ids of the elements in the color picker. Useful for composition.
@@ -1,5 +1,6 @@
1
+ import * as _zag_js_color_utils from '@zag-js/color-utils';
1
2
  import { Color, ColorChannel } from '@zag-js/color-utils';
2
3
 
3
- declare function getChannelDisplayColor(color: Color, channel: ColorChannel): Color;
4
+ declare function getChannelDisplayColor(color: Color, channel: ColorChannel): _zag_js_color_utils.ColorType;
4
5
 
5
6
  export { getChannelDisplayColor };
@@ -1,5 +1,6 @@
1
+ import * as _zag_js_color_utils from '@zag-js/color-utils';
1
2
  import { Color, ColorChannel } from '@zag-js/color-utils';
2
3
 
3
- declare function getChannelDisplayColor(color: Color, channel: ColorChannel): Color;
4
+ declare function getChannelDisplayColor(color: Color, channel: ColorChannel): _zag_js_color_utils.ColorType;
4
5
 
5
6
  export { getChannelDisplayColor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/color-picker",
3
- "version": "1.43.2",
3
+ "version": "1.44.0",
4
4
  "description": "Core logic for the color-picker widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -30,14 +30,14 @@
30
30
  "url": "https://github.com/chakra-ui/zag/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@zag-js/core": "1.43.2",
34
- "@zag-js/anatomy": "1.43.2",
35
- "@zag-js/dom-query": "1.43.2",
36
- "@zag-js/dismissable": "1.43.2",
37
- "@zag-js/utils": "1.43.2",
38
- "@zag-js/color-utils": "1.43.2",
39
- "@zag-js/popper": "1.43.2",
40
- "@zag-js/types": "1.43.2"
33
+ "@zag-js/core": "1.44.0",
34
+ "@zag-js/anatomy": "1.44.0",
35
+ "@zag-js/dom-query": "1.44.0",
36
+ "@zag-js/dismissable": "1.44.0",
37
+ "@zag-js/utils": "1.44.0",
38
+ "@zag-js/color-utils": "1.44.0",
39
+ "@zag-js/popper": "1.44.0",
40
+ "@zag-js/types": "1.44.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "clean-package": "2.2.0"