@digdir/designsystemet 1.0.2 → 1.0.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.
Files changed (190) hide show
  1. package/dist/bin/designsystemet.js +4264 -45
  2. package/dist/bin/options.js +5 -4
  3. package/dist/src/colors/colorMetadata.d.ts.map +1 -1
  4. package/dist/src/colors/colorMetadata.js +84 -35
  5. package/dist/src/colors/index.js +470 -4
  6. package/dist/src/colors/theme.d.ts.map +1 -1
  7. package/dist/src/colors/theme.js +290 -18
  8. package/dist/src/colors/types.d.ts +4 -1
  9. package/dist/src/colors/types.d.ts.map +1 -1
  10. package/dist/src/colors/utils.js +16 -15
  11. package/dist/{bin → src}/config.d.ts +46 -1
  12. package/dist/src/config.d.ts.map +1 -0
  13. package/dist/src/config.js +377 -0
  14. package/dist/src/index.js +3666 -2
  15. package/dist/src/migrations/beta-to-v1.js +85 -4
  16. package/dist/src/migrations/codemods/css/plugins.js +5 -4
  17. package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
  18. package/dist/src/migrations/codemods/css/run.js +18 -4
  19. package/dist/src/migrations/color-rename-next49.js +77 -6
  20. package/dist/src/migrations/index.d.ts +0 -1
  21. package/dist/src/migrations/index.d.ts.map +1 -1
  22. package/dist/src/migrations/index.js +461 -6
  23. package/dist/src/scripts/createJsonSchema.js +1608 -4
  24. package/dist/src/scripts/update-design-tokens.d.ts +2 -0
  25. package/dist/src/scripts/update-design-tokens.d.ts.map +1 -0
  26. package/dist/src/scripts/update-design-tokens.js +36 -0
  27. package/dist/src/{tokens/template.d.ts → scripts/update-template.d.ts} +1 -1
  28. package/dist/src/scripts/update-template.d.ts.map +1 -0
  29. package/dist/src/scripts/update-template.js +1200 -0
  30. package/dist/src/tokens/build.d.ts +2 -19
  31. package/dist/src/tokens/build.d.ts.map +1 -1
  32. package/dist/src/tokens/build.js +1511 -70
  33. package/dist/src/tokens/create/defaults.d.ts +7 -0
  34. package/dist/src/tokens/create/defaults.d.ts.map +1 -0
  35. package/dist/src/tokens/create/defaults.js +994 -0
  36. package/dist/src/tokens/create/generators/$designsystemet.d.ts +5 -0
  37. package/dist/src/tokens/create/generators/$designsystemet.d.ts.map +1 -0
  38. package/dist/src/tokens/create/generators/$designsystemet.js +100 -0
  39. package/dist/src/tokens/create/generators/$metadata.d.ts +8 -0
  40. package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -0
  41. package/dist/src/tokens/{write/generate$metadata.js → create/generators/$metadata.js} +3 -2
  42. package/dist/src/tokens/create/generators/$themes.d.ts +12 -0
  43. package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -0
  44. package/dist/src/tokens/create/generators/$themes.js +333 -0
  45. package/dist/src/tokens/create/generators/color.d.ts +5 -0
  46. package/dist/src/tokens/create/generators/color.d.ts.map +1 -0
  47. package/dist/src/tokens/create/generators/color.js +374 -0
  48. package/dist/src/tokens/create/generators/semantic.d.ts +296 -0
  49. package/dist/src/tokens/create/generators/semantic.d.ts.map +1 -0
  50. package/dist/src/tokens/create/generators/semantic.js +483 -0
  51. package/dist/src/tokens/create/generators/theme.d.ts +3 -0
  52. package/dist/src/tokens/create/generators/theme.d.ts.map +1 -0
  53. package/dist/src/tokens/create/generators/theme.js +168 -0
  54. package/dist/src/tokens/create/generators/typography.d.ts +3 -0
  55. package/dist/src/tokens/create/generators/typography.d.ts.map +1 -0
  56. package/dist/src/tokens/create/generators/typography.js +33 -0
  57. package/dist/src/tokens/{write.d.ts → create/write.d.ts} +2 -2
  58. package/dist/src/tokens/create/write.d.ts.map +1 -0
  59. package/dist/src/tokens/create/write.js +546 -0
  60. package/dist/src/tokens/create.d.ts +4 -2
  61. package/dist/src/tokens/create.d.ts.map +1 -1
  62. package/dist/src/tokens/create.js +2049 -59
  63. package/dist/src/tokens/format.d.ts +16 -0
  64. package/dist/src/tokens/format.d.ts.map +1 -0
  65. package/dist/src/tokens/format.js +3514 -0
  66. package/dist/src/tokens/index.d.ts +1 -0
  67. package/dist/src/tokens/index.d.ts.map +1 -1
  68. package/dist/src/tokens/index.js +3526 -2
  69. package/dist/src/tokens/process/configs/color.d.ts +12 -0
  70. package/dist/src/tokens/process/configs/color.d.ts.map +1 -0
  71. package/dist/src/tokens/process/configs/color.js +823 -0
  72. package/dist/src/tokens/process/configs/semantic.d.ts +3 -0
  73. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -0
  74. package/dist/src/tokens/process/configs/semantic.js +367 -0
  75. package/dist/src/tokens/process/configs/shared.d.ts +10 -0
  76. package/dist/src/tokens/process/configs/shared.d.ts.map +1 -0
  77. package/dist/src/tokens/process/configs/shared.js +99 -0
  78. package/dist/src/tokens/process/configs/storefront.d.ts +3 -0
  79. package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -0
  80. package/dist/src/tokens/process/configs/storefront.js +220 -0
  81. package/dist/src/tokens/process/configs/typography.d.ts +3 -0
  82. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -0
  83. package/dist/src/tokens/process/configs/typography.js +369 -0
  84. package/dist/src/tokens/{build → process}/configs.d.ts +3 -11
  85. package/dist/src/tokens/process/configs.d.ts.map +1 -0
  86. package/dist/src/tokens/process/configs.js +976 -0
  87. package/dist/src/tokens/process/formats/css/color.d.ts +4 -0
  88. package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -0
  89. package/dist/src/tokens/process/formats/css/color.js +128 -0
  90. package/dist/src/tokens/process/formats/css/semantic.d.ts +17 -0
  91. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -0
  92. package/dist/src/tokens/process/formats/css/semantic.js +109 -0
  93. package/dist/src/tokens/process/formats/css/typography.d.ts +3 -0
  94. package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -0
  95. package/dist/src/tokens/process/formats/css/typography.js +32 -0
  96. package/dist/src/tokens/process/formats/css.d.ts +8 -0
  97. package/dist/src/tokens/process/formats/css.d.ts.map +1 -0
  98. package/dist/src/tokens/{build → process}/formats/css.js +94 -57
  99. package/dist/src/tokens/process/formats/js-tokens.d.ts.map +1 -0
  100. package/dist/src/tokens/process/formats/js-tokens.js +109 -0
  101. package/dist/src/tokens/process/platform.d.ts +87 -0
  102. package/dist/src/tokens/process/platform.d.ts.map +1 -0
  103. package/dist/src/tokens/process/platform.js +1090 -0
  104. package/dist/src/tokens/process/transformers.d.ts.map +1 -0
  105. package/dist/src/tokens/{build → process}/transformers.js +29 -6
  106. package/dist/src/tokens/{build → process}/utils/getMultidimensionalThemes.d.ts +3 -3
  107. package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -0
  108. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +922 -0
  109. package/dist/src/tokens/template/design-tokens/primitives/globals.js +5 -0
  110. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +5 -0
  111. package/dist/src/tokens/template/design-tokens/primitives/modes/size/large.js +5 -0
  112. package/dist/src/tokens/template/design-tokens/primitives/modes/size/medium.js +5 -0
  113. package/dist/src/tokens/template/design-tokens/primitives/modes/size/small.js +5 -0
  114. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/large.js +5 -0
  115. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/medium.js +5 -0
  116. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/small.js +5 -0
  117. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/typography.template.js +5 -0
  118. package/dist/src/tokens/template/design-tokens/semantic/color.base.template.js +5 -0
  119. package/dist/src/tokens/template/design-tokens/semantic/color.template.js +5 -0
  120. package/dist/src/tokens/template/design-tokens/semantic/modes/color.template.js +5 -0
  121. package/dist/src/tokens/template/design-tokens/semantic/style.js +5 -0
  122. package/dist/src/tokens/template/design-tokens/themes/theme.base.template.js +5 -0
  123. package/dist/src/tokens/template/design-tokens/themes/theme.template.js +5 -0
  124. package/dist/src/tokens/types.d.ts +54 -38
  125. package/dist/src/tokens/types.d.ts.map +1 -1
  126. package/dist/src/tokens/types.js +8 -0
  127. package/dist/src/tokens/utils.d.ts +30 -5
  128. package/dist/src/tokens/utils.d.ts.map +1 -1
  129. package/dist/src/tokens/utils.js +36 -50
  130. package/dist/src/utils.d.ts +18 -0
  131. package/dist/src/utils.d.ts.map +1 -0
  132. package/dist/src/utils.js +63 -0
  133. package/dist/typography.template-4N5YLH7F.json +22 -0
  134. package/package.json +17 -16
  135. package/dist/bin/config.d.ts.map +0 -1
  136. package/dist/bin/config.js +0 -71
  137. package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
  138. package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
  139. package/dist/src/migrations/codemods/jsx/classname-prefix.js +0 -64
  140. package/dist/src/migrations/codemods/jsx/run.d.ts +0 -7
  141. package/dist/src/migrations/codemods/jsx/run.d.ts.map +0 -1
  142. package/dist/src/migrations/codemods/jsx/run.js +0 -22
  143. package/dist/src/migrations/react-beta-to-v1.d.ts +0 -3
  144. package/dist/src/migrations/react-beta-to-v1.d.ts.map +0 -1
  145. package/dist/src/migrations/react-beta-to-v1.js +0 -5
  146. package/dist/src/scripts/copy-internal-tokens.d.ts +0 -2
  147. package/dist/src/scripts/copy-internal-tokens.d.ts.map +0 -1
  148. package/dist/src/scripts/copy-internal-tokens.js +0 -28
  149. package/dist/src/tokens/build/configs.d.ts.map +0 -1
  150. package/dist/src/tokens/build/configs.js +0 -280
  151. package/dist/src/tokens/build/formats/css.d.ts +0 -53
  152. package/dist/src/tokens/build/formats/css.d.ts.map +0 -1
  153. package/dist/src/tokens/build/formats/js-tokens.d.ts.map +0 -1
  154. package/dist/src/tokens/build/formats/js-tokens.js +0 -48
  155. package/dist/src/tokens/build/transformers.d.ts.map +0 -1
  156. package/dist/src/tokens/build/types.d.ts +0 -48
  157. package/dist/src/tokens/build/types.d.ts.map +0 -1
  158. package/dist/src/tokens/build/types.js +0 -7
  159. package/dist/src/tokens/build/utils/entryfile.d.ts +0 -12
  160. package/dist/src/tokens/build/utils/entryfile.d.ts.map +0 -1
  161. package/dist/src/tokens/build/utils/entryfile.js +0 -67
  162. package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts.map +0 -1
  163. package/dist/src/tokens/build/utils/getMultidimensionalThemes.js +0 -112
  164. package/dist/src/tokens/design-tokens/template/$metadata.json +0 -25
  165. package/dist/src/tokens/design-tokens/template/$themes.json +0 -1498
  166. package/dist/src/tokens/template.d.ts.map +0 -1
  167. package/dist/src/tokens/template.js +0 -99
  168. package/dist/src/tokens/write/generate$metadata.d.ts +0 -9
  169. package/dist/src/tokens/write/generate$metadata.d.ts.map +0 -1
  170. package/dist/src/tokens/write/generate$themes.d.ts +0 -12
  171. package/dist/src/tokens/write/generate$themes.d.ts.map +0 -1
  172. package/dist/src/tokens/write/generate$themes.js +0 -161
  173. package/dist/src/tokens/write.d.ts.map +0 -1
  174. package/dist/src/tokens/write.js +0 -177
  175. /package/dist/{src/tokens/design-tokens/template/semantic/color-base-file.json → color.base.template-M7BHS4OV.json} +0 -0
  176. /package/dist/{src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json → color.template-LMPUQ72A.json} +0 -0
  177. /package/dist/{src/tokens/design-tokens/template/semantic/semantic-color-template.json → color.template-XQNSHLTU.json} +0 -0
  178. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/global.json → global-XVXVBKM6.json} +0 -0
  179. /package/dist/{src/tokens/design-tokens/default/primitives/globals.json → globals-76VAFMDF.json} +0 -0
  180. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/large.json → large-CIIHO7AY.json} +0 -0
  181. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/large.json → large-UUOZ6DYI.json} +0 -0
  182. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/medium.json → medium-OQ7S7P4P.json} +0 -0
  183. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/medium.json → medium-VSB2S4X3.json} +0 -0
  184. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/small.json → small-AEXJ6U7Z.json} +0 -0
  185. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/small.json → small-ZY4KOJWX.json} +0 -0
  186. /package/dist/src/tokens/{build → process}/formats/js-tokens.d.ts +0 -0
  187. /package/dist/src/tokens/{build → process}/transformers.d.ts +0 -0
  188. /package/dist/{src/tokens/design-tokens/default/semantic/style.json → style-FP5XVCUD.json} +0 -0
  189. /package/dist/{src/tokens/design-tokens/template/themes/theme-base-file.json → theme.base.template-Y4RMFBQY.json} +0 -0
  190. /package/dist/{src/tokens/design-tokens/template/themes/theme-color-template.json → theme.template-CTQRNOMO.json} +0 -0
@@ -0,0 +1,976 @@
1
+ // src/tokens/process/configs.ts
2
+ import { register } from "@tokens-studio/sd-transforms";
3
+ import * as R12 from "ramda";
4
+ import StyleDictionary2 from "style-dictionary";
5
+
6
+ // src/tokens/utils.ts
7
+ import * as R from "ramda";
8
+ var mapToLowerCase = R.map(R.toLower);
9
+ var hasAnyTruth = R.any(R.equals(true));
10
+ var getType = (token) => (token.$type ?? token.type) || "";
11
+ var getValue = (token) => token.$value ?? token.value;
12
+ var typeEquals = R.curry((types, token) => {
13
+ if (R.isNil(token)) {
14
+ return false;
15
+ }
16
+ return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));
17
+ });
18
+ var pathStartsWithOneOf = R.curry((paths, token) => {
19
+ if (R.isNil(token)) {
20
+ return false;
21
+ }
22
+ const tokenPath = mapToLowerCase(token.path);
23
+ const matchPathsStartingWith = R.map((path) => R.startsWith([path], tokenPath), mapToLowerCase(paths));
24
+ return hasAnyTruth(matchPathsStartingWith);
25
+ });
26
+ function isSemanticToken(token) {
27
+ return token.filePath.includes("semantic/");
28
+ }
29
+ function isSemanticColorToken(token, color) {
30
+ return token.filePath.includes("semantic/") && R.startsWith(["color", color], token.path);
31
+ }
32
+ function isGlobalColorToken(token) {
33
+ return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
34
+ }
35
+ function isColorCategoryToken(token, category) {
36
+ if (!category) {
37
+ return ["main", "support"].some((c) => isColorCategoryToken(token, c));
38
+ }
39
+ return R.startsWith(["color", category], token.path);
40
+ }
41
+ var isDigit = (s) => /^\d+$/.test(s);
42
+ function traverseObj(obj, fn) {
43
+ for (const key in obj) {
44
+ const prop = obj[key];
45
+ if (prop != null) {
46
+ fn.apply(null, [obj, key, prop]);
47
+ if (typeof prop === "object") {
48
+ traverseObj(prop, fn);
49
+ }
50
+ }
51
+ }
52
+ return obj;
53
+ }
54
+ function inlineTokens(shouldInline, tokens) {
55
+ const [inlineableTokens, otherTokens] = R.partition(shouldInline, tokens);
56
+ return otherTokens.map((token) => {
57
+ let transformed = getValue(token.original);
58
+ for (const ref of inlineableTokens) {
59
+ const refName = ref.path.join(".");
60
+ if (typeof transformed === "string") {
61
+ transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
62
+ }
63
+ }
64
+ const tokenWithInlinedRefs = R.set(R.lensPath(["original", "$value"]), transformed, token);
65
+ return tokenWithInlinedRefs;
66
+ });
67
+ }
68
+
69
+ // src/tokens/process/configs/color.ts
70
+ import * as R8 from "ramda";
71
+
72
+ // src/tokens/process/formats/css/color.ts
73
+ import * as R2 from "ramda";
74
+ import { createPropertyFormatter } from "style-dictionary/utils";
75
+
76
+ // src/tokens/types.ts
77
+ var colorCategories = {
78
+ main: "main",
79
+ support: "support"
80
+ };
81
+
82
+ // src/tokens/process/formats/css/color.ts
83
+ var prefersColorScheme = (colorScheme2, content) => `
84
+ @media (prefers-color-scheme: ${colorScheme2}) {
85
+ [data-color-scheme="auto"] ${content}
86
+ }
87
+ `;
88
+ var colorScheme = {
89
+ name: "ds/css-colorscheme",
90
+ format: async ({ dictionary, file, options, platform }) => {
91
+ const { allTokens } = dictionary;
92
+ const { outputReferences, usesDtcg } = options;
93
+ const { selector, colorScheme: colorScheme2, layer } = platform;
94
+ const colorScheme_ = colorScheme2;
95
+ const format = createPropertyFormatter({
96
+ outputReferences,
97
+ dictionary,
98
+ format: "css",
99
+ usesDtcg
100
+ });
101
+ const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
102
+ color-scheme: ${colorScheme_};
103
+ ` : "";
104
+ const filteredAllTokens = allTokens.filter(
105
+ R2.allPass([
106
+ R2.anyPass([
107
+ // Include semantic tokens in the output
108
+ isSemanticToken,
109
+ // Include global color tokens
110
+ isGlobalColorToken
111
+ ]),
112
+ // Don't include color category tokens -- they are exported separately
113
+ (t) => !isColorCategoryToken(t)
114
+ ])
115
+ );
116
+ const formattedTokens = filteredAllTokens.map(format).join("\n");
117
+ const content = `{
118
+ ${formattedTokens}
119
+ ${colorSchemeProperty}}
120
+ `;
121
+ const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
122
+ const body = R2.isNotNil(layer) ? `@layer ${layer} {
123
+ ${selector} ${content} ${autoSelectorContent}
124
+ }
125
+ ` : `${selector} ${content} ${autoSelectorContent}
126
+ `;
127
+ return body;
128
+ }
129
+ };
130
+ var colorCategory = {
131
+ name: "ds/css-colorcategory",
132
+ format: async ({ dictionary, file, options, platform }) => {
133
+ const { outputReferences, usesDtcg } = options;
134
+ const { selector, layer } = platform;
135
+ const format = R2.compose(
136
+ createPropertyFormatter({
137
+ outputReferences,
138
+ dictionary,
139
+ format: "css",
140
+ usesDtcg
141
+ }),
142
+ (token) => ({
143
+ ...token,
144
+ name: token.name.replace(/color-\w+-/, "color-"),
145
+ original: {
146
+ ...token.original,
147
+ $value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
148
+ }
149
+ })
150
+ );
151
+ const formattedTokens = dictionary.allTokens.map(format).join("\n");
152
+ const content = `{
153
+ ${formattedTokens}
154
+ }
155
+ `;
156
+ const body = R2.isNotNil(layer) ? `@layer ${layer} {
157
+ ${selector} ${content}
158
+ }
159
+ ` : `${selector} ${content}
160
+ `;
161
+ return body;
162
+ }
163
+ };
164
+
165
+ // src/tokens/process/formats/css/semantic.ts
166
+ import * as R3 from "ramda";
167
+ import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
168
+ var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
169
+ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
170
+ var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
171
+ var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
172
+ var overrideSizingFormula = (format, token) => {
173
+ const [name, value] = format(token).split(":");
174
+ const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
175
+ const round = `round(down, ${calc}, 0.0625rem)`;
176
+ return {
177
+ name,
178
+ round,
179
+ calc
180
+ };
181
+ };
182
+ var formatSizingTokens = (format, tokens) => {
183
+ const { round, calc } = R3.reduce(
184
+ (acc, token) => {
185
+ const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
186
+ return {
187
+ round: [...acc.round, `${name}: ${round2};`],
188
+ calc: [...acc.calc, `${name}: ${calc2};`]
189
+ };
190
+ },
191
+ { round: [], calc: [] },
192
+ tokens
193
+ );
194
+ return `
195
+ ${calc.join("\n")}
196
+
197
+ @supports (width: round(down, .1em, 1px)) {
198
+ ${round.join("\n")}
199
+ }`;
200
+ };
201
+ var semantic = {
202
+ name: "ds/css-semantic",
203
+ format: async ({ dictionary, file, options, platform }) => {
204
+ const { outputReferences, usesDtcg } = options;
205
+ const { selector, layer } = platform;
206
+ const format = createPropertyFormatter2({
207
+ outputReferences,
208
+ dictionary,
209
+ format: "css",
210
+ usesDtcg
211
+ });
212
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
213
+ const filteredTokens = R3.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
214
+ const [sizingTokens, restTokens] = R3.partition(
215
+ (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
216
+ filteredTokens
217
+ );
218
+ const formattedTokens = [R3.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
219
+ const content = `{
220
+ ${formattedTokens.join("\n")}
221
+ }
222
+ `;
223
+ const body = R3.isNotNil(layer) ? `@layer ${layer} {
224
+ ${selector} ${content}
225
+ }
226
+ ` : `${selector} ${content}
227
+ `;
228
+ return body;
229
+ }
230
+ };
231
+
232
+ // src/tokens/process/formats/css/typography.ts
233
+ import * as R4 from "ramda";
234
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
235
+ var typographyFontFamilyPredicate = R4.allPass([
236
+ R4.pathSatisfies(R4.includes("typography"), ["path"]),
237
+ R4.pathSatisfies(R4.includes("fontFamily"), ["path"])
238
+ ]);
239
+ var typography = {
240
+ name: "ds/css-typography",
241
+ format: async ({ dictionary, file, options, platform }) => {
242
+ const { outputReferences, usesDtcg } = options;
243
+ const { selector, layer } = platform;
244
+ const format = createPropertyFormatter3({
245
+ outputReferences,
246
+ dictionary,
247
+ format: "css",
248
+ usesDtcg
249
+ });
250
+ const filteredTokens = R4.reject(typographyFontFamilyPredicate, dictionary.allTokens);
251
+ const formattedTokens = R4.pipe(R4.map(format), R4.join("\n"))(filteredTokens);
252
+ const content = selector ? `${selector} {
253
+ ${formattedTokens}
254
+ }` : formattedTokens;
255
+ const body = R4.isNotNil(layer) ? `@layer ${layer} {
256
+ ${content}
257
+ }` : content;
258
+ return body;
259
+ }
260
+ };
261
+
262
+ // src/tokens/process/formats/css.ts
263
+ var formats = {
264
+ colorScheme,
265
+ colorCategory,
266
+ semantic,
267
+ typography
268
+ };
269
+
270
+ // src/tokens/process/platform.ts
271
+ import chalk2 from "chalk";
272
+ import * as R6 from "ramda";
273
+ import StyleDictionary from "style-dictionary";
274
+
275
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
276
+ var BoxShadowTypes;
277
+ (function(BoxShadowTypes2) {
278
+ BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
279
+ BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
280
+ })(BoxShadowTypes || (BoxShadowTypes = {}));
281
+
282
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
283
+ var ColorModifierTypes;
284
+ (function(ColorModifierTypes2) {
285
+ ColorModifierTypes2["LIGHTEN"] = "lighten";
286
+ ColorModifierTypes2["DARKEN"] = "darken";
287
+ ColorModifierTypes2["MIX"] = "mix";
288
+ ColorModifierTypes2["ALPHA"] = "alpha";
289
+ })(ColorModifierTypes || (ColorModifierTypes = {}));
290
+
291
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
292
+ var ColorSpaceTypes;
293
+ (function(ColorSpaceTypes2) {
294
+ ColorSpaceTypes2["LCH"] = "lch";
295
+ ColorSpaceTypes2["SRGB"] = "srgb";
296
+ ColorSpaceTypes2["P3"] = "p3";
297
+ ColorSpaceTypes2["HSL"] = "hsl";
298
+ })(ColorSpaceTypes || (ColorSpaceTypes = {}));
299
+
300
+ // ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
301
+ var Properties;
302
+ (function(Properties2) {
303
+ Properties2["sizing"] = "sizing";
304
+ Properties2["height"] = "height";
305
+ Properties2["width"] = "width";
306
+ Properties2["spacing"] = "spacing";
307
+ Properties2["verticalPadding"] = "verticalPadding";
308
+ Properties2["horizontalPadding"] = "horizontalPadding";
309
+ Properties2["paddingTop"] = "paddingTop";
310
+ Properties2["paddingRight"] = "paddingRight";
311
+ Properties2["paddingBottom"] = "paddingBottom";
312
+ Properties2["paddingLeft"] = "paddingLeft";
313
+ Properties2["itemSpacing"] = "itemSpacing";
314
+ Properties2["fill"] = "fill";
315
+ Properties2["backgroundBlur"] = "backgroundBlur";
316
+ Properties2["border"] = "border";
317
+ Properties2["borderTop"] = "borderTop";
318
+ Properties2["borderRight"] = "borderRight";
319
+ Properties2["borderBottom"] = "borderBottom";
320
+ Properties2["borderLeft"] = "borderLeft";
321
+ Properties2["borderColor"] = "borderColor";
322
+ Properties2["borderRadius"] = "borderRadius";
323
+ Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
324
+ Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
325
+ Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
326
+ Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
327
+ Properties2["borderWidth"] = "borderWidth";
328
+ Properties2["borderWidthTop"] = "borderWidthTop";
329
+ Properties2["borderWidthRight"] = "borderWidthRight";
330
+ Properties2["borderWidthBottom"] = "borderWidthBottom";
331
+ Properties2["borderWidthLeft"] = "borderWidthLeft";
332
+ Properties2["boxShadow"] = "boxShadow";
333
+ Properties2["opacity"] = "opacity";
334
+ Properties2["fontFamilies"] = "fontFamilies";
335
+ Properties2["fontWeights"] = "fontWeights";
336
+ Properties2["fontSizes"] = "fontSizes";
337
+ Properties2["lineHeights"] = "lineHeights";
338
+ Properties2["typography"] = "typography";
339
+ Properties2["composition"] = "composition";
340
+ Properties2["letterSpacing"] = "letterSpacing";
341
+ Properties2["paragraphSpacing"] = "paragraphSpacing";
342
+ Properties2["textCase"] = "textCase";
343
+ Properties2["dimension"] = "dimension";
344
+ Properties2["textDecoration"] = "textDecoration";
345
+ Properties2["asset"] = "asset";
346
+ Properties2["tokenValue"] = "tokenValue";
347
+ Properties2["value"] = "value";
348
+ Properties2["tokenName"] = "tokenName";
349
+ Properties2["description"] = "description";
350
+ })(Properties || (Properties = {}));
351
+
352
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
353
+ var TokenSetStatus;
354
+ (function(TokenSetStatus2) {
355
+ TokenSetStatus2["DISABLED"] = "disabled";
356
+ TokenSetStatus2["SOURCE"] = "source";
357
+ TokenSetStatus2["ENABLED"] = "enabled";
358
+ })(TokenSetStatus || (TokenSetStatus = {}));
359
+
360
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
361
+ var TokenTypes;
362
+ (function(TokenTypes2) {
363
+ TokenTypes2["OTHER"] = "other";
364
+ TokenTypes2["COLOR"] = "color";
365
+ TokenTypes2["BORDER_RADIUS"] = "borderRadius";
366
+ TokenTypes2["SIZING"] = "sizing";
367
+ TokenTypes2["SPACING"] = "spacing";
368
+ TokenTypes2["TEXT"] = "text";
369
+ TokenTypes2["TYPOGRAPHY"] = "typography";
370
+ TokenTypes2["OPACITY"] = "opacity";
371
+ TokenTypes2["BORDER_WIDTH"] = "borderWidth";
372
+ TokenTypes2["STROKE_STYLE"] = "strokeStyle";
373
+ TokenTypes2["BOX_SHADOW"] = "boxShadow";
374
+ TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
375
+ TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
376
+ TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
377
+ TokenTypes2["FONT_SIZES"] = "fontSizes";
378
+ TokenTypes2["LETTER_SPACING"] = "letterSpacing";
379
+ TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
380
+ TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
381
+ TokenTypes2["TEXT_DECORATION"] = "textDecoration";
382
+ TokenTypes2["TEXT_CASE"] = "textCase";
383
+ TokenTypes2["COMPOSITION"] = "composition";
384
+ TokenTypes2["DIMENSION"] = "dimension";
385
+ TokenTypes2["BORDER"] = "border";
386
+ TokenTypes2["ASSET"] = "asset";
387
+ TokenTypes2["BOOLEAN"] = "boolean";
388
+ TokenTypes2["NUMBER"] = "number";
389
+ })(TokenTypes || (TokenTypes = {}));
390
+
391
+ // ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
392
+ var BorderValues;
393
+ (function(BorderValues2) {
394
+ BorderValues2["BORDER_COLOR"] = "color";
395
+ BorderValues2["BORDER_WIDTH"] = "width";
396
+ BorderValues2["BORDER_STYLE"] = "style";
397
+ })(BorderValues || (BorderValues = {}));
398
+
399
+ // ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
400
+ var StrokeStyleValues;
401
+ (function(StrokeStyleValues2) {
402
+ StrokeStyleValues2["SOLID"] = "solid";
403
+ StrokeStyleValues2["DASHED"] = "dashed";
404
+ StrokeStyleValues2["DOTTED"] = "dotted";
405
+ StrokeStyleValues2["DOUBLE"] = "double";
406
+ StrokeStyleValues2["GROOVE"] = "groove";
407
+ StrokeStyleValues2["RIDGE"] = "ridge";
408
+ StrokeStyleValues2["OUTSET"] = "outset";
409
+ StrokeStyleValues2["INSET"] = "inset";
410
+ })(StrokeStyleValues || (StrokeStyleValues = {}));
411
+
412
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
413
+ var BoxShadowValues;
414
+ (function(BoxShadowValues2) {
415
+ BoxShadowValues2["TYPE"] = "type";
416
+ BoxShadowValues2["COLOR"] = "color";
417
+ BoxShadowValues2["X"] = "x";
418
+ BoxShadowValues2["Y"] = "y";
419
+ BoxShadowValues2["BLUR"] = "blur";
420
+ BoxShadowValues2["SPREAD"] = "spread";
421
+ BoxShadowValues2["BLEND_MODE"] = "blendMode";
422
+ })(BoxShadowValues || (BoxShadowValues = {}));
423
+
424
+ // ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
425
+ var TypographyValues;
426
+ (function(TypographyValues2) {
427
+ TypographyValues2["FONT_FAMILY"] = "fontFamily";
428
+ TypographyValues2["FONT_WEIGHT"] = "fontWeight";
429
+ TypographyValues2["LINE_HEIGHT"] = "lineHeight";
430
+ TypographyValues2["FONT_SIZE"] = "fontSize";
431
+ TypographyValues2["LETTER_SPACING"] = "letterSpacing";
432
+ TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
433
+ TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
434
+ TypographyValues2["TEXT_DECORATION"] = "textDecoration";
435
+ TypographyValues2["TEXT_CASE"] = "textCase";
436
+ })(TypographyValues || (TypographyValues = {}));
437
+
438
+ // src/tokens/process/utils/getMultidimensionalThemes.ts
439
+ import chalk from "chalk";
440
+ import { kebabCase } from "change-case";
441
+ import * as R5 from "ramda";
442
+ var getMultidimensionalThemes = (processed$themes, dimensions) => {
443
+ const verboseLogging = buildOptions?.verbose;
444
+ const grouped$themes = groupThemes(processed$themes);
445
+ const permutations = permutateThemes(grouped$themes);
446
+ const ALL_DEPENDENT_ON = ["theme"];
447
+ const keys2 = R5.keys(grouped$themes);
448
+ const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
449
+ if (verboseLogging) {
450
+ console.log(chalk.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
451
+ console.log(chalk.cyan(` (ignoring permutations for ${nonDependentKeys})`));
452
+ }
453
+ return permutations.filter((val) => {
454
+ const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
455
+ return filters.every((x) => x);
456
+ });
457
+ };
458
+ var processed = Symbol("Type brand for ProcessedThemeObject");
459
+ function isProcessed(theme) {
460
+ return Boolean(theme[processed]);
461
+ }
462
+ function processThemeObject(theme) {
463
+ if (isProcessed(theme)) {
464
+ return theme;
465
+ }
466
+ const result = { ...theme, [processed]: true };
467
+ if (result.group) {
468
+ result.group = kebabCase(result.group);
469
+ }
470
+ result.name = kebabCase(result.name);
471
+ return result;
472
+ }
473
+ function groupThemes(themes) {
474
+ const groups = {};
475
+ for (const rawTheme of themes) {
476
+ const theme = processThemeObject(rawTheme);
477
+ if (theme.group) {
478
+ const groupKey = theme.group;
479
+ groups[groupKey] = [...groups[groupKey] ?? [], theme];
480
+ } else {
481
+ throw new Error(
482
+ `Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
483
+ );
484
+ }
485
+ }
486
+ return groups;
487
+ }
488
+ var hasUnknownProps = R5.pipe(R5.values, R5.none(R5.equals("unknown")), R5.not);
489
+ function permutateThemes(groups) {
490
+ const separator = "_";
491
+ const permutations = cartesian(Object.values(groups));
492
+ const permutatedThemes = permutations.map((perm) => {
493
+ const permutatedTheme = perm.reduce(
494
+ (acc, theme) => {
495
+ const { group, name, selectedTokenSets } = theme;
496
+ let updatedPermutation = acc.permutation;
497
+ if (group) {
498
+ const groupProp = R5.lensProp(group);
499
+ updatedPermutation = R5.set(groupProp, name, updatedPermutation);
500
+ }
501
+ const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
502
+ const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
503
+ return {
504
+ permutation: updatedPermutation,
505
+ name: updatedName,
506
+ selectedTokenSets: sets
507
+ };
508
+ },
509
+ {
510
+ name: "",
511
+ selectedTokenSets: [],
512
+ permutation: {
513
+ "color-scheme": "unknown",
514
+ "main-color": "unknown",
515
+ "support-color": "unknown",
516
+ theme: "unknown",
517
+ semantic: "unknown",
518
+ size: "unknown",
519
+ typography: "unknown"
520
+ }
521
+ }
522
+ );
523
+ if (hasUnknownProps(permutatedTheme)) {
524
+ throw Error(`Theme ${permutatedTheme.name} has unknown props: ${JSON.stringify(permutatedTheme)}`);
525
+ }
526
+ const uniqueTokenSets = new Set(permutatedTheme.selectedTokenSets);
527
+ return { ...permutatedTheme, selectedTokenSets: Array.from(uniqueTokenSets) };
528
+ });
529
+ return permutatedThemes;
530
+ }
531
+ function filterTokenSets(tokensets) {
532
+ return Object.entries(tokensets).filter(([, val]) => val !== TokenSetStatus.DISABLED).sort((a, b) => {
533
+ if (a[1] === TokenSetStatus.SOURCE && b[1] === TokenSetStatus.ENABLED) {
534
+ return -1;
535
+ }
536
+ if (a[1] === TokenSetStatus.ENABLED && b[1] === TokenSetStatus.SOURCE) {
537
+ return 1;
538
+ }
539
+ return 0;
540
+ }).map((entry) => entry[0]);
541
+ }
542
+ function cartesian(a) {
543
+ return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
544
+ }
545
+
546
+ // src/tokens/process/platform.ts
547
+ var buildOptions;
548
+ var sd = new StyleDictionary();
549
+ var buildConfigs = {
550
+ typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
551
+ "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
552
+ "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
553
+ "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
554
+ "neutral-color": {
555
+ getConfig: configs.neutralColorVariables,
556
+ dimensions: ["semantic"],
557
+ log: ({ permutation: { theme } }) => `${theme} - neutral`
558
+ },
559
+ "success-color": {
560
+ getConfig: configs.successColorVariables,
561
+ dimensions: ["semantic"],
562
+ log: ({ permutation: { theme } }) => `${theme} - success`
563
+ },
564
+ "danger-color": {
565
+ getConfig: configs.dangerColorVariables,
566
+ dimensions: ["semantic"],
567
+ log: ({ permutation: { theme } }) => `${theme} - danger`
568
+ },
569
+ "warning-color": {
570
+ getConfig: configs.warningColorVariables,
571
+ dimensions: ["semantic"],
572
+ log: ({ permutation: { theme } }) => `${theme} - warning`
573
+ },
574
+ "info-color": {
575
+ getConfig: configs.infoColorVariables,
576
+ dimensions: ["semantic"],
577
+ log: ({ permutation: { theme } }) => `${theme} - info`
578
+ },
579
+ semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
580
+ // storefront: {
581
+ // name: 'Storefront preview tokens',
582
+ // getConfig: configs.typescriptTokens,
583
+ // dimensions: ['color-scheme'],
584
+ // options: { outPath: path.resolve('../../apps/storefront/tokens') },
585
+ // enabled: () => buildOptions?.preview ?? false,
586
+ // },
587
+ };
588
+
589
+ // src/tokens/process/transformers.ts
590
+ import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
591
+ import * as R7 from "ramda";
592
+ var isPx = R7.test(/\b\d+px\b/g);
593
+ var sizeRem = {
594
+ name: "ds/size/toRem",
595
+ type: "value",
596
+ transitive: true,
597
+ filter: (token) => {
598
+ const hasWantedType = typeEquals(["dimension", "fontsize"], token);
599
+ const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
600
+ return hasWantedType && hasWantedPath;
601
+ },
602
+ transform: (token, config) => {
603
+ const value = getValue(token);
604
+ if (isPx(value)) {
605
+ const baseFont = config.basePxFontSize || 16;
606
+ const size = parseInt(value);
607
+ if (size === 0) {
608
+ return "0";
609
+ }
610
+ return `${size / baseFont}rem`;
611
+ }
612
+ return value;
613
+ }
614
+ };
615
+ var typographyName = {
616
+ name: "name/typography",
617
+ type: "name",
618
+ transitive: true,
619
+ // expanded tokens have different type so we match on path instead
620
+ filter: (token) => pathStartsWithOneOf(["typography"], token),
621
+ transform: (token) => {
622
+ return token.name.replace("-typography", "");
623
+ }
624
+ };
625
+ var resolveMath = {
626
+ name: "ds/resolveMath",
627
+ type: "value",
628
+ transitive: true,
629
+ filter: (token) => {
630
+ const isValidValue = ["string", "object"].includes(typeof getValue(token));
631
+ const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
632
+ return isValidValue && isTokenOfInterest;
633
+ },
634
+ transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
635
+ };
636
+ var unitless = {
637
+ name: "ds/unitless",
638
+ type: "value",
639
+ transitive: true,
640
+ filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
641
+ transform: (token) => parseInt(getValue(token))
642
+ };
643
+
644
+ // src/tokens/process/configs/shared.ts
645
+ var prefix = "ds";
646
+ var basePxFontSize = 16;
647
+ var dsTransformers = [
648
+ "name/kebab",
649
+ resolveMath.name,
650
+ "ts/size/px",
651
+ sizeRem.name,
652
+ unitless.name,
653
+ "ts/typography/fontWeight",
654
+ typographyName.name,
655
+ "ts/color/modifiers",
656
+ "ts/color/css/hexrgba",
657
+ "ts/size/lineheight",
658
+ "shadow/css/shorthand"
659
+ ];
660
+
661
+ // src/tokens/process/configs/color.ts
662
+ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
663
+ const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
664
+ const layer = `ds.theme.color-scheme.${colorScheme2}`;
665
+ return {
666
+ preprocessors: ["tokens-studio"],
667
+ platforms: {
668
+ css: {
669
+ // custom
670
+ colorScheme: colorScheme2,
671
+ theme,
672
+ selector,
673
+ layer,
674
+ //
675
+ prefix,
676
+ buildPath: `${theme}/`,
677
+ transforms: dsTransformers,
678
+ files: [
679
+ {
680
+ destination: `color-scheme/${colorScheme2}.css`,
681
+ format: formats.colorScheme.name,
682
+ filter: (token) => typeEquals("color", token) && !R8.startsWith(["global"], token.path)
683
+ }
684
+ ],
685
+ options: {
686
+ outputReferences: false
687
+ }
688
+ }
689
+ }
690
+ };
691
+ };
692
+ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
693
+ const category = opts.category;
694
+ const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
695
+ if (!color) {
696
+ throw new Error(
697
+ category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
698
+ );
699
+ }
700
+ const layer = `ds.theme.color`;
701
+ const isRootColor = color === buildOptions?.rootColor;
702
+ const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
703
+ const config = {
704
+ preprocessors: ["tokens-studio"],
705
+ platforms: {
706
+ css: {
707
+ // custom
708
+ colorScheme: colorScheme2,
709
+ theme,
710
+ selector,
711
+ layer,
712
+ //
713
+ prefix,
714
+ buildPath: `${theme}/`,
715
+ transforms: dsTransformers,
716
+ files: [
717
+ {
718
+ destination: `color/${color}.css`,
719
+ format: formats.colorCategory.name,
720
+ filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
721
+ }
722
+ ],
723
+ options: {
724
+ outputReferences: true
725
+ }
726
+ }
727
+ }
728
+ };
729
+ return config;
730
+ };
731
+
732
+ // src/tokens/process/configs/semantic.ts
733
+ import * as R9 from "ramda";
734
+ import { outputReferencesFilter } from "style-dictionary/utils";
735
+ var semanticVariables = ({ theme }) => {
736
+ const selector = `:root`;
737
+ const layer = `ds.theme.semantic`;
738
+ return {
739
+ preprocessors: ["tokens-studio"],
740
+ platforms: {
741
+ css: {
742
+ // custom
743
+ theme,
744
+ basePxFontSize,
745
+ selector,
746
+ layer,
747
+ //
748
+ prefix,
749
+ buildPath: `${theme}/`,
750
+ transforms: dsTransformers,
751
+ files: [
752
+ {
753
+ destination: `semantic.css`,
754
+ format: formats.semantic.name,
755
+ filter: (token) => {
756
+ const isUwantedToken = R9.anyPass([R9.includes("primitives/global")])(token.filePath);
757
+ const isPrivateToken = R9.includes("_", token.path);
758
+ const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
759
+ const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
760
+ const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
761
+ return unwantedTokens;
762
+ }
763
+ }
764
+ ],
765
+ options: {
766
+ outputReferences: (token, options) => {
767
+ const include = pathStartsWithOneOf(["border-radius"], token);
768
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
769
+ return (include || isWantedSize) && outputReferencesFilter(token, options);
770
+ }
771
+ }
772
+ }
773
+ }
774
+ };
775
+ };
776
+
777
+ // src/tokens/process/configs/storefront.ts
778
+ import * as R11 from "ramda";
779
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
780
+
781
+ // src/tokens/process/formats/js-tokens.ts
782
+ import * as R10 from "ramda";
783
+ import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
784
+ var groupByType = R10.groupBy((token) => getType(token));
785
+ var removeUnwatedTokens = R10.pipe(
786
+ R10.reject((token) => isColorCategoryToken(token)),
787
+ R10.reject((token) => R10.any((path) => path.startsWith("_"))(token.path))
788
+ );
789
+ var dissocExtensions = R10.pipe(R10.dissoc("$extensions"), R10.dissocPath(["original", "$extensions"]));
790
+ var removeUnwatedProps = R10.map((token) => dissocExtensions(token));
791
+ var toCssVarName = R10.pipe(R10.split(":"), R10.head, R10.trim);
792
+ var jsTokens = {
793
+ name: "ds/js-tokens",
794
+ format: async ({ dictionary, file, options }) => {
795
+ const { usesDtcg, outputReferences } = options;
796
+ const format = createPropertyFormatter4({
797
+ outputReferences,
798
+ dictionary,
799
+ format: "css",
800
+ usesDtcg
801
+ });
802
+ const formatTokens = R10.map((token) => {
803
+ if (pathStartsWithOneOf(["size", "_size"], token)) {
804
+ const { calc, name } = overrideSizingFormula(format, token);
805
+ return {
806
+ ...token,
807
+ name: name.trim(),
808
+ $value: calc.trim()
809
+ };
810
+ }
811
+ return {
812
+ ...token,
813
+ name: toCssVarName(format(token))
814
+ };
815
+ });
816
+ const processTokens = R10.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
817
+ const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
818
+ const content = Object.entries(tokens).map(
819
+ ([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
820
+ `
821
+ ).join("\n");
822
+ return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
823
+ }
824
+ };
825
+
826
+ // src/tokens/process/configs/storefront.ts
827
+ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
828
+ return {
829
+ preprocessors: ["tokens-studio"],
830
+ platforms: {
831
+ ts: {
832
+ prefix,
833
+ basePxFontSize,
834
+ transforms: dsTransformers,
835
+ buildPath: `${theme}/`,
836
+ files: [
837
+ {
838
+ destination: `${colorScheme2}.ts`,
839
+ format: jsTokens.name,
840
+ filter: (token) => {
841
+ if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R11.includes("semantic", token.filePath))
842
+ return false;
843
+ const isSemanticColor = R11.includes("semantic", token.filePath) && typeEquals(["color"], token);
844
+ const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
845
+ return isSemanticColor || wantedTypes;
846
+ }
847
+ }
848
+ ],
849
+ options: {
850
+ outputReferences: (token, options) => {
851
+ const include = pathStartsWithOneOf(["border-radius"], token);
852
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
853
+ return (include || isWantedSize) && outputReferencesFilter2(token, options);
854
+ }
855
+ }
856
+ }
857
+ }
858
+ };
859
+ };
860
+
861
+ // src/tokens/process/configs/typography.ts
862
+ import { expandTypesMap } from "@tokens-studio/sd-transforms";
863
+ var typographyVariables = ({ theme, typography: typography2 }) => {
864
+ const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
865
+ const layer = `ds.theme.typography.${typography2}`;
866
+ return {
867
+ usesDtcg: true,
868
+ preprocessors: ["tokens-studio"],
869
+ expand: {
870
+ include: ["typography"],
871
+ typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
872
+ },
873
+ platforms: {
874
+ css: {
875
+ prefix,
876
+ typography: typography2,
877
+ selector,
878
+ layer,
879
+ buildPath: `${theme}/`,
880
+ basePxFontSize,
881
+ transforms: [
882
+ "name/kebab",
883
+ "ts/size/px",
884
+ sizeRem.name,
885
+ "ts/size/lineheight",
886
+ "ts/typography/fontWeight",
887
+ typographyName.name
888
+ ],
889
+ files: [
890
+ {
891
+ destination: `typography/${typography2}.css`,
892
+ format: formats.typography.name,
893
+ filter: (token) => {
894
+ const included = typeEquals(
895
+ ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
896
+ token
897
+ );
898
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
899
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
900
+ }
901
+ }
902
+ ]
903
+ }
904
+ }
905
+ };
906
+ };
907
+
908
+ // src/tokens/process/configs.ts
909
+ void register(StyleDictionary2, { withSDBuiltins: false });
910
+ StyleDictionary2.registerTransform(sizeRem);
911
+ StyleDictionary2.registerTransform(typographyName);
912
+ StyleDictionary2.registerTransform(resolveMath);
913
+ StyleDictionary2.registerTransform(unitless);
914
+ StyleDictionary2.registerFormat(jsTokens);
915
+ for (const format of Object.values(formats)) {
916
+ StyleDictionary2.registerFormat(format);
917
+ }
918
+ var configs = {
919
+ colorSchemeVariables,
920
+ mainColorVariables: colorCategoryVariables({ category: "main" }),
921
+ supportColorVariables: colorCategoryVariables({ category: "support" }),
922
+ neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
923
+ successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
924
+ dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
925
+ warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
926
+ infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
927
+ typographyVariables,
928
+ semanticVariables,
929
+ typescriptTokens
930
+ };
931
+ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
932
+ const { tokensDir, tokenSets } = options;
933
+ const permutations = getMultidimensionalThemes(processed$themes, dimensions);
934
+ return permutations.flatMap(({ selectedTokenSets, permutation }) => {
935
+ const tokenSource = { source: void 0, tokens: {} };
936
+ if (tokenSets) {
937
+ for (const tokenSet of selectedTokenSets) {
938
+ const tokens = tokenSets.get(tokenSet);
939
+ if (tokens) {
940
+ const tokensWithFilePath = traverseObj(tokens, (obj) => {
941
+ if (Object.hasOwn(obj, `$value`) && !obj.filePath) {
942
+ obj.filePath = tokenSet;
943
+ }
944
+ });
945
+ tokenSource.tokens = R12.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
946
+ }
947
+ }
948
+ } else {
949
+ tokenSource.source = selectedTokenSets.map((x) => `${tokensDir}/${x}.json`);
950
+ }
951
+ const configOrConfigs = getConfig(permutation);
952
+ const configs_ = Array.isArray(configOrConfigs) ? configOrConfigs : [{ config: configOrConfigs }];
953
+ const configs2 = configs_.map(({ config, permutationOverrides }) => {
954
+ return {
955
+ permutation: { ...permutation, ...permutationOverrides },
956
+ config: {
957
+ ...config,
958
+ /** Use official W3C design token format
959
+ @see https://v4.styledictionary.com/info/dtcg/
960
+ @see https://design-tokens.github.io/community-group/format/ */
961
+ usesDtcg: true,
962
+ log: {
963
+ ...config?.log,
964
+ verbosity: buildOptions?.verbose ? "verbose" : "silent"
965
+ },
966
+ ...tokenSource
967
+ }
968
+ };
969
+ });
970
+ return configs2;
971
+ }).sort();
972
+ };
973
+ export {
974
+ configs,
975
+ getConfigsForThemeDimensions
976
+ };