@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,10 +1,10 @@
1
1
  // src/tokens/process/formats/css/typography.ts
2
- import * as R10 from "ramda";
3
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
2
+ import * as R15 from "ramda";
3
+ import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
4
4
 
5
5
  // src/tokens/process/platform.ts
6
6
  import pc2 from "picocolors";
7
- import * as R9 from "ramda";
7
+ import * as R14 from "ramda";
8
8
  import StyleDictionary2 from "style-dictionary";
9
9
 
10
10
  // src/tokens/types.ts
@@ -15,7 +15,7 @@ var colorCategories = {
15
15
 
16
16
  // src/tokens/process/configs.ts
17
17
  import { register } from "@tokens-studio/sd-transforms";
18
- import * as R8 from "ramda";
18
+ import * as R13 from "ramda";
19
19
  import StyleDictionary from "style-dictionary";
20
20
 
21
21
  // src/tokens/utils.ts
@@ -38,7 +38,10 @@ var pathStartsWithOneOf = R.curry(
38
38
  return false;
39
39
  }
40
40
  const tokenPath = mapToLowerCase(token.path);
41
- const matchPathsStartingWith = R.map((path) => R.startsWith([path], tokenPath), mapToLowerCase(paths));
41
+ const matchPathsStartingWith = R.map((pathOrString) => {
42
+ const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
43
+ return R.startsWith(mapToLowerCase(path), tokenPath);
44
+ }, paths);
42
45
  return hasAnyTruth(matchPathsStartingWith);
43
46
  }
44
47
  );
@@ -74,9 +77,26 @@ function inlineTokens(shouldInline, tokens) {
74
77
  return tokenWithInlinedRefs;
75
78
  });
76
79
  }
80
+ var sizeMap = {
81
+ xsmall: "xs",
82
+ small: "sm",
83
+ medium: "md",
84
+ large: "lg",
85
+ xlarge: "xl"
86
+ };
87
+ function shortSizeName(size2) {
88
+ return sizeMap[size2] ?? size2;
89
+ }
90
+ var sizeComparator = (size2) => {
91
+ const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
92
+ return sortIndex ?? 0;
93
+ };
94
+ function orderBySize(sizes) {
95
+ return R.sortBy(sizeComparator, sizes);
96
+ }
77
97
 
78
98
  // src/tokens/process/configs/color.ts
79
- import * as R5 from "ramda";
99
+ import * as R8 from "ramda";
80
100
 
81
101
  // src/tokens/process/formats/css/color.ts
82
102
  import * as R2 from "ramda";
@@ -134,10 +154,10 @@ ${selector} ${content} ${autoSelectorContent}
134
154
  };
135
155
  var colorCategory = {
136
156
  name: "ds/css-colorcategory",
137
- format: async ({ dictionary, options, platform }) => {
157
+ format: async ({ dictionary, file, options, platform }) => {
138
158
  const { outputReferences, usesDtcg } = options;
139
- const { selector, layer, files } = platform;
140
- const destination = files?.[0]?.destination;
159
+ const { selector, layer } = platform;
160
+ const destination = file.destination;
141
161
  const format = R2.compose(
142
162
  createPropertyFormatter({
143
163
  outputReferences,
@@ -174,6 +194,10 @@ ${selector} ${content}
174
194
  };
175
195
 
176
196
  // src/tokens/process/formats/css/semantic.ts
197
+ import * as R4 from "ramda";
198
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
199
+
200
+ // src/tokens/process/formats/css/size.ts
177
201
  import * as R3 from "ramda";
178
202
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
179
203
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
@@ -181,12 +205,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
181
205
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
182
206
  var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
183
207
  var overrideSizingFormula = (format, token) => {
184
- const [name, value] = format(token).split(":");
185
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
186
- const round = `round(down, ${calc}, 1px)`;
208
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
209
+ let calc;
210
+ let round;
211
+ if (token.path[1] === "unit") {
212
+ calc = `calc(1rem * ${value})`;
213
+ } else if (value.startsWith("floor")) {
214
+ calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
215
+ round = `round(down, ${calc}, 1px)`;
216
+ } else {
217
+ calc = value.includes("*") ? `calc(${value})` : value;
218
+ }
187
219
  return {
188
220
  name,
189
- round,
221
+ round: round ?? calc,
190
222
  calc
191
223
  };
192
224
  };
@@ -202,18 +234,21 @@ var formatSizingTokens = (format, tokens) => R3.reduce(
202
234
  { tokens: [], round: [], calc: [] },
203
235
  tokens
204
236
  );
205
- var sizingTemplate = ({ round, calc }) => `
237
+ var sizingTemplate = ({ round, calc }) => {
238
+ const usesRounding = round.filter((val, i) => val !== calc[i]);
239
+ return `
206
240
  ${calc.join("\n")}
207
241
 
208
242
  @supports (width: round(down, .1em, 1px)) {
209
- ${round.join("\n")}
243
+ ${usesRounding.join("\n ")}
210
244
  }`;
211
- var semantic = {
212
- name: "ds/css-semantic",
213
- format: async ({ dictionary, options, platform }) => {
245
+ };
246
+ var size = {
247
+ name: "ds/css-size",
248
+ format: async ({ dictionary, file, options, platform }) => {
214
249
  const { outputReferences, usesDtcg } = options;
215
- const { selector, layer, files } = platform;
216
- const destination = files?.[0]?.destination;
250
+ const { selector, layer } = platform;
251
+ const destination = file.destination;
217
252
  const format = createPropertyFormatter2({
218
253
  outputReferences,
219
254
  dictionary,
@@ -221,9 +256,9 @@ var semantic = {
221
256
  usesDtcg
222
257
  });
223
258
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
224
- const filteredTokens = R3.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
259
+ const filteredTokens = R3.reject((token) => R3.equals(["_size", "mode-font-size"], token.path), tokens);
225
260
  const [sizingTokens, restTokens] = R3.partition(
226
- (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
261
+ (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
227
262
  filteredTokens
228
263
  );
229
264
  const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
@@ -236,51 +271,83 @@ var semantic = {
236
271
  formatted: t
237
272
  }));
238
273
  buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
239
- const sizingSnippet = sizingTemplate(formattedSizingTokens);
240
- const formattedTokens = formattedMap.map(R3.view(R3.lensProp("formatted"))).concat(sizingSnippet);
241
- const content = `{
274
+ const formattedTokens = [formattedMap.map(R3.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
275
+ const content = `${selector} {
242
276
  ${formattedTokens.join("\n")}
243
277
  }
244
278
  `;
245
279
  const body = R3.isNotNil(layer) ? `@layer ${layer} {
246
- ${selector} ${content}
280
+ ${content}
247
281
  }
248
- ` : `${selector} ${content}
282
+ ` : `${content}
249
283
  `;
250
284
  return body;
251
285
  }
252
286
  };
253
287
 
254
- // src/tokens/process/formats/css.ts
255
- var formats = {
256
- colorScheme,
257
- colorCategory,
258
- semantic,
259
- typography
288
+ // src/tokens/process/formats/css/semantic.ts
289
+ var semantic = {
290
+ name: "ds/css-semantic",
291
+ format: async ({ dictionary, file, options, platform }) => {
292
+ const { outputReferences, usesDtcg } = options;
293
+ const { selector, layer } = platform;
294
+ const destination = file.destination;
295
+ const format = createPropertyFormatter3({
296
+ outputReferences,
297
+ dictionary,
298
+ format: "css",
299
+ usesDtcg
300
+ });
301
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
302
+ const formattedMap = tokens.map((token) => ({
303
+ token,
304
+ formatted: format(token)
305
+ }));
306
+ buildOptions.buildTokenFormats[destination] = formattedMap;
307
+ const formattedTokens = formattedMap.map(R4.prop("formatted")).join("\n");
308
+ const content = `${selector} {
309
+ ${formattedTokens}
310
+ }
311
+ `;
312
+ const body = R4.isNotNil(layer) ? `@layer ${layer} {
313
+ ${content}
314
+ }
315
+ ` : `${content}
316
+ `;
317
+ return body;
318
+ }
260
319
  };
261
320
 
321
+ // src/tokens/process/formats/css/size-mode.ts
322
+ import * as R6 from "ramda";
323
+ import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
324
+
262
325
  // src/tokens/process/transformers.ts
263
326
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
264
- import * as R4 from "ramda";
265
- var isPx = R4.test(/\b\d+px\b/g);
327
+ import * as R5 from "ramda";
328
+ var isPx = R5.test(/\b\d+px\b/g);
266
329
  var sizeRem = {
267
330
  name: "ds/size/toRem",
268
331
  type: "value",
269
332
  transitive: true,
270
333
  filter: (token) => {
271
334
  const hasWantedType = typeEquals(["dimension", "fontsize"], token);
272
- const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
335
+ const hasWantedPath = pathStartsWithOneOf([
336
+ "border-radius",
337
+ "font-size"
338
+ /*, ['_size', 'mode-font-size']*/
339
+ ], token);
273
340
  return hasWantedType && hasWantedPath;
274
341
  },
275
342
  transform: (token, config) => {
276
343
  const value = getValue(token);
277
344
  if (isPx(value)) {
278
345
  const baseFont = config.basePxFontSize || 16;
279
- const size = parseInt(value, 10);
280
- if (size === 0) {
346
+ const size2 = parseInt(value, 10);
347
+ if (size2 === 0) {
281
348
  return "0";
282
349
  }
283
- return `${size / baseFont}rem`;
350
+ return `${size2 / baseFont}rem`;
284
351
  }
285
352
  return value;
286
353
  }
@@ -331,6 +398,118 @@ var dsTransformers = [
331
398
  "shadow/css/shorthand"
332
399
  ];
333
400
 
401
+ // src/tokens/process/formats/css/size-mode.ts
402
+ var formatBaseSizeToken = (size2) => (token) => ({
403
+ ...token,
404
+ originalName: token.name,
405
+ name: `${token.name}--${shortSizeName(size2)}`,
406
+ $value: token.$value / basePxFontSize
407
+ });
408
+ var sizeMode = {
409
+ name: "ds/css-size-mode",
410
+ format: async ({ dictionary, file, options, platform }) => {
411
+ const { outputReferences, usesDtcg } = options;
412
+ const { selector, layer, size: size2 } = platform;
413
+ const destination = file.destination;
414
+ const format = createPropertyFormatter4({
415
+ outputReferences,
416
+ dictionary,
417
+ format: "css",
418
+ usesDtcg
419
+ });
420
+ const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
421
+ const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
422
+ const formattedMap = sizeSpecificTokens.map((token) => ({
423
+ token,
424
+ formatted: format({
425
+ ...token,
426
+ // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
427
+ name: token.originalName
428
+ })
429
+ }));
430
+ buildOptions.buildTokenFormats[destination] = formattedMap;
431
+ const content = `${selector} /* ${size2} */ {
432
+ ${sizeSpecificVariables}
433
+ }`;
434
+ const body = wrapInLayer(content, layer);
435
+ const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
436
+ const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
437
+ const sizingToggles = `:root, [data-size] {
438
+ --ds-size: var(--ds-size--${defaultSize});
439
+ ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
440
+ --ds-size-mode-font-size:
441
+ ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
442
+ }`;
443
+ const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
444
+ const sharedContent = `${sizingToggles}
445
+
446
+ ${sizingHelpers}`;
447
+ const sharedBody = shortSizeName(size2) === R6.last(sizes) ? `
448
+ ${wrapInLayer(sharedContent, layer)}` : "";
449
+ return body + sharedBody;
450
+ }
451
+ };
452
+ function wrapInLayer(content, layer) {
453
+ return R6.isNotNil(layer) ? `@layer ${layer} {
454
+ ${content}
455
+ }
456
+ ` : `${content}
457
+ `;
458
+ }
459
+
460
+ // src/tokens/process/formats/css/type-scale.ts
461
+ import * as R7 from "ramda";
462
+ import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
463
+ var typographyFontFamilyPredicate = R7.allPass([
464
+ R7.pathSatisfies(R7.includes("typography"), ["path"]),
465
+ R7.pathSatisfies(R7.includes("fontFamily"), ["path"])
466
+ ]);
467
+ function formatTypographySizeToken(token) {
468
+ return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
469
+ }
470
+ var typeScale = {
471
+ name: "ds/css-type-scale",
472
+ format: async ({ dictionary, file, options, platform }) => {
473
+ const { outputReferences, usesDtcg } = options;
474
+ const { selector, layer } = platform;
475
+ const destination = file.destination;
476
+ const format = createPropertyFormatter5({
477
+ outputReferences,
478
+ dictionary,
479
+ format: "css",
480
+ usesDtcg
481
+ });
482
+ const filteredTokens = R7.reject(typographyFontFamilyPredicate, dictionary.allTokens);
483
+ const tokens = R7.map(formatTypographySizeToken, filteredTokens);
484
+ const formattedMap = tokens.map((token) => ({
485
+ token,
486
+ formatted: format(token)
487
+ }));
488
+ buildOptions.buildTokenFormats[destination] = formattedMap;
489
+ const formattedTokens = formattedMap.map(R7.prop("formatted")).join("\n");
490
+ const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
491
+ const content = `${selector} {
492
+ ${sizeFactor}
493
+ ${formattedTokens}
494
+ }`;
495
+ const body = R7.isNotNil(layer) ? `@layer ${layer} {
496
+ ${content}
497
+ }` : content;
498
+ return body;
499
+ }
500
+ };
501
+
502
+ // src/tokens/process/formats/css.ts
503
+ var formats = {
504
+ colorScheme,
505
+ colorCategory,
506
+ semantic,
507
+ sizeMode,
508
+ size,
509
+ typography,
510
+ typeScale
511
+ };
512
+
334
513
  // src/tokens/process/configs/color.ts
335
514
  var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
336
515
  const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
@@ -352,7 +531,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
352
531
  {
353
532
  destination: `color-scheme/${colorScheme2}.css`,
354
533
  format: formats.colorScheme.name,
355
- filter: (token) => typeEquals("color", token) && !R5.startsWith(["global"], token.path)
534
+ filter: (token) => typeEquals("color", token) && !R8.startsWith(["global"], token.path)
356
535
  }
357
536
  ],
358
537
  options: {
@@ -403,7 +582,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
403
582
  };
404
583
 
405
584
  // src/tokens/process/configs/semantic.ts
406
- import * as R6 from "ramda";
585
+ import * as R9 from "ramda";
407
586
  import { outputReferencesFilter } from "style-dictionary/utils";
408
587
  var semanticVariables = ({ theme }) => {
409
588
  const selector = `:root`;
@@ -426,9 +605,12 @@ var semanticVariables = ({ theme }) => {
426
605
  destination: `semantic.css`,
427
606
  format: formats.semantic.name,
428
607
  filter: (token) => {
429
- const isUwantedToken = R6.anyPass([R6.includes("primitives/global")])(token.filePath);
430
- const isPrivateToken = R6.includes("_", token.path);
431
- const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
608
+ const isUwantedToken = R9.anyPass([R9.includes("primitives/global")])(token.filePath);
609
+ const isPrivateToken = R9.includes("_", token.path);
610
+ const unwantedPaths = pathStartsWithOneOf(
611
+ ["size", "_size", "font-size", "line-height", "letter-spacing"],
612
+ token
613
+ );
432
614
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
433
615
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
434
616
  return unwantedTokens;
@@ -438,8 +620,48 @@ var semanticVariables = ({ theme }) => {
438
620
  options: {
439
621
  outputReferences: (token, options) => {
440
622
  const include = pathStartsWithOneOf(["border-radius"], token);
441
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
442
- return (include || isWantedSize) && outputReferencesFilter(token, options);
623
+ return include && outputReferencesFilter(token, options);
624
+ }
625
+ }
626
+ }
627
+ }
628
+ };
629
+ };
630
+
631
+ // src/tokens/process/configs/size.ts
632
+ import * as R10 from "ramda";
633
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
634
+ var sizeVariables = ({ theme }) => {
635
+ const selector = `:root, [data-size]`;
636
+ const layer = `ds.theme.size`;
637
+ return {
638
+ preprocessors: ["tokens-studio"],
639
+ platforms: {
640
+ css: {
641
+ // custom
642
+ theme,
643
+ basePxFontSize,
644
+ selector,
645
+ layer,
646
+ //
647
+ prefix,
648
+ buildPath: `${theme}/`,
649
+ transforms: dsTransformers,
650
+ files: [
651
+ {
652
+ destination: `size.css`,
653
+ format: formats.size.name,
654
+ filter: (token) => {
655
+ const isUwantedToken = R10.anyPass([R10.includes("primitives/global")])(token.filePath);
656
+ const isPrivateToken = R10.includes("_", token.path);
657
+ return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
658
+ }
659
+ }
660
+ ],
661
+ options: {
662
+ outputReferences: (token, options) => {
663
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
664
+ return isWantedSize && outputReferencesFilter2(token, options);
443
665
  }
444
666
  }
445
667
  }
@@ -447,6 +669,83 @@ var semanticVariables = ({ theme }) => {
447
669
  };
448
670
  };
449
671
 
672
+ // src/tokens/process/configs/size-mode.ts
673
+ import * as R11 from "ramda";
674
+ var sizeModeVariables = ({ theme, size: size2 }) => {
675
+ const selector = `:root`;
676
+ const layer = `ds.theme.size-mode`;
677
+ return {
678
+ preprocessors: ["tokens-studio"],
679
+ platforms: {
680
+ css: {
681
+ // custom
682
+ size: size2,
683
+ theme,
684
+ basePxFontSize,
685
+ selector,
686
+ layer,
687
+ //
688
+ prefix,
689
+ buildPath: `${theme}/`,
690
+ transforms: dsTransformers,
691
+ files: [
692
+ {
693
+ destination: `size-mode/${size2}.css`,
694
+ format: formats.sizeMode.name,
695
+ filter: (token) => {
696
+ return R11.equals(["_size", "mode-font-size"], token.path);
697
+ }
698
+ }
699
+ ]
700
+ }
701
+ }
702
+ };
703
+ };
704
+
705
+ // src/tokens/process/configs/type-scale.ts
706
+ var typeScaleVariables = ({ theme }) => {
707
+ const selector = ":root, [data-size]";
708
+ const layer = `ds.theme.type-scale`;
709
+ return {
710
+ usesDtcg: true,
711
+ preprocessors: ["tokens-studio"],
712
+ expand: {
713
+ include: ["typography"]
714
+ },
715
+ platforms: {
716
+ css: {
717
+ prefix,
718
+ selector,
719
+ layer,
720
+ buildPath: `${theme}/`,
721
+ basePxFontSize,
722
+ transforms: [
723
+ "name/kebab",
724
+ "ts/size/px",
725
+ sizeRem.name,
726
+ "ts/size/lineheight",
727
+ "ts/typography/fontWeight",
728
+ typographyName.name
729
+ ],
730
+ files: [
731
+ {
732
+ destination: `type-scale.css`,
733
+ format: formats.typeScale.name,
734
+ filter: (token) => {
735
+ const included = typeEquals(["typography", "dimension", "fontsize"], token);
736
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
737
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
738
+ }
739
+ }
740
+ ],
741
+ options: {
742
+ outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
743
+ }
744
+ }
745
+ }
746
+ };
747
+ };
748
+
450
749
  // src/tokens/process/configs/typography.ts
451
750
  import { expandTypesMap } from "@tokens-studio/sd-transforms";
452
751
  var typographyVariables = ({ theme, typography: typography2 }) => {
@@ -481,12 +780,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
481
780
  destination: `typography/${typography2}.css`,
482
781
  format: formats.typography.name,
483
782
  filter: (token) => {
484
- const included = typeEquals(
485
- ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
486
- token
487
- );
783
+ const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
488
784
  if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
489
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
785
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
490
786
  }
491
787
  }
492
788
  ]
@@ -661,9 +957,9 @@ var TypographyValues;
661
957
  // src/tokens/process/utils/getMultidimensionalThemes.ts
662
958
  import { kebabCase } from "change-case";
663
959
  import pc from "picocolors";
664
- import * as R7 from "ramda";
960
+ import * as R12 from "ramda";
665
961
  var processed = Symbol("Type brand for ProcessedThemeObject");
666
- var hasUnknownProps = R7.pipe(R7.values, R7.none(R7.equals("unknown")), R7.not);
962
+ var hasUnknownProps = R12.pipe(R12.values, R12.none(R12.equals("unknown")), R12.not);
667
963
 
668
964
  // src/tokens/process/configs.ts
669
965
  void register(StyleDictionary, { withSDBuiltins: false });
@@ -683,7 +979,10 @@ var configs = {
683
979
  dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
684
980
  warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
685
981
  infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
982
+ sizeModeVariables,
983
+ sizeVariables,
686
984
  typographyVariables,
985
+ typeScaleVariables,
687
986
  semanticVariables
688
987
  };
689
988
 
@@ -696,6 +995,9 @@ var buildOptions = {
696
995
  var sd = new StyleDictionary2();
697
996
  var buildConfigs = {
698
997
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
998
+ sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
999
+ size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
1000
+ typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
699
1001
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
700
1002
  "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
701
1003
  "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
@@ -728,33 +1030,33 @@ var buildConfigs = {
728
1030
  };
729
1031
 
730
1032
  // src/tokens/process/formats/css/typography.ts
731
- var typographyFontFamilyPredicate = R10.allPass([
732
- R10.pathSatisfies(R10.includes("typography"), ["path"]),
733
- R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
1033
+ var typographyFontFamilyPredicate2 = R15.allPass([
1034
+ R15.pathSatisfies(R15.includes("typography"), ["path"]),
1035
+ R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
734
1036
  ]);
735
1037
  var typography = {
736
1038
  name: "ds/css-typography",
737
- format: async ({ dictionary, options, platform }) => {
1039
+ format: async ({ dictionary, file, options, platform }) => {
738
1040
  const { outputReferences, usesDtcg } = options;
739
- const { selector, layer, files } = platform;
740
- const destination = files?.[0]?.destination;
741
- const format = createPropertyFormatter3({
1041
+ const { selector, layer } = platform;
1042
+ const destination = file.destination;
1043
+ const format = createPropertyFormatter6({
742
1044
  outputReferences,
743
1045
  dictionary,
744
1046
  format: "css",
745
1047
  usesDtcg
746
1048
  });
747
- const filteredTokens = R10.reject(typographyFontFamilyPredicate, dictionary.allTokens);
1049
+ const filteredTokens = R15.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
748
1050
  const formattedMap = filteredTokens.map((token) => ({
749
1051
  token,
750
1052
  formatted: format(token)
751
1053
  }));
752
1054
  buildOptions.buildTokenFormats[destination] = formattedMap;
753
- const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).join("\n");
1055
+ const formattedTokens = formattedMap.map(R15.view(R15.lensProp("formatted"))).join("\n");
754
1056
  const content = selector ? `${selector} {
755
1057
  ${formattedTokens}
756
1058
  }` : formattedTokens;
757
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
1059
+ const body = R15.isNotNil(layer) ? `@layer ${layer} {
758
1060
  ${content}
759
1061
  }` : content;
760
1062
  return body;
@@ -3,6 +3,9 @@ export declare const formats: {
3
3
  colorScheme: Format;
4
4
  colorCategory: Format;
5
5
  semantic: Format;
6
+ sizeMode: Format;
7
+ size: Format;
6
8
  typography: Format;
9
+ typeScale: Format;
7
10
  };
8
11
  //# sourceMappingURL=css.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/formats/css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAMrD,eAAO,MAAM,OAAO;;;;;CAKc,CAAC"}
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/formats/css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASrD,eAAO,MAAM,OAAO;;;;;;;;CAQc,CAAC"}