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