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