@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
@@ -3,171 +3,165 @@ import type { Declaration, Node, Rule } from 'postcss';
3
3
  import { uniqueWordsFromTokens } from '../../utils/tokens';
4
4
 
5
5
  import { extractCssVarName } from './declaration';
6
- import {
7
- knownNamedColors,
8
- knownRawColors,
9
- knownVariables,
10
- } from './legacy-colors';
6
+ import { knownNamedColors, knownRawColors, knownVariables } from './legacy-colors';
11
7
 
12
8
  function filterDuplicateFoundations(meta: string[]) {
13
- const foundations = ['text', 'background', 'shadow', 'border'];
14
- let hasFoundation = false;
9
+ const foundations = ['text', 'background', 'shadow', 'border'];
10
+ let hasFoundation = false;
15
11
 
16
- return meta.filter((val) => {
17
- if (!hasFoundation && foundations.includes(val)) {
18
- hasFoundation = true;
19
- return true;
20
- }
12
+ return meta.filter((val) => {
13
+ if (!hasFoundation && foundations.includes(val)) {
14
+ hasFoundation = true;
15
+ return true;
16
+ }
21
17
 
22
- if (hasFoundation && foundations.includes(val)) {
23
- return false;
24
- }
18
+ if (hasFoundation && foundations.includes(val)) {
19
+ return false;
20
+ }
25
21
 
26
- return true;
27
- });
22
+ return true;
23
+ });
28
24
  }
29
25
 
30
26
  const REPLACEMENTS: Record<string, string> = {
31
- ':': '',
32
- ',': '',
33
- texts: 'text',
34
- error: 'danger',
35
- invalid: 'danger',
36
- removed: 'danger',
37
- removal: 'danger',
38
- remove: 'danger',
39
- focus: 'focused',
40
- valid: 'success',
41
- successful: 'success',
42
- risk: 'warning',
43
- caution: 'warning',
44
- warn: 'warning',
45
- primary: 'bold',
46
- info: 'bold',
47
- secondary: 'subtle',
48
- hyperlink: 'link',
49
- anchor: 'link',
50
- active: 'pressed',
51
- hover: 'hovered',
52
- dragged: 'overlay',
53
- dragging: 'overlay',
54
- drag: 'overlay',
55
- 'background-color': 'background',
56
- color: 'text',
57
- icons: 'icon',
58
- arrow: 'icon',
59
- glyph: 'icon',
60
- stroke: 'border',
61
- 'border-left': 'border',
62
- 'border-right': 'border',
63
- 'border-top': 'border',
64
- 'border-bottom': 'border',
65
- 'box-shadow': 'shadow',
27
+ ':': '',
28
+ ',': '',
29
+ texts: 'text',
30
+ error: 'danger',
31
+ invalid: 'danger',
32
+ removed: 'danger',
33
+ removal: 'danger',
34
+ remove: 'danger',
35
+ focus: 'focused',
36
+ valid: 'success',
37
+ successful: 'success',
38
+ risk: 'warning',
39
+ caution: 'warning',
40
+ warn: 'warning',
41
+ primary: 'bold',
42
+ info: 'bold',
43
+ secondary: 'subtle',
44
+ hyperlink: 'link',
45
+ anchor: 'link',
46
+ active: 'pressed',
47
+ hover: 'hovered',
48
+ dragged: 'overlay',
49
+ dragging: 'overlay',
50
+ drag: 'overlay',
51
+ 'background-color': 'background',
52
+ color: 'text',
53
+ icons: 'icon',
54
+ arrow: 'icon',
55
+ glyph: 'icon',
56
+ stroke: 'border',
57
+ 'border-left': 'border',
58
+ 'border-right': 'border',
59
+ 'border-top': 'border',
60
+ 'border-bottom': 'border',
61
+ 'box-shadow': 'shadow',
66
62
  };
67
63
  const ADDITIONAL_META: Record<string, string> = {
68
- grey: 'neutral',
69
- red: 'danger',
64
+ grey: 'neutral',
65
+ red: 'danger',
70
66
  };
71
67
 
72
68
  export function cleanMeta(meta: string[]) {
73
- const cleanMeta = meta
74
- .reduce(
75
- (accum: string[], val: string) => [
76
- ...accum,
77
- ...(typeof val === 'string'
78
- ? val.split(/(?=[A-Z])/g).map((e) => e.toLowerCase())
79
- : []),
80
- ],
81
- [],
82
- )
83
- .reduce((accum: string[], val: string) => {
84
- if (val in ADDITIONAL_META) {
85
- accum.push(val, ADDITIONAL_META[val]);
86
- } else {
87
- accum.push(val);
88
- }
89
- accum.push(val in REPLACEMENTS ? REPLACEMENTS[val] : val);
90
-
91
- return accum;
92
- }, [])
93
- .filter((val: string) => uniqueWordsFromTokens.includes(val))
94
- .reduce((accum: string[], val: string) => {
95
- if (!accum.includes(val)) {
96
- accum.push(val);
97
- }
98
-
99
- return accum;
100
- }, []);
101
-
102
- return filterDuplicateFoundations(cleanMeta);
69
+ const cleanMeta = meta
70
+ .reduce(
71
+ (accum: string[], val: string) => [
72
+ ...accum,
73
+ ...(typeof val === 'string' ? val.split(/(?=[A-Z])/g).map((e) => e.toLowerCase()) : []),
74
+ ],
75
+ [],
76
+ )
77
+ .reduce((accum: string[], val: string) => {
78
+ if (val in ADDITIONAL_META) {
79
+ accum.push(val, ADDITIONAL_META[val]);
80
+ } else {
81
+ accum.push(val);
82
+ }
83
+ accum.push(val in REPLACEMENTS ? REPLACEMENTS[val] : val);
84
+
85
+ return accum;
86
+ }, [])
87
+ .filter((val: string) => uniqueWordsFromTokens.includes(val))
88
+ .reduce((accum: string[], val: string) => {
89
+ if (!accum.includes(val)) {
90
+ accum.push(val);
91
+ }
92
+
93
+ return accum;
94
+ }, []);
95
+
96
+ return filterDuplicateFoundations(cleanMeta);
103
97
  }
104
98
 
105
99
  export function getBaseDeclarationMeta(decl: Declaration): string[] {
106
- const parentSelectors = getParentSelectors(decl)
107
- .split(/\-|\.|\,|\ |\:|\&/)
108
- .filter(Boolean);
100
+ const parentSelectors = getParentSelectors(decl)
101
+ .split(/\-|\.|\,|\ |\:|\&/)
102
+ .filter(Boolean);
109
103
 
110
- return [getPropertyMeta(decl.prop), ...parentSelectors];
104
+ return [getPropertyMeta(decl.prop), ...parentSelectors];
111
105
  }
112
106
 
113
107
  function getPropertyMeta(prop: string) {
114
- if (prop === 'color') {
115
- return 'text';
116
- }
108
+ if (prop === 'color') {
109
+ return 'text';
110
+ }
117
111
 
118
- if (prop.startsWith('background')) {
119
- return 'background';
120
- }
112
+ if (prop.startsWith('background')) {
113
+ return 'background';
114
+ }
121
115
 
122
- if (prop.includes('shadow')) {
123
- return 'shadow';
124
- }
116
+ if (prop.includes('shadow')) {
117
+ return 'shadow';
118
+ }
125
119
 
126
- if (prop.includes('border')) {
127
- return 'border';
128
- }
120
+ if (prop.includes('border')) {
121
+ return 'border';
122
+ }
129
123
 
130
- return '';
124
+ return '';
131
125
  }
132
126
 
133
127
  function isRule(node: Node): node is Rule {
134
- return node.type === 'rule';
128
+ return node.type === 'rule';
135
129
  }
136
130
 
137
131
  function getParentSelectors(node: Node): string {
138
- if (isRule(node)) {
139
- // @ts-expect-error
140
- return getParentSelectors(node.parent) + ' ' + node.selector;
141
- }
132
+ if (isRule(node)) {
133
+ // @ts-expect-error
134
+ return getParentSelectors(node.parent) + ' ' + node.selector;
135
+ }
142
136
 
143
- if (node.parent) {
144
- return getParentSelectors(node.parent);
145
- }
137
+ if (node.parent) {
138
+ return getParentSelectors(node.parent);
139
+ }
146
140
 
147
- return '';
141
+ return '';
148
142
  }
149
143
 
150
144
  export function getCssVarMeta(cssVariable: string) {
151
- const tokenName = extractCssVarName(cssVariable);
152
- const meta = knownVariables[tokenName];
145
+ const tokenName = extractCssVarName(cssVariable);
146
+ const meta = knownVariables[tokenName];
153
147
 
154
- if (!meta || meta.length === 0) {
155
- return tokenName.split('-');
156
- }
148
+ if (!meta || meta.length === 0) {
149
+ return tokenName.split('-');
150
+ }
157
151
 
158
- return meta;
152
+ return meta;
159
153
  }
160
154
 
161
155
  export function getRawColorMeta(rawColor: string) {
162
- let cleanColor = rawColor.toLowerCase();
156
+ let cleanColor = rawColor.toLowerCase();
163
157
 
164
- if (cleanColor.length === 4) {
165
- cleanColor = cleanColor + cleanColor.substring(cleanColor.indexOf('#') + 1);
166
- }
158
+ if (cleanColor.length === 4) {
159
+ cleanColor = cleanColor + cleanColor.substring(cleanColor.indexOf('#') + 1);
160
+ }
167
161
 
168
- return knownRawColors[cleanColor] ?? [];
162
+ return knownRawColors[cleanColor] ?? [];
169
163
  }
170
164
 
171
165
  export function getNamedColorMeta(namedColor: string) {
172
- return knownNamedColors[namedColor] ?? [];
166
+ return knownNamedColors[namedColor] ?? [];
173
167
  }
@@ -4,51 +4,44 @@ import { activeTokens } from '../../utils/tokens';
4
4
  import { cleanMeta } from './meta';
5
5
 
6
6
  const COLOR_TOKEN_SEARCH_TYPES = [
7
- 'text',
8
- 'link',
9
- 'icon',
10
- 'border',
11
- 'background',
12
- 'blanket',
13
- 'skeleton',
14
- 'chart',
15
- 'surface',
16
- 'shadow',
7
+ 'text',
8
+ 'link',
9
+ 'icon',
10
+ 'border',
11
+ 'background',
12
+ 'blanket',
13
+ 'skeleton',
14
+ 'chart',
15
+ 'surface',
16
+ 'shadow',
17
17
  ];
18
18
 
19
19
  function filterTokens(meta: string[]) {
20
- const commonSearchTypes = COLOR_TOKEN_SEARCH_TYPES.filter((type) =>
21
- meta.includes(type),
22
- );
23
- return commonSearchTypes.length !== 0
24
- ? activeTokens.filter((token) =>
25
- commonSearchTypes.some(
26
- (type) =>
27
- token.startsWith(`color.${type}`) ||
28
- token.startsWith(`elevation.${type}`),
29
- ),
30
- )
31
- : activeTokens;
20
+ const commonSearchTypes = COLOR_TOKEN_SEARCH_TYPES.filter((type) => meta.includes(type));
21
+ return commonSearchTypes.length !== 0
22
+ ? activeTokens.filter((token) =>
23
+ commonSearchTypes.some(
24
+ (type) => token.startsWith(`color.${type}`) || token.startsWith(`elevation.${type}`),
25
+ ),
26
+ )
27
+ : activeTokens;
32
28
  }
33
29
 
34
30
  function tokenToVar(token: string) {
35
- return `--ds-${token
36
- .replace(/\./g, '-')
37
- .replace('color-', '')
38
- .replace('elevation-', '')}`;
31
+ return `--ds-${token.replace(/\./g, '-').replace('color-', '').replace('elevation-', '')}`;
39
32
  }
40
33
 
41
34
  export default function findToken(meta: string[]) {
42
- const filteredTokens = filterTokens(meta);
43
- const tokenFuzzySearch = Search(filteredTokens, false);
44
- const cleanSearchTerms = cleanMeta(meta).join(' ');
45
- const results: string[] = tokenFuzzySearch.get(cleanSearchTerms);
35
+ const filteredTokens = filterTokens(meta);
36
+ const tokenFuzzySearch = Search(filteredTokens, false);
37
+ const cleanSearchTerms = cleanMeta(meta).join(' ');
38
+ const results: string[] = tokenFuzzySearch.get(cleanSearchTerms);
46
39
 
47
- if (!results || results.length === 0) {
48
- return 'MISSING_TOKEN';
49
- }
40
+ if (!results || results.length === 0) {
41
+ return 'MISSING_TOKEN';
42
+ }
50
43
 
51
- const candidates = results.map((result) => result[1]);
44
+ const candidates = results.map((result) => result[1]);
52
45
 
53
- return tokenToVar(candidates[0]);
46
+ return tokenToVar(candidates[0]);
54
47
  }
@@ -1,85 +1,83 @@
1
1
  import {
2
- extractBetweenParentheses,
3
- isGradient,
4
- isKnownCssVariable,
5
- isLessFunction,
6
- isNamedColor,
7
- isRawColor,
2
+ extractBetweenParentheses,
3
+ isGradient,
4
+ isKnownCssVariable,
5
+ isLessFunction,
6
+ isNamedColor,
7
+ isRawColor,
8
8
  } from './colors';
9
9
  import { extractCssVarName } from './declaration';
10
10
  import { getCssVarMeta, getNamedColorMeta, getRawColorMeta } from './meta';
11
11
  import findToken from './tokens';
12
12
 
13
13
  interface Value {
14
- getReplacement: (additionalMeta?: string[]) => string;
15
- getMeta: () => string[];
14
+ getReplacement: (additionalMeta?: string[]) => string;
15
+ getMeta: () => string[];
16
16
  }
17
17
 
18
18
  export default function parseValue(value: string): Value | null {
19
- if (isLessFunction(value)) {
20
- // eslint-disable-next-line no-console
21
- console.warn(
22
- 'Cannot parse - less function detected, would cause compilation error',
23
- );
24
- return null;
25
- }
26
- if (isGradient(value)) {
27
- return {
28
- getReplacement(additionalMeta = []) {
29
- const gradientContent = extractBetweenParentheses(value);
30
- const values = gradientContent.split(',');
31
- const replacedValues = values.map((val) => {
32
- const parsedValue = parseValue(val.trim());
33
- return parsedValue ? parsedValue.getReplacement(additionalMeta) : val;
34
- });
35
- return value.replace(gradientContent, replacedValues.join(', '));
36
- },
37
- getMeta() {
38
- const BASE_META: string[] = [];
39
- const gradientContent = extractBetweenParentheses(value);
40
- const values = gradientContent.split(',');
41
- const metas = values.reduce((acc, val) => {
42
- const parsedValue = parseValue(val.trim());
43
- return parsedValue ? [...acc, ...parsedValue.getMeta()] : acc;
44
- }, BASE_META);
45
- return metas;
46
- },
47
- };
48
- }
49
- if (isKnownCssVariable(extractCssVarName(value))) {
50
- return {
51
- getReplacement(additionalMeta = []) {
52
- const token = findToken([...additionalMeta, ...this.getMeta()]);
53
- return `var(${token}, ${value})`;
54
- },
55
- getMeta() {
56
- return getCssVarMeta(value);
57
- },
58
- };
59
- }
60
- if (isRawColor(value)) {
61
- return {
62
- getReplacement(additionalMeta = []) {
63
- const token = findToken([...additionalMeta, ...this.getMeta()]);
64
- return `var(${token}, ${value})`;
65
- },
66
- getMeta() {
67
- return getRawColorMeta(value);
68
- },
69
- };
70
- }
19
+ if (isLessFunction(value)) {
20
+ // eslint-disable-next-line no-console
21
+ console.warn('Cannot parse - less function detected, would cause compilation error');
22
+ return null;
23
+ }
24
+ if (isGradient(value)) {
25
+ return {
26
+ getReplacement(additionalMeta = []) {
27
+ const gradientContent = extractBetweenParentheses(value);
28
+ const values = gradientContent.split(',');
29
+ const replacedValues = values.map((val) => {
30
+ const parsedValue = parseValue(val.trim());
31
+ return parsedValue ? parsedValue.getReplacement(additionalMeta) : val;
32
+ });
33
+ return value.replace(gradientContent, replacedValues.join(', '));
34
+ },
35
+ getMeta() {
36
+ const BASE_META: string[] = [];
37
+ const gradientContent = extractBetweenParentheses(value);
38
+ const values = gradientContent.split(',');
39
+ const metas = values.reduce((acc, val) => {
40
+ const parsedValue = parseValue(val.trim());
41
+ return parsedValue ? [...acc, ...parsedValue.getMeta()] : acc;
42
+ }, BASE_META);
43
+ return metas;
44
+ },
45
+ };
46
+ }
47
+ if (isKnownCssVariable(extractCssVarName(value))) {
48
+ return {
49
+ getReplacement(additionalMeta = []) {
50
+ const token = findToken([...additionalMeta, ...this.getMeta()]);
51
+ return `var(${token}, ${value})`;
52
+ },
53
+ getMeta() {
54
+ return getCssVarMeta(value);
55
+ },
56
+ };
57
+ }
58
+ if (isRawColor(value)) {
59
+ return {
60
+ getReplacement(additionalMeta = []) {
61
+ const token = findToken([...additionalMeta, ...this.getMeta()]);
62
+ return `var(${token}, ${value})`;
63
+ },
64
+ getMeta() {
65
+ return getRawColorMeta(value);
66
+ },
67
+ };
68
+ }
71
69
 
72
- if (isNamedColor(value)) {
73
- return {
74
- getReplacement(additionalMeta = []) {
75
- const token = findToken([...additionalMeta, ...this.getMeta()]);
76
- return `var(${token}, ${value})`;
77
- },
78
- getMeta() {
79
- return getNamedColorMeta(value);
80
- },
81
- };
82
- }
70
+ if (isNamedColor(value)) {
71
+ return {
72
+ getReplacement(additionalMeta = []) {
73
+ const token = findToken([...additionalMeta, ...this.getMeta()]);
74
+ return `var(${token}, ${value})`;
75
+ },
76
+ getMeta() {
77
+ return getNamedColorMeta(value);
78
+ },
79
+ };
80
+ }
83
81
 
84
- return null;
82
+ return null;
85
83
  }