@canonical/react-components 1.3.0 → 1.3.1

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 (348) hide show
  1. package/dist-esm/components/Accordion/Accordion.js +52 -0
  2. package/dist-esm/components/Accordion/AccordionSection/AccordionSection.js +47 -0
  3. package/dist-esm/components/Accordion/AccordionSection/index.js +1 -0
  4. package/dist-esm/components/Accordion/index.js +1 -0
  5. package/dist-esm/components/ActionButton/ActionButton.js +106 -0
  6. package/dist-esm/components/ActionButton/index.js +1 -0
  7. package/dist-esm/components/ApplicationLayout/AppAside/AppAside.js +29 -0
  8. package/dist-esm/components/ApplicationLayout/AppAside/index.js +1 -0
  9. package/dist-esm/components/ApplicationLayout/AppMain/AppMain.js +21 -0
  10. package/dist-esm/components/ApplicationLayout/AppMain/index.js +1 -0
  11. package/dist-esm/components/ApplicationLayout/AppNavigation/AppNavigation.js +31 -0
  12. package/dist-esm/components/ApplicationLayout/AppNavigation/index.js +1 -0
  13. package/dist-esm/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.js +24 -0
  14. package/dist-esm/components/ApplicationLayout/AppNavigationBar/index.js +1 -0
  15. package/dist-esm/components/ApplicationLayout/AppStatus/AppStatus.js +21 -0
  16. package/dist-esm/components/ApplicationLayout/AppStatus/index.js +1 -0
  17. package/dist-esm/components/ApplicationLayout/Application/Application.js +22 -0
  18. package/dist-esm/components/ApplicationLayout/Application/index.js +1 -0
  19. package/dist-esm/components/ApplicationLayout/ApplicationLayout.js +113 -0
  20. package/dist-esm/components/ApplicationLayout/index.js +7 -0
  21. package/dist-esm/components/ArticlePagination/ArticlePagination.js +39 -0
  22. package/dist-esm/components/ArticlePagination/index.js +1 -0
  23. package/dist-esm/components/Badge/Badge.js +64 -0
  24. package/dist-esm/components/Badge/index.js +1 -0
  25. package/dist-esm/components/Button/Button.js +55 -0
  26. package/dist-esm/components/Button/index.js +1 -0
  27. package/dist-esm/components/Card/Card.js +45 -0
  28. package/dist-esm/components/Card/index.js +1 -0
  29. package/dist-esm/components/CheckboxInput/CheckableInput/CheckableInput.js +35 -0
  30. package/dist-esm/components/CheckboxInput/CheckableInput/index.js +1 -0
  31. package/dist-esm/components/CheckboxInput/CheckboxInput.js +24 -0
  32. package/dist-esm/components/CheckboxInput/index.js +1 -0
  33. package/dist-esm/components/Chip/Chip.js +81 -0
  34. package/dist-esm/components/Chip/index.js +1 -0
  35. package/dist-esm/components/Code/Code.js +49 -0
  36. package/dist-esm/components/Code/index.js +1 -0
  37. package/dist-esm/components/CodeSnippet/CodeSnippet.js +28 -0
  38. package/dist-esm/components/CodeSnippet/CodeSnippetBlock.js +64 -0
  39. package/dist-esm/components/CodeSnippet/CodeSnippetDropdown.js +27 -0
  40. package/dist-esm/components/CodeSnippet/index.js +2 -0
  41. package/dist-esm/components/Col/Col.js +38 -0
  42. package/dist-esm/components/Col/index.js +1 -0
  43. package/dist-esm/components/ConfirmationButton/ConfirmationButton.js +63 -0
  44. package/dist-esm/components/ConfirmationButton/index.js +1 -0
  45. package/dist-esm/components/ConfirmationModal/ConfirmationModal.js +47 -0
  46. package/dist-esm/components/ConfirmationModal/index.js +1 -0
  47. package/dist-esm/components/ContextualMenu/ContextualMenu.js +215 -0
  48. package/dist-esm/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +249 -0
  49. package/dist-esm/components/ContextualMenu/ContextualMenuDropdown/index.js +1 -0
  50. package/dist-esm/components/ContextualMenu/index.js +1 -0
  51. package/dist-esm/components/EmptyState/EmptyState.js +28 -0
  52. package/dist-esm/components/EmptyState/index.js +1 -0
  53. package/dist-esm/components/Field/Field.js +126 -0
  54. package/dist-esm/components/Field/index.js +1 -0
  55. package/dist-esm/components/Form/Form.js +28 -0
  56. package/dist-esm/components/Form/index.js +1 -0
  57. package/dist-esm/components/FormikField/FormikField.js +33 -0
  58. package/dist-esm/components/FormikField/index.js +1 -0
  59. package/dist-esm/components/Icon/Icon.js +61 -0
  60. package/dist-esm/components/Icon/index.js +1 -0
  61. package/dist-esm/components/Input/Input.js +103 -0
  62. package/dist-esm/components/Input/index.js +1 -0
  63. package/dist-esm/components/Label/Label.js +27 -0
  64. package/dist-esm/components/Label/index.js +1 -0
  65. package/dist-esm/components/Link/Link.js +37 -0
  66. package/dist-esm/components/Link/index.js +1 -0
  67. package/dist-esm/components/List/List.js +110 -0
  68. package/dist-esm/components/List/index.js +1 -0
  69. package/dist-esm/components/Loader/Loader.js +14 -0
  70. package/dist-esm/components/Loader/index.js +1 -0
  71. package/dist-esm/components/LoginPageLayout/LoginPageLayout.js +63 -0
  72. package/dist-esm/components/LoginPageLayout/index.js +1 -0
  73. package/dist-esm/components/MainTable/MainTable.js +211 -0
  74. package/dist-esm/components/MainTable/index.js +1 -0
  75. package/dist-esm/components/Modal/Modal.js +135 -0
  76. package/dist-esm/components/Modal/index.js +1 -0
  77. package/dist-esm/components/ModularTable/ModularTable.js +166 -0
  78. package/dist-esm/components/ModularTable/index.js +1 -0
  79. package/dist-esm/components/MultiSelect/FadeInDown/FadeInDown.js +25 -0
  80. package/dist-esm/components/MultiSelect/FadeInDown/index.js +1 -0
  81. package/dist-esm/components/MultiSelect/MultiSelect.js +308 -0
  82. package/dist-esm/components/MultiSelect/index.js +1 -0
  83. package/dist-esm/components/Navigation/Navigation.js +215 -0
  84. package/dist-esm/components/Navigation/NavigationLink/NavigationLink.js +58 -0
  85. package/dist-esm/components/Navigation/NavigationLink/index.js +1 -0
  86. package/dist-esm/components/Navigation/NavigationMenu/NavigationMenu.js +57 -0
  87. package/dist-esm/components/Navigation/NavigationMenu/index.js +1 -0
  88. package/dist-esm/components/Navigation/index.js +1 -0
  89. package/dist-esm/components/Navigation/types.js +1 -0
  90. package/dist-esm/components/Notification/Notification.js +119 -0
  91. package/dist-esm/components/Notification/index.js +1 -0
  92. package/dist-esm/components/NotificationProvider/NotificationProvider.js +83 -0
  93. package/dist-esm/components/NotificationProvider/index.js +2 -0
  94. package/dist-esm/components/NotificationProvider/messageBuilder.js +31 -0
  95. package/dist-esm/components/NotificationProvider/types.js +1 -0
  96. package/dist-esm/components/Pagination/Pagination.js +173 -0
  97. package/dist-esm/components/Pagination/PaginationButton/PaginationButton.js +31 -0
  98. package/dist-esm/components/Pagination/PaginationButton/index.js +1 -0
  99. package/dist-esm/components/Pagination/PaginationItem/PaginationItem.js +20 -0
  100. package/dist-esm/components/Pagination/PaginationItem/index.js +1 -0
  101. package/dist-esm/components/Pagination/index.js +1 -0
  102. package/dist-esm/components/Panel/Panel.js +89 -0
  103. package/dist-esm/components/Panel/index.js +1 -0
  104. package/dist-esm/components/PasswordToggle/PasswordToggle.js +90 -0
  105. package/dist-esm/components/PasswordToggle/index.js +1 -0
  106. package/dist-esm/components/RadioInput/RadioInput.js +22 -0
  107. package/dist-esm/components/RadioInput/index.js +1 -0
  108. package/dist-esm/components/Row/Row.js +22 -0
  109. package/dist-esm/components/Row/index.js +1 -0
  110. package/dist-esm/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.js +107 -0
  111. package/dist-esm/components/SearchAndFilter/FilterPanelSection/index.js +1 -0
  112. package/dist-esm/components/SearchAndFilter/SearchAndFilter.js +286 -0
  113. package/dist-esm/components/SearchAndFilter/index.js +1 -0
  114. package/dist-esm/components/SearchAndFilter/types.js +1 -0
  115. package/dist-esm/components/SearchAndFilter/utils.js +22 -0
  116. package/dist-esm/components/SearchBox/SearchBox.js +95 -0
  117. package/dist-esm/components/SearchBox/index.js +1 -0
  118. package/dist-esm/components/Select/Select.js +84 -0
  119. package/dist-esm/components/Select/index.js +1 -0
  120. package/dist-esm/components/SideNavigation/SideNavigation.js +89 -0
  121. package/dist-esm/components/SideNavigation/SideNavigationBase/SideNavigationBase.js +31 -0
  122. package/dist-esm/components/SideNavigation/SideNavigationBase/index.js +1 -0
  123. package/dist-esm/components/SideNavigation/SideNavigationItem/SideNavigationItem.js +32 -0
  124. package/dist-esm/components/SideNavigation/SideNavigationItem/index.js +1 -0
  125. package/dist-esm/components/SideNavigation/SideNavigationLink/SideNavigationLink.js +25 -0
  126. package/dist-esm/components/SideNavigation/SideNavigationLink/index.js +1 -0
  127. package/dist-esm/components/SideNavigation/SideNavigationText/SideNavigationText.js +20 -0
  128. package/dist-esm/components/SideNavigation/SideNavigationText/index.js +1 -0
  129. package/dist-esm/components/SideNavigation/index.js +4 -0
  130. package/dist-esm/components/Slider/Slider.js +83 -0
  131. package/dist-esm/components/Slider/index.js +1 -0
  132. package/dist-esm/components/Spinner/Spinner.js +36 -0
  133. package/dist-esm/components/Spinner/index.js +1 -0
  134. package/dist-esm/components/StatusLabel/StatusLabel.js +36 -0
  135. package/dist-esm/components/StatusLabel/index.js +1 -0
  136. package/dist-esm/components/Strip/Strip.js +50 -0
  137. package/dist-esm/components/Strip/index.js +1 -0
  138. package/dist-esm/components/SummaryButton/SummaryButton.js +28 -0
  139. package/dist-esm/components/SummaryButton/index.js +1 -0
  140. package/dist-esm/components/Switch/Switch.js +28 -0
  141. package/dist-esm/components/Switch/index.js +1 -0
  142. package/dist-esm/components/Table/Table.js +23 -0
  143. package/dist-esm/components/Table/index.js +1 -0
  144. package/dist-esm/components/TableCell/TableCell.js +26 -0
  145. package/dist-esm/components/TableCell/index.js +1 -0
  146. package/dist-esm/components/TableHeader/TableHeader.js +17 -0
  147. package/dist-esm/components/TableHeader/index.js +1 -0
  148. package/dist-esm/components/TablePagination/TablePagination.js +104 -0
  149. package/dist-esm/components/TablePagination/TablePaginationControls/TablePaginationControls.js +120 -0
  150. package/dist-esm/components/TablePagination/TablePaginationControls/index.js +1 -0
  151. package/dist-esm/components/TablePagination/index.js +1 -0
  152. package/dist-esm/components/TablePagination/utils.js +67 -0
  153. package/dist-esm/components/TableRow/TableRow.js +15 -0
  154. package/dist-esm/components/TableRow/index.js +1 -0
  155. package/dist-esm/components/Tabs/Tabs.js +42 -0
  156. package/dist-esm/components/Tabs/index.js +1 -0
  157. package/dist-esm/components/Textarea/Textarea.js +115 -0
  158. package/dist-esm/components/Textarea/index.js +1 -0
  159. package/dist-esm/components/Tooltip/Tooltip.js +245 -0
  160. package/dist-esm/components/Tooltip/index.js +1 -0
  161. package/dist-esm/enums.js +8 -0
  162. package/dist-esm/hooks/index.js +8 -0
  163. package/dist-esm/hooks/useId.js +13 -0
  164. package/dist-esm/hooks/useListener.js +51 -0
  165. package/dist-esm/hooks/useOnClickOutside.js +38 -0
  166. package/dist-esm/hooks/useOnEscapePressed.js +25 -0
  167. package/dist-esm/hooks/usePagination.js +45 -0
  168. package/dist-esm/hooks/usePrevious.js +16 -0
  169. package/dist-esm/hooks/useThrottle.js +49 -0
  170. package/dist-esm/hooks/useWindowFitment.js +109 -0
  171. package/dist-esm/index.js +69 -0
  172. package/dist-esm/types/index.js +1 -0
  173. package/dist-esm/types/react-table-config.d.js +1 -0
  174. package/dist-esm/utils.js +41 -0
  175. package/dist-types/components/Accordion/Accordion.d.ts +46 -0
  176. package/dist-types/components/Accordion/AccordionSection/AccordionSection.d.ts +34 -0
  177. package/dist-types/components/Accordion/AccordionSection/index.d.ts +2 -0
  178. package/dist-types/components/Accordion/index.d.ts +2 -0
  179. package/dist-types/components/ActionButton/ActionButton.d.ts +48 -0
  180. package/dist-types/components/ActionButton/index.d.ts +2 -0
  181. package/dist-types/components/ApplicationLayout/AppAside/AppAside.d.ts +33 -0
  182. package/dist-types/components/ApplicationLayout/AppAside/index.d.ts +2 -0
  183. package/dist-types/components/ApplicationLayout/AppMain/AppMain.d.ts +14 -0
  184. package/dist-types/components/ApplicationLayout/AppMain/index.d.ts +2 -0
  185. package/dist-types/components/ApplicationLayout/AppNavigation/AppNavigation.d.ts +26 -0
  186. package/dist-types/components/ApplicationLayout/AppNavigation/index.d.ts +2 -0
  187. package/dist-types/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.d.ts +18 -0
  188. package/dist-types/components/ApplicationLayout/AppNavigationBar/index.d.ts +2 -0
  189. package/dist-types/components/ApplicationLayout/AppStatus/AppStatus.d.ts +14 -0
  190. package/dist-types/components/ApplicationLayout/AppStatus/index.d.ts +2 -0
  191. package/dist-types/components/ApplicationLayout/Application/Application.d.ts +15 -0
  192. package/dist-types/components/ApplicationLayout/Application/index.d.ts +2 -0
  193. package/dist-types/components/ApplicationLayout/ApplicationLayout.d.ts +89 -0
  194. package/dist-types/components/ApplicationLayout/index.d.ts +7 -0
  195. package/dist-types/components/ArticlePagination/ArticlePagination.d.ts +31 -0
  196. package/dist-types/components/ArticlePagination/index.d.ts +2 -0
  197. package/dist-types/components/Badge/Badge.d.ts +34 -0
  198. package/dist-types/components/Badge/index.d.ts +2 -0
  199. package/dist-types/components/Button/Button.d.ts +64 -0
  200. package/dist-types/components/Button/index.d.ts +2 -0
  201. package/dist-types/components/Card/Card.d.ts +35 -0
  202. package/dist-types/components/Card/index.d.ts +2 -0
  203. package/dist-types/components/CheckboxInput/CheckableInput/CheckableInput.d.ts +27 -0
  204. package/dist-types/components/CheckboxInput/CheckableInput/index.d.ts +2 -0
  205. package/dist-types/components/CheckboxInput/CheckboxInput.d.ts +9 -0
  206. package/dist-types/components/CheckboxInput/index.d.ts +2 -0
  207. package/dist-types/components/Chip/Chip.d.ts +56 -0
  208. package/dist-types/components/Chip/index.d.ts +2 -0
  209. package/dist-types/components/Code/Code.d.ts +13 -0
  210. package/dist-types/components/Code/index.d.ts +2 -0
  211. package/dist-types/components/CodeSnippet/CodeSnippet.d.ts +21 -0
  212. package/dist-types/components/CodeSnippet/CodeSnippetBlock.d.ts +40 -0
  213. package/dist-types/components/CodeSnippet/CodeSnippetDropdown.d.ts +18 -0
  214. package/dist-types/components/CodeSnippet/index.d.ts +5 -0
  215. package/dist-types/components/Col/Col.d.ts +53 -0
  216. package/dist-types/components/Col/index.d.ts +2 -0
  217. package/dist-types/components/ConfirmationButton/ConfirmationButton.d.ts +28 -0
  218. package/dist-types/components/ConfirmationButton/index.d.ts +2 -0
  219. package/dist-types/components/ConfirmationModal/ConfirmationModal.d.ts +53 -0
  220. package/dist-types/components/ConfirmationModal/index.d.ts +2 -0
  221. package/dist-types/components/ContextualMenu/ContextualMenu.d.ts +110 -0
  222. package/dist-types/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +43 -0
  223. package/dist-types/components/ContextualMenu/ContextualMenuDropdown/index.d.ts +2 -0
  224. package/dist-types/components/ContextualMenu/index.d.ts +3 -0
  225. package/dist-types/components/EmptyState/EmptyState.d.ts +25 -0
  226. package/dist-types/components/EmptyState/index.d.ts +2 -0
  227. package/dist-types/components/Field/Field.d.ts +77 -0
  228. package/dist-types/components/Field/index.d.ts +2 -0
  229. package/dist-types/components/Form/Form.d.ts +21 -0
  230. package/dist-types/components/Form/index.d.ts +2 -0
  231. package/dist-types/components/FormikField/FormikField.d.ts +25 -0
  232. package/dist-types/components/FormikField/index.d.ts +1 -0
  233. package/dist-types/components/Icon/Icon.d.ts +59 -0
  234. package/dist-types/components/Icon/index.d.ts +2 -0
  235. package/dist-types/components/Input/Input.d.ts +70 -0
  236. package/dist-types/components/Input/index.d.ts +2 -0
  237. package/dist-types/components/Label/Label.d.ts +25 -0
  238. package/dist-types/components/Label/index.d.ts +2 -0
  239. package/dist-types/components/Link/Link.d.ts +31 -0
  240. package/dist-types/components/Link/index.d.ts +2 -0
  241. package/dist-types/components/List/List.d.ts +36 -0
  242. package/dist-types/components/List/index.d.ts +2 -0
  243. package/dist-types/components/Loader/Loader.d.ts +6 -0
  244. package/dist-types/components/Loader/index.d.ts +1 -0
  245. package/dist-types/components/LoginPageLayout/LoginPageLayout.d.ts +17 -0
  246. package/dist-types/components/LoginPageLayout/index.d.ts +2 -0
  247. package/dist-types/components/MainTable/MainTable.d.ts +102 -0
  248. package/dist-types/components/MainTable/index.d.ts +2 -0
  249. package/dist-types/components/Modal/Modal.d.ts +36 -0
  250. package/dist-types/components/Modal/index.d.ts +2 -0
  251. package/dist-types/components/ModularTable/ModularTable.d.ts +105 -0
  252. package/dist-types/components/ModularTable/index.d.ts +2 -0
  253. package/dist-types/components/MultiSelect/FadeInDown/FadeInDown.d.ts +10 -0
  254. package/dist-types/components/MultiSelect/FadeInDown/index.d.ts +1 -0
  255. package/dist-types/components/MultiSelect/MultiSelect.d.ts +57 -0
  256. package/dist-types/components/MultiSelect/index.d.ts +1 -0
  257. package/dist-types/components/Navigation/Navigation.d.ts +66 -0
  258. package/dist-types/components/Navigation/NavigationLink/NavigationLink.d.ts +10 -0
  259. package/dist-types/components/Navigation/NavigationLink/index.d.ts +1 -0
  260. package/dist-types/components/Navigation/NavigationMenu/NavigationMenu.d.ts +11 -0
  261. package/dist-types/components/Navigation/NavigationMenu/index.d.ts +1 -0
  262. package/dist-types/components/Navigation/index.d.ts +3 -0
  263. package/dist-types/components/Navigation/types.d.ts +64 -0
  264. package/dist-types/components/Notification/Notification.d.ts +110 -0
  265. package/dist-types/components/Notification/index.d.ts +2 -0
  266. package/dist-types/components/NotificationProvider/NotificationProvider.d.ts +5 -0
  267. package/dist-types/components/NotificationProvider/index.d.ts +3 -0
  268. package/dist-types/components/NotificationProvider/messageBuilder.d.ts +6 -0
  269. package/dist-types/components/NotificationProvider/types.d.ts +35 -0
  270. package/dist-types/components/Pagination/Pagination.d.ts +102 -0
  271. package/dist-types/components/Pagination/PaginationButton/PaginationButton.d.ts +30 -0
  272. package/dist-types/components/Pagination/PaginationButton/index.d.ts +2 -0
  273. package/dist-types/components/Pagination/PaginationItem/PaginationItem.d.ts +17 -0
  274. package/dist-types/components/Pagination/PaginationItem/index.d.ts +2 -0
  275. package/dist-types/components/Pagination/index.d.ts +2 -0
  276. package/dist-types/components/Panel/Panel.d.ts +123 -0
  277. package/dist-types/components/Panel/index.d.ts +1 -0
  278. package/dist-types/components/PasswordToggle/PasswordToggle.d.ts +108 -0
  279. package/dist-types/components/PasswordToggle/index.d.ts +2 -0
  280. package/dist-types/components/RadioInput/RadioInput.d.ts +9 -0
  281. package/dist-types/components/RadioInput/index.d.ts +2 -0
  282. package/dist-types/components/Row/Row.d.ts +19 -0
  283. package/dist-types/components/Row/index.d.ts +2 -0
  284. package/dist-types/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.d.ts +25 -0
  285. package/dist-types/components/SearchAndFilter/FilterPanelSection/index.d.ts +1 -0
  286. package/dist-types/components/SearchAndFilter/SearchAndFilter.d.ts +33 -0
  287. package/dist-types/components/SearchAndFilter/index.d.ts +2 -0
  288. package/dist-types/components/SearchAndFilter/types.d.ts +11 -0
  289. package/dist-types/components/SearchAndFilter/utils.d.ts +13 -0
  290. package/dist-types/components/SearchBox/SearchBox.d.ts +63 -0
  291. package/dist-types/components/SearchBox/index.d.ts +2 -0
  292. package/dist-types/components/Select/Select.d.ts +71 -0
  293. package/dist-types/components/Select/index.d.ts +2 -0
  294. package/dist-types/components/SideNavigation/SideNavigation.d.ts +50 -0
  295. package/dist-types/components/SideNavigation/SideNavigationBase/SideNavigationBase.d.ts +31 -0
  296. package/dist-types/components/SideNavigation/SideNavigationBase/index.d.ts +1 -0
  297. package/dist-types/components/SideNavigation/SideNavigationItem/SideNavigationItem.d.ts +20 -0
  298. package/dist-types/components/SideNavigation/SideNavigationItem/index.d.ts +1 -0
  299. package/dist-types/components/SideNavigation/SideNavigationLink/SideNavigationLink.d.ts +18 -0
  300. package/dist-types/components/SideNavigation/SideNavigationLink/index.d.ts +1 -0
  301. package/dist-types/components/SideNavigation/SideNavigationText/SideNavigationText.d.ts +7 -0
  302. package/dist-types/components/SideNavigation/SideNavigationText/index.d.ts +1 -0
  303. package/dist-types/components/SideNavigation/index.d.ts +5 -0
  304. package/dist-types/components/Slider/Slider.d.ts +62 -0
  305. package/dist-types/components/Slider/index.d.ts +2 -0
  306. package/dist-types/components/Spinner/Spinner.d.ts +29 -0
  307. package/dist-types/components/Spinner/index.d.ts +2 -0
  308. package/dist-types/components/StatusLabel/StatusLabel.d.ts +33 -0
  309. package/dist-types/components/StatusLabel/index.d.ts +2 -0
  310. package/dist-types/components/Strip/Strip.d.ts +64 -0
  311. package/dist-types/components/Strip/index.d.ts +2 -0
  312. package/dist-types/components/SummaryButton/SummaryButton.d.ts +29 -0
  313. package/dist-types/components/SummaryButton/index.d.ts +2 -0
  314. package/dist-types/components/Switch/Switch.d.ts +17 -0
  315. package/dist-types/components/Switch/index.d.ts +2 -0
  316. package/dist-types/components/Table/Table.d.ts +22 -0
  317. package/dist-types/components/Table/index.d.ts +2 -0
  318. package/dist-types/components/TableCell/TableCell.d.ts +26 -0
  319. package/dist-types/components/TableCell/index.d.ts +2 -0
  320. package/dist-types/components/TableHeader/TableHeader.d.ts +14 -0
  321. package/dist-types/components/TableHeader/index.d.ts +2 -0
  322. package/dist-types/components/TablePagination/TablePagination.d.ts +98 -0
  323. package/dist-types/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +24 -0
  324. package/dist-types/components/TablePagination/TablePaginationControls/index.d.ts +2 -0
  325. package/dist-types/components/TablePagination/index.d.ts +2 -0
  326. package/dist-types/components/TablePagination/utils.d.ts +27 -0
  327. package/dist-types/components/TableRow/TableRow.d.ts +10 -0
  328. package/dist-types/components/TableRow/index.d.ts +2 -0
  329. package/dist-types/components/Tabs/Tabs.d.ts +45 -0
  330. package/dist-types/components/Tabs/index.d.ts +2 -0
  331. package/dist-types/components/Textarea/Textarea.d.ts +70 -0
  332. package/dist-types/components/Textarea/index.d.ts +2 -0
  333. package/dist-types/components/Tooltip/Tooltip.d.ts +75 -0
  334. package/dist-types/components/Tooltip/index.d.ts +2 -0
  335. package/dist-types/enums.d.ts +13 -0
  336. package/dist-types/hooks/index.d.ts +9 -0
  337. package/dist-types/hooks/useId.d.ts +4 -0
  338. package/dist-types/hooks/useListener.d.ts +11 -0
  339. package/dist-types/hooks/useOnClickOutside.d.ts +12 -0
  340. package/dist-types/hooks/useOnEscapePressed.d.ts +6 -0
  341. package/dist-types/hooks/usePagination.d.ts +19 -0
  342. package/dist-types/hooks/usePrevious.d.ts +7 -0
  343. package/dist-types/hooks/useThrottle.d.ts +9 -0
  344. package/dist-types/hooks/useWindowFitment.d.ts +54 -0
  345. package/dist-types/index.d.ts +132 -0
  346. package/dist-types/types/index.d.ts +38 -0
  347. package/dist-types/utils.d.ts +27 -0
  348. package/package.json +3 -1
@@ -0,0 +1,211 @@
1
+ var _excluded = ["content", "sortKey"],
2
+ _excluded2 = ["columns", "expanded", "expandedContent", "key", "sortData"],
3
+ _excluded3 = ["content"],
4
+ _excluded4 = ["defaultSort", "defaultSortDirection", "emptyStateMsg", "expanding", "headers", "onUpdateSort", "paginate", "rows", "responsive", "sortable", "sortFunction", "hiddenCaption"];
5
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
6
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
7
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
8
+ import React, { useEffect, useMemo, useState } from "react";
9
+ import Pagination from "../Pagination";
10
+ import Table from "../Table";
11
+ import TableRow from "../TableRow";
12
+ import TableHeader from "../TableHeader";
13
+ import TableCell from "../TableCell";
14
+ import { usePagination } from "../../hooks";
15
+ var updateSort = (setSortKey, setSortDirection, sortKey, sortDirection) => {
16
+ var newDirection = null;
17
+ if (sortDirection === "none") {
18
+ newDirection = "ascending";
19
+ } else if (sortDirection === "ascending") {
20
+ newDirection = "descending";
21
+ } else {
22
+ sortKey = null;
23
+ }
24
+ setSortKey(sortKey);
25
+ setSortDirection(newDirection);
26
+ };
27
+ var generateHeaders = (currentSortKey, currentSortDirection, expanding, headers, sortable, setSortKey, setSortDirection) => {
28
+ var headerItems = headers.map((_ref, index) => {
29
+ var {
30
+ content,
31
+ sortKey
32
+ } = _ref,
33
+ props = _objectWithoutProperties(_ref, _excluded);
34
+ var sortDirection;
35
+ if (sortable && sortKey) {
36
+ if (currentSortKey === sortKey) {
37
+ sortDirection = currentSortDirection;
38
+ } else {
39
+ sortDirection = "none";
40
+ }
41
+ }
42
+ return /*#__PURE__*/React.createElement(TableHeader, _extends({
43
+ key: index,
44
+ sort: sortDirection,
45
+ onClick: sortable && sortKey ? updateSort.bind(this, setSortKey, setSortDirection, sortKey, sortDirection) : undefined
46
+ }, props), content);
47
+ });
48
+ // When there is expanding content then provide an extra hidden header to
49
+ // account for the extra cell in the body rows.
50
+ return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement(TableRow, null, headerItems, expanding && /*#__PURE__*/React.createElement(TableHeader, {
51
+ "aria-hidden": "true"
52
+ })));
53
+ };
54
+ var generateRows = _ref2 => {
55
+ var {
56
+ rows,
57
+ headers,
58
+ responsive,
59
+ expanding
60
+ } = _ref2;
61
+ return rows.map((_ref3, index) => {
62
+ var {
63
+ columns,
64
+ expanded,
65
+ expandedContent,
66
+ key,
67
+ sortData: _
68
+ } = _ref3,
69
+ rowProps = _objectWithoutProperties(_ref3, _excluded2);
70
+ var cellItems = columns === null || columns === void 0 ? void 0 : columns.map((_ref4, index) => {
71
+ var {
72
+ content
73
+ } = _ref4,
74
+ cellProps = _objectWithoutProperties(_ref4, _excluded3);
75
+ var headerContent = headers && headers[index]["content"];
76
+ var headerReplacement = headers && headers[index]["heading"];
77
+ if (responsive) {
78
+ cellProps["data-heading"] = typeof headerContent === "string" ? headerContent : headerReplacement;
79
+ }
80
+ return /*#__PURE__*/React.createElement(TableCell, _extends({
81
+ key: index
82
+ }, cellProps), content);
83
+ });
84
+ // if key was not provided as a prop, use row's index instead
85
+ if (key === null || typeof key === "undefined") {
86
+ key = index;
87
+ }
88
+
89
+ // The expanding cell is alway created to match the correct number of
90
+ // table cells in rows that do have expanding content.
91
+ return /*#__PURE__*/React.createElement(TableRow, _extends({
92
+ key: key
93
+ }, rowProps), cellItems, expanding && /*#__PURE__*/React.createElement(TableCell, {
94
+ expanding: true,
95
+ hidden: !expanded
96
+ }, expandedContent));
97
+ });
98
+ };
99
+ var sortRows = _ref5 => {
100
+ var {
101
+ currentSortDirection,
102
+ currentSortKey,
103
+ rows,
104
+ sortable,
105
+ sortFunction
106
+ } = _ref5;
107
+ if (!rows) {
108
+ return [];
109
+ }
110
+ // Clone the rows so we can restore the original order.
111
+ var sortedRows = [...rows];
112
+ if (sortable && currentSortKey) {
113
+ if (!sortFunction) {
114
+ sortFunction = (a, b) => {
115
+ if (!a.sortData || !b.sortData) {
116
+ return 0;
117
+ }
118
+ if (a.sortData[currentSortKey] > b.sortData[currentSortKey]) {
119
+ return currentSortDirection === "ascending" ? 1 : -1;
120
+ } else if (a.sortData[currentSortKey] < b.sortData[currentSortKey]) {
121
+ return currentSortDirection === "ascending" ? -1 : 1;
122
+ }
123
+ return 0;
124
+ };
125
+ }
126
+ sortedRows.sort((a, b) => sortFunction(a, b, currentSortDirection, currentSortKey));
127
+ }
128
+ return sortedRows;
129
+ };
130
+
131
+ /**
132
+ * This is a [React](https://reactjs.org/) component to support many table use cases.
133
+ */
134
+ var MainTable = _ref6 => {
135
+ var {
136
+ defaultSort,
137
+ defaultSortDirection,
138
+ emptyStateMsg = "",
139
+ expanding,
140
+ headers,
141
+ onUpdateSort,
142
+ paginate,
143
+ rows,
144
+ responsive,
145
+ sortable,
146
+ sortFunction,
147
+ hiddenCaption
148
+ } = _ref6,
149
+ props = _objectWithoutProperties(_ref6, _excluded4);
150
+ var [currentSortKey, setSortKey] = useState(defaultSort);
151
+ var [currentSortDirection, setSortDirection] = useState(defaultSortDirection);
152
+
153
+ // Update the current sort state if the prop changes.
154
+ useEffect(() => {
155
+ setSortKey(defaultSort);
156
+ }, [defaultSort]);
157
+
158
+ // Update the current sort direction state if the prop changes.
159
+ useEffect(() => {
160
+ setSortDirection(defaultSortDirection);
161
+ }, [defaultSortDirection]);
162
+ var updateSort = newSort => {
163
+ setSortKey(newSort);
164
+ onUpdateSort && onUpdateSort(newSort);
165
+ };
166
+ var sortedRows = useMemo(() => sortRows({
167
+ currentSortDirection,
168
+ currentSortKey,
169
+ rows,
170
+ sortable,
171
+ sortFunction
172
+ }), [currentSortDirection, currentSortKey, rows, sortable, sortFunction]);
173
+ var {
174
+ pageData: finalRows,
175
+ currentPage,
176
+ paginate: setCurrentPage
177
+ } = usePagination(sortedRows, {
178
+ itemsPerPage: paginate,
179
+ autoResetPage: true
180
+ });
181
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Table, _extends({
182
+ expanding: expanding,
183
+ responsive: responsive
184
+ }, props), hiddenCaption && /*#__PURE__*/React.createElement("caption", {
185
+ "data-testid": "hidden-caption",
186
+ style: {
187
+ height: "1px",
188
+ left: "-1000px",
189
+ overflow: "hidden",
190
+ position: "absolute",
191
+ top: "auto",
192
+ width: "1px"
193
+ }
194
+ }, hiddenCaption), !!headers && generateHeaders(currentSortKey, currentSortDirection, expanding, headers, sortable, updateSort, setSortDirection),
195
+ // If the table has no rows, return empty state message
196
+ Object.entries(finalRows).length === 0 && emptyStateMsg ? /*#__PURE__*/React.createElement("caption", null, emptyStateMsg) : /*#__PURE__*/React.createElement("tbody", null, generateRows({
197
+ rows: finalRows,
198
+ headers,
199
+ responsive,
200
+ expanding
201
+ }))), paginate && rows && rows.length > 0 && /*#__PURE__*/React.createElement(Pagination, {
202
+ currentPage: currentPage,
203
+ itemsPerPage: paginate,
204
+ paginate: setCurrentPage,
205
+ style: {
206
+ marginTop: "1rem"
207
+ },
208
+ totalItems: rows.length
209
+ }));
210
+ };
211
+ export default MainTable;
@@ -0,0 +1 @@
1
+ export { default } from "./MainTable";
@@ -0,0 +1,135 @@
1
+ var _excluded = ["buttonRow", "children", "className", "close", "title", "shouldPropagateClickEvent"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
5
+ import classNames from "classnames";
6
+ import React, { useId, useRef, useEffect } from "react";
7
+ /**
8
+ * This is a [React](https://reactjs.org/) component for the Vanilla [Modal](https://docs.vanillaframework.io/patterns/modal/).
9
+ *
10
+ * The modal component can be used to overlay an area of the screen which can contain a prompt, dialog or interaction.
11
+ */
12
+ export var Modal = _ref => {
13
+ var {
14
+ buttonRow,
15
+ children,
16
+ className,
17
+ close,
18
+ title,
19
+ shouldPropagateClickEvent = false
20
+ } = _ref,
21
+ wrapperProps = _objectWithoutProperties(_ref, _excluded);
22
+ // list of focusable selectors is based on this Stack Overflow answer:
23
+ // https://stackoverflow.com/a/30753870/3732840
24
+ var focusableElementSelectors = 'a[href]:not([tabindex="-1"]), button:not([disabled]), textarea:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), area[href]:not([tabindex="-1"]), iframe:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), [contentEditable=true]:not([tabindex="-1"])';
25
+ var descriptionId = useId();
26
+ var titleId = useId();
27
+ var shouldClose = useRef(false);
28
+ var modalRef = useRef(null);
29
+ var focusableModalElements = useRef(null);
30
+ var handleTabKey = event => {
31
+ if (focusableModalElements.current.length > 0) {
32
+ var firstElement = focusableModalElements.current[0];
33
+ var lastElement = focusableModalElements.current[focusableModalElements.current.length - 1];
34
+ if (!event.shiftKey && document.activeElement === lastElement) {
35
+ firstElement.focus();
36
+ event.preventDefault();
37
+ }
38
+ if (event.shiftKey && document.activeElement === firstElement) {
39
+ lastElement.focus();
40
+ return event.preventDefault();
41
+ }
42
+ }
43
+ };
44
+ var handleEscKey = event => {
45
+ if ("nativeEvent" in event && event.nativeEvent.stopImmediatePropagation) {
46
+ event.nativeEvent.stopImmediatePropagation();
47
+ } else if ("stopImmediatePropagation" in event) {
48
+ event.stopImmediatePropagation();
49
+ } else if (event.stopPropagation) {
50
+ event.stopPropagation();
51
+ }
52
+ if (close) {
53
+ close();
54
+ }
55
+ };
56
+ var keyListenersMap = new Map([["Escape", handleEscKey], ["Tab", handleTabKey]]);
57
+ useEffect(() => {
58
+ modalRef.current.focus();
59
+ }, [modalRef]);
60
+ useEffect(() => {
61
+ var _focusableModalElemen;
62
+ focusableModalElements.current = modalRef.current.querySelectorAll(focusableElementSelectors);
63
+ var focusIndex = 0;
64
+ // when the close button is rendered, focus on the 2nd content element and not the close btn.
65
+ if (close && focusableModalElements.current.length > 1) {
66
+ focusIndex = 1;
67
+ }
68
+ (_focusableModalElemen = focusableModalElements.current[focusIndex]) === null || _focusableModalElemen === void 0 || _focusableModalElemen.focus({
69
+ preventScroll: true
70
+ });
71
+ }, [close]);
72
+ useEffect(() => {
73
+ var keyDown = event => {
74
+ var listener = keyListenersMap.get(event.code);
75
+ return listener && listener(event);
76
+ };
77
+ document.addEventListener("keydown", keyDown);
78
+ return () => {
79
+ document.removeEventListener("keydown", keyDown);
80
+ };
81
+ });
82
+ var handleContentOnMouseDown = () => {
83
+ shouldClose.current = false;
84
+ };
85
+ var handleContentOnMouseUp = () => {
86
+ shouldClose.current = false;
87
+ };
88
+ var handleOverlayOnMouseDown = event => {
89
+ if (event.target === modalRef.current) {
90
+ shouldClose.current = true;
91
+ }
92
+ };
93
+ var handleClose = event => {
94
+ if (!shouldPropagateClickEvent) {
95
+ event.stopPropagation();
96
+ }
97
+ if (close) {
98
+ close();
99
+ }
100
+ };
101
+ var handleOverlayOnClick = event => {
102
+ if (shouldClose.current) {
103
+ handleClose(event);
104
+ }
105
+ };
106
+ return /*#__PURE__*/React.createElement("div", _extends({
107
+ className: classNames("p-modal", className),
108
+ onClick: handleOverlayOnClick,
109
+ onMouseDown: handleOverlayOnMouseDown
110
+ }, wrapperProps, {
111
+ ref: modalRef
112
+ }), /*#__PURE__*/React.createElement("section", {
113
+ className: "p-modal__dialog",
114
+ role: "dialog",
115
+ "aria-modal": "true",
116
+ "aria-labelledby": titleId,
117
+ "aria-describedby": descriptionId,
118
+ onMouseDown: handleContentOnMouseDown,
119
+ onMouseUp: handleContentOnMouseUp
120
+ }, !!title && /*#__PURE__*/React.createElement("header", {
121
+ className: "p-modal__header"
122
+ }, /*#__PURE__*/React.createElement("h2", {
123
+ className: "p-modal__title",
124
+ id: titleId
125
+ }, title), !!close && /*#__PURE__*/React.createElement("button", {
126
+ className: "p-modal__close",
127
+ "aria-label": "Close active modal",
128
+ onClick: handleClose
129
+ }, "Close")), /*#__PURE__*/React.createElement("div", {
130
+ id: descriptionId
131
+ }, children), !!buttonRow && /*#__PURE__*/React.createElement("footer", {
132
+ className: "p-modal__footer"
133
+ }, buttonRow)));
134
+ };
135
+ export default Modal;
@@ -0,0 +1 @@
1
+ export { default } from "./Modal";
@@ -0,0 +1,166 @@
1
+ var _excluded = ["data", "columns", "emptyMsg", "footer", "sortable", "getHeaderProps", "getRowProps", "getCellProps", "getRowId", "initialSortColumn", "initialSortDirection", "autoResetSortBy"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import React, { useMemo, isValidElement } from "react";
11
+ import { useTable, useSortBy } from "react-table";
12
+ import Table from "../Table";
13
+ import TableRow from "../TableRow";
14
+ import TableHeader from "../TableHeader";
15
+ import TableCell from "../TableCell";
16
+ import Icon from "../Icon";
17
+ var generateCell = (cell, getCellProps) => {
18
+ var _cell$column$getCellI, _cell$column;
19
+ var hasColumnIcon = cell.column.getCellIcon;
20
+ var iconName = hasColumnIcon && ((_cell$column$getCellI = (_cell$column = cell.column).getCellIcon) === null || _cell$column$getCellI === void 0 ? void 0 : _cell$column$getCellI.call(_cell$column, cell));
21
+ return /*#__PURE__*/React.createElement(TableCell, cell.getCellProps([{
22
+ className: cell.column.className
23
+ }, {
24
+ className: hasColumnIcon ? "p-table__cell--icon-placeholder" : ""
25
+ }, _objectSpread({}, getCellProps === null || getCellProps === void 0 ? void 0 : getCellProps(cell))]), iconName && /*#__PURE__*/React.createElement(Icon, {
26
+ name: iconName
27
+ }), cell.render("Cell"));
28
+ };
29
+ var generateRows = (rows, prepareRow, getRowProps, getCellProps) => {
30
+ var tableRows = [];
31
+ rows.forEach(row => {
32
+ var _row$subRows;
33
+ // This function is responsible for lazily preparing a row for rendering.
34
+ // Any row that you intend to render in your table needs to be passed to this function before every render.
35
+ // see: https://react-table.tanstack.com/docs/api/useTable#instance-properties
36
+ prepareRow(row);
37
+ tableRows.push( /*#__PURE__*/React.createElement(TableRow, row.getRowProps(getRowProps === null || getRowProps === void 0 ? void 0 : getRowProps(row)), row.cells.map(cell => generateCell(cell, getCellProps))));
38
+ if ((_row$subRows = row.subRows) !== null && _row$subRows !== void 0 && _row$subRows.length) {
39
+ tableRows = tableRows.concat(generateRows(row.subRows, prepareRow, getRowProps, getCellProps));
40
+ }
41
+ });
42
+ return tableRows;
43
+ };
44
+
45
+ /**
46
+ This is a [React](https://reactjs.org/) component to support many table use cases.
47
+
48
+ ModularTable components accepts `columns` and `data` arguments in the same format as [`useTable`](https://react-table.tanstack.com/docs/api/useTable) hook of the ReactTable library.
49
+
50
+ `columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
51
+ `data` - The data array that you want to display on the table.
52
+ ### Important note!
53
+ Values passed to both of these params have to me memoized (for example via{" "}
54
+ <code>React.useMemo</code>). Memoization ensures that our data isn't recreated
55
+ on every render. If we didn't use <code>React.useMemo</code>, the table would
56
+ think it was receiving new data on every render and attempt to recalulate a
57
+ lot of logic every single time.
58
+
59
+ #### Custom column options
60
+
61
+ In addition to standard column propeties from [`useTable`](https://react-table.tanstack.com/docs/api/useTable) `ModularTable` accepts some custom properties.
62
+
63
+ ##### Class names
64
+
65
+ Custom `className` can be used to provide a specific CSS class name that will be added to all cells in given column.
66
+ You can also provide `getHeaderProps`, `getRowProps` and `getCellProps` to resolve additional custom props for a specific element. More on this in [`useTable - cell properties`](https://react-table.tanstack.com/docs/api/useTable#cell-properties).
67
+
68
+ ```js
69
+ getCellProps={({ value, column }) => ({
70
+ className: `table__cell--${column.id} ${value === "1 minute" ? "p-heading--5" : ""}`,
71
+ })}
72
+ columns = {
73
+ Header: "Hidden on mobile",
74
+ accessor: "example",
75
+ className: "u-hide--small"
76
+ }
77
+ ```
78
+
79
+ ##### Icons
80
+
81
+ To show an icon in the cells of a column `getCellIcon` function should be defined. The function takes a cell data as an argument and should return one of built in icons (from the `ICONS` const), a string with a custom icon name, or `false` if no icon should be shown.
82
+
83
+ The `ICONS` const contains all [the Vanilla built in icons](https://vanillaframework.io/docs/patterns/icons) such as "plus", "minus", "success", "error", etc.
84
+
85
+ Product specific icons can be used as well, assuming that the product provides the necessary CSS styling and the icon follows the Vanilla naming convention `p-icon--{name}`.
86
+
87
+ ```js
88
+ columns = {
89
+ Header: "With icons",
90
+ accessor: "status",
91
+ getCellIcon: ({ value }) => {
92
+ return value === "released" ? ICONS.success : false;
93
+ },
94
+ };
95
+ ```
96
+ */
97
+ function ModularTable(_ref) {
98
+ var {
99
+ data,
100
+ columns,
101
+ emptyMsg,
102
+ footer,
103
+ sortable,
104
+ getHeaderProps,
105
+ getRowProps,
106
+ getCellProps,
107
+ getRowId,
108
+ initialSortColumn,
109
+ initialSortDirection,
110
+ autoResetSortBy = false
111
+ } = _ref,
112
+ props = _objectWithoutProperties(_ref, _excluded);
113
+ var sortBy = useMemo(() => initialSortColumn ? [{
114
+ id: initialSortColumn,
115
+ desc: initialSortDirection === "descending"
116
+ }] : [], [initialSortColumn, initialSortDirection]);
117
+ var {
118
+ getTableProps,
119
+ getTableBodyProps,
120
+ headerGroups,
121
+ rows,
122
+ prepareRow
123
+ } = useTable({
124
+ columns,
125
+ data,
126
+ getRowId: getRowId || undefined,
127
+ initialState: {
128
+ sortBy
129
+ },
130
+ autoResetSortBy
131
+ }, sortable ? useSortBy : undefined);
132
+ var showEmpty = !!emptyMsg && (!rows || rows.length === 0);
133
+
134
+ // Function returns whether table can be sorted by a specific column.
135
+ // Returns true if sorting is enabled for the column and there is text
136
+ // or JSX provided for the header, otherwise returns false.
137
+ var isColumnSortable = column => column.canSort && ( /*#__PURE__*/isValidElement(column.Header) || (typeof column.Header === "string" || typeof column.Header === "number") && !!String(column.Header).trim());
138
+ var getColumnSortDirection = column => {
139
+ if (!isColumnSortable(column)) {
140
+ return undefined;
141
+ }
142
+ if (!column.isSorted) {
143
+ return "none";
144
+ }
145
+ return column.isSortedDesc ? "descending" : "ascending";
146
+ };
147
+ return /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), props), /*#__PURE__*/React.createElement("thead", null, headerGroups.map((headerGroup, i) => /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps(), {
148
+ key: i
149
+ }), headerGroup.headers.map((column, j) => /*#__PURE__*/React.createElement(TableHeader, _extends({
150
+ key: j,
151
+ sort: getColumnSortDirection(column)
152
+ }, column.getHeaderProps([{
153
+ className: column.className
154
+ }, {
155
+ className: column.getCellIcon ? "p-table__cell--icon-placeholder" : ""
156
+ }, _objectSpread({}, getHeaderProps === null || getHeaderProps === void 0 ? void 0 : getHeaderProps(column)),
157
+ // Only call this if we want it to be sortable too.
158
+ sortable && isColumnSortable(column) ? column.getSortByToggleProps({
159
+ title: undefined
160
+ }) : {}])), column.render("Header")))))), /*#__PURE__*/React.createElement("tbody", getTableBodyProps(), generateRows(rows, prepareRow, getRowProps, getCellProps), showEmpty && /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
161
+ colSpan: columns.length
162
+ }, emptyMsg)), footer && /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
163
+ colSpan: columns.length
164
+ }, footer))));
165
+ }
166
+ export default ModularTable;
@@ -0,0 +1 @@
1
+ export { default } from "./ModularTable";
@@ -0,0 +1,25 @@
1
+ import _pt from "prop-types";
2
+ import React from "react";
3
+ import classNames from "classnames";
4
+ import "./FadeInDown.scss";
5
+ /**
6
+ * EXPERIMENTAL: This component is experimental and should be used internally only.
7
+ */
8
+ export var FadeInDown = _ref => {
9
+ var {
10
+ children,
11
+ className,
12
+ isVisible
13
+ } = _ref;
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ className: classNames("fade-in--down", className),
16
+ "aria-hidden": isVisible ? "false" : "true",
17
+ style: {
18
+ visibility: isVisible ? "visible" : "hidden"
19
+ }
20
+ }, children);
21
+ };
22
+ FadeInDown.propTypes = {
23
+ isVisible: _pt.bool.isRequired,
24
+ className: _pt.string
25
+ };
@@ -0,0 +1 @@
1
+ export * from "./FadeInDown";