@yamada-ui/color-picker 1.0.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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/dist/alpha-slider.d.mts +62 -0
  4. package/dist/alpha-slider.d.ts +62 -0
  5. package/dist/alpha-slider.js +438 -0
  6. package/dist/alpha-slider.mjs +8 -0
  7. package/dist/chunk-3EO2XBIZ.mjs +54 -0
  8. package/dist/chunk-3KASGDAY.mjs +122 -0
  9. package/dist/chunk-3N443XSV.mjs +105 -0
  10. package/dist/chunk-73BVTMII.mjs +73 -0
  11. package/dist/chunk-7QGCTVDG.mjs +66 -0
  12. package/dist/chunk-DTB2Z3IJ.mjs +278 -0
  13. package/dist/chunk-EMWFECJD.mjs +123 -0
  14. package/dist/chunk-HNVFOSAM.mjs +210 -0
  15. package/dist/chunk-KJS52X4M.mjs +330 -0
  16. package/dist/chunk-MAHWFXUG.mjs +294 -0
  17. package/dist/chunk-N2GG5L7Q.mjs +39 -0
  18. package/dist/chunk-NR2XCTSD.mjs +430 -0
  19. package/dist/chunk-PTTNJPGJ.mjs +98 -0
  20. package/dist/chunk-PVWIBTBL.mjs +67 -0
  21. package/dist/chunk-TFQ62YSQ.mjs +68 -0
  22. package/dist/chunk-U6OJ4TDG.mjs +127 -0
  23. package/dist/color-input.d.mts +79 -0
  24. package/dist/color-input.d.ts +79 -0
  25. package/dist/color-input.js +2283 -0
  26. package/dist/color-input.mjs +21 -0
  27. package/dist/color-picker-body.d.mts +38 -0
  28. package/dist/color-picker-body.d.ts +38 -0
  29. package/dist/color-picker-body.js +794 -0
  30. package/dist/color-picker-body.mjs +14 -0
  31. package/dist/color-picker-channels.d.mts +20 -0
  32. package/dist/color-picker-channels.d.ts +20 -0
  33. package/dist/color-picker-channels.js +101 -0
  34. package/dist/color-picker-channels.mjs +10 -0
  35. package/dist/color-picker-eye-dropper.d.mts +10 -0
  36. package/dist/color-picker-eye-dropper.d.ts +10 -0
  37. package/dist/color-picker-eye-dropper.js +88 -0
  38. package/dist/color-picker-eye-dropper.mjs +10 -0
  39. package/dist/color-picker-sliders.d.mts +30 -0
  40. package/dist/color-picker-sliders.d.ts +30 -0
  41. package/dist/color-picker-sliders.js +590 -0
  42. package/dist/color-picker-sliders.mjs +11 -0
  43. package/dist/color-picker-swatches.d.mts +34 -0
  44. package/dist/color-picker-swatches.d.ts +34 -0
  45. package/dist/color-picker-swatches.js +195 -0
  46. package/dist/color-picker-swatches.mjs +9 -0
  47. package/dist/color-picker.d.mts +59 -0
  48. package/dist/color-picker.d.ts +59 -0
  49. package/dist/color-picker.js +1790 -0
  50. package/dist/color-picker.mjs +19 -0
  51. package/dist/color-swatch.d.mts +36 -0
  52. package/dist/color-swatch.d.ts +36 -0
  53. package/dist/color-swatch.js +124 -0
  54. package/dist/color-swatch.mjs +6 -0
  55. package/dist/hue-slider.d.mts +56 -0
  56. package/dist/hue-slider.d.ts +56 -0
  57. package/dist/hue-slider.js +409 -0
  58. package/dist/hue-slider.mjs +8 -0
  59. package/dist/index.d.mts +23 -0
  60. package/dist/index.d.ts +23 -0
  61. package/dist/index.js +2295 -0
  62. package/dist/index.mjs +36 -0
  63. package/dist/saturation-slider.d.mts +33 -0
  64. package/dist/saturation-slider.d.ts +33 -0
  65. package/dist/saturation-slider.js +414 -0
  66. package/dist/saturation-slider.mjs +7 -0
  67. package/dist/use-color-input.d.mts +90 -0
  68. package/dist/use-color-input.d.ts +90 -0
  69. package/dist/use-color-input.js +340 -0
  70. package/dist/use-color-input.mjs +10 -0
  71. package/dist/use-color-picker.d.mts +131 -0
  72. package/dist/use-color-picker.d.ts +131 -0
  73. package/dist/use-color-picker.js +472 -0
  74. package/dist/use-color-picker.mjs +11 -0
  75. package/dist/use-color-slider.d.mts +69 -0
  76. package/dist/use-color-slider.d.ts +69 -0
  77. package/dist/use-color-slider.js +321 -0
  78. package/dist/use-color-slider.mjs +7 -0
  79. package/dist/use-saturation-slider.d.mts +77 -0
  80. package/dist/use-saturation-slider.d.ts +77 -0
  81. package/dist/use-saturation-slider.js +302 -0
  82. package/dist/use-saturation-slider.mjs +6 -0
  83. package/package.json +88 -0
@@ -0,0 +1,1790 @@
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);
19
+
20
+ // src/color-picker.tsx
21
+ var color_picker_exports = {};
22
+ __export(color_picker_exports, {
23
+ ColorPicker: () => ColorPicker
24
+ });
25
+ module.exports = __toCommonJS(color_picker_exports);
26
+ var import_core10 = require("@yamada-ui/core");
27
+ var import_utils13 = require("@yamada-ui/utils");
28
+
29
+ // src/color-picker-body.tsx
30
+ var import_core6 = require("@yamada-ui/core");
31
+ var import_utils8 = require("@yamada-ui/utils");
32
+
33
+ // src/color-picker-eye-dropper.tsx
34
+ var import_button = require("@yamada-ui/button");
35
+ var import_core = require("@yamada-ui/core");
36
+ var import_icon = require("@yamada-ui/icon");
37
+ var import_utils2 = require("@yamada-ui/utils");
38
+
39
+ // src/use-color-picker.ts
40
+ var import_form_control = require("@yamada-ui/form-control");
41
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
42
+ var import_use_eye_dropper = require("@yamada-ui/use-eye-dropper");
43
+ var import_utils = require("@yamada-ui/utils");
44
+ var import_react = require("react");
45
+
46
+ // ../../utils/src/object.ts
47
+ var pickObject = (obj, keys) => {
48
+ const result = {};
49
+ keys.forEach((key) => {
50
+ if (key in obj)
51
+ result[key] = obj[key];
52
+ });
53
+ return result;
54
+ };
55
+ var getObject = (obj, path, fallback, i) => {
56
+ const k = typeof path === "string" ? path.split(".") : [path];
57
+ for (i = 0; i < k.length; i += 1) {
58
+ if (!obj)
59
+ break;
60
+ obj = obj[k[i]];
61
+ }
62
+ return obj === void 0 ? fallback : obj;
63
+ };
64
+ var memoizeObject = (func) => {
65
+ const cache = /* @__PURE__ */ new WeakMap();
66
+ const memoizedFunc = (obj, path, fallback, i) => {
67
+ if (typeof obj === "undefined")
68
+ return func(obj, path, fallback);
69
+ if (!cache.has(obj))
70
+ cache.set(obj, /* @__PURE__ */ new Map());
71
+ const map = cache.get(obj);
72
+ if (map.has(path))
73
+ return map.get(path);
74
+ const value = func(obj, path, fallback, i);
75
+ map.set(path, value);
76
+ return value;
77
+ };
78
+ return memoizedFunc;
79
+ };
80
+ var getMemoizedObject = memoizeObject(getObject);
81
+
82
+ // src/use-color-picker.ts
83
+ var convertHsla = (value, fallback) => {
84
+ var _a;
85
+ let [h, s, l, a] = (_a = (0, import_utils.parseToHsla)(value, fallback)) != null ? _a : [0, 0, 1, 1];
86
+ if (a > 1)
87
+ a = 1;
88
+ return { h, s, l, a };
89
+ };
90
+ var convertRgba = (value, fallback) => {
91
+ var _a;
92
+ let [r, g, b, a] = (_a = (0, import_utils.parseToRgba)(value, fallback)) != null ? _a : [255, 255, 255, 1];
93
+ if (r > 255)
94
+ r = 255;
95
+ if (g > 255)
96
+ g = 255;
97
+ if (b > 255)
98
+ b = 255;
99
+ if (a > 1)
100
+ a = 1;
101
+ return { r, g, b, a };
102
+ };
103
+ var convertHsva = (value, fallback) => {
104
+ const [h, s, v, a] = (0, import_utils.parseToHsv)(value, fallback);
105
+ return { h, s, v, a };
106
+ };
107
+ var [ColorPickerProvider, useColorPickerContext] = (0, import_utils.createContext)({
108
+ name: "ColorPickerContext",
109
+ errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in "<ColorPicker />"`
110
+ });
111
+ var useColorPicker = ({
112
+ isInvalid,
113
+ ...props
114
+ }) => {
115
+ var _a;
116
+ let {
117
+ id,
118
+ name,
119
+ value: valueProp,
120
+ defaultValue,
121
+ fallbackValue,
122
+ onChange: onChangeProp,
123
+ onChangeStart: onChangeStartProp,
124
+ onChangeEnd: onChangeEndProp,
125
+ format,
126
+ required,
127
+ disabled,
128
+ readOnly,
129
+ onSwatchClick,
130
+ ...rest
131
+ } = (0, import_form_control.useFormControlProps)({ isInvalid, ...props });
132
+ const onChangeStartRef = (0, import_utils.useCallbackRef)(onChangeStartProp);
133
+ const onChangeEndRef = (0, import_utils.useCallbackRef)(onChangeEndProp);
134
+ const { supported: eyeDropperSupported, onOpen } = (0, import_use_eye_dropper.useEyeDropper)();
135
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
136
+ value: valueProp,
137
+ defaultValue: (_a = defaultValue != null ? defaultValue : fallbackValue) != null ? _a : "#ffffffff",
138
+ onChange: onChangeProp
139
+ });
140
+ const timeoutId = (0, import_react.useRef)(void 0);
141
+ const formatRef = (0, import_react.useRef)(format != null ? format : (0, import_utils.calcFormat)(value));
142
+ const isDraggingRef = (0, import_react.useRef)(false);
143
+ const [parsedValue, setParsedValue] = (0, import_react.useState)(
144
+ convertHsva(value, fallbackValue)
145
+ );
146
+ const { h, s, v, a } = parsedValue;
147
+ const withAlpha = formatRef.current.endsWith("a");
148
+ const isInteractive = !(disabled || readOnly);
149
+ const channels = (0, import_react.useMemo)(() => {
150
+ if (value.startsWith("hsl")) {
151
+ const { h: h2, s: s2, l, a: a2 } = convertHsla(value, fallbackValue);
152
+ let channels2 = [
153
+ { label: "H", space: "h", value: Math.round(h2), min: 0, max: 360 },
154
+ {
155
+ label: "S(%)",
156
+ space: "s",
157
+ value: Math.round(s2 * 100),
158
+ min: 0,
159
+ max: 100
160
+ },
161
+ {
162
+ label: "L(%)",
163
+ space: "l",
164
+ value: Math.round(l * 100),
165
+ min: 0,
166
+ max: 100
167
+ }
168
+ ];
169
+ if (withAlpha) {
170
+ channels2 = [
171
+ ...channels2,
172
+ {
173
+ label: "A(%)",
174
+ space: "a",
175
+ value: Math.round(a2 * 100),
176
+ min: 0,
177
+ max: 100
178
+ }
179
+ ];
180
+ }
181
+ return channels2;
182
+ } else {
183
+ const { r, g, b, a: a2 } = convertRgba(value, fallbackValue);
184
+ let channels2 = [
185
+ { label: "R", space: "r", value: Math.round(r), min: 0, max: 255 },
186
+ { label: "G", space: "g", value: Math.round(g), min: 0, max: 255 },
187
+ { label: "B", space: "b", value: Math.round(b), min: 0, max: 255 }
188
+ ];
189
+ if (withAlpha) {
190
+ channels2 = [
191
+ ...channels2,
192
+ {
193
+ label: "A(%)",
194
+ space: "a",
195
+ value: Math.round(a2 * 100),
196
+ min: 0,
197
+ max: 100
198
+ }
199
+ ];
200
+ }
201
+ return channels2;
202
+ }
203
+ }, [value, withAlpha, fallbackValue]);
204
+ const onChange = (0, import_react.useCallback)(
205
+ (value2) => {
206
+ if ((0, import_utils.isString)(value2)) {
207
+ setParsedValue(convertHsva(value2, fallbackValue));
208
+ } else {
209
+ setParsedValue((prev) => ({ ...prev, ...value2 }));
210
+ }
211
+ },
212
+ [fallbackValue]
213
+ );
214
+ const onChangeStart = (0, import_react.useCallback)(
215
+ (value2) => {
216
+ window.clearTimeout(timeoutId.current);
217
+ isDraggingRef.current = true;
218
+ const { h: h2, s: s2, v: v2, a: a2 } = { ...parsedValue, ...value2 };
219
+ const nextValue = (0, import_utils.hsvTo)([h2, s2, v2, a2], fallbackValue)(formatRef.current);
220
+ if (nextValue)
221
+ onChangeStartRef(nextValue);
222
+ },
223
+ [formatRef, onChangeStartRef, fallbackValue, parsedValue]
224
+ );
225
+ const onChangeEnd = (0, import_react.useCallback)(
226
+ (value2) => {
227
+ window.clearTimeout(timeoutId.current);
228
+ timeoutId.current = window.setTimeout(() => {
229
+ isDraggingRef.current = false;
230
+ }, 200);
231
+ let nextValue;
232
+ if ((0, import_utils.isString)(value2)) {
233
+ nextValue = (0, import_utils.convertColor)(value2, fallbackValue)(formatRef.current);
234
+ } else {
235
+ const { h: h2, s: s2, v: v2, a: a2 } = { ...parsedValue, ...value2 };
236
+ nextValue = (0, import_utils.hsvTo)([h2, s2, v2, a2], fallbackValue)(formatRef.current);
237
+ }
238
+ if (nextValue)
239
+ onChangeEndRef(nextValue);
240
+ },
241
+ [formatRef, onChangeEndRef, fallbackValue, parsedValue]
242
+ );
243
+ const onChannelChange = (0, import_react.useCallback)(
244
+ (ev, space) => {
245
+ let n = Math.floor(parseFloat(ev.target.value));
246
+ if (isNaN(n))
247
+ n = 0;
248
+ if (["s", "l", "a"].includes(space))
249
+ n = n / 100;
250
+ let nextValue;
251
+ if (value.startsWith("hsl")) {
252
+ const { h: h2, s: s2, l, a: a2 } = Object.assign(
253
+ convertHsla(value, fallbackValue),
254
+ { [space]: n }
255
+ );
256
+ nextValue = (0, import_utils.hslaTo)([h2, s2, l, a2], fallbackValue)(formatRef.current);
257
+ } else {
258
+ const { r, g, b, a: a2 } = Object.assign(
259
+ convertRgba(value, fallbackValue),
260
+ { [space]: n }
261
+ );
262
+ nextValue = (0, import_utils.rgbaTo)([r, g, b, a2], fallbackValue)(formatRef.current);
263
+ }
264
+ if (!nextValue)
265
+ return;
266
+ onChange(nextValue);
267
+ onChangeEnd(nextValue);
268
+ },
269
+ [value, onChange, onChangeEnd, formatRef, fallbackValue]
270
+ );
271
+ const onEyeDropperClick = (0, import_react.useCallback)(async () => {
272
+ var _a2;
273
+ try {
274
+ const { sRGBHex } = (_a2 = await onOpen()) != null ? _a2 : {};
275
+ if (!sRGBHex)
276
+ return;
277
+ onChange(sRGBHex);
278
+ onChangeEnd(sRGBHex);
279
+ } catch {
280
+ }
281
+ }, [onOpen, onChange, onChangeEnd]);
282
+ (0, import_utils.useUpdateEffect)(() => {
283
+ const value2 = (0, import_utils.hsvTo)([h, s, v, a], fallbackValue)(formatRef.current);
284
+ if (value2)
285
+ setValue(value2);
286
+ }, [h, s, v, a, fallbackValue]);
287
+ (0, import_utils.useUpdateEffect)(() => {
288
+ if (isDraggingRef.current)
289
+ return;
290
+ if (valueProp)
291
+ setParsedValue(convertHsva(valueProp, fallbackValue));
292
+ }, [valueProp]);
293
+ (0, import_utils.useUpdateEffect)(() => {
294
+ if (!format)
295
+ return;
296
+ formatRef.current = format;
297
+ const nextValue = (0, import_utils.convertColor)(value, fallbackValue)(format);
298
+ if (nextValue)
299
+ setValue(nextValue);
300
+ }, [format, fallbackValue]);
301
+ const getContainerProps = (props2 = {}, ref = null) => ({
302
+ ...props2,
303
+ ref,
304
+ ...(0, import_utils.omitObject)(rest, ["aria-readonly"])
305
+ });
306
+ const getInputProps = (0, import_react.useCallback)(
307
+ (props2 = {}, ref = null) => ({
308
+ ...pickObject(rest, import_form_control.formControlProperties),
309
+ ...props2,
310
+ id,
311
+ ref,
312
+ type: "hidden",
313
+ name,
314
+ value,
315
+ required,
316
+ disabled,
317
+ readOnly
318
+ }),
319
+ [disabled, id, name, readOnly, required, rest, value]
320
+ );
321
+ const getSaturationSliderProps = (0, import_react.useCallback)(
322
+ (props2 = {}, ref = null) => ({
323
+ required,
324
+ disabled,
325
+ readOnly,
326
+ isInvalid,
327
+ ...props2,
328
+ ref,
329
+ value: [h, s, v],
330
+ onChange: (0, import_utils.handlerAll)(props2.onChange, ([, s2, v2]) => onChange({ s: s2, v: v2 })),
331
+ onChangeStart: (0, import_utils.handlerAll)(
332
+ props2.onChangeStart,
333
+ ([, s2, v2]) => onChangeStart({ s: s2, v: v2 })
334
+ ),
335
+ onChangeEnd: (0, import_utils.handlerAll)(
336
+ props2.onChangeEnd,
337
+ ([, s2, v2]) => onChangeEnd({ s: s2, v: v2 })
338
+ )
339
+ }),
340
+ [
341
+ required,
342
+ disabled,
343
+ readOnly,
344
+ isInvalid,
345
+ h,
346
+ s,
347
+ v,
348
+ onChange,
349
+ onChangeStart,
350
+ onChangeEnd
351
+ ]
352
+ );
353
+ const getHueSliderProps = (0, import_react.useCallback)(
354
+ (props2 = {}, ref = null) => ({
355
+ required,
356
+ disabled,
357
+ readOnly,
358
+ isInvalid,
359
+ ...props2,
360
+ ref,
361
+ value: h,
362
+ onChange: (0, import_utils.handlerAll)(props2.onChange, (h2) => onChange({ h: h2 })),
363
+ onChangeStart: (0, import_utils.handlerAll)(
364
+ props2.onChangeStart,
365
+ (h2) => onChangeStart({ h: h2 })
366
+ ),
367
+ onChangeEnd: (0, import_utils.handlerAll)(props2.onChangeEnd, (h2) => onChangeEnd({ h: h2 }))
368
+ }),
369
+ [
370
+ required,
371
+ disabled,
372
+ readOnly,
373
+ isInvalid,
374
+ h,
375
+ onChange,
376
+ onChangeStart,
377
+ onChangeEnd
378
+ ]
379
+ );
380
+ const getAlphaSliderProps = (0, import_react.useCallback)(
381
+ (props2 = {}, ref = null) => ({
382
+ required,
383
+ disabled,
384
+ readOnly,
385
+ isInvalid,
386
+ ...props2,
387
+ ref,
388
+ value: a,
389
+ color: (0, import_utils.hsvTo)([h, s, v, a], fallbackValue)(formatRef.current),
390
+ onChange: (0, import_utils.handlerAll)(props2.onChange, (a2) => onChange({ a: a2 })),
391
+ onChangeStart: (0, import_utils.handlerAll)(
392
+ props2.onChangeStart,
393
+ (a2) => onChangeStart({ a: a2 })
394
+ ),
395
+ onChangeEnd: (0, import_utils.handlerAll)(props2.onChangeEnd, (a2) => onChangeEnd({ a: a2 }))
396
+ }),
397
+ [
398
+ fallbackValue,
399
+ required,
400
+ disabled,
401
+ readOnly,
402
+ isInvalid,
403
+ formatRef,
404
+ h,
405
+ s,
406
+ v,
407
+ a,
408
+ onChange,
409
+ onChangeStart,
410
+ onChangeEnd
411
+ ]
412
+ );
413
+ const getChannelProps = (0, import_react.useCallback)(
414
+ ({ space, ...props2 }, ref = null) => {
415
+ return {
416
+ required,
417
+ disabled,
418
+ readOnly,
419
+ isInvalid,
420
+ ...props2,
421
+ ref,
422
+ type: "number",
423
+ step: 1,
424
+ onChange: (0, import_utils.handlerAll)(
425
+ props2.onChange,
426
+ (ev) => onChannelChange(ev, space)
427
+ )
428
+ };
429
+ },
430
+ [required, disabled, readOnly, isInvalid, onChannelChange]
431
+ );
432
+ const getEyeDropperProps = (0, import_react.useCallback)(
433
+ (props2 = {}, ref = null) => ({
434
+ disabled,
435
+ "aria-label": "Pick a color",
436
+ ...props2,
437
+ ref,
438
+ onClick: (0, import_utils.handlerAll)(props2.onClick, onEyeDropperClick)
439
+ }),
440
+ [disabled, onEyeDropperClick]
441
+ );
442
+ const getSwatchProps = (0, import_react.useCallback)(
443
+ ({ color, ...props2 } = {}, ref = null) => ({
444
+ "aria-label": `select ${color} as the color`,
445
+ disabled,
446
+ readOnly,
447
+ ...props2,
448
+ ref,
449
+ color,
450
+ onClick: (0, import_utils.handlerAll)(props2.onClick, () => {
451
+ if (!color)
452
+ return;
453
+ onSwatchClick == null ? void 0 : onSwatchClick(color);
454
+ onChange(color);
455
+ onChangeEnd(color);
456
+ })
457
+ }),
458
+ [disabled, readOnly, onSwatchClick, onChange, onChangeEnd]
459
+ );
460
+ return {
461
+ value,
462
+ onChange,
463
+ eyeDropperSupported,
464
+ withAlpha,
465
+ isInteractive,
466
+ disabled,
467
+ readOnly,
468
+ channels,
469
+ getContainerProps,
470
+ getInputProps,
471
+ getSaturationSliderProps,
472
+ getHueSliderProps,
473
+ getAlphaSliderProps,
474
+ getEyeDropperProps,
475
+ getChannelProps,
476
+ getSwatchProps
477
+ };
478
+ };
479
+
480
+ // src/color-picker-eye-dropper.tsx
481
+ var import_jsx_runtime = require("react/jsx-runtime");
482
+ var ColorPickerEyeDropper = (0, import_core.forwardRef)(({ className, ...rest }, ref) => {
483
+ const { getEyeDropperProps, readOnly, size, styles } = useColorPickerContext();
484
+ const css = {
485
+ h: "auto",
486
+ minW: "auto",
487
+ pointerEvents: readOnly ? "none" : void 0,
488
+ ...styles.eyeDropper
489
+ };
490
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
491
+ import_button.IconButton,
492
+ {
493
+ className: (0, import_utils2.cx)("ui-color-picker__eye-dropper", className),
494
+ variant: "outline",
495
+ size,
496
+ __css: css,
497
+ ...getEyeDropperProps(rest, ref),
498
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EyeDropperIcon, { className: "ui-color-picker__eye-dropper__icon" })
499
+ }
500
+ );
501
+ });
502
+ var EyeDropperIcon = ({ ...rest }) => {
503
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
504
+ import_icon.Icon,
505
+ {
506
+ viewBox: "0 0 24 24",
507
+ fill: "none",
508
+ stroke: "currentColor",
509
+ strokeWidth: "2",
510
+ strokeLinecap: "round",
511
+ strokeLinejoin: "round",
512
+ ...rest,
513
+ children: [
514
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m2 22 1-1h3l9-9" }),
515
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 21v-3l9-9" }),
516
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z" })
517
+ ]
518
+ }
519
+ );
520
+ };
521
+
522
+ // src/color-picker-sliders.tsx
523
+ var import_core4 = require("@yamada-ui/core");
524
+ var import_utils6 = require("@yamada-ui/utils");
525
+
526
+ // src/alpha-slider.tsx
527
+ var import_core2 = require("@yamada-ui/core");
528
+ var import_utils4 = require("@yamada-ui/utils");
529
+
530
+ // src/use-color-slider.ts
531
+ var import_form_control2 = require("@yamada-ui/form-control");
532
+ var import_use_controllable_state2 = require("@yamada-ui/use-controllable-state");
533
+ var import_use_latest_ref = require("@yamada-ui/use-latest-ref");
534
+ var import_use_pan_event = require("@yamada-ui/use-pan-event");
535
+ var import_use_size = require("@yamada-ui/use-size");
536
+ var import_utils3 = require("@yamada-ui/utils");
537
+ var import_react2 = require("react");
538
+ var useColorSlider = ({
539
+ focusThumbOnChange = true,
540
+ ...props
541
+ }) => {
542
+ if (!focusThumbOnChange)
543
+ props.isReadOnly = true;
544
+ let {
545
+ id,
546
+ name,
547
+ value: valueProp,
548
+ defaultValue,
549
+ min = 0,
550
+ max,
551
+ step = 1,
552
+ onChange: onChangeProp,
553
+ onChangeStart: onChangeStartProp,
554
+ onChangeEnd: onChangeEndProp,
555
+ thumbColor,
556
+ required,
557
+ disabled,
558
+ readOnly,
559
+ ...rest
560
+ } = (0, import_form_control2.useFormControlProps)(props);
561
+ const onChangeStart = (0, import_utils3.useCallbackRef)(onChangeStartProp);
562
+ const onChangeEnd = (0, import_utils3.useCallbackRef)(onChangeEndProp);
563
+ const [computedValue, setValue] = (0, import_use_controllable_state2.useControllableState)({
564
+ value: valueProp,
565
+ defaultValue: defaultValue != null ? defaultValue : min + (max - min) / 2,
566
+ onChange: onChangeProp
567
+ });
568
+ const value = (0, import_utils3.clampNumber)(computedValue, min, max);
569
+ const thumbPercent = (0, import_utils3.valueToPercent)(value, min, max);
570
+ const [isDragging, setDragging] = (0, import_react2.useState)(false);
571
+ const isInteractive = !(disabled || readOnly);
572
+ const oneStep = step || (max - min) / 100;
573
+ const tenStep = (max - min) / 10;
574
+ const containerRef = (0, import_react2.useRef)(null);
575
+ const trackRef = (0, import_react2.useRef)(null);
576
+ const thumbRef = (0, import_react2.useRef)(null);
577
+ const latestRef = (0, import_use_latest_ref.useLatestRef)({
578
+ value,
579
+ min,
580
+ max,
581
+ step,
582
+ isInteractive,
583
+ eventSource: null,
584
+ focusThumbOnChange
585
+ });
586
+ const thumbSize = (0, import_use_size.useSize)(thumbRef);
587
+ const getValueFromPointer = (0, import_react2.useCallback)(
588
+ (ev) => {
589
+ var _a, _b;
590
+ if (!trackRef.current)
591
+ return;
592
+ const { min: min2, max: max2, step: step2 } = latestRef.current;
593
+ latestRef.current.eventSource = "pointer";
594
+ const { left, width } = trackRef.current.getBoundingClientRect();
595
+ const { clientX } = (_b = (_a = ev.touches) == null ? void 0 : _a[0]) != null ? _b : ev;
596
+ let percent = (clientX - left) / width;
597
+ let nextValue = (0, import_utils3.percentToValue)(percent, min2, max2);
598
+ if (step2)
599
+ nextValue = parseFloat((0, import_utils3.roundNumberToStep)(nextValue, min2, step2));
600
+ nextValue = (0, import_utils3.clampNumber)(nextValue, min2, max2);
601
+ return nextValue;
602
+ },
603
+ [latestRef]
604
+ );
605
+ const setValueFromPointer = (ev) => {
606
+ const { value: value2 } = latestRef.current;
607
+ const nextValue = getValueFromPointer(ev);
608
+ if (nextValue != null && nextValue !== value2)
609
+ setValue(nextValue);
610
+ };
611
+ const focusThumb = (0, import_react2.useCallback)(() => {
612
+ const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
613
+ if (focusThumbOnChange2)
614
+ setTimeout(() => {
615
+ var _a;
616
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
617
+ });
618
+ }, [latestRef]);
619
+ const constrain = (0, import_react2.useCallback)(
620
+ (value2) => {
621
+ const { isInteractive: isInteractive2, min: min2, max: max2 } = latestRef.current;
622
+ if (!isInteractive2)
623
+ return;
624
+ value2 = parseFloat((0, import_utils3.roundNumberToStep)(value2, min2, oneStep));
625
+ value2 = (0, import_utils3.clampNumber)(value2, min2, max2);
626
+ setValue(value2);
627
+ },
628
+ [setValue, latestRef, oneStep]
629
+ );
630
+ const stepUp = (0, import_react2.useCallback)(
631
+ (step2 = oneStep) => constrain(value + step2),
632
+ [constrain, value, oneStep]
633
+ );
634
+ const stepDown = (0, import_react2.useCallback)(
635
+ (step2 = oneStep) => constrain(value - step2),
636
+ [constrain, value, oneStep]
637
+ );
638
+ const onKeyDown = (0, import_react2.useCallback)(
639
+ (ev) => {
640
+ const { min: min2, max: max2 } = latestRef.current;
641
+ const actions = {
642
+ ArrowRight: () => stepUp(),
643
+ ArrowUp: () => stepUp(),
644
+ ArrowLeft: () => stepDown(),
645
+ ArrowDown: () => stepDown(),
646
+ PageUp: () => stepUp(tenStep),
647
+ PageDown: () => stepDown(tenStep),
648
+ Home: () => constrain(min2),
649
+ End: () => constrain(max2)
650
+ };
651
+ const action = actions[ev.key];
652
+ if (!action)
653
+ return;
654
+ ev.preventDefault();
655
+ ev.stopPropagation();
656
+ action(ev);
657
+ latestRef.current.eventSource = "keyboard";
658
+ },
659
+ [constrain, latestRef, stepDown, stepUp, tenStep]
660
+ );
661
+ (0, import_use_pan_event.usePanEvent)(containerRef, {
662
+ onSessionStart: (ev) => {
663
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
664
+ if (!isInteractive2)
665
+ return;
666
+ setDragging(true);
667
+ focusThumb();
668
+ setValueFromPointer(ev);
669
+ onChangeStart(value2);
670
+ },
671
+ onSessionEnd: () => {
672
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
673
+ if (!isInteractive2)
674
+ return;
675
+ setDragging(false);
676
+ onChangeEnd(value2);
677
+ },
678
+ onMove: (ev) => {
679
+ const { isInteractive: isInteractive2 } = latestRef.current;
680
+ if (!isInteractive2)
681
+ return;
682
+ setValueFromPointer(ev);
683
+ }
684
+ });
685
+ (0, import_utils3.useUpdateEffect)(() => {
686
+ const { eventSource, value: value2 } = latestRef.current;
687
+ if (eventSource === "keyboard")
688
+ onChangeEnd(value2);
689
+ }, [value, onChangeEnd]);
690
+ const getContainerProps = (0, import_react2.useCallback)(
691
+ (props2 = {}, ref = null) => {
692
+ const { width: w } = thumbSize != null ? thumbSize : { width: 0 };
693
+ const style = {
694
+ ...props2.style,
695
+ ...rest.style,
696
+ paddingInline: `${w / 2}px`
697
+ };
698
+ return {
699
+ ...props2,
700
+ ...(0, import_utils3.omitObject)(rest, ["aria-readonly"]),
701
+ ref: (0, import_utils3.mergeRefs)(ref, containerRef),
702
+ tabIndex: -1,
703
+ style
704
+ };
705
+ },
706
+ [rest, thumbSize]
707
+ );
708
+ const getInputProps = (0, import_react2.useCallback)(
709
+ (props2 = {}, ref = null) => ({
710
+ ...pickObject(rest, import_form_control2.formControlProperties),
711
+ ...props2,
712
+ id,
713
+ ref,
714
+ type: "hidden",
715
+ name,
716
+ value,
717
+ required,
718
+ disabled,
719
+ readOnly
720
+ }),
721
+ [disabled, id, name, readOnly, required, rest, value]
722
+ );
723
+ const getTrackProps = (0, import_react2.useCallback)(
724
+ (props2 = {}, ref = null) => ({
725
+ ...pickObject(
726
+ rest,
727
+ (0, import_form_control2.getFormControlProperties)({ omit: ["aria-readonly"] })
728
+ ),
729
+ ...props2,
730
+ ref: (0, import_utils3.mergeRefs)(ref, trackRef)
731
+ }),
732
+ [rest]
733
+ );
734
+ const getThumbProps = (0, import_react2.useCallback)(
735
+ (props2 = {}, ref = null) => {
736
+ const n = thumbPercent;
737
+ const { width: w } = thumbSize != null ? thumbSize : { width: 0 };
738
+ const style = {
739
+ ...props2.style,
740
+ position: "absolute",
741
+ userSelect: "none",
742
+ touchAction: "none",
743
+ left: `calc(${n}% - ${w / 2}px)`
744
+ };
745
+ return {
746
+ "aria-label": "Slider thumb",
747
+ bg: thumbColor != null ? thumbColor : `hsl(${value}, 100%, 50%)`,
748
+ ...pickObject(rest, import_form_control2.formControlProperties),
749
+ ...props2,
750
+ ref: (0, import_utils3.mergeRefs)(ref, thumbRef),
751
+ tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
752
+ role: "slider",
753
+ "aria-valuenow": value,
754
+ "aria-valuemin": min,
755
+ "aria-valuemax": max,
756
+ "data-active": (0, import_utils3.dataAttr)(isDragging && focusThumbOnChange),
757
+ onKeyDown: (0, import_utils3.handlerAll)(props2.onKeyDown, onKeyDown),
758
+ onFocus: (0, import_utils3.handlerAll)(props2.onFocus, rest.onFocus),
759
+ onBlur: (0, import_utils3.handlerAll)(props2.onBlur, rest.onBlur),
760
+ style
761
+ };
762
+ },
763
+ [
764
+ thumbColor,
765
+ focusThumbOnChange,
766
+ isDragging,
767
+ isInteractive,
768
+ min,
769
+ max,
770
+ onKeyDown,
771
+ rest,
772
+ thumbPercent,
773
+ thumbSize,
774
+ value
775
+ ]
776
+ );
777
+ return {
778
+ value,
779
+ getContainerProps,
780
+ getTrackProps,
781
+ getInputProps,
782
+ getThumbProps
783
+ };
784
+ };
785
+
786
+ // src/alpha-slider.tsx
787
+ var import_jsx_runtime2 = require("react/jsx-runtime");
788
+ var defaultOverlays = (color, min, max, withShadow) => {
789
+ let overlays = [
790
+ {
791
+ bgImage: "linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)",
792
+ bgSize: `8px 8px`,
793
+ bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,
794
+ var: [
795
+ {
796
+ name: "checkers",
797
+ token: "colors",
798
+ value: ["blackAlpha.300", "whiteAlpha.300"]
799
+ },
800
+ {
801
+ name: "body",
802
+ token: "colors",
803
+ value: ["whiteAlpha.500", "blackAlpha.500"]
804
+ }
805
+ ]
806
+ },
807
+ {
808
+ bgGradient: `linear(to-r, ${(0, import_utils4.convertColor)(color)("hex") + (0, import_utils4.alphaToHex)(min)}, ${(0, import_utils4.convertColor)(color)("hex") + (0, import_utils4.alphaToHex)(max)})`
809
+ }
810
+ ];
811
+ if (withShadow)
812
+ overlays = [
813
+ ...overlays,
814
+ {
815
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
816
+ }
817
+ ];
818
+ return overlays;
819
+ };
820
+ var AlphaSlider = (0, import_core2.forwardRef)(
821
+ (props, ref) => {
822
+ const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("AlphaSlider", props);
823
+ const {
824
+ className,
825
+ inputProps,
826
+ trackProps,
827
+ thumbProps,
828
+ color = "#ffffff",
829
+ min = 0,
830
+ max = 1,
831
+ withShadow = true,
832
+ overlays = defaultOverlays(color, min, max, withShadow),
833
+ __css,
834
+ ...computedProps
835
+ } = (0, import_core2.omitThemeProps)(mergedProps);
836
+ const { getContainerProps, getTrackProps, getInputProps, getThumbProps } = useColorSlider({
837
+ min,
838
+ max,
839
+ step: 0.01,
840
+ thumbColor: "transparent",
841
+ ...computedProps
842
+ });
843
+ const css = {
844
+ position: "relative",
845
+ ...styles.container,
846
+ ...__css
847
+ };
848
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
849
+ import_core2.ui.div,
850
+ {
851
+ className: (0, import_utils4.cx)("ui-alpha-slider", className),
852
+ __css: css,
853
+ ...getContainerProps(),
854
+ children: [
855
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.input, { ...getInputProps(inputProps, ref) }),
856
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
857
+ import_core2.ui.div,
858
+ {
859
+ className: "ui-alpha-slider__overlay",
860
+ __css: {
861
+ position: "absolute",
862
+ top: 0,
863
+ left: 0,
864
+ right: 0,
865
+ bottom: 0,
866
+ ...styles.overlay
867
+ },
868
+ ...props2
869
+ },
870
+ index
871
+ )),
872
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
873
+ import_core2.ui.div,
874
+ {
875
+ className: "ui-alpha-slider__track",
876
+ __css: {
877
+ position: "relative",
878
+ w: "full",
879
+ h: "full",
880
+ ...styles.track
881
+ },
882
+ ...getTrackProps(trackProps),
883
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
884
+ import_core2.ui.div,
885
+ {
886
+ className: "ui-alpha-slider__thumb",
887
+ __css: { ...styles.thumb },
888
+ ...getThumbProps(thumbProps)
889
+ }
890
+ )
891
+ }
892
+ )
893
+ ]
894
+ }
895
+ );
896
+ }
897
+ );
898
+
899
+ // src/hue-slider.tsx
900
+ var import_core3 = require("@yamada-ui/core");
901
+ var import_utils5 = require("@yamada-ui/utils");
902
+ var import_jsx_runtime3 = require("react/jsx-runtime");
903
+ var defaultOverlays2 = (min, max, withShadow) => {
904
+ let overlays = [
905
+ {
906
+ bgGradient: `linear(to-r, ${[...Array(7)].map(
907
+ (_, index) => `hsl(${Math.round(min + (max - min) / 6 * index)}, 100%, 50%)`
908
+ ).join(", ")})`
909
+ }
910
+ ];
911
+ if (withShadow)
912
+ overlays = [
913
+ ...overlays,
914
+ {
915
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
916
+ }
917
+ ];
918
+ return overlays;
919
+ };
920
+ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
921
+ const [styles, mergedProps] = (0, import_core3.useMultiComponentStyle)("HueSlider", props);
922
+ const {
923
+ className,
924
+ inputProps,
925
+ trackProps,
926
+ thumbProps,
927
+ min = 0,
928
+ max = 360,
929
+ withShadow = true,
930
+ overlays = defaultOverlays2(min, max, withShadow),
931
+ __css,
932
+ ...computedProps
933
+ } = (0, import_core3.omitThemeProps)(mergedProps);
934
+ const { getContainerProps, getTrackProps, getInputProps, getThumbProps } = useColorSlider({ min, max, step: 1, ...computedProps });
935
+ const css = {
936
+ position: "relative",
937
+ ...styles.container,
938
+ ...__css
939
+ };
940
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
941
+ import_core3.ui.div,
942
+ {
943
+ className: (0, import_utils5.cx)("ui-hue-slider", className),
944
+ __css: css,
945
+ ...getContainerProps(),
946
+ children: [
947
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.input, { ...getInputProps(inputProps, ref) }),
948
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
949
+ import_core3.ui.div,
950
+ {
951
+ className: "ui-hue-slider__overlay",
952
+ __css: {
953
+ position: "absolute",
954
+ top: 0,
955
+ left: 0,
956
+ right: 0,
957
+ bottom: 0,
958
+ ...styles.overlay
959
+ },
960
+ ...props2
961
+ },
962
+ index
963
+ )),
964
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
965
+ import_core3.ui.div,
966
+ {
967
+ className: "ui-hue-slider__track",
968
+ __css: { position: "relative", w: "full", h: "full", ...styles.track },
969
+ ...getTrackProps(trackProps),
970
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
971
+ import_core3.ui.div,
972
+ {
973
+ className: "ui-hue-slider__thumb",
974
+ __css: { ...styles.thumb },
975
+ ...getThumbProps(thumbProps)
976
+ }
977
+ )
978
+ }
979
+ )
980
+ ]
981
+ }
982
+ );
983
+ });
984
+
985
+ // src/color-picker-sliders.tsx
986
+ var import_jsx_runtime4 = require("react/jsx-runtime");
987
+ var ColorPickerSliders = (0, import_core4.forwardRef)(
988
+ ({
989
+ className,
990
+ hueSliderRef,
991
+ hueSliderProps,
992
+ alphaSliderRef,
993
+ alphaSliderProps,
994
+ ...rest
995
+ }, ref) => {
996
+ let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } = useColorPickerContext();
997
+ if (size === "full")
998
+ size = "lg";
999
+ const css = {
1000
+ display: "flex",
1001
+ flexDirection: "column",
1002
+ ...styles.sliders
1003
+ };
1004
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
1005
+ import_core4.ui.div,
1006
+ {
1007
+ ref,
1008
+ className: (0, import_utils6.cx)("ui-color-picker__sliders", className),
1009
+ __css: css,
1010
+ ...rest,
1011
+ children: [
1012
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1013
+ HueSlider,
1014
+ {
1015
+ size,
1016
+ className: "ui-color-picker__hue-slider",
1017
+ __css: { ...styles.hueSlider },
1018
+ ...getHueSliderProps(hueSliderProps, hueSliderRef)
1019
+ }
1020
+ ),
1021
+ withAlpha ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1022
+ AlphaSlider,
1023
+ {
1024
+ size,
1025
+ className: "ui-color-picker__alpha-slider",
1026
+ __css: { ...styles.alphaSlider },
1027
+ ...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)
1028
+ }
1029
+ ) : null
1030
+ ]
1031
+ }
1032
+ );
1033
+ }
1034
+ );
1035
+
1036
+ // src/color-swatch.tsx
1037
+ var import_core5 = require("@yamada-ui/core");
1038
+ var import_utils7 = require("@yamada-ui/utils");
1039
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1040
+ var defaultOverlays3 = (background, withShadow) => {
1041
+ let overlays = [
1042
+ {
1043
+ bgImage: "linear-gradient(45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(-45deg, var(--ui-checkers) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--ui-checkers) 75%), linear-gradient(-45deg, var(--ui-body) 75%, var(--ui-checkers) 75%)",
1044
+ bgSize: `8px 8px`,
1045
+ bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,
1046
+ var: [
1047
+ {
1048
+ name: "checkers",
1049
+ token: "colors",
1050
+ value: ["blackAlpha.300", "whiteAlpha.300"]
1051
+ },
1052
+ {
1053
+ name: "body",
1054
+ token: "colors",
1055
+ value: ["whiteAlpha.500", "blackAlpha.500"]
1056
+ }
1057
+ ]
1058
+ },
1059
+ { background }
1060
+ ];
1061
+ if (withShadow)
1062
+ overlays = [
1063
+ ...overlays,
1064
+ {
1065
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
1066
+ }
1067
+ ];
1068
+ return overlays;
1069
+ };
1070
+ var ColorSwatch = (0, import_core5.forwardRef)((props, ref) => {
1071
+ const [styles, mergedProps] = (0, import_core5.useMultiComponentStyle)("ColorSwatch", props);
1072
+ const {
1073
+ className,
1074
+ color = "#ffffff00",
1075
+ withShadow = true,
1076
+ overlays = defaultOverlays3(color, withShadow),
1077
+ isRounded,
1078
+ __css,
1079
+ ...rest
1080
+ } = (0, import_core5.omitThemeProps)(mergedProps);
1081
+ const css = {
1082
+ position: "relative",
1083
+ _before: {
1084
+ content: `""`,
1085
+ display: "block",
1086
+ h: 0,
1087
+ pb: "100%"
1088
+ },
1089
+ "& > *": {
1090
+ overflow: "hidden",
1091
+ position: "absolute",
1092
+ top: "0",
1093
+ right: "0",
1094
+ bottom: "0",
1095
+ left: "0",
1096
+ display: "flex",
1097
+ justifyContent: "center",
1098
+ alignItems: "center",
1099
+ w: "100%",
1100
+ h: "100%"
1101
+ },
1102
+ ...styles.container,
1103
+ ...__css
1104
+ };
1105
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1106
+ import_core5.ui.div,
1107
+ {
1108
+ ref,
1109
+ className: (0, import_utils7.cx)("ui-color-swatch", className),
1110
+ ...isRounded ? { rounded: "full" } : {},
1111
+ __css: css,
1112
+ ...rest,
1113
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.div, { ...isRounded ? { rounded: "full" } : {}, children: overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1114
+ import_core5.ui.div,
1115
+ {
1116
+ __css: {
1117
+ position: "absolute",
1118
+ top: 0,
1119
+ left: 0,
1120
+ right: 0,
1121
+ bottom: 0,
1122
+ ...styles.overlay
1123
+ },
1124
+ ...isRounded ? { rounded: "full" } : {},
1125
+ ...props2
1126
+ },
1127
+ index
1128
+ )) })
1129
+ }
1130
+ );
1131
+ });
1132
+
1133
+ // src/color-picker-body.tsx
1134
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1135
+ var ColorPickerBody = (0, import_core6.forwardRef)(
1136
+ ({
1137
+ className,
1138
+ withEyeDropper = true,
1139
+ withResult,
1140
+ eyeDropperRef,
1141
+ eyeDropperProps,
1142
+ hueSliderRef,
1143
+ hueSliderProps,
1144
+ alphaSliderRef,
1145
+ alphaSliderProps,
1146
+ ...rest
1147
+ }, ref) => {
1148
+ const { value, eyeDropperSupported, styles } = useColorPickerContext();
1149
+ const css = {
1150
+ display: "flex",
1151
+ w: "full",
1152
+ ...styles.body
1153
+ };
1154
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1155
+ import_core6.ui.div,
1156
+ {
1157
+ ref,
1158
+ className: (0, import_utils8.cx)("ui-color-picker__body", className),
1159
+ __css: css,
1160
+ ...rest,
1161
+ children: [
1162
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1163
+ ColorPickerSliders,
1164
+ {
1165
+ ...{
1166
+ hueSliderRef,
1167
+ hueSliderProps,
1168
+ alphaSliderRef,
1169
+ alphaSliderProps
1170
+ }
1171
+ }
1172
+ ),
1173
+ withEyeDropper && eyeDropperSupported ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ColorPickerEyeDropper, { ref: eyeDropperRef, ...eyeDropperProps }) : null,
1174
+ withResult ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1175
+ ColorSwatch,
1176
+ {
1177
+ className: "ui-color-picker__result",
1178
+ color: value,
1179
+ __css: { ...styles.result }
1180
+ }
1181
+ ) : null
1182
+ ]
1183
+ }
1184
+ );
1185
+ }
1186
+ );
1187
+
1188
+ // src/color-picker-channels.tsx
1189
+ var import_core7 = require("@yamada-ui/core");
1190
+ var import_input = require("@yamada-ui/input");
1191
+ var import_utils9 = require("@yamada-ui/utils");
1192
+ var import_react3 = require("react");
1193
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1194
+ var ColorPickerChannels = (0, import_core7.forwardRef)(
1195
+ ({ className, channelProps, ...rest }, ref) => {
1196
+ const { withAlpha, channels, getChannelProps, styles } = useColorPickerContext();
1197
+ const css = {
1198
+ display: "grid",
1199
+ gridTemplateColumns: `repeat(${withAlpha ? "4" : "3"}, 1fr)`,
1200
+ ...styles.channels
1201
+ };
1202
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1203
+ import_core7.ui.div,
1204
+ {
1205
+ ref,
1206
+ className: (0, import_utils9.cx)("ui-color-picker__channels", className),
1207
+ __css: css,
1208
+ ...rest,
1209
+ children: channels.map(({ label, space, value, min, max }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1210
+ ColorPickerChannel,
1211
+ {
1212
+ channelLabel: label,
1213
+ ...getChannelProps({ ...channelProps, space, value, min, max })
1214
+ },
1215
+ label
1216
+ ))
1217
+ }
1218
+ );
1219
+ }
1220
+ );
1221
+ var ColorPickerChannel = (0, import_core7.forwardRef)(
1222
+ ({ className, channelLabel, ...rest }, ref) => {
1223
+ const id = (0, import_react3.useId)();
1224
+ let { size, disabled, readOnly, styles } = useColorPickerContext();
1225
+ if (size === "full")
1226
+ size = "lg";
1227
+ const css = { ...styles.channel };
1228
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core7.ui.div, { className: (0, import_utils9.cx)("ui-color-picker__channel", className), children: [
1229
+ channelLabel ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1230
+ import_core7.ui.label,
1231
+ {
1232
+ htmlFor: id,
1233
+ style: { cursor: disabled ? "not-allowed" : void 0 },
1234
+ __css: {
1235
+ display: "block",
1236
+ pointerEvents: readOnly ? "none" : void 0,
1237
+ ...styles.channelLabel
1238
+ },
1239
+ children: channelLabel
1240
+ }
1241
+ ) : null,
1242
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_input.Input, { ref, id, size, __css: css, ...rest })
1243
+ ] });
1244
+ }
1245
+ );
1246
+
1247
+ // src/color-picker-swatches.tsx
1248
+ var import_core8 = require("@yamada-ui/core");
1249
+ var import_utils10 = require("@yamada-ui/utils");
1250
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1251
+ var ColorPickerSwatches = (0, import_core8.forwardRef)(
1252
+ ({
1253
+ className,
1254
+ swatchesLabel,
1255
+ swatches,
1256
+ swatchesContainerProps,
1257
+ swatchProps,
1258
+ swatchesColumns,
1259
+ ...rest
1260
+ }, ref) => {
1261
+ const { getSwatchProps, readOnly, styles } = useColorPickerContext();
1262
+ const css = {
1263
+ display: "grid",
1264
+ gridTemplateColumns: (0, import_utils10.replaceObject)(
1265
+ swatchesColumns,
1266
+ (value) => value != null ? `repeat(${value}, minmax(0, 1fr))` : void 0
1267
+ ),
1268
+ ...styles.swatches
1269
+ };
1270
+ return (swatches == null ? void 0 : swatches.length) ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core8.ui.div, { ...swatchesContainerProps, children: [
1271
+ swatchesLabel ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1272
+ import_core8.ui.p,
1273
+ {
1274
+ className: "ui-color-picker__swatches__label",
1275
+ __css: { ...styles.swatchesLabel },
1276
+ children: swatchesLabel
1277
+ }
1278
+ ) : null,
1279
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1280
+ import_core8.ui.div,
1281
+ {
1282
+ ref,
1283
+ className: (0, import_utils10.cx)("ui-color-picker__swatches", className),
1284
+ __css: css,
1285
+ ...rest,
1286
+ children: swatches.map((color) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1287
+ ColorSwatch,
1288
+ {
1289
+ as: "button",
1290
+ __css: {
1291
+ boxSize: "full",
1292
+ pointerEvents: readOnly ? "none" : void 0,
1293
+ ...styles.swatch
1294
+ },
1295
+ ...getSwatchProps({ color, ...swatchProps })
1296
+ },
1297
+ color
1298
+ ))
1299
+ }
1300
+ )
1301
+ ] }) : null;
1302
+ }
1303
+ );
1304
+
1305
+ // src/saturation-slider.tsx
1306
+ var import_core9 = require("@yamada-ui/core");
1307
+ var import_utils12 = require("@yamada-ui/utils");
1308
+
1309
+ // src/use-saturation-slider.ts
1310
+ var import_form_control3 = require("@yamada-ui/form-control");
1311
+ var import_use_controllable_state3 = require("@yamada-ui/use-controllable-state");
1312
+ var import_use_latest_ref2 = require("@yamada-ui/use-latest-ref");
1313
+ var import_use_pan_event2 = require("@yamada-ui/use-pan-event");
1314
+ var import_use_size2 = require("@yamada-ui/use-size");
1315
+ var import_utils11 = require("@yamada-ui/utils");
1316
+ var import_react4 = require("react");
1317
+ var defaultOverlays4 = (withShadow) => {
1318
+ let overlays = [
1319
+ ([h]) => ({
1320
+ bg: `hsl(${h}, 100%, 50%)`,
1321
+ bgImage: "linear-gradient(0deg, #000, transparent), linear-gradient(90deg, #fff, transparent)"
1322
+ })
1323
+ ];
1324
+ if (withShadow)
1325
+ overlays = [
1326
+ ...overlays,
1327
+ {
1328
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
1329
+ }
1330
+ ];
1331
+ return overlays;
1332
+ };
1333
+ var useSaturationSlider = ({
1334
+ focusThumbOnChange = true,
1335
+ ...props
1336
+ }) => {
1337
+ if (!focusThumbOnChange)
1338
+ props.isReadOnly = true;
1339
+ let {
1340
+ id,
1341
+ name,
1342
+ value: valueProp,
1343
+ defaultValue = [0, 0, 1],
1344
+ onChange: onChangeProp,
1345
+ onChangeStart: onChangeStartProp,
1346
+ onChangeEnd: onChangeEndProp,
1347
+ step = 0.01,
1348
+ thumbColor,
1349
+ required,
1350
+ disabled,
1351
+ readOnly,
1352
+ withShadow = true,
1353
+ overlays: overlaysProp = defaultOverlays4(withShadow),
1354
+ ...rest
1355
+ } = (0, import_form_control3.useFormControlProps)(props);
1356
+ const onChangeStart = (0, import_utils11.useCallbackRef)(onChangeStartProp);
1357
+ const onChangeEnd = (0, import_utils11.useCallbackRef)(onChangeEndProp);
1358
+ const [value, setValue] = (0, import_use_controllable_state3.useControllableState)({
1359
+ value: valueProp,
1360
+ defaultValue,
1361
+ onChange: onChangeProp
1362
+ });
1363
+ const [isDragging, setDragging] = (0, import_react4.useState)(false);
1364
+ const isInteractive = !(disabled || readOnly);
1365
+ let [h, s, v] = value;
1366
+ s = (0, import_utils11.clampNumber)(s, 0, 1);
1367
+ v = (0, import_utils11.clampNumber)(v, 0, 1);
1368
+ const containerRef = (0, import_react4.useRef)(null);
1369
+ const trackRef = (0, import_react4.useRef)(null);
1370
+ const thumbRef = (0, import_react4.useRef)(null);
1371
+ const latestRef = (0, import_use_latest_ref2.useLatestRef)({
1372
+ value,
1373
+ step,
1374
+ isInteractive,
1375
+ eventSource: null,
1376
+ focusThumbOnChange
1377
+ });
1378
+ const thumbSize = (0, import_use_size2.useSize)(thumbRef);
1379
+ const overlays = (0, import_react4.useMemo)(
1380
+ () => overlaysProp.map((propsOrFunc) => (0, import_utils11.runIfFunc)(propsOrFunc, [h, s, v])),
1381
+ [overlaysProp, h, s, v]
1382
+ );
1383
+ const getValueFromPointer = (0, import_react4.useCallback)(
1384
+ (ev) => {
1385
+ var _a, _b;
1386
+ if (!trackRef.current)
1387
+ return [];
1388
+ const { step: step2 } = latestRef.current;
1389
+ latestRef.current.eventSource = "pointer";
1390
+ const { bottom, left, height, width } = trackRef.current.getBoundingClientRect();
1391
+ const { clientX, clientY } = (_b = (_a = ev.touches) == null ? void 0 : _a[0]) != null ? _b : ev;
1392
+ let s2 = (0, import_utils11.clampNumber)((clientX - left) / width, 0, 1);
1393
+ let v2 = (0, import_utils11.clampNumber)((bottom - clientY) / height, 0, 1);
1394
+ if (step2) {
1395
+ s2 = parseFloat((0, import_utils11.roundNumberToStep)(s2, 0, step2));
1396
+ v2 = parseFloat((0, import_utils11.roundNumberToStep)(v2, 0, step2));
1397
+ }
1398
+ return [s2, v2];
1399
+ },
1400
+ [latestRef]
1401
+ );
1402
+ const setValueFromPointer = (ev) => {
1403
+ const { value: value2 } = latestRef.current;
1404
+ const [nextS, nextV] = getValueFromPointer(ev);
1405
+ if (nextS == null || nextV == null)
1406
+ return;
1407
+ const [, s2, v2] = value2;
1408
+ if (nextS !== s2 || nextV !== v2)
1409
+ setValue(([h2]) => [h2, nextS, nextV]);
1410
+ };
1411
+ const focusThumb = (0, import_react4.useCallback)(() => {
1412
+ const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
1413
+ if (focusThumbOnChange2)
1414
+ setTimeout(() => {
1415
+ var _a;
1416
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
1417
+ });
1418
+ }, [latestRef]);
1419
+ const constrain = (0, import_react4.useCallback)(
1420
+ ([s2, v2]) => {
1421
+ const { isInteractive: isInteractive2 } = latestRef.current;
1422
+ if (!isInteractive2)
1423
+ return;
1424
+ s2 = (0, import_utils11.clampNumber)(s2, 0, 1);
1425
+ v2 = (0, import_utils11.clampNumber)(v2, 0, 1);
1426
+ setValue(([h2]) => [h2, s2, v2]);
1427
+ },
1428
+ [latestRef, setValue]
1429
+ );
1430
+ const onKeyDown = (0, import_react4.useCallback)(
1431
+ (ev) => {
1432
+ const actions = {
1433
+ ArrowRight: () => constrain([s + step, v]),
1434
+ ArrowUp: () => constrain([s, v + step]),
1435
+ ArrowLeft: () => constrain([s - step, v]),
1436
+ ArrowDown: () => constrain([s, v - step])
1437
+ };
1438
+ const action = actions[ev.key];
1439
+ if (!action)
1440
+ return;
1441
+ ev.preventDefault();
1442
+ ev.stopPropagation();
1443
+ action(ev);
1444
+ latestRef.current.eventSource = "keyboard";
1445
+ },
1446
+ [latestRef, constrain, s, v, step]
1447
+ );
1448
+ (0, import_use_pan_event2.usePanEvent)(containerRef, {
1449
+ onSessionStart: (ev) => {
1450
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
1451
+ if (!isInteractive2)
1452
+ return;
1453
+ setDragging(true);
1454
+ focusThumb();
1455
+ setValueFromPointer(ev);
1456
+ onChangeStart(value2);
1457
+ },
1458
+ onSessionEnd: () => {
1459
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
1460
+ if (!isInteractive2)
1461
+ return;
1462
+ setDragging(false);
1463
+ onChangeEnd(value2);
1464
+ },
1465
+ onMove: (ev) => {
1466
+ const { isInteractive: isInteractive2 } = latestRef.current;
1467
+ if (!isInteractive2)
1468
+ return;
1469
+ setValueFromPointer(ev);
1470
+ }
1471
+ });
1472
+ (0, import_utils11.useUpdateEffect)(() => {
1473
+ const { eventSource, value: value2 } = latestRef.current;
1474
+ if (eventSource === "keyboard")
1475
+ onChangeEnd(value2);
1476
+ }, [value, onChangeEnd]);
1477
+ const getContainerProps = (0, import_react4.useCallback)(
1478
+ (props2 = {}, ref = null) => ({
1479
+ ...props2,
1480
+ ...(0, import_utils11.omitObject)(rest, ["aria-readonly"]),
1481
+ ref: (0, import_utils11.mergeRefs)(ref, containerRef),
1482
+ tabIndex: -1
1483
+ }),
1484
+ [rest]
1485
+ );
1486
+ const getInnerProps = (0, import_react4.useCallback)(
1487
+ (props2 = {}, ref = null) => {
1488
+ const { width: w } = thumbSize != null ? thumbSize : { width: 0 };
1489
+ const style = {
1490
+ ...props2.style,
1491
+ ...rest.style,
1492
+ padding: `${w / 2}px`
1493
+ };
1494
+ return {
1495
+ ...props2,
1496
+ ref,
1497
+ style
1498
+ };
1499
+ },
1500
+ [rest, thumbSize]
1501
+ );
1502
+ const getInputProps = (0, import_react4.useCallback)(
1503
+ (props2 = {}, ref = null) => ({
1504
+ ...(0, import_utils11.pickObject)(rest, import_form_control3.formControlProperties),
1505
+ ...props2,
1506
+ id,
1507
+ ref,
1508
+ type: "hidden",
1509
+ name,
1510
+ value: [h, s, v].toString(),
1511
+ required,
1512
+ disabled,
1513
+ readOnly
1514
+ }),
1515
+ [disabled, id, name, readOnly, required, rest, h, s, v]
1516
+ );
1517
+ const getTrackProps = (0, import_react4.useCallback)(
1518
+ (props2 = {}, ref = null) => ({
1519
+ ...(0, import_utils11.pickObject)(
1520
+ rest,
1521
+ (0, import_form_control3.getFormControlProperties)({ omit: ["aria-readonly"] })
1522
+ ),
1523
+ ...props2,
1524
+ ref: (0, import_utils11.mergeRefs)(ref, trackRef)
1525
+ }),
1526
+ [rest]
1527
+ );
1528
+ const getThumbProps = (0, import_react4.useCallback)(
1529
+ (props2 = {}, ref = null) => {
1530
+ const { width, height } = thumbSize != null ? thumbSize : { width: 0, height: 0 };
1531
+ const x = s * 100;
1532
+ const y = v * 100;
1533
+ const style = {
1534
+ ...props2.style,
1535
+ position: "absolute",
1536
+ userSelect: "none",
1537
+ touchAction: "none",
1538
+ left: `calc(${x}% - ${width / 2}px)`,
1539
+ bottom: `calc(${y}% - ${height / 2}px)`
1540
+ };
1541
+ return {
1542
+ "aria-label": "Saturation and brightness thumb",
1543
+ bg: thumbColor != null ? thumbColor : (0, import_utils11.hsvTo)([h, s, v])(),
1544
+ ...(0, import_utils11.pickObject)(rest, import_form_control3.formControlProperties),
1545
+ ...props2,
1546
+ ref: (0, import_utils11.mergeRefs)(ref, thumbRef),
1547
+ tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
1548
+ role: "slider",
1549
+ "aria-valuenow": s,
1550
+ "aria-valuemin": 0,
1551
+ "aria-valuemax": 100,
1552
+ "aria-valuetext": `saturation ${s}, brightness ${v}`,
1553
+ "data-active": (0, import_utils11.dataAttr)(isDragging && focusThumbOnChange),
1554
+ onKeyDown: (0, import_utils11.handlerAll)(props2.onKeyDown, onKeyDown),
1555
+ onFocus: (0, import_utils11.handlerAll)(props2.onFocus, rest.onFocus),
1556
+ onBlur: (0, import_utils11.handlerAll)(props2.onBlur, rest.onBlur),
1557
+ style
1558
+ };
1559
+ },
1560
+ [
1561
+ h,
1562
+ s,
1563
+ v,
1564
+ thumbColor,
1565
+ focusThumbOnChange,
1566
+ isDragging,
1567
+ isInteractive,
1568
+ onKeyDown,
1569
+ rest,
1570
+ thumbSize
1571
+ ]
1572
+ );
1573
+ return {
1574
+ value,
1575
+ overlays,
1576
+ getContainerProps,
1577
+ getInnerProps,
1578
+ getTrackProps,
1579
+ getInputProps,
1580
+ getThumbProps
1581
+ };
1582
+ };
1583
+
1584
+ // src/saturation-slider.tsx
1585
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1586
+ var SaturationSlider = (0, import_core9.forwardRef)(
1587
+ (props, ref) => {
1588
+ const [styles, mergedProps] = (0, import_core9.useMultiComponentStyle)(
1589
+ "SaturationSlider",
1590
+ props
1591
+ );
1592
+ const {
1593
+ className,
1594
+ ratio = 16 / 9,
1595
+ innerProps,
1596
+ inputProps,
1597
+ trackProps,
1598
+ thumbProps,
1599
+ __css,
1600
+ ...computedProps
1601
+ } = (0, import_core9.omitThemeProps)(mergedProps);
1602
+ const {
1603
+ overlays,
1604
+ getContainerProps,
1605
+ getInnerProps,
1606
+ getTrackProps,
1607
+ getInputProps,
1608
+ getThumbProps
1609
+ } = useSaturationSlider(computedProps);
1610
+ const css = {
1611
+ position: "relative",
1612
+ _before: {
1613
+ content: `""`,
1614
+ display: "block",
1615
+ h: 0,
1616
+ pb: (0, import_utils12.replaceObject)(ratio, (r) => `${1 / r * 100}%`)
1617
+ },
1618
+ "& > *": {
1619
+ position: "absolute",
1620
+ top: "0",
1621
+ right: "0",
1622
+ bottom: "0",
1623
+ left: "0",
1624
+ display: "flex",
1625
+ justifyContent: "center",
1626
+ alignItems: "center",
1627
+ w: "100%",
1628
+ h: "100%"
1629
+ },
1630
+ ...styles.container,
1631
+ ...__css
1632
+ };
1633
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1634
+ import_core9.ui.div,
1635
+ {
1636
+ className: (0, import_utils12.cx)("ui-saturation-slider", className),
1637
+ __css: css,
1638
+ ...getContainerProps(),
1639
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1640
+ import_core9.ui.div,
1641
+ {
1642
+ className: (0, import_utils12.cx)("ui-saturation-slider__inner", className),
1643
+ __css: { ...styles.inner },
1644
+ ...getInnerProps(innerProps),
1645
+ children: [
1646
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core9.ui.input, { ...getInputProps(inputProps, ref) }),
1647
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1648
+ import_core9.ui.div,
1649
+ {
1650
+ className: "ui-saturation-slider__overlay",
1651
+ __css: {
1652
+ position: "absolute",
1653
+ top: 0,
1654
+ left: 0,
1655
+ right: 0,
1656
+ bottom: 0,
1657
+ ...styles.overlay
1658
+ },
1659
+ ...props2
1660
+ },
1661
+ index
1662
+ )),
1663
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1664
+ import_core9.ui.div,
1665
+ {
1666
+ className: "ui-saturation-slider__track",
1667
+ __css: {
1668
+ position: "relative",
1669
+ w: "full",
1670
+ h: "full",
1671
+ ...styles.track
1672
+ },
1673
+ ...getTrackProps(trackProps),
1674
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1675
+ import_core9.ui.div,
1676
+ {
1677
+ className: "ui-saturation-slider__thumb",
1678
+ __css: { ...styles.thumb },
1679
+ ...getThumbProps(thumbProps)
1680
+ }
1681
+ )
1682
+ }
1683
+ )
1684
+ ]
1685
+ }
1686
+ )
1687
+ }
1688
+ );
1689
+ }
1690
+ );
1691
+
1692
+ // src/color-picker.tsx
1693
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1694
+ var ColorPicker = (0, import_core10.forwardRef)(
1695
+ ({ size, ...props }, ref) => {
1696
+ const [styles, mergedProps] = (0, import_core10.useMultiComponentStyle)("ColorPicker", {
1697
+ size,
1698
+ ...props
1699
+ });
1700
+ const {
1701
+ className,
1702
+ withResult = true,
1703
+ withPicker = true,
1704
+ withChannel = true,
1705
+ swatches,
1706
+ swatchesColumns = 7,
1707
+ inputProps,
1708
+ withEyeDropper,
1709
+ eyeDropperRef,
1710
+ eyeDropperProps,
1711
+ saturationSliderRef,
1712
+ saturationSliderProps,
1713
+ hueSliderRef,
1714
+ hueSliderProps,
1715
+ alphaSliderRef,
1716
+ alphaSliderProps,
1717
+ swatchesLabel,
1718
+ swatchProps,
1719
+ swatchesProps,
1720
+ ...computedProps
1721
+ } = (0, import_core10.omitThemeProps)(mergedProps);
1722
+ const {
1723
+ getContainerProps,
1724
+ getInputProps,
1725
+ getSaturationSliderProps,
1726
+ ...rest
1727
+ } = useColorPicker(computedProps);
1728
+ const css = {
1729
+ display: "flex",
1730
+ flexDirection: "column",
1731
+ ...styles.container
1732
+ };
1733
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ColorPickerProvider, { value: { styles, size, ...rest }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1734
+ import_core10.ui.div,
1735
+ {
1736
+ ref,
1737
+ className: (0, import_utils13.cx)("ui-color-picker", className),
1738
+ __css: css,
1739
+ ...getContainerProps(),
1740
+ children: [
1741
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core10.ui.input, { ...getInputProps(inputProps, ref) }),
1742
+ withPicker ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1743
+ SaturationSlider,
1744
+ {
1745
+ size,
1746
+ className: "ui-color-picker__saturation-slider",
1747
+ __css: { ...styles.saturationSlider },
1748
+ ...getSaturationSliderProps(
1749
+ saturationSliderProps,
1750
+ saturationSliderRef
1751
+ )
1752
+ }
1753
+ ) : null,
1754
+ withPicker ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1755
+ ColorPickerBody,
1756
+ {
1757
+ ...{
1758
+ withResult,
1759
+ withEyeDropper,
1760
+ eyeDropperRef,
1761
+ eyeDropperProps,
1762
+ hueSliderRef,
1763
+ hueSliderProps,
1764
+ alphaSliderRef,
1765
+ alphaSliderProps
1766
+ }
1767
+ }
1768
+ ) : null,
1769
+ withPicker && withChannel ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ColorPickerChannels, {}) : null,
1770
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1771
+ ColorPickerSwatches,
1772
+ {
1773
+ ...{
1774
+ swatchesLabel,
1775
+ swatches,
1776
+ swatchesColumns,
1777
+ swatchProps,
1778
+ ...swatchesProps
1779
+ }
1780
+ }
1781
+ )
1782
+ ]
1783
+ }
1784
+ ) });
1785
+ }
1786
+ );
1787
+ // Annotate the CommonJS export names for ESM import in node:
1788
+ 0 && (module.exports = {
1789
+ ColorPicker
1790
+ });