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

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 (67) hide show
  1. package/LICENSE +12 -19
  2. package/dist/_chunks/ColorPickerInput-0lOoTrf0.js +206 -0
  3. package/dist/_chunks/ColorPickerInput-0lOoTrf0.js.map +1 -0
  4. package/dist/_chunks/ColorPickerInput-fKB6YXW8.mjs +185 -0
  5. package/dist/_chunks/ColorPickerInput-fKB6YXW8.mjs.map +1 -0
  6. package/dist/_chunks/cs-4GdZY0p6.js +16 -0
  7. package/dist/_chunks/cs-4GdZY0p6.js.map +1 -0
  8. package/{admin/src/translations/cs.json → dist/_chunks/cs-A2xRj-2-.mjs} +6 -2
  9. package/dist/_chunks/cs-A2xRj-2-.mjs.map +1 -0
  10. package/{admin/src/translations/en.json → dist/_chunks/en-L6ZZWDJv.mjs} +6 -2
  11. package/dist/_chunks/en-L6ZZWDJv.mjs.map +1 -0
  12. package/dist/_chunks/en-WeRHjVEB.js +19 -0
  13. package/dist/_chunks/en-WeRHjVEB.js.map +1 -0
  14. package/dist/_chunks/index-OJYEuoCq.js +117 -0
  15. package/dist/_chunks/index-OJYEuoCq.js.map +1 -0
  16. package/dist/_chunks/index-uOrtnJpz.mjs +116 -0
  17. package/dist/_chunks/index-uOrtnJpz.mjs.map +1 -0
  18. package/{admin/src/translations/ru.json → dist/_chunks/ru-LLXYEOwl.mjs} +6 -2
  19. package/dist/_chunks/ru-LLXYEOwl.mjs.map +1 -0
  20. package/dist/_chunks/ru-UXN_ByI9.js +19 -0
  21. package/dist/_chunks/ru-UXN_ByI9.js.map +1 -0
  22. package/dist/_chunks/sv-3-Yk9bKb.js +16 -0
  23. package/dist/_chunks/sv-3-Yk9bKb.js.map +1 -0
  24. package/{admin/src/translations/sv.json → dist/_chunks/sv-QqRPNQLw.mjs} +6 -2
  25. package/dist/_chunks/sv-QqRPNQLw.mjs.map +1 -0
  26. package/dist/_chunks/tr-AbD-f8F0.js +16 -0
  27. package/dist/_chunks/tr-AbD-f8F0.js.map +1 -0
  28. package/{admin/src/translations/tr.json → dist/_chunks/tr-qYGSw8gH.mjs} +6 -2
  29. package/dist/_chunks/tr-qYGSw8gH.mjs.map +1 -0
  30. package/dist/_chunks/zh-c23gv_oM.js +16 -0
  31. package/dist/_chunks/zh-c23gv_oM.js.map +1 -0
  32. package/{admin/src/translations/zh.json → dist/_chunks/zh-fPTOIT6s.mjs} +6 -2
  33. package/dist/_chunks/zh-fPTOIT6s.mjs.map +1 -0
  34. package/dist/admin/index.js +9 -0
  35. package/dist/admin/index.js.map +1 -0
  36. package/dist/admin/index.mjs +10 -0
  37. package/dist/admin/index.mjs.map +1 -0
  38. package/dist/admin/src/components/ColorPickerIcon.d.ts +1 -0
  39. package/dist/admin/src/components/ColorPickerInput.d.ts +32 -0
  40. package/dist/admin/src/hooks/useComposeRefs.d.ts +29 -0
  41. package/dist/admin/src/index.d.ts +18 -0
  42. package/dist/admin/src/pluginId.d.ts +1 -0
  43. package/dist/admin/src/utils/getTrad.d.ts +1 -0
  44. package/dist/server/index.js +13 -0
  45. package/dist/server/index.js.map +1 -0
  46. package/dist/server/index.mjs +14 -0
  47. package/dist/server/index.mjs.map +1 -0
  48. package/dist/server/src/index.d.ts +5 -0
  49. package/dist/server/src/index.d.ts.map +1 -0
  50. package/dist/server/src/register.d.ts +2 -0
  51. package/dist/server/src/register.d.ts.map +1 -0
  52. package/package.json +67 -38
  53. package/strapi-server.js +1 -1
  54. package/.eslintignore +0 -2
  55. package/.eslintrc.js +0 -14
  56. package/admin/src/components/ColorPicker/ColorPickerIcon/index.js +0 -25
  57. package/admin/src/components/ColorPicker/ColorPickerInput/index.js +0 -205
  58. package/admin/src/components/tests/__snapshots__/color-picker-input.test.js.snap +0 -238
  59. package/admin/src/components/tests/color-picker-input.test.js +0 -63
  60. package/admin/src/index.js +0 -87
  61. package/admin/src/pluginId.js +0 -5
  62. package/admin/src/utils/getTrad.js +0 -5
  63. package/color-picker.png +0 -0
  64. package/jest.config.front.js +0 -6
  65. package/server/index.js +0 -7
  66. package/server/register.js +0 -9
  67. package/strapi-admin.js +0 -3
package/package.json CHANGED
@@ -1,42 +1,7 @@
1
1
  {
2
2
  "name": "@strapi/plugin-color-picker",
3
- "version": "0.0.0-next.e3b4cdeebf6e9b0cd5575ff80b8a86715d44ce98",
3
+ "version": "0.0.0-next.e6eaa3d0563c85f80fd88b258df70a55c057096e",
4
4
  "description": "Strapi maintained Custom Fields",
5
- "strapi": {
6
- "name": "color-picker",
7
- "description": "Color picker custom field",
8
- "kind": "plugin",
9
- "displayName": "Color Picker"
10
- },
11
- "dependencies": {
12
- "@strapi/design-system": "1.7.5",
13
- "@strapi/helper-plugin": "0.0.0-next.e3b4cdeebf6e9b0cd5575ff80b8a86715d44ce98",
14
- "@strapi/icons": "1.7.5",
15
- "prop-types": "^15.7.2",
16
- "react-colorful": "5.6.1",
17
- "react-intl": "6.4.1"
18
- },
19
- "devDependencies": {
20
- "@testing-library/react": "12.1.4",
21
- "react": "^17.0.2",
22
- "react-dom": "^17.0.2",
23
- "react-router-dom": "5.3.4",
24
- "styled-components": "5.3.3"
25
- },
26
- "peerDependencies": {
27
- "@strapi/strapi": "^4.4.0",
28
- "react": "^17.0.2",
29
- "react-dom": "^17.0.2",
30
- "react-router-dom": "^5.3.4",
31
- "styled-components": "^5.3.3"
32
- },
33
- "scripts": {
34
- "test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
35
- "test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
36
- "test:front:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js",
37
- "test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
38
- "lint": "run -T eslint ."
39
- },
40
5
  "repository": {
41
6
  "type": "git",
42
7
  "url": "https://github.com/strapi/strapi.git",
@@ -55,9 +20,73 @@
55
20
  "url": "https://strapi.io"
56
21
  }
57
22
  ],
23
+ "exports": {
24
+ "./strapi-admin": {
25
+ "types": "./dist/admin/src/index.d.ts",
26
+ "source": "./admin/src/index.ts",
27
+ "import": "./dist/admin/index.mjs",
28
+ "require": "./dist/admin/index.js",
29
+ "default": "./dist/admin/index.js"
30
+ },
31
+ "./strapi-server": {
32
+ "types": "./dist/server/src/index.d.ts",
33
+ "source": "./server/src/index.ts",
34
+ "import": "./dist/server/index.mjs",
35
+ "require": "./dist/server/index.js",
36
+ "default": "./dist/server/index.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "./dist",
42
+ "strapi-server.js"
43
+ ],
44
+ "scripts": {
45
+ "build": "strapi plugin:build --force",
46
+ "clean": "run -T rimraf ./dist",
47
+ "lint": "run -T eslint .",
48
+ "test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
49
+ "test:front:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js",
50
+ "test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
51
+ "test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
52
+ "test:ts:front": "run -T tsc -p admin/tsconfig.json",
53
+ "watch": "strapi plugin:watch"
54
+ },
55
+ "dependencies": {
56
+ "@strapi/design-system": "1.16.0",
57
+ "@strapi/helper-plugin": "0.0.0-next.e6eaa3d0563c85f80fd88b258df70a55c057096e",
58
+ "@strapi/icons": "1.16.0",
59
+ "prop-types": "^15.8.1",
60
+ "react-colorful": "5.6.1",
61
+ "react-intl": "6.4.1"
62
+ },
63
+ "devDependencies": {
64
+ "@strapi/strapi": "0.0.0-next.e6eaa3d0563c85f80fd88b258df70a55c057096e",
65
+ "@testing-library/react": "14.0.0",
66
+ "@testing-library/user-event": "14.4.3",
67
+ "@types/styled-components": "5.1.32",
68
+ "react": "^18.2.0",
69
+ "react-dom": "^18.2.0",
70
+ "react-router-dom": "5.3.4",
71
+ "styled-components": "5.3.3",
72
+ "typescript": "5.2.2"
73
+ },
74
+ "peerDependencies": {
75
+ "@strapi/strapi": "^4.4.0",
76
+ "react": "^17.0.0 || ^18.0.0",
77
+ "react-dom": "^17.0.0 || ^18.0.0",
78
+ "react-router-dom": "^5.2.0",
79
+ "styled-components": "^5.2.1"
80
+ },
58
81
  "engines": {
59
- "node": ">=14.19.1 <=18.x.x",
82
+ "node": ">=18.0.0 <=20.x.x",
60
83
  "npm": ">=6.0.0"
61
84
  },
62
- "gitHead": "e3b4cdeebf6e9b0cd5575ff80b8a86715d44ce98"
85
+ "strapi": {
86
+ "name": "color-picker",
87
+ "description": "Color picker custom field",
88
+ "kind": "plugin",
89
+ "displayName": "Color Picker"
90
+ },
91
+ "gitHead": "e6eaa3d0563c85f80fd88b258df70a55c057096e"
63
92
  }
package/strapi-server.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = require('./server');
3
+ module.exports = require('./dist/server');
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules/
2
- .eslintrc.js
package/.eslintrc.js DELETED
@@ -1,14 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- overrides: [
4
- {
5
- files: ['admin/**/*'],
6
- extends: ['custom/front'],
7
- },
8
- {
9
- files: ['**/*'],
10
- excludedFiles: ['admin/**/*'],
11
- extends: ['custom/back'],
12
- },
13
- ],
14
- };
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import { Icon, Flex } from '@strapi/design-system';
4
- import { Paint } from '@strapi/icons';
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
-
17
- const ColorPickerIcon = () => {
18
- return (
19
- <IconBox justifyContent="center" alignItems="center" width={7} height={6} hasRadius aria-hidden>
20
- <Icon as={Paint} />
21
- </IconBox>
22
- );
23
- };
24
-
25
- export default ColorPickerIcon;
@@ -1,205 +0,0 @@
1
- import React, { useState, useRef } from 'react';
2
- import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
4
- import {
5
- Typography,
6
- Flex,
7
- Box,
8
- BaseButton,
9
- FocusTrap,
10
- Field,
11
- FieldHint,
12
- FieldError,
13
- FieldLabel,
14
- FieldInput,
15
- Popover,
16
- } from '@strapi/design-system';
17
- import { CarretDown } from '@strapi/icons';
18
- import { useIntl } from 'react-intl';
19
- import { HexColorPicker } from 'react-colorful';
20
-
21
- import getTrad from '../../../utils/getTrad';
22
-
23
- const ColorPreview = styled.div`
24
- border-radius: 50%;
25
- width: 20px;
26
- height: 20px;
27
- margin-right: 10px;
28
- background-color: ${(props) => props.color};
29
- border: 1px solid rgba(0, 0, 0, 0.1);
30
- `;
31
-
32
- const ColorPicker = styled(HexColorPicker)`
33
- && {
34
- width: 100%;
35
- aspect-ratio: 1.5;
36
- }
37
-
38
- .react-colorful__pointer {
39
- width: ${({ theme }) => theme.spaces[3]};
40
- height: ${({ theme }) => theme.spaces[3]};
41
- }
42
-
43
- .react-colorful__saturation {
44
- border-radius: ${({ theme }) => theme.spaces[1]};
45
- border-bottom: none;
46
- }
47
-
48
- .react-colorful__hue {
49
- border-radius: 10px;
50
- height: ${({ theme }) => theme.spaces[3]};
51
- margin-top: ${({ theme }) => theme.spaces[2]};
52
- }
53
- `;
54
-
55
- const ColorPickerToggle = styled(BaseButton)`
56
- display: flex;
57
- justify-content: space-between;
58
- align-items: center;
59
-
60
- svg {
61
- width: ${({ theme }) => theme.spaces[2]};
62
- height: ${({ theme }) => theme.spaces[2]};
63
- }
64
-
65
- svg > path {
66
- fill: ${({ theme }) => theme.colors.neutral500};
67
- justify-self: flex-end;
68
- }
69
- `;
70
-
71
- const ColorPickerPopover = styled(Popover)`
72
- padding: ${({ theme }) => theme.spaces[2]};
73
- min-height: 270px;
74
- `;
75
-
76
- const ColorPickerInput = ({
77
- attribute,
78
- description,
79
- disabled,
80
- error,
81
- intlLabel,
82
- labelAction,
83
- name,
84
- onChange,
85
- required,
86
- value,
87
- }) => {
88
- const [showColorPicker, setShowColorPicker] = useState(false);
89
- const colorPickerButtonRef = useRef();
90
- const { formatMessage } = useIntl();
91
- const color = value || '#000000';
92
- const styleUppercase = { textTransform: 'uppercase' };
93
-
94
- const handleBlur = (e) => {
95
- e.preventDefault();
96
-
97
- if (!e.currentTarget.contains(e.relatedTarget)) {
98
- setShowColorPicker(false);
99
- }
100
- };
101
-
102
- return (
103
- <Field
104
- name={name}
105
- id={name}
106
- // GenericInput calls formatMessage and returns a string for the error
107
- error={error}
108
- hint={description && formatMessage(description)}
109
- required={required}
110
- >
111
- <Flex direction="column" alignItems="stretch" gap={1}>
112
- <FieldLabel action={labelAction}>{formatMessage(intlLabel)}</FieldLabel>
113
- <ColorPickerToggle
114
- ref={colorPickerButtonRef}
115
- aria-label={formatMessage({
116
- id: getTrad('color-picker.toggle.aria-label'),
117
- defaultMessage: 'Color picker toggle',
118
- })}
119
- aria-controls="color-picker-value"
120
- aria-haspopup="dialog"
121
- aria-expanded={showColorPicker}
122
- aria-disabled={disabled}
123
- disabled={disabled}
124
- onClick={() => setShowColorPicker(!showColorPicker)}
125
- >
126
- <Flex>
127
- <ColorPreview color={color} />
128
- <Typography
129
- style={styleUppercase}
130
- textColor={value ? null : 'neutral600'}
131
- variant="omega"
132
- >
133
- {color}
134
- </Typography>
135
- </Flex>
136
- <CarretDown aria-hidden />
137
- </ColorPickerToggle>
138
- {showColorPicker && (
139
- <ColorPickerPopover
140
- onBlur={handleBlur}
141
- role="dialog"
142
- source={colorPickerButtonRef}
143
- spacing={4}
144
- >
145
- <FocusTrap onEscape={() => setShowColorPicker(false)}>
146
- <ColorPicker
147
- color={color}
148
- onChange={(hexValue) =>
149
- onChange({ target: { name, value: hexValue, type: attribute.type } })
150
- }
151
- />
152
- <Flex paddingTop={3} paddingLeft={4} justifyContent="flex-end">
153
- <Box paddingRight={2}>
154
- <Typography variant="omega" as="label" textColor="neutral600">
155
- {formatMessage({
156
- id: getTrad('color-picker.input.format'),
157
- defaultMessage: 'HEX',
158
- })}
159
- </Typography>
160
- </Box>
161
- <FieldInput
162
- id="color-picker-value"
163
- aria-label={formatMessage({
164
- id: getTrad('color-picker.input.aria-label'),
165
- defaultMessage: 'Color picker input',
166
- })}
167
- style={styleUppercase}
168
- value={value}
169
- placeholder="#000000"
170
- onChange={onChange}
171
- />
172
- </Flex>
173
- </FocusTrap>
174
- </ColorPickerPopover>
175
- )}
176
- <FieldHint />
177
- <FieldError />
178
- </Flex>
179
- </Field>
180
- );
181
- };
182
-
183
- ColorPickerInput.defaultProps = {
184
- description: null,
185
- disabled: false,
186
- error: null,
187
- labelAction: null,
188
- required: false,
189
- value: '',
190
- };
191
-
192
- ColorPickerInput.propTypes = {
193
- intlLabel: PropTypes.object.isRequired,
194
- onChange: PropTypes.func.isRequired,
195
- attribute: PropTypes.object.isRequired,
196
- name: PropTypes.string.isRequired,
197
- description: PropTypes.object,
198
- disabled: PropTypes.bool,
199
- error: PropTypes.string,
200
- labelAction: PropTypes.object,
201
- required: PropTypes.bool,
202
- value: PropTypes.string,
203
- };
204
-
205
- export default ColorPickerInput;
@@ -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
- .c1 {
14
- font-size: 0.75rem;
15
- line-height: 1.33;
16
- font-weight: 600;
17
- color: #32324d;
18
- }
19
-
20
- .c8 {
21
- font-size: 0.875rem;
22
- line-height: 1.43;
23
- color: #666687;
24
- }
25
-
26
- .c0 {
27
- -webkit-align-items: stretch;
28
- -webkit-box-align: stretch;
29
- -ms-flex-align: stretch;
30
- align-items: stretch;
31
- display: -webkit-box;
32
- display: -webkit-flex;
33
- display: -ms-flexbox;
34
- display: flex;
35
- -webkit-flex-direction: column;
36
- -ms-flex-direction: column;
37
- flex-direction: column;
38
- gap: 4px;
39
- }
40
-
41
- .c4 {
42
- -webkit-align-items: center;
43
- -webkit-box-align: center;
44
- -ms-flex-align: center;
45
- align-items: center;
46
- display: -webkit-box;
47
- display: -webkit-flex;
48
- display: -ms-flexbox;
49
- display: flex;
50
- -webkit-flex-direction: row;
51
- -ms-flex-direction: row;
52
- flex-direction: row;
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
- });