@atlaskit/primitives 0.9.0 → 0.9.2

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 (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +6 -2
  3. package/box/package.json +2 -2
  4. package/constellation/box/code.mdx +6 -2
  5. package/constellation/box/usage.mdx +30 -0
  6. package/constellation/inline/code.mdx +1 -1
  7. package/constellation/inline/usage.mdx +36 -0
  8. package/constellation/overview/images/box-usage-example.png +0 -0
  9. package/constellation/overview/images/inline-usage-example.png +0 -0
  10. package/constellation/overview/images/stack-usage-example.png +0 -0
  11. package/constellation/overview/index.mdx +66 -0
  12. package/constellation/stack/code.mdx +1 -1
  13. package/constellation/stack/usage.mdx +31 -0
  14. package/constellation/xcss/examples.mdx +21 -0
  15. package/constellation/xcss/logo.png +0 -0
  16. package/constellation/xcss/migration.mdx +142 -0
  17. package/constellation/xcss/usage.mdx +115 -0
  18. package/dist/cjs/components/box.js +1 -1
  19. package/dist/cjs/components/inline.js +1 -1
  20. package/dist/cjs/components/internal/base-box.js +1 -1
  21. package/dist/cjs/components/stack.js +1 -1
  22. package/dist/cjs/index.js +1 -1
  23. package/dist/cjs/version.json +1 -1
  24. package/dist/cjs/{internal → xcss}/style-maps.partial.js +13 -43
  25. package/dist/cjs/{internal → xcss}/xcss.js +38 -26
  26. package/dist/es2019/components/box.js +1 -1
  27. package/dist/es2019/components/inline.js +1 -1
  28. package/dist/es2019/components/internal/base-box.js +1 -1
  29. package/dist/es2019/components/stack.js +1 -1
  30. package/dist/es2019/index.js +1 -1
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/es2019/{internal → xcss}/style-maps.partial.js +12 -40
  33. package/dist/es2019/{internal → xcss}/xcss.js +38 -25
  34. package/dist/esm/components/box.js +1 -1
  35. package/dist/esm/components/inline.js +1 -1
  36. package/dist/esm/components/internal/base-box.js +1 -1
  37. package/dist/esm/components/stack.js +1 -1
  38. package/dist/esm/index.js +1 -1
  39. package/dist/esm/version.json +1 -1
  40. package/dist/esm/{internal → xcss}/style-maps.partial.js +12 -40
  41. package/dist/esm/{internal → xcss}/xcss.js +39 -27
  42. package/dist/types/components/box.d.ts +2 -2
  43. package/dist/types/components/inline.d.ts +7 -7
  44. package/dist/types/components/internal/base-box.d.ts +15 -14
  45. package/dist/types/components/stack.d.ts +6 -6
  46. package/dist/types/components/types.d.ts +3 -3
  47. package/dist/types/constants.d.ts +1 -1
  48. package/dist/types/helpers/responsive/types.d.ts +4 -4
  49. package/dist/types/index.d.ts +1 -1
  50. package/dist/types/{internal → xcss}/style-maps.partial.d.ts +81 -130
  51. package/dist/types/xcss/xcss.d.ts +57 -0
  52. package/extract-react-types/box-props.tsx +95 -0
  53. package/extract-react-types/inline-props.tsx +86 -1
  54. package/extract-react-types/stack-props.tsx +70 -1
  55. package/inline/package.json +2 -2
  56. package/package.json +25 -8
  57. package/report.api.md +94 -354
  58. package/responsive/package.json +2 -2
  59. package/scripts/codegen-file-templates/dimensions.tsx +17 -16
  60. package/scripts/codegen-styles.tsx +2 -2
  61. package/scripts/spacing-codegen-template.tsx +24 -91
  62. package/stack/package.json +2 -2
  63. package/tmp/api-report-tmp.d.ts +649 -0
  64. package/constellation/overview/examples.mdx +0 -7
  65. package/dist/cjs/components/internal/extract-react-types/inline-props.js +0 -7
  66. package/dist/cjs/components/internal/extract-react-types/stack-props.js +0 -7
  67. package/dist/es2019/components/internal/extract-react-types/inline-props.js +0 -1
  68. package/dist/es2019/components/internal/extract-react-types/stack-props.js +0 -1
  69. package/dist/esm/components/internal/extract-react-types/inline-props.js +0 -1
  70. package/dist/esm/components/internal/extract-react-types/stack-props.js +0 -1
  71. package/dist/types/components/internal/extract-react-types/inline-props.d.ts +0 -2
  72. package/dist/types/components/internal/extract-react-types/stack-props.d.ts +0 -2
  73. package/dist/types/internal/xcss.d.ts +0 -50
@@ -3,98 +3,31 @@ import parserTypeScript from 'prettier/parser-typescript';
3
3
 
4
4
  import { spacing as tokens } from '@atlaskit/tokens/tokens-raw';
5
5
 
6
- import { capitalize, constructTokenFunctionCall } from './utils';
7
-
8
- const spacingProperties: Record<
9
- string,
10
- {
11
- cssProperties: readonly string[];
12
- propNameFormatter?: (propName: string) => string;
13
- }
14
- > = {
15
- padding: {
16
- cssProperties: [
17
- 'padding',
18
- 'paddingBlock',
19
- 'paddingBlockEnd',
20
- 'paddingBlockStart',
21
- 'paddingBottom',
22
- 'paddingInline',
23
- 'paddingInlineEnd',
24
- 'paddingInlineStart',
25
- 'paddingLeft',
26
- 'paddingRight',
27
- 'paddingTop',
28
- ],
29
- },
30
- space: {
31
- cssProperties: ['gap', 'rowGap', 'columnGap'],
32
- },
33
- inset: {
34
- cssProperties: [
35
- 'inset',
36
- 'insetBlock',
37
- 'insetBlockEnd',
38
- 'insetBlockStart',
39
- 'insetInline',
40
- 'insetInlineEnd',
41
- 'insetInlineStart',
42
- ],
43
- },
44
- } as const;
6
+ import { constructTokenFunctionCall } from './utils';
45
7
 
46
8
  const spacingTokenPrefix = 'space.';
47
- const onlySpaceTokens = tokens.filter(token =>
48
- token.name.startsWith(spacingTokenPrefix),
49
- );
50
-
51
- const activeTokens = onlySpaceTokens.map(t => ({
52
- name: t.name,
53
- fallback: t.attributes.pixelValue!,
54
- }));
55
-
56
- export const createSpacingStylesFromTemplate = (
57
- spacingProperty: keyof typeof spacingProperties,
58
- ) => {
59
- if (!spacingProperties[spacingProperty]) {
60
- throw new Error(`[codegen] Unknown option found "${spacingProperty}"`);
61
- }
62
-
63
- const { cssProperties, propNameFormatter } =
64
- spacingProperties[spacingProperty]!;
65
-
66
- return prettier.format(
67
- `
68
- export const ${spacingProperty}Map = {
69
- ${activeTokens
70
- .sort((a, b) =>
71
- a.name.localeCompare(b.name, undefined, { numeric: true }),
9
+ const spaceTokens = tokens
10
+ .filter(token => token.name.startsWith(spacingTokenPrefix))
11
+ .map(t => ({
12
+ name: t.name,
13
+ fallback: t.attributes.pixelValue!,
14
+ }));
15
+
16
+ export const createSpacingStylesFromTemplate = () => {
17
+ const output = [
18
+ `export const spaceMap = {\n${spaceTokens
19
+ .map(
20
+ ({ name, fallback }) =>
21
+ `'${name}': ${constructTokenFunctionCall(name, fallback)},`,
72
22
  )
73
- .map(token => {
74
- const propName = propNameFormatter
75
- ? propNameFormatter(token.name)
76
- : token.name;
77
- return `'${propName}': ${constructTokenFunctionCall(
78
- token.name,
79
- token.fallback,
80
- )}`;
81
- })}
82
- } as const;` +
83
- (cssProperties
84
- .map(
85
- cssProperty =>
86
- // TODO: Update to use `keyof` when ERT supports it: https://github.com/atlassian/extract-react-types/issues/149
87
- `\nexport type ${capitalize(cssProperty)} = ${activeTokens
88
- .map(token => `'${token.name}'`)
89
- .join(' | ')}`,
90
- )
91
- .join('') +
92
- '\n'),
93
- {
94
- singleQuote: true,
95
- trailingComma: 'all',
96
- parser: 'typescript',
97
- plugins: [parserTypeScript],
98
- },
99
- );
23
+ .join('\n')}}`,
24
+ `export type Space = keyof typeof spaceMap;\n`,
25
+ ].join('\n');
26
+
27
+ return prettier.format(output, {
28
+ singleQuote: true,
29
+ trailingComma: 'all',
30
+ parser: 'typescript',
31
+ plugins: [parserTypeScript],
32
+ });
100
33
  };
@@ -6,9 +6,9 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/components/stack.d.ts",
8
8
  "typesVersions": {
9
- ">=4.0 <4.5": {
9
+ ">=4.5 <4.9": {
10
10
  "*": [
11
- "../dist/types-ts4.0/components/stack.d.ts"
11
+ "../dist/types-ts4.5/components/stack.d.ts"
12
12
  ]
13
13
  }
14
14
  }