@atlaskit/color-picker 3.2.14 → 3.2.16
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/CHANGELOG.md +17 -0
- package/codemods/1.0.0-popper-props.ts +75 -88
- package/codemods/__tests__/1.0.0-popper-props.ts +51 -51
- package/codemods/utils/helpers.ts +250 -261
- package/dist/cjs/components/ColorCard.js +19 -17
- package/dist/cjs/components/ColorPaletteMenu.js +9 -4
- package/dist/cjs/components/ColorPicker.js +3 -5
- package/dist/cjs/components/Trigger.js +8 -14
- package/dist/cjs/components/components.js +1 -0
- package/dist/cjs/messages.js +5 -0
- package/dist/cjs/utils.js +1 -2
- package/dist/es2019/components/ColorCard.js +20 -17
- package/dist/es2019/components/ColorPaletteMenu.js +9 -4
- package/dist/es2019/components/ColorPicker.js +3 -5
- package/dist/es2019/components/Trigger.js +8 -14
- package/dist/es2019/components/components.js +1 -0
- package/dist/es2019/messages.js +5 -0
- package/dist/es2019/utils.js +1 -2
- package/dist/esm/components/ColorCard.js +19 -17
- package/dist/esm/components/ColorPaletteMenu.js +9 -4
- package/dist/esm/components/ColorPicker.js +3 -5
- package/dist/esm/components/Trigger.js +8 -14
- package/dist/esm/components/components.js +1 -0
- package/dist/esm/messages.js +5 -0
- package/dist/esm/utils.js +1 -2
- package/dist/types/messages.d.ts +5 -0
- package/dist/types-ts4.5/messages.d.ts +5 -0
- package/docs/0-intro.tsx +35 -34
- package/package.json +5 -8
- package/report.api.md +103 -107
|
@@ -1,261 +1,256 @@
|
|
|
1
1
|
import { type NodePath } from 'ast-types/lib/node-path';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
type default as core,
|
|
4
|
+
type ASTPath,
|
|
5
|
+
type ImportDeclaration,
|
|
6
|
+
type JSXAttribute,
|
|
7
|
+
type JSXElement,
|
|
8
|
+
type Node,
|
|
9
9
|
} from 'jscodeshift';
|
|
10
10
|
import { type Collection } from 'jscodeshift/src/Collection';
|
|
11
11
|
|
|
12
12
|
export type Nullable<T> = T | null;
|
|
13
13
|
|
|
14
14
|
export function hasImportDeclaration(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
j: core.JSCodeshift,
|
|
16
|
+
source: string,
|
|
17
|
+
importPath: string,
|
|
18
18
|
): boolean {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
).length > 0
|
|
26
|
-
);
|
|
19
|
+
return (
|
|
20
|
+
j(source)
|
|
21
|
+
.find(j.ImportDeclaration)
|
|
22
|
+
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === importPath).length >
|
|
23
|
+
0
|
|
24
|
+
);
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export function getDefaultSpecifierName({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
j,
|
|
29
|
+
base,
|
|
30
|
+
packageName,
|
|
33
31
|
}: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
j: core.JSCodeshift;
|
|
33
|
+
base: Collection<any>;
|
|
34
|
+
packageName: string;
|
|
37
35
|
}): Nullable<string> {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const specifiers = base
|
|
37
|
+
.find(j.ImportDeclaration)
|
|
38
|
+
.filter((path) => path.node.source.value === packageName)
|
|
39
|
+
.find(j.ImportDefaultSpecifier);
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
if (!specifiers.length) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return specifiers.nodes()[0]!.local!.name;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
export function getSpecifierName({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
j,
|
|
49
|
+
base,
|
|
50
|
+
packageName,
|
|
51
|
+
component,
|
|
54
52
|
}: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
j: core.JSCodeshift;
|
|
54
|
+
base: Collection<any>;
|
|
55
|
+
packageName: string;
|
|
56
|
+
component: string;
|
|
59
57
|
}): Nullable<string> {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
const specifiers = base
|
|
59
|
+
.find(j.ImportDeclaration)
|
|
60
|
+
.filter((path) => path.node.source.value === packageName)
|
|
61
|
+
.find(j.ImportSpecifier);
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// @ts-ignore
|
|
75
|
-
return specifierNode.local.name;
|
|
63
|
+
if (!specifiers.length) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const specifierNode = specifiers.nodes().find((node) => node.imported.name === component);
|
|
67
|
+
if (!specifierNode) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
return specifierNode.local.name;
|
|
76
72
|
}
|
|
77
73
|
|
|
78
74
|
export function getJSXAttributesByName({
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
j,
|
|
76
|
+
element,
|
|
77
|
+
attributeName,
|
|
82
78
|
}: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
j: core.JSCodeshift;
|
|
80
|
+
element: JSXElement | ASTPath<JSXElement>;
|
|
81
|
+
attributeName: string;
|
|
86
82
|
}): Collection<JSXAttribute> {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
return j(element)
|
|
84
|
+
.find(j.JSXOpeningElement)
|
|
85
|
+
.find(j.JSXAttribute)
|
|
86
|
+
.filter((attribute) => {
|
|
87
|
+
const matches = j(attribute)
|
|
88
|
+
.find(j.JSXIdentifier)
|
|
89
|
+
.filter((identifier) => identifier.value.name === attributeName);
|
|
90
|
+
return Boolean(matches.length);
|
|
91
|
+
});
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
export function hasJSXAttributesByName({
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
j,
|
|
96
|
+
element,
|
|
97
|
+
attributeName,
|
|
102
98
|
}: {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
j: core.JSCodeshift;
|
|
100
|
+
element: JSXElement;
|
|
101
|
+
attributeName: string;
|
|
106
102
|
}): boolean {
|
|
107
|
-
|
|
103
|
+
return getJSXAttributesByName({ j, element, attributeName }).length > 0;
|
|
108
104
|
}
|
|
109
105
|
|
|
110
106
|
export function isUsingSupportedSpread({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
j,
|
|
108
|
+
base,
|
|
109
|
+
element,
|
|
114
110
|
}: {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
j: core.JSCodeshift;
|
|
112
|
+
base: Collection<any>;
|
|
113
|
+
element: NodePath<JSXElement, JSXElement>;
|
|
118
114
|
}): boolean {
|
|
119
|
-
|
|
120
|
-
j(element).find(j.JSXSpreadAttribute).length > 0;
|
|
115
|
+
const isUsingSpread: boolean = j(element).find(j.JSXSpreadAttribute).length > 0;
|
|
121
116
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
if (!isUsingSpread) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
125
120
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
121
|
+
return (
|
|
122
|
+
j(element)
|
|
123
|
+
.find(j.JSXSpreadAttribute)
|
|
124
|
+
.filter((spread) => {
|
|
125
|
+
const argument = spread.value.argument;
|
|
126
|
+
// in place expression is supported
|
|
127
|
+
if (argument.type === 'ObjectExpression') {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
135
130
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
131
|
+
// Supporting identifiers that point to an a local object expression
|
|
132
|
+
if (argument.type === 'Identifier') {
|
|
133
|
+
return (
|
|
134
|
+
base.find(j.VariableDeclarator).filter((declarator): boolean => {
|
|
135
|
+
return (
|
|
136
|
+
declarator.value.id.type === 'Identifier' &&
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
declarator.value.init.type === 'ObjectExpression'
|
|
139
|
+
);
|
|
140
|
+
}).length > 0
|
|
141
|
+
);
|
|
142
|
+
}
|
|
148
143
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
// We don't support anything else
|
|
145
|
+
return false;
|
|
146
|
+
}).length > 0
|
|
147
|
+
);
|
|
153
148
|
}
|
|
154
149
|
|
|
155
150
|
export function isUsingThroughSpread({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
j,
|
|
152
|
+
base,
|
|
153
|
+
element,
|
|
154
|
+
propName,
|
|
160
155
|
}: {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
j: core.JSCodeshift;
|
|
157
|
+
base: Collection<any>;
|
|
158
|
+
element: NodePath<JSXElement, JSXElement>;
|
|
159
|
+
propName: string;
|
|
165
160
|
}): boolean {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
if (!isUsingSupportedSpread({ j, base, element })) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
169
164
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
165
|
+
const isUsedThroughExpression: boolean =
|
|
166
|
+
j(element)
|
|
167
|
+
.find(j.JSXSpreadAttribute)
|
|
168
|
+
.find(j.ObjectExpression)
|
|
169
|
+
.filter((item) => {
|
|
170
|
+
const match: boolean =
|
|
171
|
+
item.value.properties.filter(
|
|
172
|
+
(property) =>
|
|
173
|
+
property.type === 'ObjectProperty' &&
|
|
174
|
+
property.key.type === 'Identifier' &&
|
|
175
|
+
property.key.name === propName,
|
|
176
|
+
).length > 0;
|
|
182
177
|
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
return match;
|
|
179
|
+
}).length > 0;
|
|
185
180
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
if (isUsedThroughExpression) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
189
184
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
185
|
+
const isUsedThroughIdentifier: boolean =
|
|
186
|
+
j(element)
|
|
187
|
+
.find(j.JSXSpreadAttribute)
|
|
188
|
+
.find(j.Identifier)
|
|
189
|
+
.filter((identifier): boolean => {
|
|
190
|
+
return (
|
|
191
|
+
base
|
|
192
|
+
.find(j.VariableDeclarator)
|
|
193
|
+
.filter(
|
|
194
|
+
(declarator) =>
|
|
195
|
+
declarator.value.id.type === 'Identifier' &&
|
|
196
|
+
declarator.value.id.name === identifier.value.name,
|
|
197
|
+
)
|
|
198
|
+
.filter((declarator) => {
|
|
199
|
+
const value = declarator.value;
|
|
200
|
+
if (value.id.type !== 'Identifier') {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
208
203
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
204
|
+
if (value.id.name !== identifier.value.name) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
// @ts-ignore
|
|
208
|
+
if (value.init.type !== 'ObjectExpression') {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
216
211
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
212
|
+
const match: boolean =
|
|
213
|
+
// @ts-ignore
|
|
214
|
+
value.init.properties.filter(
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
(property) =>
|
|
217
|
+
property.type === 'ObjectProperty' &&
|
|
218
|
+
property.key.type === 'Identifier' &&
|
|
219
|
+
property.key.name === propName,
|
|
220
|
+
).length > 0;
|
|
226
221
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
222
|
+
return match;
|
|
223
|
+
}).length > 0
|
|
224
|
+
);
|
|
225
|
+
}).length > 0;
|
|
231
226
|
|
|
232
|
-
|
|
227
|
+
return isUsedThroughIdentifier;
|
|
233
228
|
}
|
|
234
229
|
|
|
235
230
|
export function isUsingProp({
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
231
|
+
j,
|
|
232
|
+
base,
|
|
233
|
+
element,
|
|
234
|
+
propName,
|
|
240
235
|
}: {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
236
|
+
j: core.JSCodeshift;
|
|
237
|
+
base: Collection<any>;
|
|
238
|
+
element: NodePath<JSXElement, JSXElement>;
|
|
239
|
+
propName: string;
|
|
245
240
|
}): boolean {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
241
|
+
return (
|
|
242
|
+
hasJSXAttributesByName({
|
|
243
|
+
j,
|
|
244
|
+
element: element.value,
|
|
245
|
+
attributeName: propName,
|
|
246
|
+
}) ||
|
|
247
|
+
isUsingThroughSpread({
|
|
248
|
+
j,
|
|
249
|
+
base,
|
|
250
|
+
element,
|
|
251
|
+
propName,
|
|
252
|
+
})
|
|
253
|
+
);
|
|
259
254
|
}
|
|
260
255
|
|
|
261
256
|
// not replacing newlines (which \s does)
|
|
@@ -263,82 +258,76 @@ const spacesAndTabs: RegExp = /[ \t]{2,}/g;
|
|
|
263
258
|
const lineStartWithSpaces: RegExp = /^[ \t]*/gm;
|
|
264
259
|
|
|
265
260
|
function clean(value: string): string {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
261
|
+
return (
|
|
262
|
+
value
|
|
263
|
+
.replace(spacesAndTabs, ' ')
|
|
264
|
+
.replace(lineStartWithSpaces, '')
|
|
265
|
+
// using .trim() to clear the any newlines before the first text and after last text
|
|
266
|
+
.trim()
|
|
267
|
+
);
|
|
273
268
|
}
|
|
274
269
|
|
|
275
270
|
export function addCommentToStartOfFile({
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
271
|
+
j,
|
|
272
|
+
base,
|
|
273
|
+
message,
|
|
279
274
|
}: {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
275
|
+
j: core.JSCodeshift;
|
|
276
|
+
base: Collection<Node>;
|
|
277
|
+
message: string;
|
|
283
278
|
}) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
279
|
+
addCommentBefore({
|
|
280
|
+
j,
|
|
281
|
+
// @ts-ignore
|
|
282
|
+
target: base.find(j.Program),
|
|
283
|
+
message,
|
|
284
|
+
});
|
|
290
285
|
}
|
|
291
286
|
|
|
292
287
|
export function addCommentBefore({
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
288
|
+
j,
|
|
289
|
+
target,
|
|
290
|
+
message,
|
|
296
291
|
}: {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
292
|
+
j: core.JSCodeshift;
|
|
293
|
+
target: Collection<Node>;
|
|
294
|
+
message: string;
|
|
300
295
|
}) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
296
|
+
const content: string = ` TODO: (from codemod) ${clean(message)} `;
|
|
297
|
+
target.forEach((path) => {
|
|
298
|
+
path.value.comments = path.value.comments || [];
|
|
304
299
|
|
|
305
|
-
|
|
306
|
-
(comment) => comment.value === content,
|
|
307
|
-
);
|
|
300
|
+
const exists = path.value.comments.find((comment) => comment.value === content);
|
|
308
301
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
302
|
+
// avoiding duplicates of the same comment
|
|
303
|
+
if (exists) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
313
306
|
|
|
314
|
-
|
|
315
|
-
|
|
307
|
+
path.value.comments.push(j.commentBlock(content));
|
|
308
|
+
});
|
|
316
309
|
}
|
|
317
310
|
|
|
318
311
|
export function updateRenderProps(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
312
|
+
j: core.JSCodeshift,
|
|
313
|
+
source: Collection<any>,
|
|
314
|
+
specifier: string,
|
|
315
|
+
oldProperty: string,
|
|
316
|
+
newProperty: string,
|
|
324
317
|
) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
),
|
|
341
|
-
);
|
|
342
|
-
});
|
|
343
|
-
});
|
|
318
|
+
source.findJSXElements(specifier).forEach((element: ASTPath<JSXElement>) => {
|
|
319
|
+
j(element)
|
|
320
|
+
.find(j.ArrowFunctionExpression)
|
|
321
|
+
.find(j.ObjectPattern)
|
|
322
|
+
.find(j.ObjectProperty)
|
|
323
|
+
.filter(
|
|
324
|
+
// @ts-ignore
|
|
325
|
+
(path: ASTPath<ObjectProperty>) => path.value.key.name === oldProperty,
|
|
326
|
+
)
|
|
327
|
+
.forEach((path) => {
|
|
328
|
+
j(path).replaceWith(
|
|
329
|
+
j.property('init', j.identifier(newProperty), j.identifier(oldProperty)),
|
|
330
|
+
);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
344
333
|
}
|
|
@@ -12,8 +12,10 @@ var _done = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/done"));
|
|
|
12
12
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
13
13
|
var _constants = require("../constants");
|
|
14
14
|
var _react2 = require("@emotion/react");
|
|
15
|
+
var _reactIntlNext = require("react-intl-next");
|
|
15
16
|
var _colors = require("@atlaskit/theme/colors");
|
|
16
17
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
|
+
var _messages = _interopRequireDefault(require("../messages"));
|
|
17
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
21
|
/** @jsx jsx */
|
|
@@ -29,6 +31,8 @@ var ColorCard = function ColorCard(props) {
|
|
|
29
31
|
onClick = props.onClick,
|
|
30
32
|
onKeyDown = props.onKeyDown;
|
|
31
33
|
var ref = (0, _react.useRef)(null);
|
|
34
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
35
|
+
formatMessage = _useIntl.formatMessage;
|
|
32
36
|
var handleMouseDown = (0, _react.useCallback)(function (event) {
|
|
33
37
|
event.preventDefault();
|
|
34
38
|
}, []);
|
|
@@ -49,19 +53,17 @@ var ColorCard = function ColorCard(props) {
|
|
|
49
53
|
}
|
|
50
54
|
}, [isTabbing, onKeyDown, value]);
|
|
51
55
|
(0, _react.useEffect)(function () {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
}
|
|
56
|
+
var refCurrent = ref.current;
|
|
57
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
58
|
+
if (e.key === 'Tab') {
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
refCurrent === null || refCurrent === void 0 || refCurrent.addEventListener('keydown', handleKeyDown);
|
|
64
|
+
return function () {
|
|
65
|
+
refCurrent === null || refCurrent === void 0 || refCurrent.removeEventListener('keydown', handleKeyDown);
|
|
66
|
+
};
|
|
65
67
|
}, []);
|
|
66
68
|
return (0, _react2.jsx)(_tooltip.default, {
|
|
67
69
|
content: label
|
|
@@ -72,11 +74,10 @@ var ColorCard = function ColorCard(props) {
|
|
|
72
74
|
onKeyDown: handleKeyDown,
|
|
73
75
|
role: "radio",
|
|
74
76
|
"aria-checked": selected
|
|
75
|
-
},
|
|
76
|
-
'aria-label':
|
|
77
|
+
}, (0, _platformFeatureFlags.getBooleanFF)('platform.jca11y-2997-remove-duplicate-screen-reader-announcements_fz13s') && {
|
|
78
|
+
'aria-label': formatMessage(_messages.default.colorCardRadioItemLabel)
|
|
77
79
|
}, {
|
|
78
|
-
tabIndex: 0
|
|
79
|
-
}, (0, _platformFeatureFlags.getBooleanFF)('platform.color-picker-radio-button-functionality_6hkcy') && {
|
|
80
|
+
tabIndex: 0,
|
|
80
81
|
ref: ref
|
|
81
82
|
}), (0, _react2.jsx)("div", {
|
|
82
83
|
css: colorCardWrapperStyles
|
|
@@ -94,6 +95,7 @@ var ColorCard = function ColorCard(props) {
|
|
|
94
95
|
};
|
|
95
96
|
var _default = exports.default = ColorCard;
|
|
96
97
|
var colorCardOptionTabbingStyles = (0, _react2.css)({
|
|
98
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
97
99
|
':hover, :focus': {
|
|
98
100
|
borderColor: "var(--ds-border-focused, ".concat(_colors.B75, ")")
|
|
99
101
|
}
|