material-react-table 1.14.0 → 2.0.0-alpha.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 (467) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/index.js +1629 -1323
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/MaterialReactTable.d.ts +7 -11
  5. package/dist/cjs/types/body/MRT_TableBody.d.ts +4 -5
  6. package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +5 -5
  7. package/dist/cjs/types/body/MRT_TableBodyCellValue.d.ts +4 -4
  8. package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +5 -6
  9. package/dist/cjs/types/body/MRT_TableBodyRowGrabHandle.d.ts +5 -5
  10. package/dist/cjs/types/body/MRT_TableDetailPanel.d.ts +6 -6
  11. package/dist/cjs/types/body/index.d.ts +6 -0
  12. package/dist/cjs/types/buttons/MRT_ColumnPinningButtons.d.ts +2 -2
  13. package/dist/cjs/types/buttons/MRT_CopyButton.d.ts +2 -2
  14. package/dist/cjs/types/buttons/MRT_EditActionButtons.d.ts +2 -2
  15. package/dist/cjs/types/buttons/MRT_ExpandAllButton.d.ts +3 -3
  16. package/dist/cjs/types/buttons/MRT_ExpandButton.d.ts +2 -2
  17. package/dist/cjs/types/buttons/MRT_GrabHandleButton.d.ts +2 -2
  18. package/dist/cjs/types/buttons/MRT_ShowHideColumnsButton.d.ts +2 -2
  19. package/dist/cjs/types/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -2
  20. package/dist/cjs/types/buttons/MRT_ToggleFiltersButton.d.ts +2 -2
  21. package/dist/cjs/types/buttons/MRT_ToggleFullScreenButton.d.ts +7 -0
  22. package/dist/cjs/types/buttons/MRT_ToggleGlobalFilterButton.d.ts +2 -2
  23. package/dist/cjs/types/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -2
  24. package/dist/cjs/types/buttons/index.d.ts +12 -0
  25. package/dist/cjs/types/column.utils.d.ts +39 -51
  26. package/dist/cjs/types/filterFns.d.ts +14 -14
  27. package/dist/cjs/types/footer/MRT_TableFooter.d.ts +3 -3
  28. package/dist/cjs/types/footer/MRT_TableFooterCell.d.ts +4 -4
  29. package/dist/cjs/types/footer/MRT_TableFooterRow.d.ts +4 -4
  30. package/dist/cjs/types/footer/index.d.ts +3 -0
  31. package/dist/cjs/types/head/MRT_TableHead.d.ts +3 -3
  32. package/dist/cjs/types/head/MRT_TableHeadCell.d.ts +4 -4
  33. package/dist/cjs/types/head/MRT_TableHeadCellColumnActionsButton.d.ts +4 -4
  34. package/dist/cjs/types/head/MRT_TableHeadCellFilterContainer.d.ts +4 -4
  35. package/dist/cjs/types/head/MRT_TableHeadCellFilterLabel.d.ts +4 -4
  36. package/dist/cjs/types/head/MRT_TableHeadCellGrabHandle.d.ts +4 -4
  37. package/dist/cjs/types/head/MRT_TableHeadCellResizeHandle.d.ts +4 -4
  38. package/dist/cjs/types/head/MRT_TableHeadCellSortLabel.d.ts +4 -4
  39. package/dist/cjs/types/head/MRT_TableHeadRow.d.ts +4 -4
  40. package/dist/cjs/types/head/index.d.ts +9 -0
  41. package/dist/cjs/types/hooks/useMRT_DisplayColumns.d.ts +9 -0
  42. package/dist/cjs/types/hooks/useMRT_Effects.d.ts +2 -0
  43. package/dist/cjs/types/hooks/useMRT_TableInstance.d.ts +2 -0
  44. package/dist/cjs/types/hooks/useMRT_TableOptions.d.ts +2 -0
  45. package/dist/cjs/types/index.d.ts +14 -25
  46. package/dist/cjs/types/inputs/MRT_EditCellTextField.d.ts +2 -3
  47. package/dist/cjs/types/inputs/MRT_FilterCheckbox.d.ts +4 -4
  48. package/dist/cjs/types/inputs/MRT_FilterRangeFields.d.ts +4 -4
  49. package/dist/cjs/types/inputs/MRT_FilterRangeSlider.d.ts +4 -4
  50. package/dist/cjs/types/inputs/MRT_FilterTextField.d.ts +4 -4
  51. package/dist/cjs/types/inputs/MRT_GlobalFilterTextField.d.ts +2 -2
  52. package/dist/cjs/types/inputs/MRT_SelectCheckbox.d.ts +4 -4
  53. package/dist/cjs/types/inputs/index.d.ts +7 -0
  54. package/dist/cjs/types/locales/ar.d.ts +2 -0
  55. package/dist/cjs/types/locales/bg.d.ts +2 -0
  56. package/dist/cjs/types/locales/et.d.ts +2 -0
  57. package/dist/cjs/types/locales/ko.d.ts +2 -0
  58. package/dist/cjs/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
  59. package/dist/cjs/types/menus/MRT_FilterOptionMenu.d.ts +2 -2
  60. package/dist/cjs/types/menus/MRT_RowActionMenu.d.ts +4 -4
  61. package/dist/cjs/types/menus/MRT_ShowHideColumnsMenu.d.ts +2 -2
  62. package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -2
  63. package/dist/cjs/types/menus/index.d.ts +5 -0
  64. package/dist/cjs/types/modals/MRT_EditRowModal.d.ts +7 -0
  65. package/dist/cjs/types/modals/index.d.ts +1 -0
  66. package/dist/cjs/types/sortingFns.d.ts +2 -418
  67. package/dist/cjs/types/table/MRT_Table.d.ts +3 -3
  68. package/dist/cjs/types/table/MRT_TableContainer.d.ts +3 -3
  69. package/dist/cjs/types/table/MRT_TablePaper.d.ts +3 -3
  70. package/dist/cjs/types/table/index.d.ts +4 -0
  71. package/dist/cjs/types/toolbar/MRT_BottomToolbar.d.ts +2 -2
  72. package/dist/cjs/types/toolbar/MRT_LinearProgressBar.d.ts +2 -2
  73. package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
  74. package/dist/cjs/types/toolbar/MRT_ToolbarAlertBanner.d.ts +2 -2
  75. package/dist/cjs/types/toolbar/MRT_ToolbarDropZone.d.ts +2 -2
  76. package/dist/cjs/types/toolbar/MRT_ToolbarInternalButtons.d.ts +2 -2
  77. package/dist/cjs/types/toolbar/MRT_TopToolbar.d.ts +2 -2
  78. package/dist/cjs/types/toolbar/index.d.ts +7 -0
  79. package/dist/cjs/types/types.d.ts +116 -85
  80. package/dist/cjs/types/useMaterialReactTable.d.ts +2 -0
  81. package/dist/esm/material-react-table.esm.js +1559 -1317
  82. package/dist/esm/material-react-table.esm.js.map +1 -1
  83. package/dist/esm/types/MaterialReactTable.d.ts +7 -11
  84. package/dist/esm/types/body/MRT_TableBody.d.ts +4 -5
  85. package/dist/esm/types/body/MRT_TableBodyCell.d.ts +5 -5
  86. package/dist/esm/types/body/MRT_TableBodyCellValue.d.ts +4 -4
  87. package/dist/esm/types/body/MRT_TableBodyRow.d.ts +5 -6
  88. package/dist/esm/types/body/MRT_TableBodyRowGrabHandle.d.ts +5 -5
  89. package/dist/esm/types/body/MRT_TableDetailPanel.d.ts +6 -6
  90. package/dist/esm/types/body/index.d.ts +6 -0
  91. package/dist/esm/types/buttons/MRT_ColumnPinningButtons.d.ts +2 -2
  92. package/dist/esm/types/buttons/MRT_CopyButton.d.ts +2 -2
  93. package/dist/esm/types/buttons/MRT_EditActionButtons.d.ts +2 -2
  94. package/dist/esm/types/buttons/MRT_ExpandAllButton.d.ts +3 -3
  95. package/dist/esm/types/buttons/MRT_ExpandButton.d.ts +2 -2
  96. package/dist/esm/types/buttons/MRT_GrabHandleButton.d.ts +2 -2
  97. package/dist/esm/types/buttons/MRT_ShowHideColumnsButton.d.ts +2 -2
  98. package/dist/esm/types/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -2
  99. package/dist/esm/types/buttons/MRT_ToggleFiltersButton.d.ts +2 -2
  100. package/dist/esm/types/buttons/MRT_ToggleFullScreenButton.d.ts +7 -0
  101. package/dist/esm/types/buttons/MRT_ToggleGlobalFilterButton.d.ts +2 -2
  102. package/dist/esm/types/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -2
  103. package/dist/esm/types/buttons/index.d.ts +12 -0
  104. package/dist/esm/types/column.utils.d.ts +39 -51
  105. package/dist/esm/types/filterFns.d.ts +14 -14
  106. package/dist/esm/types/footer/MRT_TableFooter.d.ts +3 -3
  107. package/dist/esm/types/footer/MRT_TableFooterCell.d.ts +4 -4
  108. package/dist/esm/types/footer/MRT_TableFooterRow.d.ts +4 -4
  109. package/dist/esm/types/footer/index.d.ts +3 -0
  110. package/dist/esm/types/head/MRT_TableHead.d.ts +3 -3
  111. package/dist/esm/types/head/MRT_TableHeadCell.d.ts +4 -4
  112. package/dist/esm/types/head/MRT_TableHeadCellColumnActionsButton.d.ts +4 -4
  113. package/dist/esm/types/head/MRT_TableHeadCellFilterContainer.d.ts +4 -4
  114. package/dist/esm/types/head/MRT_TableHeadCellFilterLabel.d.ts +4 -4
  115. package/dist/esm/types/head/MRT_TableHeadCellGrabHandle.d.ts +4 -4
  116. package/dist/esm/types/head/MRT_TableHeadCellResizeHandle.d.ts +4 -4
  117. package/dist/esm/types/head/MRT_TableHeadCellSortLabel.d.ts +4 -4
  118. package/dist/esm/types/head/MRT_TableHeadRow.d.ts +4 -4
  119. package/dist/esm/types/head/index.d.ts +9 -0
  120. package/dist/esm/types/hooks/useMRT_DisplayColumns.d.ts +9 -0
  121. package/dist/esm/types/hooks/useMRT_Effects.d.ts +2 -0
  122. package/dist/esm/types/hooks/useMRT_TableInstance.d.ts +2 -0
  123. package/dist/esm/types/hooks/useMRT_TableOptions.d.ts +2 -0
  124. package/dist/esm/types/index.d.ts +14 -25
  125. package/dist/esm/types/inputs/MRT_EditCellTextField.d.ts +2 -3
  126. package/dist/esm/types/inputs/MRT_FilterCheckbox.d.ts +4 -4
  127. package/dist/esm/types/inputs/MRT_FilterRangeFields.d.ts +4 -4
  128. package/dist/esm/types/inputs/MRT_FilterRangeSlider.d.ts +4 -4
  129. package/dist/esm/types/inputs/MRT_FilterTextField.d.ts +4 -4
  130. package/dist/esm/types/inputs/MRT_GlobalFilterTextField.d.ts +2 -2
  131. package/dist/esm/types/inputs/MRT_SelectCheckbox.d.ts +4 -4
  132. package/dist/esm/types/inputs/index.d.ts +7 -0
  133. package/dist/esm/types/locales/ar.d.ts +2 -0
  134. package/dist/esm/types/locales/bg.d.ts +2 -0
  135. package/dist/esm/types/locales/et.d.ts +2 -0
  136. package/dist/esm/types/locales/ko.d.ts +2 -0
  137. package/dist/esm/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
  138. package/dist/esm/types/menus/MRT_FilterOptionMenu.d.ts +2 -2
  139. package/dist/esm/types/menus/MRT_RowActionMenu.d.ts +4 -4
  140. package/dist/esm/types/menus/MRT_ShowHideColumnsMenu.d.ts +2 -2
  141. package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -2
  142. package/dist/esm/types/menus/index.d.ts +5 -0
  143. package/dist/esm/types/modals/MRT_EditRowModal.d.ts +7 -0
  144. package/dist/esm/types/modals/index.d.ts +1 -0
  145. package/dist/esm/types/sortingFns.d.ts +2 -418
  146. package/dist/esm/types/table/MRT_Table.d.ts +3 -3
  147. package/dist/esm/types/table/MRT_TableContainer.d.ts +3 -3
  148. package/dist/esm/types/table/MRT_TablePaper.d.ts +3 -3
  149. package/dist/esm/types/table/index.d.ts +4 -0
  150. package/dist/esm/types/toolbar/MRT_BottomToolbar.d.ts +2 -2
  151. package/dist/esm/types/toolbar/MRT_LinearProgressBar.d.ts +2 -2
  152. package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
  153. package/dist/esm/types/toolbar/MRT_ToolbarAlertBanner.d.ts +2 -2
  154. package/dist/esm/types/toolbar/MRT_ToolbarDropZone.d.ts +2 -2
  155. package/dist/esm/types/toolbar/MRT_ToolbarInternalButtons.d.ts +2 -2
  156. package/dist/esm/types/toolbar/MRT_TopToolbar.d.ts +2 -2
  157. package/dist/esm/types/toolbar/index.d.ts +7 -0
  158. package/dist/esm/types/types.d.ts +116 -85
  159. package/dist/esm/types/useMaterialReactTable.d.ts +2 -0
  160. package/dist/index.d.ts +606 -156
  161. package/locales/ar.d.ts +2 -0
  162. package/locales/ar.esm.d.ts +2 -0
  163. package/locales/ar.esm.js +93 -0
  164. package/locales/ar.esm.js.map +1 -0
  165. package/locales/ar.js +97 -0
  166. package/locales/ar.js.map +1 -0
  167. package/locales/bg.d.ts +2 -0
  168. package/locales/bg.esm.d.ts +2 -0
  169. package/locales/bg.esm.js +93 -0
  170. package/locales/bg.esm.js.map +1 -0
  171. package/locales/bg.js +97 -0
  172. package/locales/bg.js.map +1 -0
  173. package/locales/cs.esm.js +1 -2
  174. package/locales/cs.esm.js.map +1 -1
  175. package/locales/cs.js +1 -2
  176. package/locales/cs.js.map +1 -1
  177. package/locales/da.esm.js +0 -1
  178. package/locales/da.esm.js.map +1 -1
  179. package/locales/da.js +0 -1
  180. package/locales/da.js.map +1 -1
  181. package/locales/de.esm.js +0 -1
  182. package/locales/de.esm.js.map +1 -1
  183. package/locales/de.js +0 -1
  184. package/locales/de.js.map +1 -1
  185. package/locales/en.esm.js +0 -1
  186. package/locales/en.esm.js.map +1 -1
  187. package/locales/en.js +0 -1
  188. package/locales/en.js.map +1 -1
  189. package/locales/es.esm.js +0 -1
  190. package/locales/es.esm.js.map +1 -1
  191. package/locales/es.js +0 -1
  192. package/locales/es.js.map +1 -1
  193. package/locales/et.d.ts +2 -0
  194. package/locales/et.esm.d.ts +2 -0
  195. package/locales/et.esm.js +93 -0
  196. package/locales/et.esm.js.map +1 -0
  197. package/locales/et.js +97 -0
  198. package/locales/et.js.map +1 -0
  199. package/locales/fa.esm.js +0 -1
  200. package/locales/fa.esm.js.map +1 -1
  201. package/locales/fa.js +0 -1
  202. package/locales/fa.js.map +1 -1
  203. package/locales/fi.esm.js +0 -1
  204. package/locales/fi.esm.js.map +1 -1
  205. package/locales/fi.js +0 -1
  206. package/locales/fi.js.map +1 -1
  207. package/locales/fr.esm.js +0 -1
  208. package/locales/fr.esm.js.map +1 -1
  209. package/locales/fr.js +0 -1
  210. package/locales/fr.js.map +1 -1
  211. package/locales/hu.esm.js +0 -1
  212. package/locales/hu.esm.js.map +1 -1
  213. package/locales/hu.js +0 -1
  214. package/locales/hu.js.map +1 -1
  215. package/locales/id.esm.js +0 -1
  216. package/locales/id.esm.js.map +1 -1
  217. package/locales/id.js +0 -1
  218. package/locales/id.js.map +1 -1
  219. package/locales/it.esm.js +0 -1
  220. package/locales/it.esm.js.map +1 -1
  221. package/locales/it.js +0 -1
  222. package/locales/it.js.map +1 -1
  223. package/locales/ja.esm.js +0 -1
  224. package/locales/ja.esm.js.map +1 -1
  225. package/locales/ja.js +0 -1
  226. package/locales/ja.js.map +1 -1
  227. package/locales/ko.d.ts +2 -0
  228. package/locales/ko.esm.d.ts +2 -0
  229. package/locales/ko.esm.js +93 -0
  230. package/locales/ko.esm.js.map +1 -0
  231. package/locales/ko.js +97 -0
  232. package/locales/ko.js.map +1 -0
  233. package/locales/nl.esm.js +0 -1
  234. package/locales/nl.esm.js.map +1 -1
  235. package/locales/nl.js +0 -1
  236. package/locales/nl.js.map +1 -1
  237. package/locales/no.esm.js +0 -1
  238. package/locales/no.esm.js.map +1 -1
  239. package/locales/no.js +0 -1
  240. package/locales/no.js.map +1 -1
  241. package/locales/pl.esm.js +0 -1
  242. package/locales/pl.esm.js.map +1 -1
  243. package/locales/pl.js +0 -1
  244. package/locales/pl.js.map +1 -1
  245. package/locales/pt-BR.esm.js +0 -1
  246. package/locales/pt-BR.esm.js.map +1 -1
  247. package/locales/pt-BR.js +0 -1
  248. package/locales/pt-BR.js.map +1 -1
  249. package/locales/pt.esm.js +0 -1
  250. package/locales/pt.esm.js.map +1 -1
  251. package/locales/pt.js +0 -1
  252. package/locales/pt.js.map +1 -1
  253. package/locales/ro.esm.js +0 -1
  254. package/locales/ro.esm.js.map +1 -1
  255. package/locales/ro.js +0 -1
  256. package/locales/ro.js.map +1 -1
  257. package/locales/ru.esm.js +0 -1
  258. package/locales/ru.esm.js.map +1 -1
  259. package/locales/ru.js +0 -1
  260. package/locales/ru.js.map +1 -1
  261. package/locales/sk.esm.js +0 -1
  262. package/locales/sk.esm.js.map +1 -1
  263. package/locales/sk.js +0 -1
  264. package/locales/sk.js.map +1 -1
  265. package/locales/sr-Cyrl-RS.esm.js +0 -1
  266. package/locales/sr-Cyrl-RS.esm.js.map +1 -1
  267. package/locales/sr-Cyrl-RS.js +0 -1
  268. package/locales/sr-Cyrl-RS.js.map +1 -1
  269. package/locales/sr-Latn-RS.esm.js +0 -1
  270. package/locales/sr-Latn-RS.esm.js.map +1 -1
  271. package/locales/sr-Latn-RS.js +0 -1
  272. package/locales/sr-Latn-RS.js.map +1 -1
  273. package/locales/sv.esm.js +0 -1
  274. package/locales/sv.esm.js.map +1 -1
  275. package/locales/sv.js +0 -1
  276. package/locales/sv.js.map +1 -1
  277. package/locales/tr.esm.js +0 -1
  278. package/locales/tr.esm.js.map +1 -1
  279. package/locales/tr.js +0 -1
  280. package/locales/tr.js.map +1 -1
  281. package/locales/uk.esm.js +0 -1
  282. package/locales/uk.esm.js.map +1 -1
  283. package/locales/uk.js +0 -1
  284. package/locales/uk.js.map +1 -1
  285. package/locales/vi.esm.js +0 -1
  286. package/locales/vi.esm.js.map +1 -1
  287. package/locales/vi.js +0 -1
  288. package/locales/vi.js.map +1 -1
  289. package/locales/zh-Hans.esm.js +7 -8
  290. package/locales/zh-Hans.esm.js.map +1 -1
  291. package/locales/zh-Hans.js +7 -8
  292. package/locales/zh-Hans.js.map +1 -1
  293. package/locales/zh-Hant.esm.js +1 -2
  294. package/locales/zh-Hant.esm.js.map +1 -1
  295. package/locales/zh-Hant.js +1 -2
  296. package/locales/zh-Hant.js.map +1 -1
  297. package/package.json +44 -42
  298. package/src/MaterialReactTable.tsx +31 -168
  299. package/src/body/MRT_TableBody.tsx +10 -23
  300. package/src/body/MRT_TableBodyCell.tsx +36 -39
  301. package/src/body/MRT_TableBodyCellValue.tsx +7 -4
  302. package/src/body/MRT_TableBodyRow.tsx +7 -7
  303. package/src/body/MRT_TableBodyRowGrabHandle.tsx +13 -10
  304. package/src/body/MRT_TableDetailPanel.tsx +11 -11
  305. package/src/body/index.ts +6 -0
  306. package/src/buttons/MRT_ColumnPinningButtons.tsx +2 -4
  307. package/src/buttons/MRT_CopyButton.tsx +9 -9
  308. package/src/buttons/MRT_EditActionButtons.tsx +56 -25
  309. package/src/buttons/MRT_ExpandAllButton.tsx +5 -3
  310. package/src/buttons/MRT_ExpandButton.tsx +2 -2
  311. package/src/buttons/MRT_GrabHandleButton.tsx +2 -2
  312. package/src/buttons/MRT_ShowHideColumnsButton.tsx +2 -5
  313. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -3
  314. package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -5
  315. package/src/buttons/{MRT_FullScreenToggleButton.tsx → MRT_ToggleFullScreenButton.tsx} +13 -6
  316. package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -5
  317. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +16 -8
  318. package/src/buttons/index.ts +12 -0
  319. package/src/column.utils.ts +96 -45
  320. package/src/filterFns.ts +14 -14
  321. package/src/footer/MRT_TableFooter.tsx +4 -4
  322. package/src/footer/MRT_TableFooterCell.tsx +7 -4
  323. package/src/footer/MRT_TableFooterRow.tsx +6 -6
  324. package/src/footer/index.ts +3 -0
  325. package/src/head/MRT_TableHead.tsx +4 -4
  326. package/src/head/MRT_TableHeadCell.tsx +7 -4
  327. package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +14 -12
  328. package/src/head/MRT_TableHeadCellFilterContainer.tsx +9 -4
  329. package/src/head/MRT_TableHeadCellFilterLabel.tsx +9 -4
  330. package/src/head/MRT_TableHeadCellGrabHandle.tsx +13 -13
  331. package/src/head/MRT_TableHeadCellResizeHandle.tsx +9 -4
  332. package/src/head/MRT_TableHeadCellSortLabel.tsx +8 -6
  333. package/src/head/MRT_TableHeadRow.tsx +6 -6
  334. package/src/head/index.ts +9 -0
  335. package/src/hooks/useMRT_DisplayColumns.tsx +142 -0
  336. package/src/hooks/useMRT_Effects.ts +77 -0
  337. package/src/hooks/useMRT_TableInstance.ts +291 -0
  338. package/src/hooks/useMRT_TableOptions.ts +169 -0
  339. package/src/index.ts +16 -0
  340. package/src/inputs/MRT_EditCellTextField.tsx +39 -25
  341. package/src/inputs/MRT_FilterCheckbox.tsx +14 -11
  342. package/src/inputs/MRT_FilterRangeFields.tsx +7 -4
  343. package/src/inputs/MRT_FilterRangeSlider.tsx +18 -19
  344. package/src/inputs/MRT_FilterTextField.tsx +15 -15
  345. package/src/inputs/MRT_GlobalFilterTextField.tsx +2 -4
  346. package/src/inputs/MRT_SelectCheckbox.tsx +8 -4
  347. package/src/inputs/index.ts +7 -0
  348. package/src/locales/ar.ts +94 -0
  349. package/src/locales/bg.ts +93 -0
  350. package/src/{_locales → locales}/cs.ts +1 -2
  351. package/src/{_locales → locales}/da.ts +0 -1
  352. package/src/{_locales → locales}/de.ts +0 -1
  353. package/src/{_locales → locales}/en.ts +1 -1
  354. package/src/{_locales → locales}/es.ts +0 -1
  355. package/src/locales/et.ts +94 -0
  356. package/src/{_locales → locales}/fa.ts +0 -1
  357. package/src/{_locales → locales}/fi.ts +0 -1
  358. package/src/{_locales → locales}/fr.ts +0 -1
  359. package/src/{_locales → locales}/hu.ts +0 -1
  360. package/src/{_locales → locales}/id.ts +0 -1
  361. package/src/{_locales → locales}/it.ts +0 -1
  362. package/src/{_locales → locales}/ja.ts +0 -1
  363. package/src/locales/ko.ts +93 -0
  364. package/src/{_locales → locales}/nl.ts +0 -1
  365. package/src/{_locales → locales}/no.ts +1 -1
  366. package/src/{_locales → locales}/pl.ts +0 -1
  367. package/src/{_locales → locales}/pt-BR.ts +0 -1
  368. package/src/{_locales → locales}/pt.ts +0 -1
  369. package/src/{_locales → locales}/ro.ts +0 -1
  370. package/src/{_locales → locales}/ru.ts +0 -1
  371. package/src/{_locales → locales}/sk.ts +0 -1
  372. package/src/{_locales → locales}/sr-Cyrl-RS.ts +0 -1
  373. package/src/{_locales → locales}/sr-Latn-RS.ts +0 -1
  374. package/src/{_locales → locales}/sv.ts +0 -1
  375. package/src/{_locales → locales}/tr.ts +0 -1
  376. package/src/{_locales → locales}/uk.ts +0 -1
  377. package/src/{_locales → locales}/vi.ts +0 -1
  378. package/src/{_locales → locales}/zh-Hans.ts +7 -8
  379. package/src/{_locales → locales}/zh-Hant.ts +1 -2
  380. package/src/menus/MRT_ColumnActionMenu.tsx +8 -8
  381. package/src/menus/MRT_FilterOptionMenu.tsx +4 -3
  382. package/src/menus/MRT_RowActionMenu.tsx +5 -5
  383. package/src/menus/MRT_ShowHideColumnsMenu.tsx +4 -6
  384. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +4 -4
  385. package/src/menus/index.ts +5 -0
  386. package/src/modals/MRT_EditRowModal.tsx +115 -0
  387. package/src/modals/index.ts +1 -0
  388. package/src/sortingFns.ts +2 -2
  389. package/src/table/MRT_Table.tsx +40 -33
  390. package/src/table/MRT_TableContainer.tsx +23 -5
  391. package/src/table/MRT_TablePaper.tsx +13 -4
  392. package/src/table/index.ts +4 -0
  393. package/src/toolbar/MRT_BottomToolbar.tsx +2 -2
  394. package/src/toolbar/MRT_LinearProgressBar.tsx +2 -2
  395. package/src/toolbar/MRT_TablePagination.tsx +2 -2
  396. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +2 -2
  397. package/src/toolbar/MRT_ToolbarDropZone.tsx +2 -2
  398. package/src/toolbar/MRT_ToolbarInternalButtons.tsx +6 -8
  399. package/src/toolbar/MRT_TopToolbar.tsx +2 -2
  400. package/src/toolbar/index.ts +7 -0
  401. package/src/types.ts +765 -751
  402. package/src/useMaterialReactTable.ts +11 -0
  403. package/dist/cjs/types/body/MRT_EditRowModal.d.ts +0 -8
  404. package/dist/cjs/types/buttons/MRT_FullScreenToggleButton.d.ts +0 -7
  405. package/dist/cjs/types/table/MRT_TableRoot.d.ts +0 -1
  406. package/dist/esm/types/body/MRT_EditRowModal.d.ts +0 -8
  407. package/dist/esm/types/buttons/MRT_FullScreenToggleButton.d.ts +0 -7
  408. package/dist/esm/types/table/MRT_TableRoot.d.ts +0 -1
  409. package/src/body/MRT_EditRowModal.tsx +0 -57
  410. package/src/index.tsx +0 -50
  411. package/src/table/MRT_TableRoot.tsx +0 -421
  412. /package/dist/cjs/types/{_locales → locales}/cs.d.ts +0 -0
  413. /package/dist/cjs/types/{_locales → locales}/da.d.ts +0 -0
  414. /package/dist/cjs/types/{_locales → locales}/de.d.ts +0 -0
  415. /package/dist/cjs/types/{_locales → locales}/en.d.ts +0 -0
  416. /package/dist/cjs/types/{_locales → locales}/es.d.ts +0 -0
  417. /package/dist/cjs/types/{_locales → locales}/fa.d.ts +0 -0
  418. /package/dist/cjs/types/{_locales → locales}/fi.d.ts +0 -0
  419. /package/dist/cjs/types/{_locales → locales}/fr.d.ts +0 -0
  420. /package/dist/cjs/types/{_locales → locales}/hu.d.ts +0 -0
  421. /package/dist/cjs/types/{_locales → locales}/id.d.ts +0 -0
  422. /package/dist/cjs/types/{_locales → locales}/it.d.ts +0 -0
  423. /package/dist/cjs/types/{_locales → locales}/ja.d.ts +0 -0
  424. /package/dist/cjs/types/{_locales → locales}/nl.d.ts +0 -0
  425. /package/dist/cjs/types/{_locales → locales}/no.d.ts +0 -0
  426. /package/dist/cjs/types/{_locales → locales}/pl.d.ts +0 -0
  427. /package/dist/cjs/types/{_locales → locales}/pt-BR.d.ts +0 -0
  428. /package/dist/cjs/types/{_locales → locales}/pt.d.ts +0 -0
  429. /package/dist/cjs/types/{_locales → locales}/ro.d.ts +0 -0
  430. /package/dist/cjs/types/{_locales → locales}/ru.d.ts +0 -0
  431. /package/dist/cjs/types/{_locales → locales}/sk.d.ts +0 -0
  432. /package/dist/cjs/types/{_locales → locales}/sr-Cyrl-RS.d.ts +0 -0
  433. /package/dist/cjs/types/{_locales → locales}/sr-Latn-RS.d.ts +0 -0
  434. /package/dist/cjs/types/{_locales → locales}/sv.d.ts +0 -0
  435. /package/dist/cjs/types/{_locales → locales}/tr.d.ts +0 -0
  436. /package/dist/cjs/types/{_locales → locales}/uk.d.ts +0 -0
  437. /package/dist/cjs/types/{_locales → locales}/vi.d.ts +0 -0
  438. /package/dist/cjs/types/{_locales → locales}/zh-Hans.d.ts +0 -0
  439. /package/dist/cjs/types/{_locales → locales}/zh-Hant.d.ts +0 -0
  440. /package/dist/esm/types/{_locales → locales}/cs.d.ts +0 -0
  441. /package/dist/esm/types/{_locales → locales}/da.d.ts +0 -0
  442. /package/dist/esm/types/{_locales → locales}/de.d.ts +0 -0
  443. /package/dist/esm/types/{_locales → locales}/en.d.ts +0 -0
  444. /package/dist/esm/types/{_locales → locales}/es.d.ts +0 -0
  445. /package/dist/esm/types/{_locales → locales}/fa.d.ts +0 -0
  446. /package/dist/esm/types/{_locales → locales}/fi.d.ts +0 -0
  447. /package/dist/esm/types/{_locales → locales}/fr.d.ts +0 -0
  448. /package/dist/esm/types/{_locales → locales}/hu.d.ts +0 -0
  449. /package/dist/esm/types/{_locales → locales}/id.d.ts +0 -0
  450. /package/dist/esm/types/{_locales → locales}/it.d.ts +0 -0
  451. /package/dist/esm/types/{_locales → locales}/ja.d.ts +0 -0
  452. /package/dist/esm/types/{_locales → locales}/nl.d.ts +0 -0
  453. /package/dist/esm/types/{_locales → locales}/no.d.ts +0 -0
  454. /package/dist/esm/types/{_locales → locales}/pl.d.ts +0 -0
  455. /package/dist/esm/types/{_locales → locales}/pt-BR.d.ts +0 -0
  456. /package/dist/esm/types/{_locales → locales}/pt.d.ts +0 -0
  457. /package/dist/esm/types/{_locales → locales}/ro.d.ts +0 -0
  458. /package/dist/esm/types/{_locales → locales}/ru.d.ts +0 -0
  459. /package/dist/esm/types/{_locales → locales}/sk.d.ts +0 -0
  460. /package/dist/esm/types/{_locales → locales}/sr-Cyrl-RS.d.ts +0 -0
  461. /package/dist/esm/types/{_locales → locales}/sr-Latn-RS.d.ts +0 -0
  462. /package/dist/esm/types/{_locales → locales}/sv.d.ts +0 -0
  463. /package/dist/esm/types/{_locales → locales}/tr.d.ts +0 -0
  464. /package/dist/esm/types/{_locales → locales}/uk.d.ts +0 -0
  465. /package/dist/esm/types/{_locales → locales}/vi.d.ts +0 -0
  466. /package/dist/esm/types/{_locales → locales}/zh-Hans.d.ts +0 -0
  467. /package/dist/esm/types/{_locales → locales}/zh-Hant.d.ts +0 -0
package/dist/cjs/index.js CHANGED
@@ -35,23 +35,29 @@ var SearchOffIcon = require('@mui/icons-material/SearchOff');
35
35
  var SortIcon = require('@mui/icons-material/Sort');
36
36
  var ViewColumnIcon = require('@mui/icons-material/ViewColumn');
37
37
  var VisibilityOffIcon = require('@mui/icons-material/VisibilityOff');
38
- var Box = require('@mui/material/Box');
39
- var Dialog = require('@mui/material/Dialog');
40
- var Grow = require('@mui/material/Grow');
41
- var IconButton = require('@mui/material/IconButton');
38
+ var reactVirtual = require('@tanstack/react-virtual');
39
+ var TableBody = require('@mui/material/TableBody');
40
+ var Typography = require('@mui/material/Typography');
41
+ var TableRow = require('@mui/material/TableRow');
42
+ var Skeleton = require('@mui/material/Skeleton');
43
+ var TableCell = require('@mui/material/TableCell');
44
+ var TextField = require('@mui/material/TextField');
45
+ var MenuItem = require('@mui/material/MenuItem');
46
+ var Button = require('@mui/material/Button');
42
47
  var Tooltip = require('@mui/material/Tooltip');
48
+ var IconButton = require('@mui/material/IconButton');
49
+ var Box = require('@mui/material/Box');
50
+ var highlightWords = require('highlight-words');
51
+ var Collapse = require('@mui/material/Collapse');
43
52
  var ListItemIcon = require('@mui/material/ListItemIcon');
44
53
  var Menu = require('@mui/material/Menu');
45
- var MenuItem = require('@mui/material/MenuItem');
46
- var Button = require('@mui/material/Button');
54
+ var CircularProgress = require('@mui/material/CircularProgress');
47
55
  var Checkbox = require('@mui/material/Checkbox');
48
56
  var Radio = require('@mui/material/Radio');
49
57
  var Paper = require('@mui/material/Paper');
50
58
  var Toolbar = require('@mui/material/Toolbar');
51
59
  var useMediaQuery = require('@mui/material/useMediaQuery');
52
- var Collapse = require('@mui/material/Collapse');
53
60
  var InputAdornment = require('@mui/material/InputAdornment');
54
- var TextField = require('@mui/material/TextField');
55
61
  var utils = require('@mui/material/utils');
56
62
  var LinearProgress = require('@mui/material/LinearProgress');
57
63
  var TablePagination = require('@mui/material/TablePagination');
@@ -61,23 +67,18 @@ var Chip = require('@mui/material/Chip');
61
67
  var Divider = require('@mui/material/Divider');
62
68
  var FormControlLabel = require('@mui/material/FormControlLabel');
63
69
  var Switch = require('@mui/material/Switch');
64
- var Typography = require('@mui/material/Typography');
65
70
  var Fade = require('@mui/material/Fade');
66
71
  var TableContainer = require('@mui/material/TableContainer');
67
- var reactVirtual = require('@tanstack/react-virtual');
68
72
  var Table = require('@mui/material/Table');
69
73
  var TableHead = require('@mui/material/TableHead');
70
- var TableRow = require('@mui/material/TableRow');
71
- var TableCell = require('@mui/material/TableCell');
72
74
  var Slider = require('@mui/material/Slider');
73
75
  var Stack = require('@mui/material/Stack');
74
76
  var FormHelperText = require('@mui/material/FormHelperText');
77
+ var Grow = require('@mui/material/Grow');
75
78
  var Badge = require('@mui/material/Badge');
76
79
  var TableSortLabel = require('@mui/material/TableSortLabel');
77
- var TableBody = require('@mui/material/TableBody');
78
- var Skeleton = require('@mui/material/Skeleton');
79
- var highlightWords = require('highlight-words');
80
80
  var TableFooter = require('@mui/material/TableFooter');
81
+ var Dialog = require('@mui/material/Dialog');
81
82
  var DialogActions = require('@mui/material/DialogActions');
82
83
  var DialogContent = require('@mui/material/DialogContent');
83
84
  var DialogTitle = require('@mui/material/DialogTitle');
@@ -112,23 +113,28 @@ var SearchOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(SearchOffIcon);
112
113
  var SortIcon__default = /*#__PURE__*/_interopDefaultLegacy(SortIcon);
113
114
  var ViewColumnIcon__default = /*#__PURE__*/_interopDefaultLegacy(ViewColumnIcon);
114
115
  var VisibilityOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(VisibilityOffIcon);
115
- var Box__default = /*#__PURE__*/_interopDefaultLegacy(Box);
116
- var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
117
- var Grow__default = /*#__PURE__*/_interopDefaultLegacy(Grow);
118
- var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
116
+ var TableBody__default = /*#__PURE__*/_interopDefaultLegacy(TableBody);
117
+ var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
118
+ var TableRow__default = /*#__PURE__*/_interopDefaultLegacy(TableRow);
119
+ var Skeleton__default = /*#__PURE__*/_interopDefaultLegacy(Skeleton);
120
+ var TableCell__default = /*#__PURE__*/_interopDefaultLegacy(TableCell);
121
+ var TextField__default = /*#__PURE__*/_interopDefaultLegacy(TextField);
122
+ var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
123
+ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
119
124
  var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
125
+ var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
126
+ var Box__default = /*#__PURE__*/_interopDefaultLegacy(Box);
127
+ var highlightWords__default = /*#__PURE__*/_interopDefaultLegacy(highlightWords);
128
+ var Collapse__default = /*#__PURE__*/_interopDefaultLegacy(Collapse);
120
129
  var ListItemIcon__default = /*#__PURE__*/_interopDefaultLegacy(ListItemIcon);
121
130
  var Menu__default = /*#__PURE__*/_interopDefaultLegacy(Menu);
122
- var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
123
- var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
131
+ var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgress);
124
132
  var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
125
133
  var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
126
134
  var Paper__default = /*#__PURE__*/_interopDefaultLegacy(Paper);
127
135
  var Toolbar__default = /*#__PURE__*/_interopDefaultLegacy(Toolbar);
128
136
  var useMediaQuery__default = /*#__PURE__*/_interopDefaultLegacy(useMediaQuery);
129
- var Collapse__default = /*#__PURE__*/_interopDefaultLegacy(Collapse);
130
137
  var InputAdornment__default = /*#__PURE__*/_interopDefaultLegacy(InputAdornment);
131
- var TextField__default = /*#__PURE__*/_interopDefaultLegacy(TextField);
132
138
  var LinearProgress__default = /*#__PURE__*/_interopDefaultLegacy(LinearProgress);
133
139
  var TablePagination__default = /*#__PURE__*/_interopDefaultLegacy(TablePagination);
134
140
  var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
@@ -137,22 +143,18 @@ var Chip__default = /*#__PURE__*/_interopDefaultLegacy(Chip);
137
143
  var Divider__default = /*#__PURE__*/_interopDefaultLegacy(Divider);
138
144
  var FormControlLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormControlLabel);
139
145
  var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
140
- var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
141
146
  var Fade__default = /*#__PURE__*/_interopDefaultLegacy(Fade);
142
147
  var TableContainer__default = /*#__PURE__*/_interopDefaultLegacy(TableContainer);
143
148
  var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
144
149
  var TableHead__default = /*#__PURE__*/_interopDefaultLegacy(TableHead);
145
- var TableRow__default = /*#__PURE__*/_interopDefaultLegacy(TableRow);
146
- var TableCell__default = /*#__PURE__*/_interopDefaultLegacy(TableCell);
147
150
  var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
148
151
  var Stack__default = /*#__PURE__*/_interopDefaultLegacy(Stack);
149
152
  var FormHelperText__default = /*#__PURE__*/_interopDefaultLegacy(FormHelperText);
153
+ var Grow__default = /*#__PURE__*/_interopDefaultLegacy(Grow);
150
154
  var Badge__default = /*#__PURE__*/_interopDefaultLegacy(Badge);
151
155
  var TableSortLabel__default = /*#__PURE__*/_interopDefaultLegacy(TableSortLabel);
152
- var TableBody__default = /*#__PURE__*/_interopDefaultLegacy(TableBody);
153
- var Skeleton__default = /*#__PURE__*/_interopDefaultLegacy(Skeleton);
154
- var highlightWords__default = /*#__PURE__*/_interopDefaultLegacy(highlightWords);
155
156
  var TableFooter__default = /*#__PURE__*/_interopDefaultLegacy(TableFooter);
157
+ var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
156
158
  var DialogActions__default = /*#__PURE__*/_interopDefaultLegacy(DialogActions);
157
159
  var DialogContent__default = /*#__PURE__*/_interopDefaultLegacy(DialogContent);
158
160
  var DialogTitle__default = /*#__PURE__*/_interopDefaultLegacy(DialogTitle);
@@ -179,6 +181,10 @@ function __rest(s, e) {
179
181
  }
180
182
  return t;
181
183
  }
184
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
185
+ var e = new Error(message);
186
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
187
+ };
182
188
 
183
189
  const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
184
190
 
@@ -361,7 +367,7 @@ const getLeadingDisplayColumnIds = (props) => {
361
367
  props.positionActionsColumn === 'first' &&
362
368
  (props.enableRowActions ||
363
369
  (props.enableEditing &&
364
- ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
370
+ ['row', 'modal'].includes((_a = props.editDisplayMode) !== null && _a !== void 0 ? _a : ''))) &&
365
371
  'mrt-row-actions',
366
372
  props.positionExpandColumn === 'first' &&
367
373
  showExpandColumn(props) &&
@@ -376,7 +382,7 @@ const getTrailingDisplayColumnIds = (props) => {
376
382
  props.positionActionsColumn === 'last' &&
377
383
  (props.enableRowActions ||
378
384
  (props.enableEditing &&
379
- ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
385
+ ['row', 'modal'].includes((_a = props.editDisplayMode) !== null && _a !== void 0 ? _a : ''))) &&
380
386
  'mrt-row-actions',
381
387
  props.positionExpandColumn === 'last' &&
382
388
  showExpandColumn(props) &&
@@ -423,6 +429,19 @@ const getTotalRight = (table, column) => {
423
429
  .slice(column.getPinnedIndex() + 1)
424
430
  .reduce((acc, col) => acc + col.getSize(), 0);
425
431
  };
432
+ const getCanRankRows = (table) => {
433
+ const { options, getState } = table;
434
+ const { manualExpanding, manualFiltering, manualGrouping, manualSorting, enableGlobalFilterRankedResults, } = options;
435
+ const { globalFilterFn, expanded } = getState();
436
+ return (!manualExpanding &&
437
+ !manualFiltering &&
438
+ !manualGrouping &&
439
+ !manualSorting &&
440
+ enableGlobalFilterRankedResults &&
441
+ globalFilterFn === 'fuzzy' &&
442
+ expanded !== true &&
443
+ !Object.values(expanded).some(Boolean));
444
+ };
426
445
  const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
427
446
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
428
447
  const widthStyles = {
@@ -484,37 +503,10 @@ const MRT_DefaultDisplayColumn = {
484
503
  enableSorting: false,
485
504
  };
486
505
  const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
487
-
488
- const MRT_Default_Icons = {
489
- ArrowDownwardIcon: ArrowDownwardIcon__default["default"],
490
- ArrowRightIcon: ArrowRightIcon__default["default"],
491
- CancelIcon: CancelIcon__default["default"],
492
- ClearAllIcon: ClearAllIcon__default["default"],
493
- CloseIcon: CloseIcon__default["default"],
494
- DensityLargeIcon: DensityLargeIcon__default["default"],
495
- DensityMediumIcon: DensityMediumIcon__default["default"],
496
- DensitySmallIcon: DensitySmallIcon__default["default"],
497
- DragHandleIcon: DragHandleIcon__default["default"],
498
- DynamicFeedIcon: DynamicFeedIcon__default["default"],
499
- EditIcon: EditIcon__default["default"],
500
- ExpandMoreIcon: ExpandMoreIcon__default["default"],
501
- FilterAltIcon: FilterAltIcon__default["default"],
502
- FilterListIcon: FilterListIcon__default["default"],
503
- FilterListOffIcon: FilterListOffIcon__default["default"],
504
- FullscreenExitIcon: FullscreenExitIcon__default["default"],
505
- FullscreenIcon: FullscreenIcon__default["default"],
506
- KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDownIcon__default["default"],
507
- MoreHorizIcon: MoreHorizIcon__default["default"],
508
- MoreVertIcon: MoreVertIcon__default["default"],
509
- PushPinIcon: PushPinIcon__default["default"],
510
- RestartAltIcon: RestartAltIcon__default["default"],
511
- SaveIcon: SaveIcon__default["default"],
512
- SearchIcon: SearchIcon__default["default"],
513
- SearchOffIcon: SearchOffIcon__default["default"],
514
- SortIcon: SortIcon__default["default"],
515
- ViewColumnIcon: ViewColumnIcon__default["default"],
516
- VisibilityOffIcon: VisibilityOffIcon__default["default"],
517
- };
506
+ const flexRender = reactTable.flexRender;
507
+ const createRow = (table, originalRow) => reactTable.createRow(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
508
+ [getColumnId(col)]: '',
509
+ }))), -1, 0);
518
510
 
519
511
  const MRT_Localization_EN = {
520
512
  actions: 'Actions',
@@ -605,56 +597,705 @@ const MRT_Localization_EN = {
605
597
  ungroupByColumn: 'Ungroup by {column}',
606
598
  unpin: 'Unpin',
607
599
  unpinAll: 'Unpin all',
608
- unsorted: 'Unsorted',
609
600
  };
610
601
 
611
- const MRT_ExpandAllButton = ({ table }) => {
612
- var _a, _b;
613
- const { getIsAllRowsExpanded, getIsSomeRowsExpanded, getCanSomeRowsExpand, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
614
- const { density, isLoading } = getState();
615
- const iconButtonProps = muiExpandAllButtonProps instanceof Function
616
- ? muiExpandAllButtonProps({ table })
617
- : muiExpandAllButtonProps;
618
- const isAllRowsExpanded = getIsAllRowsExpanded();
619
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isAllRowsExpanded)
620
- ? localization.collapseAll
621
- : localization.expandAll, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], 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', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
622
- ? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
623
- : iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(KeyboardDoubleArrowDownIcon, { style: {
624
- transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
625
- transition: 'transform 150ms',
626
- } })) })) }) }));
602
+ const MRT_Default_Icons = {
603
+ ArrowDownwardIcon: ArrowDownwardIcon__default["default"],
604
+ ArrowRightIcon: ArrowRightIcon__default["default"],
605
+ CancelIcon: CancelIcon__default["default"],
606
+ ClearAllIcon: ClearAllIcon__default["default"],
607
+ CloseIcon: CloseIcon__default["default"],
608
+ DensityLargeIcon: DensityLargeIcon__default["default"],
609
+ DensityMediumIcon: DensityMediumIcon__default["default"],
610
+ DensitySmallIcon: DensitySmallIcon__default["default"],
611
+ DragHandleIcon: DragHandleIcon__default["default"],
612
+ DynamicFeedIcon: DynamicFeedIcon__default["default"],
613
+ EditIcon: EditIcon__default["default"],
614
+ ExpandMoreIcon: ExpandMoreIcon__default["default"],
615
+ FilterAltIcon: FilterAltIcon__default["default"],
616
+ FilterListIcon: FilterListIcon__default["default"],
617
+ FilterListOffIcon: FilterListOffIcon__default["default"],
618
+ FullscreenExitIcon: FullscreenExitIcon__default["default"],
619
+ FullscreenIcon: FullscreenIcon__default["default"],
620
+ KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDownIcon__default["default"],
621
+ MoreHorizIcon: MoreHorizIcon__default["default"],
622
+ MoreVertIcon: MoreVertIcon__default["default"],
623
+ PushPinIcon: PushPinIcon__default["default"],
624
+ RestartAltIcon: RestartAltIcon__default["default"],
625
+ SaveIcon: SaveIcon__default["default"],
626
+ SearchIcon: SearchIcon__default["default"],
627
+ SearchOffIcon: SearchOffIcon__default["default"],
628
+ SortIcon: SortIcon__default["default"],
629
+ ViewColumnIcon: ViewColumnIcon__default["default"],
630
+ VisibilityOffIcon: VisibilityOffIcon__default["default"],
627
631
  };
628
632
 
629
- const MRT_ExpandButton = ({ row, table, }) => {
630
- var _a, _b;
631
- const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, renderDetailPanel, }, } = table;
632
- const { density } = getState();
633
- const iconButtonProps = muiExpandButtonProps instanceof Function
634
- ? muiExpandButtonProps({ table, row })
635
- : muiExpandButtonProps;
636
- const canExpand = row.getCanExpand();
637
- const isExpanded = row.getIsExpanded();
638
- const handleToggleExpand = (event) => {
633
+ const useMRT_TableOptions = (_a) => {
634
+ var _b;
635
+ var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableColumnPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode = 'semantic', localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'static', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableColumnPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "selectAllMode", "sortingFns"]);
636
+ const _icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
637
+ const _localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
638
+ const _aggregationFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
639
+ const _filterFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
640
+ const _sortingFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
641
+ const _defaultColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
642
+ const _defaultDisplayColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
643
+ if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
644
+ layoutMode = 'grid';
645
+ }
646
+ if (rest.enableRowVirtualization) {
647
+ enableStickyHeader = true;
648
+ }
649
+ if (enablePagination === false && manualPagination === undefined) {
650
+ manualPagination = true;
651
+ }
652
+ if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
653
+ manualFiltering = true;
654
+ manualGrouping = true;
655
+ manualPagination = true;
656
+ manualSorting = true;
657
+ }
658
+ return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
659
+ columnFilterDisplayMode,
660
+ columnResizeMode,
661
+ createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
662
+ enableBottomToolbar,
663
+ enableColumnActions,
664
+ enableColumnFilters,
665
+ enableColumnOrdering,
666
+ enableColumnResizing,
667
+ enableDensityToggle,
668
+ enableExpandAll,
669
+ enableExpanding,
670
+ enableFilterMatchHighlighting,
671
+ enableFilters,
672
+ enableFullScreenToggle,
673
+ enableGlobalFilter,
674
+ enableGlobalFilterRankedResults,
675
+ enableGrouping,
676
+ enableHiding,
677
+ enableMultiRowSelection,
678
+ enableMultiSort,
679
+ enablePagination,
680
+ enableColumnPinning,
681
+ enableRowSelection,
682
+ enableSelectAll,
683
+ enableSorting,
684
+ enableStickyHeader,
685
+ enableTableFooter,
686
+ enableTableHead,
687
+ enableToolbarInternalActions,
688
+ enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode, localization: _localization, manualFiltering,
689
+ manualGrouping,
690
+ manualPagination,
691
+ manualSorting,
692
+ paginationDisplayMode,
693
+ positionActionsColumn,
694
+ positionExpandColumn,
695
+ positionGlobalFilter,
696
+ positionPagination,
697
+ positionToolbarAlertBanner,
698
+ positionToolbarDropZone,
699
+ rowNumberMode,
700
+ selectAllMode, sortingFns: _sortingFns }, rest);
701
+ };
702
+
703
+ const MRT_EditCellTextField = ({ cell, table, }) => {
704
+ var _a, _b, _c;
705
+ const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, setCreatingRow, } = table;
706
+ const { column, row } = cell;
707
+ const { columnDef } = column;
708
+ const { creatingRow, editingRow } = getState();
709
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
710
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
711
+ const isSelectEdit = columnDef.editVariant === 'select';
712
+ const [value, setValue] = react.useState(() => cell.getValue());
713
+ const mTableBodyCellEditTextFieldProps = muiEditTextFieldProps instanceof Function
714
+ ? muiEditTextFieldProps({ cell, column, row, table })
715
+ : muiEditTextFieldProps;
716
+ const mcTableBodyCellEditTextFieldProps = columnDef.muiEditTextFieldProps instanceof Function
717
+ ? columnDef.muiEditTextFieldProps({
718
+ cell,
719
+ column,
720
+ row,
721
+ table,
722
+ })
723
+ : columnDef.muiEditTextFieldProps;
724
+ const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
725
+ const saveInputValueToRowCache = (newValue) => {
726
+ //@ts-ignore
727
+ row._valuesCache[column.id] = newValue;
728
+ if (isCreating) {
729
+ setCreatingRow(Object.assign({}, row));
730
+ }
731
+ else if (isEditing) {
732
+ setEditingRow(Object.assign({}, row));
733
+ }
734
+ };
735
+ const handleChange = (event) => {
639
736
  var _a;
640
- event.stopPropagation();
641
- row.toggleExpanded();
642
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
737
+ (_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
738
+ setValue(event.target.value);
739
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) {
740
+ saveInputValueToRowCache(event.target.value);
741
+ }
643
742
  };
644
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, disableHoverListener: !canExpand && !renderDetailPanel, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isExpanded)
645
- ? localization.collapse
646
- : localization.expand, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
647
- ? iconButtonProps.sx(theme)
648
- : iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(ExpandMoreIcon, { style: {
649
- transform: `rotate(${!canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0}deg)`,
650
- transition: 'transform 150ms',
651
- } })) })) }) }));
743
+ const handleBlur = (event) => {
744
+ var _a;
745
+ (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
746
+ saveInputValueToRowCache(value);
747
+ setEditingCell(null);
748
+ };
749
+ const handleEnterKeyDown = (event) => {
750
+ var _a, _b;
751
+ (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
752
+ if (event.key === 'Enter' && !event.shiftKey) {
753
+ (_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
754
+ }
755
+ };
756
+ if (columnDef.Edit) {
757
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }) });
758
+ }
759
+ return (jsxRuntime.jsx(TextField__default["default"], Object.assign({ disabled: (columnDef.enableEditing instanceof Function
760
+ ? columnDef.enableEditing(row)
761
+ : columnDef.enableEditing) === false, fullWidth: true, inputRef: (inputRef) => {
762
+ if (inputRef) {
763
+ editInputRefs.current[column.id] = inputRef;
764
+ if (textFieldProps.inputRef) {
765
+ textFieldProps.inputRef = inputRef;
766
+ }
767
+ }
768
+ }, label: ['modal', 'custom'].includes((isCreating ? createDisplayMode : editDisplayMode))
769
+ ? column.columnDef.header
770
+ : undefined, margin: "none", name: column.id, placeholder: !['modal', 'custom'].includes((isCreating ? createDisplayMode : editDisplayMode))
771
+ ? columnDef.header
772
+ : undefined, select: isSelectEdit, value: value, variant: "standard" }, textFieldProps, { onClick: (e) => {
773
+ var _a;
774
+ e.stopPropagation();
775
+ (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
776
+ }, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown, children: (_b = textFieldProps.children) !== null && _b !== void 0 ? _b : (_c = columnDef === null || columnDef === void 0 ? void 0 : columnDef.editSelectOptions) === null || _c === void 0 ? void 0 : _c.map((option) => {
777
+ let value;
778
+ let text;
779
+ if (typeof option !== 'object') {
780
+ value = option;
781
+ text = option;
782
+ }
783
+ else {
784
+ value = option.value;
785
+ text = option.text;
786
+ }
787
+ return (jsxRuntime.jsx(MenuItem__default["default"], { sx: {
788
+ display: 'flex',
789
+ m: 0,
790
+ alignItems: 'center',
791
+ gap: '0.5rem',
792
+ }, value: value, children: text }, value));
793
+ }) })));
652
794
  };
653
795
 
654
- const mrtFilterOptions = (localization) => [
655
- {
656
- option: 'fuzzy',
657
- symbol: '≈',
796
+ const MRT_CopyButton = ({ cell, children, table, }) => {
797
+ var _a;
798
+ const { options: { localization, muiCopyButtonProps }, } = table;
799
+ const { column, row } = cell;
800
+ const { columnDef } = column;
801
+ const [copied, setCopied] = react.useState(false);
802
+ const handleCopy = (event, text) => {
803
+ event.stopPropagation();
804
+ navigator.clipboard.writeText(text);
805
+ setCopied(true);
806
+ setTimeout(() => setCopied(false), 4000);
807
+ };
808
+ const mTableBodyCellCopyButtonProps = muiCopyButtonProps instanceof Function
809
+ ? muiCopyButtonProps({ cell, column, row, table })
810
+ : muiCopyButtonProps;
811
+ const mcTableBodyCellCopyButtonProps = columnDef.muiCopyButtonProps instanceof Function
812
+ ? columnDef.muiCopyButtonProps({
813
+ cell,
814
+ column,
815
+ row,
816
+ table,
817
+ })
818
+ : columnDef.muiCopyButtonProps;
819
+ const buttonProps = Object.assign(Object.assign({}, mTableBodyCellCopyButtonProps), mcTableBodyCellCopyButtonProps);
820
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsxRuntime.jsx(Button__default["default"], 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', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
821
+ ? buttonProps.sx(theme)
822
+ : buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))), title: undefined, children: children })) }));
823
+ };
824
+
825
+ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
826
+ var _a;
827
+ const { options: { icons: { DragHandleIcon }, localization, }, } = table;
828
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.move, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
829
+ var _a;
830
+ e.stopPropagation();
831
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
832
+ }, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: '0 -0.1rem', opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
833
+ backgroundColor: 'transparent',
834
+ opacity: 1,
835
+ }, '&:active': {
836
+ cursor: 'grabbing',
837
+ } }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
838
+ ? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
839
+ : iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: jsxRuntime.jsx(DragHandleIcon, {}) })) }));
840
+ };
841
+
842
+ const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, }) => {
843
+ const { options: { muiRowDragHandleProps }, } = table;
844
+ const iconButtonProps = muiRowDragHandleProps instanceof Function
845
+ ? muiRowDragHandleProps({ row, table })
846
+ : muiRowDragHandleProps;
847
+ const handleDragStart = (event) => {
848
+ var _a;
849
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
850
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
851
+ table.setDraggingRow(row);
852
+ };
853
+ const handleDragEnd = (event) => {
854
+ var _a;
855
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
856
+ table.setDraggingRow(null);
857
+ table.setHoveredRow(null);
858
+ };
859
+ return (jsxRuntime.jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
860
+ };
861
+
862
+ const allowedTypes = ['string', 'number'];
863
+ const MRT_TableBodyCellValue = ({ cell, table, }) => {
864
+ var _a, _b, _c;
865
+ const { getState, options: { enableFilterMatchHighlighting }, } = table;
866
+ const { column, row } = cell;
867
+ const { columnDef } = column;
868
+ const { globalFilter, globalFilterFn } = getState();
869
+ const filterValue = column.getFilterValue();
870
+ let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
871
+ ? columnDef.AggregatedCell({
872
+ cell,
873
+ column,
874
+ row,
875
+ table,
876
+ })
877
+ : row.getIsGrouped() && !cell.getIsGrouped()
878
+ ? null
879
+ : cell.getIsGrouped() && columnDef.GroupedCell
880
+ ? columnDef.GroupedCell({
881
+ cell,
882
+ column,
883
+ row,
884
+ table,
885
+ })
886
+ : undefined;
887
+ const isGroupedValue = renderedCellValue !== undefined;
888
+ if (!isGroupedValue) {
889
+ renderedCellValue = cell.renderValue();
890
+ }
891
+ if (enableFilterMatchHighlighting &&
892
+ columnDef.enableFilterMatchHighlighting !== false &&
893
+ renderedCellValue &&
894
+ allowedTypes.includes(typeof renderedCellValue) &&
895
+ ((filterValue &&
896
+ allowedTypes.includes(typeof filterValue) &&
897
+ columnDef.filterVariant === 'text') ||
898
+ (globalFilter &&
899
+ allowedTypes.includes(typeof globalFilter) &&
900
+ column.getCanGlobalFilter()))) {
901
+ const chunks = highlightWords__default["default"] === null || highlightWords__default["default"] === void 0 ? void 0 : highlightWords__default["default"]({
902
+ text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
903
+ query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
904
+ matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
905
+ });
906
+ 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)) {
907
+ 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__default["default"], { "aria-hidden": "true", component: "span", sx: match
908
+ ? {
909
+ backgroundColor: (theme) => theme.palette.mode === 'dark'
910
+ ? styles.darken(theme.palette.warning.dark, 0.25)
911
+ : styles.lighten(theme.palette.warning.light, 0.5),
912
+ borderRadius: '2px',
913
+ color: (theme) => theme.palette.mode === 'dark' ? 'white' : 'black',
914
+ padding: '2px 1px',
915
+ }
916
+ : undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
917
+ }
918
+ }
919
+ if (columnDef.Cell && !isGroupedValue) {
920
+ renderedCellValue = columnDef.Cell({
921
+ cell,
922
+ renderedCellValue,
923
+ column,
924
+ row,
925
+ table,
926
+ });
927
+ }
928
+ return jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderedCellValue });
929
+ };
930
+
931
+ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
932
+ var _a, _b, _c, _d;
933
+ const theme = styles.useTheme();
934
+ const { getState, options: { createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiTableBodyCellProps, muiSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
935
+ const { creatingRow, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, density, isLoading, showSkeletons, } = getState();
936
+ const { column, row } = cell;
937
+ const { columnDef } = column;
938
+ const { columnDefType } = columnDef;
939
+ const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
940
+ ? muiTableBodyCellProps({ cell, column, row, table })
941
+ : muiTableBodyCellProps;
942
+ const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
943
+ ? columnDef.muiTableBodyCellProps({ cell, column, row, table })
944
+ : columnDef.muiTableBodyCellProps;
945
+ const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
946
+ const skeletonProps = muiSkeletonProps instanceof Function
947
+ ? muiSkeletonProps({ cell, column, row, table })
948
+ : muiSkeletonProps;
949
+ const [skeletonWidth, setSkeletonWidth] = react.useState(100);
950
+ react.useEffect(() => {
951
+ if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
952
+ return;
953
+ const size = column.getSize();
954
+ setSkeletonWidth(columnDefType === 'display'
955
+ ? size / 2
956
+ : Math.round(Math.random() * (size - size / 3) + size / 3));
957
+ }, [isLoading, showSkeletons]);
958
+ const draggingBorders = react.useMemo(() => {
959
+ const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
960
+ const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
961
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
962
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
963
+ const isFirstColumn = getIsFirstColumn(column, table);
964
+ const isLastColumn = getIsLastColumn(column, table);
965
+ const isLastRow = rowIndex === numRows - 1;
966
+ const borderStyle = isDraggingColumn || isDraggingRow
967
+ ? `1px dashed ${theme.palette.text.secondary} !important`
968
+ : isHoveredColumn || isHoveredRow
969
+ ? `2px dashed ${theme.palette.primary.main} !important`
970
+ : undefined;
971
+ return borderStyle
972
+ ? {
973
+ borderLeft: isDraggingColumn ||
974
+ isHoveredColumn ||
975
+ ((isDraggingRow || isHoveredRow) && isFirstColumn)
976
+ ? borderStyle
977
+ : undefined,
978
+ borderRight: isDraggingColumn ||
979
+ isHoveredColumn ||
980
+ ((isDraggingRow || isHoveredRow) && isLastColumn)
981
+ ? borderStyle
982
+ : undefined,
983
+ borderBottom: isDraggingRow || isHoveredRow || isLastRow
984
+ ? borderStyle
985
+ : undefined,
986
+ borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
987
+ }
988
+ : undefined;
989
+ }, [draggingColumn, draggingRow, hoveredColumn, hoveredRow, rowIndex]);
990
+ const isEditable = (enableEditing instanceof Function ? enableEditing(row) : enableEditing) &&
991
+ (columnDef.enableEditing instanceof Function
992
+ ? columnDef.enableEditing(row)
993
+ : columnDef.enableEditing) !== false;
994
+ const isEditing = isEditable &&
995
+ !['modal', 'custom'].includes(editDisplayMode) &&
996
+ (editDisplayMode === 'table' ||
997
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
998
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
999
+ !row.getIsGrouped();
1000
+ const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1001
+ const handleDoubleClick = (event) => {
1002
+ var _a;
1003
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
1004
+ if (isEditable && editDisplayMode === 'cell') {
1005
+ setEditingCell(cell);
1006
+ queueMicrotask(() => {
1007
+ var _a;
1008
+ const textField = editInputRefs.current[column.id];
1009
+ if (textField) {
1010
+ textField.focus();
1011
+ (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
1012
+ }
1013
+ });
1014
+ }
1015
+ };
1016
+ const handleDragEnter = (e) => {
1017
+ var _a;
1018
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
1019
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1020
+ setHoveredColumn(null);
1021
+ }
1022
+ if (enableColumnOrdering && draggingColumn) {
1023
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
1024
+ }
1025
+ };
1026
+ return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ "data-index": virtualCell === null || virtualCell === void 0 ? void 0 : virtualCell.index, ref: (node) => {
1027
+ if (node) {
1028
+ measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
1029
+ }
1030
+ } }, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ alignItems: layoutMode === 'grid' ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', justifyContent: layoutMode === 'grid' ? tableCellProps.align : undefined, overflow: 'hidden', p: density === 'compact'
1031
+ ? columnDefType === 'display'
1032
+ ? '0 0.5rem'
1033
+ : '0.5rem'
1034
+ : density === 'comfortable'
1035
+ ? columnDefType === 'display'
1036
+ ? '0.5rem 0.75rem'
1037
+ : '1rem'
1038
+ : columnDefType === 'display'
1039
+ ? '1rem 1.25rem'
1040
+ : '1.5rem', pl: column.id === 'mrt-row-expand'
1041
+ ? `${row.depth +
1042
+ (density === 'compact'
1043
+ ? 0.5
1044
+ : density === 'comfortable'
1045
+ ? 0.75
1046
+ : 1.25)}rem`
1047
+ : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0, '&:hover': {
1048
+ outline: ['table', 'cell'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')
1049
+ ? `1px solid ${theme.palette.text.secondary}`
1050
+ : undefined,
1051
+ outlineOffset: '-1px',
1052
+ textOverflow: 'clip',
1053
+ } }, getCommonCellStyles({
1054
+ column,
1055
+ table,
1056
+ theme,
1057
+ tableCellProps,
1058
+ })), draggingBorders)), children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [cell.getIsPlaceholder() ? ((_b = (_a = columnDef.PlaceholderCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : null) : (isLoading || showSkeletons) && cell.getValue() === null ? (jsxRuntime.jsx(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
1059
+ rowNumberMode === 'static' &&
1060
+ column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
1061
+ (column.id === 'mrt-row-select' ||
1062
+ column.id === 'mrt-row-expand' ||
1063
+ !row.getIsGrouped()) ? ((_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
1064
+ cell,
1065
+ renderedCellValue: cell.renderValue(),
1066
+ column,
1067
+ row,
1068
+ table,
1069
+ })) : isCreating || isEditing ? (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
1070
+ columnDef.enableClickToCopy !== false ? (jsxRuntime.jsx(MRT_CopyButton, { cell: cell, table: table, children: jsxRuntime.jsx(MRT_TableBodyCellValue, { cell: cell, table: table }) })) : (jsxRuntime.jsx(MRT_TableBodyCellValue, { cell: cell, table: table })), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_d = row.subRows) === null || _d === void 0 ? void 0 : _d.length, ")"] }))] }) })));
1071
+ };
1072
+ const Memo_MRT_TableBodyCell = react.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
1073
+
1074
+ const MRT_TableDetailPanel = ({ parentRowRef, row, rowIndex, table, virtualRow, }) => {
1075
+ const { getVisibleLeafColumns, getState, options: { layoutMode, muiTableBodyRowProps, muiDetailPanelProps, renderDetailPanel, }, } = table;
1076
+ const { isLoading } = getState();
1077
+ const tableRowProps = muiTableBodyRowProps instanceof Function
1078
+ ? muiTableBodyRowProps({
1079
+ isDetailPanel: true,
1080
+ row,
1081
+ staticRowIndex: rowIndex,
1082
+ table,
1083
+ })
1084
+ : muiTableBodyRowProps;
1085
+ const tableCellProps = muiDetailPanelProps instanceof Function
1086
+ ? muiDetailPanelProps({ row, table })
1087
+ : muiDetailPanelProps;
1088
+ return (jsxRuntime.jsx(TableRow__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel" }, tableRowProps, { sx: (theme) => {
1089
+ var _a, _b;
1090
+ return (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row', position: virtualRow ? 'absolute' : undefined, top: virtualRow
1091
+ ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
1092
+ : undefined, transform: virtualRow
1093
+ ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
1094
+ : undefined, width: '100%', zIndex: virtualRow ? 2 : undefined }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
1095
+ ? tableRowProps.sx(theme)
1096
+ : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)));
1097
+ }, children: jsxRuntime.jsx(TableCell__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
1098
+ ? styles.lighten(theme.palette.background.default, 0.06)
1099
+ : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: layoutMode === 'grid' ? 'flex' : 'table-cell', pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
1100
+ ? tableCellProps.sx(theme)
1101
+ : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))), children: renderDetailPanel && (jsxRuntime.jsx(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
1102
+ };
1103
+
1104
+ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
1105
+ const { getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
1106
+ const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
1107
+ const tableRowProps = muiTableBodyRowProps instanceof Function
1108
+ ? muiTableBodyRowProps({ row, staticRowIndex: rowIndex, table })
1109
+ : muiTableBodyRowProps;
1110
+ const handleDragEnter = (_e) => {
1111
+ if (enableRowOrdering && draggingRow) {
1112
+ setHoveredRow(row);
1113
+ }
1114
+ };
1115
+ const rowRef = react.useRef(null);
1116
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(TableRow__default["default"], Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
1117
+ if (node) {
1118
+ rowRef.current = node;
1119
+ measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
1120
+ }
1121
+ } }, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.06), boxSizing: 'border-box', display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, position: virtualRow ? 'absolute' : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', top: virtualRow ? 0 : undefined, width: '100%', '&:hover td': {
1122
+ backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
1123
+ ? row.getIsSelected()
1124
+ ? `${styles.alpha(theme.palette.primary.main, 0.2)}`
1125
+ : theme.palette.mode === 'dark'
1126
+ ? `${styles.lighten(theme.palette.background.default, 0.12)}`
1127
+ : `${styles.darken(theme.palette.background.default, 0.05)}`
1128
+ : undefined,
1129
+ } }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
1130
+ ? tableRowProps.sx(theme)
1131
+ : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))), style: Object.assign({ transform: virtualRow
1132
+ ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
1133
+ : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), children: [virtualPaddingLeft ? (jsxRuntime.jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
1134
+ const cell = columnVirtualizer
1135
+ ? row.getVisibleCells()[cellOrVirtualCell.index]
1136
+ : cellOrVirtualCell;
1137
+ const props = {
1138
+ cell,
1139
+ measureElement: columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement,
1140
+ numRows,
1141
+ rowIndex,
1142
+ rowRef,
1143
+ table,
1144
+ virtualCell: columnVirtualizer
1145
+ ? cellOrVirtualCell
1146
+ : undefined,
1147
+ };
1148
+ return memoMode === 'cells' &&
1149
+ cell.column.columnDef.columnDefType === 'data' &&
1150
+ !draggingColumn &&
1151
+ !draggingRow &&
1152
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
1153
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), cell.id)) : (jsxRuntime.jsx(MRT_TableBodyCell, Object.assign({}, props), cell.id));
1154
+ }), virtualPaddingRight ? (jsxRuntime.jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsxRuntime.jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowIndex: rowIndex, table: table, virtualRow: virtualRow }))] }));
1155
+ };
1156
+ const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
1157
+
1158
+ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
1159
+ var _a, _b, _c, _d;
1160
+ const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef, tablePaperRef }, } = table;
1161
+ const { columnFilters, density, expanded, globalFilter, globalFilterFn, pagination, sorting, } = getState();
1162
+ const tableBodyProps = muiTableBodyProps instanceof Function
1163
+ ? muiTableBodyProps({ table })
1164
+ : muiTableBodyProps;
1165
+ const vProps = rowVirtualizerOptions instanceof Function
1166
+ ? rowVirtualizerOptions({ table })
1167
+ : rowVirtualizerOptions;
1168
+ const shouldRankResults = react.useMemo(() => !manualExpanding &&
1169
+ !manualFiltering &&
1170
+ !manualGrouping &&
1171
+ !manualSorting &&
1172
+ enableGlobalFilterRankedResults &&
1173
+ globalFilter &&
1174
+ globalFilterFn === 'fuzzy' &&
1175
+ expanded !== true &&
1176
+ !Object.values(sorting).some(Boolean) &&
1177
+ !Object.values(expanded).some(Boolean), [
1178
+ enableGlobalFilterRankedResults,
1179
+ expanded,
1180
+ globalFilter,
1181
+ manualExpanding,
1182
+ manualFiltering,
1183
+ manualGrouping,
1184
+ manualSorting,
1185
+ sorting,
1186
+ ]);
1187
+ const rows = react.useMemo(() => {
1188
+ if (!shouldRankResults)
1189
+ return getRowModel().rows;
1190
+ const rankedRows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
1191
+ if (enablePagination && !manualPagination) {
1192
+ const start = pagination.pageIndex * pagination.pageSize;
1193
+ return rankedRows.slice(start, start + pagination.pageSize);
1194
+ }
1195
+ return rankedRows;
1196
+ }, [
1197
+ shouldRankResults,
1198
+ shouldRankResults ? getPrePaginationRowModel().rows : getRowModel().rows,
1199
+ pagination.pageIndex,
1200
+ pagination.pageSize,
1201
+ ]);
1202
+ const rowVirtualizer = enableRowVirtualization
1203
+ ? reactVirtual.useVirtualizer(Object.assign({ count: rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
1204
+ navigator.userAgent.indexOf('Firefox') === -1
1205
+ ? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
1206
+ : undefined, overscan: 4 }, vProps))
1207
+ : undefined;
1208
+ if (rowVirtualizerInstanceRef && rowVirtualizer) {
1209
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
1210
+ }
1211
+ const virtualRows = rowVirtualizer
1212
+ ? rowVirtualizer.getVirtualItems()
1213
+ : undefined;
1214
+ return (jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', height: rowVirtualizer
1215
+ ? `${rowVirtualizer.getTotalSize()}px`
1216
+ : 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, ((tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx) instanceof Function
1217
+ ? tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx(theme)
1218
+ : tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx))), children: (_a = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _a !== void 0 ? _a : (!rows.length ? (jsxRuntime.jsx("tr", { style: { display: layoutMode === 'grid' ? 'grid' : 'table-row' }, children: jsxRuntime.jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
1219
+ display: layoutMode === 'grid' ? 'grid' : 'table-cell',
1220
+ }, children: (_b = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(Typography__default["default"], { sx: {
1221
+ color: 'text.secondary',
1222
+ fontStyle: 'italic',
1223
+ maxWidth: `min(100vw, ${(_d = (_c = tablePaperRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth) !== null && _d !== void 0 ? _d : 360}px)`,
1224
+ py: '2rem',
1225
+ textAlign: 'center',
1226
+ width: '100%',
1227
+ }, children: globalFilter || columnFilters.length
1228
+ ? localization.noResultsFound
1229
+ : localization.noRecordsToDisplay })) }) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
1230
+ const row = rowVirtualizer
1231
+ ? rows[rowOrVirtualRow.index]
1232
+ : rowOrVirtualRow;
1233
+ const props = {
1234
+ columnVirtualizer,
1235
+ measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
1236
+ numRows: rows.length,
1237
+ row,
1238
+ rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex,
1239
+ table,
1240
+ virtualColumns,
1241
+ virtualPaddingLeft,
1242
+ virtualPaddingRight,
1243
+ virtualRow: rowVirtualizer
1244
+ ? rowOrVirtualRow
1245
+ : undefined,
1246
+ };
1247
+ return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
1248
+ }) }))) })));
1249
+ };
1250
+ const Memo_MRT_TableBody = react.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
1251
+
1252
+ const MRT_ExpandAllButton = ({ table, }) => {
1253
+ var _a, _b;
1254
+ const { getIsAllRowsExpanded, getIsSomeRowsExpanded, getCanSomeRowsExpand, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1255
+ const { density, isLoading } = getState();
1256
+ const iconButtonProps = muiExpandAllButtonProps instanceof Function
1257
+ ? muiExpandAllButtonProps({ table })
1258
+ : muiExpandAllButtonProps;
1259
+ const isAllRowsExpanded = getIsAllRowsExpanded();
1260
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isAllRowsExpanded)
1261
+ ? localization.collapseAll
1262
+ : localization.expandAll, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], 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', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
1263
+ ? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
1264
+ : iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(KeyboardDoubleArrowDownIcon, { style: {
1265
+ transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
1266
+ transition: 'transform 150ms',
1267
+ } })) })) }) }));
1268
+ };
1269
+
1270
+ const MRT_ExpandButton = ({ row, table, }) => {
1271
+ var _a, _b;
1272
+ const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, renderDetailPanel, }, } = table;
1273
+ const { density } = getState();
1274
+ const iconButtonProps = muiExpandButtonProps instanceof Function
1275
+ ? muiExpandButtonProps({ table, row })
1276
+ : muiExpandButtonProps;
1277
+ const canExpand = row.getCanExpand();
1278
+ const isExpanded = row.getIsExpanded();
1279
+ const handleToggleExpand = (event) => {
1280
+ var _a;
1281
+ event.stopPropagation();
1282
+ row.toggleExpanded();
1283
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1284
+ };
1285
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, disableHoverListener: !canExpand && !renderDetailPanel, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isExpanded)
1286
+ ? localization.collapse
1287
+ : localization.expand, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
1288
+ ? iconButtonProps.sx(theme)
1289
+ : iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(ExpandMoreIcon, { style: {
1290
+ transform: `rotate(${!canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0}deg)`,
1291
+ transition: 'transform 150ms',
1292
+ } })) })) }) }));
1293
+ };
1294
+
1295
+ const mrtFilterOptions = (localization) => [
1296
+ {
1297
+ option: 'fuzzy',
1298
+ symbol: '≈',
658
1299
  label: localization.filterFuzzy,
659
1300
  divider: false,
660
1301
  },
@@ -740,6 +1381,7 @@ const mrtFilterOptions = (localization) => [
740
1381
  const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
741
1382
  const emptyModes = ['empty', 'notEmpty'];
742
1383
  const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
1384
+ const rangeVariants = ['range-slider', 'date-range', 'range'];
743
1385
  const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilterValue, table, }) => {
744
1386
  var _a, _b, _c, _d;
745
1387
  const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
@@ -748,7 +1390,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
748
1390
  const { columnDef } = column !== null && column !== void 0 ? column : {};
749
1391
  const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
750
1392
  let allowedColumnFilterOptions = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _a !== void 0 ? _a : columnFilterModeOptions;
751
- if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'range-slider') {
1393
+ if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
752
1394
  allowedColumnFilterOptions = [
753
1395
  ...rangeModes,
754
1396
  ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
@@ -860,7 +1502,7 @@ const commonListItemStyles = {
860
1502
  };
861
1503
  const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
862
1504
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
863
- const { getState, toggleAllColumnsVisible, setColumnOrder, options: { columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnSizingInfo, setShowColumnFilters, } = table;
1505
+ const { getState, toggleAllColumnsVisible, setColumnOrder, options: { columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enableColumnPinning, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnSizingInfo, setShowColumnFilters, } = table;
864
1506
  const { column } = header;
865
1507
  const { columnDef } = column;
866
1508
  const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
@@ -941,10 +1583,10 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
941
1583
  : []),
942
1584
  ...(enableGrouping && column.getCanGroup()
943
1585
  ? [
944
- jsxRuntime.jsx(MenuItem__default["default"], { divider: enablePinning, onClick: handleGroupByColumn, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(DynamicFeedIcon, {}) }), (_e = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header))] }) }, 6),
1586
+ jsxRuntime.jsx(MenuItem__default["default"], { divider: enableColumnPinning, onClick: handleGroupByColumn, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(DynamicFeedIcon, {}) }), (_e = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header))] }) }, 6),
945
1587
  ]
946
1588
  : []),
947
- ...(enablePinning && column.getCanPin()
1589
+ ...(enableColumnPinning && column.getCanPin()
948
1590
  ? [
949
1591
  jsxRuntime.jsx(MenuItem__default["default"], { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), onClick: () => handlePinColumn('left'), sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }) }), localization.pinToLeft] }) }, 7),
950
1592
  jsxRuntime.jsx(MenuItem__default["default"], { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), onClick: () => handlePinColumn('right'), sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }) }), localization.pinToRight] }) }, 8),
@@ -994,30 +1636,49 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
994
1636
  };
995
1637
 
996
1638
  const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
997
- const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, onEditingRowCancel, }, refs: { editInputRefs }, setEditingRow, } = table;
998
- const { editingRow } = getState();
1639
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowSave, onEditingRowCancel, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
1640
+ const { creatingRow, editingRow, isSaving } = getState();
1641
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1642
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
999
1643
  const handleCancel = () => {
1000
- onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
1001
- setEditingRow(null);
1644
+ if (isCreating) {
1645
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
1646
+ setCreatingRow(null);
1647
+ }
1648
+ else if (isEditing) {
1649
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
1650
+ setEditingRow(null);
1651
+ }
1652
+ row._valuesCache = {}; //reset values cache
1002
1653
  };
1003
- const handleSave = () => {
1004
- var _a, _b;
1654
+ const handleSubmitRow = () => {
1655
+ var _a;
1005
1656
  //look for auto-filled input values
1006
- (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
1657
+ (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)
1658
+ .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 || _a === void 0 ? void 0 : _a.forEach((input) => {
1007
1659
  if (input.value !== undefined &&
1008
- Object.hasOwn(editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache, input.name)) {
1660
+ Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
1009
1661
  // @ts-ignore
1010
- editingRow._valuesCache[input.name] = input.value;
1662
+ row._valuesCache[input.name] = input.value;
1011
1663
  }
1012
1664
  });
1013
- onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
1014
- exitEditingMode: () => setEditingRow(null),
1015
- row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
1016
- table,
1017
- values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
1018
- });
1665
+ if (isCreating)
1666
+ onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
1667
+ exitCreatingMode: () => setCreatingRow(null),
1668
+ row,
1669
+ table,
1670
+ values: row._valuesCache,
1671
+ });
1672
+ else if (isEditing) {
1673
+ onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
1674
+ exitEditingMode: () => setEditingRow(null),
1675
+ row,
1676
+ table,
1677
+ values: row === null || row === void 0 ? void 0 : row._valuesCache,
1678
+ });
1679
+ }
1019
1680
  };
1020
- return (jsxRuntime.jsx(Box__default["default"], { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' }, children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.cancel, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }), jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.save, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.save, color: "info", onClick: handleSave, children: jsxRuntime.jsx(SaveIcon, {}) }) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button__default["default"], { onClick: handleCancel, children: localization.cancel }), jsxRuntime.jsx(Button__default["default"], { onClick: handleSave, variant: "contained", children: localization.save })] })) }));
1681
+ return (jsxRuntime.jsx(Box__default["default"], { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' }, children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.cancel, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }), jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.save, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsxRuntime.jsx(CircularProgress__default["default"], { size: 18 }) : jsxRuntime.jsx(SaveIcon, {}) }) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button__default["default"], { sx: { minWidth: '100px' }, onClick: handleCancel, children: localization.cancel }), jsxRuntime.jsxs(Button__default["default"], { sx: { minWidth: '100px' }, onClick: handleSubmitRow, variant: "contained", children: [isSaving && jsxRuntime.jsx(CircularProgress__default["default"], { color: "inherit", size: 18 }), localization.save] })] })) }));
1021
1682
  };
1022
1683
 
1023
1684
  const commonIconButtonStyles = {
@@ -1031,8 +1692,12 @@ const commonIconButtonStyles = {
1031
1692
  },
1032
1693
  };
1033
1694
  const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
1034
- const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
1035
- const { editingRow } = getState();
1695
+ const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
1696
+ const { creatingRow, editingRow } = getState();
1697
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1698
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
1699
+ const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
1700
+ (isEditing && editDisplayMode === 'row');
1036
1701
  const [anchorEl, setAnchorEl] = react.useState(null);
1037
1702
  const handleOpenRowActionMenu = (event) => {
1038
1703
  event.stopPropagation();
@@ -1044,13 +1709,13 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
1044
1709
  setEditingRow(Object.assign({}, row));
1045
1710
  setAnchorEl(null);
1046
1711
  };
1047
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderRowActions ? (renderRowActions({ cell, row, table })) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
1712
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, table })) : showEditActionButtons ? (jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
1048
1713
  (enableEditing instanceof Function
1049
1714
  ? enableEditing(row)
1050
1715
  : enableEditing) ? (jsxRuntime.jsx(Tooltip__default["default"], { placement: "right", arrow: true, title: localization.edit, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.edit, sx: commonIconButtonStyles, onClick: handleStartEditMode, children: jsxRuntime.jsx(EditIcon, {}) }) })) : renderRowActionMenuItems ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles, children: jsxRuntime.jsx(MoreHorizIcon, {}) }) }), jsxRuntime.jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
1051
1716
  };
1052
1717
 
1053
- const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
1718
+ const MRT_SelectCheckbox = ({ row, selectAll, table, }) => {
1054
1719
  var _a;
1055
1720
  const { getState, options: { localization, enableMultiRowSelection, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
1056
1721
  const { density, isLoading } = getState();
@@ -1088,6 +1753,288 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
1088
1753
  : row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps))) }));
1089
1754
  };
1090
1755
 
1756
+ const useMRT_DisplayColumns = ({ creatingRow, columnOrder, grouping, tableOptions, }) => {
1757
+ var _a, _b;
1758
+ return react.useMemo(() => {
1759
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
1760
+ return [
1761
+ ((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, rowRef, table }) => (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), header: tableOptions.localization.move, size: 60 }, tableOptions.defaultDisplayColumn), (_c = tableOptions.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-drag']), { id: 'mrt-row-drag' }),
1762
+ (((_e = (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-actions') ||
1763
+ (creatingRow && tableOptions.createDisplayMode === 'row')) && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row, table }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: tableOptions.localization.actions, size: 70 }, tableOptions.defaultDisplayColumn), (_f = tableOptions.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-actions']), { id: 'mrt-row-actions' }),
1764
+ ((_h = (_g = tableOptions.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-expand') &&
1765
+ showExpandColumn(tableOptions, (_k = (_j = tableOptions.state) === null || _j === void 0 ? void 0 : _j.grouping) !== null && _k !== void 0 ? _k : grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_ExpandButton, { row: row, table: table })), Header: tableOptions.enableExpandAll
1766
+ ? ({ table }) => jsxRuntime.jsx(MRT_ExpandAllButton, { table: table })
1767
+ : null, header: tableOptions.localization.expand, size: 60 }, tableOptions.defaultDisplayColumn), (_l = tableOptions.displayColumnDefOptions) === null || _l === void 0 ? void 0 : _l['mrt-row-expand']), { id: 'mrt-row-expand' }),
1768
+ ((_o = (_m = tableOptions.state) === null || _m === void 0 ? void 0 : _m.columnOrder) !== null && _o !== void 0 ? _o : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: tableOptions.enableSelectAll &&
1769
+ tableOptions.enableMultiRowSelection
1770
+ ? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
1771
+ : null, header: tableOptions.localization.select, size: 60 }, tableOptions.defaultDisplayColumn), (_p = tableOptions.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-select']), { id: 'mrt-row-select' }),
1772
+ ((_r = (_q = tableOptions.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber, header: tableOptions.localization.rowNumbers, size: 60 }, tableOptions.defaultDisplayColumn), (_s = tableOptions.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
1773
+ ].filter(Boolean);
1774
+ }, [
1775
+ columnOrder,
1776
+ grouping,
1777
+ tableOptions.displayColumnDefOptions,
1778
+ tableOptions.editDisplayMode,
1779
+ tableOptions.enableColumnDragging,
1780
+ tableOptions.enableColumnFilterModes,
1781
+ tableOptions.enableColumnOrdering,
1782
+ tableOptions.enableEditing,
1783
+ tableOptions.enableExpandAll,
1784
+ tableOptions.enableExpanding,
1785
+ tableOptions.enableGrouping,
1786
+ tableOptions.enableRowActions,
1787
+ tableOptions.enableRowDragging,
1788
+ tableOptions.enableRowNumbers,
1789
+ tableOptions.enableRowOrdering,
1790
+ tableOptions.enableRowSelection,
1791
+ tableOptions.enableSelectAll,
1792
+ tableOptions.localization,
1793
+ tableOptions.positionActionsColumn,
1794
+ tableOptions.renderDetailPanel,
1795
+ tableOptions.renderRowActionMenuItems,
1796
+ tableOptions.renderRowActions,
1797
+ (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder,
1798
+ (_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.grouping,
1799
+ ]);
1800
+ };
1801
+
1802
+ const useMRT_Effects = (table) => {
1803
+ const { getState, options: { enablePagination, rowCount }, } = table;
1804
+ const { globalFilter, isFullScreen, pagination, sorting, isLoading, showSkeletons, } = getState();
1805
+ const isMounted = react.useRef(false);
1806
+ const initialBodyHeight = react.useRef();
1807
+ const previousTop = react.useRef();
1808
+ react.useEffect(() => {
1809
+ if (typeof window !== 'undefined') {
1810
+ initialBodyHeight.current = document.body.style.height;
1811
+ }
1812
+ }, []);
1813
+ react.useEffect(() => {
1814
+ if (isMounted && typeof window !== 'undefined') {
1815
+ if (isFullScreen) {
1816
+ previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
1817
+ document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
1818
+ }
1819
+ else {
1820
+ document.body.style.height = initialBodyHeight.current;
1821
+ if (!previousTop.current)
1822
+ return;
1823
+ //restore scroll position
1824
+ window.scrollTo({
1825
+ top: -1 * previousTop.current,
1826
+ behavior: 'instant',
1827
+ });
1828
+ }
1829
+ }
1830
+ isMounted.current = true;
1831
+ }, [isFullScreen]);
1832
+ //if page index is out of bounds, set it to the last page
1833
+ react.useEffect(() => {
1834
+ if (!enablePagination || isLoading || showSkeletons)
1835
+ return;
1836
+ const { pageIndex, pageSize } = pagination;
1837
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
1838
+ const firstVisibleRowIndex = pageIndex * pageSize;
1839
+ if (firstVisibleRowIndex > totalRowCount) {
1840
+ table.setPageIndex(Math.floor(totalRowCount / pageSize));
1841
+ }
1842
+ }, [rowCount, table.getPrePaginationRowModel().rows.length]);
1843
+ //turn off sort when global filter is looking for ranked results
1844
+ const appliedSort = react.useRef(sorting);
1845
+ react.useEffect(() => {
1846
+ if (sorting.length) {
1847
+ appliedSort.current = sorting;
1848
+ }
1849
+ }, [sorting]);
1850
+ react.useEffect(() => {
1851
+ if (!getCanRankRows(table))
1852
+ return;
1853
+ if (globalFilter) {
1854
+ table.setSorting([]);
1855
+ }
1856
+ else {
1857
+ table.setSorting(() => appliedSort.current || []);
1858
+ }
1859
+ }, [globalFilter]);
1860
+ };
1861
+
1862
+ const useMRT_TableInstance = (tableOptions) => {
1863
+ 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;
1864
+ const bottomToolbarRef = react.useRef(null);
1865
+ const editInputRefs = react.useRef({});
1866
+ const filterInputRefs = react.useRef({});
1867
+ const searchInputRef = react.useRef(null);
1868
+ const tableContainerRef = react.useRef(null);
1869
+ const tableHeadCellRefs = react.useRef({});
1870
+ const tablePaperRef = react.useRef(null);
1871
+ const topToolbarRef = react.useRef(null);
1872
+ const initialState = react.useMemo(() => {
1873
+ var _a, _b, _c;
1874
+ const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1875
+ initState.columnOrder =
1876
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
1877
+ initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1878
+ return initState;
1879
+ }, []);
1880
+ const [creatingRow, _setCreatingRow] = react.useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
1881
+ const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
1882
+ var _a, _b, _c, _d;
1883
+ return ({
1884
+ [getColumnId(col)]: col.filterFn instanceof Function
1885
+ ? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
1886
+ : (_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),
1887
+ });
1888
+ })));
1889
+ const [columnOrder, setColumnOrder] = react.useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
1890
+ const [density, setDensity] = react.useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
1891
+ const [draggingColumn, setDraggingColumn] = react.useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
1892
+ const [draggingRow, setDraggingRow] = react.useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
1893
+ const [editingCell, setEditingCell] = react.useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
1894
+ const [editingRow, setEditingRow] = react.useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
1895
+ const [globalFilterFn, setGlobalFilterFn] = react.useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
1896
+ const [grouping, setGrouping] = react.useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
1897
+ const [hoveredColumn, setHoveredColumn] = react.useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
1898
+ const [hoveredRow, setHoveredRow] = react.useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
1899
+ const [isFullScreen, setIsFullScreen] = react.useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
1900
+ const [showAlertBanner, setShowAlertBanner] = react.useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
1901
+ const [showColumnFilters, setShowColumnFilters] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
1902
+ const [showGlobalFilter, setShowGlobalFilter] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
1903
+ const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
1904
+ const displayColumns = useMRT_DisplayColumns({
1905
+ columnOrder,
1906
+ creatingRow,
1907
+ grouping,
1908
+ tableOptions,
1909
+ });
1910
+ const columnDefs = react.useMemo(() => {
1911
+ var _a, _b, _c;
1912
+ return prepareColumns({
1913
+ aggregationFns: tableOptions.aggregationFns,
1914
+ columnDefs: [...displayColumns, ...tableOptions.columns],
1915
+ columnFilterFns: (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
1916
+ defaultDisplayColumn: (_c = tableOptions.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
1917
+ filterFns: tableOptions.filterFns,
1918
+ sortingFns: tableOptions.sortingFns,
1919
+ });
1920
+ }, [
1921
+ columnFilterFns,
1922
+ displayColumns,
1923
+ tableOptions.columns,
1924
+ (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnFilterFns,
1925
+ ]);
1926
+ const data = react.useMemo(() => {
1927
+ var _a, _b, _c, _d, _e;
1928
+ return (((_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
1929
+ !tableOptions.data.length
1930
+ ? [
1931
+ ...Array(((_d = (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
1932
+ ((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
1933
+ 10).fill(null),
1934
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
1935
+ [getColumnId(col)]: null,
1936
+ }))))
1937
+ : tableOptions.data;
1938
+ }, [
1939
+ tableOptions.data,
1940
+ (_u = tableOptions.state) === null || _u === void 0 ? void 0 : _u.isLoading,
1941
+ (_v = tableOptions.state) === null || _v === void 0 ? void 0 : _v.showSkeletons,
1942
+ ]);
1943
+ //@ts-ignore
1944
+ const table = reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
1945
+ ? reactTable.getExpandedRowModel()
1946
+ : undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
1947
+ ? reactTable.getFacetedMinMaxValues()
1948
+ : undefined, getFacetedRowModel: tableOptions.enableFacetedValues
1949
+ ? reactTable.getFacetedRowModel()
1950
+ : undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
1951
+ ? reactTable.getFacetedUniqueValues()
1952
+ : undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
1953
+ tableOptions.enableGlobalFilter ||
1954
+ tableOptions.enableFilters
1955
+ ? reactTable.getFilteredRowModel()
1956
+ : undefined, getGroupedRowModel: tableOptions.enableGrouping
1957
+ ? reactTable.getGroupedRowModel()
1958
+ : undefined, getPaginationRowModel: tableOptions.enablePagination
1959
+ ? reactTable.getPaginationRowModel()
1960
+ : undefined, getSortedRowModel: tableOptions.enableSorting
1961
+ ? reactTable.getSortedRowModel()
1962
+ : undefined, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, tableOptions), {
1963
+ //@ts-ignore
1964
+ columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ creatingRow,
1965
+ columnFilterFns,
1966
+ columnOrder,
1967
+ density,
1968
+ draggingColumn,
1969
+ draggingRow,
1970
+ editingCell,
1971
+ editingRow,
1972
+ globalFilterFn,
1973
+ grouping,
1974
+ hoveredColumn,
1975
+ hoveredRow,
1976
+ isFullScreen,
1977
+ showAlertBanner,
1978
+ showColumnFilters,
1979
+ showGlobalFilter,
1980
+ showToolbarDropZone }, tableOptions.state) }));
1981
+ // @ts-ignore
1982
+ table.refs = {
1983
+ // @ts-ignore
1984
+ bottomToolbarRef,
1985
+ editInputRefs,
1986
+ filterInputRefs,
1987
+ // @ts-ignore
1988
+ searchInputRef,
1989
+ // @ts-ignore
1990
+ tableContainerRef,
1991
+ tableHeadCellRefs,
1992
+ // @ts-ignore
1993
+ tablePaperRef,
1994
+ // @ts-ignore
1995
+ topToolbarRef,
1996
+ };
1997
+ const setCreatingRow = (row) => {
1998
+ if (row === true) {
1999
+ table.setCreatingRow(createRow(table));
2000
+ }
2001
+ else {
2002
+ _setCreatingRow(row);
2003
+ }
2004
+ };
2005
+ table.setCreatingRow = setCreatingRow;
2006
+ table.setColumnFilterFns =
2007
+ (_x = tableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
2008
+ table.setDensity = (_y = tableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
2009
+ table.setDraggingColumn =
2010
+ (_z = tableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
2011
+ table.setDraggingRow = (_0 = tableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
2012
+ table.setEditingCell = (_1 = tableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
2013
+ table.setEditingRow = (_2 = tableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
2014
+ table.setGlobalFilterFn =
2015
+ (_3 = tableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
2016
+ table.setHoveredColumn =
2017
+ (_4 = tableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
2018
+ table.setHoveredRow = (_5 = tableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
2019
+ table.setIsFullScreen = (_6 = tableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
2020
+ table.setShowAlertBanner =
2021
+ (_7 = tableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
2022
+ table.setShowColumnFilters =
2023
+ (_8 = tableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
2024
+ table.setShowGlobalFilter =
2025
+ (_9 = tableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
2026
+ table.setShowToolbarDropZone =
2027
+ (_10 = tableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
2028
+ useMRT_Effects(table);
2029
+ return table;
2030
+ };
2031
+
2032
+ const useMaterialReactTable = (tableOptions) => {
2033
+ const parsedTableOptions = useMRT_TableOptions(tableOptions);
2034
+ const tableInstance = useMRT_TableInstance(parsedTableOptions);
2035
+ return tableInstance;
2036
+ };
2037
+
1091
2038
  const MRT_GlobalFilterTextField = ({ table, }) => {
1092
2039
  var _a;
1093
2040
  const { getState, setGlobalFilter, options: { enableGlobalFilterModes, icons: { SearchIcon, CloseIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
@@ -1211,49 +2158,34 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
1211
2158
  : alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))), children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsxRuntime.jsx(AlertTitle__default["default"], { children: alertProps.title }), jsxRuntime.jsxs(Box__default["default"], { sx: { p: '0.5rem 1rem' }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectMessage || groupedByMessage) && (jsxRuntime.jsx("br", {})), selectMessage, selectMessage && groupedByMessage && jsxRuntime.jsx("br", {}), groupedByMessage] })] })) }));
1212
2159
  };
1213
2160
 
1214
- const MRT_FullScreenToggleButton = (_a) => {
2161
+ const MRT_ToggleFullScreenButton = (_a) => {
1215
2162
  var _b;
1216
2163
  var { table } = _a, rest = __rest(_a, ["table"]);
1217
2164
  const { getState, options: { icons: { FullscreenExitIcon, FullscreenIcon }, localization, }, setIsFullScreen, } = table;
1218
2165
  const { isFullScreen } = getState();
2166
+ const [tooltipOpened, setTooltipOpened] = react.useState(false);
1219
2167
  const handleToggleFullScreen = () => {
2168
+ setTooltipOpened(false);
1220
2169
  setIsFullScreen(!isFullScreen);
1221
2170
  };
1222
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleFullScreen }, rest, { title: undefined, children: isFullScreen ? jsxRuntime.jsx(FullscreenExitIcon, {}) : jsxRuntime.jsx(FullscreenIcon, {}) })) }));
2171
+ return (jsxRuntime.jsx(Tooltip__default["default"], { open: tooltipOpened, arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsxRuntime.jsx(FullscreenExitIcon, {}) : jsxRuntime.jsx(FullscreenIcon, {}) })) }));
1223
2172
  };
1224
2173
 
1225
2174
  const MRT_ColumnPinningButtons = ({ column, table, }) => {
1226
2175
  const { options: { icons: { PushPinIcon }, localization, }, } = table;
1227
2176
  const handlePinColumn = (pinDirection) => {
1228
- column.pin(pinDirection);
1229
- };
1230
- return (jsxRuntime.jsx(Box__default["default"], { sx: { minWidth: '70px', textAlign: 'center' }, children: column.getIsPinned() ? (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.unpin, children: jsxRuntime.jsx(IconButton__default["default"], { onClick: () => handlePinColumn(false), size: "small", children: jsxRuntime.jsx(PushPinIcon, {}) }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.pinToLeft, children: jsxRuntime.jsx(IconButton__default["default"], { onClick: () => handlePinColumn('left'), size: "small", children: jsxRuntime.jsx(PushPinIcon, { style: {
1231
- transform: 'rotate(90deg)',
1232
- } }) }) }), jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.pinToRight, children: jsxRuntime.jsx(IconButton__default["default"], { onClick: () => handlePinColumn('right'), size: "small", children: jsxRuntime.jsx(PushPinIcon, { style: {
1233
- transform: 'rotate(-90deg)',
1234
- } }) }) })] })) }));
1235
- };
1236
-
1237
- const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
1238
- var _a;
1239
- const { options: { icons: { DragHandleIcon }, localization, }, } = table;
1240
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.move, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
1241
- var _a;
1242
- e.stopPropagation();
1243
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
1244
- }, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: '0 -0.1rem', opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
1245
- backgroundColor: 'transparent',
1246
- opacity: 1,
1247
- }, '&:active': {
1248
- cursor: 'grabbing',
1249
- } }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
1250
- ? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
1251
- : iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined, children: jsxRuntime.jsx(DragHandleIcon, {}) })) }));
2177
+ column.pin(pinDirection);
2178
+ };
2179
+ return (jsxRuntime.jsx(Box__default["default"], { sx: { minWidth: '70px', textAlign: 'center' }, children: column.getIsPinned() ? (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.unpin, children: jsxRuntime.jsx(IconButton__default["default"], { onClick: () => handlePinColumn(false), size: "small", children: jsxRuntime.jsx(PushPinIcon, {}) }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.pinToLeft, children: jsxRuntime.jsx(IconButton__default["default"], { onClick: () => handlePinColumn('left'), size: "small", children: jsxRuntime.jsx(PushPinIcon, { style: {
2180
+ transform: 'rotate(90deg)',
2181
+ } }) }) }), jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.pinToRight, children: jsxRuntime.jsx(IconButton__default["default"], { onClick: () => handlePinColumn('right'), size: "small", children: jsxRuntime.jsx(PushPinIcon, { style: {
2182
+ transform: 'rotate(-90deg)',
2183
+ } }) }) })] })) }));
1252
2184
  };
1253
2185
 
1254
2186
  const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, table, }) => {
1255
2187
  var _a;
1256
- const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
2188
+ const { getState, options: { enableColumnOrdering, enableHiding, enableColumnPinning, localization, }, setColumnOrder, } = table;
1257
2189
  const { columnOrder } = getState();
1258
2190
  const { columnDef } = column;
1259
2191
  const { columnDefType } = columnDef;
@@ -1309,7 +2241,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredCol
1309
2241
  }, children: [columnDefType !== 'group' &&
1310
2242
  enableColumnOrdering &&
1311
2243
  !allColumns.some((col) => col.columnDef.columnDefType === 'group') &&
1312
- (columnDef.enableColumnOrdering !== false ? (jsxRuntime.jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsxRuntime.jsx(Box__default["default"], { sx: { width: '28px' } }))), enablePinning &&
2244
+ (columnDef.enableColumnOrdering !== false ? (jsxRuntime.jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsxRuntime.jsx(Box__default["default"], { sx: { width: '28px' } }))), enableColumnPinning &&
1313
2245
  (column.getCanPin() ? (jsxRuntime.jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsxRuntime.jsx(Box__default["default"], { sx: { width: '70px' } }))), enableHiding ? (jsxRuntime.jsx(FormControlLabel__default["default"], { componentsProps: {
1314
2246
  typography: {
1315
2247
  sx: {
@@ -1321,7 +2253,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredCol
1321
2253
  };
1322
2254
 
1323
2255
  const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, }) => {
1324
- const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, toggleAllColumnsVisible, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, } = table;
2256
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, toggleAllColumnsVisible, options: { enableColumnOrdering, enableHiding, enableColumnPinning, localization, }, } = table;
1325
2257
  const { density, columnOrder, columnPinning } = getState();
1326
2258
  const hideAllColumns = () => {
1327
2259
  getAllLeafColumns()
@@ -1355,7 +2287,7 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, }) => {
1355
2287
  justifyContent: 'space-between',
1356
2288
  p: '0.5rem',
1357
2289
  pt: 0,
1358
- }, children: [enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsVisible(), onClick: hideAllColumns, children: localization.hideAll })), enableColumnOrdering && (jsxRuntime.jsx(Button__default["default"], { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options)), children: localization.resetOrder })), enablePinning && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: getIsAllColumnsVisible(), onClick: () => toggleAllColumnsVisible(true), children: localization.showAll }))] }), jsxRuntime.jsx(Divider__default["default"], {}), allColumns.map((column, index) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] }));
2290
+ }, children: [enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsVisible(), onClick: hideAllColumns, children: localization.hideAll })), enableColumnOrdering && (jsxRuntime.jsx(Button__default["default"], { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options)), children: localization.resetOrder })), enableColumnPinning && (jsxRuntime.jsx(Button__default["default"], { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsxRuntime.jsx(Button__default["default"], { disabled: getIsAllColumnsVisible(), onClick: () => toggleAllColumnsVisible(true), children: localization.showAll }))] }), jsxRuntime.jsx(Divider__default["default"], {}), allColumns.map((column, index) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] }));
1359
2291
  };
1360
2292
 
1361
2293
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -1410,7 +2342,7 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
1410
2342
 
1411
2343
  const MRT_ToolbarInternalButtons = ({ table, }) => {
1412
2344
  var _a;
1413
- const { options: { enableColumnFilters, enableColumnOrdering, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, enablePinning, initialState, renderToolbarInternalActions, }, } = table;
2345
+ const { options: { enableColumnFilters, enableColumnOrdering, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, enableColumnPinning, initialState, renderToolbarInternalActions, }, } = table;
1414
2346
  return (jsxRuntime.jsx(Box__default["default"], { sx: {
1415
2347
  alignItems: 'center',
1416
2348
  display: 'flex',
@@ -1419,7 +2351,7 @@ const MRT_ToolbarInternalButtons = ({ table, }) => {
1419
2351
  table,
1420
2352
  })) !== null && _a !== void 0 ? _a : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [enableFilters &&
1421
2353
  enableGlobalFilter &&
1422
- !(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsxRuntime.jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters && enableColumnFilters && (jsxRuntime.jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enablePinning) && (jsxRuntime.jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsxRuntime.jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsxRuntime.jsx(MRT_FullScreenToggleButton, { table: table }))] })) }));
2354
+ !(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsxRuntime.jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters && enableColumnFilters && (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 }))] })) }));
1423
2355
  };
1424
2356
 
1425
2357
  const MRT_ToolbarDropZone = ({ table, }) => {
@@ -1538,7 +2470,7 @@ const MRT_BottomToolbar = ({ table, }) => {
1538
2470
 
1539
2471
  const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
1540
2472
  var _a;
1541
- const { options: { icons: { MoreVertIcon }, localization, muiTableHeadCellColumnActionsButtonProps, }, } = table;
2473
+ const { options: { icons: { MoreVertIcon }, localization, muiColumnActionsButtonProps, }, } = table;
1542
2474
  const { column } = header;
1543
2475
  const { columnDef } = column;
1544
2476
  const [anchorEl, setAnchorEl] = react.useState(null);
@@ -1547,15 +2479,15 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
1547
2479
  event.preventDefault();
1548
2480
  setAnchorEl(event.currentTarget);
1549
2481
  };
1550
- const mTableHeadCellColumnActionsButtonProps = muiTableHeadCellColumnActionsButtonProps instanceof Function
1551
- ? muiTableHeadCellColumnActionsButtonProps({ column, table })
1552
- : muiTableHeadCellColumnActionsButtonProps;
1553
- const mcTableHeadCellColumnActionsButtonProps = columnDef.muiTableHeadCellColumnActionsButtonProps instanceof Function
1554
- ? columnDef.muiTableHeadCellColumnActionsButtonProps({
2482
+ const mTableHeadCellColumnActionsButtonProps = muiColumnActionsButtonProps instanceof Function
2483
+ ? muiColumnActionsButtonProps({ column, table })
2484
+ : muiColumnActionsButtonProps;
2485
+ const mcTableHeadCellColumnActionsButtonProps = columnDef.muiColumnActionsButtonProps instanceof Function
2486
+ ? columnDef.muiColumnActionsButtonProps({
1555
2487
  column,
1556
2488
  table,
1557
2489
  })
1558
- : columnDef.muiTableHeadCellColumnActionsButtonProps;
2490
+ : columnDef.muiColumnActionsButtonProps;
1559
2491
  const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
1560
2492
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.columnActions, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', m: '-8px -4px', opacity: 0.5, transform: 'scale(0.85) translateX(-4px)', transition: 'opacity 150ms', width: '2rem', '&:hover': {
1561
2493
  opacity: 1,
@@ -1566,23 +2498,23 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
1566
2498
 
1567
2499
  const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1568
2500
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1569
- const { options: { enableColumnFilterModes, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, manualFiltering, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
2501
+ const { options: { enableColumnFilterModes, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, manualFiltering, muiFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
1570
2502
  const { column } = header;
1571
2503
  const { columnDef } = column;
1572
- const mTableHeadCellFilterTextFieldProps = muiTableHeadCellFilterTextFieldProps instanceof Function
1573
- ? muiTableHeadCellFilterTextFieldProps({
2504
+ const mTableHeadCellFilterTextFieldProps = muiFilterTextFieldProps instanceof Function
2505
+ ? muiFilterTextFieldProps({
1574
2506
  column,
1575
2507
  table,
1576
2508
  rangeFilterIndex,
1577
2509
  })
1578
- : muiTableHeadCellFilterTextFieldProps;
1579
- const mcTableHeadCellFilterTextFieldProps = columnDef.muiTableHeadCellFilterTextFieldProps instanceof Function
1580
- ? columnDef.muiTableHeadCellFilterTextFieldProps({
2510
+ : muiFilterTextFieldProps;
2511
+ const mcTableHeadCellFilterTextFieldProps = columnDef.muiFilterTextFieldProps instanceof Function
2512
+ ? columnDef.muiFilterTextFieldProps({
1581
2513
  column,
1582
2514
  table,
1583
2515
  rangeFilterIndex,
1584
2516
  })
1585
- : columnDef.muiTableHeadCellFilterTextFieldProps;
2517
+ : columnDef.muiFilterTextFieldProps;
1586
2518
  const textFieldProps = Object.assign(Object.assign({}, mTableHeadCellFilterTextFieldProps), mcTableHeadCellFilterTextFieldProps);
1587
2519
  const isRangeFilter = columnDef.filterVariant === 'range' || rangeFilterIndex !== undefined;
1588
2520
  const isSelectFilter = columnDef.filterVariant === 'select';
@@ -1612,7 +2544,9 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1612
2544
  const filterSelectOptions = react.useMemo(() => {
1613
2545
  var _a;
1614
2546
  return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter) && facetedUniqueValues
1615
- ? Array.from(facetedUniqueValues.keys()).sort((a, b) => a.localeCompare(b))
2547
+ ? Array.from(facetedUniqueValues.keys())
2548
+ .filter((value) => value !== null && value !== undefined)
2549
+ .sort((a, b) => a.localeCompare(b))
1616
2550
  : undefined);
1617
2551
  }, [
1618
2552
  columnDef.filterSelectOptions,
@@ -1759,966 +2693,442 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1759
2693
  value = option;
1760
2694
  text = option;
1761
2695
  }
1762
- else {
1763
- value = option.value;
1764
- text = option.text;
1765
- }
1766
- return (jsxRuntime.jsxs(MenuItem__default["default"], { sx: {
1767
- display: 'flex',
1768
- m: 0,
1769
- alignItems: 'center',
1770
- gap: '0.5rem',
1771
- }, value: value, children: [isMultiSelectFilter && (jsxRuntime.jsx(Checkbox__default["default"], { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), text, ' ', !columnDef.filterSelectOptions &&
1772
- `(${facetedUniqueValues.get(value)})`] }, value));
1773
- })] })), jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table, setFilterValue: setFilterValue })] }));
1774
- };
1775
-
1776
- const MRT_FilterRangeFields = ({ header, table }) => {
1777
- return (jsxRuntime.jsxs(Box__default["default"], { sx: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1rem' }, children: [jsxRuntime.jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: 0, table: table }), jsxRuntime.jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: 1, table: table })] }));
1778
- };
1779
-
1780
- const MRT_FilterCheckbox = ({ column, table }) => {
1781
- var _a, _b, _c;
1782
- const { getState, options: { localization, muiTableHeadCellFilterCheckboxProps }, } = table;
1783
- const { density } = getState();
1784
- const { columnDef } = column;
1785
- const mTableHeadCellFilterCheckboxProps = muiTableHeadCellFilterCheckboxProps instanceof Function
1786
- ? muiTableHeadCellFilterCheckboxProps({
1787
- column,
1788
- table,
1789
- })
1790
- : muiTableHeadCellFilterCheckboxProps;
1791
- const mcTableHeadCellFilterCheckboxProps = columnDef.muiTableHeadCellFilterCheckboxProps instanceof Function
1792
- ? columnDef.muiTableHeadCellFilterCheckboxProps({
1793
- column,
1794
- table,
1795
- })
1796
- : columnDef.muiTableHeadCellFilterCheckboxProps;
1797
- const checkboxProps = Object.assign(Object.assign({}, mTableHeadCellFilterCheckboxProps), mcTableHeadCellFilterCheckboxProps);
1798
- const filterLabel = (_a = localization.filterByColumn) === null || _a === void 0 ? void 0 : _a.replace('{column}', columnDef.header);
1799
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : filterLabel, children: jsxRuntime.jsx(FormControlLabel__default["default"], { control: jsxRuntime.jsx(Checkbox__default["default"], Object.assign({ checked: column.getFilterValue() === 'true', indeterminate: column.getFilterValue() === undefined, color: column.getFilterValue() === undefined ? 'default' : 'primary', size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
1800
- var _a;
1801
- e.stopPropagation();
1802
- (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
1803
- }, onChange: (e, checked) => {
1804
- var _a;
1805
- column.setFilterValue(column.getFilterValue() === undefined
1806
- ? 'true'
1807
- : column.getFilterValue() === 'true'
1808
- ? 'false'
1809
- : undefined);
1810
- (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
1811
- }, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
1812
- ? checkboxProps.sx(theme)
1813
- : checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) })), disableTypography: true, label: (_c = checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, sx: { color: 'text.secondary', mt: '-4px', fontWeight: 'normal' }, title: undefined }) }));
1814
- };
1815
-
1816
- const MRT_FilterRangeSlider = ({ header, table }) => {
1817
- var _a, _b;
1818
- const { options: { localization, muiTableHeadCellFilterSliderProps, enableColumnFilterModes, }, refs: { filterInputRefs }, } = table;
1819
- const { column } = header;
1820
- const { columnDef } = column;
1821
- const currentFilterOption = columnDef._filterFn;
1822
- const showChangeModeButton = enableColumnFilterModes && columnDef.enableColumnFilterModes !== false;
1823
- const mTableHeadCellFilterTextFieldProps = muiTableHeadCellFilterSliderProps instanceof Function
1824
- ? muiTableHeadCellFilterSliderProps({
1825
- column,
1826
- table,
1827
- })
1828
- : muiTableHeadCellFilterSliderProps;
1829
- const mcTableHeadCellFilterTextFieldProps = columnDef.muiTableHeadCellFilterSliderProps instanceof Function
1830
- ? columnDef.muiTableHeadCellFilterSliderProps({
1831
- column,
1832
- table,
1833
- })
1834
- : columnDef.muiTableHeadCellFilterSliderProps;
1835
- const sliderProps = Object.assign(Object.assign({}, mTableHeadCellFilterTextFieldProps), mcTableHeadCellFilterTextFieldProps);
1836
- let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
1837
- ? [sliderProps.min, sliderProps.max]
1838
- : (_a = column.getFacetedMinMaxValues()) !== null && _a !== void 0 ? _a : [0, 1];
1839
- //fix potential TanStack Table bugs where min or max is an array
1840
- if (Array.isArray(min))
1841
- min = min[0];
1842
- if (Array.isArray(max))
1843
- max = max[0];
1844
- if (min === null)
1845
- min = 0;
1846
- if (max === null)
1847
- max = 1;
1848
- const [filterValues, setFilterValues] = react.useState([min, max]);
1849
- const columnFilterValue = column.getFilterValue();
1850
- const isMounted = react.useRef(false);
1851
- react.useEffect(() => {
1852
- if (isMounted.current) {
1853
- if (columnFilterValue === undefined) {
1854
- setFilterValues([min, max]);
1855
- }
1856
- else if (Array.isArray(columnFilterValue)) {
1857
- setFilterValues(columnFilterValue);
1858
- }
1859
- }
1860
- isMounted.current = true;
1861
- }, [columnFilterValue, min, max]);
1862
- return (jsxRuntime.jsxs(Stack__default["default"], { children: [jsxRuntime.jsx(Slider__default["default"], Object.assign({ disableSwap: true, min: min, max: max, onChange: (_event, values) => {
1863
- setFilterValues(values);
1864
- }, onChangeCommitted: (_event, value) => {
1865
- if (Array.isArray(value)) {
1866
- if (value[0] <= min && value[1] >= max) {
1867
- //if the user has selected the entire range, remove the filter
1868
- column.setFilterValue(undefined);
1869
- }
1870
- else {
1871
- column.setFilterValue(value);
1872
- }
1873
- }
1874
- }, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
1875
- input: {
1876
- ref: (node) => {
1877
- var _a, _b;
1878
- if (node) {
1879
- filterInputRefs.current[`${column.id}-0`] = node;
1880
- // @ts-ignore
1881
- 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) {
1882
- //@ts-ignore
1883
- sliderProps.slotProps.input.ref = node;
1884
- }
1885
- }
1886
- },
1887
- },
1888
- }, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, ((sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx) instanceof Function
1889
- ? sliderProps.sx(theme)
1890
- : sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx))) })), showChangeModeButton ? (jsxRuntime.jsx(FormHelperText__default["default"], { sx: {
1891
- m: '-3px -6px',
1892
- fontSize: '0.75rem',
1893
- lineHeight: '0.8rem',
1894
- whiteSpace: 'nowrap',
1895
- }, children: localization.filterMode.replace('{filterType}',
1896
- // @ts-ignore
1897
- localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
1898
- (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
1899
- };
1900
-
1901
- const MRT_TableHeadCellFilterContainer = ({ header, table }) => {
1902
- const { getState } = table;
1903
- const { showColumnFilters } = getState();
1904
- const { column } = header;
1905
- const { columnDef } = column;
1906
- return (jsxRuntime.jsx(Collapse__default["default"], { in: showColumnFilters, mountOnEnter: true, unmountOnExit: true, children: columnDef.filterVariant === 'checkbox' ? (jsxRuntime.jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsxRuntime.jsx(MRT_FilterRangeSlider, { header: header, table: table })) : columnDef.filterVariant === 'range' ||
1907
- ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn) ? (jsxRuntime.jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsxRuntime.jsx(MRT_FilterTextField, { header: header, table: table })) }));
1908
- };
1909
-
1910
- const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1911
- var _a, _b, _c, _d;
1912
- const { options: { icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
1913
- const { column } = header;
1914
- const { columnDef } = column;
1915
- const isRangeFilter = ['range', 'ranger-slider'].includes((_a = columnDef.filterVariant) !== null && _a !== void 0 ? _a : '') ||
1916
- ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
1917
- const currentFilterOption = columnDef._filterFn;
1918
- const filterTooltip = localization.filteringByColumn
1919
- .replace('{column}', String(columnDef.header))
1920
- .replace('{filterType}',
1921
- // @ts-ignore
1922
- localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
1923
- (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`])
1924
- .replace('{filterValue}', `"${Array.isArray(column.getFilterValue())
1925
- ? column.getFilterValue().join(`" ${isRangeFilter ? localization.and : localization.or} "`)
1926
- : column.getFilterValue()}"`)
1927
- .replace('" "', '');
1928
- return (jsxRuntime.jsx(Grow__default["default"], { unmountOnExit: true, in: (!!column.getFilterValue() && !isRangeFilter) ||
1929
- (isRangeFilter && // @ts-ignore
1930
- (!!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[0]) || !!((_d = column.getFilterValue()) === null || _d === void 0 ? void 0 : _d[1]))), children: jsxRuntime.jsx(Box__default["default"], { component: "span", sx: { flex: '0 0' }, children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, placement: "top", title: filterTooltip, children: jsxRuntime.jsx(IconButton__default["default"], { disableRipple: true, onClick: (event) => {
1931
- setShowColumnFilters(true);
1932
- queueMicrotask(() => {
1933
- var _a, _b;
1934
- (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus();
1935
- (_b = filterInputRefs.current[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.select();
1936
- });
1937
- event.stopPropagation();
1938
- }, size: "small", sx: {
1939
- height: '12px',
1940
- m: 0,
1941
- opacity: 0.8,
1942
- p: '2px',
1943
- transform: 'scale(0.66)',
1944
- width: '12px',
1945
- }, children: jsxRuntime.jsx(FilterAltIcon, {}) }) }) }) }));
1946
- };
1947
-
1948
- const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
1949
- const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
1950
- const { columnDef } = column;
1951
- const { hoveredColumn, draggingColumn, columnOrder } = getState();
1952
- const mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function
1953
- ? muiTableHeadCellDragHandleProps({ column, table })
1954
- : muiTableHeadCellDragHandleProps;
1955
- const mcIconButtonProps = columnDef.muiTableHeadCellDragHandleProps instanceof Function
1956
- ? columnDef.muiTableHeadCellDragHandleProps({ column, table })
1957
- : columnDef.muiTableHeadCellDragHandleProps;
1958
- const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
1959
- const handleDragStart = (event) => {
1960
- var _a;
1961
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1962
- setDraggingColumn(column);
1963
- event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
1964
- };
1965
- const handleDragEnd = (event) => {
1966
- var _a;
1967
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1968
- if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1969
- column.toggleGrouping();
1970
- }
1971
- else if (enableColumnOrdering &&
1972
- hoveredColumn &&
1973
- (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
1974
- setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
1975
- }
1976
- setDraggingColumn(null);
1977
- setHoveredColumn(null);
1978
- };
1979
- return (jsxRuntime.jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
1980
- };
1981
-
1982
- const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
1983
- var _a;
1984
- const { getState, options: { columnResizeMode }, setColumnSizingInfo, } = table;
1985
- const { density } = getState();
1986
- const { column } = header;
1987
- return (jsxRuntime.jsx(Box__default["default"], { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
1988
- setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
1989
- column.resetSize();
1990
- }, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), sx: (theme) => ({
1991
- cursor: 'col-resize',
1992
- mr: density === 'compact' ? '-0.75rem' : '-1rem',
1993
- position: 'absolute',
1994
- right: '4px',
1995
- px: '4px',
1996
- '&:active > hr': {
1997
- backgroundColor: theme.palette.info.main,
1998
- opacity: 1,
1999
- },
2000
- }), style: {
2001
- transform: column.getIsResizing() && columnResizeMode === 'onEnd'
2002
- ? `translateX(${(_a = getState().columnSizingInfo.deltaOffset) !== null && _a !== void 0 ? _a : 0}px)`
2003
- : undefined,
2004
- }, children: jsxRuntime.jsx(Divider__default["default"], { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: {
2005
- borderRadius: '2px',
2006
- borderWidth: '2px',
2007
- height: '24px',
2008
- touchAction: 'none',
2009
- transition: column.getIsResizing()
2010
- ? undefined
2011
- : 'all 150ms ease-in-out',
2012
- userSelect: 'none',
2013
- zIndex: 4,
2014
- } }) }));
2015
- };
2016
-
2017
- const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
2018
- const { getState, options: { icons: { ArrowDownwardIcon }, localization, }, } = table;
2019
- const { column } = header;
2020
- const { columnDef } = column;
2021
- const { sorting } = getState();
2022
- const sortTooltip = column.getIsSorted()
2023
- ? column.getIsSorted() === 'desc'
2024
- ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
2025
- : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
2026
- : localization.unsorted;
2027
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, placement: "top", title: sortTooltip, children: jsxRuntime.jsx(Badge__default["default"], { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular", children: jsxRuntime.jsx(TableSortLabel__default["default"], { "aria-label": sortTooltip, active: !!column.getIsSorted(), direction: column.getIsSorted()
2028
- ? column.getIsSorted()
2029
- : undefined, sx: {
2030
- flex: '0 0',
2031
- width: '2.4ch',
2032
- transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
2033
- ? 'translateX(-0.5ch)'
2034
- : undefined,
2035
- }, IconComponent: ArrowDownwardIcon, onClick: (e) => {
2036
- var _a;
2037
- e.stopPropagation();
2038
- (_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
2039
- } }) }) }));
2696
+ else {
2697
+ value = option.value;
2698
+ text = option.text;
2699
+ }
2700
+ return (jsxRuntime.jsxs(MenuItem__default["default"], { sx: {
2701
+ display: 'flex',
2702
+ m: 0,
2703
+ alignItems: 'center',
2704
+ gap: '0.5rem',
2705
+ }, value: value, children: [isMultiSelectFilter && (jsxRuntime.jsx(Checkbox__default["default"], { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), text, ' ', !columnDef.filterSelectOptions &&
2706
+ `(${facetedUniqueValues.get(value)})`] }, value));
2707
+ })] })), jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table, setFilterValue: setFilterValue })] }));
2040
2708
  };
2041
2709
 
2042
- const MRT_TableHeadCell = ({ header, table }) => {
2043
- var _a, _b, _c, _d, _f, _g;
2044
- const theme = styles.useTheme();
2045
- const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
2046
- const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
2047
- const { column } = header;
2710
+ const MRT_FilterRangeFields = ({ header, table, }) => {
2711
+ return (jsxRuntime.jsxs(Box__default["default"], { sx: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1rem' }, children: [jsxRuntime.jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: 0, table: table }), jsxRuntime.jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: 1, table: table })] }));
2712
+ };
2713
+
2714
+ const MRT_FilterCheckbox = ({ column, table, }) => {
2715
+ var _a, _b, _c;
2716
+ const { getState, options: { localization, muiFilterCheckboxProps }, } = table;
2717
+ const { density } = getState();
2048
2718
  const { columnDef } = column;
2049
- const { columnDefType } = columnDef;
2050
- const mTableHeadCellProps = muiTableHeadCellProps instanceof Function
2051
- ? muiTableHeadCellProps({ column, table })
2052
- : muiTableHeadCellProps;
2053
- const mcTableHeadCellProps = columnDef.muiTableHeadCellProps instanceof Function
2054
- ? columnDef.muiTableHeadCellProps({ column, table })
2055
- : columnDef.muiTableHeadCellProps;
2056
- const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
2057
- const showColumnActions = (enableColumnActions || columnDef.enableColumnActions) &&
2058
- columnDef.enableColumnActions !== false;
2059
- const showDragHandle = enableColumnDragging !== false &&
2060
- columnDef.enableColumnDragging !== false &&
2061
- (enableColumnDragging ||
2062
- (enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
2063
- (enableGrouping &&
2064
- columnDef.enableGrouping !== false &&
2065
- !grouping.includes(column.id)));
2066
- const headerPL = react.useMemo(() => {
2067
- let pl = 0;
2068
- if (column.getCanSort())
2069
- pl++;
2070
- if (showColumnActions)
2071
- pl += 1.75;
2072
- if (showDragHandle)
2073
- pl += 1.25;
2074
- return pl;
2075
- }, [showColumnActions, showDragHandle]);
2076
- const draggingBorder = react.useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
2077
- ? `1px dashed ${theme.palette.text.secondary}`
2078
- : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
2079
- ? `2px dashed ${theme.palette.primary.main}`
2080
- : undefined, [draggingColumn, hoveredColumn]);
2081
- const draggingBorders = draggingBorder
2082
- ? {
2083
- borderLeft: draggingBorder,
2084
- borderRight: draggingBorder,
2085
- borderTop: draggingBorder,
2086
- }
2087
- : undefined;
2088
- const handleDragEnter = (_e) => {
2089
- if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2090
- setHoveredColumn(null);
2091
- }
2092
- if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
2093
- setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2094
- }
2095
- };
2096
- const headerElement = (columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) instanceof Function
2097
- ? (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
2719
+ const mTableHeadCellFilterCheckboxProps = muiFilterCheckboxProps instanceof Function
2720
+ ? muiFilterCheckboxProps({
2098
2721
  column,
2099
- header,
2100
2722
  table,
2101
2723
  })
2102
- : (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) !== null && _b !== void 0 ? _b : columnDef.header;
2103
- return (jsxRuntime.jsxs(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
2104
- if (node) {
2105
- tableHeadCellRefs.current[column.id] = node;
2106
- }
2107
- } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: layoutMode === 'grid' ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
2108
- ? '0.5rem'
2109
- : density === 'comfortable'
2110
- ? columnDefType === 'display'
2111
- ? '0.75rem'
2112
- : '1rem'
2113
- : columnDefType === 'display'
2114
- ? '1rem 1.25rem'
2115
- : '1.5rem', pb: columnDefType === 'display'
2116
- ? 0
2117
- : showColumnFilters || density === 'compact'
2118
- ? '0.4rem'
2119
- : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
2120
- ? '0.25rem'
2121
- : density === 'comfortable'
2122
- ? '.75rem'
2123
- : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
2124
- ? 3
2125
- : column.getIsPinned() && columnDefType !== 'group'
2126
- ? 2
2127
- : 1 }, getCommonCellStyles({
2724
+ : muiFilterCheckboxProps;
2725
+ const mcTableHeadCellFilterCheckboxProps = columnDef.muiFilterCheckboxProps instanceof Function
2726
+ ? columnDef.muiFilterCheckboxProps({
2128
2727
  column,
2129
- header,
2130
2728
  table,
2131
- tableCellProps,
2132
- theme,
2133
- })), draggingBorders)), children: [header.isPlaceholder ? null : (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content", sx: {
2134
- alignItems: 'center',
2135
- display: 'flex',
2136
- flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
2137
- justifyContent: columnDefType === 'group' || (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
2138
- ? 'center'
2139
- : column.getCanResize()
2140
- ? 'space-between'
2141
- : 'flex-start',
2142
- position: 'relative',
2143
- width: '100%',
2144
- }, children: [jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Labels", onClick: column.getToggleSortingHandler(), sx: {
2145
- alignItems: 'center',
2146
- cursor: column.getCanSort() && columnDefType !== 'group'
2147
- ? 'pointer'
2148
- : undefined,
2149
- display: 'flex',
2150
- flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
2151
- overflow: columnDefType === 'data' ? 'hidden' : undefined,
2152
- pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
2153
- ? `${headerPL}rem`
2154
- : undefined,
2155
- }, children: [jsxRuntime.jsx(Box__default["default"], { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
2156
- minWidth: `${Math.min((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0, 5)}ch`,
2157
- overflow: columnDefType === 'data' ? 'hidden' : undefined,
2158
- textOverflow: 'ellipsis',
2159
- whiteSpace: ((_g = (_f = columnDef.header) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0) < 20 ? 'nowrap' : 'normal',
2160
- '&:hover': {
2161
- textOverflow: 'clip',
2162
- },
2163
- }, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanSort() && (jsxRuntime.jsx(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Actions", sx: { whiteSpace: 'nowrap' }, children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
2164
- current: tableHeadCellRefs.current[column.id],
2165
- } })), showColumnActions && (jsxRuntime.jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] })), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
2166
- };
2167
-
2168
- const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
2169
- const { options: { layoutMode, muiTableHeadRowProps }, } = table;
2170
- const tableRowProps = muiTableHeadRowProps instanceof Function
2171
- ? muiTableHeadRowProps({ headerGroup, table })
2172
- : muiTableHeadRowProps;
2173
- return (jsxRuntime.jsxs(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.04), boxShadow: `4px 0 8px ${styles.alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', top: 0 }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2174
- ? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
2175
- : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))), children: [virtualPaddingLeft ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
2176
- const header = virtualColumns
2177
- ? headerGroup.headers[headerOrVirtualHeader.index]
2178
- : headerOrVirtualHeader;
2179
- return (jsxRuntime.jsx(MRT_TableHeadCell, { header: header, table: table }, header.id));
2180
- }), virtualPaddingRight ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2181
- };
2182
-
2183
- const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
2184
- const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, } = table;
2185
- const { isFullScreen } = getState();
2186
- const tableHeadProps = muiTableHeadProps instanceof Function
2187
- ? muiTableHeadProps({ table })
2188
- : muiTableHeadProps;
2189
- const stickyHeader = enableStickyHeader || isFullScreen;
2190
- return (jsxRuntime.jsx(TableHead__default["default"], Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
2191
- ? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
2192
- : tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))), children: getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { headerGroup: headerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, headerGroup.id))) })));
2729
+ })
2730
+ : columnDef.muiFilterCheckboxProps;
2731
+ const checkboxProps = Object.assign(Object.assign({}, mTableHeadCellFilterCheckboxProps), mcTableHeadCellFilterCheckboxProps);
2732
+ const filterLabel = (_a = localization.filterByColumn) === null || _a === void 0 ? void 0 : _a.replace('{column}', columnDef.header);
2733
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : filterLabel, children: jsxRuntime.jsx(FormControlLabel__default["default"], { control: jsxRuntime.jsx(Checkbox__default["default"], Object.assign({ checked: column.getFilterValue() === 'true', indeterminate: column.getFilterValue() === undefined, color: column.getFilterValue() === undefined ? 'default' : 'primary', size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
2734
+ var _a;
2735
+ e.stopPropagation();
2736
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
2737
+ }, onChange: (e, checked) => {
2738
+ var _a;
2739
+ column.setFilterValue(column.getFilterValue() === undefined
2740
+ ? 'true'
2741
+ : column.getFilterValue() === 'true'
2742
+ ? 'false'
2743
+ : undefined);
2744
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
2745
+ }, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
2746
+ ? checkboxProps.sx(theme)
2747
+ : checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) })), disableTypography: true, label: (_c = checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, sx: { color: 'text.secondary', mt: '-4px', fontWeight: 'normal' }, title: undefined }) }));
2193
2748
  };
2194
2749
 
2195
- const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
2196
- var _a, _b, _c;
2197
- const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
2198
- const { column, row } = cell;
2750
+ const MRT_FilterRangeSlider = ({ header, table, }) => {
2751
+ var _a, _b;
2752
+ const { options: { localization, muiFilterSliderProps, enableColumnFilterModes }, refs: { filterInputRefs }, } = table;
2753
+ const { column } = header;
2199
2754
  const { columnDef } = column;
2200
- const { editingRow } = getState();
2201
- const [value, setValue] = react.useState(() => cell.getValue());
2202
- const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
2203
- ? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
2204
- : muiTableBodyCellEditTextFieldProps;
2205
- const mcTableBodyCellEditTextFieldProps = columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
2206
- ? columnDef.muiTableBodyCellEditTextFieldProps({
2207
- cell,
2755
+ const currentFilterOption = columnDef._filterFn;
2756
+ const showChangeModeButton = enableColumnFilterModes && columnDef.enableColumnFilterModes !== false;
2757
+ const mFilterSliderProps = muiFilterSliderProps instanceof Function
2758
+ ? muiFilterSliderProps({
2208
2759
  column,
2209
- row,
2210
2760
  table,
2211
2761
  })
2212
- : columnDef.muiTableBodyCellEditTextFieldProps;
2213
- const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
2214
- const isSelectEdit = columnDef.editVariant === 'select';
2215
- const saveRow = (newValue) => {
2216
- if (editingRow) {
2217
- setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: newValue }) }));
2218
- }
2219
- };
2220
- const handleChange = (event) => {
2221
- var _a;
2222
- (_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2223
- setValue(event.target.value);
2224
- if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) {
2225
- saveRow(event.target.value);
2226
- }
2227
- };
2228
- const handleBlur = (event) => {
2229
- var _a;
2230
- (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2231
- saveRow(value);
2232
- setEditingCell(null);
2233
- };
2234
- const handleEnterKeyDown = (event) => {
2235
- var _a, _b;
2236
- (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2237
- if (event.key === 'Enter') {
2238
- (_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
2239
- }
2240
- };
2241
- if (columnDef.Edit) {
2242
- return jsxRuntime.jsx(jsxRuntime.Fragment, { children: (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }) });
2243
- }
2244
- return (jsxRuntime.jsx(TextField__default["default"], Object.assign({ disabled: (columnDef.enableEditing instanceof Function
2245
- ? columnDef.enableEditing(row)
2246
- : columnDef.enableEditing) === false, fullWidth: true, inputRef: (inputRef) => {
2247
- if (inputRef) {
2248
- editInputRefs.current[column.id] = inputRef;
2249
- if (textFieldProps.inputRef) {
2250
- textFieldProps.inputRef = inputRef;
2251
- }
2252
- }
2253
- }, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, placeholder: columnDef.header, select: isSelectEdit, value: value, variant: "standard" }, textFieldProps, { onClick: (e) => {
2254
- var _a;
2255
- e.stopPropagation();
2256
- (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
2257
- }, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown, children: (_b = textFieldProps.children) !== null && _b !== void 0 ? _b : (_c = columnDef === null || columnDef === void 0 ? void 0 : columnDef.editSelectOptions) === null || _c === void 0 ? void 0 : _c.map((option) => {
2258
- let value;
2259
- let text;
2260
- if (typeof option !== 'object') {
2261
- value = option;
2262
- text = option;
2762
+ : muiFilterSliderProps;
2763
+ const mcFilterSliderProps = columnDef.muiFilterSliderProps instanceof Function
2764
+ ? columnDef.muiFilterSliderProps({
2765
+ column,
2766
+ table,
2767
+ })
2768
+ : columnDef.muiFilterSliderProps;
2769
+ const sliderProps = Object.assign(Object.assign({}, mFilterSliderProps), mcFilterSliderProps);
2770
+ let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
2771
+ ? [sliderProps.min, sliderProps.max]
2772
+ : (_a = column.getFacetedMinMaxValues()) !== null && _a !== void 0 ? _a : [0, 1];
2773
+ //fix potential TanStack Table bugs where min or max is an array
2774
+ if (Array.isArray(min))
2775
+ min = min[0];
2776
+ if (Array.isArray(max))
2777
+ max = max[0];
2778
+ if (min === null)
2779
+ min = 0;
2780
+ if (max === null)
2781
+ max = 1;
2782
+ const [filterValues, setFilterValues] = react.useState([min, max]);
2783
+ const columnFilterValue = column.getFilterValue();
2784
+ const isMounted = react.useRef(false);
2785
+ react.useEffect(() => {
2786
+ if (isMounted.current) {
2787
+ if (columnFilterValue === undefined) {
2788
+ setFilterValues([min, max]);
2263
2789
  }
2264
- else {
2265
- value = option.value;
2266
- text = option.text;
2790
+ else if (Array.isArray(columnFilterValue)) {
2791
+ setFilterValues(columnFilterValue);
2267
2792
  }
2268
- return (jsxRuntime.jsx(MenuItem__default["default"], { sx: {
2269
- display: 'flex',
2270
- m: 0,
2271
- alignItems: 'center',
2272
- gap: '0.5rem',
2273
- }, value: value, children: text }, value));
2274
- }) })));
2793
+ }
2794
+ isMounted.current = true;
2795
+ }, [columnFilterValue, min, max]);
2796
+ return (jsxRuntime.jsxs(Stack__default["default"], { children: [jsxRuntime.jsx(Slider__default["default"], Object.assign({ disableSwap: true, min: min, max: max, onChange: (_event, values) => {
2797
+ setFilterValues(values);
2798
+ }, onChangeCommitted: (_event, value) => {
2799
+ if (Array.isArray(value)) {
2800
+ if (value[0] <= min && value[1] >= max) {
2801
+ //if the user has selected the entire range, remove the filter
2802
+ column.setFilterValue(undefined);
2803
+ }
2804
+ else {
2805
+ column.setFilterValue(value);
2806
+ }
2807
+ }
2808
+ }, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
2809
+ input: {
2810
+ ref: (node) => {
2811
+ var _a, _b;
2812
+ if (node) {
2813
+ filterInputRefs.current[`${column.id}-0`] = node;
2814
+ // @ts-ignore
2815
+ 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) {
2816
+ //@ts-ignore
2817
+ sliderProps.slotProps.input.ref = node;
2818
+ }
2819
+ }
2820
+ },
2821
+ },
2822
+ }, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, ((sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx) instanceof Function
2823
+ ? sliderProps.sx(theme)
2824
+ : sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx))) })), showChangeModeButton ? (jsxRuntime.jsx(FormHelperText__default["default"], { sx: {
2825
+ m: '-3px -6px',
2826
+ fontSize: '0.75rem',
2827
+ lineHeight: '0.8rem',
2828
+ whiteSpace: 'nowrap',
2829
+ }, children: localization.filterMode.replace('{filterType}',
2830
+ // @ts-ignore
2831
+ localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
2832
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
2275
2833
  };
2276
2834
 
2277
- const MRT_CopyButton = ({ cell, children, table, }) => {
2278
- var _a;
2279
- const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
2280
- const { column, row } = cell;
2835
+ const MRT_TableHeadCellFilterContainer = ({ header, table, }) => {
2836
+ const { getState } = table;
2837
+ const { showColumnFilters } = getState();
2838
+ const { column } = header;
2281
2839
  const { columnDef } = column;
2282
- const [copied, setCopied] = react.useState(false);
2283
- const handleCopy = (event, text) => {
2284
- event.stopPropagation();
2285
- navigator.clipboard.writeText(text);
2286
- setCopied(true);
2287
- setTimeout(() => setCopied(false), 4000);
2288
- };
2289
- const mTableBodyCellCopyButtonProps = muiTableBodyCellCopyButtonProps instanceof Function
2290
- ? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
2291
- : muiTableBodyCellCopyButtonProps;
2292
- const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
2293
- ? columnDef.muiTableBodyCellCopyButtonProps({
2294
- cell,
2295
- column,
2296
- row,
2297
- table,
2298
- })
2299
- : columnDef.muiTableBodyCellCopyButtonProps;
2300
- const buttonProps = Object.assign(Object.assign({}, mTableBodyCellCopyButtonProps), mcTableBodyCellCopyButtonProps);
2301
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsxRuntime.jsx(Button__default["default"], 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', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
2302
- ? buttonProps.sx(theme)
2303
- : buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))), title: undefined, children: children })) }));
2840
+ return (jsxRuntime.jsx(Collapse__default["default"], { in: showColumnFilters, mountOnEnter: true, unmountOnExit: true, children: columnDef.filterVariant === 'checkbox' ? (jsxRuntime.jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsxRuntime.jsx(MRT_FilterRangeSlider, { header: header, table: table })) : columnDef.filterVariant === 'range' ||
2841
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn) ? (jsxRuntime.jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsxRuntime.jsx(MRT_FilterTextField, { header: header, table: table })) }));
2842
+ };
2843
+
2844
+ const MRT_TableHeadCellFilterLabel = ({ header, table, }) => {
2845
+ var _a, _b, _c, _d;
2846
+ const { options: { icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
2847
+ const { column } = header;
2848
+ const { columnDef } = column;
2849
+ const isRangeFilter = ['range', 'ranger-slider'].includes((_a = columnDef.filterVariant) !== null && _a !== void 0 ? _a : '') ||
2850
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
2851
+ const currentFilterOption = columnDef._filterFn;
2852
+ const filterTooltip = localization.filteringByColumn
2853
+ .replace('{column}', String(columnDef.header))
2854
+ .replace('{filterType}',
2855
+ // @ts-ignore
2856
+ localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
2857
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`])
2858
+ .replace('{filterValue}', `"${Array.isArray(column.getFilterValue())
2859
+ ? column.getFilterValue().join(`" ${isRangeFilter ? localization.and : localization.or} "`)
2860
+ : column.getFilterValue()}"`)
2861
+ .replace('" "', '');
2862
+ return (jsxRuntime.jsx(Grow__default["default"], { unmountOnExit: true, in: (!!column.getFilterValue() && !isRangeFilter) ||
2863
+ (isRangeFilter && // @ts-ignore
2864
+ (!!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[0]) || !!((_d = column.getFilterValue()) === null || _d === void 0 ? void 0 : _d[1]))), children: jsxRuntime.jsx(Box__default["default"], { component: "span", sx: { flex: '0 0' }, children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, placement: "top", title: filterTooltip, children: jsxRuntime.jsx(IconButton__default["default"], { disableRipple: true, onClick: (event) => {
2865
+ setShowColumnFilters(true);
2866
+ queueMicrotask(() => {
2867
+ var _a, _b;
2868
+ (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus();
2869
+ (_b = filterInputRefs.current[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.select();
2870
+ });
2871
+ event.stopPropagation();
2872
+ }, size: "small", sx: {
2873
+ height: '12px',
2874
+ m: 0,
2875
+ opacity: 0.8,
2876
+ p: '2px',
2877
+ transform: 'scale(0.66)',
2878
+ width: '12px',
2879
+ }, children: jsxRuntime.jsx(FilterAltIcon, {}) }) }) }) }));
2304
2880
  };
2305
2881
 
2306
- const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table }) => {
2307
- const { options: { muiTableBodyRowDragHandleProps }, } = table;
2308
- const { row } = cell;
2309
- const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
2310
- ? muiTableBodyRowDragHandleProps({ row, table })
2311
- : muiTableBodyRowDragHandleProps;
2882
+ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
2883
+ const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
2884
+ const { columnDef } = column;
2885
+ const { hoveredColumn, draggingColumn, columnOrder } = getState();
2886
+ const mIconButtonProps = muiColumnDragHandleProps instanceof Function
2887
+ ? muiColumnDragHandleProps({ column, table })
2888
+ : muiColumnDragHandleProps;
2889
+ const mcIconButtonProps = columnDef.muiColumnDragHandleProps instanceof Function
2890
+ ? columnDef.muiColumnDragHandleProps({ column, table })
2891
+ : columnDef.muiColumnDragHandleProps;
2892
+ const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
2312
2893
  const handleDragStart = (event) => {
2313
2894
  var _a;
2314
2895
  (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
2315
- event.dataTransfer.setDragImage(rowRef.current, 0, 0);
2316
- table.setDraggingRow(row);
2896
+ setDraggingColumn(column);
2897
+ event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
2317
2898
  };
2318
2899
  const handleDragEnd = (event) => {
2319
2900
  var _a;
2320
2901
  (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
2321
- table.setDraggingRow(null);
2322
- table.setHoveredRow(null);
2902
+ if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2903
+ column.toggleGrouping();
2904
+ }
2905
+ else if (enableColumnOrdering &&
2906
+ hoveredColumn &&
2907
+ (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
2908
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
2909
+ }
2910
+ setDraggingColumn(null);
2911
+ setHoveredColumn(null);
2323
2912
  };
2324
2913
  return (jsxRuntime.jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
2325
2914
  };
2326
2915
 
2327
- const allowedTypes = ['string', 'number'];
2328
- const MRT_TableBodyCellValue = ({ cell, table }) => {
2329
- var _a, _b, _c;
2330
- const { getState, options: { enableFilterMatchHighlighting }, } = table;
2331
- const { column, row } = cell;
2916
+ const MRT_TableHeadCellResizeHandle = ({ header, table, }) => {
2917
+ var _a;
2918
+ const { getState, options: { columnResizeMode }, setColumnSizingInfo, } = table;
2919
+ const { density } = getState();
2920
+ const { column } = header;
2921
+ return (jsxRuntime.jsx(Box__default["default"], { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
2922
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2923
+ column.resetSize();
2924
+ }, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), sx: (theme) => ({
2925
+ cursor: 'col-resize',
2926
+ mr: density === 'compact' ? '-0.75rem' : '-1rem',
2927
+ position: 'absolute',
2928
+ right: '4px',
2929
+ px: '4px',
2930
+ '&:active > hr': {
2931
+ backgroundColor: theme.palette.info.main,
2932
+ opacity: 1,
2933
+ },
2934
+ }), style: {
2935
+ transform: column.getIsResizing() && columnResizeMode === 'onEnd'
2936
+ ? `translateX(${(_a = getState().columnSizingInfo.deltaOffset) !== null && _a !== void 0 ? _a : 0}px)`
2937
+ : undefined,
2938
+ }, children: jsxRuntime.jsx(Divider__default["default"], { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: {
2939
+ borderRadius: '2px',
2940
+ borderWidth: '2px',
2941
+ height: '24px',
2942
+ touchAction: 'none',
2943
+ transition: column.getIsResizing()
2944
+ ? undefined
2945
+ : 'all 150ms ease-in-out',
2946
+ userSelect: 'none',
2947
+ zIndex: 4,
2948
+ } }) }));
2949
+ };
2950
+
2951
+ const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
2952
+ const { getState, options: { icons: { ArrowDownwardIcon }, localization, }, } = table;
2953
+ const { column } = header;
2332
2954
  const { columnDef } = column;
2333
- const { globalFilter, globalFilterFn } = getState();
2334
- const filterValue = column.getFilterValue();
2335
- let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
2336
- ? columnDef.AggregatedCell({
2337
- cell,
2338
- column,
2339
- row,
2340
- table,
2341
- })
2342
- : row.getIsGrouped() && !cell.getIsGrouped()
2343
- ? null
2344
- : cell.getIsGrouped() && columnDef.GroupedCell
2345
- ? columnDef.GroupedCell({
2346
- cell,
2347
- column,
2348
- row,
2349
- table,
2350
- })
2351
- : undefined;
2352
- const isGroupedValue = renderedCellValue !== undefined;
2353
- if (!isGroupedValue) {
2354
- renderedCellValue = cell.renderValue();
2355
- }
2356
- if (enableFilterMatchHighlighting &&
2357
- columnDef.enableFilterMatchHighlighting !== false &&
2358
- renderedCellValue &&
2359
- allowedTypes.includes(typeof renderedCellValue) &&
2360
- ((filterValue &&
2361
- allowedTypes.includes(typeof filterValue) &&
2362
- columnDef.filterVariant === 'text') ||
2363
- (globalFilter &&
2364
- allowedTypes.includes(typeof globalFilter) &&
2365
- column.getCanGlobalFilter()))) {
2366
- const chunks = highlightWords__default["default"] === null || highlightWords__default["default"] === void 0 ? void 0 : highlightWords__default["default"]({
2367
- text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
2368
- query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
2369
- matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
2370
- });
2371
- 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)) {
2372
- 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__default["default"], { "aria-hidden": "true", component: "span", sx: match
2373
- ? {
2374
- backgroundColor: (theme) => theme.palette.mode === 'dark'
2375
- ? styles.darken(theme.palette.warning.dark, 0.25)
2376
- : styles.lighten(theme.palette.warning.light, 0.5),
2377
- borderRadius: '2px',
2378
- color: (theme) => theme.palette.mode === 'dark' ? 'white' : 'black',
2379
- padding: '2px 1px',
2380
- }
2381
- : undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
2382
- }
2383
- }
2384
- if (columnDef.Cell && !isGroupedValue) {
2385
- renderedCellValue = columnDef.Cell({
2386
- cell,
2387
- renderedCellValue,
2388
- column,
2389
- row,
2390
- table,
2391
- });
2392
- }
2393
- return jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderedCellValue });
2955
+ const { sorting } = getState();
2956
+ const sortTooltip = column.getIsSorted()
2957
+ ? column.getIsSorted() === 'desc'
2958
+ ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
2959
+ : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
2960
+ : column.getNextSortingOrder() === 'desc'
2961
+ ? localization.sortByColumnDesc.replace('{column}', columnDef.header)
2962
+ : localization.sortByColumnAsc.replace('{column}', columnDef.header);
2963
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, placement: "top", title: sortTooltip, children: jsxRuntime.jsx(Badge__default["default"], { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular", children: jsxRuntime.jsx(TableSortLabel__default["default"], { "aria-label": sortTooltip, active: !!column.getIsSorted(), direction: column.getIsSorted()
2964
+ ? column.getIsSorted()
2965
+ : undefined, sx: {
2966
+ flex: '0 0',
2967
+ width: '2.4ch',
2968
+ transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
2969
+ ? 'translateX(-0.5ch)'
2970
+ : undefined,
2971
+ }, IconComponent: ArrowDownwardIcon, onClick: (e) => {
2972
+ var _a;
2973
+ e.stopPropagation();
2974
+ (_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
2975
+ } }) }) }));
2394
2976
  };
2395
2977
 
2396
- const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
2397
- var _a, _b, _c, _d;
2978
+ const MRT_TableHeadCell = ({ header, table, }) => {
2979
+ var _a, _b, _c, _d, _f, _g;
2398
2980
  const theme = styles.useTheme();
2399
- const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
2400
- const { draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, density, isLoading, showSkeletons, } = getState();
2401
- const { column, row } = cell;
2981
+ const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
2982
+ const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
2983
+ const { column } = header;
2402
2984
  const { columnDef } = column;
2403
2985
  const { columnDefType } = columnDef;
2404
- const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
2405
- ? muiTableBodyCellProps({ cell, column, row, table })
2406
- : muiTableBodyCellProps;
2407
- const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
2408
- ? columnDef.muiTableBodyCellProps({ cell, column, row, table })
2409
- : columnDef.muiTableBodyCellProps;
2410
- const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
2411
- const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
2412
- ? muiTableBodyCellSkeletonProps({ cell, column, row, table })
2413
- : muiTableBodyCellSkeletonProps;
2414
- const [skeletonWidth, setSkeletonWidth] = react.useState(0);
2415
- react.useEffect(() => setSkeletonWidth(isLoading || showSkeletons
2416
- ? columnDefType === 'display'
2417
- ? column.getSize() / 2
2418
- : Math.round(Math.random() * (column.getSize() - column.getSize() / 3) +
2419
- column.getSize() / 3)
2420
- : 100), []);
2421
- const draggingBorders = react.useMemo(() => {
2422
- const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
2423
- const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
2424
- const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
2425
- const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
2426
- const isFirstColumn = getIsFirstColumn(column, table);
2427
- const isLastColumn = getIsLastColumn(column, table);
2428
- const isLastRow = rowIndex === numRows - 1;
2429
- const borderStyle = isDraggingColumn || isDraggingRow
2430
- ? `1px dashed ${theme.palette.text.secondary} !important`
2431
- : isHoveredColumn || isHoveredRow
2432
- ? `2px dashed ${theme.palette.primary.main} !important`
2433
- : undefined;
2434
- return borderStyle
2435
- ? {
2436
- borderLeft: isDraggingColumn ||
2437
- isHoveredColumn ||
2438
- ((isDraggingRow || isHoveredRow) && isFirstColumn)
2439
- ? borderStyle
2440
- : undefined,
2441
- borderRight: isDraggingColumn ||
2442
- isHoveredColumn ||
2443
- ((isDraggingRow || isHoveredRow) && isLastColumn)
2444
- ? borderStyle
2445
- : undefined,
2446
- borderBottom: isDraggingRow || isHoveredRow || isLastRow
2447
- ? borderStyle
2448
- : undefined,
2449
- borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
2450
- }
2451
- : undefined;
2452
- }, [draggingColumn, draggingRow, hoveredColumn, hoveredRow, rowIndex]);
2453
- const isEditable = (enableEditing instanceof Function ? enableEditing(row) : enableEditing) &&
2454
- (columnDef.enableEditing instanceof Function
2455
- ? columnDef.enableEditing(row)
2456
- : columnDef.enableEditing) !== false;
2457
- const isEditing = isEditable &&
2458
- editingMode !== 'modal' &&
2459
- (editingMode === 'table' ||
2460
- (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
2461
- (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
2462
- !row.getIsGrouped();
2463
- const handleDoubleClick = (event) => {
2464
- var _a;
2465
- (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2466
- if (isEditable && editingMode === 'cell') {
2467
- setEditingCell(cell);
2468
- queueMicrotask(() => {
2469
- var _a;
2470
- const textField = editInputRefs.current[column.id];
2471
- if (textField) {
2472
- textField.focus();
2473
- (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
2474
- }
2475
- });
2986
+ const mTableHeadCellProps = muiTableHeadCellProps instanceof Function
2987
+ ? muiTableHeadCellProps({ column, table })
2988
+ : muiTableHeadCellProps;
2989
+ const mcTableHeadCellProps = columnDef.muiTableHeadCellProps instanceof Function
2990
+ ? columnDef.muiTableHeadCellProps({ column, table })
2991
+ : columnDef.muiTableHeadCellProps;
2992
+ const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
2993
+ const showColumnActions = (enableColumnActions || columnDef.enableColumnActions) &&
2994
+ columnDef.enableColumnActions !== false;
2995
+ const showDragHandle = enableColumnDragging !== false &&
2996
+ columnDef.enableColumnDragging !== false &&
2997
+ (enableColumnDragging ||
2998
+ (enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
2999
+ (enableGrouping &&
3000
+ columnDef.enableGrouping !== false &&
3001
+ !grouping.includes(column.id)));
3002
+ const headerPL = react.useMemo(() => {
3003
+ let pl = 0;
3004
+ if (column.getCanSort())
3005
+ pl++;
3006
+ if (showColumnActions)
3007
+ pl += 1.75;
3008
+ if (showDragHandle)
3009
+ pl += 1.25;
3010
+ return pl;
3011
+ }, [showColumnActions, showDragHandle]);
3012
+ const draggingBorder = react.useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
3013
+ ? `1px dashed ${theme.palette.text.secondary}`
3014
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
3015
+ ? `2px dashed ${theme.palette.primary.main}`
3016
+ : undefined, [draggingColumn, hoveredColumn]);
3017
+ const draggingBorders = draggingBorder
3018
+ ? {
3019
+ borderLeft: draggingBorder,
3020
+ borderRight: draggingBorder,
3021
+ borderTop: draggingBorder,
2476
3022
  }
2477
- };
2478
- const handleDragEnter = (e) => {
2479
- var _a;
2480
- (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
3023
+ : undefined;
3024
+ const handleDragEnter = (_e) => {
2481
3025
  if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2482
3026
  setHoveredColumn(null);
2483
3027
  }
2484
- if (enableColumnOrdering && draggingColumn) {
3028
+ if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
2485
3029
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2486
3030
  }
2487
3031
  };
2488
- return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ "data-index": virtualCell === null || virtualCell === void 0 ? void 0 : virtualCell.index, ref: (node) => {
3032
+ const headerElement = (columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) instanceof Function
3033
+ ? (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
3034
+ column,
3035
+ header,
3036
+ table,
3037
+ })
3038
+ : (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) !== null && _b !== void 0 ? _b : columnDef.header;
3039
+ return (jsxRuntime.jsxs(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
2489
3040
  if (node) {
2490
- measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
3041
+ tableHeadCellRefs.current[column.id] = node;
2491
3042
  }
2492
- } }, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ alignItems: layoutMode === 'grid' ? 'center' : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'inherit', justifyContent: layoutMode === 'grid' ? tableCellProps.align : undefined, overflow: 'hidden', p: density === 'compact'
2493
- ? columnDefType === 'display'
2494
- ? '0 0.5rem'
2495
- : '0.5rem'
3043
+ } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: layoutMode === 'grid' ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
3044
+ ? '0.5rem'
2496
3045
  : density === 'comfortable'
2497
3046
  ? columnDefType === 'display'
2498
- ? '0.5rem 0.75rem'
3047
+ ? '0.75rem'
2499
3048
  : '1rem'
2500
3049
  : columnDefType === 'display'
2501
3050
  ? '1rem 1.25rem'
2502
- : '1.5rem', pl: column.id === 'mrt-row-expand'
2503
- ? `${row.depth +
2504
- (density === 'compact'
2505
- ? 0.5
2506
- : density === 'comfortable'
2507
- ? 0.75
2508
- : 1.25)}rem`
2509
- : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0, '&:hover': {
2510
- outline: ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
2511
- ? `1px solid ${theme.palette.text.secondary}`
2512
- : undefined,
2513
- outlineOffset: '-1px',
2514
- textOverflow: 'clip',
2515
- } }, getCommonCellStyles({
3051
+ : '1.5rem', pb: columnDefType === 'display'
3052
+ ? 0
3053
+ : showColumnFilters || density === 'compact'
3054
+ ? '0.4rem'
3055
+ : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
3056
+ ? '0.25rem'
3057
+ : density === 'comfortable'
3058
+ ? '.75rem'
3059
+ : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
3060
+ ? 3
3061
+ : column.getIsPinned() && columnDefType !== 'group'
3062
+ ? 2
3063
+ : 1 }, getCommonCellStyles({
2516
3064
  column,
3065
+ header,
2517
3066
  table,
2518
- theme,
2519
3067
  tableCellProps,
2520
- })), draggingBorders)), children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [cell.getIsPlaceholder() ? ((_b = (_a = columnDef.PlaceholderCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : null) : isLoading || showSkeletons ? (jsxRuntime.jsx(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
2521
- rowNumberMode === 'static' &&
2522
- column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
2523
- (column.id === 'mrt-row-select' ||
2524
- column.id === 'mrt-row-expand' ||
2525
- !row.getIsGrouped()) ? ((_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2526
- cell,
2527
- renderedCellValue: cell.renderValue(),
2528
- column,
2529
- row,
2530
- table,
2531
- })) : isEditing ? (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2532
- columnDef.enableClickToCopy !== false ? (jsxRuntime.jsx(MRT_CopyButton, { cell: cell, table: table, children: jsxRuntime.jsx(MRT_TableBodyCellValue, { cell: cell, table: table }) })) : (jsxRuntime.jsx(MRT_TableBodyCellValue, { cell: cell, table: table })), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_d = row.subRows) === null || _d === void 0 ? void 0 : _d.length, ")"] }))] }) })));
2533
- };
2534
- const Memo_MRT_TableBodyCell = react.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2535
-
2536
- const MRT_TableDetailPanel = ({ parentRowRef, row, rowIndex, table, virtualRow, }) => {
2537
- const { getVisibleLeafColumns, getState, options: { layoutMode, muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
2538
- const { isLoading } = getState();
2539
- const tableRowProps = muiTableBodyRowProps instanceof Function
2540
- ? muiTableBodyRowProps({
2541
- isDetailPanel: true,
2542
- row,
2543
- staticRowIndex: rowIndex,
2544
- table,
2545
- })
2546
- : muiTableBodyRowProps;
2547
- const tableCellProps = muiTableDetailPanelProps instanceof Function
2548
- ? muiTableDetailPanelProps({ row, table })
2549
- : muiTableDetailPanelProps;
2550
- return (jsxRuntime.jsx(TableRow__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel" }, tableRowProps, { sx: (theme) => {
2551
- var _a, _b;
2552
- return (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row', position: virtualRow ? 'absolute' : undefined, top: virtualRow
2553
- ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
2554
- : undefined, transform: virtualRow
2555
- ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2556
- : undefined, width: '100%', zIndex: virtualRow ? 2 : undefined }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2557
- ? tableRowProps.sx(theme)
2558
- : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)));
2559
- }, children: jsxRuntime.jsx(TableCell__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
2560
- ? styles.lighten(theme.palette.background.default, 0.06)
2561
- : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: layoutMode === 'grid' ? 'flex' : 'table-cell', pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
2562
- ? tableCellProps.sx(theme)
2563
- : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))), children: renderDetailPanel && (jsxRuntime.jsx(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
2564
- };
2565
-
2566
- const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
2567
- const { getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
2568
- const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
2569
- const tableRowProps = muiTableBodyRowProps instanceof Function
2570
- ? muiTableBodyRowProps({ row, staticRowIndex: rowIndex, table })
2571
- : muiTableBodyRowProps;
2572
- const handleDragEnter = (_e) => {
2573
- if (enableRowOrdering && draggingRow) {
2574
- setHoveredRow(row);
2575
- }
2576
- };
2577
- const rowRef = react.useRef(null);
2578
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(TableRow__default["default"], Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
2579
- if (node) {
2580
- rowRef.current = node;
2581
- measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2582
- }
2583
- } }, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.06), boxSizing: 'border-box', display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, position: virtualRow ? 'absolute' : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', top: virtualRow ? 0 : undefined, width: '100%', '&:hover td': {
2584
- backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
2585
- ? row.getIsSelected()
2586
- ? `${styles.alpha(theme.palette.primary.main, 0.2)}`
2587
- : theme.palette.mode === 'dark'
2588
- ? `${styles.lighten(theme.palette.background.default, 0.12)}`
2589
- : `${styles.darken(theme.palette.background.default, 0.05)}`
2590
- : undefined,
2591
- } }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2592
- ? tableRowProps.sx(theme)
2593
- : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))), style: Object.assign({ transform: virtualRow
2594
- ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2595
- : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), children: [virtualPaddingLeft ? (jsxRuntime.jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
2596
- const cell = columnVirtualizer
2597
- ? row.getVisibleCells()[cellOrVirtualCell.index]
2598
- : cellOrVirtualCell;
2599
- const props = {
2600
- cell,
2601
- measureElement: columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement,
2602
- numRows,
2603
- rowIndex,
2604
- rowRef,
2605
- table,
2606
- virtualCell: columnVirtualizer
2607
- ? cellOrVirtualCell
2608
- : undefined,
2609
- };
2610
- return memoMode === 'cells' &&
2611
- cell.column.columnDef.columnDefType === 'data' &&
2612
- !draggingColumn &&
2613
- !draggingRow &&
2614
- (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
2615
- (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), cell.id)) : (jsxRuntime.jsx(MRT_TableBodyCell, Object.assign({}, props), cell.id));
2616
- }), virtualPaddingRight ? (jsxRuntime.jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsxRuntime.jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowIndex: rowIndex, table: table, virtualRow: virtualRow }))] }));
3068
+ theme,
3069
+ })), draggingBorders)), children: [header.isPlaceholder ? null : (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content", sx: {
3070
+ alignItems: 'center',
3071
+ display: 'flex',
3072
+ flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
3073
+ justifyContent: columnDefType === 'group' || (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
3074
+ ? 'center'
3075
+ : column.getCanResize()
3076
+ ? 'space-between'
3077
+ : 'flex-start',
3078
+ position: 'relative',
3079
+ width: '100%',
3080
+ }, children: [jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Labels", onClick: column.getToggleSortingHandler(), sx: {
3081
+ alignItems: 'center',
3082
+ cursor: column.getCanSort() && columnDefType !== 'group'
3083
+ ? 'pointer'
3084
+ : undefined,
3085
+ display: 'flex',
3086
+ flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
3087
+ overflow: columnDefType === 'data' ? 'hidden' : undefined,
3088
+ pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
3089
+ ? `${headerPL}rem`
3090
+ : undefined,
3091
+ }, children: [jsxRuntime.jsx(Box__default["default"], { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
3092
+ minWidth: `${Math.min((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0, 5)}ch`,
3093
+ overflow: columnDefType === 'data' ? 'hidden' : undefined,
3094
+ textOverflow: 'ellipsis',
3095
+ whiteSpace: ((_g = (_f = columnDef.header) === null || _f === void 0 ? void 0 : _f.length) !== null && _g !== void 0 ? _g : 0) < 20 ? 'nowrap' : 'normal',
3096
+ '&:hover': {
3097
+ textOverflow: 'clip',
3098
+ },
3099
+ }, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanSort() && (jsxRuntime.jsx(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Actions", sx: { whiteSpace: 'nowrap' }, children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
3100
+ current: tableHeadCellRefs.current[column.id],
3101
+ } })), showColumnActions && (jsxRuntime.jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] })), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
2617
3102
  };
2618
- const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
2619
3103
 
2620
- const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
2621
- var _a, _b, _c, _d;
2622
- const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowVirtualizerInstanceRef, rowVirtualizerProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
2623
- const { columnFilters, density, expanded, globalFilter, globalFilterFn, pagination, sorting, } = getState();
2624
- const tableBodyProps = muiTableBodyProps instanceof Function
2625
- ? muiTableBodyProps({ table })
2626
- : muiTableBodyProps;
2627
- const vProps_old = virtualizerProps instanceof Function
2628
- ? virtualizerProps({ table })
2629
- : virtualizerProps;
2630
- const vProps = rowVirtualizerProps instanceof Function
2631
- ? rowVirtualizerProps({ table })
2632
- : rowVirtualizerProps;
2633
- const shouldRankResults = react.useMemo(() => !manualExpanding &&
2634
- !manualFiltering &&
2635
- !manualGrouping &&
2636
- !manualSorting &&
2637
- enableGlobalFilterRankedResults &&
2638
- globalFilter &&
2639
- globalFilterFn === 'fuzzy' &&
2640
- expanded !== true &&
2641
- !Object.values(sorting).some(Boolean) &&
2642
- !Object.values(expanded).some(Boolean), [
2643
- enableGlobalFilterRankedResults,
2644
- expanded,
2645
- globalFilter,
2646
- manualExpanding,
2647
- manualFiltering,
2648
- manualGrouping,
2649
- manualSorting,
2650
- sorting,
2651
- ]);
2652
- const rows = react.useMemo(() => {
2653
- if (!shouldRankResults)
2654
- return getRowModel().rows;
2655
- const rankedRows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
2656
- if (enablePagination && !manualPagination) {
2657
- const start = pagination.pageIndex * pagination.pageSize;
2658
- return rankedRows.slice(start, start + pagination.pageSize);
2659
- }
2660
- return rankedRows;
2661
- }, [
2662
- shouldRankResults,
2663
- shouldRankResults ? getPrePaginationRowModel().rows : getRowModel().rows,
2664
- pagination.pageIndex,
2665
- pagination.pageSize,
2666
- ]);
2667
- const rowVirtualizer = enableRowVirtualization
2668
- ? reactVirtual.useVirtualizer(Object.assign(Object.assign({ count: rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
2669
- navigator.userAgent.indexOf('Firefox') === -1
2670
- ? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
2671
- : undefined, overscan: 4 }, vProps_old), vProps))
2672
- : undefined;
2673
- if (rowVirtualizerInstanceRef && rowVirtualizer) {
2674
- rowVirtualizerInstanceRef.current = rowVirtualizer;
2675
- }
2676
- //deprecated
2677
- if (virtualizerInstanceRef && rowVirtualizer) {
2678
- virtualizerInstanceRef.current = rowVirtualizer;
2679
- }
2680
- const virtualRows = rowVirtualizer
2681
- ? rowVirtualizer.getVirtualItems()
2682
- : undefined;
2683
- return (jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', height: rowVirtualizer
2684
- ? `${rowVirtualizer.getTotalSize()}px`
2685
- : 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, ((tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx) instanceof Function
2686
- ? tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx(theme)
2687
- : tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx))), children: (_a = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _a !== void 0 ? _a : (!rows.length ? (jsxRuntime.jsx("tr", { style: { display: layoutMode === 'grid' ? 'grid' : 'table-row' }, children: jsxRuntime.jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
2688
- display: layoutMode === 'grid' ? 'grid' : 'table-cell',
2689
- }, children: (_b = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(Typography__default["default"], { sx: {
2690
- color: 'text.secondary',
2691
- fontStyle: 'italic',
2692
- maxWidth: `min(100vw, ${(_d = (_c = tablePaperRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth) !== null && _d !== void 0 ? _d : 360}px)`,
2693
- py: '2rem',
2694
- textAlign: 'center',
2695
- width: '100%',
2696
- }, children: globalFilter || columnFilters.length
2697
- ? localization.noResultsFound
2698
- : localization.noRecordsToDisplay })) }) })) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
2699
- const row = rowVirtualizer
2700
- ? rows[rowOrVirtualRow.index]
2701
- : rowOrVirtualRow;
2702
- const props = {
2703
- columnVirtualizer,
2704
- measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
2705
- numRows: rows.length,
2706
- row,
2707
- rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex,
2708
- table,
2709
- virtualColumns,
2710
- virtualPaddingLeft,
2711
- virtualPaddingRight,
2712
- virtualRow: rowVirtualizer
2713
- ? rowOrVirtualRow
2714
- : undefined,
2715
- };
2716
- return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2717
- }) }))) })));
3104
+ const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
3105
+ const { options: { layoutMode, muiTableHeadRowProps }, } = table;
3106
+ const tableRowProps = muiTableHeadRowProps instanceof Function
3107
+ ? muiTableHeadRowProps({ headerGroup, table })
3108
+ : muiTableHeadRowProps;
3109
+ return (jsxRuntime.jsxs(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.04), boxShadow: `4px 0 8px ${styles.alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', top: 0 }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
3110
+ ? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
3111
+ : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))), children: [virtualPaddingLeft ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
3112
+ const header = virtualColumns
3113
+ ? headerGroup.headers[headerOrVirtualHeader.index]
3114
+ : headerOrVirtualHeader;
3115
+ return (jsxRuntime.jsx(MRT_TableHeadCell, { header: header, table: table }, header.id));
3116
+ }), virtualPaddingRight ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3117
+ };
3118
+
3119
+ const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
3120
+ const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, } = table;
3121
+ const { isFullScreen } = getState();
3122
+ const tableHeadProps = muiTableHeadProps instanceof Function
3123
+ ? muiTableHeadProps({ table })
3124
+ : muiTableHeadProps;
3125
+ const stickyHeader = enableStickyHeader || isFullScreen;
3126
+ return (jsxRuntime.jsx(TableHead__default["default"], Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
3127
+ ? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
3128
+ : tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))), children: getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { headerGroup: headerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, headerGroup.id))) })));
2718
3129
  };
2719
- const Memo_MRT_TableBody = react.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2720
3130
 
2721
- const MRT_TableFooterCell = ({ footer, table }) => {
3131
+ const MRT_TableFooterCell = ({ footer, table, }) => {
2722
3132
  var _a, _b, _c;
2723
3133
  const { getState, options: { layoutMode, muiTableFooterCellProps }, } = table;
2724
3134
  const { density } = getState();
@@ -2789,16 +3199,16 @@ const MRT_TableFooter = ({ table, virtualColumns, virtualPaddingLeft, virtualPad
2789
3199
  : tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { footerGroup: footerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, footerGroup.id))) })));
2790
3200
  };
2791
3201
 
2792
- const MRT_Table = ({ table }) => {
3202
+ const MRT_Table = ({ table, }) => {
2793
3203
  var _a, _b, _c, _d;
2794
- const { getFlatHeaders, getState, options: { columns, columnVirtualizerInstanceRef, columnVirtualizerProps, enableColumnResizing, enableColumnVirtualization, enablePinning, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
3204
+ const { getFlatHeaders, getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, columns, enableColumnResizing, enableColumnVirtualization, enableColumnPinning, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
2795
3205
  const { columnPinning, columnSizing, columnSizingInfo, columnVisibility, isFullScreen, } = getState();
2796
3206
  const tableProps = muiTableProps instanceof Function
2797
3207
  ? muiTableProps({ table })
2798
3208
  : muiTableProps;
2799
- const vProps = columnVirtualizerProps instanceof Function
2800
- ? columnVirtualizerProps({ table })
2801
- : columnVirtualizerProps;
3209
+ const vProps = columnVirtualizerOptions instanceof Function
3210
+ ? columnVirtualizerOptions({ table })
3211
+ : columnVirtualizerOptions;
2802
3212
  const columnSizeVars = react.useMemo(() => {
2803
3213
  const headers = getFlatHeaders();
2804
3214
  const colSizes = {};
@@ -2820,14 +3230,14 @@ const MRT_Table = ({ table }) => {
2820
3230
  .rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
2821
3231
  return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
2822
3232
  }, [table.getRowModel().rows, columnPinning, columnVisibility]);
2823
- const [leftPinnedIndexes, rightPinnedIndexes] = react.useMemo(() => enableColumnVirtualization && enablePinning
3233
+ const [leftPinnedIndexes, rightPinnedIndexes] = react.useMemo(() => enableColumnVirtualization && enableColumnPinning
2824
3234
  ? [
2825
3235
  table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
2826
3236
  table
2827
3237
  .getRightLeafColumns()
2828
3238
  .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
2829
3239
  ]
2830
- : [[], []], [columnPinning, enableColumnVirtualization, enablePinning]);
3240
+ : [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
2831
3241
  const columnVirtualizer = enableColumnVirtualization
2832
3242
  ? reactVirtual.useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: react.useCallback((range) => [
2833
3243
  ...new Set([
@@ -2857,15 +3267,60 @@ const MRT_Table = ({ table }) => {
2857
3267
  virtualPaddingLeft,
2858
3268
  virtualPaddingRight,
2859
3269
  };
2860
- return (jsxRuntime.jsxs(Table__default["default"], Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, ((tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) instanceof Function
2861
- ? tableProps.sx(theme)
2862
- : tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))), style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, props))] })));
3270
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Table__default["default"], Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, ((tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) instanceof Function
3271
+ ? tableProps.sx(theme)
3272
+ : tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))), style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, props))] })) }));
3273
+ };
3274
+
3275
+ const MRT_EditRowModal = ({ open, table, }) => {
3276
+ var _a;
3277
+ const { getState, options: { localization, onEditingRowCancel, onCreatingRowCancel, renderEditRowModalContent, renderCreateRowModalContent, muiCreateRowModalProps, muiEditRowModalProps, }, setEditingRow, setCreatingRow, } = table;
3278
+ const { creatingRow, editingRow } = getState();
3279
+ const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
3280
+ const createModalProps = muiCreateRowModalProps instanceof Function
3281
+ ? muiCreateRowModalProps({ row, table })
3282
+ : muiCreateRowModalProps;
3283
+ const editModalProps = muiEditRowModalProps instanceof Function
3284
+ ? muiEditRowModalProps({ row, table })
3285
+ : muiEditRowModalProps;
3286
+ const dialogProps = Object.assign(Object.assign({}, editModalProps), (creatingRow && createModalProps));
3287
+ const internalEditComponents = row
3288
+ .getAllCells()
3289
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
3290
+ .map((cell) => (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
3291
+ return (jsxRuntime.jsx(Dialog__default["default"], Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
3292
+ var _a;
3293
+ if (creatingRow) {
3294
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
3295
+ setCreatingRow(null);
3296
+ }
3297
+ else {
3298
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
3299
+ setEditingRow(null);
3300
+ }
3301
+ row._valuesCache = {}; //reset values cache
3302
+ (_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
3303
+ }, open: open }, dialogProps, { children: (_a = ((creatingRow &&
3304
+ (renderCreateRowModalContent === null || renderCreateRowModalContent === void 0 ? void 0 : renderCreateRowModalContent({
3305
+ row,
3306
+ table,
3307
+ internalEditComponents,
3308
+ }))) ||
3309
+ (renderEditRowModalContent === null || renderEditRowModalContent === void 0 ? void 0 : renderEditRowModalContent({
3310
+ row,
3311
+ table,
3312
+ internalEditComponents,
3313
+ })))) !== null && _a !== void 0 ? _a : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DialogTitle__default["default"], { sx: { textAlign: 'center' }, children: (creatingRow && localization.create) || localization.edit }), jsxRuntime.jsx(DialogContent__default["default"], { children: jsxRuntime.jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsxRuntime.jsx(Stack__default["default"], { sx: {
3314
+ gap: '24px',
3315
+ paddingTop: '16px',
3316
+ width: '100%',
3317
+ }, children: internalEditComponents }) }) }), jsxRuntime.jsx(DialogActions__default["default"], { sx: { p: '1.25rem' }, children: jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
2863
3318
  };
2864
3319
 
2865
3320
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react.useLayoutEffect : react.useEffect;
2866
- const MRT_TableContainer = ({ table }) => {
2867
- const { getState, options: { enableStickyHeader, muiTableContainerProps }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
2868
- const { isFullScreen } = getState();
3321
+ const MRT_TableContainer = ({ table, }) => {
3322
+ const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
3323
+ const { isFullScreen, creatingRow, editingRow, } = getState();
2869
3324
  const [totalToolbarHeight, setTotalToolbarHeight] = react.useState(0);
2870
3325
  const tableContainerProps = muiTableContainerProps instanceof Function
2871
3326
  ? muiTableContainerProps({ table })
@@ -2880,7 +3335,9 @@ const MRT_TableContainer = ({ table }) => {
2880
3335
  : 0;
2881
3336
  setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
2882
3337
  });
2883
- return (jsxRuntime.jsx(TableContainer__default["default"], Object.assign({}, tableContainerProps, { ref: (node) => {
3338
+ const createModalOpen = createDisplayMode === 'modal' && creatingRow;
3339
+ const editModalOpen = editDisplayMode === 'modal' && editingRow;
3340
+ return (jsxRuntime.jsxs(TableContainer__default["default"], Object.assign({}, tableContainerProps, { ref: (node) => {
2884
3341
  if (node) {
2885
3342
  tableContainerRef.current = node;
2886
3343
  if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
@@ -2894,10 +3351,10 @@ const MRT_TableContainer = ({ table }) => {
2894
3351
  ? tableContainerProps.sx(theme)
2895
3352
  : tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx))), style: Object.assign({ maxHeight: isFullScreen
2896
3353
  ? `calc(100vh - ${totalToolbarHeight}px)`
2897
- : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), children: jsxRuntime.jsx(MRT_Table, { table: table }) })));
3354
+ : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), children: [jsxRuntime.jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsxRuntime.jsx(MRT_EditRowModal, { open: true, table: table }))] })));
2898
3355
  };
2899
3356
 
2900
- const MRT_TablePaper = ({ table }) => {
3357
+ const MRT_TablePaper = ({ table, }) => {
2901
3358
  const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
2902
3359
  const { isFullScreen } = getState();
2903
3360
  const tablePaperProps = muiTablePaperProps instanceof Function
@@ -2909,16 +3366,22 @@ const MRT_TablePaper = ({ table }) => {
2909
3366
  //@ts-ignore
2910
3367
  tablePaperProps.ref.current = ref;
2911
3368
  }
2912
- }, sx: (theme) => (Object.assign({ transition: 'all 150ms ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
3369
+ }, sx: (theme) => (Object.assign({ overflow: 'hidden', transition: 'all 100ms ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
2913
3370
  ? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
2914
3371
  : tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
2915
3372
  ? {
3373
+ bottom: 0,
2916
3374
  height: '100vh',
3375
+ left: 0,
2917
3376
  margin: 0,
2918
3377
  maxHeight: '100vh',
2919
3378
  maxWidth: '100vw',
2920
3379
  padding: 0,
3380
+ position: 'fixed',
3381
+ right: 0,
3382
+ top: 0,
2921
3383
  width: '100vw',
3384
+ zIndex: 10,
2922
3385
  }
2923
3386
  : {})), children: [enableTopToolbar &&
2924
3387
  (renderTopToolbar instanceof Function
@@ -2929,254 +3392,70 @@ const MRT_TablePaper = ({ table }) => {
2929
3392
  : renderBottomToolbar !== null && renderBottomToolbar !== void 0 ? renderBottomToolbar : jsxRuntime.jsx(MRT_BottomToolbar, { table: table }))] })));
2930
3393
  };
2931
3394
 
2932
- const MRT_EditRowModal = ({ open, row, table, }) => {
2933
- const { options: { localization }, } = table;
2934
- return (jsxRuntime.jsxs(Dialog__default["default"], { open: open, children: [jsxRuntime.jsx(DialogTitle__default["default"], { textAlign: "center", children: localization.edit }), jsxRuntime.jsx(DialogContent__default["default"], { children: jsxRuntime.jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsxRuntime.jsx(Stack__default["default"], { sx: {
2935
- gap: '1.5rem',
2936
- minWidth: { xs: '300px', sm: '360px', md: '400px' },
2937
- pt: '1rem',
2938
- width: '100%',
2939
- }, children: row
2940
- .getAllCells()
2941
- .filter((cell) => cell.column.columnDef.columnDefType === 'data')
2942
- .map((cell) => (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, showLabel: true, table: table }, cell.id))) }) }) }), jsxRuntime.jsx(DialogActions__default["default"], { sx: { p: '1.25rem' }, children: jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] }));
2943
- };
2944
-
2945
- const MRT_TableRoot = (props) => {
2946
- 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, _11, _12, _13;
2947
- const bottomToolbarRef = react.useRef(null);
2948
- const editInputRefs = react.useRef({});
2949
- const filterInputRefs = react.useRef({});
2950
- const searchInputRef = react.useRef(null);
2951
- const tableContainerRef = react.useRef(null);
2952
- const tableHeadCellRefs = react.useRef({});
2953
- const tablePaperRef = react.useRef(null);
2954
- const topToolbarRef = react.useRef(null);
2955
- const initialState = react.useMemo(() => {
2956
- var _a, _b, _c;
2957
- const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
2958
- initState.columnOrder =
2959
- (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(props);
2960
- initState.globalFilterFn = (_c = props.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
2961
- return initState;
2962
- }, []);
2963
- const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(props.columns).map((col) => {
2964
- var _a, _b, _c, _d;
2965
- return ({
2966
- [getColumnId(col)]: col.filterFn instanceof Function
2967
- ? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
2968
- : (_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),
2969
- });
2970
- })));
2971
- const [columnOrder, setColumnOrder] = react.useState((_a = initialState.columnOrder) !== null && _a !== void 0 ? _a : []);
2972
- const [density, setDensity] = react.useState((_b = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _b !== void 0 ? _b : 'comfortable');
2973
- const [draggingColumn, setDraggingColumn] = react.useState((_c = initialState.draggingColumn) !== null && _c !== void 0 ? _c : null);
2974
- const [draggingRow, setDraggingRow] = react.useState((_d = initialState.draggingRow) !== null && _d !== void 0 ? _d : null);
2975
- const [editingCell, setEditingCell] = react.useState((_e = initialState.editingCell) !== null && _e !== void 0 ? _e : null);
2976
- const [editingRow, setEditingRow] = react.useState((_f = initialState.editingRow) !== null && _f !== void 0 ? _f : null);
2977
- const [globalFilterFn, setGlobalFilterFn] = react.useState((_g = initialState.globalFilterFn) !== null && _g !== void 0 ? _g : 'fuzzy');
2978
- const [grouping, setGrouping] = react.useState((_h = initialState.grouping) !== null && _h !== void 0 ? _h : []);
2979
- const [hoveredColumn, setHoveredColumn] = react.useState((_j = initialState.hoveredColumn) !== null && _j !== void 0 ? _j : null);
2980
- const [hoveredRow, setHoveredRow] = react.useState((_k = initialState.hoveredRow) !== null && _k !== void 0 ? _k : null);
2981
- const [isFullScreen, setIsFullScreen] = react.useState((_l = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _l !== void 0 ? _l : false);
2982
- const [showAlertBanner, setShowAlertBanner] = react.useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
2983
- const [showColumnFilters, setShowColumnFilters] = react.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
2984
- const [showGlobalFilter, setShowGlobalFilter] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
2985
- const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _r !== void 0 ? _r : false);
2986
- const displayColumns = react.useMemo(() => {
2987
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
2988
- return [
2989
- ((_b = (_a = props.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header: props.localization.move, size: 60 }, props.defaultDisplayColumn), (_c = props.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-drag']), { id: 'mrt-row-drag' }),
2990
- ((_e = (_d = props.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: props.localization.actions, size: 70 }, props.defaultDisplayColumn), (_f = props.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-actions']), { id: 'mrt-row-actions' }),
2991
- ((_h = (_g = props.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-expand') &&
2992
- showExpandColumn(props, (_k = (_j = props.state) === null || _j === void 0 ? void 0 : _j.grouping) !== null && _k !== void 0 ? _k : grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (jsxRuntime.jsx(MRT_ExpandButton, { row: row, table: table })), Header: props.enableExpandAll
2993
- ? () => jsxRuntime.jsx(MRT_ExpandAllButton, { table: table })
2994
- : null, header: props.localization.expand, size: 60 }, props.defaultDisplayColumn), (_l = props.displayColumnDefOptions) === null || _l === void 0 ? void 0 : _l['mrt-row-expand']), { id: 'mrt-row-expand' }),
2995
- ((_o = (_m = props.state) === null || _m === void 0 ? void 0 : _m.columnOrder) !== null && _o !== void 0 ? _o : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: props.enableSelectAll && props.enableMultiRowSelection
2996
- ? () => jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
2997
- : null, header: props.localization.select, size: 60 }, props.defaultDisplayColumn), (_p = props.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-select']), { id: 'mrt-row-select' }),
2998
- ((_r = (_q = props.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => props.localization.rowNumber, header: props.localization.rowNumbers, size: 60 }, props.defaultDisplayColumn), (_s = props.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
2999
- ].filter(Boolean);
3000
- }, [
3001
- columnOrder,
3002
- grouping,
3003
- props.displayColumnDefOptions,
3004
- props.editingMode,
3005
- props.enableColumnDragging,
3006
- props.enableColumnFilterModes,
3007
- props.enableColumnOrdering,
3008
- props.enableEditing,
3009
- props.enableExpandAll,
3010
- props.enableExpanding,
3011
- props.enableGrouping,
3012
- props.enableRowActions,
3013
- props.enableRowDragging,
3014
- props.enableRowNumbers,
3015
- props.enableRowOrdering,
3016
- props.enableRowSelection,
3017
- props.enableSelectAll,
3018
- props.localization,
3019
- props.positionActionsColumn,
3020
- props.renderDetailPanel,
3021
- props.renderRowActionMenuItems,
3022
- props.renderRowActions,
3023
- (_s = props.state) === null || _s === void 0 ? void 0 : _s.columnOrder,
3024
- (_t = props.state) === null || _t === void 0 ? void 0 : _t.grouping,
3025
- ]);
3026
- const columnDefs = react.useMemo(() => {
3027
- var _a, _b, _c;
3028
- return prepareColumns({
3029
- aggregationFns: props.aggregationFns,
3030
- columnDefs: [...displayColumns, ...props.columns],
3031
- columnFilterFns: (_b = (_a = props.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
3032
- defaultDisplayColumn: (_c = props.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
3033
- filterFns: props.filterFns,
3034
- sortingFns: props.sortingFns,
3035
- });
3036
- }, [
3037
- columnFilterFns,
3038
- displayColumns,
3039
- props.columns,
3040
- (_u = props.state) === null || _u === void 0 ? void 0 : _u.columnFilterFns,
3041
- ]);
3042
- const data = react.useMemo(() => {
3043
- var _a, _b, _c, _d, _e;
3044
- return (((_a = props.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = props.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
3045
- !props.data.length
3046
- ? [
3047
- ...Array(((_d = (_c = props.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
3048
- ((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
3049
- 10).fill(null),
3050
- ].map(() => Object.assign({}, ...getAllLeafColumnDefs(props.columns).map((col) => ({
3051
- [getColumnId(col)]: null,
3052
- }))))
3053
- : props.data;
3054
- }, [props.data, (_v = props.state) === null || _v === void 0 ? void 0 : _v.isLoading, (_w = props.state) === null || _w === void 0 ? void 0 : _w.showSkeletons]);
3055
- //@ts-ignore
3056
- const table = Object.assign(Object.assign({}, reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: props.enableExpanding || props.enableGrouping
3057
- ? reactTable.getExpandedRowModel()
3058
- : undefined, getFacetedMinMaxValues: props.enableFacetedValues
3059
- ? reactTable.getFacetedMinMaxValues()
3060
- : undefined, getFacetedRowModel: props.enableFacetedValues
3061
- ? reactTable.getFacetedRowModel()
3062
- : undefined, getFacetedUniqueValues: props.enableFacetedValues
3063
- ? reactTable.getFacetedUniqueValues()
3064
- : undefined, getFilteredRowModel: props.enableColumnFilters ||
3065
- props.enableGlobalFilter ||
3066
- props.enableFilters
3067
- ? reactTable.getFilteredRowModel()
3068
- : undefined, getGroupedRowModel: props.enableGrouping
3069
- ? reactTable.getGroupedRowModel()
3070
- : undefined, getPaginationRowModel: props.enablePagination
3071
- ? reactTable.getPaginationRowModel()
3072
- : undefined, getSortedRowModel: props.enableSorting ? reactTable.getSortedRowModel() : undefined, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
3073
- //@ts-ignore
3074
- columns: columnDefs, data, globalFilterFn: (_y = (_x = props.filterFns) === null || _x === void 0 ? void 0 : _x[globalFilterFn]) !== null && _y !== void 0 ? _y : (_z = props.filterFns) === null || _z === void 0 ? void 0 : _z.fuzzy, initialState, state: Object.assign({ columnFilterFns,
3075
- columnOrder,
3076
- density,
3077
- draggingColumn,
3078
- draggingRow,
3079
- editingCell,
3080
- editingRow,
3081
- globalFilterFn,
3082
- grouping,
3083
- hoveredColumn,
3084
- hoveredRow,
3085
- isFullScreen,
3086
- showAlertBanner,
3087
- showColumnFilters,
3088
- showGlobalFilter,
3089
- showToolbarDropZone }, props.state) }))), { refs: {
3090
- bottomToolbarRef,
3091
- editInputRefs,
3092
- filterInputRefs,
3093
- searchInputRef,
3094
- tableContainerRef,
3095
- tableHeadCellRefs,
3096
- tablePaperRef,
3097
- topToolbarRef,
3098
- }, setColumnFilterFns: (_0 = props.onColumnFilterFnsChange) !== null && _0 !== void 0 ? _0 : setColumnFilterFns, setDensity: (_1 = props.onDensityChange) !== null && _1 !== void 0 ? _1 : setDensity, setDraggingColumn: (_2 = props.onDraggingColumnChange) !== null && _2 !== void 0 ? _2 : setDraggingColumn, setDraggingRow: (_3 = props.onDraggingRowChange) !== null && _3 !== void 0 ? _3 : setDraggingRow, setEditingCell: (_4 = props.onEditingCellChange) !== null && _4 !== void 0 ? _4 : setEditingCell, setEditingRow: (_5 = props.onEditingRowChange) !== null && _5 !== void 0 ? _5 : setEditingRow, setGlobalFilterFn: (_6 = props.onGlobalFilterFnChange) !== null && _6 !== void 0 ? _6 : setGlobalFilterFn, setHoveredColumn: (_7 = props.onHoveredColumnChange) !== null && _7 !== void 0 ? _7 : setHoveredColumn, setHoveredRow: (_8 = props.onHoveredRowChange) !== null && _8 !== void 0 ? _8 : setHoveredRow, setIsFullScreen: (_9 = props.onIsFullScreenChange) !== null && _9 !== void 0 ? _9 : setIsFullScreen, setShowAlertBanner: (_10 = props.onShowAlertBannerChange) !== null && _10 !== void 0 ? _10 : setShowAlertBanner, setShowColumnFilters: (_11 = props.onShowColumnFiltersChange) !== null && _11 !== void 0 ? _11 : setShowColumnFilters, setShowGlobalFilter: (_12 = props.onShowGlobalFilterChange) !== null && _12 !== void 0 ? _12 : setShowGlobalFilter, setShowToolbarDropZone: (_13 = props.onShowToolbarDropZoneChange) !== null && _13 !== void 0 ? _13 : setShowToolbarDropZone });
3099
- if (props.tableFeatures) {
3100
- props.tableFeatures.forEach((feature) => {
3101
- Object.assign(table, feature(table));
3102
- });
3103
- }
3104
- if (props.tableInstanceRef) {
3105
- props.tableInstanceRef.current = table;
3106
- }
3107
- const initialBodyHeight = react.useRef();
3108
- react.useEffect(() => {
3109
- if (typeof window !== 'undefined') {
3110
- initialBodyHeight.current = document.body.style.height;
3111
- }
3112
- }, []);
3113
- react.useEffect(() => {
3114
- if (typeof window !== 'undefined') {
3115
- if (table.getState().isFullScreen) {
3116
- document.body.style.height = '100vh';
3117
- }
3118
- else {
3119
- document.body.style.height = initialBodyHeight.current;
3120
- }
3121
- }
3122
- }, [table.getState().isFullScreen]);
3123
- //if page index is out of bounds, set it to the last page
3124
- react.useEffect(() => {
3125
- var _a;
3126
- const { pageIndex, pageSize } = table.getState().pagination;
3127
- const totalRowCount = (_a = props.rowCount) !== null && _a !== void 0 ? _a : table.getPrePaginationRowModel().rows.length;
3128
- const firstVisibleRowIndex = pageIndex * pageSize;
3129
- if (firstVisibleRowIndex > totalRowCount) {
3130
- table.setPageIndex(Math.floor(totalRowCount / pageSize));
3131
- }
3132
- }, [props.rowCount, table.getPrePaginationRowModel().rows.length]);
3133
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Dialog__default["default"], { PaperComponent: Box__default["default"], TransitionComponent: !props.enableRowVirtualization ? Grow__default["default"] : undefined, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400, children: jsxRuntime.jsx(MRT_TablePaper, { table: table }) }), !table.getState().isFullScreen && (jsxRuntime.jsx(MRT_TablePaper, { table: table })), editingRow && props.editingMode === 'modal' && (jsxRuntime.jsx(MRT_EditRowModal, { row: editingRow, table: table, open: true }))] }));
3134
- };
3135
-
3136
- const MaterialReactTable = (_a) => {
3137
- var _b;
3138
- var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onChange', defaultColumn, defaultDisplayColumn, editingMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enablePinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode = 'semantic', localization, manualFiltering, manualGrouping, manualPagination, manualSorting, positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'original', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnResizeMode", "defaultColumn", "defaultDisplayColumn", "editingMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "selectAllMode", "sortingFns"]);
3139
- const _icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
3140
- const _localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
3141
- const _aggregationFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
3142
- const _filterFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
3143
- const _sortingFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
3144
- const _defaultColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
3145
- const _defaultDisplayColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
3146
- if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
3147
- layoutMode = 'grid';
3148
- }
3149
- if (rest.enableRowVirtualization) {
3150
- enableStickyHeader = true;
3395
+ const isTableInstanceProp = (props) => props.table !== undefined;
3396
+ const MaterialReactTable = (props) => {
3397
+ let table;
3398
+ if (isTableInstanceProp(props)) {
3399
+ table = props.table;
3151
3400
  }
3152
- if (enablePagination === false && manualPagination === undefined) {
3153
- manualPagination = true;
3154
- }
3155
- if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
3156
- manualFiltering = true;
3157
- manualGrouping = true;
3158
- manualPagination = true;
3159
- manualSorting = true;
3401
+ else {
3402
+ table = useMaterialReactTable(props);
3160
3403
  }
3161
- return (jsxRuntime.jsx(MRT_TableRoot, Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableExpanding: enableExpanding, enableFilterMatchHighlighting: enableFilterMatchHighlighting, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode: layoutMode, localization: _localization, manualFiltering: manualFiltering, manualGrouping: manualGrouping, manualPagination: manualPagination, manualSorting: manualSorting, positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: _sortingFns }, rest)));
3404
+ return jsxRuntime.jsx(MRT_TablePaper, { table: table });
3162
3405
  };
3163
3406
 
3164
3407
  exports.MRT_AggregationFns = MRT_AggregationFns;
3165
3408
  exports.MRT_BottomToolbar = MRT_BottomToolbar;
3409
+ exports.MRT_ColumnActionMenu = MRT_ColumnActionMenu;
3410
+ exports.MRT_ColumnPinningButtons = MRT_ColumnPinningButtons;
3166
3411
  exports.MRT_CopyButton = MRT_CopyButton;
3412
+ exports.MRT_DefaultColumn = MRT_DefaultColumn;
3413
+ exports.MRT_DefaultDisplayColumn = MRT_DefaultDisplayColumn;
3167
3414
  exports.MRT_EditActionButtons = MRT_EditActionButtons;
3415
+ exports.MRT_EditCellTextField = MRT_EditCellTextField;
3416
+ exports.MRT_EditRowModal = MRT_EditRowModal;
3417
+ exports.MRT_ExpandAllButton = MRT_ExpandAllButton;
3168
3418
  exports.MRT_ExpandButton = MRT_ExpandButton;
3419
+ exports.MRT_FilterCheckbox = MRT_FilterCheckbox;
3169
3420
  exports.MRT_FilterFns = MRT_FilterFns;
3170
3421
  exports.MRT_FilterOptionMenu = MRT_FilterOptionMenu;
3171
- exports.MRT_FullScreenToggleButton = MRT_FullScreenToggleButton;
3422
+ exports.MRT_FilterRangeFields = MRT_FilterRangeFields;
3423
+ exports.MRT_FilterRangeSlider = MRT_FilterRangeSlider;
3424
+ exports.MRT_FilterTextField = MRT_FilterTextField;
3172
3425
  exports.MRT_GlobalFilterTextField = MRT_GlobalFilterTextField;
3173
3426
  exports.MRT_GrabHandleButton = MRT_GrabHandleButton;
3427
+ exports.MRT_LinearProgressBar = MRT_LinearProgressBar;
3428
+ exports.MRT_RowActionMenu = MRT_RowActionMenu;
3429
+ exports.MRT_SelectCheckbox = MRT_SelectCheckbox;
3174
3430
  exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
3431
+ exports.MRT_ShowHideColumnsMenu = MRT_ShowHideColumnsMenu;
3432
+ exports.MRT_ShowHideColumnsMenuItems = MRT_ShowHideColumnsMenuItems;
3175
3433
  exports.MRT_SortingFns = MRT_SortingFns;
3434
+ exports.MRT_Table = MRT_Table;
3435
+ exports.MRT_TableBody = MRT_TableBody;
3436
+ exports.MRT_TableBodyCell = MRT_TableBodyCell;
3437
+ exports.MRT_TableBodyCellValue = MRT_TableBodyCellValue;
3438
+ exports.MRT_TableBodyRow = MRT_TableBodyRow;
3439
+ exports.MRT_TableBodyRowGrabHandle = MRT_TableBodyRowGrabHandle;
3440
+ exports.MRT_TableContainer = MRT_TableContainer;
3441
+ exports.MRT_TableDetailPanel = MRT_TableDetailPanel;
3442
+ exports.MRT_TableFooter = MRT_TableFooter;
3443
+ exports.MRT_TableFooterCell = MRT_TableFooterCell;
3444
+ exports.MRT_TableFooterRow = MRT_TableFooterRow;
3445
+ exports.MRT_TableHead = MRT_TableHead;
3446
+ exports.MRT_TableHeadCell = MRT_TableHeadCell;
3447
+ exports.MRT_TableHeadCellColumnActionsButton = MRT_TableHeadCellColumnActionsButton;
3176
3448
  exports.MRT_TableHeadCellFilterContainer = MRT_TableHeadCellFilterContainer;
3449
+ exports.MRT_TableHeadCellFilterLabel = MRT_TableHeadCellFilterLabel;
3450
+ exports.MRT_TableHeadCellGrabHandle = MRT_TableHeadCellGrabHandle;
3451
+ exports.MRT_TableHeadCellResizeHandle = MRT_TableHeadCellResizeHandle;
3452
+ exports.MRT_TableHeadCellSortLabel = MRT_TableHeadCellSortLabel;
3453
+ exports.MRT_TableHeadRow = MRT_TableHeadRow;
3177
3454
  exports.MRT_TablePagination = MRT_TablePagination;
3455
+ exports.MRT_TablePaper = MRT_TablePaper;
3178
3456
  exports.MRT_ToggleDensePaddingButton = MRT_ToggleDensePaddingButton;
3179
3457
  exports.MRT_ToggleFiltersButton = MRT_ToggleFiltersButton;
3458
+ exports.MRT_ToggleFullScreenButton = MRT_ToggleFullScreenButton;
3180
3459
  exports.MRT_ToggleGlobalFilterButton = MRT_ToggleGlobalFilterButton;
3181
3460
  exports.MRT_ToggleRowActionMenuButton = MRT_ToggleRowActionMenuButton;
3182
3461
  exports.MRT_ToolbarAlertBanner = MRT_ToolbarAlertBanner;
@@ -3184,5 +3463,32 @@ exports.MRT_ToolbarDropZone = MRT_ToolbarDropZone;
3184
3463
  exports.MRT_ToolbarInternalButtons = MRT_ToolbarInternalButtons;
3185
3464
  exports.MRT_TopToolbar = MRT_TopToolbar;
3186
3465
  exports.MaterialReactTable = MaterialReactTable;
3187
- exports["default"] = MaterialReactTable;
3466
+ exports.Memo_MRT_TableBody = Memo_MRT_TableBody;
3467
+ exports.Memo_MRT_TableBodyCell = Memo_MRT_TableBodyCell;
3468
+ exports.Memo_MRT_TableBodyRow = Memo_MRT_TableBodyRow;
3469
+ exports.commonListItemStyles = commonListItemStyles;
3470
+ exports.commonMenuItemStyles = commonMenuItemStyles;
3471
+ exports.commonToolbarStyles = commonToolbarStyles;
3472
+ exports.createRow = createRow;
3473
+ exports.flexRender = flexRender;
3474
+ exports.getAllLeafColumnDefs = getAllLeafColumnDefs;
3475
+ exports.getCanRankRows = getCanRankRows;
3476
+ exports.getColumnId = getColumnId;
3477
+ exports.getCommonCellStyles = getCommonCellStyles;
3478
+ exports.getDefaultColumnFilterFn = getDefaultColumnFilterFn;
3479
+ exports.getDefaultColumnOrderIds = getDefaultColumnOrderIds;
3480
+ exports.getIsFirstColumn = getIsFirstColumn;
3481
+ exports.getIsFirstRightPinnedColumn = getIsFirstRightPinnedColumn;
3482
+ exports.getIsLastColumn = getIsLastColumn;
3483
+ exports.getIsLastLeftPinnedColumn = getIsLastLeftPinnedColumn;
3484
+ exports.getLeadingDisplayColumnIds = getLeadingDisplayColumnIds;
3485
+ exports.getTotalRight = getTotalRight;
3486
+ exports.getTrailingDisplayColumnIds = getTrailingDisplayColumnIds;
3487
+ exports.mrtFilterOptions = mrtFilterOptions;
3488
+ exports.parseCSSVarId = parseCSSVarId;
3489
+ exports.prepareColumns = prepareColumns;
3490
+ exports.rankGlobalFuzzy = rankGlobalFuzzy;
3491
+ exports.reorderColumn = reorderColumn;
3492
+ exports.showExpandColumn = showExpandColumn;
3493
+ exports.useMaterialReactTable = useMaterialReactTable;
3188
3494
  //# sourceMappingURL=index.js.map