@digdir/designsystemet 1.0.4 → 1.0.6

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 (44) hide show
  1. package/LICENSE +7 -0
  2. package/dist/bin/designsystemet.js +623 -593
  3. package/dist/src/colors/index.js +32 -0
  4. package/dist/src/colors/theme.js +1 -0
  5. package/dist/src/colors/utils.d.ts +13 -0
  6. package/dist/src/colors/utils.d.ts.map +1 -1
  7. package/dist/src/colors/utils.js +32 -0
  8. package/dist/src/config.js +1 -0
  9. package/dist/src/index.js +196 -142
  10. package/dist/src/scripts/createJsonSchema.js +39 -38
  11. package/dist/src/scripts/update-design-tokens.js +1 -0
  12. package/dist/src/tokens/build.d.ts.map +1 -1
  13. package/dist/src/tokens/build.js +353 -590
  14. package/dist/src/tokens/create/generators/$designsystemet.js +22 -19
  15. package/dist/src/tokens/create/generators/$themes.js +10 -10
  16. package/dist/src/tokens/create/generators/color.js +1 -0
  17. package/dist/src/tokens/create/write.js +32 -29
  18. package/dist/src/tokens/create.js +1 -0
  19. package/dist/src/tokens/format.d.ts +4 -5
  20. package/dist/src/tokens/format.d.ts.map +1 -1
  21. package/dist/src/tokens/format.js +165 -143
  22. package/dist/src/tokens/index.js +165 -142
  23. package/dist/src/tokens/process/configs/color.js +26 -22
  24. package/dist/src/tokens/process/configs/semantic.js +16 -12
  25. package/dist/src/tokens/process/configs/shared.js +16 -12
  26. package/dist/src/tokens/process/configs/storefront.js +16 -12
  27. package/dist/src/tokens/process/configs/typography.js +16 -12
  28. package/dist/src/tokens/process/configs.js +26 -22
  29. package/dist/src/tokens/process/formats/css/color.js +16 -12
  30. package/dist/src/tokens/process/formats/css/semantic.js +16 -12
  31. package/dist/src/tokens/process/formats/css.js +16 -12
  32. package/dist/src/tokens/process/formats/js-tokens.js +16 -12
  33. package/dist/src/tokens/process/platform.js +27 -23
  34. package/dist/src/tokens/process/theme.d.ts +27 -0
  35. package/dist/src/tokens/process/theme.d.ts.map +1 -0
  36. package/dist/src/tokens/process/theme.js +174 -0
  37. package/dist/src/tokens/process/transformers.js +16 -12
  38. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +26 -22
  39. package/dist/src/tokens/types.d.ts +4 -0
  40. package/dist/src/tokens/types.d.ts.map +1 -1
  41. package/dist/src/tokens/utils.d.ts +2 -2
  42. package/dist/src/tokens/utils.d.ts.map +1 -1
  43. package/dist/src/tokens/utils.js +16 -12
  44. package/package.json +31 -28
@@ -1,6 +1,7 @@
1
1
  // src/tokens/build.ts
2
2
  import path from "node:path";
3
3
  import chalk5 from "chalk";
4
+ import * as R14 from "ramda";
4
5
 
5
6
  // src/utils.ts
6
7
  import fs from "node:fs/promises";
@@ -44,18 +45,18 @@ var readFile = async (path2, dry) => {
44
45
  return fs.readFile(path2, "utf-8");
45
46
  };
46
47
 
47
- // src/tokens/format.ts
48
- import * as R19 from "ramda";
49
- import chalk4 from "chalk";
48
+ // src/tokens/process/theme.ts
49
+ import * as R from "ramda";
50
+ import chalk2 from "chalk";
50
51
 
51
52
  // package.json
52
53
  var package_default = {
53
54
  name: "@digdir/designsystemet",
54
- version: "1.0.4",
55
+ version: "1.0.6",
55
56
  description: "CLI for Designsystemet",
56
57
  author: "Designsystemet team",
57
58
  engines: {
58
- node: ">=22.14.0"
59
+ node: ">=22.15.0"
59
60
  },
60
61
  repository: {
61
62
  type: "git",
@@ -85,491 +86,139 @@ var package_default = {
85
86
  },
86
87
  scripts: {
87
88
  designsystemet: "tsx ./bin/designsystemet.ts",
88
- "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
89
+ "build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
89
90
  "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
90
- build: "tsup && yarn build:types && yarn build:json-schema",
91
+ build: "tsup && pnpm build:types && pnpm build:json-schema",
91
92
  "build:types": "tsc --emitDeclarationOnly --declaration",
92
93
  "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
93
94
  types: "tsc --noEmit",
94
- "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
95
- "test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
96
- "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
97
- "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
98
- "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
99
- test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
100
- "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
95
+ "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./test-tokens/options --theme options --clean',
96
+ "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./test/test-tokens.config.json",
97
+ "test:tokens-build": "pnpm run designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
98
+ "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
99
+ "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
100
+ "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
101
+ test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
102
+ "internal:tokens-create": "pnpm run designsystemet tokens create --config ./internal.config.json",
101
103
  "update:template": "tsx ./src/scripts/update-template.ts",
102
- "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
103
- verify: "yarn test && yarn update:template && yarn update:design-tokens"
104
+ "update:design-tokens": "pnpm internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
105
+ verify: "pnpm test && pnpm update:template && pnpm update:design-tokens"
104
106
  },
105
107
  dependencies: {
106
108
  "@commander-js/extra-typings": "^13.1.0",
107
- "@tokens-studio/sd-transforms": "1.2.12",
109
+ "@tokens-studio/sd-transforms": "1.3.0",
108
110
  "apca-w3": "^0.1.9",
109
111
  chalk: "^5.4.1",
110
112
  "change-case": "^5.4.4",
111
113
  "chroma-js": "^3.1.2",
114
+ "colorjs.io": "^0.6.0-alpha.1",
112
115
  commander: "^13.1.0",
113
116
  "fast-glob": "^3.3.3",
114
117
  hsluv: "^1.0.1",
115
118
  "object-hash": "^3.0.0",
116
119
  postcss: "^8.5.3",
117
120
  ramda: "^0.30.1",
118
- "style-dictionary": "^4.3.3",
119
- zod: "^3.24.2",
121
+ "style-dictionary": "^4.4.0",
122
+ zod: "^3.24.4",
120
123
  "zod-validation-error": "^3.4.0"
121
124
  },
122
125
  devDependencies: {
126
+ "@tokens-studio/types": "0.5.2",
123
127
  "@types/apca-w3": "^0.1.3",
124
128
  "@types/chroma-js": "^3.1.1",
125
129
  "@types/fs-extra": "^11.0.4",
126
130
  "@types/glob": "^8.1.0",
127
131
  "@types/jscodeshift": "^0.12.0",
128
- "@types/node": "^22.14.0",
132
+ "@types/node": "^22.15.3",
129
133
  "@types/object-hash": "^3.0.6",
130
134
  "@types/ramda": "^0.30.2",
131
135
  "fs-extra": "^11.3.0",
132
136
  "ts-toolbelt": "^9.6.0",
133
137
  tslib: "^2.8.1",
134
138
  tsup: "^8.4.0",
135
- tsx: "^4.19.3",
136
- typescript: "^5.8.2",
139
+ tsx: "^4.19.4",
140
+ typescript: "^5.8.3",
137
141
  "zod-to-json-schema": "^3.24.5"
138
142
  }
139
143
  };
140
144
 
141
- // src/tokens/create/defaults.ts
142
- import * as R from "ramda";
143
-
144
- // src/tokens/create/generators/color.ts
145
- import * as R4 from "ramda";
146
-
147
- // src/colors/utils.ts
148
- import chroma from "chroma-js";
149
- import { Hsluv } from "hsluv";
150
-
151
- // src/colors/theme.ts
152
- import chroma2 from "chroma-js";
153
- import * as R3 from "ramda";
154
-
155
- // src/colors/colorMetadata.ts
156
- import * as R2 from "ramda";
157
- var colorMetadata = {
158
- "background-default": {
159
- number: 1,
160
- name: "background-default",
161
- group: "background",
162
- displayName: "Background Default",
163
- description: {
164
- long: "Background Default er den mest n\xF8ytrale bakgrunnsfargen.",
165
- short: "Standard bakgrunnsfarge."
166
- },
167
- luminance: {
168
- light: 1,
169
- dark: 9e-3,
170
- contrast: 1e-3
171
- }
172
- },
173
- "background-tinted": {
174
- number: 2,
175
- name: "background-tinted",
176
- group: "background",
177
- displayName: "Background Tinted",
178
- description: {
179
- long: "Background Tinted er en bakgrunnsfarge som har et hint av farge i seg.",
180
- short: "Bakgrunn med et hint av farge i seg."
181
- },
182
- luminance: {
183
- light: 0.9,
184
- dark: 0.014,
185
- contrast: 65e-4
186
- }
187
- },
188
- "surface-default": {
189
- number: 3,
190
- name: "surface-default",
191
- group: "surface",
192
- displayName: "Surface Default",
193
- description: {
194
- long: "Surface Default brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Dette er den mest n\xF8ytrale surface fargen.",
195
- short: "Standardfarge for overflater / komponenter."
196
- },
197
- luminance: {
198
- light: 1,
199
- dark: 0.021,
200
- contrast: 0.015
201
- }
202
- },
203
- "surface-tinted": {
204
- number: 4,
205
- name: "surface-tinted",
206
- group: "surface",
207
- displayName: "Surface Tinted",
208
- description: {
209
- long: "Surface Tinted brukes p\xE5 flater som ligger opp\xE5 bakgrunnsfargene. Denne har et hint av farge i seg.",
210
- short: "Overflater / komponenter med et hint av farge i seg."
211
- },
212
- luminance: {
213
- light: 0.81,
214
- dark: 0.027,
215
- contrast: 0.015
216
- }
217
- },
218
- "surface-hover": {
219
- number: 5,
220
- name: "surface-hover",
221
- group: "surface",
222
- displayName: "Surface Hover",
223
- description: {
224
- long: "Surface Hover brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en hover state.",
225
- short: "Hover-farge til overflater / komponenter."
226
- },
227
- luminance: {
228
- light: 0.7,
229
- dark: 0.036,
230
- contrast: 0.028
231
- }
232
- },
233
- "surface-active": {
234
- number: 6,
235
- name: "surface-active",
236
- group: "surface",
237
- displayName: "Surface Active",
238
- description: {
239
- long: "Surface Active brukes p\xE5 interaktive flater som ligger opp\xE5 bakgrunnsfargene i en active state.",
240
- short: "Active-farge til overflater / komponenter."
241
- },
242
- luminance: {
243
- light: 0.59,
244
- dark: 0.056,
245
- contrast: 0.045
246
- }
247
- },
248
- "border-subtle": {
249
- number: 7,
250
- name: "border-subtle",
251
- group: "border",
252
- displayName: "Border Subtle",
253
- description: {
254
- long: "Border Subtle er den lyseste border-fargen og brukes for \xE5 skille elementer fra hverandre.",
255
- short: "Border-farge med lav kontrast til dekorativ bruk (skillelinjer)."
256
- },
257
- luminance: {
258
- light: 0.5,
259
- dark: 0.08,
260
- contrast: 0.26
261
- }
262
- },
263
- "border-default": {
264
- number: 8,
265
- name: "border-default",
266
- group: "border",
267
- displayName: "Border Default",
268
- description: {
269
- long: "Border Default er en border-farge som brukes n\xE5r man \xF8nsker god kontrast mot bakgrunnsfargene.",
270
- short: "Standard border-farge til skjemakomponenter og meningsb\xE6rende elementer."
271
- },
272
- luminance: {
273
- light: 0.19,
274
- dark: 0.22,
275
- contrast: 0.4
276
- }
277
- },
278
- "border-strong": {
279
- number: 9,
280
- name: "border-strong",
281
- group: "border",
282
- displayName: "Border Strong",
283
- description: {
284
- long: "Border Strong er den m\xF8rkeste border-fargen og brukes n\xE5r man \xF8nsker en veldig tydelig og sterk border.",
285
- short: "Border-farge med h\xF8y kontrast for ekstra synlighet."
286
- },
287
- luminance: {
288
- light: 0.11,
289
- dark: 0.39,
290
- contrast: 0.6
291
- }
292
- },
293
- "text-subtle": {
294
- number: 10,
295
- name: "text-subtle",
296
- group: "text",
297
- displayName: "Text Subtle",
298
- description: {
299
- 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.",
300
- short: "Tekst- og ikonfarge med lavere kontrast."
301
- },
302
- luminance: {
303
- light: 0.11,
304
- dark: 0.39,
305
- contrast: 0.57
306
- }
307
- },
308
- "text-default": {
309
- number: 11,
310
- name: "text-default",
311
- group: "text",
312
- displayName: "Text Default",
313
- description: {
314
- 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.",
315
- short: "Tekst- og ikonfarge med h\xF8y kontrast og god synlighet."
316
- },
317
- luminance: {
318
- light: 0.0245,
319
- dark: 0.84,
320
- contrast: 0.86
321
- }
322
- },
323
- "base-default": {
324
- number: 12,
325
- name: "base-default",
326
- group: "base",
327
- displayName: "Base Default",
328
- description: {
329
- 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.",
330
- short: "Standardfarge for solide bakgrunner."
331
- },
332
- luminance: {
333
- light: 1,
334
- dark: 1,
335
- contrast: 1
336
- }
337
- },
338
- "base-hover": {
339
- number: 13,
340
- name: "base-hover",
341
- group: "base",
342
- displayName: "Base Hover",
343
- description: {
344
- long: "Base Hover brukes som hover farge p\xE5 elementer som bruker Base Default fargen.",
345
- short: "Hover-farge for solide bakgrunner."
346
- },
347
- luminance: {
348
- light: 1,
349
- dark: 1,
350
- contrast: 1
351
- }
352
- },
353
- "base-active": {
354
- number: 14,
355
- name: "base-active",
356
- group: "base",
357
- displayName: "Base Active",
358
- description: {
359
- long: "Base Active brukes som active farge p\xE5 elementer som bruker Base Default fargen.",
360
- short: "Active-farge for solide bakgrunner."
361
- },
362
- luminance: {
363
- light: 1,
364
- dark: 1,
365
- contrast: 1
366
- }
367
- },
368
- "base-contrast-subtle": {
369
- number: 15,
370
- name: "base-contrast-subtle",
371
- group: "base",
372
- displayName: "Contrast Subtle",
373
- description: {
374
- long: "Contrast Subtle brukes som en viktig meningsb\xE6rende farge opp\xE5 Base Default fargen.",
375
- short: "Farge med god kontrast mot Base-default."
376
- },
377
- luminance: {
378
- light: 1,
379
- dark: 1,
380
- contrast: 1
381
- }
382
- },
383
- "base-contrast-default": {
384
- number: 16,
385
- name: "base-contrast-default",
386
- group: "base",
387
- displayName: "Contrast Default",
388
- description: {
389
- long: "Contrast Default brukes som en viktig meningsb\xE6rende farge opp\xE5 alle Base fargane.",
390
- short: "Farge med god kontrast mot Base-default og Base-hover."
391
- },
392
- luminance: {
393
- light: 1,
394
- dark: 1,
395
- contrast: 1
145
+ // src/tokens/process/theme.ts
146
+ var defaultFileHeader = `build: v${package_default.version}`;
147
+ var createThemeCSSFiles = ({
148
+ processedBuilds,
149
+ fileHeader: fileHeader2 = defaultFileHeader
150
+ }) => {
151
+ const groupedByTheme = {};
152
+ for (const [_, buildResults] of Object.entries(R.dissoc("types", processedBuilds))) {
153
+ for (const buildResult of buildResults) {
154
+ const themeName = buildResult.permutation.theme;
155
+ const newOutputs = buildResult.formatted;
156
+ if (R.isNotEmpty(newOutputs)) {
157
+ const currentOutputs = groupedByTheme[themeName] ?? [];
158
+ groupedByTheme[themeName] = R.concat(currentOutputs, newOutputs);
159
+ }
396
160
  }
397
161
  }
398
- };
399
- var colorMetadataByNumber = R2.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
400
-
401
- // src/tokens/create/generators/semantic.ts
402
- import * as R5 from "ramda";
403
-
404
- // src/tokens/create/generators/theme.ts
405
- import * as R6 from "ramda";
406
-
407
- // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
408
- var BoxShadowTypes;
409
- (function(BoxShadowTypes2) {
410
- BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
411
- BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
412
- })(BoxShadowTypes || (BoxShadowTypes = {}));
413
-
414
- // ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
415
- var ColorModifierTypes;
416
- (function(ColorModifierTypes2) {
417
- ColorModifierTypes2["LIGHTEN"] = "lighten";
418
- ColorModifierTypes2["DARKEN"] = "darken";
419
- ColorModifierTypes2["MIX"] = "mix";
420
- ColorModifierTypes2["ALPHA"] = "alpha";
421
- })(ColorModifierTypes || (ColorModifierTypes = {}));
422
-
423
- // ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
424
- var ColorSpaceTypes;
425
- (function(ColorSpaceTypes2) {
426
- ColorSpaceTypes2["LCH"] = "lch";
427
- ColorSpaceTypes2["SRGB"] = "srgb";
428
- ColorSpaceTypes2["P3"] = "p3";
429
- ColorSpaceTypes2["HSL"] = "hsl";
430
- })(ColorSpaceTypes || (ColorSpaceTypes = {}));
431
-
432
- // ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
433
- var Properties;
434
- (function(Properties2) {
435
- Properties2["sizing"] = "sizing";
436
- Properties2["height"] = "height";
437
- Properties2["width"] = "width";
438
- Properties2["spacing"] = "spacing";
439
- Properties2["verticalPadding"] = "verticalPadding";
440
- Properties2["horizontalPadding"] = "horizontalPadding";
441
- Properties2["paddingTop"] = "paddingTop";
442
- Properties2["paddingRight"] = "paddingRight";
443
- Properties2["paddingBottom"] = "paddingBottom";
444
- Properties2["paddingLeft"] = "paddingLeft";
445
- Properties2["itemSpacing"] = "itemSpacing";
446
- Properties2["fill"] = "fill";
447
- Properties2["backgroundBlur"] = "backgroundBlur";
448
- Properties2["border"] = "border";
449
- Properties2["borderTop"] = "borderTop";
450
- Properties2["borderRight"] = "borderRight";
451
- Properties2["borderBottom"] = "borderBottom";
452
- Properties2["borderLeft"] = "borderLeft";
453
- Properties2["borderColor"] = "borderColor";
454
- Properties2["borderRadius"] = "borderRadius";
455
- Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
456
- Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
457
- Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
458
- Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
459
- Properties2["borderWidth"] = "borderWidth";
460
- Properties2["borderWidthTop"] = "borderWidthTop";
461
- Properties2["borderWidthRight"] = "borderWidthRight";
462
- Properties2["borderWidthBottom"] = "borderWidthBottom";
463
- Properties2["borderWidthLeft"] = "borderWidthLeft";
464
- Properties2["boxShadow"] = "boxShadow";
465
- Properties2["opacity"] = "opacity";
466
- Properties2["fontFamilies"] = "fontFamilies";
467
- Properties2["fontWeights"] = "fontWeights";
468
- Properties2["fontSizes"] = "fontSizes";
469
- Properties2["lineHeights"] = "lineHeights";
470
- Properties2["typography"] = "typography";
471
- Properties2["composition"] = "composition";
472
- Properties2["letterSpacing"] = "letterSpacing";
473
- Properties2["paragraphSpacing"] = "paragraphSpacing";
474
- Properties2["textCase"] = "textCase";
475
- Properties2["dimension"] = "dimension";
476
- Properties2["textDecoration"] = "textDecoration";
477
- Properties2["asset"] = "asset";
478
- Properties2["tokenValue"] = "tokenValue";
479
- Properties2["value"] = "value";
480
- Properties2["tokenName"] = "tokenName";
481
- Properties2["description"] = "description";
482
- })(Properties || (Properties = {}));
483
-
484
- // ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
485
- var TokenSetStatus;
486
- (function(TokenSetStatus2) {
487
- TokenSetStatus2["DISABLED"] = "disabled";
488
- TokenSetStatus2["SOURCE"] = "source";
489
- TokenSetStatus2["ENABLED"] = "enabled";
490
- })(TokenSetStatus || (TokenSetStatus = {}));
491
-
492
- // ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
493
- var TokenTypes;
494
- (function(TokenTypes2) {
495
- TokenTypes2["OTHER"] = "other";
496
- TokenTypes2["COLOR"] = "color";
497
- TokenTypes2["BORDER_RADIUS"] = "borderRadius";
498
- TokenTypes2["SIZING"] = "sizing";
499
- TokenTypes2["SPACING"] = "spacing";
500
- TokenTypes2["TEXT"] = "text";
501
- TokenTypes2["TYPOGRAPHY"] = "typography";
502
- TokenTypes2["OPACITY"] = "opacity";
503
- TokenTypes2["BORDER_WIDTH"] = "borderWidth";
504
- TokenTypes2["STROKE_STYLE"] = "strokeStyle";
505
- TokenTypes2["BOX_SHADOW"] = "boxShadow";
506
- TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
507
- TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
508
- TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
509
- TokenTypes2["FONT_SIZES"] = "fontSizes";
510
- TokenTypes2["LETTER_SPACING"] = "letterSpacing";
511
- TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
512
- TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
513
- TokenTypes2["TEXT_DECORATION"] = "textDecoration";
514
- TokenTypes2["TEXT_CASE"] = "textCase";
515
- TokenTypes2["COMPOSITION"] = "composition";
516
- TokenTypes2["DIMENSION"] = "dimension";
517
- TokenTypes2["BORDER"] = "border";
518
- TokenTypes2["ASSET"] = "asset";
519
- TokenTypes2["BOOLEAN"] = "boolean";
520
- TokenTypes2["NUMBER"] = "number";
521
- })(TokenTypes || (TokenTypes = {}));
522
-
523
- // ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
524
- var BorderValues;
525
- (function(BorderValues2) {
526
- BorderValues2["BORDER_COLOR"] = "color";
527
- BorderValues2["BORDER_WIDTH"] = "width";
528
- BorderValues2["BORDER_STYLE"] = "style";
529
- })(BorderValues || (BorderValues = {}));
162
+ const sortOrder = [
163
+ "color-scheme/light",
164
+ "typography/secondary",
165
+ "semantic",
166
+ "color-scheme/dark",
167
+ "color-scheme/contrast",
168
+ "typography/primary",
169
+ "color/"
170
+ ];
171
+ const sortByDefinedOrder = R.sortBy((file) => {
172
+ const filePath = file.destination || "";
173
+ const sortIndex = sortOrder.findIndex((sortElement) => {
174
+ if (sortElement.endsWith("/")) {
175
+ return filePath.includes(sortElement);
176
+ }
177
+ return filePath.includes(`${sortElement}.css`);
178
+ });
179
+ if (sortIndex === -1) {
180
+ console.error(
181
+ chalk2.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
182
+ );
183
+ console.log(
184
+ chalk2.dim(
185
+ `
186
+ The section will currently be added to the end of the entry file, but the exact
187
+ order may change due to nondeterminism.`.trim()
188
+ )
189
+ );
190
+ return Infinity;
191
+ }
192
+ return sortIndex;
193
+ });
194
+ const header = `@charset "UTF-8";
530
195
 
531
- // ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
532
- var StrokeStyleValues;
533
- (function(StrokeStyleValues2) {
534
- StrokeStyleValues2["SOLID"] = "solid";
535
- StrokeStyleValues2["DASHED"] = "dashed";
536
- StrokeStyleValues2["DOTTED"] = "dotted";
537
- StrokeStyleValues2["DOUBLE"] = "double";
538
- StrokeStyleValues2["GROOVE"] = "groove";
539
- StrokeStyleValues2["RIDGE"] = "ridge";
540
- StrokeStyleValues2["OUTSET"] = "outset";
541
- StrokeStyleValues2["INSET"] = "inset";
542
- })(StrokeStyleValues || (StrokeStyleValues = {}));
196
+ @layer ds.theme, ds.base, ds.utilities, ds.components;
543
197
 
544
- // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
545
- var BoxShadowValues;
546
- (function(BoxShadowValues2) {
547
- BoxShadowValues2["TYPE"] = "type";
548
- BoxShadowValues2["COLOR"] = "color";
549
- BoxShadowValues2["X"] = "x";
550
- BoxShadowValues2["Y"] = "y";
551
- BoxShadowValues2["BLUR"] = "blur";
552
- BoxShadowValues2["SPREAD"] = "spread";
553
- BoxShadowValues2["BLEND_MODE"] = "blendMode";
554
- })(BoxShadowValues || (BoxShadowValues = {}));
198
+ /*
199
+ ${fileHeader2}
200
+ */
555
201
 
556
- // ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
557
- var TypographyValues;
558
- (function(TypographyValues2) {
559
- TypographyValues2["FONT_FAMILY"] = "fontFamily";
560
- TypographyValues2["FONT_WEIGHT"] = "fontWeight";
561
- TypographyValues2["LINE_HEIGHT"] = "lineHeight";
562
- TypographyValues2["FONT_SIZE"] = "fontSize";
563
- TypographyValues2["LETTER_SPACING"] = "letterSpacing";
564
- TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
565
- TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
566
- TypographyValues2["TEXT_DECORATION"] = "textDecoration";
567
- TypographyValues2["TEXT_CASE"] = "textCase";
568
- })(TypographyValues || (TypographyValues = {}));
202
+ `;
203
+ const sortAlphabetically = R.sort(R.ascend((x) => x.destination || ""));
204
+ const pickOutputs = R.map(R.view(R.lensProp("output")));
205
+ const themeCSSFile = R.pipe(
206
+ sortAlphabetically,
207
+ sortByDefinedOrder,
208
+ pickOutputs,
209
+ R.join("\n"),
210
+ (content) => header + content
211
+ );
212
+ const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
213
+ destination: `${theme}.css`,
214
+ output: themeCSSFile(files)
215
+ }));
216
+ return themeCSSFiles;
217
+ };
569
218
 
570
219
  // src/tokens/process/platform.ts
571
- import chalk3 from "chalk";
572
- import * as R18 from "ramda";
220
+ import chalk4 from "chalk";
221
+ import * as R13 from "ramda";
573
222
  import StyleDictionary2 from "style-dictionary";
574
223
 
575
224
  // src/tokens/types.ts
@@ -580,34 +229,38 @@ var colorCategories = {
580
229
 
581
230
  // src/tokens/process/configs.ts
582
231
  import { register } from "@tokens-studio/sd-transforms";
583
- import * as R17 from "ramda";
232
+ import * as R12 from "ramda";
584
233
  import StyleDictionary from "style-dictionary";
585
234
 
586
235
  // src/tokens/utils.ts
587
- import * as R7 from "ramda";
588
- var mapToLowerCase = R7.map(R7.toLower);
589
- var hasAnyTruth = R7.any(R7.equals(true));
236
+ import * as R2 from "ramda";
237
+ var mapToLowerCase = R2.map(R2.toLower);
238
+ var hasAnyTruth = R2.any(R2.equals(true));
590
239
  var getType = (token) => (token.$type ?? token.type) || "";
591
240
  var getValue = (token) => token.$value ?? token.value;
592
- var typeEquals = R7.curry((types, token) => {
593
- if (R7.isNil(token)) {
594
- return false;
241
+ var typeEquals = R2.curry(
242
+ (types, token) => {
243
+ if (R2.isNil(token)) {
244
+ return false;
245
+ }
246
+ return R2.includes(R2.toLower(getType(token)), R2.map(R2.toLower, Array.isArray(types) ? types : [types]));
595
247
  }
596
- return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
597
- });
598
- var pathStartsWithOneOf = R7.curry((paths, token) => {
599
- if (R7.isNil(token)) {
600
- return false;
248
+ );
249
+ var pathStartsWithOneOf = R2.curry(
250
+ (paths, token) => {
251
+ if (R2.isNil(token)) {
252
+ return false;
253
+ }
254
+ const tokenPath = mapToLowerCase(token.path);
255
+ const matchPathsStartingWith = R2.map((path2) => R2.startsWith([path2], tokenPath), mapToLowerCase(paths));
256
+ return hasAnyTruth(matchPathsStartingWith);
601
257
  }
602
- const tokenPath = mapToLowerCase(token.path);
603
- const matchPathsStartingWith = R7.map((path2) => R7.startsWith([path2], tokenPath), mapToLowerCase(paths));
604
- return hasAnyTruth(matchPathsStartingWith);
605
- });
258
+ );
606
259
  function isSemanticToken(token) {
607
260
  return token.filePath.includes("semantic/");
608
261
  }
609
262
  function isSemanticColorToken(token, color) {
610
- return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
263
+ return token.filePath.includes("semantic/") && R2.startsWith(["color", color], token.path);
611
264
  }
612
265
  function isGlobalColorToken(token) {
613
266
  return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
@@ -616,7 +269,7 @@ function isColorCategoryToken(token, category) {
616
269
  if (!category) {
617
270
  return ["main", "support"].some((c) => isColorCategoryToken(token, c));
618
271
  }
619
- return R7.startsWith(["color", category], token.path);
272
+ return R2.startsWith(["color", category], token.path);
620
273
  }
621
274
  var isDigit = (s) => /^\d+$/.test(s);
622
275
  function traverseObj(obj, fn) {
@@ -632,7 +285,7 @@ function traverseObj(obj, fn) {
632
285
  return obj;
633
286
  }
634
287
  function inlineTokens(shouldInline, tokens) {
635
- const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
288
+ const [inlineableTokens, otherTokens] = R2.partition(shouldInline, tokens);
636
289
  return otherTokens.map((token) => {
637
290
  let transformed = getValue(token.original);
638
291
  for (const ref of inlineableTokens) {
@@ -641,16 +294,16 @@ function inlineTokens(shouldInline, tokens) {
641
294
  transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
642
295
  }
643
296
  }
644
- const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
297
+ const tokenWithInlinedRefs = R2.set(R2.lensPath(["original", "$value"]), transformed, token);
645
298
  return tokenWithInlinedRefs;
646
299
  });
647
300
  }
648
301
 
649
302
  // src/tokens/process/configs/color.ts
650
- import * as R12 from "ramda";
303
+ import * as R7 from "ramda";
651
304
 
652
305
  // src/tokens/process/formats/css/color.ts
653
- import * as R8 from "ramda";
306
+ import * as R3 from "ramda";
654
307
  import { createPropertyFormatter } from "style-dictionary/utils";
655
308
  var prefersColorScheme = (colorScheme2, content) => `
656
309
  @media (prefers-color-scheme: ${colorScheme2}) {
@@ -674,8 +327,8 @@ var colorScheme = {
674
327
  color-scheme: ${colorScheme_};
675
328
  ` : "";
676
329
  const filteredAllTokens = allTokens.filter(
677
- R8.allPass([
678
- R8.anyPass([
330
+ R3.allPass([
331
+ R3.anyPass([
679
332
  // Include semantic tokens in the output
680
333
  isSemanticToken,
681
334
  // Include global color tokens
@@ -691,7 +344,7 @@ ${formattedTokens}
691
344
  ${colorSchemeProperty}}
692
345
  `;
693
346
  const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
694
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
347
+ const body = R3.isNotNil(layer) ? `@layer ${layer} {
695
348
  ${selector} ${content} ${autoSelectorContent}
696
349
  }
697
350
  ` : `${selector} ${content} ${autoSelectorContent}
@@ -704,7 +357,7 @@ var colorCategory = {
704
357
  format: async ({ dictionary, file, options, platform }) => {
705
358
  const { outputReferences, usesDtcg } = options;
706
359
  const { selector, layer } = platform;
707
- const format = R8.compose(
360
+ const format = R3.compose(
708
361
  createPropertyFormatter({
709
362
  outputReferences,
710
363
  dictionary,
@@ -725,7 +378,7 @@ var colorCategory = {
725
378
  ${formattedTokens}
726
379
  }
727
380
  `;
728
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
381
+ const body = R3.isNotNil(layer) ? `@layer ${layer} {
729
382
  ${selector} ${content}
730
383
  }
731
384
  ` : `${selector} ${content}
@@ -735,12 +388,12 @@ ${selector} ${content}
735
388
  };
736
389
 
737
390
  // src/tokens/process/formats/css/semantic.ts
738
- import * as R9 from "ramda";
391
+ import * as R4 from "ramda";
739
392
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
740
393
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
741
394
  var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
742
395
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
743
- var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
396
+ var isInlineTokens = R4.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
744
397
  var overrideSizingFormula = (format, token) => {
745
398
  const [name, value] = format(token).split(":");
746
399
  const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
@@ -752,7 +405,7 @@ var overrideSizingFormula = (format, token) => {
752
405
  };
753
406
  };
754
407
  var formatSizingTokens = (format, tokens) => {
755
- const { round, calc } = R9.reduce(
408
+ const { round, calc } = R4.reduce(
756
409
  (acc, token) => {
757
410
  const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
758
411
  return {
@@ -782,17 +435,17 @@ var semantic = {
782
435
  usesDtcg
783
436
  });
784
437
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
785
- const filteredTokens = R9.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
786
- const [sizingTokens, restTokens] = R9.partition(
438
+ const filteredTokens = R4.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
439
+ const [sizingTokens, restTokens] = R4.partition(
787
440
  (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
788
441
  filteredTokens
789
442
  );
790
- const formattedTokens = [R9.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
443
+ const formattedTokens = [R4.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
791
444
  const content = `{
792
445
  ${formattedTokens.join("\n")}
793
446
  }
794
447
  `;
795
- const body = R9.isNotNil(layer) ? `@layer ${layer} {
448
+ const body = R4.isNotNil(layer) ? `@layer ${layer} {
796
449
  ${selector} ${content}
797
450
  }
798
451
  ` : `${selector} ${content}
@@ -802,11 +455,11 @@ ${selector} ${content}
802
455
  };
803
456
 
804
457
  // src/tokens/process/formats/css/typography.ts
805
- import * as R10 from "ramda";
458
+ import * as R5 from "ramda";
806
459
  import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
807
- var typographyFontFamilyPredicate = R10.allPass([
808
- R10.pathSatisfies(R10.includes("typography"), ["path"]),
809
- R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
460
+ var typographyFontFamilyPredicate = R5.allPass([
461
+ R5.pathSatisfies(R5.includes("typography"), ["path"]),
462
+ R5.pathSatisfies(R5.includes("fontFamily"), ["path"])
810
463
  ]);
811
464
  var typography = {
812
465
  name: "ds/css-typography",
@@ -819,12 +472,12 @@ var typography = {
819
472
  format: "css",
820
473
  usesDtcg
821
474
  });
822
- const filteredTokens = R10.reject(typographyFontFamilyPredicate, dictionary.allTokens);
823
- const formattedTokens = R10.pipe(R10.map(format), R10.join("\n"))(filteredTokens);
475
+ const filteredTokens = R5.reject(typographyFontFamilyPredicate, dictionary.allTokens);
476
+ const formattedTokens = R5.pipe(R5.map(format), R5.join("\n"))(filteredTokens);
824
477
  const content = selector ? `${selector} {
825
478
  ${formattedTokens}
826
479
  }` : formattedTokens;
827
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
480
+ const body = R5.isNotNil(layer) ? `@layer ${layer} {
828
481
  ${content}
829
482
  }` : content;
830
483
  return body;
@@ -841,8 +494,8 @@ var formats = {
841
494
 
842
495
  // src/tokens/process/transformers.ts
843
496
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
844
- import * as R11 from "ramda";
845
- var isPx = R11.test(/\b\d+px\b/g);
497
+ import * as R6 from "ramda";
498
+ var isPx = R6.test(/\b\d+px\b/g);
846
499
  var sizeRem = {
847
500
  name: "ds/size/toRem",
848
501
  type: "value",
@@ -932,7 +585,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
932
585
  {
933
586
  destination: `color-scheme/${colorScheme2}.css`,
934
587
  format: formats.colorScheme.name,
935
- filter: (token) => typeEquals("color", token) && !R12.startsWith(["global"], token.path)
588
+ filter: (token) => typeEquals("color", token) && !R7.startsWith(["global"], token.path)
936
589
  }
937
590
  ],
938
591
  options: {
@@ -983,7 +636,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
983
636
  };
984
637
 
985
638
  // src/tokens/process/configs/semantic.ts
986
- import * as R13 from "ramda";
639
+ import * as R8 from "ramda";
987
640
  import { outputReferencesFilter } from "style-dictionary/utils";
988
641
  var semanticVariables = ({ theme }) => {
989
642
  const selector = `:root`;
@@ -1006,8 +659,8 @@ var semanticVariables = ({ theme }) => {
1006
659
  destination: `semantic.css`,
1007
660
  format: formats.semantic.name,
1008
661
  filter: (token) => {
1009
- const isUwantedToken = R13.anyPass([R13.includes("primitives/global")])(token.filePath);
1010
- const isPrivateToken = R13.includes("_", token.path);
662
+ const isUwantedToken = R8.anyPass([R8.includes("primitives/global")])(token.filePath);
663
+ const isPrivateToken = R8.includes("_", token.path);
1011
664
  const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
1012
665
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
1013
666
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
@@ -1028,20 +681,20 @@ var semanticVariables = ({ theme }) => {
1028
681
  };
1029
682
 
1030
683
  // src/tokens/process/configs/storefront.ts
1031
- import * as R15 from "ramda";
684
+ import * as R10 from "ramda";
1032
685
  import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
1033
686
 
1034
687
  // src/tokens/process/formats/js-tokens.ts
1035
- import * as R14 from "ramda";
688
+ import * as R9 from "ramda";
1036
689
  import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
1037
- var groupByType = R14.groupBy((token) => getType(token));
1038
- var removeUnwatedTokens = R14.pipe(
1039
- R14.reject((token) => isColorCategoryToken(token)),
1040
- R14.reject((token) => R14.any((path2) => path2.startsWith("_"))(token.path))
690
+ var groupByType = R9.groupBy((token) => getType(token));
691
+ var removeUnwatedTokens = R9.pipe(
692
+ R9.reject((token) => isColorCategoryToken(token)),
693
+ R9.reject((token) => R9.any((path2) => path2.startsWith("_"))(token.path))
1041
694
  );
1042
- var dissocExtensions = R14.pipe(R14.dissoc("$extensions"), R14.dissocPath(["original", "$extensions"]));
1043
- var removeUnwatedProps = R14.map((token) => dissocExtensions(token));
1044
- var toCssVarName = R14.pipe(R14.split(":"), R14.head, R14.trim);
695
+ var dissocExtensions = R9.pipe(R9.dissoc("$extensions"), R9.dissocPath(["original", "$extensions"]));
696
+ var removeUnwatedProps = R9.map((token) => dissocExtensions(token));
697
+ var toCssVarName = R9.pipe(R9.split(":"), R9.head, R9.trim);
1045
698
  var jsTokens = {
1046
699
  name: "ds/js-tokens",
1047
700
  format: async ({ dictionary, file, options }) => {
@@ -1052,7 +705,7 @@ var jsTokens = {
1052
705
  format: "css",
1053
706
  usesDtcg
1054
707
  });
1055
- const formatTokens = R14.map((token) => {
708
+ const formatTokens = R9.map((token) => {
1056
709
  if (pathStartsWithOneOf(["size", "_size"], token)) {
1057
710
  const { calc, name } = overrideSizingFormula(format, token);
1058
711
  return {
@@ -1066,7 +719,7 @@ var jsTokens = {
1066
719
  name: toCssVarName(format(token))
1067
720
  };
1068
721
  });
1069
- const processTokens = R14.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
722
+ const processTokens = R9.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
1070
723
  const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
1071
724
  const content = Object.entries(tokens).map(
1072
725
  ([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
@@ -1091,9 +744,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
1091
744
  destination: `${colorScheme2}.ts`,
1092
745
  format: jsTokens.name,
1093
746
  filter: (token) => {
1094
- if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R15.includes("semantic", token.filePath))
747
+ if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R10.includes("semantic", token.filePath))
1095
748
  return false;
1096
- const isSemanticColor = R15.includes("semantic", token.filePath) && typeEquals(["color"], token);
749
+ const isSemanticColor = R10.includes("semantic", token.filePath) && typeEquals(["color"], token);
1097
750
  const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
1098
751
  return isSemanticColor || wantedTypes;
1099
752
  }
@@ -1158,20 +811,183 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
1158
811
  };
1159
812
  };
1160
813
 
814
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
815
+ var BoxShadowTypes;
816
+ (function(BoxShadowTypes2) {
817
+ BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
818
+ BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
819
+ })(BoxShadowTypes || (BoxShadowTypes = {}));
820
+
821
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
822
+ var ColorModifierTypes;
823
+ (function(ColorModifierTypes2) {
824
+ ColorModifierTypes2["LIGHTEN"] = "lighten";
825
+ ColorModifierTypes2["DARKEN"] = "darken";
826
+ ColorModifierTypes2["MIX"] = "mix";
827
+ ColorModifierTypes2["ALPHA"] = "alpha";
828
+ })(ColorModifierTypes || (ColorModifierTypes = {}));
829
+
830
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
831
+ var ColorSpaceTypes;
832
+ (function(ColorSpaceTypes2) {
833
+ ColorSpaceTypes2["LCH"] = "lch";
834
+ ColorSpaceTypes2["SRGB"] = "srgb";
835
+ ColorSpaceTypes2["P3"] = "p3";
836
+ ColorSpaceTypes2["HSL"] = "hsl";
837
+ })(ColorSpaceTypes || (ColorSpaceTypes = {}));
838
+
839
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
840
+ var Properties;
841
+ (function(Properties2) {
842
+ Properties2["sizing"] = "sizing";
843
+ Properties2["height"] = "height";
844
+ Properties2["width"] = "width";
845
+ Properties2["spacing"] = "spacing";
846
+ Properties2["verticalPadding"] = "verticalPadding";
847
+ Properties2["horizontalPadding"] = "horizontalPadding";
848
+ Properties2["paddingTop"] = "paddingTop";
849
+ Properties2["paddingRight"] = "paddingRight";
850
+ Properties2["paddingBottom"] = "paddingBottom";
851
+ Properties2["paddingLeft"] = "paddingLeft";
852
+ Properties2["itemSpacing"] = "itemSpacing";
853
+ Properties2["fill"] = "fill";
854
+ Properties2["backgroundBlur"] = "backgroundBlur";
855
+ Properties2["border"] = "border";
856
+ Properties2["borderTop"] = "borderTop";
857
+ Properties2["borderRight"] = "borderRight";
858
+ Properties2["borderBottom"] = "borderBottom";
859
+ Properties2["borderLeft"] = "borderLeft";
860
+ Properties2["borderColor"] = "borderColor";
861
+ Properties2["borderRadius"] = "borderRadius";
862
+ Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
863
+ Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
864
+ Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
865
+ Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
866
+ Properties2["borderWidth"] = "borderWidth";
867
+ Properties2["borderWidthTop"] = "borderWidthTop";
868
+ Properties2["borderWidthRight"] = "borderWidthRight";
869
+ Properties2["borderWidthBottom"] = "borderWidthBottom";
870
+ Properties2["borderWidthLeft"] = "borderWidthLeft";
871
+ Properties2["boxShadow"] = "boxShadow";
872
+ Properties2["opacity"] = "opacity";
873
+ Properties2["fontFamilies"] = "fontFamilies";
874
+ Properties2["fontWeights"] = "fontWeights";
875
+ Properties2["fontSizes"] = "fontSizes";
876
+ Properties2["lineHeights"] = "lineHeights";
877
+ Properties2["typography"] = "typography";
878
+ Properties2["composition"] = "composition";
879
+ Properties2["letterSpacing"] = "letterSpacing";
880
+ Properties2["paragraphSpacing"] = "paragraphSpacing";
881
+ Properties2["textCase"] = "textCase";
882
+ Properties2["dimension"] = "dimension";
883
+ Properties2["textDecoration"] = "textDecoration";
884
+ Properties2["asset"] = "asset";
885
+ Properties2["tokenValue"] = "tokenValue";
886
+ Properties2["value"] = "value";
887
+ Properties2["tokenName"] = "tokenName";
888
+ Properties2["description"] = "description";
889
+ })(Properties || (Properties = {}));
890
+
891
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
892
+ var TokenSetStatus;
893
+ (function(TokenSetStatus2) {
894
+ TokenSetStatus2["DISABLED"] = "disabled";
895
+ TokenSetStatus2["SOURCE"] = "source";
896
+ TokenSetStatus2["ENABLED"] = "enabled";
897
+ })(TokenSetStatus || (TokenSetStatus = {}));
898
+
899
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
900
+ var TokenTypes;
901
+ (function(TokenTypes2) {
902
+ TokenTypes2["OTHER"] = "other";
903
+ TokenTypes2["COLOR"] = "color";
904
+ TokenTypes2["BORDER_RADIUS"] = "borderRadius";
905
+ TokenTypes2["SIZING"] = "sizing";
906
+ TokenTypes2["SPACING"] = "spacing";
907
+ TokenTypes2["TEXT"] = "text";
908
+ TokenTypes2["TYPOGRAPHY"] = "typography";
909
+ TokenTypes2["OPACITY"] = "opacity";
910
+ TokenTypes2["BORDER_WIDTH"] = "borderWidth";
911
+ TokenTypes2["STROKE_STYLE"] = "strokeStyle";
912
+ TokenTypes2["BOX_SHADOW"] = "boxShadow";
913
+ TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
914
+ TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
915
+ TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
916
+ TokenTypes2["FONT_SIZES"] = "fontSizes";
917
+ TokenTypes2["LETTER_SPACING"] = "letterSpacing";
918
+ TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
919
+ TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
920
+ TokenTypes2["TEXT_DECORATION"] = "textDecoration";
921
+ TokenTypes2["TEXT_CASE"] = "textCase";
922
+ TokenTypes2["COMPOSITION"] = "composition";
923
+ TokenTypes2["DIMENSION"] = "dimension";
924
+ TokenTypes2["BORDER"] = "border";
925
+ TokenTypes2["ASSET"] = "asset";
926
+ TokenTypes2["BOOLEAN"] = "boolean";
927
+ TokenTypes2["NUMBER"] = "number";
928
+ })(TokenTypes || (TokenTypes = {}));
929
+
930
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
931
+ var BorderValues;
932
+ (function(BorderValues2) {
933
+ BorderValues2["BORDER_COLOR"] = "color";
934
+ BorderValues2["BORDER_WIDTH"] = "width";
935
+ BorderValues2["BORDER_STYLE"] = "style";
936
+ })(BorderValues || (BorderValues = {}));
937
+
938
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
939
+ var StrokeStyleValues;
940
+ (function(StrokeStyleValues2) {
941
+ StrokeStyleValues2["SOLID"] = "solid";
942
+ StrokeStyleValues2["DASHED"] = "dashed";
943
+ StrokeStyleValues2["DOTTED"] = "dotted";
944
+ StrokeStyleValues2["DOUBLE"] = "double";
945
+ StrokeStyleValues2["GROOVE"] = "groove";
946
+ StrokeStyleValues2["RIDGE"] = "ridge";
947
+ StrokeStyleValues2["OUTSET"] = "outset";
948
+ StrokeStyleValues2["INSET"] = "inset";
949
+ })(StrokeStyleValues || (StrokeStyleValues = {}));
950
+
951
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
952
+ var BoxShadowValues;
953
+ (function(BoxShadowValues2) {
954
+ BoxShadowValues2["TYPE"] = "type";
955
+ BoxShadowValues2["COLOR"] = "color";
956
+ BoxShadowValues2["X"] = "x";
957
+ BoxShadowValues2["Y"] = "y";
958
+ BoxShadowValues2["BLUR"] = "blur";
959
+ BoxShadowValues2["SPREAD"] = "spread";
960
+ BoxShadowValues2["BLEND_MODE"] = "blendMode";
961
+ })(BoxShadowValues || (BoxShadowValues = {}));
962
+
963
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
964
+ var TypographyValues;
965
+ (function(TypographyValues2) {
966
+ TypographyValues2["FONT_FAMILY"] = "fontFamily";
967
+ TypographyValues2["FONT_WEIGHT"] = "fontWeight";
968
+ TypographyValues2["LINE_HEIGHT"] = "lineHeight";
969
+ TypographyValues2["FONT_SIZE"] = "fontSize";
970
+ TypographyValues2["LETTER_SPACING"] = "letterSpacing";
971
+ TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
972
+ TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
973
+ TypographyValues2["TEXT_DECORATION"] = "textDecoration";
974
+ TypographyValues2["TEXT_CASE"] = "textCase";
975
+ })(TypographyValues || (TypographyValues = {}));
976
+
1161
977
  // src/tokens/process/utils/getMultidimensionalThemes.ts
1162
- import chalk2 from "chalk";
978
+ import chalk3 from "chalk";
1163
979
  import { kebabCase } from "change-case";
1164
- import * as R16 from "ramda";
980
+ import * as R11 from "ramda";
1165
981
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
1166
982
  const verboseLogging = buildOptions?.verbose;
1167
983
  const grouped$themes = groupThemes(processed$themes);
1168
984
  const permutations = permutateThemes(grouped$themes);
1169
985
  const ALL_DEPENDENT_ON = ["theme"];
1170
- const keys2 = R16.keys(grouped$themes);
986
+ const keys2 = R11.keys(grouped$themes);
1171
987
  const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
1172
988
  if (verboseLogging) {
1173
- console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
1174
- console.log(chalk2.cyan(` (ignoring permutations for ${nonDependentKeys})`));
989
+ console.log(chalk3.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
990
+ console.log(chalk3.cyan(` (ignoring permutations for ${nonDependentKeys})`));
1175
991
  }
1176
992
  return permutations.filter((val) => {
1177
993
  const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
@@ -1208,7 +1024,7 @@ function groupThemes(themes) {
1208
1024
  }
1209
1025
  return groups;
1210
1026
  }
1211
- var hasUnknownProps = R16.pipe(R16.values, R16.none(R16.equals("unknown")), R16.not);
1027
+ var hasUnknownProps = R11.pipe(R11.values, R11.none(R11.equals("unknown")), R11.not);
1212
1028
  function permutateThemes(groups) {
1213
1029
  const separator = "_";
1214
1030
  const permutations = cartesian(Object.values(groups));
@@ -1218,8 +1034,8 @@ function permutateThemes(groups) {
1218
1034
  const { group, name, selectedTokenSets } = theme;
1219
1035
  let updatedPermutation = acc.permutation;
1220
1036
  if (group) {
1221
- const groupProp = R16.lensProp(group);
1222
- updatedPermutation = R16.set(groupProp, name, updatedPermutation);
1037
+ const groupProp = R11.lensProp(group);
1038
+ updatedPermutation = R11.set(groupProp, name, updatedPermutation);
1223
1039
  }
1224
1040
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
1225
1041
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -1303,7 +1119,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
1303
1119
  obj.filePath = tokenSet;
1304
1120
  }
1305
1121
  });
1306
- tokenSource.tokens = R17.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
1122
+ tokenSource.tokens = R12.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
1307
1123
  }
1308
1124
  }
1309
1125
  } else {
@@ -1390,19 +1206,19 @@ var buildConfigs = {
1390
1206
  // },
1391
1207
  };
1392
1208
  async function processPlatform(options) {
1393
- const { dry, process, $themes } = options;
1209
+ const { process, $themes } = options;
1394
1210
  const platform = "css";
1395
1211
  const tokenSets = process === "format" ? options.tokenSets : void 0;
1396
1212
  const tokensDir = process === "build" ? options.tokensDir : void 0;
1397
1213
  buildOptions = options;
1398
- const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
1214
+ const processed$themes = $themes.map(processThemeObject).filter((theme) => R13.not(theme.group === "size" && theme.name !== "medium"));
1399
1215
  const customColors = getCustomColors(processed$themes);
1400
1216
  if (!buildOptions.rootColor) {
1401
- const firstMainColor = R18.head(customColors);
1217
+ const firstMainColor = R13.head(customColors);
1402
1218
  buildOptions.rootColor = firstMainColor;
1403
- console.log(`Using first main color; ${chalk3.blue(firstMainColor)}, as ${chalk3.green(`":root"`)} color`);
1219
+ console.log(`Using first main color; ${chalk4.blue(firstMainColor)}, as ${chalk4.green(`":root"`)} color`);
1404
1220
  }
1405
- const buildAndSdConfigs = R18.map((buildConfig) => {
1221
+ const buildAndSdConfigs = R13.map((buildConfig) => {
1406
1222
  const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
1407
1223
  tokensDir,
1408
1224
  tokenSets
@@ -1434,19 +1250,19 @@ async function processPlatform(options) {
1434
1250
  types: [initResult]
1435
1251
  };
1436
1252
  try {
1437
- for (const [buildName, { buildConfig, sdConfigs }] of R18.toPairs(buildAndSdConfigs)) {
1253
+ for (const [buildName, { buildConfig, sdConfigs }] of R13.toPairs(buildAndSdConfigs)) {
1438
1254
  if (!(buildConfig.enabled?.() ?? true)) {
1439
1255
  continue;
1440
1256
  }
1441
1257
  if (sdConfigs.length > 0) {
1442
1258
  console.log(`
1443
- \u{1F371} Building ${chalk3.green(buildConfig.name ?? buildName)}`);
1259
+ \u{1F371} Building ${chalk4.green(buildConfig.name ?? buildName)}`);
1444
1260
  const results = await Promise.all(
1445
1261
  sdConfigs.map(async (sdConfig) => {
1446
1262
  const { config, permutation } = sdConfig;
1447
1263
  const modes = ["theme", ...buildConfig.dimensions];
1448
1264
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
1449
- const logMessage = R18.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1265
+ const logMessage = R13.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1450
1266
  console.log(logMessage);
1451
1267
  const sdOptions = { cache: true };
1452
1268
  const sdExtended = await sd.extend(config);
@@ -1478,7 +1294,7 @@ async function processPlatform(options) {
1478
1294
  }
1479
1295
  async function createColorTypeDeclaration(colors) {
1480
1296
  console.log(`
1481
- \u{1F371} Building ${chalk3.green("type declarations")}`);
1297
+ \u{1F371} Building ${chalk4.green("type declarations")}`);
1482
1298
  const typeDeclaration = `
1483
1299
  import type {} from '@digdir/designsystemet-react/colors';
1484
1300
 
@@ -1491,70 +1307,6 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
1491
1307
  return typeDeclaration;
1492
1308
  }
1493
1309
 
1494
- // src/tokens/format.ts
1495
- var createThemeCSSFiles = (processedBuilds) => {
1496
- const groupedByTheme = {};
1497
- for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
1498
- for (const buildResult of buildResults) {
1499
- const previous = groupedByTheme[buildResult.permutation.theme] ?? [];
1500
- groupedByTheme[buildResult.permutation.theme] = R19.concat(previous, buildResult.formatted);
1501
- }
1502
- }
1503
- const sortOrder = [
1504
- "color-scheme/light",
1505
- "typography/secondary",
1506
- "semantic",
1507
- "color-scheme/dark",
1508
- "color-scheme/contrast",
1509
- "typography/primary",
1510
- "color/"
1511
- ];
1512
- const sortByDefinedOrder = R19.sortBy((file) => {
1513
- const filePath = file.destination || "";
1514
- const sortIndex = sortOrder.findIndex((sortElement) => {
1515
- if (sortElement.endsWith("/")) {
1516
- return filePath.includes(sortElement);
1517
- }
1518
- return filePath.includes(`${sortElement}.css`);
1519
- });
1520
- if (sortIndex === -1) {
1521
- console.error(
1522
- chalk4.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
1523
- );
1524
- console.log(
1525
- chalk4.dim(
1526
- `
1527
- The section will currently be added to the end of the entry file, but the exact
1528
- order may change due to nondeterminism.`.trim()
1529
- )
1530
- );
1531
- return Infinity;
1532
- }
1533
- return sortIndex;
1534
- });
1535
- const header = `@charset "UTF-8";
1536
-
1537
- @layer ds.theme, ds.base, ds.utilities, ds.components;
1538
-
1539
- /* This file is generated by ${package_default.name}@${package_default.version} */
1540
-
1541
- `;
1542
- const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
1543
- const pickOutputs = R19.map(R19.view(R19.lensProp("output")));
1544
- const themeCSSFile = R19.pipe(
1545
- sortAlphabetically,
1546
- sortByDefinedOrder,
1547
- pickOutputs,
1548
- R19.join("\n"),
1549
- (content) => header + content
1550
- );
1551
- const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
1552
- destination: `${theme}.css`,
1553
- output: themeCSSFile(files)
1554
- }));
1555
- return themeCSSFiles;
1556
- };
1557
-
1558
1310
  // src/tokens/build.ts
1559
1311
  async function write(files, outDir, dry) {
1560
1312
  for (const { destination, output } of files) {
@@ -1571,6 +1323,12 @@ var buildTokens = async (options) => {
1571
1323
  const outDir = path.resolve(options.outDir);
1572
1324
  const tokensDir = path.resolve(options.tokensDir);
1573
1325
  const $themes = JSON.parse(await readFile(`${tokensDir}/$themes.json`));
1326
+ let $designsystemet;
1327
+ try {
1328
+ const $designsystemetContent = await readFile(`${tokensDir}/$designsystemet.json`);
1329
+ $designsystemet = JSON.parse($designsystemetContent);
1330
+ } catch (error) {
1331
+ }
1574
1332
  console.log(`
1575
1333
  \u{1F3D7}\uFE0F Start building tokens in ${chalk5.green(tokensDir)}`);
1576
1334
  const processedBuilds = await processPlatform({
@@ -1588,7 +1346,12 @@ var buildTokens = async (options) => {
1588
1346
  for (const { formatted } of processedBuilds.types) {
1589
1347
  await write(formatted, outDir, options.dry);
1590
1348
  }
1591
- await write(createThemeCSSFiles(processedBuilds), outDir, options.dry);
1349
+ const fileHeader2 = R14.join("")([
1350
+ defaultFileHeader,
1351
+ $designsystemet ? `
1352
+ design-tokens: v${$designsystemet.version} ` : ""
1353
+ ]);
1354
+ await write(createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 }), outDir, options.dry);
1592
1355
  console.log(`
1593
1356
  \u2705 Finished building tokens!`);
1594
1357
  return processedBuilds;