@digdir/designsystemet 1.13.2 → 1.14.0

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