@cutting/material-react-table 4.0.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 (327) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +215 -0
  3. package/dist/index.d.ts +1876 -0
  4. package/dist/index.esm.js +4434 -0
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/index.js +4540 -0
  7. package/dist/index.js.map +1 -0
  8. package/locales/ar/index.d.ts +3 -0
  9. package/locales/ar/index.esm.d.ts +3 -0
  10. package/locales/ar/index.esm.js +96 -0
  11. package/locales/ar/index.js +98 -0
  12. package/locales/ar/package.json +6 -0
  13. package/locales/az/index.d.ts +3 -0
  14. package/locales/az/index.esm.d.ts +3 -0
  15. package/locales/az/index.esm.js +96 -0
  16. package/locales/az/index.js +98 -0
  17. package/locales/az/package.json +6 -0
  18. package/locales/bg/index.d.ts +3 -0
  19. package/locales/bg/index.esm.d.ts +3 -0
  20. package/locales/bg/index.esm.js +96 -0
  21. package/locales/bg/index.js +98 -0
  22. package/locales/bg/package.json +6 -0
  23. package/locales/cs/index.d.ts +3 -0
  24. package/locales/cs/index.esm.d.ts +3 -0
  25. package/locales/cs/index.esm.js +96 -0
  26. package/locales/cs/index.js +98 -0
  27. package/locales/cs/package.json +6 -0
  28. package/locales/da/index.d.ts +3 -0
  29. package/locales/da/index.esm.d.ts +3 -0
  30. package/locales/da/index.esm.js +96 -0
  31. package/locales/da/index.js +98 -0
  32. package/locales/da/package.json +6 -0
  33. package/locales/de/index.d.ts +3 -0
  34. package/locales/de/index.esm.d.ts +3 -0
  35. package/locales/de/index.esm.js +96 -0
  36. package/locales/de/index.js +98 -0
  37. package/locales/de/package.json +6 -0
  38. package/locales/el/index.d.ts +3 -0
  39. package/locales/el/index.esm.d.ts +3 -0
  40. package/locales/el/index.esm.js +96 -0
  41. package/locales/el/index.js +98 -0
  42. package/locales/el/package.json +6 -0
  43. package/locales/en/index.d.ts +3 -0
  44. package/locales/en/index.esm.d.ts +3 -0
  45. package/locales/en/index.esm.js +96 -0
  46. package/locales/en/index.js +98 -0
  47. package/locales/en/package.json +6 -0
  48. package/locales/es/index.d.ts +3 -0
  49. package/locales/es/index.esm.d.ts +3 -0
  50. package/locales/es/index.esm.js +96 -0
  51. package/locales/es/index.js +98 -0
  52. package/locales/es/package.json +6 -0
  53. package/locales/et/index.d.ts +3 -0
  54. package/locales/et/index.esm.d.ts +3 -0
  55. package/locales/et/index.esm.js +96 -0
  56. package/locales/et/index.js +98 -0
  57. package/locales/et/package.json +6 -0
  58. package/locales/fa/index.d.ts +3 -0
  59. package/locales/fa/index.esm.d.ts +3 -0
  60. package/locales/fa/index.esm.js +96 -0
  61. package/locales/fa/index.js +98 -0
  62. package/locales/fa/package.json +6 -0
  63. package/locales/fi/index.d.ts +3 -0
  64. package/locales/fi/index.esm.d.ts +3 -0
  65. package/locales/fi/index.esm.js +96 -0
  66. package/locales/fi/index.js +98 -0
  67. package/locales/fi/package.json +6 -0
  68. package/locales/fr/index.d.ts +3 -0
  69. package/locales/fr/index.esm.d.ts +3 -0
  70. package/locales/fr/index.esm.js +96 -0
  71. package/locales/fr/index.js +98 -0
  72. package/locales/fr/package.json +6 -0
  73. package/locales/he/index.d.ts +3 -0
  74. package/locales/he/index.esm.d.ts +3 -0
  75. package/locales/he/index.esm.js +96 -0
  76. package/locales/he/index.js +98 -0
  77. package/locales/he/package.json +6 -0
  78. package/locales/hr/index.d.ts +3 -0
  79. package/locales/hr/index.esm.d.ts +3 -0
  80. package/locales/hr/index.esm.js +96 -0
  81. package/locales/hr/index.js +98 -0
  82. package/locales/hr/package.json +6 -0
  83. package/locales/hu/index.d.ts +3 -0
  84. package/locales/hu/index.esm.d.ts +3 -0
  85. package/locales/hu/index.esm.js +96 -0
  86. package/locales/hu/index.js +98 -0
  87. package/locales/hu/package.json +6 -0
  88. package/locales/hy/index.d.ts +3 -0
  89. package/locales/hy/index.esm.d.ts +3 -0
  90. package/locales/hy/index.esm.js +96 -0
  91. package/locales/hy/index.js +98 -0
  92. package/locales/hy/package.json +6 -0
  93. package/locales/id/index.d.ts +3 -0
  94. package/locales/id/index.esm.d.ts +3 -0
  95. package/locales/id/index.esm.js +96 -0
  96. package/locales/id/index.js +98 -0
  97. package/locales/id/package.json +6 -0
  98. package/locales/it/index.d.ts +3 -0
  99. package/locales/it/index.esm.d.ts +3 -0
  100. package/locales/it/index.esm.js +96 -0
  101. package/locales/it/index.js +98 -0
  102. package/locales/it/package.json +6 -0
  103. package/locales/ja/index.d.ts +3 -0
  104. package/locales/ja/index.esm.d.ts +3 -0
  105. package/locales/ja/index.esm.js +96 -0
  106. package/locales/ja/index.js +98 -0
  107. package/locales/ja/package.json +6 -0
  108. package/locales/ko/index.d.ts +3 -0
  109. package/locales/ko/index.esm.d.ts +3 -0
  110. package/locales/ko/index.esm.js +96 -0
  111. package/locales/ko/index.js +98 -0
  112. package/locales/ko/package.json +6 -0
  113. package/locales/nl/index.d.ts +3 -0
  114. package/locales/nl/index.esm.d.ts +3 -0
  115. package/locales/nl/index.esm.js +96 -0
  116. package/locales/nl/index.js +98 -0
  117. package/locales/nl/package.json +6 -0
  118. package/locales/no/index.d.ts +3 -0
  119. package/locales/no/index.esm.d.ts +3 -0
  120. package/locales/no/index.esm.js +96 -0
  121. package/locales/no/index.js +98 -0
  122. package/locales/no/package.json +6 -0
  123. package/locales/np/index.d.ts +3 -0
  124. package/locales/np/index.esm.d.ts +3 -0
  125. package/locales/np/index.esm.js +96 -0
  126. package/locales/np/index.js +98 -0
  127. package/locales/np/package.json +6 -0
  128. package/locales/pl/index.d.ts +3 -0
  129. package/locales/pl/index.esm.d.ts +3 -0
  130. package/locales/pl/index.esm.js +96 -0
  131. package/locales/pl/index.js +98 -0
  132. package/locales/pl/package.json +6 -0
  133. package/locales/pt/index.d.ts +3 -0
  134. package/locales/pt/index.esm.d.ts +3 -0
  135. package/locales/pt/index.esm.js +96 -0
  136. package/locales/pt/index.js +98 -0
  137. package/locales/pt/package.json +6 -0
  138. package/locales/pt-BR/index.d.ts +3 -0
  139. package/locales/pt-BR/index.esm.d.ts +3 -0
  140. package/locales/pt-BR/index.esm.js +96 -0
  141. package/locales/pt-BR/index.js +98 -0
  142. package/locales/pt-BR/package.json +6 -0
  143. package/locales/ro/index.d.ts +3 -0
  144. package/locales/ro/index.esm.d.ts +3 -0
  145. package/locales/ro/index.esm.js +96 -0
  146. package/locales/ro/index.js +98 -0
  147. package/locales/ro/package.json +6 -0
  148. package/locales/ru/index.d.ts +3 -0
  149. package/locales/ru/index.esm.d.ts +3 -0
  150. package/locales/ru/index.esm.js +96 -0
  151. package/locales/ru/index.js +98 -0
  152. package/locales/ru/package.json +6 -0
  153. package/locales/sk/index.d.ts +3 -0
  154. package/locales/sk/index.esm.d.ts +3 -0
  155. package/locales/sk/index.esm.js +96 -0
  156. package/locales/sk/index.js +98 -0
  157. package/locales/sk/package.json +6 -0
  158. package/locales/sr-Cyrl-RS/index.d.ts +3 -0
  159. package/locales/sr-Cyrl-RS/index.esm.d.ts +3 -0
  160. package/locales/sr-Cyrl-RS/index.esm.js +96 -0
  161. package/locales/sr-Cyrl-RS/index.js +98 -0
  162. package/locales/sr-Cyrl-RS/package.json +6 -0
  163. package/locales/sr-Latn-RS/index.d.ts +3 -0
  164. package/locales/sr-Latn-RS/index.esm.d.ts +3 -0
  165. package/locales/sr-Latn-RS/index.esm.js +96 -0
  166. package/locales/sr-Latn-RS/index.js +98 -0
  167. package/locales/sr-Latn-RS/package.json +6 -0
  168. package/locales/sv/index.d.ts +3 -0
  169. package/locales/sv/index.esm.d.ts +3 -0
  170. package/locales/sv/index.esm.js +96 -0
  171. package/locales/sv/index.js +98 -0
  172. package/locales/sv/package.json +6 -0
  173. package/locales/tr/index.d.ts +3 -0
  174. package/locales/tr/index.esm.d.ts +3 -0
  175. package/locales/tr/index.esm.js +96 -0
  176. package/locales/tr/index.js +98 -0
  177. package/locales/tr/package.json +6 -0
  178. package/locales/uk/index.d.ts +3 -0
  179. package/locales/uk/index.esm.d.ts +3 -0
  180. package/locales/uk/index.esm.js +96 -0
  181. package/locales/uk/index.js +98 -0
  182. package/locales/uk/package.json +6 -0
  183. package/locales/vi/index.d.ts +3 -0
  184. package/locales/vi/index.esm.d.ts +3 -0
  185. package/locales/vi/index.esm.js +96 -0
  186. package/locales/vi/index.js +98 -0
  187. package/locales/vi/package.json +6 -0
  188. package/locales/zh-Hans/index.d.ts +3 -0
  189. package/locales/zh-Hans/index.esm.d.ts +3 -0
  190. package/locales/zh-Hans/index.esm.js +96 -0
  191. package/locales/zh-Hans/index.js +98 -0
  192. package/locales/zh-Hans/package.json +6 -0
  193. package/locales/zh-Hant/index.d.ts +3 -0
  194. package/locales/zh-Hant/index.esm.d.ts +3 -0
  195. package/locales/zh-Hant/index.esm.js +96 -0
  196. package/locales/zh-Hant/index.js +98 -0
  197. package/locales/zh-Hant/package.json +6 -0
  198. package/package.json +133 -0
  199. package/src/MaterialReactTable.smoke.test.tsx +56 -0
  200. package/src/components/MaterialReactTable.tsx +36 -0
  201. package/src/components/body/MRT_TableBody.tsx +222 -0
  202. package/src/components/body/MRT_TableBodyCell.tsx +352 -0
  203. package/src/components/body/MRT_TableBodyCellValue.tsx +131 -0
  204. package/src/components/body/MRT_TableBodyRow.tsx +283 -0
  205. package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +62 -0
  206. package/src/components/body/MRT_TableBodyRowPinButton.tsx +59 -0
  207. package/src/components/body/MRT_TableDetailPanel.tsx +111 -0
  208. package/src/components/buttons/MRT_ColumnPinningButtons.tsx +73 -0
  209. package/src/components/buttons/MRT_CopyButton.tsx +88 -0
  210. package/src/components/buttons/MRT_EditActionButtons.tsx +135 -0
  211. package/src/components/buttons/MRT_ExpandAllButton.tsx +79 -0
  212. package/src/components/buttons/MRT_ExpandButton.tsx +103 -0
  213. package/src/components/buttons/MRT_GrabHandleButton.tsx +66 -0
  214. package/src/components/buttons/MRT_RowPinButton.tsx +85 -0
  215. package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +51 -0
  216. package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +53 -0
  217. package/src/components/buttons/MRT_ToggleFiltersButton.tsx +41 -0
  218. package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +52 -0
  219. package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +47 -0
  220. package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +127 -0
  221. package/src/components/footer/MRT_TableFooter.tsx +89 -0
  222. package/src/components/footer/MRT_TableFooterCell.tsx +108 -0
  223. package/src/components/footer/MRT_TableFooterRow.tsx +96 -0
  224. package/src/components/head/MRT_TableHead.tsx +92 -0
  225. package/src/components/head/MRT_TableHeadCell.tsx +352 -0
  226. package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +97 -0
  227. package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +53 -0
  228. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +179 -0
  229. package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +92 -0
  230. package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +97 -0
  231. package/src/components/head/MRT_TableHeadCellSortLabel.tsx +102 -0
  232. package/src/components/head/MRT_TableHeadRow.tsx +91 -0
  233. package/src/components/inputs/MRT_EditCellTextField.tsx +190 -0
  234. package/src/components/inputs/MRT_FilterCheckbox.tsx +91 -0
  235. package/src/components/inputs/MRT_FilterRangeFields.tsx +42 -0
  236. package/src/components/inputs/MRT_FilterRangeSlider.tsx +144 -0
  237. package/src/components/inputs/MRT_FilterTextField.tsx +599 -0
  238. package/src/components/inputs/MRT_GlobalFilterTextField.tsx +160 -0
  239. package/src/components/inputs/MRT_SelectCheckbox.tsx +136 -0
  240. package/src/components/menus/MRT_ActionMenuItem.tsx +63 -0
  241. package/src/components/menus/MRT_CellActionMenu.tsx +108 -0
  242. package/src/components/menus/MRT_ColumnActionMenu.tsx +353 -0
  243. package/src/components/menus/MRT_FilterOptionMenu.tsx +293 -0
  244. package/src/components/menus/MRT_RowActionMenu.tsx +89 -0
  245. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +180 -0
  246. package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +204 -0
  247. package/src/components/modals/MRT_EditRowModal.tsx +115 -0
  248. package/src/components/table/MRT_Table.tsx +85 -0
  249. package/src/components/table/MRT_TableContainer.tsx +112 -0
  250. package/src/components/table/MRT_TableLoadingOverlay.tsx +59 -0
  251. package/src/components/table/MRT_TablePaper.tsx +90 -0
  252. package/src/components/toolbar/MRT_BottomToolbar.tsx +109 -0
  253. package/src/components/toolbar/MRT_LinearProgressBar.tsx +54 -0
  254. package/src/components/toolbar/MRT_TablePagination.tsx +244 -0
  255. package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +184 -0
  256. package/src/components/toolbar/MRT_ToolbarDropZone.tsx +81 -0
  257. package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +73 -0
  258. package/src/components/toolbar/MRT_TopToolbar.tsx +131 -0
  259. package/src/fns/aggregationFns.ts +3 -0
  260. package/src/fns/filterFns.ts +197 -0
  261. package/src/fns/sortingFns.ts +34 -0
  262. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +28 -0
  263. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +30 -0
  264. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +97 -0
  265. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +30 -0
  266. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +24 -0
  267. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +34 -0
  268. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +33 -0
  269. package/src/hooks/useMRT_ColumnVirtualizer.ts +125 -0
  270. package/src/hooks/useMRT_Effects.ts +107 -0
  271. package/src/hooks/useMRT_RowVirtualizer.ts +89 -0
  272. package/src/hooks/useMRT_Rows.ts +45 -0
  273. package/src/hooks/useMRT_TableInstance.ts +318 -0
  274. package/src/hooks/useMRT_TableOptions.ts +271 -0
  275. package/src/hooks/useMaterialReactTable.ts +12 -0
  276. package/src/icons.ts +73 -0
  277. package/src/index.ts +91 -0
  278. package/src/locales/ar.ts +97 -0
  279. package/src/locales/az.ts +97 -0
  280. package/src/locales/bg.ts +97 -0
  281. package/src/locales/cs.ts +98 -0
  282. package/src/locales/da.ts +97 -0
  283. package/src/locales/de.ts +97 -0
  284. package/src/locales/el.ts +97 -0
  285. package/src/locales/en.ts +97 -0
  286. package/src/locales/es.ts +97 -0
  287. package/src/locales/et.ts +98 -0
  288. package/src/locales/fa.ts +97 -0
  289. package/src/locales/fi.ts +98 -0
  290. package/src/locales/fr.ts +97 -0
  291. package/src/locales/he.ts +97 -0
  292. package/src/locales/hr.ts +97 -0
  293. package/src/locales/hu.ts +97 -0
  294. package/src/locales/hy.ts +97 -0
  295. package/src/locales/id.ts +98 -0
  296. package/src/locales/it.ts +97 -0
  297. package/src/locales/ja.ts +97 -0
  298. package/src/locales/ko.ts +97 -0
  299. package/src/locales/mk.ts +96 -0
  300. package/src/locales/nl.ts +97 -0
  301. package/src/locales/no.ts +99 -0
  302. package/src/locales/np.ts +98 -0
  303. package/src/locales/pl.ts +97 -0
  304. package/src/locales/pt-BR.ts +97 -0
  305. package/src/locales/pt.ts +97 -0
  306. package/src/locales/ro.ts +97 -0
  307. package/src/locales/ru.ts +97 -0
  308. package/src/locales/sk.ts +98 -0
  309. package/src/locales/sr-Cyrl-RS.ts +97 -0
  310. package/src/locales/sr-Latn-RS.ts +97 -0
  311. package/src/locales/sv.ts +97 -0
  312. package/src/locales/tr.ts +97 -0
  313. package/src/locales/uk.ts +97 -0
  314. package/src/locales/vi.ts +97 -0
  315. package/src/locales/zh-Hans.ts +96 -0
  316. package/src/locales/zh-Hant.ts +96 -0
  317. package/src/types.ts +1290 -0
  318. package/src/utils/cell.utils.ts +234 -0
  319. package/src/utils/column.utils.ts +210 -0
  320. package/src/utils/displayColumn.utils.ts +152 -0
  321. package/src/utils/row.utils.ts +261 -0
  322. package/src/utils/slotProps.utils.ts +25 -0
  323. package/src/utils/style.utils.ts +210 -0
  324. package/src/utils/tanstack.helpers.ts +65 -0
  325. package/src/utils/utils.ts +23 -0
  326. package/src/utils/virtualization.utils.ts +24 -0
  327. package/src/vitest.setup.ts +1 -0
@@ -0,0 +1,4434 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import TableBody from '@mui/material/TableBody';
3
+ import Typography from '@mui/material/Typography';
4
+ import { useMemo, useCallback, useState, memo, useEffect, useRef, Fragment as Fragment$1, useId, useReducer, useLayoutEffect } from 'react';
5
+ import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
6
+ import { sortingFns, flexRender as flexRender$1, createRow as createRow$1, aggregationFns, filterFns, getSortedRowModel, getPaginationRowModel, getGroupedRowModel, getFilteredRowModel, getFacetedUniqueValues, getFacetedRowModel, getFacetedMinMaxValues, getExpandedRowModel, getCoreRowModel, useReactTable } from '@tanstack/react-table';
7
+ import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
8
+ import { alpha, darken, lighten, useTheme } from '@mui/material/styles';
9
+ import TableRow from '@mui/material/TableRow';
10
+ import Skeleton from '@mui/material/Skeleton';
11
+ import TableCell from '@mui/material/TableCell';
12
+ import Button from '@mui/material/Button';
13
+ import Tooltip from '@mui/material/Tooltip';
14
+ import MenuItem from '@mui/material/MenuItem';
15
+ import TextField from '@mui/material/TextField';
16
+ import Box from '@mui/material/Box';
17
+ import highlightWords from 'highlight-words';
18
+ import Collapse from '@mui/material/Collapse';
19
+ import IconButton from '@mui/material/IconButton';
20
+ import CircularProgress from '@mui/material/CircularProgress';
21
+ import Divider from '@mui/material/Divider';
22
+ import Menu from '@mui/material/Menu';
23
+ import FormControlLabel from '@mui/material/FormControlLabel';
24
+ import Switch from '@mui/material/Switch';
25
+ import ListItemIcon from '@mui/material/ListItemIcon';
26
+ import TableFooter from '@mui/material/TableFooter';
27
+ import TableHead from '@mui/material/TableHead';
28
+ import Alert from '@mui/material/Alert';
29
+ import AlertTitle from '@mui/material/AlertTitle';
30
+ import Chip from '@mui/material/Chip';
31
+ import Stack from '@mui/material/Stack';
32
+ import Checkbox from '@mui/material/Checkbox';
33
+ import Radio from '@mui/material/Radio';
34
+ import Autocomplete from '@mui/material/Autocomplete';
35
+ import InputAdornment from '@mui/material/InputAdornment';
36
+ import { debounce } from '@mui/material/utils';
37
+ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
38
+ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
39
+ import { TimePicker } from '@mui/x-date-pickers/TimePicker';
40
+ import FormHelperText from '@mui/material/FormHelperText';
41
+ import Slider from '@mui/material/Slider';
42
+ import Grow from '@mui/material/Grow';
43
+ import Popover from '@mui/material/Popover';
44
+ import Badge from '@mui/material/Badge';
45
+ import TableSortLabel from '@mui/material/TableSortLabel';
46
+ import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
47
+ import ArrowRightIcon from '@mui/icons-material/ArrowRight';
48
+ import CancelIcon from '@mui/icons-material/Cancel';
49
+ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
50
+ import ChevronRightIcon from '@mui/icons-material/ChevronRight';
51
+ import ClearAllIcon from '@mui/icons-material/ClearAll';
52
+ import CloseIcon from '@mui/icons-material/Close';
53
+ import ContentCopy from '@mui/icons-material/ContentCopy';
54
+ import DensityLargeIcon from '@mui/icons-material/DensityLarge';
55
+ import DensityMediumIcon from '@mui/icons-material/DensityMedium';
56
+ import DensitySmallIcon from '@mui/icons-material/DensitySmall';
57
+ import DragHandleIcon from '@mui/icons-material/DragHandle';
58
+ import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
59
+ import EditIcon from '@mui/icons-material/Edit';
60
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
61
+ import FilterAltIcon from '@mui/icons-material/FilterAlt';
62
+ import FilterListIcon from '@mui/icons-material/FilterList';
63
+ import FilterListOffIcon from '@mui/icons-material/FilterListOff';
64
+ import FirstPageIcon from '@mui/icons-material/FirstPage';
65
+ import FullscreenIcon from '@mui/icons-material/Fullscreen';
66
+ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
67
+ import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
68
+ import LastPageIcon from '@mui/icons-material/LastPage';
69
+ import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
70
+ import MoreVertIcon from '@mui/icons-material/MoreVert';
71
+ import PushPinIcon from '@mui/icons-material/PushPin';
72
+ import RestartAltIcon from '@mui/icons-material/RestartAlt';
73
+ import SaveIcon from '@mui/icons-material/Save';
74
+ import SearchIcon from '@mui/icons-material/Search';
75
+ import SearchOffIcon from '@mui/icons-material/SearchOff';
76
+ import SortIcon from '@mui/icons-material/Sort';
77
+ import SyncAltIcon from '@mui/icons-material/SyncAlt';
78
+ import ViewColumnIcon from '@mui/icons-material/ViewColumn';
79
+ import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
80
+ import Paper from '@mui/material/Paper';
81
+ import useMediaQuery from '@mui/material/useMediaQuery';
82
+ import LinearProgress from '@mui/material/LinearProgress';
83
+ import InputLabel from '@mui/material/InputLabel';
84
+ import Pagination from '@mui/material/Pagination';
85
+ import PaginationItem from '@mui/material/PaginationItem';
86
+ import Select from '@mui/material/Select';
87
+ import Fade from '@mui/material/Fade';
88
+ import TableContainer from '@mui/material/TableContainer';
89
+ import Dialog from '@mui/material/Dialog';
90
+ import DialogActions from '@mui/material/DialogActions';
91
+ import DialogContent from '@mui/material/DialogContent';
92
+ import DialogTitle from '@mui/material/DialogTitle';
93
+ import Table from '@mui/material/Table';
94
+
95
+ /******************************************************************************
96
+ Copyright (c) Microsoft Corporation.
97
+
98
+ Permission to use, copy, modify, and/or distribute this software for any
99
+ purpose with or without fee is hereby granted.
100
+
101
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
102
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
103
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
104
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
105
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
106
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
107
+ PERFORMANCE OF THIS SOFTWARE.
108
+ ***************************************************************************** */
109
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
110
+
111
+
112
+ function __rest(s, e) {
113
+ var t = {};
114
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
115
+ t[p] = s[p];
116
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
117
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
118
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
119
+ t[p[i]] = s[p[i]];
120
+ }
121
+ return t;
122
+ }
123
+
124
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
125
+ var e = new Error(message);
126
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
127
+ };
128
+
129
+ const fuzzy$1 = (rowA, rowB, columnId) => {
130
+ let dir = 0;
131
+ if (rowA.columnFiltersMeta[columnId]) {
132
+ dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
133
+ }
134
+ // Provide a fallback for when the item ranks are equal
135
+ return dir === 0
136
+ ? sortingFns.alphanumeric(rowA, rowB, columnId)
137
+ : dir;
138
+ };
139
+ const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
140
+ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
141
+ Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
142
+
143
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
144
+ const getValueAndLabel = (option) => {
145
+ var _a, _b;
146
+ let label = '';
147
+ let value = '';
148
+ if (option) {
149
+ if (typeof option !== 'object') {
150
+ label = option;
151
+ value = option;
152
+ }
153
+ else {
154
+ label = (_a = option.label) !== null && _a !== void 0 ? _a : option.value;
155
+ value = (_b = option.value) !== null && _b !== void 0 ? _b : label;
156
+ }
157
+ }
158
+ return { label, value };
159
+ };
160
+
161
+ const getMRT_Rows = (table, all) => {
162
+ const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
163
+ const { creatingRow, pagination } = getState();
164
+ const isRankingRows = getIsRankingRows(table);
165
+ let rows = [];
166
+ if (!isRankingRows) {
167
+ rows =
168
+ !enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
169
+ ? all
170
+ ? getPrePaginationRowModel().rows
171
+ : getRowModel().rows
172
+ : getCenterRows();
173
+ }
174
+ else {
175
+ // fuzzy ranking adjustments
176
+ rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
177
+ if (enablePagination && !manualPagination && !all) {
178
+ const start = pagination.pageIndex * pagination.pageSize;
179
+ rows = rows.slice(start, start + pagination.pageSize);
180
+ }
181
+ if (enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
182
+ // "re-center-ize" the rows (no top or bottom pinned rows unless sticky)
183
+ rows = rows.filter((row) => !row.getIsPinned());
184
+ }
185
+ }
186
+ // row pinning adjustments
187
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
188
+ const centerPinnedRowIds = rows
189
+ .filter((row) => row.getIsPinned())
190
+ .map((r) => r.id);
191
+ rows = [
192
+ ...getTopRows().filter((row) => !centerPinnedRowIds.includes(row.id)),
193
+ ...rows,
194
+ ];
195
+ }
196
+ // blank inserted creating row adjustments
197
+ if (positionCreatingRow !== undefined &&
198
+ creatingRow &&
199
+ createDisplayMode === 'row') {
200
+ const creatingRowIndex = !isNaN(+positionCreatingRow)
201
+ ? +positionCreatingRow
202
+ : positionCreatingRow === 'top'
203
+ ? 0
204
+ : rows.length;
205
+ rows = [
206
+ ...rows.slice(0, creatingRowIndex),
207
+ creatingRow,
208
+ ...rows.slice(creatingRowIndex),
209
+ ];
210
+ }
211
+ return rows;
212
+ };
213
+ const getCanRankRows = (table) => {
214
+ const { getState, options: { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, }, } = table;
215
+ const { expanded, globalFilterFn } = getState();
216
+ return (!manualExpanding &&
217
+ !manualFiltering &&
218
+ !manualGrouping &&
219
+ !manualSorting &&
220
+ enableGlobalFilterRankedResults &&
221
+ globalFilterFn === 'fuzzy' &&
222
+ expanded !== true &&
223
+ !Object.values(expanded).some(Boolean));
224
+ };
225
+ const getIsRankingRows = (table) => {
226
+ const { globalFilter, sorting } = table.getState();
227
+ return (getCanRankRows(table) &&
228
+ globalFilter &&
229
+ !Object.values(sorting).some(Boolean));
230
+ };
231
+ const getIsRowSelected = ({ row, table, }) => {
232
+ const { options: { enableRowSelection }, } = table;
233
+ return (row.getIsSelected() ||
234
+ (parseFromValuesOrFunc(enableRowSelection, row) &&
235
+ row.getCanSelectSubRows() &&
236
+ row.getIsAllSubRowsSelected()));
237
+ };
238
+ const getMRT_RowSelectionHandler = ({ row, staticRowIndex = 0, table, }) => (event, value) => {
239
+ var _a;
240
+ const { getState, options: { enableBatchRowSelection, enableMultiRowSelection, enableRowPinning, manualPagination, rowPinningDisplayMode, }, refs: { lastSelectedRowId: lastSelectedRowId }, } = table;
241
+ const { pagination: { pageIndex, pageSize }, } = getState();
242
+ const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
243
+ const wasCurrentRowChecked = getIsRowSelected({ row, table });
244
+ // toggle selection of this row
245
+ row.toggleSelected(value !== null && value !== void 0 ? value : !wasCurrentRowChecked);
246
+ const changedRowIds = new Set([row.id]);
247
+ // if shift key is pressed, select all rows between last selected and this one
248
+ if (enableBatchRowSelection &&
249
+ enableMultiRowSelection &&
250
+ event.nativeEvent.shiftKey &&
251
+ lastSelectedRowId.current !== null) {
252
+ const rows = getMRT_Rows(table, true);
253
+ const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
254
+ if (lastIndex !== -1) {
255
+ const isLastIndexChecked = getIsRowSelected({
256
+ row: rows === null || rows === void 0 ? void 0 : rows[lastIndex],
257
+ table,
258
+ });
259
+ const currentIndex = staticRowIndex + paginationOffset;
260
+ const [start, end] = lastIndex < currentIndex
261
+ ? [lastIndex, currentIndex]
262
+ : [currentIndex, lastIndex];
263
+ // toggle selection of all rows between last selected and this one
264
+ // but only if the last selected row is not the same as the current one
265
+ if (wasCurrentRowChecked !== isLastIndexChecked) {
266
+ for (let i = start; i <= end; i++) {
267
+ rows[i].toggleSelected(!wasCurrentRowChecked);
268
+ changedRowIds.add(rows[i].id);
269
+ }
270
+ }
271
+ }
272
+ }
273
+ // record the last selected row id
274
+ lastSelectedRowId.current = row.id;
275
+ // if all sub rows were selected, unselect them
276
+ if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
277
+ (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
278
+ }
279
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
280
+ changedRowIds.forEach((rowId) => {
281
+ const rowToTogglePin = table.getRow(rowId);
282
+ rowToTogglePin.pin(!wasCurrentRowChecked //was not previously pinned or selected
283
+ ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
284
+ ? 'bottom'
285
+ : 'top'
286
+ : false);
287
+ });
288
+ }
289
+ };
290
+ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
291
+ const { options: { enableRowPinning, rowPinningDisplayMode, selectAllMode }, refs: { lastSelectedRowId }, } = table;
292
+ selectAllMode === 'all' || forceAll
293
+ ? table.toggleAllRowsSelected(value !== null && value !== void 0 ? value : event.target.checked)
294
+ : table.toggleAllPageRowsSelected(value !== null && value !== void 0 ? value : event.target.checked);
295
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
296
+ table.setRowPinning({ bottom: [], top: [] });
297
+ }
298
+ lastSelectedRowId.current = null;
299
+ };
300
+
301
+ const useMRT_Rows = (table) => {
302
+ const { getRowModel, getState, options: { data, enableGlobalFilterRankedResults, positionCreatingRow }, } = table;
303
+ const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = getState();
304
+ const rows = useMemo(() => getMRT_Rows(table), [
305
+ creatingRow,
306
+ data,
307
+ enableGlobalFilterRankedResults,
308
+ expanded,
309
+ getRowModel().rows,
310
+ globalFilter,
311
+ pagination.pageIndex,
312
+ pagination.pageSize,
313
+ positionCreatingRow,
314
+ rowPinning,
315
+ sorting,
316
+ ]);
317
+ return rows;
318
+ };
319
+
320
+ /**
321
+ * When scroll, the `draggingRow` or `draggingColumn` can be removed from document because of virtualization,
322
+ * then, the `dragEnd` event on `MRT_TableBodyRowGrabHandle` or `MRT_TableHeadCellGrabHandle` will not fire.
323
+ * We should keep the `draggingRow` or `draggingColumn` in `getVirtualItems()` to avoid this thing.
324
+ */
325
+ const extraIndexRangeExtractor = (range, draggingIndex) => {
326
+ const newIndexes = defaultRangeExtractor(range);
327
+ if (draggingIndex === undefined)
328
+ return newIndexes;
329
+ if (draggingIndex >= 0 &&
330
+ draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
331
+ newIndexes.unshift(draggingIndex);
332
+ }
333
+ if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
334
+ newIndexes.push(draggingIndex);
335
+ }
336
+ return newIndexes;
337
+ };
338
+
339
+ const useMRT_RowVirtualizer = (table, rows) => {
340
+ const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
341
+ const { density, draggingRow, expanded } = getState();
342
+ if (!enableRowVirtualization)
343
+ return undefined;
344
+ const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
345
+ table,
346
+ });
347
+ const realRows = rows !== null && rows !== void 0 ? rows : getRowModel().rows;
348
+ /**
349
+ * when filtering, should find the correct index in filtered rows
350
+ */
351
+ const draggingRowIndex = useMemo(() => (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id)
352
+ ? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
353
+ : undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
354
+ const rowCount = realRows.length;
355
+ const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
356
+ const rowVirtualizer = useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
357
+ ? expanded === true
358
+ ? 100
359
+ : 0
360
+ : normalRowHeight, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
361
+ navigator.userAgent.indexOf('Firefox') === -1
362
+ ? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
363
+ : undefined, overscan: 4, rangeExtractor: useCallback((range) => {
364
+ return extraIndexRangeExtractor(range, draggingRowIndex);
365
+ }, [draggingRowIndex]) }, rowVirtualizerProps));
366
+ rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
367
+ if (rowVirtualizerInstanceRef) {
368
+ //@ts-expect-error
369
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
370
+ }
371
+ return rowVirtualizer;
372
+ };
373
+
374
+ const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
375
+ const getMRTTheme = (mrtTheme, muiTheme) => {
376
+ var _a;
377
+ const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
378
+ const baseBackgroundColor = (_a = mrtThemeOverrides === null || mrtThemeOverrides === void 0 ? void 0 : mrtThemeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (muiTheme.palette.mode === 'dark'
379
+ ? lighten(muiTheme.palette.background.default, 0.05)
380
+ : muiTheme.palette.background.default);
381
+ return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
382
+ ? darken(muiTheme.palette.warning.dark, 0.25)
383
+ : lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
384
+ };
385
+ const commonCellBeforeAfterStyles = {
386
+ content: '""',
387
+ height: '100%',
388
+ left: 0,
389
+ position: 'absolute',
390
+ top: 0,
391
+ width: '100%',
392
+ zIndex: -1,
393
+ };
394
+ const getCommonPinnedCellStyles = ({ column, table, theme, }) => {
395
+ const { baseBackgroundColor } = table.options.mrtTheme;
396
+ const isPinned = column === null || column === void 0 ? void 0 : column.getIsPinned();
397
+ return {
398
+ '&[data-pinned="true"]': {
399
+ '&:before': Object.assign({ backgroundColor: alpha(darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97), boxShadow: column
400
+ ? isPinned === 'left' && column.getIsLastColumn(isPinned)
401
+ ? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
402
+ : isPinned === 'right' && column.getIsFirstColumn(isPinned)
403
+ ? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
404
+ : undefined
405
+ : undefined }, commonCellBeforeAfterStyles),
406
+ },
407
+ };
408
+ };
409
+ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
410
+ var _a, _b, _c, _d, _e, _f;
411
+ const { getState, options: { enableColumnVirtualization, layoutMode }, } = table;
412
+ const { draggingColumn } = getState();
413
+ const { columnDef } = column;
414
+ const { columnDefType } = columnDef;
415
+ const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
416
+ const widthStyles = {
417
+ minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
418
+ width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px)`,
419
+ };
420
+ if (layoutMode === 'grid') {
421
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
422
+ ? 0
423
+ : `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_d = header === null || header === void 0 ? void 0 : header.id) !== null && _d !== void 0 ? _d : column.id)}-size)`} 0 auto`;
424
+ }
425
+ else if (layoutMode === 'grid-no-grow') {
426
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
427
+ }
428
+ const pinnedStyles = isColumnPinned
429
+ ? Object.assign(Object.assign({}, getCommonPinnedCellStyles({ column, table, theme })), { left: isColumnPinned === 'left'
430
+ ? `${column.getStart('left')}px`
431
+ : undefined, opacity: 0.97, position: 'sticky', right: isColumnPinned === 'right'
432
+ ? `${column.getAfter('right')}px`
433
+ : undefined }) : {};
434
+ return Object.assign(Object.assign(Object.assign({ '&:focus-visible': {
435
+ outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
436
+ outlineOffset: '-2px',
437
+ }, backgroundColor: 'inherit', backgroundImage: 'inherit', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, justifyContent: columnDefType === 'group'
438
+ ? 'center'
439
+ : (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
440
+ ? tableCellProps.align
441
+ : undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
442
+ ((_f = table.getState().hoveredColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id
443
+ ? 0.5
444
+ : 1, position: 'relative', transition: enableColumnVirtualization
445
+ ? 'none'
446
+ : `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
447
+ ? 2
448
+ : columnDefType !== 'group' && isColumnPinned
449
+ ? 1
450
+ : 0 }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
451
+ };
452
+ const getCommonToolbarStyles = ({ table, }) => ({
453
+ alignItems: 'flex-start',
454
+ backgroundColor: table.options.mrtTheme.baseBackgroundColor,
455
+ display: 'grid',
456
+ flexWrap: 'wrap-reverse',
457
+ minHeight: '3.5rem',
458
+ overflow: 'hidden',
459
+ position: 'relative',
460
+ transition: 'all 150ms ease-in-out',
461
+ zIndex: 1,
462
+ });
463
+ const flipIconStyles = (theme) => theme.direction === 'rtl'
464
+ ? { style: { transform: 'scaleX(-1)' } }
465
+ : undefined;
466
+ const getCommonTooltipProps = (placement) => ({
467
+ disableInteractive: true,
468
+ enterDelay: 1000,
469
+ enterNextDelay: 1000,
470
+ placement,
471
+ });
472
+
473
+ const isWinCtrlMacMeta = (event) => {
474
+ return ((event.ctrlKey && navigator.platform.toLowerCase().includes('win')) ||
475
+ (event.metaKey && navigator.platform.toLowerCase().includes('mac')));
476
+ };
477
+ const isCellEditable = ({ cell, table, }) => {
478
+ const { enableEditing } = table.options;
479
+ const { column: { columnDef }, row, } = cell;
480
+ return (!cell.getIsPlaceholder() &&
481
+ parseFromValuesOrFunc(enableEditing, row) &&
482
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
483
+ };
484
+ const openEditingCell = ({ cell, table, }) => {
485
+ const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
486
+ const { column } = cell;
487
+ if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
488
+ table.setEditingCell(cell);
489
+ queueMicrotask(() => {
490
+ var _a, _b;
491
+ const textField = (_a = editInputRefs.current) === null || _a === void 0 ? void 0 : _a[column.id];
492
+ if (textField) {
493
+ textField.focus();
494
+ (_b = textField.select) === null || _b === void 0 ? void 0 : _b.call(textField);
495
+ }
496
+ });
497
+ }
498
+ };
499
+ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
500
+ var _a, _b, _c, _d, _e, _f, _g, _h;
501
+ if (!table.options.enableKeyboardShortcuts)
502
+ return;
503
+ if (event.isPropagationStopped())
504
+ return;
505
+ const currentCell = event.currentTarget;
506
+ if (cellValue && isWinCtrlMacMeta(event) && event.key === 'c') {
507
+ navigator.clipboard.writeText(cellValue);
508
+ }
509
+ else if ([' ', 'Enter'].includes(event.key)) {
510
+ if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
511
+ event.preventDefault();
512
+ getMRT_RowSelectionHandler({
513
+ row: cell.row,
514
+ //@ts-expect-error
515
+ staticRowIndex: +event.target.getAttribute('data-index'),
516
+ table,
517
+ })(event);
518
+ }
519
+ else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
520
+ table.options.enableSelectAll) {
521
+ event.preventDefault();
522
+ getMRT_SelectAllHandler({
523
+ table,
524
+ })(event);
525
+ }
526
+ else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
527
+ (cell.row.getCanExpand() ||
528
+ ((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
529
+ event.preventDefault();
530
+ cell.row.toggleExpanded();
531
+ }
532
+ else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
533
+ table.options.enableExpandAll) {
534
+ event.preventDefault();
535
+ table.toggleAllRowsExpanded();
536
+ }
537
+ else if ((cell === null || cell === void 0 ? void 0 : cell.column.id) === 'mrt-row-pin') {
538
+ event.preventDefault();
539
+ cell.row.getIsPinned()
540
+ ? cell.row.pin(false)
541
+ : cell.row.pin(((_g = table.options.rowPinningDisplayMode) === null || _g === void 0 ? void 0 : _g.includes('bottom'))
542
+ ? 'bottom'
543
+ : 'top');
544
+ }
545
+ else if (header && isWinCtrlMacMeta(event)) {
546
+ const actionsButton = currentCell.querySelector(`button[aria-label="${table.options.localization.columnActions}"]`);
547
+ if (actionsButton) {
548
+ actionsButton.click();
549
+ }
550
+ }
551
+ else if ((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.getCanSort()) {
552
+ event.preventDefault();
553
+ header.column.toggleSorting();
554
+ }
555
+ }
556
+ else if ([
557
+ 'ArrowDown',
558
+ 'ArrowLeft',
559
+ 'ArrowRight',
560
+ 'ArrowUp',
561
+ 'End',
562
+ 'Home',
563
+ 'PageDown',
564
+ 'PageUp',
565
+ ].includes(event.key)) {
566
+ event.preventDefault();
567
+ const currentRow = parentElement || currentCell.closest('tr');
568
+ const tableElement = containerElement || currentCell.closest('table');
569
+ const allCells = cellElements ||
570
+ Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
571
+ const currentCellIndex = allCells.indexOf(currentCell);
572
+ const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
573
+ let nextCell = undefined;
574
+ //home/end first or last cell in row
575
+ const findEdgeCell = (rowIndex, edge) => {
576
+ var _a;
577
+ const row = rowIndex === 'c'
578
+ ? currentRow
579
+ : rowIndex === 'f'
580
+ ? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
581
+ : (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
582
+ const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
583
+ const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
584
+ return targetCell;
585
+ };
586
+ //page up/down first or last cell in column
587
+ const findBottomTopCell = (columnIndex, edge) => {
588
+ var _a;
589
+ const row = edge === 't'
590
+ ? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
591
+ : (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
592
+ const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
593
+ const targetCell = rowCells[columnIndex];
594
+ return targetCell;
595
+ };
596
+ const findAdjacentCell = (columnIndex, searchDirection) => {
597
+ const searchArray = searchDirection === 'f'
598
+ ? allCells.slice(currentCellIndex + 1)
599
+ : allCells.slice(0, currentCellIndex).reverse();
600
+ return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
601
+ };
602
+ switch (event.key) {
603
+ case 'ArrowDown':
604
+ nextCell = findAdjacentCell(currentIndex, 'f');
605
+ break;
606
+ case 'ArrowLeft':
607
+ nextCell = findAdjacentCell(currentIndex - 1, 'b');
608
+ break;
609
+ case 'ArrowRight':
610
+ nextCell = findAdjacentCell(currentIndex + 1, 'f');
611
+ break;
612
+ case 'ArrowUp':
613
+ nextCell = findAdjacentCell(currentIndex, 'b');
614
+ break;
615
+ case 'End':
616
+ nextCell = findEdgeCell(isWinCtrlMacMeta(event) ? 'l' : 'c', 'l');
617
+ break;
618
+ case 'Home':
619
+ nextCell = findEdgeCell(isWinCtrlMacMeta(event) ? 'f' : 'c', 'f');
620
+ break;
621
+ case 'PageDown':
622
+ nextCell = findBottomTopCell(currentIndex, 'b');
623
+ break;
624
+ case 'PageUp':
625
+ nextCell = findBottomTopCell(currentIndex, 't');
626
+ break;
627
+ }
628
+ if (nextCell) {
629
+ nextCell.focus();
630
+ }
631
+ }
632
+ };
633
+
634
+ const MRT_CopyButton = (_a) => {
635
+ var _b;
636
+ var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
637
+ const { options: { localization, muiCopyButtonProps }, } = table;
638
+ const { column, row } = cell;
639
+ const { columnDef } = column;
640
+ const [copied, setCopied] = useState(false);
641
+ const handleCopy = (event, text) => {
642
+ event.stopPropagation();
643
+ navigator.clipboard.writeText(text);
644
+ setCopied(true);
645
+ setTimeout(() => setCopied(false), 4000);
646
+ };
647
+ const buttonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCopyButtonProps, {
648
+ cell,
649
+ column,
650
+ row,
651
+ table,
652
+ })), parseFromValuesOrFunc(columnDef.muiCopyButtonProps, {
653
+ cell,
654
+ column,
655
+ row,
656
+ table,
657
+ })), rest);
658
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', py: 0, textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) })));
659
+ };
660
+
661
+ const getTextFieldSlotProps = (slotProps) => ({
662
+ formHelperText: slotProps === null || slotProps === void 0 ? void 0 : slotProps.formHelperText,
663
+ htmlInput: slotProps === null || slotProps === void 0 ? void 0 : slotProps.htmlInput,
664
+ input: slotProps === null || slotProps === void 0 ? void 0 : slotProps.input,
665
+ inputLabel: slotProps === null || slotProps === void 0 ? void 0 : slotProps.inputLabel,
666
+ select: slotProps === null || slotProps === void 0 ? void 0 : slotProps.select,
667
+ });
668
+
669
+ const MRT_EditCellTextField = (_a) => {
670
+ var _b, _c, _d;
671
+ var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
672
+ const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
673
+ const { column, row } = cell;
674
+ const { columnDef } = column;
675
+ const { creatingRow, editingRow } = getState();
676
+ const { editSelectOptions, editVariant } = columnDef;
677
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
678
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
679
+ const [value, setValue] = useState(() => cell.getValue());
680
+ const [completesComposition, setCompletesComposition] = useState(true);
681
+ const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
682
+ cell,
683
+ column,
684
+ row,
685
+ table,
686
+ })), parseFromValuesOrFunc(columnDef.muiEditTextFieldProps, {
687
+ cell,
688
+ column,
689
+ row,
690
+ table,
691
+ })), rest);
692
+ const selectOptions = parseFromValuesOrFunc(editSelectOptions, {
693
+ cell,
694
+ column,
695
+ row,
696
+ table,
697
+ });
698
+ const isSelectEdit = editVariant === 'select' || (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select);
699
+ const saveInputValueToRowCache = (newValue) => {
700
+ //@ts-expect-error
701
+ row._valuesCache[column.id] = newValue;
702
+ if (isCreating) {
703
+ setCreatingRow(row);
704
+ }
705
+ else if (isEditing) {
706
+ setEditingRow(row);
707
+ }
708
+ };
709
+ const handleChange = (event) => {
710
+ var _a;
711
+ (_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
712
+ setValue(event.target.value);
713
+ if (isSelectEdit) {
714
+ saveInputValueToRowCache(event.target.value);
715
+ }
716
+ };
717
+ const handleBlur = (event) => {
718
+ var _a;
719
+ (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
720
+ saveInputValueToRowCache(value);
721
+ setEditingCell(null);
722
+ };
723
+ const handleEnterKeyDown = (event) => {
724
+ var _a, _b, _c;
725
+ (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
726
+ if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
727
+ (_c = (_b = editInputRefs.current) === null || _b === void 0 ? void 0 : _b[column.id]) === null || _c === void 0 ? void 0 : _c.blur();
728
+ }
729
+ };
730
+ if (columnDef.Edit) {
731
+ return jsx(Fragment, { children: (_b = columnDef.Edit) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table }) });
732
+ }
733
+ const consumerSlots = getTextFieldSlotProps(textFieldProps.slotProps);
734
+ return (jsx(TextField, Object.assign({ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false, fullWidth: true, inputRef: (inputRef) => {
735
+ if (inputRef) {
736
+ editInputRefs.current[column.id] = isSelectEdit
737
+ ? inputRef.node
738
+ : inputRef;
739
+ if (textFieldProps.inputRef) {
740
+ textFieldProps.inputRef = inputRef;
741
+ }
742
+ }
743
+ }, label: ['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
744
+ ? columnDef.header
745
+ : undefined, margin: "none", name: column.id, placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
746
+ ? columnDef.header
747
+ : undefined, select: isSelectEdit, size: "small", value: value !== null && value !== void 0 ? value : '', variant: "standard" }, textFieldProps, { onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
748
+ var _a;
749
+ e.stopPropagation();
750
+ (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
751
+ }, onCompositionEnd: () => setCompletesComposition(true), onCompositionStart: () => setCompletesComposition(false), onKeyDown: handleEnterKeyDown, slotProps: {
752
+ htmlInput: Object.assign({ autoComplete: 'off' }, consumerSlots.htmlInput),
753
+ input: Object.assign(Object.assign(Object.assign({}, (textFieldProps.variant !== 'outlined'
754
+ ? { disableUnderline: editDisplayMode === 'table' }
755
+ : {})), consumerSlots.input), { sx: Object.assign({ mb: 0 }, (_c = consumerSlots.input) === null || _c === void 0 ? void 0 : _c.sx) }),
756
+ select: Object.assign({ MenuProps: { disableScrollLock: true } }, consumerSlots.select),
757
+ }, children: (_d = textFieldProps.children) !== null && _d !== void 0 ? _d : selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.map((option) => {
758
+ const { label, value } = getValueAndLabel(option);
759
+ return (jsx(MenuItem, { sx: {
760
+ alignItems: 'center',
761
+ display: 'flex',
762
+ gap: '0.5rem',
763
+ m: 0,
764
+ }, value: value, children: label }, value));
765
+ }) })));
766
+ };
767
+
768
+ const allowedTypes = ['string', 'number'];
769
+ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowIndex, table, }) => {
770
+ var _a, _b, _c;
771
+ const { getState, options: { enableFilterMatchHighlighting, mrtTheme: { matchHighlightColor }, }, } = table;
772
+ const { column, row } = cell;
773
+ const { columnDef } = column;
774
+ const { globalFilter, globalFilterFn } = getState();
775
+ const filterValue = column.getFilterValue();
776
+ let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
777
+ ? columnDef.AggregatedCell({
778
+ cell,
779
+ column,
780
+ row,
781
+ staticColumnIndex,
782
+ staticRowIndex,
783
+ table,
784
+ })
785
+ : row.getIsGrouped() && !cell.getIsGrouped()
786
+ ? null
787
+ : cell.getIsGrouped() && columnDef.GroupedCell
788
+ ? columnDef.GroupedCell({
789
+ cell,
790
+ column,
791
+ row,
792
+ staticColumnIndex,
793
+ staticRowIndex,
794
+ table,
795
+ })
796
+ : undefined;
797
+ const isGroupedValue = renderedCellValue !== undefined;
798
+ if (!isGroupedValue) {
799
+ renderedCellValue = cell.renderValue();
800
+ }
801
+ if (enableFilterMatchHighlighting &&
802
+ columnDef.enableFilterMatchHighlighting !== false &&
803
+ String(renderedCellValue) &&
804
+ allowedTypes.includes(typeof renderedCellValue) &&
805
+ ((filterValue &&
806
+ allowedTypes.includes(typeof filterValue) &&
807
+ ['autocomplete', 'text'].includes(columnDef.filterVariant)) ||
808
+ (globalFilter &&
809
+ allowedTypes.includes(typeof globalFilter) &&
810
+ column.getCanGlobalFilter()))) {
811
+ const chunks = highlightWords === null || highlightWords === void 0 ? void 0 : highlightWords({
812
+ matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
813
+ query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
814
+ text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
815
+ });
816
+ if ((chunks === null || chunks === void 0 ? void 0 : chunks.length) > 1 || ((_b = chunks === null || chunks === void 0 ? void 0 : chunks[0]) === null || _b === void 0 ? void 0 : _b.match)) {
817
+ renderedCellValue = (jsx("span", { "aria-label": renderedCellValue, role: "note", children: (_c = chunks === null || chunks === void 0 ? void 0 : chunks.map(({ key, match, text }) => (jsx(Box, { "aria-hidden": "true", component: "span", sx: match
818
+ ? {
819
+ backgroundColor: matchHighlightColor,
820
+ borderRadius: '2px',
821
+ color: (theme) => theme.palette.mode === 'dark'
822
+ ? theme.palette.common.white
823
+ : theme.palette.common.black,
824
+ padding: '2px 1px',
825
+ }
826
+ : undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
827
+ }
828
+ }
829
+ if (columnDef.Cell && !isGroupedValue) {
830
+ renderedCellValue = columnDef.Cell({
831
+ cell,
832
+ column,
833
+ renderedCellValue,
834
+ row,
835
+ rowRef,
836
+ staticColumnIndex,
837
+ staticRowIndex,
838
+ table,
839
+ });
840
+ }
841
+ return renderedCellValue;
842
+ };
843
+
844
+ const MRT_TableBodyCell = (_a) => {
845
+ var _b, _c, _d, _e, _f;
846
+ var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
847
+ const theme = useTheme();
848
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
849
+ const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
850
+ const { column, row } = cell;
851
+ const { columnDef } = column;
852
+ const { columnDefType } = columnDef;
853
+ const args = { cell, column, row, table };
854
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, args)), rest);
855
+ const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
856
+ cell,
857
+ column,
858
+ row,
859
+ table,
860
+ });
861
+ const [skeletonWidth, setSkeletonWidth] = useState(100);
862
+ useEffect(() => {
863
+ if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
864
+ return;
865
+ const size = column.getSize();
866
+ setSkeletonWidth(columnDefType === 'display'
867
+ ? size / 2
868
+ : Math.round(Math.random() * (size - size / 3) + size / 3));
869
+ }, [isLoading, showSkeletons]);
870
+ const draggingBorders = useMemo(() => {
871
+ const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
872
+ const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
873
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
874
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
875
+ const isFirstColumn = column.getIsFirstColumn();
876
+ const isLastColumn = column.getIsLastColumn();
877
+ const isLastRow = numRows && staticRowIndex === numRows - 1;
878
+ const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
879
+ const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
880
+ const borderStyle = showResizeBorder
881
+ ? `2px solid ${draggingBorderColor} !important`
882
+ : isDraggingColumn || isDraggingRow
883
+ ? `1px dashed ${theme.palette.grey[500]} !important`
884
+ : isHoveredColumn || isHoveredRow || isResizingColumn
885
+ ? `2px dashed ${draggingBorderColor} !important`
886
+ : undefined;
887
+ if (showResizeBorder) {
888
+ return columnResizeDirection === 'ltr'
889
+ ? { borderRight: borderStyle }
890
+ : { borderLeft: borderStyle };
891
+ }
892
+ return borderStyle
893
+ ? {
894
+ borderBottom: isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn)
895
+ ? borderStyle
896
+ : undefined,
897
+ borderLeft: isDraggingColumn ||
898
+ isHoveredColumn ||
899
+ ((isDraggingRow || isHoveredRow) && isFirstColumn)
900
+ ? borderStyle
901
+ : undefined,
902
+ borderRight: isDraggingColumn ||
903
+ isHoveredColumn ||
904
+ ((isDraggingRow || isHoveredRow) && isLastColumn)
905
+ ? borderStyle
906
+ : undefined,
907
+ borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
908
+ }
909
+ : undefined;
910
+ }, [
911
+ columnSizingInfo.isResizingColumn,
912
+ draggingColumn,
913
+ draggingRow,
914
+ hoveredColumn,
915
+ hoveredRow,
916
+ staticRowIndex,
917
+ ]);
918
+ const isColumnPinned = enableColumnPinning &&
919
+ columnDef.columnDefType !== 'group' &&
920
+ column.getIsPinned();
921
+ const isEditable = isCellEditable({ cell, table });
922
+ const isEditing = isEditable &&
923
+ !['custom', 'modal'].includes(editDisplayMode) &&
924
+ (editDisplayMode === 'table' ||
925
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
926
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
927
+ !row.getIsGrouped();
928
+ const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
929
+ const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
930
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
931
+ !['context-menu', false].includes(
932
+ // @ts-expect-error
933
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell));
934
+ const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
935
+ const cellValueProps = {
936
+ cell,
937
+ staticColumnIndex,
938
+ staticRowIndex,
939
+ table,
940
+ };
941
+ const handleDoubleClick = (event) => {
942
+ var _a;
943
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
944
+ openEditingCell({ cell, table });
945
+ };
946
+ const handleDragEnter = (e) => {
947
+ var _a;
948
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
949
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
950
+ setHoveredColumn(null);
951
+ }
952
+ if (enableColumnOrdering && draggingColumn) {
953
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
954
+ }
955
+ };
956
+ const handleDragOver = (e) => {
957
+ if (columnDef.enableColumnOrdering !== false) {
958
+ e.preventDefault();
959
+ }
960
+ };
961
+ const handleContextMenu = (e) => {
962
+ var _a;
963
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onContextMenu) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
964
+ if (isRightClickable) {
965
+ e.preventDefault();
966
+ table.setActionCell(cell);
967
+ table.refs.actionCellRef.current = e.currentTarget;
968
+ }
969
+ };
970
+ const handleKeyDown = (event) => {
971
+ var _a;
972
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
973
+ cellKeyboardShortcuts({
974
+ cell,
975
+ cellValue: cell.getValue(),
976
+ event,
977
+ table,
978
+ });
979
+ };
980
+ return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
981
+ outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
982
+ (editDisplayMode === 'cell' && isEditable) ||
983
+ (editDisplayMode === 'table' && (isCreating || isEditing))
984
+ ? `1px solid ${theme.palette.grey[500]}`
985
+ : undefined,
986
+ textOverflow: 'clip',
987
+ }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isRightClickable
988
+ ? 'context-menu'
989
+ : isEditable && editDisplayMode === 'cell'
990
+ ? 'pointer'
991
+ : 'inherit', outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id
992
+ ? `1px solid ${theme.palette.grey[500]}`
993
+ : undefined, outlineOffset: '-1px', overflow: 'hidden', p: density === 'compact'
994
+ ? columnDefType === 'display'
995
+ ? '0 0.5rem'
996
+ : '0.5rem'
997
+ : density === 'comfortable'
998
+ ? columnDefType === 'display'
999
+ ? '0.5rem 0.75rem'
1000
+ : '1rem'
1001
+ : columnDefType === 'display'
1002
+ ? '1rem 1.25rem'
1003
+ : '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal' }, getCommonMRTCellStyles({
1004
+ column,
1005
+ table,
1006
+ tableCellProps,
1007
+ theme,
1008
+ })), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? (((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null)) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
1009
+ (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
1010
+ !row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
1011
+ cell,
1012
+ column,
1013
+ renderedCellValue: cell.renderValue(),
1014
+ row,
1015
+ rowRef,
1016
+ staticColumnIndex,
1017
+ staticRowIndex,
1018
+ table,
1019
+ })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : showClickToCopyButton && columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
1020
+ };
1021
+ const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
1022
+
1023
+ const MRT_TableDetailPanel = (_a) => {
1024
+ var { parentRowRef, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["parentRowRef", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
1025
+ const { getState, getVisibleLeafColumns, options: { layoutMode, mrtTheme: { baseBackgroundColor }, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel, }, } = table;
1026
+ const { isLoading } = getState();
1027
+ const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
1028
+ isDetailPanel: true,
1029
+ row,
1030
+ staticRowIndex,
1031
+ table,
1032
+ });
1033
+ const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiDetailPanelProps, {
1034
+ row,
1035
+ table,
1036
+ })), rest);
1037
+ const DetailPanel = !isLoading && (renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
1038
+ return (jsx(TableRow, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", "data-index": renderDetailPanel ? staticRowIndex * 2 + 1 : staticRowIndex, ref: (node) => {
1039
+ var _a;
1040
+ if (node) {
1041
+ (_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
1042
+ }
1043
+ } }, tableRowProps, { sx: (theme) => {
1044
+ var _a, _b;
1045
+ return (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: virtualRow ? 'absolute' : undefined, top: virtualRow
1046
+ ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
1047
+ : undefined, transform: virtualRow
1048
+ ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
1049
+ : undefined, width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme)));
1050
+ }, children: jsx(TableCell, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow ? baseBackgroundColor : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: !!DetailPanel && row.getIsExpanded() ? '1rem' : 0, transition: !virtualRow ? 'all 150ms ease-in-out' : undefined, width: `100%` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: virtualRow ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: DetailPanel })) })) })));
1051
+ };
1052
+
1053
+ const MRT_TableBodyRow = (_a) => {
1054
+ var _b, _c, _d, _f;
1055
+ var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
1056
+ const theme = useTheme();
1057
+ const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
1058
+ const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
1059
+ const visibleCells = row.getVisibleCells();
1060
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
1061
+ const isRowSelected = getIsRowSelected({ row, table });
1062
+ const isRowPinned = enableRowPinning && row.getIsPinned();
1063
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
1064
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
1065
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyRowProps, {
1066
+ row,
1067
+ staticRowIndex,
1068
+ table,
1069
+ })), rest);
1070
+ const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
1071
+ if (!enableRowPinning ||
1072
+ !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) ||
1073
+ !pinnedRowIds ||
1074
+ !row.getIsPinned())
1075
+ return [];
1076
+ return [
1077
+ [...pinnedRowIds].reverse().indexOf(row.id),
1078
+ pinnedRowIds.indexOf(row.id),
1079
+ ];
1080
+ }, [pinnedRowIds, rowPinning]);
1081
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
1082
+ ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
1083
+ 0;
1084
+ const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
1085
+ const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
1086
+ const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
1087
+ const customRowHeight =
1088
+ // @ts-expect-error
1089
+ parseInt((_f = (_d = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _d === void 0 ? void 0 : _d.height) !== null && _f !== void 0 ? _f : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
1090
+ const rowHeight = customRowHeight || defaultRowHeight;
1091
+ const handleDragEnter = (_e) => {
1092
+ if (enableRowOrdering && draggingRow) {
1093
+ setHoveredRow(row);
1094
+ }
1095
+ };
1096
+ const handleDragOver = (e) => {
1097
+ e.preventDefault();
1098
+ };
1099
+ const rowRef = useRef(null);
1100
+ const cellHighlightColor = isRowSelected
1101
+ ? selectedRowBackgroundColor
1102
+ : isRowPinned
1103
+ ? pinnedRowBackgroundColor
1104
+ : undefined;
1105
+ const cellHighlightColorHover = (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
1106
+ ? isRowSelected
1107
+ ? cellHighlightColor
1108
+ : theme.palette.mode === 'dark'
1109
+ ? `${lighten(baseBackgroundColor, 0.3)}`
1110
+ : `${darken(baseBackgroundColor, 0.3)}`
1111
+ : undefined;
1112
+ return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": renderDetailPanel ? staticRowIndex * 2 : staticRowIndex, "data-pinned": !!isRowPinned || undefined, "data-selected": isRowSelected || undefined, onDragEnter: handleDragEnter, onDragOver: handleDragOver, ref: (node) => {
1113
+ if (node) {
1114
+ rowRef.current = node;
1115
+ rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement(node);
1116
+ }
1117
+ }, selected: isRowSelected }, tableRowProps, { style: Object.assign({ transform: virtualRow
1118
+ ? `translateY(${virtualRow.start}px)`
1119
+ : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), sx: (theme) => (Object.assign({ '&:hover td:after': cellHighlightColorHover
1120
+ ? Object.assign({ backgroundColor: alpha(cellHighlightColorHover, 0.3) }, commonCellBeforeAfterStyles) : undefined, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
1121
+ ? `${bottomPinnedIndex * rowHeight +
1122
+ (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
1123
+ : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
1124
+ ? 'absolute'
1125
+ : (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned
1126
+ ? 'sticky'
1127
+ : 'relative', td: Object.assign({}, getCommonPinnedCellStyles({ table, theme })), 'td:after': cellHighlightColor
1128
+ ? Object.assign({ backgroundColor: cellHighlightColor }, commonCellBeforeAfterStyles) : undefined, top: virtualRow
1129
+ ? 0
1130
+ : topPinnedIndex !== undefined && isRowPinned
1131
+ ? `${topPinnedIndex * rowHeight +
1132
+ (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
1133
+ : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned ? 2 : 0 }, sx)), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : visibleCells).map((cellOrVirtualCell, staticColumnIndex) => {
1134
+ let cell = cellOrVirtualCell;
1135
+ if (columnVirtualizer) {
1136
+ staticColumnIndex = cellOrVirtualCell.index;
1137
+ cell = visibleCells[staticColumnIndex];
1138
+ }
1139
+ const props = {
1140
+ cell,
1141
+ numRows,
1142
+ rowRef,
1143
+ staticColumnIndex,
1144
+ staticRowIndex,
1145
+ table,
1146
+ };
1147
+ const key = `${cell.id}-${staticRowIndex}`;
1148
+ return cell ? (memoMode === 'cells' &&
1149
+ cell.column.columnDef.columnDefType === 'data' &&
1150
+ !draggingColumn &&
1151
+ !draggingRow &&
1152
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
1153
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
1154
+ }), virtualPaddingRight ? (jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
1155
+ };
1156
+ const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
1157
+
1158
+ const MRT_TableBody = (_a) => {
1159
+ var _b, _c, _d, _e, _f, _g;
1160
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
1161
+ const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
1162
+ const { columnFilters, globalFilter, isFullScreen, rowPinning } = getState();
1163
+ const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
1164
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
1165
+ ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
1166
+ 0;
1167
+ const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
1168
+ const pinnedRowIds = useMemo(() => {
1169
+ var _a, _b;
1170
+ if (!((_a = rowPinning.bottom) === null || _a === void 0 ? void 0 : _a.length) && !((_b = rowPinning.top) === null || _b === void 0 ? void 0 : _b.length))
1171
+ return [];
1172
+ return getRowModel()
1173
+ .rows.filter((row) => row.getIsPinned())
1174
+ .map((r) => r.id);
1175
+ }, [rowPinning, getRowModel().rows]);
1176
+ const rows = useMRT_Rows(table);
1177
+ const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
1178
+ const { virtualRows } = rowVirtualizer !== null && rowVirtualizer !== void 0 ? rowVirtualizer : {};
1179
+ const commonRowProps = {
1180
+ columnVirtualizer,
1181
+ numRows: rows.length,
1182
+ table,
1183
+ };
1184
+ return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
1185
+ getIsSomeRowsPinned('top') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, staticRowIndex) => {
1186
+ const props = Object.assign(Object.assign({}, commonRowProps), { row,
1187
+ staticRowIndex });
1188
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
1189
+ }) }))), jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
1190
+ ? `${rowVirtualizer.getTotalSize()}px`
1191
+ : undefined, minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: (_d = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _d !== void 0 ? _d : (!rows.length ? (jsx("tr", { style: {
1192
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
1193
+ }, children: jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
1194
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
1195
+ }, children: (_e = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _e !== void 0 ? _e : (jsx(Typography, { sx: {
1196
+ color: 'text.secondary',
1197
+ fontStyle: 'italic',
1198
+ maxWidth: `min(100vw, ${((_f = tablePaperRef.current) === null || _f === void 0 ? void 0 : _f.clientWidth) ? ((_g = tablePaperRef.current) === null || _g === void 0 ? void 0 : _g.clientWidth) + "px" : "100%"})`,
1199
+ py: '2rem',
1200
+ textAlign: 'center',
1201
+ width: '100%',
1202
+ }, children: globalFilter || columnFilters.length
1203
+ ? localization.noResultsFound
1204
+ : localization.noRecordsToDisplay })) }) })) : (jsx(Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, staticRowIndex) => {
1205
+ let row = rowOrVirtualRow;
1206
+ if (rowVirtualizer) {
1207
+ if (renderDetailPanel) {
1208
+ if (rowOrVirtualRow.index % 2 === 1) {
1209
+ return null;
1210
+ }
1211
+ else {
1212
+ staticRowIndex = rowOrVirtualRow.index / 2;
1213
+ }
1214
+ }
1215
+ else {
1216
+ staticRowIndex = rowOrVirtualRow.index;
1217
+ }
1218
+ row = rows[staticRowIndex];
1219
+ }
1220
+ const props = Object.assign(Object.assign({}, commonRowProps), { pinnedRowIds,
1221
+ row,
1222
+ rowVirtualizer,
1223
+ staticRowIndex, virtualRow: rowVirtualizer
1224
+ ? rowOrVirtualRow
1225
+ : undefined });
1226
+ const key = `${row.id}-${row.index}`;
1227
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
1228
+ }) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
1229
+ getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, staticRowIndex) => {
1230
+ const props = Object.assign(Object.assign({}, commonRowProps), { row,
1231
+ staticRowIndex });
1232
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
1233
+ }) })))] }));
1234
+ };
1235
+ const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
1236
+
1237
+ const MRT_GrabHandleButton = (_a) => {
1238
+ var _b, _c;
1239
+ var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
1240
+ const { options: { icons: { DragHandleIcon }, localization, }, } = table;
1241
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, rest, { onClick: (e) => {
1242
+ var _a;
1243
+ e.stopPropagation();
1244
+ (_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
1245
+ }, sx: (theme) => (Object.assign({ '&:active': {
1246
+ cursor: 'grabbing',
1247
+ }, '&:hover': {
1248
+ backgroundColor: 'transparent',
1249
+ opacity: 1,
1250
+ }, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.5, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) })));
1251
+ };
1252
+
1253
+ const MRT_TableBodyRowGrabHandle = (_a) => {
1254
+ var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
1255
+ const { options: { muiRowDragHandleProps }, } = table;
1256
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
1257
+ row,
1258
+ table,
1259
+ })), rest);
1260
+ const handleDragStart = (event) => {
1261
+ var _a;
1262
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1263
+ try {
1264
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
1265
+ }
1266
+ catch (e) {
1267
+ console.error(e);
1268
+ }
1269
+ table.setDraggingRow(row);
1270
+ };
1271
+ const handleDragEnd = (event) => {
1272
+ var _a;
1273
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1274
+ table.setDraggingRow(null);
1275
+ table.setHoveredRow(null);
1276
+ };
1277
+ return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
1278
+ };
1279
+
1280
+ const MRT_RowPinButton = (_a) => {
1281
+ var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
1282
+ const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
1283
+ const isPinned = row.getIsPinned();
1284
+ const [tooltipOpened, setTooltipOpened] = useState(false);
1285
+ const handleTogglePin = (event) => {
1286
+ setTooltipOpened(false);
1287
+ event.stopPropagation();
1288
+ row.pin(isPinned ? false : pinningPosition);
1289
+ };
1290
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, Object.assign({ "aria-label": localization.pin, onBlur: () => setTooltipOpened(false), onClick: handleTogglePin, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '24px', width: '24px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: isPinned ? (jsx(CloseIcon, {})) : (jsx(PushPinIcon, { fontSize: "small", style: {
1291
+ transform: `rotate(${rowPinningDisplayMode === 'sticky'
1292
+ ? 135
1293
+ : pinningPosition === 'top'
1294
+ ? 180
1295
+ : 0}deg)`,
1296
+ } })) })) })));
1297
+ };
1298
+
1299
+ const MRT_TableBodyRowPinButton = (_a) => {
1300
+ var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
1301
+ const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
1302
+ const { density } = getState();
1303
+ const canPin = parseFromValuesOrFunc(enableRowPinning, row);
1304
+ if (!canPin)
1305
+ return null;
1306
+ const rowPinButtonProps = Object.assign({ row,
1307
+ table }, rest);
1308
+ if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
1309
+ return (jsxs(Box, { sx: {
1310
+ display: 'flex',
1311
+ flexDirection: density === 'compact' ? 'row' : 'column',
1312
+ }, children: [jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
1313
+ }
1314
+ return (jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
1315
+ };
1316
+
1317
+ const MRT_ColumnPinningButtons = (_a) => {
1318
+ var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
1319
+ const { options: { icons: { PushPinIcon }, localization, }, } = table;
1320
+ const handlePinColumn = (pinDirection) => {
1321
+ column.pin(pinDirection);
1322
+ };
1323
+ return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ minWidth: '70px', textAlign: 'center' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: column.getIsPinned() ? (jsx(Tooltip, { title: localization.unpin, children: jsx(IconButton, { onClick: () => handlePinColumn(false), size: "small", children: jsx(PushPinIcon, {}) }) })) : (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.pinToLeft, children: jsx(IconButton, { onClick: () => handlePinColumn('left'), size: "small", children: jsx(PushPinIcon, { style: {
1324
+ transform: 'rotate(90deg)',
1325
+ } }) }) }), jsx(Tooltip, { title: localization.pinToRight, children: jsx(IconButton, { onClick: () => handlePinColumn('right'), size: "small", children: jsx(PushPinIcon, { style: {
1326
+ transform: 'rotate(-90deg)',
1327
+ } }) }) })] })) })));
1328
+ };
1329
+
1330
+ const MRT_EditActionButtons = (_a) => {
1331
+ var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
1332
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
1333
+ const { creatingRow, editingRow, isSaving } = getState();
1334
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1335
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
1336
+ const handleCancel = () => {
1337
+ if (isCreating) {
1338
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
1339
+ setCreatingRow(null);
1340
+ }
1341
+ else if (isEditing) {
1342
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
1343
+ setEditingRow(null);
1344
+ }
1345
+ row._valuesCache = {}; //reset values cache
1346
+ };
1347
+ const handleSubmitRow = () => {
1348
+ var _a, _b;
1349
+ //look for auto-filled input values
1350
+ (_b = Object.values((_a = editInputRefs.current) !== null && _a !== void 0 ? _a : {})
1351
+ .filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _b === void 0 ? void 0 : _b.forEach((input) => {
1352
+ if (input.value !== undefined &&
1353
+ Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
1354
+ // @ts-expect-error
1355
+ row._valuesCache[input.name] = input.value;
1356
+ }
1357
+ });
1358
+ if (isCreating)
1359
+ onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
1360
+ exitCreatingMode: () => setCreatingRow(null),
1361
+ row,
1362
+ table,
1363
+ values: row._valuesCache,
1364
+ });
1365
+ else if (isEditing) {
1366
+ onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
1367
+ exitEditingMode: () => setEditingRow(null),
1368
+ row,
1369
+ table,
1370
+ values: row === null || row === void 0 ? void 0 : row._valuesCache,
1371
+ });
1372
+ }
1373
+ };
1374
+ return (jsx(Box, { onClick: (e) => e.stopPropagation(), sx: (theme) => (Object.assign({ display: 'flex', gap: '0.75rem' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: variant === 'icon' ? (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.cancel, children: jsx(IconButton, { "aria-label": localization.cancel, onClick: handleCancel, children: jsx(CancelIcon, {}) }) }), ((isCreating && onCreatingRowSave) ||
1375
+ (isEditing && onEditingRowSave)) && (jsx(Tooltip, { title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", disabled: isSaving, onClick: handleSubmitRow, children: isSaving ? jsx(CircularProgress, { size: 18 }) : jsx(SaveIcon, {}) }) }))] })) : (jsxs(Fragment, { children: [jsx(Button, { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxs(Button, { disabled: isSaving, onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
1376
+ };
1377
+
1378
+ const MRT_ExpandAllButton = (_a) => {
1379
+ var _b, _c;
1380
+ var { table } = _a, rest = __rest(_a, ["table"]);
1381
+ const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1382
+ const { density, isLoading } = getState();
1383
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
1384
+ table,
1385
+ })), rest);
1386
+ const isAllRowsExpanded = getIsAllRowsExpanded();
1387
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : (isAllRowsExpanded ? localization.collapseAll : localization.expandAll), children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsx(KeyboardDoubleArrowDownIcon, { style: {
1388
+ transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
1389
+ transition: 'transform 150ms',
1390
+ } })) })) }) })));
1391
+ };
1392
+
1393
+ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1394
+ var _a, _b;
1395
+ const theme = useTheme();
1396
+ const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
1397
+ const { density } = getState();
1398
+ const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
1399
+ row,
1400
+ staticRowIndex,
1401
+ table,
1402
+ });
1403
+ const canExpand = row.getCanExpand();
1404
+ const isExpanded = row.getIsExpanded();
1405
+ const handleToggleExpand = (event) => {
1406
+ var _a;
1407
+ event.stopPropagation();
1408
+ row.toggleExpanded();
1409
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1410
+ };
1411
+ const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
1412
+ return (jsx(Tooltip, Object.assign({ disableHoverListener: !canExpand && !detailPanel }, getCommonTooltipProps(), { title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : (isExpanded ? localization.collapse : localization.expand), children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !detailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', opacity: !canExpand && !detailPanel ? 0.3 : 1, [theme.direction === 'rtl' || positionExpandColumn === 'last'
1413
+ ? 'mr'
1414
+ : 'ml']: `${row.depth * 16}px`, width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsx(ExpandMoreIcon, { style: {
1415
+ transform: `rotate(${!canExpand && !renderDetailPanel
1416
+ ? positionExpandColumn === 'last' ||
1417
+ theme.direction === 'rtl'
1418
+ ? 90
1419
+ : -90
1420
+ : isExpanded
1421
+ ? -180
1422
+ : 0}deg)`,
1423
+ transition: 'transform 150ms',
1424
+ } })) })) }) })));
1425
+ };
1426
+
1427
+ const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
1428
+ const getAllLeafColumnDefs = (columns) => {
1429
+ const allLeafColumnDefs = [];
1430
+ const getLeafColumns = (cols) => {
1431
+ cols.forEach((col) => {
1432
+ if (col.columns) {
1433
+ getLeafColumns(col.columns);
1434
+ }
1435
+ else {
1436
+ allLeafColumnDefs.push(col);
1437
+ }
1438
+ });
1439
+ };
1440
+ getLeafColumns(columns);
1441
+ return allLeafColumnDefs;
1442
+ };
1443
+ const prepareColumns = ({ columnDefs, tableOptions, }) => {
1444
+ const { aggregationFns = {}, defaultDisplayColumn, filterFns = {}, sortingFns = {}, state: { columnFilterFns = {} } = {}, } = tableOptions;
1445
+ return columnDefs.map((columnDef) => {
1446
+ var _a, _b;
1447
+ //assign columnId
1448
+ if (!columnDef.id)
1449
+ columnDef.id = getColumnId(columnDef);
1450
+ //assign columnDefType
1451
+ if (!columnDef.columnDefType)
1452
+ columnDef.columnDefType = 'data';
1453
+ if ((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length) {
1454
+ columnDef.columnDefType = 'group';
1455
+ //recursively prepare columns if this is a group column
1456
+ columnDef.columns = prepareColumns({
1457
+ columnDefs: columnDef.columns,
1458
+ tableOptions,
1459
+ });
1460
+ }
1461
+ else if (columnDef.columnDefType === 'data') {
1462
+ //assign aggregationFns if multiple aggregationFns are provided
1463
+ if (Array.isArray(columnDef.aggregationFn)) {
1464
+ const aggFns = columnDef.aggregationFn;
1465
+ columnDef.aggregationFn = (columnId, leafRows, childRows) => aggFns.map((fn) => { var _a; return (_a = aggregationFns[fn]) === null || _a === void 0 ? void 0 : _a.call(aggregationFns, columnId, leafRows, childRows); });
1466
+ }
1467
+ //assign filterFns
1468
+ if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
1469
+ columnDef.filterFn =
1470
+ (_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
1471
+ columnDef._filterFn =
1472
+ columnFilterFns[columnDef.id];
1473
+ }
1474
+ //assign sortingFns
1475
+ if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
1476
+ // @ts-expect-error
1477
+ columnDef.sortingFn = sortingFns[columnDef.sortingFn];
1478
+ }
1479
+ }
1480
+ else if (columnDef.columnDefType === 'display') {
1481
+ columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
1482
+ }
1483
+ return columnDef;
1484
+ });
1485
+ };
1486
+ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
1487
+ if (draggedColumn.getCanPin()) {
1488
+ draggedColumn.pin(targetColumn.getIsPinned());
1489
+ }
1490
+ const newColumnOrder = [...columnOrder];
1491
+ newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
1492
+ return newColumnOrder;
1493
+ };
1494
+ const getDefaultColumnFilterFn = (columnDef) => {
1495
+ const { filterVariant } = columnDef;
1496
+ if (filterVariant === 'multi-select')
1497
+ return 'arrIncludesSome';
1498
+ if (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range'))
1499
+ return 'betweenInclusive';
1500
+ if (filterVariant === 'select' || filterVariant === 'checkbox')
1501
+ return 'equals';
1502
+ return 'fuzzy';
1503
+ };
1504
+ const getColumnFilterInfo = ({ header, table, }) => {
1505
+ var _a;
1506
+ const { options: { columnFilterModeOptions }, } = table;
1507
+ const { column } = header;
1508
+ const { columnDef } = column;
1509
+ const { filterVariant } = columnDef;
1510
+ const isDateFilter = !!((filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) || (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')));
1511
+ const isAutocompleteFilter = filterVariant === 'autocomplete';
1512
+ const isRangeFilter = (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range')) ||
1513
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
1514
+ const isSelectFilter = filterVariant === 'select';
1515
+ const isMultiSelectFilter = filterVariant === 'multi-select';
1516
+ const isTextboxFilter = ['autocomplete', 'text'].includes(filterVariant) ||
1517
+ (!isSelectFilter && !isMultiSelectFilter);
1518
+ const currentFilterOption = columnDef._filterFn;
1519
+ const allowedColumnFilterOptions = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _a !== void 0 ? _a : columnFilterModeOptions;
1520
+ const facetedUniqueValues = column.getFacetedUniqueValues();
1521
+ return {
1522
+ allowedColumnFilterOptions,
1523
+ currentFilterOption,
1524
+ facetedUniqueValues,
1525
+ isAutocompleteFilter,
1526
+ isDateFilter,
1527
+ isMultiSelectFilter,
1528
+ isRangeFilter,
1529
+ isSelectFilter,
1530
+ isTextboxFilter,
1531
+ };
1532
+ };
1533
+ const useDropdownOptions = ({ header, table, }) => {
1534
+ const { column } = header;
1535
+ const { columnDef } = column;
1536
+ const { facetedUniqueValues, isAutocompleteFilter, isMultiSelectFilter, isSelectFilter, } = getColumnFilterInfo({ header, table });
1537
+ return useMemo(() => {
1538
+ var _a;
1539
+ return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter || isAutocompleteFilter) &&
1540
+ facetedUniqueValues
1541
+ ? Array.from(facetedUniqueValues.keys())
1542
+ .filter((value) => value !== null && value !== undefined)
1543
+ .sort((a, b) => a.localeCompare(b))
1544
+ : undefined);
1545
+ }, [
1546
+ columnDef.filterSelectOptions,
1547
+ facetedUniqueValues,
1548
+ isMultiSelectFilter,
1549
+ isSelectFilter,
1550
+ ]);
1551
+ };
1552
+
1553
+ function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
1554
+ const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
1555
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
1556
+ }
1557
+ const showRowPinningColumn = (tableOptions) => {
1558
+ const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
1559
+ return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
1560
+ };
1561
+ const showRowDragColumn = (tableOptions) => {
1562
+ const { enableRowDragging, enableRowOrdering } = tableOptions;
1563
+ return !!(enableRowDragging || enableRowOrdering);
1564
+ };
1565
+ const showRowExpandColumn = (tableOptions) => {
1566
+ const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
1567
+ return !!(enableExpanding ||
1568
+ (enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
1569
+ renderDetailPanel);
1570
+ };
1571
+ const showRowActionsColumn = (tableOptions) => {
1572
+ const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
1573
+ return !!(enableRowActions ||
1574
+ (creatingRow && createDisplayMode === 'row') ||
1575
+ (enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
1576
+ };
1577
+ const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
1578
+ const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
1579
+ const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
1580
+ const getLeadingDisplayColumnIds = (tableOptions) => [
1581
+ showRowPinningColumn(tableOptions) && 'mrt-row-pin',
1582
+ showRowDragColumn(tableOptions) && 'mrt-row-drag',
1583
+ tableOptions.positionActionsColumn === 'first' &&
1584
+ showRowActionsColumn(tableOptions) &&
1585
+ 'mrt-row-actions',
1586
+ tableOptions.positionExpandColumn === 'first' &&
1587
+ showRowExpandColumn(tableOptions) &&
1588
+ 'mrt-row-expand',
1589
+ showRowSelectionColumn(tableOptions) && 'mrt-row-select',
1590
+ showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
1591
+ ].filter(Boolean);
1592
+ const getTrailingDisplayColumnIds = (tableOptions) => [
1593
+ tableOptions.positionActionsColumn === 'last' &&
1594
+ showRowActionsColumn(tableOptions) &&
1595
+ 'mrt-row-actions',
1596
+ tableOptions.positionExpandColumn === 'last' &&
1597
+ showRowExpandColumn(tableOptions) &&
1598
+ 'mrt-row-expand',
1599
+ showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
1600
+ ].filter(Boolean);
1601
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
1602
+ const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
1603
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
1604
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
1605
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
1606
+ let allLeafColumnDefIds = reset
1607
+ ? defaultColumnDefIds
1608
+ : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
1609
+ allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
1610
+ !trailingDisplayColIds.includes(colId));
1611
+ return [
1612
+ ...leadingDisplayColIds,
1613
+ ...allLeafColumnDefIds,
1614
+ ...trailingDisplayColIds,
1615
+ ];
1616
+ };
1617
+
1618
+ const MRT_ShowHideColumnsMenuItems = (_a) => {
1619
+ var _b;
1620
+ var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
1621
+ const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, setColumnPinning, } = table;
1622
+ const { columnOrder } = getState();
1623
+ const { columnDef } = column;
1624
+ const { columnDefType } = columnDef;
1625
+ const switchChecked = column.getIsVisible();
1626
+ const handleToggleColumnHidden = (column) => {
1627
+ var _a, _b;
1628
+ if (columnDefType === 'group') {
1629
+ (_b = (_a = column === null || column === void 0 ? void 0 : column.columns) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (childColumn) => {
1630
+ childColumn.toggleVisibility(!switchChecked);
1631
+ });
1632
+ }
1633
+ else {
1634
+ column.toggleVisibility();
1635
+ }
1636
+ };
1637
+ const menuItemRef = useRef(null);
1638
+ const [isDragging, setIsDragging] = useState(false);
1639
+ const handleDragStart = (e) => {
1640
+ setIsDragging(true);
1641
+ try {
1642
+ e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
1643
+ }
1644
+ catch (e) {
1645
+ console.error(e);
1646
+ }
1647
+ };
1648
+ const handleDragEnd = (_e) => {
1649
+ setIsDragging(false);
1650
+ setHoveredColumn(null);
1651
+ if (hoveredColumn) {
1652
+ const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
1653
+ setColumnOrder(reorderedColumns);
1654
+ setColumnPinning(({ left = [], right = [] }) => ({
1655
+ left: reorderedColumns.filter((header) => left.includes(header)),
1656
+ right: reorderedColumns.filter((header) => right.includes(header)),
1657
+ }));
1658
+ }
1659
+ };
1660
+ const handleDragEnter = (_e) => {
1661
+ if (!isDragging && columnDef.enableColumnOrdering !== false) {
1662
+ setHoveredColumn(column);
1663
+ }
1664
+ };
1665
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
1666
+ return null;
1667
+ }
1668
+ return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging
1669
+ ? `2px dashed ${theme.palette.grey[500]}`
1670
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
1671
+ ? `2px dashed ${draggingBorderColor}`
1672
+ : 'none', outlineOffset: '-2px', pl: `${(column.depth + 0.5) * 2}rem`, py: '6px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsxs(Box, { sx: {
1673
+ display: 'flex',
1674
+ flexWrap: 'nowrap',
1675
+ gap: '8px',
1676
+ }, children: [columnDefType !== 'group' &&
1677
+ enableColumnOrdering &&
1678
+ !isNestedColumns &&
1679
+ (columnDef.enableColumnOrdering !== false ? (jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsx(Box, { sx: { width: '28px' } }))), enableColumnPinning &&
1680
+ (column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { sx: { width: '70px' } }))), enableHiding ? (jsx(FormControlLabel, { checked: switchChecked, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column), slotProps: {
1681
+ typography: {
1682
+ sx: {
1683
+ mb: 0,
1684
+ opacity: columnDefType !== 'display' ? 1 : 0.5,
1685
+ },
1686
+ },
1687
+ } })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
1688
+ };
1689
+
1690
+ const MRT_ShowHideColumnsMenu = (_a) => {
1691
+ var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
1692
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, initialState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
1693
+ const { columnOrder, columnPinning, density } = getState();
1694
+ const handleToggleAllColumns = (value) => {
1695
+ const updates = getAllLeafColumns()
1696
+ .filter((column) => column.columnDef.enableHiding !== false)
1697
+ .reduce((acc, column) => {
1698
+ acc[column.id] = value !== null && value !== void 0 ? value : !column.getIsVisible();
1699
+ return acc;
1700
+ }, {});
1701
+ table.setColumnVisibility((old) => (Object.assign(Object.assign({}, old), updates)));
1702
+ };
1703
+ const allColumns = useMemo(() => {
1704
+ const columns = getAllColumns();
1705
+ if (columnOrder.length > 0 &&
1706
+ !columns.some((col) => col.columnDef.columnDefType === 'group')) {
1707
+ return [
1708
+ ...getLeftLeafColumns(),
1709
+ ...Array.from(new Set(columnOrder)).map((colId) => getCenterLeafColumns().find((col) => (col === null || col === void 0 ? void 0 : col.id) === colId)),
1710
+ ...getRightLeafColumns(),
1711
+ ].filter(Boolean);
1712
+ }
1713
+ return columns;
1714
+ }, [
1715
+ columnOrder,
1716
+ columnPinning,
1717
+ getAllColumns(),
1718
+ getCenterLeafColumns(),
1719
+ getLeftLeafColumns(),
1720
+ getRightLeafColumns(),
1721
+ ]);
1722
+ const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === 'group');
1723
+ const hasColumnOrderChanged = useMemo(() => columnOrder.length !== initialState.columnOrder.length ||
1724
+ !columnOrder.every((column, index) => column === initialState.columnOrder[index]), [columnOrder, initialState.columnOrder]);
1725
+ const [hoveredColumn, setHoveredColumn] = useState(null);
1726
+ return (jsxs(Menu, Object.assign({ anchorEl: anchorEl, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl, slotProps: {
1727
+ list: {
1728
+ dense: density === 'compact',
1729
+ sx: {
1730
+ backgroundColor: menuBackgroundColor,
1731
+ },
1732
+ },
1733
+ } }, rest, { children: [jsxs(Box, { sx: {
1734
+ display: 'flex',
1735
+ justifyContent: 'space-between',
1736
+ p: '0.5rem',
1737
+ pt: 0,
1738
+ }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { disabled: !hasColumnOrderChanged, onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
1739
+ };
1740
+
1741
+ const MRT_ShowHideColumnsButton = (_a) => {
1742
+ var _b;
1743
+ var { table } = _a, rest = __rest(_a, ["table"]);
1744
+ const { options: { icons: { ViewColumnIcon }, localization, }, } = table;
1745
+ const [anchorEl, setAnchorEl] = useState(null);
1746
+ const handleClick = (event) => {
1747
+ setAnchorEl(event.currentTarget);
1748
+ };
1749
+ return (jsxs(Fragment, { children: [jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideColumns, children: jsx(IconButton, Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick }, rest, { title: undefined, children: jsx(ViewColumnIcon, {}) })) }), anchorEl && (jsx(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table }))] }));
1750
+ };
1751
+
1752
+ const MRT_ToggleDensePaddingButton = (_a) => {
1753
+ var _b;
1754
+ var { table } = _a, rest = __rest(_a, ["table"]);
1755
+ const { getState, options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, setDensity, } = table;
1756
+ const { density } = getState();
1757
+ const handleToggleDensePadding = () => {
1758
+ const nextDensity = density === 'comfortable'
1759
+ ? 'compact'
1760
+ : density === 'compact'
1761
+ ? 'spacious'
1762
+ : 'comfortable';
1763
+ setDensity(nextDensity);
1764
+ };
1765
+ return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleDensity, children: jsx(IconButton, Object.assign({ "aria-label": localization.toggleDensity, onClick: handleToggleDensePadding }, rest, { title: undefined, children: density === 'compact' ? (jsx(DensitySmallIcon, {})) : density === 'comfortable' ? (jsx(DensityMediumIcon, {})) : (jsx(DensityLargeIcon, {})) })) }));
1766
+ };
1767
+
1768
+ const MRT_ToggleFiltersButton = (_a) => {
1769
+ var _b;
1770
+ var { table } = _a, rest = __rest(_a, ["table"]);
1771
+ const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowColumnFilters, } = table;
1772
+ const { showColumnFilters } = getState();
1773
+ const handleToggleShowFilters = () => {
1774
+ setShowColumnFilters(!showColumnFilters);
1775
+ };
1776
+ return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideFilters, children: jsx(IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleShowFilters }, rest, { title: undefined, children: showColumnFilters ? jsx(FilterListOffIcon, {}) : jsx(FilterListIcon, {}) })) }));
1777
+ };
1778
+
1779
+ const MRT_ToggleFullScreenButton = (_a) => {
1780
+ var _b;
1781
+ var { table } = _a, rest = __rest(_a, ["table"]);
1782
+ const { getState, options: { icons: { FullscreenExitIcon, FullscreenIcon }, localization, }, setIsFullScreen, } = table;
1783
+ const { isFullScreen } = getState();
1784
+ const [tooltipOpened, setTooltipOpened] = useState(false);
1785
+ const handleToggleFullScreen = () => {
1786
+ setTooltipOpened(false);
1787
+ setIsFullScreen(!isFullScreen);
1788
+ };
1789
+ return (jsx(Tooltip, { open: tooltipOpened, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsx(IconButton, Object.assign({ "aria-label": localization.toggleFullScreen, onBlur: () => setTooltipOpened(false), onClick: handleToggleFullScreen, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsx(FullscreenExitIcon, {}) : jsx(FullscreenIcon, {}) })) }));
1790
+ };
1791
+
1792
+ const MRT_ToggleGlobalFilterButton = (_a) => {
1793
+ var _b, _c;
1794
+ var { table } = _a, rest = __rest(_a, ["table"]);
1795
+ const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
1796
+ const { globalFilter, showGlobalFilter } = getState();
1797
+ const handleToggleSearch = () => {
1798
+ setShowGlobalFilter(!showGlobalFilter);
1799
+ queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
1800
+ };
1801
+ return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter && showGlobalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }) }));
1802
+ };
1803
+
1804
+ const MRT_ActionMenuItem = (_a) => {
1805
+ var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
1806
+ const { options: { icons: { ArrowRightIcon }, }, } = table;
1807
+ return (jsxs(MenuItem, Object.assign({ sx: {
1808
+ alignItems: 'center',
1809
+ justifyContent: 'space-between',
1810
+ minWidth: '120px',
1811
+ my: 0,
1812
+ py: '6px',
1813
+ }, tabIndex: 0 }, rest, { children: [jsxs(Box, { sx: {
1814
+ alignItems: 'center',
1815
+ display: 'flex',
1816
+ }, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
1817
+ };
1818
+
1819
+ const MRT_RowActionMenu = (_a) => {
1820
+ var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
1821
+ const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
1822
+ const { density } = getState();
1823
+ const menuItems = useMemo(() => {
1824
+ const items = [];
1825
+ const editItem = parseFromValuesOrFunc(enableEditing, row) &&
1826
+ ['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }, 'edit'));
1827
+ if (editItem)
1828
+ items.push(editItem);
1829
+ const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
1830
+ closeMenu: () => setAnchorEl(null),
1831
+ row,
1832
+ staticRowIndex,
1833
+ table,
1834
+ });
1835
+ if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
1836
+ items.push(...rowActionMenuItems);
1837
+ return items;
1838
+ }, [renderRowActionMenuItems, row, staticRowIndex, table]);
1839
+ if (!menuItems.length)
1840
+ return null;
1841
+ return (jsx(Menu, Object.assign({ anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl, slotProps: {
1842
+ list: {
1843
+ dense: density === 'compact',
1844
+ sx: {
1845
+ backgroundColor: menuBackgroundColor,
1846
+ },
1847
+ },
1848
+ } }, rest, { children: menuItems })));
1849
+ };
1850
+
1851
+ const commonIconButtonStyles = {
1852
+ '&:hover': {
1853
+ opacity: 1,
1854
+ },
1855
+ height: '2rem',
1856
+ ml: '10px',
1857
+ opacity: 0.5,
1858
+ transition: 'opacity 150ms',
1859
+ width: '2rem',
1860
+ };
1861
+ const MRT_ToggleRowActionMenuButton = (_a) => {
1862
+ var _b;
1863
+ var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
1864
+ const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
1865
+ const { creatingRow, editingRow } = getState();
1866
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1867
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
1868
+ const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
1869
+ (isEditing && editDisplayMode === 'row');
1870
+ const [anchorEl, setAnchorEl] = useState(null);
1871
+ const handleOpenRowActionMenu = (event) => {
1872
+ event.stopPropagation();
1873
+ event.preventDefault();
1874
+ setAnchorEl(event.currentTarget);
1875
+ };
1876
+ const handleStartEditMode = (event) => {
1877
+ event.stopPropagation();
1878
+ setEditingRow(Object.assign({}, row));
1879
+ setAnchorEl(null);
1880
+ };
1881
+ return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
1882
+ parseFromValuesOrFunc(enableEditing, row) &&
1883
+ ['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
1884
+ row,
1885
+ staticRowIndex,
1886
+ table,
1887
+ })) === null || _b === void 0 ? void 0 : _b.length) ? (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsx(MoreHorizIcon, {}) })) })), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
1888
+ };
1889
+
1890
+ const MRT_TableFooterCell = (_a) => {
1891
+ var _b, _c, _d;
1892
+ var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
1893
+ const theme = useTheme();
1894
+ const { getState, options: { enableColumnPinning, enableKeyboardShortcuts, muiTableFooterCellProps, }, } = table;
1895
+ const { density } = getState();
1896
+ const { column } = footer;
1897
+ const { columnDef } = column;
1898
+ const { columnDefType } = columnDef;
1899
+ const isColumnPinned = enableColumnPinning &&
1900
+ columnDef.columnDefType !== 'group' &&
1901
+ column.getIsPinned();
1902
+ const args = { column, table };
1903
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
1904
+ const handleKeyDown = (event) => {
1905
+ var _a;
1906
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
1907
+ cellKeyboardShortcuts({
1908
+ cellValue: footer.column.columnDef.footer,
1909
+ event,
1910
+ table,
1911
+ });
1912
+ };
1913
+ return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
1914
+ ? 'center'
1915
+ : theme.direction === 'rtl'
1916
+ ? 'right'
1917
+ : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined, variant: "footer" }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
1918
+ ? '0.5rem'
1919
+ : density === 'comfortable'
1920
+ ? '1rem'
1921
+ : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
1922
+ column,
1923
+ header: footer,
1924
+ table,
1925
+ tableCellProps,
1926
+ theme,
1927
+ })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
1928
+ ? null
1929
+ : ((_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
1930
+ column,
1931
+ footer,
1932
+ table,
1933
+ })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null)) })));
1934
+ };
1935
+
1936
+ const MRT_TableFooterRow = (_a) => {
1937
+ var _b;
1938
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
1939
+ const { options: { layoutMode, mrtTheme: { baseBackgroundColor }, muiTableFooterRowProps, }, } = table;
1940
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
1941
+ // if no content in row, skip row
1942
+ if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
1943
+ !!header.column.columnDef.footer) ||
1944
+ header.column.columnDef.Footer))) {
1945
+ return null;
1946
+ }
1947
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
1948
+ footerGroup,
1949
+ table,
1950
+ })), rest);
1951
+ return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: baseBackgroundColor, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: 'relative', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, staticColumnIndex) => {
1952
+ let footer = footerOrVirtualFooter;
1953
+ if (columnVirtualizer) {
1954
+ staticColumnIndex = footerOrVirtualFooter
1955
+ .index;
1956
+ footer = footerGroup.headers[staticColumnIndex];
1957
+ }
1958
+ return footer ? (jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
1959
+ }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
1960
+ };
1961
+
1962
+ const MRT_TableFooter = (_a) => {
1963
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
1964
+ const { getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
1965
+ const { isFullScreen } = getState();
1966
+ const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
1967
+ table,
1968
+ })), rest);
1969
+ const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
1970
+ const footerGroups = table.getFooterGroups();
1971
+ //if no footer cells at all, skip footer
1972
+ if (!footerGroups.some((footerGroup) => {
1973
+ var _a;
1974
+ return (_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
1975
+ !!header.column.columnDef.footer) ||
1976
+ header.column.columnDef.Footer);
1977
+ })) {
1978
+ return null;
1979
+ }
1980
+ return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
1981
+ tableFooterRef.current = ref;
1982
+ if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
1983
+ // @ts-expect-error
1984
+ tableFooterProps.ref.current = ref;
1985
+ }
1986
+ }, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
1987
+ ? theme.palette.mode === 'light'
1988
+ ? `1px solid ${theme.palette.grey[300]}`
1989
+ : `1px solid ${theme.palette.grey[700]}`
1990
+ : undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: footerGroups.map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
1991
+ };
1992
+
1993
+ const MRT_SelectCheckbox = (_a) => {
1994
+ var _b;
1995
+ var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
1996
+ const { getState, options: { enableMultiRowSelection, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, selectAllMode, }, } = table;
1997
+ const { density, isLoading } = getState();
1998
+ const selectAll = !row;
1999
+ const allRowsSelected = selectAll
2000
+ ? selectAllMode === 'page'
2001
+ ? table.getIsAllPageRowsSelected()
2002
+ : table.getIsAllRowsSelected()
2003
+ : undefined;
2004
+ const isChecked = selectAll
2005
+ ? allRowsSelected
2006
+ : getIsRowSelected({ row, table });
2007
+ const checkboxProps = Object.assign(Object.assign({}, (selectAll
2008
+ ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
2009
+ : parseFromValuesOrFunc(muiSelectCheckboxProps, {
2010
+ row,
2011
+ staticRowIndex,
2012
+ table,
2013
+ }))), rest);
2014
+ const onSelectionChange = row
2015
+ ? getMRT_RowSelectionHandler({
2016
+ row,
2017
+ staticRowIndex,
2018
+ table,
2019
+ })
2020
+ : undefined;
2021
+ const onSelectAllChange = getMRT_SelectAllHandler({ table });
2022
+ const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
2023
+ ? localization.toggleSelectAll
2024
+ : localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', onChange: (event) => {
2025
+ event.stopPropagation();
2026
+ selectAll ? onSelectAllChange(event) : onSelectionChange(event);
2027
+ }, size: (density === 'compact' ? 'small' : 'medium'), slotProps: {
2028
+ input: {
2029
+ 'aria-label': selectAll
2030
+ ? localization.toggleSelectAll
2031
+ : localization.toggleSelectRow,
2032
+ },
2033
+ } }, checkboxProps), { onClick: (e) => {
2034
+ var _a;
2035
+ e.stopPropagation();
2036
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
2037
+ }, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.5rem', zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
2038
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
2039
+ ? localization.toggleSelectAll
2040
+ : localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: !isChecked && selectAll
2041
+ ? table.getIsSomeRowsSelected()
2042
+ : (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
2043
+ };
2044
+
2045
+ const MRT_ToolbarAlertBanner = (_a) => {
2046
+ var _b, _c, _d;
2047
+ var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
2048
+ const { getCoreRowModel, getFilteredSelectedRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
2049
+ const { density, grouping, rowSelection, showAlertBanner } = getState();
2050
+ const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
2051
+ table,
2052
+ })), rest);
2053
+ const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
2054
+ table,
2055
+ });
2056
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getCoreRowModel().rows.length;
2057
+ const filteredRowCount = getFilteredSelectedRowModel().rows.length;
2058
+ const selectedRowCount = useMemo(() => manualPagination
2059
+ ? Object.values(rowSelection).filter(Boolean).length
2060
+ : filteredRowCount, [rowSelection, totalRowCount, manualPagination, filteredRowCount]);
2061
+ const selectedAlert = selectedRowCount > 0 ? (jsxs(Stack, { direction: "row", sx: {
2062
+ alignItems: "center",
2063
+ gap: "16px"
2064
+ }, children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString(localization.language))) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.toLocaleString(localization.language)), jsx(Button, { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
2065
+ const groupedAlert = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
2066
+ return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
2067
+ var _a, _b;
2068
+ return (Object.assign({ '& .MuiAlert-message': {
2069
+ maxWidth: `calc(${(_b = (_a = tablePaperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 360}px - 1rem)`,
2070
+ width: '100%',
2071
+ }, borderRadius: 0, fontSize: '1rem', left: 0, mb: stackAlertBanner
2072
+ ? 0
2073
+ : positionToolbarAlertBanner === 'bottom'
2074
+ ? '-1rem'
2075
+ : undefined, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, parseFromValuesOrFunc(alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx, theme)));
2076
+ }, children: (_d = renderToolbarAlertBannerContent === null || renderToolbarAlertBannerContent === void 0 ? void 0 : renderToolbarAlertBannerContent({
2077
+ groupedAlert,
2078
+ selectedAlert,
2079
+ table,
2080
+ })) !== null && _d !== void 0 ? _d : (jsxs(Fragment, { children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsx(AlertTitle, { children: alertProps.title }), jsxs(Stack, { sx: {
2081
+ p: positionToolbarAlertBanner !== 'head-overlay'
2082
+ ? '0.5rem 1rem'
2083
+ : density === 'spacious'
2084
+ ? '0.75rem 1.25rem'
2085
+ : density === 'comfortable'
2086
+ ? '0.5rem 0.75rem'
2087
+ : '0.25rem 0.5rem',
2088
+ }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectedAlert || groupedAlert) && (jsx("br", {})), jsxs(Box, { sx: { display: 'flex' }, children: [enableRowSelection &&
2089
+ enableSelectAll &&
2090
+ positionToolbarAlertBanner === 'head-overlay' && (jsx(MRT_SelectCheckbox, { table: table })), ' ', selectedAlert] }), selectedAlert && groupedAlert && jsx("br", {}), groupedAlert] })] })) })) }));
2091
+ };
2092
+
2093
+ const mrtFilterOptions = (localization) => [
2094
+ {
2095
+ divider: false,
2096
+ label: localization.filterFuzzy,
2097
+ option: 'fuzzy',
2098
+ symbol: '≈',
2099
+ },
2100
+ {
2101
+ divider: false,
2102
+ label: localization.filterContains,
2103
+ option: 'contains',
2104
+ symbol: '*',
2105
+ },
2106
+ {
2107
+ divider: false,
2108
+ label: localization.filterStartsWith,
2109
+ option: 'startsWith',
2110
+ symbol: 'a',
2111
+ },
2112
+ {
2113
+ divider: true,
2114
+ label: localization.filterEndsWith,
2115
+ option: 'endsWith',
2116
+ symbol: 'z',
2117
+ },
2118
+ {
2119
+ divider: false,
2120
+ label: localization.filterEquals,
2121
+ option: 'equals',
2122
+ symbol: '=',
2123
+ },
2124
+ {
2125
+ divider: true,
2126
+ label: localization.filterNotEquals,
2127
+ option: 'notEquals',
2128
+ symbol: '≠',
2129
+ },
2130
+ {
2131
+ divider: false,
2132
+ label: localization.filterBetween,
2133
+ option: 'between',
2134
+ symbol: '⇿',
2135
+ },
2136
+ {
2137
+ divider: true,
2138
+ label: localization.filterBetweenInclusive,
2139
+ option: 'betweenInclusive',
2140
+ symbol: '⬌',
2141
+ },
2142
+ {
2143
+ divider: false,
2144
+ label: localization.filterGreaterThan,
2145
+ option: 'greaterThan',
2146
+ symbol: '>',
2147
+ },
2148
+ {
2149
+ divider: false,
2150
+ label: localization.filterGreaterThanOrEqualTo,
2151
+ option: 'greaterThanOrEqualTo',
2152
+ symbol: '≥',
2153
+ },
2154
+ {
2155
+ divider: false,
2156
+ label: localization.filterLessThan,
2157
+ option: 'lessThan',
2158
+ symbol: '<',
2159
+ },
2160
+ {
2161
+ divider: true,
2162
+ label: localization.filterLessThanOrEqualTo,
2163
+ option: 'lessThanOrEqualTo',
2164
+ symbol: '≤',
2165
+ },
2166
+ {
2167
+ divider: false,
2168
+ label: localization.filterEmpty,
2169
+ option: 'empty',
2170
+ symbol: '∅',
2171
+ },
2172
+ {
2173
+ divider: false,
2174
+ label: localization.filterNotEmpty,
2175
+ option: 'notEmpty',
2176
+ symbol: '!∅',
2177
+ },
2178
+ ];
2179
+ const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
2180
+ const emptyModes = ['empty', 'notEmpty'];
2181
+ const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
2182
+ const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
2183
+ const MRT_FilterOptionMenu = (_a) => {
2184
+ var _b, _c, _d, _e;
2185
+ var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
2186
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, mrtTheme: { menuBackgroundColor }, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
2187
+ const { density, globalFilterFn } = getState();
2188
+ const { column } = header !== null && header !== void 0 ? header : {};
2189
+ const { columnDef } = column !== null && column !== void 0 ? column : {};
2190
+ const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
2191
+ let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2192
+ if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
2193
+ allowedColumnFilterOptions = [
2194
+ ...rangeModes,
2195
+ ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
2196
+ ].filter((option) => rangeModes.includes(option));
2197
+ }
2198
+ const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
2199
+ ? allowedColumnFilterOptions === undefined ||
2200
+ (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
2201
+ : (!globalFilterModeOptions ||
2202
+ globalFilterModeOptions.includes(filterOption.option)) &&
2203
+ ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
2204
+ const handleSelectFilterMode = (option) => {
2205
+ var _a, _b;
2206
+ const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
2207
+ if (!header || !column) {
2208
+ // global filter mode
2209
+ setGlobalFilterFn(option);
2210
+ }
2211
+ else if (option !== prevFilterMode) {
2212
+ // column filter mode
2213
+ setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
2214
+ // reset filter value and/or perform new filter render
2215
+ if (emptyModes.includes(option)) {
2216
+ // will now be empty/notEmpty filter mode
2217
+ if (currentFilterValue !== ' ' &&
2218
+ !emptyModes.includes(prevFilterMode)) {
2219
+ column.setFilterValue(' ');
2220
+ }
2221
+ else if (currentFilterValue) {
2222
+ column.setFilterValue(currentFilterValue); // perform new filter render
2223
+ }
2224
+ }
2225
+ else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
2226
+ arrModes.includes(option)) {
2227
+ // will now be array filter mode
2228
+ if (currentFilterValue instanceof String ||
2229
+ (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
2230
+ column.setFilterValue([]);
2231
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
2232
+ }
2233
+ else if (currentFilterValue) {
2234
+ column.setFilterValue(currentFilterValue); // perform new filter render
2235
+ }
2236
+ }
2237
+ else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
2238
+ rangeModes.includes(option)) {
2239
+ // will now be range filter mode
2240
+ if (!Array.isArray(currentFilterValue) ||
2241
+ (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
2242
+ !rangeModes.includes(prevFilterMode))) {
2243
+ column.setFilterValue(['', '']);
2244
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2245
+ }
2246
+ else {
2247
+ column.setFilterValue(currentFilterValue); // perform new filter render
2248
+ }
2249
+ }
2250
+ else {
2251
+ // will now be single value filter mode
2252
+ if (Array.isArray(currentFilterValue)) {
2253
+ column.setFilterValue('');
2254
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2255
+ }
2256
+ else if (currentFilterValue === ' ' &&
2257
+ emptyModes.includes(prevFilterMode)) {
2258
+ column.setFilterValue(undefined);
2259
+ }
2260
+ else {
2261
+ column.setFilterValue(currentFilterValue); // perform new filter render
2262
+ }
2263
+ }
2264
+ }
2265
+ setAnchorEl(null);
2266
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
2267
+ };
2268
+ const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
2269
+ return (jsx(Menu, Object.assign({ anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl, slotProps: {
2270
+ list: {
2271
+ dense: density === 'compact',
2272
+ sx: {
2273
+ backgroundColor: menuBackgroundColor,
2274
+ },
2275
+ },
2276
+ } }, rest, { children: (_e = (header && column && columnDef
2277
+ ? ((_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2278
+ column: column,
2279
+ internalFilterOptions,
2280
+ onSelectFilterMode: handleSelectFilterMode,
2281
+ table,
2282
+ })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
2283
+ column: column,
2284
+ internalFilterOptions,
2285
+ onSelectFilterMode: handleSelectFilterMode,
2286
+ table,
2287
+ }))
2288
+ : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
2289
+ internalFilterOptions,
2290
+ onSelectFilterMode: handleSelectFilterMode,
2291
+ table,
2292
+ }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsx(MRT_ActionMenuItem, { divider: divider, icon: symbol, label: label, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, table: table, value: option }, index))) })));
2293
+ };
2294
+
2295
+ const MRT_ColumnActionMenu = (_a) => {
2296
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2297
+ var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
2298
+ const { getAllLeafColumns, getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, mrtTheme: { menuBackgroundColor }, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, } = table;
2299
+ const { column } = header;
2300
+ const { columnDef } = column;
2301
+ const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
2302
+ const columnFilterValue = column.getFilterValue();
2303
+ const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
2304
+ const handleClearSort = () => {
2305
+ column.clearSorting();
2306
+ setAnchorEl(null);
2307
+ };
2308
+ const handleSortAsc = () => {
2309
+ column.toggleSorting(false);
2310
+ setAnchorEl(null);
2311
+ };
2312
+ const handleSortDesc = () => {
2313
+ column.toggleSorting(true);
2314
+ setAnchorEl(null);
2315
+ };
2316
+ const handleResetColumnSize = () => {
2317
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2318
+ column.resetSize();
2319
+ setAnchorEl(null);
2320
+ };
2321
+ const handleHideColumn = () => {
2322
+ column.toggleVisibility(false);
2323
+ setAnchorEl(null);
2324
+ };
2325
+ const handlePinColumn = (pinDirection) => {
2326
+ column.pin(pinDirection);
2327
+ setAnchorEl(null);
2328
+ };
2329
+ const handleGroupByColumn = () => {
2330
+ column.toggleGrouping();
2331
+ setColumnOrder((old) => ['mrt-row-expand', ...old]);
2332
+ setAnchorEl(null);
2333
+ };
2334
+ const handleClearFilter = () => {
2335
+ column.setFilterValue(undefined);
2336
+ setAnchorEl(null);
2337
+ if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
2338
+ setColumnFilterFns((prev) => {
2339
+ var _a;
2340
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
2341
+ });
2342
+ }
2343
+ };
2344
+ const handleFilterByColumn = () => {
2345
+ setShowColumnFilters(true);
2346
+ queueMicrotask(() => { var _a, _b; return (_b = (_a = filterInputRefs.current) === null || _a === void 0 ? void 0 : _a[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.focus(); });
2347
+ setAnchorEl(null);
2348
+ };
2349
+ const handleShowAllColumns = () => {
2350
+ getAllLeafColumns()
2351
+ .filter((col) => col.columnDef.enableHiding !== false)
2352
+ .forEach((col) => col.toggleVisibility(true));
2353
+ setAnchorEl(null);
2354
+ };
2355
+ const handleOpenFilterModeMenu = (event) => {
2356
+ event.stopPropagation();
2357
+ setFilterMenuAnchorEl(event.currentTarget);
2358
+ };
2359
+ const isSelectFilter = !!columnDef.filterSelectOptions;
2360
+ const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2361
+ const showFilterModeSubMenu = enableColumnFilterModes &&
2362
+ columnDef.enableColumnFilterModes !== false &&
2363
+ !isSelectFilter &&
2364
+ (allowedColumnFilterOptions === undefined ||
2365
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
2366
+ const internalColumnMenuItems = [
2367
+ ...(enableSorting && column.getCanSort()
2368
+ ? [
2369
+ enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === false, icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
2370
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'asc', icon: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }), label: (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header)), onClick: handleSortAsc, table: table }, 1),
2371
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, icon: jsx(SortIcon, {}), label: (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)), onClick: handleSortDesc, table: table }, 2),
2372
+ ]
2373
+ : []),
2374
+ ...(enableColumnFilters && column.getCanFilter()
2375
+ ? [
2376
+ jsx(MRT_ActionMenuItem, { disabled: !columnFilterValue ||
2377
+ (Array.isArray(columnFilterValue) &&
2378
+ !columnFilterValue.filter((value) => value).length), icon: jsx(FilterListOffIcon, {}), label: localization.clearFilter, onClick: handleClearFilter, table: table }, 3),
2379
+ columnFilterDisplayMode === 'subheader' && (jsx(MRT_ActionMenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, icon: jsx(FilterListIcon, {}), label: (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header)), onClick: showColumnFilters
2380
+ ? handleOpenFilterModeMenu
2381
+ : handleFilterByColumn, onOpenSubMenu: showFilterModeSubMenu ? handleOpenFilterModeMenu : undefined, table: table }, 4)),
2382
+ showFilterModeSubMenu && (jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
2383
+ ].filter(Boolean)
2384
+ : []),
2385
+ ...(enableGrouping && column.getCanGroup()
2386
+ ? [
2387
+ jsx(MRT_ActionMenuItem, { divider: enableColumnPinning, icon: jsx(DynamicFeedIcon, {}), label: (_f = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)), onClick: handleGroupByColumn, table: table }, 6),
2388
+ ]
2389
+ : []),
2390
+ ...(enableColumnPinning && column.getCanPin()
2391
+ ? [
2392
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }), label: localization.pinToLeft, onClick: () => handlePinColumn('left'), table: table }, 7),
2393
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }), label: localization.pinToRight, onClick: () => handlePinColumn('right'), table: table }, 8),
2394
+ jsx(MRT_ActionMenuItem, { disabled: !column.getIsPinned(), divider: enableHiding, icon: jsx(PushPinIcon, {}), label: localization.unpin, onClick: () => handlePinColumn(false), table: table }, 9),
2395
+ ]
2396
+ : []),
2397
+ ...(enableColumnResizing && column.getCanResize()
2398
+ ? [
2399
+ jsx(MRT_ActionMenuItem, { disabled: columnSizing[column.id] === undefined, icon: jsx(RestartAltIcon, {}), label: localization.resetColumnSize, onClick: handleResetColumnSize, table: table }, 10),
2400
+ ]
2401
+ : []),
2402
+ ...(enableHiding
2403
+ ? [
2404
+ jsx(MRT_ActionMenuItem, { disabled: !column.getCanHide(), icon: jsx(VisibilityOffIcon, {}), label: (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header)), onClick: handleHideColumn, table: table }, 11),
2405
+ jsx(MRT_ActionMenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
2406
+ .length, icon: jsx(ViewColumnIcon, {}), label: (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header)), onClick: handleShowAllColumns, table: table }, 12),
2407
+ ]
2408
+ : []),
2409
+ ].filter(Boolean);
2410
+ return (jsx(Menu, Object.assign({ anchorEl: anchorEl, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl, slotProps: {
2411
+ list: {
2412
+ dense: density === 'compact',
2413
+ sx: {
2414
+ backgroundColor: menuBackgroundColor,
2415
+ },
2416
+ },
2417
+ } }, rest, { children: (_l = (_k = (_j = columnDef.renderColumnActionsMenuItems) === null || _j === void 0 ? void 0 : _j.call(columnDef, {
2418
+ closeMenu: () => setAnchorEl(null),
2419
+ column,
2420
+ internalColumnMenuItems,
2421
+ table,
2422
+ })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
2423
+ closeMenu: () => setAnchorEl(null),
2424
+ column,
2425
+ internalColumnMenuItems,
2426
+ table,
2427
+ })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
2428
+ };
2429
+
2430
+ const MRT_TableHeadCellColumnActionsButton = (_a) => {
2431
+ var _b, _c;
2432
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2433
+ const { options: { icons: { MoreVertIcon }, localization, muiColumnActionsButtonProps, }, } = table;
2434
+ const { column } = header;
2435
+ const { columnDef } = column;
2436
+ const [anchorEl, setAnchorEl] = useState(null);
2437
+ const handleClick = (event) => {
2438
+ event.stopPropagation();
2439
+ event.preventDefault();
2440
+ setAnchorEl(event.currentTarget);
2441
+ };
2442
+ const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnActionsButtonProps, {
2443
+ column,
2444
+ table,
2445
+ })), parseFromValuesOrFunc(columnDef.muiColumnActionsButtonProps, {
2446
+ column,
2447
+ table,
2448
+ })), rest);
2449
+ return (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.columnActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ '&:hover': {
2450
+ opacity: 1,
2451
+ }, height: '2rem', m: '-8px -4px', opacity: 0.3, transition: 'all 150ms', width: '2rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsx(MoreVertIcon, { style: { transform: 'scale(0.9)' } })) })) })), anchorEl && (jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
2452
+ };
2453
+
2454
+ const MRT_FilterCheckbox = (_a) => {
2455
+ var _b, _c, _d;
2456
+ var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
2457
+ const { getState, options: { localization, muiFilterCheckboxProps }, } = table;
2458
+ const { density } = getState();
2459
+ const { columnDef } = column;
2460
+ const checkboxProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterCheckboxProps, {
2461
+ column,
2462
+ table,
2463
+ })), parseFromValuesOrFunc(columnDef.muiFilterCheckboxProps, {
2464
+ column,
2465
+ table,
2466
+ })), rest);
2467
+ const filterLabel = (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', columnDef.header);
2468
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_c = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, children: jsx(FormControlLabel, { control: jsx(Checkbox, Object.assign({ checked: column.getFilterValue() === 'true', color: column.getFilterValue() === undefined ? 'default' : 'primary', indeterminate: column.getFilterValue() === undefined, size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onChange: (e, checked) => {
2469
+ var _a;
2470
+ column.setFilterValue(column.getFilterValue() === undefined
2471
+ ? 'true'
2472
+ : column.getFilterValue() === 'true'
2473
+ ? 'false'
2474
+ : undefined);
2475
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
2476
+ }, onClick: (e) => {
2477
+ var _a;
2478
+ e.stopPropagation();
2479
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
2480
+ }, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))) })), disableTypography: true, label: (_d = checkboxProps.title) !== null && _d !== void 0 ? _d : filterLabel, sx: { color: 'text.secondary', fontWeight: 'normal', mt: '-4px' }, title: undefined }) })));
2481
+ };
2482
+
2483
+ const MRT_FilterTextField = (_a) => {
2484
+ var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
2485
+ var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
2486
+ const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
2487
+ const { column } = header;
2488
+ const { columnDef } = column;
2489
+ const { filterVariant } = columnDef;
2490
+ const args = { column, rangeFilterIndex, table };
2491
+ const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTextFieldProps, args)), parseFromValuesOrFunc(columnDef.muiFilterTextFieldProps, args)), rest);
2492
+ const autocompleteProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterAutocompleteProps, args)), parseFromValuesOrFunc(columnDef.muiFilterAutocompleteProps, args));
2493
+ const datePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterDatePickerProps, args)), parseFromValuesOrFunc(columnDef.muiFilterDatePickerProps, args));
2494
+ const dateTimePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterDateTimePickerProps, args)), parseFromValuesOrFunc(columnDef.muiFilterDateTimePickerProps, args));
2495
+ const timePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTimePickerProps, args)), parseFromValuesOrFunc(columnDef.muiFilterTimePickerProps, args));
2496
+ const { allowedColumnFilterOptions, currentFilterOption, facetedUniqueValues, isAutocompleteFilter, isDateFilter, isMultiSelectFilter, isRangeFilter, isSelectFilter, isTextboxFilter, } = getColumnFilterInfo({ header, table });
2497
+ const dropdownOptions = useDropdownOptions({ header, table });
2498
+ const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
2499
+ ? localization[`filter${((_c = (_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt) === null || _b === void 0 ? void 0 : _b.call(currentFilterOption, 0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
2500
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
2501
+ : '';
2502
+ const filterPlaceholder = !isRangeFilter
2503
+ ? ((_d = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.placeholder) !== null && _d !== void 0 ? _d : (_f = localization.filterByColumn) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)))
2504
+ : rangeFilterIndex === 0
2505
+ ? localization.min
2506
+ : rangeFilterIndex === 1
2507
+ ? localization.max
2508
+ : '';
2509
+ const showChangeModeButton = !!(enableColumnFilterModes &&
2510
+ columnDef.enableColumnFilterModes !== false &&
2511
+ !rangeFilterIndex &&
2512
+ (allowedColumnFilterOptions === undefined ||
2513
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length)));
2514
+ const [anchorEl, setAnchorEl] = useState(null);
2515
+ const [filterValue, setFilterValue] = useState(() => {
2516
+ var _a, _b;
2517
+ return isMultiSelectFilter
2518
+ ? column.getFilterValue() || []
2519
+ : isRangeFilter
2520
+ ? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
2521
+ : isAutocompleteFilter
2522
+ ? typeof column.getFilterValue() === 'string'
2523
+ ? column.getFilterValue()
2524
+ : ''
2525
+ : ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
2526
+ });
2527
+ const [autocompleteValue, setAutocompleteValue] = useState(() => isAutocompleteFilter
2528
+ ? (column.getFilterValue() || null)
2529
+ : null);
2530
+ const handleChangeDebounced = useCallback(debounce((newValue) => {
2531
+ if (isRangeFilter) {
2532
+ column.setFilterValue((old) => {
2533
+ const newFilterValues = old !== null && old !== void 0 ? old : ['', ''];
2534
+ newFilterValues[rangeFilterIndex] = newValue !== null && newValue !== void 0 ? newValue : undefined;
2535
+ return newFilterValues;
2536
+ });
2537
+ }
2538
+ else {
2539
+ column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
2540
+ }
2541
+ }, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
2542
+ const handleChange = (newValue) => {
2543
+ setFilterValue(newValue !== null && newValue !== void 0 ? newValue : '');
2544
+ handleChangeDebounced(newValue);
2545
+ };
2546
+ const handleTextFieldChange = (event) => {
2547
+ var _a;
2548
+ const newValue = textFieldProps.type === 'date'
2549
+ ? event.target.valueAsDate
2550
+ : textFieldProps.type === 'number'
2551
+ ? event.target.valueAsNumber
2552
+ : event.target.value;
2553
+ handleChange(newValue);
2554
+ (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2555
+ };
2556
+ const handleAutocompleteInputChange = (_event, newValue, _reason) => {
2557
+ handleChange(newValue);
2558
+ };
2559
+ const handleAutocompleteChange = (newValue) => {
2560
+ setAutocompleteValue(newValue);
2561
+ handleChangeDebounced(getValueAndLabel(newValue).value);
2562
+ };
2563
+ const handleClear = () => {
2564
+ if (isMultiSelectFilter) {
2565
+ setFilterValue([]);
2566
+ column.setFilterValue([]);
2567
+ }
2568
+ else if (isRangeFilter) {
2569
+ setFilterValue('');
2570
+ column.setFilterValue((old) => {
2571
+ const newFilterValues = (Array.isArray(old) && old) || ['', ''];
2572
+ newFilterValues[rangeFilterIndex] = undefined;
2573
+ return newFilterValues;
2574
+ });
2575
+ }
2576
+ else if (isAutocompleteFilter) {
2577
+ setAutocompleteValue(null);
2578
+ setFilterValue('');
2579
+ // when using 'autocomplete' this function is called only inside effect and only if the filterValue === undefined
2580
+ // so the following call is excessive; should be uncommented if the handleClear becomes part of the Autocomplete component callbacks
2581
+ // column.setFilterValue(undefined)
2582
+ }
2583
+ else {
2584
+ setFilterValue('');
2585
+ column.setFilterValue(undefined);
2586
+ }
2587
+ };
2588
+ const handleClearEmptyFilterChip = () => {
2589
+ setFilterValue('');
2590
+ column.setFilterValue(undefined);
2591
+ setColumnFilterFns((prev) => {
2592
+ var _a;
2593
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
2594
+ });
2595
+ };
2596
+ const handleFilterMenuOpen = (event) => {
2597
+ setAnchorEl(event.currentTarget);
2598
+ };
2599
+ const isMounted = useRef(false);
2600
+ useEffect(() => {
2601
+ if (isMounted.current) {
2602
+ const filterValue = column.getFilterValue();
2603
+ if (filterValue === undefined) {
2604
+ handleClear();
2605
+ }
2606
+ else if (isRangeFilter && rangeFilterIndex !== undefined) {
2607
+ setFilterValue(filterValue[rangeFilterIndex]);
2608
+ }
2609
+ else {
2610
+ setFilterValue(filterValue);
2611
+ }
2612
+ }
2613
+ isMounted.current = true;
2614
+ }, [column.getFilterValue()]);
2615
+ if (columnDef.Filter) {
2616
+ return (jsx(Fragment, { children: (_g = columnDef.Filter) === null || _g === void 0 ? void 0 : _g.call(columnDef, { column, header, rangeFilterIndex, table }) }));
2617
+ }
2618
+ const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsx(InputAdornment, { position: "end", sx: {
2619
+ mr: isSelectFilter || isMultiSelectFilter ? '20px' : undefined,
2620
+ visibility: ((_h = filterValue === null || filterValue === void 0 ? void 0 : filterValue.length) !== null && _h !== void 0 ? _h : 0) > 0 ? 'visible' : 'hidden',
2621
+ }, children: jsx(Tooltip, { placement: "right", title: (_j = localization.clearFilter) !== null && _j !== void 0 ? _j : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearFilter, disabled: !((_k = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _k === void 0 ? void 0 : _k.length), onClick: handleClear, size: "small", sx: {
2622
+ height: '2rem',
2623
+ transform: 'scale(0.9)',
2624
+ width: '2rem',
2625
+ }, children: jsx(CloseIcon, {}) }) }) }) })) : null;
2626
+ const startAdornment = showChangeModeButton ? (jsxs(InputAdornment, { position: "start", children: [jsx(Tooltip, { title: localization.changeFilterMode, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.changeFilterMode, onClick: handleFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(FilterListIcon, {}) }) }) }), filterChipLabel && (jsx(Chip, { label: filterChipLabel, onDelete: handleClearEmptyFilterChip }))] })) : null;
2627
+ const commonTextFieldProps = Object.assign(Object.assign({ fullWidth: true, helperText: showChangeModeButton ? (jsx("label", { children: localization.filterMode.replace('{filterType}', localization[`filter${((_l = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _l === void 0 ? void 0 : _l.toUpperCase()) +
2628
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputRef: (inputRef) => {
2629
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
2630
+ inputRef;
2631
+ if (textFieldProps.inputRef) {
2632
+ textFieldProps.inputRef = inputRef;
2633
+ }
2634
+ }, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
2635
+ ? undefined
2636
+ : filterPlaceholder, variant: 'standard' }, textFieldProps), { onKeyDown: (e) => {
2637
+ var _a;
2638
+ e.stopPropagation();
2639
+ (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
2640
+ }, slotProps: Object.assign(Object.assign({}, textFieldProps.slotProps), { formHelperText: Object.assign({ sx: {
2641
+ fontSize: '0.75rem',
2642
+ lineHeight: '0.8rem',
2643
+ whiteSpace: 'nowrap',
2644
+ } }, (_m = textFieldProps.slotProps) === null || _m === void 0 ? void 0 : _m.formHelperText), htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
2645
+ textOverflow: 'ellipsis',
2646
+ width: filterChipLabel ? 0 : undefined,
2647
+ }, title: filterPlaceholder }, (_o = textFieldProps.slotProps) === null || _o === void 0 ? void 0 : _o.htmlInput), input: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
2648
+ ? Object.assign({ endAdornment, startAdornment }, (_p = textFieldProps.slotProps) === null || _p === void 0 ? void 0 : _p.input) : Object.assign({ startAdornment }, (_q = textFieldProps.slotProps) === null || _q === void 0 ? void 0 : _q.input) }), sx: (theme) => (Object.assign({ minWidth: isDateFilter
2649
+ ? '160px'
2650
+ : enableColumnFilterModes && rangeFilterIndex === 0
2651
+ ? '110px'
2652
+ : isRangeFilter
2653
+ ? '100px'
2654
+ : !filterChipLabel
2655
+ ? '120px'
2656
+ : 'auto', mx: '-2px', p: 0, width: 'calc(100% + 4px)' }, parseFromValuesOrFunc(textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx, theme))) });
2657
+ const commonDatePickerProps = {
2658
+ onChange: (newDate) => {
2659
+ handleChange(newDate);
2660
+ },
2661
+ value: filterValue || null,
2662
+ };
2663
+ return (jsxs(Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsx(TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: Object.assign(Object.assign({}, timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps), { field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_r = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.field), textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField) }) }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsx(DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: Object.assign(Object.assign({}, dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps), { field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_t = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _t === void 0 ? void 0 : _t.field), textField: Object.assign(Object.assign({}, commonTextFieldProps), (_u = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _u === void 0 ? void 0 : _u.textField) }) }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: Object.assign(Object.assign({}, datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps), { field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_v = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _v === void 0 ? void 0 : _v.field), textField: Object.assign(Object.assign({}, commonTextFieldProps), (_w = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _w === void 0 ? void 0 : _w.textField) }) }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, inputValue: filterValue, onChange: (_e, newValue) => handleAutocompleteChange(newValue), onInputChange: handleAutocompleteInputChange, options: (_x = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _x !== void 0 ? _x : [] }, autocompleteProps, { renderInput: (params) => {
2664
+ const commonInput = getTextFieldSlotProps(commonTextFieldProps.slotProps).input;
2665
+ const commonHtmlInput = getTextFieldSlotProps(commonTextFieldProps.slotProps).htmlInput;
2666
+ return (jsx(TextField, Object.assign({}, commonTextFieldProps, { disabled: params.disabled, fullWidth: params.fullWidth, id: params.id, onClick: (e) => e.stopPropagation(), size: params.size, slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { htmlInput: Object.assign(Object.assign({}, params.slotProps.htmlInput), commonHtmlInput), input: Object.assign(Object.assign({}, params.slotProps.input), { startAdornment: commonInput === null || commonInput === void 0 ? void 0 : commonInput.startAdornment }), inputLabel: params.slotProps.inputLabel }) })));
2667
+ }, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { inputLabel: Object.assign({ shrink: isSelectFilter || isMultiSelectFilter }, (_y = commonTextFieldProps.slotProps) === null || _y === void 0 ? void 0 : _y.inputLabel), select: Object.assign({ displayEmpty: true, MenuProps: { disableScrollLock: true }, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
2668
+ ? (selected) => !Array.isArray(selected) || (selected === null || selected === void 0 ? void 0 : selected.length) === 0 ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected.map((value) => {
2669
+ const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
2670
+ return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
2671
+ }) }))
2672
+ : undefined }, (_z = commonTextFieldProps.slotProps) === null || _z === void 0 ? void 0 : _z.select) }), value: isMultiSelectFilter
2673
+ ? Array.isArray(filterValue)
2674
+ ? filterValue
2675
+ : []
2676
+ : filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
2677
+ jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
2678
+ ...[
2679
+ (_0 = textFieldProps.children) !== null && _0 !== void 0 ? _0 : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
2680
+ var _a;
2681
+ const { label, value } = getValueAndLabel(option);
2682
+ return (jsxs(MenuItem, { sx: {
2683
+ alignItems: 'center',
2684
+ display: 'flex',
2685
+ gap: '0.5rem',
2686
+ m: 0,
2687
+ }, value: value, children: [isMultiSelectFilter && (jsx(Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), label, ' ', !columnDef.filterSelectOptions &&
2688
+ `(${facetedUniqueValues.get(value)})`] }, `${index}-${value}`));
2689
+ }),
2690
+ ],
2691
+ ] }))), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, setFilterValue: setFilterValue, table: table })] }));
2692
+ };
2693
+
2694
+ const MRT_FilterRangeFields = (_a) => {
2695
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2696
+ return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ display: 'grid', gap: '1rem', gridTemplateColumns: '1fr 1fr' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: [0, 1].map((rangeFilterIndex) => (jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: rangeFilterIndex, table: table }, rangeFilterIndex))) })));
2697
+ };
2698
+
2699
+ const MRT_FilterRangeSlider = (_a) => {
2700
+ var _b, _c;
2701
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2702
+ const { options: { enableColumnFilterModes, localization, muiFilterSliderProps }, refs: { filterInputRefs }, } = table;
2703
+ const { column } = header;
2704
+ const { columnDef } = column;
2705
+ const currentFilterOption = columnDef._filterFn;
2706
+ const showChangeModeButton = enableColumnFilterModes && columnDef.enableColumnFilterModes !== false;
2707
+ const sliderProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterSliderProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterSliderProps, { column, table })), rest);
2708
+ let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
2709
+ ? [sliderProps.min, sliderProps.max]
2710
+ : ((_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1]);
2711
+ //fix potential TanStack Table bugs where min or max is an array
2712
+ if (Array.isArray(min))
2713
+ min = min[0];
2714
+ if (Array.isArray(max))
2715
+ max = max[0];
2716
+ if (min === null)
2717
+ min = 0;
2718
+ if (max === null)
2719
+ max = 1;
2720
+ const [filterValues, setFilterValues] = useState([min, max]);
2721
+ const columnFilterValue = column.getFilterValue();
2722
+ const isMounted = useRef(false);
2723
+ // prevent moving the focus to the next/prev cell when using the arrow keys
2724
+ const handleKeyDown = (event) => {
2725
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
2726
+ event.stopPropagation();
2727
+ }
2728
+ };
2729
+ useEffect(() => {
2730
+ if (isMounted.current) {
2731
+ if (columnFilterValue === undefined) {
2732
+ setFilterValues([min, max]);
2733
+ }
2734
+ else if (Array.isArray(columnFilterValue)) {
2735
+ setFilterValues(columnFilterValue);
2736
+ }
2737
+ }
2738
+ isMounted.current = true;
2739
+ }, [columnFilterValue, min, max]);
2740
+ return (jsxs(Stack, { children: [jsx(Slider, Object.assign({ disableSwap: true, max: max, min: min, onChange: (_event, values) => {
2741
+ setFilterValues(values);
2742
+ }, onChangeCommitted: (_event, value) => {
2743
+ if (Array.isArray(value)) {
2744
+ if (value[0] <= min && value[1] >= max) {
2745
+ //if the user has selected the entire range, remove the filter
2746
+ column.setFilterValue(undefined);
2747
+ }
2748
+ else {
2749
+ column.setFilterValue(value);
2750
+ }
2751
+ }
2752
+ }, onKeyDown: handleKeyDown, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
2753
+ input: {
2754
+ ref: (node) => {
2755
+ var _a, _b;
2756
+ if (node) {
2757
+ filterInputRefs.current[`${column.id}-0`] = node;
2758
+ // @ts-expect-error
2759
+ if ((_b = (_a = sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.slotProps) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.ref) {
2760
+ //@ts-expect-error
2761
+ sliderProps.slotProps.input.ref = node;
2762
+ }
2763
+ }
2764
+ },
2765
+ },
2766
+ }, sx: (theme) => (Object.assign({ m: 'auto', minWidth: `${column.getSize() - 50}px`, mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsx(FormHelperText, { sx: {
2767
+ fontSize: '0.75rem',
2768
+ lineHeight: '0.8rem',
2769
+ m: '-3px -6px',
2770
+ whiteSpace: 'nowrap',
2771
+ }, children: localization.filterMode.replace('{filterType}', localization[`filter${((_c = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
2772
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
2773
+ };
2774
+
2775
+ const MRT_TableHeadCellFilterContainer = (_a) => {
2776
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2777
+ const { getState, options: { columnFilterDisplayMode }, } = table;
2778
+ const { showColumnFilters } = getState();
2779
+ const { column } = header;
2780
+ const { columnDef } = column;
2781
+ const { isRangeFilter } = getColumnFilterInfo({ header, table });
2782
+ return (jsx(Collapse, Object.assign({ in: showColumnFilters || columnFilterDisplayMode === 'popover', mountOnEnter: true, unmountOnExit: true }, rest, { children: columnDef.filterVariant === 'checkbox' ? (jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsx(MRT_FilterRangeSlider, { header: header, table: table })) : isRangeFilter ? (jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsx(MRT_FilterTextField, { header: header, table: table })) })));
2783
+ };
2784
+
2785
+ const MRT_TableHeadCellFilterLabel = (_a) => {
2786
+ var _b;
2787
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2788
+ const { options: { columnFilterDisplayMode, icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
2789
+ const { column } = header;
2790
+ const { columnDef } = column;
2791
+ const filterValue = column.getFilterValue();
2792
+ const [anchorEl, setAnchorEl] = useState(null);
2793
+ const { currentFilterOption, isMultiSelectFilter, isRangeFilter, isSelectFilter, } = getColumnFilterInfo({ header, table });
2794
+ const dropdownOptions = useDropdownOptions({ header, table });
2795
+ const getSelectLabel = (index) => getValueAndLabel(dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value ===
2796
+ (index !== undefined ? filterValue[index] : filterValue))).label;
2797
+ const isFilterActive = (Array.isArray(filterValue) && filterValue.some(Boolean)) ||
2798
+ (!!filterValue && !Array.isArray(filterValue));
2799
+ const filterTooltip = columnFilterDisplayMode === 'popover' && !isFilterActive
2800
+ ? (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', String(columnDef.header))
2801
+ : localization.filteringByColumn
2802
+ .replace('{column}', String(columnDef.header))
2803
+ .replace('{filterType}', currentFilterOption
2804
+ ? localization[`filter${currentFilterOption.charAt(0).toUpperCase() +
2805
+ currentFilterOption.slice(1)}`]
2806
+ : '')
2807
+ .replace('{filterValue}', `"${Array.isArray(filterValue)
2808
+ ? filterValue
2809
+ .map((value, index) => isMultiSelectFilter ? getSelectLabel(index) : value)
2810
+ .join(`" ${isRangeFilter ? localization.and : localization.or} "`)
2811
+ : isSelectFilter
2812
+ ? getSelectLabel()
2813
+ : filterValue}"`)
2814
+ .replace('" "', '');
2815
+ return (jsxs(Fragment, { children: [jsx(Grow, { in: columnFilterDisplayMode === 'popover' ||
2816
+ (!!filterValue && !isRangeFilter) ||
2817
+ (isRangeFilter && (!!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[0]) || !!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[1]))), unmountOnExit: true, children: jsx(Box, { component: "span", sx: { flex: '0 0' }, children: jsx(Tooltip, { placement: "top", title: filterTooltip, children: jsx(IconButton, Object.assign({ disableRipple: true, onClick: (event) => {
2818
+ if (columnFilterDisplayMode === 'popover') {
2819
+ setAnchorEl(event.currentTarget);
2820
+ }
2821
+ else {
2822
+ setShowColumnFilters(true);
2823
+ }
2824
+ queueMicrotask(() => {
2825
+ var _a, _b, _c, _d, _e, _f;
2826
+ (_c = (_b = (_a = filterInputRefs.current) === null || _a === void 0 ? void 0 : _a[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.focus) === null || _c === void 0 ? void 0 : _c.call(_b);
2827
+ (_f = (_e = (_d = filterInputRefs.current) === null || _d === void 0 ? void 0 : _d[`${column.id}-0`]) === null || _e === void 0 ? void 0 : _e.select) === null || _f === void 0 ? void 0 : _f.call(_e);
2828
+ });
2829
+ event.stopPropagation();
2830
+ }, size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '16px', ml: '4px', opacity: isFilterActive ? 1 : 0.3, p: '8px', transform: 'scale(0.75)', transition: 'all 150ms ease-in-out', width: '16px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(FilterAltIcon, {}) })) }) }) }), columnFilterDisplayMode === 'popover' && (jsx(Popover, { anchorEl: anchorEl, anchorOrigin: {
2831
+ horizontal: 'center',
2832
+ vertical: 'top',
2833
+ }, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
2834
+ //@ts-expect-error
2835
+ event.stopPropagation();
2836
+ setAnchorEl(null);
2837
+ }, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, slotProps: { paper: { sx: { overflow: 'visible' } } }, transformOrigin: {
2838
+ horizontal: 'center',
2839
+ vertical: 'bottom',
2840
+ }, children: jsx(Box, { sx: { p: '1rem' }, children: jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }) }))] }));
2841
+ };
2842
+
2843
+ const MRT_TableHeadCellGrabHandle = (_a) => {
2844
+ var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
2845
+ const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setColumnPinning, setDraggingColumn, setHoveredColumn, } = table;
2846
+ const { columnDef } = column;
2847
+ const { columnOrder, draggingColumn, hoveredColumn } = getState();
2848
+ const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
2849
+ column,
2850
+ table,
2851
+ })), rest);
2852
+ const handleDragStart = (event) => {
2853
+ var _a;
2854
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
2855
+ setDraggingColumn(column);
2856
+ try {
2857
+ event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
2858
+ }
2859
+ catch (e) {
2860
+ console.error(e);
2861
+ }
2862
+ };
2863
+ const handleDragEnd = (event) => {
2864
+ var _a;
2865
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
2866
+ if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2867
+ column.toggleGrouping();
2868
+ }
2869
+ else if (enableColumnOrdering &&
2870
+ hoveredColumn &&
2871
+ (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
2872
+ const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
2873
+ setColumnOrder(reorderedColumns);
2874
+ setColumnPinning(({ left = [], right = [] }) => ({
2875
+ left: reorderedColumns.filter((header) => left.includes(header)),
2876
+ right: reorderedColumns.filter((header) => right.includes(header)),
2877
+ }));
2878
+ }
2879
+ setDraggingColumn(null);
2880
+ setHoveredColumn(null);
2881
+ };
2882
+ return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
2883
+ };
2884
+
2885
+ const MRT_TableHeadCellResizeHandle = (_a) => {
2886
+ var _b;
2887
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2888
+ const { getState, options: { columnResizeDirection, columnResizeMode }, setColumnSizingInfo, } = table;
2889
+ const { density } = getState();
2890
+ const { column } = header;
2891
+ const handler = header.getResizeHandler();
2892
+ const mx = density === 'compact'
2893
+ ? '-8px'
2894
+ : density === 'comfortable'
2895
+ ? '-16px'
2896
+ : '-24px';
2897
+ const lr = column.columnDef.columnDefType === 'display' ? '4px' : '0';
2898
+ return (jsx(Box, { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
2899
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2900
+ column.resetSize();
2901
+ }, onMouseDown: handler, onTouchStart: handler, style: {
2902
+ transform: column.getIsResizing() && columnResizeMode === 'onEnd'
2903
+ ? `translateX(${(columnResizeDirection === 'rtl' ? -1 : 1) *
2904
+ ((_b = getState().columnSizingInfo.deltaOffset) !== null && _b !== void 0 ? _b : 0)}px)`
2905
+ : undefined,
2906
+ }, sx: (theme) => ({
2907
+ '&:active > hr': {
2908
+ backgroundColor: theme.palette.info.main,
2909
+ opacity: header.subHeaders.length || columnResizeMode === 'onEnd' ? 1 : 0,
2910
+ },
2911
+ cursor: 'col-resize',
2912
+ left: columnResizeDirection === 'rtl' ? lr : undefined,
2913
+ ml: columnResizeDirection === 'rtl' ? mx : undefined,
2914
+ mr: columnResizeDirection === 'ltr' ? mx : undefined,
2915
+ position: 'absolute',
2916
+ px: '4px',
2917
+ right: columnResizeDirection === 'ltr' ? lr : undefined,
2918
+ }), children: jsx(Divider, { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: (theme) => (Object.assign({ borderRadius: '2px', borderWidth: '2px', height: '24px', touchAction: 'none', transform: 'translateX(4px)', transition: column.getIsResizing()
2919
+ ? undefined
2920
+ : 'all 150ms ease-in-out', userSelect: 'none', zIndex: 4 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) }) }));
2921
+ };
2922
+
2923
+ const MRT_TableHeadCellSortLabel = (_a) => {
2924
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2925
+ const { getState, options: { icons: { ArrowDownwardIcon, SyncAltIcon }, localization, }, } = table;
2926
+ const { column } = header;
2927
+ const { columnDef } = column;
2928
+ const { isLoading, showSkeletons, sorting } = getState();
2929
+ const isSorted = !!column.getIsSorted();
2930
+ const sortTooltip = isLoading || showSkeletons
2931
+ ? ''
2932
+ : column.getIsSorted()
2933
+ ? column.getIsSorted() === 'desc'
2934
+ ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
2935
+ : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
2936
+ : column.getNextSortingOrder() === 'desc'
2937
+ ? localization.sortByColumnDesc.replace('{column}', columnDef.header)
2938
+ : localization.sortByColumnAsc.replace('{column}', columnDef.header);
2939
+ const direction = isSorted
2940
+ ? column.getIsSorted()
2941
+ : undefined;
2942
+ return (jsx(Tooltip, { placement: "top", title: sortTooltip, children: jsx(Badge, { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular", children: jsx(TableSortLabel, Object.assign({ active: true, "aria-label": sortTooltip, direction: direction, IconComponent: !isSorted
2943
+ ? (props) => (jsx(SyncAltIcon, Object.assign({}, props, { direction: direction, style: {
2944
+ transform: 'rotate(-90deg) scaleX(0.9) translateX(-1px)',
2945
+ } })))
2946
+ : ArrowDownwardIcon, onClick: (e) => {
2947
+ var _a;
2948
+ e.stopPropagation();
2949
+ (_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
2950
+ } }, rest, { sx: (theme) => (Object.assign({ '.MuiTableSortLabel-icon': {
2951
+ color: `${theme.palette.mode === 'dark'
2952
+ ? theme.palette.text.primary
2953
+ : theme.palette.text.secondary} !important`,
2954
+ }, flex: '0 0', opacity: isSorted ? 1 : 0.3, transition: 'all 150ms ease-in-out', width: '3ch' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) })) }) }));
2955
+ };
2956
+
2957
+ const MRT_TableHeadCell = (_a) => {
2958
+ var _b, _c, _d, _f, _g, _h, _j;
2959
+ var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
2960
+ const theme = useTheme();
2961
+ const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
2962
+ const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
2963
+ const { column } = header;
2964
+ const { columnDef } = column;
2965
+ const { columnDefType } = columnDef;
2966
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
2967
+ column,
2968
+ table,
2969
+ })), rest);
2970
+ const isColumnPinned = enableColumnPinning &&
2971
+ columnDef.columnDefType !== 'group' &&
2972
+ column.getIsPinned();
2973
+ const showColumnActions = (enableColumnActions || columnDef.enableColumnActions) &&
2974
+ columnDef.enableColumnActions !== false;
2975
+ const showDragHandle = enableColumnDragging !== false &&
2976
+ columnDef.enableColumnDragging !== false &&
2977
+ (enableColumnDragging ||
2978
+ (enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
2979
+ (enableGrouping &&
2980
+ columnDef.enableGrouping !== false &&
2981
+ !grouping.includes(column.id)));
2982
+ const headerPL = useMemo(() => {
2983
+ let pl = 0;
2984
+ if (column.getCanSort())
2985
+ pl += 1;
2986
+ if (showColumnActions)
2987
+ pl += 1.75;
2988
+ if (showDragHandle)
2989
+ pl += 1.5;
2990
+ return pl;
2991
+ }, [showColumnActions, showDragHandle]);
2992
+ const draggingBorders = useMemo(() => {
2993
+ const showResizeBorder = columnSizingInfo.isResizingColumn === column.id &&
2994
+ columnResizeMode === 'onChange' &&
2995
+ !header.subHeaders.length;
2996
+ const borderStyle = showResizeBorder
2997
+ ? `2px solid ${draggingBorderColor} !important`
2998
+ : (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
2999
+ ? `1px dashed ${theme.palette.grey[500]}`
3000
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
3001
+ ? `2px dashed ${draggingBorderColor}`
3002
+ : undefined;
3003
+ if (showResizeBorder) {
3004
+ return columnResizeDirection === 'ltr'
3005
+ ? { borderRight: borderStyle }
3006
+ : { borderLeft: borderStyle };
3007
+ }
3008
+ const draggingBorders = borderStyle
3009
+ ? {
3010
+ borderLeft: borderStyle,
3011
+ borderRight: borderStyle,
3012
+ borderTop: borderStyle,
3013
+ }
3014
+ : undefined;
3015
+ return draggingBorders;
3016
+ }, [draggingColumn, hoveredColumn, columnSizingInfo.isResizingColumn]);
3017
+ const handleDragEnter = (_e) => {
3018
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
3019
+ setHoveredColumn(null);
3020
+ }
3021
+ if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
3022
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
3023
+ }
3024
+ };
3025
+ const handleDragOver = (e) => {
3026
+ if (columnDef.enableColumnOrdering !== false) {
3027
+ e.preventDefault();
3028
+ }
3029
+ };
3030
+ const handleKeyDown = (event) => {
3031
+ var _a;
3032
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
3033
+ cellKeyboardShortcuts({
3034
+ cellValue: header.column.columnDef.header,
3035
+ event,
3036
+ header,
3037
+ table,
3038
+ });
3039
+ };
3040
+ const handleRef = useCallback((node) => {
3041
+ var _a;
3042
+ if (node) {
3043
+ if (tableHeadCellRefs.current) {
3044
+ tableHeadCellRefs.current[column.id] = node;
3045
+ }
3046
+ if (columnDefType !== 'group') {
3047
+ (_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
3048
+ }
3049
+ }
3050
+ }, [column.id, columnDefType, columnVirtualizer, tableHeadCellRefs]);
3051
+ const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
3052
+ column,
3053
+ header,
3054
+ table,
3055
+ })) !== null && _b !== void 0 ? _b : columnDef.header;
3056
+ return (jsxs(TableCell, Object.assign({ align: columnDefType === 'group'
3057
+ ? 'center'
3058
+ : theme.direction === 'rtl'
3059
+ ? 'right'
3060
+ : 'left', "aria-sort": column.getIsSorted()
3061
+ ? column.getIsSorted() === 'asc'
3062
+ ? 'ascending'
3063
+ : 'descending'
3064
+ : 'none', colSpan: header.colSpan, "data-can-sort": column.getCanSort() || undefined, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, "data-sort": column.getIsSorted() || undefined, onDragEnter: handleDragEnter, onDragOver: handleDragOver, ref: handleRef, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3065
+ '.MuiButtonBase-root': {
3066
+ opacity: 1,
3067
+ },
3068
+ }, flexDirection: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
3069
+ ? '0.5rem'
3070
+ : density === 'comfortable'
3071
+ ? columnDefType === 'display'
3072
+ ? '0.75rem'
3073
+ : '1rem'
3074
+ : columnDefType === 'display'
3075
+ ? '1rem 1.25rem'
3076
+ : '1.5rem', pb: columnDefType === 'display'
3077
+ ? 0
3078
+ : showColumnFilters || density === 'compact'
3079
+ ? '0.4rem'
3080
+ : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
3081
+ ? '0.25rem'
3082
+ : density === 'comfortable'
3083
+ ? '.75rem'
3084
+ : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top' }, getCommonMRTCellStyles({
3085
+ column,
3086
+ header,
3087
+ table,
3088
+ tableCellProps,
3089
+ theme,
3090
+ })), draggingBorders)), children: [header.isPlaceholder
3091
+ ? null
3092
+ : ((_c = tableCellProps.children) !== null && _c !== void 0 ? _c : (jsxs(Box, { className: "Mui-TableHeadCell-Content", sx: {
3093
+ alignItems: 'center',
3094
+ display: 'flex',
3095
+ flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
3096
+ justifyContent: columnDefType === 'group' ||
3097
+ (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
3098
+ ? 'center'
3099
+ : column.getCanResize()
3100
+ ? 'space-between'
3101
+ : 'flex-start',
3102
+ position: 'relative',
3103
+ width: '100%',
3104
+ }, children: [jsxs(Box, { className: "Mui-TableHeadCell-Content-Labels", onClick: column.getToggleSortingHandler(), sx: {
3105
+ alignItems: 'center',
3106
+ cursor: column.getCanSort() && columnDefType !== 'group'
3107
+ ? 'pointer'
3108
+ : undefined,
3109
+ display: 'flex',
3110
+ flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
3111
+ overflow: columnDefType === 'data' ? 'hidden' : undefined,
3112
+ pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
3113
+ ? `${headerPL}rem`
3114
+ : undefined,
3115
+ }, children: [jsx(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
3116
+ '&:hover': {
3117
+ textOverflow: 'clip',
3118
+ },
3119
+ minWidth: `${Math.min((_f = (_d = columnDef.header) === null || _d === void 0 ? void 0 : _d.length) !== null && _f !== void 0 ? _f : 0, 4)}ch`,
3120
+ overflow: columnDefType === 'data' ? 'hidden' : undefined,
3121
+ textOverflow: 'ellipsis',
3122
+ whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
3123
+ ? 'nowrap'
3124
+ : 'normal',
3125
+ }, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
3126
+ whiteSpace: 'nowrap',
3127
+ }, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
3128
+ current: (_j = tableHeadCellRefs.current) === null || _j === void 0 ? void 0 : _j[column.id],
3129
+ } })), showColumnActions && (jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] }))), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
3130
+ };
3131
+
3132
+ const MRT_TableHeadRow = (_a) => {
3133
+ var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
3134
+ const { options: { enableStickyHeader, layoutMode, mrtTheme: { baseBackgroundColor }, muiTableHeadRowProps, }, } = table;
3135
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
3136
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
3137
+ headerGroup,
3138
+ table,
3139
+ })), rest);
3140
+ return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: baseBackgroundColor, boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: enableStickyHeader && layoutMode === 'semantic'
3141
+ ? 'sticky'
3142
+ : 'relative', top: 0 }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader, staticColumnIndex) => {
3143
+ let header = headerOrVirtualHeader;
3144
+ if (columnVirtualizer) {
3145
+ staticColumnIndex = headerOrVirtualHeader
3146
+ .index;
3147
+ header = headerGroup.headers[staticColumnIndex];
3148
+ }
3149
+ return header ? (jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3150
+ }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3151
+ };
3152
+
3153
+ const MRT_TableHead = (_a) => {
3154
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
3155
+ const { getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
3156
+ const { isFullScreen, showAlertBanner } = getState();
3157
+ const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
3158
+ const stickyHeader = enableStickyHeader || isFullScreen;
3159
+ return (jsx(TableHead, Object.assign({}, tableHeadProps, { ref: (ref) => {
3160
+ tableHeadRef.current = ref;
3161
+ if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
3162
+ // @ts-expect-error
3163
+ tableHeadProps.ref.current = ref;
3164
+ }
3165
+ }, sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, parseFromValuesOrFunc(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx, theme))), children: positionToolbarAlertBanner === 'head-overlay' &&
3166
+ (showAlertBanner || table.getSelectedRowModel().rows.length > 0) ? (jsx("tr", { style: {
3167
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3168
+ }, children: jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
3169
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3170
+ padding: 0,
3171
+ }, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (table
3172
+ .getHeaderGroups()
3173
+ .map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
3174
+ };
3175
+
3176
+ const MRT_GlobalFilterTextField = (_a) => {
3177
+ var _b, _c;
3178
+ var { table } = _a, rest = __rest(_a, ["table"]);
3179
+ const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
3180
+ const { globalFilter, showGlobalFilter } = getState();
3181
+ const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiSearchTextFieldProps, {
3182
+ table,
3183
+ })), rest);
3184
+ const isMounted = useRef(false);
3185
+ const [anchorEl, setAnchorEl] = useState(null);
3186
+ const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
3187
+ const handleChangeDebounced = useCallback(debounce((event) => {
3188
+ var _a;
3189
+ setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
3190
+ }, manualFiltering ? 500 : 250), []);
3191
+ const handleChange = (event) => {
3192
+ setSearchValue(event.target.value);
3193
+ handleChangeDebounced(event);
3194
+ };
3195
+ const handleGlobalFilterMenuOpen = (event) => {
3196
+ setAnchorEl(event.currentTarget);
3197
+ };
3198
+ const handleClear = () => {
3199
+ setSearchValue('');
3200
+ setGlobalFilter(undefined);
3201
+ };
3202
+ useEffect(() => {
3203
+ if (isMounted.current) {
3204
+ if (globalFilter === undefined) {
3205
+ handleClear();
3206
+ }
3207
+ else {
3208
+ setSearchValue(globalFilter);
3209
+ }
3210
+ }
3211
+ isMounted.current = true;
3212
+ }, [globalFilter]);
3213
+ const consumerSlots = getTextFieldSlotProps(textFieldProps.slotProps);
3214
+ return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ onChange: handleChange, placeholder: localization.search, size: "small", value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "outlined" }, textFieldProps, { inputRef: (inputRef) => {
3215
+ searchInputRef.current = inputRef;
3216
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
3217
+ textFieldProps.inputRef = inputRef;
3218
+ }
3219
+ }, slotProps: {
3220
+ htmlInput: Object.assign({ autoComplete: 'off' }, consumerSlots.htmlInput),
3221
+ input: Object.assign(Object.assign({ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { title: (_b = localization.clearSearch) !== null && _b !== void 0 ? _b : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsx(CloseIcon, {}) }) }) }) })), startAdornment: enableGlobalFilterModes ? (jsx(InputAdornment, { position: "start", children: jsx(Tooltip, { title: localization.changeSearchMode, children: jsx(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(SearchIcon, {}) }) }) })) : (jsx(SearchIcon, { style: { marginRight: '4px' } })) }, consumerSlots.input), { sx: Object.assign({ mb: 0 }, (_c = consumerSlots.input) === null || _c === void 0 ? void 0 : _c.sx) }),
3222
+ } })), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, onSelect: handleClear, setAnchorEl: setAnchorEl, table: table })] }));
3223
+ };
3224
+
3225
+ const flexRender = flexRender$1;
3226
+ function createMRTColumnHelper() {
3227
+ return {
3228
+ accessor: (accessor, column) => {
3229
+ return typeof accessor === 'function'
3230
+ ? Object.assign(Object.assign({}, column), { accessorFn: accessor })
3231
+ : Object.assign(Object.assign({}, column), { accessorKey: accessor });
3232
+ },
3233
+ display: (column) => column,
3234
+ group: (column) => column,
3235
+ };
3236
+ }
3237
+ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => createRow$1(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
3238
+ [getColumnId(col)]: '',
3239
+ }))), rowIndex, depth, subRows, parentId);
3240
+
3241
+ const getMRT_RowActionsColumnDef = (tableOptions) => {
3242
+ return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
3243
+ header: 'actions',
3244
+ id: 'mrt-row-actions',
3245
+ size: 70,
3246
+ tableOptions,
3247
+ }));
3248
+ };
3249
+
3250
+ const getMRT_RowDragColumnDef = (tableOptions) => {
3251
+ return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
3252
+ header: 'move',
3253
+ id: 'mrt-row-drag',
3254
+ size: 60,
3255
+ tableOptions,
3256
+ }));
3257
+ };
3258
+
3259
+ const getMRT_RowExpandColumnDef = (tableOptions) => {
3260
+ var _a;
3261
+ const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
3262
+ const alignProps = positionExpandColumn === 'last'
3263
+ ? {
3264
+ align: 'right',
3265
+ }
3266
+ : undefined;
3267
+ return Object.assign({ Cell: ({ cell, column, row, staticRowIndex, table }) => {
3268
+ var _a, _b, _c;
3269
+ const expandButtonProps = { row, staticRowIndex, table };
3270
+ const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
3271
+ if (groupedColumnMode === 'remove' && row.groupingColumnId) {
3272
+ return (jsxs(Stack, { sx: {
3273
+ alignItems: "center",
3274
+ flexDirection: "row",
3275
+ gap: "0.25rem"
3276
+ }, children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsx(Tooltip, Object.assign({}, getCommonTooltipProps('right'), { title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) })), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
3277
+ }
3278
+ else {
3279
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, { cell, column, row, table })] }));
3280
+ }
3281
+ }, Header: enableExpandAll
3282
+ ? ({ table }) => {
3283
+ var _a;
3284
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandAllButton, { table: table }), groupedColumnMode === 'remove' &&
3285
+ ((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
3286
+ }
3287
+ : undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
3288
+ header: 'expand',
3289
+ id: 'mrt-row-expand',
3290
+ size: groupedColumnMode === 'remove'
3291
+ ? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
3292
+ : renderDetailPanel
3293
+ ? enableExpandAll
3294
+ ? 60
3295
+ : 70
3296
+ : 100,
3297
+ tableOptions,
3298
+ }));
3299
+ };
3300
+
3301
+ const getMRT_RowNumbersColumnDef = (tableOptions) => {
3302
+ const { localization, rowNumberDisplayMode } = tableOptions;
3303
+ const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
3304
+ return Object.assign({ Cell: ({ row, staticRowIndex }) => {
3305
+ var _a;
3306
+ return ((_a = (rowNumberDisplayMode === 'static'
3307
+ ? (staticRowIndex || 0) + (pageSize || 0) * (pageIndex || 0)
3308
+ : row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
3309
+ }, grow: false, Header: () => localization.rowNumber }, defaultDisplayColumnProps({
3310
+ header: 'rowNumbers',
3311
+ id: 'mrt-row-numbers',
3312
+ size: 50,
3313
+ tableOptions,
3314
+ }));
3315
+ };
3316
+
3317
+ const getMRT_RowPinningColumnDef = (tableOptions) => {
3318
+ return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
3319
+ header: 'pin',
3320
+ id: 'mrt-row-pin',
3321
+ size: 60,
3322
+ tableOptions,
3323
+ }));
3324
+ };
3325
+
3326
+ const getMRT_RowSelectColumnDef = (tableOptions) => {
3327
+ const { enableMultiRowSelection, enableSelectAll } = tableOptions;
3328
+ return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), grow: false, Header: enableSelectAll && enableMultiRowSelection
3329
+ ? ({ table }) => jsx(MRT_SelectCheckbox, { table: table })
3330
+ : undefined }, defaultDisplayColumnProps({
3331
+ header: 'select',
3332
+ id: 'mrt-row-select',
3333
+ size: enableSelectAll ? 60 : 70,
3334
+ tableOptions,
3335
+ }));
3336
+ };
3337
+
3338
+ const MRT_AggregationFns = Object.assign({}, aggregationFns);
3339
+
3340
+ const fuzzy = (row, columnId, filterValue, addMeta) => {
3341
+ const itemRank = rankItem(row.getValue(columnId), filterValue, {
3342
+ threshold: rankings.MATCHES,
3343
+ });
3344
+ addMeta(itemRank);
3345
+ return itemRank.passed;
3346
+ };
3347
+ fuzzy.autoRemove = (val) => !val;
3348
+ const contains = (row, id, filterValue) => {
3349
+ var _a;
3350
+ return !!((_a = row
3351
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
3352
+ };
3353
+ contains.autoRemove = (val) => !val;
3354
+ const startsWith = (row, id, filterValue) => {
3355
+ var _a;
3356
+ return !!((_a = row
3357
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
3358
+ };
3359
+ startsWith.autoRemove = (val) => !val;
3360
+ const endsWith = (row, id, filterValue) => {
3361
+ var _a;
3362
+ return !!((_a = row
3363
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
3364
+ };
3365
+ endsWith.autoRemove = (val) => !val;
3366
+ const equals = (row, id, filterValue) => {
3367
+ var _a;
3368
+ return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
3369
+ filterValue.toString().toLowerCase().trim();
3370
+ };
3371
+ equals.autoRemove = (val) => !val;
3372
+ const notEquals = (row, id, filterValue) => {
3373
+ var _a;
3374
+ return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
3375
+ filterValue.toString().toLowerCase().trim();
3376
+ };
3377
+ notEquals.autoRemove = (val) => !val;
3378
+ const greaterThan = (row, id, filterValue) => {
3379
+ var _a, _b, _c;
3380
+ return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
3381
+ ? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
3382
+ : ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
3383
+ };
3384
+ greaterThan.autoRemove = (val) => !val;
3385
+ const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
3386
+ greaterThanOrEqualTo.autoRemove = (val) => !val;
3387
+ const lessThan = (row, id, filterValue) => {
3388
+ var _a, _b, _c;
3389
+ return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
3390
+ ? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
3391
+ : ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
3392
+ };
3393
+ lessThan.autoRemove = (val) => !val;
3394
+ const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
3395
+ lessThanOrEqualTo.autoRemove = (val) => !val;
3396
+ const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
3397
+ greaterThan(row, id, filterValues[0])) &&
3398
+ ((!isNaN(+filterValues[0]) &&
3399
+ !isNaN(+filterValues[1]) &&
3400
+ +filterValues[0] > +filterValues[1]) ||
3401
+ ['', undefined].includes(filterValues[1]) ||
3402
+ lessThan(row, id, filterValues[1]));
3403
+ between.autoRemove = (val) => !val;
3404
+ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
3405
+ greaterThanOrEqualTo(row, id, filterValues[0])) &&
3406
+ ((!isNaN(+filterValues[0]) &&
3407
+ !isNaN(+filterValues[1]) &&
3408
+ +filterValues[0] > +filterValues[1]) ||
3409
+ ['', undefined].includes(filterValues[1]) ||
3410
+ lessThanOrEqualTo(row, id, filterValues[1]));
3411
+ betweenInclusive.autoRemove = (val) => !val;
3412
+ const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
3413
+ empty.autoRemove = (val) => !val;
3414
+ const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
3415
+ notEmpty.autoRemove = (val) => !val;
3416
+ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
3417
+ betweenInclusive,
3418
+ contains,
3419
+ empty,
3420
+ endsWith,
3421
+ equals,
3422
+ fuzzy,
3423
+ greaterThan,
3424
+ greaterThanOrEqualTo,
3425
+ lessThan,
3426
+ lessThanOrEqualTo,
3427
+ notEmpty,
3428
+ notEquals,
3429
+ startsWith });
3430
+
3431
+ const MRT_Default_Icons = {
3432
+ ArrowDownwardIcon,
3433
+ ArrowRightIcon,
3434
+ CancelIcon,
3435
+ ChevronLeftIcon,
3436
+ ChevronRightIcon,
3437
+ ClearAllIcon,
3438
+ CloseIcon,
3439
+ ContentCopy,
3440
+ DensityLargeIcon,
3441
+ DensityMediumIcon,
3442
+ DensitySmallIcon,
3443
+ DragHandleIcon,
3444
+ DynamicFeedIcon,
3445
+ EditIcon,
3446
+ ExpandMoreIcon,
3447
+ FilterAltIcon,
3448
+ FilterListIcon,
3449
+ FilterListOffIcon,
3450
+ FirstPageIcon,
3451
+ FullscreenExitIcon,
3452
+ FullscreenIcon,
3453
+ KeyboardDoubleArrowDownIcon,
3454
+ LastPageIcon,
3455
+ MoreHorizIcon,
3456
+ MoreVertIcon,
3457
+ PushPinIcon,
3458
+ RestartAltIcon,
3459
+ SaveIcon,
3460
+ SearchIcon,
3461
+ SearchOffIcon,
3462
+ SortIcon,
3463
+ SyncAltIcon,
3464
+ ViewColumnIcon,
3465
+ VisibilityOffIcon,
3466
+ };
3467
+
3468
+ const MRT_Localization_EN = {
3469
+ language: 'en',
3470
+ actions: 'Actions',
3471
+ and: 'and',
3472
+ cancel: 'Cancel',
3473
+ changeFilterMode: 'Change filter mode',
3474
+ changeSearchMode: 'Change search mode',
3475
+ clearFilter: 'Clear filter',
3476
+ clearSearch: 'Clear search',
3477
+ clearSelection: 'Clear selection',
3478
+ clearSort: 'Clear sort',
3479
+ clickToCopy: 'Click to copy',
3480
+ copy: 'Copy',
3481
+ collapse: 'Collapse',
3482
+ collapseAll: 'Collapse all',
3483
+ columnActions: 'Column Actions',
3484
+ copiedToClipboard: 'Copied to clipboard',
3485
+ dropToGroupBy: 'Drop to group by {column}',
3486
+ edit: 'Edit',
3487
+ expand: 'Expand',
3488
+ expandAll: 'Expand all',
3489
+ filterArrIncludes: 'Includes',
3490
+ filterArrIncludesAll: 'Includes all',
3491
+ filterArrIncludesSome: 'Includes',
3492
+ filterBetween: 'Between',
3493
+ filterBetweenInclusive: 'Between Inclusive',
3494
+ filterByColumn: 'Filter by {column}',
3495
+ filterContains: 'Contains',
3496
+ filterEmpty: 'Empty',
3497
+ filterEndsWith: 'Ends With',
3498
+ filterEquals: 'Equals',
3499
+ filterEqualsString: 'Equals',
3500
+ filterFuzzy: 'Fuzzy',
3501
+ filterGreaterThan: 'Greater Than',
3502
+ filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
3503
+ filterInNumberRange: 'Between',
3504
+ filterIncludesString: 'Contains',
3505
+ filterIncludesStringSensitive: 'Contains',
3506
+ filterLessThan: 'Less Than',
3507
+ filterLessThanOrEqualTo: 'Less Than Or Equal To',
3508
+ filterMode: 'Filter Mode: {filterType}',
3509
+ filterNotEmpty: 'Not Empty',
3510
+ filterNotEquals: 'Not Equals',
3511
+ filterStartsWith: 'Starts With',
3512
+ filterWeakEquals: 'Equals',
3513
+ filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
3514
+ goToFirstPage: 'Go to first page',
3515
+ goToLastPage: 'Go to last page',
3516
+ goToNextPage: 'Go to next page',
3517
+ goToPreviousPage: 'Go to previous page',
3518
+ grab: 'Grab',
3519
+ groupByColumn: 'Group by {column}',
3520
+ groupedBy: 'Grouped by ',
3521
+ hideAll: 'Hide all',
3522
+ hideColumn: 'Hide {column} column',
3523
+ max: 'Max',
3524
+ min: 'Min',
3525
+ move: 'Move',
3526
+ noRecordsToDisplay: 'No records to display',
3527
+ noResultsFound: 'No results found',
3528
+ of: 'of',
3529
+ or: 'or',
3530
+ pin: 'Pin',
3531
+ pinToLeft: 'Pin to left',
3532
+ pinToRight: 'Pin to right',
3533
+ resetColumnSize: 'Reset column size',
3534
+ resetOrder: 'Reset order',
3535
+ rowActions: 'Row Actions',
3536
+ rowNumber: '#',
3537
+ rowNumbers: 'Row Numbers',
3538
+ rowsPerPage: 'Rows per page',
3539
+ save: 'Save',
3540
+ search: 'Search',
3541
+ selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
3542
+ select: 'Select',
3543
+ showAll: 'Show all',
3544
+ showAllColumns: 'Show all columns',
3545
+ showHideColumns: 'Show/Hide columns',
3546
+ showHideFilters: 'Show/Hide filters',
3547
+ showHideSearch: 'Show/Hide search',
3548
+ sortByColumnAsc: 'Sort by {column} ascending',
3549
+ sortByColumnDesc: 'Sort by {column} descending',
3550
+ sortedByColumnAsc: 'Sorted by {column} ascending',
3551
+ sortedByColumnDesc: 'Sorted by {column} descending',
3552
+ thenBy: ', then by ',
3553
+ toggleDensity: 'Toggle density',
3554
+ toggleFullScreen: 'Toggle full screen',
3555
+ toggleSelectAll: 'Toggle select all',
3556
+ toggleSelectRow: 'Toggle select row',
3557
+ toggleVisibility: 'Toggle visibility',
3558
+ ungroupByColumn: 'Ungroup by {column}',
3559
+ unpin: 'Unpin',
3560
+ unpinAll: 'Unpin all',
3561
+ };
3562
+
3563
+ const MRT_DefaultColumn = {
3564
+ filterVariant: 'text',
3565
+ maxSize: 1000,
3566
+ minSize: 40,
3567
+ size: 180,
3568
+ };
3569
+ const MRT_DefaultDisplayColumn = {
3570
+ columnDefType: 'display',
3571
+ enableClickToCopy: false,
3572
+ enableColumnActions: false,
3573
+ enableColumnDragging: false,
3574
+ enableColumnFilter: false,
3575
+ enableColumnOrdering: false,
3576
+ enableEditing: false,
3577
+ enableGlobalFilter: false,
3578
+ enableGrouping: false,
3579
+ enableHiding: false,
3580
+ enableResizing: false,
3581
+ enableSorting: false,
3582
+ };
3583
+ const useMRT_TableOptions = (_a) => {
3584
+ var _b;
3585
+ var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
3586
+ const theme = useTheme();
3587
+ icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
3588
+ localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
3589
+ mrtTheme = useMemo(() => getMRTTheme(mrtTheme, theme), [mrtTheme, theme]);
3590
+ aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
3591
+ filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
3592
+ sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
3593
+ defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
3594
+ defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
3595
+ //cannot be changed after initialization
3596
+ [enableColumnVirtualization, enableRowVirtualization] = useMemo(() => [enableColumnVirtualization, enableRowVirtualization], []);
3597
+ if (!columnResizeDirection) {
3598
+ columnResizeDirection = theme.direction || 'ltr';
3599
+ }
3600
+ layoutMode =
3601
+ layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
3602
+ if (layoutMode === 'semantic' &&
3603
+ (enableRowVirtualization || enableColumnVirtualization)) {
3604
+ layoutMode = 'grid';
3605
+ }
3606
+ if (enableRowVirtualization) {
3607
+ enableStickyHeader = true;
3608
+ }
3609
+ if (enablePagination === false && manualPagination === undefined) {
3610
+ manualPagination = true;
3611
+ }
3612
+ if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
3613
+ manualFiltering = true;
3614
+ manualGrouping = true;
3615
+ manualPagination = true;
3616
+ manualSorting = true;
3617
+ }
3618
+ return Object.assign({ aggregationFns,
3619
+ autoResetExpanded,
3620
+ columnFilterDisplayMode,
3621
+ columnResizeDirection,
3622
+ columnResizeMode,
3623
+ createDisplayMode,
3624
+ defaultColumn,
3625
+ defaultDisplayColumn,
3626
+ editDisplayMode,
3627
+ enableBatchRowSelection,
3628
+ enableBottomToolbar,
3629
+ enableColumnActions,
3630
+ enableColumnFilters,
3631
+ enableColumnOrdering,
3632
+ enableColumnPinning,
3633
+ enableColumnResizing,
3634
+ enableColumnVirtualization,
3635
+ enableDensityToggle,
3636
+ enableExpandAll,
3637
+ enableExpanding,
3638
+ enableFacetedValues,
3639
+ enableFilterMatchHighlighting,
3640
+ enableFilters,
3641
+ enableFullScreenToggle,
3642
+ enableGlobalFilter,
3643
+ enableGlobalFilterRankedResults,
3644
+ enableGrouping,
3645
+ enableHiding,
3646
+ enableKeyboardShortcuts,
3647
+ enableMultiRowSelection,
3648
+ enableMultiSort,
3649
+ enablePagination,
3650
+ enableRowPinning,
3651
+ enableRowSelection,
3652
+ enableRowVirtualization,
3653
+ enableSelectAll,
3654
+ enableSorting,
3655
+ enableStickyHeader,
3656
+ enableTableFooter,
3657
+ enableTableHead,
3658
+ enableToolbarInternalActions,
3659
+ enableTopToolbar,
3660
+ filterFns, getCoreRowModel: getCoreRowModel(), getExpandedRowModel: enableExpanding || enableGrouping ? getExpandedRowModel() : undefined, getFacetedMinMaxValues: enableFacetedValues
3661
+ ? getFacetedMinMaxValues()
3662
+ : undefined, getFacetedRowModel: enableFacetedValues ? getFacetedRowModel() : undefined, getFacetedUniqueValues: enableFacetedValues
3663
+ ? getFacetedUniqueValues()
3664
+ : undefined, getFilteredRowModel: (enableColumnFilters || enableGlobalFilter || enableFilters) &&
3665
+ !manualFiltering
3666
+ ? getFilteredRowModel()
3667
+ : undefined, getGroupedRowModel: enableGrouping && !manualGrouping ? getGroupedRowModel() : undefined, getPaginationRowModel: enablePagination && !manualPagination
3668
+ ? getPaginationRowModel()
3669
+ : undefined, getSortedRowModel: enableSorting && !manualSorting ? getSortedRowModel() : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, icons,
3670
+ id,
3671
+ layoutMode,
3672
+ localization,
3673
+ manualFiltering,
3674
+ manualGrouping,
3675
+ manualPagination,
3676
+ manualSorting,
3677
+ mrtTheme,
3678
+ paginationDisplayMode,
3679
+ positionActionsColumn,
3680
+ positionCreatingRow,
3681
+ positionExpandColumn,
3682
+ positionGlobalFilter,
3683
+ positionPagination,
3684
+ positionToolbarAlertBanner,
3685
+ positionToolbarDropZone,
3686
+ rowNumberDisplayMode,
3687
+ rowPinningDisplayMode,
3688
+ selectAllMode,
3689
+ sortingFns }, rest);
3690
+ };
3691
+
3692
+ const blankColProps = {
3693
+ children: null,
3694
+ sx: {
3695
+ minWidth: 0,
3696
+ p: 0,
3697
+ width: 0,
3698
+ },
3699
+ };
3700
+ const getMRT_RowSpacerColumnDef = (tableOptions) => {
3701
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
3702
+ id: 'mrt-row-spacer',
3703
+ size: 0,
3704
+ tableOptions,
3705
+ })), { grow: true }), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
3706
+ };
3707
+
3708
+ const useMRT_Effects = (table) => {
3709
+ const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
3710
+ const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
3711
+ const totalColumnCount = table.options.columns.length;
3712
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
3713
+ const rerender = useReducer(() => ({}), {})[1];
3714
+ const initialBodyHeight = useRef(null);
3715
+ const previousTop = useRef(null);
3716
+ useEffect(() => {
3717
+ if (typeof window !== 'undefined') {
3718
+ initialBodyHeight.current = document.body.style.height;
3719
+ }
3720
+ }, []);
3721
+ //hide scrollbars when table is in full screen mode, preserve body scroll position after full screen exit
3722
+ useEffect(() => {
3723
+ if (typeof window !== 'undefined') {
3724
+ if (isFullScreen) {
3725
+ previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
3726
+ document.body.style.height = '100dvh'; //hide page scrollbars when table is in full screen mode
3727
+ }
3728
+ else {
3729
+ document.body.style.height = initialBodyHeight.current;
3730
+ if (!previousTop.current)
3731
+ return;
3732
+ //restore scroll position
3733
+ window.scrollTo({
3734
+ behavior: 'instant',
3735
+ top: -1 * previousTop.current,
3736
+ });
3737
+ }
3738
+ }
3739
+ }, [isFullScreen]);
3740
+ //recalculate column order when columns change or features are toggled on/off
3741
+ useEffect(() => {
3742
+ if (totalColumnCount !== columnOrder.length) {
3743
+ table.setColumnOrder(getDefaultColumnOrderIds(table.options));
3744
+ }
3745
+ }, [totalColumnCount]);
3746
+ //if page index is out of bounds, set it to the last page
3747
+ useEffect(() => {
3748
+ if (!enablePagination || isLoading || showSkeletons)
3749
+ return;
3750
+ const { pageIndex, pageSize } = pagination;
3751
+ const totalPages = totalRowCount > 0 ? Math.ceil(totalRowCount / pageSize) : 1;
3752
+ const isOutOfBounds = pageIndex < 0 || pageIndex >= totalPages;
3753
+ if (isOutOfBounds) {
3754
+ table.setPageIndex(totalPages - 1);
3755
+ }
3756
+ }, [totalRowCount, enablePagination, isLoading, showSkeletons]);
3757
+ //turn off sort when global filter is looking for ranked results
3758
+ const appliedSort = useRef(sorting);
3759
+ useEffect(() => {
3760
+ if (sorting.length) {
3761
+ appliedSort.current = sorting;
3762
+ }
3763
+ }, [sorting]);
3764
+ useEffect(() => {
3765
+ if (!getCanRankRows(table))
3766
+ return;
3767
+ if (globalFilter) {
3768
+ table.setSorting([]);
3769
+ }
3770
+ else {
3771
+ table.setSorting(() => appliedSort.current || []);
3772
+ }
3773
+ }, [globalFilter]);
3774
+ //fix pinned row top style when density changes
3775
+ useEffect(() => {
3776
+ if (enableRowPinning && getIsSomeRowsPinned()) {
3777
+ setTimeout(() => {
3778
+ rerender();
3779
+ }, 150);
3780
+ }
3781
+ }, [density]);
3782
+ };
3783
+
3784
+ /**
3785
+ * The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
3786
+ * @param definedTableOptions - table options with proper defaults set
3787
+ * @returns the MRT table instance
3788
+ */
3789
+ const useMRT_TableInstance = (definedTableOptions) => {
3790
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
3791
+ const lastSelectedRowId = useRef(null);
3792
+ const actionCellRef = useRef(null);
3793
+ const bottomToolbarRef = useRef(null);
3794
+ const editInputRefs = useRef({});
3795
+ const filterInputRefs = useRef({});
3796
+ const searchInputRef = useRef(null);
3797
+ const tableContainerRef = useRef(null);
3798
+ const tableHeadCellRefs = useRef({});
3799
+ const tablePaperRef = useRef(null);
3800
+ const topToolbarRef = useRef(null);
3801
+ const tableHeadRef = useRef(null);
3802
+ const tableFooterRef = useRef(null);
3803
+ //transform initial state with proper column order
3804
+ const initialState = useMemo(() => {
3805
+ var _a, _b, _c;
3806
+ const initState = (_a = definedTableOptions.initialState) !== null && _a !== void 0 ? _a : {};
3807
+ initState.columnOrder =
3808
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, definedTableOptions), { state: Object.assign(Object.assign({}, definedTableOptions.initialState), definedTableOptions.state) }));
3809
+ initState.globalFilterFn = (_c = definedTableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
3810
+ return initState;
3811
+ }, []);
3812
+ definedTableOptions.initialState = initialState;
3813
+ const [actionCell, setActionCell] = useState((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null);
3814
+ const [creatingRow, _setCreatingRow] = useState((_b = initialState.creatingRow) !== null && _b !== void 0 ? _b : null);
3815
+ const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
3816
+ var _a, _b, _c, _d;
3817
+ return ({
3818
+ [getColumnId(col)]: col.filterFn instanceof Function
3819
+ ? ((_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom')
3820
+ : ((_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col)),
3821
+ });
3822
+ })));
3823
+ const [columnOrder, onColumnOrderChange] = useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
3824
+ const [columnSizingInfo, onColumnSizingInfoChange] = useState((_d = initialState.columnSizingInfo) !== null && _d !== void 0 ? _d : {});
3825
+ const [density, setDensity] = useState((_e = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _e !== void 0 ? _e : 'comfortable');
3826
+ const [draggingColumn, setDraggingColumn] = useState((_f = initialState.draggingColumn) !== null && _f !== void 0 ? _f : null);
3827
+ const [draggingRow, setDraggingRow] = useState((_g = initialState.draggingRow) !== null && _g !== void 0 ? _g : null);
3828
+ const [editingCell, setEditingCell] = useState((_h = initialState.editingCell) !== null && _h !== void 0 ? _h : null);
3829
+ const [editingRow, setEditingRow] = useState((_j = initialState.editingRow) !== null && _j !== void 0 ? _j : null);
3830
+ const [globalFilterFn, setGlobalFilterFn] = useState((_k = initialState.globalFilterFn) !== null && _k !== void 0 ? _k : 'fuzzy');
3831
+ const [grouping, onGroupingChange] = useState((_l = initialState.grouping) !== null && _l !== void 0 ? _l : []);
3832
+ const [hoveredColumn, setHoveredColumn] = useState((_m = initialState.hoveredColumn) !== null && _m !== void 0 ? _m : null);
3833
+ const [hoveredRow, setHoveredRow] = useState((_o = initialState.hoveredRow) !== null && _o !== void 0 ? _o : null);
3834
+ const [isFullScreen, setIsFullScreen] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _p !== void 0 ? _p : false);
3835
+ const [pagination, onPaginationChange] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _q !== void 0 ? _q : { pageIndex: 0, pageSize: 10 });
3836
+ const [showAlertBanner, setShowAlertBanner] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
3837
+ const [showColumnFilters, setShowColumnFilters] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
3838
+ const [showGlobalFilter, setShowGlobalFilter] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
3839
+ const [showToolbarDropZone, setShowToolbarDropZone] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
3840
+ definedTableOptions.state = Object.assign({ actionCell,
3841
+ columnFilterFns,
3842
+ columnOrder,
3843
+ columnSizingInfo,
3844
+ creatingRow,
3845
+ density,
3846
+ draggingColumn,
3847
+ draggingRow,
3848
+ editingCell,
3849
+ editingRow,
3850
+ globalFilterFn,
3851
+ grouping,
3852
+ hoveredColumn,
3853
+ hoveredRow,
3854
+ isFullScreen,
3855
+ pagination,
3856
+ showAlertBanner,
3857
+ showColumnFilters,
3858
+ showGlobalFilter,
3859
+ showToolbarDropZone }, definedTableOptions.state);
3860
+ //The table options now include all state needed to help determine column visibility and order logic
3861
+ const statefulTableOptions = definedTableOptions;
3862
+ //don't recompute columnDefs while resizing column or dragging column/row
3863
+ const columnDefsRef = useRef([]);
3864
+ statefulTableOptions.columns =
3865
+ statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
3866
+ statefulTableOptions.state.draggingColumn ||
3867
+ statefulTableOptions.state.draggingRow
3868
+ ? columnDefsRef.current
3869
+ : prepareColumns({
3870
+ columnDefs: [
3871
+ ...[
3872
+ showRowPinningColumn(statefulTableOptions) &&
3873
+ getMRT_RowPinningColumnDef(statefulTableOptions),
3874
+ showRowDragColumn(statefulTableOptions) &&
3875
+ getMRT_RowDragColumnDef(statefulTableOptions),
3876
+ showRowActionsColumn(statefulTableOptions) &&
3877
+ getMRT_RowActionsColumnDef(statefulTableOptions),
3878
+ showRowExpandColumn(statefulTableOptions) &&
3879
+ getMRT_RowExpandColumnDef(statefulTableOptions),
3880
+ showRowSelectionColumn(statefulTableOptions) &&
3881
+ getMRT_RowSelectColumnDef(statefulTableOptions),
3882
+ showRowNumbersColumn(statefulTableOptions) &&
3883
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
3884
+ ].filter(Boolean),
3885
+ ...statefulTableOptions.columns,
3886
+ ...[
3887
+ showRowSpacerColumn(statefulTableOptions) &&
3888
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
3889
+ ].filter(Boolean),
3890
+ ],
3891
+ tableOptions: statefulTableOptions,
3892
+ });
3893
+ columnDefsRef.current = statefulTableOptions.columns;
3894
+ //if loading, generate blank rows to show skeleton loaders
3895
+ statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading ||
3896
+ statefulTableOptions.state.showSkeletons) &&
3897
+ !statefulTableOptions.data.length
3898
+ ? [
3899
+ ...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null),
3900
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(statefulTableOptions.columns).map((col) => ({
3901
+ [getColumnId(col)]: null,
3902
+ }))))
3903
+ : statefulTableOptions.data, [
3904
+ statefulTableOptions.data,
3905
+ statefulTableOptions.state.isLoading,
3906
+ statefulTableOptions.state.showSkeletons,
3907
+ ]);
3908
+ //@ts-expect-error
3909
+ const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
3910
+ onColumnSizingInfoChange,
3911
+ onGroupingChange,
3912
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_v = statefulTableOptions.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
3913
+ table.refs = {
3914
+ actionCellRef,
3915
+ bottomToolbarRef,
3916
+ editInputRefs,
3917
+ filterInputRefs,
3918
+ lastSelectedRowId,
3919
+ searchInputRef,
3920
+ tableContainerRef,
3921
+ tableFooterRef,
3922
+ tableHeadCellRefs,
3923
+ tableHeadRef,
3924
+ tablePaperRef,
3925
+ topToolbarRef,
3926
+ };
3927
+ table.setActionCell =
3928
+ (_w = statefulTableOptions.onActionCellChange) !== null && _w !== void 0 ? _w : setActionCell;
3929
+ table.setCreatingRow = (row) => {
3930
+ var _a, _b;
3931
+ let _row = row;
3932
+ if (row === true) {
3933
+ _row = createRow(table);
3934
+ }
3935
+ (_b = (_a = statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(statefulTableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
3936
+ };
3937
+ table.setColumnFilterFns =
3938
+ (_x = statefulTableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
3939
+ table.setDensity = (_y = statefulTableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
3940
+ table.setDraggingColumn =
3941
+ (_z = statefulTableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
3942
+ table.setDraggingRow =
3943
+ (_0 = statefulTableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
3944
+ table.setEditingCell =
3945
+ (_1 = statefulTableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
3946
+ table.setEditingRow =
3947
+ (_2 = statefulTableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
3948
+ table.setGlobalFilterFn =
3949
+ (_3 = statefulTableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
3950
+ table.setHoveredColumn =
3951
+ (_4 = statefulTableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
3952
+ table.setHoveredRow =
3953
+ (_5 = statefulTableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
3954
+ table.setIsFullScreen =
3955
+ (_6 = statefulTableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
3956
+ table.setShowAlertBanner =
3957
+ (_7 = statefulTableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
3958
+ table.setShowColumnFilters =
3959
+ (_8 = statefulTableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
3960
+ table.setShowGlobalFilter =
3961
+ (_9 = statefulTableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
3962
+ table.setShowToolbarDropZone =
3963
+ (_10 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
3964
+ useMRT_Effects(table);
3965
+ return table;
3966
+ };
3967
+
3968
+ const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
3969
+
3970
+ const MRT_LinearProgressBar = (_a) => {
3971
+ var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
3972
+ const { getState, options: { muiLinearProgressProps }, } = table;
3973
+ const { isSaving, showProgressBars } = getState();
3974
+ const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
3975
+ isTopToolbar,
3976
+ table,
3977
+ })), rest);
3978
+ return (jsx(Collapse, { in: showProgressBars !== false && (showProgressBars || isSaving), mountOnEnter: true, sx: {
3979
+ bottom: isTopToolbar ? 0 : undefined,
3980
+ position: 'absolute',
3981
+ top: !isTopToolbar ? 0 : undefined,
3982
+ width: '100%',
3983
+ }, unmountOnExit: true, children: jsx(LinearProgress, Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
3984
+ };
3985
+
3986
+ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
3987
+ const MRT_TablePagination = (_a) => {
3988
+ var { position = 'bottom', table } = _a, rest = __rest(_a, ["position", "table"]);
3989
+ const theme = useTheme();
3990
+ const isMobile = useMediaQuery('(max-width: 720px)');
3991
+ const { getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, id, localization, muiPaginationProps, paginationDisplayMode, }, } = table;
3992
+ const { pagination: { pageIndex = 0, pageSize = 10 }, } = getState();
3993
+ const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiPaginationProps, {
3994
+ table,
3995
+ })), rest);
3996
+ const totalRowCount = table.getRowCount();
3997
+ const numberOfPages = table.getPageCount();
3998
+ const showFirstLastPageButtons = numberOfPages > 2;
3999
+ const firstRowIndex = pageIndex * pageSize;
4000
+ const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
4001
+ const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { disabled = false, rowsPerPageOptions = defaultRowsPerPage, SelectProps = {}, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, restPaginationProps = __rest(_b, ["disabled", "rowsPerPageOptions", "SelectProps", "showFirstButton", "showLastButton", "showRowsPerPage"]);
4002
+ const disableBack = pageIndex <= 0 || disabled;
4003
+ const disableNext = lastRowIndex >= totalRowCount || disabled;
4004
+ if (isMobile && (SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.native) !== false) {
4005
+ SelectProps.native = true;
4006
+ }
4007
+ const tooltipProps = getCommonTooltipProps();
4008
+ return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
4009
+ alignItems: 'center',
4010
+ display: 'flex',
4011
+ flexWrap: 'wrap',
4012
+ gap: '8px',
4013
+ justifyContent: { md: 'space-between', sm: 'center' },
4014
+ justifySelf: 'flex-end',
4015
+ mt: position === 'top' && enableToolbarInternalActions
4016
+ ? '3rem'
4017
+ : undefined,
4018
+ position: 'relative',
4019
+ px: '8px',
4020
+ py: '12px',
4021
+ zIndex: 2,
4022
+ }, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: `mrt-rows-per-page-${id}`, sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ disabled: disabled, disableUnderline: true, inputProps: {
4023
+ 'aria-label': localization.rowsPerPage,
4024
+ id: `mrt-rows-per-page-${id}`,
4025
+ }, label: localization.rowsPerPage, MenuProps: { disableScrollLock: true }, onChange: (event) => table.setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
4026
+ var _a;
4027
+ const value = typeof option !== 'number' ? option.value : option;
4028
+ const label = typeof option !== 'number' ? option.label : `${option}`;
4029
+ return ((_a = SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.children) !== null && _a !== void 0 ? _a : ((SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.native) ? (jsx("option", { value: value, children: label }, value)) : (jsx(MenuItem, { sx: { m: 0 }, value: value, children: label }, value))));
4030
+ }) }))] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, Object.assign({ count: numberOfPages, disabled: disabled, onChange: (_e, newPageIndex) => table.setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsx(PaginationItem, Object.assign({ slots: {
4031
+ first: FirstPageIcon,
4032
+ last: LastPageIcon,
4033
+ next: ChevronRightIcon,
4034
+ previous: ChevronLeftIcon,
4035
+ } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, restPaginationProps))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0
4036
+ ? 0
4037
+ : (firstRowIndex + 1).toLocaleString(localization.language)}-${lastRowIndex.toLocaleString(localization.language)} ${localization.of} ${totalRowCount.toLocaleString(localization.language)}` }), jsxs(Box, { sx: {
4038
+ gap: "xs"
4039
+ }, children: [showFirstButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => table.firstPage(), size: "small", children: jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => table.previousPage(), size: "small", children: jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => table.nextPage(), size: "small", children: jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), showLastButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => table.lastPage(), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })))] })] })) : null] }));
4040
+ };
4041
+
4042
+ const MRT_ToolbarDropZone = (_a) => {
4043
+ var _b, _c;
4044
+ var { table } = _a, rest = __rest(_a, ["table"]);
4045
+ const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
4046
+ const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = getState();
4047
+ const handleDragEnter = (_event) => {
4048
+ setHoveredColumn({ id: 'drop-zone' });
4049
+ };
4050
+ const handleDragOver = (e) => {
4051
+ e.preventDefault();
4052
+ };
4053
+ useEffect(() => {
4054
+ var _a;
4055
+ if (((_a = table.options.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
4056
+ setShowToolbarDropZone(!!enableGrouping &&
4057
+ !!draggingColumn &&
4058
+ draggingColumn.columnDef.enableGrouping !== false &&
4059
+ !grouping.includes(draggingColumn.id));
4060
+ }
4061
+ }, [enableGrouping, draggingColumn, grouping]);
4062
+ return (jsx(Fade, { in: showToolbarDropZone, children: jsx(Box, Object.assign({ className: "Mui-ToolbarDropZone", onDragEnter: handleDragEnter, onDragOver: handleDragOver }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', backdropFilter: 'blur(4px)', backgroundColor: alpha(theme.palette.info.main, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1), border: `dashed ${theme.palette.info.main} 2px`, boxSizing: 'border-box', display: 'flex', height: '100%', justifyContent: 'center', position: 'absolute', width: '100%', zIndex: 4 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(Typography, { sx: {
4063
+ fontStyle: "italic"
4064
+ }, children: localization.dropToGroupBy.replace('{column}', (_c = (_b = draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.columnDef) === null || _b === void 0 ? void 0 : _b.header) !== null && _c !== void 0 ? _c : '') }) })) }));
4065
+ };
4066
+
4067
+ const MRT_BottomToolbar = (_a) => {
4068
+ var { table } = _a, rest = __rest(_a, ["table"]);
4069
+ const { getState, options: { enablePagination, muiBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
4070
+ const { isFullScreen } = getState();
4071
+ const isMobile = useMediaQuery('(max-width:720px)');
4072
+ const toolbarProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiBottomToolbarProps, { table })), rest);
4073
+ const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
4074
+ return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (node) => {
4075
+ if (node) {
4076
+ bottomToolbarRef.current = node;
4077
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
4078
+ // @ts-expect-error
4079
+ toolbarProps.ref.current = node;
4080
+ }
4081
+ }
4082
+ }, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, getCommonToolbarStyles({ table})), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${alpha(theme.palette.grey[700], 0.5)} inset`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), parseFromValuesOrFunc(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx, theme))), children: [jsx(MRT_LinearProgressBar, { isTopToolbar: false, table: table }), positionToolbarAlertBanner === 'bottom' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
4083
+ alignItems: 'center',
4084
+ boxSizing: 'border-box',
4085
+ display: 'flex',
4086
+ justifyContent: 'space-between',
4087
+ p: '0.5rem',
4088
+ width: '100%',
4089
+ }, children: [renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (jsx("span", {})), jsx(Box, { sx: {
4090
+ display: 'flex',
4091
+ justifyContent: 'flex-end',
4092
+ position: stackAlertBanner ? 'relative' : 'absolute',
4093
+ right: 0,
4094
+ top: 0,
4095
+ }, children: enablePagination &&
4096
+ ['both', 'bottom'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "bottom", table: table })) })] })] })));
4097
+ };
4098
+
4099
+ const MRT_ToolbarInternalButtons = (_a) => {
4100
+ var _b;
4101
+ var { table } = _a, rest = __rest(_a, ["table"]);
4102
+ const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions, }, } = table;
4103
+ return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', display: 'flex', zIndex: 3 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: (_b = renderToolbarInternalActions === null || renderToolbarInternalActions === void 0 ? void 0 : renderToolbarInternalActions({
4104
+ table,
4105
+ })) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [enableFilters &&
4106
+ enableGlobalFilter &&
4107
+ !(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
4108
+ enableColumnFilters &&
4109
+ columnFilterDisplayMode !== 'popover' && (jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsx(MRT_ToggleFullScreenButton, { table: table }))] })) })));
4110
+ };
4111
+
4112
+ const MRT_TopToolbar = ({ table, }) => {
4113
+ var _a;
4114
+ const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
4115
+ const { isFullScreen, showGlobalFilter } = getState();
4116
+ const isMobile = useMediaQuery('(max-width:720px)');
4117
+ const isTablet = useMediaQuery('(max-width:1024px)');
4118
+ const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
4119
+ const stackAlertBanner = isMobile ||
4120
+ !!renderTopToolbarCustomActions ||
4121
+ (showGlobalFilter && isTablet);
4122
+ const globalFilterProps = {
4123
+ sx: !isTablet
4124
+ ? {
4125
+ zIndex: 2,
4126
+ }
4127
+ : undefined,
4128
+ table,
4129
+ };
4130
+ return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
4131
+ topToolbarRef.current = ref;
4132
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
4133
+ // @ts-expect-error
4134
+ toolbarProps.ref.current = ref;
4135
+ }
4136
+ }, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, getCommonToolbarStyles({ table})), { position: isFullScreen ? 'sticky' : 'relative', top: isFullScreen ? '0' : undefined }), parseFromValuesOrFunc(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx, theme))), children: [positionToolbarAlertBanner === 'top' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
4137
+ alignItems: 'flex-start',
4138
+ boxSizing: 'border-box',
4139
+ display: 'flex',
4140
+ gap: '0.5rem',
4141
+ justifyContent: 'space-between',
4142
+ p: '0.5rem',
4143
+ position: stackAlertBanner ? 'relative' : 'absolute',
4144
+ right: 0,
4145
+ top: 0,
4146
+ width: '100%',
4147
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsx("span", {}), enableToolbarInternalActions ? (jsxs(Box, { sx: {
4148
+ alignItems: 'center',
4149
+ display: 'flex',
4150
+ flexWrap: 'wrap-reverse',
4151
+ gap: '0.5rem',
4152
+ justifyContent: 'flex-end',
4153
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
4154
+ positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), enablePagination &&
4155
+ ['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
4156
+ };
4157
+
4158
+ const MRT_CellActionMenu = (_a) => {
4159
+ var _b, _c;
4160
+ var { table } = _a, rest = __rest(_a, ["table"]);
4161
+ const { getState, options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
4162
+ const { actionCell, density } = getState();
4163
+ const cell = actionCell;
4164
+ const { row } = cell;
4165
+ const { column } = cell;
4166
+ const { columnDef } = column;
4167
+ const handleClose = (event) => {
4168
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
4169
+ table.setActionCell(null);
4170
+ actionCellRef.current = null;
4171
+ };
4172
+ const internalMenuItems = [
4173
+ (parseFromValuesOrFunc(enableClickToCopy, cell) === 'context-menu' ||
4174
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) ===
4175
+ 'context-menu') && (jsx(MRT_ActionMenuItem, { icon: jsx(ContentCopy, {}), label: localization.copy, onClick: (event) => {
4176
+ event.stopPropagation();
4177
+ navigator.clipboard.writeText(cell.getValue());
4178
+ handleClose();
4179
+ }, table: table }, 'mrt-copy')),
4180
+ parseFromValuesOrFunc(enableEditing, row) && editDisplayMode === 'cell' && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: () => {
4181
+ openEditingCell({ cell, table });
4182
+ handleClose();
4183
+ }, table: table }, 'mrt-edit')),
4184
+ ].filter(Boolean);
4185
+ const renderActionProps = {
4186
+ cell,
4187
+ closeMenu: handleClose,
4188
+ column,
4189
+ internalMenuItems,
4190
+ row,
4191
+ table,
4192
+ };
4193
+ const menuItems = (_c = (_b = columnDef.renderCellActionMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, renderActionProps)) !== null && _c !== void 0 ? _c : renderCellActionMenuItems === null || renderCellActionMenuItems === void 0 ? void 0 : renderCellActionMenuItems(renderActionProps);
4194
+ return ((!!(menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) || !!(internalMenuItems === null || internalMenuItems === void 0 ? void 0 : internalMenuItems.length)) && (jsx(Menu, Object.assign({ anchorEl: actionCellRef.current, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: handleClose, open: !!cell, slotProps: {
4195
+ list: {
4196
+ dense: density === 'compact',
4197
+ sx: {
4198
+ backgroundColor: menuBackgroundColor,
4199
+ },
4200
+ },
4201
+ }, transformOrigin: { horizontal: -100, vertical: 8 } }, rest, { children: menuItems !== null && menuItems !== void 0 ? menuItems : internalMenuItems }))));
4202
+ };
4203
+
4204
+ const MRT_EditRowModal = (_a) => {
4205
+ var _b;
4206
+ var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
4207
+ const { getState, options: { localization, muiCreateRowModalProps, muiEditRowDialogProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowDialogContent, renderEditRowDialogContent, }, setCreatingRow, setEditingRow, } = table;
4208
+ const { creatingRow, editingRow } = getState();
4209
+ const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
4210
+ const dialogProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowDialogProps, { row, table })), (creatingRow &&
4211
+ parseFromValuesOrFunc(muiCreateRowModalProps, { row, table }))), rest);
4212
+ const internalEditComponents = row
4213
+ .getAllCells()
4214
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
4215
+ .map((cell) => (jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
4216
+ return (jsx(Dialog, Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
4217
+ var _a;
4218
+ if (creatingRow) {
4219
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
4220
+ setCreatingRow(null);
4221
+ }
4222
+ else {
4223
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
4224
+ setEditingRow(null);
4225
+ }
4226
+ row._valuesCache = {}; //reset values cache
4227
+ (_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
4228
+ }, open: open }, dialogProps, { children: (_b = ((creatingRow &&
4229
+ (renderCreateRowDialogContent === null || renderCreateRowDialogContent === void 0 ? void 0 : renderCreateRowDialogContent({
4230
+ internalEditComponents,
4231
+ row,
4232
+ table,
4233
+ }))) ||
4234
+ (renderEditRowDialogContent === null || renderEditRowDialogContent === void 0 ? void 0 : renderEditRowDialogContent({
4235
+ internalEditComponents,
4236
+ row,
4237
+ table,
4238
+ })))) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [jsx(DialogTitle, { sx: { textAlign: 'center' }, children: localization.edit }), jsx(DialogContent, { children: jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsx(Stack, { sx: {
4239
+ gap: '32px',
4240
+ paddingTop: '16px',
4241
+ width: '100%',
4242
+ }, children: internalEditComponents }) }) }), jsx(DialogActions, { sx: { p: '1.25rem' }, children: jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
4243
+ };
4244
+
4245
+ const useMRT_ColumnVirtualizer = (table) => {
4246
+ var _a, _b, _c, _d;
4247
+ const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
4248
+ const { columnPinning, columnVisibility, draggingColumn } = getState();
4249
+ if (!enableColumnVirtualization)
4250
+ return undefined;
4251
+ const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
4252
+ table,
4253
+ });
4254
+ const visibleColumns = table.getVisibleLeafColumns();
4255
+ const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnPinning
4256
+ ? [
4257
+ table.getLeftVisibleLeafColumns().map((c) => c.getPinnedIndex()),
4258
+ table
4259
+ .getRightVisibleLeafColumns()
4260
+ .map((column) => visibleColumns.length - column.getPinnedIndex() - 1)
4261
+ .sort((a, b) => a - b),
4262
+ ]
4263
+ : [[], []], [columnPinning, columnVisibility, enableColumnPinning]);
4264
+ const numPinnedLeft = leftPinnedIndexes.length;
4265
+ const numPinnedRight = rightPinnedIndexes.length;
4266
+ const draggingColumnIndex = useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
4267
+ ? visibleColumns.findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
4268
+ : undefined, [draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id]);
4269
+ const columnVirtualizer = useVirtualizer(Object.assign({ count: visibleColumns.length, estimateSize: (index) => visibleColumns[index].getSize(), getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
4270
+ const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
4271
+ if (!numPinnedLeft && !numPinnedRight) {
4272
+ return newIndexes;
4273
+ }
4274
+ return [
4275
+ ...new Set([
4276
+ ...leftPinnedIndexes,
4277
+ ...newIndexes,
4278
+ ...rightPinnedIndexes,
4279
+ ]),
4280
+ ];
4281
+ }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps));
4282
+ const virtualColumns = columnVirtualizer.getVirtualItems();
4283
+ columnVirtualizer.virtualColumns = virtualColumns;
4284
+ const numColumns = virtualColumns.length;
4285
+ if (numColumns) {
4286
+ const totalSize = columnVirtualizer.getTotalSize();
4287
+ const leftNonPinnedStart = ((_a = virtualColumns[numPinnedLeft]) === null || _a === void 0 ? void 0 : _a.start) || 0;
4288
+ const leftNonPinnedEnd = ((_b = virtualColumns[leftPinnedIndexes.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0;
4289
+ const rightNonPinnedStart = ((_c = virtualColumns[numColumns - numPinnedRight]) === null || _c === void 0 ? void 0 : _c.start) || 0;
4290
+ const rightNonPinnedEnd = ((_d = virtualColumns[numColumns - numPinnedRight - 1]) === null || _d === void 0 ? void 0 : _d.end) || 0;
4291
+ columnVirtualizer.virtualPaddingLeft =
4292
+ leftNonPinnedStart - leftNonPinnedEnd;
4293
+ columnVirtualizer.virtualPaddingRight =
4294
+ totalSize -
4295
+ rightNonPinnedEnd -
4296
+ (numPinnedRight ? totalSize - rightNonPinnedStart : 0);
4297
+ }
4298
+ if (columnVirtualizerInstanceRef) {
4299
+ //@ts-expect-error
4300
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
4301
+ }
4302
+ return columnVirtualizer;
4303
+ };
4304
+
4305
+ const MRT_Table = (_a) => {
4306
+ var { table } = _a, rest = __rest(_a, ["table"]);
4307
+ const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, renderCaption, }, } = table;
4308
+ const { columnSizing, columnSizingInfo, columnVisibility, isFullScreen } = getState();
4309
+ const tableProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableProps, { table })), rest);
4310
+ const Caption = parseFromValuesOrFunc(renderCaption, { table });
4311
+ const columnSizeVars = useMemo(() => {
4312
+ const headers = getFlatHeaders();
4313
+ const colSizes = {};
4314
+ for (let i = 0; i < headers.length; i++) {
4315
+ const header = headers[i];
4316
+ const colSize = header.getSize();
4317
+ colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
4318
+ colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
4319
+ }
4320
+ return colSizes;
4321
+ }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
4322
+ const columnVirtualizer = useMRT_ColumnVirtualizer(table);
4323
+ const commonTableGroupProps = {
4324
+ columnVirtualizer,
4325
+ table,
4326
+ };
4327
+ return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [!!Caption && jsx("caption", { children: Caption }), enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
4328
+ };
4329
+
4330
+ const MRT_TableLoadingOverlay = (_a) => {
4331
+ var _b;
4332
+ var { table } = _a, rest = __rest(_a, ["table"]);
4333
+ const { options: { id, localization, mrtTheme: { baseBackgroundColor }, muiCircularProgressProps, }, } = table;
4334
+ const circularProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCircularProgressProps, { table })), rest);
4335
+ return (jsx(Box, { sx: {
4336
+ alignItems: 'center',
4337
+ backgroundColor: alpha(baseBackgroundColor, 0.5),
4338
+ bottom: 0,
4339
+ display: 'flex',
4340
+ justifyContent: 'center',
4341
+ left: 0,
4342
+ maxHeight: '100vh',
4343
+ position: 'absolute',
4344
+ right: 0,
4345
+ top: 0,
4346
+ width: '100%',
4347
+ zIndex: 3,
4348
+ }, children: (_b = circularProgressProps === null || circularProgressProps === void 0 ? void 0 : circularProgressProps.Component) !== null && _b !== void 0 ? _b : (jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: `mrt-progress-${id}` }, circularProgressProps))) }));
4349
+ };
4350
+
4351
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
4352
+ const MRT_TableContainer = (_a) => {
4353
+ var { table } = _a, rest = __rest(_a, ["table"]);
4354
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
4355
+ const { actionCell, creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
4356
+ const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
4357
+ const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
4358
+ const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
4359
+ table,
4360
+ })), rest);
4361
+ useIsomorphicLayoutEffect(() => {
4362
+ var _a, _b, _c, _d;
4363
+ const topToolbarHeight = typeof document !== 'undefined'
4364
+ ? ((_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0)
4365
+ : 0;
4366
+ const bottomToolbarHeight = typeof document !== 'undefined'
4367
+ ? ((_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0)
4368
+ : 0;
4369
+ setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
4370
+ });
4371
+ const createModalOpen = createDisplayMode === 'modal' && creatingRow;
4372
+ const editModalOpen = editDisplayMode === 'modal' && editingRow;
4373
+ return (jsxs(TableContainer, Object.assign({ "aria-busy": loading, "aria-describedby": loading ? 'mrt-progress' : undefined }, tableContainerProps, { ref: (node) => {
4374
+ if (node) {
4375
+ tableContainerRef.current = node;
4376
+ if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
4377
+ //@ts-expect-error
4378
+ tableContainerProps.ref.current = node;
4379
+ }
4380
+ }
4381
+ }, style: Object.assign({ maxHeight: isFullScreen
4382
+ ? `calc(100vh - ${totalToolbarHeight}px)`
4383
+ : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
4384
+ ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
4385
+ : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table })), enableCellActions && actionCell && jsx(MRT_CellActionMenu, { table: table })] })));
4386
+ };
4387
+
4388
+ const MRT_TablePaper = (_a) => {
4389
+ var _b, _c;
4390
+ var { table } = _a, rest = __rest(_a, ["table"]);
4391
+ const { getState, options: { enableBottomToolbar, enableTopToolbar, mrtTheme: { baseBackgroundColor }, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
4392
+ const { isFullScreen } = getState();
4393
+ const paperProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTablePaperProps, { table })), rest);
4394
+ const theme = useTheme();
4395
+ return (jsxs(Paper, Object.assign({ elevation: 2, onKeyDown: (e) => e.key === 'Escape' && table.setIsFullScreen(false) }, paperProps, { ref: (ref) => {
4396
+ tablePaperRef.current = ref;
4397
+ if (paperProps === null || paperProps === void 0 ? void 0 : paperProps.ref) {
4398
+ //@ts-expect-error
4399
+ paperProps.ref.current = ref;
4400
+ }
4401
+ }, style: Object.assign(Object.assign({}, (isFullScreen
4402
+ ? {
4403
+ bottom: 0,
4404
+ height: '100dvh',
4405
+ left: 0,
4406
+ margin: 0,
4407
+ maxHeight: '100dvh',
4408
+ maxWidth: '100dvw',
4409
+ padding: 0,
4410
+ position: 'fixed',
4411
+ right: 0,
4412
+ top: 0,
4413
+ width: '100dvw',
4414
+ zIndex: theme.zIndex.modal,
4415
+ }
4416
+ : {})), paperProps === null || paperProps === void 0 ? void 0 : paperProps.style), sx: (theme) => (Object.assign({ backgroundColor: baseBackgroundColor, backgroundImage: 'unset', overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(paperProps === null || paperProps === void 0 ? void 0 : paperProps.sx, theme))), children: [enableTopToolbar &&
4417
+ ((_b = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _b !== void 0 ? _b : (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
4418
+ ((_c = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _c !== void 0 ? _c : (jsx(MRT_BottomToolbar, { table: table })))] })));
4419
+ };
4420
+
4421
+ const isTableInstanceProp = (props) => props.table !== undefined;
4422
+ const MaterialReactTable = (props) => {
4423
+ let table;
4424
+ if (isTableInstanceProp(props)) {
4425
+ table = props.table;
4426
+ }
4427
+ else {
4428
+ table = useMaterialReactTable(props);
4429
+ }
4430
+ return jsx(MRT_TablePaper, { table: table });
4431
+ };
4432
+
4433
+ export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, cellKeyboardShortcuts, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
4434
+ //# sourceMappingURL=index.esm.js.map