@strapi/plugin-color-picker 0.0.0-next.fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a → 0.0.0-next.fd9757603c653ca239c45d6e28ab536d2dae0b39

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 (75) hide show
  1. package/LICENSE +34 -12
  2. package/dist/_chunks/ColorPickerInput-0lOoTrf0.js +206 -0
  3. package/dist/_chunks/{ColorPickerInput-1e9c7a15.js.map → ColorPickerInput-0lOoTrf0.js.map} +1 -1
  4. package/dist/_chunks/ColorPickerInput-fKB6YXW8.mjs +185 -0
  5. package/dist/_chunks/{ColorPickerInput-3335ebf5.mjs.map → ColorPickerInput-fKB6YXW8.mjs.map} +1 -1
  6. package/dist/_chunks/cs-4GdZY0p6.js +16 -0
  7. package/dist/_chunks/cs-4GdZY0p6.js.map +1 -0
  8. package/dist/_chunks/{cs-70e06424.mjs → cs-A2xRj-2-.mjs} +3 -3
  9. package/dist/_chunks/cs-A2xRj-2-.mjs.map +1 -0
  10. package/dist/_chunks/{en-096b1095.mjs → en-L6ZZWDJv.mjs} +3 -3
  11. package/dist/_chunks/en-L6ZZWDJv.mjs.map +1 -0
  12. package/dist/_chunks/en-WeRHjVEB.js +19 -0
  13. package/dist/_chunks/en-WeRHjVEB.js.map +1 -0
  14. package/dist/_chunks/index-OJYEuoCq.js +117 -0
  15. package/dist/_chunks/index-OJYEuoCq.js.map +1 -0
  16. package/dist/_chunks/index-uOrtnJpz.mjs +116 -0
  17. package/dist/_chunks/index-uOrtnJpz.mjs.map +1 -0
  18. package/dist/_chunks/{ru-05c0aa5b.mjs → ru-LLXYEOwl.mjs} +3 -3
  19. package/dist/_chunks/ru-LLXYEOwl.mjs.map +1 -0
  20. package/dist/_chunks/ru-UXN_ByI9.js +19 -0
  21. package/dist/_chunks/ru-UXN_ByI9.js.map +1 -0
  22. package/dist/_chunks/sv-3-Yk9bKb.js +16 -0
  23. package/dist/_chunks/sv-3-Yk9bKb.js.map +1 -0
  24. package/dist/_chunks/{sv-6ccbf5f0.mjs → sv-QqRPNQLw.mjs} +3 -3
  25. package/dist/_chunks/sv-QqRPNQLw.mjs.map +1 -0
  26. package/dist/_chunks/tr-AbD-f8F0.js +16 -0
  27. package/dist/_chunks/tr-AbD-f8F0.js.map +1 -0
  28. package/dist/_chunks/{tr-34587a44.mjs → tr-qYGSw8gH.mjs} +3 -3
  29. package/dist/_chunks/tr-qYGSw8gH.mjs.map +1 -0
  30. package/dist/_chunks/zh-c23gv_oM.js +16 -0
  31. package/dist/_chunks/zh-c23gv_oM.js.map +1 -0
  32. package/dist/_chunks/{zh-667ba169.mjs → zh-fPTOIT6s.mjs} +3 -3
  33. package/dist/_chunks/zh-fPTOIT6s.mjs.map +1 -0
  34. package/dist/admin/index.js +8 -1
  35. package/dist/admin/index.js.map +1 -1
  36. package/dist/admin/index.mjs +3 -3
  37. package/dist/server/index.js +12 -1
  38. package/dist/server/index.js.map +1 -1
  39. package/dist/server/index.mjs +6 -5
  40. package/dist/server/index.mjs.map +1 -1
  41. package/dist/server/{index.d.ts → src/index.d.ts} +1 -0
  42. package/dist/server/src/index.d.ts.map +1 -0
  43. package/dist/server/{register.d.ts → src/register.d.ts} +1 -0
  44. package/dist/server/src/register.d.ts.map +1 -0
  45. package/package.json +22 -26
  46. package/dist/_chunks/ColorPickerInput-1e9c7a15.js +0 -47
  47. package/dist/_chunks/ColorPickerInput-3335ebf5.mjs +0 -168
  48. package/dist/_chunks/cs-67f98136.js +0 -2
  49. package/dist/_chunks/cs-67f98136.js.map +0 -1
  50. package/dist/_chunks/cs-70e06424.mjs.map +0 -1
  51. package/dist/_chunks/en-096b1095.mjs.map +0 -1
  52. package/dist/_chunks/en-32ea9fdb.js +0 -2
  53. package/dist/_chunks/en-32ea9fdb.js.map +0 -1
  54. package/dist/_chunks/index-3cecbc68.js +0 -37
  55. package/dist/_chunks/index-3cecbc68.js.map +0 -1
  56. package/dist/_chunks/index-e75c6fdb.mjs +0 -730
  57. package/dist/_chunks/index-e75c6fdb.mjs.map +0 -1
  58. package/dist/_chunks/ru-05c0aa5b.mjs.map +0 -1
  59. package/dist/_chunks/ru-c5a712be.js +0 -2
  60. package/dist/_chunks/ru-c5a712be.js.map +0 -1
  61. package/dist/_chunks/sv-6ccbf5f0.mjs.map +0 -1
  62. package/dist/_chunks/sv-e4ea8db8.js +0 -2
  63. package/dist/_chunks/sv-e4ea8db8.js.map +0 -1
  64. package/dist/_chunks/tr-34587a44.mjs.map +0 -1
  65. package/dist/_chunks/tr-fb5cfb93.js +0 -2
  66. package/dist/_chunks/tr-fb5cfb93.js.map +0 -1
  67. package/dist/_chunks/zh-667ba169.mjs.map +0 -1
  68. package/dist/_chunks/zh-b25c84c2.js +0 -2
  69. package/dist/_chunks/zh-b25c84c2.js.map +0 -1
  70. /package/dist/admin/{components → src/components}/ColorPickerIcon.d.ts +0 -0
  71. /package/dist/admin/{components → src/components}/ColorPickerInput.d.ts +0 -0
  72. /package/dist/admin/{hooks → src/hooks}/useComposeRefs.d.ts +0 -0
  73. /package/dist/admin/{index.d.ts → src/index.d.ts} +0 -0
  74. /package/dist/admin/{pluginId.d.ts → src/pluginId.d.ts} +0 -0
  75. /package/dist/admin/{utils → src/utils}/getTrad.d.ts +0 -0
package/LICENSE CHANGED
@@ -1,15 +1,37 @@
1
1
  Copyright (c) 2015-present Strapi Solutions SAS
2
-
2
+
3
3
  Portions of the Strapi software are licensed as follows:
4
-
5
- * If you are accessing or using any component of the software that resides under an "ee/" directory, then you are deemed to be using our Enterprise Editionof the software and you understand and agree that the software is not licensed under the "MIT Expat" license as set forth below but instead, all the software you access is licensed under the license defined in "strapi/packages/core/admin/ee/LICENSE" and located at https://github.com/strapi/strapi/blob/a76b557047e9ef1c168dbf1b6cf879bcc3022de6/packages/core/admin/ee/LICENSE, unless (a) you or the company you represent has signed an alternative agreement referencing this code, then such signed agreement applies or (b) you are using the software in connection with a subscription to our cloud offering, then the terms of the agreement relevant to the cloud offering which you have assented to apply and the software licenses included in that agreement shall apply.
6
-
7
- * If (a) you are not accessing or using the software that resides under an “ee/” directory and therefore you are only accessing or using our “Community Edition” of the Software and (b) you have no registered account on our cloud offering, then we are providing you the software under the "MIT Expat" license as set forth below.
8
-
4
+
5
+ * All software that resides under an "ee/" directory (theEE Software), if that directory exists, is licensed under the license defined below.
6
+
7
+ Enterprise License
8
+
9
+ If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
10
+ https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
11
+ represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
12
+ agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
13
+ Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
14
+
15
+ BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
16
+ IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
17
+ HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
18
+ THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
19
+ IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
20
+
21
+ * All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
22
+
9
23
  MIT Expat License
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ of this software and associated documentation files (the "Software"), to deal
27
+ in the Software without restriction, including without limitation the rights
28
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ copies of the Software, and to permit persons to whom the Software is
30
+ furnished to do so, subject to the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be included in all
33
+ copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
37
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const icons = require("@strapi/icons");
7
+ const reactColorful = require("react-colorful");
8
+ const reactIntl = require("react-intl");
9
+ const styled = require("styled-components");
10
+ const index = require("./index-OJYEuoCq.js");
11
+ require("@strapi/helper-plugin");
12
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule)
15
+ return e;
16
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
17
+ if (e) {
18
+ for (const k in e) {
19
+ if (k !== "default") {
20
+ const d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: () => e[k]
24
+ });
25
+ }
26
+ }
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
32
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
33
+ function setRef(ref, value) {
34
+ if (typeof ref === "function") {
35
+ ref(value);
36
+ } else if (ref !== null && ref !== void 0) {
37
+ ref.current = value;
38
+ }
39
+ }
40
+ function composeRefs(...refs) {
41
+ return (node) => refs.forEach((ref) => setRef(ref, node));
42
+ }
43
+ function useComposedRefs(...refs) {
44
+ return React__namespace.useCallback(composeRefs(...refs), refs);
45
+ }
46
+ const ColorPreview = styled__default.default.div`
47
+ border-radius: 50%;
48
+ width: 20px;
49
+ height: 20px;
50
+ margin-right: 10px;
51
+ background-color: ${(props) => props.color};
52
+ border: 1px solid rgba(0, 0, 0, 0.1);
53
+ `;
54
+ const ColorPicker = styled__default.default(reactColorful.HexColorPicker)`
55
+ && {
56
+ width: 100%;
57
+ aspect-ratio: 1.5;
58
+ }
59
+
60
+ .react-colorful__pointer {
61
+ width: ${({ theme }) => theme.spaces[3]};
62
+ height: ${({ theme }) => theme.spaces[3]};
63
+ }
64
+
65
+ .react-colorful__saturation {
66
+ border-radius: ${({ theme }) => theme.spaces[1]};
67
+ border-bottom: none;
68
+ }
69
+
70
+ .react-colorful__hue {
71
+ border-radius: 10px;
72
+ height: ${({ theme }) => theme.spaces[3]};
73
+ margin-top: ${({ theme }) => theme.spaces[2]};
74
+ }
75
+ `;
76
+ const ColorPickerToggle = styled__default.default(designSystem.BaseButton)`
77
+ display: flex;
78
+ justify-content: space-between;
79
+ align-items: center;
80
+
81
+ svg {
82
+ width: ${({ theme }) => theme.spaces[2]};
83
+ height: ${({ theme }) => theme.spaces[2]};
84
+ }
85
+
86
+ svg > path {
87
+ fill: ${({ theme }) => theme.colors.neutral500};
88
+ justify-self: flex-end;
89
+ }
90
+ `;
91
+ const ColorPickerPopover = styled__default.default(designSystem.Popover)`
92
+ padding: ${({ theme }) => theme.spaces[2]};
93
+ min-height: 270px;
94
+ `;
95
+ const ColorPickerInput = React__namespace.forwardRef(
96
+ ({
97
+ attribute,
98
+ description,
99
+ disabled = false,
100
+ error,
101
+ intlLabel,
102
+ labelAction,
103
+ name,
104
+ onChange,
105
+ required = false,
106
+ value = ""
107
+ }, forwardedRef) => {
108
+ const [showColorPicker, setShowColorPicker] = React__namespace.useState(false);
109
+ const colorPickerButtonRef = React__namespace.useRef(null);
110
+ const { formatMessage } = reactIntl.useIntl();
111
+ const color = value || "#000000";
112
+ const handleBlur = (e) => {
113
+ e.preventDefault();
114
+ if (!e.currentTarget.contains(e.relatedTarget)) {
115
+ setShowColorPicker(false);
116
+ }
117
+ };
118
+ const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);
119
+ return /* @__PURE__ */ jsxRuntime.jsx(
120
+ designSystem.Field,
121
+ {
122
+ name,
123
+ id: name,
124
+ error,
125
+ hint: description && formatMessage(description),
126
+ required,
127
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
128
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { action: labelAction, children: formatMessage(intlLabel) }),
129
+ /* @__PURE__ */ jsxRuntime.jsxs(
130
+ ColorPickerToggle,
131
+ {
132
+ ref: composedRefs,
133
+ "aria-label": formatMessage({
134
+ id: index.getTrad("color-picker.toggle.aria-label"),
135
+ defaultMessage: "Color picker toggle"
136
+ }),
137
+ "aria-controls": "color-picker-value",
138
+ "aria-haspopup": "dialog",
139
+ "aria-expanded": showColorPicker,
140
+ "aria-disabled": disabled,
141
+ disabled,
142
+ onClick: () => setShowColorPicker(!showColorPicker),
143
+ children: [
144
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
145
+ /* @__PURE__ */ jsxRuntime.jsx(ColorPreview, { color }),
146
+ /* @__PURE__ */ jsxRuntime.jsx(
147
+ designSystem.Typography,
148
+ {
149
+ style: { textTransform: "uppercase" },
150
+ textColor: value ? void 0 : "neutral600",
151
+ variant: "omega",
152
+ children: color
153
+ }
154
+ )
155
+ ] }),
156
+ /* @__PURE__ */ jsxRuntime.jsx(icons.CarretDown, { "aria-hidden": true })
157
+ ]
158
+ }
159
+ ),
160
+ showColorPicker && /* @__PURE__ */ jsxRuntime.jsx(
161
+ ColorPickerPopover,
162
+ {
163
+ onBlur: handleBlur,
164
+ role: "dialog",
165
+ source: colorPickerButtonRef,
166
+ spacing: 4,
167
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.FocusTrap, { onEscape: () => setShowColorPicker(false), children: [
168
+ /* @__PURE__ */ jsxRuntime.jsx(
169
+ ColorPicker,
170
+ {
171
+ color,
172
+ onChange: (hexValue) => onChange({ target: { name, value: hexValue, type: attribute.type } })
173
+ }
174
+ ),
175
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { paddingTop: 3, paddingLeft: 4, justifyContent: "flex-end", children: [
176
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingRight: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", as: "label", textColor: "neutral600", children: formatMessage({
177
+ id: index.getTrad("color-picker.input.format"),
178
+ defaultMessage: "HEX"
179
+ }) }) }),
180
+ /* @__PURE__ */ jsxRuntime.jsx(
181
+ designSystem.FieldInput,
182
+ {
183
+ id: "color-picker-value",
184
+ "aria-label": formatMessage({
185
+ id: index.getTrad("color-picker.input.aria-label"),
186
+ defaultMessage: "Color picker input"
187
+ }),
188
+ style: { textTransform: "uppercase" },
189
+ value,
190
+ placeholder: "#000000",
191
+ onChange
192
+ }
193
+ )
194
+ ] })
195
+ ] })
196
+ }
197
+ ),
198
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldHint, {}),
199
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldError, {})
200
+ ] })
201
+ }
202
+ );
203
+ }
204
+ );
205
+ exports.ColorPickerInput = ColorPickerInput;
206
+ //# sourceMappingURL=ColorPickerInput-0lOoTrf0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerInput-1e9c7a15.js","sources":["../../admin/src/hooks/useComposeRefs.ts","../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * Takes multiple React like refs either React.Ref or a callback:\n * (node: T) => void and returns a single function that can be\n * passed to a React component as a ref.\n *\n * Example:\n * ```tsx\n * import { useComposedRefs } from '../hooks/useComposedRefs';\n *\n * const Component = React.forwardRef<HTMLInputElement, ComponentProps>((props, forwardedRef) => {\n * const ref = useComposedRefs(internalRef, forwardedRef);\n *\n * React.useEffect(() => {\n * ref.current.focus();\n * }, [ref]);\n *\n * return <input ref={ref} />\n * }\n * ```\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from 'react';\n\nimport {\n BaseButton,\n Box,\n Field,\n FieldError,\n FieldHint,\n FieldInput,\n FieldLabel,\n Flex,\n FocusTrap,\n Popover,\n Typography,\n} from '@strapi/design-system';\nimport { CarretDown } from '@strapi/icons';\nimport { HexColorPicker } from 'react-colorful';\nimport { useIntl, MessageDescriptor } from 'react-intl';\nimport styled from 'styled-components';\n\nimport { useComposedRefs } from '../hooks/useComposeRefs';\nimport { getTrad } from '../utils/getTrad';\n\nconst ColorPreview = styled.div`\n border-radius: 50%;\n width: 20px;\n height: 20px;\n margin-right: 10px;\n background-color: ${(props) => props.color};\n border: 1px solid rgba(0, 0, 0, 0.1);\n`;\n\nconst ColorPicker = styled(HexColorPicker)`\n && {\n width: 100%;\n aspect-ratio: 1.5;\n }\n\n .react-colorful__pointer {\n width: ${({ theme }) => theme.spaces[3]};\n height: ${({ theme }) => theme.spaces[3]};\n }\n\n .react-colorful__saturation {\n border-radius: ${({ theme }) => theme.spaces[1]};\n border-bottom: none;\n }\n\n .react-colorful__hue {\n border-radius: 10px;\n height: ${({ theme }) => theme.spaces[3]};\n margin-top: ${({ theme }) => theme.spaces[2]};\n }\n`;\n\nconst ColorPickerToggle = styled(BaseButton)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n svg {\n width: ${({ theme }) => theme.spaces[2]};\n height: ${({ theme }) => theme.spaces[2]};\n }\n\n svg > path {\n fill: ${({ theme }) => theme.colors.neutral500};\n justify-self: flex-end;\n }\n`;\n\nconst ColorPickerPopover = styled(Popover)`\n padding: ${({ theme }) => theme.spaces[2]};\n min-height: 270px;\n`;\n\n/**\n * TODO: A lot of these props should extend `FieldProps`\n */\ninterface ColorPickerInputProps {\n intlLabel: MessageDescriptor;\n /**\n * TODO: this should be extended from `FieldInputProps['onChange']\n * but that conflicts with it's secondary usage in `HexColorPicker`\n */\n onChange: (event: { target: { name: string; value: string; type: string } }) => void;\n attribute: { type: string; [key: string]: unknown };\n name: string;\n description?: MessageDescriptor;\n disabled?: boolean;\n error?: string;\n labelAction?: React.ReactNode;\n required?: boolean;\n value?: string;\n}\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n (\n {\n attribute,\n description,\n disabled = false,\n error,\n intlLabel,\n labelAction,\n name,\n onChange,\n required = false,\n value = '',\n },\n forwardedRef\n ) => {\n const [showColorPicker, setShowColorPicker] = React.useState(false);\n const colorPickerButtonRef = React.useRef<HTMLButtonElement>(null!);\n const { formatMessage } = useIntl();\n const color = value || '#000000';\n\n const handleBlur: React.FocusEventHandler<HTMLDivElement> = (e) => {\n e.preventDefault();\n\n if (!e.currentTarget.contains(e.relatedTarget)) {\n setShowColorPicker(false);\n }\n };\n\n const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);\n\n return (\n <Field\n name={name}\n id={name}\n // GenericInput calls formatMessage and returns a string for the error\n error={error}\n hint={description && formatMessage(description)}\n required={required}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <FieldLabel action={labelAction}>{formatMessage(intlLabel)}</FieldLabel>\n <ColorPickerToggle\n ref={composedRefs}\n aria-label={formatMessage({\n id: getTrad('color-picker.toggle.aria-label'),\n defaultMessage: 'Color picker toggle',\n })}\n aria-controls=\"color-picker-value\"\n aria-haspopup=\"dialog\"\n aria-expanded={showColorPicker}\n aria-disabled={disabled}\n disabled={disabled}\n onClick={() => setShowColorPicker(!showColorPicker)}\n >\n <Flex>\n <ColorPreview color={color} />\n <Typography\n style={{ textTransform: 'uppercase' }}\n textColor={value ? undefined : 'neutral600'}\n variant=\"omega\"\n >\n {color}\n </Typography>\n </Flex>\n <CarretDown aria-hidden />\n </ColorPickerToggle>\n {showColorPicker && (\n <ColorPickerPopover\n onBlur={handleBlur}\n role=\"dialog\"\n source={colorPickerButtonRef}\n spacing={4}\n >\n <FocusTrap onEscape={() => setShowColorPicker(false)}>\n <ColorPicker\n color={color}\n onChange={(hexValue) =>\n onChange({ target: { name, value: hexValue, type: attribute.type } })\n }\n />\n <Flex paddingTop={3} paddingLeft={4} justifyContent=\"flex-end\">\n <Box paddingRight={2}>\n <Typography variant=\"omega\" as=\"label\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('color-picker.input.format'),\n defaultMessage: 'HEX',\n })}\n </Typography>\n </Box>\n <FieldInput\n id=\"color-picker-value\"\n aria-label={formatMessage({\n id: getTrad('color-picker.input.aria-label'),\n defaultMessage: 'Color picker input',\n })}\n style={{ textTransform: 'uppercase' }}\n value={value}\n placeholder=\"#000000\"\n onChange={onChange}\n />\n </Flex>\n </FocusTrap>\n </ColorPickerPopover>\n )}\n <FieldHint />\n <FieldError />\n </Flex>\n </Field>\n );\n }\n);\n"],"names":["setRef","ref","value","composeRefs","refs","node","useComposedRefs","React","ColorPreview","styled","props","ColorPicker","HexColorPicker","theme","ColorPickerToggle","BaseButton","ColorPickerPopover","Popover","ColorPickerInput","attribute","description","disabled","error","intlLabel","labelAction","name","onChange","required","forwardedRef","showColorPicker","setShowColorPicker","colorPickerButtonRef","formatMessage","useIntl","color","handleBlur","e","composedRefs","jsx","Field","Flex","FieldLabel","jsxs","getTrad","Typography","CarretDown","FocusTrap","hexValue","Box","FieldInput","FieldHint","FieldError"],"mappings":"slBAQA,SAASA,EAAUC,EAAqBC,EAAU,CAC5C,OAAOD,GAAQ,WACjBA,EAAIC,CAAK,EACAD,GAAQ,OAChBA,EAAkC,QAAUC,EAEjD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AC1B,EACChB,GACCS,EAAA,kBAAA,IAACtB,EAAA,CACC,OAAQmB,EACR,KAAK,SACL,OAAQJ,EACR,QAAS,EAET,kCAACe,EAAAA,UAAU,CAAA,SAAU,IAAMhB,EAAmB,EAAK,EACjD,SAAA,CAAAQ,EAAA,kBAAA,IAAC3B,EAAA,CACC,MAAAuB,EACA,SAAWa,GACTrB,EAAS,CAAE,OAAQ,CAAE,KAAAD,EAAM,MAAOsB,EAAU,KAAM5B,EAAU,MAAQ,CAAA,CAExE,2BACCqB,EAAAA,KAAK,CAAA,WAAY,EAAG,YAAa,EAAG,eAAe,WAClD,SAAA,CAACF,EAAA,kBAAA,IAAAU,EAAA,IAAA,CAAI,aAAc,EACjB,SAACV,EAAAA,kBAAAA,IAAAM,EAAA,WAAA,CAAW,QAAQ,QAAQ,GAAG,QAAQ,UAAU,aAC9C,SAAcZ,EAAA,CACb,GAAIW,UAAQ,2BAA2B,EACvC,eAAgB,KAAA,CACjB,EACH,CACF,CAAA,EACAL,EAAA,kBAAA,IAACW,EAAA,WAAA,CACC,GAAG,qBACH,aAAYjB,EAAc,CACxB,GAAIW,UAAQ,+BAA+B,EAC3C,eAAgB,oBAAA,CACjB,EACD,MAAO,CAAE,cAAe,WAAY,EACpC,MAAAzC,EACA,YAAY,UACZ,SAAAwB,CAAA,CACF,CAAA,EACF,CAAA,EACF,CAAA,CACF,0BAEDwB,EAAU,UAAA,EAAA,0BACVC,EAAW,WAAA,EAAA,CAAA,EACd,CAAA,CAAA,CAGN,CACF"}
1
+ {"version":3,"file":"ColorPickerInput-0lOoTrf0.js","sources":["../../admin/src/hooks/useComposeRefs.ts","../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * Takes multiple React like refs either React.Ref or a callback:\n * (node: T) => void and returns a single function that can be\n * passed to a React component as a ref.\n *\n * Example:\n * ```tsx\n * import { useComposedRefs } from '../hooks/useComposedRefs';\n *\n * const Component = React.forwardRef<HTMLInputElement, ComponentProps>((props, forwardedRef) => {\n * const ref = useComposedRefs(internalRef, forwardedRef);\n *\n * React.useEffect(() => {\n * ref.current.focus();\n * }, [ref]);\n *\n * return <input ref={ref} />\n * }\n * ```\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from 'react';\n\nimport {\n BaseButton,\n Box,\n Field,\n FieldError,\n FieldHint,\n FieldInput,\n FieldLabel,\n Flex,\n FocusTrap,\n Popover,\n Typography,\n} from '@strapi/design-system';\nimport { CarretDown } from '@strapi/icons';\nimport { HexColorPicker } from 'react-colorful';\nimport { useIntl, MessageDescriptor } from 'react-intl';\nimport styled from 'styled-components';\n\nimport { useComposedRefs } from '../hooks/useComposeRefs';\nimport { getTrad } from '../utils/getTrad';\n\nconst ColorPreview = styled.div`\n border-radius: 50%;\n width: 20px;\n height: 20px;\n margin-right: 10px;\n background-color: ${(props) => props.color};\n border: 1px solid rgba(0, 0, 0, 0.1);\n`;\n\nconst ColorPicker = styled(HexColorPicker)`\n && {\n width: 100%;\n aspect-ratio: 1.5;\n }\n\n .react-colorful__pointer {\n width: ${({ theme }) => theme.spaces[3]};\n height: ${({ theme }) => theme.spaces[3]};\n }\n\n .react-colorful__saturation {\n border-radius: ${({ theme }) => theme.spaces[1]};\n border-bottom: none;\n }\n\n .react-colorful__hue {\n border-radius: 10px;\n height: ${({ theme }) => theme.spaces[3]};\n margin-top: ${({ theme }) => theme.spaces[2]};\n }\n`;\n\nconst ColorPickerToggle = styled(BaseButton)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n svg {\n width: ${({ theme }) => theme.spaces[2]};\n height: ${({ theme }) => theme.spaces[2]};\n }\n\n svg > path {\n fill: ${({ theme }) => theme.colors.neutral500};\n justify-self: flex-end;\n }\n`;\n\nconst ColorPickerPopover = styled(Popover)`\n padding: ${({ theme }) => theme.spaces[2]};\n min-height: 270px;\n`;\n\n/**\n * TODO: A lot of these props should extend `FieldProps`\n */\ninterface ColorPickerInputProps {\n intlLabel: MessageDescriptor;\n /**\n * TODO: this should be extended from `FieldInputProps['onChange']\n * but that conflicts with it's secondary usage in `HexColorPicker`\n */\n onChange: (event: { target: { name: string; value: string; type: string } }) => void;\n attribute: { type: string; [key: string]: unknown };\n name: string;\n description?: MessageDescriptor;\n disabled?: boolean;\n error?: string;\n labelAction?: React.ReactNode;\n required?: boolean;\n value?: string;\n}\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n (\n {\n attribute,\n description,\n disabled = false,\n error,\n intlLabel,\n labelAction,\n name,\n onChange,\n required = false,\n value = '',\n },\n forwardedRef\n ) => {\n const [showColorPicker, setShowColorPicker] = React.useState(false);\n const colorPickerButtonRef = React.useRef<HTMLButtonElement>(null!);\n const { formatMessage } = useIntl();\n const color = value || '#000000';\n\n const handleBlur: React.FocusEventHandler<HTMLDivElement> = (e) => {\n e.preventDefault();\n\n if (!e.currentTarget.contains(e.relatedTarget)) {\n setShowColorPicker(false);\n }\n };\n\n const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);\n\n return (\n <Field\n name={name}\n id={name}\n // GenericInput calls formatMessage and returns a string for the error\n error={error}\n hint={description && formatMessage(description)}\n required={required}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <FieldLabel action={labelAction}>{formatMessage(intlLabel)}</FieldLabel>\n <ColorPickerToggle\n ref={composedRefs}\n aria-label={formatMessage({\n id: getTrad('color-picker.toggle.aria-label'),\n defaultMessage: 'Color picker toggle',\n })}\n aria-controls=\"color-picker-value\"\n aria-haspopup=\"dialog\"\n aria-expanded={showColorPicker}\n aria-disabled={disabled}\n disabled={disabled}\n onClick={() => setShowColorPicker(!showColorPicker)}\n >\n <Flex>\n <ColorPreview color={color} />\n <Typography\n style={{ textTransform: 'uppercase' }}\n textColor={value ? undefined : 'neutral600'}\n variant=\"omega\"\n >\n {color}\n </Typography>\n </Flex>\n <CarretDown aria-hidden />\n </ColorPickerToggle>\n {showColorPicker && (\n <ColorPickerPopover\n onBlur={handleBlur}\n role=\"dialog\"\n source={colorPickerButtonRef}\n spacing={4}\n >\n <FocusTrap onEscape={() => setShowColorPicker(false)}>\n <ColorPicker\n color={color}\n onChange={(hexValue) =>\n onChange({ target: { name, value: hexValue, type: attribute.type } })\n }\n />\n <Flex paddingTop={3} paddingLeft={4} justifyContent=\"flex-end\">\n <Box paddingRight={2}>\n <Typography variant=\"omega\" as=\"label\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('color-picker.input.format'),\n defaultMessage: 'HEX',\n })}\n </Typography>\n </Box>\n <FieldInput\n id=\"color-picker-value\"\n aria-label={formatMessage({\n id: getTrad('color-picker.input.aria-label'),\n defaultMessage: 'Color picker input',\n })}\n style={{ textTransform: 'uppercase' }}\n value={value}\n placeholder=\"#000000\"\n onChange={onChange}\n />\n </Flex>\n </FocusTrap>\n </ColorPickerPopover>\n )}\n <FieldHint />\n <FieldError />\n </Flex>\n </Field>\n );\n }\n);\n"],"names":["React","styled","HexColorPicker","BaseButton","Popover","useIntl","jsx","Field","Flex","FieldLabel","jsxs","getTrad","Typography","CarretDown","FocusTrap","Box","FieldInput","FieldHint","FieldError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,SAAS,OAAU,KAAqB,OAAU;AAC5C,M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Ae,YAAY;AAAA,sBACpC;AAAA,sBACA,aAAY;AAAA,sBACZ;AAAA,oBAAA;AAAA,kBACF;AAAA,gBAAA,GACF;AAAA,cAAA,GACF;AAAA,YAAA;AAAA,UACF;AAAA,yCAEDM,aAAU,WAAA,EAAA;AAAA,yCACVC,aAAW,YAAA,EAAA;AAAA,QAAA,GACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;;"}
@@ -0,0 +1,185 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { BaseButton, Popover, Field, Flex, FieldLabel, Typography, FocusTrap, Box, FieldInput, FieldHint, FieldError } from "@strapi/design-system";
4
+ import { CarretDown } from "@strapi/icons";
5
+ import { HexColorPicker } from "react-colorful";
6
+ import { useIntl } from "react-intl";
7
+ import styled from "styled-components";
8
+ import { g as getTrad } from "./index-uOrtnJpz.mjs";
9
+ import "@strapi/helper-plugin";
10
+ function setRef(ref, value) {
11
+ if (typeof ref === "function") {
12
+ ref(value);
13
+ } else if (ref !== null && ref !== void 0) {
14
+ ref.current = value;
15
+ }
16
+ }
17
+ function composeRefs(...refs) {
18
+ return (node) => refs.forEach((ref) => setRef(ref, node));
19
+ }
20
+ function useComposedRefs(...refs) {
21
+ return React.useCallback(composeRefs(...refs), refs);
22
+ }
23
+ const ColorPreview = styled.div`
24
+ border-radius: 50%;
25
+ width: 20px;
26
+ height: 20px;
27
+ margin-right: 10px;
28
+ background-color: ${(props) => props.color};
29
+ border: 1px solid rgba(0, 0, 0, 0.1);
30
+ `;
31
+ const ColorPicker = styled(HexColorPicker)`
32
+ && {
33
+ width: 100%;
34
+ aspect-ratio: 1.5;
35
+ }
36
+
37
+ .react-colorful__pointer {
38
+ width: ${({ theme }) => theme.spaces[3]};
39
+ height: ${({ theme }) => theme.spaces[3]};
40
+ }
41
+
42
+ .react-colorful__saturation {
43
+ border-radius: ${({ theme }) => theme.spaces[1]};
44
+ border-bottom: none;
45
+ }
46
+
47
+ .react-colorful__hue {
48
+ border-radius: 10px;
49
+ height: ${({ theme }) => theme.spaces[3]};
50
+ margin-top: ${({ theme }) => theme.spaces[2]};
51
+ }
52
+ `;
53
+ const ColorPickerToggle = styled(BaseButton)`
54
+ display: flex;
55
+ justify-content: space-between;
56
+ align-items: center;
57
+
58
+ svg {
59
+ width: ${({ theme }) => theme.spaces[2]};
60
+ height: ${({ theme }) => theme.spaces[2]};
61
+ }
62
+
63
+ svg > path {
64
+ fill: ${({ theme }) => theme.colors.neutral500};
65
+ justify-self: flex-end;
66
+ }
67
+ `;
68
+ const ColorPickerPopover = styled(Popover)`
69
+ padding: ${({ theme }) => theme.spaces[2]};
70
+ min-height: 270px;
71
+ `;
72
+ const ColorPickerInput = React.forwardRef(
73
+ ({
74
+ attribute,
75
+ description,
76
+ disabled = false,
77
+ error,
78
+ intlLabel,
79
+ labelAction,
80
+ name,
81
+ onChange,
82
+ required = false,
83
+ value = ""
84
+ }, forwardedRef) => {
85
+ const [showColorPicker, setShowColorPicker] = React.useState(false);
86
+ const colorPickerButtonRef = React.useRef(null);
87
+ const { formatMessage } = useIntl();
88
+ const color = value || "#000000";
89
+ const handleBlur = (e) => {
90
+ e.preventDefault();
91
+ if (!e.currentTarget.contains(e.relatedTarget)) {
92
+ setShowColorPicker(false);
93
+ }
94
+ };
95
+ const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);
96
+ return /* @__PURE__ */ jsx(
97
+ Field,
98
+ {
99
+ name,
100
+ id: name,
101
+ error,
102
+ hint: description && formatMessage(description),
103
+ required,
104
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
105
+ /* @__PURE__ */ jsx(FieldLabel, { action: labelAction, children: formatMessage(intlLabel) }),
106
+ /* @__PURE__ */ jsxs(
107
+ ColorPickerToggle,
108
+ {
109
+ ref: composedRefs,
110
+ "aria-label": formatMessage({
111
+ id: getTrad("color-picker.toggle.aria-label"),
112
+ defaultMessage: "Color picker toggle"
113
+ }),
114
+ "aria-controls": "color-picker-value",
115
+ "aria-haspopup": "dialog",
116
+ "aria-expanded": showColorPicker,
117
+ "aria-disabled": disabled,
118
+ disabled,
119
+ onClick: () => setShowColorPicker(!showColorPicker),
120
+ children: [
121
+ /* @__PURE__ */ jsxs(Flex, { children: [
122
+ /* @__PURE__ */ jsx(ColorPreview, { color }),
123
+ /* @__PURE__ */ jsx(
124
+ Typography,
125
+ {
126
+ style: { textTransform: "uppercase" },
127
+ textColor: value ? void 0 : "neutral600",
128
+ variant: "omega",
129
+ children: color
130
+ }
131
+ )
132
+ ] }),
133
+ /* @__PURE__ */ jsx(CarretDown, { "aria-hidden": true })
134
+ ]
135
+ }
136
+ ),
137
+ showColorPicker && /* @__PURE__ */ jsx(
138
+ ColorPickerPopover,
139
+ {
140
+ onBlur: handleBlur,
141
+ role: "dialog",
142
+ source: colorPickerButtonRef,
143
+ spacing: 4,
144
+ children: /* @__PURE__ */ jsxs(FocusTrap, { onEscape: () => setShowColorPicker(false), children: [
145
+ /* @__PURE__ */ jsx(
146
+ ColorPicker,
147
+ {
148
+ color,
149
+ onChange: (hexValue) => onChange({ target: { name, value: hexValue, type: attribute.type } })
150
+ }
151
+ ),
152
+ /* @__PURE__ */ jsxs(Flex, { paddingTop: 3, paddingLeft: 4, justifyContent: "flex-end", children: [
153
+ /* @__PURE__ */ jsx(Box, { paddingRight: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", as: "label", textColor: "neutral600", children: formatMessage({
154
+ id: getTrad("color-picker.input.format"),
155
+ defaultMessage: "HEX"
156
+ }) }) }),
157
+ /* @__PURE__ */ jsx(
158
+ FieldInput,
159
+ {
160
+ id: "color-picker-value",
161
+ "aria-label": formatMessage({
162
+ id: getTrad("color-picker.input.aria-label"),
163
+ defaultMessage: "Color picker input"
164
+ }),
165
+ style: { textTransform: "uppercase" },
166
+ value,
167
+ placeholder: "#000000",
168
+ onChange
169
+ }
170
+ )
171
+ ] })
172
+ ] })
173
+ }
174
+ ),
175
+ /* @__PURE__ */ jsx(FieldHint, {}),
176
+ /* @__PURE__ */ jsx(FieldError, {})
177
+ ] })
178
+ }
179
+ );
180
+ }
181
+ );
182
+ export {
183
+ ColorPickerInput
184
+ };
185
+ //# sourceMappingURL=ColorPickerInput-fKB6YXW8.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ColorPickerInput-3335ebf5.mjs","sources":["../../admin/src/hooks/useComposeRefs.ts","../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * Takes multiple React like refs either React.Ref or a callback:\n * (node: T) => void and returns a single function that can be\n * passed to a React component as a ref.\n *\n * Example:\n * ```tsx\n * import { useComposedRefs } from '../hooks/useComposedRefs';\n *\n * const Component = React.forwardRef<HTMLInputElement, ComponentProps>((props, forwardedRef) => {\n * const ref = useComposedRefs(internalRef, forwardedRef);\n *\n * React.useEffect(() => {\n * ref.current.focus();\n * }, [ref]);\n *\n * return <input ref={ref} />\n * }\n * ```\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from 'react';\n\nimport {\n BaseButton,\n Box,\n Field,\n FieldError,\n FieldHint,\n FieldInput,\n FieldLabel,\n Flex,\n FocusTrap,\n Popover,\n Typography,\n} from '@strapi/design-system';\nimport { CarretDown } from '@strapi/icons';\nimport { HexColorPicker } from 'react-colorful';\nimport { useIntl, MessageDescriptor } from 'react-intl';\nimport styled from 'styled-components';\n\nimport { useComposedRefs } from '../hooks/useComposeRefs';\nimport { getTrad } from '../utils/getTrad';\n\nconst ColorPreview = styled.div`\n border-radius: 50%;\n width: 20px;\n height: 20px;\n margin-right: 10px;\n background-color: ${(props) => props.color};\n border: 1px solid rgba(0, 0, 0, 0.1);\n`;\n\nconst ColorPicker = styled(HexColorPicker)`\n && {\n width: 100%;\n aspect-ratio: 1.5;\n }\n\n .react-colorful__pointer {\n width: ${({ theme }) => theme.spaces[3]};\n height: ${({ theme }) => theme.spaces[3]};\n }\n\n .react-colorful__saturation {\n border-radius: ${({ theme }) => theme.spaces[1]};\n border-bottom: none;\n }\n\n .react-colorful__hue {\n border-radius: 10px;\n height: ${({ theme }) => theme.spaces[3]};\n margin-top: ${({ theme }) => theme.spaces[2]};\n }\n`;\n\nconst ColorPickerToggle = styled(BaseButton)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n svg {\n width: ${({ theme }) => theme.spaces[2]};\n height: ${({ theme }) => theme.spaces[2]};\n }\n\n svg > path {\n fill: ${({ theme }) => theme.colors.neutral500};\n justify-self: flex-end;\n }\n`;\n\nconst ColorPickerPopover = styled(Popover)`\n padding: ${({ theme }) => theme.spaces[2]};\n min-height: 270px;\n`;\n\n/**\n * TODO: A lot of these props should extend `FieldProps`\n */\ninterface ColorPickerInputProps {\n intlLabel: MessageDescriptor;\n /**\n * TODO: this should be extended from `FieldInputProps['onChange']\n * but that conflicts with it's secondary usage in `HexColorPicker`\n */\n onChange: (event: { target: { name: string; value: string; type: string } }) => void;\n attribute: { type: string; [key: string]: unknown };\n name: string;\n description?: MessageDescriptor;\n disabled?: boolean;\n error?: string;\n labelAction?: React.ReactNode;\n required?: boolean;\n value?: string;\n}\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n (\n {\n attribute,\n description,\n disabled = false,\n error,\n intlLabel,\n labelAction,\n name,\n onChange,\n required = false,\n value = '',\n },\n forwardedRef\n ) => {\n const [showColorPicker, setShowColorPicker] = React.useState(false);\n const colorPickerButtonRef = React.useRef<HTMLButtonElement>(null!);\n const { formatMessage } = useIntl();\n const color = value || '#000000';\n\n const handleBlur: React.FocusEventHandler<HTMLDivElement> = (e) => {\n e.preventDefault();\n\n if (!e.currentTarget.contains(e.relatedTarget)) {\n setShowColorPicker(false);\n }\n };\n\n const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);\n\n return (\n <Field\n name={name}\n id={name}\n // GenericInput calls formatMessage and returns a string for the error\n error={error}\n hint={description && formatMessage(description)}\n required={required}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <FieldLabel action={labelAction}>{formatMessage(intlLabel)}</FieldLabel>\n <ColorPickerToggle\n ref={composedRefs}\n aria-label={formatMessage({\n id: getTrad('color-picker.toggle.aria-label'),\n defaultMessage: 'Color picker toggle',\n })}\n aria-controls=\"color-picker-value\"\n aria-haspopup=\"dialog\"\n aria-expanded={showColorPicker}\n aria-disabled={disabled}\n disabled={disabled}\n onClick={() => setShowColorPicker(!showColorPicker)}\n >\n <Flex>\n <ColorPreview color={color} />\n <Typography\n style={{ textTransform: 'uppercase' }}\n textColor={value ? undefined : 'neutral600'}\n variant=\"omega\"\n >\n {color}\n </Typography>\n </Flex>\n <CarretDown aria-hidden />\n </ColorPickerToggle>\n {showColorPicker && (\n <ColorPickerPopover\n onBlur={handleBlur}\n role=\"dialog\"\n source={colorPickerButtonRef}\n spacing={4}\n >\n <FocusTrap onEscape={() => setShowColorPicker(false)}>\n <ColorPicker\n color={color}\n onChange={(hexValue) =>\n onChange({ target: { name, value: hexValue, type: attribute.type } })\n }\n />\n <Flex paddingTop={3} paddingLeft={4} justifyContent=\"flex-end\">\n <Box paddingRight={2}>\n <Typography variant=\"omega\" as=\"label\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('color-picker.input.format'),\n defaultMessage: 'HEX',\n })}\n </Typography>\n </Box>\n <FieldInput\n id=\"color-picker-value\"\n aria-label={formatMessage({\n id: getTrad('color-picker.input.aria-label'),\n defaultMessage: 'Color picker input',\n })}\n style={{ textTransform: 'uppercase' }}\n value={value}\n placeholder=\"#000000\"\n onChange={onChange}\n />\n </Flex>\n </FocusTrap>\n </ColorPickerPopover>\n )}\n <FieldHint />\n <FieldError />\n </Flex>\n </Field>\n );\n }\n);\n"],"names":["setRef","ref","value","composeRefs","refs","node","useComposedRefs","React","ColorPreview","styled","props","ColorPicker","HexColorPicker","theme","ColorPickerToggle","BaseButton","ColorPickerPopover","Popover","ColorPickerInput","attribute","description","disabled","error","intlLabel","labelAction","name","onChange","required","forwardedRef","showColorPicker","setShowColorPicker","colorPickerButtonRef","formatMessage","useIntl","color","handleBlur","e","composedRefs","jsx","Field","Flex","FieldLabel","jsxs","getTrad","Typography","CarretDown","FocusTrap","hexValue","Box","FieldInput","FieldHint","FieldError"],"mappings":";;;;;;;;AAQA,SAASA,EAAUC,GAAqBC,GAAU;AAC5C,EAAA,OAAOD,KAAQ,aACjBA,EAAIC,CAAK,IACAD,KAAQ,SAChBA,EAAkC,UAAUC;AAEjD;AAMA,SAASC,KAAkBC,GAAwB;AAC1C,SAAA,CAACC,MAAYD,EAAK,QAAQ,CAACH,MAAQD,EAAOC,GAAKI,CAAI,CAAC;AAC7D;AAsBA,SAASC,KAAsBF,GAAwB;AAErD,SAAOG,EAAM,YAAYJ,EAAY,GAAGC,CAAI,GAAGA,CAAI;AACrD;ACxBA,MAAMI,IAAeC,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA,sBAKN,CAACC,MAAUA,EAAM,KAAK;AAAA;AAAA,GAItCC,IAAcF,EAAOG,CAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAO5B,CAAC,EAAE,OAAAC,QAAYA,EAAM,OAAO,CAAC,CAAC;AAAA,cAC7B,CAAC,EAAE,OAAAA,QAAYA,EAAM,OAA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AAA,UAAU,MAAMhB,EAAmB,EAAK,GACjD,UAAA;AAAA,gBAAAQ,gBAAAA,EAAA;AAAA,kBAAC3B;AAAA,kBAAA;AAAA,oBACC,OAAAuB;AAAA,oBACA,UAAU,CAACa,MACTrB,EAAS,EAAE,QAAQ,EAAE,MAAAD,GAAM,OAAOsB,GAAU,MAAM5B,EAAU,QAAQ;AAAA,kBAAA;AAAA,gBAExE;AAAA,uCACCqB,GAAK,EAAA,YAAY,GAAG,aAAa,GAAG,gBAAe,YAClD,UAAA;AAAA,kBAACF,gBAAAA,EAAA,IAAAU,GAAA,EAAI,cAAc,GACjB,UAACV,gBAAAA,EAAAA,IAAAM,GAAA,EAAW,SAAQ,SAAQ,IAAG,SAAQ,WAAU,cAC9C,UAAcZ,EAAA;AAAA,oBACb,IAAIW,EAAQ,2BAA2B;AAAA,oBACvC,gBAAgB;AAAA,kBAAA,CACjB,GACH,EACF,CAAA;AAAA,kBACAL,gBAAAA,EAAA;AAAA,oBAACW;AAAA,oBAAA;AAAA,sBACC,IAAG;AAAA,sBACH,cAAYjB,EAAc;AAAA,wBACxB,IAAIW,EAAQ,+BAA+B;AAAA,wBAC3C,gBAAgB;AAAA,sBAAA,CACjB;AAAA,sBACD,OAAO,EAAE,eAAe,YAAY;AAAA,sBACpC,OAAAzC;AAAA,sBACA,aAAY;AAAA,sBACZ,UAAAwB;AAAA,oBAAA;AAAA,kBACF;AAAA,gBAAA,GACF;AAAA,cAAA,GACF;AAAA,YAAA;AAAA,UACF;AAAA,gCAEDwB,GAAU,EAAA;AAAA,gCACVC,GAAW,EAAA;AAAA,QAAA,GACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;"}
1
+ {"version":3,"file":"ColorPickerInput-fKB6YXW8.mjs","sources":["../../admin/src/hooks/useComposeRefs.ts","../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref !== null && ref !== undefined) {\n (ref as React.MutableRefObject<T>).current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * Takes multiple React like refs either React.Ref or a callback:\n * (node: T) => void and returns a single function that can be\n * passed to a React component as a ref.\n *\n * Example:\n * ```tsx\n * import { useComposedRefs } from '../hooks/useComposedRefs';\n *\n * const Component = React.forwardRef<HTMLInputElement, ComponentProps>((props, forwardedRef) => {\n * const ref = useComposedRefs(internalRef, forwardedRef);\n *\n * React.useEffect(() => {\n * ref.current.focus();\n * }, [ref]);\n *\n * return <input ref={ref} />\n * }\n * ```\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from 'react';\n\nimport {\n BaseButton,\n Box,\n Field,\n FieldError,\n FieldHint,\n FieldInput,\n FieldLabel,\n Flex,\n FocusTrap,\n Popover,\n Typography,\n} from '@strapi/design-system';\nimport { CarretDown } from '@strapi/icons';\nimport { HexColorPicker } from 'react-colorful';\nimport { useIntl, MessageDescriptor } from 'react-intl';\nimport styled from 'styled-components';\n\nimport { useComposedRefs } from '../hooks/useComposeRefs';\nimport { getTrad } from '../utils/getTrad';\n\nconst ColorPreview = styled.div`\n border-radius: 50%;\n width: 20px;\n height: 20px;\n margin-right: 10px;\n background-color: ${(props) => props.color};\n border: 1px solid rgba(0, 0, 0, 0.1);\n`;\n\nconst ColorPicker = styled(HexColorPicker)`\n && {\n width: 100%;\n aspect-ratio: 1.5;\n }\n\n .react-colorful__pointer {\n width: ${({ theme }) => theme.spaces[3]};\n height: ${({ theme }) => theme.spaces[3]};\n }\n\n .react-colorful__saturation {\n border-radius: ${({ theme }) => theme.spaces[1]};\n border-bottom: none;\n }\n\n .react-colorful__hue {\n border-radius: 10px;\n height: ${({ theme }) => theme.spaces[3]};\n margin-top: ${({ theme }) => theme.spaces[2]};\n }\n`;\n\nconst ColorPickerToggle = styled(BaseButton)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n svg {\n width: ${({ theme }) => theme.spaces[2]};\n height: ${({ theme }) => theme.spaces[2]};\n }\n\n svg > path {\n fill: ${({ theme }) => theme.colors.neutral500};\n justify-self: flex-end;\n }\n`;\n\nconst ColorPickerPopover = styled(Popover)`\n padding: ${({ theme }) => theme.spaces[2]};\n min-height: 270px;\n`;\n\n/**\n * TODO: A lot of these props should extend `FieldProps`\n */\ninterface ColorPickerInputProps {\n intlLabel: MessageDescriptor;\n /**\n * TODO: this should be extended from `FieldInputProps['onChange']\n * but that conflicts with it's secondary usage in `HexColorPicker`\n */\n onChange: (event: { target: { name: string; value: string; type: string } }) => void;\n attribute: { type: string; [key: string]: unknown };\n name: string;\n description?: MessageDescriptor;\n disabled?: boolean;\n error?: string;\n labelAction?: React.ReactNode;\n required?: boolean;\n value?: string;\n}\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n (\n {\n attribute,\n description,\n disabled = false,\n error,\n intlLabel,\n labelAction,\n name,\n onChange,\n required = false,\n value = '',\n },\n forwardedRef\n ) => {\n const [showColorPicker, setShowColorPicker] = React.useState(false);\n const colorPickerButtonRef = React.useRef<HTMLButtonElement>(null!);\n const { formatMessage } = useIntl();\n const color = value || '#000000';\n\n const handleBlur: React.FocusEventHandler<HTMLDivElement> = (e) => {\n e.preventDefault();\n\n if (!e.currentTarget.contains(e.relatedTarget)) {\n setShowColorPicker(false);\n }\n };\n\n const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);\n\n return (\n <Field\n name={name}\n id={name}\n // GenericInput calls formatMessage and returns a string for the error\n error={error}\n hint={description && formatMessage(description)}\n required={required}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <FieldLabel action={labelAction}>{formatMessage(intlLabel)}</FieldLabel>\n <ColorPickerToggle\n ref={composedRefs}\n aria-label={formatMessage({\n id: getTrad('color-picker.toggle.aria-label'),\n defaultMessage: 'Color picker toggle',\n })}\n aria-controls=\"color-picker-value\"\n aria-haspopup=\"dialog\"\n aria-expanded={showColorPicker}\n aria-disabled={disabled}\n disabled={disabled}\n onClick={() => setShowColorPicker(!showColorPicker)}\n >\n <Flex>\n <ColorPreview color={color} />\n <Typography\n style={{ textTransform: 'uppercase' }}\n textColor={value ? undefined : 'neutral600'}\n variant=\"omega\"\n >\n {color}\n </Typography>\n </Flex>\n <CarretDown aria-hidden />\n </ColorPickerToggle>\n {showColorPicker && (\n <ColorPickerPopover\n onBlur={handleBlur}\n role=\"dialog\"\n source={colorPickerButtonRef}\n spacing={4}\n >\n <FocusTrap onEscape={() => setShowColorPicker(false)}>\n <ColorPicker\n color={color}\n onChange={(hexValue) =>\n onChange({ target: { name, value: hexValue, type: attribute.type } })\n }\n />\n <Flex paddingTop={3} paddingLeft={4} justifyContent=\"flex-end\">\n <Box paddingRight={2}>\n <Typography variant=\"omega\" as=\"label\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('color-picker.input.format'),\n defaultMessage: 'HEX',\n })}\n </Typography>\n </Box>\n <FieldInput\n id=\"color-picker-value\"\n aria-label={formatMessage({\n id: getTrad('color-picker.input.aria-label'),\n defaultMessage: 'Color picker input',\n })}\n style={{ textTransform: 'uppercase' }}\n value={value}\n placeholder=\"#000000\"\n onChange={onChange}\n />\n </Flex>\n </FocusTrap>\n </ColorPickerPopover>\n )}\n <FieldHint />\n <FieldError />\n </Flex>\n </Field>\n );\n }\n);\n"],"names":[],"mappings":";;;;;;;;;AAQA,SAAS,OAAU,KAAqB,OAAU;AAC5C,MAAA,OAAO,QAAQ,YAAY;AAC7B,QAA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1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const cs = {
4
+ "color-picker.description": "Vyberte libovolnou barvu",
5
+ "color-picker.input.aria-label": "Vstup pro výběr barvy",
6
+ "color-picker.input.format": "HEX",
7
+ "color-picker.label": "Barva",
8
+ "color-picker.options.advanced.regex": "RegExp vzor",
9
+ "color-picker.options.advanced.regex.description": "Zadejte regulární výraz pro ověření hodnoty HEX",
10
+ "color-picker.options.advanced.requiredField": "Povinné pole",
11
+ "color-picker.options.advanced.requiredField.description": "Pokud je toto pole prázdné, nebudete moci vytvořit záznam",
12
+ "color-picker.settings": "Nastavení",
13
+ "color-picker.toggle.aria-label": "Přepínač výběru barvy"
14
+ };
15
+ exports.default = cs;
16
+ //# sourceMappingURL=cs-4GdZY0p6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cs-4GdZY0p6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- const o = {
1
+ const cs = {
2
2
  "color-picker.description": "Vyberte libovolnou barvu",
3
3
  "color-picker.input.aria-label": "Vstup pro výběr barvy",
4
4
  "color-picker.input.format": "HEX",
@@ -11,6 +11,6 @@ const o = {
11
11
  "color-picker.toggle.aria-label": "Přepínač výběru barvy"
12
12
  };
13
13
  export {
14
- o as default
14
+ cs as default
15
15
  };
16
- //# sourceMappingURL=cs-70e06424.mjs.map
16
+ //# sourceMappingURL=cs-A2xRj-2-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cs-A2xRj-2-.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- const e = {
1
+ const en = {
2
2
  "color-picker.description": "Select any color",
3
3
  "color-picker.input.aria-label": "Color picker input",
4
4
  "color-picker.input.format": "HEX",
@@ -14,6 +14,6 @@ const e = {
14
14
  "plugin.name": "Color picker"
15
15
  };
16
16
  export {
17
- e as default
17
+ en as default
18
18
  };
19
- //# sourceMappingURL=en-096b1095.mjs.map
19
+ //# sourceMappingURL=en-L6ZZWDJv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-L6ZZWDJv.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const en = {
4
+ "color-picker.description": "Select any color",
5
+ "color-picker.input.aria-label": "Color picker input",
6
+ "color-picker.input.format": "HEX",
7
+ "color-picker.label": "Color",
8
+ "color-picker.options.advanced.regex": "RegExp pattern",
9
+ "color-picker.options.advanced.regex.description": "Provide a regular expression to validate the HEX value",
10
+ "color-picker.options.advanced.requiredField": "Required field",
11
+ "color-picker.options.advanced.requiredField.description": "You won't be able to create an entry if this field is empty",
12
+ "color-picker.settings": "Settings",
13
+ "color-picker.toggle.aria-label": "Color picker toggle",
14
+ "plugin.description.long": "A Strapi-maintained color picker custom field. Use saturation and hue sliders to select a color and save the value as a HEX string.",
15
+ "plugin.description.short": "A Strapi-maintained color picker custom field.",
16
+ "plugin.name": "Color picker"
17
+ };
18
+ exports.default = en;
19
+ //# sourceMappingURL=en-WeRHjVEB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-WeRHjVEB.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}