@digdir/designsystemet 1.5.0 → 1.6.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 (48) hide show
  1. package/configs/test-tokens.config.json +15 -1
  2. package/dist/bin/config.js +14 -3
  3. package/dist/bin/designsystemet.js +105 -43
  4. package/dist/config.schema.json +52 -0
  5. package/dist/src/colors/colorMetadata.d.ts +1 -0
  6. package/dist/src/colors/colorMetadata.d.ts.map +1 -1
  7. package/dist/src/colors/colorMetadata.js +2 -0
  8. package/dist/src/colors/index.js +2 -0
  9. package/dist/src/colors/theme.js +1 -0
  10. package/dist/src/config.d.ts +70 -0
  11. package/dist/src/config.d.ts.map +1 -1
  12. package/dist/src/config.js +12 -1
  13. package/dist/src/index.js +90 -37
  14. package/dist/src/scripts/createJsonSchema.js +12 -1
  15. package/dist/src/scripts/update-preview-tokens.js +80 -28
  16. package/dist/src/tokens/build.js +45 -27
  17. package/dist/src/tokens/create/generators/$designsystemet.js +9 -9
  18. package/dist/src/tokens/create/generators/color.d.ts +2 -1
  19. package/dist/src/tokens/create/generators/color.d.ts.map +1 -1
  20. package/dist/src/tokens/create/generators/color.js +40 -6
  21. package/dist/src/tokens/create/write.js +9 -9
  22. package/dist/src/tokens/create.js +44 -10
  23. package/dist/src/tokens/format.js +89 -37
  24. package/dist/src/tokens/index.js +89 -37
  25. package/dist/src/tokens/process/configs/color.js +31 -13
  26. package/dist/src/tokens/process/configs/semantic.js +31 -13
  27. package/dist/src/tokens/process/configs/size-mode.js +31 -13
  28. package/dist/src/tokens/process/configs/size.js +31 -13
  29. package/dist/src/tokens/process/configs/type-scale.js +31 -13
  30. package/dist/src/tokens/process/configs/typography.js +31 -13
  31. package/dist/src/tokens/process/configs.js +36 -18
  32. package/dist/src/tokens/process/formats/css/color.js +31 -13
  33. package/dist/src/tokens/process/formats/css/semantic.js +31 -13
  34. package/dist/src/tokens/process/formats/css/size-mode.js +31 -13
  35. package/dist/src/tokens/process/formats/css/size.d.ts +4 -0
  36. package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -1
  37. package/dist/src/tokens/process/formats/css/size.js +33 -14
  38. package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -1
  39. package/dist/src/tokens/process/formats/css/type-scale.js +31 -13
  40. package/dist/src/tokens/process/formats/css/typography.js +33 -15
  41. package/dist/src/tokens/process/formats/css.js +31 -13
  42. package/dist/src/tokens/process/output/declarations.js +40 -22
  43. package/dist/src/tokens/process/output/theme.js +9 -9
  44. package/dist/src/tokens/process/platform.js +36 -18
  45. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +31 -13
  46. package/dist/src/tokens/types.d.ts +1 -1
  47. package/dist/src/tokens/types.d.ts.map +1 -1
  48. package/package.json +9 -9
@@ -372,7 +372,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
372
372
  };
373
373
 
374
374
  // src/tokens/process/configs/type-scale.ts
375
- var typeScaleVariables = ({ theme, size: size2 }) => {
375
+ var typeScaleVariables = ({ theme }) => {
376
376
  const selector = ":root, [data-size]";
377
377
  const layer = `ds.theme.type-scale`;
378
378
  return {
@@ -971,13 +971,33 @@ ${content}
971
971
  // src/tokens/process/formats/css/type-scale.ts
972
972
  import * as R15 from "ramda";
973
973
  import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
974
- var typographyFontFamilyPredicate2 = R15.allPass([
974
+ var isTypographyFontFamilyToken = R15.allPass([
975
975
  R15.pathSatisfies(R15.includes("typography"), ["path"]),
976
976
  R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
977
977
  ]);
978
- function formatTypographySizeToken(token) {
979
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
980
- }
978
+ var formatTypographySizeToken = (format, token) => {
979
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
980
+ let calc;
981
+ let round;
982
+ if (R15.startsWith(["font-size"], token.path)) {
983
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
984
+ round = `round(${calc}, 1px)`;
985
+ } else {
986
+ calc = value;
987
+ }
988
+ return { name, calc, round: round ?? calc };
989
+ };
990
+ var formatTypographySizeTokens = (format, tokens) => R15.reduce(
991
+ (acc, token) => {
992
+ const { name, calc, round } = formatTypographySizeToken(format, token);
993
+ acc.tokens.push(token);
994
+ acc.calc.push(`${name}: ${calc};`);
995
+ acc.round.push(`${name}: ${round};`);
996
+ return acc;
997
+ },
998
+ { tokens: [], calc: [], round: [] },
999
+ tokens
1000
+ );
981
1001
  var typeScale = {
982
1002
  name: "ds/css-type-scale",
983
1003
  format: async ({ dictionary, file, options, platform }) => {
@@ -990,18 +1010,16 @@ var typeScale = {
990
1010
  format: "css",
991
1011
  usesDtcg
992
1012
  });
993
- const filteredTokens = R15.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
994
- const tokens = R15.map(formatTypographySizeToken, filteredTokens);
995
- const formattedMap = tokens.map((token) => ({
996
- token,
997
- formatted: format(token)
1013
+ const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
1014
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
1015
+ const formattedMap = formattedTokens.round.map((t, i) => ({
1016
+ token: formattedTokens.tokens[i],
1017
+ formatted: t
998
1018
  }));
999
1019
  buildOptions.buildTokenFormats[destination] = formattedMap;
1000
- const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
1001
1020
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
1002
1021
  const content = `${selector} {
1003
- ${sizeFactor}
1004
- ${formattedTokens}
1022
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
1005
1023
  }`;
1006
1024
  const body = R15.isNotNil(layer) ? `@layer ${layer} {
1007
1025
  ${content}
@@ -58,11 +58,11 @@ function isColorCategoryToken(token, category) {
58
58
  var isDigit = (s) => /^\d+$/.test(s);
59
59
  function traverseObj(obj, fn) {
60
60
  for (const key in obj) {
61
- const prop4 = obj[key];
62
- if (prop4 != null) {
63
- fn.apply(null, [obj, key, prop4]);
64
- if (typeof prop4 === "object") {
65
- traverseObj(prop4, fn);
61
+ const prop3 = obj[key];
62
+ if (prop3 != null) {
63
+ fn.apply(null, [obj, key, prop3]);
64
+ if (typeof prop3 === "object") {
65
+ traverseObj(prop3, fn);
66
66
  }
67
67
  }
68
68
  }
@@ -807,13 +807,33 @@ ${content}
807
807
  // src/tokens/process/formats/css/type-scale.ts
808
808
  import * as R10 from "ramda";
809
809
  import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
810
- var typographyFontFamilyPredicate2 = R10.allPass([
810
+ var isTypographyFontFamilyToken = R10.allPass([
811
811
  R10.pathSatisfies(R10.includes("typography"), ["path"]),
812
812
  R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
813
813
  ]);
814
- function formatTypographySizeToken(token) {
815
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
816
- }
814
+ var formatTypographySizeToken = (format, token) => {
815
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
816
+ let calc;
817
+ let round;
818
+ if (R10.startsWith(["font-size"], token.path)) {
819
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
820
+ round = `round(${calc}, 1px)`;
821
+ } else {
822
+ calc = value;
823
+ }
824
+ return { name, calc, round: round ?? calc };
825
+ };
826
+ var formatTypographySizeTokens = (format, tokens) => R10.reduce(
827
+ (acc, token) => {
828
+ const { name, calc, round } = formatTypographySizeToken(format, token);
829
+ acc.tokens.push(token);
830
+ acc.calc.push(`${name}: ${calc};`);
831
+ acc.round.push(`${name}: ${round};`);
832
+ return acc;
833
+ },
834
+ { tokens: [], calc: [], round: [] },
835
+ tokens
836
+ );
817
837
  var typeScale = {
818
838
  name: "ds/css-type-scale",
819
839
  format: async ({ dictionary, file, options, platform }) => {
@@ -826,18 +846,16 @@ var typeScale = {
826
846
  format: "css",
827
847
  usesDtcg
828
848
  });
829
- const filteredTokens = R10.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
830
- const tokens = R10.map(formatTypographySizeToken, filteredTokens);
831
- const formattedMap = tokens.map((token) => ({
832
- token,
833
- formatted: format(token)
849
+ const filteredTokens = R10.reject(R10.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
850
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
851
+ const formattedMap = formattedTokens.round.map((t, i) => ({
852
+ token: formattedTokens.tokens[i],
853
+ formatted: t
834
854
  }));
835
855
  buildOptions.buildTokenFormats[destination] = formattedMap;
836
- const formattedTokens = formattedMap.map(R10.prop("formatted")).join("\n");
837
856
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
838
857
  const content = `${selector} {
839
- ${sizeFactor}
840
- ${formattedTokens}
858
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
841
859
  }`;
842
860
  const body = R10.isNotNil(layer) ? `@layer ${layer} {
843
861
  ${content}
@@ -1050,7 +1068,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
1050
1068
  };
1051
1069
 
1052
1070
  // src/tokens/process/configs/type-scale.ts
1053
- var typeScaleVariables = ({ theme, size: size2 }) => {
1071
+ var typeScaleVariables = ({ theme }) => {
1054
1072
  const selector = ":root, [data-size]";
1055
1073
  const layer = `ds.theme.type-scale`;
1056
1074
  return {
@@ -401,13 +401,33 @@ ${content}
401
401
  // src/tokens/process/formats/css/type-scale.ts
402
402
  import * as R7 from "ramda";
403
403
  import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
404
- var typographyFontFamilyPredicate2 = R7.allPass([
404
+ var isTypographyFontFamilyToken = R7.allPass([
405
405
  R7.pathSatisfies(R7.includes("typography"), ["path"]),
406
406
  R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
407
407
  ]);
408
- function formatTypographySizeToken(token) {
409
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
410
- }
408
+ var formatTypographySizeToken = (format, token) => {
409
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
410
+ let calc;
411
+ let round;
412
+ if (R7.startsWith(["font-size"], token.path)) {
413
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
414
+ round = `round(${calc}, 1px)`;
415
+ } else {
416
+ calc = value;
417
+ }
418
+ return { name, calc, round: round ?? calc };
419
+ };
420
+ var formatTypographySizeTokens = (format, tokens) => R7.reduce(
421
+ (acc, token) => {
422
+ const { name, calc, round } = formatTypographySizeToken(format, token);
423
+ acc.tokens.push(token);
424
+ acc.calc.push(`${name}: ${calc};`);
425
+ acc.round.push(`${name}: ${round};`);
426
+ return acc;
427
+ },
428
+ { tokens: [], calc: [], round: [] },
429
+ tokens
430
+ );
411
431
  var typeScale = {
412
432
  name: "ds/css-type-scale",
413
433
  format: async ({ dictionary, file, options, platform }) => {
@@ -420,18 +440,16 @@ var typeScale = {
420
440
  format: "css",
421
441
  usesDtcg
422
442
  });
423
- const filteredTokens = R7.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
424
- const tokens = R7.map(formatTypographySizeToken, filteredTokens);
425
- const formattedMap = tokens.map((token) => ({
426
- token,
427
- formatted: format(token)
443
+ const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
444
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
445
+ const formattedMap = formattedTokens.round.map((t, i) => ({
446
+ token: formattedTokens.tokens[i],
447
+ formatted: t
428
448
  }));
429
449
  buildOptions.buildTokenFormats[destination] = formattedMap;
430
- const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
431
450
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
432
451
  const content = `${selector} {
433
- ${sizeFactor}
434
- ${formattedTokens}
452
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
435
453
  }`;
436
454
  const body = R7.isNotNil(layer) ? `@layer ${layer} {
437
455
  ${content}
@@ -644,7 +662,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
644
662
  };
645
663
 
646
664
  // src/tokens/process/configs/type-scale.ts
647
- var typeScaleVariables = ({ theme, size: size2 }) => {
665
+ var typeScaleVariables = ({ theme }) => {
648
666
  const selector = ":root, [data-size]";
649
667
  const layer = `ds.theme.type-scale`;
650
668
  return {
@@ -461,13 +461,33 @@ ${content}
461
461
  // src/tokens/process/formats/css/type-scale.ts
462
462
  import * as R7 from "ramda";
463
463
  import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
464
- var typographyFontFamilyPredicate2 = R7.allPass([
464
+ var isTypographyFontFamilyToken = R7.allPass([
465
465
  R7.pathSatisfies(R7.includes("typography"), ["path"]),
466
466
  R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
467
467
  ]);
468
- function formatTypographySizeToken(token) {
469
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
470
- }
468
+ var formatTypographySizeToken = (format, token) => {
469
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
470
+ let calc;
471
+ let round;
472
+ if (R7.startsWith(["font-size"], token.path)) {
473
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
474
+ round = `round(${calc}, 1px)`;
475
+ } else {
476
+ calc = value;
477
+ }
478
+ return { name, calc, round: round ?? calc };
479
+ };
480
+ var formatTypographySizeTokens = (format, tokens) => R7.reduce(
481
+ (acc, token) => {
482
+ const { name, calc, round } = formatTypographySizeToken(format, token);
483
+ acc.tokens.push(token);
484
+ acc.calc.push(`${name}: ${calc};`);
485
+ acc.round.push(`${name}: ${round};`);
486
+ return acc;
487
+ },
488
+ { tokens: [], calc: [], round: [] },
489
+ tokens
490
+ );
471
491
  var typeScale = {
472
492
  name: "ds/css-type-scale",
473
493
  format: async ({ dictionary, file, options, platform }) => {
@@ -480,18 +500,16 @@ var typeScale = {
480
500
  format: "css",
481
501
  usesDtcg
482
502
  });
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)
503
+ const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
504
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
505
+ const formattedMap = formattedTokens.round.map((t, i) => ({
506
+ token: formattedTokens.tokens[i],
507
+ formatted: t
488
508
  }));
489
509
  buildOptions.buildTokenFormats[destination] = formattedMap;
490
- const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
491
510
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
492
511
  const content = `${selector} {
493
- ${sizeFactor}
494
- ${formattedTokens}
512
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
495
513
  }`;
496
514
  const body = R7.isNotNil(layer) ? `@layer ${layer} {
497
515
  ${content}
@@ -704,7 +722,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
704
722
  };
705
723
 
706
724
  // src/tokens/process/configs/type-scale.ts
707
- var typeScaleVariables = ({ theme, size: size2 }) => {
725
+ var typeScaleVariables = ({ theme }) => {
708
726
  const selector = ":root, [data-size]";
709
727
  const layer = `ds.theme.type-scale`;
710
728
  return {
@@ -435,13 +435,33 @@ ${content}
435
435
  // src/tokens/process/formats/css/type-scale.ts
436
436
  import * as R7 from "ramda";
437
437
  import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
438
- var typographyFontFamilyPredicate2 = R7.allPass([
438
+ var isTypographyFontFamilyToken = R7.allPass([
439
439
  R7.pathSatisfies(R7.includes("typography"), ["path"]),
440
440
  R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
441
441
  ]);
442
- function formatTypographySizeToken(token) {
443
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
444
- }
442
+ var formatTypographySizeToken = (format, token) => {
443
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
444
+ let calc;
445
+ let round;
446
+ if (R7.startsWith(["font-size"], token.path)) {
447
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
448
+ round = `round(${calc}, 1px)`;
449
+ } else {
450
+ calc = value;
451
+ }
452
+ return { name, calc, round: round ?? calc };
453
+ };
454
+ var formatTypographySizeTokens = (format, tokens) => R7.reduce(
455
+ (acc, token) => {
456
+ const { name, calc, round } = formatTypographySizeToken(format, token);
457
+ acc.tokens.push(token);
458
+ acc.calc.push(`${name}: ${calc};`);
459
+ acc.round.push(`${name}: ${round};`);
460
+ return acc;
461
+ },
462
+ { tokens: [], calc: [], round: [] },
463
+ tokens
464
+ );
445
465
  var typeScale = {
446
466
  name: "ds/css-type-scale",
447
467
  format: async ({ dictionary, file, options, platform }) => {
@@ -454,18 +474,16 @@ var typeScale = {
454
474
  format: "css",
455
475
  usesDtcg
456
476
  });
457
- const filteredTokens = R7.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
458
- const tokens = R7.map(formatTypographySizeToken, filteredTokens);
459
- const formattedMap = tokens.map((token) => ({
460
- token,
461
- formatted: format(token)
477
+ const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
478
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
479
+ const formattedMap = formattedTokens.round.map((t, i) => ({
480
+ token: formattedTokens.tokens[i],
481
+ formatted: t
462
482
  }));
463
483
  buildOptions.buildTokenFormats[destination] = formattedMap;
464
- const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
465
484
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
466
485
  const content = `${selector} {
467
- ${sizeFactor}
468
- ${formattedTokens}
486
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
469
487
  }`;
470
488
  const body = R7.isNotNil(layer) ? `@layer ${layer} {
471
489
  ${content}
@@ -678,7 +696,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
678
696
  };
679
697
 
680
698
  // src/tokens/process/configs/type-scale.ts
681
- var typeScaleVariables = ({ theme, size: size2 }) => {
699
+ var typeScaleVariables = ({ theme }) => {
682
700
  const selector = ":root, [data-size]";
683
701
  const layer = `ds.theme.type-scale`;
684
702
  return {
@@ -13,5 +13,9 @@ export declare const overrideSizingFormula: (format: (t: TransformedToken) => st
13
13
  round: string;
14
14
  calc: string;
15
15
  };
16
+ export declare const sizingTemplate: ({ round, calc }: {
17
+ round: string[];
18
+ calc: string[];
19
+ }) => string;
16
20
  export declare const size: Format;
17
21
  //# sourceMappingURL=size.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASrD,eAAO,MAAM,cAAc,MAJY,gBAAgB,YAI+C,CAAC;AAEvG;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,EAAE,OAAO,gBAAgB;;;;CAmBrG,CAAC;AAiCF,eAAO,MAAM,IAAI,EAAE,MAyClB,CAAC"}
1
+ {"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASrD,eAAO,MAAM,cAAc,MAJY,gBAAgB,YAI+C,CAAC;AAEvG;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,EAAE,OAAO,gBAAgB;;;;CAmBrG,CAAC;AAwBF,eAAO,MAAM,cAAc,GAAI,iBAAiB;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,WAOlF,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAyClB,CAAC"}
@@ -408,13 +408,33 @@ ${content}
408
408
  // src/tokens/process/formats/css/type-scale.ts
409
409
  import * as R7 from "ramda";
410
410
  import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
411
- var typographyFontFamilyPredicate2 = R7.allPass([
411
+ var isTypographyFontFamilyToken = R7.allPass([
412
412
  R7.pathSatisfies(R7.includes("typography"), ["path"]),
413
413
  R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
414
414
  ]);
415
- function formatTypographySizeToken(token) {
416
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
417
- }
415
+ var formatTypographySizeToken = (format, token) => {
416
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
417
+ let calc;
418
+ let round;
419
+ if (R7.startsWith(["font-size"], token.path)) {
420
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
421
+ round = `round(${calc}, 1px)`;
422
+ } else {
423
+ calc = value;
424
+ }
425
+ return { name, calc, round: round ?? calc };
426
+ };
427
+ var formatTypographySizeTokens = (format, tokens) => R7.reduce(
428
+ (acc, token) => {
429
+ const { name, calc, round } = formatTypographySizeToken(format, token);
430
+ acc.tokens.push(token);
431
+ acc.calc.push(`${name}: ${calc};`);
432
+ acc.round.push(`${name}: ${round};`);
433
+ return acc;
434
+ },
435
+ { tokens: [], calc: [], round: [] },
436
+ tokens
437
+ );
418
438
  var typeScale = {
419
439
  name: "ds/css-type-scale",
420
440
  format: async ({ dictionary, file, options, platform }) => {
@@ -427,18 +447,16 @@ var typeScale = {
427
447
  format: "css",
428
448
  usesDtcg
429
449
  });
430
- const filteredTokens = R7.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
431
- const tokens = R7.map(formatTypographySizeToken, filteredTokens);
432
- const formattedMap = tokens.map((token) => ({
433
- token,
434
- formatted: format(token)
450
+ const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
451
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
452
+ const formattedMap = formattedTokens.round.map((t, i) => ({
453
+ token: formattedTokens.tokens[i],
454
+ formatted: t
435
455
  }));
436
456
  buildOptions.buildTokenFormats[destination] = formattedMap;
437
- const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
438
457
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
439
458
  const content = `${selector} {
440
- ${sizeFactor}
441
- ${formattedTokens}
459
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
442
460
  }`;
443
461
  const body = R7.isNotNil(layer) ? `@layer ${layer} {
444
462
  ${content}
@@ -651,7 +669,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
651
669
  };
652
670
 
653
671
  // src/tokens/process/configs/type-scale.ts
654
- var typeScaleVariables = ({ theme, size: size2 }) => {
672
+ var typeScaleVariables = ({ theme }) => {
655
673
  const selector = ":root, [data-size]";
656
674
  const layer = `ds.theme.type-scale`;
657
675
  return {
@@ -1065,5 +1083,6 @@ ${content}
1065
1083
  export {
1066
1084
  isInlineTokens,
1067
1085
  overrideSizingFormula,
1068
- size
1086
+ size,
1087
+ sizingTemplate
1069
1088
  };
@@ -1 +1 @@
1
- {"version":3,"file":"type-scale.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/type-scale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;AAevE,eAAO,MAAM,SAAS,EAAE,MAgCvB,CAAC"}
1
+ {"version":3,"file":"type-scale.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/type-scale.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;AA2CvE,eAAO,MAAM,SAAS,EAAE,MA8BvB,CAAC"}
@@ -699,7 +699,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
699
699
  };
700
700
 
701
701
  // src/tokens/process/configs/type-scale.ts
702
- var typeScaleVariables = ({ theme, size: size2 }) => {
702
+ var typeScaleVariables = ({ theme }) => {
703
703
  const selector = ":root, [data-size]";
704
704
  const layer = `ds.theme.type-scale`;
705
705
  return {
@@ -1026,13 +1026,33 @@ var buildConfigs = {
1026
1026
  };
1027
1027
 
1028
1028
  // src/tokens/process/formats/css/type-scale.ts
1029
- var typographyFontFamilyPredicate2 = R15.allPass([
1029
+ var isTypographyFontFamilyToken = R15.allPass([
1030
1030
  R15.pathSatisfies(R15.includes("typography"), ["path"]),
1031
1031
  R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
1032
1032
  ]);
1033
- function formatTypographySizeToken(token) {
1034
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
1035
- }
1033
+ var formatTypographySizeToken = (format, token) => {
1034
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
1035
+ let calc;
1036
+ let round;
1037
+ if (R15.startsWith(["font-size"], token.path)) {
1038
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
1039
+ round = `round(${calc}, 1px)`;
1040
+ } else {
1041
+ calc = value;
1042
+ }
1043
+ return { name, calc, round: round ?? calc };
1044
+ };
1045
+ var formatTypographySizeTokens = (format, tokens) => R15.reduce(
1046
+ (acc, token) => {
1047
+ const { name, calc, round } = formatTypographySizeToken(format, token);
1048
+ acc.tokens.push(token);
1049
+ acc.calc.push(`${name}: ${calc};`);
1050
+ acc.round.push(`${name}: ${round};`);
1051
+ return acc;
1052
+ },
1053
+ { tokens: [], calc: [], round: [] },
1054
+ tokens
1055
+ );
1036
1056
  var typeScale = {
1037
1057
  name: "ds/css-type-scale",
1038
1058
  format: async ({ dictionary, file, options, platform }) => {
@@ -1045,18 +1065,16 @@ var typeScale = {
1045
1065
  format: "css",
1046
1066
  usesDtcg
1047
1067
  });
1048
- const filteredTokens = R15.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
1049
- const tokens = R15.map(formatTypographySizeToken, filteredTokens);
1050
- const formattedMap = tokens.map((token) => ({
1051
- token,
1052
- formatted: format(token)
1068
+ const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
1069
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
1070
+ const formattedMap = formattedTokens.round.map((t, i) => ({
1071
+ token: formattedTokens.tokens[i],
1072
+ formatted: t
1053
1073
  }));
1054
1074
  buildOptions.buildTokenFormats[destination] = formattedMap;
1055
- const formattedTokens = formattedMap.map(R15.prop("formatted")).join("\n");
1056
1075
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
1057
1076
  const content = `${selector} {
1058
- ${sizeFactor}
1059
- ${formattedTokens}
1077
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
1060
1078
  }`;
1061
1079
  const body = R15.isNotNil(layer) ? `@layer ${layer} {
1062
1080
  ${content}
@@ -460,13 +460,33 @@ ${content}
460
460
  // src/tokens/process/formats/css/type-scale.ts
461
461
  import * as R7 from "ramda";
462
462
  import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
463
- var typographyFontFamilyPredicate = R7.allPass([
463
+ var isTypographyFontFamilyToken = R7.allPass([
464
464
  R7.pathSatisfies(R7.includes("typography"), ["path"]),
465
465
  R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
466
466
  ]);
467
- function formatTypographySizeToken(token) {
468
- return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
469
- }
467
+ var formatTypographySizeToken = (format, token) => {
468
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
469
+ let calc;
470
+ let round;
471
+ if (R7.startsWith(["font-size"], token.path)) {
472
+ calc = `calc(${value} * var(--_ds-font-size-factor))`;
473
+ round = `round(${calc}, 1px)`;
474
+ } else {
475
+ calc = value;
476
+ }
477
+ return { name, calc, round: round ?? calc };
478
+ };
479
+ var formatTypographySizeTokens = (format, tokens) => R7.reduce(
480
+ (acc, token) => {
481
+ const { name, calc, round } = formatTypographySizeToken(format, token);
482
+ acc.tokens.push(token);
483
+ acc.calc.push(`${name}: ${calc};`);
484
+ acc.round.push(`${name}: ${round};`);
485
+ return acc;
486
+ },
487
+ { tokens: [], calc: [], round: [] },
488
+ tokens
489
+ );
470
490
  var typeScale = {
471
491
  name: "ds/css-type-scale",
472
492
  format: async ({ dictionary, file, options, platform }) => {
@@ -479,18 +499,16 @@ var typeScale = {
479
499
  format: "css",
480
500
  usesDtcg
481
501
  });
482
- const filteredTokens = R7.reject(typographyFontFamilyPredicate, dictionary.allTokens);
483
- const tokens = R7.map(formatTypographySizeToken, filteredTokens);
484
- const formattedMap = tokens.map((token) => ({
485
- token,
486
- formatted: format(token)
502
+ const filteredTokens = R7.reject(R7.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
503
+ const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
504
+ const formattedMap = formattedTokens.round.map((t, i) => ({
505
+ token: formattedTokens.tokens[i],
506
+ formatted: t
487
507
  }));
488
508
  buildOptions.buildTokenFormats[destination] = formattedMap;
489
- const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
490
509
  const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
491
510
  const content = `${selector} {
492
- ${sizeFactor}
493
- ${formattedTokens}
511
+ ${sizeFactor}${sizingTemplate(formattedTokens)}
494
512
  }`;
495
513
  const body = R7.isNotNil(layer) ? `@layer ${layer} {
496
514
  ${content}
@@ -703,7 +721,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
703
721
  };
704
722
 
705
723
  // src/tokens/process/configs/type-scale.ts
706
- var typeScaleVariables = ({ theme, size: size2 }) => {
724
+ var typeScaleVariables = ({ theme }) => {
707
725
  const selector = ":root, [data-size]";
708
726
  const layer = `ds.theme.type-scale`;
709
727
  return {
@@ -1030,7 +1048,7 @@ var buildConfigs = {
1030
1048
  };
1031
1049
 
1032
1050
  // src/tokens/process/formats/css/typography.ts
1033
- var typographyFontFamilyPredicate2 = R15.allPass([
1051
+ var typographyFontFamilyPredicate = R15.allPass([
1034
1052
  R15.pathSatisfies(R15.includes("typography"), ["path"]),
1035
1053
  R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
1036
1054
  ]);
@@ -1046,7 +1064,7 @@ var typography = {
1046
1064
  format: "css",
1047
1065
  usesDtcg
1048
1066
  });
1049
- const filteredTokens = R15.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
1067
+ const filteredTokens = R15.reject(typographyFontFamilyPredicate, dictionary.allTokens);
1050
1068
  const formattedMap = filteredTokens.map((token) => ({
1051
1069
  token,
1052
1070
  formatted: format(token)