@digdir/designsystemet 1.0.4 → 1.0.5

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.
@@ -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,14 +45,14 @@ 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.5",
55
56
  description: "CLI for Designsystemet",
56
57
  author: "Designsystemet team",
57
58
  engines: {
@@ -91,11 +92,12 @@ var package_default = {
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",
95
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
96
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
97
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
98
+ "test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
97
99
  "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",
100
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
99
101
  test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
100
102
  "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
101
103
  "update:template": "tsx ./src/scripts/update-template.ts",
@@ -138,438 +140,83 @@ var package_default = {
138
140
  }
139
141
  };
140
142
 
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
143
+ // src/tokens/process/theme.ts
144
+ var defaultFileHeader = `build: v${package_default.version}`;
145
+ var createThemeCSSFiles = ({
146
+ processedBuilds,
147
+ fileHeader: fileHeader2 = defaultFileHeader
148
+ }) => {
149
+ const groupedByTheme = {};
150
+ for (const [_, buildResults] of Object.entries(R.dissoc("types", processedBuilds))) {
151
+ for (const buildResult of buildResults) {
152
+ const themeName = buildResult.permutation.theme;
153
+ const newOutputs = buildResult.formatted;
154
+ if (R.isNotEmpty(newOutputs)) {
155
+ const currentOutputs = groupedByTheme[themeName] ?? [];
156
+ groupedByTheme[themeName] = R.concat(currentOutputs, newOutputs);
157
+ }
396
158
  }
397
159
  }
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 = {}));
160
+ const sortOrder = [
161
+ "color-scheme/light",
162
+ "typography/secondary",
163
+ "semantic",
164
+ "color-scheme/dark",
165
+ "color-scheme/contrast",
166
+ "typography/primary",
167
+ "color/"
168
+ ];
169
+ const sortByDefinedOrder = R.sortBy((file) => {
170
+ const filePath = file.destination || "";
171
+ const sortIndex = sortOrder.findIndex((sortElement) => {
172
+ if (sortElement.endsWith("/")) {
173
+ return filePath.includes(sortElement);
174
+ }
175
+ return filePath.includes(`${sortElement}.css`);
176
+ });
177
+ if (sortIndex === -1) {
178
+ console.error(
179
+ chalk2.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
180
+ );
181
+ console.log(
182
+ chalk2.dim(
183
+ `
184
+ The section will currently be added to the end of the entry file, but the exact
185
+ order may change due to nondeterminism.`.trim()
186
+ )
187
+ );
188
+ return Infinity;
189
+ }
190
+ return sortIndex;
191
+ });
192
+ const header = `@charset "UTF-8";
530
193
 
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 = {}));
194
+ @layer ds.theme, ds.base, ds.utilities, ds.components;
543
195
 
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 = {}));
196
+ /*
197
+ ${fileHeader2}
198
+ */
555
199
 
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 = {}));
200
+ `;
201
+ const sortAlphabetically = R.sort(R.ascend((x) => x.destination || ""));
202
+ const pickOutputs = R.map(R.view(R.lensProp("output")));
203
+ const themeCSSFile = R.pipe(
204
+ sortAlphabetically,
205
+ sortByDefinedOrder,
206
+ pickOutputs,
207
+ R.join("\n"),
208
+ (content) => header + content
209
+ );
210
+ const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
211
+ destination: `${theme}.css`,
212
+ output: themeCSSFile(files)
213
+ }));
214
+ return themeCSSFiles;
215
+ };
569
216
 
570
217
  // src/tokens/process/platform.ts
571
- import chalk3 from "chalk";
572
- import * as R18 from "ramda";
218
+ import chalk4 from "chalk";
219
+ import * as R13 from "ramda";
573
220
  import StyleDictionary2 from "style-dictionary";
574
221
 
575
222
  // src/tokens/types.ts
@@ -580,34 +227,34 @@ var colorCategories = {
580
227
 
581
228
  // src/tokens/process/configs.ts
582
229
  import { register } from "@tokens-studio/sd-transforms";
583
- import * as R17 from "ramda";
230
+ import * as R12 from "ramda";
584
231
  import StyleDictionary from "style-dictionary";
585
232
 
586
233
  // 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));
234
+ import * as R2 from "ramda";
235
+ var mapToLowerCase = R2.map(R2.toLower);
236
+ var hasAnyTruth = R2.any(R2.equals(true));
590
237
  var getType = (token) => (token.$type ?? token.type) || "";
591
238
  var getValue = (token) => token.$value ?? token.value;
592
- var typeEquals = R7.curry((types, token) => {
593
- if (R7.isNil(token)) {
239
+ var typeEquals = R2.curry((types, token) => {
240
+ if (R2.isNil(token)) {
594
241
  return false;
595
242
  }
596
- return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
243
+ return R2.includes(R2.toLower(getType(token)), R2.map(R2.toLower, Array.isArray(types) ? types : [types]));
597
244
  });
598
- var pathStartsWithOneOf = R7.curry((paths, token) => {
599
- if (R7.isNil(token)) {
245
+ var pathStartsWithOneOf = R2.curry((paths, token) => {
246
+ if (R2.isNil(token)) {
600
247
  return false;
601
248
  }
602
249
  const tokenPath = mapToLowerCase(token.path);
603
- const matchPathsStartingWith = R7.map((path2) => R7.startsWith([path2], tokenPath), mapToLowerCase(paths));
250
+ const matchPathsStartingWith = R2.map((path2) => R2.startsWith([path2], tokenPath), mapToLowerCase(paths));
604
251
  return hasAnyTruth(matchPathsStartingWith);
605
252
  });
606
253
  function isSemanticToken(token) {
607
254
  return token.filePath.includes("semantic/");
608
255
  }
609
256
  function isSemanticColorToken(token, color) {
610
- return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
257
+ return token.filePath.includes("semantic/") && R2.startsWith(["color", color], token.path);
611
258
  }
612
259
  function isGlobalColorToken(token) {
613
260
  return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
@@ -616,7 +263,7 @@ function isColorCategoryToken(token, category) {
616
263
  if (!category) {
617
264
  return ["main", "support"].some((c) => isColorCategoryToken(token, c));
618
265
  }
619
- return R7.startsWith(["color", category], token.path);
266
+ return R2.startsWith(["color", category], token.path);
620
267
  }
621
268
  var isDigit = (s) => /^\d+$/.test(s);
622
269
  function traverseObj(obj, fn) {
@@ -632,7 +279,7 @@ function traverseObj(obj, fn) {
632
279
  return obj;
633
280
  }
634
281
  function inlineTokens(shouldInline, tokens) {
635
- const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
282
+ const [inlineableTokens, otherTokens] = R2.partition(shouldInline, tokens);
636
283
  return otherTokens.map((token) => {
637
284
  let transformed = getValue(token.original);
638
285
  for (const ref of inlineableTokens) {
@@ -641,16 +288,16 @@ function inlineTokens(shouldInline, tokens) {
641
288
  transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
642
289
  }
643
290
  }
644
- const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
291
+ const tokenWithInlinedRefs = R2.set(R2.lensPath(["original", "$value"]), transformed, token);
645
292
  return tokenWithInlinedRefs;
646
293
  });
647
294
  }
648
295
 
649
296
  // src/tokens/process/configs/color.ts
650
- import * as R12 from "ramda";
297
+ import * as R7 from "ramda";
651
298
 
652
299
  // src/tokens/process/formats/css/color.ts
653
- import * as R8 from "ramda";
300
+ import * as R3 from "ramda";
654
301
  import { createPropertyFormatter } from "style-dictionary/utils";
655
302
  var prefersColorScheme = (colorScheme2, content) => `
656
303
  @media (prefers-color-scheme: ${colorScheme2}) {
@@ -674,8 +321,8 @@ var colorScheme = {
674
321
  color-scheme: ${colorScheme_};
675
322
  ` : "";
676
323
  const filteredAllTokens = allTokens.filter(
677
- R8.allPass([
678
- R8.anyPass([
324
+ R3.allPass([
325
+ R3.anyPass([
679
326
  // Include semantic tokens in the output
680
327
  isSemanticToken,
681
328
  // Include global color tokens
@@ -691,7 +338,7 @@ ${formattedTokens}
691
338
  ${colorSchemeProperty}}
692
339
  `;
693
340
  const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
694
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
341
+ const body = R3.isNotNil(layer) ? `@layer ${layer} {
695
342
  ${selector} ${content} ${autoSelectorContent}
696
343
  }
697
344
  ` : `${selector} ${content} ${autoSelectorContent}
@@ -704,7 +351,7 @@ var colorCategory = {
704
351
  format: async ({ dictionary, file, options, platform }) => {
705
352
  const { outputReferences, usesDtcg } = options;
706
353
  const { selector, layer } = platform;
707
- const format = R8.compose(
354
+ const format = R3.compose(
708
355
  createPropertyFormatter({
709
356
  outputReferences,
710
357
  dictionary,
@@ -725,7 +372,7 @@ var colorCategory = {
725
372
  ${formattedTokens}
726
373
  }
727
374
  `;
728
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
375
+ const body = R3.isNotNil(layer) ? `@layer ${layer} {
729
376
  ${selector} ${content}
730
377
  }
731
378
  ` : `${selector} ${content}
@@ -735,12 +382,12 @@ ${selector} ${content}
735
382
  };
736
383
 
737
384
  // src/tokens/process/formats/css/semantic.ts
738
- import * as R9 from "ramda";
385
+ import * as R4 from "ramda";
739
386
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
740
387
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
741
388
  var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
742
389
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
743
- var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
390
+ var isInlineTokens = R4.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
744
391
  var overrideSizingFormula = (format, token) => {
745
392
  const [name, value] = format(token).split(":");
746
393
  const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
@@ -752,7 +399,7 @@ var overrideSizingFormula = (format, token) => {
752
399
  };
753
400
  };
754
401
  var formatSizingTokens = (format, tokens) => {
755
- const { round, calc } = R9.reduce(
402
+ const { round, calc } = R4.reduce(
756
403
  (acc, token) => {
757
404
  const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
758
405
  return {
@@ -782,17 +429,17 @@ var semantic = {
782
429
  usesDtcg
783
430
  });
784
431
  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(
432
+ const filteredTokens = R4.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
433
+ const [sizingTokens, restTokens] = R4.partition(
787
434
  (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
788
435
  filteredTokens
789
436
  );
790
- const formattedTokens = [R9.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
437
+ const formattedTokens = [R4.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
791
438
  const content = `{
792
439
  ${formattedTokens.join("\n")}
793
440
  }
794
441
  `;
795
- const body = R9.isNotNil(layer) ? `@layer ${layer} {
442
+ const body = R4.isNotNil(layer) ? `@layer ${layer} {
796
443
  ${selector} ${content}
797
444
  }
798
445
  ` : `${selector} ${content}
@@ -802,11 +449,11 @@ ${selector} ${content}
802
449
  };
803
450
 
804
451
  // src/tokens/process/formats/css/typography.ts
805
- import * as R10 from "ramda";
452
+ import * as R5 from "ramda";
806
453
  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"])
454
+ var typographyFontFamilyPredicate = R5.allPass([
455
+ R5.pathSatisfies(R5.includes("typography"), ["path"]),
456
+ R5.pathSatisfies(R5.includes("fontFamily"), ["path"])
810
457
  ]);
811
458
  var typography = {
812
459
  name: "ds/css-typography",
@@ -819,12 +466,12 @@ var typography = {
819
466
  format: "css",
820
467
  usesDtcg
821
468
  });
822
- const filteredTokens = R10.reject(typographyFontFamilyPredicate, dictionary.allTokens);
823
- const formattedTokens = R10.pipe(R10.map(format), R10.join("\n"))(filteredTokens);
469
+ const filteredTokens = R5.reject(typographyFontFamilyPredicate, dictionary.allTokens);
470
+ const formattedTokens = R5.pipe(R5.map(format), R5.join("\n"))(filteredTokens);
824
471
  const content = selector ? `${selector} {
825
472
  ${formattedTokens}
826
473
  }` : formattedTokens;
827
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
474
+ const body = R5.isNotNil(layer) ? `@layer ${layer} {
828
475
  ${content}
829
476
  }` : content;
830
477
  return body;
@@ -841,8 +488,8 @@ var formats = {
841
488
 
842
489
  // src/tokens/process/transformers.ts
843
490
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
844
- import * as R11 from "ramda";
845
- var isPx = R11.test(/\b\d+px\b/g);
491
+ import * as R6 from "ramda";
492
+ var isPx = R6.test(/\b\d+px\b/g);
846
493
  var sizeRem = {
847
494
  name: "ds/size/toRem",
848
495
  type: "value",
@@ -932,7 +579,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
932
579
  {
933
580
  destination: `color-scheme/${colorScheme2}.css`,
934
581
  format: formats.colorScheme.name,
935
- filter: (token) => typeEquals("color", token) && !R12.startsWith(["global"], token.path)
582
+ filter: (token) => typeEquals("color", token) && !R7.startsWith(["global"], token.path)
936
583
  }
937
584
  ],
938
585
  options: {
@@ -983,7 +630,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
983
630
  };
984
631
 
985
632
  // src/tokens/process/configs/semantic.ts
986
- import * as R13 from "ramda";
633
+ import * as R8 from "ramda";
987
634
  import { outputReferencesFilter } from "style-dictionary/utils";
988
635
  var semanticVariables = ({ theme }) => {
989
636
  const selector = `:root`;
@@ -1006,8 +653,8 @@ var semanticVariables = ({ theme }) => {
1006
653
  destination: `semantic.css`,
1007
654
  format: formats.semantic.name,
1008
655
  filter: (token) => {
1009
- const isUwantedToken = R13.anyPass([R13.includes("primitives/global")])(token.filePath);
1010
- const isPrivateToken = R13.includes("_", token.path);
656
+ const isUwantedToken = R8.anyPass([R8.includes("primitives/global")])(token.filePath);
657
+ const isPrivateToken = R8.includes("_", token.path);
1011
658
  const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
1012
659
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
1013
660
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
@@ -1028,20 +675,20 @@ var semanticVariables = ({ theme }) => {
1028
675
  };
1029
676
 
1030
677
  // src/tokens/process/configs/storefront.ts
1031
- import * as R15 from "ramda";
678
+ import * as R10 from "ramda";
1032
679
  import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
1033
680
 
1034
681
  // src/tokens/process/formats/js-tokens.ts
1035
- import * as R14 from "ramda";
682
+ import * as R9 from "ramda";
1036
683
  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))
684
+ var groupByType = R9.groupBy((token) => getType(token));
685
+ var removeUnwatedTokens = R9.pipe(
686
+ R9.reject((token) => isColorCategoryToken(token)),
687
+ R9.reject((token) => R9.any((path2) => path2.startsWith("_"))(token.path))
1041
688
  );
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);
689
+ var dissocExtensions = R9.pipe(R9.dissoc("$extensions"), R9.dissocPath(["original", "$extensions"]));
690
+ var removeUnwatedProps = R9.map((token) => dissocExtensions(token));
691
+ var toCssVarName = R9.pipe(R9.split(":"), R9.head, R9.trim);
1045
692
  var jsTokens = {
1046
693
  name: "ds/js-tokens",
1047
694
  format: async ({ dictionary, file, options }) => {
@@ -1052,7 +699,7 @@ var jsTokens = {
1052
699
  format: "css",
1053
700
  usesDtcg
1054
701
  });
1055
- const formatTokens = R14.map((token) => {
702
+ const formatTokens = R9.map((token) => {
1056
703
  if (pathStartsWithOneOf(["size", "_size"], token)) {
1057
704
  const { calc, name } = overrideSizingFormula(format, token);
1058
705
  return {
@@ -1066,7 +713,7 @@ var jsTokens = {
1066
713
  name: toCssVarName(format(token))
1067
714
  };
1068
715
  });
1069
- const processTokens = R14.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
716
+ const processTokens = R9.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
1070
717
  const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
1071
718
  const content = Object.entries(tokens).map(
1072
719
  ([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
@@ -1091,9 +738,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
1091
738
  destination: `${colorScheme2}.ts`,
1092
739
  format: jsTokens.name,
1093
740
  filter: (token) => {
1094
- if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R15.includes("semantic", token.filePath))
741
+ if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R10.includes("semantic", token.filePath))
1095
742
  return false;
1096
- const isSemanticColor = R15.includes("semantic", token.filePath) && typeEquals(["color"], token);
743
+ const isSemanticColor = R10.includes("semantic", token.filePath) && typeEquals(["color"], token);
1097
744
  const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
1098
745
  return isSemanticColor || wantedTypes;
1099
746
  }
@@ -1158,20 +805,183 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
1158
805
  };
1159
806
  };
1160
807
 
808
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
809
+ var BoxShadowTypes;
810
+ (function(BoxShadowTypes2) {
811
+ BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
812
+ BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
813
+ })(BoxShadowTypes || (BoxShadowTypes = {}));
814
+
815
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
816
+ var ColorModifierTypes;
817
+ (function(ColorModifierTypes2) {
818
+ ColorModifierTypes2["LIGHTEN"] = "lighten";
819
+ ColorModifierTypes2["DARKEN"] = "darken";
820
+ ColorModifierTypes2["MIX"] = "mix";
821
+ ColorModifierTypes2["ALPHA"] = "alpha";
822
+ })(ColorModifierTypes || (ColorModifierTypes = {}));
823
+
824
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
825
+ var ColorSpaceTypes;
826
+ (function(ColorSpaceTypes2) {
827
+ ColorSpaceTypes2["LCH"] = "lch";
828
+ ColorSpaceTypes2["SRGB"] = "srgb";
829
+ ColorSpaceTypes2["P3"] = "p3";
830
+ ColorSpaceTypes2["HSL"] = "hsl";
831
+ })(ColorSpaceTypes || (ColorSpaceTypes = {}));
832
+
833
+ // ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
834
+ var Properties;
835
+ (function(Properties2) {
836
+ Properties2["sizing"] = "sizing";
837
+ Properties2["height"] = "height";
838
+ Properties2["width"] = "width";
839
+ Properties2["spacing"] = "spacing";
840
+ Properties2["verticalPadding"] = "verticalPadding";
841
+ Properties2["horizontalPadding"] = "horizontalPadding";
842
+ Properties2["paddingTop"] = "paddingTop";
843
+ Properties2["paddingRight"] = "paddingRight";
844
+ Properties2["paddingBottom"] = "paddingBottom";
845
+ Properties2["paddingLeft"] = "paddingLeft";
846
+ Properties2["itemSpacing"] = "itemSpacing";
847
+ Properties2["fill"] = "fill";
848
+ Properties2["backgroundBlur"] = "backgroundBlur";
849
+ Properties2["border"] = "border";
850
+ Properties2["borderTop"] = "borderTop";
851
+ Properties2["borderRight"] = "borderRight";
852
+ Properties2["borderBottom"] = "borderBottom";
853
+ Properties2["borderLeft"] = "borderLeft";
854
+ Properties2["borderColor"] = "borderColor";
855
+ Properties2["borderRadius"] = "borderRadius";
856
+ Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
857
+ Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
858
+ Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
859
+ Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
860
+ Properties2["borderWidth"] = "borderWidth";
861
+ Properties2["borderWidthTop"] = "borderWidthTop";
862
+ Properties2["borderWidthRight"] = "borderWidthRight";
863
+ Properties2["borderWidthBottom"] = "borderWidthBottom";
864
+ Properties2["borderWidthLeft"] = "borderWidthLeft";
865
+ Properties2["boxShadow"] = "boxShadow";
866
+ Properties2["opacity"] = "opacity";
867
+ Properties2["fontFamilies"] = "fontFamilies";
868
+ Properties2["fontWeights"] = "fontWeights";
869
+ Properties2["fontSizes"] = "fontSizes";
870
+ Properties2["lineHeights"] = "lineHeights";
871
+ Properties2["typography"] = "typography";
872
+ Properties2["composition"] = "composition";
873
+ Properties2["letterSpacing"] = "letterSpacing";
874
+ Properties2["paragraphSpacing"] = "paragraphSpacing";
875
+ Properties2["textCase"] = "textCase";
876
+ Properties2["dimension"] = "dimension";
877
+ Properties2["textDecoration"] = "textDecoration";
878
+ Properties2["asset"] = "asset";
879
+ Properties2["tokenValue"] = "tokenValue";
880
+ Properties2["value"] = "value";
881
+ Properties2["tokenName"] = "tokenName";
882
+ Properties2["description"] = "description";
883
+ })(Properties || (Properties = {}));
884
+
885
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
886
+ var TokenSetStatus;
887
+ (function(TokenSetStatus2) {
888
+ TokenSetStatus2["DISABLED"] = "disabled";
889
+ TokenSetStatus2["SOURCE"] = "source";
890
+ TokenSetStatus2["ENABLED"] = "enabled";
891
+ })(TokenSetStatus || (TokenSetStatus = {}));
892
+
893
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
894
+ var TokenTypes;
895
+ (function(TokenTypes2) {
896
+ TokenTypes2["OTHER"] = "other";
897
+ TokenTypes2["COLOR"] = "color";
898
+ TokenTypes2["BORDER_RADIUS"] = "borderRadius";
899
+ TokenTypes2["SIZING"] = "sizing";
900
+ TokenTypes2["SPACING"] = "spacing";
901
+ TokenTypes2["TEXT"] = "text";
902
+ TokenTypes2["TYPOGRAPHY"] = "typography";
903
+ TokenTypes2["OPACITY"] = "opacity";
904
+ TokenTypes2["BORDER_WIDTH"] = "borderWidth";
905
+ TokenTypes2["STROKE_STYLE"] = "strokeStyle";
906
+ TokenTypes2["BOX_SHADOW"] = "boxShadow";
907
+ TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
908
+ TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
909
+ TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
910
+ TokenTypes2["FONT_SIZES"] = "fontSizes";
911
+ TokenTypes2["LETTER_SPACING"] = "letterSpacing";
912
+ TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
913
+ TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
914
+ TokenTypes2["TEXT_DECORATION"] = "textDecoration";
915
+ TokenTypes2["TEXT_CASE"] = "textCase";
916
+ TokenTypes2["COMPOSITION"] = "composition";
917
+ TokenTypes2["DIMENSION"] = "dimension";
918
+ TokenTypes2["BORDER"] = "border";
919
+ TokenTypes2["ASSET"] = "asset";
920
+ TokenTypes2["BOOLEAN"] = "boolean";
921
+ TokenTypes2["NUMBER"] = "number";
922
+ })(TokenTypes || (TokenTypes = {}));
923
+
924
+ // ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
925
+ var BorderValues;
926
+ (function(BorderValues2) {
927
+ BorderValues2["BORDER_COLOR"] = "color";
928
+ BorderValues2["BORDER_WIDTH"] = "width";
929
+ BorderValues2["BORDER_STYLE"] = "style";
930
+ })(BorderValues || (BorderValues = {}));
931
+
932
+ // ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
933
+ var StrokeStyleValues;
934
+ (function(StrokeStyleValues2) {
935
+ StrokeStyleValues2["SOLID"] = "solid";
936
+ StrokeStyleValues2["DASHED"] = "dashed";
937
+ StrokeStyleValues2["DOTTED"] = "dotted";
938
+ StrokeStyleValues2["DOUBLE"] = "double";
939
+ StrokeStyleValues2["GROOVE"] = "groove";
940
+ StrokeStyleValues2["RIDGE"] = "ridge";
941
+ StrokeStyleValues2["OUTSET"] = "outset";
942
+ StrokeStyleValues2["INSET"] = "inset";
943
+ })(StrokeStyleValues || (StrokeStyleValues = {}));
944
+
945
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
946
+ var BoxShadowValues;
947
+ (function(BoxShadowValues2) {
948
+ BoxShadowValues2["TYPE"] = "type";
949
+ BoxShadowValues2["COLOR"] = "color";
950
+ BoxShadowValues2["X"] = "x";
951
+ BoxShadowValues2["Y"] = "y";
952
+ BoxShadowValues2["BLUR"] = "blur";
953
+ BoxShadowValues2["SPREAD"] = "spread";
954
+ BoxShadowValues2["BLEND_MODE"] = "blendMode";
955
+ })(BoxShadowValues || (BoxShadowValues = {}));
956
+
957
+ // ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
958
+ var TypographyValues;
959
+ (function(TypographyValues2) {
960
+ TypographyValues2["FONT_FAMILY"] = "fontFamily";
961
+ TypographyValues2["FONT_WEIGHT"] = "fontWeight";
962
+ TypographyValues2["LINE_HEIGHT"] = "lineHeight";
963
+ TypographyValues2["FONT_SIZE"] = "fontSize";
964
+ TypographyValues2["LETTER_SPACING"] = "letterSpacing";
965
+ TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
966
+ TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
967
+ TypographyValues2["TEXT_DECORATION"] = "textDecoration";
968
+ TypographyValues2["TEXT_CASE"] = "textCase";
969
+ })(TypographyValues || (TypographyValues = {}));
970
+
1161
971
  // src/tokens/process/utils/getMultidimensionalThemes.ts
1162
- import chalk2 from "chalk";
972
+ import chalk3 from "chalk";
1163
973
  import { kebabCase } from "change-case";
1164
- import * as R16 from "ramda";
974
+ import * as R11 from "ramda";
1165
975
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
1166
976
  const verboseLogging = buildOptions?.verbose;
1167
977
  const grouped$themes = groupThemes(processed$themes);
1168
978
  const permutations = permutateThemes(grouped$themes);
1169
979
  const ALL_DEPENDENT_ON = ["theme"];
1170
- const keys2 = R16.keys(grouped$themes);
980
+ const keys2 = R11.keys(grouped$themes);
1171
981
  const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
1172
982
  if (verboseLogging) {
1173
- console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
1174
- console.log(chalk2.cyan(` (ignoring permutations for ${nonDependentKeys})`));
983
+ console.log(chalk3.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
984
+ console.log(chalk3.cyan(` (ignoring permutations for ${nonDependentKeys})`));
1175
985
  }
1176
986
  return permutations.filter((val) => {
1177
987
  const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
@@ -1208,7 +1018,7 @@ function groupThemes(themes) {
1208
1018
  }
1209
1019
  return groups;
1210
1020
  }
1211
- var hasUnknownProps = R16.pipe(R16.values, R16.none(R16.equals("unknown")), R16.not);
1021
+ var hasUnknownProps = R11.pipe(R11.values, R11.none(R11.equals("unknown")), R11.not);
1212
1022
  function permutateThemes(groups) {
1213
1023
  const separator = "_";
1214
1024
  const permutations = cartesian(Object.values(groups));
@@ -1218,8 +1028,8 @@ function permutateThemes(groups) {
1218
1028
  const { group, name, selectedTokenSets } = theme;
1219
1029
  let updatedPermutation = acc.permutation;
1220
1030
  if (group) {
1221
- const groupProp = R16.lensProp(group);
1222
- updatedPermutation = R16.set(groupProp, name, updatedPermutation);
1031
+ const groupProp = R11.lensProp(group);
1032
+ updatedPermutation = R11.set(groupProp, name, updatedPermutation);
1223
1033
  }
1224
1034
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
1225
1035
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -1303,7 +1113,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
1303
1113
  obj.filePath = tokenSet;
1304
1114
  }
1305
1115
  });
1306
- tokenSource.tokens = R17.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
1116
+ tokenSource.tokens = R12.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
1307
1117
  }
1308
1118
  }
1309
1119
  } else {
@@ -1390,19 +1200,19 @@ var buildConfigs = {
1390
1200
  // },
1391
1201
  };
1392
1202
  async function processPlatform(options) {
1393
- const { dry, process, $themes } = options;
1203
+ const { process, $themes } = options;
1394
1204
  const platform = "css";
1395
1205
  const tokenSets = process === "format" ? options.tokenSets : void 0;
1396
1206
  const tokensDir = process === "build" ? options.tokensDir : void 0;
1397
1207
  buildOptions = options;
1398
- const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
1208
+ const processed$themes = $themes.map(processThemeObject).filter((theme) => R13.not(theme.group === "size" && theme.name !== "medium"));
1399
1209
  const customColors = getCustomColors(processed$themes);
1400
1210
  if (!buildOptions.rootColor) {
1401
- const firstMainColor = R18.head(customColors);
1211
+ const firstMainColor = R13.head(customColors);
1402
1212
  buildOptions.rootColor = firstMainColor;
1403
- console.log(`Using first main color; ${chalk3.blue(firstMainColor)}, as ${chalk3.green(`":root"`)} color`);
1213
+ console.log(`Using first main color; ${chalk4.blue(firstMainColor)}, as ${chalk4.green(`":root"`)} color`);
1404
1214
  }
1405
- const buildAndSdConfigs = R18.map((buildConfig) => {
1215
+ const buildAndSdConfigs = R13.map((buildConfig) => {
1406
1216
  const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
1407
1217
  tokensDir,
1408
1218
  tokenSets
@@ -1434,19 +1244,19 @@ async function processPlatform(options) {
1434
1244
  types: [initResult]
1435
1245
  };
1436
1246
  try {
1437
- for (const [buildName, { buildConfig, sdConfigs }] of R18.toPairs(buildAndSdConfigs)) {
1247
+ for (const [buildName, { buildConfig, sdConfigs }] of R13.toPairs(buildAndSdConfigs)) {
1438
1248
  if (!(buildConfig.enabled?.() ?? true)) {
1439
1249
  continue;
1440
1250
  }
1441
1251
  if (sdConfigs.length > 0) {
1442
1252
  console.log(`
1443
- \u{1F371} Building ${chalk3.green(buildConfig.name ?? buildName)}`);
1253
+ \u{1F371} Building ${chalk4.green(buildConfig.name ?? buildName)}`);
1444
1254
  const results = await Promise.all(
1445
1255
  sdConfigs.map(async (sdConfig) => {
1446
1256
  const { config, permutation } = sdConfig;
1447
1257
  const modes = ["theme", ...buildConfig.dimensions];
1448
1258
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
1449
- const logMessage = R18.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1259
+ const logMessage = R13.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1450
1260
  console.log(logMessage);
1451
1261
  const sdOptions = { cache: true };
1452
1262
  const sdExtended = await sd.extend(config);
@@ -1478,7 +1288,7 @@ async function processPlatform(options) {
1478
1288
  }
1479
1289
  async function createColorTypeDeclaration(colors) {
1480
1290
  console.log(`
1481
- \u{1F371} Building ${chalk3.green("type declarations")}`);
1291
+ \u{1F371} Building ${chalk4.green("type declarations")}`);
1482
1292
  const typeDeclaration = `
1483
1293
  import type {} from '@digdir/designsystemet-react/colors';
1484
1294
 
@@ -1491,70 +1301,6 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
1491
1301
  return typeDeclaration;
1492
1302
  }
1493
1303
 
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
1304
  // src/tokens/build.ts
1559
1305
  async function write(files, outDir, dry) {
1560
1306
  for (const { destination, output } of files) {
@@ -1571,6 +1317,12 @@ var buildTokens = async (options) => {
1571
1317
  const outDir = path.resolve(options.outDir);
1572
1318
  const tokensDir = path.resolve(options.tokensDir);
1573
1319
  const $themes = JSON.parse(await readFile(`${tokensDir}/$themes.json`));
1320
+ let $designsystemet;
1321
+ try {
1322
+ const $designsystemetContent = await readFile(`${tokensDir}/$designsystemet.json`);
1323
+ $designsystemet = JSON.parse($designsystemetContent);
1324
+ } catch (error) {
1325
+ }
1574
1326
  console.log(`
1575
1327
  \u{1F3D7}\uFE0F Start building tokens in ${chalk5.green(tokensDir)}`);
1576
1328
  const processedBuilds = await processPlatform({
@@ -1588,7 +1340,12 @@ var buildTokens = async (options) => {
1588
1340
  for (const { formatted } of processedBuilds.types) {
1589
1341
  await write(formatted, outDir, options.dry);
1590
1342
  }
1591
- await write(createThemeCSSFiles(processedBuilds), outDir, options.dry);
1343
+ const fileHeader2 = R14.join("")([
1344
+ defaultFileHeader,
1345
+ $designsystemet ? `
1346
+ design-tokens: v${$designsystemet.version} ` : ""
1347
+ ]);
1348
+ await write(createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 }), outDir, options.dry);
1592
1349
  console.log(`
1593
1350
  \u2705 Finished building tokens!`);
1594
1351
  return processedBuilds;