@digdir/designsystemet 1.13.2 → 1.13.3

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