@strapi/plugin-color-picker 0.0.0-next.e3b4cdeebf6e9b0cd5575ff80b8a86715d44ce98 → 0.0.0-next.e3eb36dde0d936dc941df54e440e2c50a0582eeb

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 (94) hide show
  1. package/LICENSE +18 -3
  2. package/dist/admin/components/ColorPickerIcon.js +31 -0
  3. package/dist/admin/components/ColorPickerIcon.js.map +1 -0
  4. package/dist/admin/components/ColorPickerIcon.mjs +29 -0
  5. package/dist/admin/components/ColorPickerIcon.mjs.map +1 -0
  6. package/dist/admin/components/ColorPickerInput.js +199 -0
  7. package/dist/admin/components/ColorPickerInput.js.map +1 -0
  8. package/dist/admin/components/ColorPickerInput.mjs +178 -0
  9. package/dist/admin/components/ColorPickerInput.mjs.map +1 -0
  10. package/dist/admin/index.js +108 -0
  11. package/dist/admin/index.js.map +1 -0
  12. package/dist/admin/index.mjs +104 -0
  13. package/dist/admin/index.mjs.map +1 -0
  14. package/dist/admin/pluginId.js +6 -0
  15. package/dist/admin/pluginId.js.map +1 -0
  16. package/dist/admin/pluginId.mjs +4 -0
  17. package/dist/admin/pluginId.mjs.map +1 -0
  18. package/dist/admin/src/components/ColorPickerIcon.d.ts +1 -0
  19. package/dist/admin/src/components/ColorPickerInput.d.ts +7 -0
  20. package/dist/admin/src/components/tests/ColorPickerInput.test.d.ts +1 -0
  21. package/dist/admin/src/index.d.ts +18 -0
  22. package/dist/admin/src/pluginId.d.ts +1 -0
  23. package/dist/admin/src/utils/getTrad.d.ts +1 -0
  24. package/dist/admin/src/utils/prefixPluginTranslations.d.ts +3 -0
  25. package/dist/admin/translations/cs.json.js +17 -0
  26. package/dist/admin/translations/cs.json.js.map +1 -0
  27. package/dist/admin/translations/cs.json.mjs +15 -0
  28. package/dist/admin/translations/cs.json.mjs.map +1 -0
  29. package/dist/admin/translations/en.json.js +20 -0
  30. package/dist/admin/translations/en.json.js.map +1 -0
  31. package/dist/admin/translations/en.json.mjs +18 -0
  32. package/dist/admin/translations/en.json.mjs.map +1 -0
  33. package/dist/admin/translations/ru.json.js +20 -0
  34. package/dist/admin/translations/ru.json.js.map +1 -0
  35. package/dist/admin/translations/ru.json.mjs +18 -0
  36. package/dist/admin/translations/ru.json.mjs.map +1 -0
  37. package/dist/admin/translations/sv.json.js +17 -0
  38. package/dist/admin/translations/sv.json.js.map +1 -0
  39. package/dist/admin/translations/sv.json.mjs +15 -0
  40. package/dist/admin/translations/sv.json.mjs.map +1 -0
  41. package/dist/admin/translations/tr.json.js +17 -0
  42. package/dist/admin/translations/tr.json.js.map +1 -0
  43. package/dist/admin/translations/tr.json.mjs +15 -0
  44. package/dist/admin/translations/tr.json.mjs.map +1 -0
  45. package/dist/admin/translations/uk.json.js +20 -0
  46. package/dist/admin/translations/uk.json.js.map +1 -0
  47. package/dist/admin/translations/uk.json.mjs +18 -0
  48. package/dist/admin/translations/uk.json.mjs.map +1 -0
  49. package/dist/admin/translations/zh.json.js +17 -0
  50. package/dist/admin/translations/zh.json.js.map +1 -0
  51. package/dist/admin/translations/zh.json.mjs +15 -0
  52. package/dist/admin/translations/zh.json.mjs.map +1 -0
  53. package/dist/admin/utils/getTrad.js +8 -0
  54. package/dist/admin/utils/getTrad.js.map +1 -0
  55. package/dist/admin/utils/getTrad.mjs +6 -0
  56. package/dist/admin/utils/getTrad.mjs.map +1 -0
  57. package/dist/admin/utils/prefixPluginTranslations.js +11 -0
  58. package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
  59. package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
  60. package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
  61. package/dist/server/index.js +10 -0
  62. package/dist/server/index.js.map +1 -0
  63. package/dist/server/index.mjs +8 -0
  64. package/dist/server/index.mjs.map +1 -0
  65. package/dist/server/register.js +12 -0
  66. package/dist/server/register.js.map +1 -0
  67. package/dist/server/register.mjs +10 -0
  68. package/dist/server/register.mjs.map +1 -0
  69. package/dist/server/src/index.d.ts +5 -0
  70. package/dist/server/src/index.d.ts.map +1 -0
  71. package/dist/server/src/register.d.ts +2 -0
  72. package/dist/server/src/register.d.ts.map +1 -0
  73. package/package.json +67 -38
  74. package/.eslintignore +0 -2
  75. package/.eslintrc.js +0 -14
  76. package/admin/src/components/ColorPicker/ColorPickerIcon/index.js +0 -25
  77. package/admin/src/components/ColorPicker/ColorPickerInput/index.js +0 -205
  78. package/admin/src/components/tests/__snapshots__/color-picker-input.test.js.snap +0 -238
  79. package/admin/src/components/tests/color-picker-input.test.js +0 -63
  80. package/admin/src/index.js +0 -87
  81. package/admin/src/pluginId.js +0 -5
  82. package/admin/src/translations/cs.json +0 -12
  83. package/admin/src/translations/en.json +0 -15
  84. package/admin/src/translations/ru.json +0 -15
  85. package/admin/src/translations/sv.json +0 -12
  86. package/admin/src/translations/tr.json +0 -12
  87. package/admin/src/translations/zh.json +0 -12
  88. package/admin/src/utils/getTrad.js +0 -5
  89. package/color-picker.png +0 -0
  90. package/jest.config.front.js +0 -6
  91. package/server/index.js +0 -7
  92. package/server/register.js +0 -9
  93. package/strapi-admin.js +0 -3
  94. package/strapi-server.js +0 -3
package/LICENSE CHANGED
@@ -2,7 +2,21 @@ Copyright (c) 2015-present Strapi Solutions SAS
2
2
 
3
3
  Portions of the Strapi software are licensed as follows:
4
4
 
5
- * All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
5
+ * All software that resides under an "ee/" directory (the “EE 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.
6
20
 
7
21
  * All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
8
22
 
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
18
32
  The above copyright notice and this permission notice shall be included in all
19
33
  copies or substantial portions of the Software.
20
34
 
21
- 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
22
- SOFTWARE.
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,31 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var designSystem = require('@strapi/design-system');
5
+ var icons = require('@strapi/icons');
6
+ var styledComponents = require('styled-components');
7
+
8
+ const IconBox = styledComponents.styled(designSystem.Flex)`
9
+ /* Hard code color values */
10
+ /* to stay consistent between themes */
11
+ background-color: #f0f0ff; /* primary100 */
12
+ border: 1px solid #d9d8ff; /* primary200 */
13
+
14
+ svg > path {
15
+ fill: #4945ff; /* primary600 */
16
+ }
17
+ `;
18
+ const ColorPickerIcon = ()=>{
19
+ return /*#__PURE__*/ jsxRuntime.jsx(IconBox, {
20
+ justifyContent: "center",
21
+ alignItems: "center",
22
+ width: 7,
23
+ height: 6,
24
+ hasRadius: true,
25
+ "aria-hidden": true,
26
+ children: /*#__PURE__*/ jsxRuntime.jsx(icons.PaintBrush, {})
27
+ });
28
+ };
29
+
30
+ exports.ColorPickerIcon = ColorPickerIcon;
31
+ //# sourceMappingURL=ColorPickerIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPickerIcon.js","sources":["../../../admin/src/components/ColorPickerIcon.tsx"],"sourcesContent":["import { Flex } from '@strapi/design-system';\nimport { PaintBrush } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\nconst IconBox = styled(Flex)`\n /* Hard code color values */\n /* to stay consistent between themes */\n background-color: #f0f0ff; /* primary100 */\n border: 1px solid #d9d8ff; /* primary200 */\n\n svg > path {\n fill: #4945ff; /* primary600 */\n }\n`;\n\nexport const ColorPickerIcon = () => {\n return (\n <IconBox justifyContent=\"center\" alignItems=\"center\" width={7} height={6} hasRadius aria-hidden>\n <PaintBrush />\n </IconBox>\n );\n};\n"],"names":["IconBox","styled","Flex","ColorPickerIcon","_jsx","justifyContent","alignItems","width","height","hasRadius","aria-hidden","PaintBrush"],"mappings":";;;;;;;AAIA,MAAMA,OAAAA,GAAUC,uBAAOC,CAAAA,iBAAAA,CAAK;;;;;;;;;AAS5B,CAAC;MAEYC,eAAkB,GAAA,IAAA;AAC7B,IAAA,qBACEC,cAACJ,CAAAA,OAAAA,EAAAA;QAAQK,cAAe,EAAA,QAAA;QAASC,UAAW,EAAA,QAAA;QAASC,KAAO,EAAA,CAAA;QAAGC,MAAQ,EAAA,CAAA;QAAGC,SAAS,EAAA,IAAA;QAACC,aAAW,EAAA,IAAA;AAC7F,QAAA,QAAA,gBAAAN,cAACO,CAAAA,gBAAAA,EAAAA,EAAAA;;AAGP;;;;"}
@@ -0,0 +1,29 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { Flex } from '@strapi/design-system';
3
+ import { PaintBrush } from '@strapi/icons';
4
+ import { styled } from 'styled-components';
5
+
6
+ const IconBox = styled(Flex)`
7
+ /* Hard code color values */
8
+ /* to stay consistent between themes */
9
+ background-color: #f0f0ff; /* primary100 */
10
+ border: 1px solid #d9d8ff; /* primary200 */
11
+
12
+ svg > path {
13
+ fill: #4945ff; /* primary600 */
14
+ }
15
+ `;
16
+ const ColorPickerIcon = ()=>{
17
+ return /*#__PURE__*/ jsx(IconBox, {
18
+ justifyContent: "center",
19
+ alignItems: "center",
20
+ width: 7,
21
+ height: 6,
22
+ hasRadius: true,
23
+ "aria-hidden": true,
24
+ children: /*#__PURE__*/ jsx(PaintBrush, {})
25
+ });
26
+ };
27
+
28
+ export { ColorPickerIcon };
29
+ //# sourceMappingURL=ColorPickerIcon.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPickerIcon.mjs","sources":["../../../admin/src/components/ColorPickerIcon.tsx"],"sourcesContent":["import { Flex } from '@strapi/design-system';\nimport { PaintBrush } from '@strapi/icons';\nimport { styled } from 'styled-components';\n\nconst IconBox = styled(Flex)`\n /* Hard code color values */\n /* to stay consistent between themes */\n background-color: #f0f0ff; /* primary100 */\n border: 1px solid #d9d8ff; /* primary200 */\n\n svg > path {\n fill: #4945ff; /* primary600 */\n }\n`;\n\nexport const ColorPickerIcon = () => {\n return (\n <IconBox justifyContent=\"center\" alignItems=\"center\" width={7} height={6} hasRadius aria-hidden>\n <PaintBrush />\n </IconBox>\n );\n};\n"],"names":["IconBox","styled","Flex","ColorPickerIcon","_jsx","justifyContent","alignItems","width","height","hasRadius","aria-hidden","PaintBrush"],"mappings":";;;;;AAIA,MAAMA,OAAAA,GAAUC,MAAOC,CAAAA,IAAAA,CAAK;;;;;;;;;AAS5B,CAAC;MAEYC,eAAkB,GAAA,IAAA;AAC7B,IAAA,qBACEC,GAACJ,CAAAA,OAAAA,EAAAA;QAAQK,cAAe,EAAA,QAAA;QAASC,UAAW,EAAA,QAAA;QAASC,KAAO,EAAA,CAAA;QAAGC,MAAQ,EAAA,CAAA;QAAGC,SAAS,EAAA,IAAA;QAACC,aAAW,EAAA,IAAA;AAC7F,QAAA,QAAA,gBAAAN,GAACO,CAAAA,UAAAA,EAAAA,EAAAA;;AAGP;;;;"}
@@ -0,0 +1,199 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var designSystem = require('@strapi/design-system');
6
+ var icons = require('@strapi/icons');
7
+ var admin = require('@strapi/strapi/admin');
8
+ var reactColorful = require('react-colorful');
9
+ var reactIntl = require('react-intl');
10
+ var styledComponents = require('styled-components');
11
+ var getTrad = require('../utils/getTrad.js');
12
+
13
+ function _interopNamespaceDefault(e) {
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
31
+
32
+ const ColorPreview = styledComponents.styled.div`
33
+ border-radius: 50%;
34
+ width: 20px;
35
+ height: 20px;
36
+ margin-right: 10px;
37
+ background-color: ${(props)=>props.color};
38
+ border: 1px solid rgba(0, 0, 0, 0.1);
39
+ `;
40
+ const ColorPicker = styledComponents.styled(reactColorful.HexColorPicker)`
41
+ && {
42
+ width: 100%;
43
+ aspect-ratio: 1.5;
44
+ }
45
+
46
+ .react-colorful__pointer {
47
+ width: ${({ theme })=>theme.spaces[3]};
48
+ height: ${({ theme })=>theme.spaces[3]};
49
+ }
50
+
51
+ .react-colorful__saturation {
52
+ border-radius: ${({ theme })=>theme.spaces[1]};
53
+ border-bottom: none;
54
+ }
55
+
56
+ .react-colorful__hue {
57
+ border-radius: 10px;
58
+ height: ${({ theme })=>theme.spaces[3]};
59
+ margin-top: ${({ theme })=>theme.spaces[2]};
60
+ }
61
+ `;
62
+ const ColorPickerToggle = styledComponents.styled(designSystem.Button)`
63
+ & > span {
64
+ display: flex;
65
+ justify-content: space-between;
66
+ align-items: center;
67
+ width: 100%;
68
+ }
69
+
70
+ svg {
71
+ width: ${({ theme })=>theme.spaces[2]};
72
+ height: ${({ theme })=>theme.spaces[2]};
73
+ }
74
+
75
+ svg > path {
76
+ fill: ${({ theme })=>theme.colors.neutral500};
77
+ justify-self: flex-end;
78
+ }
79
+ `;
80
+ const ColorPickerPopover = styledComponents.styled(designSystem.Popover.Content)`
81
+ padding: ${({ theme })=>theme.spaces[2]};
82
+ min-height: 270px;
83
+ `;
84
+ const ColorPickerInput = /*#__PURE__*/ React__namespace.forwardRef(({ hint, disabled, labelAction, label, name, required, ...props }, forwardedRef)=>{
85
+ const [showColorPicker, setShowColorPicker] = React__namespace.useState(false);
86
+ const colorPickerButtonRef = React__namespace.useRef(null);
87
+ const { formatMessage } = reactIntl.useIntl();
88
+ const field = admin.useField(name);
89
+ const color = field.value ?? '#000000';
90
+ const composedRefs = designSystem.useComposedRefs(forwardedRef, colorPickerButtonRef);
91
+ return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Root, {
92
+ name: name,
93
+ id: name,
94
+ error: field.error,
95
+ hint: hint,
96
+ required: required,
97
+ children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
98
+ direction: "column",
99
+ alignItems: "stretch",
100
+ gap: 1,
101
+ children: [
102
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
103
+ action: labelAction,
104
+ children: label
105
+ }),
106
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Popover.Root, {
107
+ onOpenChange: setShowColorPicker,
108
+ children: [
109
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Popover.Trigger, {
110
+ children: /*#__PURE__*/ jsxRuntime.jsxs(ColorPickerToggle, {
111
+ ref: composedRefs,
112
+ "aria-label": formatMessage({
113
+ id: getTrad.getTrad('color-picker.toggle.aria-label'),
114
+ defaultMessage: 'Color picker toggle'
115
+ }),
116
+ "aria-controls": "color-picker-value",
117
+ "aria-haspopup": "dialog",
118
+ "aria-expanded": showColorPicker,
119
+ "aria-disabled": disabled,
120
+ disabled: disabled,
121
+ variant: "tertiary",
122
+ size: "L",
123
+ children: [
124
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
125
+ children: [
126
+ /*#__PURE__*/ jsxRuntime.jsx(ColorPreview, {
127
+ color: color
128
+ }),
129
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
130
+ style: {
131
+ textTransform: 'uppercase'
132
+ },
133
+ textColor: field.value ? undefined : 'neutral600',
134
+ variant: "omega",
135
+ children: color
136
+ })
137
+ ]
138
+ }),
139
+ /*#__PURE__*/ jsxRuntime.jsx(icons.CaretDown, {
140
+ "aria-hidden": true
141
+ })
142
+ ]
143
+ })
144
+ }),
145
+ /*#__PURE__*/ jsxRuntime.jsxs(ColorPickerPopover, {
146
+ sideOffset: 4,
147
+ children: [
148
+ /*#__PURE__*/ jsxRuntime.jsx(ColorPicker, {
149
+ color: color,
150
+ onChange: (hexValue)=>field.onChange(name, hexValue)
151
+ }),
152
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
153
+ paddingTop: 3,
154
+ paddingLeft: 4,
155
+ justifyContent: "flex-end",
156
+ children: [
157
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
158
+ paddingRight: 2,
159
+ children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
160
+ variant: "omega",
161
+ tag: "label",
162
+ textColor: "neutral600",
163
+ children: formatMessage({
164
+ id: getTrad.getTrad('color-picker.input.format'),
165
+ defaultMessage: 'HEX'
166
+ })
167
+ })
168
+ }),
169
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Root, {
170
+ children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Input, {
171
+ "aria-label": formatMessage({
172
+ id: getTrad.getTrad('color-picker.input.aria-label'),
173
+ defaultMessage: 'Color picker input'
174
+ }),
175
+ style: {
176
+ textTransform: 'uppercase'
177
+ },
178
+ name: name,
179
+ defaultValue: color,
180
+ placeholder: "#000000",
181
+ onChange: field.onChange,
182
+ ...props
183
+ })
184
+ })
185
+ ]
186
+ })
187
+ ]
188
+ })
189
+ ]
190
+ }),
191
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Hint, {}),
192
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {})
193
+ ]
194
+ })
195
+ });
196
+ });
197
+
198
+ exports.ColorPickerInput = ColorPickerInput;
199
+ //# sourceMappingURL=ColorPickerInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPickerInput.js","sources":["../../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Button,\n Box,\n Field,\n Flex,\n Popover,\n Typography,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { CaretDown } from '@strapi/icons';\nimport { type InputProps, useField } from '@strapi/strapi/admin';\nimport { HexColorPicker } from 'react-colorful';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\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(Button)`\n & > span {\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n }\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.Content)`\n padding: ${({ theme }) => theme.spaces[2]};\n min-height: 270px;\n`;\n\ntype ColorPickerInputProps = InputProps & {\n labelAction?: React.ReactNode;\n};\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n ({ hint, disabled, labelAction, label, name, required, ...props }, forwardedRef) => {\n const [showColorPicker, setShowColorPicker] = React.useState(false);\n const colorPickerButtonRef = React.useRef<HTMLButtonElement>(null!);\n const { formatMessage } = useIntl();\n const field = useField(name);\n const color = field.value ?? '#000000';\n\n const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);\n\n return (\n <Field.Root name={name} id={name} error={field.error} hint={hint} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <Popover.Root onOpenChange={setShowColorPicker}>\n <Popover.Trigger>\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 variant=\"tertiary\"\n size=\"L\"\n >\n <Flex>\n <ColorPreview color={color} />\n <Typography\n style={{ textTransform: 'uppercase' }}\n textColor={field.value ? undefined : 'neutral600'}\n variant=\"omega\"\n >\n {color}\n </Typography>\n </Flex>\n <CaretDown aria-hidden />\n </ColorPickerToggle>\n </Popover.Trigger>\n <ColorPickerPopover sideOffset={4}>\n <ColorPicker color={color} onChange={(hexValue) => field.onChange(name, hexValue)} />\n <Flex paddingTop={3} paddingLeft={4} justifyContent=\"flex-end\">\n <Box paddingRight={2}>\n <Typography variant=\"omega\" tag=\"label\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('color-picker.input.format'),\n defaultMessage: 'HEX',\n })}\n </Typography>\n </Box>\n <Field.Root>\n <Field.Input\n aria-label={formatMessage({\n id: getTrad('color-picker.input.aria-label'),\n defaultMessage: 'Color picker input',\n })}\n style={{ textTransform: 'uppercase' }}\n name={name}\n defaultValue={color}\n placeholder=\"#000000\"\n onChange={field.onChange}\n {...props}\n />\n </Field.Root>\n </Flex>\n </ColorPickerPopover>\n </Popover.Root>\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n"],"names":["ColorPreview","styled","div","props","color","ColorPicker","HexColorPicker","theme","spaces","ColorPickerToggle","Button","colors","neutral500","ColorPickerPopover","Popover","Content","ColorPickerInput","React","forwardRef","hint","disabled","labelAction","label","name","required","forwardedRef","showColorPicker","setShowColorPicker","useState","colorPickerButtonRef","useRef","formatMessage","useIntl","field","useField","value","composedRefs","useComposedRefs","_jsx","Field","Root","id","error","_jsxs","Flex","direction","alignItems","gap","Label","action","onOpenChange","Trigger","ref","aria-label","getTrad","defaultMessage","aria-controls","aria-haspopup","aria-expanded","aria-disabled","variant","size","Typography","style","textTransform","textColor","undefined","CaretDown","aria-hidden","sideOffset","onChange","hexValue","paddingTop","paddingLeft","justifyContent","Box","paddingRight","tag","Input","defaultValue","placeholder","Hint","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,YAAAA,GAAeC,uBAAOC,CAAAA,GAAG;;;;;AAKX,oBAAA,EAAE,CAACC,KAAAA,GAAUA,KAAMC,CAAAA,KAAK,CAAC;;AAE7C,CAAC;AAED,MAAMC,WAAAA,GAAcJ,uBAAOK,CAAAA,4BAAAA,CAAe;;;;;;;WAO/B,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;YAChC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;;;mBAI1B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;;;;;YAMxC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;gBAC7B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;AAEj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cAAA,CAACC,mBAAM0C,IAAI,EAAA,EAAA,CAAA;AACX,8BAAA3C,cAAA,CAACC,mBAAM2C,KAAK,EAAA,EAAA;;;;AAIpB,CACA;;;;"}
@@ -0,0 +1,178 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { Button, Popover, useComposedRefs, Field, Flex, Typography, Box } from '@strapi/design-system';
4
+ import { CaretDown } from '@strapi/icons';
5
+ import { useField } from '@strapi/strapi/admin';
6
+ import { HexColorPicker } from 'react-colorful';
7
+ import { useIntl } from 'react-intl';
8
+ import { styled } from 'styled-components';
9
+ import { getTrad } from '../utils/getTrad.mjs';
10
+
11
+ const ColorPreview = styled.div`
12
+ border-radius: 50%;
13
+ width: 20px;
14
+ height: 20px;
15
+ margin-right: 10px;
16
+ background-color: ${(props)=>props.color};
17
+ border: 1px solid rgba(0, 0, 0, 0.1);
18
+ `;
19
+ const ColorPicker = styled(HexColorPicker)`
20
+ && {
21
+ width: 100%;
22
+ aspect-ratio: 1.5;
23
+ }
24
+
25
+ .react-colorful__pointer {
26
+ width: ${({ theme })=>theme.spaces[3]};
27
+ height: ${({ theme })=>theme.spaces[3]};
28
+ }
29
+
30
+ .react-colorful__saturation {
31
+ border-radius: ${({ theme })=>theme.spaces[1]};
32
+ border-bottom: none;
33
+ }
34
+
35
+ .react-colorful__hue {
36
+ border-radius: 10px;
37
+ height: ${({ theme })=>theme.spaces[3]};
38
+ margin-top: ${({ theme })=>theme.spaces[2]};
39
+ }
40
+ `;
41
+ const ColorPickerToggle = styled(Button)`
42
+ & > span {
43
+ display: flex;
44
+ justify-content: space-between;
45
+ align-items: center;
46
+ width: 100%;
47
+ }
48
+
49
+ svg {
50
+ width: ${({ theme })=>theme.spaces[2]};
51
+ height: ${({ theme })=>theme.spaces[2]};
52
+ }
53
+
54
+ svg > path {
55
+ fill: ${({ theme })=>theme.colors.neutral500};
56
+ justify-self: flex-end;
57
+ }
58
+ `;
59
+ const ColorPickerPopover = styled(Popover.Content)`
60
+ padding: ${({ theme })=>theme.spaces[2]};
61
+ min-height: 270px;
62
+ `;
63
+ const ColorPickerInput = /*#__PURE__*/ React.forwardRef(({ hint, disabled, labelAction, label, name, required, ...props }, forwardedRef)=>{
64
+ const [showColorPicker, setShowColorPicker] = React.useState(false);
65
+ const colorPickerButtonRef = React.useRef(null);
66
+ const { formatMessage } = useIntl();
67
+ const field = useField(name);
68
+ const color = field.value ?? '#000000';
69
+ const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);
70
+ return /*#__PURE__*/ jsx(Field.Root, {
71
+ name: name,
72
+ id: name,
73
+ error: field.error,
74
+ hint: hint,
75
+ required: required,
76
+ children: /*#__PURE__*/ jsxs(Flex, {
77
+ direction: "column",
78
+ alignItems: "stretch",
79
+ gap: 1,
80
+ children: [
81
+ /*#__PURE__*/ jsx(Field.Label, {
82
+ action: labelAction,
83
+ children: label
84
+ }),
85
+ /*#__PURE__*/ jsxs(Popover.Root, {
86
+ onOpenChange: setShowColorPicker,
87
+ children: [
88
+ /*#__PURE__*/ jsx(Popover.Trigger, {
89
+ children: /*#__PURE__*/ jsxs(ColorPickerToggle, {
90
+ ref: composedRefs,
91
+ "aria-label": formatMessage({
92
+ id: getTrad('color-picker.toggle.aria-label'),
93
+ defaultMessage: 'Color picker toggle'
94
+ }),
95
+ "aria-controls": "color-picker-value",
96
+ "aria-haspopup": "dialog",
97
+ "aria-expanded": showColorPicker,
98
+ "aria-disabled": disabled,
99
+ disabled: disabled,
100
+ variant: "tertiary",
101
+ size: "L",
102
+ children: [
103
+ /*#__PURE__*/ jsxs(Flex, {
104
+ children: [
105
+ /*#__PURE__*/ jsx(ColorPreview, {
106
+ color: color
107
+ }),
108
+ /*#__PURE__*/ jsx(Typography, {
109
+ style: {
110
+ textTransform: 'uppercase'
111
+ },
112
+ textColor: field.value ? undefined : 'neutral600',
113
+ variant: "omega",
114
+ children: color
115
+ })
116
+ ]
117
+ }),
118
+ /*#__PURE__*/ jsx(CaretDown, {
119
+ "aria-hidden": true
120
+ })
121
+ ]
122
+ })
123
+ }),
124
+ /*#__PURE__*/ jsxs(ColorPickerPopover, {
125
+ sideOffset: 4,
126
+ children: [
127
+ /*#__PURE__*/ jsx(ColorPicker, {
128
+ color: color,
129
+ onChange: (hexValue)=>field.onChange(name, hexValue)
130
+ }),
131
+ /*#__PURE__*/ jsxs(Flex, {
132
+ paddingTop: 3,
133
+ paddingLeft: 4,
134
+ justifyContent: "flex-end",
135
+ children: [
136
+ /*#__PURE__*/ jsx(Box, {
137
+ paddingRight: 2,
138
+ children: /*#__PURE__*/ jsx(Typography, {
139
+ variant: "omega",
140
+ tag: "label",
141
+ textColor: "neutral600",
142
+ children: formatMessage({
143
+ id: getTrad('color-picker.input.format'),
144
+ defaultMessage: 'HEX'
145
+ })
146
+ })
147
+ }),
148
+ /*#__PURE__*/ jsx(Field.Root, {
149
+ children: /*#__PURE__*/ jsx(Field.Input, {
150
+ "aria-label": formatMessage({
151
+ id: getTrad('color-picker.input.aria-label'),
152
+ defaultMessage: 'Color picker input'
153
+ }),
154
+ style: {
155
+ textTransform: 'uppercase'
156
+ },
157
+ name: name,
158
+ defaultValue: color,
159
+ placeholder: "#000000",
160
+ onChange: field.onChange,
161
+ ...props
162
+ })
163
+ })
164
+ ]
165
+ })
166
+ ]
167
+ })
168
+ ]
169
+ }),
170
+ /*#__PURE__*/ jsx(Field.Hint, {}),
171
+ /*#__PURE__*/ jsx(Field.Error, {})
172
+ ]
173
+ })
174
+ });
175
+ });
176
+
177
+ export { ColorPickerInput };
178
+ //# sourceMappingURL=ColorPickerInput.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPickerInput.mjs","sources":["../../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n Button,\n Box,\n Field,\n Flex,\n Popover,\n Typography,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { CaretDown } from '@strapi/icons';\nimport { type InputProps, useField } from '@strapi/strapi/admin';\nimport { HexColorPicker } from 'react-colorful';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\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(Button)`\n & > span {\n display: flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n }\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.Content)`\n padding: ${({ theme }) => theme.spaces[2]};\n min-height: 270px;\n`;\n\ntype ColorPickerInputProps = InputProps & {\n labelAction?: React.ReactNode;\n};\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n ({ hint, disabled, labelAction, label, name, required, ...props }, forwardedRef) => {\n const [showColorPicker, setShowColorPicker] = React.useState(false);\n const colorPickerButtonRef = React.useRef<HTMLButtonElement>(null!);\n const { formatMessage } = useIntl();\n const field = useField(name);\n const color = field.value ?? '#000000';\n\n const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);\n\n return (\n <Field.Root name={name} id={name} error={field.error} hint={hint} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <Popover.Root onOpenChange={setShowColorPicker}>\n <Popover.Trigger>\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 variant=\"tertiary\"\n size=\"L\"\n >\n <Flex>\n <ColorPreview color={color} />\n <Typography\n style={{ textTransform: 'uppercase' }}\n textColor={field.value ? undefined : 'neutral600'}\n variant=\"omega\"\n >\n {color}\n </Typography>\n </Flex>\n <CaretDown aria-hidden />\n </ColorPickerToggle>\n </Popover.Trigger>\n <ColorPickerPopover sideOffset={4}>\n <ColorPicker color={color} onChange={(hexValue) => field.onChange(name, hexValue)} />\n <Flex paddingTop={3} paddingLeft={4} justifyContent=\"flex-end\">\n <Box paddingRight={2}>\n <Typography variant=\"omega\" tag=\"label\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('color-picker.input.format'),\n defaultMessage: 'HEX',\n })}\n </Typography>\n </Box>\n <Field.Root>\n <Field.Input\n aria-label={formatMessage({\n id: getTrad('color-picker.input.aria-label'),\n defaultMessage: 'Color picker input',\n })}\n style={{ textTransform: 'uppercase' }}\n name={name}\n defaultValue={color}\n placeholder=\"#000000\"\n onChange={field.onChange}\n {...props}\n />\n </Field.Root>\n </Flex>\n </ColorPickerPopover>\n </Popover.Root>\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n"],"names":["ColorPreview","styled","div","props","color","ColorPicker","HexColorPicker","theme","spaces","ColorPickerToggle","Button","colors","neutral500","ColorPickerPopover","Popover","Content","ColorPickerInput","React","forwardRef","hint","disabled","labelAction","label","name","required","forwardedRef","showColorPicker","setShowColorPicker","useState","colorPickerButtonRef","useRef","formatMessage","useIntl","field","useField","value","composedRefs","useComposedRefs","_jsx","Field","Root","id","error","_jsxs","Flex","direction","alignItems","gap","Label","action","onOpenChange","Trigger","ref","aria-label","getTrad","defaultMessage","aria-controls","aria-haspopup","aria-expanded","aria-disabled","variant","size","Typography","style","textTransform","textColor","undefined","CaretDown","aria-hidden","sideOffset","onChange","hexValue","paddingTop","paddingLeft","justifyContent","Box","paddingRight","tag","Input","defaultValue","placeholder","Hint","Error"],"mappings":";;;;;;;;;;AAmBA,MAAMA,YAAAA,GAAeC,MAAOC,CAAAA,GAAG;;;;;AAKX,oBAAA,EAAE,CAACC,KAAAA,GAAUA,KAAMC,CAAAA,KAAK,CAAC;;AAE7C,CAAC;AAED,MAAMC,WAAAA,GAAcJ,MAAOK,CAAAA,cAAAA,CAAe;;;;;;;WAO/B,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;YAChC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;;;mBAI1B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;;;;;YAMxC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;gBAC7B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;AAEjD,CAAC;AAED,MAAMC,iBAAAA,GAAoBR,MAAOS,CAAAA,MAAAA,CAAO;;;;;;;;;WAS7B,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;YAChC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;;;;UAInC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMI,CAAAA,MAAM,C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CAAAA,IAAAA,EAAAA;oCAAK4B,UAAY,EAAA,CAAA;oCAAGC,WAAa,EAAA,CAAA;oCAAGC,cAAe,EAAA,UAAA;;sDAClDpC,GAACqC,CAAAA,GAAAA,EAAAA;4CAAIC,YAAc,EAAA,CAAA;AACjB,4CAAA,QAAA,gBAAAtC,GAACwB,CAAAA,UAAAA,EAAAA;gDAAWF,OAAQ,EAAA,OAAA;gDAAQiB,GAAI,EAAA,OAAA;gDAAQZ,SAAU,EAAA,YAAA;0DAC/ClC,aAAc,CAAA;AACbU,oDAAAA,EAAAA,EAAIa,OAAQ,CAAA,2BAAA,CAAA;oDACZC,cAAgB,EAAA;AAClB,iDAAA;;;AAGJ,sDAAAjB,GAAA,CAACC,MAAMC,IAAI,EAAA;oEACTF,GAAA,CAACC,MAAMuC,KAAK,EAAA;AACVzB,gDAAAA,YAAAA,EAAYtB,aAAc,CAAA;AACxBU,oDAAAA,EAAAA,EAAIa,OAAQ,CAAA,+BAAA,CAAA;oDACZC,cAAgB,EAAA;AAClB,iDAAA,CAAA;gDACAQ,KAAO,EAAA;oDAAEC,aAAe,EAAA;AAAY,iDAAA;gDACpCzC,IAAMA,EAAAA,IAAAA;gDACNwD,YAAc3E,EAAAA,KAAAA;gDACd4E,WAAY,EAAA,SAAA;AACZV,gDAAAA,QAAAA,EAAUrC,MAAMqC,QAAQ;AACvB,gDAAA,GAAGnE;;;;;;;;;AAMd,8BAAAmC,GAAA,CAACC,MAAM0C,IAAI,EAAA,EAAA,CAAA;AACX,8BAAA3C,GAAA,CAACC,MAAM2C,KAAK,EAAA,EAAA;;;;AAIpB,CACA;;;;"}
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ var ColorPickerIcon = require('./components/ColorPickerIcon.js');
4
+ var pluginId = require('./pluginId.js');
5
+ var getTrad = require('./utils/getTrad.js');
6
+ var prefixPluginTranslations = require('./utils/prefixPluginTranslations.js');
7
+
8
+ function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); }
9
+
10
+ function __variableDynamicImportRuntime1__(path) {
11
+ switch (path) {
12
+ case './translations/cs.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/cs.json.js')); });
13
+ case './translations/en.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/en.json.js')); });
14
+ case './translations/ru.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/ru.json.js')); });
15
+ case './translations/sv.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/sv.json.js')); });
16
+ case './translations/tr.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/tr.json.js')); });
17
+ case './translations/uk.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/uk.json.js')); });
18
+ case './translations/zh.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/zh.json.js')); });
19
+ default: return new Promise(function(resolve, reject) {
20
+ (typeof queueMicrotask === 'function' ? queueMicrotask : setTimeout)(
21
+ reject.bind(null, new Error("Unknown variable dynamic import: " + path))
22
+ );
23
+ })
24
+ }
25
+ }
26
+ // eslint-disable-next-line import/no-default-export
27
+ var index = {
28
+ /**
29
+ * TODO: we need to have the type for StrapiApp done from `@strapi/admin` package.
30
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ register (app) {
32
+ app.customFields.register({
33
+ name: 'color',
34
+ pluginId: 'color-picker',
35
+ type: 'string',
36
+ icon: ColorPickerIcon.ColorPickerIcon,
37
+ intlLabel: {
38
+ id: getTrad.getTrad('color-picker.label'),
39
+ defaultMessage: 'Color'
40
+ },
41
+ intlDescription: {
42
+ id: getTrad.getTrad('color-picker.description'),
43
+ defaultMessage: 'Select any color'
44
+ },
45
+ components: {
46
+ Input: async ()=>Promise.resolve().then(function () { return require('./components/ColorPickerInput.js'); }).then((module)=>({
47
+ default: module.ColorPickerInput
48
+ }))
49
+ },
50
+ options: {
51
+ advanced: [
52
+ {
53
+ intlLabel: {
54
+ id: getTrad.getTrad('color-picker.options.advanced.regex'),
55
+ defaultMessage: 'RegExp pattern'
56
+ },
57
+ name: 'regex',
58
+ type: 'text',
59
+ defaultValue: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',
60
+ description: {
61
+ id: getTrad.getTrad('color-picker.options.advanced.regex.description'),
62
+ defaultMessage: 'The text of the regular expression'
63
+ }
64
+ },
65
+ {
66
+ sectionTitle: {
67
+ id: 'global.settings',
68
+ defaultMessage: 'Settings'
69
+ },
70
+ items: [
71
+ {
72
+ name: 'required',
73
+ type: 'checkbox',
74
+ intlLabel: {
75
+ id: getTrad.getTrad('color-picker.options.advanced.requiredField'),
76
+ defaultMessage: 'Required field'
77
+ },
78
+ description: {
79
+ id: getTrad.getTrad('color-picker.options.advanced.requiredField.description'),
80
+ defaultMessage: "You won't be able to create an entry if this field is empty"
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ ]
86
+ }
87
+ });
88
+ },
89
+ async registerTrads ({ locales }) {
90
+ const importedTrads = await Promise.all(locales.map((locale)=>{
91
+ return __variableDynamicImportRuntime1__(`./translations/${locale}.json`).then(({ default: data })=>{
92
+ return {
93
+ data: prefixPluginTranslations.prefixPluginTranslations(data, pluginId.pluginId),
94
+ locale
95
+ };
96
+ }).catch(()=>{
97
+ return {
98
+ data: {},
99
+ locale
100
+ };
101
+ });
102
+ }));
103
+ return Promise.resolve(importedTrads);
104
+ }
105
+ };
106
+
107
+ module.exports = index;
108
+ //# sourceMappingURL=index.js.map