@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,794 @@
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-body.tsx
21
+ var color_picker_body_exports = {};
22
+ __export(color_picker_body_exports, {
23
+ ColorPickerBody: () => ColorPickerBody
24
+ });
25
+ module.exports = __toCommonJS(color_picker_body_exports);
26
+ var import_core6 = require("@yamada-ui/core");
27
+ var import_utils8 = require("@yamada-ui/utils");
28
+
29
+ // src/color-picker-eye-dropper.tsx
30
+ var import_button = require("@yamada-ui/button");
31
+ var import_core = require("@yamada-ui/core");
32
+ var import_icon = require("@yamada-ui/icon");
33
+ var import_utils2 = require("@yamada-ui/utils");
34
+
35
+ // src/use-color-picker.ts
36
+ var import_form_control = require("@yamada-ui/form-control");
37
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
38
+ var import_use_eye_dropper = require("@yamada-ui/use-eye-dropper");
39
+ var import_utils = require("@yamada-ui/utils");
40
+ var import_react = require("react");
41
+
42
+ // ../../utils/src/object.ts
43
+ var pickObject = (obj, keys) => {
44
+ const result = {};
45
+ keys.forEach((key) => {
46
+ if (key in obj)
47
+ result[key] = obj[key];
48
+ });
49
+ return result;
50
+ };
51
+ var getObject = (obj, path, fallback, i) => {
52
+ const k = typeof path === "string" ? path.split(".") : [path];
53
+ for (i = 0; i < k.length; i += 1) {
54
+ if (!obj)
55
+ break;
56
+ obj = obj[k[i]];
57
+ }
58
+ return obj === void 0 ? fallback : obj;
59
+ };
60
+ var memoizeObject = (func) => {
61
+ const cache = /* @__PURE__ */ new WeakMap();
62
+ const memoizedFunc = (obj, path, fallback, i) => {
63
+ if (typeof obj === "undefined")
64
+ return func(obj, path, fallback);
65
+ if (!cache.has(obj))
66
+ cache.set(obj, /* @__PURE__ */ new Map());
67
+ const map = cache.get(obj);
68
+ if (map.has(path))
69
+ return map.get(path);
70
+ const value = func(obj, path, fallback, i);
71
+ map.set(path, value);
72
+ return value;
73
+ };
74
+ return memoizedFunc;
75
+ };
76
+ var getMemoizedObject = memoizeObject(getObject);
77
+
78
+ // src/use-color-picker.ts
79
+ var [ColorPickerProvider, useColorPickerContext] = (0, import_utils.createContext)({
80
+ name: "ColorPickerContext",
81
+ errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in "<ColorPicker />"`
82
+ });
83
+
84
+ // src/color-picker-eye-dropper.tsx
85
+ var import_jsx_runtime = require("react/jsx-runtime");
86
+ var ColorPickerEyeDropper = (0, import_core.forwardRef)(({ className, ...rest }, ref) => {
87
+ const { getEyeDropperProps, readOnly, size, styles } = useColorPickerContext();
88
+ const css = {
89
+ h: "auto",
90
+ minW: "auto",
91
+ pointerEvents: readOnly ? "none" : void 0,
92
+ ...styles.eyeDropper
93
+ };
94
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
+ import_button.IconButton,
96
+ {
97
+ className: (0, import_utils2.cx)("ui-color-picker__eye-dropper", className),
98
+ variant: "outline",
99
+ size,
100
+ __css: css,
101
+ ...getEyeDropperProps(rest, ref),
102
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EyeDropperIcon, { className: "ui-color-picker__eye-dropper__icon" })
103
+ }
104
+ );
105
+ });
106
+ var EyeDropperIcon = ({ ...rest }) => {
107
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
108
+ import_icon.Icon,
109
+ {
110
+ viewBox: "0 0 24 24",
111
+ fill: "none",
112
+ stroke: "currentColor",
113
+ strokeWidth: "2",
114
+ strokeLinecap: "round",
115
+ strokeLinejoin: "round",
116
+ ...rest,
117
+ children: [
118
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m2 22 1-1h3l9-9" }),
119
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 21v-3l9-9" }),
120
+ /* @__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" })
121
+ ]
122
+ }
123
+ );
124
+ };
125
+
126
+ // src/color-picker-sliders.tsx
127
+ var import_core4 = require("@yamada-ui/core");
128
+ var import_utils6 = require("@yamada-ui/utils");
129
+
130
+ // src/alpha-slider.tsx
131
+ var import_core2 = require("@yamada-ui/core");
132
+ var import_utils4 = require("@yamada-ui/utils");
133
+
134
+ // src/use-color-slider.ts
135
+ var import_form_control2 = require("@yamada-ui/form-control");
136
+ var import_use_controllable_state2 = require("@yamada-ui/use-controllable-state");
137
+ var import_use_latest_ref = require("@yamada-ui/use-latest-ref");
138
+ var import_use_pan_event = require("@yamada-ui/use-pan-event");
139
+ var import_use_size = require("@yamada-ui/use-size");
140
+ var import_utils3 = require("@yamada-ui/utils");
141
+ var import_react2 = require("react");
142
+ var useColorSlider = ({
143
+ focusThumbOnChange = true,
144
+ ...props
145
+ }) => {
146
+ if (!focusThumbOnChange)
147
+ props.isReadOnly = true;
148
+ let {
149
+ id,
150
+ name,
151
+ value: valueProp,
152
+ defaultValue,
153
+ min = 0,
154
+ max,
155
+ step = 1,
156
+ onChange: onChangeProp,
157
+ onChangeStart: onChangeStartProp,
158
+ onChangeEnd: onChangeEndProp,
159
+ thumbColor,
160
+ required,
161
+ disabled,
162
+ readOnly,
163
+ ...rest
164
+ } = (0, import_form_control2.useFormControlProps)(props);
165
+ const onChangeStart = (0, import_utils3.useCallbackRef)(onChangeStartProp);
166
+ const onChangeEnd = (0, import_utils3.useCallbackRef)(onChangeEndProp);
167
+ const [computedValue, setValue] = (0, import_use_controllable_state2.useControllableState)({
168
+ value: valueProp,
169
+ defaultValue: defaultValue != null ? defaultValue : min + (max - min) / 2,
170
+ onChange: onChangeProp
171
+ });
172
+ const value = (0, import_utils3.clampNumber)(computedValue, min, max);
173
+ const thumbPercent = (0, import_utils3.valueToPercent)(value, min, max);
174
+ const [isDragging, setDragging] = (0, import_react2.useState)(false);
175
+ const isInteractive = !(disabled || readOnly);
176
+ const oneStep = step || (max - min) / 100;
177
+ const tenStep = (max - min) / 10;
178
+ const containerRef = (0, import_react2.useRef)(null);
179
+ const trackRef = (0, import_react2.useRef)(null);
180
+ const thumbRef = (0, import_react2.useRef)(null);
181
+ const latestRef = (0, import_use_latest_ref.useLatestRef)({
182
+ value,
183
+ min,
184
+ max,
185
+ step,
186
+ isInteractive,
187
+ eventSource: null,
188
+ focusThumbOnChange
189
+ });
190
+ const thumbSize = (0, import_use_size.useSize)(thumbRef);
191
+ const getValueFromPointer = (0, import_react2.useCallback)(
192
+ (ev) => {
193
+ var _a, _b;
194
+ if (!trackRef.current)
195
+ return;
196
+ const { min: min2, max: max2, step: step2 } = latestRef.current;
197
+ latestRef.current.eventSource = "pointer";
198
+ const { left, width } = trackRef.current.getBoundingClientRect();
199
+ const { clientX } = (_b = (_a = ev.touches) == null ? void 0 : _a[0]) != null ? _b : ev;
200
+ let percent = (clientX - left) / width;
201
+ let nextValue = (0, import_utils3.percentToValue)(percent, min2, max2);
202
+ if (step2)
203
+ nextValue = parseFloat((0, import_utils3.roundNumberToStep)(nextValue, min2, step2));
204
+ nextValue = (0, import_utils3.clampNumber)(nextValue, min2, max2);
205
+ return nextValue;
206
+ },
207
+ [latestRef]
208
+ );
209
+ const setValueFromPointer = (ev) => {
210
+ const { value: value2 } = latestRef.current;
211
+ const nextValue = getValueFromPointer(ev);
212
+ if (nextValue != null && nextValue !== value2)
213
+ setValue(nextValue);
214
+ };
215
+ const focusThumb = (0, import_react2.useCallback)(() => {
216
+ const { focusThumbOnChange: focusThumbOnChange2 } = latestRef.current;
217
+ if (focusThumbOnChange2)
218
+ setTimeout(() => {
219
+ var _a;
220
+ return (_a = thumbRef.current) == null ? void 0 : _a.focus();
221
+ });
222
+ }, [latestRef]);
223
+ const constrain = (0, import_react2.useCallback)(
224
+ (value2) => {
225
+ const { isInteractive: isInteractive2, min: min2, max: max2 } = latestRef.current;
226
+ if (!isInteractive2)
227
+ return;
228
+ value2 = parseFloat((0, import_utils3.roundNumberToStep)(value2, min2, oneStep));
229
+ value2 = (0, import_utils3.clampNumber)(value2, min2, max2);
230
+ setValue(value2);
231
+ },
232
+ [setValue, latestRef, oneStep]
233
+ );
234
+ const stepUp = (0, import_react2.useCallback)(
235
+ (step2 = oneStep) => constrain(value + step2),
236
+ [constrain, value, oneStep]
237
+ );
238
+ const stepDown = (0, import_react2.useCallback)(
239
+ (step2 = oneStep) => constrain(value - step2),
240
+ [constrain, value, oneStep]
241
+ );
242
+ const onKeyDown = (0, import_react2.useCallback)(
243
+ (ev) => {
244
+ const { min: min2, max: max2 } = latestRef.current;
245
+ const actions = {
246
+ ArrowRight: () => stepUp(),
247
+ ArrowUp: () => stepUp(),
248
+ ArrowLeft: () => stepDown(),
249
+ ArrowDown: () => stepDown(),
250
+ PageUp: () => stepUp(tenStep),
251
+ PageDown: () => stepDown(tenStep),
252
+ Home: () => constrain(min2),
253
+ End: () => constrain(max2)
254
+ };
255
+ const action = actions[ev.key];
256
+ if (!action)
257
+ return;
258
+ ev.preventDefault();
259
+ ev.stopPropagation();
260
+ action(ev);
261
+ latestRef.current.eventSource = "keyboard";
262
+ },
263
+ [constrain, latestRef, stepDown, stepUp, tenStep]
264
+ );
265
+ (0, import_use_pan_event.usePanEvent)(containerRef, {
266
+ onSessionStart: (ev) => {
267
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
268
+ if (!isInteractive2)
269
+ return;
270
+ setDragging(true);
271
+ focusThumb();
272
+ setValueFromPointer(ev);
273
+ onChangeStart(value2);
274
+ },
275
+ onSessionEnd: () => {
276
+ const { isInteractive: isInteractive2, value: value2 } = latestRef.current;
277
+ if (!isInteractive2)
278
+ return;
279
+ setDragging(false);
280
+ onChangeEnd(value2);
281
+ },
282
+ onMove: (ev) => {
283
+ const { isInteractive: isInteractive2 } = latestRef.current;
284
+ if (!isInteractive2)
285
+ return;
286
+ setValueFromPointer(ev);
287
+ }
288
+ });
289
+ (0, import_utils3.useUpdateEffect)(() => {
290
+ const { eventSource, value: value2 } = latestRef.current;
291
+ if (eventSource === "keyboard")
292
+ onChangeEnd(value2);
293
+ }, [value, onChangeEnd]);
294
+ const getContainerProps = (0, import_react2.useCallback)(
295
+ (props2 = {}, ref = null) => {
296
+ const { width: w } = thumbSize != null ? thumbSize : { width: 0 };
297
+ const style = {
298
+ ...props2.style,
299
+ ...rest.style,
300
+ paddingInline: `${w / 2}px`
301
+ };
302
+ return {
303
+ ...props2,
304
+ ...(0, import_utils3.omitObject)(rest, ["aria-readonly"]),
305
+ ref: (0, import_utils3.mergeRefs)(ref, containerRef),
306
+ tabIndex: -1,
307
+ style
308
+ };
309
+ },
310
+ [rest, thumbSize]
311
+ );
312
+ const getInputProps = (0, import_react2.useCallback)(
313
+ (props2 = {}, ref = null) => ({
314
+ ...pickObject(rest, import_form_control2.formControlProperties),
315
+ ...props2,
316
+ id,
317
+ ref,
318
+ type: "hidden",
319
+ name,
320
+ value,
321
+ required,
322
+ disabled,
323
+ readOnly
324
+ }),
325
+ [disabled, id, name, readOnly, required, rest, value]
326
+ );
327
+ const getTrackProps = (0, import_react2.useCallback)(
328
+ (props2 = {}, ref = null) => ({
329
+ ...pickObject(
330
+ rest,
331
+ (0, import_form_control2.getFormControlProperties)({ omit: ["aria-readonly"] })
332
+ ),
333
+ ...props2,
334
+ ref: (0, import_utils3.mergeRefs)(ref, trackRef)
335
+ }),
336
+ [rest]
337
+ );
338
+ const getThumbProps = (0, import_react2.useCallback)(
339
+ (props2 = {}, ref = null) => {
340
+ const n = thumbPercent;
341
+ const { width: w } = thumbSize != null ? thumbSize : { width: 0 };
342
+ const style = {
343
+ ...props2.style,
344
+ position: "absolute",
345
+ userSelect: "none",
346
+ touchAction: "none",
347
+ left: `calc(${n}% - ${w / 2}px)`
348
+ };
349
+ return {
350
+ "aria-label": "Slider thumb",
351
+ bg: thumbColor != null ? thumbColor : `hsl(${value}, 100%, 50%)`,
352
+ ...pickObject(rest, import_form_control2.formControlProperties),
353
+ ...props2,
354
+ ref: (0, import_utils3.mergeRefs)(ref, thumbRef),
355
+ tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
356
+ role: "slider",
357
+ "aria-valuenow": value,
358
+ "aria-valuemin": min,
359
+ "aria-valuemax": max,
360
+ "data-active": (0, import_utils3.dataAttr)(isDragging && focusThumbOnChange),
361
+ onKeyDown: (0, import_utils3.handlerAll)(props2.onKeyDown, onKeyDown),
362
+ onFocus: (0, import_utils3.handlerAll)(props2.onFocus, rest.onFocus),
363
+ onBlur: (0, import_utils3.handlerAll)(props2.onBlur, rest.onBlur),
364
+ style
365
+ };
366
+ },
367
+ [
368
+ thumbColor,
369
+ focusThumbOnChange,
370
+ isDragging,
371
+ isInteractive,
372
+ min,
373
+ max,
374
+ onKeyDown,
375
+ rest,
376
+ thumbPercent,
377
+ thumbSize,
378
+ value
379
+ ]
380
+ );
381
+ return {
382
+ value,
383
+ getContainerProps,
384
+ getTrackProps,
385
+ getInputProps,
386
+ getThumbProps
387
+ };
388
+ };
389
+
390
+ // src/alpha-slider.tsx
391
+ var import_jsx_runtime2 = require("react/jsx-runtime");
392
+ var defaultOverlays = (color, min, max, withShadow) => {
393
+ let overlays = [
394
+ {
395
+ 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%)",
396
+ bgSize: `8px 8px`,
397
+ bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,
398
+ var: [
399
+ {
400
+ name: "checkers",
401
+ token: "colors",
402
+ value: ["blackAlpha.300", "whiteAlpha.300"]
403
+ },
404
+ {
405
+ name: "body",
406
+ token: "colors",
407
+ value: ["whiteAlpha.500", "blackAlpha.500"]
408
+ }
409
+ ]
410
+ },
411
+ {
412
+ 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)})`
413
+ }
414
+ ];
415
+ if (withShadow)
416
+ overlays = [
417
+ ...overlays,
418
+ {
419
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
420
+ }
421
+ ];
422
+ return overlays;
423
+ };
424
+ var AlphaSlider = (0, import_core2.forwardRef)(
425
+ (props, ref) => {
426
+ const [styles, mergedProps] = (0, import_core2.useMultiComponentStyle)("AlphaSlider", props);
427
+ const {
428
+ className,
429
+ inputProps,
430
+ trackProps,
431
+ thumbProps,
432
+ color = "#ffffff",
433
+ min = 0,
434
+ max = 1,
435
+ withShadow = true,
436
+ overlays = defaultOverlays(color, min, max, withShadow),
437
+ __css,
438
+ ...computedProps
439
+ } = (0, import_core2.omitThemeProps)(mergedProps);
440
+ const { getContainerProps, getTrackProps, getInputProps, getThumbProps } = useColorSlider({
441
+ min,
442
+ max,
443
+ step: 0.01,
444
+ thumbColor: "transparent",
445
+ ...computedProps
446
+ });
447
+ const css = {
448
+ position: "relative",
449
+ ...styles.container,
450
+ ...__css
451
+ };
452
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
453
+ import_core2.ui.div,
454
+ {
455
+ className: (0, import_utils4.cx)("ui-alpha-slider", className),
456
+ __css: css,
457
+ ...getContainerProps(),
458
+ children: [
459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.input, { ...getInputProps(inputProps, ref) }),
460
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
461
+ import_core2.ui.div,
462
+ {
463
+ className: "ui-alpha-slider__overlay",
464
+ __css: {
465
+ position: "absolute",
466
+ top: 0,
467
+ left: 0,
468
+ right: 0,
469
+ bottom: 0,
470
+ ...styles.overlay
471
+ },
472
+ ...props2
473
+ },
474
+ index
475
+ )),
476
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
477
+ import_core2.ui.div,
478
+ {
479
+ className: "ui-alpha-slider__track",
480
+ __css: {
481
+ position: "relative",
482
+ w: "full",
483
+ h: "full",
484
+ ...styles.track
485
+ },
486
+ ...getTrackProps(trackProps),
487
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
488
+ import_core2.ui.div,
489
+ {
490
+ className: "ui-alpha-slider__thumb",
491
+ __css: { ...styles.thumb },
492
+ ...getThumbProps(thumbProps)
493
+ }
494
+ )
495
+ }
496
+ )
497
+ ]
498
+ }
499
+ );
500
+ }
501
+ );
502
+
503
+ // src/hue-slider.tsx
504
+ var import_core3 = require("@yamada-ui/core");
505
+ var import_utils5 = require("@yamada-ui/utils");
506
+ var import_jsx_runtime3 = require("react/jsx-runtime");
507
+ var defaultOverlays2 = (min, max, withShadow) => {
508
+ let overlays = [
509
+ {
510
+ bgGradient: `linear(to-r, ${[...Array(7)].map(
511
+ (_, index) => `hsl(${Math.round(min + (max - min) / 6 * index)}, 100%, 50%)`
512
+ ).join(", ")})`
513
+ }
514
+ ];
515
+ if (withShadow)
516
+ overlays = [
517
+ ...overlays,
518
+ {
519
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
520
+ }
521
+ ];
522
+ return overlays;
523
+ };
524
+ var HueSlider = (0, import_core3.forwardRef)((props, ref) => {
525
+ const [styles, mergedProps] = (0, import_core3.useMultiComponentStyle)("HueSlider", props);
526
+ const {
527
+ className,
528
+ inputProps,
529
+ trackProps,
530
+ thumbProps,
531
+ min = 0,
532
+ max = 360,
533
+ withShadow = true,
534
+ overlays = defaultOverlays2(min, max, withShadow),
535
+ __css,
536
+ ...computedProps
537
+ } = (0, import_core3.omitThemeProps)(mergedProps);
538
+ const { getContainerProps, getTrackProps, getInputProps, getThumbProps } = useColorSlider({ min, max, step: 1, ...computedProps });
539
+ const css = {
540
+ position: "relative",
541
+ ...styles.container,
542
+ ...__css
543
+ };
544
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
545
+ import_core3.ui.div,
546
+ {
547
+ className: (0, import_utils5.cx)("ui-hue-slider", className),
548
+ __css: css,
549
+ ...getContainerProps(),
550
+ children: [
551
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.input, { ...getInputProps(inputProps, ref) }),
552
+ overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
553
+ import_core3.ui.div,
554
+ {
555
+ className: "ui-hue-slider__overlay",
556
+ __css: {
557
+ position: "absolute",
558
+ top: 0,
559
+ left: 0,
560
+ right: 0,
561
+ bottom: 0,
562
+ ...styles.overlay
563
+ },
564
+ ...props2
565
+ },
566
+ index
567
+ )),
568
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
569
+ import_core3.ui.div,
570
+ {
571
+ className: "ui-hue-slider__track",
572
+ __css: { position: "relative", w: "full", h: "full", ...styles.track },
573
+ ...getTrackProps(trackProps),
574
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
575
+ import_core3.ui.div,
576
+ {
577
+ className: "ui-hue-slider__thumb",
578
+ __css: { ...styles.thumb },
579
+ ...getThumbProps(thumbProps)
580
+ }
581
+ )
582
+ }
583
+ )
584
+ ]
585
+ }
586
+ );
587
+ });
588
+
589
+ // src/color-picker-sliders.tsx
590
+ var import_jsx_runtime4 = require("react/jsx-runtime");
591
+ var ColorPickerSliders = (0, import_core4.forwardRef)(
592
+ ({
593
+ className,
594
+ hueSliderRef,
595
+ hueSliderProps,
596
+ alphaSliderRef,
597
+ alphaSliderProps,
598
+ ...rest
599
+ }, ref) => {
600
+ let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } = useColorPickerContext();
601
+ if (size === "full")
602
+ size = "lg";
603
+ const css = {
604
+ display: "flex",
605
+ flexDirection: "column",
606
+ ...styles.sliders
607
+ };
608
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
609
+ import_core4.ui.div,
610
+ {
611
+ ref,
612
+ className: (0, import_utils6.cx)("ui-color-picker__sliders", className),
613
+ __css: css,
614
+ ...rest,
615
+ children: [
616
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
617
+ HueSlider,
618
+ {
619
+ size,
620
+ className: "ui-color-picker__hue-slider",
621
+ __css: { ...styles.hueSlider },
622
+ ...getHueSliderProps(hueSliderProps, hueSliderRef)
623
+ }
624
+ ),
625
+ withAlpha ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
626
+ AlphaSlider,
627
+ {
628
+ size,
629
+ className: "ui-color-picker__alpha-slider",
630
+ __css: { ...styles.alphaSlider },
631
+ ...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)
632
+ }
633
+ ) : null
634
+ ]
635
+ }
636
+ );
637
+ }
638
+ );
639
+
640
+ // src/color-swatch.tsx
641
+ var import_core5 = require("@yamada-ui/core");
642
+ var import_utils7 = require("@yamada-ui/utils");
643
+ var import_jsx_runtime5 = require("react/jsx-runtime");
644
+ var defaultOverlays3 = (background, withShadow) => {
645
+ let overlays = [
646
+ {
647
+ 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%)",
648
+ bgSize: `8px 8px`,
649
+ bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,
650
+ var: [
651
+ {
652
+ name: "checkers",
653
+ token: "colors",
654
+ value: ["blackAlpha.300", "whiteAlpha.300"]
655
+ },
656
+ {
657
+ name: "body",
658
+ token: "colors",
659
+ value: ["whiteAlpha.500", "blackAlpha.500"]
660
+ }
661
+ ]
662
+ },
663
+ { background }
664
+ ];
665
+ if (withShadow)
666
+ overlays = [
667
+ ...overlays,
668
+ {
669
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
670
+ }
671
+ ];
672
+ return overlays;
673
+ };
674
+ var ColorSwatch = (0, import_core5.forwardRef)((props, ref) => {
675
+ const [styles, mergedProps] = (0, import_core5.useMultiComponentStyle)("ColorSwatch", props);
676
+ const {
677
+ className,
678
+ color = "#ffffff00",
679
+ withShadow = true,
680
+ overlays = defaultOverlays3(color, withShadow),
681
+ isRounded,
682
+ __css,
683
+ ...rest
684
+ } = (0, import_core5.omitThemeProps)(mergedProps);
685
+ const css = {
686
+ position: "relative",
687
+ _before: {
688
+ content: `""`,
689
+ display: "block",
690
+ h: 0,
691
+ pb: "100%"
692
+ },
693
+ "& > *": {
694
+ overflow: "hidden",
695
+ position: "absolute",
696
+ top: "0",
697
+ right: "0",
698
+ bottom: "0",
699
+ left: "0",
700
+ display: "flex",
701
+ justifyContent: "center",
702
+ alignItems: "center",
703
+ w: "100%",
704
+ h: "100%"
705
+ },
706
+ ...styles.container,
707
+ ...__css
708
+ };
709
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
710
+ import_core5.ui.div,
711
+ {
712
+ ref,
713
+ className: (0, import_utils7.cx)("ui-color-swatch", className),
714
+ ...isRounded ? { rounded: "full" } : {},
715
+ __css: css,
716
+ ...rest,
717
+ 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)(
718
+ import_core5.ui.div,
719
+ {
720
+ __css: {
721
+ position: "absolute",
722
+ top: 0,
723
+ left: 0,
724
+ right: 0,
725
+ bottom: 0,
726
+ ...styles.overlay
727
+ },
728
+ ...isRounded ? { rounded: "full" } : {},
729
+ ...props2
730
+ },
731
+ index
732
+ )) })
733
+ }
734
+ );
735
+ });
736
+
737
+ // src/color-picker-body.tsx
738
+ var import_jsx_runtime6 = require("react/jsx-runtime");
739
+ var ColorPickerBody = (0, import_core6.forwardRef)(
740
+ ({
741
+ className,
742
+ withEyeDropper = true,
743
+ withResult,
744
+ eyeDropperRef,
745
+ eyeDropperProps,
746
+ hueSliderRef,
747
+ hueSliderProps,
748
+ alphaSliderRef,
749
+ alphaSliderProps,
750
+ ...rest
751
+ }, ref) => {
752
+ const { value, eyeDropperSupported, styles } = useColorPickerContext();
753
+ const css = {
754
+ display: "flex",
755
+ w: "full",
756
+ ...styles.body
757
+ };
758
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
759
+ import_core6.ui.div,
760
+ {
761
+ ref,
762
+ className: (0, import_utils8.cx)("ui-color-picker__body", className),
763
+ __css: css,
764
+ ...rest,
765
+ children: [
766
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
767
+ ColorPickerSliders,
768
+ {
769
+ ...{
770
+ hueSliderRef,
771
+ hueSliderProps,
772
+ alphaSliderRef,
773
+ alphaSliderProps
774
+ }
775
+ }
776
+ ),
777
+ withEyeDropper && eyeDropperSupported ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ColorPickerEyeDropper, { ref: eyeDropperRef, ...eyeDropperProps }) : null,
778
+ withResult ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
779
+ ColorSwatch,
780
+ {
781
+ className: "ui-color-picker__result",
782
+ color: value,
783
+ __css: { ...styles.result }
784
+ }
785
+ ) : null
786
+ ]
787
+ }
788
+ );
789
+ }
790
+ );
791
+ // Annotate the CommonJS export names for ESM import in node:
792
+ 0 && (module.exports = {
793
+ ColorPickerBody
794
+ });