@primer/primitives 7.16.0 → 7.17.0-rc.132f02a7

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 (360) hide show
  1. package/dist/css/functional/themes/dark-colorblind.css +14 -14
  2. package/dist/css/functional/themes/dark-tritanopia.css +14 -14
  3. package/dist/css/functional/themes/dark.css +14 -14
  4. package/dist/docs/functional/themes/dark-colorblind.json +7 -7
  5. package/dist/docs/functional/themes/dark-tritanopia.json +7 -7
  6. package/dist/docs/functional/themes/dark.json +7 -7
  7. package/dist/figma/scales/dark.json +5 -5
  8. package/dist/figma/themes/dark-colorblind.json +20 -20
  9. package/dist/figma/themes/dark-tritanopia.json +20 -20
  10. package/dist/figma/themes/dark.json +20 -20
  11. package/dist/internalCss/dark-colorblind.css +18 -18
  12. package/dist/internalCss/dark-tritanopia.css +18 -18
  13. package/dist/internalCss/dark.css +18 -18
  14. package/{tokens-next-private/docs → dist/styleLint}/base/size/size.json +17 -17
  15. package/{tokens-next-private/docs → dist/styleLint}/functional/size/border.json +6 -6
  16. package/{tokens-next-private/docs → dist/styleLint}/functional/size/breakpoints.json +6 -6
  17. package/{tokens-next-private/docs → dist/styleLint}/functional/size/size-coarse.json +3 -3
  18. package/{tokens-next-private/docs → dist/styleLint}/functional/size/size-fine.json +3 -3
  19. package/{tokens-next-private/docs → dist/styleLint}/functional/size/size.json +72 -72
  20. package/{tokens-next-private/docs → dist/styleLint}/functional/size/viewport.json +4 -4
  21. package/{tokens-next-private/docs → dist/styleLint}/functional/themes/dark-colorblind.json +7 -7
  22. package/{tokens-next-private/docs → dist/styleLint}/functional/themes/dark-tritanopia.json +7 -7
  23. package/{tokens-next-private/docs → dist/styleLint}/functional/themes/dark.json +7 -7
  24. package/{tokens-next-private/docs → dist/styleLint}/functional/typography/typography.json +23 -23
  25. package/package.json +12 -11
  26. package/src/PrimerStyleDictionary.ts +226 -0
  27. package/src/filters/index.ts +12 -0
  28. package/src/filters/isBorder.ts +10 -0
  29. package/src/filters/isColor.ts +10 -0
  30. package/src/filters/isColorWithAlpha.ts +11 -0
  31. package/src/filters/isColorWithMix.ts +33 -0
  32. package/src/filters/isDeprecated.ts +10 -0
  33. package/src/filters/isDimension.ts +10 -0
  34. package/src/filters/isDuration.ts +10 -0
  35. package/src/filters/isFontFamily.ts +10 -0
  36. package/src/filters/isFontWeight.ts +10 -0
  37. package/src/filters/isFromFile.ts +12 -0
  38. package/src/filters/isShadow.ts +10 -0
  39. package/src/filters/isSource.ts +10 -0
  40. package/src/filters/isTypography.ts +10 -0
  41. package/src/formats/cssCustomMedia.ts +24 -0
  42. package/src/formats/cssThemed.ts +35 -0
  43. package/src/formats/cssVariables.ts +25 -0
  44. package/src/formats/cssWrapMediaQuery.ts +29 -0
  45. package/src/formats/index.ts +11 -0
  46. package/src/formats/javascriptCommonJs.ts +21 -0
  47. package/src/formats/javascriptEsm.ts +21 -0
  48. package/src/formats/jsonFigma.ts +133 -0
  49. package/src/formats/jsonNestedPrefixed.ts +23 -0
  50. package/src/formats/jsonOneDimensional.ts +18 -0
  51. package/src/formats/jsonPostCssFallback.ts +16 -0
  52. package/src/formats/typescriptExportDefinition.ts +170 -0
  53. package/src/formats/utilities/jsonToFlat.ts +10 -0
  54. package/src/formats/utilities/jsonToNestedValue.ts +20 -0
  55. package/src/formats/utilities/prefixTokens.ts +17 -0
  56. package/src/parsers/index.ts +1 -0
  57. package/src/parsers/w3cJsonParser.ts +25 -0
  58. package/src/platforms/css.ts +93 -0
  59. package/src/platforms/deprecatedJson.ts +16 -0
  60. package/src/platforms/docJson.ts +34 -0
  61. package/src/platforms/fallbacks.ts +34 -0
  62. package/src/platforms/figma.ts +48 -0
  63. package/src/platforms/index.ts +10 -0
  64. package/src/platforms/javascript.ts +30 -0
  65. package/src/platforms/json.ts +32 -0
  66. package/src/platforms/styleLint.ts +34 -0
  67. package/src/platforms/typeDefinitions.ts +30 -0
  68. package/src/platforms/typescript.ts +30 -0
  69. package/src/schemas/alphaValue.ts +12 -0
  70. package/src/schemas/baseToken.ts +7 -0
  71. package/src/schemas/borderToken.ts +19 -0
  72. package/src/schemas/collections.ts +49 -0
  73. package/src/schemas/colorHexValue.ts +18 -0
  74. package/src/schemas/colorToken.ts +50 -0
  75. package/src/schemas/designToken.ts +38 -0
  76. package/src/schemas/dimensionToken.ts +22 -0
  77. package/src/schemas/dimensionValue.ts +16 -0
  78. package/src/schemas/durationToken.ts +12 -0
  79. package/src/schemas/durationValue.ts +9 -0
  80. package/src/schemas/fontFamilyToken.ts +21 -0
  81. package/src/schemas/fontWeightToken.ts +22 -0
  82. package/src/schemas/fontWeightValue.ts +14 -0
  83. package/src/schemas/numberToken.ts +11 -0
  84. package/src/schemas/referenceValue.ts +12 -0
  85. package/src/schemas/scopes.ts +16 -0
  86. package/src/schemas/shadowToken.ts +45 -0
  87. package/src/schemas/stringToken.ts +11 -0
  88. package/src/schemas/tokenName.ts +12 -0
  89. package/src/schemas/tokenType.ts +4 -0
  90. package/src/schemas/typographyToken.ts +20 -0
  91. package/src/schemas/validTokenType.ts +44 -0
  92. package/src/schemas/viewportRangeToken.ts +11 -0
  93. package/src/test-utilities/getMockDictionary.ts +22 -0
  94. package/src/test-utilities/getMockFormatterArguments.ts +21 -0
  95. package/src/test-utilities/getMockParserInput.ts +72 -0
  96. package/src/test-utilities/getMockToken.ts +25 -0
  97. package/src/test-utilities/index.ts +4 -0
  98. package/src/tokens/base/color/dark/dark.dimmed.json5 +1326 -0
  99. package/src/tokens/base/color/dark/dark.high-contrast.json5 +856 -0
  100. package/src/tokens/base/color/dark/dark.json5 +866 -0
  101. package/src/tokens/base/color/dark/display-dark.json5 +1774 -0
  102. package/src/tokens/base/color/light/display-light.json5 +1774 -0
  103. package/src/tokens/base/color/light/light.high-contrast.json5 +847 -0
  104. package/src/tokens/base/color/light/light.json5 +866 -0
  105. package/src/tokens/base/size/size.json +176 -0
  106. package/src/tokens/base/typography/typography.json +24 -0
  107. package/{tokens-next-private/fallbacks → src/tokens/fallback}/color-fallbacks.json +1 -1
  108. package/src/tokens/functional/border/dark.json5 +12 -0
  109. package/src/tokens/functional/border/light.json5 +12 -0
  110. package/src/tokens/functional/color/dark/app-dark.json5 +554 -0
  111. package/src/tokens/functional/color/dark/data-vis-dark.json5 +144 -0
  112. package/src/tokens/functional/color/dark/display-dark.json5 +1060 -0
  113. package/src/tokens/functional/color/dark/overrides/dark.dimmed.json5 +57 -0
  114. package/src/tokens/functional/color/dark/overrides/dark.high-contrast.json5 +390 -0
  115. package/src/tokens/functional/color/dark/overrides/dark.protanopia-deuteranopia.json5 +314 -0
  116. package/src/tokens/functional/color/dark/overrides/dark.tritanopia.json5 +229 -0
  117. package/src/tokens/functional/color/dark/patterns-dark.json5 +3073 -0
  118. package/src/tokens/functional/color/dark/primitives-dark.json5 +1206 -0
  119. package/src/tokens/functional/color/dark/syntax-dark.json5 +559 -0
  120. package/src/tokens/functional/color/light/app-light.json5 +551 -0
  121. package/src/tokens/functional/color/light/data-vis-light.json5 +144 -0
  122. package/src/tokens/functional/color/light/display-light.json5 +1060 -0
  123. package/src/tokens/functional/color/light/overrides/light.high-contrast.json5 +440 -0
  124. package/src/tokens/functional/color/light/overrides/light.protanopia-deuteranopia.json5 +340 -0
  125. package/src/tokens/functional/color/light/overrides/light.tritanopia.json5 +249 -0
  126. package/src/tokens/functional/color/light/patterns-light.json5 +3070 -0
  127. package/src/tokens/functional/color/light/primitives-light.json5 +1196 -0
  128. package/src/tokens/functional/color/light/syntax-light.json5 +559 -0
  129. package/src/tokens/functional/motion/loading.json5 +17 -0
  130. package/src/tokens/functional/motion/patterns.json5 +28 -0
  131. package/src/tokens/functional/shadow/dark.json5 +383 -0
  132. package/src/tokens/functional/shadow/light.json5 +376 -0
  133. package/src/tokens/functional/size/border.json +98 -0
  134. package/src/tokens/functional/size/breakpoints.json +64 -0
  135. package/src/tokens/functional/size/size-coarse.json +28 -0
  136. package/src/tokens/functional/size/size-fine.json +28 -0
  137. package/src/tokens/functional/size/size.json +802 -0
  138. package/src/tokens/functional/size/viewport.json +28 -0
  139. package/src/tokens/functional/typography/typography.json +279 -0
  140. package/src/transformers/borderToCss.ts +38 -0
  141. package/src/transformers/colorToHex.ts +16 -0
  142. package/src/transformers/colorToHexAlpha.ts +23 -0
  143. package/src/transformers/colorToHexMix.ts +19 -0
  144. package/src/transformers/colorToRgbAlpha.ts +19 -0
  145. package/src/transformers/colorToRgbaFloat.ts +45 -0
  146. package/src/transformers/dimensionToPixelUnitless.ts +60 -0
  147. package/src/transformers/dimensionToRem.ts +56 -0
  148. package/src/transformers/dimensionToRemPxArray.ts +60 -0
  149. package/src/transformers/durationToCss.ts +29 -0
  150. package/src/transformers/figmaAttributes.ts +55 -0
  151. package/src/transformers/fontFamilyToCss.ts +38 -0
  152. package/src/transformers/fontWeightToNumber.ts +53 -0
  153. package/src/transformers/index.ts +21 -0
  154. package/src/transformers/jsonDeprecated.ts +15 -0
  155. package/src/transformers/namePathToCamelCase.ts +14 -0
  156. package/src/transformers/namePathToDotNotation.ts +34 -0
  157. package/src/transformers/namePathToFigma.ts +28 -0
  158. package/src/transformers/namePathToKebabCase.ts +19 -0
  159. package/src/transformers/namePathToSlashNotation.ts +19 -0
  160. package/src/transformers/shadowToCss.ts +37 -0
  161. package/src/transformers/typographyToCss.ts +31 -0
  162. package/src/transformers/utilities/alpha.ts +23 -0
  163. package/src/transformers/utilities/checkRequiredTokenProperties.ts +16 -0
  164. package/src/transformers/utilities/getTokenValue.ts +18 -0
  165. package/src/transformers/utilities/hexToRgbaFloat.ts +31 -0
  166. package/src/transformers/utilities/invalidTokenError.ts +34 -0
  167. package/src/transformers/utilities/isRgbaFloat.ts +29 -0
  168. package/src/transformers/utilities/mix.ts +46 -0
  169. package/src/transformers/utilities/rgbaFloatToHex.ts +15 -0
  170. package/src/types/Border.d.ts +5 -0
  171. package/src/types/BorderTokenValue.d.ts +10 -0
  172. package/src/types/ColorHex.d.ts +4 -0
  173. package/src/types/PlatformInitializer.d.ts +11 -0
  174. package/src/types/Shadow.d.ts +5 -0
  175. package/src/types/ShadowTokenValue.d.ts +14 -0
  176. package/src/types/SizeEm.d.ts +4 -0
  177. package/src/types/SizePx.d.ts +4 -0
  178. package/src/types/SizeRem.d.ts +4 -0
  179. package/src/types/StyleDictionaryConfigGenerator.d.ts +15 -0
  180. package/src/types/TokenBuildInput.d.ts +8 -0
  181. package/src/types/TypographyTokenValue.d.ts +12 -0
  182. package/src/types/w3cTransformedToken.d.ts +8 -0
  183. package/src/utilities/copyFromDir.ts +21 -0
  184. package/src/utilities/getFlag.ts +12 -0
  185. package/src/utilities/index.ts +3 -0
  186. package/src/utilities/joinFriendly.ts +2 -0
  187. package/src/utilities/schemaErrorMessage.ts +2 -0
  188. package/src/utilities/toCamelCase.ts +29 -0
  189. package/src/utilities/treeWalker.ts +27 -0
  190. package/src/utilities/upperCaseFirstCharacter.ts +10 -0
  191. package/src/utils-v1.ts +36 -0
  192. package/tokens-v2-private/css/tokens/base/size/size.css +1 -1
  193. package/tokens-v2-private/css/tokens/base/typography/typography.css +1 -1
  194. package/tokens-v2-private/css/tokens/functional/size/border.css +1 -1
  195. package/tokens-v2-private/css/tokens/functional/size/breakpoints.css +1 -1
  196. package/tokens-v2-private/css/tokens/functional/size/size-coarse.css +1 -1
  197. package/tokens-v2-private/css/tokens/functional/size/size-fine.css +1 -1
  198. package/tokens-v2-private/css/tokens/functional/size/size.css +1 -1
  199. package/tokens-v2-private/css/tokens/functional/typography/typography.css +1 -1
  200. package/tokens-v2-private/js/module/tokens/base/size/size.js +1 -1
  201. package/tokens-v2-private/js/module/tokens/base/typography/typography.js +1 -1
  202. package/tokens-v2-private/js/module/tokens/functional/size/border.js +1 -1
  203. package/tokens-v2-private/js/module/tokens/functional/size/breakpoints.js +1 -1
  204. package/tokens-v2-private/js/module/tokens/functional/size/size-coarse.js +1 -1
  205. package/tokens-v2-private/js/module/tokens/functional/size/size-fine.js +1 -1
  206. package/tokens-v2-private/js/module/tokens/functional/size/size.js +1 -1
  207. package/tokens-v2-private/js/module/tokens/functional/size/viewport.js +1 -1
  208. package/tokens-v2-private/js/module/tokens/functional/typography/typography.js +1 -1
  209. package/tokens-v2-private/js/tokens/base/size/size.js +1 -1
  210. package/tokens-v2-private/js/tokens/base/typography/typography.js +1 -1
  211. package/tokens-v2-private/js/tokens/functional/size/border.js +1 -1
  212. package/tokens-v2-private/js/tokens/functional/size/breakpoints.js +1 -1
  213. package/tokens-v2-private/js/tokens/functional/size/size-coarse.js +1 -1
  214. package/tokens-v2-private/js/tokens/functional/size/size-fine.js +1 -1
  215. package/tokens-v2-private/js/tokens/functional/size/size.js +1 -1
  216. package/tokens-v2-private/js/tokens/functional/size/viewport.js +1 -1
  217. package/tokens-v2-private/js/tokens/functional/typography/typography.js +1 -1
  218. package/tokens-v2-private/scss/tokens/base/size/size.scss +1 -1
  219. package/tokens-v2-private/scss/tokens/base/typography/typography.scss +1 -1
  220. package/tokens-v2-private/scss/tokens/functional/size/border.scss +1 -1
  221. package/tokens-v2-private/scss/tokens/functional/size/breakpoints.scss +1 -1
  222. package/tokens-v2-private/scss/tokens/functional/size/size-coarse.scss +1 -1
  223. package/tokens-v2-private/scss/tokens/functional/size/size-fine.scss +1 -1
  224. package/tokens-v2-private/scss/tokens/functional/size/size.scss +1 -1
  225. package/tokens-v2-private/scss/tokens/functional/size/viewport.scss +1 -1
  226. package/tokens-v2-private/scss/tokens/functional/typography/typography.scss +1 -1
  227. package/tokens-v2-private/ts/tokens/base/size/size.d.ts +1 -1
  228. package/tokens-v2-private/ts/tokens/base/size/size.js +1 -1
  229. package/tokens-v2-private/ts/tokens/base/typography/typography.d.ts +1 -1
  230. package/tokens-v2-private/ts/tokens/base/typography/typography.js +1 -1
  231. package/tokens-v2-private/ts/tokens/functional/size/border.d.ts +1 -1
  232. package/tokens-v2-private/ts/tokens/functional/size/border.js +1 -1
  233. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.d.ts +1 -1
  234. package/tokens-v2-private/ts/tokens/functional/size/breakpoints.js +1 -1
  235. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.d.ts +1 -1
  236. package/tokens-v2-private/ts/tokens/functional/size/size-coarse.js +1 -1
  237. package/tokens-v2-private/ts/tokens/functional/size/size-fine.d.ts +1 -1
  238. package/tokens-v2-private/ts/tokens/functional/size/size-fine.js +1 -1
  239. package/tokens-v2-private/ts/tokens/functional/size/size.d.ts +1 -1
  240. package/tokens-v2-private/ts/tokens/functional/size/size.js +1 -1
  241. package/tokens-v2-private/ts/tokens/functional/size/viewport.d.ts +1 -1
  242. package/tokens-v2-private/ts/tokens/functional/size/viewport.js +1 -1
  243. package/tokens-v2-private/ts/tokens/functional/typography/typography.d.ts +1 -1
  244. package/tokens-v2-private/ts/tokens/functional/typography/typography.js +1 -1
  245. package/dist/deprecated/colors.json +0 -7
  246. package/dist/js/colors/dark.d.ts +0 -516
  247. package/dist/js/colors/dark.js +0 -616
  248. package/dist/js/colors/dark_colorblind.d.ts +0 -516
  249. package/dist/js/colors/dark_colorblind.js +0 -616
  250. package/dist/js/colors/dark_dimmed.d.ts +0 -516
  251. package/dist/js/colors/dark_dimmed.js +0 -616
  252. package/dist/js/colors/dark_high_contrast.d.ts +0 -516
  253. package/dist/js/colors/dark_high_contrast.js +0 -616
  254. package/dist/js/colors/dark_tritanopia.d.ts +0 -516
  255. package/dist/js/colors/dark_tritanopia.js +0 -616
  256. package/dist/js/colors/index.d.ts +0 -4638
  257. package/dist/js/colors/index.js +0 -15
  258. package/dist/js/colors/light.d.ts +0 -516
  259. package/dist/js/colors/light.js +0 -616
  260. package/dist/js/colors/light_colorblind.d.ts +0 -516
  261. package/dist/js/colors/light_colorblind.js +0 -616
  262. package/dist/js/colors/light_high_contrast.d.ts +0 -516
  263. package/dist/js/colors/light_high_contrast.js +0 -616
  264. package/dist/js/colors/light_tritanopia.d.ts +0 -516
  265. package/dist/js/colors/light_tritanopia.js +0 -616
  266. package/dist/js/index.d.ts +0 -4655
  267. package/dist/js/index.js +0 -9
  268. package/dist/js/spacing/index.d.ts +0 -6
  269. package/dist/js/spacing/index.js +0 -7
  270. package/dist/js/spacing/normal.d.ts +0 -4
  271. package/dist/js/spacing/normal.js +0 -13
  272. package/dist/js/typography/index.d.ts +0 -11
  273. package/dist/js/typography/index.js +0 -7
  274. package/dist/js/typography/normal.d.ts +0 -9
  275. package/dist/js/typography/normal.js +0 -19
  276. package/dist/json/colors/dark.json +0 -614
  277. package/dist/json/colors/dark_colorblind.json +0 -614
  278. package/dist/json/colors/dark_dimmed.json +0 -614
  279. package/dist/json/colors/dark_high_contrast.json +0 -614
  280. package/dist/json/colors/dark_tritanopia.json +0 -614
  281. package/dist/json/colors/light.json +0 -614
  282. package/dist/json/colors/light_colorblind.json +0 -614
  283. package/dist/json/colors/light_high_contrast.json +0 -614
  284. package/dist/json/colors/light_tritanopia.json +0 -614
  285. package/dist/json/spacing/normal.json +0 -11
  286. package/dist/json/typography/normal.json +0 -17
  287. package/dist/removed/colors.json +0 -432
  288. package/dist/scss/colors/_dark.scss +0 -452
  289. package/dist/scss/colors/_dark_colorblind.scss +0 -452
  290. package/dist/scss/colors/_dark_dimmed.scss +0 -452
  291. package/dist/scss/colors/_dark_high_contrast.scss +0 -452
  292. package/dist/scss/colors/_dark_tritanopia.scss +0 -452
  293. package/dist/scss/colors/_light.scss +0 -452
  294. package/dist/scss/colors/_light_colorblind.scss +0 -452
  295. package/dist/scss/colors/_light_high_contrast.scss +0 -452
  296. package/dist/scss/colors/_light_tritanopia.scss +0 -452
  297. package/dist/scss/spacing/_normal.scss +0 -11
  298. package/dist/scss/typography/_normal.scss +0 -15
  299. package/dist/ts/colors/dark.ts +0 -614
  300. package/dist/ts/colors/dark_colorblind.ts +0 -614
  301. package/dist/ts/colors/dark_dimmed.ts +0 -614
  302. package/dist/ts/colors/dark_high_contrast.ts +0 -614
  303. package/dist/ts/colors/dark_tritanopia.ts +0 -614
  304. package/dist/ts/colors/index.ts +0 -10
  305. package/dist/ts/colors/light.ts +0 -614
  306. package/dist/ts/colors/light_colorblind.ts +0 -614
  307. package/dist/ts/colors/light_high_contrast.ts +0 -614
  308. package/dist/ts/colors/light_tritanopia.ts +0 -614
  309. package/dist/ts/index.ts +0 -4
  310. package/dist/ts/spacing/index.ts +0 -2
  311. package/dist/ts/spacing/normal.ts +0 -11
  312. package/dist/ts/typography/index.ts +0 -2
  313. package/dist/ts/typography/normal.ts +0 -17
  314. package/tokens-next-private/css/base/size/size.css +0 -19
  315. package/tokens-next-private/css/base/typography/typography.css +0 -6
  316. package/tokens-next-private/css/functional/motion/motion.css +0 -5
  317. package/tokens-next-private/css/functional/size/border.css +0 -14
  318. package/tokens-next-private/css/functional/size/breakpoints.css +0 -8
  319. package/tokens-next-private/css/functional/size/size-coarse.css +0 -7
  320. package/tokens-next-private/css/functional/size/size-fine.css +0 -7
  321. package/tokens-next-private/css/functional/size/size.css +0 -74
  322. package/tokens-next-private/css/functional/size/viewport.css +0 -6
  323. package/tokens-next-private/css/functional/themes/dark-colorblind.css +0 -1078
  324. package/tokens-next-private/css/functional/themes/dark-dimmed.css +0 -1078
  325. package/tokens-next-private/css/functional/themes/dark-high-contrast.css +0 -1078
  326. package/tokens-next-private/css/functional/themes/dark-tritanopia.css +0 -1078
  327. package/tokens-next-private/css/functional/themes/dark.css +0 -1078
  328. package/tokens-next-private/css/functional/themes/light-colorblind.css +0 -1078
  329. package/tokens-next-private/css/functional/themes/light-high-contrast.css +0 -1078
  330. package/tokens-next-private/css/functional/themes/light-tritanopia.css +0 -1078
  331. package/tokens-next-private/css/functional/themes/light.css +0 -1078
  332. package/tokens-next-private/css/functional/typography/typography.css +0 -47
  333. package/tokens-next-private/fallbacks/base/size/size.json +0 -19
  334. package/tokens-next-private/fallbacks/base/typography/typography.json +0 -6
  335. package/tokens-next-private/fallbacks/functional/motion/motion.json +0 -5
  336. package/tokens-next-private/fallbacks/functional/size/border.json +0 -14
  337. package/tokens-next-private/fallbacks/functional/size/breakpoints.json +0 -8
  338. package/tokens-next-private/fallbacks/functional/size/size-coarse.json +0 -5
  339. package/tokens-next-private/fallbacks/functional/size/size-fine.json +0 -5
  340. package/tokens-next-private/fallbacks/functional/size/size.json +0 -74
  341. package/tokens-next-private/fallbacks/functional/size/viewport.json +0 -8
  342. package/tokens-next-private/fallbacks/functional/typography/typography.json +0 -47
  343. package/tokens-next-private/internalCss/dark-colorblind.css +0 -1648
  344. package/tokens-next-private/internalCss/dark-dimmed.css +0 -1648
  345. package/tokens-next-private/internalCss/dark-high-contrast.css +0 -1648
  346. package/tokens-next-private/internalCss/dark-tritanopia.css +0 -1648
  347. package/tokens-next-private/internalCss/dark.css +0 -1648
  348. package/tokens-next-private/internalCss/light-colorblind.css +0 -1648
  349. package/tokens-next-private/internalCss/light-high-contrast.css +0 -1648
  350. package/tokens-next-private/internalCss/light-tritanopia.css +0 -1648
  351. package/tokens-next-private/internalCss/light.css +0 -1648
  352. /package/{tokens-next-private/docs → dist/styleLint}/base/typography/typography.json +0 -0
  353. /package/{tokens-next-private/docs → dist/styleLint}/functional/motion/motion.json +0 -0
  354. /package/{tokens-next-private/docs → dist/styleLint}/functional/themes/dark-dimmed.json +0 -0
  355. /package/{tokens-next-private/docs → dist/styleLint}/functional/themes/dark-high-contrast.json +0 -0
  356. /package/{tokens-next-private/docs → dist/styleLint}/functional/themes/light-colorblind.json +0 -0
  357. /package/{tokens-next-private/docs → dist/styleLint}/functional/themes/light-high-contrast.json +0 -0
  358. /package/{tokens-next-private/docs → dist/styleLint}/functional/themes/light-tritanopia.json +0 -0
  359. /package/{tokens-next-private/docs → dist/styleLint}/functional/themes/light.json +0 -0
  360. /package/{tokens-next-private → src/tokens}/removed/color.json +0 -0
@@ -0,0 +1,55 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ type FigmaVariableScope =
4
+ | 'ALL_SCOPES'
5
+ | 'TEXT_CONTENT'
6
+ | 'CORNER_RADIUS'
7
+ | 'WIDTH_HEIGHT'
8
+ | 'GAP'
9
+ | 'ALL_FILLS'
10
+ | 'FRAME_FILL'
11
+ | 'SHAPE_FILL'
12
+ | 'TEXT_FILL'
13
+ | 'STROKE_COLOR'
14
+
15
+ const figmaScopes: Record<string, FigmaVariableScope[]> = {
16
+ all: ['ALL_SCOPES'],
17
+ radius: ['CORNER_RADIUS'],
18
+ size: ['WIDTH_HEIGHT'],
19
+ gap: ['GAP'],
20
+ bgColor: ['FRAME_FILL', 'SHAPE_FILL'],
21
+ fgColor: ['TEXT_FILL', 'SHAPE_FILL'],
22
+ borderColor: ['STROKE_COLOR'],
23
+ }
24
+
25
+ const getScopes = (scopes: string[] | string | undefined): FigmaVariableScope[] => {
26
+ if (typeof scopes === 'string') scopes = [scopes]
27
+ if (Array.isArray(scopes))
28
+ return scopes
29
+ .map(scope => {
30
+ if (scope in figmaScopes) return figmaScopes[scope]
31
+ throw new Error(`Invalid scope: ${scope}`)
32
+ })
33
+ .flat() as FigmaVariableScope[]
34
+
35
+ return ['ALL_SCOPES']
36
+ }
37
+ /**
38
+ * @description retrieves figma attributes from token and adds them to attributes
39
+ * @type attribute transformer — [StyleDictionary.AttributeTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
40
+ * @matcher matches all tokens
41
+ * @transformer returns ab object of figma attributes
42
+ */
43
+ export const figmaAttributes: StyleDictionary.Transform = {
44
+ type: `attribute`,
45
+ transformer: (token: StyleDictionary.TransformedToken, platform: StyleDictionary.Platform = {}) => {
46
+ const {mode, collection, scopes, group, codeSyntax} = token.$extensions?.['org.primer.figma'] || {}
47
+ return {
48
+ mode: platform.options?.mode || mode || 'default',
49
+ collection,
50
+ group: group || collection,
51
+ scopes: getScopes(scopes),
52
+ codeSyntax,
53
+ }
54
+ },
55
+ }
@@ -0,0 +1,38 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {isFontFamily} from '../filters'
3
+ import {getTokenValue} from './utilities/getTokenValue'
4
+
5
+ const hasSpaceInName = (string: string) => /\s/g.test(string)
6
+ /**
7
+ * takes a value and returns it if its a string or concats strings in an array quoting strings with spaces
8
+ * @param value
9
+ * @returns string
10
+ */
11
+ export const parseFontFamily = (value: unknown): string => {
12
+ if (typeof value === 'string') {
13
+ return value
14
+ }
15
+ if (Array.isArray(value)) {
16
+ return value
17
+ .map((string: string) => {
18
+ if (typeof string !== 'string') {
19
+ throw new Error(`Invalid value in array ${string}, must be a string`)
20
+ }
21
+ return hasSpaceInName(string) ? `'${string}'` : string
22
+ })
23
+ .join(', ')
24
+ }
25
+ throw new Error(`Invalid value ${value}, should be a string or array of strings`)
26
+ }
27
+ /**
28
+ * @description converts fontFamily tokens value to string
29
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
30
+ * @matcher matches all tokens of $type `fontFamily`
31
+ * @transformer returns a number
32
+ */
33
+ export const fontFamilyToCss: StyleDictionary.Transform = {
34
+ type: `value`,
35
+ transitive: true,
36
+ matcher: isFontFamily,
37
+ transformer: (token: StyleDictionary.TransformedToken): string => parseFontFamily(getTokenValue(token)),
38
+ }
@@ -0,0 +1,53 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {isFontWeight} from '../filters'
3
+ import {getTokenValue} from './utilities/getTokenValue'
4
+
5
+ const fontWeightMatrix: Record<string, string[]> = {
6
+ '100': ['thin', 'hairline'],
7
+ '200': ['extra-light', 'ultra-light'],
8
+ '300': ['light'],
9
+ '400': ['normal', 'regular', 'book'],
10
+ '500': ['medium'],
11
+ '600': ['semi-bold', 'demi-bold'],
12
+ '700': ['bold'],
13
+ '800': ['extra-bold', 'ultra-bold'],
14
+ '900': ['black', 'heavy'],
15
+ '950': ['extra-black', 'ultra-black'],
16
+ }
17
+
18
+ export const parseFontWeight = (value: unknown): number => {
19
+ // throw on anything but string and number
20
+ if (typeof value !== 'string' && typeof value !== 'number') {
21
+ throw new Error(`Invalid value ${value}, should be a number or fontWeight string`)
22
+ }
23
+ // valid string
24
+ if (typeof value === 'string') {
25
+ const key = Object.keys(fontWeightMatrix).find((k: string) => fontWeightMatrix[k].includes(value as string))
26
+ if (key !== undefined) {
27
+ return parseInt(key)
28
+ }
29
+ }
30
+ // if number as string
31
+ if (typeof value === 'string' && typeof parseInt(value) === 'number' && !isNaN(parseInt(value))) {
32
+ value = parseInt(value)
33
+ }
34
+ // return if valid numver
35
+ if (typeof value === 'number' && value > 0 && value <= 1000) {
36
+ return value
37
+ }
38
+ // invalid value
39
+ throw new Error(`Invalid value ${value}, should be a number or fontWeight string`)
40
+ }
41
+
42
+ /**
43
+ * @description converts fontWeight tokens value to numeric value
44
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
45
+ * @matcher matches all tokens of $type `fontWeight`
46
+ * @transformer returns a number
47
+ */
48
+ export const fontWeightToNumber: StyleDictionary.Transform = {
49
+ type: `value`,
50
+ transitive: true,
51
+ matcher: isFontWeight,
52
+ transformer: (token: StyleDictionary.TransformedToken): number => parseFontWeight(getTokenValue(token)),
53
+ }
@@ -0,0 +1,21 @@
1
+ export {borderToCss} from './borderToCss'
2
+ export {colorToHex} from './colorToHex'
3
+ export {colorToHexAlpha} from './colorToHexAlpha'
4
+ export {colorToHexMix} from './colorToHexMix'
5
+ export {colorToRgbAlpha} from './colorToRgbAlpha'
6
+ export {colorToRgbaFloat} from './colorToRgbaFloat'
7
+ export {dimensionToRem} from './dimensionToRem'
8
+ export {dimensionToRemPxArray} from './dimensionToRemPxArray'
9
+ export {dimensionToPixelUnitless} from './dimensionToPixelUnitless'
10
+ export {durationToCss} from './durationToCss'
11
+ export {figmaAttributes} from './figmaAttributes'
12
+ export {fontFamilyToCss} from './fontFamilyToCss'
13
+ export {fontWeightToNumber} from './fontWeightToNumber'
14
+ export {jsonDeprecated} from './jsonDeprecated'
15
+ export {namePathToCamelCase} from './namePathToCamelCase'
16
+ export {namePathToDotNotation} from './namePathToDotNotation'
17
+ export {namePathToFigma} from './namePathToFigma'
18
+ export {namePathToKebabCase} from './namePathToKebabCase'
19
+ export {namePathToSlashNotation} from './namePathToSlashNotation'
20
+ export {shadowToCss} from './shadowToCss'
21
+ export {typographyToCss} from './typographyToCss'
@@ -0,0 +1,15 @@
1
+ import {isDeprecated} from '../filters'
2
+ import type StyleDictionary from 'style-dictionary'
3
+ /**
4
+ * @description replaces tokens value with content of tokens `deprecated` property
5
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
6
+ * @matcher matches all tokens with a `deprecated` property
7
+ * @transformer returns `string` specified in `token.deprecated` or `null`
8
+ */
9
+ export const jsonDeprecated: StyleDictionary.Transform = {
10
+ type: `value`,
11
+ transitive: true,
12
+ matcher: isDeprecated,
13
+ transformer: (token: StyleDictionary.TransformedToken) =>
14
+ typeof token.deprecated === 'string' ? token.deprecated.replace(/[{}]/g, '') : null,
15
+ }
@@ -0,0 +1,14 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {toCamelCase} from '../utilities'
3
+
4
+ /**
5
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a camelCase string, preserves casing of parts
6
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
7
+ * @matcher omitted to match all tokens
8
+ * @transformer returns `string` camelCase
9
+ */
10
+ export const namePathToCamelCase: StyleDictionary.Transform = {
11
+ type: `name`,
12
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string =>
13
+ toCamelCase([options?.prefix || '', ...token.path]),
14
+ }
@@ -0,0 +1,34 @@
1
+ import {upperCaseFirstCharacter} from '../utilities'
2
+ import type StyleDictionary from 'style-dictionary'
3
+
4
+ /**
5
+ * camelCase
6
+ * @scope custom camelCase implementation should only be used within `name path to dot notation` transformer
7
+ * @description replaces space ` `, dash `-`, underscore `_` and plus `+` by camelCasing e.g. `camel-case` -> `camelCase`
8
+ * @param string
9
+ * @returns string
10
+ */
11
+ const camelCase = (string: string): string => {
12
+ return string
13
+ .split(/[\s-_+]+/g)
14
+ .map((stringPart: string, index: number) => (index === 0 ? stringPart : upperCaseFirstCharacter(stringPart)))
15
+ .join('')
16
+ }
17
+ /**
18
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a dot.notation string
19
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
20
+ * @matcher omitted to match all tokens
21
+ * @transformer returns `string` in dot.notation
22
+ */
23
+ export const namePathToDotNotation: StyleDictionary.Transform = {
24
+ type: `name`,
25
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string => {
26
+ return (
27
+ [options?.prefix, ...token.path]
28
+ // remove undefined if exists
29
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
30
+ .map((part: string) => camelCase(part))
31
+ .join('.')
32
+ )
33
+ },
34
+ }
@@ -0,0 +1,28 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ export const transformNamePathToFigma = (
4
+ token: StyleDictionary.TransformedToken,
5
+ options?: StyleDictionary.Platform,
6
+ ): string => {
7
+ let pathArray = token.path.filter((part: unknown): part is string => part !== '@')
8
+ if (['fgColor', 'borderColor', 'bgColor'].includes(pathArray[0]) && pathArray.length === 3) {
9
+ pathArray = [pathArray[0], `${pathArray[1]}-${pathArray[2]}`]
10
+ }
11
+ return (
12
+ [options?.prefix, ...pathArray]
13
+ // remove undefined if exists
14
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
15
+ .join('/')
16
+ )
17
+ }
18
+
19
+ /**
20
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a specific figma name
21
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
22
+ * @matcher omitted to match all tokens
23
+ * @transformer returns `string`
24
+ */
25
+ export const namePathToFigma: StyleDictionary.Transform = {
26
+ type: `name`,
27
+ transformer: transformNamePathToFigma,
28
+ }
@@ -0,0 +1,19 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ /**
4
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a kebab-case string, preserves casing of parts
5
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
6
+ * @matcher omitted to match all tokens
7
+ * @transformer returns `string` kebab-case
8
+ */
9
+ export const namePathToKebabCase: StyleDictionary.Transform = {
10
+ type: `name`,
11
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string => {
12
+ return (
13
+ [options?.prefix, ...token.path]
14
+ // remove undefined if exists
15
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
16
+ .join('-')
17
+ )
18
+ },
19
+ }
@@ -0,0 +1,19 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ /**
4
+ * @description converts the [TransformedToken's](https://github.com/amzn/style-dictionary/blob/main/types/TransformedToken.d.ts) `.path` array to a slash/notation string
5
+ * @type name transformer — [StyleDictionary.NameTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
6
+ * @matcher omitted to match all tokens
7
+ * @transformer returns `string` on slash/notation
8
+ */
9
+ export const namePathToSlashNotation: StyleDictionary.Transform = {
10
+ type: `name`,
11
+ transformer: (token: StyleDictionary.TransformedToken, options?: StyleDictionary.Platform): string => {
12
+ return (
13
+ [options?.prefix, ...token.path]
14
+ // remove undefined if exists
15
+ .filter((part: unknown): part is string => typeof part === 'string' && part !== '@')
16
+ .join('/')
17
+ )
18
+ },
19
+ }
@@ -0,0 +1,37 @@
1
+ import {toHex} from 'color2k'
2
+ import {isShadow} from '../filters'
3
+ import {alpha} from './utilities/alpha'
4
+ import {checkRequiredTokenProperties} from './utilities/checkRequiredTokenProperties'
5
+ import type {ShadowTokenValue} from '../types/ShadowTokenValue'
6
+ import type StyleDictionary from 'style-dictionary'
7
+ import {getTokenValue} from './utilities/getTokenValue'
8
+
9
+ /**
10
+ * @description converts w3c shadow tokens in css shadow string
11
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
12
+ * @matcher matches all tokens of $type `shadow`
13
+ * @transformer returns css shadow `string`
14
+ */
15
+ export const shadowToCss: StyleDictionary.Transform = {
16
+ type: `value`,
17
+ transitive: true,
18
+ matcher: isShadow,
19
+ transformer: (token: StyleDictionary.TransformedToken) => {
20
+ // extract value
21
+ const {value}: {value: ShadowTokenValue | ShadowTokenValue[]} = token
22
+ // turn value into array
23
+ const shadowValues = !Array.isArray(value) ? [value] : value
24
+
25
+ return shadowValues
26
+ .map((shadow: ShadowTokenValue) => {
27
+ // if value === string it was probably already transformed
28
+ if (typeof shadow === 'string') return shadow
29
+ checkRequiredTokenProperties(shadow, ['color', 'offsetX', 'offsetY', 'blur', 'spread'])
30
+ /*css box shadow: inset? | offset-x | offset-y | blur-radius | spread-radius | color */
31
+ return `${shadow.inset === true ? 'inset ' : ''}${shadow.offsetX} ${shadow.offsetY} ${shadow.blur} ${
32
+ shadow.spread
33
+ } ${toHex(alpha(getTokenValue({...token, ...{value: shadow}}, 'color'), shadow.alpha || 1, token))}`
34
+ })
35
+ .join(', ')
36
+ },
37
+ }
@@ -0,0 +1,31 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {isTypography} from '../filters'
3
+ import type {TypographyTokenValue} from '../types/TypographyTokenValue'
4
+ import {checkRequiredTokenProperties} from './utilities/checkRequiredTokenProperties'
5
+ import {parseFontFamily} from './fontFamilyToCss'
6
+ import {parseFontWeight} from './fontWeightToNumber'
7
+ import {getTokenValue} from './utilities/getTokenValue'
8
+
9
+ /**
10
+ * @description converts typograhy token value to css font shorthand
11
+ * @type value transformer — [StyleDictionary.ValueTransform](https://github.com/amzn/style-dictionary/blob/main/types/Transform.d.ts)
12
+ * @matcher matches all tokens of $type `typography`
13
+ * @transformer returns a css font string
14
+ */
15
+ export const typographyToCss: StyleDictionary.Transform = {
16
+ type: `value`,
17
+ transitive: true,
18
+ matcher: isTypography,
19
+ transformer: (token: StyleDictionary.TransformedToken) => {
20
+ // extract value
21
+ const value: TypographyTokenValue = getTokenValue(token)
22
+ // validate token properties
23
+ checkRequiredTokenProperties(value, ['fontWeight', 'fontSize', 'fontFamily'])
24
+ // format output
25
+ return `${value.fontStyle || ''} ${parseFontWeight(getTokenValue(token, 'fontWeight'))} ${value.fontSize}${
26
+ value.lineHeight ? `/${value.lineHeight}` : ''
27
+ } ${parseFontFamily(getTokenValue(token, 'fontFamily'))}`
28
+ .trim()
29
+ .replace(/\s\s+/g, ' ')
30
+ },
31
+ }
@@ -0,0 +1,23 @@
1
+ import {rgba, parseToRgba} from 'color2k'
2
+ import type {TransformedToken} from 'style-dictionary'
3
+ /**
4
+ * alpha
5
+ * @description takes a colors string like hex or rgba and returns an rgba color with the specified alpha value
6
+ * @param color color string like a `#334455` or `rgb(255,200,100)`
7
+ * @param desiredAlpha number
8
+ * @returns rgba value
9
+ */
10
+ export const alpha = (color: string, desiredAlpha: number, token?: TransformedToken): string => {
11
+ const [r, g, b, a] = parseToRgba(color)
12
+
13
+ if (a < 1 && desiredAlpha < 1) {
14
+ // eslint-disable-next-line no-console
15
+ console.warn(
16
+ `🚨 You are setting an alpha value of "${desiredAlpha}" for a color with an alpha value (${color}). The previous alpha value will be disregarded as if the color would have been 100% opaque.${
17
+ token !== undefined ? `\n ↳ Token: "${token.name}" in file: "${token.filePath}"` : ''
18
+ }`,
19
+ )
20
+ }
21
+
22
+ return rgba(r, g, b, desiredAlpha)
23
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * checks if all required properties exist on token
3
+ * @param object - tokenValue
4
+ * @param array - property names
5
+ * @returns void or throws error
6
+ */
7
+ export const checkRequiredTokenProperties = (
8
+ tokenValue: Record<string, unknown>,
9
+ requiredProperties: readonly string[],
10
+ ) => {
11
+ for (const prop of requiredProperties) {
12
+ if (prop in tokenValue === false) {
13
+ throw new Error(`Missing property: ${prop} on token with value ${JSON.stringify(tokenValue)}`)
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,18 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+ import {invalidTokenValueError, invalidTokenValuePropertyError} from './invalidTokenError'
3
+
4
+ export const getTokenValue = (token: StyleDictionary.TransformedToken, property?: string) => {
5
+ if (token.value === undefined) {
6
+ throw new invalidTokenValueError(token)
7
+ }
8
+ // for composite token if subproperty is needed
9
+ if (typeof property === 'string' && token.value[property] === undefined) {
10
+ throw new invalidTokenValuePropertyError(token, property)
11
+ }
12
+
13
+ if (typeof property === 'string') {
14
+ return token.value[property]
15
+ }
16
+
17
+ return token.value
18
+ }
@@ -0,0 +1,31 @@
1
+ import type {RgbaFloat} from './isRgbaFloat'
2
+
3
+ export const hexToRgbaFloat = (hex: string, alpha?: number): RgbaFloat => {
4
+ // retrieve spots from hex value (hex 3, hex 4, hex 6 or hex 8)
5
+ let result
6
+ if (hex.length > 5) {
7
+ result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(hex)
8
+ } else {
9
+ result = /^#?([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})([a-f\d]{1})?$/i.exec(hex)
10
+ }
11
+
12
+ if (result === null) {
13
+ throw new Error('Invalid hex value in "hexToRgbaFloat". Please provide a valid hex3, hex4, hex6 or hex8 value.')
14
+ }
15
+ // doule characters if hex 3 or hex 4
16
+ if (hex.length < 6) {
17
+ result[1] = `${result[1]}${result[1]}` // double the character
18
+ result[2] = `${result[2]}${result[2]}` // double the character
19
+ result[3] = `${result[3]}${result[3]}` // double the character
20
+ if (result[4]) {
21
+ result[4] = `${result[4]}${result[4]}` // double the character
22
+ }
23
+ }
24
+ // return parsed rgba float object using alpha value from token, from hex code or defaults to 1
25
+ return {
26
+ r: parseInt(result[1], 16) / 255,
27
+ g: parseInt(result[2], 16) / 255,
28
+ b: parseInt(result[3], 16) / 255,
29
+ a: alpha !== undefined ? alpha : result[4] ? parseInt(result[4], 16) / 255 : 1,
30
+ }
31
+ }
@@ -0,0 +1,34 @@
1
+ import type {TransformedToken} from 'style-dictionary'
2
+ import {namePathToDotNotation} from '../namePathToDotNotation'
3
+
4
+ const composeValueErrorMessage = (token: TransformedToken) => {
5
+ // eslint-disable-next-line i18n-text/no-en
6
+ return `Invalid token "${namePathToDotNotation.transformer(token, {})}" in file "${
7
+ token.filePath
8
+ }". Transformed value: "${JSON.stringify(token.value)}". ${
9
+ token.original.value ? `Original value: "${JSON.stringify(token.original.value)}" ` : ''
10
+ }This may be due to referencing a token that does not exists.`
11
+ }
12
+
13
+ const composeValuePropertyErrorMessage = (token: TransformedToken, property: string) => {
14
+ // eslint-disable-next-line i18n-text/no-en
15
+ return `Invalid property "${property}" of token "${namePathToDotNotation.transformer(token, {})}" in file "${
16
+ token.filePath
17
+ }". Transformed property value: "${token.value[property]}". ${
18
+ token.original.value ? `Original value: "${token.original.value[property]}" ` : ''
19
+ }This may be due to referencing a token that does not exists.`
20
+ }
21
+
22
+ export class invalidTokenValueError extends Error {
23
+ constructor(token: TransformedToken) {
24
+ super(composeValueErrorMessage(token))
25
+ Error.captureStackTrace(this, invalidTokenValueError)
26
+ }
27
+ }
28
+
29
+ export class invalidTokenValuePropertyError extends Error {
30
+ constructor(token: TransformedToken, property: string) {
31
+ super(composeValuePropertyErrorMessage(token, property))
32
+ Error.captureStackTrace(this, invalidTokenValuePropertyError)
33
+ }
34
+ }
@@ -0,0 +1,29 @@
1
+ export type RgbaFloat = {
2
+ r: number
3
+ g: number
4
+ b: number
5
+ a?: number
6
+ }
7
+
8
+ // check if a value is an rgba float object
9
+ export const isRgbaFloat = (value: unknown): value is RgbaFloat => {
10
+ if (
11
+ value &&
12
+ typeof value === `object` &&
13
+ 'r' in value &&
14
+ typeof value.r === `number` &&
15
+ 'g' in value &&
16
+ typeof value.g === `number` &&
17
+ 'b' in value &&
18
+ typeof value.b === `number` &&
19
+ value.r >= 0 &&
20
+ value.r <= 1 &&
21
+ value.g >= 0 &&
22
+ value.g <= 1 &&
23
+ value.b >= 0 &&
24
+ value.b <= 1
25
+ ) {
26
+ return true
27
+ }
28
+ return false
29
+ }
@@ -0,0 +1,46 @@
1
+ import {rgba, parseToRgba} from 'color2k'
2
+
3
+ /**
4
+ * Mixes two colors together. Taken from sass's implementation.
5
+ */
6
+ function mix(color1: string, color2: string, weight: number): string {
7
+ const normalize = (n: number, index: number) =>
8
+ // 3rd index is alpha channel which is already normalized
9
+ index === 3 ? n : n / 255
10
+
11
+ const [r1, g1, b1, a1] = parseToRgba(color1).map(normalize)
12
+ const [r2, g2, b2, a2] = parseToRgba(color2).map(normalize)
13
+
14
+ // The formula is copied from the original Sass implementation:
15
+ // http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
16
+ const normalizedWeight = 2 * weight - 1
17
+ const alphaDelta = a1 - a2
18
+
19
+ const combinedWeight =
20
+ normalizedWeight * alphaDelta === -1
21
+ ? normalizedWeight
22
+ : (normalizedWeight + alphaDelta) / (1 + normalizedWeight * alphaDelta)
23
+
24
+ const weight2 = (combinedWeight + 1) / 2
25
+ const weight1 = 1 - weight2
26
+ const r = Math.round((r1 * weight1 + r2 * weight2) * 255)
27
+ const g = Math.round((g1 * weight1 + g2 * weight2) * 255)
28
+ const b = Math.round((b1 * weight1 + b2 * weight2) * 255)
29
+ const a = a2 * weight + a1 * (1 - weight)
30
+ return rgba(r, g, b, a)
31
+ }
32
+
33
+ export default mix
34
+ // Number* weight = ARGR("$weight", Number, 0, 100);
35
+ // double p = weight->value()/100;
36
+ // double w = 2*p - 1;
37
+ // double a = color1->a() - color2->a();
38
+ // double nW = ((w * a == -1) ? w : (w + a)/(1 + w*a))
39
+ // double w1 = (nW + 1)/2.0;
40
+ // double w2 = 1 - w1;
41
+
42
+ // return new (ctx.mem) Color(pstate,
43
+ // std::round(w1*color1->r() + w2*color2->r()),
44
+ // std::round(w1*color1->g() + w2*color2->g()),
45
+ // std::round(w1*color1->b() + w2*color2->b()),
46
+ // color1->a()*p + color2->a()*(1-p));
@@ -0,0 +1,15 @@
1
+ export const rgbaFloatToHex = ({r, g, b, a}: {r: number; g: number; b: number; a?: number}, alpha = true): string => {
2
+ const values = [r, g, b, alpha === true && a && a < 1 ? a : undefined].filter(item => item !== undefined) as number[]
3
+
4
+ if (r > 1 || r < 0 || g > 1 || g < 0 || b > 1 || b < 0) {
5
+ throw new Error('Invalid RgbaFloat value. R, G and B values must be between 0 and 1.')
6
+ }
7
+
8
+ return `#${values
9
+ .map(v =>
10
+ Number(parseInt(`${v * 255}`, 10))
11
+ .toString(16)
12
+ .padStart(2, '0'),
13
+ )
14
+ .join('')}`
15
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @description a css border string
3
+ * @format color | style | width
4
+ */
5
+ type Border = `${ColorHex} ${string} ${string}`
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Type definition for w3c border composite token value
3
+ * @link https://design-tokens.github.io/community-group/format/#border
4
+ */
5
+ export type StrokeStyleString = 'solid' | 'dashed' | 'dotted' | 'double' | 'groove' | 'ridge' | 'outset' | 'inset'
6
+ export type BorderTokenValue = {
7
+ color: string
8
+ width: string
9
+ style: StrokeStyleString
10
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @description hex string (6 or 8-digit)
3
+ */
4
+ type ColorHex = string
@@ -0,0 +1,11 @@
1
+ import type StyleDictionary from 'style-dictionary'
2
+
3
+ export type PlatformInitializer = (
4
+ // the filename including the extension (e.g. `.css`) and any subfolders after the buildPath (e.g. `functional`)
5
+ outputFile: string,
6
+ // the prefix is prepended to all tokens
7
+ prefix: string | undefined,
8
+ // the build path in which the `outputFile` is placed
9
+ buildPath: string,
10
+ options?: StyleDictionary.Options,
11
+ ) => StyleDictionary.Platform
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @description a css shadow
3
+ * @format inset? | offset-x | offset-y | blur-radius? | spread-radius? | color?
4
+ */
5
+ type Shadow = string