@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.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/alpha-slider.d.mts +62 -0
- package/dist/alpha-slider.d.ts +62 -0
- package/dist/alpha-slider.js +438 -0
- package/dist/alpha-slider.mjs +8 -0
- package/dist/chunk-3EO2XBIZ.mjs +54 -0
- package/dist/chunk-3KASGDAY.mjs +122 -0
- package/dist/chunk-3N443XSV.mjs +105 -0
- package/dist/chunk-73BVTMII.mjs +73 -0
- package/dist/chunk-7QGCTVDG.mjs +66 -0
- package/dist/chunk-DTB2Z3IJ.mjs +278 -0
- package/dist/chunk-EMWFECJD.mjs +123 -0
- package/dist/chunk-HNVFOSAM.mjs +210 -0
- package/dist/chunk-KJS52X4M.mjs +330 -0
- package/dist/chunk-MAHWFXUG.mjs +294 -0
- package/dist/chunk-N2GG5L7Q.mjs +39 -0
- package/dist/chunk-NR2XCTSD.mjs +430 -0
- package/dist/chunk-PTTNJPGJ.mjs +98 -0
- package/dist/chunk-PVWIBTBL.mjs +67 -0
- package/dist/chunk-TFQ62YSQ.mjs +68 -0
- package/dist/chunk-U6OJ4TDG.mjs +127 -0
- package/dist/color-input.d.mts +79 -0
- package/dist/color-input.d.ts +79 -0
- package/dist/color-input.js +2283 -0
- package/dist/color-input.mjs +21 -0
- package/dist/color-picker-body.d.mts +38 -0
- package/dist/color-picker-body.d.ts +38 -0
- package/dist/color-picker-body.js +794 -0
- package/dist/color-picker-body.mjs +14 -0
- package/dist/color-picker-channels.d.mts +20 -0
- package/dist/color-picker-channels.d.ts +20 -0
- package/dist/color-picker-channels.js +101 -0
- package/dist/color-picker-channels.mjs +10 -0
- package/dist/color-picker-eye-dropper.d.mts +10 -0
- package/dist/color-picker-eye-dropper.d.ts +10 -0
- package/dist/color-picker-eye-dropper.js +88 -0
- package/dist/color-picker-eye-dropper.mjs +10 -0
- package/dist/color-picker-sliders.d.mts +30 -0
- package/dist/color-picker-sliders.d.ts +30 -0
- package/dist/color-picker-sliders.js +590 -0
- package/dist/color-picker-sliders.mjs +11 -0
- package/dist/color-picker-swatches.d.mts +34 -0
- package/dist/color-picker-swatches.d.ts +34 -0
- package/dist/color-picker-swatches.js +195 -0
- package/dist/color-picker-swatches.mjs +9 -0
- package/dist/color-picker.d.mts +59 -0
- package/dist/color-picker.d.ts +59 -0
- package/dist/color-picker.js +1790 -0
- package/dist/color-picker.mjs +19 -0
- package/dist/color-swatch.d.mts +36 -0
- package/dist/color-swatch.d.ts +36 -0
- package/dist/color-swatch.js +124 -0
- package/dist/color-swatch.mjs +6 -0
- package/dist/hue-slider.d.mts +56 -0
- package/dist/hue-slider.d.ts +56 -0
- package/dist/hue-slider.js +409 -0
- package/dist/hue-slider.mjs +8 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +2295 -0
- package/dist/index.mjs +36 -0
- package/dist/saturation-slider.d.mts +33 -0
- package/dist/saturation-slider.d.ts +33 -0
- package/dist/saturation-slider.js +414 -0
- package/dist/saturation-slider.mjs +7 -0
- package/dist/use-color-input.d.mts +90 -0
- package/dist/use-color-input.d.ts +90 -0
- package/dist/use-color-input.js +340 -0
- package/dist/use-color-input.mjs +10 -0
- package/dist/use-color-picker.d.mts +131 -0
- package/dist/use-color-picker.d.ts +131 -0
- package/dist/use-color-picker.js +472 -0
- package/dist/use-color-picker.mjs +11 -0
- package/dist/use-color-slider.d.mts +69 -0
- package/dist/use-color-slider.d.ts +69 -0
- package/dist/use-color-slider.js +321 -0
- package/dist/use-color-slider.mjs +7 -0
- package/dist/use-saturation-slider.d.mts +77 -0
- package/dist/use-saturation-slider.d.ts +77 -0
- package/dist/use-saturation-slider.js +302 -0
- package/dist/use-saturation-slider.mjs +6 -0
- package/package.json +88 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useColorSlider
|
|
3
|
+
} from "./chunk-DTB2Z3IJ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/alpha-slider.tsx
|
|
6
|
+
import {
|
|
7
|
+
ui,
|
|
8
|
+
forwardRef,
|
|
9
|
+
omitThemeProps,
|
|
10
|
+
useMultiComponentStyle
|
|
11
|
+
} from "@yamada-ui/core";
|
|
12
|
+
import { alphaToHex, convertColor, cx } from "@yamada-ui/utils";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var defaultOverlays = (color, min, max, withShadow) => {
|
|
15
|
+
let overlays = [
|
|
16
|
+
{
|
|
17
|
+
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%)",
|
|
18
|
+
bgSize: `8px 8px`,
|
|
19
|
+
bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,
|
|
20
|
+
var: [
|
|
21
|
+
{
|
|
22
|
+
name: "checkers",
|
|
23
|
+
token: "colors",
|
|
24
|
+
value: ["blackAlpha.300", "whiteAlpha.300"]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "body",
|
|
28
|
+
token: "colors",
|
|
29
|
+
value: ["whiteAlpha.500", "blackAlpha.500"]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
bgGradient: `linear(to-r, ${convertColor(color)("hex") + alphaToHex(min)}, ${convertColor(color)("hex") + alphaToHex(max)})`
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
if (withShadow)
|
|
38
|
+
overlays = [
|
|
39
|
+
...overlays,
|
|
40
|
+
{
|
|
41
|
+
boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
return overlays;
|
|
45
|
+
};
|
|
46
|
+
var AlphaSlider = forwardRef(
|
|
47
|
+
(props, ref) => {
|
|
48
|
+
const [styles, mergedProps] = useMultiComponentStyle("AlphaSlider", props);
|
|
49
|
+
const {
|
|
50
|
+
className,
|
|
51
|
+
inputProps,
|
|
52
|
+
trackProps,
|
|
53
|
+
thumbProps,
|
|
54
|
+
color = "#ffffff",
|
|
55
|
+
min = 0,
|
|
56
|
+
max = 1,
|
|
57
|
+
withShadow = true,
|
|
58
|
+
overlays = defaultOverlays(color, min, max, withShadow),
|
|
59
|
+
__css,
|
|
60
|
+
...computedProps
|
|
61
|
+
} = omitThemeProps(mergedProps);
|
|
62
|
+
const { getContainerProps, getTrackProps, getInputProps, getThumbProps } = useColorSlider({
|
|
63
|
+
min,
|
|
64
|
+
max,
|
|
65
|
+
step: 0.01,
|
|
66
|
+
thumbColor: "transparent",
|
|
67
|
+
...computedProps
|
|
68
|
+
});
|
|
69
|
+
const css = {
|
|
70
|
+
position: "relative",
|
|
71
|
+
...styles.container,
|
|
72
|
+
...__css
|
|
73
|
+
};
|
|
74
|
+
return /* @__PURE__ */ jsxs(
|
|
75
|
+
ui.div,
|
|
76
|
+
{
|
|
77
|
+
className: cx("ui-alpha-slider", className),
|
|
78
|
+
__css: css,
|
|
79
|
+
...getContainerProps(),
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ jsx(ui.input, { ...getInputProps(inputProps, ref) }),
|
|
82
|
+
overlays.map((props2, index) => /* @__PURE__ */ jsx(
|
|
83
|
+
ui.div,
|
|
84
|
+
{
|
|
85
|
+
className: "ui-alpha-slider__overlay",
|
|
86
|
+
__css: {
|
|
87
|
+
position: "absolute",
|
|
88
|
+
top: 0,
|
|
89
|
+
left: 0,
|
|
90
|
+
right: 0,
|
|
91
|
+
bottom: 0,
|
|
92
|
+
...styles.overlay
|
|
93
|
+
},
|
|
94
|
+
...props2
|
|
95
|
+
},
|
|
96
|
+
index
|
|
97
|
+
)),
|
|
98
|
+
/* @__PURE__ */ jsx(
|
|
99
|
+
ui.div,
|
|
100
|
+
{
|
|
101
|
+
className: "ui-alpha-slider__track",
|
|
102
|
+
__css: {
|
|
103
|
+
position: "relative",
|
|
104
|
+
w: "full",
|
|
105
|
+
h: "full",
|
|
106
|
+
...styles.track
|
|
107
|
+
},
|
|
108
|
+
...getTrackProps(trackProps),
|
|
109
|
+
children: /* @__PURE__ */ jsx(
|
|
110
|
+
ui.div,
|
|
111
|
+
{
|
|
112
|
+
className: "ui-alpha-slider__thumb",
|
|
113
|
+
__css: { ...styles.thumb },
|
|
114
|
+
...getThumbProps(thumbProps)
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
AlphaSlider
|
|
127
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import './color-picker.mjs';
|
|
2
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
3
|
+
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
4
|
+
import { PortalProps } from '@yamada-ui/portal';
|
|
5
|
+
import { ColorSwatchProps } from './color-swatch.mjs';
|
|
6
|
+
import { UseColorInputProps } from './use-color-input.mjs';
|
|
7
|
+
import './hue-slider.mjs';
|
|
8
|
+
import './alpha-slider.mjs';
|
|
9
|
+
import './saturation-slider.mjs';
|
|
10
|
+
import './use-saturation-slider.mjs';
|
|
11
|
+
import 'react';
|
|
12
|
+
import './color-picker-body.mjs';
|
|
13
|
+
import './color-picker-eye-dropper.mjs';
|
|
14
|
+
import '@yamada-ui/button';
|
|
15
|
+
import '@yamada-ui/icon';
|
|
16
|
+
import './color-picker-sliders.mjs';
|
|
17
|
+
import './use-color-slider.mjs';
|
|
18
|
+
import '@yamada-ui/form-control';
|
|
19
|
+
import './color-picker-swatches.mjs';
|
|
20
|
+
import './use-color-picker.mjs';
|
|
21
|
+
import '@yamada-ui/input';
|
|
22
|
+
import '@yamada-ui/utils';
|
|
23
|
+
import '@yamada-ui/popover';
|
|
24
|
+
|
|
25
|
+
type ColorInputOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* If `true`, display the color swatch component.
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
withSwatch?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* If `true`, display the eye dropper component.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
withEyeDropper?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The border color when the input is focused.
|
|
40
|
+
*/
|
|
41
|
+
focusBorderColor?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The border color when the input is invalid.
|
|
44
|
+
*/
|
|
45
|
+
errorBorderColor?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Props for color input container element.
|
|
48
|
+
*/
|
|
49
|
+
containerProps?: Omit<HTMLUIProps<"div">, "children">;
|
|
50
|
+
/**
|
|
51
|
+
* Props for color input element.
|
|
52
|
+
*/
|
|
53
|
+
inputProps?: HTMLUIProps<"input">;
|
|
54
|
+
/**
|
|
55
|
+
* Props for color swatch component.
|
|
56
|
+
*/
|
|
57
|
+
swatchProps?: ColorInputSwatchProps;
|
|
58
|
+
/**
|
|
59
|
+
* Props for color eye dropper component.
|
|
60
|
+
*/
|
|
61
|
+
eyeDropperProps?: ColorInputEyeDropperProps;
|
|
62
|
+
/**
|
|
63
|
+
* Props to be forwarded to the portal component.
|
|
64
|
+
*
|
|
65
|
+
* @default '{ isDisabled: true }'
|
|
66
|
+
*/
|
|
67
|
+
portalProps?: Omit<PortalProps, "children">;
|
|
68
|
+
};
|
|
69
|
+
type ColorInputProps = ThemeProps<"ColorInput"> & UseColorInputProps & ColorInputOptions;
|
|
70
|
+
/**
|
|
71
|
+
* `ColorInput` is a component used by the user to select a color or enter an arbitrary color value.
|
|
72
|
+
*
|
|
73
|
+
* @see Docs https://yamada-ui.com/components/forms/color-input
|
|
74
|
+
*/
|
|
75
|
+
declare const ColorInput: _yamada_ui_core.Component<"input", ColorInputProps>;
|
|
76
|
+
type ColorInputSwatchProps = ColorSwatchProps;
|
|
77
|
+
type ColorInputEyeDropperProps = HTMLUIProps<"button">;
|
|
78
|
+
|
|
79
|
+
export { ColorInput, type ColorInputProps };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import './color-picker.js';
|
|
2
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
3
|
+
import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
|
|
4
|
+
import { PortalProps } from '@yamada-ui/portal';
|
|
5
|
+
import { ColorSwatchProps } from './color-swatch.js';
|
|
6
|
+
import { UseColorInputProps } from './use-color-input.js';
|
|
7
|
+
import './hue-slider.js';
|
|
8
|
+
import './alpha-slider.js';
|
|
9
|
+
import './saturation-slider.js';
|
|
10
|
+
import './use-saturation-slider.js';
|
|
11
|
+
import 'react';
|
|
12
|
+
import './color-picker-body.js';
|
|
13
|
+
import './color-picker-eye-dropper.js';
|
|
14
|
+
import '@yamada-ui/button';
|
|
15
|
+
import '@yamada-ui/icon';
|
|
16
|
+
import './color-picker-sliders.js';
|
|
17
|
+
import './use-color-slider.js';
|
|
18
|
+
import '@yamada-ui/form-control';
|
|
19
|
+
import './color-picker-swatches.js';
|
|
20
|
+
import './use-color-picker.js';
|
|
21
|
+
import '@yamada-ui/input';
|
|
22
|
+
import '@yamada-ui/utils';
|
|
23
|
+
import '@yamada-ui/popover';
|
|
24
|
+
|
|
25
|
+
type ColorInputOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* If `true`, display the color swatch component.
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
withSwatch?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* If `true`, display the eye dropper component.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
withEyeDropper?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The border color when the input is focused.
|
|
40
|
+
*/
|
|
41
|
+
focusBorderColor?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The border color when the input is invalid.
|
|
44
|
+
*/
|
|
45
|
+
errorBorderColor?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Props for color input container element.
|
|
48
|
+
*/
|
|
49
|
+
containerProps?: Omit<HTMLUIProps<"div">, "children">;
|
|
50
|
+
/**
|
|
51
|
+
* Props for color input element.
|
|
52
|
+
*/
|
|
53
|
+
inputProps?: HTMLUIProps<"input">;
|
|
54
|
+
/**
|
|
55
|
+
* Props for color swatch component.
|
|
56
|
+
*/
|
|
57
|
+
swatchProps?: ColorInputSwatchProps;
|
|
58
|
+
/**
|
|
59
|
+
* Props for color eye dropper component.
|
|
60
|
+
*/
|
|
61
|
+
eyeDropperProps?: ColorInputEyeDropperProps;
|
|
62
|
+
/**
|
|
63
|
+
* Props to be forwarded to the portal component.
|
|
64
|
+
*
|
|
65
|
+
* @default '{ isDisabled: true }'
|
|
66
|
+
*/
|
|
67
|
+
portalProps?: Omit<PortalProps, "children">;
|
|
68
|
+
};
|
|
69
|
+
type ColorInputProps = ThemeProps<"ColorInput"> & UseColorInputProps & ColorInputOptions;
|
|
70
|
+
/**
|
|
71
|
+
* `ColorInput` is a component used by the user to select a color or enter an arbitrary color value.
|
|
72
|
+
*
|
|
73
|
+
* @see Docs https://yamada-ui.com/components/forms/color-input
|
|
74
|
+
*/
|
|
75
|
+
declare const ColorInput: _yamada_ui_core.Component<"input", ColorInputProps>;
|
|
76
|
+
type ColorInputSwatchProps = ColorSwatchProps;
|
|
77
|
+
type ColorInputEyeDropperProps = HTMLUIProps<"button">;
|
|
78
|
+
|
|
79
|
+
export { ColorInput, type ColorInputProps };
|