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