@digdir/designsystemet 1.4.0 → 1.5.1

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 (60) hide show
  1. package/dist/bin/designsystemet.js +485 -163
  2. package/dist/global-Y35YADVH.json +100 -0
  3. package/dist/src/index.js +524 -200
  4. package/dist/src/scripts/update-preview-tokens.js +429 -118
  5. package/dist/src/tokens/build.js +426 -108
  6. package/dist/src/tokens/create/defaults.js +27 -23
  7. package/dist/src/tokens/create/generators/$designsystemet.js +3 -3
  8. package/dist/src/tokens/create/write.js +3 -3
  9. package/dist/src/tokens/create.js +27 -23
  10. package/dist/src/tokens/format.js +524 -200
  11. package/dist/src/tokens/index.js +524 -200
  12. package/dist/src/tokens/process/configs/color.js +366 -66
  13. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
  14. package/dist/src/tokens/process/configs/semantic.js +368 -68
  15. package/dist/src/tokens/process/configs/shared.js +9 -2
  16. package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
  17. package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
  18. package/dist/src/tokens/process/configs/size-mode.js +1067 -0
  19. package/dist/src/tokens/process/configs/size.d.ts +3 -0
  20. package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
  21. package/dist/src/tokens/process/configs/size.js +1069 -0
  22. package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
  23. package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
  24. package/dist/src/tokens/process/configs/type-scale.js +1067 -0
  25. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  26. package/dist/src/tokens/process/configs/typography.js +364 -64
  27. package/dist/src/tokens/process/configs.d.ts +3 -0
  28. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  29. package/dist/src/tokens/process/configs.js +373 -71
  30. package/dist/src/tokens/process/formats/css/color.js +381 -79
  31. package/dist/src/tokens/process/formats/css/semantic.d.ts +0 -14
  32. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
  33. package/dist/src/tokens/process/formats/css/semantic.js +407 -109
  34. package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
  35. package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
  36. package/dist/src/tokens/process/formats/css/size-mode.js +1068 -0
  37. package/dist/src/tokens/process/formats/css/size.d.ts +17 -0
  38. package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
  39. package/dist/src/tokens/process/formats/css/size.js +1069 -0
  40. package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
  41. package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
  42. package/dist/src/tokens/process/formats/css/type-scale.js +1069 -0
  43. package/dist/src/tokens/process/formats/css/typography.js +365 -63
  44. package/dist/src/tokens/process/formats/css.d.ts +3 -0
  45. package/dist/src/tokens/process/formats/css.d.ts.map +1 -1
  46. package/dist/src/tokens/process/formats/css.js +364 -64
  47. package/dist/src/tokens/process/output/declarations.js +373 -71
  48. package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
  49. package/dist/src/tokens/process/output/theme.js +60 -11
  50. package/dist/src/tokens/process/platform.d.ts +16 -0
  51. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  52. package/dist/src/tokens/process/platform.js +402 -95
  53. package/dist/src/tokens/process/transformers.js +9 -2
  54. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +373 -71
  55. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +1 -1
  56. package/dist/src/tokens/utils.d.ts +4 -1
  57. package/dist/src/tokens/utils.d.ts.map +1 -1
  58. package/dist/src/tokens/utils.js +24 -1
  59. package/package.json +3 -3
  60. package/dist/global-XVXVBKM6.json +0 -96
@@ -1,6 +1,6 @@
1
1
  // src/tokens/process/platform.ts
2
2
  import pc2 from "picocolors";
3
- import * as R10 from "ramda";
3
+ import * as R15 from "ramda";
4
4
  import StyleDictionary2 from "style-dictionary";
5
5
 
6
6
  // src/tokens/types.ts
@@ -11,7 +11,7 @@ var colorCategories = {
11
11
 
12
12
  // src/tokens/process/configs.ts
13
13
  import { register } from "@tokens-studio/sd-transforms";
14
- import * as R9 from "ramda";
14
+ import * as R14 from "ramda";
15
15
  import StyleDictionary from "style-dictionary";
16
16
 
17
17
  // src/tokens/utils.ts
@@ -34,7 +34,10 @@ var pathStartsWithOneOf = R.curry(
34
34
  return false;
35
35
  }
36
36
  const tokenPath = mapToLowerCase(token.path);
37
- const matchPathsStartingWith = R.map((path) => R.startsWith([path], tokenPath), mapToLowerCase(paths));
37
+ const matchPathsStartingWith = R.map((pathOrString) => {
38
+ const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
39
+ return R.startsWith(mapToLowerCase(path), tokenPath);
40
+ }, paths);
38
41
  return hasAnyTruth(matchPathsStartingWith);
39
42
  }
40
43
  );
@@ -58,11 +61,11 @@ function isColorCategoryToken(token, category) {
58
61
  var isDigit = (s) => /^\d+$/.test(s);
59
62
  function traverseObj(obj, fn) {
60
63
  for (const key in obj) {
61
- const prop = obj[key];
62
- if (prop != null) {
63
- fn.apply(null, [obj, key, prop]);
64
- if (typeof prop === "object") {
65
- traverseObj(prop, fn);
64
+ const prop4 = obj[key];
65
+ if (prop4 != null) {
66
+ fn.apply(null, [obj, key, prop4]);
67
+ if (typeof prop4 === "object") {
68
+ traverseObj(prop4, fn);
66
69
  }
67
70
  }
68
71
  }
@@ -82,9 +85,26 @@ function inlineTokens(shouldInline, tokens) {
82
85
  return tokenWithInlinedRefs;
83
86
  });
84
87
  }
88
+ var sizeMap = {
89
+ xsmall: "xs",
90
+ small: "sm",
91
+ medium: "md",
92
+ large: "lg",
93
+ xlarge: "xl"
94
+ };
95
+ function shortSizeName(size2) {
96
+ return sizeMap[size2] ?? size2;
97
+ }
98
+ var sizeComparator = (size2) => {
99
+ const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
100
+ return sortIndex ?? 0;
101
+ };
102
+ function orderBySize(sizes) {
103
+ return R.sortBy(sizeComparator, sizes);
104
+ }
85
105
 
86
106
  // src/tokens/process/configs/color.ts
87
- import * as R6 from "ramda";
107
+ import * as R9 from "ramda";
88
108
 
89
109
  // src/tokens/process/formats/css/color.ts
90
110
  import * as R2 from "ramda";
@@ -142,10 +162,10 @@ ${selector} ${content} ${autoSelectorContent}
142
162
  };
143
163
  var colorCategory = {
144
164
  name: "ds/css-colorcategory",
145
- format: async ({ dictionary, options, platform }) => {
165
+ format: async ({ dictionary, file, options, platform }) => {
146
166
  const { outputReferences, usesDtcg } = options;
147
- const { selector, layer, files } = platform;
148
- const destination = files?.[0]?.destination;
167
+ const { selector, layer } = platform;
168
+ const destination = file.destination;
149
169
  const format = R2.compose(
150
170
  createPropertyFormatter({
151
171
  outputReferences,
@@ -182,6 +202,10 @@ ${selector} ${content}
182
202
  };
183
203
 
184
204
  // src/tokens/process/formats/css/semantic.ts
205
+ import * as R4 from "ramda";
206
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
207
+
208
+ // src/tokens/process/formats/css/size.ts
185
209
  import * as R3 from "ramda";
186
210
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
187
211
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
@@ -189,12 +213,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
189
213
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
190
214
  var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
191
215
  var overrideSizingFormula = (format, token) => {
192
- const [name, value] = format(token).split(":");
193
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
194
- const round = `round(down, ${calc}, 1px)`;
216
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
217
+ let calc;
218
+ let round;
219
+ if (token.path[1] === "unit") {
220
+ calc = `calc(1rem * ${value})`;
221
+ } else if (value.startsWith("floor")) {
222
+ calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
223
+ round = `round(down, ${calc}, 1px)`;
224
+ } else {
225
+ calc = value.includes("*") ? `calc(${value})` : value;
226
+ }
195
227
  return {
196
228
  name,
197
- round,
229
+ round: round ?? calc,
198
230
  calc
199
231
  };
200
232
  };
@@ -210,18 +242,21 @@ var formatSizingTokens = (format, tokens) => R3.reduce(
210
242
  { tokens: [], round: [], calc: [] },
211
243
  tokens
212
244
  );
213
- var sizingTemplate = ({ round, calc }) => `
245
+ var sizingTemplate = ({ round, calc }) => {
246
+ const usesRounding = round.filter((val, i) => val !== calc[i]);
247
+ return `
214
248
  ${calc.join("\n")}
215
249
 
216
250
  @supports (width: round(down, .1em, 1px)) {
217
- ${round.join("\n")}
251
+ ${usesRounding.join("\n ")}
218
252
  }`;
219
- var semantic = {
220
- name: "ds/css-semantic",
221
- format: async ({ dictionary, options, platform }) => {
253
+ };
254
+ var size = {
255
+ name: "ds/css-size",
256
+ format: async ({ dictionary, file, options, platform }) => {
222
257
  const { outputReferences, usesDtcg } = options;
223
- const { selector, layer, files } = platform;
224
- const destination = files?.[0]?.destination;
258
+ const { selector, layer } = platform;
259
+ const destination = file.destination;
225
260
  const format = createPropertyFormatter2({
226
261
  outputReferences,
227
262
  dictionary,
@@ -229,9 +264,9 @@ var semantic = {
229
264
  usesDtcg
230
265
  });
231
266
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
232
- const filteredTokens = R3.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
267
+ const filteredTokens = R3.reject((token) => R3.equals(["_size", "mode-font-size"], token.path), tokens);
233
268
  const [sizingTokens, restTokens] = R3.partition(
234
- (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
269
+ (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
235
270
  filteredTokens
236
271
  );
237
272
  const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
@@ -244,64 +279,56 @@ var semantic = {
244
279
  formatted: t
245
280
  }));
246
281
  buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
247
- const sizingSnippet = sizingTemplate(formattedSizingTokens);
248
- const formattedTokens = formattedMap.map(R3.view(R3.lensProp("formatted"))).concat(sizingSnippet);
249
- const content = `{
282
+ const formattedTokens = [formattedMap.map(R3.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
283
+ const content = `${selector} {
250
284
  ${formattedTokens.join("\n")}
251
285
  }
252
286
  `;
253
287
  const body = R3.isNotNil(layer) ? `@layer ${layer} {
254
- ${selector} ${content}
288
+ ${content}
255
289
  }
256
- ` : `${selector} ${content}
290
+ ` : `${content}
257
291
  `;
258
292
  return body;
259
293
  }
260
294
  };
261
295
 
262
- // src/tokens/process/formats/css/typography.ts
263
- import * as R4 from "ramda";
264
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
265
- var typographyFontFamilyPredicate = R4.allPass([
266
- R4.pathSatisfies(R4.includes("typography"), ["path"]),
267
- R4.pathSatisfies(R4.includes("fontFamily"), ["path"])
268
- ]);
269
- var typography = {
270
- name: "ds/css-typography",
271
- format: async ({ dictionary, options, platform }) => {
296
+ // src/tokens/process/formats/css/semantic.ts
297
+ var semantic = {
298
+ name: "ds/css-semantic",
299
+ format: async ({ dictionary, file, options, platform }) => {
272
300
  const { outputReferences, usesDtcg } = options;
273
- const { selector, layer, files } = platform;
274
- const destination = files?.[0]?.destination;
301
+ const { selector, layer } = platform;
302
+ const destination = file.destination;
275
303
  const format = createPropertyFormatter3({
276
304
  outputReferences,
277
305
  dictionary,
278
306
  format: "css",
279
307
  usesDtcg
280
308
  });
281
- const filteredTokens = R4.reject(typographyFontFamilyPredicate, dictionary.allTokens);
282
- const formattedMap = filteredTokens.map((token) => ({
309
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
310
+ const formattedMap = tokens.map((token) => ({
283
311
  token,
284
312
  formatted: format(token)
285
313
  }));
286
314
  buildOptions.buildTokenFormats[destination] = formattedMap;
287
- const formattedTokens = formattedMap.map(R4.view(R4.lensProp("formatted"))).join("\n");
288
- const content = selector ? `${selector} {
315
+ const formattedTokens = formattedMap.map(R4.prop("formatted")).join("\n");
316
+ const content = `${selector} {
289
317
  ${formattedTokens}
290
- }` : formattedTokens;
318
+ }
319
+ `;
291
320
  const body = R4.isNotNil(layer) ? `@layer ${layer} {
292
321
  ${content}
293
- }` : content;
322
+ }
323
+ ` : `${content}
324
+ `;
294
325
  return body;
295
326
  }
296
327
  };
297
328
 
298
- // src/tokens/process/formats/css.ts
299
- var formats = {
300
- colorScheme,
301
- colorCategory,
302
- semantic,
303
- typography
304
- };
329
+ // src/tokens/process/formats/css/size-mode.ts
330
+ import * as R6 from "ramda";
331
+ import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
305
332
 
306
333
  // src/tokens/process/transformers.ts
307
334
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
@@ -313,18 +340,22 @@ var sizeRem = {
313
340
  transitive: true,
314
341
  filter: (token) => {
315
342
  const hasWantedType = typeEquals(["dimension", "fontsize"], token);
316
- const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
343
+ const hasWantedPath = pathStartsWithOneOf([
344
+ "border-radius",
345
+ "font-size"
346
+ /*, ['_size', 'mode-font-size']*/
347
+ ], token);
317
348
  return hasWantedType && hasWantedPath;
318
349
  },
319
350
  transform: (token, config) => {
320
351
  const value = getValue(token);
321
352
  if (isPx(value)) {
322
353
  const baseFont = config.basePxFontSize || 16;
323
- const size = parseInt(value, 10);
324
- if (size === 0) {
354
+ const size2 = parseInt(value, 10);
355
+ if (size2 === 0) {
325
356
  return "0";
326
357
  }
327
- return `${size / baseFont}rem`;
358
+ return `${size2 / baseFont}rem`;
328
359
  }
329
360
  return value;
330
361
  }
@@ -375,6 +406,154 @@ var dsTransformers = [
375
406
  "shadow/css/shorthand"
376
407
  ];
377
408
 
409
+ // src/tokens/process/formats/css/size-mode.ts
410
+ var formatBaseSizeToken = (size2) => (token) => ({
411
+ ...token,
412
+ originalName: token.name,
413
+ name: `${token.name}--${shortSizeName(size2)}`,
414
+ $value: token.$value / basePxFontSize
415
+ });
416
+ var sizeMode = {
417
+ name: "ds/css-size-mode",
418
+ format: async ({ dictionary, file, options, platform }) => {
419
+ const { outputReferences, usesDtcg } = options;
420
+ const { selector, layer, size: size2 } = platform;
421
+ const destination = file.destination;
422
+ const format = createPropertyFormatter4({
423
+ outputReferences,
424
+ dictionary,
425
+ format: "css",
426
+ usesDtcg
427
+ });
428
+ const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
429
+ const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
430
+ const formattedMap = sizeSpecificTokens.map((token) => ({
431
+ token,
432
+ formatted: format({
433
+ ...token,
434
+ // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
435
+ name: token.originalName
436
+ })
437
+ }));
438
+ buildOptions.buildTokenFormats[destination] = formattedMap;
439
+ const content = `${selector} /* ${size2} */ {
440
+ ${sizeSpecificVariables}
441
+ }`;
442
+ const body = wrapInLayer(content, layer);
443
+ const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
444
+ const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
445
+ const sizingToggles = `:root, [data-size] {
446
+ --ds-size: var(--ds-size--${defaultSize});
447
+ ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
448
+ --ds-size-mode-font-size:
449
+ ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
450
+ }`;
451
+ const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
452
+ const sharedContent = `${sizingToggles}
453
+
454
+ ${sizingHelpers}`;
455
+ const sharedBody = shortSizeName(size2) === R6.last(sizes) ? `
456
+ ${wrapInLayer(sharedContent, layer)}` : "";
457
+ return body + sharedBody;
458
+ }
459
+ };
460
+ function wrapInLayer(content, layer) {
461
+ return R6.isNotNil(layer) ? `@layer ${layer} {
462
+ ${content}
463
+ }
464
+ ` : `${content}
465
+ `;
466
+ }
467
+
468
+ // src/tokens/process/formats/css/typography.ts
469
+ import * as R7 from "ramda";
470
+ import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
471
+ var typographyFontFamilyPredicate = R7.allPass([
472
+ R7.pathSatisfies(R7.includes("typography"), ["path"]),
473
+ R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
474
+ ]);
475
+ var typography = {
476
+ name: "ds/css-typography",
477
+ format: async ({ dictionary, file, options, platform }) => {
478
+ const { outputReferences, usesDtcg } = options;
479
+ const { selector, layer } = platform;
480
+ const destination = file.destination;
481
+ const format = createPropertyFormatter5({
482
+ outputReferences,
483
+ dictionary,
484
+ format: "css",
485
+ usesDtcg
486
+ });
487
+ const filteredTokens = R7.reject(typographyFontFamilyPredicate, dictionary.allTokens);
488
+ const formattedMap = filteredTokens.map((token) => ({
489
+ token,
490
+ formatted: format(token)
491
+ }));
492
+ buildOptions.buildTokenFormats[destination] = formattedMap;
493
+ const formattedTokens = formattedMap.map(R7.view(R7.lensProp("formatted"))).join("\n");
494
+ const content = selector ? `${selector} {
495
+ ${formattedTokens}
496
+ }` : formattedTokens;
497
+ const body = R7.isNotNil(layer) ? `@layer ${layer} {
498
+ ${content}
499
+ }` : content;
500
+ return body;
501
+ }
502
+ };
503
+
504
+ // src/tokens/process/formats/css/type-scale.ts
505
+ import * as R8 from "ramda";
506
+ import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
507
+ var typographyFontFamilyPredicate2 = R8.allPass([
508
+ R8.pathSatisfies(R8.includes("typography"), ["path"]),
509
+ R8.pathSatisfies(R8.includes("fontFamily"), ["path"])
510
+ ]);
511
+ function formatTypographySizeToken(token) {
512
+ return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
513
+ }
514
+ var typeScale = {
515
+ name: "ds/css-type-scale",
516
+ format: async ({ dictionary, file, options, platform }) => {
517
+ const { outputReferences, usesDtcg } = options;
518
+ const { selector, layer } = platform;
519
+ const destination = file.destination;
520
+ const format = createPropertyFormatter6({
521
+ outputReferences,
522
+ dictionary,
523
+ format: "css",
524
+ usesDtcg
525
+ });
526
+ const filteredTokens = R8.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
527
+ const tokens = R8.map(formatTypographySizeToken, filteredTokens);
528
+ const formattedMap = tokens.map((token) => ({
529
+ token,
530
+ formatted: format(token)
531
+ }));
532
+ buildOptions.buildTokenFormats[destination] = formattedMap;
533
+ const formattedTokens = formattedMap.map(R8.prop("formatted")).join("\n");
534
+ const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
535
+ const content = `${selector} {
536
+ ${sizeFactor}
537
+ ${formattedTokens}
538
+ }`;
539
+ const body = R8.isNotNil(layer) ? `@layer ${layer} {
540
+ ${content}
541
+ }` : content;
542
+ return body;
543
+ }
544
+ };
545
+
546
+ // src/tokens/process/formats/css.ts
547
+ var formats = {
548
+ colorScheme,
549
+ colorCategory,
550
+ semantic,
551
+ sizeMode,
552
+ size,
553
+ typography,
554
+ typeScale
555
+ };
556
+
378
557
  // src/tokens/process/configs/color.ts
379
558
  var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
380
559
  const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
@@ -396,7 +575,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
396
575
  {
397
576
  destination: `color-scheme/${colorScheme2}.css`,
398
577
  format: formats.colorScheme.name,
399
- filter: (token) => typeEquals("color", token) && !R6.startsWith(["global"], token.path)
578
+ filter: (token) => typeEquals("color", token) && !R9.startsWith(["global"], token.path)
400
579
  }
401
580
  ],
402
581
  options: {
@@ -447,7 +626,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
447
626
  };
448
627
 
449
628
  // src/tokens/process/configs/semantic.ts
450
- import * as R7 from "ramda";
629
+ import * as R10 from "ramda";
451
630
  import { outputReferencesFilter } from "style-dictionary/utils";
452
631
  var semanticVariables = ({ theme }) => {
453
632
  const selector = `:root`;
@@ -470,9 +649,12 @@ var semanticVariables = ({ theme }) => {
470
649
  destination: `semantic.css`,
471
650
  format: formats.semantic.name,
472
651
  filter: (token) => {
473
- const isUwantedToken = R7.anyPass([R7.includes("primitives/global")])(token.filePath);
474
- const isPrivateToken = R7.includes("_", token.path);
475
- const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
652
+ const isUwantedToken = R10.anyPass([R10.includes("primitives/global")])(token.filePath);
653
+ const isPrivateToken = R10.includes("_", token.path);
654
+ const unwantedPaths = pathStartsWithOneOf(
655
+ ["size", "_size", "font-size", "line-height", "letter-spacing"],
656
+ token
657
+ );
476
658
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
477
659
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
478
660
  return unwantedTokens;
@@ -482,8 +664,7 @@ var semanticVariables = ({ theme }) => {
482
664
  options: {
483
665
  outputReferences: (token, options) => {
484
666
  const include = pathStartsWithOneOf(["border-radius"], token);
485
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
486
- return (include || isWantedSize) && outputReferencesFilter(token, options);
667
+ return include && outputReferencesFilter(token, options);
487
668
  }
488
669
  }
489
670
  }
@@ -491,6 +672,124 @@ var semanticVariables = ({ theme }) => {
491
672
  };
492
673
  };
493
674
 
675
+ // src/tokens/process/configs/size.ts
676
+ import * as R11 from "ramda";
677
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
678
+ var sizeVariables = ({ theme }) => {
679
+ const selector = `:root, [data-size]`;
680
+ const layer = `ds.theme.size`;
681
+ return {
682
+ preprocessors: ["tokens-studio"],
683
+ platforms: {
684
+ css: {
685
+ // custom
686
+ theme,
687
+ basePxFontSize,
688
+ selector,
689
+ layer,
690
+ //
691
+ prefix,
692
+ buildPath: `${theme}/`,
693
+ transforms: dsTransformers,
694
+ files: [
695
+ {
696
+ destination: `size.css`,
697
+ format: formats.size.name,
698
+ filter: (token) => {
699
+ const isUwantedToken = R11.anyPass([R11.includes("primitives/global")])(token.filePath);
700
+ const isPrivateToken = R11.includes("_", token.path);
701
+ return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
702
+ }
703
+ }
704
+ ],
705
+ options: {
706
+ outputReferences: (token, options) => {
707
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
708
+ return isWantedSize && outputReferencesFilter2(token, options);
709
+ }
710
+ }
711
+ }
712
+ }
713
+ };
714
+ };
715
+
716
+ // src/tokens/process/configs/size-mode.ts
717
+ import * as R12 from "ramda";
718
+ var sizeModeVariables = ({ theme, size: size2 }) => {
719
+ const selector = `:root`;
720
+ const layer = `ds.theme.size-mode`;
721
+ return {
722
+ preprocessors: ["tokens-studio"],
723
+ platforms: {
724
+ css: {
725
+ // custom
726
+ size: size2,
727
+ theme,
728
+ basePxFontSize,
729
+ selector,
730
+ layer,
731
+ //
732
+ prefix,
733
+ buildPath: `${theme}/`,
734
+ transforms: dsTransformers,
735
+ files: [
736
+ {
737
+ destination: `size-mode/${size2}.css`,
738
+ format: formats.sizeMode.name,
739
+ filter: (token) => {
740
+ return R12.equals(["_size", "mode-font-size"], token.path);
741
+ }
742
+ }
743
+ ]
744
+ }
745
+ }
746
+ };
747
+ };
748
+
749
+ // src/tokens/process/configs/type-scale.ts
750
+ var typeScaleVariables = ({ theme }) => {
751
+ const selector = ":root, [data-size]";
752
+ const layer = `ds.theme.type-scale`;
753
+ return {
754
+ usesDtcg: true,
755
+ preprocessors: ["tokens-studio"],
756
+ expand: {
757
+ include: ["typography"]
758
+ },
759
+ platforms: {
760
+ css: {
761
+ prefix,
762
+ selector,
763
+ layer,
764
+ buildPath: `${theme}/`,
765
+ basePxFontSize,
766
+ transforms: [
767
+ "name/kebab",
768
+ "ts/size/px",
769
+ sizeRem.name,
770
+ "ts/size/lineheight",
771
+ "ts/typography/fontWeight",
772
+ typographyName.name
773
+ ],
774
+ files: [
775
+ {
776
+ destination: `type-scale.css`,
777
+ format: formats.typeScale.name,
778
+ filter: (token) => {
779
+ const included = typeEquals(["typography", "dimension", "fontsize"], token);
780
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
781
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
782
+ }
783
+ }
784
+ ],
785
+ options: {
786
+ outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
787
+ }
788
+ }
789
+ }
790
+ };
791
+ };
792
+
494
793
  // src/tokens/process/configs/typography.ts
495
794
  import { expandTypesMap } from "@tokens-studio/sd-transforms";
496
795
  var typographyVariables = ({ theme, typography: typography2 }) => {
@@ -525,12 +824,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
525
824
  destination: `typography/${typography2}.css`,
526
825
  format: formats.typography.name,
527
826
  filter: (token) => {
528
- const included = typeEquals(
529
- ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
530
- token
531
- );
827
+ const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
532
828
  if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
533
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
829
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
534
830
  }
535
831
  }
536
832
  ]
@@ -705,13 +1001,13 @@ var TypographyValues;
705
1001
  // src/tokens/process/utils/getMultidimensionalThemes.ts
706
1002
  import { kebabCase } from "change-case";
707
1003
  import pc from "picocolors";
708
- import * as R8 from "ramda";
1004
+ import * as R13 from "ramda";
709
1005
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
710
1006
  const verboseLogging = buildOptions?.verbose;
711
1007
  const grouped$themes = groupThemes(processed$themes);
712
1008
  const permutations = permutateThemes(grouped$themes);
713
1009
  const ALL_DEPENDENT_ON = ["theme"];
714
- const keys2 = R8.keys(grouped$themes);
1010
+ const keys2 = R13.keys(grouped$themes);
715
1011
  const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
716
1012
  if (verboseLogging) {
717
1013
  console.log(pc.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
@@ -737,7 +1033,7 @@ function groupThemes(themes) {
737
1033
  }
738
1034
  return groups;
739
1035
  }
740
- var hasUnknownProps = R8.pipe(R8.values, R8.none(R8.equals("unknown")), R8.not);
1036
+ var hasUnknownProps = R13.pipe(R13.values, R13.none(R13.equals("unknown")), R13.not);
741
1037
  function permutateThemes(groups) {
742
1038
  const separator = "_";
743
1039
  const permutations = cartesian(Object.values(groups));
@@ -747,8 +1043,8 @@ function permutateThemes(groups) {
747
1043
  const { group, name, selectedTokenSets } = theme;
748
1044
  let updatedPermutation = acc.permutation;
749
1045
  if (group) {
750
- const groupProp = R8.lensProp(group);
751
- updatedPermutation = R8.set(groupProp, name, updatedPermutation);
1046
+ const groupProp = R13.lensProp(group);
1047
+ updatedPermutation = R13.set(groupProp, name, updatedPermutation);
752
1048
  }
753
1049
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
754
1050
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -819,7 +1115,10 @@ var configs = {
819
1115
  dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
820
1116
  warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
821
1117
  infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
1118
+ sizeModeVariables,
1119
+ sizeVariables,
822
1120
  typographyVariables,
1121
+ typeScaleVariables,
823
1122
  semanticVariables
824
1123
  };
825
1124
  var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
@@ -836,7 +1135,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
836
1135
  obj.filePath = tokenSet;
837
1136
  }
838
1137
  });
839
- tokenSource.tokens = R9.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
1138
+ tokenSource.tokens = R14.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
840
1139
  }
841
1140
  }
842
1141
  } else {
@@ -887,6 +1186,9 @@ var buildOptions = {
887
1186
  var sd = new StyleDictionary2();
888
1187
  var buildConfigs = {
889
1188
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
1189
+ sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
1190
+ size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
1191
+ typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
890
1192
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
891
1193
  "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
892
1194
  "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
@@ -922,9 +1224,6 @@ async function processPlatform(options) {
922
1224
  const platform = "css";
923
1225
  const tokenSets = type === "format" ? options.tokenSets : void 0;
924
1226
  const tokensDir = type === "build" ? options.tokensDir : void 0;
925
- const filteredProcessed$themes = processed$themes.filter(
926
- (theme) => R10.not(theme.group === "size" && theme.name !== "medium")
927
- );
928
1227
  const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
929
1228
  if (UNSAFE_DEFAULT_COLOR) {
930
1229
  console.warn(
@@ -948,24 +1247,29 @@ async function processPlatform(options) {
948
1247
  buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
949
1248
  buildOptions.colorGroups = colorGroups;
950
1249
  if (!buildOptions.defaultColor) {
951
- const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
952
- const firstMainColor = R10.head(customColors);
1250
+ const customColors = getCustomColors(processed$themes, colorGroups);
1251
+ const firstMainColor = R15.head(customColors);
953
1252
  buildOptions.defaultColor = firstMainColor;
954
1253
  }
955
1254
  if (buildOptions.defaultColor) {
956
1255
  console.log(`
957
1256
  \u{1F3A8} Using ${pc2.blue(buildOptions.defaultColor)} as default color`);
958
1257
  }
959
- const buildAndSdConfigs = R10.map((buildConfig) => {
960
- const sdConfigs = getConfigsForThemeDimensions(
961
- buildConfig.getConfig,
962
- filteredProcessed$themes,
963
- buildConfig.dimensions,
964
- {
965
- tokensDir,
966
- tokenSets
967
- }
968
- );
1258
+ const sizeModes = processed$themes.filter((x) => x.group === "size").map((x) => x.name);
1259
+ buildOptions.sizeModes = sizeModes;
1260
+ if (!buildOptions.defaultSize) {
1261
+ const defaultSize = R15.head(sizeModes);
1262
+ buildOptions.defaultSize = defaultSize;
1263
+ }
1264
+ if (buildOptions.defaultSize) {
1265
+ console.log(`
1266
+ \u{1F4CF} Using ${pc2.blue(buildOptions.defaultSize)} as default size`);
1267
+ }
1268
+ const buildAndSdConfigs = R15.map((buildConfig) => {
1269
+ const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
1270
+ tokensDir,
1271
+ tokenSets
1272
+ });
969
1273
  const unknownConfigs = buildConfig.dimensions.map(
970
1274
  (dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
971
1275
  );
@@ -989,10 +1293,13 @@ async function processPlatform(options) {
989
1293
  "warning-color": [initResult],
990
1294
  "info-color": [initResult],
991
1295
  semantic: [initResult],
992
- typography: [initResult]
1296
+ typography: [initResult],
1297
+ sizeMode: [initResult],
1298
+ size: [initResult],
1299
+ typeScale: [initResult]
993
1300
  };
994
1301
  try {
995
- for (const [buildName, { buildConfig, sdConfigs }] of R10.toPairs(buildAndSdConfigs)) {
1302
+ for (const [buildName, { buildConfig, sdConfigs }] of R15.toPairs(buildAndSdConfigs)) {
996
1303
  if (!(buildConfig.enabled?.() ?? true)) {
997
1304
  continue;
998
1305
  }
@@ -1004,7 +1311,7 @@ async function processPlatform(options) {
1004
1311
  const { config, permutation } = sdConfig;
1005
1312
  const modes = ["theme", ...buildConfig.dimensions];
1006
1313
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
1007
- const logMessage = R10.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1314
+ const logMessage = R15.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1008
1315
  console.log(logMessage);
1009
1316
  const sdOptions = { cache: true };
1010
1317
  const sdExtended = await sd.extend(config);