@digdir/designsystemet 1.13.1 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/bin/config.js +50 -658
  2. package/dist/bin/designsystemet.js +131 -4623
  3. package/dist/bin/options.js +22 -14
  4. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js +9 -0
  5. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js +8 -0
  6. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js +13 -0
  7. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js +10 -0
  8. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js +10 -0
  9. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js +53 -0
  10. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js +14 -0
  11. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js +9 -0
  12. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js +32 -0
  13. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js +15 -0
  14. package/dist/node_modules/.pnpm/@tokens-studio_types@0.5.2/node_modules/@tokens-studio/types/dist/types/index.js +11 -0
  15. package/dist/package.js +5 -0
  16. package/dist/src/colors/colorMetadata.js +255 -261
  17. package/dist/src/colors/index.js +5 -522
  18. package/dist/src/colors/theme.js +104 -343
  19. package/dist/src/colors/types.js +22 -25
  20. package/dist/src/colors/utils.js +241 -154
  21. package/dist/src/config.js +103 -444
  22. package/dist/src/index.js +10 -3588
  23. package/dist/src/migrations/beta-to-v1.js +339 -537
  24. package/dist/src/migrations/codemods/css/plugins.js +31 -42
  25. package/dist/src/migrations/codemods/css/run.js +20 -151
  26. package/dist/src/migrations/color-rename-next49.js +44 -220
  27. package/dist/src/migrations/index.js +7 -577
  28. package/dist/src/tokens/build.js +39 -1816
  29. package/dist/src/tokens/create/files.js +43 -602
  30. package/dist/src/tokens/create/generators/$designsystemet.js +8 -97
  31. package/dist/src/tokens/create/generators/$metadata.js +17 -20
  32. package/dist/src/tokens/create/generators/$themes.js +137 -311
  33. package/dist/src/tokens/create/generators/primitives/color-scheme.js +68 -443
  34. package/dist/src/tokens/create/generators/primitives/globals.js +141 -147
  35. package/dist/src/tokens/create/generators/primitives/size.js +146 -156
  36. package/dist/src/tokens/create/generators/primitives/typography.js +213 -217
  37. package/dist/src/tokens/create/generators/semantic/color-modes.js +24 -59
  38. package/dist/src/tokens/create/generators/semantic/color.js +42 -326
  39. package/dist/src/tokens/create/generators/semantic/style.js +379 -382
  40. package/dist/src/tokens/create/generators/themes/theme.js +108 -392
  41. package/dist/src/tokens/create.js +47 -1591
  42. package/dist/src/tokens/format.js +38 -3324
  43. package/dist/src/tokens/generate-config.js +155 -298
  44. package/dist/src/tokens/index.js +3 -3344
  45. package/dist/src/tokens/process/configs/color.js +50 -1086
  46. package/dist/src/tokens/process/configs/semantic.js +45 -1084
  47. package/dist/src/tokens/process/configs/shared.js +18 -109
  48. package/dist/src/tokens/process/configs/size-mode.js +27 -1083
  49. package/dist/src/tokens/process/configs/size.js +32 -1084
  50. package/dist/src/tokens/process/configs/type-scale.js +49 -1084
  51. package/dist/src/tokens/process/configs/typography.js +63 -1085
  52. package/dist/src/tokens/process/configs.js +88 -1225
  53. package/dist/src/tokens/process/formats/css/color.js +58 -1080
  54. package/dist/src/tokens/process/formats/css/semantic.js +27 -1082
  55. package/dist/src/tokens/process/formats/css/size-mode.js +43 -1078
  56. package/dist/src/tokens/process/formats/css/size.js +86 -1080
  57. package/dist/src/tokens/process/formats/css/type-scale.js +53 -1084
  58. package/dist/src/tokens/process/formats/css/typography.js +27 -1082
  59. package/dist/src/tokens/process/formats/css.js +18 -1082
  60. package/dist/src/tokens/process/output/declarations.js +18 -1202
  61. package/dist/src/tokens/process/output/tailwind.js +26 -40
  62. package/dist/src/tokens/process/output/theme.js +73 -206
  63. package/dist/src/tokens/process/platform.js +165 -1356
  64. package/dist/src/tokens/process/transformers.js +49 -89
  65. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +100 -1183
  66. package/dist/src/tokens/process/utils/kebab-case.js +7 -5
  67. package/dist/src/tokens/types.js +6 -7
  68. package/dist/src/tokens/utils.js +102 -93
  69. package/dist/src/types.js +1 -5
  70. package/dist/src/utils/filesystem.js +112 -124
  71. package/package.json +18 -21
  72. package/configs/test-tokens.config.json +0 -82
  73. package/dist/src/scripts/createJsonSchema.js +0 -409
  74. package/dist/src/scripts/update-preview-tokens.js +0 -3353
@@ -1,1086 +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 processed = Symbol("Type brand for ProcessedThemeObject");
584
- var hasUnknownProps = R6.pipe(R6.values, R6.none(R6.equals("unknown")), R6.not);
585
-
586
- // src/tokens/process/configs.ts
587
- void register(StyleDictionary, { withSDBuiltins: false });
588
- StyleDictionary.registerTransform(sizeRem);
589
- StyleDictionary.registerTransform(typographyName);
590
- StyleDictionary.registerTransform(resolveMath);
591
- StyleDictionary.registerTransform(unitless);
592
- for (const format of Object.values(formats)) {
593
- StyleDictionary.registerFormat(format);
594
- }
595
- var configs = {
596
- colorSchemeVariables,
597
- mainColorVariables: colorCategoryVariables({ category: "main" }),
598
- supportColorVariables: colorCategoryVariables({ category: "support" }),
599
- neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
600
- successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
601
- dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
602
- warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
603
- infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
604
- sizeModeVariables,
605
- sizeVariables,
606
- typographyVariables,
607
- typeScaleVariables,
608
- semanticVariables
609
- };
610
-
611
- // src/tokens/process/platform.ts
612
- var buildOptions = {
613
- verbose: false,
614
- processed$themes: [],
615
- buildTokenFormats: {}
616
- };
617
- var sd = new StyleDictionary2();
618
- var buildConfigs = {
619
- typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
620
- sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
621
- size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
622
- typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
623
- "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
624
- "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
625
- "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
626
- "neutral-color": {
627
- getConfig: configs.neutralColorVariables,
628
- dimensions: ["semantic"],
629
- log: ({ permutation: { theme } }) => `${theme} - neutral`
630
- },
631
- "success-color": {
632
- getConfig: configs.successColorVariables,
633
- dimensions: ["semantic"],
634
- log: ({ permutation: { theme } }) => `${theme} - success`
635
- },
636
- "danger-color": {
637
- getConfig: configs.dangerColorVariables,
638
- dimensions: ["semantic"],
639
- log: ({ permutation: { theme } }) => `${theme} - danger`
640
- },
641
- "warning-color": {
642
- getConfig: configs.warningColorVariables,
643
- dimensions: ["semantic"],
644
- log: ({ permutation: { theme } }) => `${theme} - warning`
645
- },
646
- "info-color": {
647
- getConfig: configs.infoColorVariables,
648
- dimensions: ["semantic"],
649
- log: ({ permutation: { theme } }) => `${theme} - info`
650
- },
651
- semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
652
- };
653
-
654
- // src/tokens/process/formats/css/color.ts
655
- var prefersColorScheme = (colorScheme2, content) => `
656
- @media (prefers-color-scheme: ${colorScheme2}) {
657
- [data-color-scheme="auto"] ${content}
658
- }
659
- `;
660
- var colorScheme = {
661
- name: "ds/css-colorscheme",
662
- format: async ({ dictionary, options, platform }) => {
663
- const { allTokens } = dictionary;
664
- const { outputReferences, usesDtcg } = options;
665
- const { selector, colorScheme: colorScheme2, layer } = platform;
666
- const colorScheme_ = colorScheme2;
667
- const format = createPropertyFormatter({
668
- outputReferences,
669
- dictionary,
670
- format: "css",
671
- usesDtcg
672
- });
673
- const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
674
- color-scheme: ${colorScheme_};
675
- ` : "";
676
- const filteredAllTokens = allTokens.filter(
677
- R9.allPass([
678
- R9.anyPass([
679
- // Include semantic tokens in the output
680
- isSemanticToken,
681
- // Include global color tokens
682
- isGlobalColorToken
683
- ]),
684
- // Don't include color category tokens -- they are exported separately
685
- (t) => !isColorCategoryToken(t)
686
- ])
687
- );
688
- const formattedMap = filteredAllTokens.map((token) => ({
689
- token,
690
- formatted: format(token)
691
- }));
692
- const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
693
- const content = `{
694
- ${formattedTokens}
695
- ${colorSchemeProperty}}
696
- `;
697
- const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
698
- const body = R9.isNotNil(layer) ? `@layer ${layer} {
699
- ${selector} ${content} ${autoSelectorContent}
700
- }
701
- ` : `${selector} ${content} ${autoSelectorContent}
702
- `;
703
- return body;
704
- }
705
- };
706
- var colorCategory = {
707
- name: "ds/css-colorcategory",
708
- format: async ({ dictionary, file, options, platform }) => {
709
- const { outputReferences, usesDtcg } = options;
710
- const { selector, layer } = platform;
711
- const destination = file.destination;
712
- const format = R9.compose(
713
- createPropertyFormatter({
714
- outputReferences,
715
- dictionary,
716
- format: "css",
717
- usesDtcg
718
- }),
719
- (token) => ({
720
- ...token,
721
- name: token.name.replace(/color-\w+-/, "color-"),
722
- original: {
723
- ...token.original,
724
- $value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
725
- }
726
- })
727
- );
728
- const formattedMap = dictionary.allTokens.map((token) => ({
729
- token,
730
- formatted: format(token)
731
- }));
732
- buildOptions.buildTokenFormats[destination] = formattedMap;
733
- const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
734
- const content = `{
735
- ${formattedTokens}
736
- }
737
- `;
738
- const body = R9.isNotNil(layer) ? `@layer ${layer} {
739
- ${selector} ${content}
740
- }
741
- ` : `${selector} ${content}
742
- `;
743
- return body;
744
- }
745
- };
746
-
747
- // src/tokens/process/formats/css/semantic.ts
748
- import * as R11 from "ramda";
749
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
750
-
751
- // src/tokens/process/formats/css/size.ts
752
- import * as R10 from "ramda";
753
- import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
754
- var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
755
- var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
756
- var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
757
- var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
758
- var overrideSizingFormula = (format, token) => {
759
- const [name, value] = format(token).replace(/;$/, "").split(": ");
760
- let calc;
761
- let round;
762
- if (token.path[1] === "unit") {
763
- calc = `calc(1rem * ${value})`;
764
- } else if (value.startsWith("floor")) {
765
- calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
766
- round = `round(down, ${calc}, 1px)`;
767
- } else {
768
- calc = value.includes("*") ? `calc(${value})` : value;
769
- }
770
- return {
771
- name,
772
- round: round ?? calc,
773
- calc
774
- };
775
- };
776
- var formatSizingTokens = (format, tokens) => R10.reduce(
777
- (acc, token) => {
778
- const { round, calc, name } = overrideSizingFormula(format, token);
779
- return {
780
- tokens: [...acc.tokens, token],
781
- round: [...acc.round, `${name}: ${round};`],
782
- calc: [...acc.calc, `${name}: ${calc};`]
783
- };
784
- },
785
- { tokens: [], round: [], calc: [] },
786
- tokens
787
- );
788
- var sizingTemplate = ({ round, calc }) => {
789
- const usesRounding = round.filter((val, i) => val !== calc[i]);
790
- return `
791
- ${calc.join("\n")}
792
-
793
- @supports (width: round(down, .1em, 1px)) {
794
- ${usesRounding.join("\n ")}
795
- }`;
796
- };
797
- var size = {
798
- name: "ds/css-size",
799
- format: async ({ dictionary, file, options, platform }) => {
800
- const { outputReferences, usesDtcg } = options;
801
- const { selector, layer } = platform;
802
- const destination = file.destination;
803
- const format = createPropertyFormatter2({
804
- outputReferences,
805
- dictionary,
806
- format: "css",
807
- usesDtcg
808
- });
809
- const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
810
- const filteredTokens = R10.reject((token) => R10.equals(["_size", "mode-font-size"], token.path), tokens);
811
- const [sizingTokens, restTokens] = R10.partition(
812
- (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
813
- filteredTokens
814
- );
815
- const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
816
- const formattedMap = restTokens.map((token) => ({
817
- token,
818
- formatted: format(token)
819
- }));
820
- const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
821
- token: formattedSizingTokens.tokens[i],
822
- formatted: t
823
- }));
824
- buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
825
- const formattedTokens = [formattedMap.map(R10.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
826
- const content = `${selector} {
827
- ${formattedTokens.join("\n")}
828
- }
829
- `;
830
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
831
- ${content}
832
- }
833
- ` : `${content}
834
- `;
835
- return body;
836
- }
837
- };
838
-
839
- // src/tokens/process/formats/css/semantic.ts
840
- var semantic = {
841
- name: "ds/css-semantic",
842
- format: async ({ dictionary, file, options, platform }) => {
843
- const { outputReferences, usesDtcg } = options;
844
- const { selector, layer } = platform;
845
- const destination = file.destination;
846
- const format = createPropertyFormatter3({
847
- outputReferences,
848
- dictionary,
849
- format: "css",
850
- usesDtcg
851
- });
852
- const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
853
- const formattedMap = tokens.map((token) => ({
854
- token,
855
- formatted: format(token)
856
- }));
857
- buildOptions.buildTokenFormats[destination] = formattedMap;
858
- const formattedTokens = formattedMap.map(R11.prop("formatted")).join("\n");
859
- const content = `${selector} {
860
- ${formattedTokens}
861
- }
862
- `;
863
- const body = R11.isNotNil(layer) ? `@layer ${layer} {
864
- ${content}
865
- }
866
- ` : `${content}
867
- `;
868
- return body;
869
- }
870
- };
871
-
872
- // src/tokens/process/formats/css/size-mode.ts
873
- import * as R12 from "ramda";
874
- import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
875
- var formatBaseSizeToken = (size2) => (token) => ({
876
- ...token,
877
- originalName: token.name,
878
- name: `${token.name}--${shortSizeName(size2)}`,
879
- $value: token.$value / basePxFontSize
880
- });
881
- var sizeMode = {
882
- name: "ds/css-size-mode",
883
- format: async ({ dictionary, file, options, platform }) => {
884
- const { outputReferences, usesDtcg } = options;
885
- const { selector, layer, size: size2 } = platform;
886
- const destination = file.destination;
887
- const format = createPropertyFormatter4({
888
- outputReferences,
889
- dictionary,
890
- format: "css",
891
- usesDtcg
892
- });
893
- const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
894
- const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
895
- const formattedMap = sizeSpecificTokens.map((token) => ({
896
- token,
897
- formatted: format({
898
- ...token,
899
- // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
900
- name: token.originalName
901
- })
902
- }));
903
- buildOptions.buildTokenFormats[destination] = formattedMap;
904
- const content = `${selector} /* ${size2} */ {
905
- ${sizeSpecificVariables}
906
- }`;
907
- const body = wrapInLayer(content, layer);
908
- const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
909
- const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
910
- const sizingToggles = `:root, [data-size] {
911
- --ds-size: var(--ds-size--${defaultSize});
912
- ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
913
- --ds-size-mode-font-size:
914
- ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
915
- }`;
916
- const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
917
- const sharedContent = `${sizingToggles}
918
-
919
- ${sizingHelpers}`;
920
- const sharedBody = shortSizeName(size2) === R12.last(sizes) ? `
921
- ${wrapInLayer(sharedContent, layer)}` : "";
922
- return body + sharedBody;
923
- }
924
- };
925
- function wrapInLayer(content, layer) {
926
- return R12.isNotNil(layer) ? `@layer ${layer} {
927
- ${content}
928
- }
929
- ` : `${content}
930
- `;
931
- }
932
-
933
- // src/tokens/process/formats/css/typography.ts
934
- import * as R13 from "ramda";
935
- import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
936
- var typographyFontFamilyPredicate = R13.allPass([
937
- R13.pathSatisfies(R13.includes("typography"), ["path"]),
938
- R13.pathSatisfies(R13.includes("fontFamily"), ["path"])
939
- ]);
940
- var typography = {
941
- name: "ds/css-typography",
942
- format: async ({ dictionary, file, options, platform }) => {
943
- const { outputReferences, usesDtcg } = options;
944
- const { selector, layer } = platform;
945
- const destination = file.destination;
946
- const format = createPropertyFormatter5({
947
- outputReferences,
948
- dictionary,
949
- format: "css",
950
- usesDtcg
951
- });
952
- const filteredTokens = R13.reject(typographyFontFamilyPredicate, dictionary.allTokens);
953
- const formattedMap = filteredTokens.map((token) => ({
954
- token,
955
- formatted: format(token)
956
- }));
957
- buildOptions.buildTokenFormats[destination] = formattedMap;
958
- const formattedTokens = formattedMap.map(R13.view(R13.lensProp("formatted"))).join("\n");
959
- const content = selector ? `${selector} {
960
- ${formattedTokens}
961
- }` : formattedTokens;
962
- const body = R13.isNotNil(layer) ? `@layer ${layer} {
963
- ${content}
964
- }` : content;
965
- return body;
966
- }
967
- };
968
-
969
- // src/tokens/process/formats/css/type-scale.ts
970
- import * as R14 from "ramda";
971
- import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
972
- var isTypographyFontFamilyToken = R14.allPass([
973
- R14.pathSatisfies(R14.includes("typography"), ["path"]),
974
- R14.pathSatisfies(R14.includes("fontFamily"), ["path"])
975
- ]);
976
- var formatTypographySizeToken = (format, token) => {
977
- const [name, value] = format(token).replace(/;$/, "").split(": ");
978
- let calc;
979
- let round;
980
- if (R14.startsWith(["font-size"], token.path)) {
981
- calc = `calc(${value} * var(--_ds-font-size-factor))`;
982
- round = `round(${calc}, 1px)`;
983
- } else {
984
- calc = value;
985
- }
986
- return { name, calc, round: round ?? calc };
987
- };
988
- var formatTypographySizeTokens = (format, tokens) => R14.reduce(
989
- (acc, token) => {
990
- const { name, calc, round } = formatTypographySizeToken(format, token);
991
- acc.tokens.push(token);
992
- acc.calc.push(`${name}: ${calc};`);
993
- acc.round.push(`${name}: ${round};`);
994
- return acc;
995
- },
996
- { tokens: [], calc: [], round: [] },
997
- tokens
998
- );
999
- var typeScale = {
1000
- name: "ds/css-type-scale",
1001
- format: async ({ dictionary, file, options, platform }) => {
1002
- const { outputReferences, usesDtcg } = options;
1003
- const { selector, layer } = platform;
1004
- const destination = file.destination;
1005
- const format = createPropertyFormatter6({
1006
- outputReferences,
1007
- dictionary,
1008
- format: "css",
1009
- usesDtcg
1010
- });
1011
- const filteredTokens = R14.reject(R14.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
1012
- const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
1013
- const formattedMap = formattedTokens.round.map((t, i) => ({
1014
- token: formattedTokens.tokens[i],
1015
- formatted: t
1016
- }));
1017
- buildOptions.buildTokenFormats[destination] = formattedMap;
1018
- const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
1019
- const content = `${selector} {
1020
- ${sizeFactor}${sizingTemplate(formattedTokens)}
1021
- }`;
1022
- const body = R14.isNotNil(layer) ? `@layer ${layer} {
1023
- ${content}
1024
- }` : content;
1025
- return body;
1026
- }
1027
- };
1028
-
1029
- // src/tokens/process/formats/css.ts
1030
- var formats = {
1031
- colorScheme,
1032
- colorCategory,
1033
- semantic,
1034
- sizeMode,
1035
- size,
1036
- typography,
1037
- typeScale
1038
- };
1039
-
1040
- // src/tokens/process/configs/semantic.ts
1041
- var semanticVariables = ({ theme }) => {
1042
- const selector = `:root`;
1043
- const layer = `ds.theme.semantic`;
1044
- return {
1045
- preprocessors: ["tokens-studio"],
1046
- platforms: {
1047
- css: {
1048
- // custom
1049
- theme,
1050
- basePxFontSize,
1051
- selector,
1052
- layer,
1053
- //
1054
- prefix,
1055
- buildPath: `${theme}/`,
1056
- transforms: dsTransformers,
1057
- files: [
1058
- {
1059
- destination: `semantic.css`,
1060
- format: formats.semantic.name,
1061
- filter: (token) => {
1062
- const isUwantedToken = R15.anyPass([R15.includes("primitives/global")])(token.filePath);
1063
- const isPrivateToken = R15.includes("_", token.path);
1064
- const unwantedPaths = pathStartsWithOneOf(
1065
- ["size", "_size", "font-size", "line-height", "letter-spacing"],
1066
- token
1067
- );
1068
- const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
1069
- const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
1070
- return unwantedTokens;
1071
- }
1072
- }
1073
- ],
1074
- options: {
1075
- outputReferences: (token, options) => {
1076
- const include = pathStartsWithOneOf(["border-radius"], token);
1077
- return include && outputReferencesFilter2(token, options);
1078
- }
1079
- }
1080
- }
1081
- }
1082
- };
1083
- };
1084
- export {
1085
- semanticVariables
1086
- };
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 };