@digdir/designsystemet 1.4.0 → 1.5.1

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