material-react-table 1.15.0 → 2.0.0-alpha.1

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