@digdir/designsystemet 1.13.2 → 1.14.0

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