@digdir/designsystemet 1.1.2 → 1.1.4

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 (41) hide show
  1. package/dist/bin/designsystemet.js +131 -187
  2. package/dist/src/index.js +89 -146
  3. package/dist/src/scripts/update-preview-tokens.d.ts +3 -0
  4. package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -0
  5. package/dist/src/scripts/update-preview-tokens.js +3446 -0
  6. package/dist/src/tokens/build.d.ts +1 -1
  7. package/dist/src/tokens/build.d.ts.map +1 -1
  8. package/dist/src/tokens/build.js +99 -155
  9. package/dist/src/tokens/create/generators/$designsystemet.js +7 -7
  10. package/dist/src/tokens/create/write.js +7 -7
  11. package/dist/src/tokens/format.d.ts +1 -1
  12. package/dist/src/tokens/format.d.ts.map +1 -1
  13. package/dist/src/tokens/format.js +89 -146
  14. package/dist/src/tokens/index.js +89 -146
  15. package/dist/src/tokens/process/configs/color.js +234 -293
  16. package/dist/src/tokens/process/configs/semantic.js +509 -113
  17. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  18. package/dist/src/tokens/process/configs/typography.js +504 -110
  19. package/dist/src/tokens/process/configs.d.ts +0 -1
  20. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  21. package/dist/src/tokens/process/configs.js +231 -290
  22. package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -1
  23. package/dist/src/tokens/process/formats/css/color.js +644 -12
  24. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
  25. package/dist/src/tokens/process/formats/css/semantic.js +679 -23
  26. package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -1
  27. package/dist/src/tokens/process/formats/css/typography.js +741 -8
  28. package/dist/src/tokens/process/formats/css.js +549 -38
  29. package/dist/src/tokens/process/output/declarations.js +60 -121
  30. package/dist/src/tokens/process/output/theme.js +7 -7
  31. package/dist/src/tokens/process/platform.d.ts +9 -4
  32. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  33. package/dist/src/tokens/process/platform.js +76 -133
  34. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +62 -123
  35. package/package.json +7 -7
  36. package/dist/src/tokens/process/configs/storefront.d.ts +0 -3
  37. package/dist/src/tokens/process/configs/storefront.d.ts.map +0 -1
  38. package/dist/src/tokens/process/configs/storefront.js +0 -234
  39. package/dist/src/tokens/process/formats/js-tokens.d.ts +0 -6
  40. package/dist/src/tokens/process/formats/js-tokens.d.ts.map +0 -1
  41. package/dist/src/tokens/process/formats/js-tokens.js +0 -123
@@ -1,9 +1,17 @@
1
1
  // src/tokens/process/formats/css/semantic.ts
2
- import * as R2 from "ramda";
3
- import { createPropertyFormatter } from "style-dictionary/utils";
2
+ import * as R10 from "ramda";
3
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
4
4
 
5
5
  // src/tokens/utils.ts
6
6
  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
7
15
  var mapToLowerCase = R.map(R.toLower);
8
16
  var hasAnyTruth = R.any(R.equals(true));
9
17
  var getType = (token) => (token.$type ?? token.type) || "";
@@ -26,6 +34,23 @@ var pathStartsWithOneOf = R.curry(
26
34
  return hasAnyTruth(matchPathsStartingWith);
27
35
  }
28
36
  );
37
+ function isSemanticToken(token) {
38
+ return token.filePath.includes("semantic/");
39
+ }
40
+ function isSemanticColorToken(token, color) {
41
+ return token.filePath.includes("semantic/") && R.startsWith(["color", color], token.path);
42
+ }
43
+ function isGlobalColorToken(token) {
44
+ return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
45
+ }
46
+ function isColorCategoryToken(token, category) {
47
+ if (!category) {
48
+ return Object.keys(colorCategories).some(
49
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
50
+ );
51
+ }
52
+ return R.startsWith(["color", category], token.path);
53
+ }
29
54
  var isDigit = (s) => /^\d+$/.test(s);
30
55
  function inlineTokens(shouldInline, tokens) {
31
56
  const [inlineableTokens, otherTokens] = R.partition(shouldInline, tokens);
@@ -42,11 +67,631 @@ function inlineTokens(shouldInline, tokens) {
42
67
  });
43
68
  }
44
69
 
70
+ // src/tokens/process/platform.ts
71
+ import chalk2 from "chalk";
72
+ import * as R9 from "ramda";
73
+ import StyleDictionary2 from "style-dictionary";
74
+
75
+ // src/tokens/process/configs.ts
76
+ import { register } from "@tokens-studio/sd-transforms";
77
+ import * as R8 from "ramda";
78
+ import StyleDictionary from "style-dictionary";
79
+
80
+ // src/tokens/process/configs/color.ts
81
+ import * as R5 from "ramda";
82
+
83
+ // src/tokens/process/formats/css/color.ts
84
+ import * as R2 from "ramda";
85
+ import { createPropertyFormatter } from "style-dictionary/utils";
86
+ var prefersColorScheme = (colorScheme2, content) => `
87
+ @media (prefers-color-scheme: ${colorScheme2}) {
88
+ [data-color-scheme="auto"] ${content}
89
+ }
90
+ `;
91
+ var colorScheme = {
92
+ name: "ds/css-colorscheme",
93
+ format: async ({ dictionary, options, platform }) => {
94
+ const { allTokens } = dictionary;
95
+ const { outputReferences, usesDtcg } = options;
96
+ const { selector, colorScheme: colorScheme2, layer } = platform;
97
+ const colorScheme_ = colorScheme2;
98
+ const format = createPropertyFormatter({
99
+ outputReferences,
100
+ dictionary,
101
+ format: "css",
102
+ usesDtcg
103
+ });
104
+ const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
105
+ color-scheme: ${colorScheme_};
106
+ ` : "";
107
+ const filteredAllTokens = allTokens.filter(
108
+ R2.allPass([
109
+ R2.anyPass([
110
+ // Include semantic tokens in the output
111
+ isSemanticToken,
112
+ // Include global color tokens
113
+ isGlobalColorToken
114
+ ]),
115
+ // Don't include color category tokens -- they are exported separately
116
+ (t) => !isColorCategoryToken(t)
117
+ ])
118
+ );
119
+ const formattedMap = filteredAllTokens.map((token) => ({
120
+ token,
121
+ formatted: format(token)
122
+ }));
123
+ const formattedTokens = formattedMap.map(R2.view(R2.lensProp("formatted"))).join("\n");
124
+ const content = `{
125
+ ${formattedTokens}
126
+ ${colorSchemeProperty}}
127
+ `;
128
+ const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
129
+ const body = R2.isNotNil(layer) ? `@layer ${layer} {
130
+ ${selector} ${content} ${autoSelectorContent}
131
+ }
132
+ ` : `${selector} ${content} ${autoSelectorContent}
133
+ `;
134
+ return body;
135
+ }
136
+ };
137
+ var colorCategory = {
138
+ name: "ds/css-colorcategory",
139
+ format: async ({ dictionary, options, platform }) => {
140
+ const { outputReferences, usesDtcg } = options;
141
+ const { selector, layer, files } = platform;
142
+ const destination = files?.[0]?.destination;
143
+ const format = R2.compose(
144
+ createPropertyFormatter({
145
+ outputReferences,
146
+ dictionary,
147
+ format: "css",
148
+ usesDtcg
149
+ }),
150
+ (token) => ({
151
+ ...token,
152
+ name: token.name.replace(/color-\w+-/, "color-"),
153
+ original: {
154
+ ...token.original,
155
+ $value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
156
+ }
157
+ })
158
+ );
159
+ const formattedMap = dictionary.allTokens.map((token) => ({
160
+ token,
161
+ formatted: format(token)
162
+ }));
163
+ buildOptions.buildTokenFormats[destination] = formattedMap;
164
+ const formattedTokens = formattedMap.map(R2.view(R2.lensProp("formatted"))).join("\n");
165
+ const content = `{
166
+ ${formattedTokens}
167
+ }
168
+ `;
169
+ const body = R2.isNotNil(layer) ? `@layer ${layer} {
170
+ ${selector} ${content}
171
+ }
172
+ ` : `${selector} ${content}
173
+ `;
174
+ return body;
175
+ }
176
+ };
177
+
178
+ // src/tokens/process/formats/css/typography.ts
179
+ import * as R3 from "ramda";
180
+ import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
181
+ var typographyFontFamilyPredicate = R3.allPass([
182
+ R3.pathSatisfies(R3.includes("typography"), ["path"]),
183
+ R3.pathSatisfies(R3.includes("fontFamily"), ["path"])
184
+ ]);
185
+ var typography = {
186
+ name: "ds/css-typography",
187
+ format: async ({ dictionary, options, platform }) => {
188
+ const { outputReferences, usesDtcg } = options;
189
+ const { selector, layer, files } = platform;
190
+ const destination = files?.[0]?.destination;
191
+ const format = createPropertyFormatter2({
192
+ outputReferences,
193
+ dictionary,
194
+ format: "css",
195
+ usesDtcg
196
+ });
197
+ const filteredTokens = R3.reject(typographyFontFamilyPredicate, dictionary.allTokens);
198
+ const formattedMap = filteredTokens.map((token) => ({
199
+ token,
200
+ formatted: format(token)
201
+ }));
202
+ buildOptions.buildTokenFormats[destination] = formattedMap;
203
+ const formattedTokens = formattedMap.map(R3.view(R3.lensProp("formatted"))).join("\n");
204
+ const content = selector ? `${selector} {
205
+ ${formattedTokens}
206
+ }` : formattedTokens;
207
+ const body = R3.isNotNil(layer) ? `@layer ${layer} {
208
+ ${content}
209
+ }` : content;
210
+ return body;
211
+ }
212
+ };
213
+
214
+ // src/tokens/process/formats/css.ts
215
+ var formats = {
216
+ colorScheme,
217
+ colorCategory,
218
+ semantic,
219
+ typography
220
+ };
221
+
222
+ // src/tokens/process/transformers.ts
223
+ import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
224
+ import * as R4 from "ramda";
225
+ var isPx = R4.test(/\b\d+px\b/g);
226
+ var sizeRem = {
227
+ name: "ds/size/toRem",
228
+ type: "value",
229
+ transitive: true,
230
+ filter: (token) => {
231
+ const hasWantedType = typeEquals(["dimension", "fontsize"], token);
232
+ const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
233
+ return hasWantedType && hasWantedPath;
234
+ },
235
+ transform: (token, config) => {
236
+ const value = getValue(token);
237
+ if (isPx(value)) {
238
+ const baseFont = config.basePxFontSize || 16;
239
+ const size = parseInt(value);
240
+ if (size === 0) {
241
+ return "0";
242
+ }
243
+ return `${size / baseFont}rem`;
244
+ }
245
+ return value;
246
+ }
247
+ };
248
+ var typographyName = {
249
+ name: "name/typography",
250
+ type: "name",
251
+ transitive: true,
252
+ // expanded tokens have different type so we match on path instead
253
+ filter: (token) => pathStartsWithOneOf(["typography"], token),
254
+ transform: (token) => {
255
+ return token.name.replace("-typography", "");
256
+ }
257
+ };
258
+ var resolveMath = {
259
+ name: "ds/resolveMath",
260
+ type: "value",
261
+ transitive: true,
262
+ filter: (token) => {
263
+ const isValidValue = ["string", "object"].includes(typeof getValue(token));
264
+ const isTokenOfInterest = !pathStartsWithOneOf(["border-radius"], token);
265
+ return isValidValue && isTokenOfInterest;
266
+ },
267
+ transform: (token, platformCfg) => checkAndEvaluateMath(token, platformCfg.mathFractionDigits)
268
+ };
269
+ var unitless = {
270
+ name: "ds/unitless",
271
+ type: "value",
272
+ transitive: true,
273
+ filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
274
+ transform: (token) => parseInt(getValue(token))
275
+ };
276
+
277
+ // src/tokens/process/configs/shared.ts
278
+ var prefix = "ds";
279
+ var basePxFontSize = 16;
280
+ var dsTransformers = [
281
+ "name/kebab",
282
+ resolveMath.name,
283
+ "ts/size/px",
284
+ sizeRem.name,
285
+ unitless.name,
286
+ "ts/typography/fontWeight",
287
+ typographyName.name,
288
+ "ts/color/modifiers",
289
+ "ts/color/css/hexrgba",
290
+ "ts/size/lineheight",
291
+ "shadow/css/shorthand"
292
+ ];
293
+
294
+ // src/tokens/process/configs/color.ts
295
+ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
296
+ const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
297
+ const layer = `ds.theme.color-scheme.${colorScheme2}`;
298
+ return {
299
+ preprocessors: ["tokens-studio"],
300
+ platforms: {
301
+ css: {
302
+ // custom
303
+ colorScheme: colorScheme2,
304
+ theme,
305
+ selector,
306
+ layer,
307
+ //
308
+ prefix,
309
+ buildPath: `${theme}/`,
310
+ transforms: dsTransformers,
311
+ files: [
312
+ {
313
+ destination: `color-scheme/${colorScheme2}.css`,
314
+ format: formats.colorScheme.name,
315
+ filter: (token) => typeEquals("color", token) && !R5.startsWith(["global"], token.path)
316
+ }
317
+ ],
318
+ options: {
319
+ outputReferences: false
320
+ }
321
+ }
322
+ }
323
+ };
324
+ };
325
+ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, ...permutation }) => {
326
+ const category = opts.category;
327
+ const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
328
+ if (!color) {
329
+ throw new Error(
330
+ category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`
331
+ );
332
+ }
333
+ const layer = `ds.theme.color`;
334
+ const isRootColor = color === buildOptions?.defaultColor;
335
+ const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
336
+ const config = {
337
+ preprocessors: ["tokens-studio"],
338
+ platforms: {
339
+ css: {
340
+ // custom
341
+ colorScheme: colorScheme2,
342
+ theme,
343
+ selector,
344
+ layer,
345
+ //
346
+ prefix,
347
+ buildPath: `${theme}/`,
348
+ transforms: dsTransformers,
349
+ files: [
350
+ {
351
+ destination: `color/${color}.css`,
352
+ format: formats.colorCategory.name,
353
+ filter: (token) => category === "builtin" ? isSemanticColorToken(token, color) : isColorCategoryToken(token, category)
354
+ }
355
+ ],
356
+ options: {
357
+ outputReferences: true
358
+ }
359
+ }
360
+ }
361
+ };
362
+ return config;
363
+ };
364
+
365
+ // src/tokens/process/configs/semantic.ts
366
+ import * as R6 from "ramda";
367
+ import { outputReferencesFilter } from "style-dictionary/utils";
368
+ var semanticVariables = ({ theme }) => {
369
+ const selector = `:root`;
370
+ const layer = `ds.theme.semantic`;
371
+ return {
372
+ preprocessors: ["tokens-studio"],
373
+ platforms: {
374
+ css: {
375
+ // custom
376
+ theme,
377
+ basePxFontSize,
378
+ selector,
379
+ layer,
380
+ //
381
+ prefix,
382
+ buildPath: `${theme}/`,
383
+ transforms: dsTransformers,
384
+ files: [
385
+ {
386
+ destination: `semantic.css`,
387
+ format: formats.semantic.name,
388
+ filter: (token) => {
389
+ const isUwantedToken = R6.anyPass([R6.includes("primitives/global")])(token.filePath);
390
+ const isPrivateToken = R6.includes("_", token.path);
391
+ const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
392
+ const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
393
+ const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
394
+ return unwantedTokens;
395
+ }
396
+ }
397
+ ],
398
+ options: {
399
+ outputReferences: (token, options) => {
400
+ const include = pathStartsWithOneOf(["border-radius"], token);
401
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
402
+ return (include || isWantedSize) && outputReferencesFilter(token, options);
403
+ }
404
+ }
405
+ }
406
+ }
407
+ };
408
+ };
409
+
410
+ // src/tokens/process/configs/typography.ts
411
+ import { expandTypesMap } from "@tokens-studio/sd-transforms";
412
+ var typographyVariables = ({ theme, typography: typography2 }) => {
413
+ const selector = `${typography2 === "primary" ? ":root, " : ""}[data-typography="${typography2}"]`;
414
+ const layer = `ds.theme.typography.${typography2}`;
415
+ return {
416
+ usesDtcg: true,
417
+ preprocessors: ["tokens-studio"],
418
+ expand: {
419
+ include: ["typography"],
420
+ typesMap: { ...expandTypesMap, typography: { ...expandTypesMap.typography, letterSpacing: "dimension" } }
421
+ },
422
+ platforms: {
423
+ css: {
424
+ prefix,
425
+ typography: typography2,
426
+ selector,
427
+ layer,
428
+ buildPath: `${theme}/`,
429
+ basePxFontSize,
430
+ transforms: [
431
+ "name/kebab",
432
+ "ts/size/px",
433
+ sizeRem.name,
434
+ "ts/size/lineheight",
435
+ "ts/typography/fontWeight",
436
+ "ts/size/css/letterspacing",
437
+ typographyName.name
438
+ ],
439
+ files: [
440
+ {
441
+ destination: `typography/${typography2}.css`,
442
+ format: formats.typography.name,
443
+ filter: (token) => {
444
+ const included = typeEquals(
445
+ ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
446
+ token
447
+ );
448
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
449
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
450
+ }
451
+ }
452
+ ]
453
+ }
454
+ }
455
+ };
456
+ };
457
+
458
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
459
+ var BoxShadowTypes;
460
+ (function(BoxShadowTypes2) {
461
+ BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
462
+ BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
463
+ })(BoxShadowTypes || (BoxShadowTypes = {}));
464
+
465
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
466
+ var ColorModifierTypes;
467
+ (function(ColorModifierTypes2) {
468
+ ColorModifierTypes2["LIGHTEN"] = "lighten";
469
+ ColorModifierTypes2["DARKEN"] = "darken";
470
+ ColorModifierTypes2["MIX"] = "mix";
471
+ ColorModifierTypes2["ALPHA"] = "alpha";
472
+ })(ColorModifierTypes || (ColorModifierTypes = {}));
473
+
474
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
475
+ var ColorSpaceTypes;
476
+ (function(ColorSpaceTypes2) {
477
+ ColorSpaceTypes2["LCH"] = "lch";
478
+ ColorSpaceTypes2["SRGB"] = "srgb";
479
+ ColorSpaceTypes2["P3"] = "p3";
480
+ ColorSpaceTypes2["HSL"] = "hsl";
481
+ })(ColorSpaceTypes || (ColorSpaceTypes = {}));
482
+
483
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/Properties.js
484
+ var Properties;
485
+ (function(Properties2) {
486
+ Properties2["sizing"] = "sizing";
487
+ Properties2["height"] = "height";
488
+ Properties2["width"] = "width";
489
+ Properties2["spacing"] = "spacing";
490
+ Properties2["verticalPadding"] = "verticalPadding";
491
+ Properties2["horizontalPadding"] = "horizontalPadding";
492
+ Properties2["paddingTop"] = "paddingTop";
493
+ Properties2["paddingRight"] = "paddingRight";
494
+ Properties2["paddingBottom"] = "paddingBottom";
495
+ Properties2["paddingLeft"] = "paddingLeft";
496
+ Properties2["itemSpacing"] = "itemSpacing";
497
+ Properties2["fill"] = "fill";
498
+ Properties2["backgroundBlur"] = "backgroundBlur";
499
+ Properties2["border"] = "border";
500
+ Properties2["borderTop"] = "borderTop";
501
+ Properties2["borderRight"] = "borderRight";
502
+ Properties2["borderBottom"] = "borderBottom";
503
+ Properties2["borderLeft"] = "borderLeft";
504
+ Properties2["borderColor"] = "borderColor";
505
+ Properties2["borderRadius"] = "borderRadius";
506
+ Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
507
+ Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
508
+ Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
509
+ Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
510
+ Properties2["borderWidth"] = "borderWidth";
511
+ Properties2["borderWidthTop"] = "borderWidthTop";
512
+ Properties2["borderWidthRight"] = "borderWidthRight";
513
+ Properties2["borderWidthBottom"] = "borderWidthBottom";
514
+ Properties2["borderWidthLeft"] = "borderWidthLeft";
515
+ Properties2["boxShadow"] = "boxShadow";
516
+ Properties2["opacity"] = "opacity";
517
+ Properties2["fontFamilies"] = "fontFamilies";
518
+ Properties2["fontWeights"] = "fontWeights";
519
+ Properties2["fontSizes"] = "fontSizes";
520
+ Properties2["lineHeights"] = "lineHeights";
521
+ Properties2["typography"] = "typography";
522
+ Properties2["composition"] = "composition";
523
+ Properties2["letterSpacing"] = "letterSpacing";
524
+ Properties2["paragraphSpacing"] = "paragraphSpacing";
525
+ Properties2["textCase"] = "textCase";
526
+ Properties2["dimension"] = "dimension";
527
+ Properties2["textDecoration"] = "textDecoration";
528
+ Properties2["asset"] = "asset";
529
+ Properties2["tokenValue"] = "tokenValue";
530
+ Properties2["value"] = "value";
531
+ Properties2["tokenName"] = "tokenName";
532
+ Properties2["description"] = "description";
533
+ })(Properties || (Properties = {}));
534
+
535
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
536
+ var TokenSetStatus;
537
+ (function(TokenSetStatus2) {
538
+ TokenSetStatus2["DISABLED"] = "disabled";
539
+ TokenSetStatus2["SOURCE"] = "source";
540
+ TokenSetStatus2["ENABLED"] = "enabled";
541
+ })(TokenSetStatus || (TokenSetStatus = {}));
542
+
543
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
544
+ var TokenTypes;
545
+ (function(TokenTypes2) {
546
+ TokenTypes2["OTHER"] = "other";
547
+ TokenTypes2["COLOR"] = "color";
548
+ TokenTypes2["BORDER_RADIUS"] = "borderRadius";
549
+ TokenTypes2["SIZING"] = "sizing";
550
+ TokenTypes2["SPACING"] = "spacing";
551
+ TokenTypes2["TEXT"] = "text";
552
+ TokenTypes2["TYPOGRAPHY"] = "typography";
553
+ TokenTypes2["OPACITY"] = "opacity";
554
+ TokenTypes2["BORDER_WIDTH"] = "borderWidth";
555
+ TokenTypes2["STROKE_STYLE"] = "strokeStyle";
556
+ TokenTypes2["BOX_SHADOW"] = "boxShadow";
557
+ TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
558
+ TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
559
+ TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
560
+ TokenTypes2["FONT_SIZES"] = "fontSizes";
561
+ TokenTypes2["LETTER_SPACING"] = "letterSpacing";
562
+ TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
563
+ TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
564
+ TokenTypes2["TEXT_DECORATION"] = "textDecoration";
565
+ TokenTypes2["TEXT_CASE"] = "textCase";
566
+ TokenTypes2["COMPOSITION"] = "composition";
567
+ TokenTypes2["DIMENSION"] = "dimension";
568
+ TokenTypes2["BORDER"] = "border";
569
+ TokenTypes2["ASSET"] = "asset";
570
+ TokenTypes2["BOOLEAN"] = "boolean";
571
+ TokenTypes2["NUMBER"] = "number";
572
+ })(TokenTypes || (TokenTypes = {}));
573
+
574
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BorderValues.js
575
+ var BorderValues;
576
+ (function(BorderValues2) {
577
+ BorderValues2["BORDER_COLOR"] = "color";
578
+ BorderValues2["BORDER_WIDTH"] = "width";
579
+ BorderValues2["BORDER_STYLE"] = "style";
580
+ })(BorderValues || (BorderValues = {}));
581
+
582
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
583
+ var StrokeStyleValues;
584
+ (function(StrokeStyleValues2) {
585
+ StrokeStyleValues2["SOLID"] = "solid";
586
+ StrokeStyleValues2["DASHED"] = "dashed";
587
+ StrokeStyleValues2["DOTTED"] = "dotted";
588
+ StrokeStyleValues2["DOUBLE"] = "double";
589
+ StrokeStyleValues2["GROOVE"] = "groove";
590
+ StrokeStyleValues2["RIDGE"] = "ridge";
591
+ StrokeStyleValues2["OUTSET"] = "outset";
592
+ StrokeStyleValues2["INSET"] = "inset";
593
+ })(StrokeStyleValues || (StrokeStyleValues = {}));
594
+
595
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
596
+ var BoxShadowValues;
597
+ (function(BoxShadowValues2) {
598
+ BoxShadowValues2["TYPE"] = "type";
599
+ BoxShadowValues2["COLOR"] = "color";
600
+ BoxShadowValues2["X"] = "x";
601
+ BoxShadowValues2["Y"] = "y";
602
+ BoxShadowValues2["BLUR"] = "blur";
603
+ BoxShadowValues2["SPREAD"] = "spread";
604
+ BoxShadowValues2["BLEND_MODE"] = "blendMode";
605
+ })(BoxShadowValues || (BoxShadowValues = {}));
606
+
607
+ // ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
608
+ var TypographyValues;
609
+ (function(TypographyValues2) {
610
+ TypographyValues2["FONT_FAMILY"] = "fontFamily";
611
+ TypographyValues2["FONT_WEIGHT"] = "fontWeight";
612
+ TypographyValues2["LINE_HEIGHT"] = "lineHeight";
613
+ TypographyValues2["FONT_SIZE"] = "fontSize";
614
+ TypographyValues2["LETTER_SPACING"] = "letterSpacing";
615
+ TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
616
+ TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
617
+ TypographyValues2["TEXT_DECORATION"] = "textDecoration";
618
+ TypographyValues2["TEXT_CASE"] = "textCase";
619
+ })(TypographyValues || (TypographyValues = {}));
620
+
621
+ // src/tokens/process/utils/getMultidimensionalThemes.ts
622
+ import chalk from "chalk";
623
+ import { kebabCase } from "change-case";
624
+ import * as R7 from "ramda";
625
+ var processed = Symbol("Type brand for ProcessedThemeObject");
626
+ var hasUnknownProps = R7.pipe(R7.values, R7.none(R7.equals("unknown")), R7.not);
627
+
628
+ // src/tokens/process/configs.ts
629
+ void register(StyleDictionary, { withSDBuiltins: false });
630
+ StyleDictionary.registerTransform(sizeRem);
631
+ StyleDictionary.registerTransform(typographyName);
632
+ StyleDictionary.registerTransform(resolveMath);
633
+ StyleDictionary.registerTransform(unitless);
634
+ for (const format of Object.values(formats)) {
635
+ StyleDictionary.registerFormat(format);
636
+ }
637
+ var configs = {
638
+ colorSchemeVariables,
639
+ mainColorVariables: colorCategoryVariables({ category: "main" }),
640
+ supportColorVariables: colorCategoryVariables({ category: "support" }),
641
+ neutralColorVariables: colorCategoryVariables({ category: "builtin", color: "neutral" }),
642
+ successColorVariables: colorCategoryVariables({ category: "builtin", color: "success" }),
643
+ dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
644
+ warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
645
+ infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
646
+ typographyVariables,
647
+ semanticVariables
648
+ };
649
+
650
+ // src/tokens/process/platform.ts
651
+ var buildOptions = {
652
+ verbose: false,
653
+ processed$themes: [],
654
+ buildTokenFormats: {}
655
+ };
656
+ var sd = new StyleDictionary2();
657
+ var buildConfigs = {
658
+ typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
659
+ "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
660
+ "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
661
+ "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
662
+ "neutral-color": {
663
+ getConfig: configs.neutralColorVariables,
664
+ dimensions: ["semantic"],
665
+ log: ({ permutation: { theme } }) => `${theme} - neutral`
666
+ },
667
+ "success-color": {
668
+ getConfig: configs.successColorVariables,
669
+ dimensions: ["semantic"],
670
+ log: ({ permutation: { theme } }) => `${theme} - success`
671
+ },
672
+ "danger-color": {
673
+ getConfig: configs.dangerColorVariables,
674
+ dimensions: ["semantic"],
675
+ log: ({ permutation: { theme } }) => `${theme} - danger`
676
+ },
677
+ "warning-color": {
678
+ getConfig: configs.warningColorVariables,
679
+ dimensions: ["semantic"],
680
+ log: ({ permutation: { theme } }) => `${theme} - warning`
681
+ },
682
+ "info-color": {
683
+ getConfig: configs.infoColorVariables,
684
+ dimensions: ["semantic"],
685
+ log: ({ permutation: { theme } }) => `${theme} - info`
686
+ },
687
+ semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
688
+ };
689
+
45
690
  // src/tokens/process/formats/css/semantic.ts
46
691
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
47
692
  var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
48
693
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
49
- var isInlineTokens = R2.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
694
+ var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
50
695
  var overrideSizingFormula = (format, token) => {
51
696
  const [name, value] = format(token).split(":");
52
697
  const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
@@ -57,48 +702,59 @@ var overrideSizingFormula = (format, token) => {
57
702
  calc
58
703
  };
59
704
  };
60
- var formatSizingTokens = (format, tokens) => {
61
- const { round, calc } = R2.reduce(
62
- (acc, token) => {
63
- const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
64
- return {
65
- round: [...acc.round, `${name}: ${round2};`],
66
- calc: [...acc.calc, `${name}: ${calc2};`]
67
- };
68
- },
69
- { round: [], calc: [] },
70
- tokens
71
- );
72
- return `
705
+ var formatSizingTokens = (format, tokens) => R10.reduce(
706
+ (acc, token) => {
707
+ const { round, calc, name } = overrideSizingFormula(format, token);
708
+ return {
709
+ tokens: [...acc.tokens, token],
710
+ round: [...acc.round, `${name}: ${round};`],
711
+ calc: [...acc.calc, `${name}: ${calc};`]
712
+ };
713
+ },
714
+ { tokens: [], round: [], calc: [] },
715
+ tokens
716
+ );
717
+ var sizingTemplate = ({ round, calc }) => `
73
718
  ${calc.join("\n")}
74
719
 
75
720
  @supports (width: round(down, .1em, 1px)) {
76
721
  ${round.join("\n")}
77
722
  }`;
78
- };
79
723
  var semantic = {
80
724
  name: "ds/css-semantic",
81
725
  format: async ({ dictionary, options, platform }) => {
82
726
  const { outputReferences, usesDtcg } = options;
83
- const { selector, layer } = platform;
84
- const format = createPropertyFormatter({
727
+ const { selector, layer, files } = platform;
728
+ const destination = files?.[0]?.destination;
729
+ const format = createPropertyFormatter3({
85
730
  outputReferences,
86
731
  dictionary,
87
732
  format: "css",
88
733
  usesDtcg
89
734
  });
90
735
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
91
- const filteredTokens = R2.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
92
- const [sizingTokens, restTokens] = R2.partition(
736
+ const filteredTokens = R10.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
737
+ const [sizingTokens, restTokens] = R10.partition(
93
738
  (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
94
739
  filteredTokens
95
740
  );
96
- const formattedTokens = [R2.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
741
+ const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
742
+ const formattedMap = restTokens.map((token) => ({
743
+ token,
744
+ formatted: format(token)
745
+ }));
746
+ const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
747
+ token: formattedSizingTokens.tokens[i],
748
+ formatted: t
749
+ }));
750
+ buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
751
+ const sizingSnippet = sizingTemplate(formattedSizingTokens);
752
+ const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).concat(sizingSnippet);
97
753
  const content = `{
98
754
  ${formattedTokens.join("\n")}
99
755
  }
100
756
  `;
101
- const body = R2.isNotNil(layer) ? `@layer ${layer} {
757
+ const body = R10.isNotNil(layer) ? `@layer ${layer} {
102
758
  ${selector} ${content}
103
759
  }
104
760
  ` : `${selector} ${content}