@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.
Files changed (54) hide show
  1. package/dist/color-picker.anatomy.d.ts +3 -6
  2. package/dist/color-picker.anatomy.js +10 -33
  3. package/dist/color-picker.anatomy.mjs +19 -8
  4. package/dist/color-picker.connect.d.ts +4 -8
  5. package/dist/color-picker.connect.js +56 -436
  6. package/dist/color-picker.connect.mjs +368 -14
  7. package/dist/color-picker.dom.d.ts +27 -32
  8. package/dist/color-picker.dom.js +12 -34
  9. package/dist/color-picker.dom.mjs +33 -6
  10. package/dist/color-picker.machine.d.ts +3 -8
  11. package/dist/color-picker.machine.js +46 -163
  12. package/dist/color-picker.machine.mjs +335 -8
  13. package/dist/color-picker.types.d.ts +14 -16
  14. package/dist/index.d.ts +4 -8
  15. package/dist/index.js +8 -1085
  16. package/dist/index.mjs +3 -21
  17. package/dist/utils/generate-format-background.d.ts +9 -11
  18. package/dist/utils/generate-format-background.js +22 -53
  19. package/dist/utils/generate-format-background.mjs +120 -21
  20. package/dist/utils/get-channel-details.d.ts +3 -7
  21. package/dist/utils/get-channel-details.js +15 -37
  22. package/dist/utils/get-channel-details.mjs +53 -6
  23. package/dist/utils/get-channel-display-color.d.ts +3 -5
  24. package/dist/utils/get-channel-display-color.js +8 -30
  25. package/dist/utils/get-channel-display-color.mjs +22 -6
  26. package/dist/utils/get-channel-input-value.d.ts +5 -10
  27. package/dist/utils/get-channel-input-value.js +6 -30
  28. package/dist/utils/get-channel-input-value.mjs +21 -8
  29. package/dist/utils/get-color-area-gradient.d.ts +6 -10
  30. package/dist/utils/get-color-area-gradient.js +14 -158
  31. package/dist/utils/get-color-area-gradient.mjs +61 -7
  32. package/dist/utils/get-slider-background.d.ts +2 -8
  33. package/dist/utils/get-slider-background.js +6 -29
  34. package/dist/utils/get-slider-background.mjs +38 -5
  35. package/package.json +11 -16
  36. package/src/color-picker.connect.ts +1 -1
  37. package/src/color-picker.dom.ts +1 -1
  38. package/src/color-picker.types.ts +3 -1
  39. package/src/index.ts +2 -0
  40. package/src/utils/get-channel-details.ts +2 -2
  41. package/src/utils/get-channel-display-color.ts +1 -1
  42. package/src/utils/get-color-area-gradient.ts +1 -1
  43. package/dist/chunk-2ERX54SV.mjs +0 -25
  44. package/dist/chunk-3XH465XT.mjs +0 -42
  45. package/dist/chunk-5QSFKCT5.mjs +0 -393
  46. package/dist/chunk-75JXJMB5.mjs +0 -22
  47. package/dist/chunk-JNBNPPMF.mjs +0 -24
  48. package/dist/chunk-KLLIOTK6.mjs +0 -55
  49. package/dist/chunk-KO4TBUXB.mjs +0 -74
  50. package/dist/chunk-ML3WX6YS.mjs +0 -345
  51. package/dist/chunk-OY3B7NXA.mjs +0 -132
  52. package/dist/chunk-SPSDVZCT.mjs +0 -35
  53. package/dist/color-picker.types.js +0 -18
  54. package/dist/color-picker.types.mjs +0 -0
@@ -1,396 +1,18 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/color-picker.connect.ts
21
- var color_picker_connect_exports = {};
22
- __export(color_picker_connect_exports, {
23
- connect: () => connect
24
- });
25
- module.exports = __toCommonJS(color_picker_connect_exports);
26
- var import_color_utils2 = require("@zag-js/color-utils");
27
- var import_dom_event2 = require("@zag-js/dom-event");
28
- var import_dom_query2 = require("@zag-js/dom-query");
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
29
4
 
30
- // src/color-picker.anatomy.ts
31
- var import_anatomy = require("@zag-js/anatomy");
32
- var anatomy = (0, import_anatomy.createAnatomy)("color-picker", [
33
- "area",
34
- "areaThumb",
35
- "areaGradient",
36
- "channelSliderTrack",
37
- "channelSliderTrackBg",
38
- "channelSliderThumb",
39
- "channelInput",
40
- "swatch",
41
- "swatchBg",
42
- "content",
43
- "label",
44
- "eyeDropTrigger"
45
- ]);
46
- var parts = anatomy.build();
5
+ const colorUtils = require('@zag-js/color-utils');
6
+ const domEvent = require('@zag-js/dom-event');
7
+ const domQuery = require('@zag-js/dom-query');
8
+ const colorPicker_anatomy = require('./color-picker.anatomy.js');
9
+ const colorPicker_dom = require('./color-picker.dom.js');
10
+ const getChannelDetails = require('./utils/get-channel-details.js');
11
+ const getChannelDisplayColor = require('./utils/get-channel-display-color.js');
12
+ const getChannelInputValue = require('./utils/get-channel-input-value.js');
13
+ const getColorAreaGradient = require('./utils/get-color-area-gradient.js');
14
+ const getSliderBackground = require('./utils/get-slider-background.js');
47
15
 
48
- // src/color-picker.dom.ts
49
- var import_dom_event = require("@zag-js/dom-event");
50
- var import_dom_query = require("@zag-js/dom-query");
51
- var dom = (0, import_dom_query.createScope)({
52
- getContentId: (ctx) => ctx.ids?.content ?? `color-picker:${ctx.id}:content`,
53
- getAreaId: (ctx) => ctx.ids?.area ?? `color-picker:${ctx.id}:area`,
54
- getAreaGradientId: (ctx) => ctx.ids?.areaGradient ?? `color-picker:${ctx.id}:area-gradient`,
55
- getAreaThumbId: (ctx) => ctx.ids?.areaThumb ?? `color-picker:${ctx.id}:area-thumb`,
56
- getChannelSliderTrackId: (ctx, channel) => ctx.ids?.channelSliderTrack?.(channel) ?? `color-picker:${ctx.id}:slider-track:${channel}`,
57
- getChannelInputId: (ctx, channel) => ctx.ids?.channelInput?.(channel) ?? `color-picker:${ctx.id}:input:${channel}`,
58
- getChannelSliderThumbId: (ctx, channel) => ctx.ids?.channelSliderThumb?.(channel) ?? `color-picker:${ctx.id}:slider-thumb:${channel}`,
59
- getContentEl: (ctx) => dom.queryById(ctx, dom.getContentId(ctx)),
60
- getAreaThumbEl: (ctx) => dom.queryById(ctx, dom.getAreaThumbId(ctx)),
61
- getChannelSliderThumbEl: (ctx, channel) => dom.queryById(ctx, dom.getChannelSliderThumbId(ctx, channel)),
62
- getChannelInputEl: (ctx, channel) => dom.queryById(ctx, dom.getChannelInputId(ctx, channel)),
63
- getAreaEl: (ctx) => dom.queryById(ctx, dom.getAreaId(ctx)),
64
- getAreaValueFromPoint(ctx, point) {
65
- const { percent } = (0, import_dom_event.getRelativePoint)(point, dom.getAreaEl(ctx));
66
- return percent;
67
- },
68
- getChannelSliderTrackEl: (ctx, channel) => {
69
- return dom.queryById(ctx, dom.getChannelSliderTrackId(ctx, channel));
70
- },
71
- getChannelSliderValueFromPoint(ctx, point, channel) {
72
- const { percent } = (0, import_dom_event.getRelativePoint)(point, dom.getChannelSliderTrackEl(ctx, channel));
73
- return percent;
74
- },
75
- getChannelInputEls: (ctx) => {
76
- return (0, import_dom_query.queryAll)(dom.getContentEl(ctx), "input[data-channel]");
77
- }
78
- });
79
-
80
- // src/utils/get-channel-details.ts
81
- var import_numeric_range = require("@zag-js/numeric-range");
82
- function getChannelDetails(color, xChannel, yChannel) {
83
- const channels = color.getColorSpaceAxes({ xChannel, yChannel });
84
- const xChannelRange = color.getChannelRange(channels.xChannel);
85
- const yChannelRange = color.getChannelRange(channels.yChannel);
86
- const { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange;
87
- const { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange;
88
- const xValue = color.getChannelValue(channels.xChannel);
89
- const yValue = color.getChannelValue(channels.yChannel);
90
- return {
91
- channels,
92
- xChannelStep: stepX,
93
- yChannelStep: stepY,
94
- xChannelPageStep: pageSizeX,
95
- yChannelPageStep: pageSizeY,
96
- xValue,
97
- yValue,
98
- getThumbPosition() {
99
- let x = (xValue - minValueX) / (maxValueX - minValueX);
100
- let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
101
- return { x, y };
102
- },
103
- incrementX(stepSize) {
104
- return xValue + stepSize > maxValueX ? maxValueX : (0, import_numeric_range.snapValueToStep)(xValue + stepSize, minValueX, maxValueX, stepX);
105
- },
106
- incrementY(stepSize) {
107
- return yValue + stepSize > maxValueY ? maxValueY : (0, import_numeric_range.snapValueToStep)(yValue + stepSize, minValueY, maxValueY, stepY);
108
- },
109
- decrementX(stepSize) {
110
- return (0, import_numeric_range.snapValueToStep)(xValue - stepSize, minValueX, maxValueX, stepX);
111
- },
112
- decrementY(stepSize) {
113
- return (0, import_numeric_range.snapValueToStep)(yValue - stepSize, minValueY, maxValueY, stepY);
114
- },
115
- getColorFromPoint(x, y) {
116
- let newXValue = (0, import_numeric_range.getPercentValue)(x, minValueX, maxValueX, stepX);
117
- let newYValue = (0, import_numeric_range.getPercentValue)(1 - y, minValueY, maxValueY, stepY);
118
- let newColor;
119
- if (newXValue !== xValue) {
120
- newXValue = (0, import_numeric_range.snapValueToStep)(newXValue, minValueX, maxValueX, stepX);
121
- newColor = color.withChannelValue(channels.xChannel, newXValue);
122
- }
123
- if (newYValue !== yValue) {
124
- newYValue = (0, import_numeric_range.snapValueToStep)(newYValue, minValueY, maxValueY, stepY);
125
- newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
126
- }
127
- return newColor;
128
- }
129
- };
130
- }
131
-
132
- // src/utils/get-channel-display-color.ts
133
- var import_color_utils = require("@zag-js/color-utils");
134
- function getChannelDisplayColor(color, channel) {
135
- switch (channel) {
136
- case "hue":
137
- return (0, import_color_utils.parseColor)(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
138
- case "lightness":
139
- case "brightness":
140
- case "saturation":
141
- case "red":
142
- case "green":
143
- case "blue":
144
- return color.withChannelValue("alpha", 1);
145
- case "alpha": {
146
- return color;
147
- }
148
- default:
149
- throw new Error("Unknown color channel: " + channel);
150
- }
151
- }
152
-
153
- // src/utils/get-channel-input-value.ts
154
- function getChannelInputValue(color, channel) {
155
- switch (channel) {
156
- case "hex":
157
- return color.toString("hex");
158
- case "css":
159
- return color.toString("css");
160
- default:
161
- return color.getChannelValue(channel).toString();
162
- }
163
- }
164
- function getChannelInputRange(color, channel) {
165
- switch (channel) {
166
- case "hex":
167
- case "css":
168
- return void 0;
169
- default:
170
- return color.getChannelRange(channel);
171
- }
172
- }
173
-
174
- // src/utils/generate-format-background.ts
175
- var generateRGB_R = (orientation, dir, zValue) => {
176
- const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
177
- const result = {
178
- areaStyles: {
179
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,0),rgb(${zValue},255,0))`
180
- },
181
- areaGradientStyles: {
182
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(${zValue},0,255),rgb(${zValue},255,255))`,
183
- WebkitMaskImage: maskImage,
184
- maskImage
185
- }
186
- };
187
- return result;
188
- };
189
- var generateRGB_G = (orientation, dir, zValue) => {
190
- const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
191
- const result = {
192
- areaStyles: {
193
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},0),rgb(255,${zValue},0))`
194
- },
195
- areaGradientStyles: {
196
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,${zValue},255),rgb(255,${zValue},255))`,
197
- WebkitMaskImage: maskImage,
198
- maskImage
199
- }
200
- };
201
- return result;
202
- };
203
- var generateRGB_B = (orientation, dir, zValue) => {
204
- const maskImage = `linear-gradient(to ${orientation[Number(!dir)]}, transparent, #000)`;
205
- const result = {
206
- areaStyles: {
207
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,0,${zValue}),rgb(255,0,${zValue}))`
208
- },
209
- areaGradientStyles: {
210
- backgroundImage: `linear-gradient(to ${orientation[Number(dir)]},rgb(0,255,${zValue}),rgb(255,255,${zValue}))`,
211
- WebkitMaskImage: maskImage,
212
- maskImage
213
- }
214
- };
215
- return result;
216
- };
217
- var generateHSL_H = (orientation, dir, zValue) => {
218
- const result = {
219
- areaStyles: {},
220
- areaGradientStyles: {
221
- background: [
222
- `linear-gradient(to ${orientation[Number(dir)]}, hsla(0,0%,0%,1) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,1) 100%)`,
223
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,50%),hsla(0,0%,50%,0))`,
224
- `hsl(${zValue}, 100%, 50%)`
225
- ].join(",")
226
- }
227
- };
228
- return result;
229
- };
230
- var generateHSL_S = (orientation, dir, alphaValue) => {
231
- const result = {
232
- areaStyles: {},
233
- areaGradientStyles: {
234
- background: [
235
- `linear-gradient(to ${orientation[Number(!dir)]}, hsla(0,0%,0%,${alphaValue}) 0%, hsla(0,0%,0%,0) 50%, hsla(0,0%,100%,0) 50%, hsla(0,0%,100%,${alphaValue}) 100%)`,
236
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
237
- "hsl(0, 0%, 50%)"
238
- ].join(",")
239
- }
240
- };
241
- return result;
242
- };
243
- var generateHSL_L = (orientation, dir, zValue) => {
244
- const result = {
245
- areaStyles: {},
246
- areaGradientStyles: {
247
- backgroundImage: [
248
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,${zValue}%),hsla(0,0%,${zValue}%,0))`,
249
- `linear-gradient(to ${orientation[Number(dir)]},hsl(0,100%,${zValue}%),hsl(60,100%,${zValue}%),hsl(120,100%,${zValue}%),hsl(180,100%,${zValue}%),hsl(240,100%,${zValue}%),hsl(300,100%,${zValue}%),hsl(360,100%,${zValue}%))`
250
- ].join(",")
251
- }
252
- };
253
- return result;
254
- };
255
- var generateHSB_H = (orientation, dir, zValue) => {
256
- const result = {
257
- areaStyles: {},
258
- areaGradientStyles: {
259
- background: [
260
- `linear-gradient(to ${orientation[Number(dir)]},hsl(0,0%,0%),hsla(0,0%,0%,0))`,
261
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,100%),hsla(0,0%,100%,0))`,
262
- `hsl(${zValue}, 100%, 50%)`
263
- ].join(",")
264
- }
265
- };
266
- return result;
267
- };
268
- var generateHSB_S = (orientation, dir, alphaValue) => {
269
- const result = {
270
- areaStyles: {},
271
- areaGradientStyles: {
272
- background: [
273
- `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,0%,${alphaValue}),hsla(0,0%,0%,0))`,
274
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
275
- `linear-gradient(to ${orientation[Number(!dir)]},hsl(0,0%,0%),hsl(0,0%,100%))`
276
- ].join(",")
277
- }
278
- };
279
- return result;
280
- };
281
- var generateHSB_B = (orientation, dir, alphaValue) => {
282
- const result = {
283
- areaStyles: {},
284
- areaGradientStyles: {
285
- background: [
286
- `linear-gradient(to ${orientation[Number(!dir)]},hsla(0,0%,100%,${alphaValue}),hsla(0,0%,100%,0))`,
287
- `linear-gradient(to ${orientation[Number(dir)]},hsla(0,100%,50%,${alphaValue}),hsla(60,100%,50%,${alphaValue}),hsla(120,100%,50%,${alphaValue}),hsla(180,100%,50%,${alphaValue}),hsla(240,100%,50%,${alphaValue}),hsla(300,100%,50%,${alphaValue}),hsla(359,100%,50%,${alphaValue}))`,
288
- "#000"
289
- ].join(",")
290
- }
291
- };
292
- return result;
293
- };
294
-
295
- // src/utils/get-color-area-gradient.ts
296
- function getColorAreaGradient(ctx, xChannel, yChannel) {
297
- const value = ctx.valueAsColor;
298
- const { zChannel } = value.getColorSpaceAxes({ xChannel, yChannel });
299
- const zValue = value.getChannelValue(zChannel);
300
- const { minValue: zMin, maxValue: zMax } = value.getChannelRange(zChannel);
301
- const orientation = ["top", ctx.dir === "rtl" ? "left" : "right"];
302
- let dir = false;
303
- let background = { areaStyles: {}, areaGradientStyles: {} };
304
- let alphaValue = (zValue - zMin) / (zMax - zMin);
305
- let isHSL = value.getColorSpace() === "hsl";
306
- switch (zChannel) {
307
- case "red": {
308
- dir = xChannel === "green";
309
- background = generateRGB_R(orientation, dir, zValue);
310
- break;
311
- }
312
- case "green": {
313
- dir = xChannel === "red";
314
- background = generateRGB_G(orientation, dir, zValue);
315
- break;
316
- }
317
- case "blue": {
318
- dir = xChannel === "red";
319
- background = generateRGB_B(orientation, dir, zValue);
320
- break;
321
- }
322
- case "hue": {
323
- dir = xChannel !== "saturation";
324
- if (isHSL) {
325
- background = generateHSL_H(orientation, dir, zValue);
326
- } else {
327
- background = generateHSB_H(orientation, dir, zValue);
328
- }
329
- break;
330
- }
331
- case "saturation": {
332
- dir = xChannel === "hue";
333
- if (isHSL) {
334
- background = generateHSL_S(orientation, dir, alphaValue);
335
- } else {
336
- background = generateHSB_S(orientation, dir, alphaValue);
337
- }
338
- break;
339
- }
340
- case "brightness": {
341
- dir = xChannel === "hue";
342
- background = generateHSB_B(orientation, dir, alphaValue);
343
- break;
344
- }
345
- case "lightness": {
346
- dir = xChannel === "hue";
347
- background = generateHSL_L(orientation, dir, zValue);
348
- break;
349
- }
350
- }
351
- return background;
352
- }
353
-
354
- // src/utils/get-slider-background.ts
355
- function getSliderBgDirection(orientation, dir) {
356
- if (orientation === "vertical") {
357
- return "top";
358
- } else if (dir === "ltr") {
359
- return "right";
360
- } else {
361
- return "left";
362
- }
363
- }
364
- var getSliderBgImage = (ctx, props) => {
365
- const { channel } = props;
366
- const dir = getSliderBgDirection(props.orientation, ctx.dir);
367
- const value = ctx.valueAsColor;
368
- const { minValue, maxValue } = ctx.valueAsColor.getChannelRange(channel);
369
- switch (channel) {
370
- case "hue":
371
- return `linear-gradient(to ${dir}, rgb(255, 0, 0) 0%, rgb(255, 255, 0) 17%, rgb(0, 255, 0) 33%, rgb(0, 255, 255) 50%, rgb(0, 0, 255) 67%, rgb(255, 0, 255) 83%, rgb(255, 0, 0) 100%)`;
372
- case "lightness": {
373
- let start = ctx.valueAsColor.withChannelValue(channel, minValue).toString("css");
374
- let middle = value.withChannelValue(channel, (maxValue - minValue) / 2).toString("css");
375
- let end = value.withChannelValue(channel, maxValue).toString("css");
376
- return `linear-gradient(to ${dir}, ${start}, ${middle}, ${end})`;
377
- }
378
- case "saturation":
379
- case "brightness":
380
- case "red":
381
- case "green":
382
- case "blue":
383
- case "alpha": {
384
- let start = value.withChannelValue(channel, minValue).toString("css");
385
- let end = value.withChannelValue(channel, maxValue).toString("css");
386
- return `linear-gradient(to ${dir}, ${start}, ${end})`;
387
- }
388
- default:
389
- throw new Error("Unknown color channel: " + channel);
390
- }
391
- };
392
-
393
- // src/color-picker.connect.ts
394
16
  function connect(state, send, normalize) {
395
17
  const valueAsColor = state.context.valueAsColor;
396
18
  const isDisabled = state.context.disabled;
@@ -418,7 +40,7 @@ function connect(state, send, normalize) {
418
40
  * Function to set the color value
419
41
  */
420
42
  setColor(value) {
421
- send({ type: "VALUE.SET", value: (0, import_color_utils2.normalizeColor)(value), src: "set-color" });
43
+ send({ type: "VALUE.SET", value: colorUtils.normalizeColor(value), src: "set-color" });
422
44
  },
423
45
  /**
424
46
  * Function to set the color value of a specific channel
@@ -435,23 +57,23 @@ function connect(state, send, normalize) {
435
57
  send({ type: "VALUE.SET", value, src: "set-format" });
436
58
  },
437
59
  contentProps: normalize.element({
438
- ...parts.content.attrs,
439
- id: dom.getContentId(state.context)
60
+ ...colorPicker_anatomy.parts.content.attrs,
61
+ id: colorPicker_dom.dom.getContentId(state.context)
440
62
  }),
441
63
  getAreaProps(props) {
442
64
  const { xChannel, yChannel } = props;
443
- const { areaStyles } = getColorAreaGradient(state.context, xChannel, yChannel);
65
+ const { areaStyles } = getColorAreaGradient.getColorAreaGradient(state.context, xChannel, yChannel);
444
66
  return normalize.element({
445
- ...parts.area.attrs,
446
- id: dom.getAreaId(state.context),
67
+ ...colorPicker_anatomy.parts.area.attrs,
68
+ id: colorPicker_dom.dom.getAreaId(state.context),
447
69
  role: "group",
448
70
  onPointerDown(event) {
449
71
  if (!isInteractive)
450
72
  return;
451
- const evt = (0, import_dom_event2.getNativeEvent)(event);
452
- if (!(0, import_dom_event2.isLeftClick)(evt) || (0, import_dom_event2.isModifiedEvent)(evt))
73
+ const evt = domEvent.getNativeEvent(event);
74
+ if (!domEvent.isLeftClick(evt) || domEvent.isModifiedEvent(evt))
453
75
  return;
454
- const point = (0, import_dom_event2.getEventPoint)(evt);
76
+ const point = domEvent.getEventPoint(evt);
455
77
  const channel = { xChannel, yChannel };
456
78
  send({ type: "AREA.POINTER_DOWN", point, channel, id: "area" });
457
79
  },
@@ -465,10 +87,10 @@ function connect(state, send, normalize) {
465
87
  },
466
88
  getAreaGradientProps(props) {
467
89
  const { xChannel, yChannel } = props;
468
- const { areaGradientStyles } = getColorAreaGradient(state.context, xChannel, yChannel);
90
+ const { areaGradientStyles } = getColorAreaGradient.getColorAreaGradient(state.context, xChannel, yChannel);
469
91
  return normalize.element({
470
- ...parts.areaGradient.attrs,
471
- id: dom.getAreaGradientId(state.context),
92
+ ...colorPicker_anatomy.parts.areaGradient.attrs,
93
+ id: colorPicker_dom.dom.getAreaGradientId(state.context),
472
94
  style: {
473
95
  position: "relative",
474
96
  touchAction: "none",
@@ -479,14 +101,14 @@ function connect(state, send, normalize) {
479
101
  },
480
102
  getAreaThumbProps(props) {
481
103
  const { xChannel, yChannel } = props;
482
- const { getThumbPosition } = getChannelDetails(valueAsColor, xChannel, yChannel);
104
+ const { getThumbPosition } = getChannelDetails.getChannelDetails(valueAsColor, xChannel, yChannel);
483
105
  const { x, y } = getThumbPosition();
484
106
  const channel = { xChannel, yChannel };
485
107
  return normalize.element({
486
- ...parts.areaThumb.attrs,
487
- id: dom.getAreaThumbId(state.context),
108
+ ...colorPicker_anatomy.parts.areaThumb.attrs,
109
+ id: colorPicker_dom.dom.getAreaThumbId(state.context),
488
110
  tabIndex: isDisabled ? void 0 : 0,
489
- "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
111
+ "data-disabled": domQuery.dataAttr(isDisabled),
490
112
  role: "presentation",
491
113
  style: {
492
114
  position: "absolute",
@@ -503,7 +125,7 @@ function connect(state, send, normalize) {
503
125
  onKeyDown(event) {
504
126
  if (!isInteractive)
505
127
  return;
506
- const step = (0, import_dom_event2.getEventStep)(event);
128
+ const step = domEvent.getEventStep(event);
507
129
  const keyMap = {
508
130
  ArrowUp() {
509
131
  send({ type: "AREA.ARROW_UP", channel, step });
@@ -524,7 +146,7 @@ function connect(state, send, normalize) {
524
146
  send({ type: "AREA.PAGE_DOWN", channel, step });
525
147
  }
526
148
  };
527
- const exec = keyMap[(0, import_dom_event2.getEventKey)(event, state.context)];
149
+ const exec = keyMap[domEvent.getEventKey(event, state.context)];
528
150
  if (exec) {
529
151
  exec(event);
530
152
  event.preventDefault();
@@ -535,32 +157,32 @@ function connect(state, send, normalize) {
535
157
  getChannelSliderTrackProps(props) {
536
158
  const { orientation = "horizontal", channel } = props;
537
159
  return normalize.element({
538
- ...parts.channelSliderTrack.attrs,
539
- id: dom.getChannelSliderTrackId(state.context, channel),
160
+ ...colorPicker_anatomy.parts.channelSliderTrack.attrs,
161
+ id: colorPicker_dom.dom.getChannelSliderTrackId(state.context, channel),
540
162
  role: "group",
541
163
  "data-channel": channel,
542
164
  "data-orientation": orientation,
543
165
  onPointerDown(event) {
544
166
  if (!isInteractive)
545
167
  return;
546
- const evt = (0, import_dom_event2.getNativeEvent)(event);
547
- if (!(0, import_dom_event2.isLeftClick)(evt) || (0, import_dom_event2.isModifiedEvent)(evt))
168
+ const evt = domEvent.getNativeEvent(event);
169
+ if (!domEvent.isLeftClick(evt) || domEvent.isModifiedEvent(evt))
548
170
  return;
549
- const point = (0, import_dom_event2.getEventPoint)(evt);
171
+ const point = domEvent.getEventPoint(evt);
550
172
  send({ type: "CHANNEL_SLIDER.POINTER_DOWN", channel, point, id: channel, orientation });
551
173
  },
552
174
  style: {
553
175
  position: "relative",
554
176
  touchAction: "none",
555
177
  forcedColorAdjust: "none",
556
- backgroundImage: getSliderBgImage(state.context, { orientation, channel })
178
+ backgroundImage: getSliderBackground.getSliderBgImage(state.context, { orientation, channel })
557
179
  }
558
180
  });
559
181
  },
560
182
  getChannelSliderBackgroundProps(props) {
561
183
  const { orientation = "horizontal", channel } = props;
562
184
  return normalize.element({
563
- ...parts.channelSliderTrackBg.attrs,
185
+ ...colorPicker_anatomy.parts.channelSliderTrackBg.attrs,
564
186
  "data-orientation": orientation,
565
187
  "data-channel": channel,
566
188
  style: {
@@ -586,15 +208,15 @@ function connect(state, send, normalize) {
586
208
  const offset = (channelValue - minValue) / (maxValue - minValue);
587
209
  const placementStyles = orientation === "horizontal" ? { left: `${offset * 100}%`, top: "50%" } : { top: `${offset * 100}%`, left: "50%" };
588
210
  return normalize.element({
589
- ...parts.channelSliderThumb.attrs,
590
- id: dom.getChannelSliderThumbId(state.context, channel),
211
+ ...colorPicker_anatomy.parts.channelSliderThumb.attrs,
212
+ id: colorPicker_dom.dom.getChannelSliderThumbId(state.context, channel),
591
213
  role: "slider",
592
214
  "aria-label": channel,
593
215
  tabIndex: isDisabled ? void 0 : 0,
594
216
  "data-channel": channel,
595
- "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
217
+ "data-disabled": domQuery.dataAttr(isDisabled),
596
218
  "data-orientation": orientation,
597
- "aria-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
219
+ "aria-disabled": domQuery.dataAttr(isDisabled),
598
220
  "aria-orientation": orientation,
599
221
  "aria-valuemax": maxValue,
600
222
  "aria-valuemin": minValue,
@@ -602,7 +224,7 @@ function connect(state, send, normalize) {
602
224
  style: {
603
225
  forcedColorAdjust: "none",
604
226
  position: "absolute",
605
- background: getChannelDisplayColor(valueAsColor, channel).toString("css"),
227
+ background: getChannelDisplayColor.getChannelDisplayColor(valueAsColor, channel).toString("css"),
606
228
  ...placementStyles
607
229
  },
608
230
  onFocus() {
@@ -618,7 +240,7 @@ function connect(state, send, normalize) {
618
240
  onKeyDown(event) {
619
241
  if (!isInteractive)
620
242
  return;
621
- const step = (0, import_dom_event2.getEventStep)(event) * stepValue;
243
+ const step = domEvent.getEventStep(event) * stepValue;
622
244
  const keyMap = {
623
245
  ArrowUp() {
624
246
  send({ type: "CHANNEL_SLIDER.ARROW_UP", channel, step });
@@ -645,7 +267,7 @@ function connect(state, send, normalize) {
645
267
  send({ type: "CHANNEL_SLIDER.END", channel });
646
268
  }
647
269
  };
648
- const exec = keyMap[(0, import_dom_event2.getEventKey)(event, state.context)];
270
+ const exec = keyMap[domEvent.getEventKey(event, state.context)];
649
271
  if (exec) {
650
272
  exec(event);
651
273
  event.preventDefault();
@@ -656,17 +278,17 @@ function connect(state, send, normalize) {
656
278
  getChannelInputProps(props) {
657
279
  const { channel } = props;
658
280
  const isTextField = channel === "hex" || channel === "css";
659
- const range = getChannelInputRange(valueAsColor, channel);
281
+ const range = getChannelInputValue.getChannelInputRange(valueAsColor, channel);
660
282
  return normalize.input({
661
- ...parts.channelInput.attrs,
283
+ ...colorPicker_anatomy.parts.channelInput.attrs,
662
284
  type: isTextField ? "text" : "number",
663
285
  "data-channel": channel,
664
286
  "aria-label": channel,
665
287
  disabled: isDisabled,
666
- "data-disabled": (0, import_dom_query2.dataAttr)(isDisabled),
288
+ "data-disabled": domQuery.dataAttr(isDisabled),
667
289
  readOnly: state.context.readOnly,
668
- id: dom.getChannelInputId(state.context, channel),
669
- defaultValue: getChannelInputValue(valueAsColor, channel),
290
+ id: colorPicker_dom.dom.getChannelInputId(state.context, channel),
291
+ defaultValue: getChannelInputValue.getChannelInputValue(valueAsColor, channel),
670
292
  min: range?.minValue,
671
293
  max: range?.maxValue,
672
294
  step: range?.step,
@@ -699,16 +321,16 @@ function connect(state, send, normalize) {
699
321
  });
700
322
  },
701
323
  eyeDropperTriggerProps: normalize.button({
702
- ...parts.eyeDropTrigger.attrs,
324
+ ...colorPicker_anatomy.parts.eyeDropTrigger.attrs,
703
325
  onClick() {
704
326
  send("EYEDROPPER.CLICK");
705
327
  }
706
328
  }),
707
329
  getSwatchBackgroundProps(props) {
708
330
  const { value } = props;
709
- const alpha = (0, import_color_utils2.normalizeColor)(value).getChannelValue("alpha");
331
+ const alpha = colorUtils.normalizeColor(value).getChannelValue("alpha");
710
332
  return normalize.element({
711
- ...parts.swatchBg.attrs,
333
+ ...colorPicker_anatomy.parts.swatchBg.attrs,
712
334
  "data-alpha": alpha,
713
335
  style: {
714
336
  width: "100%",
@@ -730,9 +352,9 @@ function connect(state, send, normalize) {
730
352
  },
731
353
  getSwatchProps(props) {
732
354
  const { value, readOnly } = props;
733
- const color = (0, import_color_utils2.normalizeColor)(value).toFormat(valueAsColor.getColorSpace());
355
+ const color = colorUtils.normalizeColor(value).toFormat(valueAsColor.getColorSpace());
734
356
  return normalize.element({
735
- ...parts.swatch.attrs,
357
+ ...colorPicker_anatomy.parts.swatch.attrs,
736
358
  onClick() {
737
359
  if (readOnly)
738
360
  return;
@@ -746,7 +368,5 @@ function connect(state, send, normalize) {
746
368
  }
747
369
  };
748
370
  }
749
- // Annotate the CommonJS export names for ESM import in node:
750
- 0 && (module.exports = {
751
- connect
752
- });
371
+
372
+ exports.connect = connect;