@canonical/react-components 1.2.4 → 1.3.0

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 (287) hide show
  1. package/README.md +2 -2
  2. package/package.json +9 -6
  3. package/dist/components/Accordion/Accordion.d.ts +0 -46
  4. package/dist/components/Accordion/Accordion.stories.d.ts +0 -18
  5. package/dist/components/Accordion/Accordion.stories.js +0 -117
  6. package/dist/components/Accordion/AccordionSection/AccordionSection.d.ts +0 -34
  7. package/dist/components/Accordion/AccordionSection/index.d.ts +0 -2
  8. package/dist/components/Accordion/index.d.ts +0 -2
  9. package/dist/components/ActionButton/ActionButton.d.ts +0 -48
  10. package/dist/components/ActionButton/ActionButton.stories.d.ts +0 -7
  11. package/dist/components/ActionButton/ActionButton.stories.js +0 -36
  12. package/dist/components/ActionButton/index.d.ts +0 -2
  13. package/dist/components/ApplicationLayout/AppAside/AppAside.d.ts +0 -33
  14. package/dist/components/ApplicationLayout/AppAside/AppAside.stories.d.ts +0 -13
  15. package/dist/components/ApplicationLayout/AppAside/AppAside.stories.js +0 -116
  16. package/dist/components/ApplicationLayout/AppAside/index.d.ts +0 -2
  17. package/dist/components/ApplicationLayout/AppMain/AppMain.d.ts +0 -14
  18. package/dist/components/ApplicationLayout/AppMain/AppMain.stories.d.ts +0 -14
  19. package/dist/components/ApplicationLayout/AppMain/AppMain.stories.js +0 -45
  20. package/dist/components/ApplicationLayout/AppMain/index.d.ts +0 -2
  21. package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.d.ts +0 -26
  22. package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.stories.d.ts +0 -12
  23. package/dist/components/ApplicationLayout/AppNavigation/AppNavigation.stories.js +0 -104
  24. package/dist/components/ApplicationLayout/AppNavigation/index.d.ts +0 -2
  25. package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.d.ts +0 -18
  26. package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.stories.d.ts +0 -15
  27. package/dist/components/ApplicationLayout/AppNavigationBar/AppNavigationBar.stories.js +0 -52
  28. package/dist/components/ApplicationLayout/AppNavigationBar/index.d.ts +0 -2
  29. package/dist/components/ApplicationLayout/AppStatus/AppStatus.d.ts +0 -14
  30. package/dist/components/ApplicationLayout/AppStatus/AppStatus.stories.d.ts +0 -13
  31. package/dist/components/ApplicationLayout/AppStatus/AppStatus.stories.js +0 -41
  32. package/dist/components/ApplicationLayout/AppStatus/index.d.ts +0 -2
  33. package/dist/components/ApplicationLayout/Application/Application.d.ts +0 -15
  34. package/dist/components/ApplicationLayout/Application/Application.stories.d.ts +0 -6
  35. package/dist/components/ApplicationLayout/Application/Application.stories.js +0 -16
  36. package/dist/components/ApplicationLayout/Application/index.d.ts +0 -2
  37. package/dist/components/ApplicationLayout/ApplicationLayout.d.ts +0 -89
  38. package/dist/components/ApplicationLayout/ApplicationLayout.stories.d.ts +0 -24
  39. package/dist/components/ApplicationLayout/ApplicationLayout.stories.js +0 -232
  40. package/dist/components/ApplicationLayout/index.d.ts +0 -7
  41. package/dist/components/ArticlePagination/ArticlePagination.d.ts +0 -31
  42. package/dist/components/ArticlePagination/ArticlePagination.stories.d.ts +0 -6
  43. package/dist/components/ArticlePagination/ArticlePagination.stories.js +0 -22
  44. package/dist/components/ArticlePagination/index.d.ts +0 -2
  45. package/dist/components/Badge/Badge.d.ts +0 -34
  46. package/dist/components/Badge/Badge.stories.d.ts +0 -15
  47. package/dist/components/Badge/Badge.stories.js +0 -62
  48. package/dist/components/Badge/index.d.ts +0 -2
  49. package/dist/components/Button/Button.d.ts +0 -64
  50. package/dist/components/Button/Button.stories.d.ts +0 -32
  51. package/dist/components/Button/Button.stories.js +0 -180
  52. package/dist/components/Button/index.d.ts +0 -2
  53. package/dist/components/Card/Card.d.ts +0 -35
  54. package/dist/components/Card/Card.stories.d.ts +0 -33
  55. package/dist/components/Card/Card.stories.js +0 -51
  56. package/dist/components/Card/index.d.ts +0 -2
  57. package/dist/components/CheckboxInput/CheckableInput/CheckableInput.d.ts +0 -27
  58. package/dist/components/CheckboxInput/CheckableInput/index.d.ts +0 -2
  59. package/dist/components/CheckboxInput/CheckboxInput.d.ts +0 -9
  60. package/dist/components/CheckboxInput/CheckboxInput.stories.d.ts +0 -11
  61. package/dist/components/CheckboxInput/CheckboxInput.stories.js +0 -84
  62. package/dist/components/CheckboxInput/index.d.ts +0 -2
  63. package/dist/components/Chip/Chip.d.ts +0 -56
  64. package/dist/components/Chip/Chip.stories.d.ts +0 -9
  65. package/dist/components/Chip/Chip.stories.js +0 -45
  66. package/dist/components/Chip/index.d.ts +0 -2
  67. package/dist/components/Code/Code.d.ts +0 -13
  68. package/dist/components/Code/index.d.ts +0 -2
  69. package/dist/components/CodeSnippet/CodeSnippet.d.ts +0 -21
  70. package/dist/components/CodeSnippet/CodeSnippet.stories.d.ts +0 -45
  71. package/dist/components/CodeSnippet/CodeSnippet.stories.js +0 -279
  72. package/dist/components/CodeSnippet/CodeSnippetBlock.d.ts +0 -40
  73. package/dist/components/CodeSnippet/CodeSnippetDropdown.d.ts +0 -18
  74. package/dist/components/CodeSnippet/index.d.ts +0 -5
  75. package/dist/components/Col/Col.d.ts +0 -53
  76. package/dist/components/Col/Col.stories.d.ts +0 -11
  77. package/dist/components/Col/Col.stories.js +0 -154
  78. package/dist/components/Col/index.d.ts +0 -2
  79. package/dist/components/ConfirmationButton/ConfirmationButton.d.ts +0 -28
  80. package/dist/components/ConfirmationButton/ConfirmationButton.stories.d.ts +0 -9
  81. package/dist/components/ConfirmationButton/ConfirmationButton.stories.js +0 -108
  82. package/dist/components/ConfirmationButton/index.d.ts +0 -2
  83. package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +0 -53
  84. package/dist/components/ConfirmationModal/ConfirmationModal.stories.d.ts +0 -18
  85. package/dist/components/ConfirmationModal/ConfirmationModal.stories.js +0 -135
  86. package/dist/components/ConfirmationModal/index.d.ts +0 -2
  87. package/dist/components/ContextualMenu/ContextualMenu.d.ts +0 -110
  88. package/dist/components/ContextualMenu/ContextualMenu.stories.d.ts +0 -13
  89. package/dist/components/ContextualMenu/ContextualMenu.stories.js +0 -107
  90. package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.d.ts +0 -43
  91. package/dist/components/ContextualMenu/ContextualMenuDropdown/index.d.ts +0 -2
  92. package/dist/components/ContextualMenu/index.d.ts +0 -3
  93. package/dist/components/EmptyState/EmptyState.d.ts +0 -25
  94. package/dist/components/EmptyState/EmptyState.stories.d.ts +0 -7
  95. package/dist/components/EmptyState/EmptyState.stories.js +0 -49
  96. package/dist/components/EmptyState/index.d.ts +0 -2
  97. package/dist/components/Field/Field.d.ts +0 -77
  98. package/dist/components/Field/index.d.ts +0 -2
  99. package/dist/components/Form/Form.d.ts +0 -21
  100. package/dist/components/Form/Form.stories.d.ts +0 -12
  101. package/dist/components/Form/Form.stories.js +0 -179
  102. package/dist/components/Form/index.d.ts +0 -2
  103. package/dist/components/FormikField/FormikField.d.ts +0 -25
  104. package/dist/components/FormikField/FormikField.stories.d.ts +0 -8
  105. package/dist/components/FormikField/FormikField.stories.js +0 -85
  106. package/dist/components/FormikField/index.d.ts +0 -1
  107. package/dist/components/Icon/Icon.d.ts +0 -59
  108. package/dist/components/Icon/Icon.stories.d.ts +0 -16
  109. package/dist/components/Icon/Icon.stories.js +0 -49
  110. package/dist/components/Icon/index.d.ts +0 -2
  111. package/dist/components/Input/Input.d.ts +0 -70
  112. package/dist/components/Input/Input.stories.d.ts +0 -14
  113. package/dist/components/Input/Input.stories.js +0 -148
  114. package/dist/components/Input/index.d.ts +0 -2
  115. package/dist/components/Label/Label.d.ts +0 -25
  116. package/dist/components/Label/index.d.ts +0 -2
  117. package/dist/components/Link/Link.d.ts +0 -31
  118. package/dist/components/Link/Link.stories.d.ts +0 -9
  119. package/dist/components/Link/Link.stories.js +0 -48
  120. package/dist/components/Link/index.d.ts +0 -2
  121. package/dist/components/List/List.d.ts +0 -36
  122. package/dist/components/List/List.stories.d.ts +0 -15
  123. package/dist/components/List/List.stories.js +0 -122
  124. package/dist/components/List/index.d.ts +0 -2
  125. package/dist/components/Loader/Loader.d.ts +0 -6
  126. package/dist/components/Loader/index.d.ts +0 -1
  127. package/dist/components/LoginPageLayout/LoginPageLayout.d.ts +0 -17
  128. package/dist/components/LoginPageLayout/LoginPageLayout.stories.d.ts +0 -9
  129. package/dist/components/LoginPageLayout/LoginPageLayout.stories.js +0 -58
  130. package/dist/components/LoginPageLayout/index.d.ts +0 -2
  131. package/dist/components/MainTable/MainTable.d.ts +0 -102
  132. package/dist/components/MainTable/MainTable.stories.d.ts +0 -15
  133. package/dist/components/MainTable/MainTable.stories.js +0 -553
  134. package/dist/components/MainTable/index.d.ts +0 -2
  135. package/dist/components/Modal/Modal.d.ts +0 -36
  136. package/dist/components/Modal/Modal.stories.d.ts +0 -6
  137. package/dist/components/Modal/Modal.stories.js +0 -57
  138. package/dist/components/Modal/index.d.ts +0 -2
  139. package/dist/components/ModularTable/ModularTable.d.ts +0 -105
  140. package/dist/components/ModularTable/ModularTable.stories.d.ts +0 -27
  141. package/dist/components/ModularTable/ModularTable.stories.js +0 -343
  142. package/dist/components/ModularTable/index.d.ts +0 -2
  143. package/dist/components/MultiSelect/FadeInDown/FadeInDown.d.ts +0 -10
  144. package/dist/components/MultiSelect/FadeInDown/index.d.ts +0 -1
  145. package/dist/components/MultiSelect/MultiSelect.d.ts +0 -57
  146. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +0 -8
  147. package/dist/components/MultiSelect/MultiSelect.stories.js +0 -70
  148. package/dist/components/MultiSelect/index.d.ts +0 -1
  149. package/dist/components/Navigation/Navigation.d.ts +0 -66
  150. package/dist/components/Navigation/Navigation.stories.d.ts +0 -43
  151. package/dist/components/Navigation/Navigation.stories.js +0 -232
  152. package/dist/components/Navigation/NavigationLink/NavigationLink.d.ts +0 -10
  153. package/dist/components/Navigation/NavigationLink/index.d.ts +0 -1
  154. package/dist/components/Navigation/NavigationMenu/NavigationMenu.d.ts +0 -11
  155. package/dist/components/Navigation/NavigationMenu/index.d.ts +0 -1
  156. package/dist/components/Navigation/index.d.ts +0 -3
  157. package/dist/components/Navigation/types.d.ts +0 -64
  158. package/dist/components/Notification/Notification.d.ts +0 -110
  159. package/dist/components/Notification/Notification.stories.d.ts +0 -45
  160. package/dist/components/Notification/Notification.stories.js +0 -201
  161. package/dist/components/Notification/index.d.ts +0 -2
  162. package/dist/components/NotificationProvider/NotificationProvider.d.ts +0 -5
  163. package/dist/components/NotificationProvider/index.d.ts +0 -3
  164. package/dist/components/NotificationProvider/messageBuilder.d.ts +0 -6
  165. package/dist/components/NotificationProvider/types.d.ts +0 -35
  166. package/dist/components/Pagination/Pagination.d.ts +0 -102
  167. package/dist/components/Pagination/Pagination.stories.d.ts +0 -14
  168. package/dist/components/Pagination/Pagination.stories.js +0 -94
  169. package/dist/components/Pagination/PaginationButton/PaginationButton.d.ts +0 -30
  170. package/dist/components/Pagination/PaginationButton/index.d.ts +0 -2
  171. package/dist/components/Pagination/PaginationItem/PaginationItem.d.ts +0 -17
  172. package/dist/components/Pagination/PaginationItem/index.d.ts +0 -2
  173. package/dist/components/Pagination/index.d.ts +0 -2
  174. package/dist/components/Panel/Panel.d.ts +0 -123
  175. package/dist/components/Panel/Panel.stories.d.ts +0 -17
  176. package/dist/components/Panel/Panel.stories.js +0 -60
  177. package/dist/components/Panel/index.d.ts +0 -1
  178. package/dist/components/PasswordToggle/PasswordToggle.d.ts +0 -108
  179. package/dist/components/PasswordToggle/PasswordToggle.stories.d.ts +0 -12
  180. package/dist/components/PasswordToggle/PasswordToggle.stories.js +0 -74
  181. package/dist/components/PasswordToggle/index.d.ts +0 -2
  182. package/dist/components/RadioInput/RadioInput.d.ts +0 -9
  183. package/dist/components/RadioInput/RadioInput.stories.d.ts +0 -10
  184. package/dist/components/RadioInput/RadioInput.stories.js +0 -83
  185. package/dist/components/RadioInput/index.d.ts +0 -2
  186. package/dist/components/Row/Row.d.ts +0 -19
  187. package/dist/components/Row/Row.stories.d.ts +0 -9
  188. package/dist/components/Row/Row.stories.js +0 -29
  189. package/dist/components/Row/index.d.ts +0 -2
  190. package/dist/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.d.ts +0 -25
  191. package/dist/components/SearchAndFilter/FilterPanelSection/index.d.ts +0 -1
  192. package/dist/components/SearchAndFilter/SearchAndFilter.d.ts +0 -33
  193. package/dist/components/SearchAndFilter/SearchAndFilter.stories.d.ts +0 -8
  194. package/dist/components/SearchAndFilter/SearchAndFilter.stories.js +0 -218
  195. package/dist/components/SearchAndFilter/index.d.ts +0 -2
  196. package/dist/components/SearchAndFilter/types.d.ts +0 -11
  197. package/dist/components/SearchAndFilter/utils.d.ts +0 -13
  198. package/dist/components/SearchBox/SearchBox.d.ts +0 -63
  199. package/dist/components/SearchBox/SearchBox.stories.d.ts +0 -14
  200. package/dist/components/SearchBox/SearchBox.stories.js +0 -106
  201. package/dist/components/SearchBox/index.d.ts +0 -2
  202. package/dist/components/Select/Select.d.ts +0 -71
  203. package/dist/components/Select/Select.stories.d.ts +0 -7
  204. package/dist/components/Select/Select.stories.js +0 -97
  205. package/dist/components/Select/index.d.ts +0 -2
  206. package/dist/components/SideNavigation/SideNavigation.d.ts +0 -50
  207. package/dist/components/SideNavigation/SideNavigation.stories.d.ts +0 -14
  208. package/dist/components/SideNavigation/SideNavigation.stories.js +0 -62
  209. package/dist/components/SideNavigation/SideNavigationBase/SideNavigationBase.d.ts +0 -31
  210. package/dist/components/SideNavigation/SideNavigationBase/index.d.ts +0 -1
  211. package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.d.ts +0 -20
  212. package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.stories.d.ts +0 -22
  213. package/dist/components/SideNavigation/SideNavigationItem/SideNavigationItem.stories.js +0 -70
  214. package/dist/components/SideNavigation/SideNavigationItem/index.d.ts +0 -1
  215. package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.d.ts +0 -21
  216. package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.stories.d.ts +0 -7
  217. package/dist/components/SideNavigation/SideNavigationLink/SideNavigationLink.stories.js +0 -32
  218. package/dist/components/SideNavigation/SideNavigationLink/index.d.ts +0 -1
  219. package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.d.ts +0 -7
  220. package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.stories.d.ts +0 -6
  221. package/dist/components/SideNavigation/SideNavigationText/SideNavigationText.stories.js +0 -25
  222. package/dist/components/SideNavigation/SideNavigationText/index.d.ts +0 -1
  223. package/dist/components/SideNavigation/index.d.ts +0 -5
  224. package/dist/components/Slider/Slider.d.ts +0 -62
  225. package/dist/components/Slider/Slider.stories.d.ts +0 -10
  226. package/dist/components/Slider/Slider.stories.js +0 -74
  227. package/dist/components/Slider/index.d.ts +0 -2
  228. package/dist/components/Spinner/Spinner.d.ts +0 -29
  229. package/dist/components/Spinner/Spinner.stories.d.ts +0 -8
  230. package/dist/components/Spinner/Spinner.stories.js +0 -28
  231. package/dist/components/Spinner/index.d.ts +0 -2
  232. package/dist/components/StatusLabel/StatusLabel.d.ts +0 -33
  233. package/dist/components/StatusLabel/StatusLabel.stories.d.ts +0 -10
  234. package/dist/components/StatusLabel/StatusLabel.stories.js +0 -61
  235. package/dist/components/StatusLabel/index.d.ts +0 -2
  236. package/dist/components/Strip/Strip.d.ts +0 -64
  237. package/dist/components/Strip/Strip.stories.d.ts +0 -12
  238. package/dist/components/Strip/Strip.stories.js +0 -130
  239. package/dist/components/Strip/index.d.ts +0 -2
  240. package/dist/components/SummaryButton/SummaryButton.d.ts +0 -29
  241. package/dist/components/SummaryButton/SummaryButton.stories.d.ts +0 -18
  242. package/dist/components/SummaryButton/SummaryButton.stories.js +0 -59
  243. package/dist/components/SummaryButton/index.d.ts +0 -2
  244. package/dist/components/Switch/Switch.d.ts +0 -17
  245. package/dist/components/Switch/Switch.stories.d.ts +0 -7
  246. package/dist/components/Switch/Switch.stories.js +0 -26
  247. package/dist/components/Switch/index.d.ts +0 -2
  248. package/dist/components/Table/Table.d.ts +0 -22
  249. package/dist/components/Table/index.d.ts +0 -2
  250. package/dist/components/TableCell/TableCell.d.ts +0 -26
  251. package/dist/components/TableCell/index.d.ts +0 -2
  252. package/dist/components/TableHeader/TableHeader.d.ts +0 -14
  253. package/dist/components/TableHeader/index.d.ts +0 -2
  254. package/dist/components/TablePagination/TablePagination.d.ts +0 -98
  255. package/dist/components/TablePagination/TablePagination.stories.d.ts +0 -14
  256. package/dist/components/TablePagination/TablePagination.stories.js +0 -330
  257. package/dist/components/TablePagination/TablePaginationControls/TablePaginationControls.d.ts +0 -24
  258. package/dist/components/TablePagination/TablePaginationControls/index.d.ts +0 -2
  259. package/dist/components/TablePagination/index.d.ts +0 -2
  260. package/dist/components/TablePagination/utils.d.ts +0 -27
  261. package/dist/components/TableRow/TableRow.d.ts +0 -10
  262. package/dist/components/TableRow/index.d.ts +0 -2
  263. package/dist/components/Tabs/Tabs.d.ts +0 -45
  264. package/dist/components/Tabs/Tabs.stories.d.ts +0 -11
  265. package/dist/components/Tabs/Tabs.stories.js +0 -56
  266. package/dist/components/Tabs/index.d.ts +0 -2
  267. package/dist/components/Textarea/Textarea.d.ts +0 -70
  268. package/dist/components/Textarea/Textarea.stories.d.ts +0 -7
  269. package/dist/components/Textarea/Textarea.stories.js +0 -62
  270. package/dist/components/Textarea/index.d.ts +0 -2
  271. package/dist/components/Tooltip/Tooltip.d.ts +0 -75
  272. package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -12
  273. package/dist/components/Tooltip/Tooltip.stories.js +0 -71
  274. package/dist/components/Tooltip/index.d.ts +0 -2
  275. package/dist/enums.d.ts +0 -13
  276. package/dist/hooks/index.d.ts +0 -9
  277. package/dist/hooks/useId.d.ts +0 -4
  278. package/dist/hooks/useListener.d.ts +0 -11
  279. package/dist/hooks/useOnClickOutside.d.ts +0 -12
  280. package/dist/hooks/useOnEscapePressed.d.ts +0 -6
  281. package/dist/hooks/usePagination.d.ts +0 -19
  282. package/dist/hooks/usePrevious.d.ts +0 -7
  283. package/dist/hooks/useThrottle.d.ts +0 -9
  284. package/dist/hooks/useWindowFitment.d.ts +0 -54
  285. package/dist/index.d.ts +0 -132
  286. package/dist/types/index.d.ts +0 -38
  287. package/dist/utils.d.ts +0 -27
@@ -1,105 +0,0 @@
1
- import { ReactNode, HTMLProps } from "react";
2
- import { TableCellProps, TableHeaderProps, TableRowProps } from "react-table";
3
- import type { Column, UseTableOptions, Cell, Row, HeaderGroup } from "react-table";
4
- import { PropsWithSpread } from "../../types";
5
- export type Props<D extends Record<string, unknown>> = PropsWithSpread<{
6
- /**
7
- * The columns of the table.
8
- */
9
- columns: Column<D>[];
10
- /**
11
- * The data of the table.
12
- */
13
- data: D[];
14
- /**
15
- * A message to display if data is empty.
16
- */
17
- emptyMsg?: string;
18
- /**
19
- * Optional extra row to display underneath the main table content.
20
- */
21
- footer?: ReactNode;
22
- /**
23
- * Optional argument to make the tables be sortable and use the `useSortBy` plugin.
24
- */
25
- sortable?: boolean;
26
- /**
27
- * This function is used to resolve any props needed for a particular column's header cell.
28
- */
29
- getHeaderProps?: (header: HeaderGroup<D>) => Partial<TableHeaderProps & HTMLProps<HTMLTableHeaderCellElement>>;
30
- /**
31
- * This function is used to resolve any props needed for a particular row.
32
- */
33
- getRowProps?: (row: Row<D>) => Partial<TableRowProps & HTMLProps<HTMLTableRowElement>>;
34
- /**
35
- * This function is used to resolve any props needed for a particular cell.
36
- */
37
- getCellProps?: (cell: Cell<D>) => Partial<TableCellProps & HTMLProps<HTMLTableCellElement>>;
38
- getRowId?: UseTableOptions<D>["getRowId"];
39
- /**
40
- * The column that the table will be sorted by (this should match a cell selector).
41
- */
42
- initialSortColumn?: string;
43
- /**
44
- * The direction of the initial sort.
45
- */
46
- initialSortDirection?: "ascending" | "descending";
47
- /**
48
- * Whether the sort by needs to be reset after each data change.
49
- */
50
- autoResetSortBy?: boolean;
51
- }, HTMLProps<HTMLTableElement>>;
52
- /**
53
- This is a [React](https://reactjs.org/) component to support many table use cases.
54
-
55
- 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.
56
-
57
- `columns` - The core columns configuration object for the entire table. https://react-table.tanstack.com/docs/api/useTable#column-options
58
- `data` - The data array that you want to display on the table.
59
- ### Important note!
60
- Values passed to both of these params have to me memoized (for example via{" "}
61
- <code>React.useMemo</code>). Memoization ensures that our data isn't recreated
62
- on every render. If we didn't use <code>React.useMemo</code>, the table would
63
- think it was receiving new data on every render and attempt to recalulate a
64
- lot of logic every single time.
65
-
66
- #### Custom column options
67
-
68
- In addition to standard column propeties from [`useTable`](https://react-table.tanstack.com/docs/api/useTable) `ModularTable` accepts some custom properties.
69
-
70
- ##### Class names
71
-
72
- Custom `className` can be used to provide a specific CSS class name that will be added to all cells in given column.
73
- 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).
74
-
75
- ```js
76
- getCellProps={({ value, column }) => ({
77
- className: `table__cell--${column.id} ${value === "1 minute" ? "p-heading--5" : ""}`,
78
- })}
79
- columns = {
80
- Header: "Hidden on mobile",
81
- accessor: "example",
82
- className: "u-hide--small"
83
- }
84
- ```
85
-
86
- ##### Icons
87
-
88
- 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.
89
-
90
- The `ICONS` const contains all [the Vanilla built in icons](https://vanillaframework.io/docs/patterns/icons) such as "plus", "minus", "success", "error", etc.
91
-
92
- 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}`.
93
-
94
- ```js
95
- columns = {
96
- Header: "With icons",
97
- accessor: "status",
98
- getCellIcon: ({ value }) => {
99
- return value === "released" ? ICONS.success : false;
100
- },
101
- };
102
- ```
103
- */
104
- declare function ModularTable<D extends Record<string, unknown>>({ data, columns, emptyMsg, footer, sortable, getHeaderProps, getRowProps, getCellProps, getRowId, initialSortColumn, initialSortDirection, autoResetSortBy, ...props }: Props<D>): JSX.Element;
105
- export default ModularTable;
@@ -1,27 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import ModularTable from "./ModularTable";
3
- declare const meta: Meta<typeof ModularTable>;
4
- export default meta;
5
- type Story = StoryObj<typeof ModularTable>;
6
- export declare const Default: Story;
7
- export declare const Empty: Story;
8
- export declare const Sortable: Story;
9
- /**
10
- * Subrows can be used to group table rows under a heading that needs to appear
11
- at the start of the group. In the following example sorting the columns will
12
- sort the group rows, then sort the sub-rows, but the group header always comes first.
13
- */
14
- export declare const Subrows: Story;
15
- /**
16
- Example below shows a basic `ModularTable` with `SummaryButton` component in the footer.
17
- ```
18
- export const getSampleData = (i = 0) => [
19
- { data: ++i * 100 + i },
20
- { data: ++i * 100 + i },
21
- { data: ++i * 100 + i },
22
- { data: ++i * 100 + i },
23
- { data: ++i * 100 + i },
24
- ];
25
- ```
26
- */
27
- export declare const LoadMore: Story;
@@ -1,343 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.Subrows = exports.Sortable = exports.LoadMore = exports.Empty = exports.Default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _SummaryButton = _interopRequireDefault(require("../SummaryButton"));
9
- var _ModularTable = _interopRequireDefault(require("./ModularTable"));
10
- var _Icon = require("../Icon");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
- const getSampleData = function () {
15
- let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
16
- return [{
17
- data: ++i * 100 + i
18
- }, {
19
- data: ++i * 100 + i
20
- }, {
21
- data: ++i * 100 + i
22
- }, {
23
- data: ++i * 100 + i
24
- }, {
25
- data: ++i * 100 + i
26
- }];
27
- };
28
- const meta = {
29
- component: _ModularTable.default,
30
- tags: ["autodocs"]
31
- };
32
- var _default = exports.default = meta;
33
- const Default = exports.Default = {
34
- render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
35
- getCellProps: _ref => {
36
- let {
37
- value
38
- } = _ref;
39
- return {
40
- className: value === "1 minute" ? "p-heading--5" : ""
41
- };
42
- }
43
- // eslint-disable-next-line react-hooks/rules-of-hooks
44
- ,
45
- columns: _react.default.useMemo(() => [{
46
- Header: "ID",
47
- accessor: "buildId",
48
- Cell: _ref2 => {
49
- let {
50
- value
51
- } = _ref2;
52
- return /*#__PURE__*/_react.default.createElement("a", {
53
- href: "#test"
54
- }, "#", value);
55
- }
56
- }, {
57
- Header: "Architecture",
58
- accessor: "arch"
59
- }, {
60
- Header: "Build Duration",
61
- accessor: "duration",
62
- className: "u-hide--small"
63
- }, {
64
- Header: "Result",
65
- accessor: "result",
66
- Cell: _ref3 => {
67
- let {
68
- value
69
- } = _ref3;
70
- switch (value) {
71
- case "released":
72
- return "Released";
73
- case "failed":
74
- return "Failed";
75
- default:
76
- return "Unknown";
77
- }
78
- },
79
- getCellIcon: _ref4 => {
80
- let {
81
- value
82
- } = _ref4;
83
- switch (value) {
84
- case "released":
85
- return _Icon.ICONS.success;
86
- case "failed":
87
- return _Icon.ICONS.error;
88
- default:
89
- return false;
90
- }
91
- }
92
- }, {
93
- Header: "Build Finished",
94
- accessor: "finished",
95
- className: "u-align-text--right"
96
- }], [])
97
- // eslint-disable-next-line react-hooks/rules-of-hooks
98
- ,
99
- data: _react.default.useMemo(() => [{
100
- buildId: "5432",
101
- arch: "arm64",
102
- duration: "5 minutes",
103
- result: "released",
104
- finished: "10 minutes ago"
105
- }, {
106
- buildId: "1234",
107
- arch: "armhf",
108
- duration: "5 minutes",
109
- result: "failed",
110
- finished: "over 1 year ago"
111
- }, {
112
- buildId: "1111",
113
- arch: "test64",
114
- duration: "1 minute",
115
- result: "other",
116
- finished: "ages ago"
117
- }], [])
118
- }),
119
- name: "Default"
120
- };
121
- const Empty = exports.Empty = {
122
- render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
123
- // eslint-disable-next-line react-hooks/rules-of-hooks
124
- columns: _react.default.useMemo(() => [{
125
- Header: "ID",
126
- accessor: "buildId"
127
- }, {
128
- Header: "Architecture",
129
- accessor: "arch"
130
- }, {
131
- Header: "Build Duration",
132
- accessor: "duration",
133
- className: "u-hide--small"
134
- }, {
135
- Header: "Result",
136
- accessor: "result"
137
- }, {
138
- Header: "Build Finished",
139
- accessor: "finished",
140
- className: "u-align-text--right"
141
- }], []),
142
- data: [],
143
- emptyMsg: "Waiting for data..."
144
- }),
145
- name: "Empty"
146
- };
147
- const Sortable = exports.Sortable = {
148
- render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
149
- sortable: true,
150
- initialSortColumn: "duration",
151
- initialSortDirection: "ascending",
152
- getCellProps: _ref5 => {
153
- let {
154
- value
155
- } = _ref5;
156
- return {
157
- className: value === "1 minute" ? "p-heading--5" : ""
158
- };
159
- }
160
- // eslint-disable-next-line react-hooks/rules-of-hooks
161
- ,
162
- columns: _react.default.useMemo(() => [{
163
- Header: "ID",
164
- accessor: "buildId",
165
- sortType: "basic",
166
- Cell: _ref6 => {
167
- let {
168
- value
169
- } = _ref6;
170
- return /*#__PURE__*/_react.default.createElement("a", {
171
- href: "#test"
172
- }, "#", value);
173
- }
174
- }, {
175
- Header: "Architecture",
176
- accessor: "arch",
177
- sortType: "basic"
178
- }, {
179
- Header: "Build Duration",
180
- accessor: "duration",
181
- className: "u-hide--small",
182
- sortType: "basic"
183
- }, {
184
- Header: "Result",
185
- accessor: "result",
186
- sortType: "basic",
187
- Cell: _ref7 => {
188
- let {
189
- value
190
- } = _ref7;
191
- switch (value) {
192
- case "released":
193
- return "Released";
194
- case "failed":
195
- return "Failed";
196
- default:
197
- return "Unknown";
198
- }
199
- },
200
- getCellIcon: _ref8 => {
201
- let {
202
- value
203
- } = _ref8;
204
- switch (value) {
205
- case "released":
206
- return _Icon.ICONS.success;
207
- case "failed":
208
- return _Icon.ICONS.error;
209
- default:
210
- return false;
211
- }
212
- }
213
- }, {
214
- Header: "Build Finished",
215
- accessor: "finished",
216
- className: "u-align-text--right",
217
- sortType: "basic"
218
- }], [])
219
- // eslint-disable-next-line react-hooks/rules-of-hooks
220
- ,
221
- data: _react.default.useMemo(() => [{
222
- buildId: "5432",
223
- arch: "arm64",
224
- duration: "5 minutes",
225
- result: "released",
226
- finished: "10 minutes ago"
227
- }, {
228
- buildId: "1234",
229
- arch: "armhf",
230
- duration: "5 minutes",
231
- result: "failed",
232
- finished: "over 1 year ago"
233
- }, {
234
- buildId: "1111",
235
- arch: "test64",
236
- duration: "1 minute",
237
- result: "other",
238
- finished: "ages ago"
239
- }], [])
240
- }),
241
- name: "Sortable"
242
- };
243
-
244
- /**
245
- * Subrows can be used to group table rows under a heading that needs to appear
246
- at the start of the group. In the following example sorting the columns will
247
- sort the group rows, then sort the sub-rows, but the group header always comes first.
248
- */
249
- const Subrows = exports.Subrows = {
250
- render: () => /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
251
- sortable: true
252
- // eslint-disable-next-line react-hooks/rules-of-hooks
253
- ,
254
- columns: _react.default.useMemo(() => [{
255
- Header: "Flavour",
256
- accessor: "flavour",
257
- sortType: "basic",
258
- Cell: props => props.row.depth === 0 ? /*#__PURE__*/_react.default.createElement("strong", null, props.value) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("input", {
259
- type: "checkbox"
260
- }), " ", props.value)
261
- }, {
262
- Header: "Scoops",
263
- accessor: "scoops",
264
- sortType: "basic",
265
- Cell: props => props.row.depth === 0 ? /*#__PURE__*/_react.default.createElement("span", {
266
- className: "u-text--muted"
267
- }, props.value) : props.value
268
- }], [])
269
- // eslint-disable-next-line react-hooks/rules-of-hooks
270
- ,
271
- data: _react.default.useMemo(() => [{
272
- flavour: "Sorbet",
273
- scoops: "1-2",
274
- subRows: [{
275
- flavour: "Lemon",
276
- scoops: 2
277
- }, {
278
- flavour: "Mango",
279
- scoops: 1
280
- }, {
281
- flavour: "Raspberry",
282
- scoops: 2
283
- }]
284
- }, {
285
- flavour: "Ice-cream",
286
- scoops: "1-3",
287
- subRows: [{
288
- flavour: "Chocolate",
289
- scoops: 1
290
- }, {
291
- flavour: "Vanilla",
292
- scoops: 3
293
- }, {
294
- flavour: "Caramel",
295
- scoops: 2
296
- }]
297
- }], [])
298
- }),
299
- name: "Subrows"
300
- };
301
-
302
- /**
303
- Example below shows a basic `ModularTable` with `SummaryButton` component in the footer.
304
- ```
305
- export const getSampleData = (i = 0) => [
306
- { data: ++i * 100 + i },
307
- { data: ++i * 100 + i },
308
- { data: ++i * 100 + i },
309
- { data: ++i * 100 + i },
310
- { data: ++i * 100 + i },
311
- ];
312
- ```
313
- */
314
- const LoadMore = exports.LoadMore = {
315
- render: () => {
316
- // eslint-disable-next-line react-hooks/rules-of-hooks
317
- const [data, setData] = (0, _react.useState)(getSampleData());
318
- const hasMore = data.length < 20;
319
- const loadMore = () => {
320
- setData(data.concat(getSampleData(data.length)));
321
- };
322
- const columns = [{
323
- Header: "Id",
324
- accessor: (_d, i) => i
325
- }, {
326
- Header: "Data",
327
- accessor: "data"
328
- }];
329
- const footer = hasMore ? /*#__PURE__*/_react.default.createElement("div", {
330
- className: "u-align--right"
331
- }, /*#__PURE__*/_react.default.createElement(_SummaryButton.default, {
332
- summary: "Showing ".concat(data.length, " of 20 items."),
333
- label: "Show 5 more",
334
- onClick: loadMore
335
- })) : null;
336
- return /*#__PURE__*/_react.default.createElement(_ModularTable.default, {
337
- data: data,
338
- columns: columns,
339
- footer: footer
340
- });
341
- },
342
- name: "Load more"
343
- };
@@ -1,2 +0,0 @@
1
- export { default } from "./ModularTable";
2
- export type { Props as ModularTableProps } from "./ModularTable";
@@ -1,10 +0,0 @@
1
- import { FC, PropsWithChildren } from "react";
2
- import "./FadeInDown.scss";
3
- export interface FadeInDownProps extends PropsWithChildren {
4
- isVisible: boolean;
5
- className?: string;
6
- }
7
- /**
8
- * EXPERIMENTAL: This component is experimental and should be used internally only.
9
- */
10
- export declare const FadeInDown: FC<FadeInDownProps>;
@@ -1 +0,0 @@
1
- export * from "./FadeInDown";
@@ -1,57 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import React from "react";
3
- import "./MultiSelect.scss";
4
- export type MultiSelectItem = {
5
- label: string;
6
- value: string | number;
7
- group?: string;
8
- };
9
- export type MultiSelectProps = {
10
- disabled?: boolean;
11
- error?: string;
12
- selectedItems?: MultiSelectItem[];
13
- help?: string;
14
- label?: string | null;
15
- listSelected?: boolean;
16
- onDeselectItem?: (item: MultiSelectItem) => void;
17
- onItemsUpdate?: (items: MultiSelectItem[]) => void;
18
- onSelectItem?: (item: MultiSelectItem) => void;
19
- placeholder?: string;
20
- required?: boolean;
21
- items: MultiSelectItem[];
22
- disabledItems?: MultiSelectItem[];
23
- renderItem?: (item: MultiSelectItem) => ReactNode;
24
- dropdownHeader?: ReactNode;
25
- dropdownFooter?: ReactNode;
26
- showDropdownFooter?: boolean;
27
- variant?: "condensed" | "search";
28
- };
29
- type GroupFn = (items: Parameters<typeof getGroupedItems>[0]) => ReturnType<typeof getGroupedItems>;
30
- type SortFn = typeof sortAlphabetically;
31
- type MultiSelectDropdownProps = {
32
- isOpen: boolean;
33
- items: MultiSelectItem[];
34
- selectedItems: MultiSelectItem[];
35
- disabledItems: MultiSelectItem[];
36
- header?: ReactNode;
37
- updateItems: (newItems: MultiSelectItem[]) => void;
38
- onDeselectItem?: (item: MultiSelectItem) => void;
39
- onSelectItem?: (item: MultiSelectItem) => void;
40
- footer?: ReactNode;
41
- groupFn?: GroupFn;
42
- sortFn?: SortFn;
43
- } & React.HTMLAttributes<HTMLDivElement>;
44
- declare const sortAlphabetically: (a: MultiSelectItem, b: MultiSelectItem) => number;
45
- declare const getGroupedItems: (items: MultiSelectItem[]) => {
46
- group: string;
47
- items: MultiSelectItem[];
48
- }[];
49
- export declare const MultiSelectDropdown: React.FC<MultiSelectDropdownProps>;
50
- /**
51
- * Component allowing to select multiple items from a list of options.
52
- *
53
- * `MultiSelectDropdown` displays the dropdown with options which are grouped and sorted alphabetically.
54
- * `SearchBox` or `Button` is used to trigger the dropdown depending on the variant.
55
- */
56
- export declare const MultiSelect: React.FC<MultiSelectProps>;
57
- export {};
@@ -1,8 +0,0 @@
1
- import { Meta, StoryObj } from "@storybook/react";
2
- import { MultiSelect } from "./MultiSelect";
3
- declare const meta: Meta<typeof MultiSelect>;
4
- export default meta;
5
- type Story = StoryObj<typeof MultiSelect>;
6
- export declare const CondensedExample: Story;
7
- export declare const SearchExample: Story;
8
- export declare const WithDisabledItems: Story;
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.WithDisabledItems = exports.SearchExample = exports.CondensedExample = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _MultiSelect = require("./MultiSelect");
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
- 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); }
12
- const Template = props => {
13
- const [selectedItems, setSelectedItems] = (0, _react.useState)(props.selectedItems || []);
14
- return /*#__PURE__*/_react.default.createElement(_MultiSelect.MultiSelect, _extends({}, props, {
15
- selectedItems: selectedItems,
16
- onItemsUpdate: setSelectedItems
17
- }));
18
- };
19
- const meta = {
20
- component: _MultiSelect.MultiSelect,
21
- render: Template,
22
- tags: ["autodocs"],
23
- parameters: {}
24
- };
25
- var _default = exports.default = meta;
26
- const CondensedExample = exports.CondensedExample = {
27
- args: {
28
- items: [...Array.from({
29
- length: 26
30
- }, (_, i) => ({
31
- label: "".concat(String.fromCharCode(i + 65)),
32
- value: "".concat(String.fromCharCode(i + 65))
33
- })), ...Array.from({
34
- length: 26
35
- }, (_, i) => ({
36
- label: "Item ".concat(i + 1),
37
- value: i + 1
38
- }))],
39
- selectedItems: [{
40
- label: "A",
41
- value: "A"
42
- }, {
43
- label: "Item 2",
44
- value: 2
45
- }],
46
- variant: "condensed"
47
- }
48
- };
49
- const SearchExample = exports.SearchExample = {
50
- args: {
51
- ...CondensedExample.args,
52
- variant: "search",
53
- items: [...CondensedExample.args.items.map((item, i) => ({
54
- ...item,
55
- group: i % 2 === 0 ? "Group 1" : "Group 2"
56
- }))]
57
- }
58
- };
59
- const WithDisabledItems = exports.WithDisabledItems = {
60
- args: {
61
- ...CondensedExample.args,
62
- disabledItems: [{
63
- label: "Item 1",
64
- value: 1
65
- }, {
66
- label: "Item 2",
67
- value: 2
68
- }]
69
- }
70
- };
@@ -1 +0,0 @@
1
- export * from "./MultiSelect";