@atlaskit/forge-react-types 0.53.0 → 0.55.0
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 +18 -0
- package/dist/cjs/components/__generated__/BoxProps.codegen.js +12 -2
- package/dist/cjs/components/__generated__/tokens.codegen.js +666 -0
- package/dist/cjs/components/charts/PieChartProps.js +5 -1
- package/dist/es2019/components/__generated__/BoxProps.codegen.js +12 -2
- package/dist/es2019/components/__generated__/tokens.codegen.js +662 -0
- package/dist/es2019/components/charts/PieChartProps.js +1 -0
- package/dist/esm/components/__generated__/BoxProps.codegen.js +12 -2
- package/dist/esm/components/__generated__/tokens.codegen.js +667 -0
- package/dist/esm/components/charts/PieChartProps.js +1 -0
- package/dist/types/components/__generated__/BoxProps.codegen.d.ts +65 -51
- package/dist/types/components/__generated__/ButtonGroupProps.codegen.d.ts +3 -4
- package/dist/types/components/__generated__/IconProps.codegen.d.ts +1 -1
- package/dist/types/components/__generated__/PressableProps.codegen.d.ts +32 -32
- package/dist/types/components/__generated__/tokens.codegen.d.ts +1766 -0
- package/dist/types/components/charts/BarChartProps.d.ts +7 -0
- package/dist/types/components/charts/LineChartProps.d.ts +7 -0
- package/dist/types/components/charts/PieChartProps.d.ts +7 -0
- package/dist/types-ts4.5/components/__generated__/BoxProps.codegen.d.ts +65 -51
- package/dist/types-ts4.5/components/__generated__/ButtonGroupProps.codegen.d.ts +3 -4
- package/dist/types-ts4.5/components/__generated__/IconProps.codegen.d.ts +1 -1
- package/dist/types-ts4.5/components/__generated__/PressableProps.codegen.d.ts +32 -32
- package/dist/types-ts4.5/components/__generated__/tokens.codegen.d.ts +1766 -0
- package/dist/types-ts4.5/components/charts/BarChartProps.d.ts +7 -0
- package/dist/types-ts4.5/components/charts/LineChartProps.d.ts +7 -0
- package/dist/types-ts4.5/components/charts/PieChartProps.d.ts +7 -0
- package/package.json +12 -10
- package/scripts/codegen/codeGenerator.ts +176 -30
- package/scripts/codegen/componentPropTypes.ts +26 -0
- package/src/components/__generated__/BoxProps.codegen.tsx +38 -24
- package/src/components/__generated__/ButtonGroupProps.codegen.tsx +3 -4
- package/src/components/__generated__/IconProps.codegen.tsx +2 -2
- package/src/components/__generated__/tokens.codegen.tsx +1664 -0
- package/src/components/charts/BarChartProps.tsx +7 -0
- package/src/components/charts/LineChartProps.tsx +7 -0
- package/src/components/charts/PieChartProps.tsx +8 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ActiveTokens } from '@atlaskit/tokens';
|
|
2
|
+
import type { ThemeElementProps } from '@atlassian/viz-platform-charts/primitives';
|
|
2
3
|
type MarginValue = Extract<ActiveTokens, `space.${string}`>;
|
|
3
4
|
export type BarChartProps = {
|
|
4
5
|
/**
|
|
@@ -60,6 +61,12 @@ export type BarChartProps = {
|
|
|
60
61
|
* Adds a border onto the chart. Defaults to true.
|
|
61
62
|
*/
|
|
62
63
|
showBorder?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Custom color palette for the chart.
|
|
66
|
+
* Can be an array of color strings, or an array of objects with
|
|
67
|
+
* key and value properties to map specific data categories to colors.
|
|
68
|
+
*/
|
|
69
|
+
colorPalette?: ThemeElementProps['fillStyles'];
|
|
63
70
|
};
|
|
64
71
|
type StackChartProps = BarChartProps & {
|
|
65
72
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ActiveTokens } from '@atlaskit/tokens';
|
|
2
|
+
import type { ThemeElementProps } from '@atlassian/viz-platform-charts/primitives';
|
|
2
3
|
type MarginValue = Extract<ActiveTokens, `space.${string}`>;
|
|
3
4
|
export type LineChartProps = {
|
|
4
5
|
/**
|
|
@@ -60,6 +61,12 @@ export type LineChartProps = {
|
|
|
60
61
|
* Adds a border onto the chart. Defaults to true.
|
|
61
62
|
*/
|
|
62
63
|
showBorder?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Custom color palette for the chart.
|
|
66
|
+
* Can be an array of color strings, or an array of objects with
|
|
67
|
+
* key and value properties to map specific data categories to colors.
|
|
68
|
+
*/
|
|
69
|
+
colorPalette?: ThemeElementProps['fillStyles'];
|
|
63
70
|
};
|
|
64
71
|
/**
|
|
65
72
|
* A visual representation of data showing trends.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ThemeElementProps } from '@atlassian/viz-platform-charts/primitives';
|
|
1
2
|
export type PieChartProps = {
|
|
2
3
|
/**
|
|
3
4
|
* The static width of the chart in pixels. If this is not specified, the width is responsive.
|
|
@@ -42,6 +43,12 @@ export type PieChartProps = {
|
|
|
42
43
|
* Adds a border onto the chart. Defaults to true.
|
|
43
44
|
*/
|
|
44
45
|
showBorder?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Custom color palette for the chart.
|
|
48
|
+
* Can be an array of color strings, or an array of objects with
|
|
49
|
+
* key and value properties to map specific data categories to colors.
|
|
50
|
+
*/
|
|
51
|
+
colorPalette?: ThemeElementProps['fillStyles'];
|
|
45
52
|
};
|
|
46
53
|
/**
|
|
47
54
|
* A visual representation of data proportions in a circular format.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/forge-react-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Component types for Forge UI Kit React components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"@atlaskit/comment": "^13.2.0",
|
|
26
26
|
"@atlaskit/datetime-picker": "^17.4.0",
|
|
27
27
|
"@atlaskit/dynamic-table": "^18.3.0",
|
|
28
|
-
"@atlaskit/form": "^15.
|
|
29
|
-
"@atlaskit/inline-edit": "^15.
|
|
30
|
-
"@atlaskit/modal-dialog": "^14.
|
|
31
|
-
"@atlaskit/navigation-system": "^5.
|
|
28
|
+
"@atlaskit/form": "^15.3.0",
|
|
29
|
+
"@atlaskit/inline-edit": "^15.6.0",
|
|
30
|
+
"@atlaskit/modal-dialog": "^14.10.0",
|
|
31
|
+
"@atlaskit/navigation-system": "^5.27.0",
|
|
32
32
|
"@atlaskit/popup": "^4.13.0",
|
|
33
|
-
"@atlaskit/primitives": "^17.
|
|
33
|
+
"@atlaskit/primitives": "^17.1.0",
|
|
34
34
|
"@atlaskit/progress-bar": "^4.1.0",
|
|
35
35
|
"@atlaskit/progress-tracker": "^10.4.0",
|
|
36
36
|
"@atlaskit/radio": "^8.4.0",
|
|
37
|
-
"@atlaskit/section-message": "^8.
|
|
37
|
+
"@atlaskit/section-message": "^8.12.0",
|
|
38
38
|
"@atlaskit/select": "^21.6.0",
|
|
39
39
|
"@atlaskit/spinner": "^19.0.0",
|
|
40
40
|
"@atlaskit/tabs": "^18.3.0",
|
|
@@ -45,15 +45,17 @@
|
|
|
45
45
|
"@atlaskit/tile": "^1.0.0",
|
|
46
46
|
"@atlaskit/toggle": "^15.2.0",
|
|
47
47
|
"@atlaskit/tokens": "^9.1.0",
|
|
48
|
-
"@atlaskit/tooltip": "^20.
|
|
49
|
-
"@babel/runtime": "^7.0.0"
|
|
48
|
+
"@atlaskit/tooltip": "^20.14.0",
|
|
49
|
+
"@babel/runtime": "^7.0.0",
|
|
50
|
+
"@emotion/react": "^11.7.1",
|
|
51
|
+
"@emotion/serialize": "^1.1.0"
|
|
50
52
|
},
|
|
51
53
|
"peerDependencies": {
|
|
52
54
|
"react": "^18.2.0"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"@atlassian/codegen": "^0.1.0",
|
|
56
|
-
"@atlassian/forge-ui": "^32.
|
|
58
|
+
"@atlassian/forge-ui": "^32.68.0",
|
|
57
59
|
"@types/node": "~22.17.1",
|
|
58
60
|
"lodash": "^4.17.21",
|
|
59
61
|
"react": "^18.2.0",
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type VariableDeclaration,
|
|
10
10
|
SyntaxKind,
|
|
11
11
|
Node,
|
|
12
|
+
Project,
|
|
12
13
|
} from 'ts-morph';
|
|
13
14
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
14
15
|
import kebabCase from 'lodash/kebabCase';
|
|
@@ -184,29 +185,41 @@ class ImportDeclarationProxy implements IImportDeclaration {
|
|
|
184
185
|
|
|
185
186
|
public getText() {
|
|
186
187
|
const code = this.base.getText();
|
|
187
|
-
|
|
188
|
+
|
|
189
|
+
const match = code.match(/^(import(?:\s+type)?)\s+(?:(\w+)\s*,?\s*)?(?:\{([^}]*)\})?\s*from\s*['"](.+)['"];?$/);
|
|
188
190
|
if (!match) {
|
|
189
191
|
return this.base.getText();
|
|
190
192
|
}
|
|
191
|
-
|
|
192
|
-
let
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
.map((text) => text.trim())
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// Map shared UIKit type imports to types.codegen
|
|
199
|
-
packageName = './types.codegen';
|
|
200
|
-
}
|
|
193
|
+
|
|
194
|
+
let [_, importKeyword, defaultImport, namedImportsStr, packageName] = match;
|
|
195
|
+
|
|
196
|
+
let namedImportsList = namedImportsStr
|
|
197
|
+
? namedImportsStr.trim().split(',').map((text) => text.trim()).filter(Boolean)
|
|
198
|
+
: [];
|
|
199
|
+
|
|
201
200
|
|
|
202
201
|
if (this.removedNamedImports.size > 0) {
|
|
203
|
-
|
|
202
|
+
namedImportsList = namedImportsList.filter((text) => !this.removedNamedImports.has(text));
|
|
204
203
|
}
|
|
205
204
|
if (this.addedNamedImports) {
|
|
206
|
-
|
|
205
|
+
namedImportsList = Array.from(new Set([...namedImportsList, ...this.addedNamedImports]));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Build the import statement
|
|
209
|
+
const parts: string[] = [];
|
|
210
|
+
if (defaultImport) {
|
|
211
|
+
parts.push(defaultImport);
|
|
212
|
+
}
|
|
213
|
+
if (namedImportsList.length > 0) {
|
|
214
|
+
parts.push(`{ ${namedImportsList.sort().join(', ')} }`);
|
|
207
215
|
}
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
|
|
217
|
+
// If no imports left, don't output anything
|
|
218
|
+
if (parts.length === 0) {
|
|
219
|
+
return '';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return `${importKeyword} ${parts.join(', ')} from '${packageName}';`;
|
|
210
223
|
}
|
|
211
224
|
}
|
|
212
225
|
|
|
@@ -254,6 +267,131 @@ const isSharedUIKit2TypesImport = (importDeclaration: ImportDeclaration) => {
|
|
|
254
267
|
);
|
|
255
268
|
};
|
|
256
269
|
|
|
270
|
+
// Check if a module specifier points to the tokens.partial file
|
|
271
|
+
const isTokensPartialImport = (moduleSpecifier: string): boolean =>
|
|
272
|
+
moduleSpecifier.includes('tokens.partial') || moduleSpecifier.includes('UIKit/tokens');
|
|
273
|
+
|
|
274
|
+
// Merge multiple import statements from the same module into one
|
|
275
|
+
// Rewrite module paths for codegen output
|
|
276
|
+
const rewriteModulePath = (module: string): string => {
|
|
277
|
+
if (isTokensPartialImport(module)) {
|
|
278
|
+
return './tokens.codegen';
|
|
279
|
+
}
|
|
280
|
+
// Rewrite UIKit/types imports to types.codegen
|
|
281
|
+
if (module.charAt(0) === '.' && module.includes('/types')) {
|
|
282
|
+
return './types.codegen';
|
|
283
|
+
}
|
|
284
|
+
return module;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const mergeImportsFromSameModule = (code: string): string => {
|
|
288
|
+
const project = new Project({ useInMemoryFileSystem: true });
|
|
289
|
+
const tempFile = project.createSourceFile('temp.ts', code);
|
|
290
|
+
|
|
291
|
+
// Track imports by module specifier
|
|
292
|
+
interface ModuleImports {
|
|
293
|
+
typeOnly: Set<string>;
|
|
294
|
+
regular: Set<string>;
|
|
295
|
+
defaultImport?: string;
|
|
296
|
+
namespaceImport?: string;
|
|
297
|
+
isTypeOnly: boolean;
|
|
298
|
+
}
|
|
299
|
+
const importsByModule = new Map<string, ModuleImports>();
|
|
300
|
+
|
|
301
|
+
for (const importDecl of tempFile.getImportDeclarations()) {
|
|
302
|
+
const rawModule = importDecl.getModuleSpecifierValue();
|
|
303
|
+
const module = rewriteModulePath(rawModule);
|
|
304
|
+
const isTypeOnly = importDecl.isTypeOnly();
|
|
305
|
+
|
|
306
|
+
if (!importsByModule.has(module)) {
|
|
307
|
+
importsByModule.set(module, { typeOnly: new Set(), regular: new Set(), isTypeOnly: false });
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const moduleImports = importsByModule.get(module)!;
|
|
311
|
+
|
|
312
|
+
// Handle default import: import React from 'react'
|
|
313
|
+
const defaultImport = importDecl.getDefaultImport();
|
|
314
|
+
if (defaultImport) {
|
|
315
|
+
moduleImports.defaultImport = defaultImport.getText();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Handle namespace import: import * as CSS from 'csstype'
|
|
319
|
+
const namespaceImport = importDecl.getNamespaceImport();
|
|
320
|
+
if (namespaceImport) {
|
|
321
|
+
moduleImports.namespaceImport = namespaceImport.getText();
|
|
322
|
+
if (isTypeOnly) {
|
|
323
|
+
moduleImports.isTypeOnly = true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Handle named imports
|
|
328
|
+
for (const namedImport of importDecl.getNamedImports()) {
|
|
329
|
+
const name = namedImport.getName();
|
|
330
|
+
const alias = namedImport.getAliasNode()?.getText();
|
|
331
|
+
const importText = alias ? `${name} as ${alias}` : name;
|
|
332
|
+
const isNamedTypeOnly = namedImport.isTypeOnly();
|
|
333
|
+
|
|
334
|
+
if (isTypeOnly || isNamedTypeOnly) {
|
|
335
|
+
moduleImports.typeOnly.add(importText);
|
|
336
|
+
} else {
|
|
337
|
+
moduleImports.regular.add(importText);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
importDecl.remove();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Add merged imports back
|
|
345
|
+
for (const [module, { typeOnly, regular, defaultImport, namespaceImport, isTypeOnly }] of importsByModule) {
|
|
346
|
+
// Handle namespace imports separately (can't be combined with named imports)
|
|
347
|
+
if (namespaceImport) {
|
|
348
|
+
tempFile.addImportDeclaration({
|
|
349
|
+
moduleSpecifier: module,
|
|
350
|
+
namespaceImport: namespaceImport,
|
|
351
|
+
isTypeOnly: isTypeOnly,
|
|
352
|
+
});
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const allImports: string[] = [];
|
|
357
|
+
|
|
358
|
+
// Add type-only imports with `type` prefix
|
|
359
|
+
for (const imp of typeOnly) {
|
|
360
|
+
if (!regular.has(imp)) {
|
|
361
|
+
allImports.push(`type ${imp}`);
|
|
362
|
+
} else {
|
|
363
|
+
// If it's in both, keep it as regular (value import)
|
|
364
|
+
allImports.push(imp);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Add regular imports
|
|
369
|
+
for (const imp of regular) {
|
|
370
|
+
if (!typeOnly.has(imp)) {
|
|
371
|
+
allImports.push(imp);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (allImports.length > 0 || defaultImport) {
|
|
376
|
+
tempFile.addImportDeclaration({
|
|
377
|
+
moduleSpecifier: module,
|
|
378
|
+
defaultImport: defaultImport,
|
|
379
|
+
namedImports: allImports.length > 0 ? allImports : undefined,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return tempFile.getFullText();
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
// handles imports from platform/packages/forge/forge-ui/src/components/UIKit/tokens.partial.tsx
|
|
389
|
+
// (can be type-only imports OR mixed value/type imports)
|
|
390
|
+
const isSharedUIKit2TokensImport = (importDeclaration: ImportDeclaration) => {
|
|
391
|
+
const moduleSpecifier = importDeclaration.getModuleSpecifierValue();
|
|
392
|
+
return moduleSpecifier.charAt(0) === '.' && isTokensPartialImport(moduleSpecifier);
|
|
393
|
+
};
|
|
394
|
+
|
|
257
395
|
const extractImportDeclarations = (
|
|
258
396
|
sourceFile: SourceFile,
|
|
259
397
|
componentPropSymbol: Symbol,
|
|
@@ -273,11 +411,12 @@ const extractImportDeclarations = (
|
|
|
273
411
|
// only keep dependencies from
|
|
274
412
|
// - @atlaskit
|
|
275
413
|
// - react
|
|
276
|
-
// - or
|
|
414
|
+
// - or shared UIKit types/tokens files
|
|
277
415
|
return (
|
|
278
416
|
moduleSpecifier.startsWith('@atlaskit/') ||
|
|
279
417
|
moduleSpecifier === 'react' ||
|
|
280
|
-
isSharedUIKit2TypesImport(declaration)
|
|
418
|
+
isSharedUIKit2TypesImport(declaration) ||
|
|
419
|
+
isSharedUIKit2TokensImport(declaration)
|
|
281
420
|
);
|
|
282
421
|
})
|
|
283
422
|
.reduce<ImportDeclarationProxy[]>((declarations, declaration) => {
|
|
@@ -866,8 +1005,12 @@ const extractImportsForVariables = (
|
|
|
866
1005
|
|
|
867
1006
|
for (const importDecl of imports) {
|
|
868
1007
|
const moduleSpecifier = importDecl.getModuleSpecifierValue();
|
|
869
|
-
|
|
870
|
-
|
|
1008
|
+
|
|
1009
|
+
// Handle imports from @atlaskit packages or tokens.partial file
|
|
1010
|
+
const isAtlaskitImport = moduleSpecifier.startsWith('@atlaskit/');
|
|
1011
|
+
const isTokensImport = isTokensPartialImport(moduleSpecifier);
|
|
1012
|
+
|
|
1013
|
+
if (isAtlaskitImport || isTokensImport) {
|
|
871
1014
|
const namedImports = importDecl.getNamedImports();
|
|
872
1015
|
const isTypeOnlyImport = importDecl.isTypeOnly();
|
|
873
1016
|
|
|
@@ -894,16 +1037,15 @@ const extractImportsForVariables = (
|
|
|
894
1037
|
|
|
895
1038
|
// If any imports are used, create an import statement
|
|
896
1039
|
if (usedNamedImports.length > 0 || usedTypeImports.length > 0) {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
1040
|
+
// Rewrite tokens.partial imports to tokens.codegen
|
|
1041
|
+
const targetModule = isTokensImport ? './tokens.codegen' : moduleSpecifier;
|
|
1042
|
+
|
|
1043
|
+
// Combine type and value imports into a single { } block
|
|
1044
|
+
const allImports: string[] = [
|
|
1045
|
+
...usedTypeImports.map((name) => `type ${name}`),
|
|
1046
|
+
...usedNamedImports,
|
|
1047
|
+
];
|
|
1048
|
+
importDeclarations.push(`import { ${allImports.join(', ')} } from '${targetModule}';`);
|
|
907
1049
|
}
|
|
908
1050
|
}
|
|
909
1051
|
}
|
|
@@ -948,6 +1090,7 @@ const handleXCSSProp: CodeConsolidator = ({
|
|
|
948
1090
|
const xcssValidatorDeclarationCode = utilsFile.getEmitOutput({
|
|
949
1091
|
emitOnlyDtsFiles: true,
|
|
950
1092
|
}).compilerObject.outputFiles[0].text;
|
|
1093
|
+
|
|
951
1094
|
const xcssValidatorVariableDeclarationCode = [
|
|
952
1095
|
xcssValidatorDeclarationCode,
|
|
953
1096
|
variableImportsCode,
|
|
@@ -958,7 +1101,7 @@ const handleXCSSProp: CodeConsolidator = ({
|
|
|
958
1101
|
.filter((code) => !!code)
|
|
959
1102
|
.join('\n');
|
|
960
1103
|
|
|
961
|
-
|
|
1104
|
+
const allCode = [
|
|
962
1105
|
'/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */\n/* eslint-disable @atlaskit/design-system/ensure-design-token-usage/preview */',
|
|
963
1106
|
importCode,
|
|
964
1107
|
xcssValidatorVariableDeclarationCode,
|
|
@@ -969,6 +1112,9 @@ const handleXCSSProp: CodeConsolidator = ({
|
|
|
969
1112
|
]
|
|
970
1113
|
.filter((code) => !!code)
|
|
971
1114
|
.join('\n\n');
|
|
1115
|
+
|
|
1116
|
+
// Merge duplicate imports from the same module (e.g., multiple tokens.codegen imports)
|
|
1117
|
+
return mergeImportsFromSameModule(allCode);
|
|
972
1118
|
} finally {
|
|
973
1119
|
sourceFile.getProject().removeSourceFile(utilsFile);
|
|
974
1120
|
}
|
|
@@ -201,6 +201,31 @@ const generateSharedTypesFile = (componentOutputDir: string) => {
|
|
|
201
201
|
fs.writeFileSync(typesFilePath, signedSourceCode);
|
|
202
202
|
};
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* This copies the tokens file from UIKit to __generated__ folder.
|
|
206
|
+
* The tokens file contains design token maps used by xcss components.
|
|
207
|
+
*/
|
|
208
|
+
const generateSharedTokensFile = (componentOutputDir: string) => {
|
|
209
|
+
// eslint-disable-next-line no-console
|
|
210
|
+
console.log('Generating shared tokens file');
|
|
211
|
+
|
|
212
|
+
const uiKitTokensFile = require.resolve('@atlassian/forge-ui/UIKit/tokens');
|
|
213
|
+
|
|
214
|
+
const signedSourceCode = createSignedArtifact(
|
|
215
|
+
fs.readFileSync(uiKitTokensFile, 'utf8'),
|
|
216
|
+
'yarn workspace @atlaskit/forge-react-types codegen',
|
|
217
|
+
{
|
|
218
|
+
description:
|
|
219
|
+
'Shared tokens file for UI Kit components. Contains design token maps for xcss support. Source: `packages/forge/forge-ui/src/components/UIKit/tokens.partial.tsx`',
|
|
220
|
+
dependencies: [uiKitTokensFile],
|
|
221
|
+
outputFolder: componentOutputDir,
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const tokensFilePath = resolve(componentOutputDir, 'tokens.codegen.tsx');
|
|
226
|
+
fs.writeFileSync(tokensFilePath, signedSourceCode);
|
|
227
|
+
};
|
|
228
|
+
|
|
204
229
|
const generateComponentPropTypes = (componentNames?: string) => {
|
|
205
230
|
const componentOutputDir = resolve(__dirname, '..', '..', 'src', 'components', '__generated__');
|
|
206
231
|
const componentIndexSourceFile = forgeUIProject.addSourceFileAtPath(
|
|
@@ -223,6 +248,7 @@ const generateComponentPropTypes = (componentNames?: string) => {
|
|
|
223
248
|
|
|
224
249
|
// generate shared files first
|
|
225
250
|
generateSharedTypesFile(componentOutputDir);
|
|
251
|
+
generateSharedTokensFile(componentOutputDir);
|
|
226
252
|
|
|
227
253
|
generateComponentPropTypeSourceFiles(componentOutputDir, componentPropTypeSymbols);
|
|
228
254
|
|
|
@@ -3,19 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Extract component prop types from UIKit 2 components - BoxProps
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::653f98d927e1ec1646db39eca8e994fb>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen
|
|
8
|
-
* @codegenDependency ../../../../forge-ui/src/components/UIKit/box/index.tsx <<SignedSource::
|
|
8
|
+
* @codegenDependency ../../../../forge-ui/src/components/UIKit/box/index.tsx <<SignedSource::8875ae64ad6c03e0827dd8f8a893ac04>>
|
|
9
9
|
*/
|
|
10
10
|
/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */
|
|
11
11
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage/preview */
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { type BackgroundColor, type Space, type MediaQuery, type BorderRadius, tokensMap } from "./tokens.codegen";
|
|
14
|
+
import type * as CSS from "csstype";
|
|
15
|
+
import { type SerializedStyles, type CSSObject } from "@emotion/serialize";
|
|
12
16
|
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import type { Box as PlatformBox } from '@atlaskit/primitives';
|
|
15
|
-
|
|
16
|
-
import type * as CSS from 'csstype';
|
|
17
|
-
import type { MediaQuery } from '@atlaskit/primitives';
|
|
18
|
-
import { tokensMap } from '@atlaskit/primitives';
|
|
19
17
|
type CSSProperties = CSS.PropertiesFallback<number | string>;
|
|
20
18
|
type TokensMap = typeof tokensMap;
|
|
21
19
|
type TokensMapPropKey = keyof TokensMap;
|
|
@@ -67,8 +65,16 @@ declare const makeXCSSValidator: <U extends XCSSValidatorParam>(supportedXCSSPro
|
|
|
67
65
|
} ? Exclude<V[keyof V], number | ((...args: any[]) => any)> : never) | undefined; }>;
|
|
68
66
|
export { makeXCSSValidator };
|
|
69
67
|
export type { SafeCSSObject };
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Generates SerializedStyles from xcss style object.
|
|
70
|
+
*
|
|
71
|
+
* Previously we used `&&` specificity hack to ensure Emotion xcss styles could
|
|
72
|
+
* override Compiled styles when wrapping @atlaskit/primitives/compiled components.
|
|
73
|
+
*
|
|
74
|
+
* Now that components like Box and Pressable are reimplemented entirely in Emotion,
|
|
75
|
+
* we no longer need the specificity increase - Emotion merges styles in array order (last wins).
|
|
76
|
+
*/
|
|
77
|
+
export declare function generateXcss(styleObj: CSSObject): SerializedStyles;
|
|
72
78
|
const borderRadiusTokens: BorderRadius[] = [
|
|
73
79
|
'radius.xsmall',
|
|
74
80
|
'radius.small',
|
|
@@ -78,7 +84,10 @@ const borderRadiusTokens: BorderRadius[] = [
|
|
|
78
84
|
'radius.full',
|
|
79
85
|
'radius.tile',
|
|
80
86
|
];
|
|
81
|
-
const borderRadiusSupportedValues = [
|
|
87
|
+
const borderRadiusSupportedValues = [
|
|
88
|
+
...borderRadiusTokens,
|
|
89
|
+
'border.radius',
|
|
90
|
+
] as unknown as Array<BorderRadius>;
|
|
82
91
|
const xcssValidator = makeXCSSValidator({
|
|
83
92
|
// text related props
|
|
84
93
|
textAlign: {
|
|
@@ -205,9 +214,7 @@ const xcssValidator = makeXCSSValidator({
|
|
|
205
214
|
});
|
|
206
215
|
type XCSSProp = ReturnType<typeof xcssValidator>;
|
|
207
216
|
|
|
208
|
-
type
|
|
209
|
-
|
|
210
|
-
export type BoxProps = Pick<PlatformBoxProps, 'children' | 'ref' | 'testId'> & {
|
|
217
|
+
export type BoxProps = {
|
|
211
218
|
/**
|
|
212
219
|
* A token alias for background color. See: [Design tokens](https://atlassian.design/components/tokens/all-tokens)
|
|
213
220
|
* for a list of available colors.
|
|
@@ -217,68 +224,75 @@ export type BoxProps = Pick<PlatformBoxProps, 'children' | 'ref' | 'testId'> & {
|
|
|
217
224
|
*
|
|
218
225
|
* @type [Background color tokens](https://atlassian.design/components/tokens/all-tokens#color-background)
|
|
219
226
|
*/
|
|
220
|
-
backgroundColor?:
|
|
227
|
+
backgroundColor?: BackgroundColor;
|
|
221
228
|
|
|
222
229
|
/**
|
|
223
230
|
* @type ForgeComponent
|
|
224
231
|
*/
|
|
225
|
-
children?:
|
|
232
|
+
children?: React.ReactNode;
|
|
226
233
|
|
|
227
234
|
/**
|
|
228
235
|
* A shorthand for `paddingBlock` and `paddingInline` together.
|
|
229
236
|
*
|
|
230
237
|
* @type [Space tokens](https://atlassian.design/components/tokens/all-tokens#space)
|
|
231
238
|
*/
|
|
232
|
-
padding?:
|
|
239
|
+
padding?: Space;
|
|
233
240
|
|
|
234
241
|
/**
|
|
235
242
|
* The logical block start and end padding of an element.
|
|
236
243
|
*
|
|
237
244
|
* @type [Space tokens](https://atlassian.design/components/tokens/all-tokens#space)
|
|
238
245
|
*/
|
|
239
|
-
paddingBlock?:
|
|
246
|
+
paddingBlock?: Space;
|
|
240
247
|
|
|
241
248
|
/**
|
|
242
249
|
* The logical block end padding of an element.
|
|
243
250
|
*
|
|
244
251
|
* @type [Space tokens](https://atlassian.design/components/tokens/all-tokens#space)
|
|
245
252
|
*/
|
|
246
|
-
paddingBlockEnd?:
|
|
253
|
+
paddingBlockEnd?: Space;
|
|
247
254
|
|
|
248
255
|
/**
|
|
249
256
|
* The logical block start padding of an element.
|
|
250
257
|
*
|
|
251
258
|
* @type [Space tokens](https://atlassian.design/components/tokens/all-tokens#space)
|
|
252
259
|
*/
|
|
253
|
-
paddingBlockStart?:
|
|
260
|
+
paddingBlockStart?: Space;
|
|
254
261
|
|
|
255
262
|
/**
|
|
256
263
|
* The logical inline start and end padding of an element.
|
|
257
264
|
*
|
|
258
265
|
* @type [Space tokens](https://atlassian.design/components/tokens/all-tokens#space)
|
|
259
266
|
*/
|
|
260
|
-
paddingInline?:
|
|
267
|
+
paddingInline?: Space;
|
|
261
268
|
|
|
262
269
|
/**
|
|
263
270
|
* The logical inline end padding of an element.
|
|
264
271
|
*
|
|
265
272
|
* @type [Space tokens](https://atlassian.design/components/tokens/all-tokens#space)
|
|
266
273
|
*/
|
|
267
|
-
paddingInlineEnd?:
|
|
274
|
+
paddingInlineEnd?: Space;
|
|
268
275
|
|
|
269
276
|
/**
|
|
270
277
|
* The logical inline start padding of an element.
|
|
271
278
|
*
|
|
272
279
|
* @type [Space tokens](https://atlassian.design/components/tokens/all-tokens#space)
|
|
273
280
|
*/
|
|
274
|
-
paddingInlineStart?:
|
|
281
|
+
paddingInlineStart?: Space;
|
|
275
282
|
|
|
276
283
|
/**
|
|
277
284
|
* Accessible role.
|
|
278
285
|
*
|
|
279
286
|
* @type string
|
|
280
287
|
*/
|
|
281
|
-
role?:
|
|
288
|
+
role?: string;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Test ID for the box.
|
|
292
|
+
*
|
|
293
|
+
* @type string
|
|
294
|
+
*/
|
|
295
|
+
testId?: string;
|
|
282
296
|
|
|
283
297
|
/**
|
|
284
298
|
* Apply a subset of permitted styles, powered by Atlassian Design System tokens.
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Extract component prop types from UIKit 2 components - ButtonGroupProps
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::17e4c7b27bf25505bd192e44f0bc3c37>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/forge-react-types codegen
|
|
8
|
-
* @codegenDependency ../../../../forge-ui/src/components/UIKit/button/__generated__/button-group.partial.tsx <<SignedSource::
|
|
8
|
+
* @codegenDependency ../../../../forge-ui/src/components/UIKit/button/__generated__/button-group.partial.tsx <<SignedSource::425feaa78f4ad0ff0373e9e49718c6f9>>
|
|
9
9
|
*/
|
|
10
10
|
/* eslint @repo/internal/codegen/signed-source-integrity: "warn" */
|
|
11
11
|
|
|
12
|
-
import type { ButtonGroupProps as PlatformButtonGroupProps } from '@atlaskit/button';
|
|
13
|
-
import type { ButtonProps } from '@atlaskit/button';
|
|
12
|
+
import type { ButtonGroupProps as PlatformButtonGroupProps, ButtonProps } from '@atlaskit/button';
|
|
14
13
|
|
|
15
14
|
export type ButtonGroupProps = Pick<
|
|
16
15
|
PlatformButtonGroupProps,
|
|
@@ -670,7 +670,7 @@ export type IconReplaced =
|
|
|
670
670
|
| 'world'
|
|
671
671
|
| 'world-small';
|
|
672
672
|
|
|
673
|
-
type Glyph = IconNext |
|
|
673
|
+
type Glyph = IconNext | IconReplaced;
|
|
674
674
|
export type IconColor = Extract<ActiveTokens, `color.${string}`>;
|
|
675
675
|
|
|
676
676
|
export type IconProps = {
|
|
@@ -705,4 +705,4 @@ export type IconProps = {
|
|
|
705
705
|
*
|
|
706
706
|
* @see [Icon](https://developer.atlassian.com/platform/forge/ui-kit/components/icon/) in UI Kit documentation for more information
|
|
707
707
|
*/
|
|
708
|
-
export type TIcon<T> = (props: IconProps) => T;
|
|
708
|
+
export type TIcon<T> = (props: IconProps) => T;
|