@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,195 @@
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-swatches.tsx
21
+ var color_picker_swatches_exports = {};
22
+ __export(color_picker_swatches_exports, {
23
+ ColorPickerSwatches: () => ColorPickerSwatches
24
+ });
25
+ module.exports = __toCommonJS(color_picker_swatches_exports);
26
+ var import_core2 = require("@yamada-ui/core");
27
+ var import_utils3 = require("@yamada-ui/utils");
28
+
29
+ // src/color-swatch.tsx
30
+ var import_core = require("@yamada-ui/core");
31
+ var import_utils = require("@yamada-ui/utils");
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var defaultOverlays = (background, withShadow) => {
34
+ let overlays = [
35
+ {
36
+ 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%)",
37
+ bgSize: `8px 8px`,
38
+ bgPosition: `0 0, 0 4px, 4px -4px, -4px 0`,
39
+ var: [
40
+ {
41
+ name: "checkers",
42
+ token: "colors",
43
+ value: ["blackAlpha.300", "whiteAlpha.300"]
44
+ },
45
+ {
46
+ name: "body",
47
+ token: "colors",
48
+ value: ["whiteAlpha.500", "blackAlpha.500"]
49
+ }
50
+ ]
51
+ },
52
+ { background }
53
+ ];
54
+ if (withShadow)
55
+ overlays = [
56
+ ...overlays,
57
+ {
58
+ boxShadow: `rgba(0, 0, 0, .1) 0 0 0 1px inset, rgb(0, 0, 0, .15) 0 0 4px inset`
59
+ }
60
+ ];
61
+ return overlays;
62
+ };
63
+ var ColorSwatch = (0, import_core.forwardRef)((props, ref) => {
64
+ const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("ColorSwatch", props);
65
+ const {
66
+ className,
67
+ color = "#ffffff00",
68
+ withShadow = true,
69
+ overlays = defaultOverlays(color, withShadow),
70
+ isRounded,
71
+ __css,
72
+ ...rest
73
+ } = (0, import_core.omitThemeProps)(mergedProps);
74
+ const css = {
75
+ position: "relative",
76
+ _before: {
77
+ content: `""`,
78
+ display: "block",
79
+ h: 0,
80
+ pb: "100%"
81
+ },
82
+ "& > *": {
83
+ overflow: "hidden",
84
+ position: "absolute",
85
+ top: "0",
86
+ right: "0",
87
+ bottom: "0",
88
+ left: "0",
89
+ display: "flex",
90
+ justifyContent: "center",
91
+ alignItems: "center",
92
+ w: "100%",
93
+ h: "100%"
94
+ },
95
+ ...styles.container,
96
+ ...__css
97
+ };
98
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
99
+ import_core.ui.div,
100
+ {
101
+ ref,
102
+ className: (0, import_utils.cx)("ui-color-swatch", className),
103
+ ...isRounded ? { rounded: "full" } : {},
104
+ __css: css,
105
+ ...rest,
106
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { ...isRounded ? { rounded: "full" } : {}, children: overlays.map((props2, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
107
+ import_core.ui.div,
108
+ {
109
+ __css: {
110
+ position: "absolute",
111
+ top: 0,
112
+ left: 0,
113
+ right: 0,
114
+ bottom: 0,
115
+ ...styles.overlay
116
+ },
117
+ ...isRounded ? { rounded: "full" } : {},
118
+ ...props2
119
+ },
120
+ index
121
+ )) })
122
+ }
123
+ );
124
+ });
125
+
126
+ // src/use-color-picker.ts
127
+ var import_form_control = require("@yamada-ui/form-control");
128
+ var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
129
+ var import_use_eye_dropper = require("@yamada-ui/use-eye-dropper");
130
+ var import_utils2 = require("@yamada-ui/utils");
131
+ var import_react = require("react");
132
+ var [ColorPickerProvider, useColorPickerContext] = (0, import_utils2.createContext)({
133
+ name: "ColorPickerContext",
134
+ errorMessage: `useColorPickerContext returned is 'undefined'. Seems you forgot to wrap the components in "<ColorPicker />"`
135
+ });
136
+
137
+ // src/color-picker-swatches.tsx
138
+ var import_jsx_runtime2 = require("react/jsx-runtime");
139
+ var ColorPickerSwatches = (0, import_core2.forwardRef)(
140
+ ({
141
+ className,
142
+ swatchesLabel,
143
+ swatches,
144
+ swatchesContainerProps,
145
+ swatchProps,
146
+ swatchesColumns,
147
+ ...rest
148
+ }, ref) => {
149
+ const { getSwatchProps, readOnly, styles } = useColorPickerContext();
150
+ const css = {
151
+ display: "grid",
152
+ gridTemplateColumns: (0, import_utils3.replaceObject)(
153
+ swatchesColumns,
154
+ (value) => value != null ? `repeat(${value}, minmax(0, 1fr))` : void 0
155
+ ),
156
+ ...styles.swatches
157
+ };
158
+ return (swatches == null ? void 0 : swatches.length) ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.ui.div, { ...swatchesContainerProps, children: [
159
+ swatchesLabel ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
160
+ import_core2.ui.p,
161
+ {
162
+ className: "ui-color-picker__swatches__label",
163
+ __css: { ...styles.swatchesLabel },
164
+ children: swatchesLabel
165
+ }
166
+ ) : null,
167
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
168
+ import_core2.ui.div,
169
+ {
170
+ ref,
171
+ className: (0, import_utils3.cx)("ui-color-picker__swatches", className),
172
+ __css: css,
173
+ ...rest,
174
+ children: swatches.map((color) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
175
+ ColorSwatch,
176
+ {
177
+ as: "button",
178
+ __css: {
179
+ boxSize: "full",
180
+ pointerEvents: readOnly ? "none" : void 0,
181
+ ...styles.swatch
182
+ },
183
+ ...getSwatchProps({ color, ...swatchProps })
184
+ },
185
+ color
186
+ ))
187
+ }
188
+ )
189
+ ] }) : null;
190
+ }
191
+ );
192
+ // Annotate the CommonJS export names for ESM import in node:
193
+ 0 && (module.exports = {
194
+ ColorPickerSwatches
195
+ });
@@ -0,0 +1,9 @@
1
+ import {
2
+ ColorPickerSwatches
3
+ } from "./chunk-TFQ62YSQ.mjs";
4
+ import "./chunk-3N443XSV.mjs";
5
+ import "./chunk-NR2XCTSD.mjs";
6
+ import "./chunk-N2GG5L7Q.mjs";
7
+ export {
8
+ ColorPickerSwatches
9
+ };
@@ -0,0 +1,59 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
3
+ import { ForwardedRef } from 'react';
4
+ import { ColorPickerBodyProps } from './color-picker-body.mjs';
5
+ import { ColorPickerSwatchesProps } from './color-picker-swatches.mjs';
6
+ import { SaturationSliderProps } from './saturation-slider.mjs';
7
+ import { UseColorPickerProps } from './use-color-picker.mjs';
8
+ import './color-picker-eye-dropper.mjs';
9
+ import '@yamada-ui/button';
10
+ import '@yamada-ui/icon';
11
+ import './color-picker-sliders.mjs';
12
+ import './alpha-slider.mjs';
13
+ import './use-color-slider.mjs';
14
+ import '@yamada-ui/form-control';
15
+ import './hue-slider.mjs';
16
+ import './color-swatch.mjs';
17
+ import './use-saturation-slider.mjs';
18
+ import '@yamada-ui/input';
19
+ import '@yamada-ui/utils';
20
+
21
+ type ColorPickerOptions = {
22
+ /**
23
+ * If `true`, display the saturation, hue, alpha, channels and eye dropper component.
24
+ *
25
+ * @default true
26
+ */
27
+ withPicker?: boolean;
28
+ /**
29
+ * If `true`, display the channels component.
30
+ *
31
+ * @default true
32
+ */
33
+ withChannel?: boolean;
34
+ /**
35
+ * Props for the color picker input element.
36
+ */
37
+ inputProps?: HTMLUIProps<"input">;
38
+ /**
39
+ * Ref for the saturation slider component.
40
+ */
41
+ saturationSliderRef?: ForwardedRef<HTMLInputElement>;
42
+ /**
43
+ * Props for the saturation slider component.
44
+ */
45
+ saturationSliderProps?: Omit<SaturationSliderProps, "value" | "defaultValue">;
46
+ /**
47
+ * Props for the swatches component.
48
+ */
49
+ swatchesProps?: ColorPickerSwatchesProps;
50
+ };
51
+ type ColorPickerProps = ThemeProps<"ColorPicker"> & UseColorPickerProps & ColorPickerOptions & Pick<ColorPickerBodyProps, "withResult" | "withEyeDropper" | "eyeDropperRef" | "eyeDropperProps" | "hueSliderRef" | "hueSliderProps" | "alphaSliderRef" | "alphaSliderProps"> & Pick<ColorPickerSwatchesProps, "swatchesLabel" | "swatches" | "swatchesColumns" | "swatchProps">;
52
+ /**
53
+ * `ColorPicker` is a component used by the user to select a color.
54
+ *
55
+ * @see Docs https://yamada-ui.com/components/forms/color-picker
56
+ */
57
+ declare const ColorPicker: _yamada_ui_core.Component<"input", ColorPickerProps>;
58
+
59
+ export { ColorPicker, type ColorPickerProps };
@@ -0,0 +1,59 @@
1
+ import * as _yamada_ui_core from '@yamada-ui/core';
2
+ import { ThemeProps, HTMLUIProps } from '@yamada-ui/core';
3
+ import { ForwardedRef } from 'react';
4
+ import { ColorPickerBodyProps } from './color-picker-body.js';
5
+ import { ColorPickerSwatchesProps } from './color-picker-swatches.js';
6
+ import { SaturationSliderProps } from './saturation-slider.js';
7
+ import { UseColorPickerProps } from './use-color-picker.js';
8
+ import './color-picker-eye-dropper.js';
9
+ import '@yamada-ui/button';
10
+ import '@yamada-ui/icon';
11
+ import './color-picker-sliders.js';
12
+ import './alpha-slider.js';
13
+ import './use-color-slider.js';
14
+ import '@yamada-ui/form-control';
15
+ import './hue-slider.js';
16
+ import './color-swatch.js';
17
+ import './use-saturation-slider.js';
18
+ import '@yamada-ui/input';
19
+ import '@yamada-ui/utils';
20
+
21
+ type ColorPickerOptions = {
22
+ /**
23
+ * If `true`, display the saturation, hue, alpha, channels and eye dropper component.
24
+ *
25
+ * @default true
26
+ */
27
+ withPicker?: boolean;
28
+ /**
29
+ * If `true`, display the channels component.
30
+ *
31
+ * @default true
32
+ */
33
+ withChannel?: boolean;
34
+ /**
35
+ * Props for the color picker input element.
36
+ */
37
+ inputProps?: HTMLUIProps<"input">;
38
+ /**
39
+ * Ref for the saturation slider component.
40
+ */
41
+ saturationSliderRef?: ForwardedRef<HTMLInputElement>;
42
+ /**
43
+ * Props for the saturation slider component.
44
+ */
45
+ saturationSliderProps?: Omit<SaturationSliderProps, "value" | "defaultValue">;
46
+ /**
47
+ * Props for the swatches component.
48
+ */
49
+ swatchesProps?: ColorPickerSwatchesProps;
50
+ };
51
+ type ColorPickerProps = ThemeProps<"ColorPicker"> & UseColorPickerProps & ColorPickerOptions & Pick<ColorPickerBodyProps, "withResult" | "withEyeDropper" | "eyeDropperRef" | "eyeDropperProps" | "hueSliderRef" | "hueSliderProps" | "alphaSliderRef" | "alphaSliderProps"> & Pick<ColorPickerSwatchesProps, "swatchesLabel" | "swatches" | "swatchesColumns" | "swatchProps">;
52
+ /**
53
+ * `ColorPicker` is a component used by the user to select a color.
54
+ *
55
+ * @see Docs https://yamada-ui.com/components/forms/color-picker
56
+ */
57
+ declare const ColorPicker: _yamada_ui_core.Component<"input", ColorPickerProps>;
58
+
59
+ export { ColorPicker, type ColorPickerProps };