@digdir/designsystemet 1.13.2 → 1.14.0

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