@lminii/material-react-table 4.0.0

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