@atlaskit/primitives 14.11.3 → 14.11.4
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 +8 -0
- package/anchor/package.json +1 -1
- package/box/package.json +1 -1
- package/codemods/compiled-fork-stage1/transform.tsx +329 -59
- package/compiled/package.json +1 -1
- package/dist/cjs/compiled/components/anchor.js +1 -1
- package/dist/cjs/compiled/components/pressable.js +1 -1
- package/dist/cjs/components/anchor.js +1 -1
- package/dist/cjs/components/pressable.js +1 -1
- package/dist/es2019/compiled/components/anchor.js +1 -1
- package/dist/es2019/compiled/components/pressable.js +1 -1
- package/dist/es2019/components/anchor.js +1 -1
- package/dist/es2019/components/pressable.js +1 -1
- package/dist/esm/compiled/components/anchor.js +1 -1
- package/dist/esm/compiled/components/pressable.js +1 -1
- package/dist/esm/components/anchor.js +1 -1
- package/dist/esm/components/pressable.js +1 -1
- package/dist/types/compiled/responsive/use-media-query.d.ts +1 -1
- package/dist/types/responsive/build-media-query-css.d.ts +12 -2
- package/dist/types/responsive/use-media-query.d.ts +1 -1
- package/dist/types/utils/has-text-ancestor-context.d.ts +0 -1
- package/dist/types/utils/surface-provider.d.ts +0 -1
- package/dist/types/xcss/style-maps.partial.d.ts +1 -1
- package/dist/types-ts4.5/compiled/responsive/use-media-query.d.ts +1 -1
- package/dist/types-ts4.5/responsive/build-media-query-css.d.ts +12 -2
- package/dist/types-ts4.5/responsive/use-media-query.d.ts +1 -1
- package/dist/types-ts4.5/utils/has-text-ancestor-context.d.ts +0 -1
- package/dist/types-ts4.5/utils/surface-provider.d.ts +0 -1
- package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +1 -1
- package/inline/package.json +1 -1
- package/metric-text/package.json +1 -1
- package/package.json +10 -11
- package/pressable/package.json +1 -1
- package/responsive/package.json +1 -1
- package/stack/package.json +1 -1
- package/text/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/primitives
|
|
2
2
|
|
|
3
|
+
## 14.11.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`31c57f650ba07`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/31c57f650ba07) -
|
|
8
|
+
Improving tests for server side rendering and hydration
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 14.11.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/anchor/package.json
CHANGED
package/box/package.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
API,
|
|
3
|
+
FileInfo,
|
|
4
|
+
ImportSpecifier,
|
|
5
|
+
JSXAttribute,
|
|
6
|
+
VariableDeclaration,
|
|
7
|
+
} from 'jscodeshift';
|
|
2
8
|
|
|
3
9
|
const ANCHOR_PRESSABLE_XCSS_PROPS = [
|
|
4
10
|
'backgroundColor',
|
|
@@ -13,28 +19,12 @@ const ANCHOR_PRESSABLE_XCSS_PROPS = [
|
|
|
13
19
|
|
|
14
20
|
const GRID_XCSS_PROPS = ['templateRows', 'templateColumns', 'templateAreas'];
|
|
15
21
|
|
|
22
|
+
const PRIMITIVES_IMPORT_SOURCES = ['@atlaskit/primitives', '@atlaskit/primitives/compiled'];
|
|
23
|
+
|
|
16
24
|
function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
17
25
|
const root = j(file.source);
|
|
18
26
|
let needsCssMapImport = false;
|
|
19
27
|
|
|
20
|
-
// Check if any import from '@atlaskit/primitives' contains 'xcss'
|
|
21
|
-
const hasDescopedImport = root
|
|
22
|
-
.find(j.ImportDeclaration, { source: { value: '@atlaskit/primitives' } })
|
|
23
|
-
.some((path) => {
|
|
24
|
-
return path.node.specifiers!.some((specifier) => {
|
|
25
|
-
if (!j.ImportSpecifier.check(specifier)) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return ['xcss', 'media', 'XCSS'].includes(specifier.imported.name);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// If 'xcss' is imported, return the original source without transformations
|
|
34
|
-
if (hasDescopedImport) {
|
|
35
|
-
return file.source;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
28
|
// If Box primitive is used with spread props, return the original source without transformations
|
|
39
29
|
const hasBoxPrimitiveWithSpreadProps = root
|
|
40
30
|
.find(j.JSXElement, { openingElement: { name: { name: 'Box' } } })
|
|
@@ -48,6 +38,144 @@ function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
|
48
38
|
return file.source;
|
|
49
39
|
}
|
|
50
40
|
|
|
41
|
+
// Check if xcss is imported
|
|
42
|
+
const hasXcssImport = root
|
|
43
|
+
.find(j.ImportDeclaration, { source: { value: '@atlaskit/primitives' } })
|
|
44
|
+
.some(
|
|
45
|
+
(path) =>
|
|
46
|
+
path.node.specifiers?.some(
|
|
47
|
+
(specifier) => j.ImportSpecifier.check(specifier) && specifier.imported.name === 'xcss',
|
|
48
|
+
) ?? false,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Check if media is imported
|
|
52
|
+
const hasMediaImport = root
|
|
53
|
+
.find(j.ImportDeclaration, { source: { value: '@atlaskit/primitives' } })
|
|
54
|
+
.some(
|
|
55
|
+
(path) =>
|
|
56
|
+
path.node.specifiers?.some(
|
|
57
|
+
(specifier) => j.ImportSpecifier.check(specifier) && specifier.imported.name === 'media',
|
|
58
|
+
) ?? false,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// If media is imported, return the original source without transformations
|
|
62
|
+
if (hasMediaImport) {
|
|
63
|
+
return file.source;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// If xcss is imported, check if there's only one other primitive component
|
|
67
|
+
if (hasXcssImport) {
|
|
68
|
+
const primitiveImports =
|
|
69
|
+
root
|
|
70
|
+
.find(j.ImportDeclaration, { source: { value: '@atlaskit/primitives' } })
|
|
71
|
+
.get()
|
|
72
|
+
.node.specifiers?.filter(
|
|
73
|
+
(specifier: ImportSpecifier) =>
|
|
74
|
+
j.ImportSpecifier.check(specifier) && specifier.imported.name !== 'xcss',
|
|
75
|
+
) ?? [];
|
|
76
|
+
|
|
77
|
+
// If there's only one other primitive component, skip the file
|
|
78
|
+
if (primitiveImports.length === 1) {
|
|
79
|
+
return file.source;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Otherwise, split the imports but keep components that use xcss
|
|
83
|
+
root
|
|
84
|
+
.find(j.ImportDeclaration, { source: { value: '@atlaskit/primitives' } })
|
|
85
|
+
.forEach((path) => {
|
|
86
|
+
// Skip type imports
|
|
87
|
+
if (path.node.importKind === 'type') {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const xcssSpecifiers =
|
|
92
|
+
path.node.specifiers?.filter(
|
|
93
|
+
(specifier) => j.ImportSpecifier.check(specifier) && specifier.imported.name === 'xcss',
|
|
94
|
+
) ?? [];
|
|
95
|
+
const otherSpecifiers =
|
|
96
|
+
path.node.specifiers?.filter(
|
|
97
|
+
(specifier) => j.ImportSpecifier.check(specifier) && specifier.imported.name !== 'xcss',
|
|
98
|
+
) ?? [];
|
|
99
|
+
|
|
100
|
+
// Find components that use xcss
|
|
101
|
+
const componentsUsingXcss = new Set<string>();
|
|
102
|
+
root.find(j.JSXElement).forEach((jsxPath) => {
|
|
103
|
+
if (!j.JSXIdentifier.check(jsxPath.node.openingElement.name)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const elementName = jsxPath.node.openingElement.name.name;
|
|
108
|
+
const attributes = jsxPath.node.openingElement.attributes || [];
|
|
109
|
+
const hasXcssProp = attributes.some(
|
|
110
|
+
(attr) =>
|
|
111
|
+
j.JSXAttribute.check(attr) &&
|
|
112
|
+
j.JSXIdentifier.check(attr.name) &&
|
|
113
|
+
attr.name.name === 'xcss',
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (hasXcssProp) {
|
|
117
|
+
componentsUsingXcss.add(elementName);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Split specifiers based on xcss usage
|
|
122
|
+
const specifiersToKeep = otherSpecifiers.filter(
|
|
123
|
+
(specifier) =>
|
|
124
|
+
j.ImportSpecifier.check(specifier) && componentsUsingXcss.has(specifier.imported.name),
|
|
125
|
+
);
|
|
126
|
+
const specifiersToMove = otherSpecifiers.filter(
|
|
127
|
+
(specifier) =>
|
|
128
|
+
j.ImportSpecifier.check(specifier) && !componentsUsingXcss.has(specifier.imported.name),
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
if (specifiersToMove.length > 0) {
|
|
132
|
+
// Add new import for components that don't use xcss
|
|
133
|
+
path.insertAfter(
|
|
134
|
+
j.importDeclaration(specifiersToMove, j.literal('@atlaskit/primitives/compiled')),
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Update original import to include xcss and components that use it
|
|
139
|
+
path.node.specifiers = [...xcssSpecifiers, ...specifiersToKeep];
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return root.toSource({ quote: 'single' });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Check if any component uses xcss
|
|
146
|
+
const hasXcssUsage = root.find(j.JSXElement).some((path) => {
|
|
147
|
+
if (!j.JSXIdentifier.check(path.node.openingElement.name)) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const elementName = path.node.openingElement.name.name;
|
|
152
|
+
const isPrimitiveComponent = PRIMITIVES_IMPORT_SOURCES.some((importSource) =>
|
|
153
|
+
root.find(j.ImportDeclaration, { source: { value: importSource } }).some((importPath) => {
|
|
154
|
+
return importPath.node.specifiers!.some((specifier) => {
|
|
155
|
+
if (!j.ImportSpecifier.check(specifier)) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return specifier.local?.name === elementName;
|
|
159
|
+
});
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (!isPrimitiveComponent) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const attributes = path.node.openingElement.attributes || [];
|
|
168
|
+
return attributes.some(
|
|
169
|
+
(attr) =>
|
|
170
|
+
j.JSXAttribute.check(attr) && j.JSXIdentifier.check(attr.name) && attr.name.name === 'xcss',
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// If any component uses xcss, return the original source without transformations
|
|
175
|
+
if (hasXcssUsage) {
|
|
176
|
+
return file.source;
|
|
177
|
+
}
|
|
178
|
+
|
|
51
179
|
// Has @atlaskit/primitives import?
|
|
52
180
|
const hasPrimitivesImport =
|
|
53
181
|
root.find(j.ImportDeclaration, { source: { value: '@atlaskit/primitives' } }).length > 0;
|
|
@@ -56,9 +184,57 @@ function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
|
56
184
|
return file.source;
|
|
57
185
|
}
|
|
58
186
|
|
|
187
|
+
// Check if any component has mixed xcss usage by looking at JSX elements directly
|
|
188
|
+
const componentXcssUsage = new Map<string, boolean>();
|
|
189
|
+
const hasMixedXcssUsage = root.find(j.JSXElement).some((path) => {
|
|
190
|
+
if (!j.JSXIdentifier.check(path.node.openingElement.name)) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const elementName = path.node.openingElement.name.name;
|
|
195
|
+
const isPrimitiveComponent = PRIMITIVES_IMPORT_SOURCES.some((importSource) =>
|
|
196
|
+
root.find(j.ImportDeclaration, { source: { value: importSource } }).some((importPath) => {
|
|
197
|
+
return importPath.node.specifiers!.some((specifier) => {
|
|
198
|
+
if (!j.ImportSpecifier.check(specifier)) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return specifier.local?.name === elementName;
|
|
202
|
+
});
|
|
203
|
+
}),
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
if (!isPrimitiveComponent) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const attributes = path.node.openingElement.attributes || [];
|
|
211
|
+
const props = attributes.filter((attr) => j.JSXAttribute.check(attr)) as Array<JSXAttribute>;
|
|
212
|
+
const hasXcssProp = props.some(
|
|
213
|
+
(prop) => j.JSXIdentifier.check(prop.name) && prop.name.name === 'xcss',
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
// Track xcss usage for this component type
|
|
217
|
+
if (!componentXcssUsage.has(elementName)) {
|
|
218
|
+
componentXcssUsage.set(elementName, hasXcssProp);
|
|
219
|
+
} else if (componentXcssUsage.get(elementName) !== hasXcssProp) {
|
|
220
|
+
// If we've seen this component before and the xcss usage is different, we have mixed usage
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return false;
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// If there's mixed xcss usage, don't transform anything
|
|
228
|
+
if (hasMixedXcssUsage) {
|
|
229
|
+
return file.source;
|
|
230
|
+
}
|
|
231
|
+
|
|
59
232
|
// Find all import declarations from '@atlaskit/primitives'
|
|
60
233
|
root.find(j.ImportDeclaration, { source: { value: '@atlaskit/primitives' } }).forEach((path) => {
|
|
61
|
-
//
|
|
234
|
+
// Skip type imports
|
|
235
|
+
if (path.node.importKind === 'type') {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
62
238
|
path.node.source = j.literal('@atlaskit/primitives/compiled');
|
|
63
239
|
});
|
|
64
240
|
|
|
@@ -77,21 +253,70 @@ function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
|
77
253
|
}
|
|
78
254
|
}
|
|
79
255
|
|
|
80
|
-
// Find
|
|
81
|
-
|
|
256
|
+
// Find all existing cssMap declarations
|
|
257
|
+
const existingCssMapDeclarations = new Map<string, string>();
|
|
258
|
+
root.find(j.VariableDeclaration).forEach((path) => {
|
|
259
|
+
const declaration = path.node.declarations[0];
|
|
260
|
+
if (
|
|
261
|
+
j.VariableDeclarator.check(declaration) &&
|
|
262
|
+
j.Identifier.check(declaration.id) &&
|
|
263
|
+
j.CallExpression.check(declaration.init) &&
|
|
264
|
+
j.Identifier.check(declaration.init.callee) &&
|
|
265
|
+
declaration.init.callee.name === cssMapName
|
|
266
|
+
) {
|
|
267
|
+
existingCssMapDeclarations.set(declaration.id.name, declaration.id.name);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// Find all JSX elements
|
|
272
|
+
const jsxElements = root.find(j.JSXElement).paths();
|
|
273
|
+
const processedComponentTypes = new Map<
|
|
274
|
+
string,
|
|
275
|
+
{ name: string; declaration: VariableDeclaration }
|
|
276
|
+
>();
|
|
277
|
+
|
|
278
|
+
// Add token import if needed
|
|
279
|
+
let needsTokenImport = false;
|
|
280
|
+
|
|
281
|
+
jsxElements.forEach((path) => {
|
|
82
282
|
if (!j.JSXIdentifier.check(path.node.openingElement.name)) {
|
|
83
283
|
return;
|
|
84
284
|
}
|
|
85
285
|
|
|
86
286
|
const elementName = path.node.openingElement.name.name;
|
|
87
|
-
|
|
287
|
+
|
|
288
|
+
// Find if this component is imported from @atlaskit/primitives or @atlaskit/primitives/compiled
|
|
289
|
+
const isPrimitiveComponent = PRIMITIVES_IMPORT_SOURCES.some((importSource) =>
|
|
290
|
+
root.find(j.ImportDeclaration, { source: { value: importSource } }).some((importPath) => {
|
|
291
|
+
return importPath.node.specifiers!.some((specifier) => {
|
|
292
|
+
if (!j.ImportSpecifier.check(specifier)) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
return specifier.local?.name === elementName;
|
|
296
|
+
});
|
|
297
|
+
}),
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
if (!isPrimitiveComponent) {
|
|
88
301
|
return;
|
|
89
302
|
}
|
|
90
303
|
|
|
91
304
|
const attributes = path.node.openingElement.attributes || [];
|
|
92
305
|
const props = attributes.filter((attr) => j.JSXAttribute.check(attr)) as Array<JSXAttribute>;
|
|
93
306
|
|
|
94
|
-
|
|
307
|
+
// Skip if component already has xcss prop
|
|
308
|
+
const hasXcss = props.some(
|
|
309
|
+
(prop) => j.JSXIdentifier.check(prop.name) && prop.name.name === 'xcss',
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
if (hasXcss) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const xcssProps =
|
|
317
|
+
elementName === 'Grid'
|
|
318
|
+
? [...GRID_XCSS_PROPS, ...ANCHOR_PRESSABLE_XCSS_PROPS]
|
|
319
|
+
: ANCHOR_PRESSABLE_XCSS_PROPS;
|
|
95
320
|
const propsToTransform = props.filter(
|
|
96
321
|
(prop) => j.JSXIdentifier.check(prop.name) && xcssProps.includes(prop.name.name),
|
|
97
322
|
);
|
|
@@ -105,6 +330,45 @@ function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
|
105
330
|
// Create styles variable name
|
|
106
331
|
const stylesName = `${elementName.toLowerCase()}Styles`;
|
|
107
332
|
|
|
333
|
+
// Skip if we've already processed this component type
|
|
334
|
+
if (processedComponentTypes.has(elementName)) {
|
|
335
|
+
// Use existing styles
|
|
336
|
+
const existingStyles = processedComponentTypes.get(elementName)!;
|
|
337
|
+
// Remove transformed props and add xcss prop
|
|
338
|
+
propsToTransform.forEach((prop) => {
|
|
339
|
+
const index = attributes.indexOf(prop);
|
|
340
|
+
attributes.splice(index, 1);
|
|
341
|
+
});
|
|
342
|
+
attributes.push(
|
|
343
|
+
j.jsxAttribute(
|
|
344
|
+
j.jsxIdentifier('xcss'),
|
|
345
|
+
j.jsxExpressionContainer(
|
|
346
|
+
j.memberExpression(j.identifier(existingStyles.name), j.identifier('root')),
|
|
347
|
+
),
|
|
348
|
+
),
|
|
349
|
+
);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Skip if we already have a cssMap declaration for this component type
|
|
354
|
+
if (existingCssMapDeclarations.has(stylesName)) {
|
|
355
|
+
// Remove transformed props and add xcss prop
|
|
356
|
+
propsToTransform.forEach((prop) => {
|
|
357
|
+
const index = attributes.indexOf(prop);
|
|
358
|
+
attributes.splice(index, 1);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
attributes.push(
|
|
362
|
+
j.jsxAttribute(
|
|
363
|
+
j.jsxIdentifier('xcss'),
|
|
364
|
+
j.jsxExpressionContainer(
|
|
365
|
+
j.memberExpression(j.identifier(stylesName), j.identifier('root')),
|
|
366
|
+
),
|
|
367
|
+
),
|
|
368
|
+
);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
|
|
108
372
|
// Create cssMap declaration
|
|
109
373
|
const styleObj = j.objectExpression(
|
|
110
374
|
propsToTransform.map((prop) => {
|
|
@@ -127,6 +391,15 @@ function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
|
127
391
|
return j.objectProperty(j.identifier(cssPropName), prop.value.expression);
|
|
128
392
|
}
|
|
129
393
|
|
|
394
|
+
// Only wrap string values in token() if they're not grid props
|
|
395
|
+
if (j.StringLiteral.check(prop.value) && !propName.startsWith('template')) {
|
|
396
|
+
needsTokenImport = true;
|
|
397
|
+
return j.objectProperty(
|
|
398
|
+
j.identifier(cssPropName),
|
|
399
|
+
j.callExpression(j.identifier('token'), [prop.value]),
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
130
403
|
return j.objectProperty(j.identifier(cssPropName), prop.value);
|
|
131
404
|
}),
|
|
132
405
|
);
|
|
@@ -140,50 +413,35 @@ function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
|
140
413
|
),
|
|
141
414
|
]);
|
|
142
415
|
|
|
143
|
-
|
|
144
|
-
source: { value: '@atlaskit/primitives/compiled' },
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
if (importDeclaration.length > 0) {
|
|
148
|
-
// insert after the last import declaration
|
|
149
|
-
const imports = root.find(j.ImportDeclaration);
|
|
150
|
-
const lastImport = imports.at(imports.length - 1);
|
|
151
|
-
|
|
152
|
-
const cssMapDeclaration = root
|
|
153
|
-
.find(j.VariableDeclaration)
|
|
154
|
-
// @ts-expect-error
|
|
155
|
-
.filter((path) => path.node.declarations[0].id.name === stylesName);
|
|
156
|
-
|
|
157
|
-
if (lastImport && !cssMapDeclaration.length) {
|
|
158
|
-
lastImport.insertAfter(cssMapDecl);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
416
|
+
processedComponentTypes.set(elementName, { name: stylesName, declaration: cssMapDecl });
|
|
161
417
|
|
|
162
|
-
// Remove
|
|
418
|
+
// Remove all props and add xcss prop
|
|
163
419
|
propsToTransform.forEach((prop) => {
|
|
164
420
|
const index = attributes.indexOf(prop);
|
|
165
421
|
attributes.splice(index, 1);
|
|
166
422
|
});
|
|
167
423
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const xcssValue = existingXcss
|
|
173
|
-
? j.arrayExpression([
|
|
424
|
+
attributes.push(
|
|
425
|
+
j.jsxAttribute(
|
|
426
|
+
j.jsxIdentifier('xcss'),
|
|
427
|
+
j.jsxExpressionContainer(
|
|
174
428
|
j.memberExpression(j.identifier(stylesName), j.identifier('root')),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
: j.memberExpression(j.identifier(stylesName), j.identifier('root'));
|
|
179
|
-
|
|
180
|
-
if (existingXcss) {
|
|
181
|
-
existingXcss.value = j.jsxExpressionContainer(xcssValue);
|
|
182
|
-
} else {
|
|
183
|
-
attributes.push(j.jsxAttribute(j.jsxIdentifier('xcss'), j.jsxExpressionContainer(xcssValue)));
|
|
184
|
-
}
|
|
429
|
+
),
|
|
430
|
+
),
|
|
431
|
+
);
|
|
185
432
|
});
|
|
186
433
|
|
|
434
|
+
// Insert cssMap declarations after the last import declaration
|
|
435
|
+
const imports = root.find(j.ImportDeclaration);
|
|
436
|
+
const lastImport = imports.at(imports.length - 1);
|
|
437
|
+
|
|
438
|
+
if (lastImport) {
|
|
439
|
+
// Insert declarations in the order they were first encountered
|
|
440
|
+
Array.from(processedComponentTypes.values()).forEach(({ declaration }) => {
|
|
441
|
+
lastImport.insertAfter(declaration);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
187
445
|
// Add cssMap import if needed
|
|
188
446
|
if (needsCssMapImport && cssMapImport.length === 0) {
|
|
189
447
|
root
|
|
@@ -196,6 +454,18 @@ function transform(file: FileInfo, { jscodeshift: j }: API) {
|
|
|
196
454
|
);
|
|
197
455
|
}
|
|
198
456
|
|
|
457
|
+
// Add token import if needed
|
|
458
|
+
if (needsTokenImport) {
|
|
459
|
+
root
|
|
460
|
+
.get()
|
|
461
|
+
.node.program.body.unshift(
|
|
462
|
+
j.importDeclaration(
|
|
463
|
+
[j.importSpecifier(j.identifier('token'))],
|
|
464
|
+
j.literal('@atlaskit/tokens'),
|
|
465
|
+
),
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
|
|
199
469
|
return root.toSource({ quote: 'single' });
|
|
200
470
|
}
|
|
201
471
|
|
package/compiled/package.json
CHANGED
|
@@ -71,7 +71,7 @@ var AnchorNoRef = function AnchorNoRef(_ref, ref) {
|
|
|
71
71
|
action: 'clicked',
|
|
72
72
|
componentName: componentName || 'Anchor',
|
|
73
73
|
packageName: "@atlaskit/primitives",
|
|
74
|
-
packageVersion: "14.11.
|
|
74
|
+
packageVersion: "14.11.3",
|
|
75
75
|
analyticsData: analyticsContext,
|
|
76
76
|
actionSubject: 'link'
|
|
77
77
|
});
|
|
@@ -61,7 +61,7 @@ var Pressable = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
61
61
|
action: 'clicked',
|
|
62
62
|
componentName: componentName || 'Pressable',
|
|
63
63
|
packageName: "@atlaskit/primitives",
|
|
64
|
-
packageVersion: "14.11.
|
|
64
|
+
packageVersion: "14.11.3",
|
|
65
65
|
analyticsData: analyticsContext,
|
|
66
66
|
actionSubject: 'button'
|
|
67
67
|
});
|
|
@@ -104,7 +104,7 @@ var AnchorNoRef = function AnchorNoRef(_ref, ref) {
|
|
|
104
104
|
action: 'clicked',
|
|
105
105
|
componentName: componentName || 'Anchor',
|
|
106
106
|
packageName: "@atlaskit/primitives",
|
|
107
|
-
packageVersion: "14.11.
|
|
107
|
+
packageVersion: "14.11.3",
|
|
108
108
|
analyticsData: analyticsContext,
|
|
109
109
|
actionSubject: 'link'
|
|
110
110
|
});
|
|
@@ -95,7 +95,7 @@ var Pressable = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
95
95
|
action: 'clicked',
|
|
96
96
|
componentName: componentName || 'Pressable',
|
|
97
97
|
packageName: "@atlaskit/primitives",
|
|
98
|
-
packageVersion: "14.11.
|
|
98
|
+
packageVersion: "14.11.3",
|
|
99
99
|
analyticsData: analyticsContext,
|
|
100
100
|
actionSubject: 'button'
|
|
101
101
|
});
|
|
@@ -48,7 +48,7 @@ const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
48
48
|
action: 'clicked',
|
|
49
49
|
componentName: componentName || 'Pressable',
|
|
50
50
|
packageName: "@atlaskit/primitives",
|
|
51
|
-
packageVersion: "14.11.
|
|
51
|
+
packageVersion: "14.11.3",
|
|
52
52
|
analyticsData: analyticsContext,
|
|
53
53
|
actionSubject: 'button'
|
|
54
54
|
});
|
|
@@ -85,7 +85,7 @@ const Pressable = /*#__PURE__*/forwardRef(({
|
|
|
85
85
|
action: 'clicked',
|
|
86
86
|
componentName: componentName || 'Pressable',
|
|
87
87
|
packageName: "@atlaskit/primitives",
|
|
88
|
-
packageVersion: "14.11.
|
|
88
|
+
packageVersion: "14.11.3",
|
|
89
89
|
analyticsData: analyticsContext,
|
|
90
90
|
actionSubject: 'button'
|
|
91
91
|
});
|
|
@@ -62,7 +62,7 @@ var AnchorNoRef = function AnchorNoRef(_ref, ref) {
|
|
|
62
62
|
action: 'clicked',
|
|
63
63
|
componentName: componentName || 'Anchor',
|
|
64
64
|
packageName: "@atlaskit/primitives",
|
|
65
|
-
packageVersion: "14.11.
|
|
65
|
+
packageVersion: "14.11.3",
|
|
66
66
|
analyticsData: analyticsContext,
|
|
67
67
|
actionSubject: 'link'
|
|
68
68
|
});
|
|
@@ -52,7 +52,7 @@ var Pressable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
52
52
|
action: 'clicked',
|
|
53
53
|
componentName: componentName || 'Pressable',
|
|
54
54
|
packageName: "@atlaskit/primitives",
|
|
55
|
-
packageVersion: "14.11.
|
|
55
|
+
packageVersion: "14.11.3",
|
|
56
56
|
analyticsData: analyticsContext,
|
|
57
57
|
actionSubject: 'button'
|
|
58
58
|
});
|
|
@@ -98,7 +98,7 @@ var AnchorNoRef = function AnchorNoRef(_ref, ref) {
|
|
|
98
98
|
action: 'clicked',
|
|
99
99
|
componentName: componentName || 'Anchor',
|
|
100
100
|
packageName: "@atlaskit/primitives",
|
|
101
|
-
packageVersion: "14.11.
|
|
101
|
+
packageVersion: "14.11.3",
|
|
102
102
|
analyticsData: analyticsContext,
|
|
103
103
|
actionSubject: 'link'
|
|
104
104
|
});
|
|
@@ -89,7 +89,7 @@ var Pressable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
89
89
|
action: 'clicked',
|
|
90
90
|
componentName: componentName || 'Pressable',
|
|
91
91
|
packageName: "@atlaskit/primitives",
|
|
92
|
-
packageVersion: "14.11.
|
|
92
|
+
packageVersion: "14.11.3",
|
|
93
93
|
analyticsData: analyticsContext,
|
|
94
94
|
actionSubject: 'button'
|
|
95
95
|
});
|
|
@@ -19,5 +19,5 @@ type NestedQueryString = `above.${keyof typeof media.above}` | `below.${keyof ty
|
|
|
19
19
|
* - `MediaQueryList`, primarily used to get if that media query is currently
|
|
20
20
|
* - `null` when `matchMedia` is unavailable, eg. in SSR.
|
|
21
21
|
*/
|
|
22
|
-
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (
|
|
22
|
+
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (event: MediaQueryListEvent) => void) => MediaQueryList | null;
|
|
23
23
|
export {};
|
|
@@ -25,7 +25,12 @@ import type { Breakpoint } from './types';
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare const UNSAFE_buildAboveMediaQueryCSS: (
|
|
28
|
+
export declare const UNSAFE_buildAboveMediaQueryCSS: (
|
|
29
|
+
/**
|
|
30
|
+
* The desired CSS to place inside of the media query.
|
|
31
|
+
* This can either be a css object directly or functional with `breakpoint` as the arg to return a css object.
|
|
32
|
+
*/
|
|
33
|
+
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
29
34
|
/**
|
|
30
35
|
* Build a map of breakpoints to css with media queries and nested styles.
|
|
31
36
|
*
|
|
@@ -50,4 +55,9 @@ export declare const UNSAFE_buildAboveMediaQueryCSS: (input: CSSObject | ((break
|
|
|
50
55
|
* }
|
|
51
56
|
* ```
|
|
52
57
|
*/
|
|
53
|
-
export declare const UNSAFE_buildBelowMediaQueryCSS: (
|
|
58
|
+
export declare const UNSAFE_buildBelowMediaQueryCSS: (
|
|
59
|
+
/**
|
|
60
|
+
* The desired CSS to place inside of the media query.
|
|
61
|
+
* This can either be a css object directly or functional with `breakpoint` as the arg to return a css object.
|
|
62
|
+
*/
|
|
63
|
+
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
@@ -19,5 +19,5 @@ type NestedQueryString = `above.${keyof typeof UNSAFE_media.above}` | `below.${k
|
|
|
19
19
|
* - `MediaQueryList`, primarily used to get if that media query is currently
|
|
20
20
|
* - `null` when `matchMedia` is unavailable, eg. in SSR.
|
|
21
21
|
*/
|
|
22
|
-
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (
|
|
22
|
+
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (event: MediaQueryListEvent) => void) => MediaQueryList | null;
|
|
23
23
|
export {};
|
|
@@ -729,6 +729,6 @@ export declare const fontStylesMap: FontStyleMap;
|
|
|
729
729
|
export declare const textSizeStylesMap: TextStyleMap;
|
|
730
730
|
export declare const textWeightStylesMap: TextWeightStyleMap;
|
|
731
731
|
export declare const surfaceColorStylesMap: SurfaceColorStyleMap;
|
|
732
|
-
export declare const isSurfaceColorToken: (color: unknown) => color is
|
|
732
|
+
export declare const isSurfaceColorToken: (color: unknown) => color is SurfaceColorToken;
|
|
733
733
|
export declare const metricTextSizeStylesMap: MetricTextStyleMap;
|
|
734
734
|
export {};
|
|
@@ -19,5 +19,5 @@ type NestedQueryString = `above.${keyof typeof media.above}` | `below.${keyof ty
|
|
|
19
19
|
* - `MediaQueryList`, primarily used to get if that media query is currently
|
|
20
20
|
* - `null` when `matchMedia` is unavailable, eg. in SSR.
|
|
21
21
|
*/
|
|
22
|
-
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (
|
|
22
|
+
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (event: MediaQueryListEvent) => void) => MediaQueryList | null;
|
|
23
23
|
export {};
|
|
@@ -25,7 +25,12 @@ import type { Breakpoint } from './types';
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare const UNSAFE_buildAboveMediaQueryCSS: (
|
|
28
|
+
export declare const UNSAFE_buildAboveMediaQueryCSS: (
|
|
29
|
+
/**
|
|
30
|
+
* The desired CSS to place inside of the media query.
|
|
31
|
+
* This can either be a css object directly or functional with `breakpoint` as the arg to return a css object.
|
|
32
|
+
*/
|
|
33
|
+
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
29
34
|
/**
|
|
30
35
|
* Build a map of breakpoints to css with media queries and nested styles.
|
|
31
36
|
*
|
|
@@ -50,4 +55,9 @@ export declare const UNSAFE_buildAboveMediaQueryCSS: (input: CSSObject | ((break
|
|
|
50
55
|
* }
|
|
51
56
|
* ```
|
|
52
57
|
*/
|
|
53
|
-
export declare const UNSAFE_buildBelowMediaQueryCSS: (
|
|
58
|
+
export declare const UNSAFE_buildBelowMediaQueryCSS: (
|
|
59
|
+
/**
|
|
60
|
+
* The desired CSS to place inside of the media query.
|
|
61
|
+
* This can either be a css object directly or functional with `breakpoint` as the arg to return a css object.
|
|
62
|
+
*/
|
|
63
|
+
input: CSSObject | ((breakpoint: Breakpoint) => CSSObject)) => Required<Partial<Record<Breakpoint, import("@emotion/react").SerializedStyles>>>;
|
|
@@ -19,5 +19,5 @@ type NestedQueryString = `above.${keyof typeof UNSAFE_media.above}` | `below.${k
|
|
|
19
19
|
* - `MediaQueryList`, primarily used to get if that media query is currently
|
|
20
20
|
* - `null` when `matchMedia` is unavailable, eg. in SSR.
|
|
21
21
|
*/
|
|
22
|
-
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (
|
|
22
|
+
export declare const UNSAFE_useMediaQuery: (queryString: NestedQueryString, listener?: (event: MediaQueryListEvent) => void) => MediaQueryList | null;
|
|
23
23
|
export {};
|
|
@@ -740,6 +740,6 @@ export declare const fontStylesMap: FontStyleMap;
|
|
|
740
740
|
export declare const textSizeStylesMap: TextStyleMap;
|
|
741
741
|
export declare const textWeightStylesMap: TextWeightStyleMap;
|
|
742
742
|
export declare const surfaceColorStylesMap: SurfaceColorStyleMap;
|
|
743
|
-
export declare const isSurfaceColorToken: (color: unknown) => color is
|
|
743
|
+
export declare const isSurfaceColorToken: (color: unknown) => color is SurfaceColorToken;
|
|
744
744
|
export declare const metricTextSizeStylesMap: MetricTextStyleMap;
|
|
745
745
|
export {};
|
package/inline/package.json
CHANGED
package/metric-text/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/primitives",
|
|
3
|
-
"version": "14.11.
|
|
3
|
+
"version": "14.11.4",
|
|
4
4
|
"description": "Primitives are token-backed low-level building blocks.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
135
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
136
|
-
"@atlaskit/app-provider": "^3.
|
|
136
|
+
"@atlaskit/app-provider": "^3.1.0",
|
|
137
137
|
"@atlaskit/css": "^0.12.0",
|
|
138
138
|
"@atlaskit/ds-lib": "^5.0.0",
|
|
139
139
|
"@atlaskit/interaction-context": "^3.0.0",
|
|
@@ -156,21 +156,21 @@
|
|
|
156
156
|
"@af/integration-testing": "workspace:^",
|
|
157
157
|
"@af/visual-regression": "workspace:^",
|
|
158
158
|
"@atlaskit/avatar": "^25.1.0",
|
|
159
|
-
"@atlaskit/button": "^23.
|
|
159
|
+
"@atlaskit/button": "^23.4.0",
|
|
160
160
|
"@atlaskit/checkbox": "^17.1.0",
|
|
161
161
|
"@atlaskit/code": "^17.2.0",
|
|
162
162
|
"@atlaskit/docs": "^11.0.0",
|
|
163
163
|
"@atlaskit/dropdown-menu": "^16.3.0",
|
|
164
164
|
"@atlaskit/flag": "^17.3.0",
|
|
165
|
-
"@atlaskit/form": "^12.
|
|
165
|
+
"@atlaskit/form": "^12.1.0",
|
|
166
166
|
"@atlaskit/heading": "^5.2.0",
|
|
167
|
-
"@atlaskit/icon": "^
|
|
168
|
-
"@atlaskit/icon-object": "^7.
|
|
167
|
+
"@atlaskit/icon": "^28.0.0",
|
|
168
|
+
"@atlaskit/icon-object": "^7.2.0",
|
|
169
169
|
"@atlaskit/image": "^3.0.0",
|
|
170
170
|
"@atlaskit/link": "^3.2.0",
|
|
171
|
-
"@atlaskit/logo": "^19.
|
|
171
|
+
"@atlaskit/logo": "^19.7.0",
|
|
172
172
|
"@atlaskit/lozenge": "^13.0.0",
|
|
173
|
-
"@atlaskit/motion": "^5.
|
|
173
|
+
"@atlaskit/motion": "^5.3.0",
|
|
174
174
|
"@atlaskit/range": "^9.2.0",
|
|
175
175
|
"@atlaskit/section-message": "^8.5.0",
|
|
176
176
|
"@atlaskit/textfield": "^8.0.0",
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"@atlaskit/visual-regression": "workspace:^",
|
|
180
180
|
"@atlassian/analytics-bridge": "^0.7.0",
|
|
181
181
|
"@atlassian/codegen": "^0.1.0",
|
|
182
|
-
"@atlassian/ssr-tests": "^0.
|
|
182
|
+
"@atlassian/ssr-tests": "^0.3.0",
|
|
183
183
|
"@testing-library/react": "^13.4.0",
|
|
184
184
|
"@testing-library/react-hooks": "^8.0.1",
|
|
185
185
|
"@testing-library/user-event": "^14.4.3",
|
|
@@ -187,8 +187,7 @@
|
|
|
187
187
|
"jscodeshift": "^17.0.0",
|
|
188
188
|
"react-dom": "^18.2.0",
|
|
189
189
|
"react-resource-router": "^0.20.0",
|
|
190
|
-
"ts-node": "^10.9.1"
|
|
191
|
-
"typescript": "~5.4.2"
|
|
190
|
+
"ts-node": "^10.9.1"
|
|
192
191
|
},
|
|
193
192
|
"techstack": {
|
|
194
193
|
"@atlassian/frontend": {
|
package/pressable/package.json
CHANGED
package/responsive/package.json
CHANGED
package/stack/package.json
CHANGED