@digdir/designsystemet 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/bin/designsystemet.js +484 -162
  2. package/dist/global-Y35YADVH.json +100 -0
  3. package/dist/src/index.js +523 -199
  4. package/dist/src/scripts/update-preview-tokens.js +429 -118
  5. package/dist/src/tokens/build.js +425 -107
  6. package/dist/src/tokens/create/defaults.js +27 -23
  7. package/dist/src/tokens/create/generators/$designsystemet.js +2 -2
  8. package/dist/src/tokens/create/write.js +2 -2
  9. package/dist/src/tokens/create.js +27 -23
  10. package/dist/src/tokens/format.js +523 -199
  11. package/dist/src/tokens/index.js +523 -199
  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 +372 -70
  48. package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
  49. package/dist/src/tokens/process/output/theme.js +59 -10
  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 +2 -2
  60. package/dist/global-XVXVBKM6.json +0 -96
@@ -1,7 +1,7 @@
1
1
  // src/tokens/build.ts
2
2
  import path from "path";
3
3
  import pc6 from "picocolors";
4
- import * as R12 from "ramda";
4
+ import * as R17 from "ramda";
5
5
 
6
6
  // src/utils.ts
7
7
  import fs from "fs/promises";
@@ -49,7 +49,7 @@ import pc4 from "picocolors";
49
49
  // package.json
50
50
  var package_default = {
51
51
  name: "@digdir/designsystemet",
52
- version: "1.4.0",
52
+ version: "1.5.0",
53
53
  description: "CLI for Designsystemet",
54
54
  author: "Designsystemet team",
55
55
  engines: {
@@ -132,7 +132,7 @@ var package_default = {
132
132
  "@types/apca-w3": "^0.1.3",
133
133
  "@types/chroma-js": "^3.1.1",
134
134
  "@types/fs-extra": "^11.0.4",
135
- "@types/node": "^22.18.0",
135
+ "@types/node": "^22.18.1",
136
136
  "@types/object-hash": "^3.0.6",
137
137
  "@types/ramda": "^0.31.0",
138
138
  "fs-extra": "^11.3.1",
@@ -145,7 +145,7 @@ var package_default = {
145
145
 
146
146
  // src/tokens/process/platform.ts
147
147
  import pc3 from "picocolors";
148
- import * as R10 from "ramda";
148
+ import * as R15 from "ramda";
149
149
  import StyleDictionary2 from "style-dictionary";
150
150
 
151
151
  // src/tokens/types.ts
@@ -156,7 +156,7 @@ var colorCategories = {
156
156
 
157
157
  // src/tokens/process/configs.ts
158
158
  import { register } from "@tokens-studio/sd-transforms";
159
- import * as R9 from "ramda";
159
+ import * as R14 from "ramda";
160
160
  import StyleDictionary from "style-dictionary";
161
161
 
162
162
  // src/tokens/utils.ts
@@ -179,7 +179,10 @@ var pathStartsWithOneOf = R.curry(
179
179
  return false;
180
180
  }
181
181
  const tokenPath = mapToLowerCase(token.path);
182
- const matchPathsStartingWith = R.map((path2) => R.startsWith([path2], tokenPath), mapToLowerCase(paths));
182
+ const matchPathsStartingWith = R.map((pathOrString) => {
183
+ const path2 = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
184
+ return R.startsWith(mapToLowerCase(path2), tokenPath);
185
+ }, paths);
183
186
  return hasAnyTruth(matchPathsStartingWith);
184
187
  }
185
188
  );
@@ -203,11 +206,11 @@ function isColorCategoryToken(token, category) {
203
206
  var isDigit = (s) => /^\d+$/.test(s);
204
207
  function traverseObj(obj, fn) {
205
208
  for (const key in obj) {
206
- const prop = obj[key];
207
- if (prop != null) {
208
- fn.apply(null, [obj, key, prop]);
209
- if (typeof prop === "object") {
210
- traverseObj(prop, fn);
209
+ const prop4 = obj[key];
210
+ if (prop4 != null) {
211
+ fn.apply(null, [obj, key, prop4]);
212
+ if (typeof prop4 === "object") {
213
+ traverseObj(prop4, fn);
211
214
  }
212
215
  }
213
216
  }
@@ -227,9 +230,26 @@ function inlineTokens(shouldInline, tokens) {
227
230
  return tokenWithInlinedRefs;
228
231
  });
229
232
  }
233
+ var sizeMap = {
234
+ xsmall: "xs",
235
+ small: "sm",
236
+ medium: "md",
237
+ large: "lg",
238
+ xlarge: "xl"
239
+ };
240
+ function shortSizeName(size2) {
241
+ return sizeMap[size2] ?? size2;
242
+ }
243
+ var sizeComparator = (size2) => {
244
+ const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
245
+ return sortIndex ?? 0;
246
+ };
247
+ function orderBySize(sizes) {
248
+ return R.sortBy(sizeComparator, sizes);
249
+ }
230
250
 
231
251
  // src/tokens/process/configs/color.ts
232
- import * as R6 from "ramda";
252
+ import * as R9 from "ramda";
233
253
 
234
254
  // src/tokens/process/formats/css/color.ts
235
255
  import * as R2 from "ramda";
@@ -287,10 +307,10 @@ ${selector} ${content} ${autoSelectorContent}
287
307
  };
288
308
  var colorCategory = {
289
309
  name: "ds/css-colorcategory",
290
- format: async ({ dictionary, options, platform }) => {
310
+ format: async ({ dictionary, file, options, platform }) => {
291
311
  const { outputReferences, usesDtcg } = options;
292
- const { selector, layer, files } = platform;
293
- const destination = files?.[0]?.destination;
312
+ const { selector, layer } = platform;
313
+ const destination = file.destination;
294
314
  const format = R2.compose(
295
315
  createPropertyFormatter({
296
316
  outputReferences,
@@ -327,6 +347,10 @@ ${selector} ${content}
327
347
  };
328
348
 
329
349
  // src/tokens/process/formats/css/semantic.ts
350
+ import * as R4 from "ramda";
351
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
352
+
353
+ // src/tokens/process/formats/css/size.ts
330
354
  import * as R3 from "ramda";
331
355
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
332
356
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
@@ -334,12 +358,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
334
358
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
335
359
  var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
336
360
  var overrideSizingFormula = (format, token) => {
337
- const [name, value] = format(token).split(":");
338
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
339
- const round = `round(down, ${calc}, 1px)`;
361
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
362
+ let calc;
363
+ let round;
364
+ if (token.path[1] === "unit") {
365
+ calc = `calc(1rem * ${value})`;
366
+ } else if (value.startsWith("floor")) {
367
+ calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
368
+ round = `round(down, ${calc}, 1px)`;
369
+ } else {
370
+ calc = value.includes("*") ? `calc(${value})` : value;
371
+ }
340
372
  return {
341
373
  name,
342
- round,
374
+ round: round ?? calc,
343
375
  calc
344
376
  };
345
377
  };
@@ -355,18 +387,21 @@ var formatSizingTokens = (format, tokens) => R3.reduce(
355
387
  { tokens: [], round: [], calc: [] },
356
388
  tokens
357
389
  );
358
- var sizingTemplate = ({ round, calc }) => `
390
+ var sizingTemplate = ({ round, calc }) => {
391
+ const usesRounding = round.filter((val, i) => val !== calc[i]);
392
+ return `
359
393
  ${calc.join("\n")}
360
394
 
361
395
  @supports (width: round(down, .1em, 1px)) {
362
- ${round.join("\n")}
396
+ ${usesRounding.join("\n ")}
363
397
  }`;
364
- var semantic = {
365
- name: "ds/css-semantic",
366
- format: async ({ dictionary, options, platform }) => {
398
+ };
399
+ var size = {
400
+ name: "ds/css-size",
401
+ format: async ({ dictionary, file, options, platform }) => {
367
402
  const { outputReferences, usesDtcg } = options;
368
- const { selector, layer, files } = platform;
369
- const destination = files?.[0]?.destination;
403
+ const { selector, layer } = platform;
404
+ const destination = file.destination;
370
405
  const format = createPropertyFormatter2({
371
406
  outputReferences,
372
407
  dictionary,
@@ -374,9 +409,9 @@ var semantic = {
374
409
  usesDtcg
375
410
  });
376
411
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
377
- const filteredTokens = R3.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
412
+ const filteredTokens = R3.reject((token) => R3.equals(["_size", "mode-font-size"], token.path), tokens);
378
413
  const [sizingTokens, restTokens] = R3.partition(
379
- (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
414
+ (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
380
415
  filteredTokens
381
416
  );
382
417
  const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
@@ -389,64 +424,56 @@ var semantic = {
389
424
  formatted: t
390
425
  }));
391
426
  buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
392
- const sizingSnippet = sizingTemplate(formattedSizingTokens);
393
- const formattedTokens = formattedMap.map(R3.view(R3.lensProp("formatted"))).concat(sizingSnippet);
394
- const content = `{
427
+ const formattedTokens = [formattedMap.map(R3.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
428
+ const content = `${selector} {
395
429
  ${formattedTokens.join("\n")}
396
430
  }
397
431
  `;
398
432
  const body = R3.isNotNil(layer) ? `@layer ${layer} {
399
- ${selector} ${content}
433
+ ${content}
400
434
  }
401
- ` : `${selector} ${content}
435
+ ` : `${content}
402
436
  `;
403
437
  return body;
404
438
  }
405
439
  };
406
440
 
407
- // src/tokens/process/formats/css/typography.ts
408
- import * as R4 from "ramda";
409
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
410
- var typographyFontFamilyPredicate = R4.allPass([
411
- R4.pathSatisfies(R4.includes("typography"), ["path"]),
412
- R4.pathSatisfies(R4.includes("fontFamily"), ["path"])
413
- ]);
414
- var typography = {
415
- name: "ds/css-typography",
416
- format: async ({ dictionary, options, platform }) => {
441
+ // src/tokens/process/formats/css/semantic.ts
442
+ var semantic = {
443
+ name: "ds/css-semantic",
444
+ format: async ({ dictionary, file, options, platform }) => {
417
445
  const { outputReferences, usesDtcg } = options;
418
- const { selector, layer, files } = platform;
419
- const destination = files?.[0]?.destination;
446
+ const { selector, layer } = platform;
447
+ const destination = file.destination;
420
448
  const format = createPropertyFormatter3({
421
449
  outputReferences,
422
450
  dictionary,
423
451
  format: "css",
424
452
  usesDtcg
425
453
  });
426
- const filteredTokens = R4.reject(typographyFontFamilyPredicate, dictionary.allTokens);
427
- const formattedMap = filteredTokens.map((token) => ({
454
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
455
+ const formattedMap = tokens.map((token) => ({
428
456
  token,
429
457
  formatted: format(token)
430
458
  }));
431
459
  buildOptions.buildTokenFormats[destination] = formattedMap;
432
- const formattedTokens = formattedMap.map(R4.view(R4.lensProp("formatted"))).join("\n");
433
- const content = selector ? `${selector} {
460
+ const formattedTokens = formattedMap.map(R4.prop("formatted")).join("\n");
461
+ const content = `${selector} {
434
462
  ${formattedTokens}
435
- }` : formattedTokens;
463
+ }
464
+ `;
436
465
  const body = R4.isNotNil(layer) ? `@layer ${layer} {
437
466
  ${content}
438
- }` : content;
467
+ }
468
+ ` : `${content}
469
+ `;
439
470
  return body;
440
471
  }
441
472
  };
442
473
 
443
- // src/tokens/process/formats/css.ts
444
- var formats = {
445
- colorScheme,
446
- colorCategory,
447
- semantic,
448
- typography
449
- };
474
+ // src/tokens/process/formats/css/size-mode.ts
475
+ import * as R6 from "ramda";
476
+ import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
450
477
 
451
478
  // src/tokens/process/transformers.ts
452
479
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
@@ -458,18 +485,22 @@ var sizeRem = {
458
485
  transitive: true,
459
486
  filter: (token) => {
460
487
  const hasWantedType = typeEquals(["dimension", "fontsize"], token);
461
- const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
488
+ const hasWantedPath = pathStartsWithOneOf([
489
+ "border-radius",
490
+ "font-size"
491
+ /*, ['_size', 'mode-font-size']*/
492
+ ], token);
462
493
  return hasWantedType && hasWantedPath;
463
494
  },
464
495
  transform: (token, config) => {
465
496
  const value = getValue(token);
466
497
  if (isPx(value)) {
467
498
  const baseFont = config.basePxFontSize || 16;
468
- const size = parseInt(value, 10);
469
- if (size === 0) {
499
+ const size2 = parseInt(value, 10);
500
+ if (size2 === 0) {
470
501
  return "0";
471
502
  }
472
- return `${size / baseFont}rem`;
503
+ return `${size2 / baseFont}rem`;
473
504
  }
474
505
  return value;
475
506
  }
@@ -520,6 +551,154 @@ var dsTransformers = [
520
551
  "shadow/css/shorthand"
521
552
  ];
522
553
 
554
+ // src/tokens/process/formats/css/size-mode.ts
555
+ var formatBaseSizeToken = (size2) => (token) => ({
556
+ ...token,
557
+ originalName: token.name,
558
+ name: `${token.name}--${shortSizeName(size2)}`,
559
+ $value: token.$value / basePxFontSize
560
+ });
561
+ var sizeMode = {
562
+ name: "ds/css-size-mode",
563
+ format: async ({ dictionary, file, options, platform }) => {
564
+ const { outputReferences, usesDtcg } = options;
565
+ const { selector, layer, size: size2 } = platform;
566
+ const destination = file.destination;
567
+ const format = createPropertyFormatter4({
568
+ outputReferences,
569
+ dictionary,
570
+ format: "css",
571
+ usesDtcg
572
+ });
573
+ const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
574
+ const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
575
+ const formattedMap = sizeSpecificTokens.map((token) => ({
576
+ token,
577
+ formatted: format({
578
+ ...token,
579
+ // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
580
+ name: token.originalName
581
+ })
582
+ }));
583
+ buildOptions.buildTokenFormats[destination] = formattedMap;
584
+ const content = `${selector} /* ${size2} */ {
585
+ ${sizeSpecificVariables}
586
+ }`;
587
+ const body = wrapInLayer(content, layer);
588
+ const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
589
+ const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
590
+ const sizingToggles = `:root, [data-size] {
591
+ --ds-size: var(--ds-size--${defaultSize});
592
+ ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
593
+ --ds-size-mode-font-size:
594
+ ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
595
+ }`;
596
+ const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
597
+ const sharedContent = `${sizingToggles}
598
+
599
+ ${sizingHelpers}`;
600
+ const sharedBody = shortSizeName(size2) === R6.last(sizes) ? `
601
+ ${wrapInLayer(sharedContent, layer)}` : "";
602
+ return body + sharedBody;
603
+ }
604
+ };
605
+ function wrapInLayer(content, layer) {
606
+ return R6.isNotNil(layer) ? `@layer ${layer} {
607
+ ${content}
608
+ }
609
+ ` : `${content}
610
+ `;
611
+ }
612
+
613
+ // src/tokens/process/formats/css/typography.ts
614
+ import * as R7 from "ramda";
615
+ import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
616
+ var typographyFontFamilyPredicate = R7.allPass([
617
+ R7.pathSatisfies(R7.includes("typography"), ["path"]),
618
+ R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
619
+ ]);
620
+ var typography = {
621
+ name: "ds/css-typography",
622
+ format: async ({ dictionary, file, options, platform }) => {
623
+ const { outputReferences, usesDtcg } = options;
624
+ const { selector, layer } = platform;
625
+ const destination = file.destination;
626
+ const format = createPropertyFormatter5({
627
+ outputReferences,
628
+ dictionary,
629
+ format: "css",
630
+ usesDtcg
631
+ });
632
+ const filteredTokens = R7.reject(typographyFontFamilyPredicate, dictionary.allTokens);
633
+ const formattedMap = filteredTokens.map((token) => ({
634
+ token,
635
+ formatted: format(token)
636
+ }));
637
+ buildOptions.buildTokenFormats[destination] = formattedMap;
638
+ const formattedTokens = formattedMap.map(R7.view(R7.lensProp("formatted"))).join("\n");
639
+ const content = selector ? `${selector} {
640
+ ${formattedTokens}
641
+ }` : formattedTokens;
642
+ const body = R7.isNotNil(layer) ? `@layer ${layer} {
643
+ ${content}
644
+ }` : content;
645
+ return body;
646
+ }
647
+ };
648
+
649
+ // src/tokens/process/formats/css/type-scale.ts
650
+ import * as R8 from "ramda";
651
+ import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
652
+ var typographyFontFamilyPredicate2 = R8.allPass([
653
+ R8.pathSatisfies(R8.includes("typography"), ["path"]),
654
+ R8.pathSatisfies(R8.includes("fontFamily"), ["path"])
655
+ ]);
656
+ function formatTypographySizeToken(token) {
657
+ return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
658
+ }
659
+ var typeScale = {
660
+ name: "ds/css-type-scale",
661
+ format: async ({ dictionary, file, options, platform }) => {
662
+ const { outputReferences, usesDtcg } = options;
663
+ const { selector, layer } = platform;
664
+ const destination = file.destination;
665
+ const format = createPropertyFormatter6({
666
+ outputReferences,
667
+ dictionary,
668
+ format: "css",
669
+ usesDtcg
670
+ });
671
+ const filteredTokens = R8.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
672
+ const tokens = R8.map(formatTypographySizeToken, filteredTokens);
673
+ const formattedMap = tokens.map((token) => ({
674
+ token,
675
+ formatted: format(token)
676
+ }));
677
+ buildOptions.buildTokenFormats[destination] = formattedMap;
678
+ const formattedTokens = formattedMap.map(R8.prop("formatted")).join("\n");
679
+ const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
680
+ const content = `${selector} {
681
+ ${sizeFactor}
682
+ ${formattedTokens}
683
+ }`;
684
+ const body = R8.isNotNil(layer) ? `@layer ${layer} {
685
+ ${content}
686
+ }` : content;
687
+ return body;
688
+ }
689
+ };
690
+
691
+ // src/tokens/process/formats/css.ts
692
+ var formats = {
693
+ colorScheme,
694
+ colorCategory,
695
+ semantic,
696
+ sizeMode,
697
+ size,
698
+ typography,
699
+ typeScale
700
+ };
701
+
523
702
  // src/tokens/process/configs/color.ts
524
703
  var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
525
704
  const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
@@ -541,7 +720,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
541
720
  {
542
721
  destination: `color-scheme/${colorScheme2}.css`,
543
722
  format: formats.colorScheme.name,
544
- filter: (token) => typeEquals("color", token) && !R6.startsWith(["global"], token.path)
723
+ filter: (token) => typeEquals("color", token) && !R9.startsWith(["global"], token.path)
545
724
  }
546
725
  ],
547
726
  options: {
@@ -592,7 +771,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
592
771
  };
593
772
 
594
773
  // src/tokens/process/configs/semantic.ts
595
- import * as R7 from "ramda";
774
+ import * as R10 from "ramda";
596
775
  import { outputReferencesFilter } from "style-dictionary/utils";
597
776
  var semanticVariables = ({ theme }) => {
598
777
  const selector = `:root`;
@@ -615,9 +794,12 @@ var semanticVariables = ({ theme }) => {
615
794
  destination: `semantic.css`,
616
795
  format: formats.semantic.name,
617
796
  filter: (token) => {
618
- const isUwantedToken = R7.anyPass([R7.includes("primitives/global")])(token.filePath);
619
- const isPrivateToken = R7.includes("_", token.path);
620
- const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
797
+ const isUwantedToken = R10.anyPass([R10.includes("primitives/global")])(token.filePath);
798
+ const isPrivateToken = R10.includes("_", token.path);
799
+ const unwantedPaths = pathStartsWithOneOf(
800
+ ["size", "_size", "font-size", "line-height", "letter-spacing"],
801
+ token
802
+ );
621
803
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
622
804
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
623
805
  return unwantedTokens;
@@ -627,8 +809,7 @@ var semanticVariables = ({ theme }) => {
627
809
  options: {
628
810
  outputReferences: (token, options) => {
629
811
  const include = pathStartsWithOneOf(["border-radius"], token);
630
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
631
- return (include || isWantedSize) && outputReferencesFilter(token, options);
812
+ return include && outputReferencesFilter(token, options);
632
813
  }
633
814
  }
634
815
  }
@@ -636,6 +817,124 @@ var semanticVariables = ({ theme }) => {
636
817
  };
637
818
  };
638
819
 
820
+ // src/tokens/process/configs/size.ts
821
+ import * as R11 from "ramda";
822
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
823
+ var sizeVariables = ({ theme }) => {
824
+ const selector = `:root, [data-size]`;
825
+ const layer = `ds.theme.size`;
826
+ return {
827
+ preprocessors: ["tokens-studio"],
828
+ platforms: {
829
+ css: {
830
+ // custom
831
+ theme,
832
+ basePxFontSize,
833
+ selector,
834
+ layer,
835
+ //
836
+ prefix,
837
+ buildPath: `${theme}/`,
838
+ transforms: dsTransformers,
839
+ files: [
840
+ {
841
+ destination: `size.css`,
842
+ format: formats.size.name,
843
+ filter: (token) => {
844
+ const isUwantedToken = R11.anyPass([R11.includes("primitives/global")])(token.filePath);
845
+ const isPrivateToken = R11.includes("_", token.path);
846
+ return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
847
+ }
848
+ }
849
+ ],
850
+ options: {
851
+ outputReferences: (token, options) => {
852
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
853
+ return isWantedSize && outputReferencesFilter2(token, options);
854
+ }
855
+ }
856
+ }
857
+ }
858
+ };
859
+ };
860
+
861
+ // src/tokens/process/configs/size-mode.ts
862
+ import * as R12 from "ramda";
863
+ var sizeModeVariables = ({ theme, size: size2 }) => {
864
+ const selector = `:root`;
865
+ const layer = `ds.theme.size-mode`;
866
+ return {
867
+ preprocessors: ["tokens-studio"],
868
+ platforms: {
869
+ css: {
870
+ // custom
871
+ size: size2,
872
+ theme,
873
+ basePxFontSize,
874
+ selector,
875
+ layer,
876
+ //
877
+ prefix,
878
+ buildPath: `${theme}/`,
879
+ transforms: dsTransformers,
880
+ files: [
881
+ {
882
+ destination: `size-mode/${size2}.css`,
883
+ format: formats.sizeMode.name,
884
+ filter: (token) => {
885
+ return R12.equals(["_size", "mode-font-size"], token.path);
886
+ }
887
+ }
888
+ ]
889
+ }
890
+ }
891
+ };
892
+ };
893
+
894
+ // src/tokens/process/configs/type-scale.ts
895
+ var typeScaleVariables = ({ theme, size: size2 }) => {
896
+ const selector = ":root, [data-size]";
897
+ const layer = `ds.theme.type-scale`;
898
+ return {
899
+ usesDtcg: true,
900
+ preprocessors: ["tokens-studio"],
901
+ expand: {
902
+ include: ["typography"]
903
+ },
904
+ platforms: {
905
+ css: {
906
+ prefix,
907
+ selector,
908
+ layer,
909
+ buildPath: `${theme}/`,
910
+ basePxFontSize,
911
+ transforms: [
912
+ "name/kebab",
913
+ "ts/size/px",
914
+ sizeRem.name,
915
+ "ts/size/lineheight",
916
+ "ts/typography/fontWeight",
917
+ typographyName.name
918
+ ],
919
+ files: [
920
+ {
921
+ destination: `type-scale.css`,
922
+ format: formats.typeScale.name,
923
+ filter: (token) => {
924
+ const included = typeEquals(["typography", "dimension", "fontsize"], token);
925
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
926
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
927
+ }
928
+ }
929
+ ],
930
+ options: {
931
+ outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
932
+ }
933
+ }
934
+ }
935
+ };
936
+ };
937
+
639
938
  // src/tokens/process/configs/typography.ts
640
939
  import { expandTypesMap } from "@tokens-studio/sd-transforms";
641
940
  var typographyVariables = ({ theme, typography: typography2 }) => {
@@ -670,12 +969,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
670
969
  destination: `typography/${typography2}.css`,
671
970
  format: formats.typography.name,
672
971
  filter: (token) => {
673
- const included = typeEquals(
674
- ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
675
- token
676
- );
972
+ const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
677
973
  if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
678
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
974
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
679
975
  }
680
976
  }
681
977
  ]
@@ -850,13 +1146,13 @@ var TypographyValues;
850
1146
  // src/tokens/process/utils/getMultidimensionalThemes.ts
851
1147
  import { kebabCase } from "change-case";
852
1148
  import pc2 from "picocolors";
853
- import * as R8 from "ramda";
1149
+ import * as R13 from "ramda";
854
1150
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
855
1151
  const verboseLogging = buildOptions?.verbose;
856
1152
  const grouped$themes = groupThemes(processed$themes);
857
1153
  const permutations = permutateThemes(grouped$themes);
858
1154
  const ALL_DEPENDENT_ON = ["theme"];
859
- const keys2 = R8.keys(grouped$themes);
1155
+ const keys2 = R13.keys(grouped$themes);
860
1156
  const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
861
1157
  if (verboseLogging) {
862
1158
  console.log(pc2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
@@ -896,7 +1192,7 @@ function groupThemes(themes) {
896
1192
  }
897
1193
  return groups;
898
1194
  }
899
- var hasUnknownProps = R8.pipe(R8.values, R8.none(R8.equals("unknown")), R8.not);
1195
+ var hasUnknownProps = R13.pipe(R13.values, R13.none(R13.equals("unknown")), R13.not);
900
1196
  function permutateThemes(groups) {
901
1197
  const separator = "_";
902
1198
  const permutations = cartesian(Object.values(groups));
@@ -906,8 +1202,8 @@ function permutateThemes(groups) {
906
1202
  const { group, name, selectedTokenSets } = theme;
907
1203
  let updatedPermutation = acc.permutation;
908
1204
  if (group) {
909
- const groupProp = R8.lensProp(group);
910
- updatedPermutation = R8.set(groupProp, name, updatedPermutation);
1205
+ const groupProp = R13.lensProp(group);
1206
+ updatedPermutation = R13.set(groupProp, name, updatedPermutation);
911
1207
  }
912
1208
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
913
1209
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -978,7 +1274,10 @@ var configs = {
978
1274
  dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
979
1275
  warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
980
1276
  infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
1277
+ sizeModeVariables,
1278
+ sizeVariables,
981
1279
  typographyVariables,
1280
+ typeScaleVariables,
982
1281
  semanticVariables
983
1282
  };
984
1283
  var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
@@ -995,7 +1294,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
995
1294
  obj.filePath = tokenSet;
996
1295
  }
997
1296
  });
998
- tokenSource.tokens = R9.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
1297
+ tokenSource.tokens = R14.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
999
1298
  }
1000
1299
  }
1001
1300
  } else {
@@ -1046,6 +1345,9 @@ var buildOptions = {
1046
1345
  var sd = new StyleDictionary2();
1047
1346
  var buildConfigs = {
1048
1347
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
1348
+ sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
1349
+ size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
1350
+ typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
1049
1351
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
1050
1352
  "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
1051
1353
  "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
@@ -1081,9 +1383,6 @@ async function processPlatform(options) {
1081
1383
  const platform = "css";
1082
1384
  const tokenSets = type === "format" ? options.tokenSets : void 0;
1083
1385
  const tokensDir = type === "build" ? options.tokensDir : void 0;
1084
- const filteredProcessed$themes = processed$themes.filter(
1085
- (theme) => R10.not(theme.group === "size" && theme.name !== "medium")
1086
- );
1087
1386
  const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
1088
1387
  if (UNSAFE_DEFAULT_COLOR) {
1089
1388
  console.warn(
@@ -1107,24 +1406,29 @@ async function processPlatform(options) {
1107
1406
  buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
1108
1407
  buildOptions.colorGroups = colorGroups;
1109
1408
  if (!buildOptions.defaultColor) {
1110
- const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
1111
- const firstMainColor = R10.head(customColors);
1409
+ const customColors = getCustomColors(processed$themes, colorGroups);
1410
+ const firstMainColor = R15.head(customColors);
1112
1411
  buildOptions.defaultColor = firstMainColor;
1113
1412
  }
1114
1413
  if (buildOptions.defaultColor) {
1115
1414
  console.log(`
1116
1415
  \u{1F3A8} Using ${pc3.blue(buildOptions.defaultColor)} as default color`);
1117
1416
  }
1118
- const buildAndSdConfigs = R10.map((buildConfig) => {
1119
- const sdConfigs = getConfigsForThemeDimensions(
1120
- buildConfig.getConfig,
1121
- filteredProcessed$themes,
1122
- buildConfig.dimensions,
1123
- {
1124
- tokensDir,
1125
- tokenSets
1126
- }
1127
- );
1417
+ const sizeModes = processed$themes.filter((x) => x.group === "size").map((x) => x.name);
1418
+ buildOptions.sizeModes = sizeModes;
1419
+ if (!buildOptions.defaultSize) {
1420
+ const defaultSize = R15.head(sizeModes);
1421
+ buildOptions.defaultSize = defaultSize;
1422
+ }
1423
+ if (buildOptions.defaultSize) {
1424
+ console.log(`
1425
+ \u{1F4CF} Using ${pc3.blue(buildOptions.defaultSize)} as default size`);
1426
+ }
1427
+ const buildAndSdConfigs = R15.map((buildConfig) => {
1428
+ const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
1429
+ tokensDir,
1430
+ tokenSets
1431
+ });
1128
1432
  const unknownConfigs = buildConfig.dimensions.map(
1129
1433
  (dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
1130
1434
  );
@@ -1148,10 +1452,13 @@ async function processPlatform(options) {
1148
1452
  "warning-color": [initResult],
1149
1453
  "info-color": [initResult],
1150
1454
  semantic: [initResult],
1151
- typography: [initResult]
1455
+ typography: [initResult],
1456
+ sizeMode: [initResult],
1457
+ size: [initResult],
1458
+ typeScale: [initResult]
1152
1459
  };
1153
1460
  try {
1154
- for (const [buildName, { buildConfig, sdConfigs }] of R10.toPairs(buildAndSdConfigs)) {
1461
+ for (const [buildName, { buildConfig, sdConfigs }] of R15.toPairs(buildAndSdConfigs)) {
1155
1462
  if (!(buildConfig.enabled?.() ?? true)) {
1156
1463
  continue;
1157
1464
  }
@@ -1163,7 +1470,7 @@ async function processPlatform(options) {
1163
1470
  const { config, permutation } = sdConfig;
1164
1471
  const modes = ["theme", ...buildConfig.dimensions];
1165
1472
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
1166
- const logMessage = R10.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1473
+ const logMessage = R15.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1167
1474
  console.log(logMessage);
1168
1475
  const sdOptions = { cache: true };
1169
1476
  const sdExtended = await sd.extend(config);
@@ -1289,8 +1596,12 @@ ${dynamicColors}`;
1289
1596
 
1290
1597
  // src/tokens/process/output/theme.ts
1291
1598
  import pc5 from "picocolors";
1292
- import * as R11 from "ramda";
1599
+ import * as R16 from "ramda";
1293
1600
  var defaultFileHeader2 = `build: v${package_default.version}`;
1601
+ var getFileNameWithoutExtension = (path2) => {
1602
+ const pathSegments = path2.split("/");
1603
+ return pathSegments[pathSegments.length - 1].split(".").slice(0, -1).join(".");
1604
+ };
1294
1605
  var createThemeCSSFiles = ({
1295
1606
  processedBuilds,
1296
1607
  fileHeader = defaultFileHeader2
@@ -1300,22 +1611,25 @@ var createThemeCSSFiles = ({
1300
1611
  for (const buildResult of buildResults) {
1301
1612
  const themeName = buildResult.permutation.theme;
1302
1613
  const newOutputs = buildResult.formatted;
1303
- if (R11.isNotEmpty(newOutputs)) {
1614
+ if (R16.isNotEmpty(newOutputs)) {
1304
1615
  const currentOutputs = groupedByTheme[themeName] ?? [];
1305
- groupedByTheme[themeName] = R11.concat(currentOutputs, newOutputs);
1616
+ groupedByTheme[themeName] = R16.concat(currentOutputs, newOutputs);
1306
1617
  }
1307
1618
  }
1308
1619
  }
1309
1620
  const sortOrder = [
1621
+ "size-mode/",
1622
+ "type-scale",
1310
1623
  "color-scheme/light",
1311
1624
  "typography/secondary",
1625
+ "size",
1312
1626
  "semantic",
1313
1627
  "color-scheme/dark",
1314
1628
  "color-scheme/contrast",
1315
1629
  "typography/primary",
1316
1630
  "color/"
1317
1631
  ];
1318
- const sortByDefinedOrder = R11.sortBy((file) => {
1632
+ const sortByDefinedOrder = R16.sortBy((file) => {
1319
1633
  const filePath = file.destination || "";
1320
1634
  const sortIndex = sortOrder.findIndex((sortElement) => {
1321
1635
  if (sortElement.endsWith("/")) {
@@ -1344,13 +1658,17 @@ ${fileHeader}
1344
1658
  */
1345
1659
 
1346
1660
  `;
1347
- const sortAlphabetically = R11.sort(R11.ascend((x) => x.destination || ""));
1348
- const pickOutputs = R11.map(R11.view(R11.lensProp("output")));
1349
- const themeCSSFile = R11.pipe(
1661
+ const sortAlphabetically = R16.sort(R16.ascend((x) => x.destination || ""));
1662
+ const sortBySize = R16.sortBy(
1663
+ R16.pipe((s) => getFileNameWithoutExtension(s.destination ?? ""), sizeComparator)
1664
+ );
1665
+ const pickOutputs = R16.map(R16.view(R16.lensProp("output")));
1666
+ const themeCSSFile = R16.pipe(
1350
1667
  sortAlphabetically,
1668
+ sortBySize,
1351
1669
  sortByDefinedOrder,
1352
1670
  pickOutputs,
1353
- R11.join("\n"),
1671
+ R16.join("\n"),
1354
1672
  (content) => header + content
1355
1673
  );
1356
1674
  const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
@@ -1393,7 +1711,7 @@ var buildTokens = async (options) => {
1393
1711
  processed$themes,
1394
1712
  buildTokenFormats: {}
1395
1713
  });
1396
- const fileHeader = R12.join("")([
1714
+ const fileHeader = R17.join("")([
1397
1715
  defaultFileHeader2,
1398
1716
  $designsystemet ? `
1399
1717
  design-tokens: v${$designsystemet.version}` : ""