@digdir/designsystemet 1.13.1 → 1.13.3

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