@vectara/vectara-ui 0.0.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 (333) hide show
  1. package/.github/workflows/deploy-pages-site.yml +26 -0
  2. package/.github/workflows/deploy-pr-preview.yml +25 -0
  3. package/CHANGELOG.md +13 -0
  4. package/NO_LICENSE +3 -0
  5. package/lib/components/accordion/Accordion.d.ts +8 -0
  6. package/lib/components/accordion/Accordion.js +27 -0
  7. package/lib/components/accordion/_index.scss +23 -0
  8. package/lib/components/accountMenu/AccountMenu.d.ts +13 -0
  9. package/lib/components/accountMenu/AccountMenu.js +7 -0
  10. package/lib/components/accountMenu/_index.scss +20 -0
  11. package/lib/components/app/AppContent.d.ts +9 -0
  12. package/lib/components/app/AppContent.js +28 -0
  13. package/lib/components/app/AppHeader.d.ts +7 -0
  14. package/lib/components/app/AppHeader.js +18 -0
  15. package/lib/components/app/AppLayout.d.ts +9 -0
  16. package/lib/components/app/AppLayout.js +10 -0
  17. package/lib/components/app/_index.scss +4 -0
  18. package/lib/components/app/appContent.scss +26 -0
  19. package/lib/components/app/appHeader.scss +15 -0
  20. package/lib/components/app/appLayout.scss +23 -0
  21. package/lib/components/app/appSideNav/AppSideNav.d.ts +7 -0
  22. package/lib/components/app/appSideNav/AppSideNav.js +46 -0
  23. package/lib/components/app/appSideNav/AppSideNavLink.d.ts +4 -0
  24. package/lib/components/app/appSideNav/AppSideNavLink.js +26 -0
  25. package/lib/components/app/appSideNav/AppSideNavSections.d.ts +2 -0
  26. package/lib/components/app/appSideNav/AppSideNavSections.js +11 -0
  27. package/lib/components/app/appSideNav/AppSideNavTree.d.ts +2 -0
  28. package/lib/components/app/appSideNav/AppSideNavTree.js +38 -0
  29. package/lib/components/app/appSideNav/_index.scss +17 -0
  30. package/lib/components/app/appSideNav/appSideNav.scss +75 -0
  31. package/lib/components/app/appSideNav/appSideNavSections.scss +33 -0
  32. package/lib/components/app/appSideNav/appSideNavTree.scss +25 -0
  33. package/lib/components/app/types.d.ts +21 -0
  34. package/lib/components/app/types.js +1 -0
  35. package/lib/components/badge/Badge.d.ts +14 -0
  36. package/lib/components/badge/Badge.js +33 -0
  37. package/lib/components/badge/_index.scss +64 -0
  38. package/lib/components/button/BaseButton.d.ts +28 -0
  39. package/lib/components/button/BaseButton.js +65 -0
  40. package/lib/components/button/ButtonPrimary.d.ts +8 -0
  41. package/lib/components/button/ButtonPrimary.js +42 -0
  42. package/lib/components/button/ButtonSecondary.d.ts +10 -0
  43. package/lib/components/button/ButtonSecondary.js +43 -0
  44. package/lib/components/button/ButtonTertiary.d.ts +10 -0
  45. package/lib/components/button/ButtonTertiary.js +43 -0
  46. package/lib/components/button/IconButton.d.ts +16 -0
  47. package/lib/components/button/IconButton.js +29 -0
  48. package/lib/components/button/_index.scss +5 -0
  49. package/lib/components/button/baseButton.scss +94 -0
  50. package/lib/components/button/buttonPrimary.scss +51 -0
  51. package/lib/components/button/buttonSecondary.scss +54 -0
  52. package/lib/components/button/buttonTertiary.scss +56 -0
  53. package/lib/components/button/createButtonIcon.d.ts +3 -0
  54. package/lib/components/button/createButtonIcon.js +24 -0
  55. package/lib/components/button/iconButton.scss +44 -0
  56. package/lib/components/button/types.d.ts +3 -0
  57. package/lib/components/button/types.js +2 -0
  58. package/lib/components/callout/Callout.d.ts +13 -0
  59. package/lib/components/callout/Callout.js +40 -0
  60. package/lib/components/callout/_index.scss +49 -0
  61. package/lib/components/callout/types.d.ts +3 -0
  62. package/lib/components/callout/types.js +2 -0
  63. package/lib/components/card/Card.d.ts +14 -0
  64. package/lib/components/card/Card.js +29 -0
  65. package/lib/components/card/_index.scss +114 -0
  66. package/lib/components/chat/Chat.d.ts +17 -0
  67. package/lib/components/chat/Chat.js +130 -0
  68. package/lib/components/chat/ChatInspector.d.ts +7 -0
  69. package/lib/components/chat/ChatInspector.js +12 -0
  70. package/lib/components/chat/ChatPanel.d.ts +7 -0
  71. package/lib/components/chat/ChatPanel.js +11 -0
  72. package/lib/components/chat/ChatSearchResult.d.ts +16 -0
  73. package/lib/components/chat/ChatSearchResult.js +26 -0
  74. package/lib/components/chat/ChatTurn.d.ts +9 -0
  75. package/lib/components/chat/ChatTurn.js +19 -0
  76. package/lib/components/chat/_index.scss +150 -0
  77. package/lib/components/chat/chatTurn.scss +38 -0
  78. package/lib/components/chat/types.d.ts +17 -0
  79. package/lib/components/chat/types.js +19 -0
  80. package/lib/components/code/Code.d.ts +17 -0
  81. package/lib/components/code/Code.js +44 -0
  82. package/lib/components/code/_index.scss +33 -0
  83. package/lib/components/code/types.d.ts +1 -0
  84. package/lib/components/code/types.js +1 -0
  85. package/lib/components/context/Context.d.ts +18 -0
  86. package/lib/components/context/Context.js +34 -0
  87. package/lib/components/context/Context.test.util.d.ts +2 -0
  88. package/lib/components/context/Context.test.util.js +22 -0
  89. package/lib/components/copyButton/CopyButton.d.ts +10 -0
  90. package/lib/components/copyButton/CopyButton.js +50 -0
  91. package/lib/components/drawer/Drawer.d.ts +13 -0
  92. package/lib/components/drawer/Drawer.js +53 -0
  93. package/lib/components/drawer/_index.scss +73 -0
  94. package/lib/components/flex/FlexContainer.d.ts +36 -0
  95. package/lib/components/flex/FlexContainer.js +53 -0
  96. package/lib/components/flex/FlexItem.d.ts +22 -0
  97. package/lib/components/flex/FlexItem.js +36 -0
  98. package/lib/components/flex/_flexContainer.scss +79 -0
  99. package/lib/components/flex/_flexItem.scss +64 -0
  100. package/lib/components/flex/_index.scss +2 -0
  101. package/lib/components/flex/types.d.ts +2 -0
  102. package/lib/components/flex/types.js +1 -0
  103. package/lib/components/form/_index.scss +7 -0
  104. package/lib/components/form/checkbox/Checkbox.d.ts +8 -0
  105. package/lib/components/form/checkbox/Checkbox.js +24 -0
  106. package/lib/components/form/checkbox/_index.scss +3 -0
  107. package/lib/components/form/index.d.ts +10 -0
  108. package/lib/components/form/index.js +9 -0
  109. package/lib/components/form/input/BasicInput.d.ts +15 -0
  110. package/lib/components/form/input/BasicInput.js +30 -0
  111. package/lib/components/form/input/NumberInput.d.ts +8 -0
  112. package/lib/components/form/input/NumberInput.js +61 -0
  113. package/lib/components/form/input/PasswordInput.d.ts +7 -0
  114. package/lib/components/form/input/PasswordInput.js +21 -0
  115. package/lib/components/form/input/TextInput.d.ts +6 -0
  116. package/lib/components/form/input/TextInput.js +21 -0
  117. package/lib/components/form/input/_index.scss +24 -0
  118. package/lib/components/form/label/Label.d.ts +7 -0
  119. package/lib/components/form/label/Label.js +18 -0
  120. package/lib/components/form/label/_index.scss +5 -0
  121. package/lib/components/form/radioButton/RadioButton.d.ts +9 -0
  122. package/lib/components/form/radioButton/RadioButton.js +24 -0
  123. package/lib/components/form/radioButton/_index.scss +3 -0
  124. package/lib/components/form/select/Select.d.ts +17 -0
  125. package/lib/components/form/select/Select.js +34 -0
  126. package/lib/components/form/select/_index.scss +56 -0
  127. package/lib/components/form/superRadioGroup/SuperRadioButton.d.ts +7 -0
  128. package/lib/components/form/superRadioGroup/SuperRadioButton.js +22 -0
  129. package/lib/components/form/superRadioGroup/SuperRadioGroup.d.ts +8 -0
  130. package/lib/components/form/superRadioGroup/SuperRadioGroup.js +6 -0
  131. package/lib/components/form/superRadioGroup/_index.scss +31 -0
  132. package/lib/components/form/superRadioGroup/types.d.ts +8 -0
  133. package/lib/components/form/superRadioGroup/types.js +1 -0
  134. package/lib/components/form/textArea/TextArea.d.ts +12 -0
  135. package/lib/components/form/textArea/TextArea.js +21 -0
  136. package/lib/components/form/textArea/_index.scss +14 -0
  137. package/lib/components/formGroup/FormGroup.d.ts +10 -0
  138. package/lib/components/formGroup/FormGroup.js +27 -0
  139. package/lib/components/grid/Grid.d.ts +12 -0
  140. package/lib/components/grid/Grid.js +20 -0
  141. package/lib/components/grid/_index.scss +51 -0
  142. package/lib/components/horizontalRule/HorizontalRule.d.ts +6 -0
  143. package/lib/components/horizontalRule/HorizontalRule.js +4 -0
  144. package/lib/components/horizontalRule/_index.scss +40 -0
  145. package/lib/components/icon/Icon.d.ts +11 -0
  146. package/lib/components/icon/Icon.js +37 -0
  147. package/lib/components/icon/_index.scss +25 -0
  148. package/lib/components/icon/types.d.ts +2 -0
  149. package/lib/components/icon/types.js +12 -0
  150. package/lib/components/index.d.ts +75 -0
  151. package/lib/components/index.js +67 -0
  152. package/lib/components/infoTable/InfoTable.d.ts +24 -0
  153. package/lib/components/infoTable/InfoTable.js +24 -0
  154. package/lib/components/infoTable/_index.scss +53 -0
  155. package/lib/components/link/Link.d.ts +3 -0
  156. package/lib/components/link/Link.js +36 -0
  157. package/lib/components/link/Link.test.d.ts +1 -0
  158. package/lib/components/link/Link.test.js +40 -0
  159. package/lib/components/link/_index.scss +17 -0
  160. package/lib/components/link/types.d.ts +15 -0
  161. package/lib/components/link/types.js +1 -0
  162. package/lib/components/list/List.d.ts +12 -0
  163. package/lib/components/list/List.js +15 -0
  164. package/lib/components/list/_index.scss +29 -0
  165. package/lib/components/menu/Menu.d.ts +7 -0
  166. package/lib/components/menu/Menu.js +6 -0
  167. package/lib/components/menu/MenuItem.d.ts +10 -0
  168. package/lib/components/menu/MenuItem.js +31 -0
  169. package/lib/components/menu/_index.scss +75 -0
  170. package/lib/components/modal/Modal.d.ts +13 -0
  171. package/lib/components/modal/Modal.js +53 -0
  172. package/lib/components/modal/_index.scss +85 -0
  173. package/lib/components/notification/Notification.d.ts +12 -0
  174. package/lib/components/notification/Notification.js +23 -0
  175. package/lib/components/notification/Notifications.d.ts +10 -0
  176. package/lib/components/notification/Notifications.js +35 -0
  177. package/lib/components/notification/_index.scss +99 -0
  178. package/lib/components/optionsButton/OptionsButton.d.ts +7 -0
  179. package/lib/components/optionsButton/OptionsButton.js +25 -0
  180. package/lib/components/optionsButton/_index.scss +42 -0
  181. package/lib/components/optionsList/OptionsList.d.ts +13 -0
  182. package/lib/components/optionsList/OptionsList.js +31 -0
  183. package/lib/components/optionsList/OptionsListItem.d.ts +10 -0
  184. package/lib/components/optionsList/OptionsListItem.js +41 -0
  185. package/lib/components/optionsList/_index.scss +84 -0
  186. package/lib/components/optionsList/types.d.ts +13 -0
  187. package/lib/components/optionsList/types.js +1 -0
  188. package/lib/components/popover/Popover.d.ts +11 -0
  189. package/lib/components/popover/Popover.js +91 -0
  190. package/lib/components/popover/_index.scss +29 -0
  191. package/lib/components/portal/Portal.d.ts +6 -0
  192. package/lib/components/portal/Portal.js +16 -0
  193. package/lib/components/progressBar/ProgressBar.d.ts +9 -0
  194. package/lib/components/progressBar/ProgressBar.js +26 -0
  195. package/lib/components/progressBar/_index.scss +63 -0
  196. package/lib/components/prompt/Prompt.d.ts +20 -0
  197. package/lib/components/prompt/Prompt.js +19 -0
  198. package/lib/components/prompt/_index.scss +70 -0
  199. package/lib/components/screenBlock/ScreenBlock.d.ts +6 -0
  200. package/lib/components/screenBlock/ScreenBlock.js +4 -0
  201. package/lib/components/screenBlock/_index.scss +17 -0
  202. package/lib/components/searchInput/SearchInput.d.ts +13 -0
  203. package/lib/components/searchInput/SearchInput.js +19 -0
  204. package/lib/components/searchInput/_index.scss +49 -0
  205. package/lib/components/searchResult/SearchResult.d.ts +21 -0
  206. package/lib/components/searchResult/SearchResult.js +33 -0
  207. package/lib/components/searchResult/SearchResult.test.d.ts +1 -0
  208. package/lib/components/searchResult/SearchResult.test.js +280 -0
  209. package/lib/components/searchResult/_index.scss +29 -0
  210. package/lib/components/searchSelect/SearchSelect.d.ts +11 -0
  211. package/lib/components/searchSelect/SearchSelect.js +78 -0
  212. package/lib/components/searchSelect/_index.scss +13 -0
  213. package/lib/components/setting/Setting.d.ts +12 -0
  214. package/lib/components/setting/Setting.js +24 -0
  215. package/lib/components/spacer/Spacer.d.ts +6 -0
  216. package/lib/components/spacer/Spacer.js +6 -0
  217. package/lib/components/spacer/_index.scss +20 -0
  218. package/lib/components/spacer/types.d.ts +1 -0
  219. package/lib/components/spacer/types.js +1 -0
  220. package/lib/components/spinner/Spinner.d.ts +7 -0
  221. package/lib/components/spinner/Spinner.js +15 -0
  222. package/lib/components/spinner/_index.scss +52 -0
  223. package/lib/components/spinner/types.d.ts +3 -0
  224. package/lib/components/spinner/types.js +2 -0
  225. package/lib/components/statList/StatList.d.ts +9 -0
  226. package/lib/components/statList/StatList.js +15 -0
  227. package/lib/components/statList/_index.scss +3 -0
  228. package/lib/components/status/Status.d.ts +6 -0
  229. package/lib/components/status/Status.js +24 -0
  230. package/lib/components/summary/Summary.d.ts +7 -0
  231. package/lib/components/summary/Summary.js +43 -0
  232. package/lib/components/summary/Summary.test.d.ts +1 -0
  233. package/lib/components/summary/Summary.test.js +544 -0
  234. package/lib/components/summary/SummaryCitation.d.ts +8 -0
  235. package/lib/components/summary/SummaryCitation.js +20 -0
  236. package/lib/components/summary/_index.scss +29 -0
  237. package/lib/components/table/Table.d.ts +44 -0
  238. package/lib/components/table/Table.js +117 -0
  239. package/lib/components/table/TableBulkActions.d.ts +7 -0
  240. package/lib/components/table/TableBulkActions.js +34 -0
  241. package/lib/components/table/TableCell.d.ts +5 -0
  242. package/lib/components/table/TableCell.js +4 -0
  243. package/lib/components/table/TableContent.d.ts +6 -0
  244. package/lib/components/table/TableContent.js +6 -0
  245. package/lib/components/table/TableHeaderCell.d.ts +9 -0
  246. package/lib/components/table/TableHeaderCell.js +8 -0
  247. package/lib/components/table/TablePager.d.ts +9 -0
  248. package/lib/components/table/TablePager.js +9 -0
  249. package/lib/components/table/TablePagination.d.ts +10 -0
  250. package/lib/components/table/TablePagination.js +18 -0
  251. package/lib/components/table/TableRowActions.d.ts +15 -0
  252. package/lib/components/table/TableRowActions.js +29 -0
  253. package/lib/components/table/_index.scss +70 -0
  254. package/lib/components/table/createPagination.d.ts +4 -0
  255. package/lib/components/table/createPagination.js +44 -0
  256. package/lib/components/table/createPagination.test.d.ts +1 -0
  257. package/lib/components/table/createPagination.test.js +32 -0
  258. package/lib/components/table/types.d.ts +1 -0
  259. package/lib/components/table/types.js +1 -0
  260. package/lib/components/tabs/Tab.d.ts +9 -0
  261. package/lib/components/tabs/Tab.js +27 -0
  262. package/lib/components/tabs/TabbedRoutes.d.ts +15 -0
  263. package/lib/components/tabs/TabbedRoutes.js +15 -0
  264. package/lib/components/tabs/Tabs.d.ts +10 -0
  265. package/lib/components/tabs/Tabs.js +8 -0
  266. package/lib/components/tabs/_index.scss +103 -0
  267. package/lib/components/tabs/types.d.ts +2 -0
  268. package/lib/components/tabs/types.js +1 -0
  269. package/lib/components/toggle/Toggle.d.ts +8 -0
  270. package/lib/components/toggle/Toggle.js +25 -0
  271. package/lib/components/toggle/_index.scss +55 -0
  272. package/lib/components/topicButton/TopicButton.d.ts +10 -0
  273. package/lib/components/topicButton/TopicButton.js +30 -0
  274. package/lib/components/topicButton/_index.scss +21 -0
  275. package/lib/components/typography/Text.d.ts +13 -0
  276. package/lib/components/typography/Text.js +24 -0
  277. package/lib/components/typography/TextColor.d.ts +9 -0
  278. package/lib/components/typography/TextColor.js +6 -0
  279. package/lib/components/typography/Title.d.ts +11 -0
  280. package/lib/components/typography/Title.js +20 -0
  281. package/lib/components/typography/_index.scss +3 -0
  282. package/lib/components/typography/_text.scss +150 -0
  283. package/lib/components/typography/_textColor.scss +15 -0
  284. package/lib/components/typography/_title.scss +68 -0
  285. package/lib/components/typography/types.d.ts +4 -0
  286. package/lib/components/typography/types.js +3 -0
  287. package/lib/index.d.ts +1 -0
  288. package/lib/index.js +1 -0
  289. package/lib/sassUtils/_animation.scss +1 -0
  290. package/lib/sassUtils/_app.scss +1 -0
  291. package/lib/sassUtils/_borders.scss +2 -0
  292. package/lib/sassUtils/_colors.scss +24 -0
  293. package/lib/sassUtils/_depth.scss +8 -0
  294. package/lib/sassUtils/_mixins.scss +11 -0
  295. package/lib/sassUtils/_shadows.scss +5 -0
  296. package/lib/sassUtils/_sizes.scss +10 -0
  297. package/lib/sassUtils/_typography.scss +20 -0
  298. package/lib/sassUtils/index.scss +10 -0
  299. package/lib/styles/index.css +3229 -0
  300. package/lib/utils/citations/applyCitationOrder.d.ts +1 -0
  301. package/lib/utils/citations/applyCitationOrder.js +19 -0
  302. package/lib/utils/citations/applyCitationOrder.test.d.ts +1 -0
  303. package/lib/utils/citations/applyCitationOrder.test.js +65 -0
  304. package/lib/utils/citations/extractCitations.d.ts +4 -0
  305. package/lib/utils/citations/extractCitations.js +26 -0
  306. package/lib/utils/citations/extractCitations.test.d.ts +1 -0
  307. package/lib/utils/citations/extractCitations.test.js +40 -0
  308. package/lib/utils/citations/index.d.ts +5 -0
  309. package/lib/utils/citations/index.js +5 -0
  310. package/lib/utils/citations/removeCitations.d.ts +1 -0
  311. package/lib/utils/citations/removeCitations.js +2 -0
  312. package/lib/utils/citations/removeCitations.test.d.ts +1 -0
  313. package/lib/utils/citations/removeCitations.test.js +11 -0
  314. package/lib/utils/citations/reorderCitations.d.ts +1 -0
  315. package/lib/utils/citations/reorderCitations.js +9 -0
  316. package/lib/utils/citations/reorderCitations.test.d.ts +1 -0
  317. package/lib/utils/citations/reorderCitations.test.js +6 -0
  318. package/lib/utils/citations/sanitizeCitations.d.ts +1 -0
  319. package/lib/utils/citations/sanitizeCitations.js +30 -0
  320. package/lib/utils/citations/sanitizeCitations.test.d.ts +1 -0
  321. package/lib/utils/citations/sanitizeCitations.test.js +11 -0
  322. package/lib/utils/createId.d.ts +1 -0
  323. package/lib/utils/createId.js +10 -0
  324. package/lib/utils/getTrackingProps.d.ts +7 -0
  325. package/lib/utils/getTrackingProps.js +18 -0
  326. package/lib/utils/index.d.ts +1 -0
  327. package/lib/utils/index.js +1 -0
  328. package/lib/utils/truncateString.d.ts +2 -0
  329. package/lib/utils/truncateString.js +20 -0
  330. package/lib/utils/truncateString.test.d.ts +1 -0
  331. package/lib/utils/truncateString.test.js +59 -0
  332. package/licenses.txt +9035 -0
  333. package/package.json +100 -0
@@ -0,0 +1,117 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { useState } from "react";
14
+ import classNames from "classnames";
15
+ import { VuiCheckbox, VuiTextInput } from "../form";
16
+ import { VuiSpacer } from "../spacer/Spacer";
17
+ import { VuiTableRowActions } from "./TableRowActions";
18
+ import { VuiTableCell } from "./TableCell";
19
+ import { VuiTableHeaderCell } from "./TableHeaderCell";
20
+ import { VuiTablePagination } from "./TablePagination";
21
+ import { VuiTablePager } from "./TablePager";
22
+ import { VuiFlexContainer } from "../flex/FlexContainer";
23
+ import { VuiFlexItem } from "../flex/FlexItem";
24
+ import { VuiText } from "../typography/Text";
25
+ import { VuiTableBulkActions } from "./TableBulkActions";
26
+ import { VuiSpinner } from "../spinner/Spinner";
27
+ import { VuiTableContent } from "./TableContent";
28
+ import { VuiButtonSecondary } from "../button/ButtonSecondary";
29
+ // Type guard to determine type of pagination.
30
+ const isComplexPagination = (pagination) => {
31
+ return pagination.onSelectPage !== undefined;
32
+ };
33
+ const extractId = (row, idField) => {
34
+ return typeof idField === "function" ? idField(row) : row[idField];
35
+ };
36
+ // https://github.com/typescript-eslint/typescript-eslint/issues/4062
37
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
38
+ export const VuiTable = (_a) => {
39
+ var { isLoading, idField, columns, rows, actions, actionsTestIdProvider, pagination, selection, search, customControls, onSort, onReload, content, className, fluid } = _a, rest = __rest(_a, ["isLoading", "idField", "columns", "rows", "actions", "actionsTestIdProvider", "pagination", "selection", "search", "customControls", "onSort", "onReload", "content", "className", "fluid"]);
40
+ const [rowBeingActedUpon, setRowBeingActedUpon] = useState(undefined);
41
+ const { bulkActions, onSelectRow, selectedRows } = selection || {};
42
+ const { searchValue, searchPlaceholder, onSearchChange } = search || {};
43
+ const isEmpty = !isLoading && rows.length === 0;
44
+ // The user interacts with the table rows by selecting them or performing actions on them.
45
+ // This is only allowed if there is no “content” (which is an error or similar state that
46
+ // replaces the rows), and if it’s not in a loading state or empty state.
47
+ const isInteractive = Boolean(!content && !isLoading && !isEmpty);
48
+ const allRowsSelected = (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) === rows.length;
49
+ const selectedIds = (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.reduce((acc, row) => {
50
+ acc[extractId(row, idField)] = true;
51
+ return acc;
52
+ }, {})) || {};
53
+ const hasSearch = searchValue !== undefined && onSearchChange;
54
+ const hasBulkActions = bulkActions !== undefined;
55
+ const columnCount = columns.length + (onSelectRow ? 1 : 0) + (actions ? 1 : 0);
56
+ const classes = classNames("vuiTable", {
57
+ "vuiTable--fluid": fluid
58
+ }, className);
59
+ let tableContent;
60
+ if (content) {
61
+ tableContent = _jsx(VuiTableContent, Object.assign({ colSpan: columnCount }, { children: content }));
62
+ }
63
+ else if (isLoading) {
64
+ tableContent = (_jsxs(VuiTableContent, Object.assign({ colSpan: columnCount }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(VuiSpinner, { size: "xs" }) })), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(VuiText, { children: _jsx("p", { children: "Loading" }) }) }))] })));
65
+ }
66
+ else if (searchValue && isEmpty) {
67
+ tableContent = (_jsx(VuiTableContent, Object.assign({ colSpan: columnCount }, { children: _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx(VuiText, { children: _jsx("p", { children: "No matches found" }) }) })) })));
68
+ }
69
+ else {
70
+ tableContent = rows.map((row) => {
71
+ var _a, _b;
72
+ const rowId = extractId(row, idField);
73
+ return (_jsxs("tr", Object.assign({ className: rowBeingActedUpon === row ? "vuiTableRow-isBeingActedUpon" : undefined }, { children: [onSelectRow && (_jsx("td", { children: _jsx(VuiTableCell, { children: _jsx(VuiCheckbox, { checked: (_a = selectedIds[rowId]) !== null && _a !== void 0 ? _a : false, onChange: () => {
74
+ if (selectedIds[rowId]) {
75
+ delete selectedIds[rowId];
76
+ }
77
+ else {
78
+ selectedIds[rowId] = true;
79
+ }
80
+ const selectedRowIds = Object.keys(selectedIds);
81
+ // Map selected row IDs to selected rows.
82
+ const selectedRows = selectedRowIds.map((id) => rows.find((row) => row.id === id));
83
+ onSelectRow(selectedRows);
84
+ } }) }) })), columns.map((column) => {
85
+ const { name, render, className } = column;
86
+ return (_jsx("td", Object.assign({ className: className }, { children: _jsx(VuiTableCell, { children: render ? render(row) : row[column.name] }) }), name));
87
+ }), actions && (_jsx("td", { children: _jsx(VuiTableRowActions, { row: row, actions: actions, onToggle: (isSelected) => {
88
+ if (isSelected) {
89
+ setRowBeingActedUpon(row);
90
+ }
91
+ else {
92
+ setRowBeingActedUpon(undefined);
93
+ }
94
+ }, testId: (_b = actionsTestIdProvider === null || actionsTestIdProvider === void 0 ? void 0 : actionsTestIdProvider(row)) !== null && _b !== void 0 ? _b : undefined }) }))] }), rowId));
95
+ });
96
+ }
97
+ return (_jsxs(_Fragment, { children: [(hasSearch ||
98
+ customControls ||
99
+ (hasBulkActions && selectedRows && selectedRows.length > 0) ||
100
+ Boolean(onReload)) && (_jsxs(_Fragment, { children: [_jsxs(VuiFlexContainer, Object.assign({ spacing: "s", justifyContent: "spaceBetween", alignItems: "center" }, { children: [selectedRows && selectedRows.length > 0 && hasBulkActions && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiTableBulkActions, { selectedRows: selectedRows, actions: bulkActions }) }))), hasSearch && (_jsx(VuiFlexItem, Object.assign({ grow: 1, shrink: false }, { children: _jsx(VuiTextInput, { placeholder: searchPlaceholder, fullWidth: true, value: searchValue, onChange: (event) => onSearchChange(event.target.value), "data-testid": search === null || search === void 0 ? void 0 : search["data-testid"] }) }))), customControls && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: customControls }))), onReload && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiButtonSecondary, Object.assign({ color: "neutral", onClick: () => onReload() }, { children: "Reload" })) })))] })), _jsx(VuiSpacer, { size: "s" })] })), _jsxs("table", Object.assign({ className: classes }, rest, { children: [_jsx("thead", { children: _jsxs("tr", { children: [onSelectRow && (_jsx("th", Object.assign({ className: "vuiTableHeaderSelect" }, { children: _jsx(VuiTableCell, { children: _jsx(VuiCheckbox, { disabled: !isInteractive, checked: isInteractive ? allRowsSelected : false, onChange: () => {
101
+ let newSelectedRows;
102
+ if (allRowsSelected) {
103
+ newSelectedRows = [];
104
+ }
105
+ else {
106
+ newSelectedRows = rows.reduce((acc, row) => {
107
+ acc.push(row);
108
+ return acc;
109
+ }, []);
110
+ }
111
+ onSelectRow(newSelectedRows);
112
+ } }) }) }))), columns.map((column) => {
113
+ const { name, header, width } = column;
114
+ const styles = width ? { width } : undefined;
115
+ return (_jsx("th", Object.assign({ style: styles }, { children: _jsx(VuiTableHeaderCell, { name: name, header: header, onSort: onSort }) }), name));
116
+ }), actions && _jsx("th", { className: "vuiTableHeaderActions" })] }) }), _jsx("tbody", { children: tableContent })] })), !pagination ? undefined : isComplexPagination(pagination) ? (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "xs" }), _jsx(VuiTablePagination, Object.assign({ isDisabled: !isInteractive }, pagination))] })) : (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "xs" }), _jsx(VuiTablePager, Object.assign({ isDisabled: !isInteractive }, pagination))] }))] }));
117
+ };
@@ -0,0 +1,7 @@
1
+ import { Action } from "./TableRowActions";
2
+ import { Row } from "./types";
3
+ export type Props<T> = {
4
+ selectedRows: any;
5
+ actions: Action<T>[];
6
+ };
7
+ export declare const VuiTableBulkActions: <T extends Row>({ selectedRows, actions }: Props<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useState } from "react";
14
+ import { BiCaretDown } from "react-icons/bi";
15
+ import { VuiOptionsList } from "../optionsList/OptionsList";
16
+ import { VuiPopover } from "../popover/Popover";
17
+ import { VuiIcon } from "../icon/Icon";
18
+ import { VuiButtonSecondary } from "../button/ButtonSecondary";
19
+ export const VuiTableBulkActions = ({ selectedRows, actions }) => {
20
+ const [isOpen, setIsOpen] = useState(false);
21
+ let content;
22
+ if (actions.length === 1) {
23
+ content = (_jsx(VuiButtonSecondary, Object.assign({ color: "neutral", size: "m", onClick: () => actions[0].onClick && actions[0].onClick(selectedRows) }, { children: actions[0].label })));
24
+ }
25
+ else {
26
+ content = (_jsx(VuiPopover, Object.assign({ isOpen: isOpen, setIsOpen: () => setIsOpen(!isOpen), button: _jsxs(VuiButtonSecondary, Object.assign({ color: "neutral", size: "m", icon: _jsx(VuiIcon, { children: _jsx(BiCaretDown, {}) }) }, { children: [selectedRows.length, " selected"] })) }, { children: _jsx(VuiOptionsList, { onSelectOption: () => {
27
+ setIsOpen(false);
28
+ }, options: actions.map((_a) => {
29
+ var { href } = _a, action = __rest(_a, ["href"]);
30
+ return (Object.assign(Object.assign({}, action), { href: href === null || href === void 0 ? void 0 : href(selectedRows), value: selectedRows }));
31
+ }), size: "m" }) })));
32
+ }
33
+ return content;
34
+ };
@@ -0,0 +1,5 @@
1
+ type Props = {
2
+ children: React.ReactNode;
3
+ };
4
+ export declare const VuiTableCell: ({ children }: Props) => import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const VuiTableCell = ({ children }) => {
3
+ return _jsx("div", Object.assign({ className: "vuiTableCell" }, { children: children }));
4
+ };
@@ -0,0 +1,6 @@
1
+ type Props = {
2
+ colSpan: number;
3
+ children: React.ReactNode;
4
+ };
5
+ export declare const VuiTableContent: ({ colSpan, children }: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { VuiFlexContainer } from "../flex/FlexContainer";
3
+ import { VuiSpacer } from "../spacer/Spacer";
4
+ export const VuiTableContent = ({ colSpan, children }) => {
5
+ return (_jsx("tr", Object.assign({ className: "vuiTableRow--inert" }, { children: _jsxs("td", Object.assign({ className: "vuiTableContent", colSpan: colSpan }, { children: [_jsx(VuiSpacer, { size: "m" }), _jsx(VuiFlexContainer, Object.assign({ justifyContent: "center", alignItems: "center", spacing: "xs" }, { children: children })), _jsx(VuiSpacer, { size: "m" })] })) })));
6
+ };
@@ -0,0 +1,9 @@
1
+ export type Props = {
2
+ name: string;
3
+ header: {
4
+ isSortable?: boolean;
5
+ render?: () => React.ReactNode;
6
+ };
7
+ onSort?: (column: string, direction: "asc" | "desc") => void;
8
+ };
9
+ export declare const VuiTableHeaderCell: ({ name, header, onSort }: Props) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { BiChevronDown } from "react-icons/bi";
3
+ import { VuiFlexContainer } from "../flex/FlexContainer";
4
+ import { VuiFlexItem } from "../flex/FlexItem";
5
+ import { VuiIcon } from "../icon/Icon";
6
+ export const VuiTableHeaderCell = ({ name, header, onSort }) => {
7
+ return (_jsxs(VuiFlexContainer, Object.assign({ spacing: "xxs", alignItems: "center", justifyContent: "start" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: header.render ? header.render() : name })), onSort && header.isSortable && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "s" }, { children: _jsx(BiChevronDown, {}) })) })))] })));
8
+ };
@@ -0,0 +1,9 @@
1
+ export type Pager = {
2
+ onSelectPreviousPage?: () => void;
3
+ onSelectNextPage?: () => void;
4
+ };
5
+ type Props = Pager & {
6
+ isDisabled?: boolean;
7
+ };
8
+ export declare const VuiTablePager: ({ onSelectPreviousPage, onSelectNextPage, isDisabled }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { BiLeftArrowAlt, BiRightArrowAlt } from "react-icons/bi";
3
+ import { VuiFlexContainer } from "../flex/FlexContainer";
4
+ import { VuiFlexItem } from "../flex/FlexItem";
5
+ import { VuiButtonTertiary } from "../button/ButtonTertiary";
6
+ import { VuiIcon } from "../icon/Icon";
7
+ export const VuiTablePager = ({ onSelectPreviousPage, onSelectNextPage, isDisabled }) => {
8
+ return (_jsxs(VuiFlexContainer, Object.assign({ justifyContent: "start", alignItems: "center", spacing: "none" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiButtonTertiary, Object.assign({ icon: _jsx(VuiIcon, { children: _jsx(BiLeftArrowAlt, {}) }), color: "neutral", size: "s", onClick: () => onSelectPreviousPage === null || onSelectPreviousPage === void 0 ? void 0 : onSelectPreviousPage(), isDisabled: isDisabled || !onSelectPreviousPage }, { children: "Previous" })) })), _jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiButtonTertiary, Object.assign({ icon: _jsx(VuiIcon, { children: _jsx(BiRightArrowAlt, {}) }), iconSide: "right", color: "neutral", size: "s", onClick: () => onSelectNextPage === null || onSelectNextPage === void 0 ? void 0 : onSelectNextPage(), isDisabled: isDisabled || !onSelectNextPage }, { children: "Next" })) }))] })));
9
+ };
@@ -0,0 +1,10 @@
1
+ export type Pagination = {
2
+ currentPage: number;
3
+ numPages: number;
4
+ onSelectPage: (page: number) => void;
5
+ };
6
+ type Props = Pagination & {
7
+ isDisabled?: boolean;
8
+ };
9
+ export declare const VuiTablePagination: ({ currentPage, numPages, onSelectPage, isDisabled }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { BiLeftArrowAlt, BiRightArrowAlt } from "react-icons/bi";
3
+ import { VuiFlexContainer } from "../flex/FlexContainer";
4
+ import { VuiFlexItem } from "../flex/FlexItem";
5
+ import { VuiButtonTertiary } from "../button/ButtonTertiary";
6
+ import { VuiIcon } from "../icon/Icon";
7
+ import { createPagination } from "./createPagination";
8
+ import classNames from "classnames";
9
+ export const VuiTablePagination = ({ currentPage, numPages, onSelectPage, isDisabled }) => {
10
+ const { items, activeIndex } = createPagination(currentPage, numPages);
11
+ const manyPagesTokenClasses = classNames("vuiTableManyPagesToken", {
12
+ "vuiTableManyPagesToken-isDisabled": isDisabled
13
+ });
14
+ return (_jsxs(VuiFlexContainer, Object.assign({ justifyContent: "start", alignItems: "center", spacing: "none" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiButtonTertiary, Object.assign({ icon: _jsx(VuiIcon, { children: _jsx(BiLeftArrowAlt, {}) }), color: "neutral", size: "s", onClick: () => onSelectPage(currentPage - 1), isDisabled: isDisabled || currentPage === 1 }, { children: "Previous" })) })), items.map((item, index) => {
15
+ const isActive = index === activeIndex;
16
+ return (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: item === "..." ? (_jsx("div", Object.assign({ className: manyPagesTokenClasses }, { children: item }))) : (_jsx(VuiButtonTertiary, Object.assign({ color: isActive ? "primary" : "neutral", isInert: isActive, isSelected: isActive, size: "s", onClick: () => onSelectPage(item), isDisabled: isDisabled }, { children: item }))) }), index));
17
+ }), _jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiButtonTertiary, Object.assign({ icon: _jsx(VuiIcon, { children: _jsx(BiRightArrowAlt, {}) }), iconSide: "right", color: "neutral", size: "s", onClick: () => onSelectPage(currentPage + 1), isDisabled: isDisabled || currentPage === numPages }, { children: "Next" })) }))] })));
18
+ };
@@ -0,0 +1,15 @@
1
+ import { Row } from "./types";
2
+ export type Action<T> = {
3
+ label: string;
4
+ isDisabled?: (row: T) => boolean;
5
+ onClick?: (row: T) => void;
6
+ href?: (row: T) => string | undefined;
7
+ testId?: string;
8
+ };
9
+ export type Props<T> = {
10
+ row: any;
11
+ actions: Action<T>[];
12
+ onToggle: (isSelected: boolean) => void;
13
+ testId?: string;
14
+ };
15
+ export declare const VuiTableRowActions: <T extends Row>({ row, actions, onToggle, testId }: Props<T>) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { BiCaretDown } from "react-icons/bi";
4
+ import { VuiOptionsList } from "../optionsList/OptionsList";
5
+ import { VuiPopover } from "../popover/Popover";
6
+ import { VuiIcon } from "../icon/Icon";
7
+ import { VuiButtonSecondary } from "../button/ButtonSecondary";
8
+ export const VuiTableRowActions = ({ row, actions, onToggle, testId }) => {
9
+ const [isOpen, setIsOpen] = useState(false);
10
+ // Filter out disabled actions.
11
+ const actionOptions = actions.reduce((acc, action) => {
12
+ const { label, isDisabled, onClick, href, testId } = action;
13
+ if (!(isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled(row))) {
14
+ acc.push({ label, onClick, href: href === null || href === void 0 ? void 0 : href(row), value: row, testId });
15
+ }
16
+ return acc;
17
+ }, []);
18
+ if (!actionOptions.length) {
19
+ return null;
20
+ }
21
+ const content = (_jsx(VuiPopover, Object.assign({ isOpen: isOpen, setIsOpen: () => {
22
+ setIsOpen(!isOpen);
23
+ onToggle(!isOpen);
24
+ }, button: _jsx(VuiButtonSecondary, { color: "neutral", size: "xs", icon: _jsx(VuiIcon, { children: _jsx(BiCaretDown, {}) }), "data-testid": testId }) }, { children: _jsx(VuiOptionsList, { onSelectOption: () => {
25
+ setIsOpen(false);
26
+ onToggle(false);
27
+ }, options: actionOptions, size: "m" }) })));
28
+ return _jsx("div", Object.assign({ className: "vuiTableActions" }, { children: content }));
29
+ };
@@ -0,0 +1,70 @@
1
+ .vuiTable {
2
+ width: 100%;
3
+ table-layout: fixed;
4
+
5
+ thead {
6
+ border-bottom: 1px solid $borderColor;
7
+ }
8
+
9
+ tbody tr {
10
+ border-bottom: 1px solid $borderColorLight;
11
+
12
+ &.vuiTableRow-isBeingActedUpon,
13
+ &:not(.vuiTableRow--inert):hover {
14
+ background-color: $colorLightShade;
15
+ }
16
+
17
+ &:last-child {
18
+ border-bottom: 1px solid $borderColor;
19
+ }
20
+ }
21
+
22
+ th {
23
+ font-size: $fontSizeStandard;
24
+ font-weight: $fontWeightBold;
25
+ padding: $sizeXxs;
26
+ }
27
+
28
+ td {
29
+ font-size: $fontSizeStandard;
30
+ padding: $sizeXxs;
31
+ vertical-align: middle;
32
+ word-break: break-word;
33
+ }
34
+ }
35
+
36
+ .vuiTable--fluid {
37
+ table-layout: auto;
38
+ }
39
+
40
+ .vuiTableCell {
41
+ height: 100%;
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: flex-start;
45
+ }
46
+
47
+ .vuiTableActions {
48
+ display: flex;
49
+ justify-content: flex-end;
50
+ }
51
+
52
+ .vuiTableManyPagesToken {
53
+ padding: 0 $sizeXs;
54
+ }
55
+
56
+ .vuiTableManyPagesToken-isDisabled {
57
+ opacity: 0.5;
58
+ }
59
+
60
+ .vuiTableHeaderSelect {
61
+ width: 32px;
62
+ }
63
+
64
+ .vuiTableHeaderActions {
65
+ width: 42px;
66
+ }
67
+
68
+ .vuiTableContent {
69
+ height: 80px;
70
+ }
@@ -0,0 +1,4 @@
1
+ export declare const createPagination: (currentPage: number, numPages: number) => {
2
+ items: (number | "...")[];
3
+ activeIndex: number | undefined;
4
+ };
@@ -0,0 +1,44 @@
1
+ const MAX_PAGES = 5;
2
+ const TRUNCATION_LIMIT = 3;
3
+ export const createPagination = (currentPage, numPages) => {
4
+ if (numPages <= MAX_PAGES) {
5
+ // Renders as: [1] 2 3 4 5
6
+ return {
7
+ items: Array.from({ length: numPages }, (_, i) => i + 1),
8
+ activeIndex: currentPage - 1
9
+ };
10
+ }
11
+ let activeIndex;
12
+ // Pagination always begins with the first page.
13
+ const items = [1];
14
+ if (currentPage > TRUNCATION_LIMIT && currentPage <= numPages - TRUNCATION_LIMIT) {
15
+ // Renders as: 1 ... [15] ... 60
16
+ activeIndex = 2;
17
+ items.push("...");
18
+ items.push(currentPage);
19
+ items.push("...");
20
+ }
21
+ else if (currentPage > TRUNCATION_LIMIT) {
22
+ // Renders as: 1 ... [4] 5 6
23
+ // Renders as: 1 ... 4 [5] 6
24
+ const lastIndex = MAX_PAGES - 1;
25
+ activeIndex = lastIndex - (numPages - currentPage);
26
+ items.push("...");
27
+ items.push(numPages - 2);
28
+ items.push(numPages - 1);
29
+ }
30
+ else if (currentPage <= numPages - TRUNCATION_LIMIT) {
31
+ // Renders as: 1 [2] 3 ... 6
32
+ // Renders as: 1 2 [3] ... 6
33
+ activeIndex = currentPage - 1;
34
+ items.push(2);
35
+ items.push(3);
36
+ items.push("...");
37
+ }
38
+ // Pagination always ends with the last page.
39
+ items.push(numPages);
40
+ return {
41
+ items,
42
+ activeIndex
43
+ };
44
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { createPagination } from "./createPagination";
2
+ describe("createPagination", () => {
3
+ describe("when numPages <= 5", () => {
4
+ test("returns page numbers if numPages === 5", () => {
5
+ expect(createPagination(1, 5)).toEqual({ items: [1, 2, 3, 4, 5], activeIndex: 0 });
6
+ });
7
+ test("returns page numbers if numPages < 5", () => {
8
+ expect(createPagination(3, 3)).toEqual({ items: [1, 2, 3], activeIndex: 2 });
9
+ });
10
+ });
11
+ describe("when numPages > 5", () => {
12
+ describe("and page is within 2 pages of the first and last page", () => {
13
+ test("truncates last couples pages when on page 1", () => {
14
+ expect(createPagination(1, 6)).toEqual({ items: [1, 2, 3, "...", 6], activeIndex: 0 });
15
+ });
16
+ test("truncates last couples pages when on page 2", () => {
17
+ expect(createPagination(2, 6)).toEqual({ items: [1, 2, 3, "...", 6], activeIndex: 1 });
18
+ });
19
+ test("truncates first couples pages when on page 4", () => {
20
+ expect(createPagination(4, 6)).toEqual({ items: [1, "...", 4, 5, 6], activeIndex: 2 });
21
+ });
22
+ test("truncates first couples pages when on page 5", () => {
23
+ expect(createPagination(5, 6)).toEqual({ items: [1, "...", 4, 5, 6], activeIndex: 3 });
24
+ });
25
+ });
26
+ describe("and page is beyond 2 pages of the first and last page", () => {
27
+ test("truncates frist and last couples pages", () => {
28
+ expect(createPagination(15, 50)).toEqual({ items: [1, "...", 15, "...", 50], activeIndex: 2 });
29
+ });
30
+ });
31
+ });
32
+ });
@@ -0,0 +1 @@
1
+ export type Row = Record<string, any>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ type Props = {
2
+ children: React.ReactNode;
3
+ className?: string;
4
+ href?: string;
5
+ onClick?: () => void;
6
+ isActive?: boolean;
7
+ };
8
+ export declare const VuiTab: ({ children, className, href, onClick, isActive, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,27 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import classNames from "classnames";
14
+ import { useVuiContext } from "../context/Context";
15
+ export const VuiTab = (_a) => {
16
+ var { children, className, href, onClick, isActive = false } = _a, rest = __rest(_a, ["children", "className", "href", "onClick", "isActive"]);
17
+ const { createLink } = useVuiContext();
18
+ const classes = classNames(className, "vuiTab", {
19
+ "vuiTab-isActive": isActive
20
+ });
21
+ const content = _jsx("div", Object.assign({ className: "vuiTab__inner" }, { children: children }));
22
+ if (href) {
23
+ return createLink(Object.assign({ className: classes, href,
24
+ onClick, children: content }, rest));
25
+ }
26
+ return (_jsx("button", Object.assign({ className: classes, onClick: onClick }, rest, { children: content })));
27
+ };
@@ -0,0 +1,15 @@
1
+ import { TabSize } from "./types";
2
+ type Props = {
3
+ tabs: Array<{
4
+ href: string;
5
+ title: string;
6
+ render?: (tabLink: React.ReactNode) => React.ReactNode;
7
+ component: React.ReactNode;
8
+ testId?: string;
9
+ }>;
10
+ size?: TabSize;
11
+ sideContent?: React.ReactNode;
12
+ children?: React.ReactNode;
13
+ };
14
+ export declare const VuiTabbedRoutes: ({ tabs, size, sideContent, children }: Props) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { VuiTabs } from "./Tabs";
3
+ import { VuiTab } from "./Tab";
4
+ import { VuiSpacer } from "../spacer/Spacer";
5
+ import { useVuiContext } from "../context/Context";
6
+ export const VuiTabbedRoutes = ({ tabs, size, sideContent, children }) => {
7
+ const { getPath } = useVuiContext();
8
+ return (_jsxs(_Fragment, { children: [_jsx(VuiTabs, Object.assign({ append: sideContent, size: size }, { children: tabs.map(({ href, title, render, testId }, index) => {
9
+ const isActive = getPath().includes(href);
10
+ const tabLink = (_jsx(VuiTab, Object.assign({ href: href, isActive: isActive, "data-testid": testId }, { children: title }), index));
11
+ if (render)
12
+ return render(tabLink);
13
+ return tabLink;
14
+ }) })), _jsx(VuiSpacer, { size: "m" }), children] }));
15
+ };
@@ -0,0 +1,10 @@
1
+ import { TabSize } from "./types";
2
+ type Props = {
3
+ children: React.ReactNode;
4
+ append?: React.ReactNode;
5
+ className?: string;
6
+ size?: TabSize;
7
+ fullWidth?: boolean;
8
+ };
9
+ export declare const VuiTabs: ({ children, className, append, size, fullWidth }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import classNames from "classnames";
3
+ export const VuiTabs = ({ children, className, append, size = "s", fullWidth }) => {
4
+ const classes = classNames(className, "vuiTabs", `vuiTabs--${size}`, {
5
+ "vuiTabs--fullWidth": fullWidth
6
+ });
7
+ return (_jsxs("div", Object.assign({ className: classes }, { children: [_jsx("div", Object.assign({ className: "vuiTabs__tabs" }, { children: children })), append && _jsx("div", Object.assign({ className: "vuiTabs__appendedContent" }, { children: append }))] })));
8
+ };