@strapi/plugin-color-picker 5.0.0-beta.5 → 5.0.0-beta.7

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.
@@ -0,0 +1,164 @@
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 admin = require("@strapi/strapi/admin");
8
+ const reactColorful = require("react-colorful");
9
+ const reactIntl = require("react-intl");
10
+ const styledComponents = require("styled-components");
11
+ const index = require("./index-BwmWwO-Q.js");
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule)
14
+ return e;
15
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
16
+ if (e) {
17
+ for (const k in e) {
18
+ if (k !== "default") {
19
+ const d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: () => e[k]
23
+ });
24
+ }
25
+ }
26
+ }
27
+ n.default = e;
28
+ return Object.freeze(n);
29
+ }
30
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
31
+ const ColorPreview = styledComponents.styled.div`
32
+ border-radius: 50%;
33
+ width: 20px;
34
+ height: 20px;
35
+ margin-right: 10px;
36
+ background-color: ${(props) => props.color};
37
+ border: 1px solid rgba(0, 0, 0, 0.1);
38
+ `;
39
+ const ColorPicker = styledComponents.styled(reactColorful.HexColorPicker)`
40
+ && {
41
+ width: 100%;
42
+ aspect-ratio: 1.5;
43
+ }
44
+
45
+ .react-colorful__pointer {
46
+ width: ${({ theme }) => theme.spaces[3]};
47
+ height: ${({ theme }) => theme.spaces[3]};
48
+ }
49
+
50
+ .react-colorful__saturation {
51
+ border-radius: ${({ theme }) => theme.spaces[1]};
52
+ border-bottom: none;
53
+ }
54
+
55
+ .react-colorful__hue {
56
+ border-radius: 10px;
57
+ height: ${({ theme }) => theme.spaces[3]};
58
+ margin-top: ${({ theme }) => theme.spaces[2]};
59
+ }
60
+ `;
61
+ const ColorPickerToggle = styledComponents.styled(designSystem.BaseButton)`
62
+ display: flex;
63
+ justify-content: space-between;
64
+ align-items: center;
65
+
66
+ svg {
67
+ width: ${({ theme }) => theme.spaces[2]};
68
+ height: ${({ theme }) => theme.spaces[2]};
69
+ }
70
+
71
+ svg > path {
72
+ fill: ${({ theme }) => theme.colors.neutral500};
73
+ justify-self: flex-end;
74
+ }
75
+ `;
76
+ const ColorPickerPopover = styledComponents.styled(designSystem.Popover)`
77
+ padding: ${({ theme }) => theme.spaces[2]};
78
+ min-height: 270px;
79
+ `;
80
+ const ColorPickerInput = React__namespace.forwardRef(
81
+ ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {
82
+ const { onChange, value, error } = admin.useField(name);
83
+ const [showColorPicker, setShowColorPicker] = React__namespace.useState(false);
84
+ const colorPickerButtonRef = React__namespace.useRef(null);
85
+ const { formatMessage } = reactIntl.useIntl();
86
+ const color = value || "#000000";
87
+ const handleBlur = (e) => {
88
+ e.preventDefault();
89
+ if (!e.currentTarget.contains(e.relatedTarget)) {
90
+ setShowColorPicker(false);
91
+ }
92
+ };
93
+ const composedRefs = designSystem.useComposedRefs(forwardedRef, colorPickerButtonRef);
94
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { name, id: name, error, hint, required, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
95
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
96
+ /* @__PURE__ */ jsxRuntime.jsxs(
97
+ ColorPickerToggle,
98
+ {
99
+ ref: composedRefs,
100
+ "aria-label": formatMessage({
101
+ id: index.getTrad("color-picker.toggle.aria-label"),
102
+ defaultMessage: "Color picker toggle"
103
+ }),
104
+ "aria-controls": "color-picker-value",
105
+ "aria-haspopup": "dialog",
106
+ "aria-expanded": showColorPicker,
107
+ "aria-disabled": disabled,
108
+ disabled,
109
+ onClick: () => setShowColorPicker(!showColorPicker),
110
+ children: [
111
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
112
+ /* @__PURE__ */ jsxRuntime.jsx(ColorPreview, { color }),
113
+ /* @__PURE__ */ jsxRuntime.jsx(
114
+ designSystem.Typography,
115
+ {
116
+ style: { textTransform: "uppercase" },
117
+ textColor: value ? void 0 : "neutral600",
118
+ variant: "omega",
119
+ children: color
120
+ }
121
+ )
122
+ ] }),
123
+ /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, { "aria-hidden": true })
124
+ ]
125
+ }
126
+ ),
127
+ showColorPicker && /* @__PURE__ */ jsxRuntime.jsx(
128
+ ColorPickerPopover,
129
+ {
130
+ onBlur: handleBlur,
131
+ role: "dialog",
132
+ source: colorPickerButtonRef,
133
+ spacing: 4,
134
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.FocusTrap, { onEscape: () => setShowColorPicker(false), children: [
135
+ /* @__PURE__ */ jsxRuntime.jsx(ColorPicker, { color, onChange: (hexValue) => onChange(name, hexValue) }),
136
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { paddingTop: 3, paddingLeft: 4, justifyContent: "flex-end", children: [
137
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingRight: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", tag: "label", textColor: "neutral600", children: formatMessage({
138
+ id: index.getTrad("color-picker.input.format"),
139
+ defaultMessage: "HEX"
140
+ }) }) }),
141
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
142
+ designSystem.Field.Input,
143
+ {
144
+ "aria-label": formatMessage({
145
+ id: index.getTrad("color-picker.input.aria-label"),
146
+ defaultMessage: "Color picker input"
147
+ }),
148
+ style: { textTransform: "uppercase" },
149
+ value,
150
+ placeholder: "#000000",
151
+ onChange
152
+ }
153
+ ) })
154
+ ] })
155
+ ] })
156
+ }
157
+ ),
158
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
159
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
160
+ ] }) });
161
+ }
162
+ );
163
+ exports.ColorPickerInput = ColorPickerInput;
164
+ //# sourceMappingURL=ColorPickerInput-C0wO-iiI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPickerInput-C0wO-iiI.js","sources":["../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n BaseButton,\n Box,\n Field,\n Flex,\n FocusTrap,\n Popover,\n Typography,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { CaretDown } from '@strapi/icons';\nimport { useField, type InputProps } 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(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\ntype ColorPickerInputProps = InputProps & {\n labelAction?: React.ReactNode;\n};\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {\n const { onChange, value, error } = useField(name);\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.Root name={name} id={name} error={error} hint={hint} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\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 <CaretDown 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 color={color} onChange={(hexValue) => 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 value={value}\n placeholder=\"#000000\"\n onChange={onChange}\n />\n </Field.Root>\n </Flex>\n </FocusTrap>\n </ColorPickerPopover>\n )}\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n"],"names":["styled","HexColorPicker","BaseButton","Popover","React","useField","useIntl","useComposedRefs","Field","Flex","jsx","jsxs","getTrad","Typography","CaretDown","FocusTrap","Box"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,eAAeA,iBAAO,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAKN,CAAC,UAAU,MAAM,KAAK;AAAA;AAAA;AAI5C,MAAM,cAAcA,iBAAAA,OAAOC,cAAAA,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAO5B,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA,cAC7B,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,qBAIvB,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAMrC,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA,kBAC1B,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA;AAAA;AAIhD,MAAM,oBAAoBD,iBAAAA,OAAOE,aAAAA,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAM9B,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CA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+BAA+B;AAAA,oBAC3C,gBAAgB;AAAA,kBAAA,CACjB;AAAA,kBACD,OAAO,EAAE,eAAe,YAAY;AAAA,kBACpC;AAAA,kBACA,aAAY;AAAA,kBACZ;AAAA,gBAAA;AAAA,cAAA,GAEJ;AAAA,YAAA,GACF;AAAA,UAAA,GACF;AAAA,QAAA;AAAA,MACF;AAAA,MAEFF,+BAACF,aAAAA,MAAM,MAAN,EAAW;AAAA,MACZE,+BAACF,aAAAA,MAAM,OAAN,EAAY;AAAA,IAAA,EACf,CAAA,EACF,CAAA;AAAA,EAEJ;AACF;;"}
@@ -0,0 +1,145 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { BaseButton, Popover, useComposedRefs, Field, Flex, Typography, FocusTrap, 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 { g as getTrad } from "./index-L8A6Cbme.mjs";
10
+ const ColorPreview = styled.div`
11
+ border-radius: 50%;
12
+ width: 20px;
13
+ height: 20px;
14
+ margin-right: 10px;
15
+ background-color: ${(props) => props.color};
16
+ border: 1px solid rgba(0, 0, 0, 0.1);
17
+ `;
18
+ const ColorPicker = styled(HexColorPicker)`
19
+ && {
20
+ width: 100%;
21
+ aspect-ratio: 1.5;
22
+ }
23
+
24
+ .react-colorful__pointer {
25
+ width: ${({ theme }) => theme.spaces[3]};
26
+ height: ${({ theme }) => theme.spaces[3]};
27
+ }
28
+
29
+ .react-colorful__saturation {
30
+ border-radius: ${({ theme }) => theme.spaces[1]};
31
+ border-bottom: none;
32
+ }
33
+
34
+ .react-colorful__hue {
35
+ border-radius: 10px;
36
+ height: ${({ theme }) => theme.spaces[3]};
37
+ margin-top: ${({ theme }) => theme.spaces[2]};
38
+ }
39
+ `;
40
+ const ColorPickerToggle = styled(BaseButton)`
41
+ display: flex;
42
+ justify-content: space-between;
43
+ align-items: center;
44
+
45
+ svg {
46
+ width: ${({ theme }) => theme.spaces[2]};
47
+ height: ${({ theme }) => theme.spaces[2]};
48
+ }
49
+
50
+ svg > path {
51
+ fill: ${({ theme }) => theme.colors.neutral500};
52
+ justify-self: flex-end;
53
+ }
54
+ `;
55
+ const ColorPickerPopover = styled(Popover)`
56
+ padding: ${({ theme }) => theme.spaces[2]};
57
+ min-height: 270px;
58
+ `;
59
+ const ColorPickerInput = React.forwardRef(
60
+ ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {
61
+ const { onChange, value, error } = useField(name);
62
+ const [showColorPicker, setShowColorPicker] = React.useState(false);
63
+ const colorPickerButtonRef = React.useRef(null);
64
+ const { formatMessage } = useIntl();
65
+ const color = value || "#000000";
66
+ const handleBlur = (e) => {
67
+ e.preventDefault();
68
+ if (!e.currentTarget.contains(e.relatedTarget)) {
69
+ setShowColorPicker(false);
70
+ }
71
+ };
72
+ const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);
73
+ return /* @__PURE__ */ jsx(Field.Root, { name, id: name, error, hint, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
74
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
75
+ /* @__PURE__ */ jsxs(
76
+ ColorPickerToggle,
77
+ {
78
+ ref: composedRefs,
79
+ "aria-label": formatMessage({
80
+ id: getTrad("color-picker.toggle.aria-label"),
81
+ defaultMessage: "Color picker toggle"
82
+ }),
83
+ "aria-controls": "color-picker-value",
84
+ "aria-haspopup": "dialog",
85
+ "aria-expanded": showColorPicker,
86
+ "aria-disabled": disabled,
87
+ disabled,
88
+ onClick: () => setShowColorPicker(!showColorPicker),
89
+ children: [
90
+ /* @__PURE__ */ jsxs(Flex, { children: [
91
+ /* @__PURE__ */ jsx(ColorPreview, { color }),
92
+ /* @__PURE__ */ jsx(
93
+ Typography,
94
+ {
95
+ style: { textTransform: "uppercase" },
96
+ textColor: value ? void 0 : "neutral600",
97
+ variant: "omega",
98
+ children: color
99
+ }
100
+ )
101
+ ] }),
102
+ /* @__PURE__ */ jsx(CaretDown, { "aria-hidden": true })
103
+ ]
104
+ }
105
+ ),
106
+ showColorPicker && /* @__PURE__ */ jsx(
107
+ ColorPickerPopover,
108
+ {
109
+ onBlur: handleBlur,
110
+ role: "dialog",
111
+ source: colorPickerButtonRef,
112
+ spacing: 4,
113
+ children: /* @__PURE__ */ jsxs(FocusTrap, { onEscape: () => setShowColorPicker(false), children: [
114
+ /* @__PURE__ */ jsx(ColorPicker, { color, onChange: (hexValue) => onChange(name, hexValue) }),
115
+ /* @__PURE__ */ jsxs(Flex, { paddingTop: 3, paddingLeft: 4, justifyContent: "flex-end", children: [
116
+ /* @__PURE__ */ jsx(Box, { paddingRight: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", tag: "label", textColor: "neutral600", children: formatMessage({
117
+ id: getTrad("color-picker.input.format"),
118
+ defaultMessage: "HEX"
119
+ }) }) }),
120
+ /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
121
+ Field.Input,
122
+ {
123
+ "aria-label": formatMessage({
124
+ id: getTrad("color-picker.input.aria-label"),
125
+ defaultMessage: "Color picker input"
126
+ }),
127
+ style: { textTransform: "uppercase" },
128
+ value,
129
+ placeholder: "#000000",
130
+ onChange
131
+ }
132
+ ) })
133
+ ] })
134
+ ] })
135
+ }
136
+ ),
137
+ /* @__PURE__ */ jsx(Field.Hint, {}),
138
+ /* @__PURE__ */ jsx(Field.Error, {})
139
+ ] }) });
140
+ }
141
+ );
142
+ export {
143
+ ColorPickerInput
144
+ };
145
+ //# sourceMappingURL=ColorPickerInput-DAx1G9l8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorPickerInput-DAx1G9l8.mjs","sources":["../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n BaseButton,\n Box,\n Field,\n Flex,\n FocusTrap,\n Popover,\n Typography,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { CaretDown } from '@strapi/icons';\nimport { useField, type InputProps } 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(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\ntype ColorPickerInputProps = InputProps & {\n labelAction?: React.ReactNode;\n};\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {\n const { onChange, value, error } = useField(name);\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.Root name={name} id={name} error={error} hint={hint} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\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 <CaretDown 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 color={color} onChange={(hexValue) => 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 value={value}\n placeholder=\"#000000\"\n onChange={onChange}\n />\n </Field.Root>\n </Flex>\n </FocusTrap>\n </ColorPickerPopover>\n )}\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n"],"names":[],"mappings":";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AS,MAAM,QAAQ,GAAG;AAAA,iCAC5E,MAAK,EAAA,YAAY,GAAG,aAAa,GAAG,gBAAe,YAClD,UAAA;AAAA,cAAC,oBAAA,KAAA,EAAI,cAAc,GACjB,UAAC,oBAAA,YAAA,EAAW,SAAQ,SAAQ,KAAI,SAAQ,WAAU,cAC/C,UAAc,cAAA;AAAA,gBACb,IAAI,QAAQ,2BAA2B;AAAA,gBACvC,gBAAgB;AAAA,cAAA,CACjB,GACH,EACF,CAAA;AAAA,cACA,oBAAC,MAAM,MAAN,EACC,UAAA;AAAA,gBAAC,MAAM;AAAA,gBAAN;AAAA,kBACC,cAAY,cAAc;AAAA,oBACxB,IAAI,QAAQ,+BAA+B;AAAA,oBAC3C,gBAAgB;AAAA,kBAAA,CACjB;AAAA,kBACD,OAAO,EAAE,eAAe,YAAY;AAAA,kBACpC;AAAA,kBACA,aAAY;AAAA,kBACZ;AAAA,gBAAA;AAAA,cAAA,GAEJ;AAAA,YAAA,GACF;AAAA,UAAA,GACF;AAAA,QAAA;AAAA,MACF;AAAA,MAEF,oBAAC,MAAM,MAAN,EAAW;AAAA,MACZ,oBAAC,MAAM,OAAN,EAAY;AAAA,IAAA,EACf,CAAA,EACF,CAAA;AAAA,EAEJ;AACF;"}
@@ -2,9 +2,7 @@
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const designSystem = require("@strapi/design-system");
4
4
  const icons = require("@strapi/icons");
5
- const styled = require("styled-components");
6
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
7
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
5
+ const styledComponents = require("styled-components");
8
6
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
9
7
  const v = glob[path];
10
8
  if (v) {
@@ -14,7 +12,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path) => {
14
12
  (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
15
13
  });
16
14
  };
17
- const IconBox = styled__default.default(designSystem.Flex)`
15
+ const IconBox = styledComponents.styled(designSystem.Flex)`
18
16
  /* Hard code color values */
19
17
  /* to stay consistent between themes */
20
18
  background-color: #f0f0ff; /* primary100 */
@@ -25,7 +23,7 @@ const IconBox = styled__default.default(designSystem.Flex)`
25
23
  }
26
24
  `;
27
25
  const ColorPickerIcon = () => {
28
- return /* @__PURE__ */ jsxRuntime.jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Icon, { as: icons.Paint }) });
26
+ return /* @__PURE__ */ jsxRuntime.jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(icons.PaintBrush, {}) });
29
27
  };
30
28
  const pluginId = "color-picker";
31
29
  const getTrad = (id) => `${pluginId}.${id}`;
@@ -58,7 +56,7 @@ const index = {
58
56
  defaultMessage: "Select any color"
59
57
  },
60
58
  components: {
61
- Input: async () => Promise.resolve().then(() => require("./ColorPickerInput-CkToFC_n.js")).then((module2) => ({
59
+ Input: async () => Promise.resolve().then(() => require("./ColorPickerInput-C0wO-iiI.js")).then((module2) => ({
62
60
  default: module2.ColorPickerInput
63
61
  }))
64
62
  },
@@ -122,4 +120,4 @@ const index = {
122
120
  };
123
121
  exports.getTrad = getTrad;
124
122
  exports.index = index;
125
- //# sourceMappingURL=index-DPJZOfxe.js.map
123
+ //# sourceMappingURL=index-BwmWwO-Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BwmWwO-Q.js","sources":["../../admin/src/components/ColorPickerIcon.tsx","../../admin/src/pluginId.ts","../../admin/src/utils/getTrad.ts","../../admin/src/utils/prefixPluginTranslations.ts","../../admin/src/index.ts"],"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","export const pluginId = 'color-picker';\n","import { pluginId } from '../pluginId';\n\nexport const getTrad = (id: string) => `${pluginId}.${id}`;\n","type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n","import { ColorPickerIcon } from './components/ColorPickerIcon';\nimport { pluginId } from './pluginId';\nimport { getTrad } from './utils/getTrad';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n /**\n * TODO: we need to have the type for StrapiApp done from `@strapi/admin` package.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: any) {\n app.customFields.register({\n name: 'color',\n pluginId: 'color-picker',\n type: 'string',\n icon: ColorPickerIcon,\n intlLabel: {\n id: getTrad('color-picker.label'),\n defaultMessage: 'Color',\n },\n intlDescription: {\n id: getTrad('color-picker.description'),\n defaultMessage: 'Select any color',\n },\n components: {\n Input: async () =>\n import('./components/ColorPickerInput').then((module) => ({\n default: module.ColorPickerInput,\n })),\n },\n options: {\n advanced: [\n {\n intlLabel: {\n id: getTrad('color-picker.options.advanced.regex'),\n defaultMessage: 'RegExp pattern',\n },\n name: 'regex',\n type: 'text',\n defaultValue: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',\n description: {\n id: getTrad('color-picker.options.advanced.regex.description'),\n defaultMessage: 'The text of the regular expression',\n },\n },\n {\n sectionTitle: {\n id: 'global.settings',\n defaultMessage: 'Settings',\n },\n items: [\n {\n name: 'required',\n type: 'checkbox',\n intlLabel: {\n id: getTrad('color-picker.options.advanced.requiredField'),\n defaultMessage: 'Required field',\n },\n description: {\n id: getTrad('color-picker.options.advanced.requiredField.description'),\n defaultMessage: \"You won't be able to create an entry if this field is empty\",\n },\n },\n ],\n },\n ],\n },\n });\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":["styled","Flex","jsx","PaintBrush","pluginId","module"],"mappings":";;;;;;;;;;;;;;AAIA,MAAM,UAAUA,iBAAAA,OAAOC,aAAAA,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWpB,MAAM,kBAAkB,MAAM;AACnC,wCACG,SAAQ,EAAA,gBAAe,UAAS,YAAW,UAAS,OAAO,GAAG,QAAQ,GAAG,WAAS,MAAC,eAAW,MAC7F,UAAAC,2BAAAA,IAACC,oBAAW,EACd,CAAA;AAEJ;ACrBO,MAAM,WAAW;ACEjB,MAAM,UAAU,CAAC,OAAe,GAAG,QAAQ,IAAI,EAAE;ACAxD,MAAM,2BAA2B,CAAC,MAAmBC,cAAkC;AACrF,MAAI,CAACA,WAAU;AACP,UAAA,IAAI,UAAU,yBAAyB;AAAA,EAC/C;AACA,SAAO,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,KAAK,YAAY;AAChD,QAAI,GAAGA,SAAQ,IAAI,OAAO,EAAE,IAAI,KAAK,OAAO;AACrC,WAAA;AAAA,EACT,GAAG,CAAiB,CAAA;AACtB;ACJA,MAAe,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AA+B,uBAAA,OAAA,EAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,IAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,GAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,GAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,GAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,GAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,kBAAA,CAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,OAAA,EACnC,KAAK,CAAC,EAAE,SAAS,WAAW;AACpB,iBAAA;AAAA,YACL,MAAM,yBAAyB,MAAM,QAAQ;AAAA,YAC7C;AAAA,UAAA;AAAA,QACF,CACD,EACA,MAAM,MAAM;AACJ,iBAAA;AAAA,YACL,MAAM,CAAC;AAAA,YACP;AAAA,UAAA;AAAA,QACF,CACD;AAAA,MAAA,CACJ;AAAA,IAAA;AAGI,WAAA,QAAQ,QAAQ,aAAa;AAAA,EACtC;AACF;;;"}
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { Flex, Icon } from "@strapi/design-system";
3
- import { Paint } from "@strapi/icons";
4
- import styled from "styled-components";
2
+ import { Flex } from "@strapi/design-system";
3
+ import { PaintBrush } from "@strapi/icons";
4
+ import { styled } from "styled-components";
5
5
  const __variableDynamicImportRuntimeHelper = (glob, path) => {
6
6
  const v = glob[path];
7
7
  if (v) {
@@ -22,7 +22,7 @@ const IconBox = styled(Flex)`
22
22
  }
23
23
  `;
24
24
  const ColorPickerIcon = () => {
25
- return /* @__PURE__ */ jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsx(Icon, { as: Paint }) });
25
+ return /* @__PURE__ */ jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsx(PaintBrush, {}) });
26
26
  };
27
27
  const pluginId = "color-picker";
28
28
  const getTrad = (id) => `${pluginId}.${id}`;
@@ -55,7 +55,7 @@ const index = {
55
55
  defaultMessage: "Select any color"
56
56
  },
57
57
  components: {
58
- Input: async () => import("./ColorPickerInput-CGxW9duj.mjs").then((module) => ({
58
+ Input: async () => import("./ColorPickerInput-DAx1G9l8.mjs").then((module) => ({
59
59
  default: module.ColorPickerInput
60
60
  }))
61
61
  },
@@ -121,4 +121,4 @@ export {
121
121
  getTrad as g,
122
122
  index as i
123
123
  };
124
- //# sourceMappingURL=index-B_AS5Sky.mjs.map
124
+ //# sourceMappingURL=index-L8A6Cbme.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-L8A6Cbme.mjs","sources":["../../admin/src/components/ColorPickerIcon.tsx","../../admin/src/pluginId.ts","../../admin/src/utils/getTrad.ts","../../admin/src/utils/prefixPluginTranslations.ts","../../admin/src/index.ts"],"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","export const pluginId = 'color-picker';\n","import { pluginId } from '../pluginId';\n\nexport const getTrad = (id: string) => `${pluginId}.${id}`;\n","type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n","import { ColorPickerIcon } from './components/ColorPickerIcon';\nimport { pluginId } from './pluginId';\nimport { getTrad } from './utils/getTrad';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n /**\n * TODO: we need to have the type for StrapiApp done from `@strapi/admin` package.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: any) {\n app.customFields.register({\n name: 'color',\n pluginId: 'color-picker',\n type: 'string',\n icon: ColorPickerIcon,\n intlLabel: {\n id: getTrad('color-picker.label'),\n defaultMessage: 'Color',\n },\n intlDescription: {\n id: getTrad('color-picker.description'),\n defaultMessage: 'Select any color',\n },\n components: {\n Input: async () =>\n import('./components/ColorPickerInput').then((module) => ({\n default: module.ColorPickerInput,\n })),\n },\n options: {\n advanced: [\n {\n intlLabel: {\n id: getTrad('color-picker.options.advanced.regex'),\n defaultMessage: 'RegExp pattern',\n },\n name: 'regex',\n type: 'text',\n defaultValue: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',\n description: {\n id: getTrad('color-picker.options.advanced.regex.description'),\n defaultMessage: 'The text of the regular expression',\n },\n },\n {\n sectionTitle: {\n id: 'global.settings',\n defaultMessage: 'Settings',\n },\n items: [\n {\n name: 'required',\n type: 'checkbox',\n intlLabel: {\n id: getTrad('color-picker.options.advanced.requiredField'),\n defaultMessage: 'Required field',\n },\n description: {\n id: getTrad('color-picker.options.advanced.requiredField.description'),\n defaultMessage: \"You won't be able to create an entry if this field is empty\",\n },\n },\n ],\n },\n ],\n },\n });\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return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AQ,QAAQ,aAAa;AAAA,EACtC;AACF;"}
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-DPJZOfxe.js");
2
+ const index = require("../_chunks/index-BwmWwO-Q.js");
3
3
  module.exports = index.index;
4
4
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-B_AS5Sky.mjs";
1
+ import { i } from "../_chunks/index-L8A6Cbme.mjs";
2
2
  export {
3
3
  i as default
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/plugin-color-picker",
3
- "version": "5.0.0-beta.5",
3
+ "version": "5.0.0-beta.7",
4
4
  "description": "Strapi maintained Custom Fields",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,20 +53,20 @@
53
53
  "watch": "strapi plugin:watch"
54
54
  },
55
55
  "dependencies": {
56
- "@strapi/design-system": "1.18.0",
57
- "@strapi/icons": "1.18.0",
56
+ "@strapi/design-system": "2.0.0-beta.3",
57
+ "@strapi/icons": "2.0.0-beta.3",
58
58
  "react-colorful": "5.6.1",
59
59
  "react-intl": "6.6.2"
60
60
  },
61
61
  "devDependencies": {
62
- "@strapi/strapi": "5.0.0-beta.5",
62
+ "@strapi/strapi": "5.0.0-beta.7",
63
63
  "@testing-library/react": "14.0.0",
64
64
  "@testing-library/user-event": "14.4.3",
65
65
  "@types/styled-components": "5.1.34",
66
66
  "react": "^18.2.0",
67
67
  "react-dom": "^18.2.0",
68
68
  "react-router-dom": "6.22.3",
69
- "styled-components": "5.3.11",
69
+ "styled-components": "6.1.8",
70
70
  "typescript": "5.3.2"
71
71
  },
72
72
  "peerDependencies": {
@@ -74,7 +74,7 @@
74
74
  "react": "^17.0.0 || ^18.0.0",
75
75
  "react-dom": "^17.0.0 || ^18.0.0",
76
76
  "react-router-dom": "^6.0.0",
77
- "styled-components": "^5.2.1"
77
+ "styled-components": "^6.0.0"
78
78
  },
79
79
  "engines": {
80
80
  "node": ">=18.0.0 <=20.x.x",
@@ -86,5 +86,5 @@
86
86
  "kind": "plugin",
87
87
  "displayName": "Color Picker"
88
88
  },
89
- "gitHead": "2aa7d7fb419d7ece2dc1b6c0f45d6c8948abc137"
89
+ "gitHead": "a86c75effabb5eb8aa36a2e9563f2878ddfbb4c1"
90
90
  }
@@ -1,156 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { BaseButton, Popover, useComposedRefs, Field, Flex, FieldLabel, Typography, FocusTrap, Box, FieldInput, FieldHint, FieldError } from "@strapi/design-system";
4
- import { CarretDown } 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 { g as getTrad } from "./index-B_AS5Sky.mjs";
10
- const ColorPreview = styled.div`
11
- border-radius: 50%;
12
- width: 20px;
13
- height: 20px;
14
- margin-right: 10px;
15
- background-color: ${(props) => props.color};
16
- border: 1px solid rgba(0, 0, 0, 0.1);
17
- `;
18
- const ColorPicker = styled(HexColorPicker)`
19
- && {
20
- width: 100%;
21
- aspect-ratio: 1.5;
22
- }
23
-
24
- .react-colorful__pointer {
25
- width: ${({ theme }) => theme.spaces[3]};
26
- height: ${({ theme }) => theme.spaces[3]};
27
- }
28
-
29
- .react-colorful__saturation {
30
- border-radius: ${({ theme }) => theme.spaces[1]};
31
- border-bottom: none;
32
- }
33
-
34
- .react-colorful__hue {
35
- border-radius: 10px;
36
- height: ${({ theme }) => theme.spaces[3]};
37
- margin-top: ${({ theme }) => theme.spaces[2]};
38
- }
39
- `;
40
- const ColorPickerToggle = styled(BaseButton)`
41
- display: flex;
42
- justify-content: space-between;
43
- align-items: center;
44
-
45
- svg {
46
- width: ${({ theme }) => theme.spaces[2]};
47
- height: ${({ theme }) => theme.spaces[2]};
48
- }
49
-
50
- svg > path {
51
- fill: ${({ theme }) => theme.colors.neutral500};
52
- justify-self: flex-end;
53
- }
54
- `;
55
- const ColorPickerPopover = styled(Popover)`
56
- padding: ${({ theme }) => theme.spaces[2]};
57
- min-height: 270px;
58
- `;
59
- const ColorPickerInput = React.forwardRef(
60
- ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {
61
- const { onChange, value, error } = useField(name);
62
- const [showColorPicker, setShowColorPicker] = React.useState(false);
63
- const colorPickerButtonRef = React.useRef(null);
64
- const { formatMessage } = useIntl();
65
- const color = value || "#000000";
66
- const handleBlur = (e) => {
67
- e.preventDefault();
68
- if (!e.currentTarget.contains(e.relatedTarget)) {
69
- setShowColorPicker(false);
70
- }
71
- };
72
- const composedRefs = useComposedRefs(forwardedRef, colorPickerButtonRef);
73
- return /* @__PURE__ */ jsx(
74
- Field,
75
- {
76
- name,
77
- id: name,
78
- error,
79
- hint,
80
- required,
81
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
82
- /* @__PURE__ */ jsx(FieldLabel, { action: labelAction, children: label }),
83
- /* @__PURE__ */ jsxs(
84
- ColorPickerToggle,
85
- {
86
- ref: composedRefs,
87
- "aria-label": formatMessage({
88
- id: getTrad("color-picker.toggle.aria-label"),
89
- defaultMessage: "Color picker toggle"
90
- }),
91
- "aria-controls": "color-picker-value",
92
- "aria-haspopup": "dialog",
93
- "aria-expanded": showColorPicker,
94
- "aria-disabled": disabled,
95
- disabled,
96
- onClick: () => setShowColorPicker(!showColorPicker),
97
- children: [
98
- /* @__PURE__ */ jsxs(Flex, { children: [
99
- /* @__PURE__ */ jsx(ColorPreview, { color }),
100
- /* @__PURE__ */ jsx(
101
- Typography,
102
- {
103
- style: { textTransform: "uppercase" },
104
- textColor: value ? void 0 : "neutral600",
105
- variant: "omega",
106
- children: color
107
- }
108
- )
109
- ] }),
110
- /* @__PURE__ */ jsx(CarretDown, { "aria-hidden": true })
111
- ]
112
- }
113
- ),
114
- showColorPicker && /* @__PURE__ */ jsx(
115
- ColorPickerPopover,
116
- {
117
- onBlur: handleBlur,
118
- role: "dialog",
119
- source: colorPickerButtonRef,
120
- spacing: 4,
121
- children: /* @__PURE__ */ jsxs(FocusTrap, { onEscape: () => setShowColorPicker(false), children: [
122
- /* @__PURE__ */ jsx(ColorPicker, { color, onChange: (hexValue) => onChange(name, hexValue) }),
123
- /* @__PURE__ */ jsxs(Flex, { paddingTop: 3, paddingLeft: 4, justifyContent: "flex-end", children: [
124
- /* @__PURE__ */ jsx(Box, { paddingRight: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "omega", as: "label", textColor: "neutral600", children: formatMessage({
125
- id: getTrad("color-picker.input.format"),
126
- defaultMessage: "HEX"
127
- }) }) }),
128
- /* @__PURE__ */ jsx(
129
- FieldInput,
130
- {
131
- id: "color-picker-value",
132
- "aria-label": formatMessage({
133
- id: getTrad("color-picker.input.aria-label"),
134
- defaultMessage: "Color picker input"
135
- }),
136
- style: { textTransform: "uppercase" },
137
- value,
138
- placeholder: "#000000",
139
- onChange
140
- }
141
- )
142
- ] })
143
- ] })
144
- }
145
- ),
146
- /* @__PURE__ */ jsx(FieldHint, {}),
147
- /* @__PURE__ */ jsx(FieldError, {})
148
- ] })
149
- }
150
- );
151
- }
152
- );
153
- export {
154
- ColorPickerInput
155
- };
156
- //# sourceMappingURL=ColorPickerInput-CGxW9duj.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorPickerInput-CGxW9duj.mjs","sources":["../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["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 useComposedRefs,\n} from '@strapi/design-system';\nimport { CarretDown } from '@strapi/icons';\nimport { useField, type InputProps } 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(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\ntype ColorPickerInputProps = InputProps & {\n labelAction?: React.ReactNode;\n};\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {\n const { onChange, value, error } = useField(name);\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={hint}\n required={required}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <FieldLabel action={labelAction}>{label}</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 color={color} onChange={(hexValue) => onChange(name, hexValue)} />\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":";;;;;;;;;AAwBA,MAAM,eAAe,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,sBAKN,CAAC,UAAU,MAAM,KAAK;AAAA;AAAA;AAI5C,MAAM,cAAc,OAAO,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAO5B,CAAC,EAAE,YAAY,MAAM,OAAO,CA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AQ,IAAG,SAAQ,WAAU,cAC9C,UAAc,cAAA;AAAA,oBACb,IAAI,QAAQ,2BAA2B;AAAA,oBACvC,gBAAgB;AAAA,kBAAA,CACjB,GACH,EACF,CAAA;AAAA,kBACA;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,IAAG;AAAA,sBACH,cAAY,cAAc;AAAA,wBACxB,IAAI,QAAQ,+BAA+B;AAAA,wBAC3C,gBAAgB;AAAA,sBAAA,CACjB;AAAA,sBACD,OAAO,EAAE,eAAe,YAAY;AAAA,sBACpC;AAAA,sBACA,aAAY;AAAA,sBACZ;AAAA,oBAAA;AAAA,kBACF;AAAA,gBAAA,GACF;AAAA,cAAA,GACF;AAAA,YAAA;AAAA,UACF;AAAA,8BAED,WAAU,EAAA;AAAA,8BACV,YAAW,EAAA;AAAA,QAAA,GACd;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;"}
@@ -1,177 +0,0 @@
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 admin = require("@strapi/strapi/admin");
8
- const reactColorful = require("react-colorful");
9
- const reactIntl = require("react-intl");
10
- const styled = require("styled-components");
11
- const index = require("./index-DPJZOfxe.js");
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
- const ColorPreview = styled__default.default.div`
34
- border-radius: 50%;
35
- width: 20px;
36
- height: 20px;
37
- margin-right: 10px;
38
- background-color: ${(props) => props.color};
39
- border: 1px solid rgba(0, 0, 0, 0.1);
40
- `;
41
- const ColorPicker = styled__default.default(reactColorful.HexColorPicker)`
42
- && {
43
- width: 100%;
44
- aspect-ratio: 1.5;
45
- }
46
-
47
- .react-colorful__pointer {
48
- width: ${({ theme }) => theme.spaces[3]};
49
- height: ${({ theme }) => theme.spaces[3]};
50
- }
51
-
52
- .react-colorful__saturation {
53
- border-radius: ${({ theme }) => theme.spaces[1]};
54
- border-bottom: none;
55
- }
56
-
57
- .react-colorful__hue {
58
- border-radius: 10px;
59
- height: ${({ theme }) => theme.spaces[3]};
60
- margin-top: ${({ theme }) => theme.spaces[2]};
61
- }
62
- `;
63
- const ColorPickerToggle = styled__default.default(designSystem.BaseButton)`
64
- display: flex;
65
- justify-content: space-between;
66
- align-items: center;
67
-
68
- svg {
69
- width: ${({ theme }) => theme.spaces[2]};
70
- height: ${({ theme }) => theme.spaces[2]};
71
- }
72
-
73
- svg > path {
74
- fill: ${({ theme }) => theme.colors.neutral500};
75
- justify-self: flex-end;
76
- }
77
- `;
78
- const ColorPickerPopover = styled__default.default(designSystem.Popover)`
79
- padding: ${({ theme }) => theme.spaces[2]};
80
- min-height: 270px;
81
- `;
82
- const ColorPickerInput = React__namespace.forwardRef(
83
- ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {
84
- const { onChange, value, error } = admin.useField(name);
85
- const [showColorPicker, setShowColorPicker] = React__namespace.useState(false);
86
- const colorPickerButtonRef = React__namespace.useRef(null);
87
- const { formatMessage } = reactIntl.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 = designSystem.useComposedRefs(forwardedRef, colorPickerButtonRef);
96
- return /* @__PURE__ */ jsxRuntime.jsx(
97
- designSystem.Field,
98
- {
99
- name,
100
- id: name,
101
- error,
102
- hint,
103
- required,
104
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
105
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { action: labelAction, children: label }),
106
- /* @__PURE__ */ jsxRuntime.jsxs(
107
- ColorPickerToggle,
108
- {
109
- ref: composedRefs,
110
- "aria-label": formatMessage({
111
- id: index.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__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
122
- /* @__PURE__ */ jsxRuntime.jsx(ColorPreview, { color }),
123
- /* @__PURE__ */ jsxRuntime.jsx(
124
- designSystem.Typography,
125
- {
126
- style: { textTransform: "uppercase" },
127
- textColor: value ? void 0 : "neutral600",
128
- variant: "omega",
129
- children: color
130
- }
131
- )
132
- ] }),
133
- /* @__PURE__ */ jsxRuntime.jsx(icons.CarretDown, { "aria-hidden": true })
134
- ]
135
- }
136
- ),
137
- showColorPicker && /* @__PURE__ */ jsxRuntime.jsx(
138
- ColorPickerPopover,
139
- {
140
- onBlur: handleBlur,
141
- role: "dialog",
142
- source: colorPickerButtonRef,
143
- spacing: 4,
144
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.FocusTrap, { onEscape: () => setShowColorPicker(false), children: [
145
- /* @__PURE__ */ jsxRuntime.jsx(ColorPicker, { color, onChange: (hexValue) => onChange(name, hexValue) }),
146
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { paddingTop: 3, paddingLeft: 4, justifyContent: "flex-end", children: [
147
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingRight: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", as: "label", textColor: "neutral600", children: formatMessage({
148
- id: index.getTrad("color-picker.input.format"),
149
- defaultMessage: "HEX"
150
- }) }) }),
151
- /* @__PURE__ */ jsxRuntime.jsx(
152
- designSystem.FieldInput,
153
- {
154
- id: "color-picker-value",
155
- "aria-label": formatMessage({
156
- id: index.getTrad("color-picker.input.aria-label"),
157
- defaultMessage: "Color picker input"
158
- }),
159
- style: { textTransform: "uppercase" },
160
- value,
161
- placeholder: "#000000",
162
- onChange
163
- }
164
- )
165
- ] })
166
- ] })
167
- }
168
- ),
169
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldHint, {}),
170
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldError, {})
171
- ] })
172
- }
173
- );
174
- }
175
- );
176
- exports.ColorPickerInput = ColorPickerInput;
177
- //# sourceMappingURL=ColorPickerInput-CkToFC_n.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorPickerInput-CkToFC_n.js","sources":["../../admin/src/components/ColorPickerInput.tsx"],"sourcesContent":["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 useComposedRefs,\n} from '@strapi/design-system';\nimport { CarretDown } from '@strapi/icons';\nimport { useField, type InputProps } 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(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\ntype ColorPickerInputProps = InputProps & {\n labelAction?: React.ReactNode;\n};\n\nexport const ColorPickerInput = React.forwardRef<HTMLButtonElement, ColorPickerInputProps>(\n ({ hint, disabled = false, labelAction, label, name, required = false }, forwardedRef) => {\n const { onChange, value, error } = useField(name);\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={hint}\n required={required}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <FieldLabel action={labelAction}>{label}</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 color={color} onChange={(hexValue) => onChange(name, hexValue)} />\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":["styled","HexColorPicker","BaseButton","Popover","React","useField","useIntl","useComposedRefs","jsx","Field","Flex","FieldLabel","jsxs","getTrad","Typography","CarretDown","FocusTrap","Box","FieldInput","FieldHint","FieldError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,eAAeA,gBAAO,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAKN,CAAC,UAAU,MAAM,KAAK;AAAA;AAAA;AAI5C,MAAM,cAAcA,gBAAAA,QAAOC,cAAAA,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAO5B,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA,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A,gDAC5EE,aAAAA,MAAK,EAAA,YAAY,GAAG,aAAa,GAAG,gBAAe,YAClD,UAAA;AAAA,kBAACF,2BAAA,IAAAS,aAAA,KAAA,EAAI,cAAc,GACjB,UAACT,2BAAAA,IAAAM,aAAA,YAAA,EAAW,SAAQ,SAAQ,IAAG,SAAQ,WAAU,cAC9C,UAAc,cAAA;AAAA,oBACb,IAAID,cAAQ,2BAA2B;AAAA,oBACvC,gBAAgB;AAAA,kBAAA,CACjB,GACH,EACF,CAAA;AAAA,kBACAL,2BAAA;AAAA,oBAACU,aAAA;AAAA,oBAAA;AAAA,sBACC,IAAG;AAAA,sBACH,cAAY,cAAc;AAAA,wBACxB,IAAIL,cAAQ,+BAA+B;AAAA,wBAC3C,gBAAgB;AAAA,sBAAA,CACjB;AAAA,sBACD,OAAO,EAAE,eAAe,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;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-B_AS5Sky.mjs","sources":["../../admin/src/components/ColorPickerIcon.tsx","../../admin/src/pluginId.ts","../../admin/src/utils/getTrad.ts","../../admin/src/utils/prefixPluginTranslations.ts","../../admin/src/index.ts"],"sourcesContent":["import { Flex, Icon } from '@strapi/design-system';\nimport { Paint } 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 <Icon as={Paint} />\n </IconBox>\n );\n};\n","export const pluginId = 'color-picker';\n","import { pluginId } from '../pluginId';\n\nexport const getTrad = (id: string) => `${pluginId}.${id}`;\n","type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n","import { ColorPickerIcon } from './components/ColorPickerIcon';\nimport { pluginId } from './pluginId';\nimport { getTrad } from './utils/getTrad';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n /**\n * TODO: we need to have the type for StrapiApp done from `@strapi/admin` package.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: any) {\n app.customFields.register({\n name: 'color',\n pluginId: 'color-picker',\n type: 'string',\n icon: ColorPickerIcon,\n intlLabel: {\n id: getTrad('color-picker.label'),\n defaultMessage: 'Color',\n },\n intlDescription: {\n id: getTrad('color-picker.description'),\n defaultMessage: 'Select any color',\n },\n components: {\n Input: async () =>\n import('./components/ColorPickerInput').then((module) => ({\n default: module.ColorPickerInput,\n })),\n },\n options: {\n advanced: [\n {\n intlLabel: {\n id: getTrad('color-picker.options.advanced.regex'),\n defaultMessage: 'RegExp pattern',\n },\n name: 'regex',\n type: 'text',\n defaultValue: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',\n description: {\n id: getTrad('color-picker.options.advanced.regex.description'),\n defaultMessage: 'The text of the regular expression',\n },\n },\n {\n sectionTitle: {\n id: 'global.settings',\n defaultMessage: 'Settings',\n },\n items: [\n {\n name: 'required',\n type: 'checkbox',\n intlLabel: {\n id: getTrad('color-picker.options.advanced.requiredField'),\n defaultMessage: 'Required field',\n },\n description: {\n id: getTrad('color-picker.options.advanced.requiredField.description'),\n defaultMessage: \"You won't be able to create an entry if this field is empty\",\n },\n },\n ],\n },\n ],\n },\n });\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":["pluginId"],"mappings":";;;;;;;;;;;;;AAIA,MAAM,UAAU,OAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWpB,MAAM,kBAAkB,MAAM;AACnC,6BACG,SAAQ,EAAA,gBAAe,UAAS,YAAW,UAAS,OAAO,GAAG,QAAQ,GAAG,WAAS,MAAC,eAAW,MAC7F,8BAAC,MAAK,EAAA,IAAI,OAAO,EACnB,CAAA;AAEJ;ACrBO,MAAM,WAAW;ACEjB,MAAM,UAAU,CAAC,OAAe,GAAG,QAAQ,IAAI,EAAE;ACAxD,MAAM,2BAA2B,CAAC,MAAmBA,cAAkC;AACrF,MAAI,CAACA,WAAU;AACP,UAAA,IAAI,UAAU,yBAAyB;AAAA,EAC/C;AACA,SAAO,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,KAAK,YAAY;AAChD,QAAI,GAAGA,SAAQ,IAAI,OAAO,EAAE,IAAI,KAAK,OAAO;AACrC,WAAA;AAAA,EACT,GAAG,CAAiB,CAAA;AACtB;ACJA,MAAe,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,SAAS,KAAU;AACjB,QAAI,aAAa,SAAS;AAAA,MACxB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,MACN,WAAW;AAAA,QACT,IAAI,QAAQ,oBAAoB;AAAA,QAChC,gBAAgB;AAAA,MAClB;AAAA,MACA,iBAAiB;AA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EACnC,KAAK,CAAC,EAAE,SAAS,WAAW;AACpB,iBAAA;AAAA,YACL,MAAM,yBAAyB,MAAM,QAAQ;AAAA,YAC7C;AAAA,UAAA;AAAA,QACF,CACD,EACA,MAAM,MAAM;AACJ,iBAAA;AAAA,YACL,MAAM,CAAC;AAAA,YACP;AAAA,UAAA;AAAA,QACF,CACD;AAAA,MAAA,CACJ;AAAA,IAAA;AAGI,WAAA,QAAQ,QAAQ,aAAa;AAAA,EACtC;AACF;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-DPJZOfxe.js","sources":["../../admin/src/components/ColorPickerIcon.tsx","../../admin/src/pluginId.ts","../../admin/src/utils/getTrad.ts","../../admin/src/utils/prefixPluginTranslations.ts","../../admin/src/index.ts"],"sourcesContent":["import { Flex, Icon } from '@strapi/design-system';\nimport { Paint } 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 <Icon as={Paint} />\n </IconBox>\n );\n};\n","export const pluginId = 'color-picker';\n","import { pluginId } from '../pluginId';\n\nexport const getTrad = (id: string) => `${pluginId}.${id}`;\n","type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n","import { ColorPickerIcon } from './components/ColorPickerIcon';\nimport { pluginId } from './pluginId';\nimport { getTrad } from './utils/getTrad';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n /**\n * TODO: we need to have the type for StrapiApp done from `@strapi/admin` package.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register(app: any) {\n app.customFields.register({\n name: 'color',\n pluginId: 'color-picker',\n type: 'string',\n icon: ColorPickerIcon,\n intlLabel: {\n id: getTrad('color-picker.label'),\n defaultMessage: 'Color',\n },\n intlDescription: {\n id: getTrad('color-picker.description'),\n defaultMessage: 'Select any color',\n },\n components: {\n Input: async () =>\n import('./components/ColorPickerInput').then((module) => ({\n default: module.ColorPickerInput,\n })),\n },\n options: {\n advanced: [\n {\n intlLabel: {\n id: getTrad('color-picker.options.advanced.regex'),\n defaultMessage: 'RegExp pattern',\n },\n name: 'regex',\n type: 'text',\n defaultValue: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',\n description: {\n id: getTrad('color-picker.options.advanced.regex.description'),\n defaultMessage: 'The text of the regular expression',\n },\n },\n {\n sectionTitle: {\n id: 'global.settings',\n defaultMessage: 'Settings',\n },\n items: [\n {\n name: 'required',\n type: 'checkbox',\n intlLabel: {\n id: getTrad('color-picker.options.advanced.requiredField'),\n defaultMessage: 'Required field',\n },\n description: {\n id: getTrad('color-picker.options.advanced.requiredField.description'),\n defaultMessage: \"You won't be able to create an entry if this field is empty\",\n },\n },\n ],\n },\n ],\n },\n });\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, pluginId),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n"],"names":["styled","Flex","Icon","Paint","pluginId","module"],"mappings":";;;;;;;;;;;;;;;;AAIA,MAAM,UAAUA,gBAAAA,QAAOC,aAAAA,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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