@digdir/designsystemet 1.4.0 → 1.5.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 (60) hide show
  1. package/dist/bin/designsystemet.js +484 -162
  2. package/dist/global-Y35YADVH.json +100 -0
  3. package/dist/src/index.js +523 -199
  4. package/dist/src/scripts/update-preview-tokens.js +429 -118
  5. package/dist/src/tokens/build.js +425 -107
  6. package/dist/src/tokens/create/defaults.js +27 -23
  7. package/dist/src/tokens/create/generators/$designsystemet.js +2 -2
  8. package/dist/src/tokens/create/write.js +2 -2
  9. package/dist/src/tokens/create.js +27 -23
  10. package/dist/src/tokens/format.js +523 -199
  11. package/dist/src/tokens/index.js +523 -199
  12. package/dist/src/tokens/process/configs/color.js +366 -66
  13. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
  14. package/dist/src/tokens/process/configs/semantic.js +368 -68
  15. package/dist/src/tokens/process/configs/shared.js +9 -2
  16. package/dist/src/tokens/process/configs/size-mode.d.ts +3 -0
  17. package/dist/src/tokens/process/configs/size-mode.d.ts.map +1 -0
  18. package/dist/src/tokens/process/configs/size-mode.js +1067 -0
  19. package/dist/src/tokens/process/configs/size.d.ts +3 -0
  20. package/dist/src/tokens/process/configs/size.d.ts.map +1 -0
  21. package/dist/src/tokens/process/configs/size.js +1069 -0
  22. package/dist/src/tokens/process/configs/type-scale.d.ts +3 -0
  23. package/dist/src/tokens/process/configs/type-scale.d.ts.map +1 -0
  24. package/dist/src/tokens/process/configs/type-scale.js +1067 -0
  25. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  26. package/dist/src/tokens/process/configs/typography.js +364 -64
  27. package/dist/src/tokens/process/configs.d.ts +3 -0
  28. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  29. package/dist/src/tokens/process/configs.js +373 -71
  30. package/dist/src/tokens/process/formats/css/color.js +381 -79
  31. package/dist/src/tokens/process/formats/css/semantic.d.ts +0 -14
  32. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
  33. package/dist/src/tokens/process/formats/css/semantic.js +407 -109
  34. package/dist/src/tokens/process/formats/css/size-mode.d.ts +4 -0
  35. package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -0
  36. package/dist/src/tokens/process/formats/css/size-mode.js +1068 -0
  37. package/dist/src/tokens/process/formats/css/size.d.ts +17 -0
  38. package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -0
  39. package/dist/src/tokens/process/formats/css/size.js +1069 -0
  40. package/dist/src/tokens/process/formats/css/type-scale.d.ts +3 -0
  41. package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -0
  42. package/dist/src/tokens/process/formats/css/type-scale.js +1069 -0
  43. package/dist/src/tokens/process/formats/css/typography.js +365 -63
  44. package/dist/src/tokens/process/formats/css.d.ts +3 -0
  45. package/dist/src/tokens/process/formats/css.d.ts.map +1 -1
  46. package/dist/src/tokens/process/formats/css.js +364 -64
  47. package/dist/src/tokens/process/output/declarations.js +372 -70
  48. package/dist/src/tokens/process/output/theme.d.ts.map +1 -1
  49. package/dist/src/tokens/process/output/theme.js +59 -10
  50. package/dist/src/tokens/process/platform.d.ts +16 -0
  51. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  52. package/dist/src/tokens/process/platform.js +402 -95
  53. package/dist/src/tokens/process/transformers.js +9 -2
  54. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +373 -71
  55. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +1 -1
  56. package/dist/src/tokens/utils.d.ts +4 -1
  57. package/dist/src/tokens/utils.d.ts.map +1 -1
  58. package/dist/src/tokens/utils.js +24 -1
  59. package/package.json +2 -2
  60. package/dist/global-XVXVBKM6.json +0 -96
@@ -3,7 +3,7 @@
3
3
  // bin/designsystemet.ts
4
4
  import { Argument, createCommand, program } from "@commander-js/extra-typings";
5
5
  import pc11 from "picocolors";
6
- import * as R24 from "ramda";
6
+ import * as R29 from "ramda";
7
7
 
8
8
  // src/colors/colorMetadata.ts
9
9
  import * as R from "ramda";
@@ -378,7 +378,7 @@ var cssClassRename = (dictionary) => ({
378
378
  var cssVarRename = (dictionary) => ({
379
379
  postcssPlugin: `Replaces CSS variables ${hash(dictionary)}`,
380
380
  Declaration(decl) {
381
- const { value, prop: prop2 } = decl;
381
+ const { value, prop: prop5 } = decl;
382
382
  const deleted = /* @__PURE__ */ new Set();
383
383
  for (const [from, to] of Object.entries(dictionary)) {
384
384
  if (R3.isNotEmpty(to)) {
@@ -389,8 +389,8 @@ var cssVarRename = (dictionary) => ({
389
389
  decl.value = value.replace(from, to);
390
390
  continue;
391
391
  }
392
- if (R3.includes(from, prop2) && decl.variable) {
393
- decl.prop = prop2.replace(from, to);
392
+ if (R3.includes(from, prop5) && decl.variable) {
393
+ decl.prop = prop5.replace(from, to);
394
394
  }
395
395
  }
396
396
  }
@@ -862,7 +862,7 @@ var migrations_default = {
862
862
  // src/tokens/build.ts
863
863
  import path from "path";
864
864
  import pc7 from "picocolors";
865
- import * as R16 from "ramda";
865
+ import * as R21 from "ramda";
866
866
 
867
867
  // src/tokens/process/output/declarations.ts
868
868
  import pc5 from "picocolors";
@@ -870,7 +870,7 @@ import pc5 from "picocolors";
870
870
  // package.json
871
871
  var package_default = {
872
872
  name: "@digdir/designsystemet",
873
- version: "1.4.0",
873
+ version: "1.5.0",
874
874
  description: "CLI for Designsystemet",
875
875
  author: "Designsystemet team",
876
876
  engines: {
@@ -953,7 +953,7 @@ var package_default = {
953
953
  "@types/apca-w3": "^0.1.3",
954
954
  "@types/chroma-js": "^3.1.1",
955
955
  "@types/fs-extra": "^11.0.4",
956
- "@types/node": "^22.18.0",
956
+ "@types/node": "^22.18.1",
957
957
  "@types/object-hash": "^3.0.6",
958
958
  "@types/ramda": "^0.31.0",
959
959
  "fs-extra": "^11.3.1",
@@ -966,7 +966,7 @@ var package_default = {
966
966
 
967
967
  // src/tokens/process/platform.ts
968
968
  import pc4 from "picocolors";
969
- import * as R14 from "ramda";
969
+ import * as R19 from "ramda";
970
970
  import StyleDictionary2 from "style-dictionary";
971
971
 
972
972
  // src/tokens/types.ts
@@ -977,7 +977,7 @@ var colorCategories = {
977
977
 
978
978
  // src/tokens/process/configs.ts
979
979
  import { register } from "@tokens-studio/sd-transforms";
980
- import * as R13 from "ramda";
980
+ import * as R18 from "ramda";
981
981
  import StyleDictionary from "style-dictionary";
982
982
 
983
983
  // src/tokens/utils.ts
@@ -1000,7 +1000,10 @@ var pathStartsWithOneOf = R5.curry(
1000
1000
  return false;
1001
1001
  }
1002
1002
  const tokenPath = mapToLowerCase(token.path);
1003
- const matchPathsStartingWith = R5.map((path5) => R5.startsWith([path5], tokenPath), mapToLowerCase(paths));
1003
+ const matchPathsStartingWith = R5.map((pathOrString) => {
1004
+ const path5 = typeof pathOrString === "string" ? [pathOrString] : pathOrString;
1005
+ return R5.startsWith(mapToLowerCase(path5), tokenPath);
1006
+ }, paths);
1004
1007
  return hasAnyTruth(matchPathsStartingWith);
1005
1008
  }
1006
1009
  );
@@ -1024,11 +1027,11 @@ function isColorCategoryToken(token, category) {
1024
1027
  var isDigit = (s) => /^\d+$/.test(s);
1025
1028
  function traverseObj(obj, fn) {
1026
1029
  for (const key in obj) {
1027
- const prop2 = obj[key];
1028
- if (prop2 != null) {
1029
- fn.apply(null, [obj, key, prop2]);
1030
- if (typeof prop2 === "object") {
1031
- traverseObj(prop2, fn);
1030
+ const prop5 = obj[key];
1031
+ if (prop5 != null) {
1032
+ fn.apply(null, [obj, key, prop5]);
1033
+ if (typeof prop5 === "object") {
1034
+ traverseObj(prop5, fn);
1032
1035
  }
1033
1036
  }
1034
1037
  }
@@ -1048,9 +1051,26 @@ function inlineTokens(shouldInline, tokens) {
1048
1051
  return tokenWithInlinedRefs;
1049
1052
  });
1050
1053
  }
1054
+ var sizeMap = {
1055
+ xsmall: "xs",
1056
+ small: "sm",
1057
+ medium: "md",
1058
+ large: "lg",
1059
+ xlarge: "xl"
1060
+ };
1061
+ function shortSizeName(size2) {
1062
+ return sizeMap[size2] ?? size2;
1063
+ }
1064
+ var sizeComparator = (size2) => {
1065
+ const sortIndex = Object.entries(sizeMap).findIndex(([key, val]) => key === size2 || val === size2);
1066
+ return sortIndex ?? 0;
1067
+ };
1068
+ function orderBySize(sizes) {
1069
+ return R5.sortBy(sizeComparator, sizes);
1070
+ }
1051
1071
 
1052
1072
  // src/tokens/process/configs/color.ts
1053
- import * as R10 from "ramda";
1073
+ import * as R13 from "ramda";
1054
1074
 
1055
1075
  // src/tokens/process/formats/css/color.ts
1056
1076
  import * as R6 from "ramda";
@@ -1108,10 +1128,10 @@ ${selector} ${content} ${autoSelectorContent}
1108
1128
  };
1109
1129
  var colorCategory = {
1110
1130
  name: "ds/css-colorcategory",
1111
- format: async ({ dictionary, options, platform }) => {
1131
+ format: async ({ dictionary, file, options, platform }) => {
1112
1132
  const { outputReferences, usesDtcg } = options;
1113
- const { selector, layer, files } = platform;
1114
- const destination = files?.[0]?.destination;
1133
+ const { selector, layer } = platform;
1134
+ const destination = file.destination;
1115
1135
  const format = R6.compose(
1116
1136
  createPropertyFormatter({
1117
1137
  outputReferences,
@@ -1148,6 +1168,10 @@ ${selector} ${content}
1148
1168
  };
1149
1169
 
1150
1170
  // src/tokens/process/formats/css/semantic.ts
1171
+ import * as R8 from "ramda";
1172
+ import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
1173
+
1174
+ // src/tokens/process/formats/css/size.ts
1151
1175
  import * as R7 from "ramda";
1152
1176
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
1153
1177
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
@@ -1155,12 +1179,20 @@ var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.pa
1155
1179
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
1156
1180
  var isInlineTokens = R7.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
1157
1181
  var overrideSizingFormula = (format, token) => {
1158
- const [name, value] = format(token).split(":");
1159
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
1160
- const round = `round(down, ${calc}, 1px)`;
1182
+ const [name, value] = format(token).replace(/;$/, "").split(": ");
1183
+ let calc;
1184
+ let round;
1185
+ if (token.path[1] === "unit") {
1186
+ calc = `calc(1rem * ${value})`;
1187
+ } else if (value.startsWith("floor")) {
1188
+ calc = value.replace(/^floor\((.*)\)$/, "calc($1)");
1189
+ round = `round(down, ${calc}, 1px)`;
1190
+ } else {
1191
+ calc = value.includes("*") ? `calc(${value})` : value;
1192
+ }
1161
1193
  return {
1162
1194
  name,
1163
- round,
1195
+ round: round ?? calc,
1164
1196
  calc
1165
1197
  };
1166
1198
  };
@@ -1176,18 +1208,21 @@ var formatSizingTokens = (format, tokens) => R7.reduce(
1176
1208
  { tokens: [], round: [], calc: [] },
1177
1209
  tokens
1178
1210
  );
1179
- var sizingTemplate = ({ round, calc }) => `
1211
+ var sizingTemplate = ({ round, calc }) => {
1212
+ const usesRounding = round.filter((val, i) => val !== calc[i]);
1213
+ return `
1180
1214
  ${calc.join("\n")}
1181
1215
 
1182
1216
  @supports (width: round(down, .1em, 1px)) {
1183
- ${round.join("\n")}
1217
+ ${usesRounding.join("\n ")}
1184
1218
  }`;
1185
- var semantic = {
1186
- name: "ds/css-semantic",
1187
- format: async ({ dictionary, options, platform }) => {
1219
+ };
1220
+ var size = {
1221
+ name: "ds/css-size",
1222
+ format: async ({ dictionary, file, options, platform }) => {
1188
1223
  const { outputReferences, usesDtcg } = options;
1189
- const { selector, layer, files } = platform;
1190
- const destination = files?.[0]?.destination;
1224
+ const { selector, layer } = platform;
1225
+ const destination = file.destination;
1191
1226
  const format = createPropertyFormatter2({
1192
1227
  outputReferences,
1193
1228
  dictionary,
@@ -1195,9 +1230,9 @@ var semantic = {
1195
1230
  usesDtcg
1196
1231
  });
1197
1232
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
1198
- const filteredTokens = R7.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
1233
+ const filteredTokens = R7.reject((token) => R7.equals(["_size", "mode-font-size"], token.path), tokens);
1199
1234
  const [sizingTokens, restTokens] = R7.partition(
1200
- (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
1235
+ (t) => pathStartsWithOneOf(["_size"], t) && (isDigit(t.path[1]) || t.path[1] === "unit"),
1201
1236
  filteredTokens
1202
1237
  );
1203
1238
  const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
@@ -1210,64 +1245,56 @@ var semantic = {
1210
1245
  formatted: t
1211
1246
  }));
1212
1247
  buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
1213
- const sizingSnippet = sizingTemplate(formattedSizingTokens);
1214
- const formattedTokens = formattedMap.map(R7.view(R7.lensProp("formatted"))).concat(sizingSnippet);
1215
- const content = `{
1248
+ const formattedTokens = [formattedMap.map(R7.prop("formatted")).join("\n"), sizingTemplate(formattedSizingTokens)];
1249
+ const content = `${selector} {
1216
1250
  ${formattedTokens.join("\n")}
1217
1251
  }
1218
1252
  `;
1219
1253
  const body = R7.isNotNil(layer) ? `@layer ${layer} {
1220
- ${selector} ${content}
1254
+ ${content}
1221
1255
  }
1222
- ` : `${selector} ${content}
1256
+ ` : `${content}
1223
1257
  `;
1224
1258
  return body;
1225
1259
  }
1226
1260
  };
1227
1261
 
1228
- // src/tokens/process/formats/css/typography.ts
1229
- import * as R8 from "ramda";
1230
- import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
1231
- var typographyFontFamilyPredicate = R8.allPass([
1232
- R8.pathSatisfies(R8.includes("typography"), ["path"]),
1233
- R8.pathSatisfies(R8.includes("fontFamily"), ["path"])
1234
- ]);
1235
- var typography = {
1236
- name: "ds/css-typography",
1237
- format: async ({ dictionary, options, platform }) => {
1262
+ // src/tokens/process/formats/css/semantic.ts
1263
+ var semantic = {
1264
+ name: "ds/css-semantic",
1265
+ format: async ({ dictionary, file, options, platform }) => {
1238
1266
  const { outputReferences, usesDtcg } = options;
1239
- const { selector, layer, files } = platform;
1240
- const destination = files?.[0]?.destination;
1267
+ const { selector, layer } = platform;
1268
+ const destination = file.destination;
1241
1269
  const format = createPropertyFormatter3({
1242
1270
  outputReferences,
1243
1271
  dictionary,
1244
1272
  format: "css",
1245
1273
  usesDtcg
1246
1274
  });
1247
- const filteredTokens = R8.reject(typographyFontFamilyPredicate, dictionary.allTokens);
1248
- const formattedMap = filteredTokens.map((token) => ({
1275
+ const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
1276
+ const formattedMap = tokens.map((token) => ({
1249
1277
  token,
1250
1278
  formatted: format(token)
1251
1279
  }));
1252
1280
  buildOptions.buildTokenFormats[destination] = formattedMap;
1253
- const formattedTokens = formattedMap.map(R8.view(R8.lensProp("formatted"))).join("\n");
1254
- const content = selector ? `${selector} {
1281
+ const formattedTokens = formattedMap.map(R8.prop("formatted")).join("\n");
1282
+ const content = `${selector} {
1255
1283
  ${formattedTokens}
1256
- }` : formattedTokens;
1284
+ }
1285
+ `;
1257
1286
  const body = R8.isNotNil(layer) ? `@layer ${layer} {
1258
1287
  ${content}
1259
- }` : content;
1288
+ }
1289
+ ` : `${content}
1290
+ `;
1260
1291
  return body;
1261
1292
  }
1262
1293
  };
1263
1294
 
1264
- // src/tokens/process/formats/css.ts
1265
- var formats = {
1266
- colorScheme,
1267
- colorCategory,
1268
- semantic,
1269
- typography
1270
- };
1295
+ // src/tokens/process/formats/css/size-mode.ts
1296
+ import * as R10 from "ramda";
1297
+ import { createPropertyFormatter as createPropertyFormatter4 } from "style-dictionary/utils";
1271
1298
 
1272
1299
  // src/tokens/process/transformers.ts
1273
1300
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
@@ -1279,18 +1306,22 @@ var sizeRem = {
1279
1306
  transitive: true,
1280
1307
  filter: (token) => {
1281
1308
  const hasWantedType = typeEquals(["dimension", "fontsize"], token);
1282
- const hasWantedPath = pathStartsWithOneOf(["spacing", "sizing", "border-radius", "font-size"], token);
1309
+ const hasWantedPath = pathStartsWithOneOf([
1310
+ "border-radius",
1311
+ "font-size"
1312
+ /*, ['_size', 'mode-font-size']*/
1313
+ ], token);
1283
1314
  return hasWantedType && hasWantedPath;
1284
1315
  },
1285
1316
  transform: (token, config) => {
1286
1317
  const value = getValue(token);
1287
1318
  if (isPx(value)) {
1288
1319
  const baseFont = config.basePxFontSize || 16;
1289
- const size = parseInt(value, 10);
1290
- if (size === 0) {
1320
+ const size2 = parseInt(value, 10);
1321
+ if (size2 === 0) {
1291
1322
  return "0";
1292
1323
  }
1293
- return `${size / baseFont}rem`;
1324
+ return `${size2 / baseFont}rem`;
1294
1325
  }
1295
1326
  return value;
1296
1327
  }
@@ -1341,6 +1372,154 @@ var dsTransformers = [
1341
1372
  "shadow/css/shorthand"
1342
1373
  ];
1343
1374
 
1375
+ // src/tokens/process/formats/css/size-mode.ts
1376
+ var formatBaseSizeToken = (size2) => (token) => ({
1377
+ ...token,
1378
+ originalName: token.name,
1379
+ name: `${token.name}--${shortSizeName(size2)}`,
1380
+ $value: token.$value / basePxFontSize
1381
+ });
1382
+ var sizeMode = {
1383
+ name: "ds/css-size-mode",
1384
+ format: async ({ dictionary, file, options, platform }) => {
1385
+ const { outputReferences, usesDtcg } = options;
1386
+ const { selector, layer, size: size2 } = platform;
1387
+ const destination = file.destination;
1388
+ const format = createPropertyFormatter4({
1389
+ outputReferences,
1390
+ dictionary,
1391
+ format: "css",
1392
+ usesDtcg
1393
+ });
1394
+ const sizeSpecificTokens = dictionary.allTokens.map(formatBaseSizeToken(size2));
1395
+ const sizeSpecificVariables = sizeSpecificTokens.map(format).join("\n");
1396
+ const formattedMap = sizeSpecificTokens.map((token) => ({
1397
+ token,
1398
+ formatted: format({
1399
+ ...token,
1400
+ // Remove the `--<size>` suffix for the token listing, since that is the only token we actually use
1401
+ name: token.originalName
1402
+ })
1403
+ }));
1404
+ buildOptions.buildTokenFormats[destination] = formattedMap;
1405
+ const content = `${selector} /* ${size2} */ {
1406
+ ${sizeSpecificVariables}
1407
+ }`;
1408
+ const body = wrapInLayer(content, layer);
1409
+ const sizes = orderBySize(buildOptions?.sizeModes ?? []).map(shortSizeName);
1410
+ const defaultSize = shortSizeName(buildOptions?.defaultSize ?? "");
1411
+ const sizingToggles = `:root, [data-size] {
1412
+ --ds-size: var(--ds-size--${defaultSize});
1413
+ ${sizes.map((size3) => ` --ds-size--${size3}: var(--ds-size,);`).join("\n")}
1414
+ --ds-size-mode-font-size:
1415
+ ${sizes.map((size3) => ` var(--ds-size--${size3}, var(--ds-size-mode-font-size--${size3}))`).join("\n")};
1416
+ }`;
1417
+ const sizingHelpers = sizes.map((size3) => `[data-size='${size3}'] { --ds-size: var(--ds-size--${size3}); }`).join("\n");
1418
+ const sharedContent = `${sizingToggles}
1419
+
1420
+ ${sizingHelpers}`;
1421
+ const sharedBody = shortSizeName(size2) === R10.last(sizes) ? `
1422
+ ${wrapInLayer(sharedContent, layer)}` : "";
1423
+ return body + sharedBody;
1424
+ }
1425
+ };
1426
+ function wrapInLayer(content, layer) {
1427
+ return R10.isNotNil(layer) ? `@layer ${layer} {
1428
+ ${content}
1429
+ }
1430
+ ` : `${content}
1431
+ `;
1432
+ }
1433
+
1434
+ // src/tokens/process/formats/css/typography.ts
1435
+ import * as R11 from "ramda";
1436
+ import { createPropertyFormatter as createPropertyFormatter5 } from "style-dictionary/utils";
1437
+ var typographyFontFamilyPredicate = R11.allPass([
1438
+ R11.pathSatisfies(R11.includes("typography"), ["path"]),
1439
+ R11.pathSatisfies(R11.includes("fontFamily"), ["path"])
1440
+ ]);
1441
+ var typography = {
1442
+ name: "ds/css-typography",
1443
+ format: async ({ dictionary, file, options, platform }) => {
1444
+ const { outputReferences, usesDtcg } = options;
1445
+ const { selector, layer } = platform;
1446
+ const destination = file.destination;
1447
+ const format = createPropertyFormatter5({
1448
+ outputReferences,
1449
+ dictionary,
1450
+ format: "css",
1451
+ usesDtcg
1452
+ });
1453
+ const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
1454
+ const formattedMap = filteredTokens.map((token) => ({
1455
+ token,
1456
+ formatted: format(token)
1457
+ }));
1458
+ buildOptions.buildTokenFormats[destination] = formattedMap;
1459
+ const formattedTokens = formattedMap.map(R11.view(R11.lensProp("formatted"))).join("\n");
1460
+ const content = selector ? `${selector} {
1461
+ ${formattedTokens}
1462
+ }` : formattedTokens;
1463
+ const body = R11.isNotNil(layer) ? `@layer ${layer} {
1464
+ ${content}
1465
+ }` : content;
1466
+ return body;
1467
+ }
1468
+ };
1469
+
1470
+ // src/tokens/process/formats/css/type-scale.ts
1471
+ import * as R12 from "ramda";
1472
+ import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
1473
+ var typographyFontFamilyPredicate2 = R12.allPass([
1474
+ R12.pathSatisfies(R12.includes("typography"), ["path"]),
1475
+ R12.pathSatisfies(R12.includes("fontFamily"), ["path"])
1476
+ ]);
1477
+ function formatTypographySizeToken(token) {
1478
+ return { ...token, $value: `calc(${token.$value} * var(--_ds-font-size-factor))` };
1479
+ }
1480
+ var typeScale = {
1481
+ name: "ds/css-type-scale",
1482
+ format: async ({ dictionary, file, options, platform }) => {
1483
+ const { outputReferences, usesDtcg } = options;
1484
+ const { selector, layer } = platform;
1485
+ const destination = file.destination;
1486
+ const format = createPropertyFormatter6({
1487
+ outputReferences,
1488
+ dictionary,
1489
+ format: "css",
1490
+ usesDtcg
1491
+ });
1492
+ const filteredTokens = R12.reject(typographyFontFamilyPredicate2, dictionary.allTokens);
1493
+ const tokens = R12.map(formatTypographySizeToken, filteredTokens);
1494
+ const formattedMap = tokens.map((token) => ({
1495
+ token,
1496
+ formatted: format(token)
1497
+ }));
1498
+ buildOptions.buildTokenFormats[destination] = formattedMap;
1499
+ const formattedTokens = formattedMap.map(R12.prop("formatted")).join("\n");
1500
+ const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
1501
+ const content = `${selector} {
1502
+ ${sizeFactor}
1503
+ ${formattedTokens}
1504
+ }`;
1505
+ const body = R12.isNotNil(layer) ? `@layer ${layer} {
1506
+ ${content}
1507
+ }` : content;
1508
+ return body;
1509
+ }
1510
+ };
1511
+
1512
+ // src/tokens/process/formats/css.ts
1513
+ var formats = {
1514
+ colorScheme,
1515
+ colorCategory,
1516
+ semantic,
1517
+ sizeMode,
1518
+ size,
1519
+ typography,
1520
+ typeScale
1521
+ };
1522
+
1344
1523
  // src/tokens/process/configs/color.ts
1345
1524
  var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) => {
1346
1525
  const selector = `${colorScheme2 === "light" ? ":root, " : ""}[data-color-scheme="${colorScheme2}"]`;
@@ -1362,7 +1541,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
1362
1541
  {
1363
1542
  destination: `color-scheme/${colorScheme2}.css`,
1364
1543
  format: formats.colorScheme.name,
1365
- filter: (token) => typeEquals("color", token) && !R10.startsWith(["global"], token.path)
1544
+ filter: (token) => typeEquals("color", token) && !R13.startsWith(["global"], token.path)
1366
1545
  }
1367
1546
  ],
1368
1547
  options: {
@@ -1413,7 +1592,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
1413
1592
  };
1414
1593
 
1415
1594
  // src/tokens/process/configs/semantic.ts
1416
- import * as R11 from "ramda";
1595
+ import * as R14 from "ramda";
1417
1596
  import { outputReferencesFilter } from "style-dictionary/utils";
1418
1597
  var semanticVariables = ({ theme }) => {
1419
1598
  const selector = `:root`;
@@ -1436,9 +1615,12 @@ var semanticVariables = ({ theme }) => {
1436
1615
  destination: `semantic.css`,
1437
1616
  format: formats.semantic.name,
1438
1617
  filter: (token) => {
1439
- const isUwantedToken = R11.anyPass([R11.includes("primitives/global")])(token.filePath);
1440
- const isPrivateToken = R11.includes("_", token.path);
1441
- const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
1618
+ const isUwantedToken = R14.anyPass([R14.includes("primitives/global")])(token.filePath);
1619
+ const isPrivateToken = R14.includes("_", token.path);
1620
+ const unwantedPaths = pathStartsWithOneOf(
1621
+ ["size", "_size", "font-size", "line-height", "letter-spacing"],
1622
+ token
1623
+ );
1442
1624
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
1443
1625
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
1444
1626
  return unwantedTokens;
@@ -1448,9 +1630,126 @@ var semanticVariables = ({ theme }) => {
1448
1630
  options: {
1449
1631
  outputReferences: (token, options) => {
1450
1632
  const include = pathStartsWithOneOf(["border-radius"], token);
1451
- const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
1452
- return (include || isWantedSize) && outputReferencesFilter(token, options);
1633
+ return include && outputReferencesFilter(token, options);
1634
+ }
1635
+ }
1636
+ }
1637
+ }
1638
+ };
1639
+ };
1640
+
1641
+ // src/tokens/process/configs/size.ts
1642
+ import * as R15 from "ramda";
1643
+ import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
1644
+ var sizeVariables = ({ theme }) => {
1645
+ const selector = `:root, [data-size]`;
1646
+ const layer = `ds.theme.size`;
1647
+ return {
1648
+ preprocessors: ["tokens-studio"],
1649
+ platforms: {
1650
+ css: {
1651
+ // custom
1652
+ theme,
1653
+ basePxFontSize,
1654
+ selector,
1655
+ layer,
1656
+ //
1657
+ prefix,
1658
+ buildPath: `${theme}/`,
1659
+ transforms: dsTransformers,
1660
+ files: [
1661
+ {
1662
+ destination: `size.css`,
1663
+ format: formats.size.name,
1664
+ filter: (token) => {
1665
+ const isUwantedToken = R15.anyPass([R15.includes("primitives/global")])(token.filePath);
1666
+ const isPrivateToken = R15.includes("_", token.path);
1667
+ return pathStartsWithOneOf(["size", "_size"], token) && !(isUwantedToken || isPrivateToken);
1668
+ }
1669
+ }
1670
+ ],
1671
+ options: {
1672
+ outputReferences: (token, options) => {
1673
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && (isDigit(token.path[1]) || token.path[1] === "unit");
1674
+ return isWantedSize && outputReferencesFilter2(token, options);
1675
+ }
1676
+ }
1677
+ }
1678
+ }
1679
+ };
1680
+ };
1681
+
1682
+ // src/tokens/process/configs/size-mode.ts
1683
+ import * as R16 from "ramda";
1684
+ var sizeModeVariables = ({ theme, size: size2 }) => {
1685
+ const selector = `:root`;
1686
+ const layer = `ds.theme.size-mode`;
1687
+ return {
1688
+ preprocessors: ["tokens-studio"],
1689
+ platforms: {
1690
+ css: {
1691
+ // custom
1692
+ size: size2,
1693
+ theme,
1694
+ basePxFontSize,
1695
+ selector,
1696
+ layer,
1697
+ //
1698
+ prefix,
1699
+ buildPath: `${theme}/`,
1700
+ transforms: dsTransformers,
1701
+ files: [
1702
+ {
1703
+ destination: `size-mode/${size2}.css`,
1704
+ format: formats.sizeMode.name,
1705
+ filter: (token) => {
1706
+ return R16.equals(["_size", "mode-font-size"], token.path);
1707
+ }
1708
+ }
1709
+ ]
1710
+ }
1711
+ }
1712
+ };
1713
+ };
1714
+
1715
+ // src/tokens/process/configs/type-scale.ts
1716
+ var typeScaleVariables = ({ theme, size: size2 }) => {
1717
+ const selector = ":root, [data-size]";
1718
+ const layer = `ds.theme.type-scale`;
1719
+ return {
1720
+ usesDtcg: true,
1721
+ preprocessors: ["tokens-studio"],
1722
+ expand: {
1723
+ include: ["typography"]
1724
+ },
1725
+ platforms: {
1726
+ css: {
1727
+ prefix,
1728
+ selector,
1729
+ layer,
1730
+ buildPath: `${theme}/`,
1731
+ basePxFontSize,
1732
+ transforms: [
1733
+ "name/kebab",
1734
+ "ts/size/px",
1735
+ sizeRem.name,
1736
+ "ts/size/lineheight",
1737
+ "ts/typography/fontWeight",
1738
+ typographyName.name
1739
+ ],
1740
+ files: [
1741
+ {
1742
+ destination: `type-scale.css`,
1743
+ format: formats.typeScale.name,
1744
+ filter: (token) => {
1745
+ const included = typeEquals(["typography", "dimension", "fontsize"], token);
1746
+ if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
1747
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "border-width", "border-radius"], token) && (pathStartsWithOneOf(["font-size"], token) || token.path.includes("fontSize"));
1748
+ }
1453
1749
  }
1750
+ ],
1751
+ options: {
1752
+ outputReferences: (token) => pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize")
1454
1753
  }
1455
1754
  }
1456
1755
  }
@@ -1491,12 +1790,9 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
1491
1790
  destination: `typography/${typography2}.css`,
1492
1791
  format: formats.typography.name,
1493
1792
  filter: (token) => {
1494
- const included = typeEquals(
1495
- ["typography", "fontweight", "fontFamily", "lineHeight", "dimension", "font", "fontsize"],
1496
- token
1497
- );
1793
+ const included = typeEquals(["fontweight", "fontFamily", "lineHeight", "dimension"], token);
1498
1794
  if (/primitives\/modes\/typography\/(primary|secondary)/.test(token.filePath)) return false;
1499
- return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token);
1795
+ return included && !pathStartsWithOneOf(["spacing", "sizing", "size", "_size", "border-width", "border-radius"], token) && !(pathStartsWithOneOf(["typography"], token) && token.path.includes("fontSize"));
1500
1796
  }
1501
1797
  }
1502
1798
  ]
@@ -1671,13 +1967,13 @@ var TypographyValues;
1671
1967
  // src/tokens/process/utils/getMultidimensionalThemes.ts
1672
1968
  import { kebabCase } from "change-case";
1673
1969
  import pc3 from "picocolors";
1674
- import * as R12 from "ramda";
1970
+ import * as R17 from "ramda";
1675
1971
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
1676
1972
  const verboseLogging = buildOptions?.verbose;
1677
1973
  const grouped$themes = groupThemes(processed$themes);
1678
1974
  const permutations = permutateThemes(grouped$themes);
1679
1975
  const ALL_DEPENDENT_ON = ["theme"];
1680
- const keys3 = R12.keys(grouped$themes);
1976
+ const keys3 = R17.keys(grouped$themes);
1681
1977
  const nonDependentKeys = keys3.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
1682
1978
  if (verboseLogging) {
1683
1979
  console.log(pc3.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
@@ -1717,7 +2013,7 @@ function groupThemes(themes) {
1717
2013
  }
1718
2014
  return groups;
1719
2015
  }
1720
- var hasUnknownProps = R12.pipe(R12.values, R12.none(R12.equals("unknown")), R12.not);
2016
+ var hasUnknownProps = R17.pipe(R17.values, R17.none(R17.equals("unknown")), R17.not);
1721
2017
  function permutateThemes(groups) {
1722
2018
  const separator = "_";
1723
2019
  const permutations = cartesian(Object.values(groups));
@@ -1727,8 +2023,8 @@ function permutateThemes(groups) {
1727
2023
  const { group, name, selectedTokenSets } = theme;
1728
2024
  let updatedPermutation = acc.permutation;
1729
2025
  if (group) {
1730
- const groupProp = R12.lensProp(group);
1731
- updatedPermutation = R12.set(groupProp, name, updatedPermutation);
2026
+ const groupProp = R17.lensProp(group);
2027
+ updatedPermutation = R17.set(groupProp, name, updatedPermutation);
1732
2028
  }
1733
2029
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
1734
2030
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -1799,7 +2095,10 @@ var configs = {
1799
2095
  dangerColorVariables: colorCategoryVariables({ category: "builtin", color: "danger" }),
1800
2096
  warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
1801
2097
  infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
2098
+ sizeModeVariables,
2099
+ sizeVariables,
1802
2100
  typographyVariables,
2101
+ typeScaleVariables,
1803
2102
  semanticVariables
1804
2103
  };
1805
2104
  var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
@@ -1816,7 +2115,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
1816
2115
  obj.filePath = tokenSet;
1817
2116
  }
1818
2117
  });
1819
- tokenSource.tokens = R13.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
2118
+ tokenSource.tokens = R18.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
1820
2119
  }
1821
2120
  }
1822
2121
  } else {
@@ -1867,6 +2166,9 @@ var buildOptions = {
1867
2166
  var sd = new StyleDictionary2();
1868
2167
  var buildConfigs = {
1869
2168
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
2169
+ sizeMode: { getConfig: configs.sizeModeVariables, dimensions: ["size"] },
2170
+ size: { getConfig: configs.sizeVariables, dimensions: ["semantic"] },
2171
+ typeScale: { getConfig: configs.typeScaleVariables, dimensions: ["semantic"] },
1870
2172
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
1871
2173
  "main-color": { getConfig: configs.mainColorVariables, dimensions: ["main-color"] },
1872
2174
  "support-color": { getConfig: configs.supportColorVariables, dimensions: ["support-color"] },
@@ -1902,9 +2204,6 @@ async function processPlatform(options) {
1902
2204
  const platform = "css";
1903
2205
  const tokenSets = type === "format" ? options.tokenSets : void 0;
1904
2206
  const tokensDir = type === "build" ? options.tokensDir : void 0;
1905
- const filteredProcessed$themes = processed$themes.filter(
1906
- (theme) => R14.not(theme.group === "size" && theme.name !== "medium")
1907
- );
1908
2207
  const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
1909
2208
  if (UNSAFE_DEFAULT_COLOR) {
1910
2209
  console.warn(
@@ -1928,24 +2227,29 @@ async function processPlatform(options) {
1928
2227
  buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
1929
2228
  buildOptions.colorGroups = colorGroups;
1930
2229
  if (!buildOptions.defaultColor) {
1931
- const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
1932
- const firstMainColor = R14.head(customColors);
2230
+ const customColors = getCustomColors(processed$themes, colorGroups);
2231
+ const firstMainColor = R19.head(customColors);
1933
2232
  buildOptions.defaultColor = firstMainColor;
1934
2233
  }
1935
2234
  if (buildOptions.defaultColor) {
1936
2235
  console.log(`
1937
2236
  \u{1F3A8} Using ${pc4.blue(buildOptions.defaultColor)} as default color`);
1938
2237
  }
1939
- const buildAndSdConfigs = R14.map((buildConfig) => {
1940
- const sdConfigs = getConfigsForThemeDimensions(
1941
- buildConfig.getConfig,
1942
- filteredProcessed$themes,
1943
- buildConfig.dimensions,
1944
- {
1945
- tokensDir,
1946
- tokenSets
1947
- }
1948
- );
2238
+ const sizeModes = processed$themes.filter((x) => x.group === "size").map((x) => x.name);
2239
+ buildOptions.sizeModes = sizeModes;
2240
+ if (!buildOptions.defaultSize) {
2241
+ const defaultSize = R19.head(sizeModes);
2242
+ buildOptions.defaultSize = defaultSize;
2243
+ }
2244
+ if (buildOptions.defaultSize) {
2245
+ console.log(`
2246
+ \u{1F4CF} Using ${pc4.blue(buildOptions.defaultSize)} as default size`);
2247
+ }
2248
+ const buildAndSdConfigs = R19.map((buildConfig) => {
2249
+ const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
2250
+ tokensDir,
2251
+ tokenSets
2252
+ });
1949
2253
  const unknownConfigs = buildConfig.dimensions.map(
1950
2254
  (dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
1951
2255
  );
@@ -1969,10 +2273,13 @@ async function processPlatform(options) {
1969
2273
  "warning-color": [initResult],
1970
2274
  "info-color": [initResult],
1971
2275
  semantic: [initResult],
1972
- typography: [initResult]
2276
+ typography: [initResult],
2277
+ sizeMode: [initResult],
2278
+ size: [initResult],
2279
+ typeScale: [initResult]
1973
2280
  };
1974
2281
  try {
1975
- for (const [buildName, { buildConfig, sdConfigs }] of R14.toPairs(buildAndSdConfigs)) {
2282
+ for (const [buildName, { buildConfig, sdConfigs }] of R19.toPairs(buildAndSdConfigs)) {
1976
2283
  if (!(buildConfig.enabled?.() ?? true)) {
1977
2284
  continue;
1978
2285
  }
@@ -1984,7 +2291,7 @@ async function processPlatform(options) {
1984
2291
  const { config, permutation } = sdConfig;
1985
2292
  const modes = ["theme", ...buildConfig.dimensions];
1986
2293
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
1987
- const logMessage = R14.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
2294
+ const logMessage = R19.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
1988
2295
  console.log(logMessage);
1989
2296
  const sdOptions = { cache: true };
1990
2297
  const sdExtended = await sd.extend(config);
@@ -2110,8 +2417,12 @@ ${dynamicColors}`;
2110
2417
 
2111
2418
  // src/tokens/process/output/theme.ts
2112
2419
  import pc6 from "picocolors";
2113
- import * as R15 from "ramda";
2420
+ import * as R20 from "ramda";
2114
2421
  var defaultFileHeader2 = `build: v${package_default.version}`;
2422
+ var getFileNameWithoutExtension = (path5) => {
2423
+ const pathSegments = path5.split("/");
2424
+ return pathSegments[pathSegments.length - 1].split(".").slice(0, -1).join(".");
2425
+ };
2115
2426
  var createThemeCSSFiles = ({
2116
2427
  processedBuilds,
2117
2428
  fileHeader = defaultFileHeader2
@@ -2121,22 +2432,25 @@ var createThemeCSSFiles = ({
2121
2432
  for (const buildResult of buildResults) {
2122
2433
  const themeName = buildResult.permutation.theme;
2123
2434
  const newOutputs = buildResult.formatted;
2124
- if (R15.isNotEmpty(newOutputs)) {
2435
+ if (R20.isNotEmpty(newOutputs)) {
2125
2436
  const currentOutputs = groupedByTheme[themeName] ?? [];
2126
- groupedByTheme[themeName] = R15.concat(currentOutputs, newOutputs);
2437
+ groupedByTheme[themeName] = R20.concat(currentOutputs, newOutputs);
2127
2438
  }
2128
2439
  }
2129
2440
  }
2130
2441
  const sortOrder = [
2442
+ "size-mode/",
2443
+ "type-scale",
2131
2444
  "color-scheme/light",
2132
2445
  "typography/secondary",
2446
+ "size",
2133
2447
  "semantic",
2134
2448
  "color-scheme/dark",
2135
2449
  "color-scheme/contrast",
2136
2450
  "typography/primary",
2137
2451
  "color/"
2138
2452
  ];
2139
- const sortByDefinedOrder = R15.sortBy((file) => {
2453
+ const sortByDefinedOrder = R20.sortBy((file) => {
2140
2454
  const filePath = file.destination || "";
2141
2455
  const sortIndex = sortOrder.findIndex((sortElement) => {
2142
2456
  if (sortElement.endsWith("/")) {
@@ -2165,13 +2479,17 @@ ${fileHeader}
2165
2479
  */
2166
2480
 
2167
2481
  `;
2168
- const sortAlphabetically = R15.sort(R15.ascend((x) => x.destination || ""));
2169
- const pickOutputs = R15.map(R15.view(R15.lensProp("output")));
2170
- const themeCSSFile = R15.pipe(
2482
+ const sortAlphabetically = R20.sort(R20.ascend((x) => x.destination || ""));
2483
+ const sortBySize = R20.sortBy(
2484
+ R20.pipe((s) => getFileNameWithoutExtension(s.destination ?? ""), sizeComparator)
2485
+ );
2486
+ const pickOutputs = R20.map(R20.view(R20.lensProp("output")));
2487
+ const themeCSSFile = R20.pipe(
2171
2488
  sortAlphabetically,
2489
+ sortBySize,
2172
2490
  sortByDefinedOrder,
2173
2491
  pickOutputs,
2174
- R15.join("\n"),
2492
+ R20.join("\n"),
2175
2493
  (content) => header + content
2176
2494
  );
2177
2495
  const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
@@ -2214,7 +2532,7 @@ var buildTokens = async (options) => {
2214
2532
  processed$themes,
2215
2533
  buildTokenFormats: {}
2216
2534
  });
2217
- const fileHeader = R16.join("")([
2535
+ const fileHeader = R21.join("")([
2218
2536
  defaultFileHeader2,
2219
2537
  $designsystemet ? `
2220
2538
  design-tokens: v${$designsystemet.version}` : ""
@@ -2238,7 +2556,7 @@ design-tokens: v${$designsystemet.version}` : ""
2238
2556
  // src/tokens/create/write.ts
2239
2557
  import path2 from "path";
2240
2558
  import pc8 from "picocolors";
2241
- import * as R17 from "ramda";
2559
+ import * as R22 from "ramda";
2242
2560
 
2243
2561
  // src/tokens/create/generators/$designsystemet.ts
2244
2562
  function generate$Designsystemet() {
@@ -2465,12 +2783,12 @@ var writeTokens = async (options) => {
2465
2783
  }
2466
2784
  } catch (_error) {
2467
2785
  }
2468
- const concatThemeNames = R17.pipe(
2469
- R17.filter((obj) => R17.toLower(obj.group || "") === "theme"),
2470
- R17.map(R17.prop("name")),
2786
+ const concatThemeNames = R22.pipe(
2787
+ R22.filter((obj) => R22.toLower(obj.group || "") === "theme"),
2788
+ R22.map(R22.prop("name")),
2471
2789
  // New theme is added to the end of the list so we keep the same order from config and Token Studio
2472
- R17.append(themeName),
2473
- R17.uniq
2790
+ R22.append(themeName),
2791
+ R22.uniq
2474
2792
  );
2475
2793
  const themes = concatThemeNames(themeObjects);
2476
2794
  console.log(`
@@ -2491,7 +2809,7 @@ Themes: ${pc8.blue(themes.join(", "))}`);
2491
2809
  };
2492
2810
 
2493
2811
  // src/tokens/create/defaults.ts
2494
- import * as R18 from "ramda";
2812
+ import * as R23 from "ramda";
2495
2813
 
2496
2814
  // src/tokens/template/design-tokens/primitives/globals.json with { type: 'json' }
2497
2815
  var globals_default = {
@@ -2643,95 +2961,99 @@ var global_default = {
2643
2961
  _size: {
2644
2962
  "0": {
2645
2963
  $type: "dimension",
2646
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *0)"
2964
+ $value: "floor({_size.unit} * 0)"
2647
2965
  },
2648
2966
  "1": {
2649
2967
  $type: "dimension",
2650
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *1)"
2968
+ $value: "floor({_size.unit} * 1)"
2651
2969
  },
2652
2970
  "2": {
2653
2971
  $type: "dimension",
2654
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *2)"
2972
+ $value: "floor({_size.unit} * 2)"
2655
2973
  },
2656
2974
  "3": {
2657
2975
  $type: "dimension",
2658
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *3)"
2976
+ $value: "floor({_size.unit} * 3)"
2659
2977
  },
2660
2978
  "4": {
2661
2979
  $type: "dimension",
2662
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *4)"
2980
+ $value: "floor({_size.unit} * 4)"
2663
2981
  },
2664
2982
  "5": {
2665
2983
  $type: "dimension",
2666
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *5)"
2984
+ $value: "floor({_size.unit} * 5)"
2667
2985
  },
2668
2986
  "6": {
2669
2987
  $type: "dimension",
2670
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *6)"
2988
+ $value: "floor({_size.unit} * 6)"
2671
2989
  },
2672
2990
  "7": {
2673
2991
  $type: "dimension",
2674
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *7)"
2992
+ $value: "floor({_size.unit} * 7)"
2675
2993
  },
2676
2994
  "8": {
2677
2995
  $type: "dimension",
2678
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *8)"
2996
+ $value: "floor({_size.unit} * 8)"
2679
2997
  },
2680
2998
  "9": {
2681
2999
  $type: "dimension",
2682
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *9)"
3000
+ $value: "floor({_size.unit} * 9)"
2683
3001
  },
2684
3002
  "10": {
2685
3003
  $type: "dimension",
2686
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *10)"
3004
+ $value: "floor({_size.unit} * 10)"
2687
3005
  },
2688
3006
  "11": {
2689
3007
  $type: "dimension",
2690
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *11)"
3008
+ $value: "floor({_size.unit} * 11)"
2691
3009
  },
2692
3010
  "12": {
2693
3011
  $type: "dimension",
2694
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *12)"
3012
+ $value: "floor({_size.unit} * 12)"
2695
3013
  },
2696
3014
  "13": {
2697
3015
  $type: "dimension",
2698
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *13)"
3016
+ $value: "floor({_size.unit} * 13)"
2699
3017
  },
2700
3018
  "14": {
2701
3019
  $type: "dimension",
2702
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *14)"
3020
+ $value: "floor({_size.unit} * 14)"
2703
3021
  },
2704
3022
  "15": {
2705
3023
  $type: "dimension",
2706
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *15)"
3024
+ $value: "floor({_size.unit} * 15)"
2707
3025
  },
2708
3026
  "18": {
2709
3027
  $type: "dimension",
2710
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *18)"
3028
+ $value: "floor({_size.unit} * 18)"
2711
3029
  },
2712
3030
  "22": {
2713
3031
  $type: "dimension",
2714
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *22)"
3032
+ $value: "floor({_size.unit} * 22)"
2715
3033
  },
2716
3034
  "26": {
2717
3035
  $type: "dimension",
2718
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *26)"
3036
+ $value: "floor({_size.unit} * 26)"
2719
3037
  },
2720
3038
  "30": {
2721
3039
  $type: "dimension",
2722
- $value: "floor({_size.step} / {_size.base} * {_size.mode-font-size} *30)"
3040
+ $value: "floor({_size.unit} * 30)"
2723
3041
  },
2724
3042
  "mode-font-size": {
2725
- $type: "dimension",
3043
+ $type: "number",
2726
3044
  $value: "{size._mode-font-size}"
2727
3045
  },
2728
3046
  base: {
2729
- $type: "dimension",
3047
+ $type: "number",
2730
3048
  $value: "{size._base}"
2731
3049
  },
2732
3050
  step: {
2733
- $type: "dimension",
3051
+ $type: "number",
2734
3052
  $value: "{size._step}"
3053
+ },
3054
+ unit: {
3055
+ $type: "number",
3056
+ $value: "{_size.step} / {_size.base} * {_size.mode-font-size}"
2735
3057
  }
2736
3058
  }
2737
3059
  };
@@ -3476,13 +3798,13 @@ var defaultTokens = {
3476
3798
  "primitives/modes/typography/size/large": large_default2,
3477
3799
  "semantic/style": style_default
3478
3800
  };
3479
- var getDefaultTokens = (tokenSets) => Object.entries(R18.pick(tokenSets, defaultTokens));
3801
+ var getDefaultTokens = (tokenSets) => Object.entries(R23.pick(tokenSets, defaultTokens));
3480
3802
  var getDefaultToken = (tokenPath) => {
3481
3803
  return [tokenPath, defaultTokens[tokenPath]];
3482
3804
  };
3483
3805
 
3484
3806
  // src/tokens/create/generators/color.ts
3485
- import * as R19 from "ramda";
3807
+ import * as R24 from "ramda";
3486
3808
  var generateColor = (colorArray) => {
3487
3809
  const obj = {};
3488
3810
  const $type = "color";
@@ -3492,8 +3814,8 @@ var generateColor = (colorArray) => {
3492
3814
  return obj;
3493
3815
  };
3494
3816
  var generateColorScheme = (themeName, colorScheme2, colors2) => {
3495
- const main = R19.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.main);
3496
- const support = R19.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.support);
3817
+ const main = R24.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.main);
3818
+ const support = R24.map((color) => generateColor(generateColorScale(color, colorScheme2)), colors2.support);
3497
3819
  const neutral = generateColor(generateColorScale(colors2.neutral, colorScheme2));
3498
3820
  return {
3499
3821
  [themeName]: {
@@ -3521,7 +3843,7 @@ var generateColorGlobal = (colorScheme2) => {
3521
3843
  };
3522
3844
 
3523
3845
  // src/tokens/create/generators/semantic.ts
3524
- import * as R20 from "ramda";
3846
+ import * as R25 from "ramda";
3525
3847
 
3526
3848
  // src/tokens/template/design-tokens/semantic/color.base.template.json with { type: 'json' }
3527
3849
  var color_base_template_default = {
@@ -3985,7 +4307,7 @@ var generateSemantic = (colors2) => {
3985
4307
  const semanticColorTokens = customColors.map(
3986
4308
  (colorName) => [
3987
4309
  colorName,
3988
- R20.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), color_template_default)
4310
+ R25.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), color_template_default)
3989
4311
  ]
3990
4312
  );
3991
4313
  const color = {
@@ -4002,7 +4324,7 @@ var generateSemantic = (colors2) => {
4002
4324
  };
4003
4325
 
4004
4326
  // src/tokens/create/generators/theme.ts
4005
- import * as R21 from "ramda";
4327
+ import * as R26 from "ramda";
4006
4328
 
4007
4329
  // src/tokens/template/design-tokens/themes/theme.base.template.json with { type: 'json' }
4008
4330
  var theme_base_template_default = {
@@ -4138,7 +4460,7 @@ var generateTheme = (colors2, themeName, borderRadius) => {
4138
4460
  customColors.map(
4139
4461
  (colorName) => [
4140
4462
  colorName,
4141
- R21.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), theme_template_default)
4463
+ R26.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), theme_template_default)
4142
4464
  ]
4143
4465
  )
4144
4466
  );
@@ -4150,8 +4472,8 @@ var generateTheme = (colors2, themeName, borderRadius) => {
4150
4472
  },
4151
4473
  ...remainingThemeFile
4152
4474
  };
4153
- const baseBorderRadius = R21.lensPath(["border-radius", "base", "$value"]);
4154
- const updatedThemeFile = R21.set(baseBorderRadius, String(borderRadius), themeFile);
4475
+ const baseBorderRadius = R26.lensPath(["border-radius", "base", "$value"]);
4476
+ const updatedThemeFile = R26.set(baseBorderRadius, String(borderRadius), themeFile);
4155
4477
  const token = JSON.parse(
4156
4478
  JSON.stringify(
4157
4479
  updatedThemeFile,
@@ -4250,16 +4572,16 @@ var createTokens = async (opts) => {
4250
4572
  // bin/config.ts
4251
4573
  import path4 from "path";
4252
4574
  import pc10 from "picocolors";
4253
- import * as R23 from "ramda";
4575
+ import * as R28 from "ramda";
4254
4576
 
4255
4577
  // src/config.ts
4256
4578
  import pc9 from "picocolors";
4257
- import * as R22 from "ramda";
4579
+ import * as R27 from "ramda";
4258
4580
  import { z } from "zod";
4259
4581
  import { fromError } from "zod-validation-error";
4260
4582
  function mapPathToOptionName(path5) {
4261
- const normalisedPath = path5[0] === "themes" ? ["theme", ...R22.drop(2, path5)] : path5;
4262
- const option = R22.path(normalisedPath, cliOptions);
4583
+ const normalisedPath = path5[0] === "themes" ? ["theme", ...R27.drop(2, path5)] : path5;
4584
+ const option = R27.path(normalisedPath, cliOptions);
4263
4585
  if (typeof option !== "string") {
4264
4586
  return;
4265
4587
  }
@@ -4383,11 +4705,11 @@ async function parseCreateConfig(configFile, options) {
4383
4705
  const { cmd, theme = "theme", configPath } = options;
4384
4706
  const configParsed = parseConfig(configFile, configPath);
4385
4707
  const themeColors = Object.values(configParsed?.themes ?? {}).map(
4386
- (x) => /* @__PURE__ */ new Set([...R23.keys(x.colors.main), ...R23.keys(x.colors.support)])
4708
+ (x) => /* @__PURE__ */ new Set([...R28.keys(x.colors.main), ...R28.keys(x.colors.support)])
4387
4709
  );
4388
- if (!R23.all(R23.equals(R23.__, themeColors[0]), themeColors)) {
4710
+ if (!R28.all(R28.equals(R28.__, themeColors[0]), themeColors)) {
4389
4711
  console.error(pc10.redBright(`In config, all themes must have the same custom color names, but we found:`));
4390
- const themeNames = R23.keys(configParsed.themes ?? {});
4712
+ const themeNames = R28.keys(configParsed.themes ?? {});
4391
4713
  themeColors.forEach((colors2, index) => {
4392
4714
  const colorNames = Array.from(colors2);
4393
4715
  console.log(` - ${themeNames[index]}: ${colorNames.join(", ")}`);
@@ -4395,7 +4717,7 @@ async function parseCreateConfig(configFile, options) {
4395
4717
  console.log();
4396
4718
  process.exit(1);
4397
4719
  }
4398
- const noUndefined = R23.reject(R23.isNil);
4720
+ const noUndefined = R28.reject(R28.isNil);
4399
4721
  const getThemeOptions = (optionGetter) => noUndefined({
4400
4722
  colors: noUndefined({
4401
4723
  main: optionGetter(cmd, "mainColors"),
@@ -4411,10 +4733,10 @@ async function parseCreateConfig(configFile, options) {
4411
4733
  const unvalidatedConfig = noUndefined({
4412
4734
  outDir: configParsed?.outDir ?? getCliOption(cmd, "outDir"),
4413
4735
  clean: configParsed?.clean ?? getCliOption(cmd, "clean"),
4414
- themes: configParsed?.themes ? R23.map((jsonThemeValues) => {
4736
+ themes: configParsed?.themes ? R28.map((jsonThemeValues) => {
4415
4737
  const defaultThemeValues = getThemeOptions(getDefaultCliOption);
4416
4738
  const cliThemeValues = getThemeOptions(getSuppliedCliOption);
4417
- const mergedConfigs = R23.mergeDeepRight(defaultThemeValues, R23.mergeDeepRight(jsonThemeValues, cliThemeValues));
4739
+ const mergedConfigs = R28.mergeDeepRight(defaultThemeValues, R28.mergeDeepRight(jsonThemeValues, cliThemeValues));
4418
4740
  return mergedConfigs;
4419
4741
  }, configParsed.themes) : (
4420
4742
  // If there are no themes specified in the JSON config, we use both explicit
@@ -4520,7 +4842,7 @@ function parseBoolean(value) {
4520
4842
  return value === "true" || value === true;
4521
4843
  }
4522
4844
  async function getConfigFile(config) {
4523
- const allowFileNotFound = R24.isNil(config) || config === DEFAULT_CONFIG_FILE;
4845
+ const allowFileNotFound = R29.isNil(config) || config === DEFAULT_CONFIG_FILE;
4524
4846
  const configPath = config ?? DEFAULT_CONFIG_FILE;
4525
4847
  const configFile = await readConfigFile(configPath, allowFileNotFound);
4526
4848
  return { configFile, configPath };