@zag-js/color-picker 1.43.3 → 1.45.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,
@@ -593,7 +593,8 @@ var machine = (0, import_core.createMachine)({
593
593
  root: dom.getContentEl(scope),
594
594
  getInitialEl: prop("initialFocusEl")
595
595
  });
596
- element?.focus({ preventScroll: true });
596
+ if (!element) return;
597
+ element.focus({ preventScroll: true });
597
598
  });
598
599
  },
599
600
  setReturnFocus({ scope }) {
@@ -567,7 +567,8 @@ var machine = createMachine({
567
567
  root: dom.getContentEl(scope),
568
568
  getInitialEl: prop("initialFocusEl")
569
569
  });
570
- element?.focus({ preventScroll: true });
570
+ if (!element) return;
571
+ element.focus({ preventScroll: true });
571
572
  });
572
573
  },
573
574
  setReturnFocus({ scope }) {
@@ -102,8 +102,9 @@ interface ColorPickerProps extends CommonProperties, DirectionProperty, Interact
102
102
  positioning?: PositioningOptions | undefined;
103
103
  /**
104
104
  * The initial focus element when the color picker is opened.
105
+ * Return `false` to skip moving focus, or `null` to use the default.
105
106
  */
106
- initialFocusEl?: (() => HTMLElement | null) | undefined;
107
+ initialFocusEl?: (() => HTMLElement | null | false) | undefined;
107
108
  /**
108
109
  * The controlled open state of the color picker
109
110
  */
@@ -102,8 +102,9 @@ interface ColorPickerProps extends CommonProperties, DirectionProperty, Interact
102
102
  positioning?: PositioningOptions | undefined;
103
103
  /**
104
104
  * The initial focus element when the color picker is opened.
105
+ * Return `false` to skip moving focus, or `null` to use the default.
105
106
  */
106
- initialFocusEl?: (() => HTMLElement | null) | undefined;
107
+ initialFocusEl?: (() => HTMLElement | null | false) | undefined;
107
108
  /**
108
109
  * The controlled open state of the color picker
109
110
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/color-picker",
3
- "version": "1.43.3",
3
+ "version": "1.45.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.3",
34
- "@zag-js/anatomy": "1.43.3",
35
- "@zag-js/dom-query": "1.43.3",
36
- "@zag-js/dismissable": "1.43.3",
37
- "@zag-js/utils": "1.43.3",
38
- "@zag-js/color-utils": "1.43.3",
39
- "@zag-js/popper": "1.43.3",
40
- "@zag-js/types": "1.43.3"
33
+ "@zag-js/core": "1.45.0",
34
+ "@zag-js/anatomy": "1.45.0",
35
+ "@zag-js/dom-query": "1.45.0",
36
+ "@zag-js/dismissable": "1.45.0",
37
+ "@zag-js/utils": "1.45.0",
38
+ "@zag-js/color-utils": "1.45.0",
39
+ "@zag-js/popper": "1.45.0",
40
+ "@zag-js/types": "1.45.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "clean-package": "2.2.0"