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