@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
package/dist/src/index.js CHANGED
@@ -627,95 +627,99 @@ var global_default = {
627
627
  _size: {
628
628
  "0": {
629
629
  $type: "dimension",
630
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *0)"
630
+ $value: "floor({_size.unit} * 0)"
631
631
  },
632
632
  "1": {
633
633
  $type: "dimension",
634
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *1)"
634
+ $value: "floor({_size.unit} * 1)"
635
635
  },
636
636
  "2": {
637
637
  $type: "dimension",
638
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *2)"
638
+ $value: "floor({_size.unit} * 2)"
639
639
  },
640
640
  "3": {
641
641
  $type: "dimension",
642
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *3)"
642
+ $value: "floor({_size.unit} * 3)"
643
643
  },
644
644
  "4": {
645
645
  $type: "dimension",
646
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *4)"
646
+ $value: "floor({_size.unit} * 4)"
647
647
  },
648
648
  "5": {
649
649
  $type: "dimension",
650
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *5)"
650
+ $value: "floor({_size.unit} * 5)"
651
651
  },
652
652
  "6": {
653
653
  $type: "dimension",
654
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *6)"
654
+ $value: "floor({_size.unit} * 6)"
655
655
  },
656
656
  "7": {
657
657
  $type: "dimension",
658
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *7)"
658
+ $value: "floor({_size.unit} * 7)"
659
659
  },
660
660
  "8": {
661
661
  $type: "dimension",
662
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *8)"
662
+ $value: "floor({_size.unit} * 8)"
663
663
  },
664
664
  "9": {
665
665
  $type: "dimension",
666
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *9)"
666
+ $value: "floor({_size.unit} * 9)"
667
667
  },
668
668
  "10": {
669
669
  $type: "dimension",
670
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *10)"
670
+ $value: "floor({_size.unit} * 10)"
671
671
  },
672
672
  "11": {
673
673
  $type: "dimension",
674
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *11)"
674
+ $value: "floor({_size.unit} * 11)"
675
675
  },
676
676
  "12": {
677
677
  $type: "dimension",
678
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *12)"
678
+ $value: "floor({_size.unit} * 12)"
679
679
  },
680
680
  "13": {
681
681
  $type: "dimension",
682
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *13)"
682
+ $value: "floor({_size.unit} * 13)"
683
683
  },
684
684
  "14": {
685
685
  $type: "dimension",
686
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *14)"
686
+ $value: "floor({_size.unit} * 14)"
687
687
  },
688
688
  "15": {
689
689
  $type: "dimension",
690
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *15)"
690
+ $value: "floor({_size.unit} * 15)"
691
691
  },
692
692
  "18": {
693
693
  $type: "dimension",
694
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *18)"
694
+ $value: "floor({_size.unit} * 18)"
695
695
  },
696
696
  "22": {
697
697
  $type: "dimension",
698
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *22)"
698
+ $value: "floor({_size.unit} * 22)"
699
699
  },
700
700
  "26": {
701
701
  $type: "dimension",
702
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *26)"
702
+ $value: "floor({_size.unit} * 26)"
703
703
  },
704
704
  "30": {
705
705
  $type: "dimension",
706
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *30)"
706
+ $value: "floor({_size.unit} * 30)"
707
707
  },
708
708
  "mode-font-size": {
709
- $type: "dimension",
709
+ $type: "number",
710
710
  $value: "{size._mode-font-size}"
711
711
  },
712
712
  base: {
713
- $type: "dimension",
713
+ $type: "number",
714
714
  $value: "{size._base}"
715
715
  },
716
716
  step: {
717
- $type: "dimension",
717
+ $type: "number",
718
718
  $value: "{size._step}"
719
+ },
720
+ unit: {
721
+ $type: "number",
722
+ $value: "{_size.step} / {_size.base} * {_size.mode-font-size}"
719
723
  }
720
724
  }
721
725
  };
@@ -2232,7 +2236,7 @@ var createTokens = async (opts) => {
2232
2236
  };
2233
2237
 
2234
2238
  // src/tokens/format.ts
2235
- import * as R18 from "ramda";
2239
+ import * as R23 from "ramda";
2236
2240
 
2237
2241
  // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
2238
2242
  var BoxShadowTypes;
@@ -2567,12 +2571,12 @@ function generateTypographyGroup(themes) {
2567
2571
 
2568
2572
  // src/tokens/process/output/theme.ts
2569
2573
  import pc from "picocolors";
2570
- import * as R7 from "ramda";
2574
+ import * as R8 from "ramda";
2571
2575
 
2572
2576
  // package.json
2573
2577
  var package_default = {
2574
2578
  name: "@digdir/designsystemet",
2575
- version: "1.4.0",
2579
+ version: "1.5.0",
2576
2580
  description: "CLI for Designsystemet",
2577
2581
  author: "Designsystemet team",
2578
2582
  engines: {
@@ -2655,7 +2659,7 @@ var package_default = {
2655
2659
  "@types/apca-w3": "^0.1.3",
2656
2660
  "@types/chroma-js": "^3.1.1",
2657
2661
  "@types/fs-extra": "^11.0.4",
2658
- "@types/node": "^22.18.0",
2662
+ "@types/node": "^22.18.1",
2659
2663
  "@types/object-hash": "^3.0.6",
2660
2664
  "@types/ramda": "^0.31.0",
2661
2665
  "fs-extra": "^11.3.1",
@@ -2666,8 +2670,109 @@ var package_default = {
2666
2670
  }
2667
2671
  };
2668
2672
 
2673
+ // src/tokens/utils.ts
2674
+ import * as R7 from "ramda";
2675
+
2676
+ // src/tokens/types.ts
2677
+ var colorCategories = {
2678
+ main: "main",
2679
+ support: "support"
2680
+ };
2681
+
2682
+ // src/tokens/utils.ts
2683
+ var mapToLowerCase = R7.map(R7.toLower);
2684
+ var hasAnyTruth = R7.any(R7.equals(true));
2685
+ var getType = (token) => (token.$type ?? token.type) || "";
2686
+ var getValue = (token) => token.$value ?? token.value;
2687
+ var typeEquals = R7.curry(
2688
+ (types, token) => {
2689
+ if (R7.isNil(token)) {
2690
+ return false;
2691
+ }
2692
+ return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
2693
+ }
2694
+ );
2695
+ var pathStartsWithOneOf = R7.curry(
2696
+ (paths, token) => {
2697
+ if (R7.isNil(token)) {
2698
+ return false;
2699
+ }
2700
+ const tokenPath = mapToLowerCase(token.path);
2701
+ const matchPathsStartingWith = R7.map((pathOrString) => {
2702
+ const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
2703
+ return R7.startsWith(mapToLowerCase(path), tokenPath);
2704
+ }, paths);
2705
+ return hasAnyTruth(matchPathsStartingWith);
2706
+ }
2707
+ );
2708
+ function isSemanticToken(token) {
2709
+ return token.filePath.includes("semantic/");
2710
+ }
2711
+ function isSemanticColorToken(token, color) {
2712
+ return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
2713
+ }
2714
+ function isGlobalColorToken(token) {
2715
+ return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
2716
+ }
2717
+ function isColorCategoryToken(token, category) {
2718
+ if (!category) {
2719
+ return Object.keys(colorCategories).some(
2720
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
2721
+ );
2722
+ }
2723
+ return R7.startsWith(["color", category], token.path);
2724
+ }
2725
+ var isDigit = (s) => /^\d+$/.test(s);
2726
+ function traverseObj(obj, fn) {
2727
+ for (const key in obj) {
2728
+ const prop4 = obj[key];
2729
+ if (prop4 != null) {
2730
+ fn.apply(null, [obj, key, prop4]);
2731
+ if (typeof prop4 === "object") {
2732
+ traverseObj(prop4, fn);
2733
+ }
2734
+ }
2735
+ }
2736
+ return obj;
2737
+ }
2738
+ function inlineTokens(shouldInline, tokens) {
2739
+ const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
2740
+ return otherTokens.map((token) => {
2741
+ let transformed = getValue(token.original);
2742
+ for (const ref of inlineableTokens) {
2743
+ const refName = ref.path.join(".");
2744
+ if (typeof transformed === "string") {
2745
+ transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
2746
+ }
2747
+ }
2748
+ const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
2749
+ return tokenWithInlinedRefs;
2750
+ });
2751
+ }
2752
+ var sizeMap = {
2753
+ xsmall: "xs",
2754
+ small: "sm",
2755
+ medium: "md",
2756
+ large: "lg",
2757
+ xlarge: "xl"
2758
+ };
2759
+ function shortSizeName(size2) {
2760
+ return sizeMap[size2] ?? size2;
2761
+ }
2762
+ var sizeComparator = (size2) => {
2763
+ const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
2764
+ return sortIndex ?? 0;
2765
+ };
2766
+ function orderBySize(sizes) {
2767
+ return R7.sortBy(sizeComparator, sizes);
2768
+ }
2769
+
2669
2770
  // src/tokens/process/output/theme.ts
2670
2771
  var defaultFileHeader = `build: v${package_default.version}`;
2772
+ var getFileNameWithoutExtension = (path) => {
2773
+ const pathSegments = path.split("/");
2774
+ return pathSegments[pathSegments.length - 1].split(".").slice(0, -1).join(".");
2775
+ };
2671
2776
  var createThemeCSSFiles = ({
2672
2777
  processedBuilds,
2673
2778
  fileHeader = defaultFileHeader
@@ -2677,22 +2782,25 @@ var createThemeCSSFiles = ({
2677
2782
  for (const buildResult of buildResults) {
2678
2783
  const themeName = buildResult.permutation.theme;
2679
2784
  const newOutputs = buildResult.formatted;
2680
- if (R7.isNotEmpty(newOutputs)) {
2785
+ if (R8.isNotEmpty(newOutputs)) {
2681
2786
  const currentOutputs = groupedByTheme[themeName] ?? [];
2682
- groupedByTheme[themeName] = R7.concat(currentOutputs, newOutputs);
2787
+ groupedByTheme[themeName] = R8.concat(currentOutputs, newOutputs);
2683
2788
  }
2684
2789
  }
2685
2790
  }
2686
2791
  const sortOrder = [
2792
+ "size-mode/",
2793
+ "type-scale",
2687
2794
  "color-scheme/light",
2688
2795
  "typography/secondary",
2796
+ "size",
2689
2797
  "semantic",
2690
2798
  "color-scheme/dark",
2691
2799
  "color-scheme/contrast",
2692
2800
  "typography/primary",
2693
2801
  "color/"
2694
2802
  ];
2695
- const sortByDefinedOrder = R7.sortBy((file) => {
2803
+ const sortByDefinedOrder = R8.sortBy((file) => {
2696
2804
  const filePath = file.destination || "";
2697
2805
  const sortIndex = sortOrder.findIndex((sortElement) => {
2698
2806
  if (sortElement.endsWith("/")) {
@@ -2721,13 +2829,17 @@ ${fileHeader}
2721
2829
  */
2722
2830
 
2723
2831
  `;
2724
- const sortAlphabetically = R7.sort(R7.ascend((x) => x.destination || ""));
2725
- const pickOutputs = R7.map(R7.view(R7.lensProp("output")));
2726
- const themeCSSFile = R7.pipe(
2832
+ const sortAlphabetically = R8.sort(R8.ascend((x) => x.destination || ""));
2833
+ const sortBySize = R8.sortBy(
2834
+ R8.pipe((s) => getFileNameWithoutExtension(s.destination ?? ""), sizeComparator)
2835
+ );
2836
+ const pickOutputs = R8.map(R8.view(R8.lensProp("output")));
2837
+ const themeCSSFile = R8.pipe(
2727
2838
  sortAlphabetically,
2839
+ sortBySize,
2728
2840
  sortByDefinedOrder,
2729
2841
  pickOutputs,
2730
- R7.join("\n"),
2842
+ R8.join("\n"),
2731
2843
  (content) => header + content
2732
2844
  );
2733
2845
  const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
@@ -2739,91 +2851,16 @@ ${fileHeader}
2739
2851
 
2740
2852
  // src/tokens/process/platform.ts
2741
2853
  import pc3 from "picocolors";
2742
- import * as R17 from "ramda";
2854
+ import * as R22 from "ramda";
2743
2855
  import StyleDictionary2 from "style-dictionary";
2744
2856
 
2745
- // src/tokens/types.ts
2746
- var colorCategories = {
2747
- main: "main",
2748
- support: "support"
2749
- };
2750
-
2751
2857
  // src/tokens/process/configs.ts
2752
2858
  import { register } from "@tokens-studio/sd-transforms";
2753
- import * as R16 from "ramda";
2859
+ import * as R21 from "ramda";
2754
2860
  import StyleDictionary from "style-dictionary";
2755
2861
 
2756
- // src/tokens/utils.ts
2757
- import * as R8 from "ramda";
2758
- var mapToLowerCase = R8.map(R8.toLower);
2759
- var hasAnyTruth = R8.any(R8.equals(true));
2760
- var getType = (token) => (token.$type ?? token.type) || "";
2761
- var getValue = (token) => token.$value ?? token.value;
2762
- var typeEquals = R8.curry(
2763
- (types, token) => {
2764
- if (R8.isNil(token)) {
2765
- return false;
2766
- }
2767
- return R8.includes(R8.toLower(getType(token)), R8.map(R8.toLower, Array.isArray(types) ? types : [types]));
2768
- }
2769
- );
2770
- var pathStartsWithOneOf = R8.curry(
2771
- (paths, token) => {
2772
- if (R8.isNil(token)) {
2773
- return false;
2774
- }
2775
- const tokenPath = mapToLowerCase(token.path);
2776
- const matchPathsStartingWith = R8.map((path) => R8.startsWith([path], tokenPath), mapToLowerCase(paths));
2777
- return hasAnyTruth(matchPathsStartingWith);
2778
- }
2779
- );
2780
- function isSemanticToken(token) {
2781
- return token.filePath.includes("semantic/");
2782
- }
2783
- function isSemanticColorToken(token, color) {
2784
- return token.filePath.includes("semantic/") && R8.startsWith(["color", color], token.path);
2785
- }
2786
- function isGlobalColorToken(token) {
2787
- return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
2788
- }
2789
- function isColorCategoryToken(token, category) {
2790
- if (!category) {
2791
- return Object.keys(colorCategories).some(
2792
- (colorCategory2) => isColorCategoryToken(token, colorCategory2)
2793
- );
2794
- }
2795
- return R8.startsWith(["color", category], token.path);
2796
- }
2797
- var isDigit = (s) => /^\d+$/.test(s);
2798
- function traverseObj(obj, fn) {
2799
- for (const key in obj) {
2800
- const prop = obj[key];
2801
- if (prop != null) {
2802
- fn.apply(null, [obj, key, prop]);
2803
- if (typeof prop === "object") {
2804
- traverseObj(prop, fn);
2805
- }
2806
- }
2807
- }
2808
- return obj;
2809
- }
2810
- function inlineTokens(shouldInline, tokens) {
2811
- const [inlineableTokens, otherTokens] = R8.partition(shouldInline, tokens);
2812
- return otherTokens.map((token) => {
2813
- let transformed = getValue(token.original);
2814
- for (const ref of inlineableTokens) {
2815
- const refName = ref.path.join(".");
2816
- if (typeof transformed === "string") {
2817
- transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
2818
- }
2819
- }
2820
- const tokenWithInlinedRefs = R8.set(R8.lensPath(["original", "$value"]), transformed, token);
2821
- return tokenWithInlinedRefs;
2822
- });
2823
- }
2824
-
2825
2862
  // src/tokens/process/configs/color.ts
2826
- import * as R13 from "ramda";
2863
+ import * as R16 from "ramda";
2827
2864
 
2828
2865
  // src/tokens/process/formats/css/color.ts
2829
2866
  import * as R9 from "ramda";
@@ -2881,10 +2918,10 @@ ${selector} ${content} ${autoSelectorContent}
2881
2918
  };
2882
2919
  var colorCategory = {
2883
2920
  name: "ds/css-colorcategory",
2884
- format: async ({ dictionary, options, platform }) => {
2921
+ format: async ({ dictionary, file, options, platform }) => {
2885
2922
  const { outputReferences, usesDtcg } = options;
2886
- const { selector, layer, files } = platform;
2887
- const destination = files?.[0]?.destination;
2923
+ const { selector, layer } = platform;
2924
+ const destination = file.destination;
2888
2925
  const format = R9.compose(
2889
2926
  createPropertyFormatter({
2890
2927
  outputReferences,
@@ -2921,6 +2958,10 @@ ${selector} ${content}
2921
2958
  };
2922
2959
 
2923
2960
  // src/tokens/process/formats/css/semantic.ts
2961
+ import * as R11 from "ramda";
2962
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
2963
+
2964
+ // src/tokens/process/formats/css/size.ts
2924
2965
  import * as R10 from "ramda";
2925
2966
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
2926
2967
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
@@ -2928,12 +2969,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
2928
2969
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
2929
2970
  var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
2930
2971
  var overrideSizingFormula = (format, token) => {
2931
- const [name, value] = format(token).split(":");
2932
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
2933
- const round = `round(down, ${calc}, 1px)`;
2972
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
2973
+ let calc;
2974
+ let round;
2975
+ if (token.path[1] === "unit") {
2976
+ calc = `calc(1rem * ${value})`;
2977
+ } else if (value.startsWith("floor")) {
2978
+ calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
2979
+ round = `round(down, ${calc}, 1px)`;
2980
+ } else {
2981
+ calc = value.includes("*") ? `calc(${value})` : value;
2982
+ }
2934
2983
  return {
2935
2984
  name,
2936
- round,
2985
+ round: round ?? calc,
2937
2986
  calc
2938
2987
  };
2939
2988
  };
@@ -2949,18 +2998,21 @@ var formatSizingTokens = (format, tokens) => R10.reduce(
2949
2998
  { tokens: [], round: [], calc: [] },
2950
2999
  tokens
2951
3000
  );
2952
- var sizingTemplate = ({ round, calc }) => `
3001
+ var sizingTemplate = ({ round, calc }) => {
3002
+ const usesRounding = round.filter((val, i) => val !== calc[i]);
3003
+ return `
2953
3004
  ${calc.join("\n")}
2954
3005
 
2955
3006
  @supports (width: round(down, .1em, 1px)) {
2956
- ${round.join("\n")}
3007
+ ${usesRounding.join("\n ")}
2957
3008
  }`;
2958
- var semantic = {
2959
- name: "ds/css-semantic",
2960
- format: async ({ dictionary, options, platform }) => {
3009
+ };
3010
+ var size = {
3011
+ name: "ds/css-size",
3012
+ format: async ({ dictionary, file, options, platform }) => {
2961
3013
  const { outputReferences, usesDtcg } = options;
2962
- const { selector, layer, files } = platform;
2963
- const destination = files?.[0]?.destination;
3014
+ const { selector, layer } = platform;
3015
+ const destination = file.destination;
2964
3016
  const format = createPropertyFormatter2({
2965
3017
  outputReferences,
2966
3018
  dictionary,
@@ -2968,9 +3020,9 @@ var semantic = {
2968
3020
  usesDtcg
2969
3021
  });
2970
3022
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
2971
- const filteredTokens = R10.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
3023
+ const filteredTokens = R10.reject((token) => R10.equals(["_size", "mode-font-size"], token.path), tokens);
2972
3024
  const [sizingTokens, restTokens] = R10.partition(
2973
- (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
3025
+ (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
2974
3026
  filteredTokens
2975
3027
  );
2976
3028
  const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
@@ -2983,64 +3035,56 @@ var semantic = {
2983
3035
  formatted: t
2984
3036
  }));
2985
3037
  buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
2986
- const sizingSnippet = sizingTemplate(formattedSizingTokens);
2987
- const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).concat(sizingSnippet);
2988
- const content = `{
3038
+ const formattedTokens = [formattedMap.map(R10.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
3039
+ const content = `${selector} {
2989
3040
  ${formattedTokens.join("\n")}
2990
3041
  }
2991
3042
  `;
2992
3043
  const body = R10.isNotNil(layer) ? `@layer ${layer} {
2993
- ${selector} ${content}
3044
+ ${content}
2994
3045
  }
2995
- ` : `${selector} ${content}
3046
+ ` : `${content}
2996
3047
  `;
2997
3048
  return body;
2998
3049
  }
2999
3050
  };
3000
3051
 
3001
- // src/tokens/process/formats/css/typography.ts
3002
- import * as R11 from "ramda";
3003
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
3004
- var typographyFontFamilyPredicate = R11.allPass([
3005
- R11.pathSatisfies(R11.includes("typography"), ["path"]),
3006
- R11.pathSatisfies(R11.includes("fontFamily"), ["path"])
3007
- ]);
3008
- var typography = {
3009
- name: "ds/css-typography",
3010
- format: async ({ dictionary, options, platform }) => {
3052
+ // src/tokens/process/formats/css/semantic.ts
3053
+ var semantic = {
3054
+ name: "ds/css-semantic",
3055
+ format: async ({ dictionary, file, options, platform }) => {
3011
3056
  const { outputReferences, usesDtcg } = options;
3012
- const { selector, layer, files } = platform;
3013
- const destination = files?.[0]?.destination;
3057
+ const { selector, layer } = platform;
3058
+ const destination = file.destination;
3014
3059
  const format = createPropertyFormatter3({
3015
3060
  outputReferences,
3016
3061
  dictionary,
3017
3062
  format: "css",
3018
3063
  usesDtcg
3019
3064
  });
3020
- const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
3021
- const formattedMap = filteredTokens.map((token) => ({
3065
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
3066
+ const formattedMap = tokens.map((token) => ({
3022
3067
  token,
3023
3068
  formatted: format(token)
3024
3069
  }));
3025
3070
  buildOptions.buildTokenFormats[destination] = formattedMap;
3026
- const formattedTokens = formattedMap.map(R11.view(R11.lensProp("formatted"))).join("\n");
3027
- const content = selector ? `${selector} {
3071
+ const formattedTokens = formattedMap.map(R11.prop("formatted")).join("\n");
3072
+ const content = `${selector} {
3028
3073
  ${formattedTokens}
3029
- }` : formattedTokens;
3074
+ }
3075
+ `;
3030
3076
  const body = R11.isNotNil(layer) ? `@layer ${layer} {
3031
3077
  ${content}
3032
- }` : content;
3078
+ }
3079
+ ` : `${content}
3080
+ `;
3033
3081
  return body;
3034
3082
  }
3035
3083
  };
3036
3084
 
3037
- // src/tokens/process/formats/css.ts
3038
- var formats = {
3039
- colorScheme,
3040
- colorCategory,
3041
- semantic,
3042
- typography
3043
- };
3085
+ // src/tokens/process/formats/css/size-mode.ts
3086
+ import * as R13 from "ramda";
3087
+ import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
3044
3088
 
3045
3089
  // src/tokens/process/transformers.ts
3046
3090
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
@@ -3052,18 +3096,22 @@ var sizeRem = {
3052
3096
  transitive: true,
3053
3097
  filter: (token) => {
3054
3098
  const hasWantedType = typeEquals(["dimension", "fontsize"], token);
3055
- const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
3099
+ const hasWantedPath = pathStartsWithOneOf([
3100
+ "border-radius",
3101
+ "font-size"
3102
+ /*, ['_size', 'mode-font-size']*/
3103
+ ], token);
3056
3104
  return hasWantedType && hasWantedPath;
3057
3105
  },
3058
3106
  transform: (token, config) => {
3059
3107
  const value = getValue(token);
3060
3108
  if (isPx(value)) {
3061
3109
  const baseFont = config.basePxFontSize || 16;
3062
- const size = parseInt(value, 10);
3063
- if (size === 0) {
3110
+ const size2 = parseInt(value, 10);
3111
+ if (size2 === 0) {
3064
3112
  return "0";
3065
3113
  }
3066
- return `${size / baseFont}rem`;
3114
+ return `${size2 / baseFont}rem`;
3067
3115
  }
3068
3116
  return value;
3069
3117
  }
@@ -3114,6 +3162,154 @@ var dsTransformers = [
3114
3162
  "shadow/css/shorthand"
3115
3163
  ];
3116
3164
 
3165
+ // src/tokens/process/formats/css/size-mode.ts
3166
+ var formatBaseSizeToken = (size2) => (token) => ({
3167
+ ...token,
3168
+ originalName: token.name,
3169
+ name: `${token.name}--${shortSizeName(size2)}`,
3170
+ $value: token.$value / basePxFontSize
3171
+ });
3172
+ var sizeMode = {
3173
+ name: "ds/css-size-mode",
3174
+ format: async ({ dictionary, file, options, platform }) => {
3175
+ const { outputReferences, usesDtcg } = options;
3176
+ const { selector, layer, size: size2 } = platform;
3177
+ const destination = file.destination;
3178
+ const format = createPropertyFormatter4({
3179
+ outputReferences,
3180
+ dictionary,
3181
+ format: "css",
3182
+ usesDtcg
3183
+ });
3184
+ const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
3185
+ const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
3186
+ const formattedMap = sizeSpecificTokens.map((token) => ({
3187
+ token,
3188
+ formatted: format({
3189
+ ...token,
3190
+ // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
3191
+ name: token.originalName
3192
+ })
3193
+ }));
3194
+ buildOptions.buildTokenFormats[destination] = formattedMap;
3195
+ const content = `${selector} /* ${size2} */ {
3196
+ ${sizeSpecificVariables}
3197
+ }`;
3198
+ const body = wrapInLayer(content, layer);
3199
+ const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
3200
+ const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
3201
+ const sizingToggles = `:root, [data-size] {
3202
+ --ds-size: var(--ds-size--${defaultSize});
3203
+ ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
3204
+ --ds-size-mode-font-size:
3205
+ ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
3206
+ }`;
3207
+ const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
3208
+ const sharedContent = `${sizingToggles}
3209
+
3210
+ ${sizingHelpers}`;
3211
+ const sharedBody = shortSizeName(size2) === R13.last(sizes) ? `
3212
+ ${wrapInLayer(sharedContent, layer)}` : "";
3213
+ return body + sharedBody;
3214
+ }
3215
+ };
3216
+ function wrapInLayer(content, layer) {
3217
+ return R13.isNotNil(layer) ? `@layer ${layer} {
3218
+ ${content}
3219
+ }
3220
+ ` : `${content}
3221
+ `;
3222
+ }
3223
+
3224
+ // src/tokens/process/formats/css/typography.ts
3225
+ import * as R14 from "ramda";
3226
+ import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
3227
+ var typographyFontFamilyPredicate = R14.allPass([
3228
+ R14.pathSatisfies(R14.includes("typography"), ["path"]),
3229
+ R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
3230
+ ]);
3231
+ var typography = {
3232
+ name: "ds/css-typography",
3233
+ format: async ({ dictionary, file, options, platform }) => {
3234
+ const { outputReferences, usesDtcg } = options;
3235
+ const { selector, layer } = platform;
3236
+ const destination = file.destination;
3237
+ const format = createPropertyFormatter5({
3238
+ outputReferences,
3239
+ dictionary,
3240
+ format: "css",
3241
+ usesDtcg
3242
+ });
3243
+ const filteredTokens = R14.reject(typographyFontFamilyPredicate, dictionary.allTokens);
3244
+ const formattedMap = filteredTokens.map((token) => ({
3245
+ token,
3246
+ formatted: format(token)
3247
+ }));
3248
+ buildOptions.buildTokenFormats[destination] = formattedMap;
3249
+ const formattedTokens = formattedMap.map(R14.view(R14.lensProp("formatted"))).join("\n");
3250
+ const content = selector ? `${selector} {
3251
+ ${formattedTokens}
3252
+ }` : formattedTokens;
3253
+ const body = R14.isNotNil(layer) ? `@layer ${layer} {
3254
+ ${content}
3255
+ }` : content;
3256
+ return body;
3257
+ }
3258
+ };
3259
+
3260
+ // src/tokens/process/formats/css/type-scale.ts
3261
+ import * as R15 from "ramda";
3262
+ import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
3263
+ var typographyFontFamilyPredicate2 = R15.allPass([
3264
+ R15.pathSatisfies(R15.includes("typography"), ["path"]),
3265
+ R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
3266
+ ]);
3267
+ function formatTypographySizeToken(token) {
3268
+ return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
3269
+ }
3270
+ var typeScale = {
3271
+ name: "ds/css-type-scale",
3272
+ format: async ({ dictionary, file, options, platform }) => {
3273
+ const { outputReferences, usesDtcg } = options;
3274
+ const { selector, layer } = platform;
3275
+ const destination = file.destination;
3276
+ const format = createPropertyFormatter6({
3277
+ outputReferences,
3278
+ dictionary,
3279
+ format: "css",
3280
+ usesDtcg
3281
+ });
3282
+ const filteredTokens = R15.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
3283
+ const tokens = R15.map(formatTypographySizeToken, filteredTokens);
3284
+ const formattedMap = tokens.map((token) => ({
3285
+ token,
3286
+ formatted: format(token)
3287
+ }));
3288
+ buildOptions.buildTokenFormats[destination] = formattedMap;
3289
+ const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
3290
+ const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
3291
+ const content = `${selector} {
3292
+ ${sizeFactor}
3293
+ ${formattedTokens}
3294
+ }`;
3295
+ const body = R15.isNotNil(layer) ? `@layer ${layer} {
3296
+ ${content}
3297
+ }` : content;
3298
+ return body;
3299
+ }
3300
+ };
3301
+
3302
+ // src/tokens/process/formats/css.ts
3303
+ var formats = {
3304
+ colorScheme,
3305
+ colorCategory,
3306
+ semantic,
3307
+ sizeMode,
3308
+ size,
3309
+ typography,
3310
+ typeScale
3311
+ };
3312
+
3117
3313
  // src/tokens/process/configs/color.ts
3118
3314
  var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
3119
3315
  const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
@@ -3135,7 +3331,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
3135
3331
  {
3136
3332
  destination: `color-scheme/${colorScheme2}.css`,
3137
3333
  format: formats.colorScheme.name,
3138
- filter: (token) => typeEquals("color", token) && !R13.startsWith(["global"], token.path)
3334
+ filter: (token) => typeEquals("color", token) && !R16.startsWith(["global"], token.path)
3139
3335
  }
3140
3336
  ],
3141
3337
  options: {
@@ -3186,7 +3382,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
3186
3382
  };
3187
3383
 
3188
3384
  // src/tokens/process/configs/semantic.ts
3189
- import * as R14 from "ramda";
3385
+ import * as R17 from "ramda";
3190
3386
  import { outputReferencesFilter } from "style-dictionary/utils";
3191
3387
  var semanticVariables = ({ theme }) => {
3192
3388
  const selector = `:root`;
@@ -3209,9 +3405,12 @@ var semanticVariables = ({ theme }) => {
3209
3405
  destination: `semantic.css`,
3210
3406
  format: formats.semantic.name,
3211
3407
  filter: (token) => {
3212
- const isUwantedToken = R14.anyPass([R14.includes("primitives/global")])(token.filePath);
3213
- const isPrivateToken = R14.includes("_", token.path);
3214
- const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
3408
+ const isUwantedToken = R17.anyPass([R17.includes("primitives/global")])(token.filePath);
3409
+ const isPrivateToken = R17.includes("_", token.path);
3410
+ const unwantedPaths = pathStartsWithOneOf(
3411
+ ["size", "_size", "font-size", "line-height", "letter-spacing"],
3412
+ token
3413
+ );
3215
3414
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
3216
3415
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
3217
3416
  return unwantedTokens;
@@ -3221,8 +3420,48 @@ var semanticVariables = ({ theme }) => {
3221
3420
  options: {
3222
3421
  outputReferences: (token, options) => {
3223
3422
  const include = pathStartsWithOneOf(["border-radius"], token);
3224
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
3225
- return (include || isWantedSize) && outputReferencesFilter(token, options);
3423
+ return include && outputReferencesFilter(token, options);
3424
+ }
3425
+ }
3426
+ }
3427
+ }
3428
+ };
3429
+ };
3430
+
3431
+ // src/tokens/process/configs/size.ts
3432
+ import * as R18 from "ramda";
3433
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
3434
+ var sizeVariables = ({ theme }) => {
3435
+ const selector = `:root, [data-size]`;
3436
+ const layer = `ds.theme.size`;
3437
+ return {
3438
+ preprocessors: ["tokens-studio"],
3439
+ platforms: {
3440
+ css: {
3441
+ // custom
3442
+ theme,
3443
+ basePxFontSize,
3444
+ selector,
3445
+ layer,
3446
+ //
3447
+ prefix,
3448
+ buildPath: `${theme}/`,
3449
+ transforms: dsTransformers,
3450
+ files: [
3451
+ {
3452
+ destination: `size.css`,
3453
+ format: formats.size.name,
3454
+ filter: (token) => {
3455
+ const isUwantedToken = R18.anyPass([R18.includes("primitives/global")])(token.filePath);
3456
+ const isPrivateToken = R18.includes("_", token.path);
3457
+ return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
3458
+ }
3459
+ }
3460
+ ],
3461
+ options: {
3462
+ outputReferences: (token, options) => {
3463
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
3464
+ return isWantedSize && outputReferencesFilter2(token, options);
3226
3465
  }
3227
3466
  }
3228
3467
  }
@@ -3230,6 +3469,83 @@ var semanticVariables = ({ theme }) => {
3230
3469
  };
3231
3470
  };
3232
3471
 
3472
+ // src/tokens/process/configs/size-mode.ts
3473
+ import * as R19 from "ramda";
3474
+ var sizeModeVariables = ({ theme, size: size2 }) => {
3475
+ const selector = `:root`;
3476
+ const layer = `ds.theme.size-mode`;
3477
+ return {
3478
+ preprocessors: ["tokens-studio"],
3479
+ platforms: {
3480
+ css: {
3481
+ // custom
3482
+ size: size2,
3483
+ theme,
3484
+ basePxFontSize,
3485
+ selector,
3486
+ layer,
3487
+ //
3488
+ prefix,
3489
+ buildPath: `${theme}/`,
3490
+ transforms: dsTransformers,
3491
+ files: [
3492
+ {
3493
+ destination: `size-mode/${size2}.css`,
3494
+ format: formats.sizeMode.name,
3495
+ filter: (token) => {
3496
+ return R19.equals(["_size", "mode-font-size"], token.path);
3497
+ }
3498
+ }
3499
+ ]
3500
+ }
3501
+ }
3502
+ };
3503
+ };
3504
+
3505
+ // src/tokens/process/configs/type-scale.ts
3506
+ var typeScaleVariables = ({ theme, size: size2 }) => {
3507
+ const selector = ":root, [data-size]";
3508
+ const layer = `ds.theme.type-scale`;
3509
+ return {
3510
+ usesDtcg: true,
3511
+ preprocessors: ["tokens-studio"],
3512
+ expand: {
3513
+ include: ["typography"]
3514
+ },
3515
+ platforms: {
3516
+ css: {
3517
+ prefix,
3518
+ selector,
3519
+ layer,
3520
+ buildPath: `${theme}/`,
3521
+ basePxFontSize,
3522
+ transforms: [
3523
+ "name/kebab",
3524
+ "ts/size/px",
3525
+ sizeRem.name,
3526
+ "ts/size/lineheight",
3527
+ "ts/typography/fontWeight",
3528
+ typographyName.name
3529
+ ],
3530
+ files: [
3531
+ {
3532
+ destination: `type-scale.css`,
3533
+ format: formats.typeScale.name,
3534
+ filter: (token) => {
3535
+ const included = typeEquals(["typography", "dimension", "fontsize"], token);
3536
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
3537
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
3538
+ }
3539
+ }
3540
+ ],
3541
+ options: {
3542
+ outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
3543
+ }
3544
+ }
3545
+ }
3546
+ };
3547
+ };
3548
+
3233
3549
  // src/tokens/process/configs/typography.ts
3234
3550
  import { expandTypesMap } from "@tokens-studio/sd-transforms";
3235
3551
  var typographyVariables = ({ theme, typography: typography2 }) => {
@@ -3264,12 +3580,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
3264
3580
  destination: `typography/${typography2}.css`,
3265
3581
  format: formats.typography.name,
3266
3582
  filter: (token) => {
3267
- const included = typeEquals(
3268
- ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
3269
- token
3270
- );
3583
+ const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
3271
3584
  if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
3272
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
3585
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
3273
3586
  }
3274
3587
  }
3275
3588
  ]
@@ -3281,13 +3594,13 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
3281
3594
  // src/tokens/process/utils/getMultidimensionalThemes.ts
3282
3595
  import { kebabCase } from "change-case";
3283
3596
  import pc2 from "picocolors";
3284
- import * as R15 from "ramda";
3597
+ import * as R20 from "ramda";
3285
3598
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
3286
3599
  const verboseLogging = buildOptions?.verbose;
3287
3600
  const grouped$themes = groupThemes(processed$themes);
3288
3601
  const permutations = permutateThemes(grouped$themes);
3289
3602
  const ALL_DEPENDENT_ON = ["theme"];
3290
- const keys2 = R15.keys(grouped$themes);
3603
+ const keys2 = R20.keys(grouped$themes);
3291
3604
  const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
3292
3605
  if (verboseLogging) {
3293
3606
  console.log(pc2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
@@ -3327,7 +3640,7 @@ function groupThemes(themes) {
3327
3640
  }
3328
3641
  return groups;
3329
3642
  }
3330
- var hasUnknownProps = R15.pipe(R15.values, R15.none(R15.equals("unknown")), R15.not);
3643
+ var hasUnknownProps = R20.pipe(R20.values, R20.none(R20.equals("unknown")), R20.not);
3331
3644
  function permutateThemes(groups) {
3332
3645
  const separator = "_";
3333
3646
  const permutations = cartesian(Object.values(groups));
@@ -3337,8 +3650,8 @@ function permutateThemes(groups) {
3337
3650
  const { group, name, selectedTokenSets } = theme;
3338
3651
  let updatedPermutation = acc.permutation;
3339
3652
  if (group) {
3340
- const groupProp = R15.lensProp(group);
3341
- updatedPermutation = R15.set(groupProp, name, updatedPermutation);
3653
+ const groupProp = R20.lensProp(group);
3654
+ updatedPermutation = R20.set(groupProp, name, updatedPermutation);
3342
3655
  }
3343
3656
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
3344
3657
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -3409,7 +3722,10 @@ var configs = {
3409
3722
  dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
3410
3723
  warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
3411
3724
  infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
3725
+ sizeModeVariables,
3726
+ sizeVariables,
3412
3727
  typographyVariables,
3728
+ typeScaleVariables,
3413
3729
  semanticVariables
3414
3730
  };
3415
3731
  var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
@@ -3426,7 +3742,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
3426
3742
  obj.filePath = tokenSet;
3427
3743
  }
3428
3744
  });
3429
- tokenSource.tokens = R16.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
3745
+ tokenSource.tokens = R21.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
3430
3746
  }
3431
3747
  }
3432
3748
  } else {
@@ -3477,6 +3793,9 @@ var buildOptions = {
3477
3793
  var sd = new StyleDictionary2();
3478
3794
  var buildConfigs = {
3479
3795
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
3796
+ sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
3797
+ size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
3798
+ typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
3480
3799
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
3481
3800
  "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
3482
3801
  "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
@@ -3512,9 +3831,6 @@ async function processPlatform(options) {
3512
3831
  const platform = "css";
3513
3832
  const tokenSets = type === "format" ? options.tokenSets : void 0;
3514
3833
  const tokensDir = type === "build" ? options.tokensDir : void 0;
3515
- const filteredProcessed$themes = processed$themes.filter(
3516
- (theme) => R17.not(theme.group === "size" && theme.name !== "medium")
3517
- );
3518
3834
  const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
3519
3835
  if (UNSAFE_DEFAULT_COLOR) {
3520
3836
  console.warn(
@@ -3538,24 +3854,29 @@ async function processPlatform(options) {
3538
3854
  buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
3539
3855
  buildOptions.colorGroups = colorGroups;
3540
3856
  if (!buildOptions.defaultColor) {
3541
- const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
3542
- const firstMainColor = R17.head(customColors);
3857
+ const customColors = getCustomColors(processed$themes, colorGroups);
3858
+ const firstMainColor = R22.head(customColors);
3543
3859
  buildOptions.defaultColor = firstMainColor;
3544
3860
  }
3545
3861
  if (buildOptions.defaultColor) {
3546
3862
  console.log(`
3547
3863
  \u{1F3A8} Using ${pc3.blue(buildOptions.defaultColor)} as default color`);
3548
3864
  }
3549
- const buildAndSdConfigs = R17.map((buildConfig) => {
3550
- const sdConfigs = getConfigsForThemeDimensions(
3551
- buildConfig.getConfig,
3552
- filteredProcessed$themes,
3553
- buildConfig.dimensions,
3554
- {
3555
- tokensDir,
3556
- tokenSets
3557
- }
3558
- );
3865
+ const sizeModes = processed$themes.filter((x) => x.group === "size").map((x) => x.name);
3866
+ buildOptions.sizeModes = sizeModes;
3867
+ if (!buildOptions.defaultSize) {
3868
+ const defaultSize = R22.head(sizeModes);
3869
+ buildOptions.defaultSize = defaultSize;
3870
+ }
3871
+ if (buildOptions.defaultSize) {
3872
+ console.log(`
3873
+ \u{1F4CF} Using ${pc3.blue(buildOptions.defaultSize)} as default size`);
3874
+ }
3875
+ const buildAndSdConfigs = R22.map((buildConfig) => {
3876
+ const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
3877
+ tokensDir,
3878
+ tokenSets
3879
+ });
3559
3880
  const unknownConfigs = buildConfig.dimensions.map(
3560
3881
  (dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
3561
3882
  );
@@ -3579,10 +3900,13 @@ async function processPlatform(options) {
3579
3900
  "warning-color": [initResult],
3580
3901
  "info-color": [initResult],
3581
3902
  semantic: [initResult],
3582
- typography: [initResult]
3903
+ typography: [initResult],
3904
+ sizeMode: [initResult],
3905
+ size: [initResult],
3906
+ typeScale: [initResult]
3583
3907
  };
3584
3908
  try {
3585
- for (const [buildName, { buildConfig, sdConfigs }] of R17.toPairs(buildAndSdConfigs)) {
3909
+ for (const [buildName, { buildConfig, sdConfigs }] of R22.toPairs(buildAndSdConfigs)) {
3586
3910
  if (!(buildConfig.enabled?.() ?? true)) {
3587
3911
  continue;
3588
3912
  }
@@ -3594,7 +3918,7 @@ async function processPlatform(options) {
3594
3918
  const { config, permutation } = sdConfig;
3595
3919
  const modes = ["theme", ...buildConfig.dimensions];
3596
3920
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
3597
- const logMessage = R17.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
3921
+ const logMessage = R22.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
3598
3922
  console.log(logMessage);
3599
3923
  const sdOptions = { cache: true };
3600
3924
  const sdExtended = await sd.extend(config);
@@ -3643,7 +3967,7 @@ var formatTheme = async (themeConfig) => {
3643
3967
  var formatThemeCSS = async (themeConfig) => {
3644
3968
  const processedBuilds = await formatTheme(themeConfig);
3645
3969
  const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
3646
- return R18.head(themeCSSFiles)?.output ?? "";
3970
+ return R23.head(themeCSSFiles)?.output ?? "";
3647
3971
  };
3648
3972
  export {
3649
3973
  HSLToHex,