@digdir/designsystemet 1.13.1 → 1.13.3

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 (74) hide show
  1. package/dist/bin/config.js +50 -658
  2. package/dist/bin/designsystemet.js +131 -4623
  3. package/dist/bin/options.js +22 -14
  4. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js +9 -0
  5. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js +8 -0
  6. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js +13 -0
  7. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js +10 -0
  8. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js +10 -0
  9. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js +53 -0
  10. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js +14 -0
  11. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js +9 -0
  12. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js +32 -0
  13. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js +15 -0
  14. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/types/index.js +11 -0
  15. package/dist/package.js +5 -0
  16. package/dist/src/colors/colorMetadata.js +255 -261
  17. package/dist/src/colors/index.js +5 -522
  18. package/dist/src/colors/theme.js +104 -343
  19. package/dist/src/colors/types.js +22 -25
  20. package/dist/src/colors/utils.js +241 -154
  21. package/dist/src/config.js +103 -444
  22. package/dist/src/index.js +10 -3588
  23. package/dist/src/migrations/beta-to-v1.js +339 -537
  24. package/dist/src/migrations/codemods/css/plugins.js +31 -42
  25. package/dist/src/migrations/codemods/css/run.js +20 -151
  26. package/dist/src/migrations/color-rename-next49.js +44 -220
  27. package/dist/src/migrations/index.js +7 -577
  28. package/dist/src/tokens/build.js +39 -1816
  29. package/dist/src/tokens/create/files.js +43 -602
  30. package/dist/src/tokens/create/generators/$designsystemet.js +8 -97
  31. package/dist/src/tokens/create/generators/$metadata.js +17 -20
  32. package/dist/src/tokens/create/generators/$themes.js +137 -311
  33. package/dist/src/tokens/create/generators/primitives/color-scheme.js +68 -443
  34. package/dist/src/tokens/create/generators/primitives/globals.js +141 -147
  35. package/dist/src/tokens/create/generators/primitives/size.js +146 -156
  36. package/dist/src/tokens/create/generators/primitives/typography.js +213 -217
  37. package/dist/src/tokens/create/generators/semantic/color-modes.js +24 -59
  38. package/dist/src/tokens/create/generators/semantic/color.js +42 -326
  39. package/dist/src/tokens/create/generators/semantic/style.js +379 -382
  40. package/dist/src/tokens/create/generators/themes/theme.js +108 -392
  41. package/dist/src/tokens/create.js +47 -1591
  42. package/dist/src/tokens/format.js +38 -3324
  43. package/dist/src/tokens/generate-config.js +155 -298
  44. package/dist/src/tokens/index.js +3 -3344
  45. package/dist/src/tokens/process/configs/color.js +50 -1086
  46. package/dist/src/tokens/process/configs/semantic.js +45 -1084
  47. package/dist/src/tokens/process/configs/shared.js +18 -109
  48. package/dist/src/tokens/process/configs/size-mode.js +27 -1083
  49. package/dist/src/tokens/process/configs/size.js +32 -1084
  50. package/dist/src/tokens/process/configs/type-scale.js +49 -1084
  51. package/dist/src/tokens/process/configs/typography.js +63 -1085
  52. package/dist/src/tokens/process/configs.js +88 -1225
  53. package/dist/src/tokens/process/formats/css/color.js +58 -1080
  54. package/dist/src/tokens/process/formats/css/semantic.js +27 -1082
  55. package/dist/src/tokens/process/formats/css/size-mode.js +43 -1078
  56. package/dist/src/tokens/process/formats/css/size.js +86 -1080
  57. package/dist/src/tokens/process/formats/css/type-scale.js +53 -1084
  58. package/dist/src/tokens/process/formats/css/typography.js +27 -1082
  59. package/dist/src/tokens/process/formats/css.js +18 -1082
  60. package/dist/src/tokens/process/output/declarations.js +18 -1202
  61. package/dist/src/tokens/process/output/tailwind.js +26 -40
  62. package/dist/src/tokens/process/output/theme.js +73 -206
  63. package/dist/src/tokens/process/platform.js +165 -1356
  64. package/dist/src/tokens/process/transformers.js +49 -89
  65. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +100 -1183
  66. package/dist/src/tokens/process/utils/kebab-case.js +7 -5
  67. package/dist/src/tokens/types.js +6 -7
  68. package/dist/src/tokens/utils.js +102 -93
  69. package/dist/src/types.js +1 -5
  70. package/dist/src/utils/filesystem.js +112 -124
  71. package/package.json +18 -21
  72. package/configs/test-tokens.config.json +0 -82
  73. package/dist/src/scripts/createJsonSchema.js +0 -409
  74. package/dist/src/scripts/update-preview-tokens.js +0 -3353
@@ -1,94 +1,54 @@
1
- // src/tokens/process/transformers.ts
2
- import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
3
- import * as R2 from "ramda";
4
-
5
- // src/tokens/utils.ts
1
+ import { getValue, pathStartsWithOneOf, typeEquals } from "../utils.js";
6
2
  import * as R from "ramda";
7
- var mapToLowerCase = R.map(R.toLower);
8
- var hasAnyTruth = R.any(R.equals(true));
9
- var getType = (token) => (token.$type ?? token.type) || "";
10
- var getValue = (token) => token.$value ?? token.value;
11
- var typeEquals = R.curry(
12
- (types, token) => {
13
- if (R.isNil(token)) {
14
- return false;
15
- }
16
- return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));
17
- }
18
- );
19
- var pathStartsWithOneOf = R.curry(
20
- (paths, token) => {
21
- if (R.isNil(token)) {
22
- return false;
23
- }
24
- const tokenPath = mapToLowerCase(token.path);
25
- const matchPathsStartingWith = R.map((pathOrString) => {
26
- const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
27
- return R.startsWith(mapToLowerCase(path), tokenPath);
28
- }, paths);
29
- return hasAnyTruth(matchPathsStartingWith);
30
- }
31
- );
32
-
33
- // src/tokens/process/transformers.ts
34
- var isPx = R2.test(/\b\d+px\b/g);
35
- var sizeRem = {
36
- name: "ds/size/toRem",
37
- type: "value",
38
- transitive: true,
39
- filter: (token) => {
40
- const hasWantedType = typeEquals(["dimension", "fontsize"], token);
41
- const hasWantedPath = pathStartsWithOneOf([
42
- "border-radius",
43
- "font-size"
44
- /*, ['_size', 'mode-font-size']*/
45
- ], token);
46
- return hasWantedType && hasWantedPath;
47
- },
48
- transform: (token, config) => {
49
- const value = getValue(token);
50
- if (isPx(value)) {
51
- const baseFont = config.basePxFontSize || 16;
52
- const size = parseInt(value, 10);
53
- if (size === 0) {
54
- return "0";
55
- }
56
- return `${size / baseFont}rem`;
57
- }
58
- return value;
59
- }
60
- };
61
- var typographyName = {
62
- name: "name/typography",
63
- type: "name",
64
- transitive: true,
65
- // expanded tokens have different type so we match on path instead
66
- filter: (token) => pathStartsWithOneOf(["typography"], token),
67
- transform: (token) => {
68
- return token.name.replace("-typography", "");
69
- }
3
+ import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
4
+ //#region src/tokens/process/transformers.ts
5
+ const isPx = R.test(/\b\d+px\b/g);
6
+ const sizeRem = {
7
+ name: "ds/size/toRem",
8
+ type: "value",
9
+ transitive: true,
10
+ filter: (token) => {
11
+ const hasWantedType = typeEquals(["dimension", "fontsize"], token);
12
+ const hasWantedPath = pathStartsWithOneOf(["border-radius", "font-size"], token);
13
+ return hasWantedType && hasWantedPath;
14
+ },
15
+ transform: (token, config) => {
16
+ const value = getValue(token);
17
+ if (isPx(value)) {
18
+ const baseFont = config.basePxFontSize || 16;
19
+ const size = parseInt(value, 10);
20
+ if (size === 0) return "0";
21
+ return `${size / baseFont}rem`;
22
+ }
23
+ return value;
24
+ }
70
25
  };
71
- var resolveMath = {
72
- name: "ds/resolveMath",
73
- type: "value",
74
- transitive: true,
75
- filter: (token) => {
76
- const isValidValue = ["string", "object"].includes(typeof getValue(token));
77
- const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
78
- return isValidValue && isTokenOfInterest;
79
- },
80
- transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
26
+ const typographyName = {
27
+ name: "name/typography",
28
+ type: "name",
29
+ transitive: true,
30
+ filter: (token) => pathStartsWithOneOf(["typography"], token),
31
+ transform: (token) => {
32
+ return token.name.replace("-typography", "");
33
+ }
81
34
  };
82
- var unitless = {
83
- name: "ds/unitless",
84
- type: "value",
85
- transitive: true,
86
- filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
87
- transform: (token) => parseInt(getValue(token), 10)
35
+ const resolveMath = {
36
+ name: "ds/resolveMath",
37
+ type: "value",
38
+ transitive: true,
39
+ filter: (token) => {
40
+ const isValidValue = ["string", "object"].includes(typeof getValue(token));
41
+ const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
42
+ return isValidValue && isTokenOfInterest;
43
+ },
44
+ transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
88
45
  };
89
- export {
90
- resolveMath,
91
- sizeRem,
92
- typographyName,
93
- unitless
46
+ const unitless = {
47
+ name: "ds/unitless",
48
+ type: "value",
49
+ transitive: true,
50
+ filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
51
+ transform: (token) => parseInt(getValue(token), 10)
94
52
  };
53
+ //#endregion
54
+ export { resolveMath, sizeRem, typographyName, unitless };