@atlaskit/tokens 1.49.0 → 1.50.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +1589 -1591
  2. package/README.md +14 -8
  3. package/codemods/css-to-design-tokens/lib/colors.tsx +47 -49
  4. package/codemods/css-to-design-tokens/lib/declaration.tsx +26 -26
  5. package/codemods/css-to-design-tokens/lib/legacy-colors.tsx +326 -326
  6. package/codemods/css-to-design-tokens/lib/meta.tsx +116 -122
  7. package/codemods/css-to-design-tokens/lib/tokens.tsx +28 -35
  8. package/codemods/css-to-design-tokens/lib/value.tsx +70 -72
  9. package/codemods/css-to-design-tokens/transform.tsx +68 -72
  10. package/codemods/hypermod.config.tsx +5 -5
  11. package/codemods/remove-fallbacks-color/transform.tsx +16 -18
  12. package/codemods/theme-to-design-tokens/transform.tsx +505 -588
  13. package/codemods/theme-to-design-tokens/utils/ast-meta.tsx +139 -147
  14. package/codemods/theme-to-design-tokens/utils/ast.tsx +23 -34
  15. package/codemods/theme-to-design-tokens/utils/color.tsx +25 -26
  16. package/codemods/theme-to-design-tokens/utils/css-utils.tsx +27 -30
  17. package/codemods/theme-to-design-tokens/utils/fuzzy-search.tsx +272 -290
  18. package/codemods/theme-to-design-tokens/utils/legacy-colors.tsx +224 -224
  19. package/codemods/theme-to-design-tokens/utils/named-colors.tsx +148 -148
  20. package/codemods/theme-to-design-tokens/utils/string-utils.tsx +10 -16
  21. package/codemods/utils/tokens.tsx +371 -371
  22. package/dist/cjs/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
  23. package/dist/cjs/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
  24. package/dist/cjs/artifacts/generated-pairs.js +1 -1
  25. package/dist/cjs/artifacts/palettes-raw/typography-palette.js +45 -30
  26. package/dist/cjs/artifacts/theme-import-map.js +1 -1
  27. package/dist/cjs/artifacts/themes/atlassian-typography-minor3.js +2 -2
  28. package/dist/cjs/artifacts/token-default-values.js +1 -1
  29. package/dist/cjs/artifacts/token-names.js +1 -1
  30. package/dist/cjs/artifacts/tokens-raw/atlassian-typography-adg3.js +20 -20
  31. package/dist/cjs/artifacts/tokens-raw/atlassian-typography-minor3.js +13 -13
  32. package/dist/es2019/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
  33. package/dist/es2019/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
  34. package/dist/es2019/artifacts/generated-pairs.js +1 -1
  35. package/dist/es2019/artifacts/palettes-raw/typography-palette.js +45 -30
  36. package/dist/es2019/artifacts/theme-import-map.js +1 -1
  37. package/dist/es2019/artifacts/themes/atlassian-typography-minor3.js +2 -2
  38. package/dist/es2019/artifacts/token-default-values.js +1 -1
  39. package/dist/es2019/artifacts/token-names.js +1 -1
  40. package/dist/es2019/artifacts/tokens-raw/atlassian-typography-adg3.js +20 -20
  41. package/dist/es2019/artifacts/tokens-raw/atlassian-typography-minor3.js +13 -13
  42. package/dist/esm/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
  43. package/dist/esm/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
  44. package/dist/esm/artifacts/generated-pairs.js +1 -1
  45. package/dist/esm/artifacts/palettes-raw/typography-palette.js +45 -30
  46. package/dist/esm/artifacts/theme-import-map.js +1 -1
  47. package/dist/esm/artifacts/themes/atlassian-typography-minor3.js +2 -2
  48. package/dist/esm/artifacts/token-default-values.js +1 -1
  49. package/dist/esm/artifacts/token-names.js +1 -1
  50. package/dist/esm/artifacts/tokens-raw/atlassian-typography-adg3.js +20 -20
  51. package/dist/esm/artifacts/tokens-raw/atlassian-typography-minor3.js +13 -13
  52. package/dist/types/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +1 -1
  53. package/dist/types/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +1 -1
  54. package/dist/types/artifacts/generated-pairs.d.ts +1 -1
  55. package/dist/types/artifacts/palettes-raw/typography-palette.d.ts +1 -1
  56. package/dist/types/artifacts/theme-import-map.d.ts +2 -2
  57. package/dist/types/artifacts/themes/atlassian-typography-minor3.d.ts +2 -2
  58. package/dist/types/artifacts/token-default-values.d.ts +1 -1
  59. package/dist/types/artifacts/token-names.d.ts +1 -1
  60. package/dist/types/artifacts/tokens-raw/atlassian-typography-adg3.d.ts +1 -1
  61. package/dist/types/artifacts/tokens-raw/atlassian-typography-minor3.d.ts +1 -1
  62. package/dist/types/artifacts/types-internal.d.ts +1 -1
  63. package/dist/types/artifacts/types.d.ts +1 -1
  64. package/dist/types/babel-plugin/plugin.d.ts +1 -1
  65. package/dist/types/custom-theme.d.ts +2 -2
  66. package/dist/types/enable-global-theme.d.ts +2 -2
  67. package/dist/types/entry-points/css-type-schema.codegen.d.ts +1 -1
  68. package/dist/types/entry-points/token-ids.d.ts +1 -1
  69. package/dist/types/get-global-theme.d.ts +1 -1
  70. package/dist/types/get-ssr-auto-script.d.ts +1 -1
  71. package/dist/types/get-theme-html-attrs.d.ts +1 -1
  72. package/dist/types/get-theme-styles.d.ts +1 -1
  73. package/dist/types/get-token.d.ts +1 -1
  74. package/dist/types/index.d.ts +1 -1
  75. package/dist/types/load-custom-theme-styles.d.ts +1 -1
  76. package/dist/types/set-global-theme.d.ts +2 -2
  77. package/dist/types/theme-state-transformer.d.ts +1 -1
  78. package/dist/types/utils/color-detection.d.ts +1 -1
  79. package/dist/types/utils/color-mode-listeners.d.ts +1 -1
  80. package/dist/types/utils/configure-page.d.ts +1 -1
  81. package/dist/types/utils/contrast-mode-listeners.d.ts +1 -1
  82. package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -1
  83. package/dist/types/utils/custom-theme-token-contrast-check.d.ts +1 -1
  84. package/dist/types/utils/generate-custom-color-ramp.d.ts +2 -2
  85. package/dist/types/utils/get-increased-contrast-theme.d.ts +1 -1
  86. package/dist/types/utils/get-theme-preferences.d.ts +1 -1
  87. package/dist/types/utils/theme-loading.d.ts +1 -1
  88. package/dist/types-ts4.5/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +1 -1
  89. package/dist/types-ts4.5/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +1 -1
  90. package/dist/types-ts4.5/artifacts/generated-pairs.d.ts +1 -1
  91. package/dist/types-ts4.5/artifacts/palettes-raw/typography-palette.d.ts +1 -1
  92. package/dist/types-ts4.5/artifacts/theme-import-map.d.ts +2 -2
  93. package/dist/types-ts4.5/artifacts/themes/atlassian-typography-minor3.d.ts +2 -2
  94. package/dist/types-ts4.5/artifacts/token-default-values.d.ts +1 -1
  95. package/dist/types-ts4.5/artifacts/token-names.d.ts +1 -1
  96. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-typography-adg3.d.ts +1 -1
  97. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-typography-minor3.d.ts +1 -1
  98. package/dist/types-ts4.5/artifacts/types-internal.d.ts +1 -1
  99. package/dist/types-ts4.5/artifacts/types.d.ts +1 -1
  100. package/dist/types-ts4.5/babel-plugin/plugin.d.ts +1 -1
  101. package/dist/types-ts4.5/custom-theme.d.ts +2 -2
  102. package/dist/types-ts4.5/enable-global-theme.d.ts +2 -2
  103. package/dist/types-ts4.5/entry-points/css-type-schema.codegen.d.ts +1 -1
  104. package/dist/types-ts4.5/entry-points/token-ids.d.ts +1 -1
  105. package/dist/types-ts4.5/get-global-theme.d.ts +1 -1
  106. package/dist/types-ts4.5/get-ssr-auto-script.d.ts +1 -1
  107. package/dist/types-ts4.5/get-theme-html-attrs.d.ts +1 -1
  108. package/dist/types-ts4.5/get-theme-styles.d.ts +1 -1
  109. package/dist/types-ts4.5/get-token.d.ts +1 -1
  110. package/dist/types-ts4.5/index.d.ts +1 -1
  111. package/dist/types-ts4.5/load-custom-theme-styles.d.ts +1 -1
  112. package/dist/types-ts4.5/set-global-theme.d.ts +2 -2
  113. package/dist/types-ts4.5/theme-state-transformer.d.ts +1 -1
  114. package/dist/types-ts4.5/utils/color-detection.d.ts +1 -1
  115. package/dist/types-ts4.5/utils/color-mode-listeners.d.ts +1 -1
  116. package/dist/types-ts4.5/utils/configure-page.d.ts +1 -1
  117. package/dist/types-ts4.5/utils/contrast-mode-listeners.d.ts +1 -1
  118. package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -1
  119. package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +1 -1
  120. package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +2 -2
  121. package/dist/types-ts4.5/utils/get-increased-contrast-theme.d.ts +1 -1
  122. package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +1 -1
  123. package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -1
  124. package/package.json +3 -5
  125. package/report.api.md +2071 -2090
@@ -1,13 +1,9 @@
1
1
  import type { FileInfo } from 'jscodeshift';
2
- import postcss, { Plugin } from 'postcss';
2
+ import postcss, { type Plugin } from 'postcss';
3
3
  // @ts-ignore
4
4
  import lessSyntax from 'postcss-less';
5
5
 
6
- import {
7
- isColorRelatedProperty,
8
- isCssDeclaration,
9
- splitCssValue,
10
- } from './lib/declaration';
6
+ import { isColorRelatedProperty, isCssDeclaration, splitCssValue } from './lib/declaration';
11
7
  import { getBaseDeclarationMeta } from './lib/meta';
12
8
  import findToken from './lib/tokens';
13
9
  import parseValue from './lib/value';
@@ -17,83 +13,83 @@ const POSTCSS_OPTIONS = { syntax: lessSyntax, from: undefined };
17
13
  // https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md
18
14
  // https://astexplorer.net/#/2uBU1BLuJ1
19
15
  const plugin = (): Plugin => {
20
- const processed = Symbol('processed');
16
+ const processed = Symbol('processed');
21
17
 
22
- return {
23
- postcssPlugin: 'UsingTokens',
24
- AtRule(atRule) {
25
- // @ts-expect-error
26
- if (atRule[processed]) {
27
- return;
28
- }
18
+ return {
19
+ postcssPlugin: 'UsingTokens',
20
+ AtRule(atRule) {
21
+ // @ts-expect-error
22
+ if (atRule[processed]) {
23
+ return;
24
+ }
29
25
 
30
- // @ts-expect-error: The 'variable' property does not exist on 'AtRule' according to the TypeScript definitions.
31
- // However, the 'postcss-less' library adds a 'variable' property to 'AtRule' when parsing LESS variables.
32
- // This property indicates whether the 'AtRule' is a LESS variable.
33
- if (atRule.variable) {
34
- // TODO https://hello.atlassian.net/browse/DCA11Y-637
35
- }
26
+ // @ts-expect-error: The 'variable' property does not exist on 'AtRule' according to the TypeScript definitions.
27
+ // However, the 'postcss-less' library adds a 'variable' property to 'AtRule' when parsing LESS variables.
28
+ // This property indicates whether the 'AtRule' is a LESS variable.
29
+ if (atRule.variable) {
30
+ // TODO https://hello.atlassian.net/browse/DCA11Y-637
31
+ }
36
32
 
37
- // @ts-expect-error
38
- atRule[processed] = true;
39
- },
40
- Declaration: (decl) => {
41
- // @ts-expect-error
42
- if (decl[processed]) {
43
- return;
44
- }
45
- if (decl.value === 'none') {
46
- return;
47
- }
33
+ // @ts-expect-error
34
+ atRule[processed] = true;
35
+ },
36
+ Declaration: (decl) => {
37
+ // @ts-expect-error
38
+ if (decl[processed]) {
39
+ return;
40
+ }
41
+ if (decl.value === 'none') {
42
+ return;
43
+ }
48
44
 
49
- const baseMeta = getBaseDeclarationMeta(decl);
45
+ const baseMeta = getBaseDeclarationMeta(decl);
50
46
 
51
- if (isCssDeclaration(decl.prop)) {
52
- // TODO https://hello.atlassian.net/browse/DCA11Y-637
53
- }
47
+ if (isCssDeclaration(decl.prop)) {
48
+ // TODO https://hello.atlassian.net/browse/DCA11Y-637
49
+ }
54
50
 
55
- if (isColorRelatedProperty(decl.prop)) {
56
- const values = splitCssValue(decl.value);
57
- if (!values) {
58
- return;
59
- }
51
+ if (isColorRelatedProperty(decl.prop)) {
52
+ const values = splitCssValue(decl.value);
53
+ if (!values) {
54
+ return;
55
+ }
60
56
 
61
- switch (decl.prop) {
62
- case 'box-shadow':
63
- const meta = values.reduce((acc: string[], curr: string) => {
64
- const parsedValue = parseValue(curr);
65
- if (!parsedValue) {
66
- return acc;
67
- }
68
- return [...acc, ...parsedValue.getMeta()];
69
- }, baseMeta);
57
+ switch (decl.prop) {
58
+ case 'box-shadow':
59
+ const meta = values.reduce((acc: string[], curr: string) => {
60
+ const parsedValue = parseValue(curr);
61
+ if (!parsedValue) {
62
+ return acc;
63
+ }
64
+ return [...acc, ...parsedValue.getMeta()];
65
+ }, baseMeta);
70
66
 
71
- const token = findToken(meta);
72
- decl.value = `var(${token}, ${decl.value})`;
73
- break;
74
- default:
75
- const replacedValues = values.map((value) => {
76
- const parsedValue = parseValue(value);
77
- if (!parsedValue) {
78
- return value;
79
- }
67
+ const token = findToken(meta);
68
+ decl.value = `var(${token}, ${decl.value})`;
69
+ break;
70
+ default:
71
+ const replacedValues = values.map((value) => {
72
+ const parsedValue = parseValue(value);
73
+ if (!parsedValue) {
74
+ return value;
75
+ }
80
76
 
81
- return parsedValue.getReplacement(baseMeta);
82
- });
83
- decl.value = replacedValues.join(' ');
84
- break;
85
- }
86
- }
77
+ return parsedValue.getReplacement(baseMeta);
78
+ });
79
+ decl.value = replacedValues.join(' ');
80
+ break;
81
+ }
82
+ }
87
83
 
88
- // @ts-expect-error
89
- decl[processed] = true;
90
- },
91
- };
84
+ // @ts-expect-error
85
+ decl[processed] = true;
86
+ },
87
+ };
92
88
  };
93
89
 
94
90
  export default async function transformer(file: FileInfo | string) {
95
- const processor = postcss([plugin()]);
96
- const src = typeof file === 'string' ? file : file.source;
97
- const { css } = await processor.process(src, POSTCSS_OPTIONS);
98
- return css;
91
+ const processor = postcss([plugin()]);
92
+ const src = typeof file === 'string' ? file : file.source;
93
+ const { css } = await processor.process(src, POSTCSS_OPTIONS);
94
+ return css;
99
95
  }
@@ -3,9 +3,9 @@ import removeFallbacksColor from './remove-fallbacks-color/transform';
3
3
  import themeToDesignTokens from './theme-to-design-tokens/transform';
4
4
 
5
5
  export default {
6
- presets: {
7
- 'theme-to-design-tokens': themeToDesignTokens,
8
- 'css-to-design-tokens': cssToDesignTokens,
9
- 'remove-fallbacks-color': removeFallbacksColor,
10
- },
6
+ presets: {
7
+ 'theme-to-design-tokens': themeToDesignTokens,
8
+ 'css-to-design-tokens': cssToDesignTokens,
9
+ 'remove-fallbacks-color': removeFallbacksColor,
10
+ },
11
11
  };
@@ -2,25 +2,23 @@ import { hasImportDeclaration } from '@hypermod/utils';
2
2
  import type { API, FileInfo } from 'jscodeshift';
3
3
 
4
4
  export default async function transformer(file: FileInfo, api: API) {
5
- const j = api.jscodeshift;
6
- const source = j(file.source);
5
+ const j = api.jscodeshift;
6
+ const source = j(file.source);
7
7
 
8
- if (!hasImportDeclaration(j, source, '@atlaskit/tokens')) {
9
- return file.source;
10
- }
8
+ if (!hasImportDeclaration(j, source, '@atlaskit/tokens')) {
9
+ return file.source;
10
+ }
11
11
 
12
- source
13
- .find(j.CallExpression, { callee: { name: 'token' } })
14
- .forEach((path) => {
15
- if (
16
- path.node.arguments.length > 1 &&
17
- j.StringLiteral.check(path.node.arguments[0]) &&
18
- /^color\.|elevation/.test(path.node.arguments[0].value)
19
- ) {
20
- // Remove the second argument
21
- path.node.arguments.splice(1, 1);
22
- }
23
- });
12
+ source.find(j.CallExpression, { callee: { name: 'token' } }).forEach((path) => {
13
+ if (
14
+ path.node.arguments.length > 1 &&
15
+ j.StringLiteral.check(path.node.arguments[0]) &&
16
+ /^color\.|elevation/.test(path.node.arguments[0].value)
17
+ ) {
18
+ // Remove the second argument
19
+ path.node.arguments.splice(1, 1);
20
+ }
21
+ });
24
22
 
25
- return source.toSource();
23
+ return source.toSource();
26
24
  }