@strapi/plugin-color-picker 0.0.0-next.f45143c5e2a8a9d85691d0abf79a3f42024a0c71 → 0.0.0-next.f5b09a8e61e059f02784478e27c310c6290be088
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -19
- package/dist/_chunks/ColorPickerInput-0d985ad5.mjs +277 -0
- package/dist/_chunks/ColorPickerInput-0d985ad5.mjs.map +1 -0
- package/dist/_chunks/ColorPickerInput-8875b370.js +298 -0
- package/dist/_chunks/ColorPickerInput-8875b370.js.map +1 -0
- package/{admin/src/translations/cs.json → dist/_chunks/cs-32e5b75a.mjs} +6 -2
- package/dist/_chunks/cs-32e5b75a.mjs.map +1 -0
- package/dist/_chunks/cs-c22467c6.js +16 -0
- package/dist/_chunks/cs-c22467c6.js.map +1 -0
- package/{admin/src/translations/en.json → dist/_chunks/en-2230584b.mjs} +6 -2
- package/dist/_chunks/en-2230584b.mjs.map +1 -0
- package/dist/_chunks/en-eb6717ab.js +19 -0
- package/dist/_chunks/en-eb6717ab.js.map +1 -0
- package/dist/_chunks/index-214132a2.mjs +124 -0
- package/dist/_chunks/index-214132a2.mjs.map +1 -0
- package/dist/_chunks/index-9695efa4.js +125 -0
- package/dist/_chunks/index-9695efa4.js.map +1 -0
- package/{admin/src/translations/ru.json → dist/_chunks/ru-0bf57448.mjs} +6 -2
- package/dist/_chunks/ru-0bf57448.mjs.map +1 -0
- package/dist/_chunks/ru-1d1cf8a8.js +19 -0
- package/dist/_chunks/ru-1d1cf8a8.js.map +1 -0
- package/dist/_chunks/sv-6e7fa200.js +16 -0
- package/dist/_chunks/sv-6e7fa200.js.map +1 -0
- package/{admin/src/translations/sv.json → dist/_chunks/sv-de6a785a.mjs} +6 -2
- package/dist/_chunks/sv-de6a785a.mjs.map +1 -0
- package/{admin/src/translations/tr.json → dist/_chunks/tr-4d632eac.mjs} +6 -2
- package/dist/_chunks/tr-4d632eac.mjs.map +1 -0
- package/dist/_chunks/tr-67b6e192.js +16 -0
- package/dist/_chunks/tr-67b6e192.js.map +1 -0
- package/{admin/src/translations/zh.json → dist/_chunks/zh-5ba3e025.mjs} +6 -2
- package/dist/_chunks/zh-5ba3e025.mjs.map +1 -0
- package/dist/_chunks/zh-e5010f8b.js +16 -0
- package/dist/_chunks/zh-e5010f8b.js.map +1 -0
- package/dist/admin/components/ColorPickerIcon.d.ts +1 -0
- package/dist/admin/components/ColorPickerInput.d.ts +32 -0
- package/dist/admin/hooks/useComposeRefs.d.ts +29 -0
- package/dist/admin/index.d.ts +18 -0
- package/dist/admin/index.js +9 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/index.mjs +10 -0
- package/dist/admin/index.mjs.map +1 -0
- package/dist/admin/pluginId.d.ts +1 -0
- package/dist/admin/utils/getTrad.d.ts +1 -0
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +13 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +14 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/server/register.d.ts +2 -0
- package/dist/server/register.d.ts.map +1 -0
- package/package.json +68 -38
- package/strapi-server.js +1 -1
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -14
- package/admin/src/components/ColorPicker/ColorPickerIcon/index.js +0 -25
- package/admin/src/components/ColorPicker/ColorPickerInput/index.js +0 -205
- package/admin/src/components/tests/__snapshots__/color-picker-input.test.js.snap +0 -238
- package/admin/src/components/tests/color-picker-input.test.js +0 -63
- package/admin/src/index.js +0 -87
- package/admin/src/pluginId.js +0 -5
- package/admin/src/utils/getTrad.js +0 -5
- package/color-picker.png +0 -0
- package/jest.config.front.js +0 -5
- package/server/index.js +0 -7
- package/server/register.js +0 -9
- package/strapi-admin.js +0 -3
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<ColorPickerInput /> renders and matches the snapshot 1`] = `
|
|
4
|
-
.c3 {
|
|
5
|
-
background: #ffffff;
|
|
6
|
-
padding: 8px;
|
|
7
|
-
border-radius: 4px;
|
|
8
|
-
border-color: #dcdce4;
|
|
9
|
-
border: 1px solid #dcdce4;
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.c0 {
|
|
14
|
-
-webkit-align-items: stretch;
|
|
15
|
-
-webkit-box-align: stretch;
|
|
16
|
-
-ms-flex-align: stretch;
|
|
17
|
-
align-items: stretch;
|
|
18
|
-
display: -webkit-box;
|
|
19
|
-
display: -webkit-flex;
|
|
20
|
-
display: -ms-flexbox;
|
|
21
|
-
display: flex;
|
|
22
|
-
-webkit-flex-direction: column;
|
|
23
|
-
-ms-flex-direction: column;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: 4px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.c4 {
|
|
29
|
-
-webkit-align-items: center;
|
|
30
|
-
-webkit-box-align: center;
|
|
31
|
-
-ms-flex-align: center;
|
|
32
|
-
align-items: center;
|
|
33
|
-
display: -webkit-box;
|
|
34
|
-
display: -webkit-flex;
|
|
35
|
-
display: -ms-flexbox;
|
|
36
|
-
display: flex;
|
|
37
|
-
-webkit-flex-direction: row;
|
|
38
|
-
-ms-flex-direction: row;
|
|
39
|
-
flex-direction: row;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.c1 {
|
|
43
|
-
font-size: 0.75rem;
|
|
44
|
-
line-height: 1.33;
|
|
45
|
-
font-weight: 600;
|
|
46
|
-
color: #32324d;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.c8 {
|
|
50
|
-
font-size: 0.875rem;
|
|
51
|
-
line-height: 1.43;
|
|
52
|
-
color: #666687;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.c5 {
|
|
56
|
-
position: relative;
|
|
57
|
-
outline: none;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.c5 svg {
|
|
61
|
-
height: 12px;
|
|
62
|
-
width: 12px;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.c5 svg > g,
|
|
66
|
-
.c5 svg path {
|
|
67
|
-
fill: #ffffff;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.c5[aria-disabled='true'] {
|
|
71
|
-
pointer-events: none;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.c5:after {
|
|
75
|
-
-webkit-transition-property: all;
|
|
76
|
-
transition-property: all;
|
|
77
|
-
-webkit-transition-duration: 0.2s;
|
|
78
|
-
transition-duration: 0.2s;
|
|
79
|
-
border-radius: 8px;
|
|
80
|
-
content: '';
|
|
81
|
-
position: absolute;
|
|
82
|
-
top: -4px;
|
|
83
|
-
bottom: -4px;
|
|
84
|
-
left: -4px;
|
|
85
|
-
right: -4px;
|
|
86
|
-
border: 2px solid transparent;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.c5:focus-visible {
|
|
90
|
-
outline: none;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.c5:focus-visible:after {
|
|
94
|
-
border-radius: 8px;
|
|
95
|
-
content: '';
|
|
96
|
-
position: absolute;
|
|
97
|
-
top: -5px;
|
|
98
|
-
bottom: -5px;
|
|
99
|
-
left: -5px;
|
|
100
|
-
right: -5px;
|
|
101
|
-
border: 2px solid #4945ff;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.c9 {
|
|
105
|
-
border: 0;
|
|
106
|
-
-webkit-clip: rect(0 0 0 0);
|
|
107
|
-
clip: rect(0 0 0 0);
|
|
108
|
-
height: 1px;
|
|
109
|
-
margin: -1px;
|
|
110
|
-
overflow: hidden;
|
|
111
|
-
padding: 0;
|
|
112
|
-
position: absolute;
|
|
113
|
-
width: 1px;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.c2 {
|
|
117
|
-
display: -webkit-box;
|
|
118
|
-
display: -webkit-flex;
|
|
119
|
-
display: -ms-flexbox;
|
|
120
|
-
display: flex;
|
|
121
|
-
-webkit-align-items: center;
|
|
122
|
-
-webkit-box-align: center;
|
|
123
|
-
-ms-flex-align: center;
|
|
124
|
-
align-items: center;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.c7 {
|
|
128
|
-
border-radius: 50%;
|
|
129
|
-
width: 20px;
|
|
130
|
-
height: 20px;
|
|
131
|
-
margin-right: 10px;
|
|
132
|
-
background-color: #000000;
|
|
133
|
-
border: 1px solid rgba(0,0,0,0.1);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.c6 {
|
|
137
|
-
display: -webkit-box;
|
|
138
|
-
display: -webkit-flex;
|
|
139
|
-
display: -ms-flexbox;
|
|
140
|
-
display: flex;
|
|
141
|
-
-webkit-box-pack: justify;
|
|
142
|
-
-webkit-justify-content: space-between;
|
|
143
|
-
-ms-flex-pack: justify;
|
|
144
|
-
justify-content: space-between;
|
|
145
|
-
-webkit-align-items: center;
|
|
146
|
-
-webkit-box-align: center;
|
|
147
|
-
-ms-flex-align: center;
|
|
148
|
-
align-items: center;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.c6 svg {
|
|
152
|
-
width: 8px;
|
|
153
|
-
height: 8px;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.c6 svg > path {
|
|
157
|
-
fill: #8e8ea9;
|
|
158
|
-
justify-self: flex-end;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
<div>
|
|
162
|
-
<div
|
|
163
|
-
class=""
|
|
164
|
-
>
|
|
165
|
-
<div
|
|
166
|
-
class="c0"
|
|
167
|
-
>
|
|
168
|
-
<label
|
|
169
|
-
class="c1 c2"
|
|
170
|
-
for="color"
|
|
171
|
-
>
|
|
172
|
-
color-picker
|
|
173
|
-
</label>
|
|
174
|
-
<button
|
|
175
|
-
aria-controls="color-picker-value"
|
|
176
|
-
aria-disabled="false"
|
|
177
|
-
aria-expanded="false"
|
|
178
|
-
aria-haspopup="dialog"
|
|
179
|
-
aria-label="Color picker toggle"
|
|
180
|
-
class="c3 c4 c5 c6"
|
|
181
|
-
type="button"
|
|
182
|
-
>
|
|
183
|
-
<div
|
|
184
|
-
class="c4"
|
|
185
|
-
>
|
|
186
|
-
<div
|
|
187
|
-
class="c7"
|
|
188
|
-
color="#000000"
|
|
189
|
-
/>
|
|
190
|
-
<span
|
|
191
|
-
class="c8"
|
|
192
|
-
style="text-transform: uppercase;"
|
|
193
|
-
>
|
|
194
|
-
#000000
|
|
195
|
-
</span>
|
|
196
|
-
</div>
|
|
197
|
-
<svg
|
|
198
|
-
aria-hidden="true"
|
|
199
|
-
fill="none"
|
|
200
|
-
height="1rem"
|
|
201
|
-
viewBox="0 0 14 8"
|
|
202
|
-
width="1rem"
|
|
203
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
204
|
-
>
|
|
205
|
-
<path
|
|
206
|
-
clip-rule="evenodd"
|
|
207
|
-
d="M14 .889a.86.86 0 0 1-.26.625L7.615 7.736A.834.834 0 0 1 7 8a.834.834 0 0 1-.615-.264L.26 1.514A.861.861 0 0 1 0 .889c0-.24.087-.45.26-.625A.834.834 0 0 1 .875 0h12.25c.237 0 .442.088.615.264a.86.86 0 0 1 .26.625Z"
|
|
208
|
-
fill="#32324D"
|
|
209
|
-
fill-rule="evenodd"
|
|
210
|
-
/>
|
|
211
|
-
</svg>
|
|
212
|
-
</button>
|
|
213
|
-
</div>
|
|
214
|
-
</div>
|
|
215
|
-
<div
|
|
216
|
-
class="c9"
|
|
217
|
-
>
|
|
218
|
-
<p
|
|
219
|
-
aria-live="polite"
|
|
220
|
-
aria-relevant="all"
|
|
221
|
-
id="live-region-log"
|
|
222
|
-
role="log"
|
|
223
|
-
/>
|
|
224
|
-
<p
|
|
225
|
-
aria-live="polite"
|
|
226
|
-
aria-relevant="all"
|
|
227
|
-
id="live-region-status"
|
|
228
|
-
role="status"
|
|
229
|
-
/>
|
|
230
|
-
<p
|
|
231
|
-
aria-live="assertive"
|
|
232
|
-
aria-relevant="all"
|
|
233
|
-
id="live-region-alert"
|
|
234
|
-
role="alert"
|
|
235
|
-
/>
|
|
236
|
-
</div>
|
|
237
|
-
</div>
|
|
238
|
-
`;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
-
import { lightTheme, ThemeProvider } from '@strapi/design-system';
|
|
4
|
-
import { IntlProvider } from 'react-intl';
|
|
5
|
-
import ColorPickerInput from '../ColorPicker/ColorPickerInput';
|
|
6
|
-
|
|
7
|
-
const mockAttribute = {
|
|
8
|
-
customField: 'plugin::color-picker.color',
|
|
9
|
-
pluginOptions: { i18n: { localized: true } },
|
|
10
|
-
type: 'string',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const App = (
|
|
14
|
-
<IntlProvider locale="en" messages={{}} textComponent="span">
|
|
15
|
-
<ThemeProvider theme={lightTheme}>
|
|
16
|
-
<ColorPickerInput
|
|
17
|
-
name="color"
|
|
18
|
-
value=""
|
|
19
|
-
onChange={jest.fn()}
|
|
20
|
-
attribute={mockAttribute}
|
|
21
|
-
intlLabel={{ id: 'color-picker', defaultMessage: 'color-picker' }}
|
|
22
|
-
/>
|
|
23
|
-
</ThemeProvider>
|
|
24
|
-
</IntlProvider>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
describe('<ColorPickerInput />', () => {
|
|
28
|
-
/**
|
|
29
|
-
* We do this because –
|
|
30
|
-
* https://github.com/facebook/jest/issues/12670
|
|
31
|
-
*/
|
|
32
|
-
beforeAll(() => {
|
|
33
|
-
jest.setTimeout(30000);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Reset timeout to what is expected
|
|
38
|
-
*/
|
|
39
|
-
afterAll(() => {
|
|
40
|
-
jest.setTimeout(5000);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('renders and matches the snapshot', () => {
|
|
44
|
-
const { container } = render(App);
|
|
45
|
-
|
|
46
|
-
expect(container).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('toggles the popover', () => {
|
|
50
|
-
render(App);
|
|
51
|
-
const colorPickerToggle = screen.getByRole('button', { name: 'Color picker toggle' });
|
|
52
|
-
fireEvent.click(colorPickerToggle);
|
|
53
|
-
|
|
54
|
-
const popover = screen.getByRole('dialog');
|
|
55
|
-
const saturation = screen.getByRole('slider', { name: 'Color' });
|
|
56
|
-
const hue = screen.getByRole('slider', { name: 'Hue' });
|
|
57
|
-
const input = screen.getByRole('textbox', { name: 'Color picker input' });
|
|
58
|
-
expect(popover).toBeVisible();
|
|
59
|
-
expect(saturation).toBeVisible();
|
|
60
|
-
expect(hue).toBeVisible();
|
|
61
|
-
expect(input).toBeVisible();
|
|
62
|
-
});
|
|
63
|
-
});
|
package/admin/src/index.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
2
|
-
import pluginId from './pluginId';
|
|
3
|
-
import ColorPickerIcon from './components/ColorPicker/ColorPickerIcon';
|
|
4
|
-
import getTrad from './utils/getTrad';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
register(app) {
|
|
8
|
-
app.customFields.register({
|
|
9
|
-
name: 'color',
|
|
10
|
-
pluginId: 'color-picker',
|
|
11
|
-
type: 'string',
|
|
12
|
-
icon: ColorPickerIcon,
|
|
13
|
-
intlLabel: {
|
|
14
|
-
id: getTrad('color-picker.label'),
|
|
15
|
-
defaultMessage: 'Color',
|
|
16
|
-
},
|
|
17
|
-
intlDescription: {
|
|
18
|
-
id: getTrad('color-picker.description'),
|
|
19
|
-
defaultMessage: 'Select any color',
|
|
20
|
-
},
|
|
21
|
-
components: {
|
|
22
|
-
Input: async () =>
|
|
23
|
-
import(
|
|
24
|
-
/* webpackChunkName: "color-picker-input-component" */ './components/ColorPicker/ColorPickerInput'
|
|
25
|
-
),
|
|
26
|
-
},
|
|
27
|
-
options: {
|
|
28
|
-
advanced: [
|
|
29
|
-
{
|
|
30
|
-
intlLabel: {
|
|
31
|
-
id: getTrad('color-picker.options.advanced.regex'),
|
|
32
|
-
defaultMessage: 'RegExp pattern',
|
|
33
|
-
},
|
|
34
|
-
name: 'regex',
|
|
35
|
-
type: 'text',
|
|
36
|
-
defaultValue: '^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$',
|
|
37
|
-
description: {
|
|
38
|
-
id: getTrad('color-picker.options.advanced.regex.description'),
|
|
39
|
-
defaultMessage: 'The text of the regular expression',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
sectionTitle: {
|
|
44
|
-
id: 'global.settings',
|
|
45
|
-
defaultMessage: 'Settings',
|
|
46
|
-
},
|
|
47
|
-
items: [
|
|
48
|
-
{
|
|
49
|
-
name: 'required',
|
|
50
|
-
type: 'checkbox',
|
|
51
|
-
intlLabel: {
|
|
52
|
-
id: getTrad('color-picker.options.advanced.requiredField'),
|
|
53
|
-
defaultMessage: 'Required field',
|
|
54
|
-
},
|
|
55
|
-
description: {
|
|
56
|
-
id: getTrad('color-picker.options.advanced.requiredField.description'),
|
|
57
|
-
defaultMessage: "You won't be able to create an entry if this field is empty",
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
async registerTrads({ locales }) {
|
|
67
|
-
const importedTrads = await Promise.all(
|
|
68
|
-
locales.map((locale) => {
|
|
69
|
-
return import(`./translations/${locale}.json`)
|
|
70
|
-
.then(({ default: data }) => {
|
|
71
|
-
return {
|
|
72
|
-
data: prefixPluginTranslations(data, pluginId),
|
|
73
|
-
locale,
|
|
74
|
-
};
|
|
75
|
-
})
|
|
76
|
-
.catch(() => {
|
|
77
|
-
return {
|
|
78
|
-
data: {},
|
|
79
|
-
locale,
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
return Promise.resolve(importedTrads);
|
|
86
|
-
},
|
|
87
|
-
};
|
package/admin/src/pluginId.js
DELETED
package/color-picker.png
DELETED
|
Binary file
|
package/jest.config.front.js
DELETED
package/server/index.js
DELETED
package/server/register.js
DELETED
package/strapi-admin.js
DELETED