@zag-js/color-picker 1.40.0 → 1.41.1
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.
|
@@ -64,6 +64,7 @@ function connect(service, normalize) {
|
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
const currentPlacement = context.get("currentPlacement");
|
|
67
|
+
const currentPlacementSide = currentPlacement ? (0, import_popper.getPlacementSide)(currentPlacement) : void 0;
|
|
67
68
|
const popperStyles = (0, import_popper.getPlacementStyles)({
|
|
68
69
|
...prop("positioning"),
|
|
69
70
|
placement: currentPlacement
|
|
@@ -169,6 +170,7 @@ function connect(service, normalize) {
|
|
|
169
170
|
"data-readonly": (0, import_dom_query2.dataAttr)(readOnly),
|
|
170
171
|
"data-invalid": (0, import_dom_query2.dataAttr)(invalid),
|
|
171
172
|
"data-placement": currentPlacement,
|
|
173
|
+
"data-side": currentPlacementSide,
|
|
172
174
|
"aria-expanded": open,
|
|
173
175
|
"data-state": open ? "open" : "closed",
|
|
174
176
|
"data-focus": (0, import_dom_query2.dataAttr)(focused),
|
|
@@ -202,6 +204,7 @@ function connect(service, normalize) {
|
|
|
202
204
|
role: prop("inline") ? void 0 : "dialog",
|
|
203
205
|
tabIndex: -1,
|
|
204
206
|
"data-placement": currentPlacement,
|
|
207
|
+
"data-side": currentPlacementSide,
|
|
205
208
|
"data-state": open ? "open" : "closed",
|
|
206
209
|
hidden: !open
|
|
207
210
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getColorAreaGradient, normalizeColor } from "@zag-js/color-utils";
|
|
3
3
|
import { getEventKey, getEventPoint, getEventStep, isLeftClick, isModifierKey } from "@zag-js/dom-query";
|
|
4
4
|
import { dataAttr, query, visuallyHiddenStyle } from "@zag-js/dom-query";
|
|
5
|
-
import { getPlacementStyles } from "@zag-js/popper";
|
|
5
|
+
import { getPlacementSide, getPlacementStyles } from "@zag-js/popper";
|
|
6
6
|
import { parts } from "./color-picker.anatomy.mjs";
|
|
7
7
|
import * as dom from "./color-picker.dom.mjs";
|
|
8
8
|
import { getChannelDisplayColor } from "./utils/get-channel-display-color.mjs";
|
|
@@ -30,6 +30,7 @@ function connect(service, normalize) {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
const currentPlacement = context.get("currentPlacement");
|
|
33
|
+
const currentPlacementSide = currentPlacement ? getPlacementSide(currentPlacement) : void 0;
|
|
33
34
|
const popperStyles = getPlacementStyles({
|
|
34
35
|
...prop("positioning"),
|
|
35
36
|
placement: currentPlacement
|
|
@@ -135,6 +136,7 @@ function connect(service, normalize) {
|
|
|
135
136
|
"data-readonly": dataAttr(readOnly),
|
|
136
137
|
"data-invalid": dataAttr(invalid),
|
|
137
138
|
"data-placement": currentPlacement,
|
|
139
|
+
"data-side": currentPlacementSide,
|
|
138
140
|
"aria-expanded": open,
|
|
139
141
|
"data-state": open ? "open" : "closed",
|
|
140
142
|
"data-focus": dataAttr(focused),
|
|
@@ -168,6 +170,7 @@ function connect(service, normalize) {
|
|
|
168
170
|
role: prop("inline") ? void 0 : "dialog",
|
|
169
171
|
tabIndex: -1,
|
|
170
172
|
"data-placement": currentPlacement,
|
|
173
|
+
"data-side": currentPlacementSide,
|
|
171
174
|
"data-state": open ? "open" : "closed",
|
|
172
175
|
hidden: !open
|
|
173
176
|
});
|
|
@@ -441,7 +441,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
441
441
|
}
|
|
442
442
|
},
|
|
443
443
|
actions: {
|
|
444
|
-
openEyeDropper({ scope, context }) {
|
|
444
|
+
openEyeDropper({ scope, context, prop }) {
|
|
445
445
|
const win = scope.getWin();
|
|
446
446
|
const isSupported = "EyeDropper" in win;
|
|
447
447
|
if (!isSupported) return;
|
|
@@ -450,6 +450,12 @@ var machine = (0, import_core.createMachine)({
|
|
|
450
450
|
const format = context.get("value").getFormat();
|
|
451
451
|
const color = (0, import_color_utils.parseColor)(sRGBHex).toFormat(format);
|
|
452
452
|
context.set("value", color);
|
|
453
|
+
return color;
|
|
454
|
+
}).then((value) => {
|
|
455
|
+
prop("onValueChangeEnd")?.({
|
|
456
|
+
value,
|
|
457
|
+
valueAsString: value.toString(context.get("format"))
|
|
458
|
+
});
|
|
453
459
|
}).catch(() => void 0);
|
|
454
460
|
},
|
|
455
461
|
setActiveChannel({ context, event }) {
|
|
@@ -415,7 +415,7 @@ var machine = createMachine({
|
|
|
415
415
|
}
|
|
416
416
|
},
|
|
417
417
|
actions: {
|
|
418
|
-
openEyeDropper({ scope, context }) {
|
|
418
|
+
openEyeDropper({ scope, context, prop }) {
|
|
419
419
|
const win = scope.getWin();
|
|
420
420
|
const isSupported = "EyeDropper" in win;
|
|
421
421
|
if (!isSupported) return;
|
|
@@ -424,6 +424,12 @@ var machine = createMachine({
|
|
|
424
424
|
const format = context.get("value").getFormat();
|
|
425
425
|
const color = parseColor(sRGBHex).toFormat(format);
|
|
426
426
|
context.set("value", color);
|
|
427
|
+
return color;
|
|
428
|
+
}).then((value) => {
|
|
429
|
+
prop("onValueChangeEnd")?.({
|
|
430
|
+
value,
|
|
431
|
+
valueAsString: value.toString(context.get("format"))
|
|
432
|
+
});
|
|
427
433
|
}).catch(() => void 0);
|
|
428
434
|
},
|
|
429
435
|
setActiveChannel({ context, event }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.1",
|
|
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.
|
|
31
|
-
"@zag-js/anatomy": "1.
|
|
32
|
-
"@zag-js/dom-query": "1.
|
|
33
|
-
"@zag-js/dismissable": "1.
|
|
34
|
-
"@zag-js/utils": "1.
|
|
35
|
-
"@zag-js/color-utils": "1.
|
|
36
|
-
"@zag-js/
|
|
37
|
-
"@zag-js/
|
|
30
|
+
"@zag-js/core": "1.41.1",
|
|
31
|
+
"@zag-js/anatomy": "1.41.1",
|
|
32
|
+
"@zag-js/dom-query": "1.41.1",
|
|
33
|
+
"@zag-js/dismissable": "1.41.1",
|
|
34
|
+
"@zag-js/utils": "1.41.1",
|
|
35
|
+
"@zag-js/color-utils": "1.41.1",
|
|
36
|
+
"@zag-js/types": "1.41.1",
|
|
37
|
+
"@zag-js/popper": "1.41.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|