@zag-js/color-picker 0.10.2 → 0.10.4
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/color-picker.anatomy.d.ts +3 -6
- package/dist/color-picker.anatomy.js +10 -33
- package/dist/color-picker.anatomy.mjs +19 -8
- package/dist/color-picker.connect.d.ts +4 -8
- package/dist/color-picker.connect.js +56 -436
- package/dist/color-picker.connect.mjs +368 -14
- package/dist/color-picker.dom.d.ts +27 -32
- package/dist/color-picker.dom.js +12 -34
- package/dist/color-picker.dom.mjs +33 -6
- package/dist/color-picker.machine.d.ts +3 -8
- package/dist/color-picker.machine.js +46 -163
- package/dist/color-picker.machine.mjs +335 -8
- package/dist/color-picker.types.d.ts +14 -16
- package/dist/index.d.ts +4 -8
- package/dist/index.js +8 -1085
- package/dist/index.mjs +3 -21
- package/dist/utils/generate-format-background.d.ts +9 -11
- package/dist/utils/generate-format-background.js +22 -53
- package/dist/utils/generate-format-background.mjs +120 -21
- package/dist/utils/get-channel-details.d.ts +3 -7
- package/dist/utils/get-channel-details.js +15 -37
- package/dist/utils/get-channel-details.mjs +53 -6
- package/dist/utils/get-channel-display-color.d.ts +3 -5
- package/dist/utils/get-channel-display-color.js +8 -30
- package/dist/utils/get-channel-display-color.mjs +22 -6
- package/dist/utils/get-channel-input-value.d.ts +5 -10
- package/dist/utils/get-channel-input-value.js +6 -30
- package/dist/utils/get-channel-input-value.mjs +21 -8
- package/dist/utils/get-color-area-gradient.d.ts +6 -10
- package/dist/utils/get-color-area-gradient.js +14 -158
- package/dist/utils/get-color-area-gradient.mjs +61 -7
- package/dist/utils/get-slider-background.d.ts +2 -8
- package/dist/utils/get-slider-background.js +6 -29
- package/dist/utils/get-slider-background.mjs +38 -5
- package/package.json +11 -16
- package/src/color-picker.connect.ts +1 -1
- package/src/color-picker.dom.ts +1 -1
- package/src/color-picker.types.ts +3 -1
- package/src/index.ts +2 -0
- package/src/utils/get-channel-details.ts +2 -2
- package/src/utils/get-channel-display-color.ts +1 -1
- package/src/utils/get-color-area-gradient.ts +1 -1
- package/dist/chunk-2ERX54SV.mjs +0 -25
- package/dist/chunk-3XH465XT.mjs +0 -42
- package/dist/chunk-5QSFKCT5.mjs +0 -393
- package/dist/chunk-75JXJMB5.mjs +0 -22
- package/dist/chunk-JNBNPPMF.mjs +0 -24
- package/dist/chunk-KLLIOTK6.mjs +0 -55
- package/dist/chunk-KO4TBUXB.mjs +0 -74
- package/dist/chunk-ML3WX6YS.mjs +0 -345
- package/dist/chunk-OY3B7NXA.mjs +0 -132
- package/dist/chunk-SPSDVZCT.mjs +0 -35
- package/dist/color-picker.types.js +0 -18
- package/dist/color-picker.types.mjs +0 -0
package/dist/chunk-5QSFKCT5.mjs
DELETED
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getChannelDisplayColor
|
|
3
|
-
} from "./chunk-JNBNPPMF.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getColorAreaGradient
|
|
6
|
-
} from "./chunk-KO4TBUXB.mjs";
|
|
7
|
-
import {
|
|
8
|
-
getSliderBgImage
|
|
9
|
-
} from "./chunk-3XH465XT.mjs";
|
|
10
|
-
import {
|
|
11
|
-
parts
|
|
12
|
-
} from "./chunk-75JXJMB5.mjs";
|
|
13
|
-
import {
|
|
14
|
-
getChannelInputRange,
|
|
15
|
-
getChannelInputValue
|
|
16
|
-
} from "./chunk-2ERX54SV.mjs";
|
|
17
|
-
import {
|
|
18
|
-
dom
|
|
19
|
-
} from "./chunk-SPSDVZCT.mjs";
|
|
20
|
-
import {
|
|
21
|
-
getChannelDetails
|
|
22
|
-
} from "./chunk-KLLIOTK6.mjs";
|
|
23
|
-
|
|
24
|
-
// src/color-picker.connect.ts
|
|
25
|
-
import { normalizeColor } from "@zag-js/color-utils";
|
|
26
|
-
import {
|
|
27
|
-
getEventKey,
|
|
28
|
-
getEventPoint,
|
|
29
|
-
getEventStep,
|
|
30
|
-
getNativeEvent,
|
|
31
|
-
isLeftClick,
|
|
32
|
-
isModifiedEvent
|
|
33
|
-
} from "@zag-js/dom-event";
|
|
34
|
-
import { dataAttr } from "@zag-js/dom-query";
|
|
35
|
-
function connect(state, send, normalize) {
|
|
36
|
-
const valueAsColor = state.context.valueAsColor;
|
|
37
|
-
const isDisabled = state.context.disabled;
|
|
38
|
-
const isInteractive = state.context.isInteractive;
|
|
39
|
-
const isDragging = state.matches("dragging");
|
|
40
|
-
const channels = valueAsColor.getColorChannels();
|
|
41
|
-
return {
|
|
42
|
-
/**
|
|
43
|
-
* Whether the color picker is being dragged
|
|
44
|
-
*/
|
|
45
|
-
isDragging,
|
|
46
|
-
/**
|
|
47
|
-
* The current color value (as a string)
|
|
48
|
-
*/
|
|
49
|
-
value: state.context.value,
|
|
50
|
-
/**
|
|
51
|
-
* The current color value (as a Color object)
|
|
52
|
-
*/
|
|
53
|
-
valueAsColor,
|
|
54
|
-
/**
|
|
55
|
-
* The current color channels of the color
|
|
56
|
-
*/
|
|
57
|
-
channels,
|
|
58
|
-
/**
|
|
59
|
-
* Function to set the color value
|
|
60
|
-
*/
|
|
61
|
-
setColor(value) {
|
|
62
|
-
send({ type: "VALUE.SET", value: normalizeColor(value), src: "set-color" });
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* Function to set the color value of a specific channel
|
|
66
|
-
*/
|
|
67
|
-
setChannelValue(channel, value) {
|
|
68
|
-
const color = valueAsColor.withChannelValue(channel, value);
|
|
69
|
-
send({ type: "VALUE.SET", value: color, src: "set-channel" });
|
|
70
|
-
},
|
|
71
|
-
/**
|
|
72
|
-
* Function to set the color format
|
|
73
|
-
*/
|
|
74
|
-
setFormat(format) {
|
|
75
|
-
const value = valueAsColor.toFormat(format);
|
|
76
|
-
send({ type: "VALUE.SET", value, src: "set-format" });
|
|
77
|
-
},
|
|
78
|
-
contentProps: normalize.element({
|
|
79
|
-
...parts.content.attrs,
|
|
80
|
-
id: dom.getContentId(state.context)
|
|
81
|
-
}),
|
|
82
|
-
getAreaProps(props) {
|
|
83
|
-
const { xChannel, yChannel } = props;
|
|
84
|
-
const { areaStyles } = getColorAreaGradient(state.context, xChannel, yChannel);
|
|
85
|
-
return normalize.element({
|
|
86
|
-
...parts.area.attrs,
|
|
87
|
-
id: dom.getAreaId(state.context),
|
|
88
|
-
role: "group",
|
|
89
|
-
onPointerDown(event) {
|
|
90
|
-
if (!isInteractive)
|
|
91
|
-
return;
|
|
92
|
-
const evt = getNativeEvent(event);
|
|
93
|
-
if (!isLeftClick(evt) || isModifiedEvent(evt))
|
|
94
|
-
return;
|
|
95
|
-
const point = getEventPoint(evt);
|
|
96
|
-
const channel = { xChannel, yChannel };
|
|
97
|
-
send({ type: "AREA.POINTER_DOWN", point, channel, id: "area" });
|
|
98
|
-
},
|
|
99
|
-
style: {
|
|
100
|
-
position: "relative",
|
|
101
|
-
touchAction: "none",
|
|
102
|
-
forcedColorAdjust: "none",
|
|
103
|
-
...areaStyles
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
getAreaGradientProps(props) {
|
|
108
|
-
const { xChannel, yChannel } = props;
|
|
109
|
-
const { areaGradientStyles } = getColorAreaGradient(state.context, xChannel, yChannel);
|
|
110
|
-
return normalize.element({
|
|
111
|
-
...parts.areaGradient.attrs,
|
|
112
|
-
id: dom.getAreaGradientId(state.context),
|
|
113
|
-
style: {
|
|
114
|
-
position: "relative",
|
|
115
|
-
touchAction: "none",
|
|
116
|
-
forcedColorAdjust: "none",
|
|
117
|
-
...areaGradientStyles
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
getAreaThumbProps(props) {
|
|
122
|
-
const { xChannel, yChannel } = props;
|
|
123
|
-
const { getThumbPosition } = getChannelDetails(valueAsColor, xChannel, yChannel);
|
|
124
|
-
const { x, y } = getThumbPosition();
|
|
125
|
-
const channel = { xChannel, yChannel };
|
|
126
|
-
return normalize.element({
|
|
127
|
-
...parts.areaThumb.attrs,
|
|
128
|
-
id: dom.getAreaThumbId(state.context),
|
|
129
|
-
tabIndex: isDisabled ? void 0 : 0,
|
|
130
|
-
"data-disabled": dataAttr(isDisabled),
|
|
131
|
-
role: "presentation",
|
|
132
|
-
style: {
|
|
133
|
-
position: "absolute",
|
|
134
|
-
left: `${x * 100}%`,
|
|
135
|
-
top: `${y * 100}%`,
|
|
136
|
-
transform: "translate(-50%, -50%)",
|
|
137
|
-
touchAction: "none",
|
|
138
|
-
forcedColorAdjust: "none",
|
|
139
|
-
background: valueAsColor.withChannelValue("alpha", 1).toString("css")
|
|
140
|
-
},
|
|
141
|
-
onBlur() {
|
|
142
|
-
send("AREA.BLUR");
|
|
143
|
-
},
|
|
144
|
-
onKeyDown(event) {
|
|
145
|
-
if (!isInteractive)
|
|
146
|
-
return;
|
|
147
|
-
const step = getEventStep(event);
|
|
148
|
-
const keyMap = {
|
|
149
|
-
ArrowUp() {
|
|
150
|
-
send({ type: "AREA.ARROW_UP", channel, step });
|
|
151
|
-
},
|
|
152
|
-
ArrowDown() {
|
|
153
|
-
send({ type: "AREA.ARROW_DOWN", channel, step });
|
|
154
|
-
},
|
|
155
|
-
ArrowLeft() {
|
|
156
|
-
send({ type: "AREA.ARROW_LEFT", channel, step });
|
|
157
|
-
},
|
|
158
|
-
ArrowRight() {
|
|
159
|
-
send({ type: "AREA.ARROW_RIGHT", channel, step });
|
|
160
|
-
},
|
|
161
|
-
PageUp() {
|
|
162
|
-
send({ type: "AREA.PAGE_UP", channel, step });
|
|
163
|
-
},
|
|
164
|
-
PageDown() {
|
|
165
|
-
send({ type: "AREA.PAGE_DOWN", channel, step });
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const exec = keyMap[getEventKey(event, state.context)];
|
|
169
|
-
if (exec) {
|
|
170
|
-
exec(event);
|
|
171
|
-
event.preventDefault();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
},
|
|
176
|
-
getChannelSliderTrackProps(props) {
|
|
177
|
-
const { orientation = "horizontal", channel } = props;
|
|
178
|
-
return normalize.element({
|
|
179
|
-
...parts.channelSliderTrack.attrs,
|
|
180
|
-
id: dom.getChannelSliderTrackId(state.context, channel),
|
|
181
|
-
role: "group",
|
|
182
|
-
"data-channel": channel,
|
|
183
|
-
"data-orientation": orientation,
|
|
184
|
-
onPointerDown(event) {
|
|
185
|
-
if (!isInteractive)
|
|
186
|
-
return;
|
|
187
|
-
const evt = getNativeEvent(event);
|
|
188
|
-
if (!isLeftClick(evt) || isModifiedEvent(evt))
|
|
189
|
-
return;
|
|
190
|
-
const point = getEventPoint(evt);
|
|
191
|
-
send({ type: "CHANNEL_SLIDER.POINTER_DOWN", channel, point, id: channel, orientation });
|
|
192
|
-
},
|
|
193
|
-
style: {
|
|
194
|
-
position: "relative",
|
|
195
|
-
touchAction: "none",
|
|
196
|
-
forcedColorAdjust: "none",
|
|
197
|
-
backgroundImage: getSliderBgImage(state.context, { orientation, channel })
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
},
|
|
201
|
-
getChannelSliderBackgroundProps(props) {
|
|
202
|
-
const { orientation = "horizontal", channel } = props;
|
|
203
|
-
return normalize.element({
|
|
204
|
-
...parts.channelSliderTrackBg.attrs,
|
|
205
|
-
"data-orientation": orientation,
|
|
206
|
-
"data-channel": channel,
|
|
207
|
-
style: {
|
|
208
|
-
position: "absolute",
|
|
209
|
-
backgroundColor: "#fff",
|
|
210
|
-
backgroundImage: [
|
|
211
|
-
"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)",
|
|
212
|
-
"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)",
|
|
213
|
-
"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)",
|
|
214
|
-
"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)"
|
|
215
|
-
].join(","),
|
|
216
|
-
backgroundSize: "16px 16px",
|
|
217
|
-
backgroundPosition: "-2px -2px,-2px 6px,6px -10px,-10px -2px",
|
|
218
|
-
inset: 0,
|
|
219
|
-
zIndex: -1
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
},
|
|
223
|
-
getChannelSliderThumbProps(props) {
|
|
224
|
-
const { orientation = "horizontal", channel } = props;
|
|
225
|
-
const { minValue, maxValue, step: stepValue } = valueAsColor.getChannelRange(channel);
|
|
226
|
-
const channelValue = valueAsColor.getChannelValue(channel);
|
|
227
|
-
const offset = (channelValue - minValue) / (maxValue - minValue);
|
|
228
|
-
const placementStyles = orientation === "horizontal" ? { left: `${offset * 100}%`, top: "50%" } : { top: `${offset * 100}%`, left: "50%" };
|
|
229
|
-
return normalize.element({
|
|
230
|
-
...parts.channelSliderThumb.attrs,
|
|
231
|
-
id: dom.getChannelSliderThumbId(state.context, channel),
|
|
232
|
-
role: "slider",
|
|
233
|
-
"aria-label": channel,
|
|
234
|
-
tabIndex: isDisabled ? void 0 : 0,
|
|
235
|
-
"data-channel": channel,
|
|
236
|
-
"data-disabled": dataAttr(isDisabled),
|
|
237
|
-
"data-orientation": orientation,
|
|
238
|
-
"aria-disabled": dataAttr(isDisabled),
|
|
239
|
-
"aria-orientation": orientation,
|
|
240
|
-
"aria-valuemax": maxValue,
|
|
241
|
-
"aria-valuemin": minValue,
|
|
242
|
-
"aria-valuenow": channelValue,
|
|
243
|
-
style: {
|
|
244
|
-
forcedColorAdjust: "none",
|
|
245
|
-
position: "absolute",
|
|
246
|
-
background: getChannelDisplayColor(valueAsColor, channel).toString("css"),
|
|
247
|
-
...placementStyles
|
|
248
|
-
},
|
|
249
|
-
onFocus() {
|
|
250
|
-
if (!isInteractive)
|
|
251
|
-
return;
|
|
252
|
-
send({ type: "CHANNEL_SLIDER.FOCUS", channel });
|
|
253
|
-
},
|
|
254
|
-
onBlur() {
|
|
255
|
-
if (!isInteractive)
|
|
256
|
-
return;
|
|
257
|
-
send({ type: "CHANNEL_SLIDER.BLUR", channel });
|
|
258
|
-
},
|
|
259
|
-
onKeyDown(event) {
|
|
260
|
-
if (!isInteractive)
|
|
261
|
-
return;
|
|
262
|
-
const step = getEventStep(event) * stepValue;
|
|
263
|
-
const keyMap = {
|
|
264
|
-
ArrowUp() {
|
|
265
|
-
send({ type: "CHANNEL_SLIDER.ARROW_UP", channel, step });
|
|
266
|
-
},
|
|
267
|
-
ArrowDown() {
|
|
268
|
-
send({ type: "CHANNEL_SLIDER.ARROW_DOWN", channel, step });
|
|
269
|
-
},
|
|
270
|
-
ArrowLeft() {
|
|
271
|
-
send({ type: "CHANNEL_SLIDER.ARROW_LEFT", channel, step });
|
|
272
|
-
},
|
|
273
|
-
ArrowRight() {
|
|
274
|
-
send({ type: "CHANNEL_SLIDER.ARROW_RIGHT", channel, step });
|
|
275
|
-
},
|
|
276
|
-
PageUp() {
|
|
277
|
-
send({ type: "CHANNEL_SLIDER.PAGE_UP", channel });
|
|
278
|
-
},
|
|
279
|
-
PageDown() {
|
|
280
|
-
send({ type: "CHANNEL_SLIDER.PAGE_DOWN", channel });
|
|
281
|
-
},
|
|
282
|
-
Home() {
|
|
283
|
-
send({ type: "CHANNEL_SLIDER.HOME", channel });
|
|
284
|
-
},
|
|
285
|
-
End() {
|
|
286
|
-
send({ type: "CHANNEL_SLIDER.END", channel });
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
const exec = keyMap[getEventKey(event, state.context)];
|
|
290
|
-
if (exec) {
|
|
291
|
-
exec(event);
|
|
292
|
-
event.preventDefault();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
},
|
|
297
|
-
getChannelInputProps(props) {
|
|
298
|
-
const { channel } = props;
|
|
299
|
-
const isTextField = channel === "hex" || channel === "css";
|
|
300
|
-
const range = getChannelInputRange(valueAsColor, channel);
|
|
301
|
-
return normalize.input({
|
|
302
|
-
...parts.channelInput.attrs,
|
|
303
|
-
type: isTextField ? "text" : "number",
|
|
304
|
-
"data-channel": channel,
|
|
305
|
-
"aria-label": channel,
|
|
306
|
-
disabled: isDisabled,
|
|
307
|
-
"data-disabled": dataAttr(isDisabled),
|
|
308
|
-
readOnly: state.context.readOnly,
|
|
309
|
-
id: dom.getChannelInputId(state.context, channel),
|
|
310
|
-
defaultValue: getChannelInputValue(valueAsColor, channel),
|
|
311
|
-
min: range?.minValue,
|
|
312
|
-
max: range?.maxValue,
|
|
313
|
-
step: range?.step,
|
|
314
|
-
onFocus() {
|
|
315
|
-
send({ type: "CHANNEL_INPUT.FOCUS", channel });
|
|
316
|
-
},
|
|
317
|
-
onChange(event) {
|
|
318
|
-
if (isTextField)
|
|
319
|
-
return;
|
|
320
|
-
const value = event.currentTarget.value;
|
|
321
|
-
send({ type: "CHANNEL_INPUT.CHANGE", channel, value, isTextField });
|
|
322
|
-
},
|
|
323
|
-
onBlur(event) {
|
|
324
|
-
const value = event.currentTarget.value;
|
|
325
|
-
send({ type: "CHANNEL_INPUT.BLUR", channel, value, isTextField });
|
|
326
|
-
},
|
|
327
|
-
onKeyDown(event) {
|
|
328
|
-
if (!isTextField)
|
|
329
|
-
return;
|
|
330
|
-
if (event.key === "Enter") {
|
|
331
|
-
const value = event.currentTarget.value;
|
|
332
|
-
send({ type: "CHANNEL_INPUT.CHANGE", channel, value, isTextField });
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
style: {
|
|
336
|
-
appearance: "none",
|
|
337
|
-
WebkitAppearance: "none",
|
|
338
|
-
MozAppearance: "textfield"
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
},
|
|
342
|
-
eyeDropperTriggerProps: normalize.button({
|
|
343
|
-
...parts.eyeDropTrigger.attrs,
|
|
344
|
-
onClick() {
|
|
345
|
-
send("EYEDROPPER.CLICK");
|
|
346
|
-
}
|
|
347
|
-
}),
|
|
348
|
-
getSwatchBackgroundProps(props) {
|
|
349
|
-
const { value } = props;
|
|
350
|
-
const alpha = normalizeColor(value).getChannelValue("alpha");
|
|
351
|
-
return normalize.element({
|
|
352
|
-
...parts.swatchBg.attrs,
|
|
353
|
-
"data-alpha": alpha,
|
|
354
|
-
style: {
|
|
355
|
-
width: "100%",
|
|
356
|
-
height: "100%",
|
|
357
|
-
background: "#fff",
|
|
358
|
-
backgroundImage: [
|
|
359
|
-
"linear-gradient(-45deg,#0000 75.5%,#bcbcbc 75.5%)",
|
|
360
|
-
"linear-gradient(45deg,#0000 75.5%,#bcbcbc 75.5%)",
|
|
361
|
-
"linear-gradient(-45deg,#bcbcbc 25.5%,#0000 25.5%)",
|
|
362
|
-
"linear-gradient(45deg,#bcbcbc 25.5%,#0000 25.5%)"
|
|
363
|
-
].join(","),
|
|
364
|
-
backgroundPosition: "-2px -2px,-2px 6px,6px -10px,-10px -2px",
|
|
365
|
-
backgroundSize: "16px 16px",
|
|
366
|
-
position: "absolute",
|
|
367
|
-
inset: "0px",
|
|
368
|
-
zIndex: -1
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
},
|
|
372
|
-
getSwatchProps(props) {
|
|
373
|
-
const { value, readOnly } = props;
|
|
374
|
-
const color = normalizeColor(value).toFormat(valueAsColor.getColorSpace());
|
|
375
|
-
return normalize.element({
|
|
376
|
-
...parts.swatch.attrs,
|
|
377
|
-
onClick() {
|
|
378
|
-
if (readOnly)
|
|
379
|
-
return;
|
|
380
|
-
send({ type: "VALUE.SET", value: color });
|
|
381
|
-
},
|
|
382
|
-
style: {
|
|
383
|
-
position: "relative",
|
|
384
|
-
background: color.toString("css")
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
export {
|
|
392
|
-
connect
|
|
393
|
-
};
|
package/dist/chunk-75JXJMB5.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/color-picker.anatomy.ts
|
|
2
|
-
import { createAnatomy } from "@zag-js/anatomy";
|
|
3
|
-
var anatomy = createAnatomy("color-picker", [
|
|
4
|
-
"area",
|
|
5
|
-
"areaThumb",
|
|
6
|
-
"areaGradient",
|
|
7
|
-
"channelSliderTrack",
|
|
8
|
-
"channelSliderTrackBg",
|
|
9
|
-
"channelSliderThumb",
|
|
10
|
-
"channelInput",
|
|
11
|
-
"swatch",
|
|
12
|
-
"swatchBg",
|
|
13
|
-
"content",
|
|
14
|
-
"label",
|
|
15
|
-
"eyeDropTrigger"
|
|
16
|
-
]);
|
|
17
|
-
var parts = anatomy.build();
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
anatomy,
|
|
21
|
-
parts
|
|
22
|
-
};
|
package/dist/chunk-JNBNPPMF.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/utils/get-channel-display-color.ts
|
|
2
|
-
import { parseColor } from "@zag-js/color-utils";
|
|
3
|
-
function getChannelDisplayColor(color, channel) {
|
|
4
|
-
switch (channel) {
|
|
5
|
-
case "hue":
|
|
6
|
-
return parseColor(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
|
|
7
|
-
case "lightness":
|
|
8
|
-
case "brightness":
|
|
9
|
-
case "saturation":
|
|
10
|
-
case "red":
|
|
11
|
-
case "green":
|
|
12
|
-
case "blue":
|
|
13
|
-
return color.withChannelValue("alpha", 1);
|
|
14
|
-
case "alpha": {
|
|
15
|
-
return color;
|
|
16
|
-
}
|
|
17
|
-
default:
|
|
18
|
-
throw new Error("Unknown color channel: " + channel);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
getChannelDisplayColor
|
|
24
|
-
};
|
package/dist/chunk-KLLIOTK6.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// src/utils/get-channel-details.ts
|
|
2
|
-
import { snapValueToStep, getPercentValue } from "@zag-js/numeric-range";
|
|
3
|
-
function getChannelDetails(color, xChannel, yChannel) {
|
|
4
|
-
const channels = color.getColorSpaceAxes({ xChannel, yChannel });
|
|
5
|
-
const xChannelRange = color.getChannelRange(channels.xChannel);
|
|
6
|
-
const yChannelRange = color.getChannelRange(channels.yChannel);
|
|
7
|
-
const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange;
|
|
8
|
-
const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange;
|
|
9
|
-
const xValue = color.getChannelValue(channels.xChannel);
|
|
10
|
-
const yValue = color.getChannelValue(channels.yChannel);
|
|
11
|
-
return {
|
|
12
|
-
channels,
|
|
13
|
-
xChannelStep: stepX,
|
|
14
|
-
yChannelStep: stepY,
|
|
15
|
-
xChannelPageStep: pageSizeX,
|
|
16
|
-
yChannelPageStep: pageSizeY,
|
|
17
|
-
xValue,
|
|
18
|
-
yValue,
|
|
19
|
-
getThumbPosition() {
|
|
20
|
-
let x = (xValue - minValueX) / (maxValueX - minValueX);
|
|
21
|
-
let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
|
|
22
|
-
return { x, y };
|
|
23
|
-
},
|
|
24
|
-
incrementX(stepSize) {
|
|
25
|
-
return xValue + stepSize > maxValueX ? maxValueX : snapValueToStep(xValue + stepSize, minValueX, maxValueX, stepX);
|
|
26
|
-
},
|
|
27
|
-
incrementY(stepSize) {
|
|
28
|
-
return yValue + stepSize > maxValueY ? maxValueY : snapValueToStep(yValue + stepSize, minValueY, maxValueY, stepY);
|
|
29
|
-
},
|
|
30
|
-
decrementX(stepSize) {
|
|
31
|
-
return snapValueToStep(xValue - stepSize, minValueX, maxValueX, stepX);
|
|
32
|
-
},
|
|
33
|
-
decrementY(stepSize) {
|
|
34
|
-
return snapValueToStep(yValue - stepSize, minValueY, maxValueY, stepY);
|
|
35
|
-
},
|
|
36
|
-
getColorFromPoint(x, y) {
|
|
37
|
-
let newXValue = getPercentValue(x, minValueX, maxValueX, stepX);
|
|
38
|
-
let newYValue = getPercentValue(1 - y, minValueY, maxValueY, stepY);
|
|
39
|
-
let newColor;
|
|
40
|
-
if (newXValue !== xValue) {
|
|
41
|
-
newXValue = snapValueToStep(newXValue, minValueX, maxValueX, stepX);
|
|
42
|
-
newColor = color.withChannelValue(channels.xChannel, newXValue);
|
|
43
|
-
}
|
|
44
|
-
if (newYValue !== yValue) {
|
|
45
|
-
newYValue = snapValueToStep(newYValue, minValueY, maxValueY, stepY);
|
|
46
|
-
newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
|
|
47
|
-
}
|
|
48
|
-
return newColor;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
getChannelDetails
|
|
55
|
-
};
|
package/dist/chunk-KO4TBUXB.mjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
generateHSB_B,
|
|
3
|
-
generateHSB_H,
|
|
4
|
-
generateHSB_S,
|
|
5
|
-
generateHSL_H,
|
|
6
|
-
generateHSL_L,
|
|
7
|
-
generateHSL_S,
|
|
8
|
-
generateRGB_B,
|
|
9
|
-
generateRGB_G,
|
|
10
|
-
generateRGB_R
|
|
11
|
-
} from "./chunk-OY3B7NXA.mjs";
|
|
12
|
-
|
|
13
|
-
// src/utils/get-color-area-gradient.ts
|
|
14
|
-
function getColorAreaGradient(ctx, xChannel, yChannel) {
|
|
15
|
-
const value = ctx.valueAsColor;
|
|
16
|
-
const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel });
|
|
17
|
-
const zValue = value.getChannelValue(zChannel);
|
|
18
|
-
const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel);
|
|
19
|
-
const orientation = ["top", ctx.dir === "rtl" ? "left" : "right"];
|
|
20
|
-
let dir = false;
|
|
21
|
-
let background = { areaStyles: {}, areaGradientStyles: {} };
|
|
22
|
-
let alphaValue = (zValue - zMin) / (zMax - zMin);
|
|
23
|
-
let isHSL = value.getColorSpace() === "hsl";
|
|
24
|
-
switch (zChannel) {
|
|
25
|
-
case "red": {
|
|
26
|
-
dir = xChannel === "green";
|
|
27
|
-
background = generateRGB_R(orientation, dir, zValue);
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case "green": {
|
|
31
|
-
dir = xChannel === "red";
|
|
32
|
-
background = generateRGB_G(orientation, dir, zValue);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
case "blue": {
|
|
36
|
-
dir = xChannel === "red";
|
|
37
|
-
background = generateRGB_B(orientation, dir, zValue);
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
case "hue": {
|
|
41
|
-
dir = xChannel !== "saturation";
|
|
42
|
-
if (isHSL) {
|
|
43
|
-
background = generateHSL_H(orientation, dir, zValue);
|
|
44
|
-
} else {
|
|
45
|
-
background = generateHSB_H(orientation, dir, zValue);
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case "saturation": {
|
|
50
|
-
dir = xChannel === "hue";
|
|
51
|
-
if (isHSL) {
|
|
52
|
-
background = generateHSL_S(orientation, dir, alphaValue);
|
|
53
|
-
} else {
|
|
54
|
-
background = generateHSB_S(orientation, dir, alphaValue);
|
|
55
|
-
}
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
case "brightness": {
|
|
59
|
-
dir = xChannel === "hue";
|
|
60
|
-
background = generateHSB_B(orientation, dir, alphaValue);
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case "lightness": {
|
|
64
|
-
dir = xChannel === "hue";
|
|
65
|
-
background = generateHSL_L(orientation, dir, zValue);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return background;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export {
|
|
73
|
-
getColorAreaGradient
|
|
74
|
-
};
|