@leafygreen-ui/icon 14.7.0 → 14.7.2

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 (390) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/esm/AIModel.js.map +1 -1
  3. package/dist/esm/ActivityFeed.js.map +1 -1
  4. package/dist/esm/AddFile.js.map +1 -1
  5. package/dist/esm/AllProducts.js.map +1 -1
  6. package/dist/esm/AnalyticsNode.js.map +1 -1
  7. package/dist/esm/Apps.js.map +1 -1
  8. package/dist/esm/Array.js.map +1 -1
  9. package/dist/esm/ArrowDown.js.map +1 -1
  10. package/dist/esm/ArrowLeft.js.map +1 -1
  11. package/dist/esm/ArrowRight.js.map +1 -1
  12. package/dist/esm/ArrowUp.js.map +1 -1
  13. package/dist/esm/Award.js.map +1 -1
  14. package/dist/esm/Beaker.js.map +1 -1
  15. package/dist/esm/Bell.js.map +1 -1
  16. package/dist/esm/Biometric.js.map +1 -1
  17. package/dist/esm/Boolean.js.map +1 -1
  18. package/dist/esm/Building.js.map +1 -1
  19. package/dist/esm/Bulb.js.map +1 -1
  20. package/dist/esm/Calendar.js.map +1 -1
  21. package/dist/esm/Camera.js.map +1 -1
  22. package/dist/esm/Cap.js.map +1 -1
  23. package/dist/esm/CaretDown.js.map +1 -1
  24. package/dist/esm/CaretLeft.js.map +1 -1
  25. package/dist/esm/CaretRight.js.map +1 -1
  26. package/dist/esm/CaretUp.js.map +1 -1
  27. package/dist/esm/ChartFilled.js.map +1 -1
  28. package/dist/esm/Charts.js.map +1 -1
  29. package/dist/esm/Checkmark.js.map +1 -1
  30. package/dist/esm/CheckmarkWithCircle.js.map +1 -1
  31. package/dist/esm/ChevronDown.js.map +1 -1
  32. package/dist/esm/ChevronLeft.js.map +1 -1
  33. package/dist/esm/ChevronRight.js.map +1 -1
  34. package/dist/esm/ChevronUp.js.map +1 -1
  35. package/dist/esm/Circle.js.map +1 -1
  36. package/dist/esm/Clock.js.map +1 -1
  37. package/dist/esm/ClockWithArrow.js.map +1 -1
  38. package/dist/esm/Clone.js.map +1 -1
  39. package/dist/esm/Cloud.js.map +1 -1
  40. package/dist/esm/Code.js.map +1 -1
  41. package/dist/esm/CodeBlock.js.map +1 -1
  42. package/dist/esm/Coin.js.map +1 -1
  43. package/dist/esm/Colon.js.map +1 -1
  44. package/dist/esm/Config.js.map +1 -1
  45. package/dist/esm/Connect.js.map +1 -1
  46. package/dist/esm/Copy.js.map +1 -1
  47. package/dist/esm/CreditCard.js.map +1 -1
  48. package/dist/esm/CurlyBraces.js.map +1 -1
  49. package/dist/esm/Cursor.js.map +1 -1
  50. package/dist/esm/Dashboard.js.map +1 -1
  51. package/dist/esm/Database.js.map +1 -1
  52. package/dist/esm/Diagram.js.map +1 -1
  53. package/dist/esm/Diagram2.js.map +1 -1
  54. package/dist/esm/Diagram3.js.map +1 -1
  55. package/dist/esm/Disconnect.js.map +1 -1
  56. package/dist/esm/Download.js.map +1 -1
  57. package/dist/esm/Drag.js.map +1 -1
  58. package/dist/esm/Edit.js.map +1 -1
  59. package/dist/esm/Ellipsis.js.map +1 -1
  60. package/dist/esm/Email.js.map +1 -1
  61. package/dist/esm/EmptyDatabase.js.map +1 -1
  62. package/dist/esm/EmptyFolder.js.map +1 -1
  63. package/dist/esm/Eraser.js.map +1 -1
  64. package/dist/esm/Escalation.js.map +1 -1
  65. package/dist/esm/Export.js.map +1 -1
  66. package/dist/esm/Favorite.js.map +1 -1
  67. package/dist/esm/Federation.js.map +1 -1
  68. package/dist/esm/File.js.map +1 -1
  69. package/dist/esm/Filter.js.map +1 -1
  70. package/dist/esm/Folder.js.map +1 -1
  71. package/dist/esm/Format.js.map +1 -1
  72. package/dist/esm/FullScreenEnter.js.map +1 -1
  73. package/dist/esm/FullScreenExit.js.map +1 -1
  74. package/dist/esm/Function.js.map +1 -1
  75. package/dist/esm/Gauge.js.map +1 -1
  76. package/dist/esm/GlobeAmericas.js.map +1 -1
  77. package/dist/esm/GovernmentBuilding.js.map +1 -1
  78. package/dist/esm/Guide.js.map +1 -1
  79. package/dist/esm/Hash.js.map +1 -1
  80. package/dist/esm/HiddenSecondaryNode.js.map +1 -1
  81. package/dist/esm/Highlight.js.map +1 -1
  82. package/dist/esm/Home.js.map +1 -1
  83. package/dist/esm/HorizontalDrag.js.map +1 -1
  84. package/dist/esm/Import.js.map +1 -1
  85. package/dist/esm/ImportantWithCircle.js.map +1 -1
  86. package/dist/esm/InfoWithCircle.js.map +1 -1
  87. package/dist/esm/InternalEmployee.js.map +1 -1
  88. package/dist/esm/InviteUser.js.map +1 -1
  89. package/dist/esm/Key.js.map +1 -1
  90. package/dist/esm/Laptop.js.map +1 -1
  91. package/dist/esm/LightningBolt.js.map +1 -1
  92. package/dist/esm/Link.js.map +1 -1
  93. package/dist/esm/List.js.map +1 -1
  94. package/dist/esm/Lock.js.map +1 -1
  95. package/dist/esm/LogIn.js.map +1 -1
  96. package/dist/esm/LogOut.js.map +1 -1
  97. package/dist/esm/MagnifyingGlass.js.map +1 -1
  98. package/dist/esm/Megaphone.js.map +1 -1
  99. package/dist/esm/Menu.js.map +1 -1
  100. package/dist/esm/Minus.js.map +1 -1
  101. package/dist/esm/Mobile.js.map +1 -1
  102. package/dist/esm/Moon.js.map +1 -1
  103. package/dist/esm/MultiDirectionArrow.js.map +1 -1
  104. package/dist/esm/MultiLayers.js.map +1 -1
  105. package/dist/esm/NavCollapse.js.map +1 -1
  106. package/dist/esm/NavExpand.js.map +1 -1
  107. package/dist/esm/NoFilter.js.map +1 -1
  108. package/dist/esm/NotAllowed.js.map +1 -1
  109. package/dist/esm/Note.js.map +1 -1
  110. package/dist/esm/NumberedList.js.map +1 -1
  111. package/dist/esm/OpenNewTab.js.map +1 -1
  112. package/dist/esm/OutlineFavorite.js.map +1 -1
  113. package/dist/esm/Package.js.map +1 -1
  114. package/dist/esm/Pause.js.map +1 -1
  115. package/dist/esm/Pending.js.map +1 -1
  116. package/dist/esm/Person.js.map +1 -1
  117. package/dist/esm/PersonGroup.js.map +1 -1
  118. package/dist/esm/PersonWithLock.js.map +1 -1
  119. package/dist/esm/Pin.js.map +1 -1
  120. package/dist/esm/Play.js.map +1 -1
  121. package/dist/esm/Plus.js.map +1 -1
  122. package/dist/esm/PlusWithCircle.js.map +1 -1
  123. package/dist/esm/Primary.js.map +1 -1
  124. package/dist/esm/Project.js.map +1 -1
  125. package/dist/esm/QuestionMarkWithCircle.js.map +1 -1
  126. package/dist/esm/Read.js.map +1 -1
  127. package/dist/esm/Recommended.js.map +1 -1
  128. package/dist/esm/Redo.js.map +1 -1
  129. package/dist/esm/Refresh.js.map +1 -1
  130. package/dist/esm/Relationship.js.map +1 -1
  131. package/dist/esm/ReplicaSet.js.map +1 -1
  132. package/dist/esm/Resize.js.map +1 -1
  133. package/dist/esm/Resource.js.map +1 -1
  134. package/dist/esm/Return.js.map +1 -1
  135. package/dist/esm/Revert.js.map +1 -1
  136. package/dist/esm/Router.js.map +1 -1
  137. package/dist/esm/SMS.js.map +1 -1
  138. package/dist/esm/Save.js.map +1 -1
  139. package/dist/esm/SearchIndex.js.map +1 -1
  140. package/dist/esm/Secondary.js.map +1 -1
  141. package/dist/esm/Serverless.js.map +1 -1
  142. package/dist/esm/Settings.js.map +1 -1
  143. package/dist/esm/ShardedCluster.js.map +1 -1
  144. package/dist/esm/Shell.js.map +1 -1
  145. package/dist/esm/Shield.js.map +1 -1
  146. package/dist/esm/Shirt.js.map +1 -1
  147. package/dist/esm/Shortcut.js.map +1 -1
  148. package/dist/esm/SortAscending.js.map +1 -1
  149. package/dist/esm/SortDescending.js.map +1 -1
  150. package/dist/esm/Sparkle.js.map +1 -1
  151. package/dist/esm/SplitHorizontal.js.map +1 -1
  152. package/dist/esm/SplitVertical.js.map +1 -1
  153. package/dist/esm/Stitch.js.map +1 -1
  154. package/dist/esm/Stop.js.map +1 -1
  155. package/dist/esm/Streaming.js.map +1 -1
  156. package/dist/esm/String.js.map +1 -1
  157. package/dist/esm/Sun.js.map +1 -1
  158. package/dist/esm/Support.js.map +1 -1
  159. package/dist/esm/Sweep.js.map +1 -1
  160. package/dist/esm/Table.js.map +1 -1
  161. package/dist/esm/Tag.js.map +1 -1
  162. package/dist/esm/TemporaryTable.js.map +1 -1
  163. package/dist/esm/ThumbsDown.js.map +1 -1
  164. package/dist/esm/ThumbsUp.js.map +1 -1
  165. package/dist/esm/TimeSeries.js.map +1 -1
  166. package/dist/esm/TimeSeriesCollection.js.map +1 -1
  167. package/dist/esm/Trash.js.map +1 -1
  168. package/dist/esm/Undo.js.map +1 -1
  169. package/dist/esm/University.js.map +1 -1
  170. package/dist/esm/Unlock.js.map +1 -1
  171. package/dist/esm/Unsorted.js.map +1 -1
  172. package/dist/esm/UpDownCarets.js.map +1 -1
  173. package/dist/esm/Upload.js.map +1 -1
  174. package/dist/esm/VerticalEllipsis.js.map +1 -1
  175. package/dist/esm/View.js.map +1 -1
  176. package/dist/esm/Visibility.js.map +1 -1
  177. package/dist/esm/VisibilityOff.js.map +1 -1
  178. package/dist/esm/Warning.js.map +1 -1
  179. package/dist/esm/Wizard.js.map +1 -1
  180. package/dist/esm/Wrench.js.map +1 -1
  181. package/dist/esm/Write.js.map +1 -1
  182. package/dist/esm/X.js.map +1 -1
  183. package/dist/esm/XWithCircle.js.map +1 -1
  184. package/dist/esm/glyphCommon-cTThlth0.js.map +1 -1
  185. package/dist/esm/index.js +1 -1
  186. package/dist/esm/index.js.map +1 -1
  187. package/dist/types/createGlyphComponent.d.ts.map +1 -1
  188. package/dist/types/createGlyphComponent.spec.d.ts +2 -0
  189. package/dist/types/createGlyphComponent.spec.d.ts.map +1 -0
  190. package/dist/types/createIconComponent.d.ts.map +1 -1
  191. package/dist/types/createIconComponent.spec.d.ts +2 -0
  192. package/dist/types/createIconComponent.spec.d.ts.map +1 -0
  193. package/dist/types/testUtils.d.ts +10 -0
  194. package/dist/types/testUtils.d.ts.map +1 -0
  195. package/dist/umd/AIModel.js.map +1 -1
  196. package/dist/umd/ActivityFeed.js.map +1 -1
  197. package/dist/umd/AddFile.js.map +1 -1
  198. package/dist/umd/AllProducts.js.map +1 -1
  199. package/dist/umd/AnalyticsNode.js.map +1 -1
  200. package/dist/umd/Apps.js.map +1 -1
  201. package/dist/umd/Array.js.map +1 -1
  202. package/dist/umd/ArrowDown.js.map +1 -1
  203. package/dist/umd/ArrowLeft.js.map +1 -1
  204. package/dist/umd/ArrowRight.js.map +1 -1
  205. package/dist/umd/ArrowUp.js.map +1 -1
  206. package/dist/umd/Award.js.map +1 -1
  207. package/dist/umd/Beaker.js.map +1 -1
  208. package/dist/umd/Bell.js.map +1 -1
  209. package/dist/umd/Biometric.js.map +1 -1
  210. package/dist/umd/Boolean.js.map +1 -1
  211. package/dist/umd/Building.js.map +1 -1
  212. package/dist/umd/Bulb.js.map +1 -1
  213. package/dist/umd/Calendar.js.map +1 -1
  214. package/dist/umd/Camera.js.map +1 -1
  215. package/dist/umd/Cap.js.map +1 -1
  216. package/dist/umd/CaretDown.js.map +1 -1
  217. package/dist/umd/CaretLeft.js.map +1 -1
  218. package/dist/umd/CaretRight.js.map +1 -1
  219. package/dist/umd/CaretUp.js.map +1 -1
  220. package/dist/umd/ChartFilled.js.map +1 -1
  221. package/dist/umd/Charts.js.map +1 -1
  222. package/dist/umd/Checkmark.js.map +1 -1
  223. package/dist/umd/CheckmarkWithCircle.js.map +1 -1
  224. package/dist/umd/ChevronDown.js.map +1 -1
  225. package/dist/umd/ChevronLeft.js.map +1 -1
  226. package/dist/umd/ChevronRight.js.map +1 -1
  227. package/dist/umd/ChevronUp.js.map +1 -1
  228. package/dist/umd/Circle.js.map +1 -1
  229. package/dist/umd/Clock.js.map +1 -1
  230. package/dist/umd/ClockWithArrow.js.map +1 -1
  231. package/dist/umd/Clone.js.map +1 -1
  232. package/dist/umd/Cloud.js.map +1 -1
  233. package/dist/umd/Code.js.map +1 -1
  234. package/dist/umd/CodeBlock.js.map +1 -1
  235. package/dist/umd/Coin.js.map +1 -1
  236. package/dist/umd/Colon.js.map +1 -1
  237. package/dist/umd/Config.js.map +1 -1
  238. package/dist/umd/Connect.js.map +1 -1
  239. package/dist/umd/Copy.js.map +1 -1
  240. package/dist/umd/CreditCard.js.map +1 -1
  241. package/dist/umd/CurlyBraces.js.map +1 -1
  242. package/dist/umd/Cursor.js.map +1 -1
  243. package/dist/umd/Dashboard.js.map +1 -1
  244. package/dist/umd/Database.js.map +1 -1
  245. package/dist/umd/Diagram.js.map +1 -1
  246. package/dist/umd/Diagram2.js.map +1 -1
  247. package/dist/umd/Diagram3.js.map +1 -1
  248. package/dist/umd/Disconnect.js.map +1 -1
  249. package/dist/umd/Download.js.map +1 -1
  250. package/dist/umd/Drag.js.map +1 -1
  251. package/dist/umd/Edit.js.map +1 -1
  252. package/dist/umd/Ellipsis.js.map +1 -1
  253. package/dist/umd/Email.js.map +1 -1
  254. package/dist/umd/EmptyDatabase.js.map +1 -1
  255. package/dist/umd/EmptyFolder.js.map +1 -1
  256. package/dist/umd/Eraser.js.map +1 -1
  257. package/dist/umd/Escalation.js.map +1 -1
  258. package/dist/umd/Export.js.map +1 -1
  259. package/dist/umd/Favorite.js.map +1 -1
  260. package/dist/umd/Federation.js.map +1 -1
  261. package/dist/umd/File.js.map +1 -1
  262. package/dist/umd/Filter.js.map +1 -1
  263. package/dist/umd/Folder.js.map +1 -1
  264. package/dist/umd/Format.js.map +1 -1
  265. package/dist/umd/FullScreenEnter.js.map +1 -1
  266. package/dist/umd/FullScreenExit.js.map +1 -1
  267. package/dist/umd/Function.js.map +1 -1
  268. package/dist/umd/Gauge.js.map +1 -1
  269. package/dist/umd/GlobeAmericas.js.map +1 -1
  270. package/dist/umd/GovernmentBuilding.js.map +1 -1
  271. package/dist/umd/Guide.js.map +1 -1
  272. package/dist/umd/Hash.js.map +1 -1
  273. package/dist/umd/HiddenSecondaryNode.js.map +1 -1
  274. package/dist/umd/Highlight.js.map +1 -1
  275. package/dist/umd/Home.js.map +1 -1
  276. package/dist/umd/HorizontalDrag.js.map +1 -1
  277. package/dist/umd/Import.js.map +1 -1
  278. package/dist/umd/ImportantWithCircle.js.map +1 -1
  279. package/dist/umd/InfoWithCircle.js.map +1 -1
  280. package/dist/umd/InternalEmployee.js.map +1 -1
  281. package/dist/umd/InviteUser.js.map +1 -1
  282. package/dist/umd/Key.js.map +1 -1
  283. package/dist/umd/Laptop.js.map +1 -1
  284. package/dist/umd/LightningBolt.js.map +1 -1
  285. package/dist/umd/Link.js.map +1 -1
  286. package/dist/umd/List.js.map +1 -1
  287. package/dist/umd/Lock.js.map +1 -1
  288. package/dist/umd/LogIn.js.map +1 -1
  289. package/dist/umd/LogOut.js.map +1 -1
  290. package/dist/umd/MagnifyingGlass.js.map +1 -1
  291. package/dist/umd/Megaphone.js.map +1 -1
  292. package/dist/umd/Menu.js.map +1 -1
  293. package/dist/umd/Minus.js.map +1 -1
  294. package/dist/umd/Mobile.js.map +1 -1
  295. package/dist/umd/Moon.js.map +1 -1
  296. package/dist/umd/MultiDirectionArrow.js.map +1 -1
  297. package/dist/umd/MultiLayers.js.map +1 -1
  298. package/dist/umd/NavCollapse.js.map +1 -1
  299. package/dist/umd/NavExpand.js.map +1 -1
  300. package/dist/umd/NoFilter.js.map +1 -1
  301. package/dist/umd/NotAllowed.js.map +1 -1
  302. package/dist/umd/Note.js.map +1 -1
  303. package/dist/umd/NumberedList.js.map +1 -1
  304. package/dist/umd/OpenNewTab.js.map +1 -1
  305. package/dist/umd/OutlineFavorite.js.map +1 -1
  306. package/dist/umd/Package.js.map +1 -1
  307. package/dist/umd/Pause.js.map +1 -1
  308. package/dist/umd/Pending.js.map +1 -1
  309. package/dist/umd/Person.js.map +1 -1
  310. package/dist/umd/PersonGroup.js.map +1 -1
  311. package/dist/umd/PersonWithLock.js.map +1 -1
  312. package/dist/umd/Pin.js.map +1 -1
  313. package/dist/umd/Play.js.map +1 -1
  314. package/dist/umd/Plus.js.map +1 -1
  315. package/dist/umd/PlusWithCircle.js.map +1 -1
  316. package/dist/umd/Primary.js.map +1 -1
  317. package/dist/umd/Project.js.map +1 -1
  318. package/dist/umd/QuestionMarkWithCircle.js.map +1 -1
  319. package/dist/umd/Read.js.map +1 -1
  320. package/dist/umd/Recommended.js.map +1 -1
  321. package/dist/umd/Redo.js.map +1 -1
  322. package/dist/umd/Refresh.js.map +1 -1
  323. package/dist/umd/Relationship.js.map +1 -1
  324. package/dist/umd/ReplicaSet.js.map +1 -1
  325. package/dist/umd/Resize.js.map +1 -1
  326. package/dist/umd/Resource.js.map +1 -1
  327. package/dist/umd/Return.js.map +1 -1
  328. package/dist/umd/Revert.js.map +1 -1
  329. package/dist/umd/Router.js.map +1 -1
  330. package/dist/umd/SMS.js.map +1 -1
  331. package/dist/umd/Save.js.map +1 -1
  332. package/dist/umd/SearchIndex.js.map +1 -1
  333. package/dist/umd/Secondary.js.map +1 -1
  334. package/dist/umd/Serverless.js.map +1 -1
  335. package/dist/umd/Settings.js.map +1 -1
  336. package/dist/umd/ShardedCluster.js.map +1 -1
  337. package/dist/umd/Shell.js.map +1 -1
  338. package/dist/umd/Shield.js.map +1 -1
  339. package/dist/umd/Shirt.js.map +1 -1
  340. package/dist/umd/Shortcut.js.map +1 -1
  341. package/dist/umd/SortAscending.js.map +1 -1
  342. package/dist/umd/SortDescending.js.map +1 -1
  343. package/dist/umd/Sparkle.js.map +1 -1
  344. package/dist/umd/SplitHorizontal.js.map +1 -1
  345. package/dist/umd/SplitVertical.js.map +1 -1
  346. package/dist/umd/Stitch.js.map +1 -1
  347. package/dist/umd/Stop.js.map +1 -1
  348. package/dist/umd/Streaming.js.map +1 -1
  349. package/dist/umd/String.js.map +1 -1
  350. package/dist/umd/Sun.js.map +1 -1
  351. package/dist/umd/Support.js.map +1 -1
  352. package/dist/umd/Sweep.js.map +1 -1
  353. package/dist/umd/Table.js.map +1 -1
  354. package/dist/umd/Tag.js.map +1 -1
  355. package/dist/umd/TemporaryTable.js.map +1 -1
  356. package/dist/umd/ThumbsDown.js.map +1 -1
  357. package/dist/umd/ThumbsUp.js.map +1 -1
  358. package/dist/umd/TimeSeries.js.map +1 -1
  359. package/dist/umd/TimeSeriesCollection.js.map +1 -1
  360. package/dist/umd/Trash.js.map +1 -1
  361. package/dist/umd/Undo.js.map +1 -1
  362. package/dist/umd/University.js.map +1 -1
  363. package/dist/umd/Unlock.js.map +1 -1
  364. package/dist/umd/Unsorted.js.map +1 -1
  365. package/dist/umd/UpDownCarets.js.map +1 -1
  366. package/dist/umd/Upload.js.map +1 -1
  367. package/dist/umd/VerticalEllipsis.js.map +1 -1
  368. package/dist/umd/View.js.map +1 -1
  369. package/dist/umd/Visibility.js.map +1 -1
  370. package/dist/umd/VisibilityOff.js.map +1 -1
  371. package/dist/umd/Warning.js.map +1 -1
  372. package/dist/umd/Wizard.js.map +1 -1
  373. package/dist/umd/Wrench.js.map +1 -1
  374. package/dist/umd/Write.js.map +1 -1
  375. package/dist/umd/X.js.map +1 -1
  376. package/dist/umd/XWithCircle.js.map +1 -1
  377. package/dist/umd/index.js +1 -1
  378. package/dist/umd/index.js.map +1 -1
  379. package/package.json +7 -7
  380. package/scripts/build/build-batch.ts +13 -6
  381. package/scripts/build/build.ts +2 -1
  382. package/scripts/postbuild/index.ts +0 -5
  383. package/src/Icon.spec.tsx +13 -0
  384. package/src/Icon.stories.tsx +13 -1
  385. package/src/createGlyphComponent.spec.tsx +274 -0
  386. package/src/createGlyphComponent.tsx +3 -1
  387. package/src/createIconComponent.spec.tsx +395 -0
  388. package/src/createIconComponent.tsx +14 -1
  389. package/src/testUtils.tsx +26 -0
  390. package/stories.js +1 -1
@@ -0,0 +1,395 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+
4
+ import { createGlyphComponent } from './createGlyphComponent';
5
+ import { createIconComponent } from './createIconComponent';
6
+ import * as generatedGlyphs from './generated';
7
+ import { Size } from './glyphCommon';
8
+ import { isComponentGlyph } from './isComponentGlyph';
9
+ import {
10
+ AnotherCustomGlyph,
11
+ createTestSVGRComponent,
12
+ CustomSVGRGlyph,
13
+ } from './testUtils';
14
+
15
+ // Create glyph components from the SVGR components
16
+ const customGlyphs = {
17
+ CustomGlyph: createGlyphComponent('CustomGlyph', CustomSVGRGlyph),
18
+ AnotherGlyph: createGlyphComponent('AnotherGlyph', AnotherCustomGlyph),
19
+ };
20
+
21
+ describe('packages/Icon/createIconComponent', () => {
22
+ describe('basic functionality', () => {
23
+ const IconComponent = createIconComponent(customGlyphs);
24
+
25
+ test('returns a function', () => {
26
+ expect(typeof IconComponent).toBe('function');
27
+ });
28
+
29
+ test('returned function has the displayName: "Icon"', () => {
30
+ expect(IconComponent.displayName).toBe('Icon');
31
+ });
32
+
33
+ test('returned function has the property: `isGlyph`', () => {
34
+ expect(IconComponent).toHaveProperty('isGlyph');
35
+ expect(IconComponent.isGlyph).toBeTruthy();
36
+ });
37
+
38
+ test('returned function passes `isComponentGlyph`', () => {
39
+ expect(isComponentGlyph(IconComponent)).toBeTruthy();
40
+ });
41
+ });
42
+
43
+ describe('rendering glyphs', () => {
44
+ const IconComponent = createIconComponent(customGlyphs);
45
+
46
+ test('renders the correct glyph when passed a valid glyph name', () => {
47
+ render(<IconComponent glyph="CustomGlyph" />);
48
+ const glyph = screen.getByTestId('custom-svgr-glyph');
49
+ expect(glyph).toBeInTheDocument();
50
+ expect(glyph.nodeName.toLowerCase()).toBe('svg');
51
+ });
52
+
53
+ test('renders different glyphs based on glyph prop', () => {
54
+ const { rerender } = render(<IconComponent glyph="CustomGlyph" />);
55
+ expect(screen.getByTestId('custom-svgr-glyph')).toBeInTheDocument();
56
+
57
+ rerender(<IconComponent glyph="AnotherGlyph" />);
58
+ expect(screen.getByTestId('another-custom-glyph')).toBeInTheDocument();
59
+ });
60
+
61
+ test('logs an error and renders nothing when glyph does not exist', () => {
62
+ const consoleSpy = jest
63
+ .spyOn(console, 'error')
64
+ .mockImplementation(() => {});
65
+
66
+ const { container } = render(<IconComponent glyph="NonExistentGlyph" />);
67
+
68
+ // Should log an error
69
+ expect(consoleSpy).toHaveBeenCalledWith(
70
+ 'Error in Icon',
71
+ 'Could not find glyph named "NonExistentGlyph" in the icon set.',
72
+ undefined,
73
+ );
74
+
75
+ // Should not render an SVG
76
+ const svg = container.querySelector('svg');
77
+ expect(svg).not.toBeInTheDocument();
78
+
79
+ consoleSpy.mockRestore();
80
+ });
81
+
82
+ test('suggests near match when glyph name has incorrect casing', () => {
83
+ const consoleSpy = jest
84
+ .spyOn(console, 'error')
85
+ .mockImplementation(() => {});
86
+
87
+ render(<IconComponent glyph="custom-glyph" />);
88
+
89
+ expect(consoleSpy).toHaveBeenCalledWith(
90
+ 'Error in Icon',
91
+ 'Could not find glyph named "custom-glyph" in the icon set.',
92
+ 'Did you mean "CustomGlyph?"',
93
+ );
94
+
95
+ consoleSpy.mockRestore();
96
+ });
97
+ });
98
+
99
+ describe('custom SVG support', () => {
100
+ const RawSVGGlyph = createTestSVGRComponent('raw-svg-glyph');
101
+
102
+ const customSVGGlyphs = {
103
+ RawSVG: createGlyphComponent('RawSVG', RawSVGGlyph),
104
+ };
105
+
106
+ const IconComponent = createIconComponent(customSVGGlyphs);
107
+
108
+ test('renders custom SVG components correctly', () => {
109
+ render(<IconComponent glyph="RawSVG" />);
110
+ const glyph = screen.getByTestId('raw-svg-glyph');
111
+ expect(glyph).toBeInTheDocument();
112
+ expect(glyph.nodeName.toLowerCase()).toBe('svg');
113
+ });
114
+
115
+ test('applies size prop to custom SVGs', () => {
116
+ render(<IconComponent glyph="RawSVG" size={32} />);
117
+ const glyph = screen.getByTestId('raw-svg-glyph');
118
+ expect(glyph).toHaveAttribute('height', '32');
119
+ expect(glyph).toHaveAttribute('width', '32');
120
+ });
121
+
122
+ test('applies Size enum to custom SVGs', () => {
123
+ render(<IconComponent glyph="RawSVG" size={Size.Large} />);
124
+ const glyph = screen.getByTestId('raw-svg-glyph');
125
+ expect(glyph).toHaveAttribute('height', '20');
126
+ expect(glyph).toHaveAttribute('width', '20');
127
+ });
128
+ });
129
+
130
+ describe('raw SVGR component support (auto-wrapped)', () => {
131
+ // Pass raw SVGR components directly without wrapping with createGlyphComponent
132
+ const RawSVGRGlyph = createTestSVGRComponent('raw-svgr-glyph');
133
+
134
+ const IconComponent = createIconComponent({ RawSVGR: RawSVGRGlyph });
135
+
136
+ test('automatically wraps raw SVGR components with createGlyphComponent', () => {
137
+ render(<IconComponent glyph="RawSVGR" />);
138
+ const glyph = screen.getByTestId('raw-svgr-glyph');
139
+ expect(glyph).toBeInTheDocument();
140
+ expect(glyph.nodeName.toLowerCase()).toBe('svg');
141
+ });
142
+
143
+ test('applies size prop to auto-wrapped SVGR components', () => {
144
+ render(<IconComponent glyph="RawSVGR" size={28} />);
145
+ const glyph = screen.getByTestId('raw-svgr-glyph');
146
+ expect(glyph).toHaveAttribute('height', '28');
147
+ expect(glyph).toHaveAttribute('width', '28');
148
+ });
149
+
150
+ test('applies Size enum to auto-wrapped SVGR components', () => {
151
+ render(<IconComponent glyph="RawSVGR" size={Size.XLarge} />);
152
+ const glyph = screen.getByTestId('raw-svgr-glyph');
153
+ expect(glyph).toHaveAttribute('height', '24');
154
+ expect(glyph).toHaveAttribute('width', '24');
155
+ });
156
+
157
+ test('applies className to auto-wrapped SVGR components', () => {
158
+ render(<IconComponent glyph="RawSVGR" className="my-raw-class" />);
159
+ const glyph = screen.getByTestId('raw-svgr-glyph');
160
+ expect(glyph).toHaveClass('my-raw-class');
161
+ });
162
+
163
+ test('applies fill to auto-wrapped SVGR components', () => {
164
+ render(<IconComponent glyph="RawSVGR" fill="red" />);
165
+ const glyph = screen.getByTestId('raw-svgr-glyph');
166
+ // Fill is applied as a CSS color via an emotion-generated class
167
+ expect(glyph.classList.length).toBeGreaterThan(0);
168
+ });
169
+
170
+ test('applies accessibility props to auto-wrapped SVGR components', () => {
171
+ render(<IconComponent glyph="RawSVGR" />);
172
+ const glyph = screen.getByTestId('raw-svgr-glyph');
173
+ expect(glyph).toHaveAttribute('role', 'img');
174
+ // Default aria-label is generated from glyph name
175
+ expect(glyph).toHaveAttribute('aria-label', 'Raw SVGR Icon');
176
+ });
177
+ });
178
+
179
+ describe('className prop', () => {
180
+ const IconComponent = createIconComponent(customGlyphs);
181
+
182
+ test('applies className to glyph SVG element', () => {
183
+ render(<IconComponent glyph="CustomGlyph" className="custom-class" />);
184
+ const glyph = screen.getByTestId('custom-svgr-glyph');
185
+ expect(glyph).toHaveClass('custom-class');
186
+ });
187
+ });
188
+
189
+ describe('className prop with custom SVGs', () => {
190
+ const RawSVGGlyph = createTestSVGRComponent('raw-svg-for-class');
191
+
192
+ const customSVGGlyphs = {
193
+ RawSVG: createGlyphComponent('RawSVG', RawSVGGlyph),
194
+ };
195
+
196
+ const IconComponent = createIconComponent(customSVGGlyphs);
197
+
198
+ test('applies className to custom SVG components', () => {
199
+ render(<IconComponent glyph="RawSVG" className="my-custom-class" />);
200
+ const glyph = screen.getByTestId('raw-svg-for-class');
201
+ expect(glyph).toHaveClass('my-custom-class');
202
+ });
203
+ });
204
+
205
+ describe('size prop', () => {
206
+ const IconComponent = createIconComponent(customGlyphs);
207
+
208
+ test('applies numeric size to glyph', () => {
209
+ render(<IconComponent glyph="CustomGlyph" size={24} />);
210
+ const glyph = screen.getByTestId('custom-svgr-glyph');
211
+ expect(glyph).toHaveAttribute('height', '24');
212
+ expect(glyph).toHaveAttribute('width', '24');
213
+ });
214
+
215
+ test('applies Size.Small correctly', () => {
216
+ render(<IconComponent glyph="CustomGlyph" size={Size.Small} />);
217
+ const glyph = screen.getByTestId('custom-svgr-glyph');
218
+ expect(glyph).toHaveAttribute('height', '14');
219
+ expect(glyph).toHaveAttribute('width', '14');
220
+ });
221
+
222
+ test('applies Size.Default correctly', () => {
223
+ render(<IconComponent glyph="CustomGlyph" size={Size.Default} />);
224
+ const glyph = screen.getByTestId('custom-svgr-glyph');
225
+ expect(glyph).toHaveAttribute('height', '16');
226
+ expect(glyph).toHaveAttribute('width', '16');
227
+ });
228
+
229
+ test('applies Size.Large correctly', () => {
230
+ render(<IconComponent glyph="CustomGlyph" size={Size.Large} />);
231
+ const glyph = screen.getByTestId('custom-svgr-glyph');
232
+ expect(glyph).toHaveAttribute('height', '20');
233
+ expect(glyph).toHaveAttribute('width', '20');
234
+ });
235
+
236
+ test('applies Size.XLarge correctly', () => {
237
+ render(<IconComponent glyph="CustomGlyph" size={Size.XLarge} />);
238
+ const glyph = screen.getByTestId('custom-svgr-glyph');
239
+ expect(glyph).toHaveAttribute('height', '24');
240
+ expect(glyph).toHaveAttribute('width', '24');
241
+ });
242
+
243
+ test('uses default size when size prop is not provided', () => {
244
+ render(<IconComponent glyph="CustomGlyph" />);
245
+ const glyph = screen.getByTestId('custom-svgr-glyph');
246
+ expect(glyph).toHaveAttribute('height', '16');
247
+ expect(glyph).toHaveAttribute('width', '16');
248
+ });
249
+ });
250
+
251
+ describe('accessibility props', () => {
252
+ const IconComponent = createIconComponent(customGlyphs);
253
+
254
+ test('applies role="img" by default', () => {
255
+ render(<IconComponent glyph="CustomGlyph" />);
256
+ const glyph = screen.getByTestId('custom-svgr-glyph');
257
+ expect(glyph).toHaveAttribute('role', 'img');
258
+ });
259
+
260
+ test('applies role="presentation" when specified', () => {
261
+ render(<IconComponent glyph="CustomGlyph" role="presentation" />);
262
+ const glyph = screen.getByTestId('custom-svgr-glyph');
263
+ expect(glyph).toHaveAttribute('role', 'presentation');
264
+ expect(glyph).toHaveAttribute('aria-hidden', 'true');
265
+ });
266
+
267
+ test('generates default aria-label when no accessibility props provided', () => {
268
+ render(<IconComponent glyph="CustomGlyph" />);
269
+ const glyph = screen.getByTestId('custom-svgr-glyph');
270
+ expect(glyph).toHaveAttribute('aria-label', 'Custom Glyph Icon');
271
+ });
272
+
273
+ test('applies custom aria-label when provided', () => {
274
+ render(
275
+ <IconComponent glyph="CustomGlyph" aria-label="My Custom Label" />,
276
+ );
277
+ const glyph = screen.getByTestId('custom-svgr-glyph');
278
+ expect(glyph).toHaveAttribute('aria-label', 'My Custom Label');
279
+ });
280
+
281
+ test('applies aria-labelledby when provided', () => {
282
+ render(
283
+ <IconComponent glyph="CustomGlyph" aria-labelledby="my-label-id" />,
284
+ );
285
+ const glyph = screen.getByTestId('custom-svgr-glyph');
286
+ expect(glyph).toHaveAttribute('aria-labelledby', 'my-label-id');
287
+ });
288
+ });
289
+
290
+ describe('fill prop', () => {
291
+ const IconComponent = createIconComponent(customGlyphs);
292
+
293
+ test('applies fill as CSS color via className', () => {
294
+ render(<IconComponent glyph="CustomGlyph" fill="red" />);
295
+ const glyph = screen.getByTestId('custom-svgr-glyph');
296
+ // Fill is applied as a CSS color via an emotion-generated class
297
+ expect(glyph).toHaveAttribute('class');
298
+ expect(glyph.classList.length).toBeGreaterThan(0);
299
+ });
300
+
301
+ test('applies fill alongside className', () => {
302
+ render(
303
+ <IconComponent
304
+ glyph="CustomGlyph"
305
+ fill="blue"
306
+ className="custom-class"
307
+ />,
308
+ );
309
+ const glyph = screen.getByTestId('custom-svgr-glyph');
310
+ expect(glyph).toHaveClass('custom-class');
311
+ // Fill adds an emotion class in addition to custom-class
312
+ expect(glyph.classList.length).toBeGreaterThan(1);
313
+ });
314
+ });
315
+
316
+ describe('fill prop with generated glyphs', () => {
317
+ const IconComponent = createIconComponent(generatedGlyphs);
318
+
319
+ test('applies fill as CSS color to generated glyph', () => {
320
+ render(<IconComponent glyph="Edit" fill="purple" />);
321
+ const glyph = screen.getByRole('img');
322
+ // Fill is applied as a CSS color via an emotion-generated class
323
+ expect(glyph).toHaveAttribute('class');
324
+ expect(glyph.classList.length).toBeGreaterThan(0);
325
+ });
326
+ });
327
+
328
+ describe('combined props with generated glyphs', () => {
329
+ const IconComponent = createIconComponent(generatedGlyphs);
330
+
331
+ test('applies all props correctly together', () => {
332
+ render(
333
+ <IconComponent
334
+ glyph="Edit"
335
+ size={24}
336
+ className="combined-class"
337
+ title="Combined Title"
338
+ fill="green"
339
+ />,
340
+ );
341
+ const glyph = screen.getByRole('img');
342
+
343
+ expect(glyph).toHaveAttribute('height', '24');
344
+ expect(glyph).toHaveAttribute('width', '24');
345
+ expect(glyph).toHaveClass('combined-class');
346
+
347
+ // Check title
348
+ const titleElement = glyph.querySelector('title');
349
+ expect(titleElement).toBeInTheDocument();
350
+ expect(titleElement?.textContent).toBe('Combined Title');
351
+
352
+ // Check aria-labelledby points to title
353
+ expect(glyph.getAttribute('aria-labelledby')).toBe(titleElement?.id);
354
+
355
+ // Fill adds an emotion class in addition to combined-class
356
+ expect(glyph.classList.length).toBeGreaterThan(1);
357
+ });
358
+ });
359
+
360
+ describe('combined props with custom SVGR glyphs', () => {
361
+ const IconComponent = createIconComponent(customGlyphs);
362
+
363
+ test('applies size, className, and fill together', () => {
364
+ render(
365
+ <IconComponent
366
+ glyph="CustomGlyph"
367
+ size={32}
368
+ className="combined-custom-class"
369
+ fill="orange"
370
+ />,
371
+ );
372
+ const glyph = screen.getByTestId('custom-svgr-glyph');
373
+
374
+ expect(glyph).toHaveAttribute('height', '32');
375
+ expect(glyph).toHaveAttribute('width', '32');
376
+ expect(glyph).toHaveClass('combined-custom-class');
377
+ // Fill adds an emotion class in addition to combined-custom-class
378
+ expect(glyph.classList.length).toBeGreaterThan(1);
379
+ });
380
+
381
+ test('applies accessibility props with className', () => {
382
+ render(
383
+ <IconComponent
384
+ glyph="CustomGlyph"
385
+ className="accessible-class"
386
+ aria-label="Accessible Custom Icon"
387
+ />,
388
+ );
389
+ const glyph = screen.getByTestId('custom-svgr-glyph');
390
+
391
+ expect(glyph).toHaveClass('accessible-class');
392
+ expect(glyph).toHaveAttribute('aria-label', 'Accessible Custom Icon');
393
+ });
394
+ });
395
+ });
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
  import kebabCase from 'lodash/kebabCase';
3
+ import mapValues from 'lodash/mapValues';
3
4
 
5
+ import { createGlyphComponent } from './createGlyphComponent';
4
6
  import { Size } from './glyphCommon';
7
+ import { isComponentGlyph } from './isComponentGlyph';
5
8
  import { LGGlyph } from './types';
6
9
 
7
10
  // We omit size here because we map string values for size to numbers in this component.
@@ -27,8 +30,18 @@ type GlyphObject = Record<string, LGGlyph.Component>;
27
30
  export function createIconComponent<G extends GlyphObject = GlyphObject>(
28
31
  glyphs: G,
29
32
  ) {
33
+ const allGlyphsAreComponents = Object.values(glyphs).every(isComponentGlyph);
34
+ const glyphDict = allGlyphsAreComponents
35
+ ? glyphs
36
+ : mapValues(glyphs, (val, key) => {
37
+ // We do not currently check for valid SVG files. TODO: LG-5827
38
+ if (isComponentGlyph(val)) return val;
39
+
40
+ return createGlyphComponent(key, val);
41
+ });
42
+
30
43
  const Icon = ({ glyph, ...rest }: IconProps) => {
31
- const SVGComponent = glyphs[glyph];
44
+ const SVGComponent = glyphDict[glyph];
32
45
 
33
46
  if (SVGComponent) {
34
47
  return <SVGComponent {...rest} />;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+
3
+ import { SVGR } from './types';
4
+
5
+ /**
6
+ * Creates a mock SVGR component for testing purposes.
7
+ */
8
+ export const createTestSVGRComponent = (testId: string): SVGR.Component => {
9
+ const TestComponent: SVGR.Component = ({ children, ...props }) => (
10
+ <svg data-testid={testId} {...props}>
11
+ {children}
12
+ </svg>
13
+ );
14
+
15
+ return TestComponent;
16
+ };
17
+
18
+ // Pre-built mock components for common test scenarios
19
+ export const TestSVGRGlyph = createTestSVGRComponent('mock-glyph');
20
+ export const TestSVGRGlyphWithChildren = createTestSVGRComponent(
21
+ 'mock-glyph-with-children',
22
+ );
23
+ export const CustomSVGRGlyph = createTestSVGRComponent('custom-svgr-glyph');
24
+ export const AnotherCustomGlyph = createTestSVGRComponent(
25
+ 'another-custom-glyph',
26
+ );