@digdir/designsystemet 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/configs/digdir.config.json +4 -0
  2. package/dist/bin/designsystemet.js +488 -166
  3. package/dist/global-Y35YADVH.json +100 -0
  4. package/dist/src/index.js +527 -203
  5. package/dist/src/scripts/update-preview-tokens.js +478 -128
  6. package/dist/src/tokens/build.js +429 -111
  7. package/dist/src/tokens/create/defaults.js +27 -23
  8. package/dist/src/tokens/create/generators/$designsystemet.js +6 -6
  9. package/dist/src/tokens/create/write.js +6 -6
  10. package/dist/src/tokens/create.js +27 -23
  11. package/dist/src/tokens/format.js +527 -203
  12. package/dist/src/tokens/index.js +527 -203
  13. package/dist/src/tokens/process/configs/color.js +366 -66
  14. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
  15. package/dist/src/tokens/process/configs/semantic.js +368 -68
  16. package/dist/src/tokens/process/configs/shared.js +9 -2
  17. package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
  18. package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
  19. package/dist/src/tokens/process/configs/size-mode.js +1067 -0
  20. package/dist/src/tokens/process/configs/size.d.ts +3 -0
  21. package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
  22. package/dist/src/tokens/process/configs/size.js +1069 -0
  23. package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
  24. package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
  25. package/dist/src/tokens/process/configs/type-scale.js +1067 -0
  26. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  27. package/dist/src/tokens/process/configs/typography.js +364 -64
  28. package/dist/src/tokens/process/configs.d.ts +3 -0
  29. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  30. package/dist/src/tokens/process/configs.js +373 -71
  31. package/dist/src/tokens/process/formats/css/color.js +381 -79
  32. package/dist/src/tokens/process/formats/css/semantic.d.ts +0 -14
  33. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
  34. package/dist/src/tokens/process/formats/css/semantic.js +407 -109
  35. package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
  36. package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
  37. package/dist/src/tokens/process/formats/css/size-mode.js +1068 -0
  38. package/dist/src/tokens/process/formats/css/size.d.ts +17 -0
  39. package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
  40. package/dist/src/tokens/process/formats/css/size.js +1069 -0
  41. package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
  42. package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
  43. package/dist/src/tokens/process/formats/css/type-scale.js +1069 -0
  44. package/dist/src/tokens/process/formats/css/typography.js +365 -63
  45. package/dist/src/tokens/process/formats/css.d.ts +3 -0
  46. package/dist/src/tokens/process/formats/css.d.ts.map +1 -1
  47. package/dist/src/tokens/process/formats/css.js +364 -64
  48. package/dist/src/tokens/process/output/declarations.js +376 -74
  49. package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
  50. package/dist/src/tokens/process/output/theme.js +63 -14
  51. package/dist/src/tokens/process/platform.d.ts +16 -0
  52. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  53. package/dist/src/tokens/process/platform.js +402 -95
  54. package/dist/src/tokens/process/transformers.js +9 -2
  55. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +373 -71
  56. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +1 -1
  57. package/dist/src/tokens/utils.d.ts +4 -1
  58. package/dist/src/tokens/utils.d.ts.map +1 -1
  59. package/dist/src/tokens/utils.js +24 -1
  60. package/package.json +6 -6
  61. package/dist/global-XVXVBKM6.json +0 -96
@@ -4,11 +4,11 @@ import pc3 from "picocolors";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "@digdir/designsystemet",
7
- version: "1.3.0",
7
+ version: "1.5.0",
8
8
  description: "CLI for Designsystemet",
9
9
  author: "Designsystemet team",
10
10
  engines: {
11
- node: ">=22.18.0"
11
+ node: ">=22.19.0"
12
12
  },
13
13
  repository: {
14
14
  type: "git",
@@ -78,8 +78,8 @@ var package_default = {
78
78
  picocolors: "^1.1.1",
79
79
  postcss: "^8.5.6",
80
80
  ramda: "^0.31.3",
81
- "style-dictionary": "^5.0.1",
82
- zod: "^4.0.17",
81
+ "style-dictionary": "^5.0.4",
82
+ zod: "^4.1.5",
83
83
  "zod-validation-error": "^4.0.1"
84
84
  },
85
85
  devDependencies: {
@@ -87,20 +87,20 @@ var package_default = {
87
87
  "@types/apca-w3": "^0.1.3",
88
88
  "@types/chroma-js": "^3.1.1",
89
89
  "@types/fs-extra": "^11.0.4",
90
- "@types/node": "^22.17.2",
90
+ "@types/node": "^22.18.1",
91
91
  "@types/object-hash": "^3.0.6",
92
92
  "@types/ramda": "^0.31.0",
93
93
  "fs-extra": "^11.3.1",
94
94
  tslib: "^2.8.1",
95
95
  tsup: "^8.5.0",
96
- tsx: "^4.20.4",
96
+ tsx: "^4.20.5",
97
97
  typescript: "^5.9.2"
98
98
  }
99
99
  };
100
100
 
101
101
  // src/tokens/process/platform.ts
102
102
  import pc2 from "picocolors";
103
- import * as R10 from "ramda";
103
+ import * as R15 from "ramda";
104
104
  import StyleDictionary2 from "style-dictionary";
105
105
 
106
106
  // src/tokens/types.ts
@@ -111,7 +111,7 @@ var colorCategories = {
111
111
 
112
112
  // src/tokens/process/configs.ts
113
113
  import { register } from "@tokens-studio/sd-transforms";
114
- import * as R9 from "ramda";
114
+ import * as R14 from "ramda";
115
115
  import StyleDictionary from "style-dictionary";
116
116
 
117
117
  // src/tokens/utils.ts
@@ -134,7 +134,10 @@ var pathStartsWithOneOf = R.curry(
134
134
  return false;
135
135
  }
136
136
  const tokenPath = mapToLowerCase(token.path);
137
- const matchPathsStartingWith = R.map((path) => R.startsWith([path], tokenPath), mapToLowerCase(paths));
137
+ const matchPathsStartingWith = R.map((pathOrString) => {
138
+ const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
139
+ return R.startsWith(mapToLowerCase(path), tokenPath);
140
+ }, paths);
138
141
  return hasAnyTruth(matchPathsStartingWith);
139
142
  }
140
143
  );
@@ -170,9 +173,26 @@ function inlineTokens(shouldInline, tokens) {
170
173
  return tokenWithInlinedRefs;
171
174
  });
172
175
  }
176
+ var sizeMap = {
177
+ xsmall: "xs",
178
+ small: "sm",
179
+ medium: "md",
180
+ large: "lg",
181
+ xlarge: "xl"
182
+ };
183
+ function shortSizeName(size2) {
184
+ return sizeMap[size2] ?? size2;
185
+ }
186
+ var sizeComparator = (size2) => {
187
+ const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
188
+ return sortIndex ?? 0;
189
+ };
190
+ function orderBySize(sizes) {
191
+ return R.sortBy(sizeComparator, sizes);
192
+ }
173
193
 
174
194
  // src/tokens/process/configs/color.ts
175
- import * as R6 from "ramda";
195
+ import * as R9 from "ramda";
176
196
 
177
197
  // src/tokens/process/formats/css/color.ts
178
198
  import * as R2 from "ramda";
@@ -230,10 +250,10 @@ ${selector} ${content} ${autoSelectorContent}
230
250
  };
231
251
  var colorCategory = {
232
252
  name: "ds/css-colorcategory",
233
- format: async ({ dictionary, options, platform }) => {
253
+ format: async ({ dictionary, file, options, platform }) => {
234
254
  const { outputReferences, usesDtcg } = options;
235
- const { selector, layer, files } = platform;
236
- const destination = files?.[0]?.destination;
255
+ const { selector, layer } = platform;
256
+ const destination = file.destination;
237
257
  const format = R2.compose(
238
258
  createPropertyFormatter({
239
259
  outputReferences,
@@ -270,6 +290,10 @@ ${selector} ${content}
270
290
  };
271
291
 
272
292
  // src/tokens/process/formats/css/semantic.ts
293
+ import * as R4 from "ramda";
294
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
295
+
296
+ // src/tokens/process/formats/css/size.ts
273
297
  import * as R3 from "ramda";
274
298
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
275
299
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
@@ -277,12 +301,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
277
301
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
278
302
  var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
279
303
  var overrideSizingFormula = (format, token) => {
280
- const [name, value] = format(token).split(":");
281
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
282
- const round = `round(down, ${calc}, 1px)`;
304
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
305
+ let calc;
306
+ let round;
307
+ if (token.path[1] === "unit") {
308
+ calc = `calc(1rem * ${value})`;
309
+ } else if (value.startsWith("floor")) {
310
+ calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
311
+ round = `round(down, ${calc}, 1px)`;
312
+ } else {
313
+ calc = value.includes("*") ? `calc(${value})` : value;
314
+ }
283
315
  return {
284
316
  name,
285
- round,
317
+ round: round ?? calc,
286
318
  calc
287
319
  };
288
320
  };
@@ -298,18 +330,21 @@ var formatSizingTokens = (format, tokens) => R3.reduce(
298
330
  { tokens: [], round: [], calc: [] },
299
331
  tokens
300
332
  );
301
- var sizingTemplate = ({ round, calc }) => `
333
+ var sizingTemplate = ({ round, calc }) => {
334
+ const usesRounding = round.filter((val, i) => val !== calc[i]);
335
+ return `
302
336
  ${calc.join("\n")}
303
337
 
304
338
  @supports (width: round(down, .1em, 1px)) {
305
- ${round.join("\n")}
339
+ ${usesRounding.join("\n ")}
306
340
  }`;
307
- var semantic = {
308
- name: "ds/css-semantic",
309
- format: async ({ dictionary, options, platform }) => {
341
+ };
342
+ var size = {
343
+ name: "ds/css-size",
344
+ format: async ({ dictionary, file, options, platform }) => {
310
345
  const { outputReferences, usesDtcg } = options;
311
- const { selector, layer, files } = platform;
312
- const destination = files?.[0]?.destination;
346
+ const { selector, layer } = platform;
347
+ const destination = file.destination;
313
348
  const format = createPropertyFormatter2({
314
349
  outputReferences,
315
350
  dictionary,
@@ -317,9 +352,9 @@ var semantic = {
317
352
  usesDtcg
318
353
  });
319
354
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
320
- const filteredTokens = R3.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
355
+ const filteredTokens = R3.reject((token) => R3.equals(["_size", "mode-font-size"], token.path), tokens);
321
356
  const [sizingTokens, restTokens] = R3.partition(
322
- (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
357
+ (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
323
358
  filteredTokens
324
359
  );
325
360
  const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
@@ -332,64 +367,56 @@ var semantic = {
332
367
  formatted: t
333
368
  }));
334
369
  buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
335
- const sizingSnippet = sizingTemplate(formattedSizingTokens);
336
- const formattedTokens = formattedMap.map(R3.view(R3.lensProp("formatted"))).concat(sizingSnippet);
337
- const content = `{
370
+ const formattedTokens = [formattedMap.map(R3.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
371
+ const content = `${selector} {
338
372
  ${formattedTokens.join("\n")}
339
373
  }
340
374
  `;
341
375
  const body = R3.isNotNil(layer) ? `@layer ${layer} {
342
- ${selector} ${content}
376
+ ${content}
343
377
  }
344
- ` : `${selector} ${content}
378
+ ` : `${content}
345
379
  `;
346
380
  return body;
347
381
  }
348
382
  };
349
383
 
350
- // src/tokens/process/formats/css/typography.ts
351
- import * as R4 from "ramda";
352
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
353
- var typographyFontFamilyPredicate = R4.allPass([
354
- R4.pathSatisfies(R4.includes("typography"), ["path"]),
355
- R4.pathSatisfies(R4.includes("fontFamily"), ["path"])
356
- ]);
357
- var typography = {
358
- name: "ds/css-typography",
359
- format: async ({ dictionary, options, platform }) => {
384
+ // src/tokens/process/formats/css/semantic.ts
385
+ var semantic = {
386
+ name: "ds/css-semantic",
387
+ format: async ({ dictionary, file, options, platform }) => {
360
388
  const { outputReferences, usesDtcg } = options;
361
- const { selector, layer, files } = platform;
362
- const destination = files?.[0]?.destination;
389
+ const { selector, layer } = platform;
390
+ const destination = file.destination;
363
391
  const format = createPropertyFormatter3({
364
392
  outputReferences,
365
393
  dictionary,
366
394
  format: "css",
367
395
  usesDtcg
368
396
  });
369
- const filteredTokens = R4.reject(typographyFontFamilyPredicate, dictionary.allTokens);
370
- const formattedMap = filteredTokens.map((token) => ({
397
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
398
+ const formattedMap = tokens.map((token) => ({
371
399
  token,
372
400
  formatted: format(token)
373
401
  }));
374
402
  buildOptions.buildTokenFormats[destination] = formattedMap;
375
- const formattedTokens = formattedMap.map(R4.view(R4.lensProp("formatted"))).join("\n");
376
- const content = selector ? `${selector} {
403
+ const formattedTokens = formattedMap.map(R4.prop("formatted")).join("\n");
404
+ const content = `${selector} {
377
405
  ${formattedTokens}
378
- }` : formattedTokens;
406
+ }
407
+ `;
379
408
  const body = R4.isNotNil(layer) ? `@layer ${layer} {
380
409
  ${content}
381
- }` : content;
410
+ }
411
+ ` : `${content}
412
+ `;
382
413
  return body;
383
414
  }
384
415
  };
385
416
 
386
- // src/tokens/process/formats/css.ts
387
- var formats = {
388
- colorScheme,
389
- colorCategory,
390
- semantic,
391
- typography
392
- };
417
+ // src/tokens/process/formats/css/size-mode.ts
418
+ import * as R6 from "ramda";
419
+ import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
393
420
 
394
421
  // src/tokens/process/transformers.ts
395
422
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
@@ -401,18 +428,22 @@ var sizeRem = {
401
428
  transitive: true,
402
429
  filter: (token) => {
403
430
  const hasWantedType = typeEquals(["dimension", "fontsize"], token);
404
- const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
431
+ const hasWantedPath = pathStartsWithOneOf([
432
+ "border-radius",
433
+ "font-size"
434
+ /*, ['_size', 'mode-font-size']*/
435
+ ], token);
405
436
  return hasWantedType && hasWantedPath;
406
437
  },
407
438
  transform: (token, config) => {
408
439
  const value = getValue(token);
409
440
  if (isPx(value)) {
410
441
  const baseFont = config.basePxFontSize || 16;
411
- const size = parseInt(value, 10);
412
- if (size === 0) {
442
+ const size2 = parseInt(value, 10);
443
+ if (size2 === 0) {
413
444
  return "0";
414
445
  }
415
- return `${size / baseFont}rem`;
446
+ return `${size2 / baseFont}rem`;
416
447
  }
417
448
  return value;
418
449
  }
@@ -463,6 +494,154 @@ var dsTransformers = [
463
494
  "shadow/css/shorthand"
464
495
  ];
465
496
 
497
+ // src/tokens/process/formats/css/size-mode.ts
498
+ var formatBaseSizeToken = (size2) => (token) => ({
499
+ ...token,
500
+ originalName: token.name,
501
+ name: `${token.name}--${shortSizeName(size2)}`,
502
+ $value: token.$value / basePxFontSize
503
+ });
504
+ var sizeMode = {
505
+ name: "ds/css-size-mode",
506
+ format: async ({ dictionary, file, options, platform }) => {
507
+ const { outputReferences, usesDtcg } = options;
508
+ const { selector, layer, size: size2 } = platform;
509
+ const destination = file.destination;
510
+ const format = createPropertyFormatter4({
511
+ outputReferences,
512
+ dictionary,
513
+ format: "css",
514
+ usesDtcg
515
+ });
516
+ const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
517
+ const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
518
+ const formattedMap = sizeSpecificTokens.map((token) => ({
519
+ token,
520
+ formatted: format({
521
+ ...token,
522
+ // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
523
+ name: token.originalName
524
+ })
525
+ }));
526
+ buildOptions.buildTokenFormats[destination] = formattedMap;
527
+ const content = `${selector} /* ${size2} */ {
528
+ ${sizeSpecificVariables}
529
+ }`;
530
+ const body = wrapInLayer(content, layer);
531
+ const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
532
+ const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
533
+ const sizingToggles = `:root, [data-size] {
534
+ --ds-size: var(--ds-size--${defaultSize});
535
+ ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
536
+ --ds-size-mode-font-size:
537
+ ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
538
+ }`;
539
+ const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
540
+ const sharedContent = `${sizingToggles}
541
+
542
+ ${sizingHelpers}`;
543
+ const sharedBody = shortSizeName(size2) === R6.last(sizes) ? `
544
+ ${wrapInLayer(sharedContent, layer)}` : "";
545
+ return body + sharedBody;
546
+ }
547
+ };
548
+ function wrapInLayer(content, layer) {
549
+ return R6.isNotNil(layer) ? `@layer ${layer} {
550
+ ${content}
551
+ }
552
+ ` : `${content}
553
+ `;
554
+ }
555
+
556
+ // src/tokens/process/formats/css/typography.ts
557
+ import * as R7 from "ramda";
558
+ import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
559
+ var typographyFontFamilyPredicate = R7.allPass([
560
+ R7.pathSatisfies(R7.includes("typography"), ["path"]),
561
+ R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
562
+ ]);
563
+ var typography = {
564
+ name: "ds/css-typography",
565
+ format: async ({ dictionary, file, options, platform }) => {
566
+ const { outputReferences, usesDtcg } = options;
567
+ const { selector, layer } = platform;
568
+ const destination = file.destination;
569
+ const format = createPropertyFormatter5({
570
+ outputReferences,
571
+ dictionary,
572
+ format: "css",
573
+ usesDtcg
574
+ });
575
+ const filteredTokens = R7.reject(typographyFontFamilyPredicate, dictionary.allTokens);
576
+ const formattedMap = filteredTokens.map((token) => ({
577
+ token,
578
+ formatted: format(token)
579
+ }));
580
+ buildOptions.buildTokenFormats[destination] = formattedMap;
581
+ const formattedTokens = formattedMap.map(R7.view(R7.lensProp("formatted"))).join("\n");
582
+ const content = selector ? `${selector} {
583
+ ${formattedTokens}
584
+ }` : formattedTokens;
585
+ const body = R7.isNotNil(layer) ? `@layer ${layer} {
586
+ ${content}
587
+ }` : content;
588
+ return body;
589
+ }
590
+ };
591
+
592
+ // src/tokens/process/formats/css/type-scale.ts
593
+ import * as R8 from "ramda";
594
+ import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
595
+ var typographyFontFamilyPredicate2 = R8.allPass([
596
+ R8.pathSatisfies(R8.includes("typography"), ["path"]),
597
+ R8.pathSatisfies(R8.includes("fontFamily"), ["path"])
598
+ ]);
599
+ function formatTypographySizeToken(token) {
600
+ return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
601
+ }
602
+ var typeScale = {
603
+ name: "ds/css-type-scale",
604
+ format: async ({ dictionary, file, options, platform }) => {
605
+ const { outputReferences, usesDtcg } = options;
606
+ const { selector, layer } = platform;
607
+ const destination = file.destination;
608
+ const format = createPropertyFormatter6({
609
+ outputReferences,
610
+ dictionary,
611
+ format: "css",
612
+ usesDtcg
613
+ });
614
+ const filteredTokens = R8.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
615
+ const tokens = R8.map(formatTypographySizeToken, filteredTokens);
616
+ const formattedMap = tokens.map((token) => ({
617
+ token,
618
+ formatted: format(token)
619
+ }));
620
+ buildOptions.buildTokenFormats[destination] = formattedMap;
621
+ const formattedTokens = formattedMap.map(R8.prop("formatted")).join("\n");
622
+ const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
623
+ const content = `${selector} {
624
+ ${sizeFactor}
625
+ ${formattedTokens}
626
+ }`;
627
+ const body = R8.isNotNil(layer) ? `@layer ${layer} {
628
+ ${content}
629
+ }` : content;
630
+ return body;
631
+ }
632
+ };
633
+
634
+ // src/tokens/process/formats/css.ts
635
+ var formats = {
636
+ colorScheme,
637
+ colorCategory,
638
+ semantic,
639
+ sizeMode,
640
+ size,
641
+ typography,
642
+ typeScale
643
+ };
644
+
466
645
  // src/tokens/process/configs/color.ts
467
646
  var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
468
647
  const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
@@ -484,7 +663,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
484
663
  {
485
664
  destination: `color-scheme/${colorScheme2}.css`,
486
665
  format: formats.colorScheme.name,
487
- filter: (token) => typeEquals("color", token) && !R6.startsWith(["global"], token.path)
666
+ filter: (token) => typeEquals("color", token) && !R9.startsWith(["global"], token.path)
488
667
  }
489
668
  ],
490
669
  options: {
@@ -535,7 +714,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
535
714
  };
536
715
 
537
716
  // src/tokens/process/configs/semantic.ts
538
- import * as R7 from "ramda";
717
+ import * as R10 from "ramda";
539
718
  import { outputReferencesFilter } from "style-dictionary/utils";
540
719
  var semanticVariables = ({ theme }) => {
541
720
  const selector = `:root`;
@@ -558,9 +737,12 @@ var semanticVariables = ({ theme }) => {
558
737
  destination: `semantic.css`,
559
738
  format: formats.semantic.name,
560
739
  filter: (token) => {
561
- const isUwantedToken = R7.anyPass([R7.includes("primitives/global")])(token.filePath);
562
- const isPrivateToken = R7.includes("_", token.path);
563
- const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
740
+ const isUwantedToken = R10.anyPass([R10.includes("primitives/global")])(token.filePath);
741
+ const isPrivateToken = R10.includes("_", token.path);
742
+ const unwantedPaths = pathStartsWithOneOf(
743
+ ["size", "_size", "font-size", "line-height", "letter-spacing"],
744
+ token
745
+ );
564
746
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
565
747
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
566
748
  return unwantedTokens;
@@ -570,9 +752,126 @@ var semanticVariables = ({ theme }) => {
570
752
  options: {
571
753
  outputReferences: (token, options) => {
572
754
  const include = pathStartsWithOneOf(["border-radius"], token);
573
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
574
- return (include || isWantedSize) && outputReferencesFilter(token, options);
755
+ return include && outputReferencesFilter(token, options);
756
+ }
757
+ }
758
+ }
759
+ }
760
+ };
761
+ };
762
+
763
+ // src/tokens/process/configs/size.ts
764
+ import * as R11 from "ramda";
765
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
766
+ var sizeVariables = ({ theme }) => {
767
+ const selector = `:root, [data-size]`;
768
+ const layer = `ds.theme.size`;
769
+ return {
770
+ preprocessors: ["tokens-studio"],
771
+ platforms: {
772
+ css: {
773
+ // custom
774
+ theme,
775
+ basePxFontSize,
776
+ selector,
777
+ layer,
778
+ //
779
+ prefix,
780
+ buildPath: `${theme}/`,
781
+ transforms: dsTransformers,
782
+ files: [
783
+ {
784
+ destination: `size.css`,
785
+ format: formats.size.name,
786
+ filter: (token) => {
787
+ const isUwantedToken = R11.anyPass([R11.includes("primitives/global")])(token.filePath);
788
+ const isPrivateToken = R11.includes("_", token.path);
789
+ return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
790
+ }
791
+ }
792
+ ],
793
+ options: {
794
+ outputReferences: (token, options) => {
795
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
796
+ return isWantedSize && outputReferencesFilter2(token, options);
797
+ }
798
+ }
799
+ }
800
+ }
801
+ };
802
+ };
803
+
804
+ // src/tokens/process/configs/size-mode.ts
805
+ import * as R12 from "ramda";
806
+ var sizeModeVariables = ({ theme, size: size2 }) => {
807
+ const selector = `:root`;
808
+ const layer = `ds.theme.size-mode`;
809
+ return {
810
+ preprocessors: ["tokens-studio"],
811
+ platforms: {
812
+ css: {
813
+ // custom
814
+ size: size2,
815
+ theme,
816
+ basePxFontSize,
817
+ selector,
818
+ layer,
819
+ //
820
+ prefix,
821
+ buildPath: `${theme}/`,
822
+ transforms: dsTransformers,
823
+ files: [
824
+ {
825
+ destination: `size-mode/${size2}.css`,
826
+ format: formats.sizeMode.name,
827
+ filter: (token) => {
828
+ return R12.equals(["_size", "mode-font-size"], token.path);
829
+ }
575
830
  }
831
+ ]
832
+ }
833
+ }
834
+ };
835
+ };
836
+
837
+ // src/tokens/process/configs/type-scale.ts
838
+ var typeScaleVariables = ({ theme, size: size2 }) => {
839
+ const selector = ":root, [data-size]";
840
+ const layer = `ds.theme.type-scale`;
841
+ return {
842
+ usesDtcg: true,
843
+ preprocessors: ["tokens-studio"],
844
+ expand: {
845
+ include: ["typography"]
846
+ },
847
+ platforms: {
848
+ css: {
849
+ prefix,
850
+ selector,
851
+ layer,
852
+ buildPath: `${theme}/`,
853
+ basePxFontSize,
854
+ transforms: [
855
+ "name/kebab",
856
+ "ts/size/px",
857
+ sizeRem.name,
858
+ "ts/size/lineheight",
859
+ "ts/typography/fontWeight",
860
+ typographyName.name
861
+ ],
862
+ files: [
863
+ {
864
+ destination: `type-scale.css`,
865
+ format: formats.typeScale.name,
866
+ filter: (token) => {
867
+ const included = typeEquals(["typography", "dimension", "fontsize"], token);
868
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
869
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
870
+ }
871
+ }
872
+ ],
873
+ options: {
874
+ outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
576
875
  }
577
876
  }
578
877
  }
@@ -613,12 +912,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
613
912
  destination: `typography/${typography2}.css`,
614
913
  format: formats.typography.name,
615
914
  filter: (token) => {
616
- const included = typeEquals(
617
- ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
618
- token
619
- );
915
+ const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
620
916
  if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
621
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
917
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
622
918
  }
623
919
  }
624
920
  ]
@@ -793,9 +1089,9 @@ var TypographyValues;
793
1089
  // src/tokens/process/utils/getMultidimensionalThemes.ts
794
1090
  import { kebabCase } from "change-case";
795
1091
  import pc from "picocolors";
796
- import * as R8 from "ramda";
1092
+ import * as R13 from "ramda";
797
1093
  var processed = Symbol("Type brand for ProcessedThemeObject");
798
- var hasUnknownProps = R8.pipe(R8.values, R8.none(R8.equals("unknown")), R8.not);
1094
+ var hasUnknownProps = R13.pipe(R13.values, R13.none(R13.equals("unknown")), R13.not);
799
1095
  var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
800
1096
  if (!x.group) {
801
1097
  return false;
@@ -821,7 +1117,10 @@ var configs = {
821
1117
  dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
822
1118
  warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
823
1119
  infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
1120
+ sizeModeVariables,
1121
+ sizeVariables,
824
1122
  typographyVariables,
1123
+ typeScaleVariables,
825
1124
  semanticVariables
826
1125
  };
827
1126
 
@@ -834,6 +1133,9 @@ var buildOptions = {
834
1133
  var sd = new StyleDictionary2();
835
1134
  var buildConfigs = {
836
1135
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
1136
+ sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
1137
+ size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
1138
+ typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
837
1139
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
838
1140
  "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
839
1141
  "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/output/theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,QAA2B,CAAC;AAE1D,KAAK,mBAAmB,GAAG;IACzB,6GAA6G;IAC7G,eAAe,EAAE,aAAa,CAAC;IAC/B,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,GAAI,kCAGjC,mBAAmB,KAAG,UAAU,EA8ElC,CAAC"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/output/theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,iBAAiB,QAA2B,CAAC;AAE1D,KAAK,mBAAmB,GAAG;IACzB,6GAA6G;IAC7G,eAAe,EAAE,aAAa,CAAC;IAC/B,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAOF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,GAAI,kCAGjC,mBAAmB,KAAG,UAAU,EAqFlC,CAAC"}