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