@digdir/designsystemet 1.3.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 (61) hide show
  1. package/configs/digdir.config.json +4 -0
  2. package/dist/bin/designsystemet.js +488 -166
  3. package/dist/global-Y35YADVH.json +100 -0
  4. package/dist/src/index.js +527 -203
  5. package/dist/src/scripts/update-preview-tokens.js +478 -128
  6. package/dist/src/tokens/build.js +429 -111
  7. package/dist/src/tokens/create/defaults.js +27 -23
  8. package/dist/src/tokens/create/generators/$designsystemet.js +6 -6
  9. package/dist/src/tokens/create/write.js +6 -6
  10. package/dist/src/tokens/create.js +27 -23
  11. package/dist/src/tokens/format.js +527 -203
  12. package/dist/src/tokens/index.js +527 -203
  13. package/dist/src/tokens/process/configs/color.js +366 -66
  14. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
  15. package/dist/src/tokens/process/configs/semantic.js +368 -68
  16. package/dist/src/tokens/process/configs/shared.js +9 -2
  17. package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
  18. package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
  19. package/dist/src/tokens/process/configs/size-mode.js +1067 -0
  20. package/dist/src/tokens/process/configs/size.d.ts +3 -0
  21. package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
  22. package/dist/src/tokens/process/configs/size.js +1069 -0
  23. package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
  24. package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
  25. package/dist/src/tokens/process/configs/type-scale.js +1067 -0
  26. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  27. package/dist/src/tokens/process/configs/typography.js +364 -64
  28. package/dist/src/tokens/process/configs.d.ts +3 -0
  29. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  30. package/dist/src/tokens/process/configs.js +373 -71
  31. package/dist/src/tokens/process/formats/css/color.js +381 -79
  32. package/dist/src/tokens/process/formats/css/semantic.d.ts +0 -14
  33. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
  34. package/dist/src/tokens/process/formats/css/semantic.js +407 -109
  35. package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
  36. package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
  37. package/dist/src/tokens/process/formats/css/size-mode.js +1068 -0
  38. package/dist/src/tokens/process/formats/css/size.d.ts +17 -0
  39. package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
  40. package/dist/src/tokens/process/formats/css/size.js +1069 -0
  41. package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
  42. package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
  43. package/dist/src/tokens/process/formats/css/type-scale.js +1069 -0
  44. package/dist/src/tokens/process/formats/css/typography.js +365 -63
  45. package/dist/src/tokens/process/formats/css.d.ts +3 -0
  46. package/dist/src/tokens/process/formats/css.d.ts.map +1 -1
  47. package/dist/src/tokens/process/formats/css.js +364 -64
  48. package/dist/src/tokens/process/output/declarations.js +376 -74
  49. package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
  50. package/dist/src/tokens/process/output/theme.js +63 -14
  51. package/dist/src/tokens/process/platform.d.ts +16 -0
  52. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  53. package/dist/src/tokens/process/platform.js +402 -95
  54. package/dist/src/tokens/process/transformers.js +9 -2
  55. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +373 -71
  56. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +1 -1
  57. package/dist/src/tokens/utils.d.ts +4 -1
  58. package/dist/src/tokens/utils.d.ts.map +1 -1
  59. package/dist/src/tokens/utils.js +24 -1
  60. package/package.json +6 -6
  61. package/dist/global-XVXVBKM6.json +0 -96
@@ -23,7 +23,7 @@ export declare const getValue: <T>(token: TransformedToken | DesignToken) => T;
23
23
  * @returns boolean
24
24
  */
25
25
  export declare const typeEquals: (types: string[] | string, token: TransformedToken) => boolean;
26
- export declare const pathStartsWithOneOf: (paths: string[], token: TransformedToken) => boolean;
26
+ export declare const pathStartsWithOneOf: ((paths: (string | string[])[], token: TransformedToken) => boolean) & ((paths: (string | string[])[]) => (token: TransformedToken) => boolean);
27
27
  export declare function isSemanticToken(token: TransformedToken): boolean;
28
28
  export declare function isSemanticColorToken(token: TransformedToken, color: string): boolean;
29
29
  export declare function isGlobalColorToken(token: TransformedToken): boolean;
@@ -57,4 +57,7 @@ export declare function traverseObj(obj: Tokens | TokenSet, fn: (obj: TokenSet |
57
57
  * where references to the matching tokens have been inlined
58
58
  */
59
59
  export declare function inlineTokens(shouldInline: (t: TransformedToken) => boolean, tokens: TransformedToken[]): TransformedToken[];
60
+ export declare function shortSizeName(size: string): string;
61
+ export declare const sizeComparator: (size: string) => number;
62
+ export declare function orderBySize(sizes: string[]): string[];
60
63
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tokens/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,KAAK,eAAe,EAAmB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMlF;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,gBAAgB,WAAkD,CAAC;AAElG;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,OAAO,gBAAgB,GAAG,WAAW,KAAG,CAAuC,CAAC;AAE5G;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,gBAAgB,KAAK,OAQ/E,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KA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AAE,sBAetG;AAUD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAG7C,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAErD"}
@@ -26,7 +26,10 @@ var pathStartsWithOneOf = R.curry(
26
26
  return false;
27
27
  }
28
28
  const tokenPath = mapToLowerCase(token.path);
29
- const matchPathsStartingWith = R.map((path) => R.startsWith([path], tokenPath), mapToLowerCase(paths));
29
+ const matchPathsStartingWith = R.map((pathOrString) => {
30
+ const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
31
+ return R.startsWith(mapToLowerCase(path), tokenPath);
32
+ }, paths);
30
33
  return hasAnyTruth(matchPathsStartingWith);
31
34
  }
32
35
  );
@@ -74,6 +77,23 @@ function inlineTokens(shouldInline, tokens) {
74
77
  return tokenWithInlinedRefs;
75
78
  });
76
79
  }
80
+ var sizeMap = {
81
+ xsmall: "xs",
82
+ small: "sm",
83
+ medium: "md",
84
+ large: "lg",
85
+ xlarge: "xl"
86
+ };
87
+ function shortSizeName(size) {
88
+ return sizeMap[size] ?? size;
89
+ }
90
+ var sizeComparator = (size) => {
91
+ const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size || val === size);
92
+ return sortIndex ?? 0;
93
+ };
94
+ function orderBySize(sizes) {
95
+ return R.sortBy(sizeComparator, sizes);
96
+ }
77
97
  export {
78
98
  getType,
79
99
  getValue,
@@ -83,7 +103,10 @@ export {
83
103
  isGlobalColorToken,
84
104
  isSemanticColorToken,
85
105
  isSemanticToken,
106
+ orderBySize,
86
107
  pathStartsWithOneOf,
108
+ shortSizeName,
109
+ sizeComparator,
87
110
  traverseObj,
88
111
  typeEquals
89
112
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@digdir/designsystemet",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "CLI for Designsystemet",
5
5
  "author": "Designsystemet team",
6
6
  "engines": {
7
- "node": ">=22.18.0"
7
+ "node": ">=22.19.0"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
@@ -50,8 +50,8 @@
50
50
  "picocolors": "^1.1.1",
51
51
  "postcss": "^8.5.6",
52
52
  "ramda": "^0.31.3",
53
- "style-dictionary": "^5.0.1",
54
- "zod": "^4.0.17",
53
+ "style-dictionary": "^5.0.4",
54
+ "zod": "^4.1.5",
55
55
  "zod-validation-error": "^4.0.1"
56
56
  },
57
57
  "devDependencies": {
@@ -59,13 +59,13 @@
59
59
  "@types/apca-w3": "^0.1.3",
60
60
  "@types/chroma-js": "^3.1.1",
61
61
  "@types/fs-extra": "^11.0.4",
62
- "@types/node": "^22.17.2",
62
+ "@types/node": "^22.18.1",
63
63
  "@types/object-hash": "^3.0.6",
64
64
  "@types/ramda": "^0.31.0",
65
65
  "fs-extra": "^11.3.1",
66
66
  "tslib": "^2.8.1",
67
67
  "tsup": "^8.5.0",
68
- "tsx": "^4.20.4",
68
+ "tsx": "^4.20.5",
69
69
  "typescript": "^5.9.2"
70
70
  },
71
71
  "scripts": {
@@ -1,96 +0,0 @@
1
- {
2
- "_size": {
3
- "0": {
4
- "$type": "dimension",
5
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *0)"
6
- },
7
- "1": {
8
- "$type": "dimension",
9
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *1)"
10
- },
11
- "2": {
12
- "$type": "dimension",
13
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *2)"
14
- },
15
- "3": {
16
- "$type": "dimension",
17
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *3)"
18
- },
19
- "4": {
20
- "$type": "dimension",
21
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *4)"
22
- },
23
- "5": {
24
- "$type": "dimension",
25
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *5)"
26
- },
27
- "6": {
28
- "$type": "dimension",
29
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *6)"
30
- },
31
- "7": {
32
- "$type": "dimension",
33
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *7)"
34
- },
35
- "8": {
36
- "$type": "dimension",
37
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *8)"
38
- },
39
- "9": {
40
- "$type": "dimension",
41
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *9)"
42
- },
43
- "10": {
44
- "$type": "dimension",
45
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *10)"
46
- },
47
- "11": {
48
- "$type": "dimension",
49
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *11)"
50
- },
51
- "12": {
52
- "$type": "dimension",
53
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *12)"
54
- },
55
- "13": {
56
- "$type": "dimension",
57
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *13)"
58
- },
59
- "14": {
60
- "$type": "dimension",
61
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *14)"
62
- },
63
- "15": {
64
- "$type": "dimension",
65
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *15)"
66
- },
67
- "18": {
68
- "$type": "dimension",
69
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *18)"
70
- },
71
- "22": {
72
- "$type": "dimension",
73
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *22)"
74
- },
75
- "26": {
76
- "$type": "dimension",
77
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *26)"
78
- },
79
- "30": {
80
- "$type": "dimension",
81
- "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *30)"
82
- },
83
- "mode-font-size": {
84
- "$type": "dimension",
85
- "$value": "{size._mode-font-size}"
86
- },
87
- "base": {
88
- "$type": "dimension",
89
- "$value": "{size._base}"
90
- },
91
- "step": {
92
- "$type": "dimension",
93
- "$value": "{size._step}"
94
- }
95
- }
96
- }