@digdir/designsystemet 1.13.2 → 1.13.3

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 (74) hide show
  1. package/dist/bin/config.js +50 -658
  2. package/dist/bin/designsystemet.js +131 -4623
  3. package/dist/bin/options.js +22 -14
  4. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js +9 -0
  5. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js +8 -0
  6. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js +13 -0
  7. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js +10 -0
  8. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js +10 -0
  9. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js +53 -0
  10. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js +14 -0
  11. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js +9 -0
  12. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js +32 -0
  13. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js +15 -0
  14. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/types/index.js +11 -0
  15. package/dist/package.js +5 -0
  16. package/dist/src/colors/colorMetadata.js +255 -261
  17. package/dist/src/colors/index.js +5 -522
  18. package/dist/src/colors/theme.js +104 -343
  19. package/dist/src/colors/types.js +22 -25
  20. package/dist/src/colors/utils.js +241 -154
  21. package/dist/src/config.js +103 -444
  22. package/dist/src/index.js +10 -3588
  23. package/dist/src/migrations/beta-to-v1.js +339 -537
  24. package/dist/src/migrations/codemods/css/plugins.js +31 -42
  25. package/dist/src/migrations/codemods/css/run.js +20 -151
  26. package/dist/src/migrations/color-rename-next49.js +44 -220
  27. package/dist/src/migrations/index.js +7 -577
  28. package/dist/src/tokens/build.js +39 -1816
  29. package/dist/src/tokens/create/files.js +43 -602
  30. package/dist/src/tokens/create/generators/$designsystemet.js +8 -97
  31. package/dist/src/tokens/create/generators/$metadata.js +17 -20
  32. package/dist/src/tokens/create/generators/$themes.js +137 -311
  33. package/dist/src/tokens/create/generators/primitives/color-scheme.js +68 -443
  34. package/dist/src/tokens/create/generators/primitives/globals.js +141 -147
  35. package/dist/src/tokens/create/generators/primitives/size.js +146 -156
  36. package/dist/src/tokens/create/generators/primitives/typography.js +213 -217
  37. package/dist/src/tokens/create/generators/semantic/color-modes.js +24 -59
  38. package/dist/src/tokens/create/generators/semantic/color.js +42 -326
  39. package/dist/src/tokens/create/generators/semantic/style.js +379 -382
  40. package/dist/src/tokens/create/generators/themes/theme.js +108 -392
  41. package/dist/src/tokens/create.js +47 -1591
  42. package/dist/src/tokens/format.js +38 -3324
  43. package/dist/src/tokens/generate-config.js +155 -298
  44. package/dist/src/tokens/index.js +3 -3344
  45. package/dist/src/tokens/process/configs/color.js +50 -1085
  46. package/dist/src/tokens/process/configs/semantic.js +45 -1083
  47. package/dist/src/tokens/process/configs/shared.js +18 -109
  48. package/dist/src/tokens/process/configs/size-mode.js +27 -1082
  49. package/dist/src/tokens/process/configs/size.js +32 -1083
  50. package/dist/src/tokens/process/configs/type-scale.js +49 -1083
  51. package/dist/src/tokens/process/configs/typography.js +63 -1084
  52. package/dist/src/tokens/process/configs.js +88 -1224
  53. package/dist/src/tokens/process/formats/css/color.js +58 -1079
  54. package/dist/src/tokens/process/formats/css/semantic.js +27 -1081
  55. package/dist/src/tokens/process/formats/css/size-mode.js +43 -1077
  56. package/dist/src/tokens/process/formats/css/size.js +86 -1079
  57. package/dist/src/tokens/process/formats/css/type-scale.js +53 -1083
  58. package/dist/src/tokens/process/formats/css/typography.js +27 -1081
  59. package/dist/src/tokens/process/formats/css.js +18 -1081
  60. package/dist/src/tokens/process/output/declarations.js +18 -1201
  61. package/dist/src/tokens/process/output/tailwind.js +26 -40
  62. package/dist/src/tokens/process/output/theme.js +73 -206
  63. package/dist/src/tokens/process/platform.js +165 -1355
  64. package/dist/src/tokens/process/transformers.js +49 -89
  65. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +100 -1183
  66. package/dist/src/tokens/process/utils/kebab-case.js +7 -5
  67. package/dist/src/tokens/types.js +6 -7
  68. package/dist/src/tokens/utils.js +102 -93
  69. package/dist/src/types.js +1 -5
  70. package/dist/src/utils/filesystem.js +112 -124
  71. package/package.json +10 -13
  72. package/configs/test-tokens.config.json +0 -82
  73. package/dist/src/scripts/createJsonSchema.js +0 -409
  74. package/dist/src/scripts/update-preview-tokens.js +0 -3353
@@ -1,1085 +1,64 @@
1
- // src/tokens/process/configs/typography.ts
1
+ import { pathStartsWithOneOf, typeEquals } from "../../utils.js";
2
+ import { sizeRem, typographyName } from "../transformers.js";
3
+ import "./shared.js";
4
+ import { formats } from "../formats/css.js";
2
5
  import { expandTypesMap } from "@tokens-studio/sd-transforms";
3
-
4
- // src/tokens/utils.ts
5
- import * as R from "ramda";
6
-
7
- // src/tokens/types.ts
8
- var colorCategories = {
9
- main: "main",
10
- support: "support"
11
- };
12
-
13
- // src/tokens/utils.ts
14
- var mapToLowerCase = R.map(R.toLower);
15
- var hasAnyTruth = R.any(R.equals(true));
16
- var getType = (token) => (token.$type ?? token.type) || "";
17
- var getValue = (token) => token.$value ?? token.value;
18
- var typeEquals = R.curry(
19
- (types, token) => {
20
- if (R.isNil(token)) {
21
- return false;
22
- }
23
- return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));
24
- }
25
- );
26
- var pathStartsWithOneOf = R.curry(
27
- (paths, token) => {
28
- if (R.isNil(token)) {
29
- return false;
30
- }
31
- const tokenPath = mapToLowerCase(token.path);
32
- const matchPathsStartingWith = R.map((pathOrString) => {
33
- const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
34
- return R.startsWith(mapToLowerCase(path), tokenPath);
35
- }, paths);
36
- return hasAnyTruth(matchPathsStartingWith);
37
- }
38
- );
39
- function isSemanticToken(token) {
40
- return token.filePath.includes("semantic/");
41
- }
42
- function isSemanticColorToken(token, color) {
43
- return token.filePath.includes("semantic/") && R.startsWith(["color", color], token.path);
44
- }
45
- function isGlobalColorToken(token) {
46
- return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
47
- }
48
- function isColorCategoryToken(token, category) {
49
- if (!category) {
50
- return Object.keys(colorCategories).some(
51
- (colorCategory2) => isColorCategoryToken(token, colorCategory2)
52
- );
53
- }
54
- return R.startsWith(["color", category], token.path);
55
- }
56
- var isDigit = (s) => /^\d+$/.test(s);
57
- function inlineTokens(shouldInline, tokens) {
58
- const [inlineableTokens, otherTokens] = R.partition(shouldInline, tokens);
59
- return otherTokens.map((token) => {
60
- let transformed = getValue(token.original);
61
- for (const ref of inlineableTokens) {
62
- const refName = ref.path.join(".");
63
- if (typeof transformed === "string") {
64
- transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
65
- }
66
- }
67
- const tokenWithInlinedRefs = R.set(R.lensPath(["original", "$value"]), transformed, token);
68
- return tokenWithInlinedRefs;
69
- });
70
- }
71
- var sizeMap = {
72
- xsmall: "xs",
73
- small: "sm",
74
- medium: "md",
75
- large: "lg",
76
- xlarge: "xl"
77
- };
78
- function shortSizeName(size2) {
79
- return sizeMap[size2] ?? size2;
80
- }
81
- var sizeComparator = (size2) => {
82
- const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
83
- return sortIndex ?? 0;
84
- };
85
- function orderBySize(sizes) {
86
- return R.sortBy(sizeComparator, sizes);
87
- }
88
-
89
- // src/tokens/process/formats/css/color.ts
90
- import * as R10 from "ramda";
91
- import { createPropertyFormatter } from "style-dictionary/utils";
92
-
93
- // src/tokens/process/platform.ts
94
- import pc2 from "picocolors";
95
- import * as R9 from "ramda";
96
- import StyleDictionary2 from "style-dictionary";
97
-
98
- // src/tokens/process/configs.ts
99
- import { register } from "@tokens-studio/sd-transforms";
100
- import * as R8 from "ramda";
101
- import StyleDictionary from "style-dictionary";
102
-
103
- // src/tokens/process/configs/color.ts
104
- import * as R3 from "ramda";
105
-
106
- // src/tokens/process/transformers.ts
107
- import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
108
- import * as R2 from "ramda";
109
- var isPx = R2.test(/\b\d+px\b/g);
110
- var sizeRem = {
111
- name: "ds/size/toRem",
112
- type: "value",
113
- transitive: true,
114
- filter: (token) => {
115
- const hasWantedType = typeEquals(["dimension", "fontsize"], token);
116
- const hasWantedPath = pathStartsWithOneOf([
117
- "border-radius",
118
- "font-size"
119
- /*, ['_size', 'mode-font-size']*/
120
- ], token);
121
- return hasWantedType && hasWantedPath;
122
- },
123
- transform: (token, config) => {
124
- const value = getValue(token);
125
- if (isPx(value)) {
126
- const baseFont = config.basePxFontSize || 16;
127
- const size2 = parseInt(value, 10);
128
- if (size2 === 0) {
129
- return "0";
130
- }
131
- return `${size2 / baseFont}rem`;
132
- }
133
- return value;
134
- }
135
- };
136
- var typographyName = {
137
- name: "name/typography",
138
- type: "name",
139
- transitive: true,
140
- // expanded tokens have different type so we match on path instead
141
- filter: (token) => pathStartsWithOneOf(["typography"], token),
142
- transform: (token) => {
143
- return token.name.replace("-typography", "");
144
- }
145
- };
146
- var resolveMath = {
147
- name: "ds/resolveMath",
148
- type: "value",
149
- transitive: true,
150
- filter: (token) => {
151
- const isValidValue = ["string", "object"].includes(typeof getValue(token));
152
- const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
153
- return isValidValue && isTokenOfInterest;
154
- },
155
- transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
156
- };
157
- var unitless = {
158
- name: "ds/unitless",
159
- type: "value",
160
- transitive: true,
161
- filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
162
- transform: (token) => parseInt(getValue(token), 10)
163
- };
164
-
165
- // src/tokens/process/configs/shared.ts
166
- var prefix = "ds";
167
- var basePxFontSize = 16;
168
- var dsTransformers = [
169
- "name/kebab",
170
- resolveMath.name,
171
- "ts/size/px",
172
- sizeRem.name,
173
- unitless.name,
174
- "ts/typography/fontWeight",
175
- typographyName.name,
176
- "ts/color/modifiers",
177
- "ts/color/css/hexrgba",
178
- "ts/size/lineheight",
179
- "shadow/css/shorthand"
180
- ];
181
-
182
- // src/tokens/process/configs/color.ts
183
- var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
184
- const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
185
- const layer = `ds.theme.color-scheme.${colorScheme2}`;
186
- return {
187
- preprocessors: ["tokens-studio"],
188
- platforms: {
189
- css: {
190
- // custom
191
- colorScheme: colorScheme2,
192
- theme,
193
- selector,
194
- layer,
195
- //
196
- prefix,
197
- buildPath: `${theme}/`,
198
- transforms: dsTransformers,
199
- files: [
200
- {
201
- destination: `color-scheme/${colorScheme2}.css`,
202
- format: formats.colorScheme.name,
203
- filter: (token) => typeEquals("color", token) && !R3.startsWith(["global"], token.path)
204
- }
205
- ],
206
- options: {
207
- outputReferences: false
208
- }
209
- }
210
- }
211
- };
212
- };
213
- var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
214
- const category = opts.category;
215
- const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
216
- if (!color) {
217
- throw new Error(
218
- category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
219
- );
220
- }
221
- const layer = `ds.theme.color`;
222
- const isRootColor = color === buildOptions?.defaultColor;
223
- const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
224
- const config = {
225
- preprocessors: ["tokens-studio"],
226
- platforms: {
227
- css: {
228
- // custom
229
- colorScheme: colorScheme2,
230
- theme,
231
- selector,
232
- layer,
233
- //
234
- prefix,
235
- buildPath: `${theme}/`,
236
- transforms: dsTransformers,
237
- files: [
238
- {
239
- destination: `color/${color}.css`,
240
- format: formats.colorCategory.name,
241
- filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
242
- }
243
- ],
244
- options: {
245
- outputReferences: true
246
- }
247
- }
248
- }
249
- };
250
- return config;
251
- };
252
-
253
- // src/tokens/process/configs/semantic.ts
254
- import * as R4 from "ramda";
255
- import { outputReferencesFilter } from "style-dictionary/utils";
256
- var semanticVariables = ({ theme }) => {
257
- const selector = `:root`;
258
- const layer = `ds.theme.semantic`;
259
- return {
260
- preprocessors: ["tokens-studio"],
261
- platforms: {
262
- css: {
263
- // custom
264
- theme,
265
- basePxFontSize,
266
- selector,
267
- layer,
268
- //
269
- prefix,
270
- buildPath: `${theme}/`,
271
- transforms: dsTransformers,
272
- files: [
273
- {
274
- destination: `semantic.css`,
275
- format: formats.semantic.name,
276
- filter: (token) => {
277
- const isUwantedToken = R4.anyPass([R4.includes("primitives/global")])(token.filePath);
278
- const isPrivateToken = R4.includes("_", token.path);
279
- const unwantedPaths = pathStartsWithOneOf(
280
- ["size", "_size", "font-size", "line-height", "letter-spacing"],
281
- token
282
- );
283
- const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
284
- const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
285
- return unwantedTokens;
286
- }
287
- }
288
- ],
289
- options: {
290
- outputReferences: (token, options) => {
291
- const include = pathStartsWithOneOf(["border-radius"], token);
292
- return include && outputReferencesFilter(token, options);
293
- }
294
- }
295
- }
296
- }
297
- };
298
- };
299
-
300
- // src/tokens/process/configs/size.ts
301
- import * as R5 from "ramda";
302
- import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
303
- var sizeVariables = ({ theme }) => {
304
- const selector = `:root, [data-size]`;
305
- const layer = `ds.theme.size`;
306
- return {
307
- preprocessors: ["tokens-studio"],
308
- platforms: {
309
- css: {
310
- // custom
311
- theme,
312
- basePxFontSize,
313
- selector,
314
- layer,
315
- //
316
- prefix,
317
- buildPath: `${theme}/`,
318
- transforms: dsTransformers,
319
- files: [
320
- {
321
- destination: `size.css`,
322
- format: formats.size.name,
323
- filter: (token) => {
324
- const isUwantedToken = R5.anyPass([R5.includes("primitives/global")])(token.filePath);
325
- const isPrivateToken = R5.includes("_", token.path);
326
- return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
327
- }
328
- }
329
- ],
330
- options: {
331
- outputReferences: (token, options) => {
332
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
333
- return isWantedSize && outputReferencesFilter2(token, options);
334
- }
335
- }
336
- }
337
- }
338
- };
339
- };
340
-
341
- // src/tokens/process/configs/size-mode.ts
342
- import * as R6 from "ramda";
343
- var sizeModeVariables = ({ theme, size: size2 }) => {
344
- const selector = `:root`;
345
- const layer = `ds.theme.size-mode`;
346
- return {
347
- preprocessors: ["tokens-studio"],
348
- platforms: {
349
- css: {
350
- // custom
351
- size: size2,
352
- theme,
353
- basePxFontSize,
354
- selector,
355
- layer,
356
- //
357
- prefix,
358
- buildPath: `${theme}/`,
359
- transforms: dsTransformers,
360
- files: [
361
- {
362
- destination: `size-mode/${size2}.css`,
363
- format: formats.sizeMode.name,
364
- filter: (token) => {
365
- return R6.equals(["_size", "mode-font-size"], token.path);
366
- }
367
- }
368
- ]
369
- }
370
- }
371
- };
372
- };
373
-
374
- // src/tokens/process/configs/type-scale.ts
375
- var typeScaleVariables = ({ theme }) => {
376
- const selector = ":root, [data-size]";
377
- const layer = `ds.theme.type-scale`;
378
- return {
379
- usesDtcg: true,
380
- preprocessors: ["tokens-studio"],
381
- expand: {
382
- include: ["typography"]
383
- },
384
- platforms: {
385
- css: {
386
- prefix,
387
- selector,
388
- layer,
389
- buildPath: `${theme}/`,
390
- basePxFontSize,
391
- transforms: [
392
- "name/kebab",
393
- "ts/size/px",
394
- sizeRem.name,
395
- "ts/size/lineheight",
396
- "ts/typography/fontWeight",
397
- typographyName.name
398
- ],
399
- files: [
400
- {
401
- destination: `type-scale.css`,
402
- format: formats.typeScale.name,
403
- filter: (token) => {
404
- const included = typeEquals(["typography", "dimension", "fontsize"], token);
405
- if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
406
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
407
- }
408
- }
409
- ],
410
- options: {
411
- outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
412
- }
413
- }
414
- }
415
- };
416
- };
417
-
418
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
419
- var BoxShadowTypes;
420
- (function(BoxShadowTypes2) {
421
- BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
422
- BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
423
- })(BoxShadowTypes || (BoxShadowTypes = {}));
424
-
425
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
426
- var ColorModifierTypes;
427
- (function(ColorModifierTypes2) {
428
- ColorModifierTypes2["LIGHTEN"] = "lighten";
429
- ColorModifierTypes2["DARKEN"] = "darken";
430
- ColorModifierTypes2["MIX"] = "mix";
431
- ColorModifierTypes2["ALPHA"] = "alpha";
432
- })(ColorModifierTypes || (ColorModifierTypes = {}));
433
-
434
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
435
- var ColorSpaceTypes;
436
- (function(ColorSpaceTypes2) {
437
- ColorSpaceTypes2["LCH"] = "lch";
438
- ColorSpaceTypes2["SRGB"] = "srgb";
439
- ColorSpaceTypes2["P3"] = "p3";
440
- ColorSpaceTypes2["HSL"] = "hsl";
441
- })(ColorSpaceTypes || (ColorSpaceTypes = {}));
442
-
443
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
444
- var Properties;
445
- (function(Properties2) {
446
- Properties2["sizing"] = "sizing";
447
- Properties2["height"] = "height";
448
- Properties2["width"] = "width";
449
- Properties2["spacing"] = "spacing";
450
- Properties2["verticalPadding"] = "verticalPadding";
451
- Properties2["horizontalPadding"] = "horizontalPadding";
452
- Properties2["paddingTop"] = "paddingTop";
453
- Properties2["paddingRight"] = "paddingRight";
454
- Properties2["paddingBottom"] = "paddingBottom";
455
- Properties2["paddingLeft"] = "paddingLeft";
456
- Properties2["itemSpacing"] = "itemSpacing";
457
- Properties2["fill"] = "fill";
458
- Properties2["backgroundBlur"] = "backgroundBlur";
459
- Properties2["border"] = "border";
460
- Properties2["borderTop"] = "borderTop";
461
- Properties2["borderRight"] = "borderRight";
462
- Properties2["borderBottom"] = "borderBottom";
463
- Properties2["borderLeft"] = "borderLeft";
464
- Properties2["borderColor"] = "borderColor";
465
- Properties2["borderRadius"] = "borderRadius";
466
- Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
467
- Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
468
- Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
469
- Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
470
- Properties2["borderWidth"] = "borderWidth";
471
- Properties2["borderWidthTop"] = "borderWidthTop";
472
- Properties2["borderWidthRight"] = "borderWidthRight";
473
- Properties2["borderWidthBottom"] = "borderWidthBottom";
474
- Properties2["borderWidthLeft"] = "borderWidthLeft";
475
- Properties2["boxShadow"] = "boxShadow";
476
- Properties2["opacity"] = "opacity";
477
- Properties2["fontFamilies"] = "fontFamilies";
478
- Properties2["fontWeights"] = "fontWeights";
479
- Properties2["fontSizes"] = "fontSizes";
480
- Properties2["lineHeights"] = "lineHeights";
481
- Properties2["typography"] = "typography";
482
- Properties2["composition"] = "composition";
483
- Properties2["letterSpacing"] = "letterSpacing";
484
- Properties2["paragraphSpacing"] = "paragraphSpacing";
485
- Properties2["textCase"] = "textCase";
486
- Properties2["dimension"] = "dimension";
487
- Properties2["textDecoration"] = "textDecoration";
488
- Properties2["asset"] = "asset";
489
- Properties2["tokenValue"] = "tokenValue";
490
- Properties2["value"] = "value";
491
- Properties2["tokenName"] = "tokenName";
492
- Properties2["description"] = "description";
493
- })(Properties || (Properties = {}));
494
-
495
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
496
- var TokenSetStatus;
497
- (function(TokenSetStatus2) {
498
- TokenSetStatus2["DISABLED"] = "disabled";
499
- TokenSetStatus2["SOURCE"] = "source";
500
- TokenSetStatus2["ENABLED"] = "enabled";
501
- })(TokenSetStatus || (TokenSetStatus = {}));
502
-
503
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
504
- var TokenTypes;
505
- (function(TokenTypes2) {
506
- TokenTypes2["OTHER"] = "other";
507
- TokenTypes2["COLOR"] = "color";
508
- TokenTypes2["BORDER_RADIUS"] = "borderRadius";
509
- TokenTypes2["SIZING"] = "sizing";
510
- TokenTypes2["SPACING"] = "spacing";
511
- TokenTypes2["TEXT"] = "text";
512
- TokenTypes2["TYPOGRAPHY"] = "typography";
513
- TokenTypes2["OPACITY"] = "opacity";
514
- TokenTypes2["BORDER_WIDTH"] = "borderWidth";
515
- TokenTypes2["STROKE_STYLE"] = "strokeStyle";
516
- TokenTypes2["BOX_SHADOW"] = "boxShadow";
517
- TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
518
- TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
519
- TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
520
- TokenTypes2["FONT_SIZES"] = "fontSizes";
521
- TokenTypes2["LETTER_SPACING"] = "letterSpacing";
522
- TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
523
- TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
524
- TokenTypes2["TEXT_DECORATION"] = "textDecoration";
525
- TokenTypes2["TEXT_CASE"] = "textCase";
526
- TokenTypes2["COMPOSITION"] = "composition";
527
- TokenTypes2["DIMENSION"] = "dimension";
528
- TokenTypes2["BORDER"] = "border";
529
- TokenTypes2["ASSET"] = "asset";
530
- TokenTypes2["BOOLEAN"] = "boolean";
531
- TokenTypes2["NUMBER"] = "number";
532
- })(TokenTypes || (TokenTypes = {}));
533
-
534
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
535
- var BorderValues;
536
- (function(BorderValues2) {
537
- BorderValues2["BORDER_COLOR"] = "color";
538
- BorderValues2["BORDER_WIDTH"] = "width";
539
- BorderValues2["BORDER_STYLE"] = "style";
540
- })(BorderValues || (BorderValues = {}));
541
-
542
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
543
- var StrokeStyleValues;
544
- (function(StrokeStyleValues2) {
545
- StrokeStyleValues2["SOLID"] = "solid";
546
- StrokeStyleValues2["DASHED"] = "dashed";
547
- StrokeStyleValues2["DOTTED"] = "dotted";
548
- StrokeStyleValues2["DOUBLE"] = "double";
549
- StrokeStyleValues2["GROOVE"] = "groove";
550
- StrokeStyleValues2["RIDGE"] = "ridge";
551
- StrokeStyleValues2["OUTSET"] = "outset";
552
- StrokeStyleValues2["INSET"] = "inset";
553
- })(StrokeStyleValues || (StrokeStyleValues = {}));
554
-
555
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
556
- var BoxShadowValues;
557
- (function(BoxShadowValues2) {
558
- BoxShadowValues2["TYPE"] = "type";
559
- BoxShadowValues2["COLOR"] = "color";
560
- BoxShadowValues2["X"] = "x";
561
- BoxShadowValues2["Y"] = "y";
562
- BoxShadowValues2["BLUR"] = "blur";
563
- BoxShadowValues2["SPREAD"] = "spread";
564
- BoxShadowValues2["BLEND_MODE"] = "blendMode";
565
- })(BoxShadowValues || (BoxShadowValues = {}));
566
-
567
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
568
- var TypographyValues;
569
- (function(TypographyValues2) {
570
- TypographyValues2["FONT_FAMILY"] = "fontFamily";
571
- TypographyValues2["FONT_WEIGHT"] = "fontWeight";
572
- TypographyValues2["LINE_HEIGHT"] = "lineHeight";
573
- TypographyValues2["FONT_SIZE"] = "fontSize";
574
- TypographyValues2["LETTER_SPACING"] = "letterSpacing";
575
- TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
576
- TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
577
- TypographyValues2["TEXT_DECORATION"] = "textDecoration";
578
- TypographyValues2["TEXT_CASE"] = "textCase";
579
- })(TypographyValues || (TypographyValues = {}));
580
-
581
- // src/tokens/process/utils/getMultidimensionalThemes.ts
582
- import pc from "picocolors";
583
- import * as R7 from "ramda";
584
- var hasUnknownProps = R7.pipe(R7.values, R7.none(R7.equals("unknown")), R7.not);
585
-
586
- // src/tokens/process/configs.ts
587
- void register(StyleDictionary, { withSDBuiltins: false });
588
- StyleDictionary.registerTransform(sizeRem);
589
- StyleDictionary.registerTransform(typographyName);
590
- StyleDictionary.registerTransform(resolveMath);
591
- StyleDictionary.registerTransform(unitless);
592
- for (const format of Object.values(formats)) {
593
- StyleDictionary.registerFormat(format);
594
- }
595
- var configs = {
596
- colorSchemeVariables,
597
- mainColorVariables: colorCategoryVariables({ category: "main" }),
598
- supportColorVariables: colorCategoryVariables({ category: "support" }),
599
- neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
600
- successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
601
- dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
602
- warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
603
- infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
604
- sizeModeVariables,
605
- sizeVariables,
606
- typographyVariables,
607
- typeScaleVariables,
608
- semanticVariables
609
- };
610
-
611
- // src/tokens/process/platform.ts
612
- var buildOptions = {
613
- verbose: false,
614
- processed$themes: [],
615
- buildTokenFormats: {}
616
- };
617
- var sd = new StyleDictionary2();
618
- var buildConfigs = {
619
- typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
620
- sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
621
- size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
622
- typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
623
- "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
624
- "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
625
- "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
626
- "neutral-color": {
627
- getConfig: configs.neutralColorVariables,
628
- dimensions: ["semantic"],
629
- log: ({ permutation: { theme } }) => `${theme} - neutral`
630
- },
631
- "success-color": {
632
- getConfig: configs.successColorVariables,
633
- dimensions: ["semantic"],
634
- log: ({ permutation: { theme } }) => `${theme} - success`
635
- },
636
- "danger-color": {
637
- getConfig: configs.dangerColorVariables,
638
- dimensions: ["semantic"],
639
- log: ({ permutation: { theme } }) => `${theme} - danger`
640
- },
641
- "warning-color": {
642
- getConfig: configs.warningColorVariables,
643
- dimensions: ["semantic"],
644
- log: ({ permutation: { theme } }) => `${theme} - warning`
645
- },
646
- "info-color": {
647
- getConfig: configs.infoColorVariables,
648
- dimensions: ["semantic"],
649
- log: ({ permutation: { theme } }) => `${theme} - info`
650
- },
651
- semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
652
- };
653
-
654
- // src/tokens/process/formats/css/color.ts
655
- var prefersColorScheme = (colorScheme2, content) => `
656
- @media (prefers-color-scheme: ${colorScheme2}) {
657
- [data-color-scheme="auto"] ${content}
658
- }
659
- `;
660
- var colorScheme = {
661
- name: "ds/css-colorscheme",
662
- format: async ({ dictionary, options, platform }) => {
663
- const { allTokens } = dictionary;
664
- const { outputReferences, usesDtcg } = options;
665
- const { selector, colorScheme: colorScheme2, layer } = platform;
666
- const colorScheme_ = colorScheme2;
667
- const format = createPropertyFormatter({
668
- outputReferences,
669
- dictionary,
670
- format: "css",
671
- usesDtcg
672
- });
673
- const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
674
- color-scheme: ${colorScheme_};
675
- ` : "";
676
- const filteredAllTokens = allTokens.filter(
677
- R10.allPass([
678
- R10.anyPass([
679
- // Include semantic tokens in the output
680
- isSemanticToken,
681
- // Include global color tokens
682
- isGlobalColorToken
683
- ]),
684
- // Don't include color category tokens -- they are exported separately
685
- (t) => !isColorCategoryToken(t)
686
- ])
687
- );
688
- const formattedMap = filteredAllTokens.map((token) => ({
689
- token,
690
- formatted: format(token)
691
- }));
692
- const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).join("\n");
693
- const content = `{
694
- ${formattedTokens}
695
- ${colorSchemeProperty}}
696
- `;
697
- const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
698
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
699
- ${selector} ${content} ${autoSelectorContent}
700
- }
701
- ` : `${selector} ${content} ${autoSelectorContent}
702
- `;
703
- return body;
704
- }
705
- };
706
- var colorCategory = {
707
- name: "ds/css-colorcategory",
708
- format: async ({ dictionary, file, options, platform }) => {
709
- const { outputReferences, usesDtcg } = options;
710
- const { selector, layer } = platform;
711
- const destination = file.destination;
712
- const format = R10.compose(
713
- createPropertyFormatter({
714
- outputReferences,
715
- dictionary,
716
- format: "css",
717
- usesDtcg
718
- }),
719
- (token) => ({
720
- ...token,
721
- name: token.name.replace(/color-\w+-/, "color-"),
722
- original: {
723
- ...token.original,
724
- $value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
725
- }
726
- })
727
- );
728
- const formattedMap = dictionary.allTokens.map((token) => ({
729
- token,
730
- formatted: format(token)
731
- }));
732
- buildOptions.buildTokenFormats[destination] = formattedMap;
733
- const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).join("\n");
734
- const content = `{
735
- ${formattedTokens}
736
- }
737
- `;
738
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
739
- ${selector} ${content}
740
- }
741
- ` : `${selector} ${content}
742
- `;
743
- return body;
744
- }
745
- };
746
-
747
- // src/tokens/process/formats/css/semantic.ts
748
- import * as R12 from "ramda";
749
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
750
-
751
- // src/tokens/process/formats/css/size.ts
752
- import * as R11 from "ramda";
753
- import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
754
- var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
755
- var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
756
- var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
757
- var isInlineTokens = R11.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
758
- var overrideSizingFormula = (format, token) => {
759
- const [name, value] = format(token).replace(/;$/, "").split(": ");
760
- let calc;
761
- let round;
762
- if (token.path[1] === "unit") {
763
- calc = `calc(1rem * ${value})`;
764
- } else if (value.startsWith("floor")) {
765
- calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
766
- round = `round(down, ${calc}, 1px)`;
767
- } else {
768
- calc = value.includes("*") ? `calc(${value})` : value;
769
- }
770
- return {
771
- name,
772
- round: round ?? calc,
773
- calc
774
- };
775
- };
776
- var formatSizingTokens = (format, tokens) => R11.reduce(
777
- (acc, token) => {
778
- const { round, calc, name } = overrideSizingFormula(format, token);
779
- return {
780
- tokens: [...acc.tokens, token],
781
- round: [...acc.round, `${name}: ${round};`],
782
- calc: [...acc.calc, `${name}: ${calc};`]
783
- };
784
- },
785
- { tokens: [], round: [], calc: [] },
786
- tokens
787
- );
788
- var sizingTemplate = ({ round, calc }) => {
789
- const usesRounding = round.filter((val, i) => val !== calc[i]);
790
- return `
791
- ${calc.join("\n")}
792
-
793
- @supports (width: round(down, .1em, 1px)) {
794
- ${usesRounding.join("\n ")}
795
- }`;
796
- };
797
- var size = {
798
- name: "ds/css-size",
799
- format: async ({ dictionary, file, options, platform }) => {
800
- const { outputReferences, usesDtcg } = options;
801
- const { selector, layer } = platform;
802
- const destination = file.destination;
803
- const format = createPropertyFormatter2({
804
- outputReferences,
805
- dictionary,
806
- format: "css",
807
- usesDtcg
808
- });
809
- const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
810
- const filteredTokens = R11.reject((token) => R11.equals(["_size", "mode-font-size"], token.path), tokens);
811
- const [sizingTokens, restTokens] = R11.partition(
812
- (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
813
- filteredTokens
814
- );
815
- const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
816
- const formattedMap = restTokens.map((token) => ({
817
- token,
818
- formatted: format(token)
819
- }));
820
- const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
821
- token: formattedSizingTokens.tokens[i],
822
- formatted: t
823
- }));
824
- buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
825
- const formattedTokens = [formattedMap.map(R11.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
826
- const content = `${selector} {
827
- ${formattedTokens.join("\n")}
828
- }
829
- `;
830
- const body = R11.isNotNil(layer) ? `@layer ${layer} {
831
- ${content}
832
- }
833
- ` : `${content}
834
- `;
835
- return body;
836
- }
837
- };
838
-
839
- // src/tokens/process/formats/css/semantic.ts
840
- var semantic = {
841
- name: "ds/css-semantic",
842
- format: async ({ dictionary, file, options, platform }) => {
843
- const { outputReferences, usesDtcg } = options;
844
- const { selector, layer } = platform;
845
- const destination = file.destination;
846
- const format = createPropertyFormatter3({
847
- outputReferences,
848
- dictionary,
849
- format: "css",
850
- usesDtcg
851
- });
852
- const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
853
- const formattedMap = tokens.map((token) => ({
854
- token,
855
- formatted: format(token)
856
- }));
857
- buildOptions.buildTokenFormats[destination] = formattedMap;
858
- const formattedTokens = formattedMap.map(R12.prop("formatted")).join("\n");
859
- const content = `${selector} {
860
- ${formattedTokens}
861
- }
862
- `;
863
- const body = R12.isNotNil(layer) ? `@layer ${layer} {
864
- ${content}
865
- }
866
- ` : `${content}
867
- `;
868
- return body;
869
- }
870
- };
871
-
872
- // src/tokens/process/formats/css/size-mode.ts
873
- import * as R13 from "ramda";
874
- import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
875
- var formatBaseSizeToken = (size2) => (token) => ({
876
- ...token,
877
- originalName: token.name,
878
- name: `${token.name}--${shortSizeName(size2)}`,
879
- $value: token.$value / basePxFontSize
880
- });
881
- var sizeMode = {
882
- name: "ds/css-size-mode",
883
- format: async ({ dictionary, file, options, platform }) => {
884
- const { outputReferences, usesDtcg } = options;
885
- const { selector, layer, size: size2 } = platform;
886
- const destination = file.destination;
887
- const format = createPropertyFormatter4({
888
- outputReferences,
889
- dictionary,
890
- format: "css",
891
- usesDtcg
892
- });
893
- const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
894
- const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
895
- const formattedMap = sizeSpecificTokens.map((token) => ({
896
- token,
897
- formatted: format({
898
- ...token,
899
- // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
900
- name: token.originalName
901
- })
902
- }));
903
- buildOptions.buildTokenFormats[destination] = formattedMap;
904
- const content = `${selector} /* ${size2} */ {
905
- ${sizeSpecificVariables}
906
- }`;
907
- const body = wrapInLayer(content, layer);
908
- const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
909
- const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
910
- const sizingToggles = `:root, [data-size] {
911
- --ds-size: var(--ds-size--${defaultSize});
912
- ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
913
- --ds-size-mode-font-size:
914
- ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
915
- }`;
916
- const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
917
- const sharedContent = `${sizingToggles}
918
-
919
- ${sizingHelpers}`;
920
- const sharedBody = shortSizeName(size2) === R13.last(sizes) ? `
921
- ${wrapInLayer(sharedContent, layer)}` : "";
922
- return body + sharedBody;
923
- }
924
- };
925
- function wrapInLayer(content, layer) {
926
- return R13.isNotNil(layer) ? `@layer ${layer} {
927
- ${content}
928
- }
929
- ` : `${content}
930
- `;
931
- }
932
-
933
- // src/tokens/process/formats/css/typography.ts
934
- import * as R14 from "ramda";
935
- import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
936
- var typographyFontFamilyPredicate = R14.allPass([
937
- R14.pathSatisfies(R14.includes("typography"), ["path"]),
938
- R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
939
- ]);
940
- var typography = {
941
- name: "ds/css-typography",
942
- format: async ({ dictionary, file, options, platform }) => {
943
- const { outputReferences, usesDtcg } = options;
944
- const { selector, layer } = platform;
945
- const destination = file.destination;
946
- const format = createPropertyFormatter5({
947
- outputReferences,
948
- dictionary,
949
- format: "css",
950
- usesDtcg
951
- });
952
- const filteredTokens = R14.reject(typographyFontFamilyPredicate, dictionary.allTokens);
953
- const formattedMap = filteredTokens.map((token) => ({
954
- token,
955
- formatted: format(token)
956
- }));
957
- buildOptions.buildTokenFormats[destination] = formattedMap;
958
- const formattedTokens = formattedMap.map(R14.view(R14.lensProp("formatted"))).join("\n");
959
- const content = selector ? `${selector} {
960
- ${formattedTokens}
961
- }` : formattedTokens;
962
- const body = R14.isNotNil(layer) ? `@layer ${layer} {
963
- ${content}
964
- }` : content;
965
- return body;
966
- }
967
- };
968
-
969
- // src/tokens/process/formats/css/type-scale.ts
970
- import * as R15 from "ramda";
971
- import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
972
- var isTypographyFontFamilyToken = R15.allPass([
973
- R15.pathSatisfies(R15.includes("typography"), ["path"]),
974
- R15.pathSatisfies(R15.includes("fontFamily"), ["path"])
975
- ]);
976
- var formatTypographySizeToken = (format, token) => {
977
- const [name, value] = format(token).replace(/;$/, "").split(": ");
978
- let calc;
979
- let round;
980
- if (R15.startsWith(["font-size"], token.path)) {
981
- calc = `calc(${value} * var(--_ds-font-size-factor))`;
982
- round = `round(${calc}, 1px)`;
983
- } else {
984
- calc = value;
985
- }
986
- return { name, calc, round: round ?? calc };
987
- };
988
- var formatTypographySizeTokens = (format, tokens) => R15.reduce(
989
- (acc, token) => {
990
- const { name, calc, round } = formatTypographySizeToken(format, token);
991
- acc.tokens.push(token);
992
- acc.calc.push(`${name}: ${calc};`);
993
- acc.round.push(`${name}: ${round};`);
994
- return acc;
995
- },
996
- { tokens: [], calc: [], round: [] },
997
- tokens
998
- );
999
- var typeScale = {
1000
- name: "ds/css-type-scale",
1001
- format: async ({ dictionary, file, options, platform }) => {
1002
- const { outputReferences, usesDtcg } = options;
1003
- const { selector, layer } = platform;
1004
- const destination = file.destination;
1005
- const format = createPropertyFormatter6({
1006
- outputReferences,
1007
- dictionary,
1008
- format: "css",
1009
- usesDtcg
1010
- });
1011
- const filteredTokens = R15.reject(R15.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
1012
- const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
1013
- const formattedMap = formattedTokens.round.map((t, i) => ({
1014
- token: formattedTokens.tokens[i],
1015
- formatted: t
1016
- }));
1017
- buildOptions.buildTokenFormats[destination] = formattedMap;
1018
- const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
1019
- const content = `${selector} {
1020
- ${sizeFactor}${sizingTemplate(formattedTokens)}
1021
- }`;
1022
- const body = R15.isNotNil(layer) ? `@layer ${layer} {
1023
- ${content}
1024
- }` : content;
1025
- return body;
1026
- }
1027
- };
1028
-
1029
- // src/tokens/process/formats/css.ts
1030
- var formats = {
1031
- colorScheme,
1032
- colorCategory,
1033
- semantic,
1034
- sizeMode,
1035
- size,
1036
- typography,
1037
- typeScale
1038
- };
1039
-
1040
- // src/tokens/process/configs/typography.ts
1041
- var typographyVariables = ({ theme, typography: typography2 }) => {
1042
- const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
1043
- const layer = `ds.theme.typography.${typography2}`;
1044
- return {
1045
- usesDtcg: true,
1046
- preprocessors: ["tokens-studio"],
1047
- expand: {
1048
- include: ["typography"],
1049
- typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
1050
- },
1051
- platforms: {
1052
- css: {
1053
- prefix,
1054
- typography: typography2,
1055
- selector,
1056
- layer,
1057
- buildPath: `${theme}/`,
1058
- basePxFontSize,
1059
- transforms: [
1060
- "name/kebab",
1061
- "ts/size/px",
1062
- sizeRem.name,
1063
- "ts/size/lineheight",
1064
- "ts/typography/fontWeight",
1065
- "ts/size/css/letterspacing",
1066
- typographyName.name
1067
- ],
1068
- files: [
1069
- {
1070
- destination: `typography/${typography2}.css`,
1071
- format: formats.typography.name,
1072
- filter: (token) => {
1073
- const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
1074
- if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
1075
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
1076
- }
1077
- }
1078
- ]
1079
- }
1080
- }
1081
- };
1082
- };
1083
- export {
1084
- typographyVariables
1085
- };
6
+ //#region src/tokens/process/configs/typography.ts
7
+ const typographyVariables = ({ theme, typography }) => {
8
+ const selector = `${typography === "primary" ? ":root, " : ""}[data-typography="${typography}"]`;
9
+ const layer = `ds.theme.typography.${typography}`;
10
+ return {
11
+ usesDtcg: true,
12
+ preprocessors: ["tokens-studio"],
13
+ expand: {
14
+ include: ["typography"],
15
+ typesMap: {
16
+ ...expandTypesMap,
17
+ typography: {
18
+ ...expandTypesMap.typography,
19
+ letterSpacing: "dimension"
20
+ }
21
+ }
22
+ },
23
+ platforms: { css: {
24
+ prefix: "ds",
25
+ typography,
26
+ selector,
27
+ layer,
28
+ buildPath: `${theme}/`,
29
+ basePxFontSize: 16,
30
+ transforms: [
31
+ "name/kebab",
32
+ "ts/size/px",
33
+ sizeRem.name,
34
+ "ts/size/lineheight",
35
+ "ts/typography/fontWeight",
36
+ "ts/size/css/letterspacing",
37
+ typographyName.name
38
+ ],
39
+ files: [{
40
+ destination: `typography/${typography}.css`,
41
+ format: formats.typography.name,
42
+ filter: (token) => {
43
+ const included = typeEquals([
44
+ "fontweight",
45
+ "fontFamily",
46
+ "lineHeight",
47
+ "dimension"
48
+ ], token);
49
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
50
+ return included && !pathStartsWithOneOf([
51
+ "spacing",
52
+ "sizing",
53
+ "size",
54
+ "_size",
55
+ "border-width",
56
+ "border-radius"
57
+ ], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
58
+ }
59
+ }]
60
+ } }
61
+ };
62
+ };
63
+ //#endregion
64
+ export { typographyVariables };