@primer/primitives 9.1.2 → 10.0.0-rc.367a0502

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 (219) hide show
  1. package/package.json +9 -8
  2. package/dist/build/PrimerStyleDictionary.d.ts +0 -9
  3. package/dist/build/PrimerStyleDictionary.js +0 -92
  4. package/dist/build/filters/index.d.ts +0 -13
  5. package/dist/build/filters/index.js +0 -29
  6. package/dist/build/filters/isBorder.d.ts +0 -7
  7. package/dist/build/filters/isBorder.js +0 -12
  8. package/dist/build/filters/isColor.d.ts +0 -7
  9. package/dist/build/filters/isColor.js +0 -12
  10. package/dist/build/filters/isColorWithAlpha.d.ts +0 -7
  11. package/dist/build/filters/isColorWithAlpha.js +0 -13
  12. package/dist/build/filters/isColorWithMix.d.ts +0 -7
  13. package/dist/build/filters/isColorWithMix.js +0 -28
  14. package/dist/build/filters/isDeprecated.d.ts +0 -7
  15. package/dist/build/filters/isDeprecated.js +0 -12
  16. package/dist/build/filters/isDimension.d.ts +0 -7
  17. package/dist/build/filters/isDimension.js +0 -12
  18. package/dist/build/filters/isDuration.d.ts +0 -7
  19. package/dist/build/filters/isDuration.js +0 -12
  20. package/dist/build/filters/isFontFamily.d.ts +0 -7
  21. package/dist/build/filters/isFontFamily.js +0 -12
  22. package/dist/build/filters/isFontWeight.d.ts +0 -7
  23. package/dist/build/filters/isFontWeight.js +0 -12
  24. package/dist/build/filters/isFromFile.d.ts +0 -8
  25. package/dist/build/filters/isFromFile.js +0 -14
  26. package/dist/build/filters/isNumber.d.ts +0 -7
  27. package/dist/build/filters/isNumber.js +0 -10
  28. package/dist/build/filters/isShadow.d.ts +0 -7
  29. package/dist/build/filters/isShadow.js +0 -12
  30. package/dist/build/filters/isSource.d.ts +0 -7
  31. package/dist/build/filters/isSource.js +0 -12
  32. package/dist/build/filters/isTypography.d.ts +0 -7
  33. package/dist/build/filters/isTypography.js +0 -12
  34. package/dist/build/formats/cssAdvanced.d.ts +0 -2
  35. package/dist/build/formats/cssAdvanced.js +0 -84
  36. package/dist/build/formats/cssCustomMedia.d.ts +0 -7
  37. package/dist/build/formats/cssCustomMedia.js +0 -25
  38. package/dist/build/formats/index.d.ts +0 -9
  39. package/dist/build/formats/index.js +0 -21
  40. package/dist/build/formats/javascriptCommonJs.d.ts +0 -7
  41. package/dist/build/formats/javascriptCommonJs.js +0 -25
  42. package/dist/build/formats/javascriptEsm.d.ts +0 -7
  43. package/dist/build/formats/javascriptEsm.js +0 -25
  44. package/dist/build/formats/jsonFigma.d.ts +0 -7
  45. package/dist/build/formats/jsonFigma.js +0 -116
  46. package/dist/build/formats/jsonNestedPrefixed.d.ts +0 -8
  47. package/dist/build/formats/jsonNestedPrefixed.js +0 -28
  48. package/dist/build/formats/jsonOneDimensional.d.ts +0 -8
  49. package/dist/build/formats/jsonOneDimensional.js +0 -24
  50. package/dist/build/formats/jsonPostCssFallback.d.ts +0 -8
  51. package/dist/build/formats/jsonPostCssFallback.js +0 -21
  52. package/dist/build/formats/typescriptExportDefinition.d.ts +0 -7
  53. package/dist/build/formats/typescriptExportDefinition.js +0 -166
  54. package/dist/build/formats/utilities/jsonToFlat.d.ts +0 -11
  55. package/dist/build/formats/utilities/jsonToFlat.js +0 -12
  56. package/dist/build/formats/utilities/jsonToNestedValue.d.ts +0 -8
  57. package/dist/build/formats/utilities/jsonToNestedValue.js +0 -25
  58. package/dist/build/formats/utilities/prefixTokens.d.ts +0 -8
  59. package/dist/build/formats/utilities/prefixTokens.js +0 -17
  60. package/dist/build/parsers/index.d.ts +0 -1
  61. package/dist/build/parsers/index.js +0 -5
  62. package/dist/build/parsers/w3cJsonParser.d.ts +0 -6
  63. package/dist/build/parsers/w3cJsonParser.js +0 -27
  64. package/dist/build/platforms/css.d.ts +0 -2
  65. package/dist/build/platforms/css.js +0 -87
  66. package/dist/build/platforms/deprecatedJson.d.ts +0 -2
  67. package/dist/build/platforms/deprecatedJson.js +0 -17
  68. package/dist/build/platforms/docJson.d.ts +0 -2
  69. package/dist/build/platforms/docJson.js +0 -34
  70. package/dist/build/platforms/fallbacks.d.ts +0 -2
  71. package/dist/build/platforms/fallbacks.js +0 -34
  72. package/dist/build/platforms/figma.d.ts +0 -2
  73. package/dist/build/platforms/figma.js +0 -53
  74. package/dist/build/platforms/index.d.ts +0 -10
  75. package/dist/build/platforms/index.js +0 -23
  76. package/dist/build/platforms/javascript.d.ts +0 -2
  77. package/dist/build/platforms/javascript.js +0 -30
  78. package/dist/build/platforms/json.d.ts +0 -2
  79. package/dist/build/platforms/json.js +0 -32
  80. package/dist/build/platforms/styleLint.d.ts +0 -2
  81. package/dist/build/platforms/styleLint.js +0 -34
  82. package/dist/build/platforms/typeDefinitions.d.ts +0 -2
  83. package/dist/build/platforms/typeDefinitions.js +0 -30
  84. package/dist/build/platforms/typescript.d.ts +0 -2
  85. package/dist/build/platforms/typescript.js +0 -30
  86. package/dist/build/schemas/alphaValue.d.ts +0 -2
  87. package/dist/build/schemas/alphaValue.js +0 -8
  88. package/dist/build/schemas/baseToken.d.ts +0 -11
  89. package/dist/build/schemas/baseToken.js +0 -10
  90. package/dist/build/schemas/borderToken.d.ts +0 -51
  91. package/dist/build/schemas/borderToken.js +0 -20
  92. package/dist/build/schemas/collections.d.ts +0 -6
  93. package/dist/build/schemas/collections.js +0 -18
  94. package/dist/build/schemas/colorHexValue.d.ts +0 -2
  95. package/dist/build/schemas/colorHexValue.js +0 -12
  96. package/dist/build/schemas/colorToken.d.ts +0 -80
  97. package/dist/build/schemas/colorToken.js +0 -52
  98. package/dist/build/schemas/designToken.d.ts +0 -2
  99. package/dist/build/schemas/designToken.js +0 -37
  100. package/dist/build/schemas/dimensionToken.d.ts +0 -52
  101. package/dist/build/schemas/dimensionToken.js +0 -36
  102. package/dist/build/schemas/dimensionValue.d.ts +0 -2
  103. package/dist/build/schemas/dimensionValue.js +0 -12
  104. package/dist/build/schemas/durationToken.d.ts +0 -18
  105. package/dist/build/schemas/durationToken.js +0 -14
  106. package/dist/build/schemas/durationValue.d.ts +0 -2
  107. package/dist/build/schemas/durationValue.js +0 -8
  108. package/dist/build/schemas/fontFamilyToken.d.ts +0 -52
  109. package/dist/build/schemas/fontFamilyToken.js +0 -23
  110. package/dist/build/schemas/fontWeightToken.d.ts +0 -52
  111. package/dist/build/schemas/fontWeightToken.js +0 -24
  112. package/dist/build/schemas/fontWeightValue.d.ts +0 -2
  113. package/dist/build/schemas/fontWeightValue.js +0 -9
  114. package/dist/build/schemas/numberToken.d.ts +0 -71
  115. package/dist/build/schemas/numberToken.js +0 -30
  116. package/dist/build/schemas/referenceValue.d.ts +0 -2
  117. package/dist/build/schemas/referenceValue.js +0 -8
  118. package/dist/build/schemas/scopes.d.ts +0 -5
  119. package/dist/build/schemas/scopes.js +0 -34
  120. package/dist/build/schemas/shadowToken.d.ts +0 -157
  121. package/dist/build/schemas/shadowToken.js +0 -46
  122. package/dist/build/schemas/stringToken.d.ts +0 -18
  123. package/dist/build/schemas/stringToken.js +0 -13
  124. package/dist/build/schemas/tokenName.d.ts +0 -2
  125. package/dist/build/schemas/tokenName.js +0 -8
  126. package/dist/build/schemas/tokenType.d.ts +0 -3
  127. package/dist/build/schemas/tokenType.js +0 -6
  128. package/dist/build/schemas/typographyToken.d.ts +0 -59
  129. package/dist/build/schemas/typographyToken.js +0 -21
  130. package/dist/build/schemas/validTokenType.d.ts +0 -5
  131. package/dist/build/schemas/validTokenType.js +0 -34
  132. package/dist/build/schemas/viewportRangeToken.d.ts +0 -18
  133. package/dist/build/schemas/viewportRangeToken.js +0 -13
  134. package/dist/build/transformers/borderToCss.d.ts +0 -8
  135. package/dist/build/transformers/borderToCss.js +0 -38
  136. package/dist/build/transformers/colorToHex.d.ts +0 -8
  137. package/dist/build/transformers/colorToHex.js +0 -26
  138. package/dist/build/transformers/colorToHexMix.d.ts +0 -8
  139. package/dist/build/transformers/colorToHexMix.js +0 -25
  140. package/dist/build/transformers/colorToRgbAlpha.d.ts +0 -8
  141. package/dist/build/transformers/colorToRgbAlpha.js +0 -22
  142. package/dist/build/transformers/colorToRgbaFloat.d.ts +0 -8
  143. package/dist/build/transformers/colorToRgbaFloat.js +0 -50
  144. package/dist/build/transformers/dimensionToPixelUnitless.d.ts +0 -8
  145. package/dist/build/transformers/dimensionToPixelUnitless.js +0 -50
  146. package/dist/build/transformers/dimensionToRem.d.ts +0 -8
  147. package/dist/build/transformers/dimensionToRem.js +0 -47
  148. package/dist/build/transformers/dimensionToRemPxArray.d.ts +0 -8
  149. package/dist/build/transformers/dimensionToRemPxArray.js +0 -47
  150. package/dist/build/transformers/durationToCss.d.ts +0 -8
  151. package/dist/build/transformers/durationToCss.js +0 -30
  152. package/dist/build/transformers/figmaAttributes.d.ts +0 -8
  153. package/dist/build/transformers/figmaAttributes.js +0 -57
  154. package/dist/build/transformers/floatToPixel.d.ts +0 -15
  155. package/dist/build/transformers/floatToPixel.js +0 -41
  156. package/dist/build/transformers/fontFamilyToCss.d.ts +0 -14
  157. package/dist/build/transformers/fontFamilyToCss.js +0 -40
  158. package/dist/build/transformers/fontFamilyToFigma.d.ts +0 -14
  159. package/dist/build/transformers/fontFamilyToFigma.js +0 -46
  160. package/dist/build/transformers/fontWeightToNumber.d.ts +0 -9
  161. package/dist/build/transformers/fontWeightToNumber.js +0 -53
  162. package/dist/build/transformers/index.d.ts +0 -24
  163. package/dist/build/transformers/index.js +0 -51
  164. package/dist/build/transformers/jsonDeprecated.d.ts +0 -8
  165. package/dist/build/transformers/jsonDeprecated.js +0 -16
  166. package/dist/build/transformers/namePathToCamelCase.d.ts +0 -8
  167. package/dist/build/transformers/namePathToCamelCase.js +0 -14
  168. package/dist/build/transformers/namePathToDotNotation.d.ts +0 -8
  169. package/dist/build/transformers/namePathToDotNotation.js +0 -33
  170. package/dist/build/transformers/namePathToFigma.d.ts +0 -9
  171. package/dist/build/transformers/namePathToFigma.js +0 -24
  172. package/dist/build/transformers/namePathToKebabCase.d.ts +0 -8
  173. package/dist/build/transformers/namePathToKebabCase.js +0 -18
  174. package/dist/build/transformers/namePathToPascalCase.d.ts +0 -8
  175. package/dist/build/transformers/namePathToPascalCase.js +0 -14
  176. package/dist/build/transformers/namePathToSlashNotation.d.ts +0 -8
  177. package/dist/build/transformers/namePathToSlashNotation.js +0 -18
  178. package/dist/build/transformers/shadowToCss.d.ts +0 -8
  179. package/dist/build/transformers/shadowToCss.js +0 -35
  180. package/dist/build/transformers/typographyToCss.d.ts +0 -8
  181. package/dist/build/transformers/typographyToCss.js +0 -29
  182. package/dist/build/transformers/utilities/alpha.d.ts +0 -9
  183. package/dist/build/transformers/utilities/alpha.js +0 -20
  184. package/dist/build/transformers/utilities/checkRequiredTokenProperties.d.ts +0 -7
  185. package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +0 -17
  186. package/dist/build/transformers/utilities/getTokenValue.d.ts +0 -2
  187. package/dist/build/transformers/utilities/getTokenValue.js +0 -18
  188. package/dist/build/transformers/utilities/hasSpaceInString.d.ts +0 -1
  189. package/dist/build/transformers/utilities/hasSpaceInString.js +0 -10
  190. package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +0 -2
  191. package/dist/build/transformers/utilities/hexToRgbaFloat.js +0 -33
  192. package/dist/build/transformers/utilities/invalidTokenError.d.ts +0 -7
  193. package/dist/build/transformers/utilities/invalidTokenError.js +0 -26
  194. package/dist/build/transformers/utilities/isRgbaFloat.d.ts +0 -7
  195. package/dist/build/transformers/utilities/isRgbaFloat.js +0 -24
  196. package/dist/build/transformers/utilities/mix.d.ts +0 -5
  197. package/dist/build/transformers/utilities/mix.js +0 -40
  198. package/dist/build/transformers/utilities/rgbaFloatToHex.d.ts +0 -6
  199. package/dist/build/transformers/utilities/rgbaFloatToHex.js +0 -15
  200. package/dist/build/utilities/copyFromDir.d.ts +0 -8
  201. package/dist/build/utilities/copyFromDir.js +0 -34
  202. package/dist/build/utilities/filterStringArray.d.ts +0 -1
  203. package/dist/build/utilities/filterStringArray.js +0 -17
  204. package/dist/build/utilities/getFlag.d.ts +0 -8
  205. package/dist/build/utilities/getFlag.js +0 -16
  206. package/dist/build/utilities/index.d.ts +0 -3
  207. package/dist/build/utilities/index.js +0 -9
  208. package/dist/build/utilities/joinFriendly.d.ts +0 -1
  209. package/dist/build/utilities/joinFriendly.js +0 -5
  210. package/dist/build/utilities/schemaErrorMessage.d.ts +0 -1
  211. package/dist/build/utilities/schemaErrorMessage.js +0 -5
  212. package/dist/build/utilities/toCamelCase.d.ts +0 -1
  213. package/dist/build/utilities/toCamelCase.js +0 -20
  214. package/dist/build/utilities/toPascalCase.d.ts +0 -1
  215. package/dist/build/utilities/toPascalCase.js +0 -17
  216. package/dist/build/utilities/treeWalker.d.ts +0 -8
  217. package/dist/build/utilities/treeWalker.js +0 -27
  218. package/dist/build/utilities/upperCaseFirstCharacter.d.ts +0 -8
  219. package/dist/build/utilities/upperCaseFirstCharacter.js +0 -14
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@primer/primitives",
3
- "version": "9.1.2",
3
+ "version": "10.0.0-rc.367a0502",
4
4
  "description": "Typography, spacing, and color primitives for Primer design system",
5
+ "type": "module",
5
6
  "files": [
6
7
  "dist",
7
8
  "src/tokens"
@@ -22,11 +23,11 @@
22
23
  },
23
24
  "homepage": "https://github.com/primer/primitives#readme",
24
25
  "scripts": {
25
- "build": "npm run build:tokens && npm run build:fallbacks && npm run build:figma && npm run build:config",
26
+ "build": "npm run clean && npm run build:tokens && npm run build:fallbacks && npm run build:figma",
26
27
  "build:tokens": "tsx ./scripts/buildTokens.ts",
27
28
  "build:fallbacks": "tsx ./scripts/buildFallbacks.ts",
28
29
  "build:figma": "tsx scripts/buildFigma.ts",
29
- "build:config": "tsc -p buildConfig.tsconfig.jsonc",
30
+ "clean": "rm -rf dist",
30
31
  "tokenJson:check": "tsx scripts/diffThemes.ts && tsx scripts/diffTokenProps.ts",
31
32
  "contrast:check": "tsx scripts/color-contrast.ts",
32
33
  "format": "prettier --write '**/*.{js,jsx,ts,tsx,md,mdx,css}'",
@@ -53,11 +54,11 @@
53
54
  "@changesets/changelog-github": "^0.5.0",
54
55
  "@changesets/cli": "^2.27.7",
55
56
  "@github/prettier-config": "^0.0.6",
56
- "@playwright/test": "^1.45.1",
57
- "@types/node": "^20.14.9",
57
+ "@playwright/test": "^1.47.1",
58
+ "@types/node": "^20.14.11",
58
59
  "@typescript-eslint/eslint-plugin": "^7.15.0",
59
60
  "@typescript-eslint/parser": "^7.15.0",
60
- "@vitest/coverage-v8": "^2.0.1",
61
+ "@vitest/coverage-v8": "^2.0.3",
61
62
  "color-blend": "^4.0.0",
62
63
  "color2k": "^2.0.3",
63
64
  "console-table-printer": "^2.12.1",
@@ -74,9 +75,9 @@
74
75
  "json5": "^2.2.1",
75
76
  "markdown-table-ts": "^1.0.3",
76
77
  "style-dictionary": "^3.9.2",
77
- "tsx": "^4.16.2",
78
+ "tsx": "^4.19.0",
78
79
  "typescript": "5.5",
79
- "vitest": "^2.0.1",
80
+ "vitest": "^2.0.3",
80
81
  "zod": "3.23",
81
82
  "zod-validation-error": "3.3"
82
83
  }
@@ -1,9 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
- /**
3
- * @name {@link PrimerStyleDictionary}
4
- * @description Returns style dictionary object with primer preset that includes parsers, formats and transformers
5
- * @parsers [w3cJsonParser](https://github.com/primer/primitives/blob/main/config//parsers/w3c-json-parser.ts)
6
- * @formats [javascript/esm](https://github.com/primer/primitives/blob/main/config/formats/javascript-esm.ts), [javascript/commonJs](https://github.com/primer/primitives/blob/main/config/formats/javascript-commonJs.ts), [typescript/export-definition](https://github.com/primer/primitives/blob/main/config/formats/typescript-export-defition.ts)
7
- * @transformers [color/rgbAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-rgb-alpha.ts), [color/hexAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex-alpha.ts), [color/hex](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex6.ts), [json/deprecated](https://github.com/primer/primitives/blob/main/config/tranformers/json-deprecated.ts), [name/pathToDotNotation](https://github.com/primer/primitives/blob/main/config/tranformers/name-path-to-dot-notation.ts)
8
- */
9
- export declare const PrimerStyleDictionary: StyleDictionary.Core;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PrimerStyleDictionary = void 0;
7
- const style_dictionary_1 = __importDefault(require("style-dictionary"));
8
- const parsers_1 = require("./parsers");
9
- const transformers_1 = require("./transformers");
10
- const formats_1 = require("./formats");
11
- /**
12
- * Parsers
13
- *
14
- */
15
- style_dictionary_1.default.registerParser(parsers_1.w3cJsonParser);
16
- /**
17
- * Formats
18
- *
19
- */
20
- style_dictionary_1.default.registerFormat({
21
- name: 'css/advanced',
22
- formatter: formats_1.cssAdvanced,
23
- });
24
- style_dictionary_1.default.registerFormat({
25
- name: 'css/customMedia',
26
- formatter: formats_1.cssCustomMedia,
27
- });
28
- style_dictionary_1.default.registerFormat({
29
- name: 'javascript/esm',
30
- formatter: formats_1.javascriptEsm,
31
- });
32
- style_dictionary_1.default.registerFormat({
33
- name: 'javascript/commonJs',
34
- formatter: formats_1.javascriptCommonJs,
35
- });
36
- style_dictionary_1.default.registerFormat({
37
- name: 'typescript/export-definition',
38
- formatter: formats_1.typescriptExportDefinition,
39
- });
40
- style_dictionary_1.default.registerFormat({
41
- name: 'json/nested-prefixed',
42
- formatter: formats_1.jsonNestedPrefixed,
43
- });
44
- style_dictionary_1.default.registerFormat({
45
- name: 'json/one-dimensional',
46
- formatter: formats_1.jsonOneDimensional,
47
- });
48
- style_dictionary_1.default.registerFormat({
49
- name: 'json/postCss-fallback',
50
- formatter: formats_1.jsonPostCssFallback,
51
- });
52
- style_dictionary_1.default.registerFormat({
53
- name: 'json/figma',
54
- formatter: formats_1.jsonFigma,
55
- });
56
- /**
57
- * Transformers
58
- *
59
- */
60
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'color/rgbAlpha' }, transformers_1.colorToRgbAlpha));
61
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'color/rgbaFloat' }, transformers_1.colorToRgbaFloat));
62
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'color/hexMix' }, transformers_1.colorToHexMix));
63
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'color/hex' }, transformers_1.colorToHex));
64
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'float/pixel' }, transformers_1.floatToPixel));
65
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'float/pixelUnitless' }, transformers_1.floatToPixelUnitless));
66
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'dimension/rem' }, transformers_1.dimensionToRem));
67
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'dimension/remPxArray' }, transformers_1.dimensionToRemPxArray));
68
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'dimension/pixelUnitless' }, transformers_1.dimensionToPixelUnitless));
69
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'duration/css' }, transformers_1.durationToCss));
70
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'figma/attributes' }, transformers_1.figmaAttributes));
71
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'json/deprecated' }, transformers_1.jsonDeprecated));
72
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'name/pathToCamelCase' }, transformers_1.namePathToCamelCase));
73
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'name/pathToPascalCase' }, transformers_1.namePathToPascalCase));
74
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'name/pathToDotNotation' }, transformers_1.namePathToDotNotation));
75
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'name/pathToFigma' }, transformers_1.namePathToFigma));
76
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'name/pathToCamelCase' }, transformers_1.namePathToCamelCase));
77
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'name/pathToKebabCase' }, transformers_1.namePathToKebabCase));
78
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'name/pathToSlashNotation' }, transformers_1.namePathToSlashNotation));
79
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'shadow/css' }, transformers_1.shadowToCss));
80
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'border/css' }, transformers_1.borderToCss));
81
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'typography/css' }, transformers_1.typographyToCss));
82
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'fontWeight/number' }, transformers_1.fontWeightToNumber));
83
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'fontFamily/css' }, transformers_1.fontFamilyToCss));
84
- style_dictionary_1.default.registerTransform(Object.assign({ name: 'fontFamily/figma' }, transformers_1.fontFamilyToFigma));
85
- /**
86
- * @name {@link PrimerStyleDictionary}
87
- * @description Returns style dictionary object with primer preset that includes parsers, formats and transformers
88
- * @parsers [w3cJsonParser](https://github.com/primer/primitives/blob/main/config//parsers/w3c-json-parser.ts)
89
- * @formats [javascript/esm](https://github.com/primer/primitives/blob/main/config/formats/javascript-esm.ts), [javascript/commonJs](https://github.com/primer/primitives/blob/main/config/formats/javascript-commonJs.ts), [typescript/export-definition](https://github.com/primer/primitives/blob/main/config/formats/typescript-export-defition.ts)
90
- * @transformers [color/rgbAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-rgb-alpha.ts), [color/hexAlpha](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex-alpha.ts), [color/hex](https://github.com/primer/primitives/blob/main/config/tranformers/color-to-hex6.ts), [json/deprecated](https://github.com/primer/primitives/blob/main/config/tranformers/json-deprecated.ts), [name/pathToDotNotation](https://github.com/primer/primitives/blob/main/config/tranformers/name-path-to-dot-notation.ts)
91
- */
92
- exports.PrimerStyleDictionary = style_dictionary_1.default;
@@ -1,13 +0,0 @@
1
- export { isBorder } from './isBorder';
2
- export { isColor } from './isColor';
3
- export { isColorWithAlpha } from './isColorWithAlpha';
4
- export { isColorWithMix } from './isColorWithMix';
5
- export { isDimension } from './isDimension';
6
- export { isDeprecated } from './isDeprecated';
7
- export { isFromFile } from './isFromFile';
8
- export { isFontFamily } from './isFontFamily';
9
- export { isFontWeight } from './isFontWeight';
10
- export { isNumber } from './isNumber';
11
- export { isShadow } from './isShadow';
12
- export { isSource } from './isSource';
13
- export { isTypography } from './isTypography';
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTypography = exports.isSource = exports.isShadow = exports.isNumber = exports.isFontWeight = exports.isFontFamily = exports.isFromFile = exports.isDeprecated = exports.isDimension = exports.isColorWithMix = exports.isColorWithAlpha = exports.isColor = exports.isBorder = void 0;
4
- var isBorder_1 = require("./isBorder");
5
- Object.defineProperty(exports, "isBorder", { enumerable: true, get: function () { return isBorder_1.isBorder; } });
6
- var isColor_1 = require("./isColor");
7
- Object.defineProperty(exports, "isColor", { enumerable: true, get: function () { return isColor_1.isColor; } });
8
- var isColorWithAlpha_1 = require("./isColorWithAlpha");
9
- Object.defineProperty(exports, "isColorWithAlpha", { enumerable: true, get: function () { return isColorWithAlpha_1.isColorWithAlpha; } });
10
- var isColorWithMix_1 = require("./isColorWithMix");
11
- Object.defineProperty(exports, "isColorWithMix", { enumerable: true, get: function () { return isColorWithMix_1.isColorWithMix; } });
12
- var isDimension_1 = require("./isDimension");
13
- Object.defineProperty(exports, "isDimension", { enumerable: true, get: function () { return isDimension_1.isDimension; } });
14
- var isDeprecated_1 = require("./isDeprecated");
15
- Object.defineProperty(exports, "isDeprecated", { enumerable: true, get: function () { return isDeprecated_1.isDeprecated; } });
16
- var isFromFile_1 = require("./isFromFile");
17
- Object.defineProperty(exports, "isFromFile", { enumerable: true, get: function () { return isFromFile_1.isFromFile; } });
18
- var isFontFamily_1 = require("./isFontFamily");
19
- Object.defineProperty(exports, "isFontFamily", { enumerable: true, get: function () { return isFontFamily_1.isFontFamily; } });
20
- var isFontWeight_1 = require("./isFontWeight");
21
- Object.defineProperty(exports, "isFontWeight", { enumerable: true, get: function () { return isFontWeight_1.isFontWeight; } });
22
- var isNumber_1 = require("./isNumber");
23
- Object.defineProperty(exports, "isNumber", { enumerable: true, get: function () { return isNumber_1.isNumber; } });
24
- var isShadow_1 = require("./isShadow");
25
- Object.defineProperty(exports, "isShadow", { enumerable: true, get: function () { return isShadow_1.isShadow; } });
26
- var isSource_1 = require("./isSource");
27
- Object.defineProperty(exports, "isSource", { enumerable: true, get: function () { return isSource_1.isSource; } });
28
- var isTypography_1 = require("./isTypography");
29
- Object.defineProperty(exports, "isTypography", { enumerable: true, get: function () { return isTypography_1.isTypography; } });
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `border`
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isBorder: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBorder = void 0;
4
- /**
5
- * @description Checks if token is of $type `border`
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isBorder = (token) => {
10
- return token.$type === 'border';
11
- };
12
- exports.isBorder = isBorder;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `color`
4
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isColor: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isColor = void 0;
4
- /**
5
- * @description Checks if token is of $type `color`
6
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isColor = (token) => {
10
- return token.$type === 'color';
11
- };
12
- exports.isColor = isColor;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is color with an alpha value
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isColorWithAlpha: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isColorWithAlpha = void 0;
4
- const isColor_1 = require("./isColor");
5
- /**
6
- * @description Checks if token is color with an alpha value
7
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
8
- * @returns boolean
9
- */
10
- const isColorWithAlpha = (token) => {
11
- return (0, isColor_1.isColor)(token) && token.alpha !== undefined && typeof token.alpha === 'number';
12
- };
13
- exports.isColorWithAlpha = isColorWithAlpha;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is color and has a mix property
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isColorWithMix: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isColorWithMix = void 0;
4
- const isColor_1 = require("./isColor");
5
- const throwError = (token) => {
6
- throw new Error(`Invalid mix property on token: ${token.name}. "mix.color": ${token.mix.color}, "mix.weight": ${typeof token.mix.weight === 'string' ? `"${token.mix.weight}" (string)` : token.mix.weight} must be a number between 0 and 1. In file: "${token.filePath}".`);
7
- };
8
- /**
9
- * @description Checks if token is color and has a mix property
10
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
11
- * @returns boolean
12
- */
13
- const isColorWithMix = (token) => {
14
- // no color or no mix property
15
- if (!(0, isColor_1.isColor)(token) || token.mix === undefined || token.mix === null) {
16
- return false;
17
- }
18
- // invalid mix property
19
- if (typeof token.mix.color !== 'string' ||
20
- typeof token.mix.weight !== 'number' ||
21
- token.mix.weight < 0 ||
22
- token.mix.weight > 1) {
23
- throwError(token);
24
- }
25
- // valid mix property
26
- return true;
27
- };
28
- exports.isColorWithMix = isColorWithMix;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token has a valid `deprecated` property
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isDeprecated: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDeprecated = void 0;
4
- /**
5
- * @description Checks if token has a valid `deprecated` property
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isDeprecated = (token) => {
10
- return token.deprecated === true || typeof token.deprecated === 'string';
11
- };
12
- exports.isDeprecated = isDeprecated;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `dimension`
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isDimension: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDimension = void 0;
4
- /**
5
- * @description Checks if token is of $type `dimension`
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isDimension = (token) => {
10
- return token.$type === 'dimension';
11
- };
12
- exports.isDimension = isDimension;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `duration`
4
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isDuration: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDuration = void 0;
4
- /**
5
- * @description Checks if token is of $type `duration`
6
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isDuration = (token) => {
10
- return token.$type === 'duration';
11
- };
12
- exports.isDuration = isDuration;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `isFontFamily`
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isFontFamily: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFontFamily = void 0;
4
- /**
5
- * @description Checks if token is of $type `isFontFamily`
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isFontFamily = (token) => {
10
- return token.$type === 'fontFamily';
11
- };
12
- exports.isFontFamily = isFontFamily;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `fontWeight`
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isFontWeight: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFontWeight = void 0;
4
- /**
5
- * @description Checks if token is of $type `fontWeight`
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isFontWeight = (token) => {
10
- return token.$type === 'fontWeight';
11
- };
12
- exports.isFontWeight = isFontWeight;
@@ -1,8 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token comes from a specific file
4
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @param files - array of file paths
6
- * @returns boolean
7
- */
8
- export declare const isFromFile: (token: StyleDictionary.TransformedToken, files: string[]) => boolean;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isFromFile = void 0;
4
- /**
5
- * @description Checks if token comes from a specific file
6
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @param files - array of file paths
8
- * @returns boolean
9
- */
10
- const isFromFile = (token, files) => {
11
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
12
- return (files === null || files === void 0 ? void 0 : files.includes(token.filePath)) === true;
13
- };
14
- exports.isFromFile = isFromFile;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token type is a number
4
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isNumber: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNumber = void 0;
4
- /**
5
- * @description Checks if token type is a number
6
- * @param token [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isNumber = (token) => token.$type === 'number';
10
- exports.isNumber = isNumber;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `shadow`
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isShadow: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isShadow = void 0;
4
- /**
5
- * @description Checks if token is of $type `shadow`
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isShadow = (token) => {
10
- return token.$type === 'shadow';
11
- };
12
- exports.isShadow = isShadow;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is source token
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isSource: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSource = void 0;
4
- /**
5
- * @description Checks if token is source token
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isSource = (token) => {
10
- return token.isSource === true;
11
- };
12
- exports.isSource = isSource;
@@ -1,7 +0,0 @@
1
- import type StyleDictionary from 'style-dictionary';
2
- /**
3
- * @description Checks if token is of $type `typography`
4
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
5
- * @returns boolean
6
- */
7
- export declare const isTypography: (token: StyleDictionary.TransformedToken) => boolean;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTypography = void 0;
4
- /**
5
- * @description Checks if token is of $type `typography`
6
- * @param arguments [StyleDictionary.TransformedToken](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts)
7
- * @returns boolean
8
- */
9
- const isTypography = (token) => {
10
- return token.$type === 'typography';
11
- };
12
- exports.isTypography = isTypography;
@@ -1,2 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
- export declare const cssAdvanced: StyleDictionary.Formatter;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cssAdvanced = void 0;
7
- const style_dictionary_1 = __importDefault(require("style-dictionary"));
8
- const sync_1 = __importDefault(require("@prettier/sync"));
9
- const { fileHeader, formattedVariables } = style_dictionary_1.default.formatHelpers;
10
- const wrapWithSelector = (css, selector) => {
11
- // return without selector
12
- if (selector === false || selector.trim().length === 0)
13
- return css;
14
- // return with selector
15
- return `${selector} { ${css} }`;
16
- };
17
- const cssAdvanced = ({ dictionary: originalDictionary, options = {
18
- queries: [],
19
- }, file, }) => {
20
- var _a, _b, _c, _d;
21
- // get options
22
- const { outputReferences, formatting } = options;
23
- // selector
24
- const selector = ((_a = file.options) === null || _a === void 0 ? void 0 : _a.selector) !== undefined ? file.options.selector : ':root';
25
- // query extension property
26
- const queryExtProp = ((_b = file.options) === null || _b === void 0 ? void 0 : _b.queryExtensionProperty) || 'mediaQuery';
27
- // get queries from file options
28
- const queries = ((_c = file.options) === null || _c === void 0 ? void 0 : _c.queries) || [
29
- {
30
- query: undefined,
31
- matcher: () => true,
32
- },
33
- ];
34
- // set formatting
35
- const mergedFormatting = Object.assign({ commentStyle: 'long' }, formatting);
36
- // clone dictionary
37
- const dictionary = Object.assign({}, originalDictionary);
38
- // get queries from tokens
39
- for (const designToken of dictionary.allTokens) {
40
- const query = (_d = designToken.$extensions) === null || _d === void 0 ? void 0 : _d[queryExtProp];
41
- // early abort if query does not exist on token
42
- if (!query)
43
- continue;
44
- // if query exists already from other token
45
- const currentQueryIndex = queries.findIndex((q) => q.query === query);
46
- // if query exists
47
- if (currentQueryIndex > -1) {
48
- queries[currentQueryIndex] = Object.assign(Object.assign({}, queries[currentQueryIndex]), { matcher: (token) => queries[currentQueryIndex].matcher(token) ||
49
- token.$extensions[queryExtProp] === queries[currentQueryIndex].query });
50
- }
51
- // if query does not exist
52
- else {
53
- queries.push({
54
- query,
55
- matcher: (token) => { var _a; return ((_a = token.$extensions) === null || _a === void 0 ? void 0 : _a[queryExtProp]) === query; },
56
- });
57
- }
58
- }
59
- // add file header
60
- const output = [fileHeader({ file })];
61
- // add single theme css
62
- for (const query of queries) {
63
- const { query: queryString, matcher } = query;
64
- // filter tokens to only include the ones that pass the matcher
65
- const filteredDictionary = Object.assign(Object.assign({}, dictionary), { allTokens: dictionary.allTokens.filter(matcher || (() => true)) });
66
- // early abort if no matches
67
- if (!filteredDictionary.allTokens.length)
68
- continue;
69
- // add tokens into root
70
- const css = formattedVariables({
71
- format: 'css',
72
- dictionary: filteredDictionary,
73
- outputReferences,
74
- formatting: mergedFormatting,
75
- });
76
- // wrap css
77
- const cssWithSelector = wrapWithSelector(css, query.selector !== undefined ? query.selector : selector);
78
- // add css with or without query
79
- output.push(queryString ? `${queryString} { ${cssWithSelector} }` : cssWithSelector);
80
- }
81
- // return prettified
82
- return sync_1.default.format(output.join('\n'), { parser: 'css', printWidth: 500 });
83
- };
84
- exports.cssAdvanced = cssAdvanced;