@digdir/designsystemet 1.13.2 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/bin/config.js +50 -658
  2. package/dist/bin/designsystemet.js +131 -4623
  3. package/dist/bin/options.js +22 -14
  4. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js +9 -0
  5. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js +8 -0
  6. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js +13 -0
  7. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js +10 -0
  8. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js +10 -0
  9. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js +53 -0
  10. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js +14 -0
  11. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js +9 -0
  12. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js +32 -0
  13. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js +15 -0
  14. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/types/index.js +11 -0
  15. package/dist/package.js +5 -0
  16. package/dist/src/colors/colorMetadata.js +255 -261
  17. package/dist/src/colors/index.js +5 -522
  18. package/dist/src/colors/theme.js +104 -343
  19. package/dist/src/colors/types.js +22 -25
  20. package/dist/src/colors/utils.js +241 -154
  21. package/dist/src/config.js +103 -444
  22. package/dist/src/index.js +10 -3588
  23. package/dist/src/migrations/beta-to-v1.js +339 -537
  24. package/dist/src/migrations/codemods/css/plugins.js +31 -42
  25. package/dist/src/migrations/codemods/css/run.js +20 -151
  26. package/dist/src/migrations/color-rename-next49.js +44 -220
  27. package/dist/src/migrations/index.js +7 -577
  28. package/dist/src/tokens/build.js +39 -1816
  29. package/dist/src/tokens/create/files.js +43 -602
  30. package/dist/src/tokens/create/generators/$designsystemet.js +8 -97
  31. package/dist/src/tokens/create/generators/$metadata.js +17 -20
  32. package/dist/src/tokens/create/generators/$themes.js +137 -311
  33. package/dist/src/tokens/create/generators/primitives/color-scheme.js +68 -443
  34. package/dist/src/tokens/create/generators/primitives/globals.js +141 -147
  35. package/dist/src/tokens/create/generators/primitives/size.js +146 -156
  36. package/dist/src/tokens/create/generators/primitives/typography.js +213 -217
  37. package/dist/src/tokens/create/generators/semantic/color-modes.js +24 -59
  38. package/dist/src/tokens/create/generators/semantic/color.js +42 -326
  39. package/dist/src/tokens/create/generators/semantic/style.js +379 -382
  40. package/dist/src/tokens/create/generators/themes/theme.js +108 -392
  41. package/dist/src/tokens/create.js +47 -1591
  42. package/dist/src/tokens/format.js +38 -3324
  43. package/dist/src/tokens/generate-config.js +155 -298
  44. package/dist/src/tokens/index.js +3 -3344
  45. package/dist/src/tokens/process/configs/color.js +50 -1085
  46. package/dist/src/tokens/process/configs/semantic.js +45 -1083
  47. package/dist/src/tokens/process/configs/shared.js +18 -109
  48. package/dist/src/tokens/process/configs/size-mode.js +27 -1082
  49. package/dist/src/tokens/process/configs/size.js +32 -1083
  50. package/dist/src/tokens/process/configs/type-scale.js +49 -1083
  51. package/dist/src/tokens/process/configs/typography.js +63 -1084
  52. package/dist/src/tokens/process/configs.js +88 -1224
  53. package/dist/src/tokens/process/formats/css/color.js +58 -1079
  54. package/dist/src/tokens/process/formats/css/semantic.js +27 -1081
  55. package/dist/src/tokens/process/formats/css/size-mode.js +43 -1077
  56. package/dist/src/tokens/process/formats/css/size.js +86 -1079
  57. package/dist/src/tokens/process/formats/css/type-scale.js +53 -1083
  58. package/dist/src/tokens/process/formats/css/typography.js +27 -1081
  59. package/dist/src/tokens/process/formats/css.js +18 -1081
  60. package/dist/src/tokens/process/output/declarations.js +18 -1201
  61. package/dist/src/tokens/process/output/tailwind.js +26 -40
  62. package/dist/src/tokens/process/output/theme.js +73 -206
  63. package/dist/src/tokens/process/platform.js +165 -1355
  64. package/dist/src/tokens/process/transformers.js +49 -89
  65. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +100 -1183
  66. package/dist/src/tokens/process/utils/kebab-case.js +7 -5
  67. package/dist/src/tokens/types.js +6 -7
  68. package/dist/src/tokens/utils.js +102 -93
  69. package/dist/src/types.js +1 -5
  70. package/dist/src/utils/filesystem.js +112 -124
  71. package/package.json +10 -13
  72. package/configs/test-tokens.config.json +0 -82
  73. package/dist/src/scripts/createJsonSchema.js +0 -409
  74. package/dist/src/scripts/update-preview-tokens.js +0 -3353
@@ -1,1085 +1,47 @@
1
- // src/tokens/process/configs/semantic.ts
2
- import * as R15 from "ramda";
3
- import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
4
-
5
- // src/tokens/utils.ts
1
+ import { pathStartsWithOneOf, typeEquals } from "../../utils.js";
2
+ import { dsTransformers } from "./shared.js";
3
+ import { formats } from "../formats/css.js";
6
4
  import * as R from "ramda";
7
-
8
- // src/tokens/types.ts
9
- var colorCategories = {
10
- main: "main",
11
- support: "support"
12
- };
13
-
14
- // src/tokens/utils.ts
15
- var mapToLowerCase = R.map(R.toLower);
16
- var hasAnyTruth = R.any(R.equals(true));
17
- var getType = (token) => (token.$type ?? token.type) || "";
18
- var getValue = (token) => token.$value ?? token.value;
19
- var typeEquals = R.curry(
20
- (types, token) => {
21
- if (R.isNil(token)) {
22
- return false;
23
- }
24
- return R.includes(R.toLower(getType(token)), R.map(R.toLower, Array.isArray(types) ? types : [types]));
25
- }
26
- );
27
- var pathStartsWithOneOf = R.curry(
28
- (paths, token) => {
29
- if (R.isNil(token)) {
30
- return false;
31
- }
32
- const tokenPath = mapToLowerCase(token.path);
33
- const matchPathsStartingWith = R.map((pathOrString) => {
34
- const path = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
35
- return R.startsWith(mapToLowerCase(path), tokenPath);
36
- }, paths);
37
- return hasAnyTruth(matchPathsStartingWith);
38
- }
39
- );
40
- function isSemanticToken(token) {
41
- return token.filePath.includes("semantic/");
42
- }
43
- function isSemanticColorToken(token, color) {
44
- return token.filePath.includes("semantic/") && R.startsWith(["color", color], token.path);
45
- }
46
- function isGlobalColorToken(token) {
47
- return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
48
- }
49
- function isColorCategoryToken(token, category) {
50
- if (!category) {
51
- return Object.keys(colorCategories).some(
52
- (colorCategory2) => isColorCategoryToken(token, colorCategory2)
53
- );
54
- }
55
- return R.startsWith(["color", category], token.path);
56
- }
57
- var isDigit = (s) => /^\d+$/.test(s);
58
- function inlineTokens(shouldInline, tokens) {
59
- const [inlineableTokens, otherTokens] = R.partition(shouldInline, tokens);
60
- return otherTokens.map((token) => {
61
- let transformed = getValue(token.original);
62
- for (const ref of inlineableTokens) {
63
- const refName = ref.path.join(".");
64
- if (typeof transformed === "string") {
65
- transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
66
- }
67
- }
68
- const tokenWithInlinedRefs = R.set(R.lensPath(["original", "$value"]), transformed, token);
69
- return tokenWithInlinedRefs;
70
- });
71
- }
72
- var sizeMap = {
73
- xsmall: "xs",
74
- small: "sm",
75
- medium: "md",
76
- large: "lg",
77
- xlarge: "xl"
78
- };
79
- function shortSizeName(size2) {
80
- return sizeMap[size2] ?? size2;
81
- }
82
- var sizeComparator = (size2) => {
83
- const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
84
- return sortIndex ?? 0;
85
- };
86
- function orderBySize(sizes) {
87
- return R.sortBy(sizeComparator, sizes);
88
- }
89
-
90
- // src/tokens/process/formats/css/color.ts
91
- import * as R9 from "ramda";
92
- import { createPropertyFormatter } from "style-dictionary/utils";
93
-
94
- // src/tokens/process/platform.ts
95
- import pc2 from "picocolors";
96
- import * as R8 from "ramda";
97
- import StyleDictionary2 from "style-dictionary";
98
-
99
- // src/tokens/process/configs.ts
100
- import { register } from "@tokens-studio/sd-transforms";
101
- import * as R7 from "ramda";
102
- import StyleDictionary from "style-dictionary";
103
-
104
- // src/tokens/process/configs/color.ts
105
- import * as R3 from "ramda";
106
-
107
- // src/tokens/process/transformers.ts
108
- import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
109
- import * as R2 from "ramda";
110
- var isPx = R2.test(/\b\d+px\b/g);
111
- var sizeRem = {
112
- name: "ds/size/toRem",
113
- type: "value",
114
- transitive: true,
115
- filter: (token) => {
116
- const hasWantedType = typeEquals(["dimension", "fontsize"], token);
117
- const hasWantedPath = pathStartsWithOneOf([
118
- "border-radius",
119
- "font-size"
120
- /*, ['_size', 'mode-font-size']*/
121
- ], token);
122
- return hasWantedType && hasWantedPath;
123
- },
124
- transform: (token, config) => {
125
- const value = getValue(token);
126
- if (isPx(value)) {
127
- const baseFont = config.basePxFontSize || 16;
128
- const size2 = parseInt(value, 10);
129
- if (size2 === 0) {
130
- return "0";
131
- }
132
- return `${size2 / baseFont}rem`;
133
- }
134
- return value;
135
- }
136
- };
137
- var typographyName = {
138
- name: "name/typography",
139
- type: "name",
140
- transitive: true,
141
- // expanded tokens have different type so we match on path instead
142
- filter: (token) => pathStartsWithOneOf(["typography"], token),
143
- transform: (token) => {
144
- return token.name.replace("-typography", "");
145
- }
146
- };
147
- var resolveMath = {
148
- name: "ds/resolveMath",
149
- type: "value",
150
- transitive: true,
151
- filter: (token) => {
152
- const isValidValue = ["string", "object"].includes(typeof getValue(token));
153
- const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
154
- return isValidValue && isTokenOfInterest;
155
- },
156
- transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
157
- };
158
- var unitless = {
159
- name: "ds/unitless",
160
- type: "value",
161
- transitive: true,
162
- filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
163
- transform: (token) => parseInt(getValue(token), 10)
164
- };
165
-
166
- // src/tokens/process/configs/shared.ts
167
- var prefix = "ds";
168
- var basePxFontSize = 16;
169
- var dsTransformers = [
170
- "name/kebab",
171
- resolveMath.name,
172
- "ts/size/px",
173
- sizeRem.name,
174
- unitless.name,
175
- "ts/typography/fontWeight",
176
- typographyName.name,
177
- "ts/color/modifiers",
178
- "ts/color/css/hexrgba",
179
- "ts/size/lineheight",
180
- "shadow/css/shorthand"
181
- ];
182
-
183
- // src/tokens/process/configs/color.ts
184
- var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
185
- const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
186
- const layer = `ds.theme.color-scheme.${colorScheme2}`;
187
- return {
188
- preprocessors: ["tokens-studio"],
189
- platforms: {
190
- css: {
191
- // custom
192
- colorScheme: colorScheme2,
193
- theme,
194
- selector,
195
- layer,
196
- //
197
- prefix,
198
- buildPath: `${theme}/`,
199
- transforms: dsTransformers,
200
- files: [
201
- {
202
- destination: `color-scheme/${colorScheme2}.css`,
203
- format: formats.colorScheme.name,
204
- filter: (token) => typeEquals("color", token) && !R3.startsWith(["global"], token.path)
205
- }
206
- ],
207
- options: {
208
- outputReferences: false
209
- }
210
- }
211
- }
212
- };
213
- };
214
- var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
215
- const category = opts.category;
216
- const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
217
- if (!color) {
218
- throw new Error(
219
- category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
220
- );
221
- }
222
- const layer = `ds.theme.color`;
223
- const isRootColor = color === buildOptions?.defaultColor;
224
- const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
225
- const config = {
226
- preprocessors: ["tokens-studio"],
227
- platforms: {
228
- css: {
229
- // custom
230
- colorScheme: colorScheme2,
231
- theme,
232
- selector,
233
- layer,
234
- //
235
- prefix,
236
- buildPath: `${theme}/`,
237
- transforms: dsTransformers,
238
- files: [
239
- {
240
- destination: `color/${color}.css`,
241
- format: formats.colorCategory.name,
242
- filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
243
- }
244
- ],
245
- options: {
246
- outputReferences: true
247
- }
248
- }
249
- }
250
- };
251
- return config;
252
- };
253
-
254
- // src/tokens/process/configs/size.ts
255
- import * as R4 from "ramda";
256
5
  import { outputReferencesFilter } from "style-dictionary/utils";
257
- var sizeVariables = ({ theme }) => {
258
- const selector = `:root, [data-size]`;
259
- const layer = `ds.theme.size`;
260
- return {
261
- preprocessors: ["tokens-studio"],
262
- platforms: {
263
- css: {
264
- // custom
265
- theme,
266
- basePxFontSize,
267
- selector,
268
- layer,
269
- //
270
- prefix,
271
- buildPath: `${theme}/`,
272
- transforms: dsTransformers,
273
- files: [
274
- {
275
- destination: `size.css`,
276
- format: formats.size.name,
277
- filter: (token) => {
278
- const isUwantedToken = R4.anyPass([R4.includes("primitives/global")])(token.filePath);
279
- const isPrivateToken = R4.includes("_", token.path);
280
- return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
281
- }
282
- }
283
- ],
284
- options: {
285
- outputReferences: (token, options) => {
286
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
287
- return isWantedSize && outputReferencesFilter(token, options);
288
- }
289
- }
290
- }
291
- }
292
- };
293
- };
294
-
295
- // src/tokens/process/configs/size-mode.ts
296
- import * as R5 from "ramda";
297
- var sizeModeVariables = ({ theme, size: size2 }) => {
298
- const selector = `:root`;
299
- const layer = `ds.theme.size-mode`;
300
- return {
301
- preprocessors: ["tokens-studio"],
302
- platforms: {
303
- css: {
304
- // custom
305
- size: size2,
306
- theme,
307
- basePxFontSize,
308
- selector,
309
- layer,
310
- //
311
- prefix,
312
- buildPath: `${theme}/`,
313
- transforms: dsTransformers,
314
- files: [
315
- {
316
- destination: `size-mode/${size2}.css`,
317
- format: formats.sizeMode.name,
318
- filter: (token) => {
319
- return R5.equals(["_size", "mode-font-size"], token.path);
320
- }
321
- }
322
- ]
323
- }
324
- }
325
- };
326
- };
327
-
328
- // src/tokens/process/configs/type-scale.ts
329
- var typeScaleVariables = ({ theme }) => {
330
- const selector = ":root, [data-size]";
331
- const layer = `ds.theme.type-scale`;
332
- return {
333
- usesDtcg: true,
334
- preprocessors: ["tokens-studio"],
335
- expand: {
336
- include: ["typography"]
337
- },
338
- platforms: {
339
- css: {
340
- prefix,
341
- selector,
342
- layer,
343
- buildPath: `${theme}/`,
344
- basePxFontSize,
345
- transforms: [
346
- "name/kebab",
347
- "ts/size/px",
348
- sizeRem.name,
349
- "ts/size/lineheight",
350
- "ts/typography/fontWeight",
351
- typographyName.name
352
- ],
353
- files: [
354
- {
355
- destination: `type-scale.css`,
356
- format: formats.typeScale.name,
357
- filter: (token) => {
358
- const included = typeEquals(["typography", "dimension", "fontsize"], token);
359
- if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
360
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
361
- }
362
- }
363
- ],
364
- options: {
365
- outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
366
- }
367
- }
368
- }
369
- };
370
- };
371
-
372
- // src/tokens/process/configs/typography.ts
373
- import { expandTypesMap } from "@tokens-studio/sd-transforms";
374
- var typographyVariables = ({ theme, typography: typography2 }) => {
375
- const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
376
- const layer = `ds.theme.typography.${typography2}`;
377
- return {
378
- usesDtcg: true,
379
- preprocessors: ["tokens-studio"],
380
- expand: {
381
- include: ["typography"],
382
- typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
383
- },
384
- platforms: {
385
- css: {
386
- prefix,
387
- typography: typography2,
388
- selector,
389
- layer,
390
- buildPath: `${theme}/`,
391
- basePxFontSize,
392
- transforms: [
393
- "name/kebab",
394
- "ts/size/px",
395
- sizeRem.name,
396
- "ts/size/lineheight",
397
- "ts/typography/fontWeight",
398
- "ts/size/css/letterspacing",
399
- typographyName.name
400
- ],
401
- files: [
402
- {
403
- destination: `typography/${typography2}.css`,
404
- format: formats.typography.name,
405
- filter: (token) => {
406
- const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
407
- if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
408
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
409
- }
410
- }
411
- ]
412
- }
413
- }
414
- };
415
- };
416
-
417
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
418
- var BoxShadowTypes;
419
- (function(BoxShadowTypes2) {
420
- BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
421
- BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
422
- })(BoxShadowTypes || (BoxShadowTypes = {}));
423
-
424
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
425
- var ColorModifierTypes;
426
- (function(ColorModifierTypes2) {
427
- ColorModifierTypes2["LIGHTEN"] = "lighten";
428
- ColorModifierTypes2["DARKEN"] = "darken";
429
- ColorModifierTypes2["MIX"] = "mix";
430
- ColorModifierTypes2["ALPHA"] = "alpha";
431
- })(ColorModifierTypes || (ColorModifierTypes = {}));
432
-
433
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
434
- var ColorSpaceTypes;
435
- (function(ColorSpaceTypes2) {
436
- ColorSpaceTypes2["LCH"] = "lch";
437
- ColorSpaceTypes2["SRGB"] = "srgb";
438
- ColorSpaceTypes2["P3"] = "p3";
439
- ColorSpaceTypes2["HSL"] = "hsl";
440
- })(ColorSpaceTypes || (ColorSpaceTypes = {}));
441
-
442
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
443
- var Properties;
444
- (function(Properties2) {
445
- Properties2["sizing"] = "sizing";
446
- Properties2["height"] = "height";
447
- Properties2["width"] = "width";
448
- Properties2["spacing"] = "spacing";
449
- Properties2["verticalPadding"] = "verticalPadding";
450
- Properties2["horizontalPadding"] = "horizontalPadding";
451
- Properties2["paddingTop"] = "paddingTop";
452
- Properties2["paddingRight"] = "paddingRight";
453
- Properties2["paddingBottom"] = "paddingBottom";
454
- Properties2["paddingLeft"] = "paddingLeft";
455
- Properties2["itemSpacing"] = "itemSpacing";
456
- Properties2["fill"] = "fill";
457
- Properties2["backgroundBlur"] = "backgroundBlur";
458
- Properties2["border"] = "border";
459
- Properties2["borderTop"] = "borderTop";
460
- Properties2["borderRight"] = "borderRight";
461
- Properties2["borderBottom"] = "borderBottom";
462
- Properties2["borderLeft"] = "borderLeft";
463
- Properties2["borderColor"] = "borderColor";
464
- Properties2["borderRadius"] = "borderRadius";
465
- Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
466
- Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
467
- Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
468
- Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
469
- Properties2["borderWidth"] = "borderWidth";
470
- Properties2["borderWidthTop"] = "borderWidthTop";
471
- Properties2["borderWidthRight"] = "borderWidthRight";
472
- Properties2["borderWidthBottom"] = "borderWidthBottom";
473
- Properties2["borderWidthLeft"] = "borderWidthLeft";
474
- Properties2["boxShadow"] = "boxShadow";
475
- Properties2["opacity"] = "opacity";
476
- Properties2["fontFamilies"] = "fontFamilies";
477
- Properties2["fontWeights"] = "fontWeights";
478
- Properties2["fontSizes"] = "fontSizes";
479
- Properties2["lineHeights"] = "lineHeights";
480
- Properties2["typography"] = "typography";
481
- Properties2["composition"] = "composition";
482
- Properties2["letterSpacing"] = "letterSpacing";
483
- Properties2["paragraphSpacing"] = "paragraphSpacing";
484
- Properties2["textCase"] = "textCase";
485
- Properties2["dimension"] = "dimension";
486
- Properties2["textDecoration"] = "textDecoration";
487
- Properties2["asset"] = "asset";
488
- Properties2["tokenValue"] = "tokenValue";
489
- Properties2["value"] = "value";
490
- Properties2["tokenName"] = "tokenName";
491
- Properties2["description"] = "description";
492
- })(Properties || (Properties = {}));
493
-
494
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
495
- var TokenSetStatus;
496
- (function(TokenSetStatus2) {
497
- TokenSetStatus2["DISABLED"] = "disabled";
498
- TokenSetStatus2["SOURCE"] = "source";
499
- TokenSetStatus2["ENABLED"] = "enabled";
500
- })(TokenSetStatus || (TokenSetStatus = {}));
501
-
502
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
503
- var TokenTypes;
504
- (function(TokenTypes2) {
505
- TokenTypes2["OTHER"] = "other";
506
- TokenTypes2["COLOR"] = "color";
507
- TokenTypes2["BORDER_RADIUS"] = "borderRadius";
508
- TokenTypes2["SIZING"] = "sizing";
509
- TokenTypes2["SPACING"] = "spacing";
510
- TokenTypes2["TEXT"] = "text";
511
- TokenTypes2["TYPOGRAPHY"] = "typography";
512
- TokenTypes2["OPACITY"] = "opacity";
513
- TokenTypes2["BORDER_WIDTH"] = "borderWidth";
514
- TokenTypes2["STROKE_STYLE"] = "strokeStyle";
515
- TokenTypes2["BOX_SHADOW"] = "boxShadow";
516
- TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
517
- TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
518
- TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
519
- TokenTypes2["FONT_SIZES"] = "fontSizes";
520
- TokenTypes2["LETTER_SPACING"] = "letterSpacing";
521
- TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
522
- TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
523
- TokenTypes2["TEXT_DECORATION"] = "textDecoration";
524
- TokenTypes2["TEXT_CASE"] = "textCase";
525
- TokenTypes2["COMPOSITION"] = "composition";
526
- TokenTypes2["DIMENSION"] = "dimension";
527
- TokenTypes2["BORDER"] = "border";
528
- TokenTypes2["ASSET"] = "asset";
529
- TokenTypes2["BOOLEAN"] = "boolean";
530
- TokenTypes2["NUMBER"] = "number";
531
- })(TokenTypes || (TokenTypes = {}));
532
-
533
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
534
- var BorderValues;
535
- (function(BorderValues2) {
536
- BorderValues2["BORDER_COLOR"] = "color";
537
- BorderValues2["BORDER_WIDTH"] = "width";
538
- BorderValues2["BORDER_STYLE"] = "style";
539
- })(BorderValues || (BorderValues = {}));
540
-
541
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
542
- var StrokeStyleValues;
543
- (function(StrokeStyleValues2) {
544
- StrokeStyleValues2["SOLID"] = "solid";
545
- StrokeStyleValues2["DASHED"] = "dashed";
546
- StrokeStyleValues2["DOTTED"] = "dotted";
547
- StrokeStyleValues2["DOUBLE"] = "double";
548
- StrokeStyleValues2["GROOVE"] = "groove";
549
- StrokeStyleValues2["RIDGE"] = "ridge";
550
- StrokeStyleValues2["OUTSET"] = "outset";
551
- StrokeStyleValues2["INSET"] = "inset";
552
- })(StrokeStyleValues || (StrokeStyleValues = {}));
553
-
554
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
555
- var BoxShadowValues;
556
- (function(BoxShadowValues2) {
557
- BoxShadowValues2["TYPE"] = "type";
558
- BoxShadowValues2["COLOR"] = "color";
559
- BoxShadowValues2["X"] = "x";
560
- BoxShadowValues2["Y"] = "y";
561
- BoxShadowValues2["BLUR"] = "blur";
562
- BoxShadowValues2["SPREAD"] = "spread";
563
- BoxShadowValues2["BLEND_MODE"] = "blendMode";
564
- })(BoxShadowValues || (BoxShadowValues = {}));
565
-
566
- // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
567
- var TypographyValues;
568
- (function(TypographyValues2) {
569
- TypographyValues2["FONT_FAMILY"] = "fontFamily";
570
- TypographyValues2["FONT_WEIGHT"] = "fontWeight";
571
- TypographyValues2["LINE_HEIGHT"] = "lineHeight";
572
- TypographyValues2["FONT_SIZE"] = "fontSize";
573
- TypographyValues2["LETTER_SPACING"] = "letterSpacing";
574
- TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
575
- TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
576
- TypographyValues2["TEXT_DECORATION"] = "textDecoration";
577
- TypographyValues2["TEXT_CASE"] = "textCase";
578
- })(TypographyValues || (TypographyValues = {}));
579
-
580
- // src/tokens/process/utils/getMultidimensionalThemes.ts
581
- import pc from "picocolors";
582
- import * as R6 from "ramda";
583
- var hasUnknownProps = R6.pipe(R6.values, R6.none(R6.equals("unknown")), R6.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
- R9.allPass([
677
- R9.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(R9.view(R9.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 = R9.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 = R9.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(R9.view(R9.lensProp("formatted"))).join("\n");
733
- const content = `{
734
- ${formattedTokens}
735
- }
736
- `;
737
- const body = R9.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 R11 from "ramda";
748
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
749
-
750
- // src/tokens/process/formats/css/size.ts
751
- import * as R10 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 = R10.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) => R10.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 = R10.reject((token) => R10.equals(["_size", "mode-font-size"], token.path), tokens);
810
- const [sizingTokens, restTokens] = R10.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(R10.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
825
- const content = `${selector} {
826
- ${formattedTokens.join("\n")}
827
- }
828
- `;
829
- const body = R10.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(R11.prop("formatted")).join("\n");
858
- const content = `${selector} {
859
- ${formattedTokens}
860
- }
861
- `;
862
- const body = R11.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 R12 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) === R12.last(sizes) ? `
920
- ${wrapInLayer(sharedContent, layer)}` : "";
921
- return body + sharedBody;
922
- }
923
- };
924
- function wrapInLayer(content, layer) {
925
- return R12.isNotNil(layer) ? `@layer ${layer} {
926
- ${content}
927
- }
928
- ` : `${content}
929
- `;
930
- }
931
-
932
- // src/tokens/process/formats/css/typography.ts
933
- import * as R13 from "ramda";
934
- import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
935
- var typographyFontFamilyPredicate = R13.allPass([
936
- R13.pathSatisfies(R13.includes("typography"), ["path"]),
937
- R13.pathSatisfies(R13.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 = R13.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(R13.view(R13.lensProp("formatted"))).join("\n");
958
- const content = selector ? `${selector} {
959
- ${formattedTokens}
960
- }` : formattedTokens;
961
- const body = R13.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 R14 from "ramda";
970
- import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
971
- var isTypographyFontFamilyToken = R14.allPass([
972
- R14.pathSatisfies(R14.includes("typography"), ["path"]),
973
- R14.pathSatisfies(R14.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 (R14.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) => R14.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 = R14.reject(R14.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 = R14.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/semantic.ts
1040
- var semanticVariables = ({ theme }) => {
1041
- const selector = `:root`;
1042
- const layer = `ds.theme.semantic`;
1043
- return {
1044
- preprocessors: ["tokens-studio"],
1045
- platforms: {
1046
- css: {
1047
- // custom
1048
- theme,
1049
- basePxFontSize,
1050
- selector,
1051
- layer,
1052
- //
1053
- prefix,
1054
- buildPath: `${theme}/`,
1055
- transforms: dsTransformers,
1056
- files: [
1057
- {
1058
- destination: `semantic.css`,
1059
- format: formats.semantic.name,
1060
- filter: (token) => {
1061
- const isUwantedToken = R15.anyPass([R15.includes("primitives/global")])(token.filePath);
1062
- const isPrivateToken = R15.includes("_", token.path);
1063
- const unwantedPaths = pathStartsWithOneOf(
1064
- ["size", "_size", "font-size", "line-height", "letter-spacing"],
1065
- token
1066
- );
1067
- const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
1068
- const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
1069
- return unwantedTokens;
1070
- }
1071
- }
1072
- ],
1073
- options: {
1074
- outputReferences: (token, options) => {
1075
- const include = pathStartsWithOneOf(["border-radius"], token);
1076
- return include && outputReferencesFilter2(token, options);
1077
- }
1078
- }
1079
- }
1080
- }
1081
- };
1082
- };
1083
- export {
1084
- semanticVariables
1085
- };
6
+ //#region src/tokens/process/configs/semantic.ts
7
+ const semanticVariables = ({ theme }) => {
8
+ return {
9
+ preprocessors: ["tokens-studio"],
10
+ platforms: { css: {
11
+ theme,
12
+ basePxFontSize: 16,
13
+ selector: `:root`,
14
+ layer: `ds.theme.semantic`,
15
+ prefix: "ds",
16
+ buildPath: `${theme}/`,
17
+ transforms: dsTransformers,
18
+ files: [{
19
+ destination: `semantic.css`,
20
+ format: formats.semantic.name,
21
+ filter: (token) => {
22
+ const isUwantedToken = R.anyPass([R.includes("primitives/global")])(token.filePath);
23
+ const isPrivateToken = R.includes("_", token.path);
24
+ const unwantedPaths = pathStartsWithOneOf([
25
+ "size",
26
+ "_size",
27
+ "font-size",
28
+ "line-height",
29
+ "letter-spacing"
30
+ ], token);
31
+ const unwantedTypes = typeEquals([
32
+ "color",
33
+ "fontWeight",
34
+ "fontFamily",
35
+ "typography"
36
+ ], token);
37
+ return !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
38
+ }
39
+ }],
40
+ options: { outputReferences: (token, options) => {
41
+ return pathStartsWithOneOf(["border-radius"], token) && outputReferencesFilter(token, options);
42
+ } }
43
+ } }
44
+ };
45
+ };
46
+ //#endregion
47
+ export { semanticVariables };