@primer/primitives 10.0.0-rc.367a0502 → 10.0.0-rc.4b3d8b21

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 (338) hide show
  1. package/dist/build/PrimerStyleDictionary.d.ts +8 -0
  2. package/dist/build/PrimerStyleDictionary.js +80 -0
  3. package/dist/build/filters/index.d.ts +14 -0
  4. package/dist/build/filters/index.js +14 -0
  5. package/dist/build/filters/isBorder.d.ts +7 -0
  6. package/dist/build/filters/isBorder.js +8 -0
  7. package/dist/build/filters/isColor.d.ts +7 -0
  8. package/dist/build/filters/isColor.js +13 -0
  9. package/dist/build/filters/isColorWithAlpha.d.ts +7 -0
  10. package/dist/build/filters/isColorWithAlpha.js +9 -0
  11. package/dist/build/filters/isColorWithMix.d.ts +7 -0
  12. package/dist/build/filters/isColorWithMix.js +24 -0
  13. package/dist/build/filters/isCubicBezier.d.ts +7 -0
  14. package/dist/build/filters/isCubicBezier.js +10 -0
  15. package/dist/build/filters/isDeprecated.d.ts +7 -0
  16. package/dist/build/filters/isDeprecated.js +8 -0
  17. package/dist/build/filters/isDimension.d.ts +7 -0
  18. package/dist/build/filters/isDimension.js +8 -0
  19. package/dist/build/filters/isDuration.d.ts +7 -0
  20. package/dist/build/filters/isDuration.js +8 -0
  21. package/dist/build/filters/isFontFamily.d.ts +7 -0
  22. package/dist/build/filters/isFontFamily.js +8 -0
  23. package/dist/build/filters/isFontWeight.d.ts +7 -0
  24. package/dist/build/filters/isFontWeight.js +8 -0
  25. package/dist/build/filters/isFromFile.d.ts +8 -0
  26. package/dist/build/filters/isFromFile.js +10 -0
  27. package/dist/build/filters/isNumber.d.ts +7 -0
  28. package/dist/build/filters/isNumber.js +8 -0
  29. package/dist/build/filters/isShadow.d.ts +7 -0
  30. package/dist/build/filters/isShadow.js +8 -0
  31. package/dist/build/filters/isSource.d.ts +7 -0
  32. package/dist/build/filters/isSource.js +8 -0
  33. package/dist/build/filters/isTypography.d.ts +7 -0
  34. package/dist/build/filters/isTypography.js +8 -0
  35. package/dist/build/formats/cssAdvanced.d.ts +2 -0
  36. package/dist/build/formats/cssAdvanced.js +86 -0
  37. package/dist/build/formats/cssCustomMedia.d.ts +7 -0
  38. package/dist/build/formats/cssCustomMedia.js +26 -0
  39. package/dist/build/formats/index.d.ts +9 -0
  40. package/dist/build/formats/index.js +9 -0
  41. package/dist/build/formats/javascriptCommonJs.d.ts +7 -0
  42. package/dist/build/formats/javascriptCommonJs.js +26 -0
  43. package/dist/build/formats/javascriptEsm.d.ts +7 -0
  44. package/dist/build/formats/javascriptEsm.js +26 -0
  45. package/dist/build/formats/jsonFigma.d.ts +7 -0
  46. package/dist/build/formats/jsonFigma.js +121 -0
  47. package/dist/build/formats/jsonNestedPrefixed.d.ts +8 -0
  48. package/dist/build/formats/jsonNestedPrefixed.js +30 -0
  49. package/dist/build/formats/jsonOneDimensional.d.ts +8 -0
  50. package/dist/build/formats/jsonOneDimensional.js +32 -0
  51. package/dist/build/formats/jsonPostCssFallback.d.ts +8 -0
  52. package/dist/build/formats/jsonPostCssFallback.js +14 -0
  53. package/dist/build/formats/typescriptExportDefinition.d.ts +7 -0
  54. package/dist/build/formats/typescriptExportDefinition.js +170 -0
  55. package/dist/build/formats/utilities/getPropName.d.ts +1 -0
  56. package/dist/build/formats/utilities/getPropName.js +16 -0
  57. package/dist/build/formats/utilities/jsonToFlat.d.ts +11 -0
  58. package/dist/build/formats/utilities/jsonToFlat.js +8 -0
  59. package/dist/build/formats/utilities/jsonToNestedValue.d.ts +8 -0
  60. package/dist/build/formats/utilities/jsonToNestedValue.js +23 -0
  61. package/dist/build/formats/utilities/prefixTokens.d.ts +8 -0
  62. package/dist/build/formats/utilities/prefixTokens.js +13 -0
  63. package/dist/build/parsers/index.d.ts +1 -0
  64. package/dist/build/parsers/index.js +1 -0
  65. package/dist/build/parsers/w3cJsonParser.d.ts +6 -0
  66. package/dist/build/parsers/w3cJsonParser.js +25 -0
  67. package/dist/build/platforms/css.d.ts +2 -0
  68. package/dist/build/platforms/css.js +96 -0
  69. package/dist/build/platforms/deprecatedJson.d.ts +2 -0
  70. package/dist/build/platforms/deprecatedJson.js +13 -0
  71. package/dist/build/platforms/docJson.d.ts +2 -0
  72. package/dist/build/platforms/docJson.js +35 -0
  73. package/dist/build/platforms/fallbacks.d.ts +2 -0
  74. package/dist/build/platforms/fallbacks.js +30 -0
  75. package/dist/build/platforms/figma.d.ts +2 -0
  76. package/dist/build/platforms/figma.js +60 -0
  77. package/dist/build/platforms/index.d.ts +10 -0
  78. package/dist/build/platforms/index.js +10 -0
  79. package/dist/build/platforms/javascript.d.ts +2 -0
  80. package/dist/build/platforms/javascript.js +26 -0
  81. package/dist/build/platforms/json.d.ts +2 -0
  82. package/dist/build/platforms/json.js +28 -0
  83. package/dist/build/platforms/styleLint.d.ts +2 -0
  84. package/dist/build/platforms/styleLint.js +30 -0
  85. package/dist/build/platforms/typeDefinitions.d.ts +2 -0
  86. package/dist/build/platforms/typeDefinitions.js +26 -0
  87. package/dist/build/platforms/typescript.d.ts +2 -0
  88. package/dist/build/platforms/typescript.js +26 -0
  89. package/dist/build/schemas/alphaValue.d.ts +2 -0
  90. package/dist/build/schemas/alphaValue.js +5 -0
  91. package/dist/build/schemas/baseToken.d.ts +11 -0
  92. package/dist/build/schemas/baseToken.js +7 -0
  93. package/dist/build/schemas/borderToken.d.ts +51 -0
  94. package/dist/build/schemas/borderToken.js +17 -0
  95. package/dist/build/schemas/collections.d.ts +6 -0
  96. package/dist/build/schemas/collections.js +12 -0
  97. package/dist/build/schemas/colorHexValue.d.ts +2 -0
  98. package/dist/build/schemas/colorHexValue.js +9 -0
  99. package/dist/build/schemas/colorToken.d.ts +85 -0
  100. package/dist/build/schemas/colorToken.js +52 -0
  101. package/dist/build/schemas/cubicBezierToken.d.ts +18 -0
  102. package/dist/build/schemas/cubicBezierToken.js +8 -0
  103. package/dist/build/schemas/designToken.d.ts +2 -0
  104. package/dist/build/schemas/designToken.js +36 -0
  105. package/dist/build/schemas/dimensionToken.d.ts +52 -0
  106. package/dist/build/schemas/dimensionToken.js +33 -0
  107. package/dist/build/schemas/dimensionValue.d.ts +2 -0
  108. package/dist/build/schemas/dimensionValue.js +9 -0
  109. package/dist/build/schemas/durationToken.d.ts +18 -0
  110. package/dist/build/schemas/durationToken.js +11 -0
  111. package/dist/build/schemas/durationValue.d.ts +2 -0
  112. package/dist/build/schemas/durationValue.js +5 -0
  113. package/dist/build/schemas/fontFamilyToken.d.ts +52 -0
  114. package/dist/build/schemas/fontFamilyToken.js +20 -0
  115. package/dist/build/schemas/fontWeightToken.d.ts +52 -0
  116. package/dist/build/schemas/fontWeightToken.js +21 -0
  117. package/dist/build/schemas/fontWeightValue.d.ts +2 -0
  118. package/dist/build/schemas/fontWeightValue.js +6 -0
  119. package/dist/build/schemas/numberToken.d.ts +71 -0
  120. package/dist/build/schemas/numberToken.js +27 -0
  121. package/dist/build/schemas/referenceValue.d.ts +2 -0
  122. package/dist/build/schemas/referenceValue.js +5 -0
  123. package/dist/build/schemas/scopes.d.ts +5 -0
  124. package/dist/build/schemas/scopes.js +29 -0
  125. package/dist/build/schemas/shadowToken.d.ts +157 -0
  126. package/dist/build/schemas/shadowToken.js +43 -0
  127. package/dist/build/schemas/stringToken.d.ts +18 -0
  128. package/dist/build/schemas/stringToken.js +10 -0
  129. package/dist/build/schemas/tokenName.d.ts +2 -0
  130. package/dist/build/schemas/tokenName.js +5 -0
  131. package/dist/build/schemas/tokenType.d.ts +3 -0
  132. package/dist/build/schemas/tokenType.js +2 -0
  133. package/dist/build/schemas/typographyToken.d.ts +59 -0
  134. package/dist/build/schemas/typographyToken.js +18 -0
  135. package/dist/build/schemas/validTokenType.d.ts +5 -0
  136. package/dist/build/schemas/validTokenType.js +31 -0
  137. package/dist/build/schemas/viewportRangeToken.d.ts +18 -0
  138. package/dist/build/schemas/viewportRangeToken.js +10 -0
  139. package/dist/build/transformers/borderToCss.d.ts +8 -0
  140. package/dist/build/transformers/borderToCss.js +38 -0
  141. package/dist/build/transformers/colorToHex.d.ts +8 -0
  142. package/dist/build/transformers/colorToHex.js +24 -0
  143. package/dist/build/transformers/colorToHexMix.d.ts +8 -0
  144. package/dist/build/transformers/colorToHexMix.js +20 -0
  145. package/dist/build/transformers/colorToRgbAlpha.d.ts +8 -0
  146. package/dist/build/transformers/colorToRgbAlpha.js +20 -0
  147. package/dist/build/transformers/colorToRgbaFloat.d.ts +8 -0
  148. package/dist/build/transformers/colorToRgbaFloat.js +46 -0
  149. package/dist/build/transformers/cubicBezierToCss.d.ts +8 -0
  150. package/dist/build/transformers/cubicBezierToCss.js +23 -0
  151. package/dist/build/transformers/dimensionToPixelUnitless.d.ts +8 -0
  152. package/dist/build/transformers/dimensionToPixelUnitless.js +49 -0
  153. package/dist/build/transformers/dimensionToRem.d.ts +8 -0
  154. package/dist/build/transformers/dimensionToRem.js +46 -0
  155. package/dist/build/transformers/dimensionToRemPxArray.d.ts +8 -0
  156. package/dist/build/transformers/dimensionToRemPxArray.js +46 -0
  157. package/dist/build/transformers/durationToCss.d.ts +8 -0
  158. package/dist/build/transformers/durationToCss.js +29 -0
  159. package/dist/build/transformers/figmaAttributes.d.ts +8 -0
  160. package/dist/build/transformers/figmaAttributes.js +55 -0
  161. package/dist/build/transformers/floatToPixel.d.ts +15 -0
  162. package/dist/build/transformers/floatToPixel.js +39 -0
  163. package/dist/build/transformers/fontFamilyToCss.d.ts +14 -0
  164. package/dist/build/transformers/fontFamilyToCss.js +37 -0
  165. package/dist/build/transformers/fontFamilyToFigma.d.ts +14 -0
  166. package/dist/build/transformers/fontFamilyToFigma.js +44 -0
  167. package/dist/build/transformers/fontWeightToNumber.d.ts +9 -0
  168. package/dist/build/transformers/fontWeightToNumber.js +50 -0
  169. package/dist/build/transformers/index.d.ts +25 -0
  170. package/dist/build/transformers/index.js +25 -0
  171. package/dist/build/transformers/jsonDeprecated.d.ts +8 -0
  172. package/dist/build/transformers/jsonDeprecated.js +14 -0
  173. package/dist/build/transformers/namePathToCamelCase.d.ts +8 -0
  174. package/dist/build/transformers/namePathToCamelCase.js +12 -0
  175. package/dist/build/transformers/namePathToDotNotation.d.ts +8 -0
  176. package/dist/build/transformers/namePathToDotNotation.js +31 -0
  177. package/dist/build/transformers/namePathToFigma.d.ts +9 -0
  178. package/dist/build/transformers/namePathToFigma.js +21 -0
  179. package/dist/build/transformers/namePathToKebabCase.d.ts +8 -0
  180. package/dist/build/transformers/namePathToKebabCase.js +16 -0
  181. package/dist/build/transformers/namePathToPascalCase.d.ts +8 -0
  182. package/dist/build/transformers/namePathToPascalCase.js +12 -0
  183. package/dist/build/transformers/namePathToSlashNotation.d.ts +8 -0
  184. package/dist/build/transformers/namePathToSlashNotation.js +16 -0
  185. package/dist/build/transformers/shadowToCss.d.ts +8 -0
  186. package/dist/build/transformers/shadowToCss.js +34 -0
  187. package/dist/build/transformers/typographyToCss.d.ts +8 -0
  188. package/dist/build/transformers/typographyToCss.js +27 -0
  189. package/dist/build/transformers/utilities/alpha.d.ts +9 -0
  190. package/dist/build/transformers/utilities/alpha.js +16 -0
  191. package/dist/build/transformers/utilities/checkRequiredTokenProperties.d.ts +7 -0
  192. package/dist/build/transformers/utilities/checkRequiredTokenProperties.js +13 -0
  193. package/dist/build/transformers/utilities/getTokenValue.d.ts +2 -0
  194. package/dist/build/transformers/utilities/getTokenValue.js +16 -0
  195. package/dist/build/transformers/utilities/hasSpaceInString.d.ts +1 -0
  196. package/dist/build/transformers/utilities/hasSpaceInString.js +6 -0
  197. package/dist/build/transformers/utilities/hexToRgbaFloat.d.ts +2 -0
  198. package/dist/build/transformers/utilities/hexToRgbaFloat.js +29 -0
  199. package/dist/build/transformers/utilities/invalidTokenError.d.ts +7 -0
  200. package/dist/build/transformers/utilities/invalidTokenError.js +27 -0
  201. package/dist/build/transformers/utilities/isRgbaFloat.d.ts +7 -0
  202. package/dist/build/transformers/utilities/isRgbaFloat.js +20 -0
  203. package/dist/build/transformers/utilities/mix.d.ts +5 -0
  204. package/dist/build/transformers/utilities/mix.js +38 -0
  205. package/dist/build/transformers/utilities/rgbaFloatToHex.d.ts +6 -0
  206. package/dist/build/transformers/utilities/rgbaFloatToHex.js +11 -0
  207. package/dist/build/types/Border.d.ts +5 -0
  208. package/dist/build/types/BorderTokenValue.d.ts +10 -0
  209. package/dist/build/types/ColorHex.d.ts +4 -0
  210. package/dist/build/types/PlatformInitializer.d.ts +11 -0
  211. package/dist/build/types/Shadow.d.ts +5 -0
  212. package/dist/build/types/ShadowTokenValue.d.ts +14 -0
  213. package/dist/build/types/SizeEm.d.ts +4 -0
  214. package/dist/build/types/SizePx.d.ts +4 -0
  215. package/dist/build/types/SizeRem.d.ts +4 -0
  216. package/dist/build/types/StyleDictionaryConfigGenerator.d.ts +15 -0
  217. package/dist/build/types/TokenBuildInput.d.ts +8 -0
  218. package/dist/build/types/TypographyTokenValue.d.ts +12 -0
  219. package/dist/build/types/w3cTransformedToken.d.ts +8 -0
  220. package/dist/build/utilities/copyFromDir.d.ts +8 -0
  221. package/dist/build/utilities/copyFromDir.js +31 -0
  222. package/dist/build/utilities/filterStringArray.d.ts +1 -0
  223. package/dist/build/utilities/filterStringArray.js +13 -0
  224. package/dist/build/utilities/getFlag.d.ts +8 -0
  225. package/dist/build/utilities/getFlag.js +12 -0
  226. package/dist/build/utilities/index.d.ts +9 -0
  227. package/dist/build/utilities/index.js +9 -0
  228. package/dist/build/utilities/joinFriendly.d.ts +1 -0
  229. package/dist/build/utilities/joinFriendly.js +1 -0
  230. package/dist/build/utilities/schemaErrorMessage.d.ts +1 -0
  231. package/dist/build/utilities/schemaErrorMessage.js +1 -0
  232. package/dist/build/utilities/toCamelCase.d.ts +1 -0
  233. package/dist/build/utilities/toCamelCase.js +16 -0
  234. package/dist/build/utilities/toPascalCase.d.ts +1 -0
  235. package/dist/build/utilities/toPascalCase.js +13 -0
  236. package/dist/build/utilities/treeWalker.d.ts +8 -0
  237. package/dist/build/utilities/treeWalker.js +23 -0
  238. package/dist/build/utilities/upperCaseFirstCharacter.d.ts +8 -0
  239. package/dist/build/utilities/upperCaseFirstCharacter.js +10 -0
  240. package/dist/css/functional/themes/dark-colorblind.css +58 -38
  241. package/dist/css/functional/themes/dark-dimmed.css +44 -24
  242. package/dist/css/functional/themes/dark-high-contrast.css +62 -42
  243. package/dist/css/functional/themes/dark-tritanopia.css +44 -24
  244. package/dist/css/functional/themes/dark.css +42 -22
  245. package/dist/css/functional/themes/light-colorblind.css +60 -40
  246. package/dist/css/functional/themes/light-high-contrast.css +58 -38
  247. package/dist/css/functional/themes/light-tritanopia.css +42 -22
  248. package/dist/css/functional/themes/light.css +42 -22
  249. package/dist/docs/base/size/size.json +76 -76
  250. package/dist/docs/base/typography/typography.json +16 -16
  251. package/dist/docs/functional/motion/motion.json +18 -18
  252. package/dist/docs/functional/size/border.json +56 -56
  253. package/dist/docs/functional/size/breakpoints.json +24 -24
  254. package/dist/docs/functional/size/size-coarse.json +12 -12
  255. package/dist/docs/functional/size/size-fine.json +12 -12
  256. package/dist/docs/functional/size/size.json +264 -264
  257. package/dist/docs/functional/size/viewport.json +24 -24
  258. package/dist/docs/functional/themes/dark-colorblind.json +2868 -3462
  259. package/dist/docs/functional/themes/dark-dimmed.json +2826 -3016
  260. package/dist/docs/functional/themes/dark-high-contrast.json +2822 -5100
  261. package/dist/docs/functional/themes/dark-tritanopia.json +2829 -3203
  262. package/dist/docs/functional/themes/dark.json +2808 -2520
  263. package/dist/docs/functional/themes/light-colorblind.json +2604 -3150
  264. package/dist/docs/functional/themes/light-high-contrast.json +2653 -4609
  265. package/dist/docs/functional/themes/light-tritanopia.json +2546 -2960
  266. package/dist/docs/functional/themes/light.json +2590 -2312
  267. package/dist/docs/functional/typography/typography.json +206 -206
  268. package/dist/figma/dimension/dimension.json +489 -489
  269. package/dist/figma/figma.json +19 -11
  270. package/dist/figma/scales/dark-dimmed.json +2918 -38
  271. package/dist/figma/scales/dark-high-constrast.json +2918 -38
  272. package/dist/figma/scales/dark.json +2915 -35
  273. package/dist/figma/scales/light-high-constrast.json +2920 -40
  274. package/dist/figma/scales/light.json +2920 -40
  275. package/dist/figma/shadows/dark-colorblind.json +280 -280
  276. package/dist/figma/shadows/dark-dimmed.json +280 -280
  277. package/dist/figma/shadows/dark-high-contrast.json +280 -280
  278. package/dist/figma/shadows/dark-tritanopia.json +280 -280
  279. package/dist/figma/shadows/dark.json +280 -280
  280. package/dist/figma/shadows/light-colorblind.json +281 -281
  281. package/dist/figma/shadows/light-high-contrast.json +281 -281
  282. package/dist/figma/shadows/light-tritanopia.json +281 -281
  283. package/dist/figma/shadows/light.json +281 -281
  284. package/dist/figma/themes/dark-colorblind.json +5063 -5797
  285. package/dist/figma/themes/dark-dimmed.json +5294 -5604
  286. package/dist/figma/themes/dark-high-contrast.json +4258 -6617
  287. package/dist/figma/themes/dark-tritanopia.json +5239 -5763
  288. package/dist/figma/themes/dark.json +5570 -5414
  289. package/dist/figma/themes/light-colorblind.json +4933 -5570
  290. package/dist/figma/themes/light-high-contrast.json +4198 -6229
  291. package/dist/figma/themes/light-tritanopia.json +5116 -5618
  292. package/dist/figma/themes/light.json +5427 -5270
  293. package/dist/figma/typography/typography.json +112 -156
  294. package/dist/internalCss/dark-colorblind.css +58 -38
  295. package/dist/internalCss/dark-dimmed.css +44 -24
  296. package/dist/internalCss/dark-high-contrast.css +62 -42
  297. package/dist/internalCss/dark-tritanopia.css +44 -24
  298. package/dist/internalCss/dark.css +42 -22
  299. package/dist/internalCss/light-colorblind.css +60 -40
  300. package/dist/internalCss/light-high-contrast.css +58 -38
  301. package/dist/internalCss/light-tritanopia.css +42 -22
  302. package/dist/internalCss/light.css +42 -22
  303. package/dist/styleLint/base/size/size.json +38 -38
  304. package/dist/styleLint/base/typography/typography.json +8 -8
  305. package/dist/styleLint/functional/motion/motion.json +12 -12
  306. package/dist/styleLint/functional/size/border.json +30 -30
  307. package/dist/styleLint/functional/size/breakpoints.json +12 -12
  308. package/dist/styleLint/functional/size/size-coarse.json +6 -6
  309. package/dist/styleLint/functional/size/size-fine.json +6 -6
  310. package/dist/styleLint/functional/size/size.json +132 -132
  311. package/dist/styleLint/functional/size/viewport.json +12 -12
  312. package/dist/styleLint/functional/themes/dark-colorblind.json +1644 -2238
  313. package/dist/styleLint/functional/themes/dark-dimmed.json +1699 -1889
  314. package/dist/styleLint/functional/themes/dark-high-contrast.json +1627 -3905
  315. package/dist/styleLint/functional/themes/dark-tritanopia.json +1704 -2078
  316. package/dist/styleLint/functional/themes/dark.json +1692 -1404
  317. package/dist/styleLint/functional/themes/light-colorblind.json +1506 -2052
  318. package/dist/styleLint/functional/themes/light-high-contrast.json +1515 -3471
  319. package/dist/styleLint/functional/themes/light-tritanopia.json +1434 -1848
  320. package/dist/styleLint/functional/themes/light.json +1474 -1196
  321. package/dist/styleLint/functional/typography/typography.json +114 -114
  322. package/package.json +9 -7
  323. package/src/tokens/functional/color/dark/app-dark.json5 +203 -88
  324. package/src/tokens/functional/color/dark/data-vis-dark.json5 +20 -20
  325. package/src/tokens/functional/color/dark/display-dark.json5 +95 -95
  326. package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +0 -8
  327. package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +43 -30
  328. package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +62 -30
  329. package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +53 -12
  330. package/src/tokens/functional/color/dark/patterns-dark.json5 +16 -4
  331. package/src/tokens/functional/color/dark/primitives-dark.json5 +4 -4
  332. package/src/tokens/functional/color/light/app-light.json5 +195 -85
  333. package/src/tokens/functional/color/light/data-vis-light.json5 +20 -20
  334. package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +25 -25
  335. package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +65 -34
  336. package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +66 -11
  337. package/src/tokens/functional/color/light/patterns-light.json5 +13 -1
  338. package/src/tokens/functional/color/light/primitives-light.json5 +2 -2
@@ -0,0 +1,26 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { format } from 'prettier';
11
+ import { jsonToNestedValue } from './utilities/jsonToNestedValue.js';
12
+ import { prefixTokens } from './utilities/prefixTokens.js';
13
+ import { fileHeader } from 'style-dictionary/utils';
14
+ /**
15
+ * @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
16
+ * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
17
+ * @returns formatted `string`
18
+ */
19
+ export const javascriptEsm = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file, platform }) {
20
+ // add prefix if defined
21
+ const tokens = prefixTokens(dictionary.tokens, platform);
22
+ // add file header and convert output
23
+ const output = `${yield fileHeader({ file })}export default \n${JSON.stringify(jsonToNestedValue(tokens), null, 2)}\n`;
24
+ // return prettified
25
+ return format(output, { parser: 'typescript', printWidth: 500 });
26
+ });
@@ -0,0 +1,7 @@
1
+ import type { FormatFn } from 'style-dictionary/types';
2
+ /**
3
+ * @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
4
+ * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
5
+ * @returns formatted `string`
6
+ */
7
+ export declare const jsonFigma: FormatFn;
@@ -0,0 +1,121 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { format } from 'prettier';
11
+ import { transformNamePathToFigma } from '../transformers/namePathToFigma.js';
12
+ import { hexToRgbaFloat } from '../transformers/utilities/hexToRgbaFloat.js';
13
+ import { isRgbaFloat } from '../transformers/utilities/isRgbaFloat.js';
14
+ import { getReferences, sortByReference } from 'style-dictionary/utils';
15
+ const isReference = (string) => /^\{([^\\]*)\}$/g.test(string);
16
+ const getReference = (dictionary, refString, platform) => {
17
+ var _a;
18
+ if (isReference(refString)) {
19
+ // retrieve reference token
20
+ const refToken = getReferences(refString, dictionary.tokens, { unfilteredTokens: dictionary.unfilteredTokens })[0];
21
+ // return full reference
22
+ return [(_a = refToken.attributes) === null || _a === void 0 ? void 0 : _a.collection, transformNamePathToFigma(refToken, platform)].filter(Boolean).join('/');
23
+ }
24
+ };
25
+ const getFigmaType = (type) => {
26
+ const validTypes = {
27
+ color: 'COLOR',
28
+ dimension: 'FLOAT',
29
+ fontWeight: 'FLOAT',
30
+ number: 'FLOAT',
31
+ fontFamily: 'STRING',
32
+ };
33
+ if (type in validTypes)
34
+ return validTypes[type];
35
+ throw new Error(`Invalid type: ${type}`);
36
+ };
37
+ const shadowToVariables = (name, values, token) => {
38
+ // floatValue
39
+ const floatValue = (property) => ({
40
+ name: `${name}/${property}`,
41
+ value: parseInt(values[property].replace('px', '')),
42
+ type: 'FLOAT',
43
+ scopes: ['EFFECT_FLOAT'],
44
+ mode,
45
+ collection,
46
+ group,
47
+ });
48
+ const { attributes } = token;
49
+ const { mode, collection, group } = attributes || {};
50
+ return [
51
+ floatValue('offsetX'),
52
+ floatValue('offsetY'),
53
+ floatValue('blur'),
54
+ floatValue('spread'),
55
+ {
56
+ name: `${name}/color`,
57
+ value: isRgbaFloat(values.color)
58
+ ? Object.assign(Object.assign({}, values.color), (values.alpha ? { a: values.alpha } : {})) : hexToRgbaFloat(values.color, values.alpha),
59
+ type: 'COLOR',
60
+ scopes: ['EFFECT_COLOR'],
61
+ mode,
62
+ collection,
63
+ group,
64
+ },
65
+ ];
66
+ };
67
+ /**
68
+ * @description Converts `StyleDictionary.dictionary.tokens` to javascript esm (javascript export statement)
69
+ * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
70
+ * @returns formatted `string`
71
+ */
72
+ export const jsonFigma = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file: _file, platform }) {
73
+ // array to store tokens in
74
+ const tokens = [];
75
+ const sortedTokens = [...dictionary.allTokens].sort(sortByReference(dictionary.tokens, { unfilteredTokens: dictionary.unfilteredTokens }));
76
+ // loop through tokens sorted by reference
77
+ for (const token of sortedTokens) {
78
+ // deconstruct token
79
+ const { attributes, $value: value, $type, $description: description, original, alpha, mix } = token;
80
+ const { mode, collection, scopes, group, codeSyntax } = attributes || {};
81
+ // early escape if no type is present
82
+ if (!$type)
83
+ return;
84
+ // shadows need to be specifically dealt with
85
+ if ($type === 'shadow') {
86
+ const shadowValues = !Array.isArray(value) ? [value] : value;
87
+ // if only one set of shadow values is present
88
+ if (shadowValues.length === 1) {
89
+ tokens.push(...shadowToVariables(token.name, shadowValues[0], Object.assign(Object.assign({}, token), (platform.mode ? { mode: platform.mode } : {}))));
90
+ }
91
+ else {
92
+ // if multiple shadow sets values are present we need loop through them and add the index to the name
93
+ for (const [index, stepValue] of shadowValues.entries()) {
94
+ tokens.push(...shadowToVariables(`${token.name}/${index + 1}`, stepValue, Object.assign(Object.assign({}, token), (platform.mode ? { mode: platform.mode } : {}))));
95
+ }
96
+ }
97
+ // other tokens just get added to tokens array
98
+ }
99
+ else {
100
+ tokens.push({
101
+ name: token.name,
102
+ value,
103
+ type: getFigmaType($type),
104
+ alpha,
105
+ isMix: mix ? true : undefined,
106
+ description,
107
+ refId: [collection, token.name].filter(Boolean).join('/'),
108
+ reference: getReference(dictionary, original.$value, platform),
109
+ collection,
110
+ mode,
111
+ group,
112
+ scopes,
113
+ codeSyntax,
114
+ });
115
+ }
116
+ }
117
+ // add file header and convert output
118
+ const output = JSON.stringify(tokens, null, 2);
119
+ // return prettified
120
+ return format(output, { parser: 'json', printWidth: 500 });
121
+ });
@@ -0,0 +1,8 @@
1
+ import type { FormatFn } from 'style-dictionary/types';
2
+ /**
3
+ * @description Takes a style dictionary token dictionary and converts it to a nested json string.
4
+ * In contrast to the `json/nested` this formatter does add a prefix if provided
5
+ * @param FormatFnArguments
6
+ * @returns formatted json `string`
7
+ */
8
+ export declare const jsonNestedPrefixed: FormatFn;
@@ -0,0 +1,30 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { format } from 'prettier';
11
+ import { prefixTokens } from './utilities/prefixTokens.js';
12
+ import { jsonToNestedValue } from './utilities/jsonToNestedValue.js';
13
+ /**
14
+ * @description Takes a style dictionary token dictionary and converts it to a nested json string.
15
+ * In contrast to the `json/nested` this formatter does add a prefix if provided
16
+ * @param FormatFnArguments
17
+ * @returns formatted json `string`
18
+ */
19
+ export const jsonNestedPrefixed = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file: _file, options, platform }) {
20
+ const { outputVerbose } = options;
21
+ // add prefix if defined
22
+ let tokens = prefixTokens(dictionary.tokens, platform);
23
+ if (!outputVerbose) {
24
+ tokens = jsonToNestedValue(tokens);
25
+ }
26
+ // add file header and convert output
27
+ const output = JSON.stringify(tokens, null, 2);
28
+ // return prettified
29
+ return format(output, { parser: 'json', printWidth: 500 });
30
+ });
@@ -0,0 +1,8 @@
1
+ import type { FormatFn } from 'style-dictionary/types';
2
+ /**
3
+ * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
4
+ * @param FormatFnArguments
5
+ * @param options.nameSeparator - separator to use for nested token name
6
+ * @returns formatted json `string`
7
+ */
8
+ export declare const jsonOneDimensional: FormatFn;
@@ -0,0 +1,32 @@
1
+ import { format } from 'prettier';
2
+ import { jsonToFlat } from './utilities/jsonToFlat.js';
3
+ /**
4
+ * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
5
+ * @param FormatFnArguments
6
+ * @param options.nameSeparator - separator to use for nested token name
7
+ * @returns formatted json `string`
8
+ */
9
+ export const jsonOneDimensional = ({ dictionary, file: _file, options }) => {
10
+ // option to allow verbose output (object) or just the value
11
+ const { outputVerbose, propertyConversion } = options;
12
+ const tokens = jsonToFlat(dictionary.allTokens, outputVerbose);
13
+ if (propertyConversion === undefined) {
14
+ //
15
+ const output = JSON.stringify(tokens, null, 2);
16
+ // return prettified
17
+ return format(output, { parser: 'json', printWidth: 500 });
18
+ }
19
+ // replace property names
20
+ const convertedTokens = Object.fromEntries(Object.entries(tokens).map(([name, token]) => {
21
+ for (const [from, to] of Object.entries(propertyConversion)) {
22
+ if (from in token) {
23
+ token[to] = token[from];
24
+ delete token[from];
25
+ }
26
+ }
27
+ return [name, token];
28
+ }));
29
+ const output = JSON.stringify(convertedTokens, null, 2);
30
+ // return prettified
31
+ return format(output, { parser: 'json', printWidth: 500 });
32
+ };
@@ -0,0 +1,8 @@
1
+ import type { FormatFn } from 'style-dictionary/types';
2
+ /**
3
+ * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
4
+ * @param FormatFnArguments
5
+ * @param options.nameSeparator - separator to use for nested token name
6
+ * @returns formatted json `string`
7
+ */
8
+ export declare const jsonPostCssFallback: FormatFn;
@@ -0,0 +1,14 @@
1
+ import { format } from 'prettier';
2
+ /**
3
+ * @description Takes a style dictionary token dictionary and converts it to a one dimensional json object.
4
+ * @param FormatFnArguments
5
+ * @param options.nameSeparator - separator to use for nested token name
6
+ * @returns formatted json `string`
7
+ */
8
+ export const jsonPostCssFallback = ({ dictionary, file: _file }) => {
9
+ const tokens = Object.fromEntries(dictionary.allTokens.map(token => [`--${token.name}`, token.$value]));
10
+ // add file header and convert output
11
+ const output = JSON.stringify(tokens, null, 2);
12
+ // return prettified
13
+ return format(output, { parser: 'json', printWidth: 500 });
14
+ };
@@ -0,0 +1,7 @@
1
+ import type { FormatFn } from 'style-dictionary/types';
2
+ /**
3
+ * @description Converts `StyleDictionary.dictionary.tokens` to typescript definition
4
+ * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
5
+ * @returns formatted `string`
6
+ */
7
+ export declare const typescriptExportDefinition: FormatFn;
@@ -0,0 +1,170 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { format } from 'prettier';
11
+ import { readFileSync } from 'fs';
12
+ import { resolve as resolvePath } from 'path';
13
+ import { treeWalker } from '../utilities/treeWalker.js';
14
+ import { prefixTokens } from './utilities/prefixTokens.js';
15
+ import { fileHeader } from 'style-dictionary/utils';
16
+ import { getPropName } from './utilities/getPropName.js';
17
+ /**
18
+ * unquoteTypes
19
+ * @description extract types from designTokenTypes (string with type definitions from file) and replace quoted types "Color" with unquoted Color
20
+ * @param output
21
+ * @param designTokenTypes
22
+ * @returns string with unquoted types
23
+ */
24
+ const unquoteTypes = (output, designTokenTypes) => {
25
+ // join types for replacement
26
+ const regex = `"(${['number', 'string', 'any', ...designTokenTypes].join('|')})"`;
27
+ // remove strings
28
+ return output.replace(new RegExp(regex, 'g'), '$1');
29
+ };
30
+ /**
31
+ * getTokenType
32
+ * @description extract content from token files
33
+ * @param path string
34
+ */
35
+ const getTokenType = (tokenTypesPath) => {
36
+ try {
37
+ const designTokenType = readFileSync(resolvePath(tokenTypesPath), { encoding: 'utf-8' });
38
+ return designTokenType;
39
+ }
40
+ catch (e) {
41
+ // eslint-disable-next-line no-console
42
+ throw new Error(`Error trying to load design token type from file "${tokenTypesPath}".`);
43
+ }
44
+ };
45
+ /**
46
+ * @description throws an error stating the token name, type and invalid value
47
+ * @param token w3cTransformedToken
48
+ */
49
+ const invalidTokenValueError = (token, options) => {
50
+ throw new Error(`Invalid token: "${token.name}" with type "${token[getPropName('type', options.usesDtcg)]}" can not have a value of "${token[getPropName('value', options.usesDtcg)]}"`);
51
+ };
52
+ /**
53
+ * convertPropToType
54
+ * @description return take type attribute and return correct typescript type as string
55
+ * @param type
56
+ * @returns
57
+ */
58
+ const convertPropToType = (tree, options) => {
59
+ const valueProp = getPropName('value', options.usesDtcg);
60
+ if (!Object.prototype.hasOwnProperty.call(tree, valueProp)) {
61
+ throw new Error(`Invalid token: ${tree}`);
62
+ }
63
+ switch (tree.$type) {
64
+ case 'color':
65
+ if (typeof tree[valueProp] === 'string' && tree[valueProp][0] === '#') {
66
+ return 'ColorHex';
67
+ }
68
+ return invalidTokenValueError(tree, options);
69
+ case 'dimension':
70
+ if (typeof tree[valueProp] === 'string' && tree[valueProp].substring(tree[valueProp].length - 3) === 'rem')
71
+ return 'SizeRem';
72
+ if (typeof tree[valueProp] === 'string' && tree[valueProp].substring(tree[valueProp].length - 2) === 'em')
73
+ return 'SizeEm';
74
+ if (typeof tree[valueProp] === 'string' && tree[valueProp].substring(tree[valueProp].length - 2) === 'px')
75
+ return 'SizePx';
76
+ return invalidTokenValueError(tree, options);
77
+ case 'shadow':
78
+ return 'Shadow';
79
+ case 'border':
80
+ return 'Border';
81
+ default:
82
+ if (typeof tree[valueProp] === 'number')
83
+ return 'number';
84
+ if (typeof tree[valueProp] === 'string')
85
+ return 'string';
86
+ if (typeof tree[valueProp] === 'boolean')
87
+ return 'boolean';
88
+ return 'any';
89
+ }
90
+ };
91
+ /**
92
+ * a valid token node has a `value` property
93
+ * @param item object
94
+ * @returns boolean
95
+ */
96
+ const validTokenNode = (usesDtcg) => (item) => {
97
+ return typeof item === 'object' && item !== null && getPropName('value', usesDtcg) in item;
98
+ };
99
+ /**
100
+ * returns a set with every used token type
101
+ * @param item object
102
+ * @param validTypes array, all other types will be removed
103
+ * @returns set of all used token types
104
+ */
105
+ const getUsedTokenTypes = (tokens, validTypes, options) => {
106
+ // using a set to assure every value only exists once
107
+ const usedTypes = new Set();
108
+ // adds type to set
109
+ const callback = (tree) => usedTypes.add(convertPropToType(tree, options));
110
+ // tree walker adds to usedTypes
111
+ treeWalker(tokens, callback, validTokenNode(options.usesDtcg));
112
+ // clean up types
113
+ for (const type of usedTypes) {
114
+ if (!validTypes.includes(type)) {
115
+ usedTypes.delete(type);
116
+ }
117
+ }
118
+ return usedTypes;
119
+ };
120
+ /**
121
+ * returns the entire token object structure but instead of token values each token just has a typescript type
122
+ * @param item object
123
+ * @returns object
124
+ */
125
+ const getTokenObjectWithTypes = (tokens, options) => {
126
+ const callback = (tree) => convertPropToType(tree, options);
127
+ // TODO: FIX typescript issues
128
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
129
+ // @ts-ignore
130
+ return treeWalker(tokens, callback, validTokenNode(options.usesDtcg));
131
+ };
132
+ /**
133
+ * getTypeDefinition
134
+ * @description returns type definitions as string
135
+ * @param tokens
136
+ * @param moduleName
137
+ * @param tokenTypesPath
138
+ * @returns string
139
+ */
140
+ const getTypeDefinition = (tokens, options) => {
141
+ // extract options
142
+ const { moduleName = `tokens`, tokenTypesPath = `./src/types/` } = options;
143
+ const usedTypes = getUsedTokenTypes(tokens, ['Shadow', 'ColorHex', 'Border', 'SizeEm', 'SizeRem', 'SizePx'], options);
144
+ const tokenObjectWithTypes = getTokenObjectWithTypes(tokens, options);
145
+ // get token type declaration from file
146
+ const designTokenTypes = [];
147
+ for (const type of usedTypes) {
148
+ // path to type files without trailing slash
149
+ const typePath = tokenTypesPath.replace(new RegExp(/\/$/, 'g'), '');
150
+ designTokenTypes.push(getTokenType(`${typePath}/${type}.d.ts`));
151
+ }
152
+ // build output
153
+ const output = `${designTokenTypes.join('\n')}
154
+ export type ${moduleName} = ${JSON.stringify(tokenObjectWithTypes, null, 2)}`;
155
+ // JSON stringify will quote strings, because this is a type we need it unquoted.
156
+ return unquoteTypes(output, [...usedTypes]);
157
+ };
158
+ /**
159
+ * @description Converts `StyleDictionary.dictionary.tokens` to typescript definition
160
+ * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts)
161
+ * @returns formatted `string`
162
+ */
163
+ export const typescriptExportDefinition = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, file, options = {}, platform, }) {
164
+ // add prefix if defined
165
+ const tokens = prefixTokens(dictionary.tokens, platform);
166
+ // add file header and convert output
167
+ const output = `${yield fileHeader({ file })}\n${getTypeDefinition(tokens, options)}\n`;
168
+ // return prettified
169
+ return format(output, { parser: 'typescript', printWidth: 500 });
170
+ });
@@ -0,0 +1 @@
1
+ export declare const getPropName: (prop: "value" | "type" | "description", usesDtcg?: boolean) => "type" | "value" | "$value" | "$type" | "$description" | "comment";
@@ -0,0 +1,16 @@
1
+ const props = {
2
+ dtcg: {
3
+ value: '$value',
4
+ type: '$type',
5
+ description: '$description',
6
+ },
7
+ legacy: {
8
+ value: 'value',
9
+ type: 'type',
10
+ description: 'comment',
11
+ },
12
+ };
13
+ export const getPropName = (prop, usesDtcg) => {
14
+ const type = usesDtcg ? 'dtcg' : 'legacy';
15
+ return props[type][prop];
16
+ };
@@ -0,0 +1,11 @@
1
+ import type { TransformedToken } from 'style-dictionary/types';
2
+ /**
3
+ * jsonToFlat
4
+ * @description creates a one dimensional json structure with either a single value or an token object as the value
5
+ * @param token StyleDictionary.DesignToken
6
+ * @param returnObject - boolean
7
+ * @returns flat json three
8
+ */
9
+ export declare const jsonToFlat: (tokens: TransformedToken[], returnObject?: boolean) => {
10
+ [k: string]: any;
11
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * jsonToFlat
3
+ * @description creates a one dimensional json structure with either a single value or an token object as the value
4
+ * @param token StyleDictionary.DesignToken
5
+ * @param returnObject - boolean
6
+ * @returns flat json three
7
+ */
8
+ export const jsonToFlat = (tokens, returnObject = false) => Object.fromEntries(tokens.map(token => [token.name, returnObject ? token : token.$value]));
@@ -0,0 +1,8 @@
1
+ import type { DesignToken } from 'style-dictionary/types';
2
+ /**
3
+ * jsonToNestedValue
4
+ * @description creates a nested json tree where every final value is the `.value` prop
5
+ * @param token StyleDictionary.DesignToken
6
+ * @returns nested json three
7
+ */
8
+ export declare const jsonToNestedValue: (token: DesignToken | Record<string, unknown>) => any;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * jsonToNestedValue
3
+ * @description creates a nested json tree where every final value is the `.value` prop
4
+ * @param token StyleDictionary.DesignToken
5
+ * @returns nested json three
6
+ */
7
+ export const jsonToNestedValue = (token) => {
8
+ // is non-object value
9
+ if (typeof token !== 'object')
10
+ return token;
11
+ // is design token
12
+ if ('$value' in token)
13
+ return token.$value;
14
+ if ('value' in token)
15
+ return token.value;
16
+ // is obj
17
+ const nextObj = {};
18
+ for (const [prop, value] of Object.entries(token)) {
19
+ // @ts-expect-error: can't predict type
20
+ nextObj[prop] = jsonToNestedValue(value);
21
+ }
22
+ return nextObj;
23
+ };
@@ -0,0 +1,8 @@
1
+ import type { PlatformConfig, TransformedTokens } from 'style-dictionary/types';
2
+ /**
3
+ * @description extract prefix from platform and add to tokens array if defined
4
+ * @param tokens StyleDictionary.TransformedTokens
5
+ * @param platform StyleDictionary.Platform
6
+ * @return StyleDictionary.TransformedTokens
7
+ */
8
+ export declare const prefixTokens: (tokens: TransformedTokens, platform?: PlatformConfig) => TransformedTokens;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @description extract prefix from platform and add to tokens array if defined
3
+ * @param tokens StyleDictionary.TransformedTokens
4
+ * @param platform StyleDictionary.Platform
5
+ * @return StyleDictionary.TransformedTokens
6
+ */
7
+ export const prefixTokens = (tokens, platform = {}) => {
8
+ const { prefix } = platform;
9
+ if (typeof prefix === 'string') {
10
+ tokens = { [prefix]: tokens };
11
+ }
12
+ return tokens;
13
+ };
@@ -0,0 +1 @@
1
+ export { w3cJsonParser } from './w3cJsonParser.js';
@@ -0,0 +1 @@
1
+ export { w3cJsonParser } from './w3cJsonParser.js';
@@ -0,0 +1,6 @@
1
+ import type { Parser } from 'style-dictionary/types';
2
+ /**
3
+ * @description Parses a valid [json5](https://json5.org) file and replaces `$value` with `value` and `$description` with `comment` to make a w3c standard file compatible with style dictionary
4
+ * @pattern supported file extensions `.json` or `.json5`
5
+ */
6
+ export declare const w3cJsonParser: Parser;
@@ -0,0 +1,25 @@
1
+ import JSON5 from 'json5';
2
+ /**
3
+ * @description Parses a valid [json5](https://json5.org) file and replaces `$value` with `value` and `$description` with `comment` to make a w3c standard file compatible with style dictionary
4
+ * @pattern supported file extensions `.json` or `.json5`
5
+ */
6
+ export const w3cJsonParser = {
7
+ name: 'w3cJsonParser',
8
+ pattern: /\.json5?$/,
9
+ parser: ({ filePath, contents }) => {
10
+ // replace $value with value so that style dictionary recognizes it
11
+ try {
12
+ contents = contents
13
+ .replace(/["|']?\$value["|']?:/g, '"value":')
14
+ // convert $description to comment
15
+ .replace(/["|']?\$?description["|']?:/g, '"comment":')
16
+ .replace(/["|']?\$?type["|']?:/g, '"$type":')
17
+ .replace(/["|']?\$?extensions["|']?:/g, '"$extensions":');
18
+ //
19
+ return JSON5.parse(contents);
20
+ }
21
+ catch (e) {
22
+ throw new Error(`Invalid json5 file "${filePath}".`);
23
+ }
24
+ },
25
+ };
@@ -0,0 +1,2 @@
1
+ import type { PlatformInitializer } from '../types/PlatformInitializer.ts';
2
+ export declare const css: PlatformInitializer;