@yamada-ui/color-picker 1.0.0 → 1.0.1-dev-20240119044050
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alpha-slider.js +3 -41
- package/dist/alpha-slider.mjs +2 -3
- package/dist/{chunk-EMWFECJD.mjs → chunk-24BBRCTU.mjs} +20 -20
- package/dist/{chunk-TFQ62YSQ.mjs → chunk-25HMRK5Y.mjs} +8 -8
- package/dist/{chunk-7QGCTVDG.mjs → chunk-3JCJHD24.mjs} +11 -11
- package/dist/{chunk-KJS52X4M.mjs → chunk-5BN4WU5H.mjs} +30 -30
- package/dist/chunk-F7CBAED2.mjs +63 -0
- package/dist/{chunk-NR2XCTSD.mjs → chunk-KCQQ4JHN.mjs} +10 -13
- package/dist/{chunk-PTTNJPGJ.mjs → chunk-LDCDIBTZ.mjs} +1 -1
- package/dist/{chunk-73BVTMII.mjs → chunk-LG5AH76C.mjs} +14 -14
- package/dist/{chunk-U6OJ4TDG.mjs → chunk-TOGKHI2V.mjs} +1 -1
- package/dist/{chunk-3EO2XBIZ.mjs → chunk-X3D4OUWF.mjs} +8 -8
- package/dist/{chunk-DTB2Z3IJ.mjs → chunk-XAL3WIW7.mjs} +2 -5
- package/dist/{chunk-HNVFOSAM.mjs → chunk-ZH5KWDBH.mjs} +33 -33
- package/dist/color-picker.d.mts +43 -23
- package/dist/color-picker.d.ts +43 -23
- package/dist/color-picker.js +585 -134
- package/dist/color-picker.mjs +12 -11
- package/dist/{color-picker-body.d.mts → color-selector-body.d.mts} +7 -7
- package/dist/{color-picker-body.d.ts → color-selector-body.d.ts} +7 -7
- package/dist/{color-picker-body.js → color-selector-body.js} +33 -71
- package/dist/color-selector-body.mjs +13 -0
- package/dist/color-selector-channels.d.mts +20 -0
- package/dist/color-selector-channels.d.ts +20 -0
- package/dist/color-selector-channels.js +97 -0
- package/dist/color-selector-channels.mjs +9 -0
- package/dist/color-selector-eye-dropper.d.mts +10 -0
- package/dist/color-selector-eye-dropper.d.ts +10 -0
- package/dist/{color-picker-eye-dropper.js → color-selector-eye-dropper.js} +15 -15
- package/dist/color-selector-eye-dropper.mjs +9 -0
- package/dist/{color-picker-sliders.d.mts → color-selector-sliders.d.mts} +4 -4
- package/dist/{color-picker-sliders.d.ts → color-selector-sliders.d.ts} +4 -4
- package/dist/{color-picker-sliders.js → color-selector-sliders.js} +19 -57
- package/dist/color-selector-sliders.mjs +10 -0
- package/dist/{color-picker-swatches.d.mts → color-selector-swatches.d.mts} +5 -5
- package/dist/{color-picker-swatches.d.ts → color-selector-swatches.d.ts} +5 -5
- package/dist/{color-picker-swatches.js → color-selector-swatches.js} +15 -15
- package/dist/color-selector-swatches.mjs +8 -0
- package/dist/color-selector.d.mts +59 -0
- package/dist/color-selector.d.ts +59 -0
- package/dist/{color-input.js → color-selector.js} +98 -633
- package/dist/color-selector.mjs +18 -0
- package/dist/hue-slider.js +3 -41
- package/dist/hue-slider.mjs +2 -3
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +148 -190
- package/dist/index.mjs +15 -16
- package/dist/use-color-picker.d.mts +50 -91
- package/dist/use-color-picker.d.ts +50 -91
- package/dist/use-color-picker.js +252 -384
- package/dist/use-color-picker.mjs +1 -2
- package/dist/use-color-selector.d.mts +131 -0
- package/dist/use-color-selector.d.ts +131 -0
- package/dist/use-color-selector.js +434 -0
- package/dist/use-color-selector.mjs +10 -0
- package/dist/use-color-slider.js +3 -41
- package/dist/use-color-slider.mjs +1 -2
- package/package.json +14 -14
- package/dist/chunk-N2GG5L7Q.mjs +0 -39
- package/dist/chunk-PVWIBTBL.mjs +0 -67
- package/dist/color-input.d.mts +0 -79
- package/dist/color-input.d.ts +0 -79
- package/dist/color-input.mjs +0 -21
- package/dist/color-picker-body.mjs +0 -14
- package/dist/color-picker-channels.d.mts +0 -20
- package/dist/color-picker-channels.d.ts +0 -20
- package/dist/color-picker-channels.js +0 -101
- package/dist/color-picker-channels.mjs +0 -10
- package/dist/color-picker-eye-dropper.d.mts +0 -10
- package/dist/color-picker-eye-dropper.d.ts +0 -10
- package/dist/color-picker-eye-dropper.mjs +0 -10
- package/dist/color-picker-sliders.mjs +0 -11
- package/dist/color-picker-swatches.mjs +0 -9
- package/dist/use-color-input.d.mts +0 -90
- package/dist/use-color-input.d.ts +0 -90
- package/dist/use-color-input.js +0 -340
- package/dist/use-color-input.mjs +0 -10
package/dist/alpha-slider.js
CHANGED
|
@@ -34,44 +34,6 @@ var import_use_pan_event = require("@yamada-ui/use-pan-event");
|
|
|
34
34
|
var import_use_size = require("@yamada-ui/use-size");
|
|
35
35
|
var import_utils = require("@yamada-ui/utils");
|
|
36
36
|
var import_react = require("react");
|
|
37
|
-
|
|
38
|
-
// ../../utils/src/object.ts
|
|
39
|
-
var pickObject = (obj, keys) => {
|
|
40
|
-
const result = {};
|
|
41
|
-
keys.forEach((key) => {
|
|
42
|
-
if (key in obj)
|
|
43
|
-
result[key] = obj[key];
|
|
44
|
-
});
|
|
45
|
-
return result;
|
|
46
|
-
};
|
|
47
|
-
var getObject = (obj, path, fallback, i) => {
|
|
48
|
-
const k = typeof path === "string" ? path.split(".") : [path];
|
|
49
|
-
for (i = 0; i < k.length; i += 1) {
|
|
50
|
-
if (!obj)
|
|
51
|
-
break;
|
|
52
|
-
obj = obj[k[i]];
|
|
53
|
-
}
|
|
54
|
-
return obj === void 0 ? fallback : obj;
|
|
55
|
-
};
|
|
56
|
-
var memoizeObject = (func) => {
|
|
57
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
58
|
-
const memoizedFunc = (obj, path, fallback, i) => {
|
|
59
|
-
if (typeof obj === "undefined")
|
|
60
|
-
return func(obj, path, fallback);
|
|
61
|
-
if (!cache.has(obj))
|
|
62
|
-
cache.set(obj, /* @__PURE__ */ new Map());
|
|
63
|
-
const map = cache.get(obj);
|
|
64
|
-
if (map.has(path))
|
|
65
|
-
return map.get(path);
|
|
66
|
-
const value = func(obj, path, fallback, i);
|
|
67
|
-
map.set(path, value);
|
|
68
|
-
return value;
|
|
69
|
-
};
|
|
70
|
-
return memoizedFunc;
|
|
71
|
-
};
|
|
72
|
-
var getMemoizedObject = memoizeObject(getObject);
|
|
73
|
-
|
|
74
|
-
// src/use-color-slider.ts
|
|
75
37
|
var useColorSlider = ({
|
|
76
38
|
focusThumbOnChange = true,
|
|
77
39
|
...props
|
|
@@ -244,7 +206,7 @@ var useColorSlider = ({
|
|
|
244
206
|
);
|
|
245
207
|
const getInputProps = (0, import_react.useCallback)(
|
|
246
208
|
(props2 = {}, ref = null) => ({
|
|
247
|
-
...pickObject(rest, import_form_control.formControlProperties),
|
|
209
|
+
...(0, import_utils.pickObject)(rest, import_form_control.formControlProperties),
|
|
248
210
|
...props2,
|
|
249
211
|
id,
|
|
250
212
|
ref,
|
|
@@ -259,7 +221,7 @@ var useColorSlider = ({
|
|
|
259
221
|
);
|
|
260
222
|
const getTrackProps = (0, import_react.useCallback)(
|
|
261
223
|
(props2 = {}, ref = null) => ({
|
|
262
|
-
...pickObject(
|
|
224
|
+
...(0, import_utils.pickObject)(
|
|
263
225
|
rest,
|
|
264
226
|
(0, import_form_control.getFormControlProperties)({ omit: ["aria-readonly"] })
|
|
265
227
|
),
|
|
@@ -282,7 +244,7 @@ var useColorSlider = ({
|
|
|
282
244
|
return {
|
|
283
245
|
"aria-label": "Slider thumb",
|
|
284
246
|
bg: thumbColor != null ? thumbColor : `hsl(${value}, 100%, 50%)`,
|
|
285
|
-
...pickObject(rest, import_form_control.formControlProperties),
|
|
247
|
+
...(0, import_utils.pickObject)(rest, import_form_control.formControlProperties),
|
|
286
248
|
...props2,
|
|
287
249
|
ref: (0, import_utils.mergeRefs)(ref, thumbRef),
|
|
288
250
|
tabIndex: isInteractive && focusThumbOnChange ? 0 : void 0,
|
package/dist/alpha-slider.mjs
CHANGED
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
SaturationSlider
|
|
3
3
|
} from "./chunk-3KASGDAY.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
ColorSelectorBody
|
|
6
|
+
} from "./chunk-LG5AH76C.mjs";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
ColorSelectorChannels
|
|
9
|
+
} from "./chunk-F7CBAED2.mjs";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
ColorSelectorSwatches
|
|
12
|
+
} from "./chunk-25HMRK5Y.mjs";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "./chunk-
|
|
14
|
+
ColorSelectorProvider,
|
|
15
|
+
useColorSelector
|
|
16
|
+
} from "./chunk-KCQQ4JHN.mjs";
|
|
17
17
|
|
|
18
|
-
// src/color-
|
|
18
|
+
// src/color-selector.tsx
|
|
19
19
|
import {
|
|
20
20
|
ui,
|
|
21
21
|
forwardRef,
|
|
@@ -24,9 +24,9 @@ import {
|
|
|
24
24
|
} from "@yamada-ui/core";
|
|
25
25
|
import { cx } from "@yamada-ui/utils";
|
|
26
26
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
-
var
|
|
27
|
+
var ColorSelector = forwardRef(
|
|
28
28
|
({ size, ...props }, ref) => {
|
|
29
|
-
const [styles, mergedProps] = useMultiComponentStyle("
|
|
29
|
+
const [styles, mergedProps] = useMultiComponentStyle("ColorSelector", {
|
|
30
30
|
size,
|
|
31
31
|
...props
|
|
32
32
|
});
|
|
@@ -57,17 +57,17 @@ var ColorPicker = forwardRef(
|
|
|
57
57
|
getInputProps,
|
|
58
58
|
getSaturationSliderProps,
|
|
59
59
|
...rest
|
|
60
|
-
} =
|
|
60
|
+
} = useColorSelector(computedProps);
|
|
61
61
|
const css = {
|
|
62
62
|
display: "flex",
|
|
63
63
|
flexDirection: "column",
|
|
64
64
|
...styles.container
|
|
65
65
|
};
|
|
66
|
-
return /* @__PURE__ */ jsx(
|
|
66
|
+
return /* @__PURE__ */ jsx(ColorSelectorProvider, { value: { styles, size, ...rest }, children: /* @__PURE__ */ jsxs(
|
|
67
67
|
ui.div,
|
|
68
68
|
{
|
|
69
69
|
ref,
|
|
70
|
-
className: cx("ui-color-
|
|
70
|
+
className: cx("ui-color-selector", className),
|
|
71
71
|
__css: css,
|
|
72
72
|
...getContainerProps(),
|
|
73
73
|
children: [
|
|
@@ -76,7 +76,7 @@ var ColorPicker = forwardRef(
|
|
|
76
76
|
SaturationSlider,
|
|
77
77
|
{
|
|
78
78
|
size,
|
|
79
|
-
className: "ui-color-
|
|
79
|
+
className: "ui-color-selector__saturation-slider",
|
|
80
80
|
__css: { ...styles.saturationSlider },
|
|
81
81
|
...getSaturationSliderProps(
|
|
82
82
|
saturationSliderProps,
|
|
@@ -85,7 +85,7 @@ var ColorPicker = forwardRef(
|
|
|
85
85
|
}
|
|
86
86
|
) : null,
|
|
87
87
|
withPicker ? /* @__PURE__ */ jsx(
|
|
88
|
-
|
|
88
|
+
ColorSelectorBody,
|
|
89
89
|
{
|
|
90
90
|
...{
|
|
91
91
|
withResult,
|
|
@@ -99,9 +99,9 @@ var ColorPicker = forwardRef(
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
) : null,
|
|
102
|
-
withPicker && withChannel ? /* @__PURE__ */ jsx(
|
|
102
|
+
withPicker && withChannel ? /* @__PURE__ */ jsx(ColorSelectorChannels, {}) : null,
|
|
103
103
|
/* @__PURE__ */ jsx(
|
|
104
|
-
|
|
104
|
+
ColorSelectorSwatches,
|
|
105
105
|
{
|
|
106
106
|
...{
|
|
107
107
|
swatchesLabel,
|
|
@@ -119,5 +119,5 @@ var ColorPicker = forwardRef(
|
|
|
119
119
|
);
|
|
120
120
|
|
|
121
121
|
export {
|
|
122
|
-
|
|
122
|
+
ColorSelector
|
|
123
123
|
};
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
ColorSwatch
|
|
3
3
|
} from "./chunk-3N443XSV.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
useColorSelectorContext
|
|
6
|
+
} from "./chunk-KCQQ4JHN.mjs";
|
|
7
7
|
|
|
8
|
-
// src/color-
|
|
8
|
+
// src/color-selector-swatches.tsx
|
|
9
9
|
import { forwardRef, ui } from "@yamada-ui/core";
|
|
10
10
|
import { cx, replaceObject } from "@yamada-ui/utils";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
var
|
|
12
|
+
var ColorSelectorSwatches = forwardRef(
|
|
13
13
|
({
|
|
14
14
|
className,
|
|
15
15
|
swatchesLabel,
|
|
@@ -19,7 +19,7 @@ var ColorPickerSwatches = forwardRef(
|
|
|
19
19
|
swatchesColumns,
|
|
20
20
|
...rest
|
|
21
21
|
}, ref) => {
|
|
22
|
-
const { getSwatchProps, readOnly, styles } =
|
|
22
|
+
const { getSwatchProps, readOnly, styles } = useColorSelectorContext();
|
|
23
23
|
const css = {
|
|
24
24
|
display: "grid",
|
|
25
25
|
gridTemplateColumns: replaceObject(
|
|
@@ -32,7 +32,7 @@ var ColorPickerSwatches = forwardRef(
|
|
|
32
32
|
swatchesLabel ? /* @__PURE__ */ jsx(
|
|
33
33
|
ui.p,
|
|
34
34
|
{
|
|
35
|
-
className: "ui-color-
|
|
35
|
+
className: "ui-color-selector__swatches__label",
|
|
36
36
|
__css: { ...styles.swatchesLabel },
|
|
37
37
|
children: swatchesLabel
|
|
38
38
|
}
|
|
@@ -41,7 +41,7 @@ var ColorPickerSwatches = forwardRef(
|
|
|
41
41
|
ui.div,
|
|
42
42
|
{
|
|
43
43
|
ref,
|
|
44
|
-
className: cx("ui-color-
|
|
44
|
+
className: cx("ui-color-selector__swatches", className),
|
|
45
45
|
__css: css,
|
|
46
46
|
...rest,
|
|
47
47
|
children: swatches.map((color) => /* @__PURE__ */ jsx(
|
|
@@ -64,5 +64,5 @@ var ColorPickerSwatches = forwardRef(
|
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
export {
|
|
67
|
-
|
|
67
|
+
ColorSelectorSwatches
|
|
68
68
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HueSlider
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LDCDIBTZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
AlphaSlider
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TOGKHI2V.mjs";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
useColorSelectorContext
|
|
9
|
+
} from "./chunk-KCQQ4JHN.mjs";
|
|
10
10
|
|
|
11
|
-
// src/color-
|
|
11
|
+
// src/color-selector-sliders.tsx
|
|
12
12
|
import { forwardRef, ui } from "@yamada-ui/core";
|
|
13
13
|
import { cx } from "@yamada-ui/utils";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
var
|
|
15
|
+
var ColorSelectorSliders = forwardRef(
|
|
16
16
|
({
|
|
17
17
|
className,
|
|
18
18
|
hueSliderRef,
|
|
@@ -21,7 +21,7 @@ var ColorPickerSliders = forwardRef(
|
|
|
21
21
|
alphaSliderProps,
|
|
22
22
|
...rest
|
|
23
23
|
}, ref) => {
|
|
24
|
-
let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } =
|
|
24
|
+
let { size, withAlpha, getHueSliderProps, getAlphaSliderProps, styles } = useColorSelectorContext();
|
|
25
25
|
if (size === "full")
|
|
26
26
|
size = "lg";
|
|
27
27
|
const css = {
|
|
@@ -33,7 +33,7 @@ var ColorPickerSliders = forwardRef(
|
|
|
33
33
|
ui.div,
|
|
34
34
|
{
|
|
35
35
|
ref,
|
|
36
|
-
className: cx("ui-color-
|
|
36
|
+
className: cx("ui-color-selector__sliders", className),
|
|
37
37
|
__css: css,
|
|
38
38
|
...rest,
|
|
39
39
|
children: [
|
|
@@ -41,7 +41,7 @@ var ColorPickerSliders = forwardRef(
|
|
|
41
41
|
HueSlider,
|
|
42
42
|
{
|
|
43
43
|
size,
|
|
44
|
-
className: "ui-color-
|
|
44
|
+
className: "ui-color-selector__hue-slider",
|
|
45
45
|
__css: { ...styles.hueSlider },
|
|
46
46
|
...getHueSliderProps(hueSliderProps, hueSliderRef)
|
|
47
47
|
}
|
|
@@ -50,7 +50,7 @@ var ColorPickerSliders = forwardRef(
|
|
|
50
50
|
AlphaSlider,
|
|
51
51
|
{
|
|
52
52
|
size,
|
|
53
|
-
className: "ui-color-
|
|
53
|
+
className: "ui-color-selector__alpha-slider",
|
|
54
54
|
__css: { ...styles.alphaSlider },
|
|
55
55
|
...getAlphaSliderProps(alphaSliderProps, alphaSliderRef)
|
|
56
56
|
}
|
|
@@ -62,5 +62,5 @@ var ColorPickerSliders = forwardRef(
|
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
export {
|
|
65
|
-
|
|
65
|
+
ColorSelectorSliders
|
|
66
66
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/use-color-
|
|
1
|
+
// src/use-color-picker.ts
|
|
2
2
|
import { layoutStyleProperties } from "@yamada-ui/core";
|
|
3
3
|
import {
|
|
4
4
|
useFormControlProps,
|
|
@@ -22,11 +22,11 @@ import {
|
|
|
22
22
|
useUpdateEffect
|
|
23
23
|
} from "@yamada-ui/utils";
|
|
24
24
|
import { useCallback, useRef, useState } from "react";
|
|
25
|
-
var [
|
|
26
|
-
name: "
|
|
27
|
-
errorMessage: `
|
|
25
|
+
var [ColorPickerProvider, useColorPickerContext] = createContext({
|
|
26
|
+
name: "ColorPickerContext",
|
|
27
|
+
errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in "<ColorPicker />"`
|
|
28
28
|
});
|
|
29
|
-
var
|
|
29
|
+
var useColorPicker = ({
|
|
30
30
|
value: valueProp,
|
|
31
31
|
defaultValue,
|
|
32
32
|
fallbackValue,
|
|
@@ -52,10 +52,10 @@ var useColorInput = ({
|
|
|
52
52
|
withPicker,
|
|
53
53
|
withChannel,
|
|
54
54
|
withResult = false,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
withColorSelectorEyeDropper = false,
|
|
56
|
+
colorSelectorVariant,
|
|
57
|
+
colorSelectorSize,
|
|
58
|
+
colorSelectorColorScheme,
|
|
59
59
|
...rest
|
|
60
60
|
}) => {
|
|
61
61
|
rest = useFormControlProps(rest);
|
|
@@ -77,7 +77,7 @@ var useColorInput = ({
|
|
|
77
77
|
const isInputFocused = useRef(false);
|
|
78
78
|
const [inputValue, setInputValue] = useState(value != null ? value : "");
|
|
79
79
|
const [isOpen, setIsOpen] = useState(defaultIsOpen != null ? defaultIsOpen : false);
|
|
80
|
-
const
|
|
80
|
+
const isColorSelectorFull = colorSelectorSize === "full";
|
|
81
81
|
const onOpen = useCallback(() => {
|
|
82
82
|
if (disabled || readOnly)
|
|
83
83
|
return;
|
|
@@ -156,7 +156,7 @@ var useColorInput = ({
|
|
|
156
156
|
},
|
|
157
157
|
[setInputValue, formatInput, setValue]
|
|
158
158
|
);
|
|
159
|
-
const
|
|
159
|
+
const onColorSelectorChange = useCallback(
|
|
160
160
|
(value2) => {
|
|
161
161
|
setValue(value2);
|
|
162
162
|
if (!isInputFocused.current)
|
|
@@ -173,11 +173,11 @@ var useColorInput = ({
|
|
|
173
173
|
const { sRGBHex } = (_a = await onEyeDropperOpen()) != null ? _a : {};
|
|
174
174
|
if (!sRGBHex)
|
|
175
175
|
return;
|
|
176
|
-
|
|
176
|
+
onColorSelectorChange(sRGBHex);
|
|
177
177
|
} catch {
|
|
178
178
|
}
|
|
179
179
|
},
|
|
180
|
-
[onEyeDropperOpen,
|
|
180
|
+
[onEyeDropperOpen, onColorSelectorChange]
|
|
181
181
|
);
|
|
182
182
|
useOutsideClick({
|
|
183
183
|
ref: containerRef,
|
|
@@ -196,7 +196,7 @@ var useColorInput = ({
|
|
|
196
196
|
}, [format, fallbackValue]);
|
|
197
197
|
const getPopoverProps = useCallback(
|
|
198
198
|
(props) => ({
|
|
199
|
-
matchWidth:
|
|
199
|
+
matchWidth: isColorSelectorFull,
|
|
200
200
|
...rest,
|
|
201
201
|
...props,
|
|
202
202
|
isOpen,
|
|
@@ -207,7 +207,7 @@ var useColorInput = ({
|
|
|
207
207
|
trigger: "never",
|
|
208
208
|
closeOnButton: false
|
|
209
209
|
}),
|
|
210
|
-
[
|
|
210
|
+
[isColorSelectorFull, duration, onClose, onOpen, placement, rest, isOpen]
|
|
211
211
|
);
|
|
212
212
|
const getContainerProps = useCallback(
|
|
213
213
|
(props = {}, ref = null) => ({
|
|
@@ -261,14 +261,14 @@ var useColorInput = ({
|
|
|
261
261
|
}),
|
|
262
262
|
[disabled, onEyeDropperClick, readOnly]
|
|
263
263
|
);
|
|
264
|
-
const
|
|
264
|
+
const getSelectorProps = useCallback(
|
|
265
265
|
(props) => ({
|
|
266
266
|
...formControlProps,
|
|
267
267
|
...props,
|
|
268
268
|
value,
|
|
269
269
|
defaultValue: defaultColor,
|
|
270
270
|
fallbackValue,
|
|
271
|
-
onChange:
|
|
271
|
+
onChange: onColorSelectorChange,
|
|
272
272
|
onChangeStart,
|
|
273
273
|
onChangeEnd,
|
|
274
274
|
onSwatchClick: handlerAll(
|
|
@@ -279,20 +279,20 @@ var useColorInput = ({
|
|
|
279
279
|
withPicker,
|
|
280
280
|
withChannel,
|
|
281
281
|
withResult,
|
|
282
|
-
withEyeDropper:
|
|
282
|
+
withEyeDropper: withColorSelectorEyeDropper,
|
|
283
283
|
swatchesLabel,
|
|
284
284
|
swatches,
|
|
285
285
|
swatchesColumns,
|
|
286
|
-
variant:
|
|
287
|
-
size:
|
|
288
|
-
colorScheme:
|
|
286
|
+
variant: colorSelectorVariant,
|
|
287
|
+
size: colorSelectorSize,
|
|
288
|
+
colorScheme: colorSelectorColorScheme
|
|
289
289
|
}),
|
|
290
290
|
[
|
|
291
291
|
formControlProps,
|
|
292
292
|
value,
|
|
293
293
|
fallbackValue,
|
|
294
294
|
defaultColor,
|
|
295
|
-
|
|
295
|
+
onColorSelectorChange,
|
|
296
296
|
onChangeStart,
|
|
297
297
|
onChangeEnd,
|
|
298
298
|
onSwatchClick,
|
|
@@ -302,13 +302,13 @@ var useColorInput = ({
|
|
|
302
302
|
withPicker,
|
|
303
303
|
withChannel,
|
|
304
304
|
withResult,
|
|
305
|
-
|
|
305
|
+
withColorSelectorEyeDropper,
|
|
306
306
|
swatchesLabel,
|
|
307
307
|
swatches,
|
|
308
308
|
swatchesColumns,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
colorSelectorColorScheme,
|
|
310
|
+
colorSelectorSize,
|
|
311
|
+
colorSelectorVariant
|
|
312
312
|
]
|
|
313
313
|
);
|
|
314
314
|
return {
|
|
@@ -318,13 +318,13 @@ var useColorInput = ({
|
|
|
318
318
|
getPopoverProps,
|
|
319
319
|
getContainerProps,
|
|
320
320
|
getFieldProps,
|
|
321
|
-
|
|
321
|
+
getSelectorProps,
|
|
322
322
|
getEyeDropperProps
|
|
323
323
|
};
|
|
324
324
|
};
|
|
325
325
|
|
|
326
326
|
export {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
ColorPickerProvider,
|
|
328
|
+
useColorPickerContext,
|
|
329
|
+
useColorPicker
|
|
330
330
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useColorSelectorContext
|
|
3
|
+
} from "./chunk-KCQQ4JHN.mjs";
|
|
4
|
+
|
|
5
|
+
// src/color-selector-channels.tsx
|
|
6
|
+
import { forwardRef, ui } from "@yamada-ui/core";
|
|
7
|
+
import { Input } from "@yamada-ui/input";
|
|
8
|
+
import { cx } from "@yamada-ui/utils";
|
|
9
|
+
import { useId } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
var ColorSelectorChannels = forwardRef(({ className, channelProps, ...rest }, ref) => {
|
|
12
|
+
const { withAlpha, channels, getChannelProps, styles } = useColorSelectorContext();
|
|
13
|
+
const css = {
|
|
14
|
+
display: "grid",
|
|
15
|
+
gridTemplateColumns: `repeat(${withAlpha ? "4" : "3"}, 1fr)`,
|
|
16
|
+
...styles.channels
|
|
17
|
+
};
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
ui.div,
|
|
20
|
+
{
|
|
21
|
+
ref,
|
|
22
|
+
className: cx("ui-color-selector__channels", className),
|
|
23
|
+
__css: css,
|
|
24
|
+
...rest,
|
|
25
|
+
children: channels.map(({ label, space, value, min, max }) => /* @__PURE__ */ jsx(
|
|
26
|
+
ColorSelectorChannel,
|
|
27
|
+
{
|
|
28
|
+
channelLabel: label,
|
|
29
|
+
...getChannelProps({ ...channelProps, space, value, min, max })
|
|
30
|
+
},
|
|
31
|
+
label
|
|
32
|
+
))
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
var ColorSelectorChannel = forwardRef(({ className, channelLabel, ...rest }, ref) => {
|
|
37
|
+
const id = useId();
|
|
38
|
+
let { size, disabled, readOnly, styles } = useColorSelectorContext();
|
|
39
|
+
if (size === "full")
|
|
40
|
+
size = "lg";
|
|
41
|
+
const css = { ...styles.channel };
|
|
42
|
+
return /* @__PURE__ */ jsxs(ui.div, { className: cx("ui-color-selector__channel", className), children: [
|
|
43
|
+
channelLabel ? /* @__PURE__ */ jsx(
|
|
44
|
+
ui.label,
|
|
45
|
+
{
|
|
46
|
+
htmlFor: id,
|
|
47
|
+
style: { cursor: disabled ? "not-allowed" : void 0 },
|
|
48
|
+
__css: {
|
|
49
|
+
display: "block",
|
|
50
|
+
pointerEvents: readOnly ? "none" : void 0,
|
|
51
|
+
...styles.channelLabel
|
|
52
|
+
},
|
|
53
|
+
children: channelLabel
|
|
54
|
+
}
|
|
55
|
+
) : null,
|
|
56
|
+
/* @__PURE__ */ jsx(Input, { ref, id, size, __css: css, ...rest })
|
|
57
|
+
] });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
ColorSelectorChannels,
|
|
62
|
+
ColorSelectorChannel
|
|
63
|
+
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
pickObject
|
|
3
|
-
} from "./chunk-N2GG5L7Q.mjs";
|
|
4
|
-
|
|
5
|
-
// src/use-color-picker.ts
|
|
1
|
+
// src/use-color-selector.ts
|
|
6
2
|
import {
|
|
7
3
|
useFormControlProps,
|
|
8
4
|
formControlProperties
|
|
@@ -23,7 +19,8 @@ import {
|
|
|
23
19
|
parseToRgba,
|
|
24
20
|
parseToHsla,
|
|
25
21
|
rgbaTo,
|
|
26
|
-
hslaTo
|
|
22
|
+
hslaTo,
|
|
23
|
+
pickObject
|
|
27
24
|
} from "@yamada-ui/utils";
|
|
28
25
|
import { useCallback, useMemo, useRef, useState } from "react";
|
|
29
26
|
var convertHsla = (value, fallback) => {
|
|
@@ -50,11 +47,11 @@ var convertHsva = (value, fallback) => {
|
|
|
50
47
|
const [h, s, v, a] = parseToHsv(value, fallback);
|
|
51
48
|
return { h, s, v, a };
|
|
52
49
|
};
|
|
53
|
-
var [
|
|
54
|
-
name: "
|
|
55
|
-
errorMessage: `
|
|
50
|
+
var [ColorSelectorProvider, useColorSelectorContext] = createContext({
|
|
51
|
+
name: "ColorSelectorContext",
|
|
52
|
+
errorMessage: `useColorSelectorContext returned is 'undefined'. Seems you forgot to wrap the components in "<ColorSelector />"`
|
|
56
53
|
});
|
|
57
|
-
var
|
|
54
|
+
var useColorSelector = ({
|
|
58
55
|
isInvalid,
|
|
59
56
|
...props
|
|
60
57
|
}) => {
|
|
@@ -424,7 +421,7 @@ var useColorPicker = ({
|
|
|
424
421
|
};
|
|
425
422
|
|
|
426
423
|
export {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
424
|
+
ColorSelectorProvider,
|
|
425
|
+
useColorSelectorContext,
|
|
426
|
+
useColorSelector
|
|
430
427
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
ColorSelectorEyeDropper
|
|
3
|
+
} from "./chunk-X3D4OUWF.mjs";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
ColorSelectorSliders
|
|
6
|
+
} from "./chunk-3JCJHD24.mjs";
|
|
7
7
|
import {
|
|
8
8
|
ColorSwatch
|
|
9
9
|
} from "./chunk-3N443XSV.mjs";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
useColorSelectorContext
|
|
12
|
+
} from "./chunk-KCQQ4JHN.mjs";
|
|
13
13
|
|
|
14
|
-
// src/color-
|
|
14
|
+
// src/color-selector-body.tsx
|
|
15
15
|
import { forwardRef, ui } from "@yamada-ui/core";
|
|
16
16
|
import { cx } from "@yamada-ui/utils";
|
|
17
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
-
var
|
|
18
|
+
var ColorSelectorBody = forwardRef(
|
|
19
19
|
({
|
|
20
20
|
className,
|
|
21
21
|
withEyeDropper = true,
|
|
@@ -28,7 +28,7 @@ var ColorPickerBody = forwardRef(
|
|
|
28
28
|
alphaSliderProps,
|
|
29
29
|
...rest
|
|
30
30
|
}, ref) => {
|
|
31
|
-
const { value, eyeDropperSupported, styles } =
|
|
31
|
+
const { value, eyeDropperSupported, styles } = useColorSelectorContext();
|
|
32
32
|
const css = {
|
|
33
33
|
display: "flex",
|
|
34
34
|
w: "full",
|
|
@@ -38,12 +38,12 @@ var ColorPickerBody = forwardRef(
|
|
|
38
38
|
ui.div,
|
|
39
39
|
{
|
|
40
40
|
ref,
|
|
41
|
-
className: cx("ui-color-
|
|
41
|
+
className: cx("ui-color-selector__body", className),
|
|
42
42
|
__css: css,
|
|
43
43
|
...rest,
|
|
44
44
|
children: [
|
|
45
45
|
/* @__PURE__ */ jsx(
|
|
46
|
-
|
|
46
|
+
ColorSelectorSliders,
|
|
47
47
|
{
|
|
48
48
|
...{
|
|
49
49
|
hueSliderRef,
|
|
@@ -53,11 +53,11 @@ var ColorPickerBody = forwardRef(
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
),
|
|
56
|
-
withEyeDropper && eyeDropperSupported ? /* @__PURE__ */ jsx(
|
|
56
|
+
withEyeDropper && eyeDropperSupported ? /* @__PURE__ */ jsx(ColorSelectorEyeDropper, { ref: eyeDropperRef, ...eyeDropperProps }) : null,
|
|
57
57
|
withResult ? /* @__PURE__ */ jsx(
|
|
58
58
|
ColorSwatch,
|
|
59
59
|
{
|
|
60
|
-
className: "ui-color-
|
|
60
|
+
className: "ui-color-selector__result",
|
|
61
61
|
color: value,
|
|
62
62
|
__css: { ...styles.result }
|
|
63
63
|
}
|
|
@@ -69,5 +69,5 @@ var ColorPickerBody = forwardRef(
|
|
|
69
69
|
);
|
|
70
70
|
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
ColorSelectorBody
|
|
73
73
|
};
|