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