@digdir/designsystemet 1.0.3 → 1.0.4

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 (186) hide show
  1. package/dist/bin/designsystemet.js +4264 -45
  2. package/dist/bin/options.js +5 -4
  3. package/dist/src/colors/colorMetadata.js +5 -4
  4. package/dist/src/colors/index.js +470 -4
  5. package/dist/src/colors/theme.js +286 -20
  6. package/dist/src/colors/utils.js +16 -15
  7. package/dist/{bin → src}/config.d.ts +46 -1
  8. package/dist/src/config.d.ts.map +1 -0
  9. package/dist/src/config.js +377 -0
  10. package/dist/src/index.js +3666 -2
  11. package/dist/src/migrations/beta-to-v1.js +85 -4
  12. package/dist/src/migrations/codemods/css/plugins.js +5 -4
  13. package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
  14. package/dist/src/migrations/codemods/css/run.js +18 -4
  15. package/dist/src/migrations/color-rename-next49.js +77 -6
  16. package/dist/src/migrations/index.d.ts +0 -1
  17. package/dist/src/migrations/index.d.ts.map +1 -1
  18. package/dist/src/migrations/index.js +461 -6
  19. package/dist/src/scripts/createJsonSchema.js +1608 -4
  20. package/dist/src/scripts/update-design-tokens.d.ts +2 -0
  21. package/dist/src/scripts/update-design-tokens.d.ts.map +1 -0
  22. package/dist/src/scripts/update-design-tokens.js +36 -0
  23. package/dist/src/{tokens/template.d.ts → scripts/update-template.d.ts} +1 -1
  24. package/dist/src/scripts/update-template.d.ts.map +1 -0
  25. package/dist/src/scripts/update-template.js +1200 -0
  26. package/dist/src/tokens/build.d.ts +2 -19
  27. package/dist/src/tokens/build.d.ts.map +1 -1
  28. package/dist/src/tokens/build.js +1511 -70
  29. package/dist/src/tokens/create/defaults.d.ts +7 -0
  30. package/dist/src/tokens/create/defaults.d.ts.map +1 -0
  31. package/dist/src/tokens/create/defaults.js +994 -0
  32. package/dist/src/tokens/create/generators/$designsystemet.d.ts +5 -0
  33. package/dist/src/tokens/create/generators/$designsystemet.d.ts.map +1 -0
  34. package/dist/src/tokens/create/generators/$designsystemet.js +100 -0
  35. package/dist/src/tokens/create/generators/$metadata.d.ts +8 -0
  36. package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -0
  37. package/dist/src/tokens/{write/generate$metadata.js → create/generators/$metadata.js} +3 -2
  38. package/dist/src/tokens/create/generators/$themes.d.ts +12 -0
  39. package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -0
  40. package/dist/src/tokens/create/generators/$themes.js +333 -0
  41. package/dist/src/tokens/create/generators/color.d.ts +5 -0
  42. package/dist/src/tokens/create/generators/color.d.ts.map +1 -0
  43. package/dist/src/tokens/create/generators/color.js +374 -0
  44. package/dist/src/tokens/create/generators/semantic.d.ts +296 -0
  45. package/dist/src/tokens/create/generators/semantic.d.ts.map +1 -0
  46. package/dist/src/tokens/create/generators/semantic.js +483 -0
  47. package/dist/src/tokens/create/generators/theme.d.ts +3 -0
  48. package/dist/src/tokens/create/generators/theme.d.ts.map +1 -0
  49. package/dist/src/tokens/create/generators/theme.js +168 -0
  50. package/dist/src/tokens/create/generators/typography.d.ts +3 -0
  51. package/dist/src/tokens/create/generators/typography.d.ts.map +1 -0
  52. package/dist/src/tokens/create/generators/typography.js +33 -0
  53. package/dist/src/tokens/{write.d.ts → create/write.d.ts} +2 -2
  54. package/dist/src/tokens/create/write.d.ts.map +1 -0
  55. package/dist/src/tokens/create/write.js +546 -0
  56. package/dist/src/tokens/create.d.ts +4 -2
  57. package/dist/src/tokens/create.d.ts.map +1 -1
  58. package/dist/src/tokens/create.js +2049 -59
  59. package/dist/src/tokens/format.d.ts +16 -0
  60. package/dist/src/tokens/format.d.ts.map +1 -0
  61. package/dist/src/tokens/format.js +3514 -0
  62. package/dist/src/tokens/index.d.ts +1 -0
  63. package/dist/src/tokens/index.d.ts.map +1 -1
  64. package/dist/src/tokens/index.js +3526 -2
  65. package/dist/src/tokens/process/configs/color.d.ts +12 -0
  66. package/dist/src/tokens/process/configs/color.d.ts.map +1 -0
  67. package/dist/src/tokens/process/configs/color.js +823 -0
  68. package/dist/src/tokens/process/configs/semantic.d.ts +3 -0
  69. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -0
  70. package/dist/src/tokens/process/configs/semantic.js +367 -0
  71. package/dist/src/tokens/process/configs/shared.d.ts +10 -0
  72. package/dist/src/tokens/process/configs/shared.d.ts.map +1 -0
  73. package/dist/src/tokens/process/configs/shared.js +99 -0
  74. package/dist/src/tokens/process/configs/storefront.d.ts +3 -0
  75. package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -0
  76. package/dist/src/tokens/process/configs/storefront.js +220 -0
  77. package/dist/src/tokens/process/configs/typography.d.ts +3 -0
  78. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -0
  79. package/dist/src/tokens/process/configs/typography.js +369 -0
  80. package/dist/src/tokens/{build → process}/configs.d.ts +3 -11
  81. package/dist/src/tokens/process/configs.d.ts.map +1 -0
  82. package/dist/src/tokens/process/configs.js +976 -0
  83. package/dist/src/tokens/process/formats/css/color.d.ts +4 -0
  84. package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -0
  85. package/dist/src/tokens/process/formats/css/color.js +128 -0
  86. package/dist/src/tokens/process/formats/css/semantic.d.ts +17 -0
  87. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -0
  88. package/dist/src/tokens/process/formats/css/semantic.js +109 -0
  89. package/dist/src/tokens/process/formats/css/typography.d.ts +3 -0
  90. package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -0
  91. package/dist/src/tokens/process/formats/css/typography.js +32 -0
  92. package/dist/src/tokens/process/formats/css.d.ts +8 -0
  93. package/dist/src/tokens/process/formats/css.d.ts.map +1 -0
  94. package/dist/src/tokens/{build → process}/formats/css.js +94 -57
  95. package/dist/src/tokens/process/formats/js-tokens.d.ts.map +1 -0
  96. package/dist/src/tokens/process/formats/js-tokens.js +109 -0
  97. package/dist/src/tokens/process/platform.d.ts +87 -0
  98. package/dist/src/tokens/process/platform.d.ts.map +1 -0
  99. package/dist/src/tokens/process/platform.js +1090 -0
  100. package/dist/src/tokens/process/transformers.d.ts.map +1 -0
  101. package/dist/src/tokens/{build → process}/transformers.js +29 -6
  102. package/dist/src/tokens/{build → process}/utils/getMultidimensionalThemes.d.ts +3 -3
  103. package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -0
  104. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +922 -0
  105. package/dist/src/tokens/template/design-tokens/primitives/globals.js +5 -0
  106. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +5 -0
  107. package/dist/src/tokens/template/design-tokens/primitives/modes/size/large.js +5 -0
  108. package/dist/src/tokens/template/design-tokens/primitives/modes/size/medium.js +5 -0
  109. package/dist/src/tokens/template/design-tokens/primitives/modes/size/small.js +5 -0
  110. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/large.js +5 -0
  111. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/medium.js +5 -0
  112. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/small.js +5 -0
  113. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/typography.template.js +5 -0
  114. package/dist/src/tokens/template/design-tokens/semantic/color.base.template.js +5 -0
  115. package/dist/src/tokens/template/design-tokens/semantic/color.template.js +5 -0
  116. package/dist/src/tokens/template/design-tokens/semantic/modes/color.template.js +5 -0
  117. package/dist/src/tokens/template/design-tokens/semantic/style.js +5 -0
  118. package/dist/src/tokens/template/design-tokens/themes/theme.base.template.js +5 -0
  119. package/dist/src/tokens/template/design-tokens/themes/theme.template.js +5 -0
  120. package/dist/src/tokens/types.d.ts +54 -38
  121. package/dist/src/tokens/types.d.ts.map +1 -1
  122. package/dist/src/tokens/types.js +8 -0
  123. package/dist/src/tokens/utils.d.ts +30 -5
  124. package/dist/src/tokens/utils.d.ts.map +1 -1
  125. package/dist/src/tokens/utils.js +36 -50
  126. package/dist/src/utils.d.ts +18 -0
  127. package/dist/src/utils.d.ts.map +1 -0
  128. package/dist/src/utils.js +63 -0
  129. package/dist/typography.template-4N5YLH7F.json +22 -0
  130. package/package.json +17 -16
  131. package/dist/bin/config.d.ts.map +0 -1
  132. package/dist/bin/config.js +0 -71
  133. package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
  134. package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
  135. package/dist/src/migrations/codemods/jsx/classname-prefix.js +0 -64
  136. package/dist/src/migrations/codemods/jsx/run.d.ts +0 -7
  137. package/dist/src/migrations/codemods/jsx/run.d.ts.map +0 -1
  138. package/dist/src/migrations/codemods/jsx/run.js +0 -22
  139. package/dist/src/migrations/react-beta-to-v1.d.ts +0 -3
  140. package/dist/src/migrations/react-beta-to-v1.d.ts.map +0 -1
  141. package/dist/src/migrations/react-beta-to-v1.js +0 -5
  142. package/dist/src/scripts/copy-internal-tokens.d.ts +0 -2
  143. package/dist/src/scripts/copy-internal-tokens.d.ts.map +0 -1
  144. package/dist/src/scripts/copy-internal-tokens.js +0 -28
  145. package/dist/src/tokens/build/configs.d.ts.map +0 -1
  146. package/dist/src/tokens/build/configs.js +0 -280
  147. package/dist/src/tokens/build/formats/css.d.ts +0 -53
  148. package/dist/src/tokens/build/formats/css.d.ts.map +0 -1
  149. package/dist/src/tokens/build/formats/js-tokens.d.ts.map +0 -1
  150. package/dist/src/tokens/build/formats/js-tokens.js +0 -48
  151. package/dist/src/tokens/build/transformers.d.ts.map +0 -1
  152. package/dist/src/tokens/build/types.d.ts +0 -48
  153. package/dist/src/tokens/build/types.d.ts.map +0 -1
  154. package/dist/src/tokens/build/types.js +0 -7
  155. package/dist/src/tokens/build/utils/entryfile.d.ts +0 -12
  156. package/dist/src/tokens/build/utils/entryfile.d.ts.map +0 -1
  157. package/dist/src/tokens/build/utils/entryfile.js +0 -67
  158. package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts.map +0 -1
  159. package/dist/src/tokens/build/utils/getMultidimensionalThemes.js +0 -112
  160. package/dist/src/tokens/design-tokens/template/$metadata.json +0 -25
  161. package/dist/src/tokens/design-tokens/template/$themes.json +0 -1498
  162. package/dist/src/tokens/template.d.ts.map +0 -1
  163. package/dist/src/tokens/template.js +0 -99
  164. package/dist/src/tokens/write/generate$metadata.d.ts +0 -9
  165. package/dist/src/tokens/write/generate$metadata.d.ts.map +0 -1
  166. package/dist/src/tokens/write/generate$themes.d.ts +0 -12
  167. package/dist/src/tokens/write/generate$themes.d.ts.map +0 -1
  168. package/dist/src/tokens/write/generate$themes.js +0 -161
  169. package/dist/src/tokens/write.d.ts.map +0 -1
  170. package/dist/src/tokens/write.js +0 -177
  171. /package/dist/{src/tokens/design-tokens/template/semantic/color-base-file.json → color.base.template-M7BHS4OV.json} +0 -0
  172. /package/dist/{src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json → color.template-LMPUQ72A.json} +0 -0
  173. /package/dist/{src/tokens/design-tokens/template/semantic/semantic-color-template.json → color.template-XQNSHLTU.json} +0 -0
  174. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/global.json → global-XVXVBKM6.json} +0 -0
  175. /package/dist/{src/tokens/design-tokens/default/primitives/globals.json → globals-76VAFMDF.json} +0 -0
  176. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/large.json → large-CIIHO7AY.json} +0 -0
  177. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/large.json → large-UUOZ6DYI.json} +0 -0
  178. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/medium.json → medium-OQ7S7P4P.json} +0 -0
  179. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/medium.json → medium-VSB2S4X3.json} +0 -0
  180. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/small.json → small-AEXJ6U7Z.json} +0 -0
  181. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/small.json → small-ZY4KOJWX.json} +0 -0
  182. /package/dist/src/tokens/{build → process}/formats/js-tokens.d.ts +0 -0
  183. /package/dist/src/tokens/{build → process}/transformers.d.ts +0 -0
  184. /package/dist/{src/tokens/design-tokens/default/semantic/style.json → style-FP5XVCUD.json} +0 -0
  185. /package/dist/{src/tokens/design-tokens/template/themes/theme-base-file.json → theme.base.template-Y4RMFBQY.json} +0 -0
  186. /package/dist/{src/tokens/design-tokens/template/themes/theme-color-template.json → theme.template-CTQRNOMO.json} +0 -0
package/dist/src/index.js CHANGED
@@ -1,2 +1,3666 @@
1
- export * from "./colors/index.js";
2
- export * from "./tokens/index.js";
1
+ // src/colors/utils.ts
2
+ import chroma from "chroma-js";
3
+ import { Hsluv } from "hsluv";
4
+ var hexToCssHsl = (hex, valuesOnly = false) => {
5
+ const [h, s, l] = chroma(hex).hsl();
6
+ const hRounded = Math.round(h);
7
+ const sRounded = Math.round(s * 100);
8
+ const lRounded = Math.round(l * 100);
9
+ const cssString = `${hRounded},${sRounded}%,${lRounded}%`;
10
+ return valuesOnly ? cssString : `hsl(${cssString})`;
11
+ };
12
+ var hexToHSL = (hex) => {
13
+ const [h, s, l] = chroma(hex).hsl();
14
+ return [Math.round(h), Math.round(s * 100), Math.round(l * 100)];
15
+ };
16
+ var hexToHsluv = (hex) => {
17
+ const conv = new Hsluv();
18
+ conv.hex = hex;
19
+ conv.hexToHsluv();
20
+ return [conv.hsluv_h, conv.hsluv_s, conv.hsluv_l];
21
+ };
22
+ var hslArrToCss = (HSL) => {
23
+ return "hsl(" + HSL[0] + "," + HSL[1] + "%," + HSL[2] + "%)";
24
+ };
25
+ var HSLToHex = (h, s, l) => {
26
+ return chroma.hsl(h, s / 100, l / 100).hex();
27
+ };
28
+ var hexToRgb = (hex, type = "255") => {
29
+ const rgb = chroma(hex).rgb();
30
+ return {
31
+ r: type === "255" ? rgb[0] : rgb[0] / 255,
32
+ g: type === "255" ? rgb[1] : rgb[1] / 255,
33
+ b: type === "255" ? rgb[2] : rgb[2] / 255
34
+ };
35
+ };
36
+ var getContrastFromHex = (color1, color2) => {
37
+ const lum1 = chroma(color1).luminance();
38
+ const lum2 = chroma(color2).luminance();
39
+ return (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
40
+ };
41
+ var getContrastFromLightness = (lightness, mainColor, backgroundColor) => {
42
+ const conv = new Hsluv();
43
+ conv.hex = mainColor;
44
+ conv.hexToHsluv();
45
+ conv.hsluv_l = lightness;
46
+ conv.hsluvToHex();
47
+ const lightMainColor = conv.hex;
48
+ const lum1 = chroma(lightMainColor).luminance();
49
+ const lum2 = chroma(backgroundColor).luminance();
50
+ const ratio = (Math.max(lum1, lum2) + 0.05) / (Math.min(lum1, lum2) + 0.05);
51
+ return ratio;
52
+ };
53
+ var areColorsContrasting = (color1, color2, type = "aa") => {
54
+ const contrast = getContrastFromHex(color1, color2);
55
+ if (contrast !== null) {
56
+ if (type === "aaa") {
57
+ return contrast >= 7;
58
+ }
59
+ if (type === "aa") {
60
+ return contrast >= 4.5;
61
+ }
62
+ return contrast >= 3;
63
+ }
64
+ return false;
65
+ };
66
+ var isHexColor = (hex) => {
67
+ return typeof hex === "string" && hex.length === 6 && !Number.isNaN(Number("0x" + hex));
68
+ };
69
+ var getLuminanceFromLightness = (lightness) => {
70
+ const conv = new Hsluv();
71
+ conv.hsluv_l = lightness;
72
+ conv.hsluvToHex();
73
+ return chroma(conv.hex).luminance();
74
+ };
75
+ var getLightnessFromHex = (hex) => {
76
+ const conv = new Hsluv();
77
+ conv.hex = hex;
78
+ conv.hexToHsluv();
79
+ return conv.hsluv_l;
80
+ };
81
+ var canTextBeUsedOnColors = (baseDefaultColor, baseActiveColor) => {
82
+ const defaultAgainstWhite = getContrastFromHex(baseDefaultColor, "#ffffff");
83
+ const defaultAgainstBlack = getContrastFromHex(baseDefaultColor, "#000000");
84
+ const activeAgainstWhite = getContrastFromHex(baseActiveColor, "#ffffff");
85
+ const activeAgainstBlack = getContrastFromHex(baseActiveColor, "#000000");
86
+ if (defaultAgainstWhite >= 4.5 && activeAgainstWhite >= 4.5) {
87
+ return true;
88
+ }
89
+ if (defaultAgainstBlack >= 4.5 && activeAgainstBlack >= 4.5) {
90
+ return true;
91
+ }
92
+ return false;
93
+ };
94
+ var convertToHex = (color) => {
95
+ if (!color) {
96
+ return "#000000";
97
+ }
98
+ if (/^#[0-9A-Fa-f]{6}$/.test(color)) {
99
+ return color;
100
+ }
101
+ return chroma(color).hex();
102
+ };
103
+ var rgbToHex = (rgb) => {
104
+ return `#${[rgb.r, rgb.g, rgb.b].map((x) => {
105
+ const hex = Math.round(x * 255).toString(16);
106
+ return hex.length === 1 ? "0" + hex : hex;
107
+ }).join("")}`;
108
+ };
109
+
110
+ // src/colors/theme.ts
111
+ import chroma2 from "chroma-js";
112
+ import * as R2 from "ramda";
113
+
114
+ // src/colors/colorMetadata.ts
115
+ import * as R from "ramda";
116
+ var baseColors = {
117
+ blue: "#0A71C0",
118
+ green: "#068718",
119
+ orange: "#EA9B1B",
120
+ purple: "#663299",
121
+ red: "#C01B1B"
122
+ };
123
+ var colorMetadata = {
124
+ "background-default": {
125
+ number: 1,
126
+ name: "background-default",
127
+ group: "background",
128
+ displayName: "Background Default",
129
+ description: {
130
+ long: "Background Default er den mest n\xF8ytrale bakgrunnsfargen.",
131
+ short: "Standard bakgrunnsfarge."
132
+ },
133
+ luminance: {
134
+ light: 1,
135
+ dark: 9e-3,
136
+ contrast: 1e-3
137
+ }
138
+ },
139
+ "background-tinted": {
140
+ number: 2,
141
+ name: "background-tinted",
142
+ group: "background",
143
+ displayName: "Background Tinted",
144
+ description: {
145
+ long: "Background Tinted er en bakgrunnsfarge som har et hint av farge i seg.",
146
+ short: "Bakgrunn med et hint av farge i seg."
147
+ },
148
+ luminance: {
149
+ light: 0.9,
150
+ dark: 0.014,
151
+ contrast: 65e-4
152
+ }
153
+ },
154
+ "surface-default": {
155
+ number: 3,
156
+ name: "surface-default",
157
+ group: "surface",
158
+ displayName: "Surface Default",
159
+ description: {
160
+ long: "Surface Default brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Dette er den mest n\xF8ytrale surface fargen.",
161
+ short: "Standardfarge for overflater / komponenter."
162
+ },
163
+ luminance: {
164
+ light: 1,
165
+ dark: 0.021,
166
+ contrast: 0.015
167
+ }
168
+ },
169
+ "surface-tinted": {
170
+ number: 4,
171
+ name: "surface-tinted",
172
+ group: "surface",
173
+ displayName: "Surface Tinted",
174
+ description: {
175
+ long: "Surface Tinted brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Denne har et hint av farge i seg.",
176
+ short: "Overflater / komponenter med et hint av farge i seg."
177
+ },
178
+ luminance: {
179
+ light: 0.81,
180
+ dark: 0.027,
181
+ contrast: 0.015
182
+ }
183
+ },
184
+ "surface-hover": {
185
+ number: 5,
186
+ name: "surface-hover",
187
+ group: "surface",
188
+ displayName: "Surface Hover",
189
+ description: {
190
+ long: "Surface Hover brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en hover state.",
191
+ short: "Hover-farge til overflater / komponenter."
192
+ },
193
+ luminance: {
194
+ light: 0.7,
195
+ dark: 0.036,
196
+ contrast: 0.028
197
+ }
198
+ },
199
+ "surface-active": {
200
+ number: 6,
201
+ name: "surface-active",
202
+ group: "surface",
203
+ displayName: "Surface Active",
204
+ description: {
205
+ long: "Surface Active brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en active state.",
206
+ short: "Active-farge til overflater / komponenter."
207
+ },
208
+ luminance: {
209
+ light: 0.59,
210
+ dark: 0.056,
211
+ contrast: 0.045
212
+ }
213
+ },
214
+ "border-subtle": {
215
+ number: 7,
216
+ name: "border-subtle",
217
+ group: "border",
218
+ displayName: "Border Subtle",
219
+ description: {
220
+ long: "Border Subtle er den lyseste border-fargen og brukes for \xE5 skille elementer fra hverandre.",
221
+ short: "Border-farge med lav kontrast til dekorativ bruk (skillelinjer)."
222
+ },
223
+ luminance: {
224
+ light: 0.5,
225
+ dark: 0.08,
226
+ contrast: 0.26
227
+ }
228
+ },
229
+ "border-default": {
230
+ number: 8,
231
+ name: "border-default",
232
+ group: "border",
233
+ displayName: "Border Default",
234
+ description: {
235
+ long: "Border Default er en border-farge som brukes n\xE5r man \xF8nsker god kontrast mot bakgrunnsfargene.",
236
+ short: "Standard border-farge til skjemakomponenter og meningsb\xE6rende elementer."
237
+ },
238
+ luminance: {
239
+ light: 0.19,
240
+ dark: 0.22,
241
+ contrast: 0.4
242
+ }
243
+ },
244
+ "border-strong": {
245
+ number: 9,
246
+ name: "border-strong",
247
+ group: "border",
248
+ displayName: "Border Strong",
249
+ description: {
250
+ long: "Border Strong er den m\xF8rkeste border-fargen og brukes n\xE5r man \xF8nsker en veldig tydelig og sterk border.",
251
+ short: "Border-farge med h\xF8y kontrast for ekstra synlighet."
252
+ },
253
+ luminance: {
254
+ light: 0.11,
255
+ dark: 0.39,
256
+ contrast: 0.6
257
+ }
258
+ },
259
+ "text-subtle": {
260
+ number: 10,
261
+ name: "text-subtle",
262
+ group: "text",
263
+ displayName: "Text Subtle",
264
+ description: {
265
+ long: "Text Subtle er den lyseste tekstfargen og brukes p\xE5 tekst som skal v\xE6re litt mindre synlig eller for \xE5 skape variasjon i typografien.",
266
+ short: "Tekst- og ikonfarge med lavere kontrast."
267
+ },
268
+ luminance: {
269
+ light: 0.11,
270
+ dark: 0.39,
271
+ contrast: 0.57
272
+ }
273
+ },
274
+ "text-default": {
275
+ number: 11,
276
+ name: "text-default",
277
+ group: "text",
278
+ displayName: "Text Default",
279
+ description: {
280
+ long: "Text Default er den m\xF8rkeste tekstfargen og brukes p\xE5 tekst som skal v\xE6re mest synlig. Denne fargen b\xF8r brukes p\xE5 mesteparten av teksten p\xE5 en side.",
281
+ short: "Tekst- og ikonfarge med h\xF8y kontrast og god synlighet."
282
+ },
283
+ luminance: {
284
+ light: 0.0245,
285
+ dark: 0.84,
286
+ contrast: 0.86
287
+ }
288
+ },
289
+ "base-default": {
290
+ number: 12,
291
+ name: "base-default",
292
+ group: "base",
293
+ displayName: "Base Default",
294
+ description: {
295
+ long: "Base Default fargen f\xE5r den samme hex koden som fargen som er valgt i verkt\xF8yet. Brukes ofte som farge p\xE5 viktige elementer og p\xE5 flater som skal fange brukerens oppmerksomhet.",
296
+ short: "Standardfarge for solide bakgrunner."
297
+ },
298
+ luminance: {
299
+ light: 1,
300
+ dark: 1,
301
+ contrast: 1
302
+ }
303
+ },
304
+ "base-hover": {
305
+ number: 13,
306
+ name: "base-hover",
307
+ group: "base",
308
+ displayName: "Base Hover",
309
+ description: {
310
+ long: "Base Hover brukes som hover farge p\xE5 elementer som bruker Base Default fargen.",
311
+ short: "Hover-farge for solide bakgrunner."
312
+ },
313
+ luminance: {
314
+ light: 1,
315
+ dark: 1,
316
+ contrast: 1
317
+ }
318
+ },
319
+ "base-active": {
320
+ number: 14,
321
+ name: "base-active",
322
+ group: "base",
323
+ displayName: "Base Active",
324
+ description: {
325
+ long: "Base Active brukes som active farge p\xE5 elementer som bruker Base Default fargen.",
326
+ short: "Active-farge for solide bakgrunner."
327
+ },
328
+ luminance: {
329
+ light: 1,
330
+ dark: 1,
331
+ contrast: 1
332
+ }
333
+ },
334
+ "base-contrast-subtle": {
335
+ number: 15,
336
+ name: "base-contrast-subtle",
337
+ group: "base",
338
+ displayName: "Contrast Subtle",
339
+ description: {
340
+ long: "Contrast Subtle brukes som en viktig meningsb\xE6rende farge opp\xE5 Base Default fargen.",
341
+ short: "Farge med god kontrast mot Base-default."
342
+ },
343
+ luminance: {
344
+ light: 1,
345
+ dark: 1,
346
+ contrast: 1
347
+ }
348
+ },
349
+ "base-contrast-default": {
350
+ number: 16,
351
+ name: "base-contrast-default",
352
+ group: "base",
353
+ displayName: "Contrast Default",
354
+ description: {
355
+ long: "Contrast Default brukes som en viktig meningsb\xE6rende farge opp\xE5 alle Base fargane.",
356
+ short: "Farge med god kontrast mot Base-default og Base-hover."
357
+ },
358
+ luminance: {
359
+ light: 1,
360
+ dark: 1,
361
+ contrast: 1
362
+ }
363
+ }
364
+ };
365
+ var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
366
+ var getColorMetadataByNumber = (number) => {
367
+ return colorMetadataByNumber[number];
368
+ };
369
+
370
+ // src/colors/theme.ts
371
+ var RESERVED_COLORS = [
372
+ "neutral",
373
+ "success",
374
+ "warning",
375
+ "danger",
376
+ "info",
377
+ "blue",
378
+ "green",
379
+ "orange",
380
+ "purple",
381
+ "red"
382
+ ];
383
+ var generateColorScale = (color, colorScheme2) => {
384
+ let interpolationColor = color;
385
+ if (colorScheme2 === "dark") {
386
+ const [L, C, H] = chroma2(color).oklch();
387
+ const chromaModifier = 0.7;
388
+ interpolationColor = chroma2(L, C * chromaModifier, H, "oklch").hex();
389
+ }
390
+ const colors = R2.mapObjIndexed((colorData) => {
391
+ const luminance = colorData.luminance[colorScheme2];
392
+ return {
393
+ ...colorData,
394
+ hex: chroma2(interpolationColor).luminance(luminance).hex()
395
+ };
396
+ }, colorMetadata);
397
+ const baseColors2 = generateBaseColors(color, colorScheme2);
398
+ colors["base-default"] = { ...colors["base-default"], hex: baseColors2.default };
399
+ colors["base-hover"] = { ...colors["base-hover"], hex: baseColors2.hover };
400
+ colors["base-active"] = { ...colors["base-active"], hex: baseColors2.active };
401
+ colors["base-contrast-subtle"] = {
402
+ ...colors["base-contrast-subtle"],
403
+ hex: generateColorContrast(baseColors2.default, "subtle")
404
+ };
405
+ colors["base-contrast-default"] = {
406
+ ...colors["base-contrast-default"],
407
+ hex: generateColorContrast(baseColors2.default, "default")
408
+ };
409
+ return Object.values(colors);
410
+ };
411
+ var generateColorSchemes = (color) => ({
412
+ light: generateColorScale(color, "light"),
413
+ dark: generateColorScale(color, "dark"),
414
+ contrast: generateColorScale(color, "contrast")
415
+ });
416
+ var generateBaseColors = (color, colorScheme2) => {
417
+ let colorLightness = getLightnessFromHex(color);
418
+ if (colorScheme2 !== "light") {
419
+ colorLightness = colorLightness <= 30 ? 70 : 100 - colorLightness;
420
+ }
421
+ const modifier = colorLightness <= 30 || colorLightness >= 49 && colorLightness <= 65 ? -8 : 8;
422
+ const calculateLightness = (base, mod) => base - mod;
423
+ return {
424
+ default: colorScheme2 === "light" ? color : chroma2(color).luminance(getLuminanceFromLightness(colorLightness)).hex(),
425
+ hover: chroma2(color).luminance(getLuminanceFromLightness(calculateLightness(colorLightness, modifier))).hex(),
426
+ active: chroma2(color).luminance(getLuminanceFromLightness(calculateLightness(colorLightness, modifier * 2))).hex()
427
+ };
428
+ };
429
+ var generateColorContrast = (color, type) => {
430
+ if (type === "default") {
431
+ return chroma2.contrast(color, "#ffffff") >= chroma2.contrast(color, "#000000") ? "#ffffff" : "#000000";
432
+ }
433
+ if (type === "subtle") {
434
+ const contrastWhite = chroma2.contrast(color, "#ffffff");
435
+ const contrastBlack = chroma2.contrast(color, "#000000");
436
+ const lightness = getLightnessFromHex(color);
437
+ const modifier = lightness <= 40 || lightness >= 60 ? 60 : 50;
438
+ const targetLightness = contrastWhite >= contrastBlack ? lightness + modifier : lightness - modifier;
439
+ return chroma2(color).luminance(getLuminanceFromLightness(targetLightness)).hex();
440
+ }
441
+ return color;
442
+ };
443
+ var getCssVariable = (colorType, colorNumber) => {
444
+ return `--ds-color-${colorType}-${getColorMetadataByNumber(colorNumber).displayName.toLowerCase().replace(/\s/g, "-")}`;
445
+ };
446
+
447
+ // src/tokens/create/defaults.ts
448
+ import * as R3 from "ramda";
449
+
450
+ // src/tokens/template/design-tokens/primitives/globals.json with { type: 'json' }
451
+ var globals_default = {
452
+ "border-width": {
453
+ "1": {
454
+ $type: "borderWidth",
455
+ $value: "1px"
456
+ },
457
+ "3": {
458
+ $type: "borderWidth",
459
+ $value: "3px"
460
+ }
461
+ },
462
+ shadow: {
463
+ "100": {
464
+ $type: "boxShadow",
465
+ $value: [
466
+ {
467
+ color: "rgba(0,0,0,0.16)",
468
+ x: "0",
469
+ y: "0",
470
+ blur: "1",
471
+ spread: "0"
472
+ },
473
+ {
474
+ x: "0",
475
+ y: "1",
476
+ blur: "2",
477
+ spread: "0",
478
+ color: "rgba(0,0,0,0.12)"
479
+ }
480
+ ]
481
+ },
482
+ "200": {
483
+ $type: "boxShadow",
484
+ $value: [
485
+ {
486
+ color: "rgba(0,0,0,0.15)",
487
+ x: "0",
488
+ y: "0",
489
+ blur: "1",
490
+ spread: "0"
491
+ },
492
+ {
493
+ color: "rgba(0,0,0,0.12)",
494
+ x: "0",
495
+ y: "1",
496
+ blur: "2",
497
+ spread: "0"
498
+ },
499
+ {
500
+ x: "0",
501
+ y: "2",
502
+ blur: "4",
503
+ spread: "0",
504
+ color: "rgba(0,0,0,0.1)"
505
+ }
506
+ ]
507
+ },
508
+ "300": {
509
+ $type: "boxShadow",
510
+ $value: [
511
+ {
512
+ color: "rgba(0,0,0,0.14)",
513
+ x: "0",
514
+ y: "0",
515
+ blur: "1",
516
+ spread: "0"
517
+ },
518
+ {
519
+ color: "rgba(0,0,0,0.12)",
520
+ x: "0",
521
+ y: "2",
522
+ blur: "4",
523
+ spread: "0"
524
+ },
525
+ {
526
+ x: "0",
527
+ y: "4",
528
+ blur: "8",
529
+ spread: "0",
530
+ color: "rgba(0,0,0,0.12)"
531
+ }
532
+ ]
533
+ },
534
+ "400": {
535
+ $type: "boxShadow",
536
+ $value: [
537
+ {
538
+ color: "rgba(0,0,0,0.13)",
539
+ x: "0",
540
+ y: "0",
541
+ blur: "1",
542
+ spread: "0"
543
+ },
544
+ {
545
+ color: "rgba(0,0,0,0.13)",
546
+ x: "0",
547
+ y: "3",
548
+ blur: "5",
549
+ spread: "0"
550
+ },
551
+ {
552
+ x: "0",
553
+ y: "6",
554
+ blur: "12",
555
+ spread: "0",
556
+ color: "rgba(0,0,0,0.14)"
557
+ }
558
+ ]
559
+ },
560
+ "500": {
561
+ $type: "boxShadow",
562
+ $value: [
563
+ {
564
+ color: "rgba(0,0,0,0.12)",
565
+ x: "0",
566
+ y: "0",
567
+ blur: "1",
568
+ spread: "0"
569
+ },
570
+ {
571
+ color: "rgba(0,0,0,0.16)",
572
+ x: "0",
573
+ y: "4",
574
+ blur: "8",
575
+ spread: "0"
576
+ },
577
+ {
578
+ x: "0",
579
+ y: "12",
580
+ blur: "24",
581
+ spread: "0",
582
+ color: "rgba(0,0,0,0.16)"
583
+ }
584
+ ]
585
+ }
586
+ },
587
+ opacity: {
588
+ "30": {
589
+ $type: "opacity",
590
+ $value: "30%"
591
+ }
592
+ }
593
+ };
594
+
595
+ // src/tokens/template/design-tokens/primitives/modes/size/global.json with { type: 'json' }
596
+ var global_default = {
597
+ _size: {
598
+ "0": {
599
+ $type: "dimension",
600
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *0)"
601
+ },
602
+ "1": {
603
+ $type: "dimension",
604
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *1)"
605
+ },
606
+ "2": {
607
+ $type: "dimension",
608
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *2)"
609
+ },
610
+ "3": {
611
+ $type: "dimension",
612
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *3)"
613
+ },
614
+ "4": {
615
+ $type: "dimension",
616
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *4)"
617
+ },
618
+ "5": {
619
+ $type: "dimension",
620
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *5)"
621
+ },
622
+ "6": {
623
+ $type: "dimension",
624
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *6)"
625
+ },
626
+ "7": {
627
+ $type: "dimension",
628
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *7)"
629
+ },
630
+ "8": {
631
+ $type: "dimension",
632
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *8)"
633
+ },
634
+ "9": {
635
+ $type: "dimension",
636
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *9)"
637
+ },
638
+ "10": {
639
+ $type: "dimension",
640
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *10)"
641
+ },
642
+ "11": {
643
+ $type: "dimension",
644
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *11)"
645
+ },
646
+ "12": {
647
+ $type: "dimension",
648
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *12)"
649
+ },
650
+ "13": {
651
+ $type: "dimension",
652
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *13)"
653
+ },
654
+ "14": {
655
+ $type: "dimension",
656
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *14)"
657
+ },
658
+ "15": {
659
+ $type: "dimension",
660
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *15)"
661
+ },
662
+ "18": {
663
+ $type: "dimension",
664
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *18)"
665
+ },
666
+ "22": {
667
+ $type: "dimension",
668
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *22)"
669
+ },
670
+ "26": {
671
+ $type: "dimension",
672
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *26)"
673
+ },
674
+ "30": {
675
+ $type: "dimension",
676
+ $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *30)"
677
+ },
678
+ "mode-font-size": {
679
+ $type: "dimension",
680
+ $value: "{size._mode-font-size}"
681
+ },
682
+ base: {
683
+ $type: "dimension",
684
+ $value: "{size._base}"
685
+ },
686
+ step: {
687
+ $type: "dimension",
688
+ $value: "{size._step}"
689
+ }
690
+ }
691
+ };
692
+
693
+ // src/tokens/template/design-tokens/primitives/modes/size/large.json with { type: 'json' }
694
+ var large_default = {
695
+ size: {
696
+ "_mode-font-size": {
697
+ $type: "dimension",
698
+ $value: "21"
699
+ },
700
+ _base: {
701
+ $type: "dimension",
702
+ $value: "18"
703
+ },
704
+ _step: {
705
+ $type: "dimension",
706
+ $value: "4"
707
+ }
708
+ }
709
+ };
710
+
711
+ // src/tokens/template/design-tokens/primitives/modes/size/medium.json with { type: 'json' }
712
+ var medium_default = {
713
+ size: {
714
+ "_mode-font-size": {
715
+ $type: "dimension",
716
+ $value: "18"
717
+ },
718
+ _base: {
719
+ $type: "dimension",
720
+ $value: "18"
721
+ },
722
+ _step: {
723
+ $type: "dimension",
724
+ $value: "4"
725
+ }
726
+ }
727
+ };
728
+
729
+ // src/tokens/template/design-tokens/primitives/modes/size/small.json with { type: 'json' }
730
+ var small_default = {
731
+ size: {
732
+ "_mode-font-size": {
733
+ $type: "dimension",
734
+ $value: "16"
735
+ },
736
+ _base: {
737
+ $type: "dimension",
738
+ $value: "18"
739
+ },
740
+ _step: {
741
+ $type: "dimension",
742
+ $value: "4"
743
+ }
744
+ }
745
+ };
746
+
747
+ // src/tokens/template/design-tokens/primitives/modes/typography/size/large.json with { type: 'json' }
748
+ var large_default2 = {
749
+ "line-height": {
750
+ sm: {
751
+ $type: "lineHeights",
752
+ $value: "130%"
753
+ },
754
+ md: {
755
+ $type: "lineHeights",
756
+ $value: "150%"
757
+ },
758
+ lg: {
759
+ $type: "lineHeights",
760
+ $value: "170%"
761
+ }
762
+ },
763
+ "font-size": {
764
+ "1": {
765
+ $type: "fontSizes",
766
+ $value: "13"
767
+ },
768
+ "2": {
769
+ $type: "fontSizes",
770
+ $value: "16"
771
+ },
772
+ "3": {
773
+ $type: "fontSizes",
774
+ $value: "18"
775
+ },
776
+ "4": {
777
+ $type: "fontSizes",
778
+ $value: "21"
779
+ },
780
+ "5": {
781
+ $type: "fontSizes",
782
+ $value: "24"
783
+ },
784
+ "6": {
785
+ $type: "fontSizes",
786
+ $value: "30"
787
+ },
788
+ "7": {
789
+ $type: "fontSizes",
790
+ $value: "36"
791
+ },
792
+ "8": {
793
+ $type: "fontSizes",
794
+ $value: "48"
795
+ },
796
+ "9": {
797
+ $type: "fontSizes",
798
+ $value: "60"
799
+ },
800
+ "10": {
801
+ $type: "fontSizes",
802
+ $value: "72"
803
+ }
804
+ },
805
+ "letter-spacing": {
806
+ "1": {
807
+ $type: "letterSpacing",
808
+ $value: "-1%"
809
+ },
810
+ "2": {
811
+ $type: "letterSpacing",
812
+ $value: "-0.5%"
813
+ },
814
+ "3": {
815
+ $type: "letterSpacing",
816
+ $value: "-0.25%"
817
+ },
818
+ "4": {
819
+ $type: "letterSpacing",
820
+ $value: "-0.15%"
821
+ },
822
+ "5": {
823
+ $type: "letterSpacing",
824
+ $value: "0%"
825
+ },
826
+ "6": {
827
+ $type: "letterSpacing",
828
+ $value: "0.15%"
829
+ },
830
+ "7": {
831
+ $type: "letterSpacing",
832
+ $value: "0.25%"
833
+ },
834
+ "8": {
835
+ $type: "letterSpacing",
836
+ $value: "0.5%"
837
+ },
838
+ "9": {
839
+ $type: "letterSpacing",
840
+ $value: "1.5%"
841
+ }
842
+ }
843
+ };
844
+
845
+ // src/tokens/template/design-tokens/primitives/modes/typography/size/medium.json with { type: 'json' }
846
+ var medium_default2 = {
847
+ "line-height": {
848
+ sm: {
849
+ $type: "lineHeights",
850
+ $value: "130%"
851
+ },
852
+ md: {
853
+ $type: "lineHeights",
854
+ $value: "150%"
855
+ },
856
+ lg: {
857
+ $type: "lineHeights",
858
+ $value: "170%"
859
+ }
860
+ },
861
+ "font-size": {
862
+ "1": {
863
+ $type: "fontSizes",
864
+ $value: "12"
865
+ },
866
+ "2": {
867
+ $type: "fontSizes",
868
+ $value: "14"
869
+ },
870
+ "3": {
871
+ $type: "fontSizes",
872
+ $value: "16"
873
+ },
874
+ "4": {
875
+ $type: "fontSizes",
876
+ $value: "18"
877
+ },
878
+ "5": {
879
+ $type: "fontSizes",
880
+ $value: "21"
881
+ },
882
+ "6": {
883
+ $type: "fontSizes",
884
+ $value: "24"
885
+ },
886
+ "7": {
887
+ $type: "fontSizes",
888
+ $value: "30"
889
+ },
890
+ "8": {
891
+ $type: "fontSizes",
892
+ $value: "36"
893
+ },
894
+ "9": {
895
+ $type: "fontSizes",
896
+ $value: "48"
897
+ },
898
+ "10": {
899
+ $type: "fontSizes",
900
+ $value: "60"
901
+ }
902
+ },
903
+ "letter-spacing": {
904
+ "1": {
905
+ $type: "letterSpacing",
906
+ $value: "-1%"
907
+ },
908
+ "2": {
909
+ $type: "letterSpacing",
910
+ $value: "-0.5%"
911
+ },
912
+ "3": {
913
+ $type: "letterSpacing",
914
+ $value: "-0.25%"
915
+ },
916
+ "4": {
917
+ $type: "letterSpacing",
918
+ $value: "-0.15%"
919
+ },
920
+ "5": {
921
+ $type: "letterSpacing",
922
+ $value: "0%"
923
+ },
924
+ "6": {
925
+ $type: "letterSpacing",
926
+ $value: "0.15%"
927
+ },
928
+ "7": {
929
+ $type: "letterSpacing",
930
+ $value: "0.25%"
931
+ },
932
+ "8": {
933
+ $type: "letterSpacing",
934
+ $value: "0.5%"
935
+ },
936
+ "9": {
937
+ $type: "letterSpacing",
938
+ $value: "1.5%"
939
+ }
940
+ }
941
+ };
942
+
943
+ // src/tokens/template/design-tokens/primitives/modes/typography/size/small.json with { type: 'json' }
944
+ var small_default2 = {
945
+ "line-height": {
946
+ sm: {
947
+ $type: "lineHeights",
948
+ $value: "130%"
949
+ },
950
+ md: {
951
+ $type: "lineHeights",
952
+ $value: "150%"
953
+ },
954
+ lg: {
955
+ $type: "lineHeights",
956
+ $value: "170%"
957
+ }
958
+ },
959
+ "font-size": {
960
+ "1": {
961
+ $type: "fontSizes",
962
+ $value: "11"
963
+ },
964
+ "2": {
965
+ $type: "fontSizes",
966
+ $value: "13"
967
+ },
968
+ "3": {
969
+ $type: "fontSizes",
970
+ $value: "14"
971
+ },
972
+ "4": {
973
+ $type: "fontSizes",
974
+ $value: "16"
975
+ },
976
+ "5": {
977
+ $type: "fontSizes",
978
+ $value: "18"
979
+ },
980
+ "6": {
981
+ $type: "fontSizes",
982
+ $value: "21"
983
+ },
984
+ "7": {
985
+ $type: "fontSizes",
986
+ $value: "24"
987
+ },
988
+ "8": {
989
+ $type: "fontSizes",
990
+ $value: "30"
991
+ },
992
+ "9": {
993
+ $type: "fontSizes",
994
+ $value: "36"
995
+ },
996
+ "10": {
997
+ $type: "fontSizes",
998
+ $value: "48"
999
+ }
1000
+ },
1001
+ "letter-spacing": {
1002
+ "1": {
1003
+ $type: "letterSpacing",
1004
+ $value: "-1%"
1005
+ },
1006
+ "2": {
1007
+ $type: "letterSpacing",
1008
+ $value: "-0.5%"
1009
+ },
1010
+ "3": {
1011
+ $type: "letterSpacing",
1012
+ $value: "-0.25%"
1013
+ },
1014
+ "4": {
1015
+ $type: "letterSpacing",
1016
+ $value: "-0.15%"
1017
+ },
1018
+ "5": {
1019
+ $type: "letterSpacing",
1020
+ $value: "0%"
1021
+ },
1022
+ "6": {
1023
+ $type: "letterSpacing",
1024
+ $value: "0.15%"
1025
+ },
1026
+ "7": {
1027
+ $type: "letterSpacing",
1028
+ $value: "0.25%"
1029
+ },
1030
+ "8": {
1031
+ $type: "letterSpacing",
1032
+ $value: "0.5%"
1033
+ },
1034
+ "9": {
1035
+ $type: "letterSpacing",
1036
+ $value: "1.5%"
1037
+ }
1038
+ }
1039
+ };
1040
+
1041
+ // src/tokens/template/design-tokens/semantic/style.json with { type: 'json' }
1042
+ var style_default = {
1043
+ typography: {
1044
+ heading: {
1045
+ "2xl": {
1046
+ $type: "typography",
1047
+ $value: {
1048
+ fontFamily: "{font-family}",
1049
+ fontWeight: "{font-weight.medium}",
1050
+ lineHeight: "{line-height.sm}",
1051
+ fontSize: "{font-size.10}",
1052
+ letterSpacing: "{letter-spacing.1}"
1053
+ }
1054
+ },
1055
+ xl: {
1056
+ $type: "typography",
1057
+ $value: {
1058
+ fontFamily: "{font-family}",
1059
+ fontWeight: "{font-weight.medium}",
1060
+ lineHeight: "{line-height.sm}",
1061
+ fontSize: "{font-size.9}",
1062
+ letterSpacing: "{letter-spacing.1}"
1063
+ }
1064
+ },
1065
+ lg: {
1066
+ $type: "typography",
1067
+ $value: {
1068
+ fontFamily: "{font-family}",
1069
+ fontWeight: "{font-weight.medium}",
1070
+ lineHeight: "{line-height.sm}",
1071
+ fontSize: "{font-size.8}",
1072
+ letterSpacing: "{letter-spacing.2}"
1073
+ }
1074
+ },
1075
+ md: {
1076
+ $type: "typography",
1077
+ $value: {
1078
+ fontFamily: "{font-family}",
1079
+ fontWeight: "{font-weight.medium}",
1080
+ lineHeight: "{line-height.sm}",
1081
+ fontSize: "{font-size.7}",
1082
+ letterSpacing: "{letter-spacing.3}"
1083
+ }
1084
+ },
1085
+ sm: {
1086
+ $type: "typography",
1087
+ $value: {
1088
+ fontFamily: "{font-family}",
1089
+ fontWeight: "{font-weight.medium}",
1090
+ lineHeight: "{line-height.sm}",
1091
+ fontSize: "{font-size.6}",
1092
+ letterSpacing: "{letter-spacing.5}"
1093
+ }
1094
+ },
1095
+ xs: {
1096
+ $type: "typography",
1097
+ $value: {
1098
+ fontFamily: "{font-family}",
1099
+ fontWeight: "{font-weight.medium}",
1100
+ lineHeight: "{line-height.sm}",
1101
+ fontSize: "{font-size.5}",
1102
+ letterSpacing: "{letter-spacing.6}"
1103
+ }
1104
+ },
1105
+ "2xs": {
1106
+ $type: "typography",
1107
+ $value: {
1108
+ fontFamily: "{font-family}",
1109
+ fontWeight: "{font-weight.medium}",
1110
+ lineHeight: "{line-height.sm}",
1111
+ fontSize: "{font-size.4}",
1112
+ letterSpacing: "{letter-spacing.6}"
1113
+ }
1114
+ }
1115
+ },
1116
+ body: {
1117
+ xl: {
1118
+ $type: "typography",
1119
+ $value: {
1120
+ fontFamily: "{font-family}",
1121
+ fontWeight: "{font-weight.regular}",
1122
+ lineHeight: "{line-height.md}",
1123
+ fontSize: "{font-size.6}",
1124
+ letterSpacing: "{letter-spacing.8}"
1125
+ }
1126
+ },
1127
+ lg: {
1128
+ $type: "typography",
1129
+ $value: {
1130
+ fontFamily: "{font-family}",
1131
+ fontWeight: "{font-weight.regular}",
1132
+ lineHeight: "{line-height.md}",
1133
+ fontSize: "{font-size.5}",
1134
+ letterSpacing: "{letter-spacing.8}"
1135
+ }
1136
+ },
1137
+ md: {
1138
+ $type: "typography",
1139
+ $value: {
1140
+ fontFamily: "{font-family}",
1141
+ fontWeight: "{font-weight.regular}",
1142
+ lineHeight: "{line-height.md}",
1143
+ fontSize: "{font-size.4}",
1144
+ letterSpacing: "{letter-spacing.8}"
1145
+ }
1146
+ },
1147
+ sm: {
1148
+ $type: "typography",
1149
+ $value: {
1150
+ fontFamily: "{font-family}",
1151
+ fontWeight: "{font-weight.regular}",
1152
+ lineHeight: "{line-height.md}",
1153
+ fontSize: "{font-size.3}",
1154
+ letterSpacing: "{letter-spacing.7}"
1155
+ }
1156
+ },
1157
+ xs: {
1158
+ $type: "typography",
1159
+ $value: {
1160
+ fontFamily: "{font-family}",
1161
+ fontWeight: "{font-weight.regular}",
1162
+ lineHeight: "{line-height.md}",
1163
+ fontSize: "{font-size.2}",
1164
+ letterSpacing: "{letter-spacing.6}"
1165
+ }
1166
+ },
1167
+ short: {
1168
+ xl: {
1169
+ $type: "typography",
1170
+ $value: {
1171
+ fontFamily: "{font-family}",
1172
+ fontWeight: "{font-weight.regular}",
1173
+ lineHeight: "{line-height.sm}",
1174
+ fontSize: "{font-size.6}",
1175
+ letterSpacing: "{letter-spacing.8}"
1176
+ }
1177
+ },
1178
+ lg: {
1179
+ $type: "typography",
1180
+ $value: {
1181
+ fontFamily: "{font-family}",
1182
+ fontWeight: "{font-weight.regular}",
1183
+ lineHeight: "{line-height.sm}",
1184
+ fontSize: "{font-size.5}",
1185
+ letterSpacing: "{letter-spacing.8}"
1186
+ }
1187
+ },
1188
+ md: {
1189
+ $type: "typography",
1190
+ $value: {
1191
+ fontFamily: "{font-family}",
1192
+ fontWeight: "{font-weight.regular}",
1193
+ lineHeight: "{line-height.sm}",
1194
+ fontSize: "{font-size.4}",
1195
+ letterSpacing: "{letter-spacing.8}"
1196
+ }
1197
+ },
1198
+ sm: {
1199
+ $type: "typography",
1200
+ $value: {
1201
+ fontFamily: "{font-family}",
1202
+ fontWeight: "{font-weight.regular}",
1203
+ lineHeight: "{line-height.sm}",
1204
+ fontSize: "{font-size.3}",
1205
+ letterSpacing: "{letter-spacing.7}"
1206
+ }
1207
+ },
1208
+ xs: {
1209
+ $type: "typography",
1210
+ $value: {
1211
+ fontFamily: "{font-family}",
1212
+ fontWeight: "{font-weight.regular}",
1213
+ lineHeight: "{line-height.sm}",
1214
+ fontSize: "{font-size.2}",
1215
+ letterSpacing: "{letter-spacing.6}"
1216
+ }
1217
+ }
1218
+ },
1219
+ long: {
1220
+ xl: {
1221
+ $type: "typography",
1222
+ $value: {
1223
+ fontFamily: "{font-family}",
1224
+ fontWeight: "{font-weight.regular}",
1225
+ lineHeight: "{line-height.lg}",
1226
+ fontSize: "{font-size.6}",
1227
+ letterSpacing: "{letter-spacing.8}"
1228
+ }
1229
+ },
1230
+ lg: {
1231
+ $type: "typography",
1232
+ $value: {
1233
+ fontFamily: "{font-family}",
1234
+ fontWeight: "{font-weight.regular}",
1235
+ lineHeight: "{line-height.lg}",
1236
+ fontSize: "{font-size.5}",
1237
+ letterSpacing: "{letter-spacing.8}"
1238
+ }
1239
+ },
1240
+ md: {
1241
+ $type: "typography",
1242
+ $value: {
1243
+ fontFamily: "{font-family}",
1244
+ fontWeight: "{font-weight.regular}",
1245
+ lineHeight: "{line-height.lg}",
1246
+ fontSize: "{font-size.4}",
1247
+ letterSpacing: "{letter-spacing.8}"
1248
+ }
1249
+ },
1250
+ sm: {
1251
+ $type: "typography",
1252
+ $value: {
1253
+ fontFamily: "{font-family}",
1254
+ fontWeight: "{font-weight.regular}",
1255
+ lineHeight: "{line-height.lg}",
1256
+ fontSize: "{font-size.3}",
1257
+ letterSpacing: "{letter-spacing.7}"
1258
+ }
1259
+ },
1260
+ xs: {
1261
+ $type: "typography",
1262
+ $value: {
1263
+ fontFamily: "{font-family}",
1264
+ fontWeight: "{font-weight.regular}",
1265
+ lineHeight: "{line-height.lg}",
1266
+ fontSize: "{font-size.2}",
1267
+ letterSpacing: "{letter-spacing.6}"
1268
+ }
1269
+ }
1270
+ }
1271
+ }
1272
+ },
1273
+ opacity: {
1274
+ disabled: {
1275
+ $type: "opacity",
1276
+ $value: "{opacity.30}"
1277
+ }
1278
+ },
1279
+ "border-width": {
1280
+ default: {
1281
+ $type: "borderWidth",
1282
+ $value: "{border-width.1}"
1283
+ },
1284
+ focus: {
1285
+ $type: "borderWidth",
1286
+ $value: "{border-width.3}"
1287
+ }
1288
+ },
1289
+ shadow: {
1290
+ xs: {
1291
+ $type: "boxShadow",
1292
+ $value: "{shadow.100}"
1293
+ },
1294
+ sm: {
1295
+ $type: "boxShadow",
1296
+ $value: "{shadow.200}"
1297
+ },
1298
+ md: {
1299
+ $type: "boxShadow",
1300
+ $value: "{shadow.300}"
1301
+ },
1302
+ lg: {
1303
+ $type: "boxShadow",
1304
+ $value: "{shadow.400}"
1305
+ },
1306
+ xl: {
1307
+ $type: "boxShadow",
1308
+ $value: "{shadow.500}"
1309
+ }
1310
+ },
1311
+ "border-radius": {
1312
+ sm: {
1313
+ $type: "dimension",
1314
+ $value: "{border-radius.1}"
1315
+ },
1316
+ md: {
1317
+ $type: "dimension",
1318
+ $value: "{border-radius.2}"
1319
+ },
1320
+ lg: {
1321
+ $type: "dimension",
1322
+ $value: "{border-radius.3}"
1323
+ },
1324
+ xl: {
1325
+ $type: "dimension",
1326
+ $value: "{border-radius.4}"
1327
+ },
1328
+ default: {
1329
+ $type: "dimension",
1330
+ $value: "{border-radius.5}"
1331
+ },
1332
+ full: {
1333
+ $type: "dimension",
1334
+ $value: "{border-radius.6}"
1335
+ }
1336
+ },
1337
+ size: {
1338
+ "0": {
1339
+ $type: "dimension",
1340
+ $value: "{_size.0}"
1341
+ },
1342
+ "1": {
1343
+ $type: "dimension",
1344
+ $value: "{_size.1}"
1345
+ },
1346
+ "2": {
1347
+ $type: "dimension",
1348
+ $value: "{_size.2}"
1349
+ },
1350
+ "3": {
1351
+ $type: "dimension",
1352
+ $value: "{_size.3}"
1353
+ },
1354
+ "4": {
1355
+ $type: "dimension",
1356
+ $value: "{_size.4}"
1357
+ },
1358
+ "5": {
1359
+ $type: "dimension",
1360
+ $value: "{_size.5}"
1361
+ },
1362
+ "6": {
1363
+ $type: "dimension",
1364
+ $value: "{_size.6}"
1365
+ },
1366
+ "7": {
1367
+ $type: "dimension",
1368
+ $value: "{_size.7}"
1369
+ },
1370
+ "8": {
1371
+ $type: "dimension",
1372
+ $value: "{_size.8}"
1373
+ },
1374
+ "9": {
1375
+ $type: "dimension",
1376
+ $value: "{_size.9}"
1377
+ },
1378
+ "10": {
1379
+ $type: "dimension",
1380
+ $value: "{_size.10}"
1381
+ },
1382
+ "11": {
1383
+ $type: "dimension",
1384
+ $value: "{_size.11}"
1385
+ },
1386
+ "12": {
1387
+ $type: "dimension",
1388
+ $value: "{_size.12}"
1389
+ },
1390
+ "13": {
1391
+ $type: "dimension",
1392
+ $value: "{_size.13}"
1393
+ },
1394
+ "14": {
1395
+ $type: "dimension",
1396
+ $value: "{_size.14}"
1397
+ },
1398
+ "15": {
1399
+ $type: "dimension",
1400
+ $value: "{_size.15}"
1401
+ },
1402
+ "18": {
1403
+ $type: "dimension",
1404
+ $value: "{_size.18}"
1405
+ },
1406
+ "22": {
1407
+ $type: "dimension",
1408
+ $value: "{_size.22}"
1409
+ },
1410
+ "26": {
1411
+ $type: "dimension",
1412
+ $value: "{_size.26}"
1413
+ },
1414
+ "30": {
1415
+ $type: "dimension",
1416
+ $value: "{_size.30}"
1417
+ }
1418
+ }
1419
+ };
1420
+
1421
+ // src/tokens/create/defaults.ts
1422
+ var defaultTokens = {
1423
+ "primitives/globals": globals_default,
1424
+ "primitives/modes/size/small": small_default,
1425
+ "primitives/modes/size/medium": medium_default,
1426
+ "primitives/modes/size/large": large_default,
1427
+ "primitives/modes/size/global": global_default,
1428
+ "primitives/modes/typography/size/small": small_default2,
1429
+ "primitives/modes/typography/size/medium": medium_default2,
1430
+ "primitives/modes/typography/size/large": large_default2,
1431
+ "semantic/style": style_default
1432
+ };
1433
+ var getDefaultTokens = (tokenSets) => Object.entries(R3.pick(tokenSets, defaultTokens));
1434
+ var getDefaultToken = (tokenPath) => {
1435
+ return [tokenPath, defaultTokens[tokenPath]];
1436
+ };
1437
+
1438
+ // src/tokens/create/generators/color.ts
1439
+ import * as R4 from "ramda";
1440
+ var generateColor = (colorArray) => {
1441
+ const obj = {};
1442
+ const $type = "color";
1443
+ for (const index in colorArray) {
1444
+ obj[Number(index) + 1] = { $type, $value: colorArray[index].hex };
1445
+ }
1446
+ return obj;
1447
+ };
1448
+ var generateColorScheme = (themeName, colorScheme2, colors) => {
1449
+ const main = R4.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors.main);
1450
+ const support = R4.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors.support);
1451
+ const neutral = generateColor(generateColorScale(colors.neutral, colorScheme2));
1452
+ return {
1453
+ [themeName]: {
1454
+ ...main,
1455
+ ...support,
1456
+ neutral
1457
+ }
1458
+ };
1459
+ };
1460
+ var generateColorGlobal = (colorScheme2) => {
1461
+ const blueScale = generateColorScale(baseColors.blue, colorScheme2);
1462
+ const greenScale = generateColorScale(baseColors.green, colorScheme2);
1463
+ const orangeScale = generateColorScale(baseColors.orange, colorScheme2);
1464
+ const purpleScale = generateColorScale(baseColors.purple, colorScheme2);
1465
+ const redScale = generateColorScale(baseColors.red, colorScheme2);
1466
+ return {
1467
+ global: {
1468
+ blue: generateColor(blueScale),
1469
+ green: generateColor(greenScale),
1470
+ orange: generateColor(orangeScale),
1471
+ purple: generateColor(purpleScale),
1472
+ red: generateColor(redScale)
1473
+ }
1474
+ };
1475
+ };
1476
+
1477
+ // src/tokens/create/generators/semantic.ts
1478
+ import * as R5 from "ramda";
1479
+
1480
+ // src/tokens/template/design-tokens/semantic/color.base.template.json with { type: 'json' }
1481
+ var color_base_template_default = {
1482
+ color: {
1483
+ success: {
1484
+ "background-default": {
1485
+ $type: "color",
1486
+ $value: "{global.green.1}"
1487
+ },
1488
+ "background-tinted": {
1489
+ $type: "color",
1490
+ $value: "{global.green.2}"
1491
+ },
1492
+ "surface-default": {
1493
+ $type: "color",
1494
+ $value: "{global.green.3}"
1495
+ },
1496
+ "surface-tinted": {
1497
+ $type: "color",
1498
+ $value: "{global.green.4}"
1499
+ },
1500
+ "surface-hover": {
1501
+ $type: "color",
1502
+ $value: "{global.green.5}"
1503
+ },
1504
+ "surface-active": {
1505
+ $type: "color",
1506
+ $value: "{global.green.6}"
1507
+ },
1508
+ "border-subtle": {
1509
+ $type: "color",
1510
+ $value: "{global.green.7}"
1511
+ },
1512
+ "border-default": {
1513
+ $type: "color",
1514
+ $value: "{global.green.8}"
1515
+ },
1516
+ "border-strong": {
1517
+ $type: "color",
1518
+ $value: "{global.green.9}"
1519
+ },
1520
+ "text-subtle": {
1521
+ $type: "color",
1522
+ $value: "{global.green.10}"
1523
+ },
1524
+ "text-default": {
1525
+ $type: "color",
1526
+ $value: "{global.green.11}"
1527
+ },
1528
+ "base-default": {
1529
+ $type: "color",
1530
+ $value: "{global.green.12}"
1531
+ },
1532
+ "base-hover": {
1533
+ $type: "color",
1534
+ $value: "{global.green.13}"
1535
+ },
1536
+ "base-active": {
1537
+ $type: "color",
1538
+ $value: "{global.green.14}"
1539
+ },
1540
+ "base-contrast-subtle": {
1541
+ $type: "color",
1542
+ $value: "{global.green.15}"
1543
+ },
1544
+ "base-contrast-default": {
1545
+ $type: "color",
1546
+ $value: "{global.green.16}"
1547
+ }
1548
+ },
1549
+ danger: {
1550
+ "background-default": {
1551
+ $type: "color",
1552
+ $value: "{global.red.1}"
1553
+ },
1554
+ "background-tinted": {
1555
+ $type: "color",
1556
+ $value: "{global.red.2}"
1557
+ },
1558
+ "surface-default": {
1559
+ $type: "color",
1560
+ $value: "{global.red.3}"
1561
+ },
1562
+ "surface-tinted": {
1563
+ $type: "color",
1564
+ $value: "{global.red.4}"
1565
+ },
1566
+ "surface-hover": {
1567
+ $type: "color",
1568
+ $value: "{global.red.5}"
1569
+ },
1570
+ "surface-active": {
1571
+ $type: "color",
1572
+ $value: "{global.red.6}"
1573
+ },
1574
+ "border-subtle": {
1575
+ $type: "color",
1576
+ $value: "{global.red.7}"
1577
+ },
1578
+ "border-default": {
1579
+ $type: "color",
1580
+ $value: "{global.red.8}"
1581
+ },
1582
+ "border-strong": {
1583
+ $type: "color",
1584
+ $value: "{global.red.9}"
1585
+ },
1586
+ "text-subtle": {
1587
+ $type: "color",
1588
+ $value: "{global.red.10}"
1589
+ },
1590
+ "text-default": {
1591
+ $type: "color",
1592
+ $value: "{global.red.11}"
1593
+ },
1594
+ "base-default": {
1595
+ $type: "color",
1596
+ $value: "{global.red.12}"
1597
+ },
1598
+ "base-hover": {
1599
+ $type: "color",
1600
+ $value: "{global.red.13}"
1601
+ },
1602
+ "base-active": {
1603
+ $type: "color",
1604
+ $value: "{global.red.14}"
1605
+ },
1606
+ "base-contrast-subtle": {
1607
+ $type: "color",
1608
+ $value: "{global.red.15}"
1609
+ },
1610
+ "base-contrast-default": {
1611
+ $type: "color",
1612
+ $value: "{global.red.16}"
1613
+ }
1614
+ },
1615
+ info: {
1616
+ "background-default": {
1617
+ $type: "color",
1618
+ $value: "{global.blue.1}"
1619
+ },
1620
+ "background-tinted": {
1621
+ $type: "color",
1622
+ $value: "{global.blue.2}"
1623
+ },
1624
+ "surface-default": {
1625
+ $type: "color",
1626
+ $value: "{global.blue.3}"
1627
+ },
1628
+ "surface-tinted": {
1629
+ $type: "color",
1630
+ $value: "{global.blue.4}"
1631
+ },
1632
+ "surface-hover": {
1633
+ $type: "color",
1634
+ $value: "{global.blue.5}"
1635
+ },
1636
+ "surface-active": {
1637
+ $type: "color",
1638
+ $value: "{global.blue.6}"
1639
+ },
1640
+ "border-subtle": {
1641
+ $type: "color",
1642
+ $value: "{global.blue.7}"
1643
+ },
1644
+ "border-default": {
1645
+ $type: "color",
1646
+ $value: "{global.blue.8}"
1647
+ },
1648
+ "border-strong": {
1649
+ $type: "color",
1650
+ $value: "{global.blue.9}"
1651
+ },
1652
+ "text-subtle": {
1653
+ $type: "color",
1654
+ $value: "{global.blue.10}"
1655
+ },
1656
+ "text-default": {
1657
+ $type: "color",
1658
+ $value: "{global.blue.11}"
1659
+ },
1660
+ "base-default": {
1661
+ $type: "color",
1662
+ $value: "{global.blue.12}"
1663
+ },
1664
+ "base-hover": {
1665
+ $type: "color",
1666
+ $value: "{global.blue.13}"
1667
+ },
1668
+ "base-active": {
1669
+ $type: "color",
1670
+ $value: "{global.blue.14}"
1671
+ },
1672
+ "base-contrast-subtle": {
1673
+ $type: "color",
1674
+ $value: "{global.blue.15}"
1675
+ },
1676
+ "base-contrast-default": {
1677
+ $type: "color",
1678
+ $value: "{global.blue.16}"
1679
+ }
1680
+ },
1681
+ warning: {
1682
+ "background-default": {
1683
+ $type: "color",
1684
+ $value: "{global.orange.1}"
1685
+ },
1686
+ "background-tinted": {
1687
+ $type: "color",
1688
+ $value: "{global.orange.2}"
1689
+ },
1690
+ "surface-default": {
1691
+ $type: "color",
1692
+ $value: "{global.orange.3}"
1693
+ },
1694
+ "surface-tinted": {
1695
+ $type: "color",
1696
+ $value: "{global.orange.4}"
1697
+ },
1698
+ "surface-hover": {
1699
+ $type: "color",
1700
+ $value: "{global.orange.5}"
1701
+ },
1702
+ "surface-active": {
1703
+ $type: "color",
1704
+ $value: "{global.orange.6}"
1705
+ },
1706
+ "border-subtle": {
1707
+ $type: "color",
1708
+ $value: "{global.orange.7}"
1709
+ },
1710
+ "border-default": {
1711
+ $type: "color",
1712
+ $value: "{global.orange.8}"
1713
+ },
1714
+ "border-strong": {
1715
+ $type: "color",
1716
+ $value: "{global.orange.9}"
1717
+ },
1718
+ "text-subtle": {
1719
+ $type: "color",
1720
+ $value: "{global.orange.10}"
1721
+ },
1722
+ "text-default": {
1723
+ $type: "color",
1724
+ $value: "{global.orange.11}"
1725
+ },
1726
+ "base-default": {
1727
+ $type: "color",
1728
+ $value: "{global.orange.12}"
1729
+ },
1730
+ "base-hover": {
1731
+ $type: "color",
1732
+ $value: "{global.orange.13}"
1733
+ },
1734
+ "base-active": {
1735
+ $type: "color",
1736
+ $value: "{global.orange.14}"
1737
+ },
1738
+ "base-contrast-subtle": {
1739
+ $type: "color",
1740
+ $value: "{global.orange.15}"
1741
+ },
1742
+ "base-contrast-default": {
1743
+ $type: "color",
1744
+ $value: "{global.orange.16}"
1745
+ }
1746
+ },
1747
+ focus: {
1748
+ inner: {
1749
+ $type: "color",
1750
+ $value: "{color.neutral.background-default}"
1751
+ },
1752
+ outer: {
1753
+ $type: "color",
1754
+ $value: "{color.neutral.text-default}"
1755
+ }
1756
+ }
1757
+ },
1758
+ link: {
1759
+ color: {
1760
+ visited: {
1761
+ $type: "color",
1762
+ $value: "{global.purple.12}"
1763
+ }
1764
+ }
1765
+ }
1766
+ };
1767
+
1768
+ // src/tokens/template/design-tokens/semantic/color.template.json with { type: 'json' }
1769
+ var color_template_default = {
1770
+ "background-default": {
1771
+ $type: "color",
1772
+ $value: "{color.<color>.1}"
1773
+ },
1774
+ "background-tinted": {
1775
+ $type: "color",
1776
+ $value: "{color.<color>.2}"
1777
+ },
1778
+ "surface-default": {
1779
+ $type: "color",
1780
+ $value: "{color.<color>.3}"
1781
+ },
1782
+ "surface-tinted": {
1783
+ $type: "color",
1784
+ $value: "{color.<color>.4}"
1785
+ },
1786
+ "surface-hover": {
1787
+ $type: "color",
1788
+ $value: "{color.<color>.5}"
1789
+ },
1790
+ "surface-active": {
1791
+ $type: "color",
1792
+ $value: "{color.<color>.6}"
1793
+ },
1794
+ "border-subtle": {
1795
+ $type: "color",
1796
+ $value: "{color.<color>.7}"
1797
+ },
1798
+ "border-default": {
1799
+ $type: "color",
1800
+ $value: "{color.<color>.8}"
1801
+ },
1802
+ "border-strong": {
1803
+ $type: "color",
1804
+ $value: "{color.<color>.9}"
1805
+ },
1806
+ "text-subtle": {
1807
+ $type: "color",
1808
+ $value: "{color.<color>.10}"
1809
+ },
1810
+ "text-default": {
1811
+ $type: "color",
1812
+ $value: "{color.<color>.11}"
1813
+ },
1814
+ "base-default": {
1815
+ $type: "color",
1816
+ $value: "{color.<color>.12}"
1817
+ },
1818
+ "base-hover": {
1819
+ $type: "color",
1820
+ $value: "{color.<color>.13}"
1821
+ },
1822
+ "base-active": {
1823
+ $type: "color",
1824
+ $value: "{color.<color>.14}"
1825
+ },
1826
+ "base-contrast-subtle": {
1827
+ $type: "color",
1828
+ $value: "{color.<color>.15}"
1829
+ },
1830
+ "base-contrast-default": {
1831
+ $type: "color",
1832
+ $value: "{color.<color>.16}"
1833
+ }
1834
+ };
1835
+
1836
+ // src/tokens/template/design-tokens/semantic/modes/color.template.json with { type: 'json' }
1837
+ var color_template_default2 = {
1838
+ "background-default": {
1839
+ $type: "color",
1840
+ $value: "{color.<color>.background-default}"
1841
+ },
1842
+ "background-tinted": {
1843
+ $type: "color",
1844
+ $value: "{color.<color>.background-tinted}"
1845
+ },
1846
+ "surface-default": {
1847
+ $type: "color",
1848
+ $value: "{color.<color>.surface-default}"
1849
+ },
1850
+ "surface-tinted": {
1851
+ $type: "color",
1852
+ $value: "{color.<color>.surface-tinted}"
1853
+ },
1854
+ "surface-hover": {
1855
+ $type: "color",
1856
+ $value: "{color.<color>.surface-hover}"
1857
+ },
1858
+ "surface-active": {
1859
+ $type: "color",
1860
+ $value: "{color.<color>.surface-active}"
1861
+ },
1862
+ "border-subtle": {
1863
+ $type: "color",
1864
+ $value: "{color.<color>.border-subtle}"
1865
+ },
1866
+ "border-default": {
1867
+ $type: "color",
1868
+ $value: "{color.<color>.border-default}"
1869
+ },
1870
+ "border-strong": {
1871
+ $type: "color",
1872
+ $value: "{color.<color>.border-strong}"
1873
+ },
1874
+ "text-subtle": {
1875
+ $type: "color",
1876
+ $value: "{color.<color>.text-subtle}"
1877
+ },
1878
+ "text-default": {
1879
+ $type: "color",
1880
+ $value: "{color.<color>.text-default}"
1881
+ },
1882
+ "base-default": {
1883
+ $type: "color",
1884
+ $value: "{color.<color>.base-default}"
1885
+ },
1886
+ "base-hover": {
1887
+ $type: "color",
1888
+ $value: "{color.<color>.base-hover}"
1889
+ },
1890
+ "base-active": {
1891
+ $type: "color",
1892
+ $value: "{color.<color>.base-active}"
1893
+ },
1894
+ "base-contrast-subtle": {
1895
+ $type: "color",
1896
+ $value: "{color.<color>.base-contrast-subtle}"
1897
+ },
1898
+ "base-contrast-default": {
1899
+ $type: "color",
1900
+ $value: "{color.<color>.base-contrast-default}"
1901
+ }
1902
+ };
1903
+
1904
+ // src/tokens/create/generators/semantic.ts
1905
+ var generateSemantic = (colors) => {
1906
+ const mainColorNames = Object.keys(colors.main);
1907
+ const supportColorNames = Object.keys(colors.support);
1908
+ const modes = {
1909
+ "main-color": {},
1910
+ "support-color": {}
1911
+ };
1912
+ const categories = [
1913
+ ["main-color", mainColorNames],
1914
+ ["support-color", supportColorNames]
1915
+ ];
1916
+ for (const [colorCategory2, colorNames] of categories) {
1917
+ for (const colorName of colorNames) {
1918
+ const category = colorCategory2.replace("-color", "");
1919
+ const customColorTokens = {
1920
+ color: {
1921
+ [category]: JSON.parse(
1922
+ JSON.stringify(
1923
+ color_template_default2,
1924
+ (key, value) => {
1925
+ if (key === "$value") {
1926
+ return value.replace("<color>", colorName);
1927
+ }
1928
+ return value;
1929
+ },
1930
+ 2
1931
+ )
1932
+ )
1933
+ }
1934
+ };
1935
+ modes[colorCategory2][colorName] = customColorTokens;
1936
+ }
1937
+ }
1938
+ const customColors = [...mainColorNames, "neutral", ...supportColorNames];
1939
+ const semanticColorTokens = customColors.map(
1940
+ (colorName) => [
1941
+ colorName,
1942
+ R5.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), color_template_default)
1943
+ ]
1944
+ );
1945
+ const color = {
1946
+ ...color_base_template_default,
1947
+ color: {
1948
+ ...Object.fromEntries(semanticColorTokens),
1949
+ ...color_base_template_default.color
1950
+ }
1951
+ };
1952
+ return {
1953
+ modes,
1954
+ color
1955
+ };
1956
+ };
1957
+
1958
+ // src/tokens/create/generators/theme.ts
1959
+ import * as R6 from "ramda";
1960
+
1961
+ // src/tokens/template/design-tokens/themes/theme.base.template.json with { type: 'json' }
1962
+ var theme_base_template_default = {
1963
+ color: {},
1964
+ "font-family": {
1965
+ $type: "fontFamilies",
1966
+ $value: "{<theme>.font-family}"
1967
+ },
1968
+ "font-weight": {
1969
+ medium: {
1970
+ $type: "fontWeights",
1971
+ $value: "{<theme>.font-weight.medium}"
1972
+ },
1973
+ semibold: {
1974
+ $type: "fontWeights",
1975
+ $value: "{<theme>.font-weight.semibold}"
1976
+ },
1977
+ regular: {
1978
+ $type: "fontWeights",
1979
+ $value: "{<theme>.font-weight.regular}"
1980
+ }
1981
+ },
1982
+ "border-radius": {
1983
+ "1": {
1984
+ $type: "dimension",
1985
+ $value: "min({border-radius.base}*0.5,{border-radius.scale})"
1986
+ },
1987
+ "2": {
1988
+ $type: "dimension",
1989
+ $value: "min({border-radius.base},{border-radius.scale}*2)"
1990
+ },
1991
+ "3": {
1992
+ $type: "dimension",
1993
+ $value: "min({border-radius.base}*2,{border-radius.scale}*5)"
1994
+ },
1995
+ "4": {
1996
+ $type: "dimension",
1997
+ $value: "min({border-radius.base}*3,{border-radius.scale}*7)"
1998
+ },
1999
+ "5": {
2000
+ $type: "dimension",
2001
+ $value: "{border-radius.base}"
2002
+ },
2003
+ "6": {
2004
+ $type: "dimension",
2005
+ $value: "9999"
2006
+ },
2007
+ base: {
2008
+ $type: "dimension",
2009
+ $value: "4"
2010
+ },
2011
+ scale: {
2012
+ $type: "dimension",
2013
+ $value: "4"
2014
+ }
2015
+ }
2016
+ };
2017
+
2018
+ // src/tokens/template/design-tokens/themes/theme.template.json with { type: 'json' }
2019
+ var theme_template_default = {
2020
+ "1": {
2021
+ $type: "color",
2022
+ $value: "{<theme>.<color>.1}"
2023
+ },
2024
+ "2": {
2025
+ $type: "color",
2026
+ $value: "{<theme>.<color>.2}"
2027
+ },
2028
+ "3": {
2029
+ $type: "color",
2030
+ $value: "{<theme>.<color>.3}"
2031
+ },
2032
+ "4": {
2033
+ $type: "color",
2034
+ $value: "{<theme>.<color>.4}"
2035
+ },
2036
+ "5": {
2037
+ $type: "color",
2038
+ $value: "{<theme>.<color>.5}"
2039
+ },
2040
+ "6": {
2041
+ $type: "color",
2042
+ $value: "{<theme>.<color>.6}"
2043
+ },
2044
+ "7": {
2045
+ $type: "color",
2046
+ $value: "{<theme>.<color>.7}"
2047
+ },
2048
+ "8": {
2049
+ $type: "color",
2050
+ $value: "{<theme>.<color>.8}"
2051
+ },
2052
+ "9": {
2053
+ $type: "color",
2054
+ $value: "{<theme>.<color>.9}"
2055
+ },
2056
+ "10": {
2057
+ $type: "color",
2058
+ $value: "{<theme>.<color>.10}"
2059
+ },
2060
+ "11": {
2061
+ $type: "color",
2062
+ $value: "{<theme>.<color>.11}"
2063
+ },
2064
+ "12": {
2065
+ $type: "color",
2066
+ $value: "{<theme>.<color>.12}"
2067
+ },
2068
+ "13": {
2069
+ $type: "color",
2070
+ $value: "{<theme>.<color>.13}"
2071
+ },
2072
+ "14": {
2073
+ $type: "color",
2074
+ $value: "{<theme>.<color>.14}"
2075
+ },
2076
+ "15": {
2077
+ $type: "color",
2078
+ $value: "{<theme>.<color>.15}"
2079
+ },
2080
+ "16": {
2081
+ $type: "color",
2082
+ $value: "{<theme>.<color>.16}"
2083
+ }
2084
+ };
2085
+
2086
+ // src/tokens/create/generators/theme.ts
2087
+ var generateTheme = (colors, themeName, borderRadius) => {
2088
+ const mainColorNames = Object.keys(colors.main);
2089
+ const supportColorNames = Object.keys(colors.support);
2090
+ const customColors = [...mainColorNames, "neutral", ...supportColorNames];
2091
+ const themeColorTokens = Object.fromEntries(
2092
+ customColors.map(
2093
+ (colorName) => [
2094
+ colorName,
2095
+ R6.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), theme_template_default)
2096
+ ]
2097
+ )
2098
+ );
2099
+ const { color: themeBaseFileColor, ...remainingThemeFile } = theme_base_template_default;
2100
+ const themeFile = {
2101
+ color: {
2102
+ ...themeColorTokens,
2103
+ ...themeBaseFileColor
2104
+ },
2105
+ ...remainingThemeFile
2106
+ };
2107
+ const baseBorderRadius = R6.lensPath(["border-radius", "base", "$value"]);
2108
+ const updatedThemeFile = R6.set(baseBorderRadius, String(borderRadius), themeFile);
2109
+ const token = JSON.parse(
2110
+ JSON.stringify(
2111
+ updatedThemeFile,
2112
+ (key, value) => {
2113
+ if (key === "$value") {
2114
+ return value.replace("<theme>", themeName);
2115
+ }
2116
+ return value;
2117
+ },
2118
+ 2
2119
+ )
2120
+ );
2121
+ return token;
2122
+ };
2123
+
2124
+ // src/tokens/template/design-tokens/primitives/modes/typography/typography.template.json with { type: 'json' }
2125
+ var typography_template_default = {
2126
+ "<theme>": {
2127
+ "font-family": {
2128
+ $type: "fontFamilies",
2129
+ $value: "<font-family>"
2130
+ },
2131
+ "font-weight": {
2132
+ medium: {
2133
+ $type: "fontWeights",
2134
+ $value: "Medium"
2135
+ },
2136
+ semibold: {
2137
+ $type: "fontWeights",
2138
+ $value: "Semi bold"
2139
+ },
2140
+ regular: {
2141
+ $type: "fontWeights",
2142
+ $value: "Regular"
2143
+ }
2144
+ }
2145
+ }
2146
+ };
2147
+
2148
+ // src/tokens/create/generators/typography.ts
2149
+ var generateTypography = (themeName, { fontFamily }) => {
2150
+ return JSON.parse(
2151
+ JSON.stringify(typography_template_default).replaceAll(/<font-family>/g, fontFamily).replaceAll(/<theme>/g, themeName)
2152
+ );
2153
+ };
2154
+
2155
+ // src/tokens/create.ts
2156
+ var cliOptions = {
2157
+ outDir: "out-dir",
2158
+ clean: "clean",
2159
+ theme: {
2160
+ colors: {
2161
+ main: "main-colors",
2162
+ support: "support-colors",
2163
+ neutral: "neutral-color"
2164
+ },
2165
+ typography: {
2166
+ fontFamily: "font-family"
2167
+ },
2168
+ borderRadius: "border-radius"
2169
+ }
2170
+ };
2171
+ var createTokens = async (opts) => {
2172
+ const { colors, typography: typography2, name, borderRadius } = opts;
2173
+ const colorSchemes = ["light", "dark"];
2174
+ const semantic2 = generateSemantic(colors);
2175
+ const tokenSets = new Map([
2176
+ ...getDefaultTokens([
2177
+ "primitives/globals",
2178
+ "primitives/modes/size/small",
2179
+ "primitives/modes/size/medium",
2180
+ "primitives/modes/size/large",
2181
+ "primitives/modes/size/global",
2182
+ "primitives/modes/typography/size/small",
2183
+ "primitives/modes/typography/size/medium",
2184
+ "primitives/modes/typography/size/large"
2185
+ ]),
2186
+ [`primitives/modes/typography/primary/${name}`, generateTypography(name, typography2)],
2187
+ [`primitives/modes/typography/secondary/${name}`, generateTypography(name, typography2)],
2188
+ ...colorSchemes.flatMap((scheme) => [
2189
+ [`primitives/modes/color-scheme/${scheme}/global`, generateColorGlobal(scheme)],
2190
+ [`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors)]
2191
+ ]),
2192
+ [`themes/${name}`, generateTheme(colors, name, borderRadius)],
2193
+ ["semantic/color", semantic2.color],
2194
+ // maps out semantic modes, ieg 'semantic/modes/main-color/accent', and 'semantic/modes/support-color/brand1'
2195
+ ...Object.entries(semantic2.modes).flatMap(
2196
+ ([mode, colors2]) => Object.entries(colors2).map(([key, colorSet]) => [`semantic/modes/${mode}/${key}`, colorSet])
2197
+ ),
2198
+ getDefaultToken("semantic/style")
2199
+ ]);
2200
+ return { tokenSets };
2201
+ };
2202
+
2203
+ // src/tokens/format.ts
2204
+ import * as R19 from "ramda";
2205
+ import chalk3 from "chalk";
2206
+
2207
+ // package.json
2208
+ var package_default = {
2209
+ name: "@digdir/designsystemet",
2210
+ version: "1.0.4",
2211
+ description: "CLI for Designsystemet",
2212
+ author: "Designsystemet team",
2213
+ engines: {
2214
+ node: ">=22.14.0"
2215
+ },
2216
+ repository: {
2217
+ type: "git",
2218
+ url: "git+https://github.com/digdir/designsystemet.git"
2219
+ },
2220
+ homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
2221
+ license: "MIT",
2222
+ type: "module",
2223
+ main: "./dist/src/index.js",
2224
+ files: [
2225
+ "./dist/**"
2226
+ ],
2227
+ bin: "dist/bin/designsystemet.js",
2228
+ exports: {
2229
+ ".": {
2230
+ import: "./dist/src/index.js"
2231
+ },
2232
+ "./color": {
2233
+ import: "./dist/src/colors/index.js"
2234
+ },
2235
+ "./tokens": {
2236
+ import: "./dist/src/tokens/index.js"
2237
+ }
2238
+ },
2239
+ publishConfig: {
2240
+ access: "public"
2241
+ },
2242
+ scripts: {
2243
+ designsystemet: "tsx ./bin/designsystemet.ts",
2244
+ "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2245
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2246
+ build: "tsup && yarn build:types && yarn build:json-schema",
2247
+ "build:types": "tsc --emitDeclarationOnly --declaration",
2248
+ "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
2249
+ types: "tsc --noEmit",
2250
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
2251
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
2252
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
2253
+ "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
2254
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
2255
+ test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
2256
+ "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
2257
+ "update:template": "tsx ./src/scripts/update-template.ts",
2258
+ "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
2259
+ verify: "yarn test && yarn update:template && yarn update:design-tokens"
2260
+ },
2261
+ dependencies: {
2262
+ "@commander-js/extra-typings": "^13.1.0",
2263
+ "@tokens-studio/sd-transforms": "1.2.12",
2264
+ "apca-w3": "^0.1.9",
2265
+ chalk: "^5.4.1",
2266
+ "change-case": "^5.4.4",
2267
+ "chroma-js": "^3.1.2",
2268
+ commander: "^13.1.0",
2269
+ "fast-glob": "^3.3.3",
2270
+ hsluv: "^1.0.1",
2271
+ "object-hash": "^3.0.0",
2272
+ postcss: "^8.5.3",
2273
+ ramda: "^0.30.1",
2274
+ "style-dictionary": "^4.3.3",
2275
+ zod: "^3.24.2",
2276
+ "zod-validation-error": "^3.4.0"
2277
+ },
2278
+ devDependencies: {
2279
+ "@types/apca-w3": "^0.1.3",
2280
+ "@types/chroma-js": "^3.1.1",
2281
+ "@types/fs-extra": "^11.0.4",
2282
+ "@types/glob": "^8.1.0",
2283
+ "@types/jscodeshift": "^0.12.0",
2284
+ "@types/node": "^22.14.0",
2285
+ "@types/object-hash": "^3.0.6",
2286
+ "@types/ramda": "^0.30.2",
2287
+ "fs-extra": "^11.3.0",
2288
+ "ts-toolbelt": "^9.6.0",
2289
+ tslib: "^2.8.1",
2290
+ tsup: "^8.4.0",
2291
+ tsx: "^4.19.3",
2292
+ typescript: "^5.8.2",
2293
+ "zod-to-json-schema": "^3.24.5"
2294
+ }
2295
+ };
2296
+
2297
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
2298
+ var BoxShadowTypes;
2299
+ (function(BoxShadowTypes2) {
2300
+ BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
2301
+ BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
2302
+ })(BoxShadowTypes || (BoxShadowTypes = {}));
2303
+
2304
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
2305
+ var ColorModifierTypes;
2306
+ (function(ColorModifierTypes2) {
2307
+ ColorModifierTypes2["LIGHTEN"] = "lighten";
2308
+ ColorModifierTypes2["DARKEN"] = "darken";
2309
+ ColorModifierTypes2["MIX"] = "mix";
2310
+ ColorModifierTypes2["ALPHA"] = "alpha";
2311
+ })(ColorModifierTypes || (ColorModifierTypes = {}));
2312
+
2313
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
2314
+ var ColorSpaceTypes;
2315
+ (function(ColorSpaceTypes2) {
2316
+ ColorSpaceTypes2["LCH"] = "lch";
2317
+ ColorSpaceTypes2["SRGB"] = "srgb";
2318
+ ColorSpaceTypes2["P3"] = "p3";
2319
+ ColorSpaceTypes2["HSL"] = "hsl";
2320
+ })(ColorSpaceTypes || (ColorSpaceTypes = {}));
2321
+
2322
+ // ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
2323
+ var Properties;
2324
+ (function(Properties2) {
2325
+ Properties2["sizing"] = "sizing";
2326
+ Properties2["height"] = "height";
2327
+ Properties2["width"] = "width";
2328
+ Properties2["spacing"] = "spacing";
2329
+ Properties2["verticalPadding"] = "verticalPadding";
2330
+ Properties2["horizontalPadding"] = "horizontalPadding";
2331
+ Properties2["paddingTop"] = "paddingTop";
2332
+ Properties2["paddingRight"] = "paddingRight";
2333
+ Properties2["paddingBottom"] = "paddingBottom";
2334
+ Properties2["paddingLeft"] = "paddingLeft";
2335
+ Properties2["itemSpacing"] = "itemSpacing";
2336
+ Properties2["fill"] = "fill";
2337
+ Properties2["backgroundBlur"] = "backgroundBlur";
2338
+ Properties2["border"] = "border";
2339
+ Properties2["borderTop"] = "borderTop";
2340
+ Properties2["borderRight"] = "borderRight";
2341
+ Properties2["borderBottom"] = "borderBottom";
2342
+ Properties2["borderLeft"] = "borderLeft";
2343
+ Properties2["borderColor"] = "borderColor";
2344
+ Properties2["borderRadius"] = "borderRadius";
2345
+ Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
2346
+ Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
2347
+ Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
2348
+ Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
2349
+ Properties2["borderWidth"] = "borderWidth";
2350
+ Properties2["borderWidthTop"] = "borderWidthTop";
2351
+ Properties2["borderWidthRight"] = "borderWidthRight";
2352
+ Properties2["borderWidthBottom"] = "borderWidthBottom";
2353
+ Properties2["borderWidthLeft"] = "borderWidthLeft";
2354
+ Properties2["boxShadow"] = "boxShadow";
2355
+ Properties2["opacity"] = "opacity";
2356
+ Properties2["fontFamilies"] = "fontFamilies";
2357
+ Properties2["fontWeights"] = "fontWeights";
2358
+ Properties2["fontSizes"] = "fontSizes";
2359
+ Properties2["lineHeights"] = "lineHeights";
2360
+ Properties2["typography"] = "typography";
2361
+ Properties2["composition"] = "composition";
2362
+ Properties2["letterSpacing"] = "letterSpacing";
2363
+ Properties2["paragraphSpacing"] = "paragraphSpacing";
2364
+ Properties2["textCase"] = "textCase";
2365
+ Properties2["dimension"] = "dimension";
2366
+ Properties2["textDecoration"] = "textDecoration";
2367
+ Properties2["asset"] = "asset";
2368
+ Properties2["tokenValue"] = "tokenValue";
2369
+ Properties2["value"] = "value";
2370
+ Properties2["tokenName"] = "tokenName";
2371
+ Properties2["description"] = "description";
2372
+ })(Properties || (Properties = {}));
2373
+
2374
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
2375
+ var TokenSetStatus;
2376
+ (function(TokenSetStatus2) {
2377
+ TokenSetStatus2["DISABLED"] = "disabled";
2378
+ TokenSetStatus2["SOURCE"] = "source";
2379
+ TokenSetStatus2["ENABLED"] = "enabled";
2380
+ })(TokenSetStatus || (TokenSetStatus = {}));
2381
+
2382
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
2383
+ var TokenTypes;
2384
+ (function(TokenTypes2) {
2385
+ TokenTypes2["OTHER"] = "other";
2386
+ TokenTypes2["COLOR"] = "color";
2387
+ TokenTypes2["BORDER_RADIUS"] = "borderRadius";
2388
+ TokenTypes2["SIZING"] = "sizing";
2389
+ TokenTypes2["SPACING"] = "spacing";
2390
+ TokenTypes2["TEXT"] = "text";
2391
+ TokenTypes2["TYPOGRAPHY"] = "typography";
2392
+ TokenTypes2["OPACITY"] = "opacity";
2393
+ TokenTypes2["BORDER_WIDTH"] = "borderWidth";
2394
+ TokenTypes2["STROKE_STYLE"] = "strokeStyle";
2395
+ TokenTypes2["BOX_SHADOW"] = "boxShadow";
2396
+ TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
2397
+ TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
2398
+ TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
2399
+ TokenTypes2["FONT_SIZES"] = "fontSizes";
2400
+ TokenTypes2["LETTER_SPACING"] = "letterSpacing";
2401
+ TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
2402
+ TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
2403
+ TokenTypes2["TEXT_DECORATION"] = "textDecoration";
2404
+ TokenTypes2["TEXT_CASE"] = "textCase";
2405
+ TokenTypes2["COMPOSITION"] = "composition";
2406
+ TokenTypes2["DIMENSION"] = "dimension";
2407
+ TokenTypes2["BORDER"] = "border";
2408
+ TokenTypes2["ASSET"] = "asset";
2409
+ TokenTypes2["BOOLEAN"] = "boolean";
2410
+ TokenTypes2["NUMBER"] = "number";
2411
+ })(TokenTypes || (TokenTypes = {}));
2412
+
2413
+ // ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
2414
+ var BorderValues;
2415
+ (function(BorderValues2) {
2416
+ BorderValues2["BORDER_COLOR"] = "color";
2417
+ BorderValues2["BORDER_WIDTH"] = "width";
2418
+ BorderValues2["BORDER_STYLE"] = "style";
2419
+ })(BorderValues || (BorderValues = {}));
2420
+
2421
+ // ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
2422
+ var StrokeStyleValues;
2423
+ (function(StrokeStyleValues2) {
2424
+ StrokeStyleValues2["SOLID"] = "solid";
2425
+ StrokeStyleValues2["DASHED"] = "dashed";
2426
+ StrokeStyleValues2["DOTTED"] = "dotted";
2427
+ StrokeStyleValues2["DOUBLE"] = "double";
2428
+ StrokeStyleValues2["GROOVE"] = "groove";
2429
+ StrokeStyleValues2["RIDGE"] = "ridge";
2430
+ StrokeStyleValues2["OUTSET"] = "outset";
2431
+ StrokeStyleValues2["INSET"] = "inset";
2432
+ })(StrokeStyleValues || (StrokeStyleValues = {}));
2433
+
2434
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
2435
+ var BoxShadowValues;
2436
+ (function(BoxShadowValues2) {
2437
+ BoxShadowValues2["TYPE"] = "type";
2438
+ BoxShadowValues2["COLOR"] = "color";
2439
+ BoxShadowValues2["X"] = "x";
2440
+ BoxShadowValues2["Y"] = "y";
2441
+ BoxShadowValues2["BLUR"] = "blur";
2442
+ BoxShadowValues2["SPREAD"] = "spread";
2443
+ BoxShadowValues2["BLEND_MODE"] = "blendMode";
2444
+ })(BoxShadowValues || (BoxShadowValues = {}));
2445
+
2446
+ // ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
2447
+ var TypographyValues;
2448
+ (function(TypographyValues2) {
2449
+ TypographyValues2["FONT_FAMILY"] = "fontFamily";
2450
+ TypographyValues2["FONT_WEIGHT"] = "fontWeight";
2451
+ TypographyValues2["LINE_HEIGHT"] = "lineHeight";
2452
+ TypographyValues2["FONT_SIZE"] = "fontSize";
2453
+ TypographyValues2["LETTER_SPACING"] = "letterSpacing";
2454
+ TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
2455
+ TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
2456
+ TypographyValues2["TEXT_DECORATION"] = "textDecoration";
2457
+ TypographyValues2["TEXT_CASE"] = "textCase";
2458
+ })(TypographyValues || (TypographyValues = {}));
2459
+
2460
+ // src/tokens/create/generators/$themes.ts
2461
+ var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
2462
+ async function createHash(text, algo = "SHA-1") {
2463
+ const crypto = globalThis.crypto;
2464
+ return Array.from(
2465
+ new Uint8Array(await crypto.subtle.digest(algo, new TextEncoder().encode(text))),
2466
+ (byte) => byte.toString(16).padStart(2, "0")
2467
+ ).join("");
2468
+ }
2469
+ async function generate$Themes(colorSchemes, themes, colors) {
2470
+ return [
2471
+ ...generateSizeGroup(),
2472
+ ...await generateThemesGroup(themes),
2473
+ ...generateTypographyGroup(themes),
2474
+ ...generateColorSchemesGroup(colorSchemes, themes),
2475
+ generateSemanticGroup(),
2476
+ ...await generateColorGroup("main", colors),
2477
+ ...await generateColorGroup("support", colors)
2478
+ ];
2479
+ }
2480
+ function generateSizeGroup() {
2481
+ return [
2482
+ {
2483
+ id: "8b2c8cc86611a34b135cb22948666779361fd729",
2484
+ name: "medium",
2485
+ $figmaStyleReferences: {},
2486
+ selectedTokenSets: {
2487
+ "primitives/modes/size/medium": TokenSetStatus.SOURCE,
2488
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
2489
+ "primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
2490
+ },
2491
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
2492
+ $figmaModeId: "41630:1",
2493
+ group: "Size"
2494
+ },
2495
+ {
2496
+ id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
2497
+ name: "large",
2498
+ $figmaStyleReferences: {},
2499
+ selectedTokenSets: {
2500
+ "primitives/modes/size/large": TokenSetStatus.SOURCE,
2501
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
2502
+ "primitives/modes/typography/size/large": TokenSetStatus.ENABLED
2503
+ },
2504
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
2505
+ $figmaModeId: "41630:2",
2506
+ group: "Size"
2507
+ },
2508
+ {
2509
+ id: "fb11567729c298ca37c9da4e3a27716a23480824",
2510
+ name: "small",
2511
+ $figmaStyleReferences: {},
2512
+ selectedTokenSets: {
2513
+ "primitives/modes/size/small": TokenSetStatus.SOURCE,
2514
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
2515
+ "primitives/modes/typography/size/small": TokenSetStatus.ENABLED
2516
+ },
2517
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
2518
+ $figmaModeId: "41630:3",
2519
+ group: "Size"
2520
+ }
2521
+ ];
2522
+ }
2523
+ var colorSchemeDefaults = {
2524
+ light: {
2525
+ name: "Light",
2526
+ selectedTokenSets: {},
2527
+ id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
2528
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
2529
+ $figmaModeId: "34811:0"
2530
+ },
2531
+ dark: {
2532
+ name: "Dark",
2533
+ selectedTokenSets: {},
2534
+ id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
2535
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
2536
+ $figmaModeId: "34811:1"
2537
+ },
2538
+ contrast: {
2539
+ name: "Contrast",
2540
+ selectedTokenSets: {},
2541
+ id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
2542
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
2543
+ $figmaModeId: "34811:2"
2544
+ }
2545
+ };
2546
+ function generateColorSchemesGroup(colorSchemes, themes) {
2547
+ return colorSchemes.map(
2548
+ (scheme) => ({
2549
+ ...colorSchemeDefaults[scheme],
2550
+ selectedTokenSets: Object.fromEntries([
2551
+ [`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
2552
+ ...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
2553
+ ]),
2554
+ group: "Color scheme"
2555
+ })
2556
+ );
2557
+ }
2558
+ async function generateThemesGroup(themes) {
2559
+ return Promise.all(
2560
+ themes.map(
2561
+ async (theme, index) => ({
2562
+ id: await createHash(theme),
2563
+ $figmaCollectionId: "VariableCollectionId:36528:61712",
2564
+ $figmaModeId: `40960:${index + 6}`,
2565
+ // Start on 6 in Token Studio and Community file for some reason
2566
+ name: theme,
2567
+ selectedTokenSets: {
2568
+ [`themes/${theme}`]: TokenSetStatus.ENABLED
2569
+ },
2570
+ group: "Theme"
2571
+ })
2572
+ )
2573
+ );
2574
+ }
2575
+ function generateSemanticGroup() {
2576
+ return {
2577
+ id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
2578
+ name: "Semantic",
2579
+ selectedTokenSets: {
2580
+ "semantic/style": TokenSetStatus.ENABLED,
2581
+ "semantic/color": TokenSetStatus.ENABLED,
2582
+ "primitives/globals": TokenSetStatus.SOURCE
2583
+ },
2584
+ $figmaCollectionId: "VariableCollectionId:34811:5976",
2585
+ $figmaModeId: "34811:5",
2586
+ group: "Semantic"
2587
+ };
2588
+ }
2589
+ async function generateColorGroup(group, colors) {
2590
+ return Promise.all(
2591
+ Object.entries(colors[group]).map(
2592
+ async ([color]) => ({
2593
+ id: await createHash(`${group}-${color}`),
2594
+ name: color,
2595
+ selectedTokenSets: {
2596
+ [`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
2597
+ },
2598
+ group: `${capitalize(group)} color`
2599
+ })
2600
+ )
2601
+ );
2602
+ }
2603
+ function generateTypographyGroup(themes) {
2604
+ return [
2605
+ {
2606
+ id: "368d753fcac4455f289500eaa42e70dc0a03522f",
2607
+ $figmaCollectionId: "VariableCollectionId:36248:20769",
2608
+ $figmaModeId: "36248:2",
2609
+ name: "Primary",
2610
+ selectedTokenSets: Object.fromEntries(
2611
+ themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
2612
+ ),
2613
+ group: "Typography"
2614
+ },
2615
+ {
2616
+ id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
2617
+ $figmaCollectionId: "VariableCollectionId:36248:20769",
2618
+ $figmaModeId: "36248:3",
2619
+ name: "Secondary",
2620
+ selectedTokenSets: Object.fromEntries(
2621
+ themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
2622
+ ),
2623
+ group: "Typography"
2624
+ }
2625
+ ];
2626
+ }
2627
+
2628
+ // src/tokens/process/platform.ts
2629
+ import chalk2 from "chalk";
2630
+ import * as R18 from "ramda";
2631
+ import StyleDictionary2 from "style-dictionary";
2632
+
2633
+ // src/tokens/types.ts
2634
+ var colorCategories = {
2635
+ main: "main",
2636
+ support: "support"
2637
+ };
2638
+
2639
+ // src/tokens/process/configs.ts
2640
+ import { register } from "@tokens-studio/sd-transforms";
2641
+ import * as R17 from "ramda";
2642
+ import StyleDictionary from "style-dictionary";
2643
+
2644
+ // src/tokens/utils.ts
2645
+ import * as R7 from "ramda";
2646
+ var mapToLowerCase = R7.map(R7.toLower);
2647
+ var hasAnyTruth = R7.any(R7.equals(true));
2648
+ var getType = (token) => (token.$type ?? token.type) || "";
2649
+ var getValue = (token) => token.$value ?? token.value;
2650
+ var typeEquals = R7.curry((types, token) => {
2651
+ if (R7.isNil(token)) {
2652
+ return false;
2653
+ }
2654
+ return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
2655
+ });
2656
+ var pathStartsWithOneOf = R7.curry((paths, token) => {
2657
+ if (R7.isNil(token)) {
2658
+ return false;
2659
+ }
2660
+ const tokenPath = mapToLowerCase(token.path);
2661
+ const matchPathsStartingWith = R7.map((path) => R7.startsWith([path], tokenPath), mapToLowerCase(paths));
2662
+ return hasAnyTruth(matchPathsStartingWith);
2663
+ });
2664
+ function isSemanticToken(token) {
2665
+ return token.filePath.includes("semantic/");
2666
+ }
2667
+ function isSemanticColorToken(token, color) {
2668
+ return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
2669
+ }
2670
+ function isGlobalColorToken(token) {
2671
+ return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
2672
+ }
2673
+ function isColorCategoryToken(token, category) {
2674
+ if (!category) {
2675
+ return ["main", "support"].some((c) => isColorCategoryToken(token, c));
2676
+ }
2677
+ return R7.startsWith(["color", category], token.path);
2678
+ }
2679
+ var isDigit = (s) => /^\d+$/.test(s);
2680
+ function traverseObj(obj, fn) {
2681
+ for (const key in obj) {
2682
+ const prop = obj[key];
2683
+ if (prop != null) {
2684
+ fn.apply(null, [obj, key, prop]);
2685
+ if (typeof prop === "object") {
2686
+ traverseObj(prop, fn);
2687
+ }
2688
+ }
2689
+ }
2690
+ return obj;
2691
+ }
2692
+ function inlineTokens(shouldInline, tokens) {
2693
+ const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
2694
+ return otherTokens.map((token) => {
2695
+ let transformed = getValue(token.original);
2696
+ for (const ref of inlineableTokens) {
2697
+ const refName = ref.path.join(".");
2698
+ if (typeof transformed === "string") {
2699
+ transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
2700
+ }
2701
+ }
2702
+ const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
2703
+ return tokenWithInlinedRefs;
2704
+ });
2705
+ }
2706
+
2707
+ // src/tokens/process/configs/color.ts
2708
+ import * as R12 from "ramda";
2709
+
2710
+ // src/tokens/process/formats/css/color.ts
2711
+ import * as R8 from "ramda";
2712
+ import { createPropertyFormatter } from "style-dictionary/utils";
2713
+ var prefersColorScheme = (colorScheme2, content) => `
2714
+ @media (prefers-color-scheme: ${colorScheme2}) {
2715
+ [data-color-scheme="auto"] ${content}
2716
+ }
2717
+ `;
2718
+ var colorScheme = {
2719
+ name: "ds/css-colorscheme",
2720
+ format: async ({ dictionary, file, options, platform }) => {
2721
+ const { allTokens } = dictionary;
2722
+ const { outputReferences, usesDtcg } = options;
2723
+ const { selector, colorScheme: colorScheme2, layer } = platform;
2724
+ const colorScheme_ = colorScheme2;
2725
+ const format = createPropertyFormatter({
2726
+ outputReferences,
2727
+ dictionary,
2728
+ format: "css",
2729
+ usesDtcg
2730
+ });
2731
+ const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
2732
+ color-scheme: ${colorScheme_};
2733
+ ` : "";
2734
+ const filteredAllTokens = allTokens.filter(
2735
+ R8.allPass([
2736
+ R8.anyPass([
2737
+ // Include semantic tokens in the output
2738
+ isSemanticToken,
2739
+ // Include global color tokens
2740
+ isGlobalColorToken
2741
+ ]),
2742
+ // Don't include color category tokens -- they are exported separately
2743
+ (t) => !isColorCategoryToken(t)
2744
+ ])
2745
+ );
2746
+ const formattedTokens = filteredAllTokens.map(format).join("\n");
2747
+ const content = `{
2748
+ ${formattedTokens}
2749
+ ${colorSchemeProperty}}
2750
+ `;
2751
+ const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
2752
+ const body = R8.isNotNil(layer) ? `@layer ${layer} {
2753
+ ${selector} ${content} ${autoSelectorContent}
2754
+ }
2755
+ ` : `${selector} ${content} ${autoSelectorContent}
2756
+ `;
2757
+ return body;
2758
+ }
2759
+ };
2760
+ var colorCategory = {
2761
+ name: "ds/css-colorcategory",
2762
+ format: async ({ dictionary, file, options, platform }) => {
2763
+ const { outputReferences, usesDtcg } = options;
2764
+ const { selector, layer } = platform;
2765
+ const format = R8.compose(
2766
+ createPropertyFormatter({
2767
+ outputReferences,
2768
+ dictionary,
2769
+ format: "css",
2770
+ usesDtcg
2771
+ }),
2772
+ (token) => ({
2773
+ ...token,
2774
+ name: token.name.replace(/color-\w+-/, "color-"),
2775
+ original: {
2776
+ ...token.original,
2777
+ $value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
2778
+ }
2779
+ })
2780
+ );
2781
+ const formattedTokens = dictionary.allTokens.map(format).join("\n");
2782
+ const content = `{
2783
+ ${formattedTokens}
2784
+ }
2785
+ `;
2786
+ const body = R8.isNotNil(layer) ? `@layer ${layer} {
2787
+ ${selector} ${content}
2788
+ }
2789
+ ` : `${selector} ${content}
2790
+ `;
2791
+ return body;
2792
+ }
2793
+ };
2794
+
2795
+ // src/tokens/process/formats/css/semantic.ts
2796
+ import * as R9 from "ramda";
2797
+ import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
2798
+ var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
2799
+ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
2800
+ var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
2801
+ var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
2802
+ var overrideSizingFormula = (format, token) => {
2803
+ const [name, value] = format(token).split(":");
2804
+ const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
2805
+ const round = `round(down, ${calc}, 0.0625rem)`;
2806
+ return {
2807
+ name,
2808
+ round,
2809
+ calc
2810
+ };
2811
+ };
2812
+ var formatSizingTokens = (format, tokens) => {
2813
+ const { round, calc } = R9.reduce(
2814
+ (acc, token) => {
2815
+ const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
2816
+ return {
2817
+ round: [...acc.round, `${name}: ${round2};`],
2818
+ calc: [...acc.calc, `${name}: ${calc2};`]
2819
+ };
2820
+ },
2821
+ { round: [], calc: [] },
2822
+ tokens
2823
+ );
2824
+ return `
2825
+ ${calc.join("\n")}
2826
+
2827
+ @supports (width: round(down, .1em, 1px)) {
2828
+ ${round.join("\n")}
2829
+ }`;
2830
+ };
2831
+ var semantic = {
2832
+ name: "ds/css-semantic",
2833
+ format: async ({ dictionary, file, options, platform }) => {
2834
+ const { outputReferences, usesDtcg } = options;
2835
+ const { selector, layer } = platform;
2836
+ const format = createPropertyFormatter2({
2837
+ outputReferences,
2838
+ dictionary,
2839
+ format: "css",
2840
+ usesDtcg
2841
+ });
2842
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
2843
+ const filteredTokens = R9.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
2844
+ const [sizingTokens, restTokens] = R9.partition(
2845
+ (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
2846
+ filteredTokens
2847
+ );
2848
+ const formattedTokens = [R9.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
2849
+ const content = `{
2850
+ ${formattedTokens.join("\n")}
2851
+ }
2852
+ `;
2853
+ const body = R9.isNotNil(layer) ? `@layer ${layer} {
2854
+ ${selector} ${content}
2855
+ }
2856
+ ` : `${selector} ${content}
2857
+ `;
2858
+ return body;
2859
+ }
2860
+ };
2861
+
2862
+ // src/tokens/process/formats/css/typography.ts
2863
+ import * as R10 from "ramda";
2864
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
2865
+ var typographyFontFamilyPredicate = R10.allPass([
2866
+ R10.pathSatisfies(R10.includes("typography"), ["path"]),
2867
+ R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
2868
+ ]);
2869
+ var typography = {
2870
+ name: "ds/css-typography",
2871
+ format: async ({ dictionary, file, options, platform }) => {
2872
+ const { outputReferences, usesDtcg } = options;
2873
+ const { selector, layer } = platform;
2874
+ const format = createPropertyFormatter3({
2875
+ outputReferences,
2876
+ dictionary,
2877
+ format: "css",
2878
+ usesDtcg
2879
+ });
2880
+ const filteredTokens = R10.reject(typographyFontFamilyPredicate, dictionary.allTokens);
2881
+ const formattedTokens = R10.pipe(R10.map(format), R10.join("\n"))(filteredTokens);
2882
+ const content = selector ? `${selector} {
2883
+ ${formattedTokens}
2884
+ }` : formattedTokens;
2885
+ const body = R10.isNotNil(layer) ? `@layer ${layer} {
2886
+ ${content}
2887
+ }` : content;
2888
+ return body;
2889
+ }
2890
+ };
2891
+
2892
+ // src/tokens/process/formats/css.ts
2893
+ var formats = {
2894
+ colorScheme,
2895
+ colorCategory,
2896
+ semantic,
2897
+ typography
2898
+ };
2899
+
2900
+ // src/tokens/process/transformers.ts
2901
+ import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
2902
+ import * as R11 from "ramda";
2903
+ var isPx = R11.test(/\b\d+px\b/g);
2904
+ var sizeRem = {
2905
+ name: "ds/size/toRem",
2906
+ type: "value",
2907
+ transitive: true,
2908
+ filter: (token) => {
2909
+ const hasWantedType = typeEquals(["dimension", "fontsize"], token);
2910
+ const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
2911
+ return hasWantedType && hasWantedPath;
2912
+ },
2913
+ transform: (token, config) => {
2914
+ const value = getValue(token);
2915
+ if (isPx(value)) {
2916
+ const baseFont = config.basePxFontSize || 16;
2917
+ const size = parseInt(value);
2918
+ if (size === 0) {
2919
+ return "0";
2920
+ }
2921
+ return `${size / baseFont}rem`;
2922
+ }
2923
+ return value;
2924
+ }
2925
+ };
2926
+ var typographyName = {
2927
+ name: "name/typography",
2928
+ type: "name",
2929
+ transitive: true,
2930
+ // expanded tokens have different type so we match on path instead
2931
+ filter: (token) => pathStartsWithOneOf(["typography"], token),
2932
+ transform: (token) => {
2933
+ return token.name.replace("-typography", "");
2934
+ }
2935
+ };
2936
+ var resolveMath = {
2937
+ name: "ds/resolveMath",
2938
+ type: "value",
2939
+ transitive: true,
2940
+ filter: (token) => {
2941
+ const isValidValue = ["string", "object"].includes(typeof getValue(token));
2942
+ const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
2943
+ return isValidValue && isTokenOfInterest;
2944
+ },
2945
+ transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
2946
+ };
2947
+ var unitless = {
2948
+ name: "ds/unitless",
2949
+ type: "value",
2950
+ transitive: true,
2951
+ filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
2952
+ transform: (token) => parseInt(getValue(token))
2953
+ };
2954
+
2955
+ // src/tokens/process/configs/shared.ts
2956
+ var prefix = "ds";
2957
+ var basePxFontSize = 16;
2958
+ var dsTransformers = [
2959
+ "name/kebab",
2960
+ resolveMath.name,
2961
+ "ts/size/px",
2962
+ sizeRem.name,
2963
+ unitless.name,
2964
+ "ts/typography/fontWeight",
2965
+ typographyName.name,
2966
+ "ts/color/modifiers",
2967
+ "ts/color/css/hexrgba",
2968
+ "ts/size/lineheight",
2969
+ "shadow/css/shorthand"
2970
+ ];
2971
+
2972
+ // src/tokens/process/configs/color.ts
2973
+ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
2974
+ const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
2975
+ const layer = `ds.theme.color-scheme.${colorScheme2}`;
2976
+ return {
2977
+ preprocessors: ["tokens-studio"],
2978
+ platforms: {
2979
+ css: {
2980
+ // custom
2981
+ colorScheme: colorScheme2,
2982
+ theme,
2983
+ selector,
2984
+ layer,
2985
+ //
2986
+ prefix,
2987
+ buildPath: `${theme}/`,
2988
+ transforms: dsTransformers,
2989
+ files: [
2990
+ {
2991
+ destination: `color-scheme/${colorScheme2}.css`,
2992
+ format: formats.colorScheme.name,
2993
+ filter: (token) => typeEquals("color", token) && !R12.startsWith(["global"], token.path)
2994
+ }
2995
+ ],
2996
+ options: {
2997
+ outputReferences: false
2998
+ }
2999
+ }
3000
+ }
3001
+ };
3002
+ };
3003
+ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
3004
+ const category = opts.category;
3005
+ const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
3006
+ if (!color) {
3007
+ throw new Error(
3008
+ category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
3009
+ );
3010
+ }
3011
+ const layer = `ds.theme.color`;
3012
+ const isRootColor = color === buildOptions?.rootColor;
3013
+ const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
3014
+ const config = {
3015
+ preprocessors: ["tokens-studio"],
3016
+ platforms: {
3017
+ css: {
3018
+ // custom
3019
+ colorScheme: colorScheme2,
3020
+ theme,
3021
+ selector,
3022
+ layer,
3023
+ //
3024
+ prefix,
3025
+ buildPath: `${theme}/`,
3026
+ transforms: dsTransformers,
3027
+ files: [
3028
+ {
3029
+ destination: `color/${color}.css`,
3030
+ format: formats.colorCategory.name,
3031
+ filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
3032
+ }
3033
+ ],
3034
+ options: {
3035
+ outputReferences: true
3036
+ }
3037
+ }
3038
+ }
3039
+ };
3040
+ return config;
3041
+ };
3042
+
3043
+ // src/tokens/process/configs/semantic.ts
3044
+ import * as R13 from "ramda";
3045
+ import { outputReferencesFilter } from "style-dictionary/utils";
3046
+ var semanticVariables = ({ theme }) => {
3047
+ const selector = `:root`;
3048
+ const layer = `ds.theme.semantic`;
3049
+ return {
3050
+ preprocessors: ["tokens-studio"],
3051
+ platforms: {
3052
+ css: {
3053
+ // custom
3054
+ theme,
3055
+ basePxFontSize,
3056
+ selector,
3057
+ layer,
3058
+ //
3059
+ prefix,
3060
+ buildPath: `${theme}/`,
3061
+ transforms: dsTransformers,
3062
+ files: [
3063
+ {
3064
+ destination: `semantic.css`,
3065
+ format: formats.semantic.name,
3066
+ filter: (token) => {
3067
+ const isUwantedToken = R13.anyPass([R13.includes("primitives/global")])(token.filePath);
3068
+ const isPrivateToken = R13.includes("_", token.path);
3069
+ const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
3070
+ const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
3071
+ const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
3072
+ return unwantedTokens;
3073
+ }
3074
+ }
3075
+ ],
3076
+ options: {
3077
+ outputReferences: (token, options) => {
3078
+ const include = pathStartsWithOneOf(["border-radius"], token);
3079
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
3080
+ return (include || isWantedSize) && outputReferencesFilter(token, options);
3081
+ }
3082
+ }
3083
+ }
3084
+ }
3085
+ };
3086
+ };
3087
+
3088
+ // src/tokens/process/configs/storefront.ts
3089
+ import * as R15 from "ramda";
3090
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
3091
+
3092
+ // src/tokens/process/formats/js-tokens.ts
3093
+ import * as R14 from "ramda";
3094
+ import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
3095
+ var groupByType = R14.groupBy((token) => getType(token));
3096
+ var removeUnwatedTokens = R14.pipe(
3097
+ R14.reject((token) => isColorCategoryToken(token)),
3098
+ R14.reject((token) => R14.any((path) => path.startsWith("_"))(token.path))
3099
+ );
3100
+ var dissocExtensions = R14.pipe(R14.dissoc("$extensions"), R14.dissocPath(["original", "$extensions"]));
3101
+ var removeUnwatedProps = R14.map((token) => dissocExtensions(token));
3102
+ var toCssVarName = R14.pipe(R14.split(":"), R14.head, R14.trim);
3103
+ var jsTokens = {
3104
+ name: "ds/js-tokens",
3105
+ format: async ({ dictionary, file, options }) => {
3106
+ const { usesDtcg, outputReferences } = options;
3107
+ const format = createPropertyFormatter4({
3108
+ outputReferences,
3109
+ dictionary,
3110
+ format: "css",
3111
+ usesDtcg
3112
+ });
3113
+ const formatTokens2 = R14.map((token) => {
3114
+ if (pathStartsWithOneOf(["size", "_size"], token)) {
3115
+ const { calc, name } = overrideSizingFormula(format, token);
3116
+ return {
3117
+ ...token,
3118
+ name: name.trim(),
3119
+ $value: calc.trim()
3120
+ };
3121
+ }
3122
+ return {
3123
+ ...token,
3124
+ name: toCssVarName(format(token))
3125
+ };
3126
+ });
3127
+ const processTokens = R14.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
3128
+ const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
3129
+ const content = Object.entries(tokens).map(
3130
+ ([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
3131
+ `
3132
+ ).join("\n");
3133
+ return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
3134
+ }
3135
+ };
3136
+
3137
+ // src/tokens/process/configs/storefront.ts
3138
+ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
3139
+ return {
3140
+ preprocessors: ["tokens-studio"],
3141
+ platforms: {
3142
+ ts: {
3143
+ prefix,
3144
+ basePxFontSize,
3145
+ transforms: dsTransformers,
3146
+ buildPath: `${theme}/`,
3147
+ files: [
3148
+ {
3149
+ destination: `${colorScheme2}.ts`,
3150
+ format: jsTokens.name,
3151
+ filter: (token) => {
3152
+ if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R15.includes("semantic", token.filePath))
3153
+ return false;
3154
+ const isSemanticColor = R15.includes("semantic", token.filePath) && typeEquals(["color"], token);
3155
+ const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
3156
+ return isSemanticColor || wantedTypes;
3157
+ }
3158
+ }
3159
+ ],
3160
+ options: {
3161
+ outputReferences: (token, options) => {
3162
+ const include = pathStartsWithOneOf(["border-radius"], token);
3163
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
3164
+ return (include || isWantedSize) && outputReferencesFilter2(token, options);
3165
+ }
3166
+ }
3167
+ }
3168
+ }
3169
+ };
3170
+ };
3171
+
3172
+ // src/tokens/process/configs/typography.ts
3173
+ import { expandTypesMap } from "@tokens-studio/sd-transforms";
3174
+ var typographyVariables = ({ theme, typography: typography2 }) => {
3175
+ const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
3176
+ const layer = `ds.theme.typography.${typography2}`;
3177
+ return {
3178
+ usesDtcg: true,
3179
+ preprocessors: ["tokens-studio"],
3180
+ expand: {
3181
+ include: ["typography"],
3182
+ typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
3183
+ },
3184
+ platforms: {
3185
+ css: {
3186
+ prefix,
3187
+ typography: typography2,
3188
+ selector,
3189
+ layer,
3190
+ buildPath: `${theme}/`,
3191
+ basePxFontSize,
3192
+ transforms: [
3193
+ "name/kebab",
3194
+ "ts/size/px",
3195
+ sizeRem.name,
3196
+ "ts/size/lineheight",
3197
+ "ts/typography/fontWeight",
3198
+ typographyName.name
3199
+ ],
3200
+ files: [
3201
+ {
3202
+ destination: `typography/${typography2}.css`,
3203
+ format: formats.typography.name,
3204
+ filter: (token) => {
3205
+ const included = typeEquals(
3206
+ ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
3207
+ token
3208
+ );
3209
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
3210
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
3211
+ }
3212
+ }
3213
+ ]
3214
+ }
3215
+ }
3216
+ };
3217
+ };
3218
+
3219
+ // src/tokens/process/utils/getMultidimensionalThemes.ts
3220
+ import chalk from "chalk";
3221
+ import { kebabCase } from "change-case";
3222
+ import * as R16 from "ramda";
3223
+ var getMultidimensionalThemes = (processed$themes, dimensions) => {
3224
+ const verboseLogging = buildOptions?.verbose;
3225
+ const grouped$themes = groupThemes(processed$themes);
3226
+ const permutations = permutateThemes(grouped$themes);
3227
+ const ALL_DEPENDENT_ON = ["theme"];
3228
+ const keys2 = R16.keys(grouped$themes);
3229
+ const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
3230
+ if (verboseLogging) {
3231
+ console.log(chalk.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
3232
+ console.log(chalk.cyan(` (ignoring permutations for ${nonDependentKeys})`));
3233
+ }
3234
+ return permutations.filter((val) => {
3235
+ const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
3236
+ return filters.every((x) => x);
3237
+ });
3238
+ };
3239
+ var processed = Symbol("Type brand for ProcessedThemeObject");
3240
+ function isProcessed(theme) {
3241
+ return Boolean(theme[processed]);
3242
+ }
3243
+ function processThemeObject(theme) {
3244
+ if (isProcessed(theme)) {
3245
+ return theme;
3246
+ }
3247
+ const result = { ...theme, [processed]: true };
3248
+ if (result.group) {
3249
+ result.group = kebabCase(result.group);
3250
+ }
3251
+ result.name = kebabCase(result.name);
3252
+ return result;
3253
+ }
3254
+ function groupThemes(themes) {
3255
+ const groups = {};
3256
+ for (const rawTheme of themes) {
3257
+ const theme = processThemeObject(rawTheme);
3258
+ if (theme.group) {
3259
+ const groupKey = theme.group;
3260
+ groups[groupKey] = [...groups[groupKey] ?? [], theme];
3261
+ } else {
3262
+ throw new Error(
3263
+ `Theme ${theme.name} does not have a group property, which is required for multi-dimensional theming.`
3264
+ );
3265
+ }
3266
+ }
3267
+ return groups;
3268
+ }
3269
+ var hasUnknownProps = R16.pipe(R16.values, R16.none(R16.equals("unknown")), R16.not);
3270
+ function permutateThemes(groups) {
3271
+ const separator = "_";
3272
+ const permutations = cartesian(Object.values(groups));
3273
+ const permutatedThemes = permutations.map((perm) => {
3274
+ const permutatedTheme = perm.reduce(
3275
+ (acc, theme) => {
3276
+ const { group, name, selectedTokenSets } = theme;
3277
+ let updatedPermutation = acc.permutation;
3278
+ if (group) {
3279
+ const groupProp = R16.lensProp(group);
3280
+ updatedPermutation = R16.set(groupProp, name, updatedPermutation);
3281
+ }
3282
+ const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
3283
+ const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
3284
+ return {
3285
+ permutation: updatedPermutation,
3286
+ name: updatedName,
3287
+ selectedTokenSets: sets
3288
+ };
3289
+ },
3290
+ {
3291
+ name: "",
3292
+ selectedTokenSets: [],
3293
+ permutation: {
3294
+ "color-scheme": "unknown",
3295
+ "main-color": "unknown",
3296
+ "support-color": "unknown",
3297
+ theme: "unknown",
3298
+ semantic: "unknown",
3299
+ size: "unknown",
3300
+ typography: "unknown"
3301
+ }
3302
+ }
3303
+ );
3304
+ if (hasUnknownProps(permutatedTheme)) {
3305
+ throw Error(`Theme ${permutatedTheme.name} has unknown props: ${JSON.stringify(permutatedTheme)}`);
3306
+ }
3307
+ const uniqueTokenSets = new Set(permutatedTheme.selectedTokenSets);
3308
+ return { ...permutatedTheme, selectedTokenSets: Array.from(uniqueTokenSets) };
3309
+ });
3310
+ return permutatedThemes;
3311
+ }
3312
+ function filterTokenSets(tokensets) {
3313
+ return Object.entries(tokensets).filter(([, val]) => val !== TokenSetStatus.DISABLED).sort((a, b) => {
3314
+ if (a[1] === TokenSetStatus.SOURCE && b[1] === TokenSetStatus.ENABLED) {
3315
+ return -1;
3316
+ }
3317
+ if (a[1] === TokenSetStatus.ENABLED && b[1] === TokenSetStatus.SOURCE) {
3318
+ return 1;
3319
+ }
3320
+ return 0;
3321
+ }).map((entry) => entry[0]);
3322
+ }
3323
+ function cartesian(a) {
3324
+ return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
3325
+ }
3326
+
3327
+ // src/tokens/process/configs.ts
3328
+ void register(StyleDictionary, { withSDBuiltins: false });
3329
+ StyleDictionary.registerTransform(sizeRem);
3330
+ StyleDictionary.registerTransform(typographyName);
3331
+ StyleDictionary.registerTransform(resolveMath);
3332
+ StyleDictionary.registerTransform(unitless);
3333
+ StyleDictionary.registerFormat(jsTokens);
3334
+ for (const format of Object.values(formats)) {
3335
+ StyleDictionary.registerFormat(format);
3336
+ }
3337
+ var configs = {
3338
+ colorSchemeVariables,
3339
+ mainColorVariables: colorCategoryVariables({ category: "main" }),
3340
+ supportColorVariables: colorCategoryVariables({ category: "support" }),
3341
+ neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
3342
+ successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
3343
+ dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
3344
+ warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
3345
+ infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
3346
+ typographyVariables,
3347
+ semanticVariables,
3348
+ typescriptTokens
3349
+ };
3350
+ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
3351
+ const { tokensDir, tokenSets } = options;
3352
+ const permutations = getMultidimensionalThemes(processed$themes, dimensions);
3353
+ return permutations.flatMap(({ selectedTokenSets, permutation }) => {
3354
+ const tokenSource = { source: void 0, tokens: {} };
3355
+ if (tokenSets) {
3356
+ for (const tokenSet of selectedTokenSets) {
3357
+ const tokens = tokenSets.get(tokenSet);
3358
+ if (tokens) {
3359
+ const tokensWithFilePath = traverseObj(tokens, (obj) => {
3360
+ if (Object.hasOwn(obj, `$value`) && !obj.filePath) {
3361
+ obj.filePath = tokenSet;
3362
+ }
3363
+ });
3364
+ tokenSource.tokens = R17.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
3365
+ }
3366
+ }
3367
+ } else {
3368
+ tokenSource.source = selectedTokenSets.map((x) => `${tokensDir}/${x}.json`);
3369
+ }
3370
+ const configOrConfigs = getConfig(permutation);
3371
+ const configs_ = Array.isArray(configOrConfigs) ? configOrConfigs : [{ config: configOrConfigs }];
3372
+ const configs2 = configs_.map(({ config, permutationOverrides }) => {
3373
+ return {
3374
+ permutation: { ...permutation, ...permutationOverrides },
3375
+ config: {
3376
+ ...config,
3377
+ /** Use official W3C design token format
3378
+ @see https://v4.styledictionary.com/info/dtcg/
3379
+ @see https://design-tokens.github.io/community-group/format/ */
3380
+ usesDtcg: true,
3381
+ log: {
3382
+ ...config?.log,
3383
+ verbosity: buildOptions?.verbose ? "verbose" : "silent"
3384
+ },
3385
+ ...tokenSource
3386
+ }
3387
+ };
3388
+ });
3389
+ return configs2;
3390
+ }).sort();
3391
+ };
3392
+
3393
+ // src/tokens/process/platform.ts
3394
+ var initResult = {
3395
+ formatted: [],
3396
+ permutation: {
3397
+ "color-scheme": "",
3398
+ "main-color": "",
3399
+ "support-color": "",
3400
+ semantic: "",
3401
+ size: "",
3402
+ theme: "",
3403
+ typography: ""
3404
+ }
3405
+ };
3406
+ var buildOptions;
3407
+ var sd = new StyleDictionary2();
3408
+ var getCustomColors = (processed$themes) => processed$themes.filter(
3409
+ (x) => x.group && [colorCategories.main, colorCategories.support].map((c) => `${c}-color`).includes(x.group)
3410
+ ).map((x) => x.name);
3411
+ var buildConfigs = {
3412
+ typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
3413
+ "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
3414
+ "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
3415
+ "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
3416
+ "neutral-color": {
3417
+ getConfig: configs.neutralColorVariables,
3418
+ dimensions: ["semantic"],
3419
+ log: ({ permutation: { theme } }) => `${theme} - neutral`
3420
+ },
3421
+ "success-color": {
3422
+ getConfig: configs.successColorVariables,
3423
+ dimensions: ["semantic"],
3424
+ log: ({ permutation: { theme } }) => `${theme} - success`
3425
+ },
3426
+ "danger-color": {
3427
+ getConfig: configs.dangerColorVariables,
3428
+ dimensions: ["semantic"],
3429
+ log: ({ permutation: { theme } }) => `${theme} - danger`
3430
+ },
3431
+ "warning-color": {
3432
+ getConfig: configs.warningColorVariables,
3433
+ dimensions: ["semantic"],
3434
+ log: ({ permutation: { theme } }) => `${theme} - warning`
3435
+ },
3436
+ "info-color": {
3437
+ getConfig: configs.infoColorVariables,
3438
+ dimensions: ["semantic"],
3439
+ log: ({ permutation: { theme } }) => `${theme} - info`
3440
+ },
3441
+ semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
3442
+ // storefront: {
3443
+ // name: 'Storefront preview tokens',
3444
+ // getConfig: configs.typescriptTokens,
3445
+ // dimensions: ['color-scheme'],
3446
+ // options: { outPath: path.resolve('../../apps/storefront/tokens') },
3447
+ // enabled: () => buildOptions?.preview ?? false,
3448
+ // },
3449
+ };
3450
+ async function processPlatform(options) {
3451
+ const { dry, process, $themes } = options;
3452
+ const platform = "css";
3453
+ const tokenSets = process === "format" ? options.tokenSets : void 0;
3454
+ const tokensDir = process === "build" ? options.tokensDir : void 0;
3455
+ buildOptions = options;
3456
+ const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
3457
+ const customColors = getCustomColors(processed$themes);
3458
+ if (!buildOptions.rootColor) {
3459
+ const firstMainColor = R18.head(customColors);
3460
+ buildOptions.rootColor = firstMainColor;
3461
+ console.log(`Using first main color; ${chalk2.blue(firstMainColor)}, as ${chalk2.green(`":root"`)} color`);
3462
+ }
3463
+ const buildAndSdConfigs = R18.map((buildConfig) => {
3464
+ const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
3465
+ tokensDir,
3466
+ tokenSets
3467
+ });
3468
+ const unknownConfigs = buildConfig.dimensions.map(
3469
+ (dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
3470
+ );
3471
+ for (const unknowns of unknownConfigs) {
3472
+ if (unknowns.length === sdConfigs.length) {
3473
+ buildConfig.enabled = () => false;
3474
+ }
3475
+ }
3476
+ return {
3477
+ buildConfig,
3478
+ sdConfigs
3479
+ };
3480
+ }, buildConfigs);
3481
+ const processedBuilds = {
3482
+ "color-scheme": [initResult],
3483
+ "main-color": [initResult],
3484
+ "support-color": [initResult],
3485
+ "neutral-color": [initResult],
3486
+ "success-color": [initResult],
3487
+ "danger-color": [initResult],
3488
+ "warning-color": [initResult],
3489
+ "info-color": [initResult],
3490
+ semantic: [initResult],
3491
+ typography: [initResult],
3492
+ types: [initResult]
3493
+ };
3494
+ try {
3495
+ for (const [buildName, { buildConfig, sdConfigs }] of R18.toPairs(buildAndSdConfigs)) {
3496
+ if (!(buildConfig.enabled?.() ?? true)) {
3497
+ continue;
3498
+ }
3499
+ if (sdConfigs.length > 0) {
3500
+ console.log(`
3501
+ \u{1F371} Building ${chalk2.green(buildConfig.name ?? buildName)}`);
3502
+ const results = await Promise.all(
3503
+ sdConfigs.map(async (sdConfig) => {
3504
+ const { config, permutation } = sdConfig;
3505
+ const modes = ["theme", ...buildConfig.dimensions];
3506
+ const modeMessage = modes.map((x) => permutation[x]).join(" - ");
3507
+ const logMessage = R18.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
3508
+ console.log(logMessage);
3509
+ const sdOptions = { cache: true };
3510
+ const sdExtended = await sd.extend(config);
3511
+ const result = {
3512
+ permutation,
3513
+ formatted: await sdExtended.formatPlatform(platform, sdOptions)
3514
+ };
3515
+ return Promise.resolve(result);
3516
+ })
3517
+ );
3518
+ processedBuilds[buildName] = results;
3519
+ }
3520
+ }
3521
+ } catch (err) {
3522
+ if (err instanceof Error) {
3523
+ err.message = err.message.replace('log.verbosity "verbose" or use ', "");
3524
+ }
3525
+ throw err;
3526
+ }
3527
+ const colorsFileName = "colors.d.ts";
3528
+ const reactColorTypes = await createColorTypeDeclaration(customColors);
3529
+ processedBuilds.types = [
3530
+ {
3531
+ ...initResult,
3532
+ formatted: [{ output: reactColorTypes, destination: colorsFileName }]
3533
+ }
3534
+ ];
3535
+ return processedBuilds;
3536
+ }
3537
+ async function createColorTypeDeclaration(colors) {
3538
+ console.log(`
3539
+ \u{1F371} Building ${chalk2.green("type declarations")}`);
3540
+ const typeDeclaration = `
3541
+ import type {} from '@digdir/designsystemet-react/colors';
3542
+
3543
+ declare module '@digdir/designsystemet-react/colors' {
3544
+ export interface MainAndSupportColors {
3545
+ ${colors.map((color) => ` ${color}: never;`).join("\n")}
3546
+ }
3547
+ }
3548
+ `.trimStart();
3549
+ return typeDeclaration;
3550
+ }
3551
+
3552
+ // src/tokens/format.ts
3553
+ var formatTokens = async (options) => {
3554
+ const processedBuilds = await processPlatform({
3555
+ process: "format",
3556
+ ...options
3557
+ });
3558
+ return processedBuilds;
3559
+ };
3560
+ var formatTheme = async (themeConfig) => {
3561
+ const { tokenSets } = await createTokens(themeConfig);
3562
+ const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3563
+ const processedBuilds = await formatTokens({
3564
+ tokenSets,
3565
+ $themes,
3566
+ verbose: false,
3567
+ preview: false
3568
+ });
3569
+ return processedBuilds;
3570
+ };
3571
+ var formatThemeCSS = async (themeConfig) => {
3572
+ const processedBuilds = await formatTheme(themeConfig);
3573
+ const themeCSSFiles = createThemeCSSFiles(processedBuilds);
3574
+ return R19.head(themeCSSFiles)?.output ?? "";
3575
+ };
3576
+ var createThemeCSSFiles = (processedBuilds) => {
3577
+ const groupedByTheme = {};
3578
+ for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
3579
+ for (const buildResult of buildResults) {
3580
+ const previous = groupedByTheme[buildResult.permutation.theme] ?? [];
3581
+ groupedByTheme[buildResult.permutation.theme] = R19.concat(previous, buildResult.formatted);
3582
+ }
3583
+ }
3584
+ const sortOrder = [
3585
+ "color-scheme/light",
3586
+ "typography/secondary",
3587
+ "semantic",
3588
+ "color-scheme/dark",
3589
+ "color-scheme/contrast",
3590
+ "typography/primary",
3591
+ "color/"
3592
+ ];
3593
+ const sortByDefinedOrder = R19.sortBy((file) => {
3594
+ const filePath = file.destination || "";
3595
+ const sortIndex = sortOrder.findIndex((sortElement) => {
3596
+ if (sortElement.endsWith("/")) {
3597
+ return filePath.includes(sortElement);
3598
+ }
3599
+ return filePath.includes(`${sortElement}.css`);
3600
+ });
3601
+ if (sortIndex === -1) {
3602
+ console.error(
3603
+ chalk3.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
3604
+ );
3605
+ console.log(
3606
+ chalk3.dim(
3607
+ `
3608
+ The section will currently be added to the end of the entry file, but the exact
3609
+ order may change due to nondeterminism.`.trim()
3610
+ )
3611
+ );
3612
+ return Infinity;
3613
+ }
3614
+ return sortIndex;
3615
+ });
3616
+ const header = `@charset "UTF-8";
3617
+
3618
+ @layer ds.theme, ds.base, ds.utilities, ds.components;
3619
+
3620
+ /* This file is generated by ${package_default.name}@${package_default.version} */
3621
+
3622
+ `;
3623
+ const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
3624
+ const pickOutputs = R19.map(R19.view(R19.lensProp("output")));
3625
+ const themeCSSFile = R19.pipe(
3626
+ sortAlphabetically,
3627
+ sortByDefinedOrder,
3628
+ pickOutputs,
3629
+ R19.join("\n"),
3630
+ (content) => header + content
3631
+ );
3632
+ const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
3633
+ destination: `${theme}.css`,
3634
+ output: themeCSSFile(files)
3635
+ }));
3636
+ return themeCSSFiles;
3637
+ };
3638
+ export {
3639
+ HSLToHex,
3640
+ RESERVED_COLORS,
3641
+ areColorsContrasting,
3642
+ baseColors,
3643
+ canTextBeUsedOnColors,
3644
+ cliOptions,
3645
+ colorMetadata,
3646
+ convertToHex,
3647
+ createTokens,
3648
+ formatThemeCSS,
3649
+ formatTokens,
3650
+ generateColorContrast,
3651
+ generateColorScale,
3652
+ generateColorSchemes,
3653
+ getColorMetadataByNumber,
3654
+ getContrastFromHex,
3655
+ getContrastFromLightness,
3656
+ getCssVariable,
3657
+ getLightnessFromHex,
3658
+ getLuminanceFromLightness,
3659
+ hexToCssHsl,
3660
+ hexToHSL,
3661
+ hexToHsluv,
3662
+ hexToRgb,
3663
+ hslArrToCss,
3664
+ isHexColor,
3665
+ rgbToHex
3666
+ };