@digdir/designsystemet 1.0.0-next.45 → 1.0.0-next.47

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 (85) hide show
  1. package/dist/bin/config.d.ts +162 -0
  2. package/dist/bin/config.d.ts.map +1 -0
  3. package/dist/bin/config.js +56 -0
  4. package/dist/bin/designsystemet.js +140 -29
  5. package/dist/bin/options.d.ts +16 -0
  6. package/dist/bin/options.d.ts.map +1 -0
  7. package/dist/bin/options.js +12 -0
  8. package/dist/config.schema.json +82 -0
  9. package/dist/src/build-scripts/createJsonSchema.d.ts +2 -0
  10. package/dist/src/build-scripts/createJsonSchema.d.ts.map +1 -0
  11. package/dist/src/build-scripts/createJsonSchema.js +15 -0
  12. package/dist/src/tokens/build/configs.d.ts.map +1 -1
  13. package/dist/src/tokens/build/configs.js +23 -12
  14. package/dist/src/tokens/build/formats/css.d.ts +4 -2
  15. package/dist/src/tokens/build/formats/css.d.ts.map +1 -1
  16. package/dist/src/tokens/build/formats/css.js +20 -12
  17. package/dist/src/tokens/build/formats/js-tokens.d.ts.map +1 -1
  18. package/dist/src/tokens/build/formats/js-tokens.js +7 -4
  19. package/dist/src/tokens/build/transformers.d.ts +0 -1
  20. package/dist/src/tokens/build/transformers.d.ts.map +1 -1
  21. package/dist/src/tokens/build/transformers.js +1 -13
  22. package/dist/src/tokens/build.d.ts +3 -1
  23. package/dist/src/tokens/build.d.ts.map +1 -1
  24. package/dist/src/tokens/build.js +5 -2
  25. package/dist/src/tokens/create.d.ts +16 -11
  26. package/dist/src/tokens/create.d.ts.map +1 -1
  27. package/dist/src/tokens/create.js +15 -5
  28. package/dist/src/tokens/design-tokens/default/Figma/components.json +3 -3
  29. package/dist/src/tokens/design-tokens/default/primitives/globals.json +1 -1
  30. package/dist/src/tokens/design-tokens/default/primitives/modes/size/global.json +21 -21
  31. package/dist/src/tokens/design-tokens/default/semantic/style.json +109 -27
  32. package/dist/src/tokens/design-tokens/template/$themes.json +63 -63
  33. package/dist/src/tokens/design-tokens/template/semantic/color-base-file.json +1 -1
  34. package/dist/src/tokens/design-tokens/template/themes/theme-base-file.json +8 -8
  35. package/dist/src/tokens/index.d.ts +2 -1
  36. package/dist/src/tokens/index.d.ts.map +1 -1
  37. package/dist/src/tokens/index.js +2 -2
  38. package/dist/src/tokens/types.d.ts +2 -8
  39. package/dist/src/tokens/types.d.ts.map +1 -1
  40. package/dist/src/tokens/utils.d.ts +2 -0
  41. package/dist/src/tokens/utils.d.ts.map +1 -1
  42. package/dist/src/tokens/utils.js +11 -0
  43. package/dist/src/tokens/write.d.ts +3 -0
  44. package/dist/src/tokens/write.d.ts.map +1 -1
  45. package/dist/src/tokens/write.js +6 -2
  46. package/package.json +23 -17
  47. package/dist/src/init/createTokensPackage.d.ts +0 -5
  48. package/dist/src/init/createTokensPackage.d.ts.map +0 -1
  49. package/dist/src/init/createTokensPackage.js +0 -273
  50. package/dist/src/init/generateMetadataJson.d.ts +0 -6
  51. package/dist/src/init/generateMetadataJson.d.ts.map +0 -1
  52. package/dist/src/init/generateMetadataJson.js +0 -24
  53. package/dist/src/init/generateThemesJson.d.ts +0 -3
  54. package/dist/src/init/generateThemesJson.d.ts.map +0 -1
  55. package/dist/src/init/generateThemesJson.js +0 -103
  56. package/dist/src/init/index.d.ts +0 -3
  57. package/dist/src/init/index.d.ts.map +0 -1
  58. package/dist/src/init/index.js +0 -10
  59. package/dist/src/init/nextStepsMarkdown.d.ts +0 -3
  60. package/dist/src/init/nextStepsMarkdown.d.ts.map +0 -1
  61. package/dist/src/init/nextStepsMarkdown.js +0 -92
  62. package/dist/src/init/template/default-files/README.md +0 -10
  63. package/dist/src/init/template/default-files/design-tokens/Figma/components.json +0 -22
  64. package/dist/src/init/template/default-files/design-tokens/README.md +0 -3
  65. package/dist/src/init/template/default-files/design-tokens/primitives/globals.json +0 -161
  66. package/dist/src/init/template/default-files/design-tokens/primitives/size/default.json +0 -175
  67. package/dist/src/init/template/default-files/design-tokens/semantic/color.json +0 -572
  68. package/dist/src/init/template/default-files/design-tokens/semantic/style.json +0 -564
  69. package/dist/src/init/template/default-files/design-tokens/themes/theme.json +0 -334
  70. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/contrast/global.json +0 -376
  71. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/contrast/theme-template.json +0 -314
  72. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/dark/global.json +0 -376
  73. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/dark/theme-template.json +0 -314
  74. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/light/global.json +0 -376
  75. package/dist/src/init/template/template-files/design-tokens/primitives/modes/colors/light/theme-template.json +0 -314
  76. package/dist/src/init/template/template-files/design-tokens/primitives/modes/typography/primary/theme-template.json +0 -30
  77. package/dist/src/init/template/template-files/design-tokens/primitives/modes/typography/secondary/theme-template.json +0 -30
  78. package/dist/src/init/template/template-files/design-tokens/themes/theme-template.json +0 -334
  79. package/dist/src/init/template/template-files/package.json +0 -24
  80. package/dist/src/init/utils.d.ts +0 -4
  81. package/dist/src/init/utils.d.ts.map +0 -1
  82. package/dist/src/init/utils.js +0 -15
  83. package/dist/src/tokens/build/utils/noCase.d.ts +0 -11
  84. package/dist/src/tokens/build/utils/noCase.d.ts.map +0 -1
  85. package/dist/src/tokens/build/utils/noCase.js +0 -24
@@ -3,10 +3,10 @@ import * as R from "ramda";
3
3
  import StyleDictionary from "style-dictionary";
4
4
  import { outputReferencesFilter } from "style-dictionary/utils";
5
5
  import { DEFAULT_COLOR, buildOptions } from "../build.js";
6
- import { isColorCategoryToken, pathStartsWithOneOf, typeEquals } from "../utils.js";
6
+ import { isColorCategoryToken, isDigit, pathStartsWithOneOf, typeEquals } from "../utils.js";
7
7
  import { formats } from "./formats/css.js";
8
8
  import { jsTokens } from "./formats/js-tokens.js";
9
- import { nameKebab, resolveMath, sizeRem, typographyName, unitless } from "./transformers.js";
9
+ import { resolveMath, sizeRem, typographyName, unitless } from "./transformers.js";
10
10
  import { getMultidimensionalThemes } from "./utils/getMultidimensionalThemes.js";
11
11
  void register(StyleDictionary, { withSDBuiltins: false });
12
12
  const usesDtcg = true;
@@ -14,7 +14,6 @@ const prefix = "ds";
14
14
  const basePxFontSize = 16;
15
15
  const fileHeader = () => [`These files are generated from design tokens defind using Token Studio`];
16
16
  StyleDictionary.registerTransform(sizeRem);
17
- StyleDictionary.registerTransform(nameKebab);
18
17
  StyleDictionary.registerTransform(typographyName);
19
18
  StyleDictionary.registerTransform(resolveMath);
20
19
  StyleDictionary.registerTransform(unitless);
@@ -23,7 +22,7 @@ for (const format of Object.values(formats)) {
23
22
  StyleDictionary.registerFormat(format);
24
23
  }
25
24
  const dsTransformers = [
26
- nameKebab.name,
25
+ "name/kebab",
27
26
  resolveMath.name,
28
27
  "ts/size/px",
29
28
  sizeRem.name,
@@ -160,8 +159,9 @@ const semanticVariables = ({ theme }, { outPath }) => {
160
159
  options: {
161
160
  fileHeader,
162
161
  outputReferences: (token, options) => {
163
- const include = pathStartsWithOneOf(["border-radius", "size"], token);
164
- return include && outputReferencesFilter(token, options);
162
+ const include = pathStartsWithOneOf(["border-radius"], token);
163
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
164
+ return (include || isWantedSize) && outputReferencesFilter(token, options);
165
165
  }
166
166
  }
167
167
  }
@@ -187,16 +187,16 @@ const typescriptTokens = ({ "color-scheme": colorScheme, theme }, { outPath }) =
187
187
  return false;
188
188
  const isSemanticColor = R.includes("semantic", token.filePath) && typeEquals(["color"], token);
189
189
  const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
190
- const isNotPrivate = R.not(R.any((path) => path.startsWith("_"))(token.path));
191
- return (isSemanticColor || wantedTypes) && isNotPrivate;
190
+ return isSemanticColor || wantedTypes;
192
191
  }
193
192
  }
194
193
  ],
195
194
  options: {
196
195
  fileHeader,
197
196
  outputReferences: (token, options) => {
198
- const include = pathStartsWithOneOf(["border-radius", "size"], token);
199
- return include && outputReferencesFilter(token, options);
197
+ const include = pathStartsWithOneOf(["border-radius"], token);
198
+ const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
199
+ return (include || isWantedSize) && outputReferencesFilter(token, options);
200
200
  }
201
201
  }
202
202
  }
@@ -222,7 +222,7 @@ const typographyVariables = ({ theme, typography }, { outPath }) => {
222
222
  buildPath: `${outPath}/${theme}/`,
223
223
  basePxFontSize,
224
224
  transforms: [
225
- nameKebab.name,
225
+ "name/kebab",
226
226
  "ts/size/px",
227
227
  sizeRem.name,
228
228
  "ts/size/lineheight",
@@ -239,7 +239,18 @@ const typographyVariables = ({ theme, typography }, { outPath }) => {
239
239
  token
240
240
  );
241
241
  return included && !pathStartsWithOneOf(
242
- ["spacing", "sizing", "size", "border-width", "border-radius", "theme", "theme2", "theme3", "theme4"],
242
+ [
243
+ "spacing",
244
+ "sizing",
245
+ "size",
246
+ "_size",
247
+ "border-width",
248
+ "border-radius",
249
+ "theme",
250
+ "theme2",
251
+ "theme3",
252
+ "theme4"
253
+ ],
243
254
  token
244
255
  );
245
256
  }
@@ -19,17 +19,19 @@ import type { Format } from 'style-dictionary/types';
19
19
  * ]
20
20
  * ```
21
21
  *
22
- * @param shouldInline - predicate to determine if token should be inlined
22
+ * @param shouldSquash - predicate to determine if token should be inlined
23
23
  * @param tokens - array of tokens to transform
24
24
  * @returns copy of `tokens` without those that matched the predicate,
25
25
  * where references to the matching tokens have been inlined
26
26
  */
27
- export declare function inlineTokens(shouldInline: (t: TransformedToken) => boolean, tokens: TransformedToken[]): import("style-dictionary/types").TransformedToken[];
27
+ export declare function squashTokens(shouldSquash: (t: TransformedToken) => boolean, tokens: TransformedToken[]): import("style-dictionary/types").TransformedToken[];
28
28
  declare module 'style-dictionary/types' {
29
29
  interface LocalOptions {
30
30
  replaceCategoryWith?: string;
31
31
  }
32
32
  }
33
+ export declare const isNumericSizeToken: (t: TransformedToken) => boolean;
34
+ export declare const isSquashTokens: (t: TransformedToken) => boolean;
33
35
  /**
34
36
  * Overrides the default sizing formula with a custom one that supports [round()](https://developer.mozilla.org/en-US/docs/Web/CSS/round) if supported.
35
37
  *
@@ -1 +1 @@
1
- {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/formats/css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,uDAYtG;AAsDD,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAiB,YAAY;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B;CACF;AAuCD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,WAAY,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,SAAS,gBAAgB;;;;CAYrG,CAAC;AAyFF,eAAO,MAAM,OAAO;;;;;CAKc,CAAC"}
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/formats/css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAarD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,uDAetG;AAsDD,OAAO,QAAQ,wBAAwB,CAAC;IACtC,UAAiB,YAAY;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B;CACF;AAmCD,eAAO,MAAM,kBAAkB,MAAO,gBAAgB,YAA4D,CAAC;AAEnH,eAAO,MAAM,cAAc,MAHY,gBAAgB,YAGkC,CAAC;AAE1F;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,WAAY,CAAC,CAAC,EAAE,gBAAgB,KAAK,MAAM,SAAS,gBAAgB;;;;CAYrG,CAAC;AA4FF,eAAO,MAAM,OAAO;;;;;CAKc,CAAC"}
@@ -3,18 +3,21 @@ import { createPropertyFormatter, fileHeader } from "style-dictionary/utils";
3
3
  import {
4
4
  getValue,
5
5
  isColorCategoryToken,
6
+ isDigit,
6
7
  isGlobalColorToken,
7
8
  isSemanticToken,
8
9
  pathStartsWithOneOf
9
10
  } from "../../utils.js";
10
11
  import { colorCategories } from "../types.js";
11
- function inlineTokens(shouldInline, tokens) {
12
- const [inlineableTokens, otherTokens] = R.partition(shouldInline, tokens);
12
+ function squashTokens(shouldSquash, tokens) {
13
+ const [inlineableTokens, otherTokens] = R.partition(shouldSquash, tokens);
13
14
  return otherTokens.map((token) => {
14
15
  let transformed = getValue(token.original);
15
16
  for (const ref of inlineableTokens) {
16
17
  const refName = ref.path.join(".");
17
- transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
18
+ if (typeof transformed === "string") {
19
+ transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
20
+ }
18
21
  }
19
22
  const tokenWithInlinedRefs = R.set(R.lensPath(["original", "$value"]), transformed, token);
20
23
  return tokenWithInlinedRefs;
@@ -102,12 +105,12 @@ ${selector} ${content}
102
105
  return header + body;
103
106
  }
104
107
  };
105
- const isDigit = (s) => /^\d+$/.test(s);
106
108
  const isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
107
- const isUwantedTokens = R.anyPass([isNumericBorderRadiusToken]);
109
+ const isNumericSizeToken = (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]);
110
+ const isSquashTokens = R.anyPass([isNumericBorderRadiusToken, isNumericSizeToken]);
108
111
  const overrideSizingFormula = (format, token) => {
109
112
  const [name, value] = format(token).split(":");
110
- const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1);");
113
+ const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
111
114
  const round = `round(down, ${calc}, 0.0625rem)`;
112
115
  return {
113
116
  name,
@@ -120,8 +123,8 @@ const formatSizingTokens = (format, tokens) => {
120
123
  (acc, token) => {
121
124
  const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
122
125
  return {
123
- round: [...acc.round, `${name}: ${round2}`],
124
- calc: [...acc.calc, `${name}: ${calc2}`]
126
+ round: [...acc.round, `${name}: ${round2};`],
127
+ calc: [...acc.calc, `${name}: ${calc2};`]
125
128
  };
126
129
  },
127
130
  { round: [], calc: [] },
@@ -146,9 +149,12 @@ const semantic = {
146
149
  format: "css",
147
150
  usesDtcg
148
151
  });
149
- const tokens = inlineTokens(isUwantedTokens, dictionary.allTokens);
152
+ const tokens = squashTokens(isSquashTokens, dictionary.allTokens);
150
153
  const filteredTokens = R.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
151
- const [sizingTokens, restTokens] = R.partition(pathStartsWithOneOf(["size"]), filteredTokens);
154
+ const [sizingTokens, restTokens] = R.partition(
155
+ (t) => pathStartsWithOneOf(["size", "_size"], t) && isDigit(t.path[1]),
156
+ filteredTokens
157
+ );
152
158
  const formattedTokens = [R.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
153
159
  const content = `{
154
160
  ${formattedTokens.join("\n")}
@@ -197,6 +203,8 @@ const formats = {
197
203
  };
198
204
  export {
199
205
  formats,
200
- inlineTokens,
201
- overrideSizingFormula
206
+ isNumericSizeToken,
207
+ isSquashTokens,
208
+ overrideSizingFormula,
209
+ squashTokens
202
210
  };
@@ -1 +1 @@
1
- {"version":3,"file":"js-tokens.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/formats/js-tokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;AAiBvE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAuCtB,CAAC"}
1
+ {"version":3,"file":"js-tokens.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/build/formats/js-tokens.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAoB,MAAM,wBAAwB,CAAC;AAoBvE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAuCtB,CAAC"}
@@ -1,9 +1,12 @@
1
1
  import * as R from "ramda";
2
2
  import { createPropertyFormatter, fileHeader } from "style-dictionary/utils";
3
3
  import { getType, isColorCategoryToken, pathStartsWithOneOf } from "../../utils.js";
4
- import { overrideSizingFormula } from "./css.js";
4
+ import { isSquashTokens, overrideSizingFormula, squashTokens } from "./css.js";
5
5
  const groupByType = R.groupBy((token) => getType(token));
6
- const removeUnwatedTokens = R.filter((token) => !isColorCategoryToken(token));
6
+ const removeUnwatedTokens = R.pipe(
7
+ R.reject((token) => isColorCategoryToken(token)),
8
+ R.reject((token) => R.any((path) => path.startsWith("_"))(token.path))
9
+ );
7
10
  const dissocExtensions = R.pipe(R.dissoc("$extensions"), R.dissocPath(["original", "$extensions"]));
8
11
  const removeUnwatedProps = R.map((token) => dissocExtensions(token));
9
12
  const toCssVarName = R.pipe(R.split(":"), R.head, R.trim);
@@ -18,7 +21,7 @@ const jsTokens = {
18
21
  usesDtcg
19
22
  });
20
23
  const formatTokens = R.map((token) => {
21
- if (pathStartsWithOneOf(["size"], token)) {
24
+ if (pathStartsWithOneOf(["size", "_size"], token)) {
22
25
  const { calc, name } = overrideSizingFormula(format, token);
23
26
  return {
24
27
  ...token,
@@ -32,7 +35,7 @@ const jsTokens = {
32
35
  };
33
36
  });
34
37
  const processTokens = R.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
35
- const tokens = processTokens(dictionary.allTokens);
38
+ const tokens = processTokens(squashTokens(isSquashTokens, dictionary.allTokens));
36
39
  const content = Object.entries(tokens).map(
37
40
  ([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
38
41
  `
@@ -1,6 +1,5 @@
1
1
  import type { Transform } from 'style-dictionary/types';
2
2
  export declare const sizeRem: Transform;
3
- export declare const nameKebab: Transform;
4
3
  export declare const typographyName: Transform;
5
4
  export declare const resolveMath: Transform;
6
5
  export declare const unitless: Transform;
@@ -1 +1 @@
1
- {"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../../src/tokens/build/transformers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAOxD,eAAO,MAAM,OAAO,EAAE,SAyBrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SASvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAS5B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAWzB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,SAMtB,CAAC"}
1
+ {"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../../src/tokens/build/transformers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxD,eAAO,MAAM,OAAO,EAAE,SAyBrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,SAS5B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,SAWzB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,SAMtB,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
2
2
  import * as R from "ramda";
3
3
  import { getValue, pathStartsWithOneOf, typeEquals } from "../utils.js";
4
- import { noCase } from "./utils/noCase.js";
5
4
  const isPx = R.test(/\b\d+px\b/g);
6
5
  const sizeRem = {
7
6
  name: "ds/size/toRem",
@@ -25,16 +24,6 @@ const sizeRem = {
25
24
  return value;
26
25
  }
27
26
  };
28
- const nameKebab = {
29
- name: "name/cti/hierarchical-kebab",
30
- type: "name",
31
- transform: (token, options) => {
32
- return noCase([options?.prefix].concat(token.path).join("-"), {
33
- delimiter: "-",
34
- stripRegexp: /[^A-Z0-9_]+/gi
35
- });
36
- }
37
- };
38
27
  const typographyName = {
39
28
  name: "name/typography",
40
29
  type: "name",
@@ -60,11 +49,10 @@ const unitless = {
60
49
  name: "ds/unitless",
61
50
  type: "value",
62
51
  transitive: true,
63
- filter: (token) => pathStartsWithOneOf(["size"], token),
52
+ filter: (token) => pathStartsWithOneOf(["size", "_size"], token),
64
53
  transform: (token) => parseInt(getValue(token))
65
54
  };
66
55
  export {
67
- nameKebab,
68
56
  resolveMath,
69
57
  sizeRem,
70
58
  typographyName,
@@ -10,8 +10,10 @@ type Options = {
10
10
  verbose: boolean;
11
11
  /** Set the default "accent" color, if not overridden with data-color */
12
12
  accentColor?: string;
13
- /** Dry run */
13
+ /** Dry run, no files will be written */
14
14
  dry?: boolean;
15
+ /** Clean the output path before building tokens */
16
+ clean?: boolean;
15
17
  };
16
18
  export declare let buildOptions: Options | undefined;
17
19
  export declare function buildTokens(options: Options): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC,KAAK,OAAO,GAAG;IACb,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,IAAI,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;AAwC7C,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiFjE"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,aAAa,WAAW,CAAC;AAEtC,KAAK,OAAO,GAAG;IACb,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,mDAAmD;IACnD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,IAAI,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;AAwC7C,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAqFjE"}
@@ -7,7 +7,7 @@ import { configs, getConfigsForThemeDimensions } from "./build/configs.js";
7
7
  import { colorCategories } from "./build/types.js";
8
8
  import { makeEntryFile } from "./build/utils/entryfile.js";
9
9
  import { processThemeObject } from "./build/utils/getMultidimensionalThemes.js";
10
- import { copyFile, writeFile } from "./utils.js";
10
+ import { cleanDir, copyFile, writeFile } from "./utils.js";
11
11
  const DEFAULT_COLOR = "accent";
12
12
  let buildOptions;
13
13
  const sd = new StyleDictionary();
@@ -42,7 +42,7 @@ const buildConfigs = {
42
42
  }
43
43
  };
44
44
  async function buildTokens(options) {
45
- const { dry } = options;
45
+ const { dry, clean } = options;
46
46
  const tokensDir = options.tokens;
47
47
  const targetDir = path.resolve(options.outDir);
48
48
  buildOptions = options;
@@ -66,6 +66,9 @@ async function buildTokens(options) {
66
66
  }),
67
67
  buildConfigs
68
68
  );
69
+ if (clean) {
70
+ await cleanDir(targetDir, dry);
71
+ }
69
72
  try {
70
73
  for (const [key, { buildConfig, sdConfigs }] of R.toPairs(buildAndSdConfigs)) {
71
74
  if (!(buildConfig.enabled?.() ?? true)) {
@@ -1,13 +1,18 @@
1
- import type { Colors, Tokens, Typography } from './types.js';
2
- export declare const colorCliOptions: {
3
- readonly main: "main-colors";
4
- readonly support: "support-colors";
5
- readonly neutral: "neutral-color";
1
+ import type { Theme, Tokens } from './types.js';
2
+ export declare const cliOptions: {
3
+ readonly outDir: "out-dir";
4
+ readonly clean: "clean";
5
+ readonly theme: {
6
+ readonly colors: {
7
+ readonly main: "main-colors";
8
+ readonly support: "support-colors";
9
+ readonly neutral: "neutral-color";
10
+ };
11
+ readonly typography: {
12
+ readonly fontFamily: "font-family";
13
+ };
14
+ readonly borderRadius: "border-radius";
15
+ };
6
16
  };
7
- export type CreateTokensOptions = {
8
- colors: Colors;
9
- typography: Typography;
10
- name: string;
11
- };
12
- export declare const createTokens: (opts: CreateTokensOptions) => Tokens;
17
+ export declare const createTokens: (opts: Theme) => Tokens;
13
18
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAyB,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpF,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAgFF,eAAO,MAAM,YAAY,SAAU,mBAAmB,WAqBrD,CAAC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,KAAK,EAAE,MAAM,EAAqC,MAAM,YAAY,CAAC;AAE3F,eAAO,MAAM,UAAU;;;;;;;;;;;;;;CAcb,CAAC;AAgFX,eAAO,MAAM,YAAY,SAAU,KAAK,WAqBvC,CAAC"}
@@ -1,9 +1,19 @@
1
1
  import * as R from "ramda";
2
2
  import { baseColors, generateColorScale } from "../colors/index.js";
3
- const colorCliOptions = {
4
- main: "main-colors",
5
- support: "support-colors",
6
- neutral: "neutral-color"
3
+ const cliOptions = {
4
+ outDir: "out-dir",
5
+ clean: "clean",
6
+ theme: {
7
+ colors: {
8
+ main: "main-colors",
9
+ support: "support-colors",
10
+ neutral: "neutral-color"
11
+ },
12
+ typography: {
13
+ fontFamily: "font-family"
14
+ },
15
+ borderRadius: "border-radius"
16
+ }
7
17
  };
8
18
  const createColorTokens = (colorArray) => {
9
19
  const obj = {};
@@ -98,6 +108,6 @@ const createTokens = (opts) => {
98
108
  return tokens;
99
109
  };
100
110
  export {
101
- colorCliOptions,
111
+ cliOptions,
102
112
  createTokens
103
113
  };
@@ -3,15 +3,15 @@
3
3
  "circle": {
4
4
  "small": {
5
5
  "$type": "sizing",
6
- "$value": "{size.5} - {switch.border}"
6
+ "$value": "{_size.5} - {switch.border}"
7
7
  },
8
8
  "medium": {
9
9
  "$type": "sizing",
10
- "$value": "{size.6} - {switch.border}"
10
+ "$value": "{_size.6} - {switch.border}"
11
11
  },
12
12
  "large": {
13
13
  "$type": "sizing",
14
- "$value": "{size.7} - {switch.border}"
14
+ "$value": "{_size.7} - {switch.border}"
15
15
  }
16
16
  },
17
17
  "border": {
@@ -140,4 +140,4 @@
140
140
  "$value": "30%"
141
141
  }
142
142
  }
143
- }
143
+ }
@@ -1,84 +1,84 @@
1
1
  {
2
- "size": {
2
+ "_size": {
3
3
  "0": {
4
4
  "$type": "dimension",
5
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *0)"
5
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *0)"
6
6
  },
7
7
  "1": {
8
8
  "$type": "dimension",
9
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *1)"
9
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *1)"
10
10
  },
11
11
  "2": {
12
12
  "$type": "dimension",
13
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *2)"
13
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *2)"
14
14
  },
15
15
  "3": {
16
16
  "$type": "dimension",
17
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *3)"
17
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *3)"
18
18
  },
19
19
  "4": {
20
20
  "$type": "dimension",
21
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *4)"
21
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *4)"
22
22
  },
23
23
  "5": {
24
24
  "$type": "dimension",
25
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *5)"
25
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *5)"
26
26
  },
27
27
  "6": {
28
28
  "$type": "dimension",
29
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *6)"
29
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *6)"
30
30
  },
31
31
  "7": {
32
32
  "$type": "dimension",
33
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *7)"
33
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *7)"
34
34
  },
35
35
  "8": {
36
36
  "$type": "dimension",
37
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *8)"
37
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *8)"
38
38
  },
39
39
  "9": {
40
40
  "$type": "dimension",
41
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *9)"
41
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *9)"
42
42
  },
43
43
  "10": {
44
44
  "$type": "dimension",
45
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *10)"
45
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *10)"
46
46
  },
47
47
  "11": {
48
48
  "$type": "dimension",
49
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *11)"
49
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *11)"
50
50
  },
51
51
  "12": {
52
52
  "$type": "dimension",
53
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *12)"
53
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *12)"
54
54
  },
55
55
  "13": {
56
56
  "$type": "dimension",
57
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *13)"
57
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *13)"
58
58
  },
59
59
  "14": {
60
60
  "$type": "dimension",
61
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *14)"
61
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *14)"
62
62
  },
63
63
  "15": {
64
64
  "$type": "dimension",
65
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *15)"
65
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *15)"
66
66
  },
67
67
  "18": {
68
68
  "$type": "dimension",
69
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *18)"
69
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *18)"
70
70
  },
71
71
  "22": {
72
72
  "$type": "dimension",
73
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *22)"
73
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *22)"
74
74
  },
75
75
  "26": {
76
76
  "$type": "dimension",
77
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *26)"
77
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *26)"
78
78
  },
79
79
  "30": {
80
80
  "$type": "dimension",
81
- "$value": "floor({size.step} / {size.base} * {size.mode-font-size} *30)"
81
+ "$value": "floor({_size.step} / {_size.base} * {_size.mode-font-size} *30)"
82
82
  },
83
83
  "mode-font-size": {
84
84
  "$type": "dimension",