@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
@@ -1,6 +1,6 @@
1
1
  // src/tokens/process/formats/css/semantic.ts
2
- import * as R10 from "ramda";
3
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
2
+ import * as R15 from "ramda";
3
+ import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
4
4
 
5
5
  // src/tokens/utils.ts
6
6
  import * as R from "ramda";
@@ -30,7 +30,10 @@ var pathStartsWithOneOf = R.curry(
30
30
  return false;
31
31
  }
32
32
  const tokenPath = mapToLowerCase(token.path);
33
- const matchPathsStartingWith = R.map((path) => R.startsWith([path], tokenPath), mapToLowerCase(paths));
33
+ const matchPathsStartingWith = R.map((pathOrString) => {
34
+ const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
35
+ return R.startsWith(mapToLowerCase(path), tokenPath);
36
+ }, paths);
34
37
  return hasAnyTruth(matchPathsStartingWith);
35
38
  }
36
39
  );
@@ -66,19 +69,36 @@ function inlineTokens(shouldInline, tokens) {
66
69
  return tokenWithInlinedRefs;
67
70
  });
68
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
+ }
69
89
 
70
90
  // src/tokens/process/platform.ts
71
91
  import pc2 from "picocolors";
72
- import * as R9 from "ramda";
92
+ import * as R14 from "ramda";
73
93
  import StyleDictionary2 from "style-dictionary";
74
94
 
75
95
  // src/tokens/process/configs.ts
76
96
  import { register } from "@tokens-studio/sd-transforms";
77
- import * as R8 from "ramda";
97
+ import * as R13 from "ramda";
78
98
  import StyleDictionary from "style-dictionary";
79
99
 
80
100
  // src/tokens/process/configs/color.ts
81
- import * as R5 from "ramda";
101
+ import * as R8 from "ramda";
82
102
 
83
103
  // src/tokens/process/formats/css/color.ts
84
104
  import * as R2 from "ramda";
@@ -136,10 +156,10 @@ ${selector} ${content} ${autoSelectorContent}
136
156
  };
137
157
  var colorCategory = {
138
158
  name: "ds/css-colorcategory",
139
- format: async ({ dictionary, options, platform }) => {
159
+ format: async ({ dictionary, file, options, platform }) => {
140
160
  const { outputReferences, usesDtcg } = options;
141
- const { selector, layer, files } = platform;
142
- const destination = files?.[0]?.destination;
161
+ const { selector, layer } = platform;
162
+ const destination = file.destination;
143
163
  const format = R2.compose(
144
164
  createPropertyFormatter({
145
165
  outputReferences,
@@ -175,49 +195,97 @@ ${selector} ${content}
175
195
  }
176
196
  };
177
197
 
178
- // src/tokens/process/formats/css/typography.ts
198
+ // src/tokens/process/formats/css/size.ts
179
199
  import * as R3 from "ramda";
180
200
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
181
- var typographyFontFamilyPredicate = R3.allPass([
182
- R3.pathSatisfies(R3.includes("typography"), ["path"]),
183
- R3.pathSatisfies(R3.includes("fontFamily"), ["path"])
184
- ]);
185
- var typography = {
186
- name: "ds/css-typography",
187
- format: async ({ dictionary, options, platform }) => {
201
+ var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
202
+ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
203
+ var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
204
+ var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
205
+ var overrideSizingFormula = (format, token) => {
206
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
207
+ let calc;
208
+ let round;
209
+ if (token.path[1] === "unit") {
210
+ calc = `calc(1rem * ${value})`;
211
+ } else if (value.startsWith("floor")) {
212
+ calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
213
+ round = `round(down, ${calc}, 1px)`;
214
+ } else {
215
+ calc = value.includes("*") ? `calc(${value})` : value;
216
+ }
217
+ return {
218
+ name,
219
+ round: round ?? calc,
220
+ calc
221
+ };
222
+ };
223
+ var formatSizingTokens = (format, tokens) => R3.reduce(
224
+ (acc, token) => {
225
+ const { round, calc, name } = overrideSizingFormula(format, token);
226
+ return {
227
+ tokens: [...acc.tokens, token],
228
+ round: [...acc.round, `${name}: ${round};`],
229
+ calc: [...acc.calc, `${name}: ${calc};`]
230
+ };
231
+ },
232
+ { tokens: [], round: [], calc: [] },
233
+ tokens
234
+ );
235
+ var sizingTemplate = ({ round, calc }) => {
236
+ const usesRounding = round.filter((val, i) => val !== calc[i]);
237
+ return `
238
+ ${calc.join("\n")}
239
+
240
+ @supports (width: round(down, .1em, 1px)) {
241
+ ${usesRounding.join("\n ")}
242
+ }`;
243
+ };
244
+ var size = {
245
+ name: "ds/css-size",
246
+ format: async ({ dictionary, file, options, platform }) => {
188
247
  const { outputReferences, usesDtcg } = options;
189
- const { selector, layer, files } = platform;
190
- const destination = files?.[0]?.destination;
248
+ const { selector, layer } = platform;
249
+ const destination = file.destination;
191
250
  const format = createPropertyFormatter2({
192
251
  outputReferences,
193
252
  dictionary,
194
253
  format: "css",
195
254
  usesDtcg
196
255
  });
197
- const filteredTokens = R3.reject(typographyFontFamilyPredicate, dictionary.allTokens);
198
- const formattedMap = filteredTokens.map((token) => ({
256
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
257
+ const filteredTokens = R3.reject((token) => R3.equals(["_size", "mode-font-size"], token.path), tokens);
258
+ const [sizingTokens, restTokens] = R3.partition(
259
+ (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
260
+ filteredTokens
261
+ );
262
+ const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
263
+ const formattedMap = restTokens.map((token) => ({
199
264
  token,
200
265
  formatted: format(token)
201
266
  }));
202
- buildOptions.buildTokenFormats[destination] = formattedMap;
203
- const formattedTokens = formattedMap.map(R3.view(R3.lensProp("formatted"))).join("\n");
204
- const content = selector ? `${selector} {
205
- ${formattedTokens}
206
- }` : formattedTokens;
267
+ const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
268
+ token: formattedSizingTokens.tokens[i],
269
+ formatted: t
270
+ }));
271
+ buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
272
+ const formattedTokens = [formattedMap.map(R3.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
273
+ const content = `${selector} {
274
+ ${formattedTokens.join("\n")}
275
+ }
276
+ `;
207
277
  const body = R3.isNotNil(layer) ? `@layer ${layer} {
208
278
  ${content}
209
- }` : content;
279
+ }
280
+ ` : `${content}
281
+ `;
210
282
  return body;
211
283
  }
212
284
  };
213
285
 
214
- // src/tokens/process/formats/css.ts
215
- var formats = {
216
- colorScheme,
217
- colorCategory,
218
- semantic,
219
- typography
220
- };
286
+ // src/tokens/process/formats/css/size-mode.ts
287
+ import * as R5 from "ramda";
288
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
221
289
 
222
290
  // src/tokens/process/transformers.ts
223
291
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
@@ -229,18 +297,22 @@ var sizeRem = {
229
297
  transitive: true,
230
298
  filter: (token) => {
231
299
  const hasWantedType = typeEquals(["dimension", "fontsize"], token);
232
- const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
300
+ const hasWantedPath = pathStartsWithOneOf([
301
+ "border-radius",
302
+ "font-size"
303
+ /*, ['_size', 'mode-font-size']*/
304
+ ], token);
233
305
  return hasWantedType && hasWantedPath;
234
306
  },
235
307
  transform: (token, config) => {
236
308
  const value = getValue(token);
237
309
  if (isPx(value)) {
238
310
  const baseFont = config.basePxFontSize || 16;
239
- const size = parseInt(value, 10);
240
- if (size === 0) {
311
+ const size2 = parseInt(value, 10);
312
+ if (size2 === 0) {
241
313
  return "0";
242
314
  }
243
- return `${size / baseFont}rem`;
315
+ return `${size2 / baseFont}rem`;
244
316
  }
245
317
  return value;
246
318
  }
@@ -291,6 +363,154 @@ var dsTransformers = [
291
363
  "shadow/css/shorthand"
292
364
  ];
293
365
 
366
+ // src/tokens/process/formats/css/size-mode.ts
367
+ var formatBaseSizeToken = (size2) => (token) => ({
368
+ ...token,
369
+ originalName: token.name,
370
+ name: `${token.name}--${shortSizeName(size2)}`,
371
+ $value: token.$value / basePxFontSize
372
+ });
373
+ var sizeMode = {
374
+ name: "ds/css-size-mode",
375
+ format: async ({ dictionary, file, options, platform }) => {
376
+ const { outputReferences, usesDtcg } = options;
377
+ const { selector, layer, size: size2 } = platform;
378
+ const destination = file.destination;
379
+ const format = createPropertyFormatter3({
380
+ outputReferences,
381
+ dictionary,
382
+ format: "css",
383
+ usesDtcg
384
+ });
385
+ const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
386
+ const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
387
+ const formattedMap = sizeSpecificTokens.map((token) => ({
388
+ token,
389
+ formatted: format({
390
+ ...token,
391
+ // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
392
+ name: token.originalName
393
+ })
394
+ }));
395
+ buildOptions.buildTokenFormats[destination] = formattedMap;
396
+ const content = `${selector} /* ${size2} */ {
397
+ ${sizeSpecificVariables}
398
+ }`;
399
+ const body = wrapInLayer(content, layer);
400
+ const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
401
+ const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
402
+ const sizingToggles = `:root, [data-size] {
403
+ --ds-size: var(--ds-size--${defaultSize});
404
+ ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
405
+ --ds-size-mode-font-size:
406
+ ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
407
+ }`;
408
+ const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
409
+ const sharedContent = `${sizingToggles}
410
+
411
+ ${sizingHelpers}`;
412
+ const sharedBody = shortSizeName(size2) === R5.last(sizes) ? `
413
+ ${wrapInLayer(sharedContent, layer)}` : "";
414
+ return body + sharedBody;
415
+ }
416
+ };
417
+ function wrapInLayer(content, layer) {
418
+ return R5.isNotNil(layer) ? `@layer ${layer} {
419
+ ${content}
420
+ }
421
+ ` : `${content}
422
+ `;
423
+ }
424
+
425
+ // src/tokens/process/formats/css/typography.ts
426
+ import * as R6 from "ramda";
427
+ import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
428
+ var typographyFontFamilyPredicate = R6.allPass([
429
+ R6.pathSatisfies(R6.includes("typography"), ["path"]),
430
+ R6.pathSatisfies(R6.includes("fontFamily"), ["path"])
431
+ ]);
432
+ var typography = {
433
+ name: "ds/css-typography",
434
+ format: async ({ dictionary, file, options, platform }) => {
435
+ const { outputReferences, usesDtcg } = options;
436
+ const { selector, layer } = platform;
437
+ const destination = file.destination;
438
+ const format = createPropertyFormatter4({
439
+ outputReferences,
440
+ dictionary,
441
+ format: "css",
442
+ usesDtcg
443
+ });
444
+ const filteredTokens = R6.reject(typographyFontFamilyPredicate, dictionary.allTokens);
445
+ const formattedMap = filteredTokens.map((token) => ({
446
+ token,
447
+ formatted: format(token)
448
+ }));
449
+ buildOptions.buildTokenFormats[destination] = formattedMap;
450
+ const formattedTokens = formattedMap.map(R6.view(R6.lensProp("formatted"))).join("\n");
451
+ const content = selector ? `${selector} {
452
+ ${formattedTokens}
453
+ }` : formattedTokens;
454
+ const body = R6.isNotNil(layer) ? `@layer ${layer} {
455
+ ${content}
456
+ }` : content;
457
+ return body;
458
+ }
459
+ };
460
+
461
+ // src/tokens/process/formats/css/type-scale.ts
462
+ import * as R7 from "ramda";
463
+ import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
464
+ var typographyFontFamilyPredicate2 = R7.allPass([
465
+ R7.pathSatisfies(R7.includes("typography"), ["path"]),
466
+ R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
467
+ ]);
468
+ function formatTypographySizeToken(token) {
469
+ return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
470
+ }
471
+ var typeScale = {
472
+ name: "ds/css-type-scale",
473
+ format: async ({ dictionary, file, options, platform }) => {
474
+ const { outputReferences, usesDtcg } = options;
475
+ const { selector, layer } = platform;
476
+ const destination = file.destination;
477
+ const format = createPropertyFormatter5({
478
+ outputReferences,
479
+ dictionary,
480
+ format: "css",
481
+ usesDtcg
482
+ });
483
+ const filteredTokens = R7.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
484
+ const tokens = R7.map(formatTypographySizeToken, filteredTokens);
485
+ const formattedMap = tokens.map((token) => ({
486
+ token,
487
+ formatted: format(token)
488
+ }));
489
+ buildOptions.buildTokenFormats[destination] = formattedMap;
490
+ const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
491
+ const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
492
+ const content = `${selector} {
493
+ ${sizeFactor}
494
+ ${formattedTokens}
495
+ }`;
496
+ const body = R7.isNotNil(layer) ? `@layer ${layer} {
497
+ ${content}
498
+ }` : content;
499
+ return body;
500
+ }
501
+ };
502
+
503
+ // src/tokens/process/formats/css.ts
504
+ var formats = {
505
+ colorScheme,
506
+ colorCategory,
507
+ semantic,
508
+ sizeMode,
509
+ size,
510
+ typography,
511
+ typeScale
512
+ };
513
+
294
514
  // src/tokens/process/configs/color.ts
295
515
  var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
296
516
  const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
@@ -312,7 +532,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
312
532
  {
313
533
  destination: `color-scheme/${colorScheme2}.css`,
314
534
  format: formats.colorScheme.name,
315
- filter: (token) => typeEquals("color", token) && !R5.startsWith(["global"], token.path)
535
+ filter: (token) => typeEquals("color", token) && !R8.startsWith(["global"], token.path)
316
536
  }
317
537
  ],
318
538
  options: {
@@ -363,7 +583,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
363
583
  };
364
584
 
365
585
  // src/tokens/process/configs/semantic.ts
366
- import * as R6 from "ramda";
586
+ import * as R9 from "ramda";
367
587
  import { outputReferencesFilter } from "style-dictionary/utils";
368
588
  var semanticVariables = ({ theme }) => {
369
589
  const selector = `:root`;
@@ -386,9 +606,12 @@ var semanticVariables = ({ theme }) => {
386
606
  destination: `semantic.css`,
387
607
  format: formats.semantic.name,
388
608
  filter: (token) => {
389
- const isUwantedToken = R6.anyPass([R6.includes("primitives/global")])(token.filePath);
390
- const isPrivateToken = R6.includes("_", token.path);
391
- const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
609
+ const isUwantedToken = R9.anyPass([R9.includes("primitives/global")])(token.filePath);
610
+ const isPrivateToken = R9.includes("_", token.path);
611
+ const unwantedPaths = pathStartsWithOneOf(
612
+ ["size", "_size", "font-size", "line-height", "letter-spacing"],
613
+ token
614
+ );
392
615
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
393
616
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
394
617
  return unwantedTokens;
@@ -398,9 +621,126 @@ var semanticVariables = ({ theme }) => {
398
621
  options: {
399
622
  outputReferences: (token, options) => {
400
623
  const include = pathStartsWithOneOf(["border-radius"], token);
401
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
402
- return (include || isWantedSize) && outputReferencesFilter(token, options);
624
+ return include && outputReferencesFilter(token, options);
625
+ }
626
+ }
627
+ }
628
+ }
629
+ };
630
+ };
631
+
632
+ // src/tokens/process/configs/size.ts
633
+ import * as R10 from "ramda";
634
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
635
+ var sizeVariables = ({ theme }) => {
636
+ const selector = `:root, [data-size]`;
637
+ const layer = `ds.theme.size`;
638
+ return {
639
+ preprocessors: ["tokens-studio"],
640
+ platforms: {
641
+ css: {
642
+ // custom
643
+ theme,
644
+ basePxFontSize,
645
+ selector,
646
+ layer,
647
+ //
648
+ prefix,
649
+ buildPath: `${theme}/`,
650
+ transforms: dsTransformers,
651
+ files: [
652
+ {
653
+ destination: `size.css`,
654
+ format: formats.size.name,
655
+ filter: (token) => {
656
+ const isUwantedToken = R10.anyPass([R10.includes("primitives/global")])(token.filePath);
657
+ const isPrivateToken = R10.includes("_", token.path);
658
+ return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
659
+ }
660
+ }
661
+ ],
662
+ options: {
663
+ outputReferences: (token, options) => {
664
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
665
+ return isWantedSize && outputReferencesFilter2(token, options);
666
+ }
667
+ }
668
+ }
669
+ }
670
+ };
671
+ };
672
+
673
+ // src/tokens/process/configs/size-mode.ts
674
+ import * as R11 from "ramda";
675
+ var sizeModeVariables = ({ theme, size: size2 }) => {
676
+ const selector = `:root`;
677
+ const layer = `ds.theme.size-mode`;
678
+ return {
679
+ preprocessors: ["tokens-studio"],
680
+ platforms: {
681
+ css: {
682
+ // custom
683
+ size: size2,
684
+ theme,
685
+ basePxFontSize,
686
+ selector,
687
+ layer,
688
+ //
689
+ prefix,
690
+ buildPath: `${theme}/`,
691
+ transforms: dsTransformers,
692
+ files: [
693
+ {
694
+ destination: `size-mode/${size2}.css`,
695
+ format: formats.sizeMode.name,
696
+ filter: (token) => {
697
+ return R11.equals(["_size", "mode-font-size"], token.path);
698
+ }
699
+ }
700
+ ]
701
+ }
702
+ }
703
+ };
704
+ };
705
+
706
+ // src/tokens/process/configs/type-scale.ts
707
+ var typeScaleVariables = ({ theme }) => {
708
+ const selector = ":root, [data-size]";
709
+ const layer = `ds.theme.type-scale`;
710
+ return {
711
+ usesDtcg: true,
712
+ preprocessors: ["tokens-studio"],
713
+ expand: {
714
+ include: ["typography"]
715
+ },
716
+ platforms: {
717
+ css: {
718
+ prefix,
719
+ selector,
720
+ layer,
721
+ buildPath: `${theme}/`,
722
+ basePxFontSize,
723
+ transforms: [
724
+ "name/kebab",
725
+ "ts/size/px",
726
+ sizeRem.name,
727
+ "ts/size/lineheight",
728
+ "ts/typography/fontWeight",
729
+ typographyName.name
730
+ ],
731
+ files: [
732
+ {
733
+ destination: `type-scale.css`,
734
+ format: formats.typeScale.name,
735
+ filter: (token) => {
736
+ const included = typeEquals(["typography", "dimension", "fontsize"], token);
737
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
738
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
739
+ }
403
740
  }
741
+ ],
742
+ options: {
743
+ outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
404
744
  }
405
745
  }
406
746
  }
@@ -441,12 +781,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
441
781
  destination: `typography/${typography2}.css`,
442
782
  format: formats.typography.name,
443
783
  filter: (token) => {
444
- const included = typeEquals(
445
- ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
446
- token
447
- );
784
+ const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
448
785
  if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
449
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
786
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
450
787
  }
451
788
  }
452
789
  ]
@@ -621,9 +958,9 @@ var TypographyValues;
621
958
  // src/tokens/process/utils/getMultidimensionalThemes.ts
622
959
  import { kebabCase } from "change-case";
623
960
  import pc from "picocolors";
624
- import * as R7 from "ramda";
961
+ import * as R12 from "ramda";
625
962
  var processed = Symbol("Type brand for ProcessedThemeObject");
626
- var hasUnknownProps = R7.pipe(R7.values, R7.none(R7.equals("unknown")), R7.not);
963
+ var hasUnknownProps = R12.pipe(R12.values, R12.none(R12.equals("unknown")), R12.not);
627
964
 
628
965
  // src/tokens/process/configs.ts
629
966
  void register(StyleDictionary, { withSDBuiltins: false });
@@ -643,7 +980,10 @@ var configs = {
643
980
  dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
644
981
  warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
645
982
  infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
983
+ sizeModeVariables,
984
+ sizeVariables,
646
985
  typographyVariables,
986
+ typeScaleVariables,
647
987
  semanticVariables
648
988
  };
649
989
 
@@ -656,6 +996,9 @@ var buildOptions = {
656
996
  var sd = new StyleDictionary2();
657
997
  var buildConfigs = {
658
998
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
999
+ sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
1000
+ size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
1001
+ typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
659
1002
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
660
1003
  "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
661
1004
  "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
@@ -688,82 +1031,37 @@ var buildConfigs = {
688
1031
  };
689
1032
 
690
1033
  // src/tokens/process/formats/css/semantic.ts
691
- var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
692
- var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
693
- var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
694
- var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
695
- var overrideSizingFormula = (format, token) => {
696
- const [name, value] = format(token).split(":");
697
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
698
- const round = `round(down, ${calc}, 1px)`;
699
- return {
700
- name,
701
- round,
702
- calc
703
- };
704
- };
705
- var formatSizingTokens = (format, tokens) => R10.reduce(
706
- (acc, token) => {
707
- const { round, calc, name } = overrideSizingFormula(format, token);
708
- return {
709
- tokens: [...acc.tokens, token],
710
- round: [...acc.round, `${name}: ${round};`],
711
- calc: [...acc.calc, `${name}: ${calc};`]
712
- };
713
- },
714
- { tokens: [], round: [], calc: [] },
715
- tokens
716
- );
717
- var sizingTemplate = ({ round, calc }) => `
718
- ${calc.join("\n")}
719
-
720
- @supports (width: round(down, .1em, 1px)) {
721
- ${round.join("\n")}
722
- }`;
723
1034
  var semantic = {
724
1035
  name: "ds/css-semantic",
725
- format: async ({ dictionary, options, platform }) => {
1036
+ format: async ({ dictionary, file, options, platform }) => {
726
1037
  const { outputReferences, usesDtcg } = options;
727
- const { selector, layer, files } = platform;
728
- const destination = files?.[0]?.destination;
729
- const format = createPropertyFormatter3({
1038
+ const { selector, layer } = platform;
1039
+ const destination = file.destination;
1040
+ const format = createPropertyFormatter6({
730
1041
  outputReferences,
731
1042
  dictionary,
732
1043
  format: "css",
733
1044
  usesDtcg
734
1045
  });
735
1046
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
736
- const filteredTokens = R10.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
737
- const [sizingTokens, restTokens] = R10.partition(
738
- (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
739
- filteredTokens
740
- );
741
- const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
742
- const formattedMap = restTokens.map((token) => ({
1047
+ const formattedMap = tokens.map((token) => ({
743
1048
  token,
744
1049
  formatted: format(token)
745
1050
  }));
746
- const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
747
- token: formattedSizingTokens.tokens[i],
748
- formatted: t
749
- }));
750
- buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
751
- const sizingSnippet = sizingTemplate(formattedSizingTokens);
752
- const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).concat(sizingSnippet);
753
- const content = `{
754
- ${formattedTokens.join("\n")}
1051
+ buildOptions.buildTokenFormats[destination] = formattedMap;
1052
+ const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
1053
+ const content = `${selector} {
1054
+ ${formattedTokens}
755
1055
  }
756
1056
  `;
757
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
758
- ${selector} ${content}
1057
+ const body = R15.isNotNil(layer) ? `@layer ${layer} {
1058
+ ${content}
759
1059
  }
760
- ` : `${selector} ${content}
1060
+ ` : `${content}
761
1061
  `;
762
1062
  return body;
763
1063
  }
764
1064
  };
765
1065
  export {
766
- isInlineTokens,
767
- overrideSizingFormula,
768
1066
  semantic
769
1067
  };
@@ -0,0 +1,4 @@
1
+ import type { Format } from 'style-dictionary/types';
2
+ export declare const sizeMode: Format;
3
+ export declare function wrapInLayer(content: string, layer?: string): string;
4
+ //# sourceMappingURL=size-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size-mode.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size-mode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAerD,eAAO,MAAM,QAAQ,EAAE,MAsDtB,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAE1D"}