@zag-js/color-picker 0.80.0 → 0.81.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.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -16
- package/dist/index.mjs +1 -3
- package/package.json +10 -12
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import { Machine, StateMachine } from '@zag-js/core';
|
|
|
9
9
|
import { PositioningOptions } from '@zag-js/popper';
|
|
10
10
|
export { PositioningOptions } from '@zag-js/popper';
|
|
11
11
|
|
|
12
|
-
declare const anatomy: _zag_js_anatomy.Anatomy<"
|
|
12
|
+
declare const anatomy: _zag_js_anatomy.Anatomy<"content" | "label" | "area" | "root" | "control" | "trigger" | "positioner" | "areaThumb" | "valueText" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
|
|
13
13
|
|
|
14
14
|
type ExtendedColorChannel = ColorChannel | "hex" | "css";
|
|
15
15
|
interface EyeDropper {
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { Machine, StateMachine } from '@zag-js/core';
|
|
|
9
9
|
import { PositioningOptions } from '@zag-js/popper';
|
|
10
10
|
export { PositioningOptions } from '@zag-js/popper';
|
|
11
11
|
|
|
12
|
-
declare const anatomy: _zag_js_anatomy.Anatomy<"
|
|
12
|
+
declare const anatomy: _zag_js_anatomy.Anatomy<"content" | "label" | "area" | "root" | "control" | "trigger" | "positioner" | "areaThumb" | "valueText" | "areaBackground" | "channelSlider" | "channelSliderLabel" | "channelSliderTrack" | "channelSliderThumb" | "channelSliderValueText" | "channelInput" | "transparencyGrid" | "swatchGroup" | "swatchTrigger" | "swatchIndicator" | "swatch" | "eyeDropperTrigger" | "formatTrigger" | "formatSelect">;
|
|
13
13
|
|
|
14
14
|
type ExtendedColorChannel = ColorChannel | "hex" | "css";
|
|
15
15
|
interface EyeDropper {
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var anatomy$1 = require('@zag-js/anatomy');
|
|
4
4
|
var colorUtils = require('@zag-js/color-utils');
|
|
5
|
-
var domEvent = require('@zag-js/dom-event');
|
|
6
5
|
var domQuery = require('@zag-js/dom-query');
|
|
7
6
|
var popper = require('@zag-js/popper');
|
|
8
7
|
var core = require('@zag-js/core');
|
|
9
8
|
var dismissable = require('@zag-js/dismissable');
|
|
10
9
|
var formUtils = require('@zag-js/form-utils');
|
|
11
|
-
var textSelection = require('@zag-js/text-selection');
|
|
12
10
|
var utils = require('@zag-js/utils');
|
|
13
11
|
|
|
14
12
|
// src/color-picker.anatomy.ts
|
|
@@ -69,7 +67,7 @@ var dom = domQuery.createScope({
|
|
|
69
67
|
getAreaValueFromPoint(ctx, point) {
|
|
70
68
|
const areaEl = dom.getAreaEl(ctx);
|
|
71
69
|
if (!areaEl) return;
|
|
72
|
-
const { percent } =
|
|
70
|
+
const { percent } = domQuery.getRelativePoint(point, areaEl);
|
|
73
71
|
return percent;
|
|
74
72
|
},
|
|
75
73
|
getControlEl: (ctx) => dom.getById(ctx, dom.getControlId(ctx)),
|
|
@@ -81,7 +79,7 @@ var dom = domQuery.createScope({
|
|
|
81
79
|
getChannelSliderValueFromPoint(ctx, point, channel) {
|
|
82
80
|
const trackEl = dom.getChannelSliderTrackEl(ctx, channel);
|
|
83
81
|
if (!trackEl) return;
|
|
84
|
-
const { percent } =
|
|
82
|
+
const { percent } = domQuery.getRelativePoint(point, trackEl);
|
|
85
83
|
return percent;
|
|
86
84
|
},
|
|
87
85
|
getChannelInputEls: (ctx) => {
|
|
@@ -381,9 +379,9 @@ function connect(state, send, normalize) {
|
|
|
381
379
|
"data-readonly": domQuery.dataAttr(state.context.readOnly),
|
|
382
380
|
onPointerDown(event) {
|
|
383
381
|
if (!interactive) return;
|
|
384
|
-
if (!
|
|
385
|
-
if (
|
|
386
|
-
const point =
|
|
382
|
+
if (!domQuery.isLeftClick(event)) return;
|
|
383
|
+
if (domQuery.isModifierKey(event)) return;
|
|
384
|
+
const point = domQuery.getEventPoint(event);
|
|
387
385
|
const channel = { xChannel, yChannel };
|
|
388
386
|
send({ type: "AREA.POINTER_DOWN", point, channel, id: "area" });
|
|
389
387
|
event.preventDefault();
|
|
@@ -457,7 +455,7 @@ function connect(state, send, normalize) {
|
|
|
457
455
|
onKeyDown(event) {
|
|
458
456
|
if (event.defaultPrevented) return;
|
|
459
457
|
if (!interactive) return;
|
|
460
|
-
const step =
|
|
458
|
+
const step = domQuery.getEventStep(event);
|
|
461
459
|
const keyMap = {
|
|
462
460
|
ArrowUp() {
|
|
463
461
|
send({ type: "AREA.ARROW_UP", channel, step });
|
|
@@ -481,7 +479,7 @@ function connect(state, send, normalize) {
|
|
|
481
479
|
event2.stopPropagation();
|
|
482
480
|
}
|
|
483
481
|
};
|
|
484
|
-
const exec = keyMap[
|
|
482
|
+
const exec = keyMap[domQuery.getEventKey(event, state.context)];
|
|
485
483
|
if (exec) {
|
|
486
484
|
exec(event);
|
|
487
485
|
event.preventDefault();
|
|
@@ -516,9 +514,9 @@ function connect(state, send, normalize) {
|
|
|
516
514
|
role: "presentation",
|
|
517
515
|
onPointerDown(event) {
|
|
518
516
|
if (!interactive) return;
|
|
519
|
-
if (!
|
|
520
|
-
if (
|
|
521
|
-
const point =
|
|
517
|
+
if (!domQuery.isLeftClick(event)) return;
|
|
518
|
+
if (domQuery.isModifierKey(event)) return;
|
|
519
|
+
const point = domQuery.getEventPoint(event);
|
|
522
520
|
send({ type: "CHANNEL_SLIDER.POINTER_DOWN", channel, format, point, id: channel, orientation });
|
|
523
521
|
event.preventDefault();
|
|
524
522
|
},
|
|
@@ -607,7 +605,7 @@ function connect(state, send, normalize) {
|
|
|
607
605
|
onKeyDown(event) {
|
|
608
606
|
if (event.defaultPrevented) return;
|
|
609
607
|
if (!interactive) return;
|
|
610
|
-
const step =
|
|
608
|
+
const step = domQuery.getEventStep(event) * channelRange.step;
|
|
611
609
|
const keyMap = {
|
|
612
610
|
ArrowUp() {
|
|
613
611
|
send({ type: "CHANNEL_SLIDER.ARROW_UP", channel, step });
|
|
@@ -637,7 +635,7 @@ function connect(state, send, normalize) {
|
|
|
637
635
|
event2.stopPropagation();
|
|
638
636
|
}
|
|
639
637
|
};
|
|
640
|
-
const exec = keyMap[
|
|
638
|
+
const exec = keyMap[domQuery.getEventKey(event, state.context)];
|
|
641
639
|
if (exec) {
|
|
642
640
|
exec(event);
|
|
643
641
|
event.preventDefault();
|
|
@@ -1184,7 +1182,7 @@ function machine(userContext) {
|
|
|
1184
1182
|
});
|
|
1185
1183
|
},
|
|
1186
1184
|
trackPointerMove(ctx2, evt, { send }) {
|
|
1187
|
-
return
|
|
1185
|
+
return domQuery.trackPointerMove(dom.getDoc(ctx2), {
|
|
1188
1186
|
onPointerMove({ point }) {
|
|
1189
1187
|
const type = ctx2.activeId === "area" ? "AREA.POINTER_MOVE" : "CHANNEL_SLIDER.POINTER_MOVE";
|
|
1190
1188
|
send({ type, point, format: evt.format });
|
|
@@ -1196,7 +1194,7 @@ function machine(userContext) {
|
|
|
1196
1194
|
});
|
|
1197
1195
|
},
|
|
1198
1196
|
disableTextSelection(ctx2) {
|
|
1199
|
-
return
|
|
1197
|
+
return domQuery.disableTextSelection({ doc: dom.getDoc(ctx2), target: dom.getContentEl(ctx2) });
|
|
1200
1198
|
}
|
|
1201
1199
|
},
|
|
1202
1200
|
actions: {
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { createAnatomy } from '@zag-js/anatomy';
|
|
2
2
|
import { normalizeColor, getColorAreaGradient, parseColor } from '@zag-js/color-utils';
|
|
3
|
-
import { getRelativePoint, isLeftClick, isModifierKey, getEventPoint, getEventStep, getEventKey, trackPointerMove } from '@zag-js/dom-
|
|
4
|
-
import { createScope, queryAll, dataAttr, query, visuallyHiddenStyle, raf, getInitialFocus } from '@zag-js/dom-query';
|
|
3
|
+
import { createScope, queryAll, getRelativePoint, dataAttr, query, isLeftClick, isModifierKey, getEventPoint, getEventStep, getEventKey, visuallyHiddenStyle, trackPointerMove, disableTextSelection, raf, getInitialFocus } from '@zag-js/dom-query';
|
|
5
4
|
import { getPlacementStyles, getPlacement } from '@zag-js/popper';
|
|
6
5
|
import { createMachine, guards } from '@zag-js/core';
|
|
7
6
|
import { trackDismissableElement } from '@zag-js/dismissable';
|
|
8
7
|
import { trackFormControl, dispatchInputValueEvent } from '@zag-js/form-utils';
|
|
9
|
-
import { disableTextSelection } from '@zag-js/text-selection';
|
|
10
8
|
import { compact, tryCatch } from '@zag-js/utils';
|
|
11
9
|
|
|
12
10
|
// src/color-picker.anatomy.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-picker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"description": "Core logic for the color-picker widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -27,17 +27,15 @@
|
|
|
27
27
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@zag-js/core": "0.
|
|
31
|
-
"@zag-js/anatomy": "0.
|
|
32
|
-
"@zag-js/dom-query": "0.
|
|
33
|
-
"@zag-js/dismissable": "0.
|
|
34
|
-
"@zag-js/
|
|
35
|
-
"@zag-js/utils": "0.
|
|
36
|
-
"@zag-js/
|
|
37
|
-
"@zag-js/
|
|
38
|
-
"@zag-js/
|
|
39
|
-
"@zag-js/text-selection": "0.80.0",
|
|
40
|
-
"@zag-js/types": "0.80.0"
|
|
30
|
+
"@zag-js/core": "0.81.0",
|
|
31
|
+
"@zag-js/anatomy": "0.81.0",
|
|
32
|
+
"@zag-js/dom-query": "0.81.0",
|
|
33
|
+
"@zag-js/dismissable": "0.81.0",
|
|
34
|
+
"@zag-js/utils": "0.81.0",
|
|
35
|
+
"@zag-js/form-utils": "0.81.0",
|
|
36
|
+
"@zag-js/color-utils": "0.81.0",
|
|
37
|
+
"@zag-js/popper": "0.81.0",
|
|
38
|
+
"@zag-js/types": "0.81.0"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
43
41
|
"clean-package": "2.2.0"
|