@careharmony/mantine-react-table-ng 0.0.0-stage → 4.0.0-beta.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 (371) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +217 -3
  3. package/dist/index.cjs +4023 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +1488 -0
  6. package/dist/index.esm.d.mts +1488 -0
  7. package/dist/index.esm.mjs +3909 -0
  8. package/dist/index.esm.mjs.map +1 -0
  9. package/locales/ar/index.cjs +97 -0
  10. package/locales/ar/index.d.cts +3 -0
  11. package/locales/ar/index.esm.d.mts +3 -0
  12. package/locales/ar/index.esm.mjs +95 -0
  13. package/locales/ar/package.json +19 -0
  14. package/locales/az/index.cjs +97 -0
  15. package/locales/az/index.d.cts +3 -0
  16. package/locales/az/index.esm.d.mts +3 -0
  17. package/locales/az/index.esm.mjs +95 -0
  18. package/locales/az/package.json +19 -0
  19. package/locales/bg/index.cjs +97 -0
  20. package/locales/bg/index.d.cts +3 -0
  21. package/locales/bg/index.esm.d.mts +3 -0
  22. package/locales/bg/index.esm.mjs +95 -0
  23. package/locales/bg/package.json +19 -0
  24. package/locales/cs/index.cjs +97 -0
  25. package/locales/cs/index.d.cts +3 -0
  26. package/locales/cs/index.esm.d.mts +3 -0
  27. package/locales/cs/index.esm.mjs +95 -0
  28. package/locales/cs/package.json +19 -0
  29. package/locales/da/index.cjs +97 -0
  30. package/locales/da/index.d.cts +3 -0
  31. package/locales/da/index.esm.d.mts +3 -0
  32. package/locales/da/index.esm.mjs +95 -0
  33. package/locales/da/package.json +19 -0
  34. package/locales/de/index.cjs +97 -0
  35. package/locales/de/index.d.cts +3 -0
  36. package/locales/de/index.esm.d.mts +3 -0
  37. package/locales/de/index.esm.mjs +95 -0
  38. package/locales/de/package.json +19 -0
  39. package/locales/el/index.cjs +97 -0
  40. package/locales/el/index.d.cts +3 -0
  41. package/locales/el/index.esm.d.mts +3 -0
  42. package/locales/el/index.esm.mjs +95 -0
  43. package/locales/el/package.json +19 -0
  44. package/locales/en/index.cjs +97 -0
  45. package/locales/en/index.d.cts +3 -0
  46. package/locales/en/index.esm.d.mts +3 -0
  47. package/locales/en/index.esm.mjs +95 -0
  48. package/locales/en/package.json +19 -0
  49. package/locales/es/index.cjs +97 -0
  50. package/locales/es/index.d.cts +3 -0
  51. package/locales/es/index.esm.d.mts +3 -0
  52. package/locales/es/index.esm.mjs +95 -0
  53. package/locales/es/package.json +19 -0
  54. package/locales/et/index.cjs +97 -0
  55. package/locales/et/index.d.cts +3 -0
  56. package/locales/et/index.esm.d.mts +3 -0
  57. package/locales/et/index.esm.mjs +95 -0
  58. package/locales/et/package.json +19 -0
  59. package/locales/fa/index.cjs +97 -0
  60. package/locales/fa/index.d.cts +3 -0
  61. package/locales/fa/index.esm.d.mts +3 -0
  62. package/locales/fa/index.esm.mjs +95 -0
  63. package/locales/fa/package.json +19 -0
  64. package/locales/fi/index.cjs +97 -0
  65. package/locales/fi/index.d.cts +3 -0
  66. package/locales/fi/index.esm.d.mts +3 -0
  67. package/locales/fi/index.esm.mjs +95 -0
  68. package/locales/fi/package.json +19 -0
  69. package/locales/fr/index.cjs +97 -0
  70. package/locales/fr/index.d.cts +3 -0
  71. package/locales/fr/index.esm.d.mts +3 -0
  72. package/locales/fr/index.esm.mjs +95 -0
  73. package/locales/fr/package.json +19 -0
  74. package/locales/he/index.cjs +97 -0
  75. package/locales/he/index.d.cts +3 -0
  76. package/locales/he/index.esm.d.mts +3 -0
  77. package/locales/he/index.esm.mjs +95 -0
  78. package/locales/he/package.json +19 -0
  79. package/locales/hr/index.cjs +97 -0
  80. package/locales/hr/index.d.cts +3 -0
  81. package/locales/hr/index.esm.d.mts +3 -0
  82. package/locales/hr/index.esm.mjs +95 -0
  83. package/locales/hr/package.json +19 -0
  84. package/locales/hu/index.cjs +97 -0
  85. package/locales/hu/index.d.cts +3 -0
  86. package/locales/hu/index.esm.d.mts +3 -0
  87. package/locales/hu/index.esm.mjs +95 -0
  88. package/locales/hu/package.json +19 -0
  89. package/locales/hy/index.cjs +97 -0
  90. package/locales/hy/index.d.cts +3 -0
  91. package/locales/hy/index.esm.d.mts +3 -0
  92. package/locales/hy/index.esm.mjs +95 -0
  93. package/locales/hy/package.json +19 -0
  94. package/locales/id/index.cjs +97 -0
  95. package/locales/id/index.d.cts +3 -0
  96. package/locales/id/index.esm.d.mts +3 -0
  97. package/locales/id/index.esm.mjs +95 -0
  98. package/locales/id/package.json +19 -0
  99. package/locales/it/index.cjs +97 -0
  100. package/locales/it/index.d.cts +3 -0
  101. package/locales/it/index.esm.d.mts +3 -0
  102. package/locales/it/index.esm.mjs +95 -0
  103. package/locales/it/package.json +19 -0
  104. package/locales/ja/index.cjs +97 -0
  105. package/locales/ja/index.d.cts +3 -0
  106. package/locales/ja/index.esm.d.mts +3 -0
  107. package/locales/ja/index.esm.mjs +95 -0
  108. package/locales/ja/package.json +19 -0
  109. package/locales/ko/index.cjs +97 -0
  110. package/locales/ko/index.d.cts +3 -0
  111. package/locales/ko/index.esm.d.mts +3 -0
  112. package/locales/ko/index.esm.mjs +95 -0
  113. package/locales/ko/package.json +19 -0
  114. package/locales/nl/index.cjs +97 -0
  115. package/locales/nl/index.d.cts +3 -0
  116. package/locales/nl/index.esm.d.mts +3 -0
  117. package/locales/nl/index.esm.mjs +95 -0
  118. package/locales/nl/package.json +19 -0
  119. package/locales/no/index.cjs +97 -0
  120. package/locales/no/index.d.cts +3 -0
  121. package/locales/no/index.esm.d.mts +3 -0
  122. package/locales/no/index.esm.mjs +95 -0
  123. package/locales/no/package.json +19 -0
  124. package/locales/np/index.cjs +97 -0
  125. package/locales/np/index.d.cts +3 -0
  126. package/locales/np/index.esm.d.mts +3 -0
  127. package/locales/np/index.esm.mjs +95 -0
  128. package/locales/np/package.json +19 -0
  129. package/locales/pl/index.cjs +97 -0
  130. package/locales/pl/index.d.cts +3 -0
  131. package/locales/pl/index.esm.d.mts +3 -0
  132. package/locales/pl/index.esm.mjs +95 -0
  133. package/locales/pl/package.json +19 -0
  134. package/locales/pt/index.cjs +97 -0
  135. package/locales/pt/index.d.cts +3 -0
  136. package/locales/pt/index.esm.d.mts +3 -0
  137. package/locales/pt/index.esm.mjs +95 -0
  138. package/locales/pt/package.json +19 -0
  139. package/locales/pt-BR/index.cjs +97 -0
  140. package/locales/pt-BR/index.d.cts +3 -0
  141. package/locales/pt-BR/index.esm.d.mts +3 -0
  142. package/locales/pt-BR/index.esm.mjs +95 -0
  143. package/locales/pt-BR/package.json +19 -0
  144. package/locales/ro/index.cjs +97 -0
  145. package/locales/ro/index.d.cts +3 -0
  146. package/locales/ro/index.esm.d.mts +3 -0
  147. package/locales/ro/index.esm.mjs +95 -0
  148. package/locales/ro/package.json +19 -0
  149. package/locales/ru/index.cjs +97 -0
  150. package/locales/ru/index.d.cts +3 -0
  151. package/locales/ru/index.esm.d.mts +3 -0
  152. package/locales/ru/index.esm.mjs +95 -0
  153. package/locales/ru/package.json +19 -0
  154. package/locales/sk/index.cjs +97 -0
  155. package/locales/sk/index.d.cts +3 -0
  156. package/locales/sk/index.esm.d.mts +3 -0
  157. package/locales/sk/index.esm.mjs +95 -0
  158. package/locales/sk/package.json +19 -0
  159. package/locales/sr-Cyrl-RS/index.cjs +97 -0
  160. package/locales/sr-Cyrl-RS/index.d.cts +3 -0
  161. package/locales/sr-Cyrl-RS/index.esm.d.mts +3 -0
  162. package/locales/sr-Cyrl-RS/index.esm.mjs +95 -0
  163. package/locales/sr-Cyrl-RS/package.json +19 -0
  164. package/locales/sr-Latn-RS/index.cjs +97 -0
  165. package/locales/sr-Latn-RS/index.d.cts +3 -0
  166. package/locales/sr-Latn-RS/index.esm.d.mts +3 -0
  167. package/locales/sr-Latn-RS/index.esm.mjs +95 -0
  168. package/locales/sr-Latn-RS/package.json +19 -0
  169. package/locales/sv/index.cjs +97 -0
  170. package/locales/sv/index.d.cts +3 -0
  171. package/locales/sv/index.esm.d.mts +3 -0
  172. package/locales/sv/index.esm.mjs +95 -0
  173. package/locales/sv/package.json +19 -0
  174. package/locales/th/index.cjs +97 -0
  175. package/locales/th/index.d.cts +3 -0
  176. package/locales/th/index.esm.d.mts +3 -0
  177. package/locales/th/index.esm.mjs +95 -0
  178. package/locales/th/package.json +19 -0
  179. package/locales/tr/index.cjs +97 -0
  180. package/locales/tr/index.d.cts +3 -0
  181. package/locales/tr/index.esm.d.mts +3 -0
  182. package/locales/tr/index.esm.mjs +95 -0
  183. package/locales/tr/package.json +19 -0
  184. package/locales/uk/index.cjs +97 -0
  185. package/locales/uk/index.d.cts +3 -0
  186. package/locales/uk/index.esm.d.mts +3 -0
  187. package/locales/uk/index.esm.mjs +95 -0
  188. package/locales/uk/package.json +19 -0
  189. package/locales/vi/index.cjs +97 -0
  190. package/locales/vi/index.d.cts +3 -0
  191. package/locales/vi/index.esm.d.mts +3 -0
  192. package/locales/vi/index.esm.mjs +95 -0
  193. package/locales/vi/package.json +19 -0
  194. package/locales/zh-Hans/index.cjs +97 -0
  195. package/locales/zh-Hans/index.d.cts +3 -0
  196. package/locales/zh-Hans/index.esm.d.mts +3 -0
  197. package/locales/zh-Hans/index.esm.mjs +95 -0
  198. package/locales/zh-Hans/package.json +19 -0
  199. package/locales/zh-Hant/index.cjs +97 -0
  200. package/locales/zh-Hant/index.d.cts +3 -0
  201. package/locales/zh-Hant/index.esm.d.mts +3 -0
  202. package/locales/zh-Hant/index.esm.mjs +95 -0
  203. package/locales/zh-Hant/package.json +19 -0
  204. package/package.json +184 -4
  205. package/src/components/MantineReactTable.tsx +38 -0
  206. package/src/components/body/MRT_TableBody.module.css +42 -0
  207. package/src/components/body/MRT_TableBody.tsx +214 -0
  208. package/src/components/body/MRT_TableBodyCell.module.css +107 -0
  209. package/src/components/body/MRT_TableBodyCell.tsx +355 -0
  210. package/src/components/body/MRT_TableBodyCellValue.tsx +114 -0
  211. package/src/components/body/MRT_TableBodyEmptyRow.tsx +89 -0
  212. package/src/components/body/MRT_TableBodyRow.module.css +261 -0
  213. package/src/components/body/MRT_TableBodyRow.tsx +278 -0
  214. package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +59 -0
  215. package/src/components/body/MRT_TableBodyRowPinButton.tsx +59 -0
  216. package/src/components/body/MRT_TableDetailPanel.module.css +35 -0
  217. package/src/components/body/MRT_TableDetailPanel.tsx +132 -0
  218. package/src/components/buttons/MRT_ColumnPinningButtons.module.css +11 -0
  219. package/src/components/buttons/MRT_ColumnPinningButtons.tsx +69 -0
  220. package/src/components/buttons/MRT_CopyButton.module.css +27 -0
  221. package/src/components/buttons/MRT_CopyButton.tsx +84 -0
  222. package/src/components/buttons/MRT_EditActionButtons.module.css +4 -0
  223. package/src/components/buttons/MRT_EditActionButtons.tsx +139 -0
  224. package/src/components/buttons/MRT_ExpandAllButton.module.css +26 -0
  225. package/src/components/buttons/MRT_ExpandAllButton.tsx +84 -0
  226. package/src/components/buttons/MRT_ExpandButton.module.css +37 -0
  227. package/src/components/buttons/MRT_ExpandButton.tsx +121 -0
  228. package/src/components/buttons/MRT_GrabHandleButton.module.css +6 -0
  229. package/src/components/buttons/MRT_GrabHandleButton.tsx +65 -0
  230. package/src/components/buttons/MRT_RowPinButton.tsx +84 -0
  231. package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +46 -0
  232. package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +66 -0
  233. package/src/components/buttons/MRT_ToggleFiltersButton.tsx +45 -0
  234. package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +59 -0
  235. package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +52 -0
  236. package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +87 -0
  237. package/src/components/footer/MRT_TableFooter.module.css +17 -0
  238. package/src/components/footer/MRT_TableFooter.tsx +70 -0
  239. package/src/components/footer/MRT_TableFooterCell.module.css +59 -0
  240. package/src/components/footer/MRT_TableFooterCell.tsx +126 -0
  241. package/src/components/footer/MRT_TableFooterRow.module.css +10 -0
  242. package/src/components/footer/MRT_TableFooterRow.tsx +111 -0
  243. package/src/components/head/MRT_TableHead.module.css +32 -0
  244. package/src/components/head/MRT_TableHead.tsx +106 -0
  245. package/src/components/head/MRT_TableHeadCell.module.css +172 -0
  246. package/src/components/head/MRT_TableHeadCell.tsx +317 -0
  247. package/src/components/head/MRT_TableHeadCellFilterContainer.module.css +5 -0
  248. package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +123 -0
  249. package/src/components/head/MRT_TableHeadCellFilterLabel.module.css +14 -0
  250. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +176 -0
  251. package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +82 -0
  252. package/src/components/head/MRT_TableHeadCellResizeHandle.module.css +44 -0
  253. package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +68 -0
  254. package/src/components/head/MRT_TableHeadCellSortLabel.module.css +22 -0
  255. package/src/components/head/MRT_TableHeadCellSortLabel.tsx +90 -0
  256. package/src/components/head/MRT_TableHeadRow.module.css +12 -0
  257. package/src/components/head/MRT_TableHeadRow.tsx +105 -0
  258. package/src/components/inputs/MRT_EditCellTextInput.tsx +214 -0
  259. package/src/components/inputs/MRT_FilterCheckBox.module.css +4 -0
  260. package/src/components/inputs/MRT_FilterCheckbox.tsx +80 -0
  261. package/src/components/inputs/MRT_FilterRangeFields.module.css +5 -0
  262. package/src/components/inputs/MRT_FilterRangeFields.tsx +36 -0
  263. package/src/components/inputs/MRT_FilterRangeSlider.module.css +6 -0
  264. package/src/components/inputs/MRT_FilterRangeSlider.tsx +107 -0
  265. package/src/components/inputs/MRT_FilterTextInput.module.css +27 -0
  266. package/src/components/inputs/MRT_FilterTextInput.tsx +418 -0
  267. package/src/components/inputs/MRT_GlobalFilterTextInput.module.css +11 -0
  268. package/src/components/inputs/MRT_GlobalFilterTextInput.tsx +142 -0
  269. package/src/components/inputs/MRT_SelectCheckbox.tsx +138 -0
  270. package/src/components/menus/MRT_ColumnActionMenu.module.css +7 -0
  271. package/src/components/menus/MRT_ColumnActionMenu.tsx +288 -0
  272. package/src/components/menus/MRT_FilterOptionMenu.module.css +6 -0
  273. package/src/components/menus/MRT_FilterOptionMenu.tsx +279 -0
  274. package/src/components/menus/MRT_RowActionMenu.tsx +75 -0
  275. package/src/components/menus/MRT_ShowHideColumnsMenu.module.css +10 -0
  276. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +136 -0
  277. package/src/components/menus/MRT_ShowHideColumnsMenuItems.module.css +35 -0
  278. package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +171 -0
  279. package/src/components/modals/MRT_EditRowModal.tsx +98 -0
  280. package/src/components/table/MRT_Table.module.css +7 -0
  281. package/src/components/table/MRT_Table.tsx +155 -0
  282. package/src/components/table/MRT_TableContainer.module.css +32 -0
  283. package/src/components/table/MRT_TableContainer.tsx +124 -0
  284. package/src/components/table/MRT_TablePaper.module.css +88 -0
  285. package/src/components/table/MRT_TablePaper.tsx +91 -0
  286. package/src/components/toolbar/MRT_BottomToolbar.module.css +40 -0
  287. package/src/components/toolbar/MRT_BottomToolbar.tsx +99 -0
  288. package/src/components/toolbar/MRT_ProgressBar.module.css +10 -0
  289. package/src/components/toolbar/MRT_ProgressBar.tsx +54 -0
  290. package/src/components/toolbar/MRT_TablePagination.module.css +20 -0
  291. package/src/components/toolbar/MRT_TablePagination.tsx +175 -0
  292. package/src/components/toolbar/MRT_ToolbarAlertBanner.module.css +37 -0
  293. package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +169 -0
  294. package/src/components/toolbar/MRT_ToolbarDropZone.module.css +23 -0
  295. package/src/components/toolbar/MRT_ToolbarDropZone.tsx +68 -0
  296. package/src/components/toolbar/MRT_ToolbarInternalButtons.module.css +6 -0
  297. package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +74 -0
  298. package/src/components/toolbar/MRT_TopToolbar.module.css +24 -0
  299. package/src/components/toolbar/MRT_TopToolbar.tsx +127 -0
  300. package/src/components/toolbar/common.styles.module.css +10 -0
  301. package/src/fns/aggregationFns.ts +3 -0
  302. package/src/fns/filterFns.ts +243 -0
  303. package/src/fns/sortingFns.ts +34 -0
  304. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +25 -0
  305. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +32 -0
  306. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +94 -0
  307. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +32 -0
  308. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +26 -0
  309. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +36 -0
  310. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +36 -0
  311. package/src/hooks/useMRT_ColumnVirtualizer.ts +135 -0
  312. package/src/hooks/useMRT_Effects.ts +109 -0
  313. package/src/hooks/useMRT_RowVirtualizer.ts +101 -0
  314. package/src/hooks/useMRT_Rows.ts +47 -0
  315. package/src/hooks/useMRT_TableInstance.ts +320 -0
  316. package/src/hooks/useMRT_TableOptions.ts +300 -0
  317. package/src/hooks/useMRT_TableSnapshot.ts +134 -0
  318. package/src/hooks/useMRT_VirtualizerScrollElement.ts +31 -0
  319. package/src/hooks/useMantineReactTable.ts +23 -0
  320. package/src/icons.ts +108 -0
  321. package/src/index.ts +91 -0
  322. package/src/locales/ar.ts +96 -0
  323. package/src/locales/az.ts +96 -0
  324. package/src/locales/bg.ts +96 -0
  325. package/src/locales/cs.ts +97 -0
  326. package/src/locales/da.ts +96 -0
  327. package/src/locales/de.ts +96 -0
  328. package/src/locales/el.ts +96 -0
  329. package/src/locales/en.ts +96 -0
  330. package/src/locales/es.ts +96 -0
  331. package/src/locales/et.ts +97 -0
  332. package/src/locales/fa.ts +96 -0
  333. package/src/locales/fi.ts +97 -0
  334. package/src/locales/fr.ts +96 -0
  335. package/src/locales/he.ts +96 -0
  336. package/src/locales/hr.ts +96 -0
  337. package/src/locales/hu.ts +96 -0
  338. package/src/locales/hy.ts +96 -0
  339. package/src/locales/id.ts +97 -0
  340. package/src/locales/it.ts +96 -0
  341. package/src/locales/ja.ts +96 -0
  342. package/src/locales/ko.ts +96 -0
  343. package/src/locales/nl.ts +96 -0
  344. package/src/locales/no.ts +97 -0
  345. package/src/locales/np.ts +97 -0
  346. package/src/locales/pl.ts +96 -0
  347. package/src/locales/pt-BR.ts +96 -0
  348. package/src/locales/pt.ts +96 -0
  349. package/src/locales/ro.ts +96 -0
  350. package/src/locales/ru.ts +96 -0
  351. package/src/locales/sk.ts +97 -0
  352. package/src/locales/sr-Cyrl-RS.ts +96 -0
  353. package/src/locales/sr-Latn-RS.ts +96 -0
  354. package/src/locales/sv.ts +96 -0
  355. package/src/locales/th.ts +97 -0
  356. package/src/locales/tr.ts +96 -0
  357. package/src/locales/uk.ts +96 -0
  358. package/src/locales/vi.ts +96 -0
  359. package/src/locales/zh-Hans.ts +95 -0
  360. package/src/locales/zh-Hant.ts +95 -0
  361. package/src/types.ts +1299 -0
  362. package/src/typings.d.ts +1 -0
  363. package/src/utils/column.utils.ts +157 -0
  364. package/src/utils/displayColumn.utils.ts +153 -0
  365. package/src/utils/row.utils.ts +263 -0
  366. package/src/utils/snapshot.utils.ts +97 -0
  367. package/src/utils/style.utils.ts +32 -0
  368. package/src/utils/tanstack.helpers.ts +66 -0
  369. package/src/utils/utils.ts +15 -0
  370. package/src/utils/virtualization.utils.ts +85 -0
  371. package/styles.css +1381 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,4023 @@
1
+ 'use no memo';
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var clsx = require('clsx');
6
+ var react = require('react');
7
+ var core = require('@mantine/core');
8
+ var reactTable = require('@tanstack/react-table');
9
+ var matchSorterUtils = require('@tanstack/match-sorter-utils');
10
+ var reactVirtual = require('@tanstack/react-virtual');
11
+ var hooks = require('@mantine/hooks');
12
+ var dates = require('@mantine/dates');
13
+ var iconsReact = require('@tabler/icons-react');
14
+
15
+ /******************************************************************************
16
+ Copyright (c) Microsoft Corporation.
17
+
18
+ Permission to use, copy, modify, and/or distribute this software for any
19
+ purpose with or without fee is hereby granted.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
+ PERFORMANCE OF THIS SOFTWARE.
28
+ ***************************************************************************** */
29
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
30
+
31
+
32
+ function __rest(s, e) {
33
+ var t = {};
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
35
+ t[p] = s[p];
36
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
37
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
38
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
39
+ t[p[i]] = s[p[i]];
40
+ }
41
+ return t;
42
+ }
43
+
44
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
45
+ var e = new Error(message);
46
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
47
+ };
48
+
49
+ var classes$C = {"root":"MRT_TableBody-module_root__kGhRy","root-grid":"MRT_TableBody-module_root-grid__WdOGg","root-no-rows":"MRT_TableBody-module_root-no-rows__iyi9K","root-virtualized":"MRT_TableBody-module_root-virtualized__TxPAi","empty-row-tr-grid":"MRT_TableBody-module_empty-row-tr-grid__LTgxw","empty-row-td-grid":"MRT_TableBody-module_empty-row-td-grid__pzlgG","empty-row-td-content":"MRT_TableBody-module_empty-row-td-content__Cc2XW","pinned":"MRT_TableBody-module_pinned__XHpcs"};
50
+
51
+ var classes$B = {"root":"MRT_TableBodyRow-module_root__2c3D4","root-grid":"MRT_TableBodyRow-module_root-grid__AwXTe","root-virtualized":"MRT_TableBodyRow-module_root-virtualized__zYgxq"};
52
+
53
+ var classes$A = {"root":"MRT_TableBodyCell-module_root__Wf-zi","root-grid":"MRT_TableBodyCell-module_root-grid__zIuC-","root-virtualized":"MRT_TableBodyCell-module_root-virtualized__jLl8R","root-data-col":"MRT_TableBodyCell-module_root-data-col__HHcxc","root-nowrap":"MRT_TableBodyCell-module_root-nowrap__-k1Jo","root-cursor-pointer":"MRT_TableBodyCell-module_root-cursor-pointer__4kw7J","root-editable-hover":"MRT_TableBodyCell-module_root-editable-hover__2DKSa","root-cell-hover-reveal":"MRT_TableBodyCell-module_root-cell-hover-reveal__T1fAH","cell-hover-reveal":"MRT_TableBodyCell-module_cell-hover-reveal__Q-1Xj","overflowing":"MRT_TableBodyCell-module_overflowing__QcXP4"};
54
+
55
+ const assignRef = (ref, value) => {
56
+ if (typeof ref === 'function') {
57
+ ref(value);
58
+ }
59
+ else if (ref) {
60
+ ref.current = value;
61
+ }
62
+ };
63
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
64
+
65
+ const allowedTypes = ['string', 'number'];
66
+ const allowedFilterVariants = ['text', 'autocomplete'];
67
+ const MRT_TableBodyCellValue = ({ cell, renderedColumnIndex = 0, renderedRowIndex = 0, table, }) => {
68
+ var _a, _b;
69
+ const { getState, options: { enableFilterMatchHighlighting, mantineHighlightProps = { size: 'sm' }, }, } = table;
70
+ const { column, row } = cell;
71
+ const { columnDef } = column;
72
+ const { globalFilter, globalFilterFn } = getState();
73
+ const filterValue = column.getFilterValue();
74
+ const highlightProps = parseFromValuesOrFunc(mantineHighlightProps, {
75
+ cell,
76
+ column,
77
+ row,
78
+ table,
79
+ });
80
+ let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
81
+ ? columnDef.AggregatedCell({
82
+ cell,
83
+ column,
84
+ row,
85
+ table,
86
+ })
87
+ : row.getIsGrouped() && !cell.getIsGrouped()
88
+ ? null
89
+ : cell.getIsGrouped() && columnDef.GroupedCell
90
+ ? columnDef.GroupedCell({
91
+ cell,
92
+ column,
93
+ row,
94
+ table,
95
+ })
96
+ : undefined;
97
+ const isGroupedValue = renderedCellValue !== undefined;
98
+ if (!isGroupedValue) {
99
+ renderedCellValue = cell.renderValue();
100
+ }
101
+ if (enableFilterMatchHighlighting &&
102
+ columnDef.enableFilterMatchHighlighting !== false &&
103
+ renderedCellValue &&
104
+ allowedTypes.includes(typeof renderedCellValue) &&
105
+ ((filterValue &&
106
+ allowedTypes.includes(typeof filterValue) &&
107
+ allowedFilterVariants.includes(columnDef.filterVariant)) ||
108
+ (globalFilter &&
109
+ allowedTypes.includes(typeof globalFilter) &&
110
+ column.getCanGlobalFilter()))) {
111
+ let highlight = ((_b = (_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : globalFilter) !== null && _b !== void 0 ? _b : '').toString();
112
+ if ((filterValue ? columnDef._filterFn : globalFilterFn) === 'fuzzy') {
113
+ highlight = highlight.split(' ');
114
+ }
115
+ renderedCellValue = (jsxRuntime.jsx(core.Highlight, Object.assign({ color: "yellow.3", highlight: highlight }, highlightProps, { children: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString() })));
116
+ }
117
+ if (columnDef.Cell && !isGroupedValue) {
118
+ renderedCellValue = columnDef.Cell({
119
+ cell,
120
+ column,
121
+ renderedCellValue,
122
+ renderedColumnIndex,
123
+ renderedRowIndex,
124
+ row,
125
+ table,
126
+ });
127
+ }
128
+ return renderedCellValue;
129
+ };
130
+
131
+ /**
132
+ * TanStack Table keeps one table, row, cell, column and header instance for as
133
+ * long as the data and column definitions stay the same. The React Compiler
134
+ * caches a call such as `row.getIsSelected()` on the identity of `row`, so a
135
+ * compiled consumer component would keep the first result forever.
136
+ *
137
+ * A view is a `Proxy` around the TanStack instance. Reads, writes, method
138
+ * calls and object spreads all reach the live instance, and only the identity
139
+ * is new. `useMantineReactTable` returns a new table view whenever table state
140
+ * or options change, and row, cell, column and header views are cached per
141
+ * table view, so they change exactly when the table does.
142
+ */
143
+ const viewsByTable = new WeakMap();
144
+ const targetsByView = new WeakMap();
145
+ /** Returns the TanStack instance behind a view, or the object itself. */
146
+ const getMRT_ViewTarget = (viewOrTarget) => { var _a; return (_a = targetsByView.get(viewOrTarget)) !== null && _a !== void 0 ? _a : viewOrTarget; };
147
+ /**
148
+ * Creates a view of a TanStack instance.
149
+ * @param overrides - properties the view answers itself instead of the instance
150
+ */
151
+ const createMRT_View = (viewOrTarget, overrides) => {
152
+ const target = getMRT_ViewTarget(viewOrTarget);
153
+ const view = new Proxy(target, overrides
154
+ ? {
155
+ get: (instance, key) => key in overrides
156
+ ? overrides[key]
157
+ : instance[key],
158
+ }
159
+ : {});
160
+ targetsByView.set(view, target);
161
+ return view;
162
+ };
163
+ const getView = (table, viewOrTarget, getOverrides) => {
164
+ const target = getMRT_ViewTarget(viewOrTarget);
165
+ let views = viewsByTable.get(table);
166
+ if (!views) {
167
+ views = new WeakMap();
168
+ viewsByTable.set(table, views);
169
+ }
170
+ let view = views.get(target);
171
+ if (!view) {
172
+ view = createMRT_View(target, getOverrides === null || getOverrides === void 0 ? void 0 : getOverrides(target));
173
+ views.set(target, view);
174
+ }
175
+ return view;
176
+ };
177
+ const getMRT_RowView = (table, row) => getView(table, row);
178
+ const getMRT_ColumnView = (table, column) => getView(table, column);
179
+ const getMRT_CellView = (table, cell) => getView(table, cell, (target) => ({
180
+ column: getMRT_ColumnView(table, target.column),
181
+ row: getMRT_RowView(table, target.row),
182
+ }));
183
+ const getMRT_HeaderView = (table, header) => getView(table, header, (target) => ({
184
+ column: getMRT_ColumnView(table, target.column),
185
+ }));
186
+
187
+ const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
188
+ const getPrimaryShade = (theme) => {
189
+ var _a, _b;
190
+ return typeof theme.primaryShade === 'number'
191
+ ? theme.primaryShade
192
+ : ((_b = (_a = theme.primaryShade) === null || _a === void 0 ? void 0 : _a.dark) !== null && _b !== void 0 ? _b : 7);
193
+ };
194
+ const getPrimaryColor = (theme, shade) => theme.colors[theme.primaryColor][shade !== null && shade !== void 0 ? shade : getPrimaryShade(theme)];
195
+ function dataVariable(name, value) {
196
+ const key = `data-${name}`;
197
+ switch (typeof value) {
198
+ case 'boolean':
199
+ return value ? { [key]: '' } : null;
200
+ case 'number':
201
+ return { [key]: `${value}` };
202
+ case 'string':
203
+ return { [key]: value };
204
+ default:
205
+ return null;
206
+ }
207
+ }
208
+
209
+ var classes$z = {"root":"MRT_CopyButton-module_root__mkXy4"};
210
+
211
+ const MRT_CopyButton = (_a) => {
212
+ var { cell, children, table } = _a, rest = __rest(_a, ["cell", "children", "table"]);
213
+ const { options: { localization: { clickToCopy, copiedToClipboard }, mantineCopyButtonProps, }, } = table;
214
+ const { column, row } = cell;
215
+ const { columnDef } = column;
216
+ const arg = { cell, column, row, table };
217
+ const buttonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineCopyButtonProps, arg)), parseFromValuesOrFunc(columnDef.mantineCopyButtonProps, arg)), rest);
218
+ return (jsxRuntime.jsx(core.CopyButton, { value: cell.getValue(), children: ({ copied, copy }) => {
219
+ var _a;
220
+ return (jsxRuntime.jsx(core.Tooltip, { color: copied ? 'green' : undefined, label: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? copiedToClipboard : clickToCopy), openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.UnstyledButton, Object.assign({}, buttonProps, { className: clsx('mrt-copy-button', classes$z.root, buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.className), onClick: (e) => {
221
+ e.stopPropagation();
222
+ copy();
223
+ }, role: "presentation", title: undefined, children: children })) }));
224
+ } }));
225
+ };
226
+
227
+ const MRT_EditCellTextInput = (_a) => {
228
+ var _b;
229
+ var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
230
+ const { getState, options: { createDisplayMode, editDisplayMode, mantineEditSelectProps, mantineEditTextInputProps, }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
231
+ const { column, row } = cell;
232
+ const { columnDef } = column;
233
+ const { creatingRow, editingRow } = getState();
234
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
235
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
236
+ const isSelectEdit = columnDef.editVariant === 'select';
237
+ const isMultiSelectEdit = columnDef.editVariant === 'multi-select';
238
+ const [value, setValue] = react.useState(() => cell.getValue());
239
+ const arg = { cell, column, row, table };
240
+ const textInputProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineEditTextInputProps, arg)), parseFromValuesOrFunc(columnDef.mantineEditTextInputProps, arg)), rest);
241
+ const selectProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineEditSelectProps, arg)), parseFromValuesOrFunc(columnDef.mantineEditSelectProps, arg)), rest);
242
+ const saveInputValueToRowCache = (newValue) => {
243
+ //@ts-ignore
244
+ row._valuesCache[column.id] = newValue;
245
+ if (isCreating) {
246
+ setCreatingRow(row);
247
+ }
248
+ else if (isEditing) {
249
+ setEditingRow(row);
250
+ }
251
+ };
252
+ const handleBlur = (event) => {
253
+ var _a;
254
+ (_a = textInputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textInputProps, event);
255
+ saveInputValueToRowCache(value);
256
+ setEditingCell(null);
257
+ };
258
+ const handleEnterKeyDown = (event) => {
259
+ var _a, _b;
260
+ (_a = textInputProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textInputProps, event);
261
+ //Enter also confirms an IME composition (Chinese, Japanese, Korean input)
262
+ if (event.key === 'Enter' && !event.nativeEvent.isComposing) {
263
+ (_b = editInputRefs.current[cell.id]) === null || _b === void 0 ? void 0 : _b.blur();
264
+ }
265
+ };
266
+ if (columnDef.Edit) {
267
+ return (_b = columnDef.Edit) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table });
268
+ }
269
+ const commonProps = {
270
+ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false,
271
+ label: ['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
272
+ ? column.columnDef.header
273
+ : undefined,
274
+ name: cell.id,
275
+ onClick: (e) => {
276
+ var _a;
277
+ e.stopPropagation();
278
+ (_a = textInputProps === null || textInputProps === void 0 ? void 0 : textInputProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textInputProps, e);
279
+ },
280
+ placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
281
+ ? columnDef.header
282
+ : undefined,
283
+ value,
284
+ variant: editDisplayMode === 'table' ? 'unstyled' : 'default',
285
+ };
286
+ if (isSelectEdit) {
287
+ return (jsxRuntime.jsx(core.Select, Object.assign({}, commonProps, { searchable: true, value: value }, selectProps, { onBlur: handleBlur, onChange: (value, option) => {
288
+ var _a, _b;
289
+ (_b = (_a = selectProps).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, option);
290
+ setValue(value);
291
+ }, onClick: (e) => {
292
+ var _a;
293
+ e.stopPropagation();
294
+ (_a = selectProps === null || selectProps === void 0 ? void 0 : selectProps.onClick) === null || _a === void 0 ? void 0 : _a.call(selectProps, e);
295
+ }, ref: (node) => {
296
+ if (node) {
297
+ editInputRefs.current[cell.id] = node;
298
+ assignRef(selectProps.ref, node);
299
+ }
300
+ } })));
301
+ }
302
+ if (isMultiSelectEdit) {
303
+ return (jsxRuntime.jsx(core.MultiSelect, Object.assign({}, commonProps, { searchable: true, value: value }, selectProps, { onBlur: handleBlur, onChange: (newValue) => {
304
+ var _a, _b;
305
+ (_b = (_a = selectProps).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, newValue);
306
+ setValue(newValue);
307
+ // Save if not in focus, otherwise it will be handled by onBlur
308
+ if (document.activeElement === editInputRefs.current[cell.id])
309
+ return;
310
+ saveInputValueToRowCache(newValue);
311
+ }, onClick: (e) => {
312
+ var _a;
313
+ e.stopPropagation();
314
+ (_a = selectProps === null || selectProps === void 0 ? void 0 : selectProps.onClick) === null || _a === void 0 ? void 0 : _a.call(selectProps, e);
315
+ }, ref: (node) => {
316
+ if (node) {
317
+ editInputRefs.current[cell.id] = node;
318
+ assignRef(selectProps.ref, node);
319
+ }
320
+ } })));
321
+ }
322
+ return (jsxRuntime.jsx(core.TextInput, Object.assign({}, commonProps, { onKeyDown: handleEnterKeyDown, value: value !== null && value !== void 0 ? value : '' }, textInputProps, { onBlur: handleBlur, onChange: (event) => {
323
+ var _a;
324
+ (_a = textInputProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textInputProps, event);
325
+ setValue(event.target.value);
326
+ }, onClick: (event) => {
327
+ var _a;
328
+ event.stopPropagation();
329
+ (_a = textInputProps === null || textInputProps === void 0 ? void 0 : textInputProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textInputProps, event);
330
+ }, ref: (node) => {
331
+ if (node) {
332
+ editInputRefs.current[cell.id] = node;
333
+ assignRef(textInputProps.ref, node);
334
+ }
335
+ } })));
336
+ };
337
+
338
+ const MRT_TableBodyCell = (_a) => {
339
+ var _b, _c, _d, _e, _f;
340
+ var { cell: cellProp, numRows = 1, renderedColumnIndex = 0, renderedRowIndex = 0, rowRef, table, virtualCell } = _a, rest = __rest(_a, ["cell", "numRows", "renderedColumnIndex", "renderedRowIndex", "rowRef", "table", "virtualCell"]);
341
+ //a view has a new identity per table reference, which compiled render callbacks need
342
+ const cell = getMRT_CellView(table, cellProp);
343
+ const direction = core.useDirection();
344
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableEditing, enableGrouping, layoutMode, mantineSkeletonProps, mantineTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
345
+ const { columnSizingInfo, creatingRow, density, draggingColumn, editingCell, editingRow, hoveredColumn, isLoading, showSkeletons, } = getState();
346
+ const { column, row } = cell;
347
+ const { columnDef } = column;
348
+ const { columnDefType } = columnDef;
349
+ const args = {
350
+ cell,
351
+ column,
352
+ renderedColumnIndex,
353
+ renderedRowIndex,
354
+ row,
355
+ table,
356
+ };
357
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableBodyCellProps, args)), parseFromValuesOrFunc(columnDef.mantineTableBodyCellProps, args)), rest);
358
+ const skeletonProps = parseFromValuesOrFunc(mantineSkeletonProps, args);
359
+ const [skeletonWidth, setSkeletonWidth] = react.useState(100);
360
+ react.useEffect(() => {
361
+ if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
362
+ return;
363
+ const size = column.getSize();
364
+ setSkeletonWidth(columnDefType === 'display'
365
+ ? size / 2
366
+ : Math.round(Math.random() * (size - size / 3) + size / 3));
367
+ }, [isLoading, showSkeletons]);
368
+ const widthStyles = {
369
+ minWidth: `max(calc(var(--col-${parseCSSVarId(column === null || column === void 0 ? void 0 : column.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
370
+ width: `calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px)`,
371
+ };
372
+ if (layoutMode === 'grid') {
373
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
374
+ ? 0
375
+ : `var(--col-${parseCSSVarId(column.id)}-size)`} 0 auto`;
376
+ }
377
+ else if (layoutMode === 'grid-no-grow') {
378
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
379
+ }
380
+ const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
381
+ const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
382
+ const isColumnPinned = enableColumnPinning &&
383
+ columnDef.columnDefType !== 'group' &&
384
+ column.getIsPinned();
385
+ const isEditable = !cell.getIsPlaceholder() &&
386
+ parseFromValuesOrFunc(enableEditing, row) &&
387
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
388
+ const isEditing = isEditable &&
389
+ !['custom', 'modal'].includes(editDisplayMode) &&
390
+ (editDisplayMode === 'table' ||
391
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
392
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
393
+ !row.getIsGrouped();
394
+ const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
395
+ const showClickToCopyButton = parseFromValuesOrFunc(enableClickToCopy, cell) ||
396
+ (parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) &&
397
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) !== false);
398
+ const handleDoubleClick = (event) => {
399
+ var _a;
400
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
401
+ if (isEditable && editDisplayMode === 'cell') {
402
+ setEditingCell(cell);
403
+ setTimeout(() => {
404
+ var _a;
405
+ const textField = editInputRefs.current[cell.id];
406
+ if (textField) {
407
+ textField.focus();
408
+ (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
409
+ }
410
+ }, 100);
411
+ }
412
+ };
413
+ const handleDragEnter = (e) => {
414
+ var _a;
415
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
416
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
417
+ setHoveredColumn(null);
418
+ }
419
+ if (enableColumnOrdering && draggingColumn) {
420
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
421
+ }
422
+ };
423
+ const cellValueProps = {
424
+ cell,
425
+ renderedColumnIndex,
426
+ renderedRowIndex,
427
+ table,
428
+ };
429
+ const cellHoverRevealDivRef = react.useRef(null);
430
+ const [isCellContentOverflowing, setIsCellContentOverflowing] = react.useState(false);
431
+ const onMouseEnter = () => {
432
+ if (!columnDef.enableCellHoverReveal)
433
+ return;
434
+ const div = cellHoverRevealDivRef.current;
435
+ if (div) {
436
+ const isOverflow = div.scrollWidth > div.clientWidth;
437
+ setIsCellContentOverflowing(isOverflow);
438
+ }
439
+ };
440
+ const onMouseLeave = () => {
441
+ if (!columnDef.enableCellHoverReveal)
442
+ return;
443
+ setIsCellContentOverflowing(false);
444
+ };
445
+ const renderCellContent = () => {
446
+ var _a, _b, _c;
447
+ if (cell.getIsPlaceholder()) {
448
+ return (_b = (_a = columnDef.PlaceholderCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : null;
449
+ }
450
+ if (showSkeletons !== false && (isLoading || showSkeletons)) {
451
+ return jsxRuntime.jsx(core.Skeleton, Object.assign({ height: 20, width: skeletonWidth }, skeletonProps));
452
+ }
453
+ if (columnDefType === 'display' &&
454
+ (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
455
+ !row.getIsGrouped())) {
456
+ return (_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, Object.assign({ column, renderedCellValue: cell.renderValue(), row,
457
+ rowRef }, cellValueProps));
458
+ }
459
+ if (isCreating || isEditing) {
460
+ return jsxRuntime.jsx(MRT_EditCellTextInput, { cell: cell, table: table });
461
+ }
462
+ if (showClickToCopyButton && columnDef.enableClickToCopy !== false) {
463
+ return (jsxRuntime.jsx(MRT_CopyButton, { cell: cell, table: table, children: jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) }));
464
+ }
465
+ return jsxRuntime.jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps));
466
+ };
467
+ return (jsxRuntime.jsx(core.TableTd, Object.assign({ "data-column-pinned": isColumnPinned || undefined, "data-dragging-column": isDraggingColumn || undefined, "data-first-right-pinned": (isColumnPinned === 'right' &&
468
+ column.getIsFirstColumn(isColumnPinned)) ||
469
+ undefined, "data-hovered-column-target": isHoveredColumn || undefined, "data-index": renderedColumnIndex, "data-last-left-pinned": (isColumnPinned === 'left' && column.getIsLastColumn(isColumnPinned)) ||
470
+ undefined, "data-last-row": renderedRowIndex === numRows - 1 || undefined, "data-resizing": (columnResizeMode === 'onChange' &&
471
+ (columnSizingInfo === null || columnSizingInfo === void 0 ? void 0 : columnSizingInfo.isResizingColumn) === column.id &&
472
+ columnResizeDirection) ||
473
+ undefined }, tableCellProps, { __vars: Object.assign({ '--mrt-cell-align': (_c = tableCellProps.align) !== null && _c !== void 0 ? _c : (direction.dir === 'rtl' ? 'right' : 'left'), '--mrt-table-cell-left': isColumnPinned === 'left'
474
+ ? `${column.getStart(isColumnPinned)}`
475
+ : undefined, '--mrt-table-cell-right': isColumnPinned === 'right'
476
+ ? `${column.getAfter(isColumnPinned)}`
477
+ : undefined }, tableCellProps.__vars), className: clsx(classes$A.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$A['root-grid'], virtualCell && classes$A['root-virtualized'], isEditable &&
478
+ editDisplayMode === 'cell' &&
479
+ classes$A['root-cursor-pointer'], isEditable &&
480
+ ['cell', 'table'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '') &&
481
+ columnDefType !== 'display' &&
482
+ classes$A['root-editable-hover'], columnDefType === 'data' && classes$A['root-data-col'], density === 'xs' && classes$A['root-nowrap'], columnDef.enableCellHoverReveal && classes$A['root-cell-hover-reveal'], tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.className), onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: (theme) => (Object.assign(Object.assign({}, widthStyles), parseFromValuesOrFunc(tableCellProps.style, theme))), children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: (_d = tableCellProps.children) !== null && _d !== void 0 ? _d : (columnDef.enableCellHoverReveal ? (jsxRuntime.jsxs("div", { className: clsx(columnDef.enableCellHoverReveal &&
483
+ !(isCreating || isEditing) &&
484
+ classes$A['cell-hover-reveal'], isCellContentOverflowing && classes$A['overflowing']), ref: cellHoverRevealDivRef, children: [renderCellContent(), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_e = row.subRows) === null || _e === void 0 ? void 0 : _e.length, ")"] }))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderCellContent(), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] }))) }) })));
485
+ };
486
+ const Memo_MRT_TableBodyCell = react.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
487
+
488
+ var classes$y = {"root":"MRT_TableDetailPanel-module_root__vQAlM","root-grid":"MRT_TableDetailPanel-module_root-grid__7UMC6","root-virtual-row":"MRT_TableDetailPanel-module_root-virtual-row__r-X4Z","inner":"MRT_TableDetailPanel-module_inner__o-Fk-","inner-grid":"MRT_TableDetailPanel-module_inner-grid__WLZgF","inner-expanded":"MRT_TableDetailPanel-module_inner-expanded__6tg9T","inner-virtual":"MRT_TableDetailPanel-module_inner-virtual__TItRy"};
489
+
490
+ const MRT_TableDetailPanel = (_a) => {
491
+ var _b, _c;
492
+ var { parentRowRef, renderedRowIndex = 0, row, rowVirtualizer, striped, table, virtualRow } = _a, rest = __rest(_a, ["parentRowRef", "renderedRowIndex", "row", "rowVirtualizer", "striped", "table", "virtualRow"]);
493
+ const { getState, getVisibleLeafColumns, options: { layoutMode, mantineDetailPanelProps, mantineTableBodyRowProps, renderDetailPanel, }, } = table;
494
+ const { isLoading } = getState();
495
+ const tableRowProps = parseFromValuesOrFunc(mantineTableBodyRowProps, {
496
+ isDetailPanel: true,
497
+ row,
498
+ table,
499
+ });
500
+ const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineDetailPanelProps, {
501
+ row,
502
+ table,
503
+ })), rest);
504
+ const internalEditComponents = row
505
+ .getAllCells()
506
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
507
+ .map((cell) => (jsxRuntime.jsx(MRT_EditCellTextInput, { cell: cell, table: table }, cell.id)));
508
+ const DetailPanel = !isLoading &&
509
+ row.getIsExpanded() &&
510
+ (renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ internalEditComponents, row, table }));
511
+ return (jsxRuntime.jsx(core.TableTr, Object.assign({ "data-index": renderDetailPanel ? renderedRowIndex * 2 + 1 : renderedRowIndex, "data-striped": striped, ref: (node) => {
512
+ var _a;
513
+ if (node) {
514
+ (_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
515
+ }
516
+ } }, tableRowProps, { __vars: Object.assign({ '--mrt-parent-row-height': virtualRow
517
+ ? `${(_c = (_b = parentRowRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) === null || _c === void 0 ? void 0 : _c.height}px`
518
+ : undefined, '--mrt-virtual-row-start': virtualRow
519
+ ? `${virtualRow.start}px`
520
+ : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.__vars), className: clsx('mantine-Table-tr-detail-panel', classes$y.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$y['root-grid'], virtualRow && classes$y['root-virtual-row'], tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.className), children: jsxRuntime.jsx(core.TableTd, Object.assign({ colSpan: getVisibleLeafColumns().length, component: "td" }, tableCellProps, { __vars: {
521
+ '--mrt-inner-width': `${table.getTotalSize()}px`,
522
+ }, className: clsx('mantine-Table-td-detail-panel', classes$y.inner, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$y['inner-grid'], row.getIsExpanded() && classes$y['inner-expanded'], virtualRow && classes$y['inner-virtual']), p: row.getIsExpanded() && DetailPanel ? 'md' : 0, children: rowVirtualizer ? (row.getIsExpanded() && DetailPanel) : (jsxRuntime.jsx(core.Collapse, { expanded: row.getIsExpanded(), children: DetailPanel })) })) })));
523
+ };
524
+
525
+ //`state` and `initialState` are compared through `table.getState()` instead
526
+ const ignoredOptionKeys = new Set(['initialState', 'state']);
527
+ const isPlain = (value) => {
528
+ if (typeof value !== 'object' || value === null)
529
+ return false;
530
+ const prototype = Object.getPrototypeOf(value);
531
+ return (prototype === Object.prototype || prototype === null || Array.isArray(value));
532
+ };
533
+ /**
534
+ * Compares plain objects and arrays by content, `depth` levels deep, and
535
+ * everything else by identity. `table.setSorting([{ desc: false, id: 'name' }])`
536
+ * with the sorting that is already set makes a new array with the same content,
537
+ * and that must not count as a change.
538
+ */
539
+ const isEqual = (a, b, depth) => {
540
+ if (Object.is(a, b))
541
+ return true;
542
+ if (!depth ||
543
+ !isPlain(a) ||
544
+ !isPlain(b) ||
545
+ Array.isArray(a) !== Array.isArray(b)) {
546
+ return false;
547
+ }
548
+ const keys = Object.keys(a);
549
+ return (keys.length === Object.keys(b).length &&
550
+ keys.every((key) => key in b && isEqual(a[key], b[key], depth - 1)));
551
+ };
552
+ /**
553
+ * Option objects such as `mantineTableProps={{ striped: true }}` compare by
554
+ * content. Arrays (`data`, `columns`) and functions compare by identity,
555
+ * because TanStack rebuilds rows and columns when their identity changes.
556
+ */
557
+ const optionsEqual = (a, b) => {
558
+ if (a === b)
559
+ return true;
560
+ const keys = Object.keys(a);
561
+ return (keys.length === Object.keys(b).length &&
562
+ keys.every((key) => key in b &&
563
+ (ignoredOptionKeys.has(key) ||
564
+ isEqual(a[key], b[key], Array.isArray(a[key]) ? 0 : 1))));
565
+ };
566
+ const stateVersions = new WeakMap();
567
+ /**
568
+ * A number that changes when table state changes, and not when only table
569
+ * options change. `memoMode: 'rows'` compares it, so a consumer that passes
570
+ * inline options still gets memoized rows.
571
+ */
572
+ const getMRT_TableStateVersion = (table) => stateVersions.get(table);
573
+ /**
574
+ * TanStack Table mutates one table instance for the lifetime of the hook. The
575
+ * React Compiler memoizes on reference identity, so compiled consumer code
576
+ * (`<MantineReactTable table={table} />`, `table.getState()` and so on) never
577
+ * sees a change on that instance.
578
+ *
579
+ * This hook returns a new reference whenever table state, table options or the
580
+ * internal render version change, and the same reference otherwise. State and
581
+ * option objects are compared by content, so a setter called with the current
582
+ * value keeps the reference. A function option is compared by identity: pass a
583
+ * stable function (`useCallback` or the React Compiler) to keep the reference
584
+ * across renders of the component that calls the hook. Each
585
+ * reference is a view (see `snapshot.utils.ts`) of the one underlying instance,
586
+ * so every reference reads current data and an old reference is never stale.
587
+ */
588
+ const useMRT_TableSnapshot = (table, tableOptions, version) => {
589
+ var _a;
590
+ const snapshotRef = react.useRef(null);
591
+ const options = tableOptions;
592
+ const state = table.getState();
593
+ const previous = snapshotRef.current;
594
+ const stateChanged = !previous ||
595
+ previous.version !== version ||
596
+ !isEqual(previous.state, state, 3);
597
+ if (stateChanged || !optionsEqual(previous.options, options)) {
598
+ const snapshot = createMRT_View(table, {
599
+ //a new function identity keeps `const { getState } = table` reactive too
600
+ getState: () => table.getState(),
601
+ });
602
+ const stateVersion = ((_a = previous === null || previous === void 0 ? void 0 : previous.stateVersion) !== null && _a !== void 0 ? _a : 0) + (stateChanged ? 1 : 0);
603
+ stateVersions.set(snapshot, stateVersion);
604
+ snapshotRef.current = {
605
+ options,
606
+ state,
607
+ stateVersion,
608
+ table: snapshot,
609
+ version,
610
+ };
611
+ }
612
+ return snapshotRef.current.table;
613
+ };
614
+
615
+ const fuzzy$1 = (rowA, rowB, columnId) => {
616
+ let dir = 0;
617
+ if (rowA.columnFiltersMeta[columnId]) {
618
+ dir = matchSorterUtils.compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
619
+ }
620
+ // Provide a fallback for when the item ranks are equal
621
+ return dir === 0
622
+ ? reactTable.sortingFns.alphanumeric(rowA, rowB, columnId)
623
+ : dir;
624
+ };
625
+ const MRT_SortingFns = Object.assign(Object.assign({}, reactTable.sortingFns), { fuzzy: fuzzy$1 });
626
+ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
627
+ Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
628
+
629
+ const getMRT_Rows = (table, all) => {
630
+ const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
631
+ const { creatingRow, pagination } = getState();
632
+ const isRankingRows = getIsRankingRows(table);
633
+ let rows = [];
634
+ if (!isRankingRows) {
635
+ rows =
636
+ !enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
637
+ ? all
638
+ ? getPrePaginationRowModel().rows
639
+ : getRowModel().rows
640
+ : getCenterRows();
641
+ }
642
+ else {
643
+ // fuzzy ranking adjustments
644
+ rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
645
+ if (enablePagination && !manualPagination && !all) {
646
+ const start = pagination.pageIndex * pagination.pageSize;
647
+ rows = rows.slice(start, start + pagination.pageSize);
648
+ }
649
+ if (enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
650
+ // "re-center-ize" the rows (no top or bottom pinned rows unless sticky)
651
+ rows = rows.filter((row) => !row.getIsPinned());
652
+ }
653
+ }
654
+ // row pinning adjustments
655
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
656
+ const centerPinnedRowIds = rows
657
+ .filter((row) => row.getIsPinned())
658
+ .map((r) => r.id);
659
+ rows = [
660
+ ...getTopRows().filter((row) => !centerPinnedRowIds.includes(row.id)),
661
+ ...rows,
662
+ ];
663
+ }
664
+ // blank inserted creating row adjustments
665
+ if (positionCreatingRow !== undefined &&
666
+ creatingRow &&
667
+ createDisplayMode === 'row') {
668
+ const creatingRowIndex = !isNaN(+positionCreatingRow)
669
+ ? +positionCreatingRow
670
+ : positionCreatingRow === 'top'
671
+ ? 0
672
+ : rows.length;
673
+ rows = [
674
+ ...rows.slice(0, creatingRowIndex),
675
+ creatingRow,
676
+ ...rows.slice(creatingRowIndex),
677
+ ];
678
+ }
679
+ return rows;
680
+ };
681
+ const getCanRankRows = (table) => {
682
+ const { getState, options: { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, }, } = table;
683
+ const { expanded, globalFilterFn } = getState();
684
+ return (!manualExpanding &&
685
+ !manualFiltering &&
686
+ !manualGrouping &&
687
+ !manualSorting &&
688
+ enableGlobalFilterRankedResults &&
689
+ globalFilterFn === 'fuzzy' &&
690
+ expanded !== true &&
691
+ !Object.values(expanded).some(Boolean));
692
+ };
693
+ const getIsRankingRows = (table) => {
694
+ const { globalFilter, sorting } = table.getState();
695
+ return (getCanRankRows(table) &&
696
+ globalFilter &&
697
+ !Object.values(sorting).some(Boolean));
698
+ };
699
+ const getIsRowSelected = ({ row, table, }) => {
700
+ const { options: { enableRowSelection }, } = table;
701
+ return (row.getIsSelected() ||
702
+ (parseFromValuesOrFunc(enableRowSelection, row) &&
703
+ row.getCanSelectSubRows() &&
704
+ row.getIsAllSubRowsSelected()));
705
+ };
706
+ const getMRT_RowSelectionHandler = ({ renderedRowIndex = 0, row, table, }) => (event, value) => {
707
+ var _a;
708
+ const { getState, options: { enableBatchRowSelection, enableMultiRowSelection, enableRowPinning, manualPagination, rowPinningDisplayMode, }, refs: { lastSelectedRowId: lastSelectedRowId }, } = table;
709
+ const { pagination: { pageIndex, pageSize }, } = getState();
710
+ const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
711
+ const wasCurrentRowChecked = getIsRowSelected({ row, table });
712
+ // toggle selection of this row
713
+ row.toggleSelected(value !== null && value !== void 0 ? value : !wasCurrentRowChecked);
714
+ const changedRowIds = new Set([row.id]);
715
+ // if shift key is pressed, select all rows between last selected and this one
716
+ if (enableBatchRowSelection &&
717
+ enableMultiRowSelection &&
718
+ event.nativeEvent.shiftKey &&
719
+ lastSelectedRowId.current !== null) {
720
+ const rows = getMRT_Rows(table, true);
721
+ const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
722
+ if (lastIndex !== -1) {
723
+ const isLastIndexChecked = getIsRowSelected({
724
+ row: rows === null || rows === void 0 ? void 0 : rows[lastIndex],
725
+ table,
726
+ });
727
+ const currentIndex = renderedRowIndex + paginationOffset;
728
+ const [start, end] = lastIndex < currentIndex
729
+ ? [lastIndex, currentIndex]
730
+ : [currentIndex, lastIndex];
731
+ // toggle selection of all rows between last selected and this one
732
+ // but only if the last selected row is not the same as the current one
733
+ if (wasCurrentRowChecked !== isLastIndexChecked) {
734
+ for (let i = start; i <= end; i++) {
735
+ rows[i].toggleSelected(!wasCurrentRowChecked);
736
+ changedRowIds.add(rows[i].id);
737
+ }
738
+ }
739
+ }
740
+ }
741
+ // record the last selected row id
742
+ lastSelectedRowId.current = row.id;
743
+ // if all sub rows were selected, unselect them
744
+ if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
745
+ (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
746
+ }
747
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
748
+ changedRowIds.forEach((rowId) => {
749
+ const rowToTogglePin = table.getRow(rowId);
750
+ rowToTogglePin.pin(!wasCurrentRowChecked //was not previously pinned or selected
751
+ ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
752
+ ? 'bottom'
753
+ : 'top'
754
+ : false);
755
+ });
756
+ }
757
+ };
758
+ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
759
+ const { options: { enableRowPinning, rowPinningDisplayMode, selectAllMode }, refs: { lastSelectedRowId }, } = table;
760
+ if (selectAllMode === 'all' || forceAll) {
761
+ table.toggleAllRowsSelected(value !== null && value !== void 0 ? value : event.target.checked);
762
+ }
763
+ else {
764
+ table.toggleAllPageRowsSelected(value !== null && value !== void 0 ? value : event.target.checked);
765
+ }
766
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
767
+ table.setRowPinning({ bottom: [], top: [] });
768
+ }
769
+ lastSelectedRowId.current = null;
770
+ };
771
+
772
+ const MRT_TableBodyRow = (_a) => {
773
+ var _b, _c, _d, _f;
774
+ var { children, columnVirtualizer, numRows, pinnedRowIds, renderedRowIndex = 0, row: rowProp, rowVirtualizer, table, tableProps, virtualRow } = _a, rest = __rest(_a, ["children", "columnVirtualizer", "numRows", "pinnedRowIds", "renderedRowIndex", "row", "rowVirtualizer", "table", "tableProps", "virtualRow"]);
775
+ //a view has a new identity per table reference, which compiled render callbacks need
776
+ const row = getMRT_RowView(table, rowProp);
777
+ const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, mantineTableBodyRowProps, memoMode, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
778
+ const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
779
+ const visibleCells = row.getVisibleCells();
780
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
781
+ //the placeholder row for an empty table has no data to show in a detail panel
782
+ const isEmptyRow = row.id === 'mrt-row-empty';
783
+ const isRowSelected = getIsRowSelected({ row, table });
784
+ const isRowPinned = enableRowPinning && row.getIsPinned();
785
+ const isRowStickyPinned = isRowPinned && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && 'sticky';
786
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
787
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
788
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableBodyRowProps, {
789
+ renderedRowIndex,
790
+ row,
791
+ table,
792
+ })), rest);
793
+ const [bottomPinnedIndex, topPinnedIndex] = react.useMemo(() => {
794
+ if (!enableRowPinning ||
795
+ !isRowStickyPinned ||
796
+ !pinnedRowIds ||
797
+ !row.getIsPinned())
798
+ return [];
799
+ return [
800
+ [...pinnedRowIds].reverse().indexOf(row.id),
801
+ pinnedRowIds.indexOf(row.id),
802
+ ];
803
+ }, [pinnedRowIds, rowPinning]);
804
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
805
+ ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
806
+ 0;
807
+ const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
808
+ const defaultRowHeightByDensity = {
809
+ lg: 61,
810
+ md: 53,
811
+ sm: 45,
812
+ xl: 69,
813
+ xs: 37,
814
+ };
815
+ const rowHeight =
816
+ // @ts-ignore
817
+ parseInt((_d = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _d === void 0 ? void 0 : _d.height, 10) ||
818
+ ((_f = defaultRowHeightByDensity[density]) !== null && _f !== void 0 ? _f : defaultRowHeightByDensity['md']);
819
+ const handleDragEnter = (_e) => {
820
+ if (enableRowOrdering && draggingRow) {
821
+ setHoveredRow(row);
822
+ }
823
+ };
824
+ const rowRef = react.useRef(null);
825
+ let striped = tableProps.striped;
826
+ if (striped) {
827
+ if (striped === true) {
828
+ striped = 'odd';
829
+ }
830
+ if (striped === 'odd' && renderedRowIndex % 2 !== 0) {
831
+ striped = false;
832
+ }
833
+ if (striped === 'even' && renderedRowIndex % 2 === 0) {
834
+ striped = false;
835
+ }
836
+ }
837
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(core.TableTr, Object.assign({ "data-dragging-row": isDraggingRow || undefined, "data-hovered-row-target": isHoveredRow || undefined, "data-index": renderDetailPanel ? renderedRowIndex * 2 : renderedRowIndex, "data-row-pinned": isRowStickyPinned || isRowPinned || undefined, "data-selected": isRowSelected || undefined, "data-striped": striped, onDragEnter: handleDragEnter, ref: (node) => {
838
+ if (node) {
839
+ rowRef.current = node;
840
+ //also registers the row with the virtualizer's ResizeObserver
841
+ rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement(node);
842
+ }
843
+ } }, tableRowProps, { __vars: Object.assign(Object.assign({}, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.__vars), { '--mrt-pinned-row-bottom': !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
844
+ ? `${bottomPinnedIndex * rowHeight +
845
+ (enableStickyFooter ? tableFooterHeight - 1 : 0)}`
846
+ : undefined, '--mrt-pinned-row-top': virtualRow
847
+ ? undefined
848
+ : topPinnedIndex !== undefined && isRowPinned
849
+ ? `${topPinnedIndex * rowHeight +
850
+ (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}`
851
+ : undefined, '--mrt-virtual-row-start': virtualRow
852
+ ? `${virtualRow.start}px`
853
+ : undefined }), className: clsx(classes$B.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$B['root-grid'], virtualRow && classes$B['root-virtualized'], tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.className), children: [virtualPaddingLeft ? (jsxRuntime.jsx(core.Box, { component: "td", display: "flex", w: virtualPaddingLeft })) : null, children
854
+ ? children
855
+ : (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell, renderedColumnIndex) => {
856
+ let cell = cellOrVirtualCell;
857
+ if (columnVirtualizer) {
858
+ renderedColumnIndex = cellOrVirtualCell
859
+ .index;
860
+ cell = visibleCells[renderedColumnIndex];
861
+ }
862
+ const cellProps = {
863
+ cell,
864
+ numRows,
865
+ renderedColumnIndex,
866
+ renderedRowIndex,
867
+ rowRef,
868
+ table,
869
+ virtualCell: columnVirtualizer
870
+ ? cellOrVirtualCell
871
+ : undefined,
872
+ };
873
+ return memoMode === 'cells' &&
874
+ cell.column.columnDef.columnDefType === 'data' &&
875
+ !draggingColumn &&
876
+ !draggingRow &&
877
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
878
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, cellProps), cell.id)) : (jsxRuntime.jsx(MRT_TableBodyCell, Object.assign({}, cellProps), cell.id));
879
+ }), virtualPaddingRight ? (jsxRuntime.jsx(core.Box, { component: "td", display: "flex", w: virtualPaddingRight })) : null] })), renderDetailPanel && !row.getIsGrouped() && !isEmptyRow && (jsxRuntime.jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, renderedRowIndex: renderedRowIndex, row: row, rowVirtualizer: rowVirtualizer, striped: striped, table: table, virtualRow: virtualRow }))] }));
880
+ };
881
+ //the state version changes whenever table state changes, so a memoized row
882
+ //still follows row selection, density, editing and so on. The `table`
883
+ //reference is not compared: an inline option gives a new one on every render.
884
+ const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => {
885
+ var _a, _b;
886
+ return prev.row === next.row &&
887
+ getMRT_TableStateVersion(prev.table) ===
888
+ getMRT_TableStateVersion(next.table) &&
889
+ ((_a = prev.virtualRow) === null || _a === void 0 ? void 0 : _a.start) === ((_b = next.virtualRow) === null || _b === void 0 ? void 0 : _b.start);
890
+ });
891
+
892
+ const MRT_TableBodyEmptyRow = (_a) => {
893
+ var _b, _c;
894
+ var { table, tableProps } = _a, commonRowProps = __rest(_a, ["table", "tableProps"]);
895
+ const { getState, options: { layoutMode, localization, renderEmptyRowsFallback }, refs: { tablePaperRef }, } = table;
896
+ const { columnFilters, globalFilter } = getState();
897
+ const emptyRow = react.useMemo(() => reactTable.createRow(table, 'mrt-row-empty', {}, 0, 0), []);
898
+ const emptyRowProps = Object.assign(Object.assign({}, commonRowProps), { renderedRowIndex: 0, row: emptyRow, virtualRow: undefined });
899
+ return (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({ className: clsx('mrt-table-body-row', (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$C['empty-row-tr-grid']), table: table, tableProps: tableProps }, emptyRowProps, { children: jsxRuntime.jsx("td", { className: clsx('mrt-table-body-cell', (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$C['empty-row-td-grid']), colSpan: table.getVisibleLeafColumns().length, children: (_b = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(core.Text, { __vars: {
900
+ '--mrt-paper-width': `${(_c = tablePaperRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth}`,
901
+ }, className: clsx(classes$C['empty-row-td-content']), children: globalFilter || columnFilters.length
902
+ ? localization.noResultsFound
903
+ : localization.noRecordsToDisplay })) }) })));
904
+ };
905
+
906
+ const useMRT_Rows = (table) => {
907
+ const { getRowModel, getState, options: { data, enableGlobalFilterRankedResults, positionCreatingRow }, } = table;
908
+ const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = getState();
909
+ const rows = react.useMemo(() => getMRT_Rows(table), [
910
+ creatingRow,
911
+ data,
912
+ enableGlobalFilterRankedResults,
913
+ expanded,
914
+ getRowModel().rows,
915
+ globalFilter,
916
+ pagination.pageIndex,
917
+ pagination.pageSize,
918
+ positionCreatingRow,
919
+ rowPinning,
920
+ sorting,
921
+ ]);
922
+ return rows;
923
+ };
924
+
925
+ /**
926
+ * Column virtualization indexes the visible leaf columns. A header group that
927
+ * holds group headers has fewer headers than there are leaf columns, so
928
+ * `headers[virtualColumn.index]` does not find the right header there.
929
+ *
930
+ * Returns the headers that sit above at least one rendered leaf column, or
931
+ * `undefined` for a header group of leaf headers, which the index does match.
932
+ * `style` narrows a group header when only some of its columns are rendered.
933
+ */
934
+ const getVirtualGroupHeaders = ({ headers, table, virtualColumns, }) => {
935
+ if (!virtualColumns || !headers.some((header) => { var _a; return (_a = header.subHeaders) === null || _a === void 0 ? void 0 : _a.length; })) {
936
+ return undefined;
937
+ }
938
+ const { layoutMode } = table.options;
939
+ const leafIndexes = new Map(table.getVisibleLeafColumns().map((column, index) => [column.id, index]));
940
+ const virtualIndexes = new Set(virtualColumns.map((virtualColumn) => virtualColumn.index));
941
+ return headers.flatMap((header) => {
942
+ const leafHeaders = header
943
+ .getLeafHeaders()
944
+ .filter((leafHeader) => { var _a; return !((_a = leafHeader.subHeaders) === null || _a === void 0 ? void 0 : _a.length); });
945
+ const renderedLeafHeaders = leafHeaders.filter((leafHeader) => { var _a; return virtualIndexes.has((_a = leafIndexes.get(leafHeader.column.id)) !== null && _a !== void 0 ? _a : -1); });
946
+ if (!renderedLeafHeaders.length)
947
+ return [];
948
+ let style;
949
+ if (renderedLeafHeaders.length < leafHeaders.length) {
950
+ const size = renderedLeafHeaders.reduce((total, leafHeader) => total + leafHeader.getSize(), 0);
951
+ style = { minWidth: `${size}px`, width: `${size}px` };
952
+ if (layoutMode === 'grid')
953
+ style.flex = `${size} 0 auto`;
954
+ }
955
+ return [
956
+ {
957
+ header,
958
+ index: leafIndexes.get(renderedLeafHeaders[0].column.id),
959
+ style,
960
+ },
961
+ ];
962
+ });
963
+ };
964
+ const extraIndexRangeExtractor = (range, draggingIndex) => {
965
+ const newIndexes = reactVirtual.defaultRangeExtractor(range);
966
+ if (draggingIndex === undefined)
967
+ return newIndexes;
968
+ if (draggingIndex >= 0 &&
969
+ draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
970
+ newIndexes.unshift(draggingIndex);
971
+ }
972
+ if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
973
+ newIndexes.push(draggingIndex);
974
+ }
975
+ return newIndexes;
976
+ };
977
+
978
+ /**
979
+ * TanStack Virtual reads its scroll element in a layout effect. Child layout
980
+ * effects run before the table container attaches its ref, so the first read
981
+ * returns null and no rows or columns are rendered.
982
+ *
983
+ * Passive effects run after every ref is attached. This hook re-renders the
984
+ * owner once when the virtualizer still holds a different scroll element, so
985
+ * the next layout effect picks up the mounted container. The virtualizer no
986
+ * longer depends on an unrelated parent re-render, which compiled consumer
987
+ * code does not produce.
988
+ */
989
+ const useMRT_VirtualizerScrollElement = (virtualizer) => {
990
+ const rerender = react.useReducer((version) => version + 1, 0)[1];
991
+ react.useEffect(() => {
992
+ //the virtualizer's own options decide the element, so a consumer's
993
+ //`getScrollElement` or `enabled: false` never leaves a permanent mismatch
994
+ const { enabled, getScrollElement } = virtualizer.options;
995
+ const scrollElement = enabled === false ? null : getScrollElement();
996
+ if (scrollElement && virtualizer.scrollElement !== scrollElement) {
997
+ rerender();
998
+ }
999
+ });
1000
+ };
1001
+
1002
+ const useMRT_RowVirtualizer = (table, rows) => {
1003
+ var _a, _b;
1004
+ const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { scrollAreaViewportRef, tableContainerRef }, } = table;
1005
+ const { density, draggingRow, expanded } = getState();
1006
+ if (!enableRowVirtualization)
1007
+ return undefined;
1008
+ const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
1009
+ table,
1010
+ });
1011
+ const rowCount = (_a = rows === null || rows === void 0 ? void 0 : rows.length) !== null && _a !== void 0 ? _a : getRowModel().rows.length;
1012
+ const defaultRowHeightByDensity = {
1013
+ lg: 62.7,
1014
+ md: 54.7,
1015
+ sm: 48.7,
1016
+ xl: 70.7,
1017
+ xs: 42.7,
1018
+ };
1019
+ const normalRowHeight = (_b = defaultRowHeightByDensity[density]) !== null && _b !== void 0 ? _b : defaultRowHeightByDensity['md'];
1020
+ const rowVirtualizer = reactVirtual.useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
1021
+ ? expanded === true
1022
+ ? 100
1023
+ : 0
1024
+ : normalRowHeight, getScrollElement: () => { var _a; return (_a = scrollAreaViewportRef.current) !== null && _a !== void 0 ? _a : tableContainerRef.current; }, measureElement: typeof window !== 'undefined' &&
1025
+ navigator.userAgent.indexOf('Firefox') === -1
1026
+ ? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
1027
+ : undefined, overscan: 4, rangeExtractor: react.useCallback((range) => {
1028
+ const current_index = getRowModel().rows.findIndex((row) => row.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id));
1029
+ return extraIndexRangeExtractor(range, current_index >= 0 ? current_index : 0);
1030
+ }, [draggingRow]) }, rowVirtualizerProps));
1031
+ useMRT_VirtualizerScrollElement(rowVirtualizer);
1032
+ rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
1033
+ if (rowVirtualizerInstanceRef) {
1034
+ //@ts-ignore
1035
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
1036
+ }
1037
+ return rowVirtualizer;
1038
+ };
1039
+
1040
+ const MRT_TableBody = (_a) => {
1041
+ var _b, _c, _d, _e;
1042
+ var { columnVirtualizer, table, tableProps } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "tableProps"]);
1043
+ const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, mantineTableBodyProps, memoMode, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, } = table;
1044
+ const { isFullScreen, rowPinning } = getState();
1045
+ const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableBodyProps, { table })), rest);
1046
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
1047
+ ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
1048
+ 0;
1049
+ const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
1050
+ const pinnedRowIds = react.useMemo(() => {
1051
+ var _a, _b;
1052
+ if (!((_a = rowPinning.bottom) === null || _a === void 0 ? void 0 : _a.length) && !((_b = rowPinning.top) === null || _b === void 0 ? void 0 : _b.length))
1053
+ return [];
1054
+ return getRowModel()
1055
+ .rows.filter((row) => row.getIsPinned())
1056
+ .map((r) => r.id);
1057
+ }, [rowPinning, getRowModel().rows]);
1058
+ const rows = useMRT_Rows(table);
1059
+ const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
1060
+ const commonRowProps = {
1061
+ columnVirtualizer,
1062
+ numRows: rows.length,
1063
+ table,
1064
+ tableProps,
1065
+ };
1066
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
1067
+ getIsSomeRowsPinned('top') && (jsxRuntime.jsx(core.TableTbody, Object.assign({}, tableBodyProps, { __vars: Object.assign({ '--mrt-table-head-height': `${tableHeadHeight}` }, tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.__vars), className: clsx(classes$C.pinned, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$C['root-grid'], tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.className), children: getTopRows().map((row, renderedRowIndex) => {
1068
+ const rowProps = Object.assign(Object.assign({}, commonRowProps), { renderedRowIndex,
1069
+ row });
1070
+ return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, rowProps), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, rowProps), row.id));
1071
+ }) }))), jsxRuntime.jsx(core.TableTbody, Object.assign({}, tableBodyProps, { __vars: Object.assign({ '--mrt-table-body-height': rowVirtualizer
1072
+ ? `${rowVirtualizer.getTotalSize()}px`
1073
+ : undefined }, tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.__vars), className: clsx(classes$C.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$C['root-grid'], !rows.length && classes$C['root-no-rows'], rowVirtualizer && classes$C['root-virtualized'], tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.className), children: (_d = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _d !== void 0 ? _d : (!rows.length ? (jsxRuntime.jsx(MRT_TableBodyEmptyRow, Object.assign({}, commonRowProps))) : (jsxRuntime.jsx(jsxRuntime.Fragment, { children: ((_e = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.virtualRows) !== null && _e !== void 0 ? _e : rows).map((rowOrVirtualRow, renderedRowIndex) => {
1074
+ if (rowVirtualizer) {
1075
+ if (renderDetailPanel) {
1076
+ if (rowOrVirtualRow.index % 2 === 1) {
1077
+ return null;
1078
+ }
1079
+ else {
1080
+ renderedRowIndex = rowOrVirtualRow.index / 2;
1081
+ }
1082
+ }
1083
+ else {
1084
+ renderedRowIndex = rowOrVirtualRow.index;
1085
+ }
1086
+ }
1087
+ const row = rowVirtualizer
1088
+ ? rows[renderedRowIndex]
1089
+ : rowOrVirtualRow;
1090
+ const props = Object.assign(Object.assign({}, commonRowProps), { pinnedRowIds,
1091
+ renderedRowIndex,
1092
+ row,
1093
+ rowVirtualizer, virtualRow: rowVirtualizer
1094
+ ? rowOrVirtualRow
1095
+ : undefined });
1096
+ const key = `${row.id}-${row.index}`;
1097
+ return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), key));
1098
+ }) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
1099
+ getIsSomeRowsPinned('bottom') && (jsxRuntime.jsx(core.TableTbody, Object.assign({}, tableBodyProps, { __vars: Object.assign({ '--mrt-table-footer-height': `${tableFooterHeight}` }, tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.__vars), className: clsx(classes$C.pinned, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$C['root-grid'], tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.className), children: getBottomRows().map((row, renderedRowIndex) => {
1100
+ const props = Object.assign(Object.assign({}, commonRowProps), { renderedRowIndex,
1101
+ row });
1102
+ return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
1103
+ }) })))] }));
1104
+ };
1105
+ const Memo_MRT_TableBody = react.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
1106
+
1107
+ var classes$x = {"grab-icon":"MRT_GrabHandleButton-module_grab-icon__mQimy"};
1108
+
1109
+ const MRT_GrabHandleButton = ({ actionIconProps, onDragEnd, onDragStart, table: { options: { icons: { IconGripHorizontal }, localization: { move }, }, }, }) => {
1110
+ var _a, _b;
1111
+ return (jsxRuntime.jsx(core.Tooltip, { label: (_a = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.title) !== null && _a !== void 0 ? _a : move, openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": (_b = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.title) !== null && _b !== void 0 ? _b : move, draggable: true }, actionIconProps, { className: clsx('mrt-grab-handle-button', classes$x['grab-icon'], actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.className), color: "gray", onClick: (e) => {
1112
+ var _a;
1113
+ e.stopPropagation();
1114
+ (_a = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.onClick) === null || _a === void 0 ? void 0 : _a.call(actionIconProps, e);
1115
+ }, onDragEnd: onDragEnd, onDragStart: onDragStart, size: "sm", title: undefined, variant: "transparent", children: jsxRuntime.jsx(IconGripHorizontal, { size: "100%" }) })) }));
1116
+ };
1117
+
1118
+ const MRT_TableBodyRowGrabHandle = (_a) => {
1119
+ var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
1120
+ const { options: { mantineRowDragHandleProps }, } = table;
1121
+ const actionIconProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineRowDragHandleProps, {
1122
+ row,
1123
+ table,
1124
+ })), rest);
1125
+ const handleDragStart = (event) => {
1126
+ var _a;
1127
+ (_a = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(actionIconProps, event);
1128
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
1129
+ table.setDraggingRow(row);
1130
+ };
1131
+ const handleDragEnd = (event) => {
1132
+ var _a;
1133
+ (_a = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(actionIconProps, event);
1134
+ table.setDraggingRow(null);
1135
+ table.setHoveredRow(null);
1136
+ };
1137
+ return (jsxRuntime.jsx(MRT_GrabHandleButton, { actionIconProps: actionIconProps, onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
1138
+ };
1139
+
1140
+ const MRT_RowPinButton = (_a) => {
1141
+ var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
1142
+ const { options: { icons: { IconPinned, IconX }, localization, rowPinningDisplayMode, }, } = table;
1143
+ const isPinned = row.getIsPinned();
1144
+ const [tooltipOpened, setTooltipOpened] = react.useState(false);
1145
+ const handleTogglePin = (event) => {
1146
+ setTooltipOpened(false);
1147
+ event.stopPropagation();
1148
+ row.pin(isPinned ? false : pinningPosition);
1149
+ };
1150
+ return (jsxRuntime.jsx(core.Tooltip, { label: isPinned ? localization.unpin : localization.pin, openDelay: 1000, opened: tooltipOpened, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": localization.pin, color: "gray", onClick: handleTogglePin, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "xs", style: {
1151
+ height: '24px',
1152
+ width: '24px',
1153
+ }, variant: "subtle" }, rest, { children: isPinned ? (jsxRuntime.jsx(IconX, {})) : (jsxRuntime.jsx(IconPinned, { fontSize: "small", style: {
1154
+ transform: `rotate(${rowPinningDisplayMode === 'sticky'
1155
+ ? 135
1156
+ : pinningPosition === 'top'
1157
+ ? 180
1158
+ : 0}deg)`,
1159
+ } })) })) }));
1160
+ };
1161
+
1162
+ const MRT_TableBodyRowPinButton = (_a) => {
1163
+ var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
1164
+ const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
1165
+ const { density } = getState();
1166
+ const canPin = parseFromValuesOrFunc(enableRowPinning, row);
1167
+ if (!canPin)
1168
+ return null;
1169
+ const rowPinButtonProps = Object.assign({ row,
1170
+ table }, rest);
1171
+ if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
1172
+ return (jsxRuntime.jsxs(core.Box, { style: {
1173
+ display: 'flex',
1174
+ flexDirection: density === 'xs' ? 'row' : 'column',
1175
+ }, children: [jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
1176
+ }
1177
+ return (jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
1178
+ };
1179
+
1180
+ var classes$w = {"root":"MRT_ColumnPinningButtons-module_root__scTtW","left":"MRT_ColumnPinningButtons-module_left__W6Aog","right":"MRT_ColumnPinningButtons-module_right__7AJE3"};
1181
+
1182
+ const MRT_ColumnPinningButtons = ({ column, table, }) => {
1183
+ const { options: { icons: { IconPinned, IconPinnedOff }, localization, }, } = table;
1184
+ return (jsxRuntime.jsx(core.Flex, { className: clsx('mrt-column-pinning-buttons', classes$w.root), children: column.getIsPinned() ? (jsxRuntime.jsx(core.Tooltip, { label: localization.unpin, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, { color: "gray", onClick: () => column.pin(false), size: "md", variant: "subtle", children: jsxRuntime.jsx(IconPinnedOff, {}) }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Tooltip, { label: localization.pinToLeft, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, { color: "gray", onClick: () => column.pin('left'), size: "md", variant: "subtle", children: jsxRuntime.jsx(IconPinned, { className: classes$w.left }) }) }), jsxRuntime.jsx(core.Tooltip, { label: localization.pinToRight, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, { color: "gray", onClick: () => column.pin('right'), size: "md", variant: "subtle", children: jsxRuntime.jsx(IconPinned, { className: classes$w.right }) }) })] })) }));
1185
+ };
1186
+
1187
+ var classes$v = {"root":"MRT_EditActionButtons-module_root__BfxVZ"};
1188
+
1189
+ const MRT_EditActionButtons = (_a) => {
1190
+ var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
1191
+ const { getState, options: { icons: { IconCircleX, IconDeviceFloppy }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
1192
+ const { creatingRow, editingRow, isSaving } = getState();
1193
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1194
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
1195
+ const handleCancel = () => {
1196
+ if (isCreating) {
1197
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
1198
+ setCreatingRow(null);
1199
+ }
1200
+ else if (isEditing) {
1201
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
1202
+ setEditingRow(null);
1203
+ }
1204
+ row._valuesCache = {}; //reset values cache
1205
+ };
1206
+ const handleSubmitRow = () => {
1207
+ var _a;
1208
+ //look for auto-filled input values. A browser can fill an input without
1209
+ //firing the change event that saves the value to the row cache.
1210
+ const inputNamePrefix = `${row.id}_`; //input names are cell ids: rowId_columnId
1211
+ const valuesCache = row._valuesCache;
1212
+ Object.values((_a = editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current) !== null && _a !== void 0 ? _a : {})
1213
+ .filter((input) => { var _a; return (_a = input === null || input === void 0 ? void 0 : input.name) === null || _a === void 0 ? void 0 : _a.startsWith(inputNamePrefix); })
1214
+ .forEach((input) => {
1215
+ var _a, _b;
1216
+ const columnId = input.name.slice(inputNamePrefix.length);
1217
+ const editVariant = (_a = table.getColumn(columnId)) === null || _a === void 0 ? void 0 : _a.columnDef.editVariant;
1218
+ //select inputs show the option label, not the value, so only text inputs are read
1219
+ const isTextInput = !editVariant || editVariant === 'text';
1220
+ if (isTextInput &&
1221
+ Object.hasOwn(valuesCache, columnId) &&
1222
+ //a number or other parsed value is the consumer's, and its text form can differ
1223
+ (typeof valuesCache[columnId] === 'string' ||
1224
+ valuesCache[columnId] == null) &&
1225
+ input.value !== String((_b = valuesCache[columnId]) !== null && _b !== void 0 ? _b : '')) {
1226
+ valuesCache[columnId] = input.value;
1227
+ }
1228
+ });
1229
+ if (isCreating)
1230
+ onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
1231
+ exitCreatingMode: () => setCreatingRow(null),
1232
+ row,
1233
+ table,
1234
+ values: row._valuesCache,
1235
+ });
1236
+ else if (isEditing) {
1237
+ onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
1238
+ exitEditingMode: () => setEditingRow(null),
1239
+ row,
1240
+ table,
1241
+ values: row === null || row === void 0 ? void 0 : row._valuesCache,
1242
+ });
1243
+ }
1244
+ };
1245
+ return (jsxRuntime.jsx(core.Box, Object.assign({ className: clsx('mrt-edit-action-buttons', classes$v.root), onClick: (e) => e.stopPropagation() }, rest, { children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Tooltip, { label: localization.cancel, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.cancel, color: "red", onClick: handleCancel, variant: "subtle", children: jsxRuntime.jsx(IconCircleX, {}) }) }), jsxRuntime.jsx(core.Tooltip, { label: localization.save, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.save, color: "blue", loading: isSaving, onClick: handleSubmitRow, variant: "subtle", children: jsxRuntime.jsx(IconDeviceFloppy, {}) }) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Button, { onClick: handleCancel, variant: "subtle", children: localization.cancel }), jsxRuntime.jsx(core.Button, { loading: isSaving, onClick: handleSubmitRow, variant: "filled", children: localization.save })] })) })));
1246
+ };
1247
+
1248
+ var classes$u = {"root":"MRT_ExpandAllButton-module_root__gkBZD","chevron":"MRT_ExpandAllButton-module_chevron__Iep0j","up":"MRT_ExpandAllButton-module_up__Xth3U","right":"MRT_ExpandAllButton-module_right__bS4L-"};
1249
+
1250
+ const MRT_ExpandAllButton = (_a) => {
1251
+ var _b, _c;
1252
+ var { table } = _a, rest = __rest(_a, ["table"]);
1253
+ const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { IconChevronsDown }, localization, mantineExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1254
+ const { density, isLoading } = getState();
1255
+ const actionIconProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineExpandAllButtonProps, {
1256
+ table,
1257
+ })), rest);
1258
+ const isAllRowsExpanded = getIsAllRowsExpanded();
1259
+ return (jsxRuntime.jsx(core.Tooltip, { label: ((_b = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.title) !== null && _b !== void 0 ? _b : isAllRowsExpanded)
1260
+ ? localization.collapseAll
1261
+ : localization.expandAll, openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": localization.expandAll, color: "gray", variant: "subtle" }, actionIconProps, { className: clsx('mrt-expand-all-button', classes$u.root, actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.className, density), disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded), title: undefined, children: (_c = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.children) !== null && _c !== void 0 ? _c : (jsxRuntime.jsx(IconChevronsDown, { className: clsx(classes$u.chevron, isAllRowsExpanded
1262
+ ? classes$u.up
1263
+ : getIsSomeRowsExpanded()
1264
+ ? classes$u.right
1265
+ : undefined) })) })) }));
1266
+ };
1267
+
1268
+ var classes$t = {"root":"MRT_ExpandButton-module_root__IFYio","root-ltr":"MRT_ExpandButton-module_root-ltr__FHNnp","chevron":"MRT_ExpandButton-module_chevron__XzC5P","right":"MRT_ExpandButton-module_right__-pC-A","up":"MRT_ExpandButton-module_up__TZGBo","root-rtl":"MRT_ExpandButton-module_root-rtl__zoudS"};
1269
+
1270
+ const MRT_ExpandButton = (_a) => {
1271
+ var _b, _c;
1272
+ var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
1273
+ const direction = core.useDirection();
1274
+ const { options: { icons: { IconChevronDown }, localization, mantineExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
1275
+ const actionIconProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineExpandButtonProps, {
1276
+ row,
1277
+ table,
1278
+ })), rest);
1279
+ const internalEditComponents = row
1280
+ .getAllCells()
1281
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
1282
+ .map((cell) => (jsxRuntime.jsx(MRT_EditCellTextInput, { cell: cell, table: table }, cell.id)));
1283
+ const canExpand = row.getCanExpand();
1284
+ const isExpanded = row.getIsExpanded();
1285
+ const DetailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({
1286
+ internalEditComponents,
1287
+ row,
1288
+ table,
1289
+ }));
1290
+ const handleToggleExpand = (event) => {
1291
+ var _a;
1292
+ event.stopPropagation();
1293
+ row.toggleExpanded();
1294
+ (_a = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.onClick) === null || _a === void 0 ? void 0 : _a.call(actionIconProps, event);
1295
+ };
1296
+ const rtl = direction.dir === 'rtl' || positionExpandColumn === 'last';
1297
+ return (jsxRuntime.jsx(core.Tooltip, { disabled: !canExpand && !DetailPanel, label: (_b = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.title) !== null && _b !== void 0 ? _b : (isExpanded ? localization.collapse : localization.expand), openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": localization.expand, color: "gray", disabled: !canExpand && !DetailPanel, variant: "subtle" }, actionIconProps, { __vars: {
1298
+ '--mrt-row-depth': `${row.depth}`,
1299
+ }, className: clsx('mrt-expand-button', classes$t.root, classes$t[`root-${rtl ? 'rtl' : 'ltr'}`], actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.className), onClick: handleToggleExpand, title: undefined, children: (_c = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.children) !== null && _c !== void 0 ? _c : (jsxRuntime.jsx(IconChevronDown, { className: clsx('mrt-expand-button-chevron', classes$t.chevron, !canExpand && !renderDetailPanel
1300
+ ? classes$t.right
1301
+ : isExpanded
1302
+ ? classes$t.up
1303
+ : undefined) })) })) }));
1304
+ };
1305
+
1306
+ var classes$s = {"root":"MRT_ShowHideColumnsMenu-module_root__2UWak","content":"MRT_ShowHideColumnsMenu-module_content__ehkWQ"};
1307
+
1308
+ var classes$r = {"root":"MRT_ShowHideColumnsMenuItems-module_root__wYgv-","menu":"MRT_ShowHideColumnsMenuItems-module_menu__CeATR","grab":"MRT_ShowHideColumnsMenuItems-module_grab__a-d-y","pin":"MRT_ShowHideColumnsMenuItems-module_pin__P437b","switch":"MRT_ShowHideColumnsMenuItems-module_switch__tMsdt","header":"MRT_ShowHideColumnsMenuItems-module_header__xVkKb"};
1309
+
1310
+ 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; };
1311
+ const getAllLeafColumnDefs = (columns) => {
1312
+ const allLeafColumnDefs = [];
1313
+ const getLeafColumns = (cols) => {
1314
+ cols.forEach((col) => {
1315
+ if (col.columns) {
1316
+ getLeafColumns(col.columns);
1317
+ }
1318
+ else {
1319
+ allLeafColumnDefs.push(col);
1320
+ }
1321
+ });
1322
+ };
1323
+ getLeafColumns(columns);
1324
+ return allLeafColumnDefs;
1325
+ };
1326
+ /**
1327
+ * Marks the placeholder rows that `useMRT_TableInstance` generates for the
1328
+ * loading skeletons. The same `Symbol.for` key is written there.
1329
+ */
1330
+ const skeletonRowKey = Symbol.for('mrt-skeleton-row');
1331
+ const isSkeletonRow = (originalRow) => !!(originalRow === null || originalRow === void 0 ? void 0 : originalRow[skeletonRowKey]);
1332
+ const skeletonSafeAccessorFns = new WeakSet();
1333
+ const prepareColumns = ({ columnDefs, tableOptions, }) => {
1334
+ const { aggregationFns = {}, defaultDisplayColumn, filterFns = {}, sortingFns = {}, state: { columnFilterFns = {} } = {}, } = tableOptions;
1335
+ return columnDefs.map((columnDef) => {
1336
+ var _a, _b, _c, _d, _e;
1337
+ //assign columnId
1338
+ if (!columnDef.id)
1339
+ columnDef.id = getColumnId(columnDef);
1340
+ //assign columnDefType
1341
+ if (!columnDef.columnDefType)
1342
+ columnDef.columnDefType = 'data';
1343
+ if ((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length) {
1344
+ columnDef.columnDefType = 'group';
1345
+ //recursively prepare columns if this is a group column
1346
+ columnDef.columns = prepareColumns({
1347
+ columnDefs: columnDef.columns,
1348
+ tableOptions,
1349
+ });
1350
+ }
1351
+ else if (columnDef.columnDefType === 'data') {
1352
+ //assign aggregationFns if multiple aggregationFns are provided
1353
+ if (Array.isArray(columnDef.aggregationFn)) {
1354
+ const aggFns = columnDef.aggregationFn;
1355
+ columnDef.aggregationFn = (columnId, leafRows, childRows) => aggFns.map((fn) => { var _a; return (_a = aggregationFns[fn]) === null || _a === void 0 ? void 0 : _a.call(aggregationFns, columnId, leafRows, childRows); });
1356
+ }
1357
+ //skeleton rows hold no data, so a custom accessorFn must not read them
1358
+ const { accessorFn } = columnDef;
1359
+ if (accessorFn && !skeletonSafeAccessorFns.has(accessorFn)) {
1360
+ columnDef.accessorFn = ((originalRow, index) => isSkeletonRow(originalRow)
1361
+ ? null
1362
+ : accessorFn(originalRow, index));
1363
+ skeletonSafeAccessorFns.add(columnDef.accessorFn);
1364
+ }
1365
+ //assign filterFns
1366
+ //a column added after the first render has no `columnFilterFns` state yet
1367
+ const filterMode = (_c = (_b = columnFilterFns[columnDef.id]) !== null && _b !== void 0 ? _b : columnDef._filterFn) !== null && _c !== void 0 ? _c : (columnDef.filterFn instanceof Function
1368
+ ? undefined
1369
+ : ((_d = columnDef.filterFn) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(columnDef)));
1370
+ if (filterMode !== undefined) {
1371
+ if (Object.keys(filterFns).includes(filterMode)) {
1372
+ columnDef.filterFn = (_e = filterFns[filterMode]) !== null && _e !== void 0 ? _e : filterFns.fuzzy;
1373
+ }
1374
+ //custom filter modes that are not in `filterFns` still need to be tracked
1375
+ columnDef._filterFn = filterMode;
1376
+ }
1377
+ //assign sortingFns
1378
+ if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
1379
+ // @ts-ignore
1380
+ columnDef.sortingFn = sortingFns[columnDef.sortingFn];
1381
+ }
1382
+ }
1383
+ else if (columnDef.columnDefType === 'display') {
1384
+ columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
1385
+ }
1386
+ return columnDef;
1387
+ });
1388
+ };
1389
+ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
1390
+ if (draggedColumn.getCanPin()) {
1391
+ draggedColumn.pin(targetColumn.getIsPinned());
1392
+ }
1393
+ const newColumnOrder = [...columnOrder];
1394
+ newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
1395
+ return newColumnOrder;
1396
+ };
1397
+ const getDefaultColumnFilterFn = (columnDef) => {
1398
+ const { filterVariant } = columnDef;
1399
+ if (filterVariant === 'multi-select')
1400
+ return 'arrIncludesSome';
1401
+ if (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range'))
1402
+ return 'betweenInclusive';
1403
+ if (['checkbox', 'date', 'select'].includes(filterVariant || ''))
1404
+ return 'equals';
1405
+ return 'fuzzy';
1406
+ };
1407
+
1408
+ const MRT_ShowHideColumnsMenuItems = ({ allColumns, column, hoveredColumn, setHoveredColumn, table, }) => {
1409
+ var _a;
1410
+ const theme = core.useMantineTheme();
1411
+ const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, setColumnOrder, } = table;
1412
+ const { columnOrder } = getState();
1413
+ const { columnDef } = column;
1414
+ const { columnDefType } = columnDef;
1415
+ const switchChecked = (columnDefType !== 'group' && column.getIsVisible()) ||
1416
+ (columnDefType === 'group' &&
1417
+ column.getLeafColumns().some((col) => col.getIsVisible()));
1418
+ const handleToggleColumnHidden = (column) => {
1419
+ var _a, _b;
1420
+ if (columnDefType === 'group') {
1421
+ (_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) => {
1422
+ childColumn.toggleVisibility(!switchChecked);
1423
+ });
1424
+ }
1425
+ else {
1426
+ column.toggleVisibility();
1427
+ }
1428
+ };
1429
+ const menuItemRef = react.useRef(null);
1430
+ const [isDragging, setIsDragging] = react.useState(false);
1431
+ const handleDragStart = (e) => {
1432
+ setIsDragging(true);
1433
+ e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
1434
+ };
1435
+ const handleDragEnd = (_e) => {
1436
+ setIsDragging(false);
1437
+ setHoveredColumn(null);
1438
+ if (hoveredColumn) {
1439
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
1440
+ }
1441
+ };
1442
+ const handleDragEnter = (_e) => {
1443
+ if (!isDragging && columnDef.enableColumnOrdering !== false) {
1444
+ setHoveredColumn(column);
1445
+ }
1446
+ };
1447
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
1448
+ return null;
1449
+ }
1450
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Menu.Item, Object.assign({ className: classes$r.root, component: "span", onDragEnter: handleDragEnter, ref: menuItemRef, style: {
1451
+ '--_column-depth': `${(column.depth + 0.5) * 2}rem`,
1452
+ '--_hover-color': getPrimaryColor(theme),
1453
+ } }, dataVariable('dragging', isDragging), dataVariable('order-hovered', (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id), { children: jsxRuntime.jsxs(core.Box, { className: classes$r.menu, children: [columnDefType !== 'group' &&
1454
+ enableColumnOrdering &&
1455
+ !allColumns.some((col) => col.columnDef.columnDefType === 'group') &&
1456
+ (columnDef.enableColumnOrdering !== false ? (jsxRuntime.jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsxRuntime.jsx(core.Box, { className: classes$r.grab }))), enableColumnPinning &&
1457
+ (column.getCanPin() ? (jsxRuntime.jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsxRuntime.jsx(core.Box, { className: classes$r.pin }))), enableHiding ? (jsxRuntime.jsx(core.Tooltip, { label: localization.toggleVisibility, openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.Switch, { checked: switchChecked, className: classes$r.switch, disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) }) })) : (jsxRuntime.jsx(core.Text, { className: classes$r.header, children: columnDef.header }))] }) })), (_a = column.columns) === null || _a === void 0 ? void 0 : _a.map((c, i) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
1458
+ };
1459
+
1460
+ function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
1461
+ const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
1462
+ 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 });
1463
+ }
1464
+ const showRowPinningColumn = (tableOptions) => {
1465
+ const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
1466
+ return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
1467
+ };
1468
+ const showRowDragColumn = (tableOptions) => {
1469
+ const { enableRowDragging, enableRowOrdering } = tableOptions;
1470
+ return !!(enableRowDragging || enableRowOrdering);
1471
+ };
1472
+ const showRowExpandColumn = (tableOptions) => {
1473
+ const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
1474
+ return !!(enableExpanding ||
1475
+ (enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
1476
+ renderDetailPanel);
1477
+ };
1478
+ const showRowActionsColumn = (tableOptions) => {
1479
+ const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
1480
+ return !!(enableRowActions ||
1481
+ (creatingRow && createDisplayMode === 'row') ||
1482
+ (enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
1483
+ };
1484
+ const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
1485
+ const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
1486
+ const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
1487
+ const getLeadingDisplayColumnIds = (tableOptions) => [
1488
+ showRowPinningColumn(tableOptions) && 'mrt-row-pin',
1489
+ showRowDragColumn(tableOptions) && 'mrt-row-drag',
1490
+ tableOptions.positionActionsColumn === 'first' &&
1491
+ showRowActionsColumn(tableOptions) &&
1492
+ 'mrt-row-actions',
1493
+ tableOptions.positionExpandColumn === 'first' &&
1494
+ showRowExpandColumn(tableOptions) &&
1495
+ 'mrt-row-expand',
1496
+ showRowSelectionColumn(tableOptions) && 'mrt-row-select',
1497
+ showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
1498
+ ].filter(Boolean);
1499
+ const getTrailingDisplayColumnIds = (tableOptions) => [
1500
+ tableOptions.positionActionsColumn === 'last' &&
1501
+ showRowActionsColumn(tableOptions) &&
1502
+ 'mrt-row-actions',
1503
+ tableOptions.positionExpandColumn === 'last' &&
1504
+ showRowExpandColumn(tableOptions) &&
1505
+ 'mrt-row-expand',
1506
+ showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
1507
+ ].filter(Boolean);
1508
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
1509
+ const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
1510
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
1511
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
1512
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
1513
+ let allLeafColumnDefIds = reset
1514
+ ? defaultColumnDefIds
1515
+ : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
1516
+ allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
1517
+ !trailingDisplayColIds.includes(colId));
1518
+ return [
1519
+ ...leadingDisplayColIds,
1520
+ ...allLeafColumnDefIds,
1521
+ ...trailingDisplayColIds,
1522
+ ];
1523
+ };
1524
+
1525
+ const MRT_ShowHideColumnsMenu = ({ table, }) => {
1526
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, } = table;
1527
+ const { columnOrder, columnPinning } = getState();
1528
+ const handleToggleAllColumns = (value) => {
1529
+ getAllLeafColumns()
1530
+ .filter((col) => col.columnDef.enableHiding !== false)
1531
+ .forEach((col) => col.toggleVisibility(value));
1532
+ };
1533
+ const allColumns = react.useMemo(() => {
1534
+ const columns = getAllColumns();
1535
+ if (columnOrder.length > 0 &&
1536
+ !columns.some((col) => col.columnDef.columnDefType === 'group')) {
1537
+ return [
1538
+ ...getLeftLeafColumns(),
1539
+ ...Array.from(new Set(columnOrder)).map((colId) => getCenterLeafColumns().find((col) => (col === null || col === void 0 ? void 0 : col.id) === colId)),
1540
+ ...getRightLeafColumns(),
1541
+ ].filter(Boolean);
1542
+ }
1543
+ return columns;
1544
+ }, [
1545
+ columnOrder,
1546
+ columnPinning,
1547
+ getAllColumns(),
1548
+ getCenterLeafColumns(),
1549
+ getLeftLeafColumns(),
1550
+ getRightLeafColumns(),
1551
+ ]);
1552
+ const [hoveredColumn, setHoveredColumn] = react.useState(null);
1553
+ return (jsxRuntime.jsxs(core.Menu.Dropdown, { className: clsx('mrt-show-hide-columns-menu', classes$s.root), children: [jsxRuntime.jsxs(core.Flex, { className: classes$s.content, children: [enableHiding && (jsxRuntime.jsx(core.Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), variant: "subtle", children: localization.hideAll })), enableColumnOrdering && (jsxRuntime.jsx(core.Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), variant: "subtle", children: localization.resetOrder })), enableColumnPinning && (jsxRuntime.jsx(core.Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), variant: "subtle", children: localization.unpinAll })), enableHiding && (jsxRuntime.jsx(core.Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), variant: "subtle", children: localization.showAll }))] }), jsxRuntime.jsx(core.Menu.Divider, {}), allColumns.map((column, index) => (jsxRuntime.jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] }));
1554
+ };
1555
+
1556
+ const MRT_ShowHideColumnsButton = (_a) => {
1557
+ var { table, title } = _a, rest = __rest(_a, ["table", "title"]);
1558
+ const { icons: { IconColumns }, localization: { showHideColumns }, } = table.options;
1559
+ return (jsxRuntime.jsxs(core.Menu, { closeOnItemClick: false, withinPortal: true, children: [jsxRuntime.jsx(core.Tooltip, { label: title !== null && title !== void 0 ? title : showHideColumns, withinPortal: true, children: jsxRuntime.jsx(core.Menu.Target, { children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": title !== null && title !== void 0 ? title : showHideColumns, color: "gray", size: "lg", variant: "subtle" }, rest, { children: jsxRuntime.jsx(IconColumns, {}) })) }) }), jsxRuntime.jsx(MRT_ShowHideColumnsMenu, { table: table })] }));
1560
+ };
1561
+
1562
+ const next = {
1563
+ md: 'xs',
1564
+ xl: 'md',
1565
+ xs: 'xl',
1566
+ };
1567
+ const MRT_ToggleDensePaddingButton = (_a) => {
1568
+ var { table: { getState, options: { icons: { IconBaselineDensityLarge, IconBaselineDensityMedium, IconBaselineDensitySmall, }, localization: { toggleDensity }, }, setDensity, }, title } = _a, rest = __rest(_a, ["table", "title"]);
1569
+ const { density } = getState();
1570
+ return (jsxRuntime.jsx(core.Tooltip, { label: title !== null && title !== void 0 ? title : toggleDensity, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": title !== null && title !== void 0 ? title : toggleDensity, color: "gray", onClick: () => setDensity((current) => next[current]), size: "lg", variant: "subtle" }, rest, { children: density === 'xs' ? (jsxRuntime.jsx(IconBaselineDensitySmall, {})) : density === 'md' ? (jsxRuntime.jsx(IconBaselineDensityMedium, {})) : (jsxRuntime.jsx(IconBaselineDensityLarge, {})) })) }));
1571
+ };
1572
+
1573
+ const MRT_ToggleFiltersButton = (_a) => {
1574
+ var { table: { getState, options: { icons: { IconFilter, IconFilterOff }, localization: { showHideFilters }, }, setShowColumnFilters, }, title } = _a, rest = __rest(_a, ["table", "title"]);
1575
+ const { showColumnFilters } = getState();
1576
+ return (jsxRuntime.jsx(core.Tooltip, { label: title !== null && title !== void 0 ? title : showHideFilters, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": title !== null && title !== void 0 ? title : showHideFilters, color: "gray", onClick: () => setShowColumnFilters((current) => !current), size: "lg", variant: "subtle" }, rest, { children: showColumnFilters ? jsxRuntime.jsx(IconFilterOff, {}) : jsxRuntime.jsx(IconFilter, {}) })) }));
1577
+ };
1578
+
1579
+ const MRT_ToggleFullScreenButton = (_a) => {
1580
+ var { table: { getState, options: { icons: { IconMaximize, IconMinimize }, localization: { toggleFullScreen }, }, setIsFullScreen, }, title } = _a, rest = __rest(_a, ["table", "title"]);
1581
+ const { isFullScreen } = getState();
1582
+ const [tooltipOpened, setTooltipOpened] = react.useState(false);
1583
+ const handleToggleFullScreen = () => {
1584
+ setTooltipOpened(false);
1585
+ setIsFullScreen((current) => !current);
1586
+ };
1587
+ return (jsxRuntime.jsx(core.Tooltip, { label: title !== null && title !== void 0 ? title : toggleFullScreen, opened: tooltipOpened, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": title !== null && title !== void 0 ? title : toggleFullScreen, color: "gray", onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "lg", variant: "subtle" }, rest, { children: isFullScreen ? jsxRuntime.jsx(IconMinimize, {}) : jsxRuntime.jsx(IconMaximize, {}) })) }));
1588
+ };
1589
+
1590
+ const MRT_ToggleGlobalFilterButton = (_a) => {
1591
+ var { table: { getState, options: { icons: { IconSearch, IconSearchOff }, localization: { showHideSearch }, }, refs: { searchInputRef }, setShowGlobalFilter, }, title } = _a, rest = __rest(_a, ["table", "title"]);
1592
+ const { globalFilter, showGlobalFilter } = getState();
1593
+ const handleToggleSearch = () => {
1594
+ setShowGlobalFilter(!showGlobalFilter);
1595
+ setTimeout(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, 100);
1596
+ };
1597
+ return (jsxRuntime.jsx(core.Tooltip, { label: title !== null && title !== void 0 ? title : showHideSearch, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": title !== null && title !== void 0 ? title : showHideSearch, color: "gray", disabled: !!globalFilter, onClick: handleToggleSearch, size: "lg", variant: "subtle" }, rest, { children: showGlobalFilter ? jsxRuntime.jsx(IconSearchOff, {}) : jsxRuntime.jsx(IconSearch, {}) })) }));
1598
+ };
1599
+
1600
+ const MRT_RowActionMenu = (_a) => {
1601
+ var { handleEdit, row, table } = _a, rest = __rest(_a, ["handleEdit", "row", "table"]);
1602
+ const { options: { editDisplayMode, enableEditing, icons: { IconDots, IconEdit }, localization, positionActionsColumn, renderRowActionMenuItems, }, } = table;
1603
+ return (jsxRuntime.jsxs(core.Menu, { closeOnItemClick: true, position: positionActionsColumn === 'first'
1604
+ ? 'bottom-start'
1605
+ : positionActionsColumn === 'last'
1606
+ ? 'bottom-end'
1607
+ : undefined, withinPortal: true, children: [jsxRuntime.jsx(core.Tooltip, { label: localization.rowActions, openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.Menu.Target, { children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": localization.rowActions, color: "gray", onClick: (event) => event.stopPropagation(), size: "sm", variant: "subtle" }, rest, { children: jsxRuntime.jsx(IconDots, {}) })) }) }), jsxRuntime.jsxs(core.Menu.Dropdown, { onClick: (event) => event.stopPropagation(), children: [enableEditing && editDisplayMode !== 'table' && (jsxRuntime.jsx(core.Menu.Item, { leftSection: jsxRuntime.jsx(IconEdit, {}), onClick: handleEdit, children: localization.edit })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
1608
+ row,
1609
+ table,
1610
+ })] })] }));
1611
+ };
1612
+
1613
+ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
1614
+ const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { IconEdit }, localization: { edit }, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
1615
+ const { creatingRow, editingRow } = getState();
1616
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1617
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
1618
+ const handleStartEditMode = (event) => {
1619
+ event.stopPropagation();
1620
+ setEditingRow(Object.assign({}, row));
1621
+ };
1622
+ const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
1623
+ (isEditing && editDisplayMode === 'row');
1624
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, table })) : showEditActionButtons ? (jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
1625
+ parseFromValuesOrFunc(enableEditing, row) ? (jsxRuntime.jsx(core.Tooltip, { label: edit, openDelay: 1000, position: "right", withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, { "aria-label": edit, color: "gray", disabled: !!editingRow && editingRow.id !== row.id, onClick: handleStartEditMode, size: "md", variant: "subtle", children: jsxRuntime.jsx(IconEdit, {}) }) })) : renderRowActionMenuItems ? (jsxRuntime.jsx(MRT_RowActionMenu, { handleEdit: handleStartEditMode, row: row, table: table })) : null }));
1626
+ };
1627
+
1628
+ var classes$q = {"root":"MRT_TableFooter-module_root__-JXpw","grid":"MRT_TableFooter-module_grid__J3Ga-","sticky":"MRT_TableFooter-module_sticky__GcoK6"};
1629
+
1630
+ var classes$p = {"root":"MRT_TableFooterRow-module_root__EuoPr","layout-mode-grid":"MRT_TableFooterRow-module_layout-mode-grid__dUEMF"};
1631
+
1632
+ var classes$o = {"root":"MRT_TableFooterCell-module_root__d8Scs","grid":"MRT_TableFooterCell-module_grid__H9jLk","group":"MRT_TableFooterCell-module_group__l3-p-"};
1633
+
1634
+ const MRT_TableFooterCell = (_a) => {
1635
+ var _b, _c, _d, _e, _f;
1636
+ var { footer: footerProp, renderedColumnIndex, table } = _a, rest = __rest(_a, ["footer", "renderedColumnIndex", "table"]);
1637
+ //a view has a new identity per table reference, which compiled render callbacks need
1638
+ const footer = getMRT_HeaderView(table, footerProp);
1639
+ const direction = core.useDirection();
1640
+ const { options: { enableColumnPinning, layoutMode, mantineTableFooterCellProps }, } = table;
1641
+ const { column } = footer;
1642
+ const { columnDef } = column;
1643
+ const { columnDefType } = columnDef;
1644
+ const isColumnPinned = enableColumnPinning &&
1645
+ columnDef.columnDefType !== 'group' &&
1646
+ column.getIsPinned();
1647
+ const args = { column, table };
1648
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.mantineTableFooterCellProps, args)), rest);
1649
+ const widthStyles = {
1650
+ minWidth: `max(calc(var(--header-${parseCSSVarId(footer === null || footer === void 0 ? void 0 : footer.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
1651
+ width: `calc(var(--header-${parseCSSVarId(footer.id)}-size) * 1px)`,
1652
+ };
1653
+ if (layoutMode === 'grid') {
1654
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
1655
+ ? 0
1656
+ : `var(--header-${parseCSSVarId(footer.id)}-size)`} 0 auto`;
1657
+ }
1658
+ else if (layoutMode === 'grid-no-grow') {
1659
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
1660
+ }
1661
+ return (jsxRuntime.jsx(core.TableTh, Object.assign({ colSpan: footer.colSpan, "data-column-pinned": isColumnPinned || undefined, "data-first-right-pinned": (isColumnPinned === 'right' &&
1662
+ column.getIsFirstColumn(isColumnPinned)) ||
1663
+ undefined, "data-index": renderedColumnIndex, "data-last-left-pinned": (isColumnPinned === 'left' && column.getIsLastColumn(isColumnPinned)) ||
1664
+ undefined }, tableCellProps, { __vars: Object.assign({ '--mrt-cell-align': (_c = tableCellProps.align) !== null && _c !== void 0 ? _c : (columnDefType === 'group'
1665
+ ? 'center'
1666
+ : direction.dir === 'rtl'
1667
+ ? 'right'
1668
+ : 'left'), '--mrt-table-cell-left': isColumnPinned === 'left'
1669
+ ? `${column.getStart(isColumnPinned)}`
1670
+ : undefined, '--mrt-table-cell-right': isColumnPinned === 'right'
1671
+ ? `${column.getAfter(isColumnPinned)}`
1672
+ : undefined }, tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.__vars), className: clsx(classes$o.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$o.grid, columnDefType === 'group' && classes$o.group, tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.className), style: (theme) => (Object.assign(Object.assign({}, widthStyles), parseFromValuesOrFunc(tableCellProps.style, theme))), children: (_d = tableCellProps.children) !== null && _d !== void 0 ? _d : (footer.isPlaceholder
1673
+ ? null
1674
+ : ((_f = (_e = parseFromValuesOrFunc(columnDef.Footer, {
1675
+ column,
1676
+ footer,
1677
+ table,
1678
+ })) !== null && _e !== void 0 ? _e : columnDef.footer) !== null && _f !== void 0 ? _f : null)) })));
1679
+ };
1680
+
1681
+ const MRT_TableFooterRow = (_a) => {
1682
+ var _b, _c;
1683
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
1684
+ const { options: { layoutMode, mantineTableFooterRowProps }, } = table;
1685
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
1686
+ // if no content in row, skip row
1687
+ if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
1688
+ !!header.column.columnDef.footer) ||
1689
+ header.column.columnDef.Footer))) {
1690
+ return null;
1691
+ }
1692
+ const virtualGroupFooters = getVirtualGroupHeaders({
1693
+ headers: footerGroup.headers,
1694
+ table,
1695
+ virtualColumns,
1696
+ });
1697
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableFooterRowProps, {
1698
+ footerGroup,
1699
+ table,
1700
+ })), rest);
1701
+ return (jsxRuntime.jsxs(core.TableTr, Object.assign({ className: clsx(classes$p.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$p['layout-mode-grid']) }, tableRowProps, { children: [virtualPaddingLeft ? (jsxRuntime.jsx(core.Box, { component: "th", display: "flex", w: virtualPaddingLeft })) : null, (_c = virtualGroupFooters === null || virtualGroupFooters === void 0 ? void 0 : virtualGroupFooters.map(({ header, index, style }) => (jsxRuntime.jsx(MRT_TableFooterCell, { footer: header, renderedColumnIndex: index, style: style, table: table }, header.id)))) !== null && _c !== void 0 ? _c : (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter, renderedColumnIndex) => {
1702
+ let footer = footerOrVirtualFooter;
1703
+ if (columnVirtualizer) {
1704
+ renderedColumnIndex = footerOrVirtualFooter
1705
+ .index;
1706
+ footer = footerGroup.headers[renderedColumnIndex];
1707
+ }
1708
+ return (jsxRuntime.jsx(MRT_TableFooterCell, { footer: footer, renderedColumnIndex: renderedColumnIndex, table: table }, footer.id));
1709
+ }), virtualPaddingRight ? (jsxRuntime.jsx(core.Box, { component: "th", display: "flex", w: virtualPaddingRight })) : null] })));
1710
+ };
1711
+
1712
+ const MRT_TableFooter = (_a) => {
1713
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
1714
+ const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, mantineTableFooterProps }, refs: { tableFooterRef }, } = table;
1715
+ const { isFullScreen } = getState();
1716
+ const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableFooterProps, {
1717
+ table,
1718
+ })), rest);
1719
+ const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
1720
+ return (jsxRuntime.jsx(core.TableTfoot, Object.assign({}, tableFooterProps, { className: clsx(classes$q.root, tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.className, stickFooter && classes$q.sticky, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$q.grid), ref: (ref) => {
1721
+ tableFooterRef.current = ref;
1722
+ assignRef(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref, ref);
1723
+ }, children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
1724
+ };
1725
+
1726
+ var classes$n = {"root":"MRT_TableHead-module_root__j9NkO","root-grid":"MRT_TableHead-module_root-grid__c3aGl","root-table-row-group":"MRT_TableHead-module_root-table-row-group__d9FO4","root-sticky":"MRT_TableHead-module_root-sticky__0kuDE","banner-tr":"MRT_TableHead-module_banner-tr__EhT-x","banner-th":"MRT_TableHead-module_banner-th__KwM5a","grid":"MRT_TableHead-module_grid__OJ-td"};
1727
+
1728
+ var classes$m = {"root":"MRT_TableHeadRow-module_root__hUKv4","layout-mode-grid":"MRT_TableHeadRow-module_layout-mode-grid__4ZGri","sticky":"MRT_TableHeadRow-module_sticky__Ej7Ax"};
1729
+
1730
+ var classes$l = {"root":"MRT_TableHeadCell-module_root__6y50a","root-grid":"MRT_TableHeadCell-module_root-grid__bAf1d","root-virtualized":"MRT_TableHeadCell-module_root-virtualized__CWLit","root-no-select":"MRT_TableHeadCell-module_root-no-select__BEOVU","content":"MRT_TableHeadCell-module_content__-pzSK","content-spaced":"MRT_TableHeadCell-module_content-spaced__S85Aa","content-center":"MRT_TableHeadCell-module_content-center__c-17L","content-right":"MRT_TableHeadCell-module_content-right__NSRZU","content-wrapper":"MRT_TableHeadCell-module_content-wrapper__py6aJ","content-wrapper-hidden-overflow":"MRT_TableHeadCell-module_content-wrapper-hidden-overflow__QY40r","content-wrapper-nowrap":"MRT_TableHeadCell-module_content-wrapper-nowrap__-4aIg","labels":"MRT_TableHeadCell-module_labels__oiMSr","labels-right":"MRT_TableHeadCell-module_labels-right__6ZJp-","labels-center":"MRT_TableHeadCell-module_labels-center__MM9q8","labels-sortable":"MRT_TableHeadCell-module_labels-sortable__tyuLr","labels-data":"MRT_TableHeadCell-module_labels-data__PvFGO","content-actions":"MRT_TableHeadCell-module_content-actions__utxbm"};
1731
+
1732
+ var classes$k = {"filter-mode-label":"MRT_TableHeadCellFilterContainer-module_filter-mode-label__8reK-"};
1733
+
1734
+ //the multi-select filter input clears itself to an empty array, which must remove the filter like '' does
1735
+ const isBlankFilterValue = (val) => !val || (Array.isArray(val) && !val.length);
1736
+ /**
1737
+ * Mantine 8+ date inputs emit 'YYYY-MM-DD' strings. When the cell value is a
1738
+ * Date, the filter value is read as a Date at local midnight, so the two
1739
+ * compare as dates and not as text.
1740
+ */
1741
+ const getDateFilterValue = (cellValue, filterValue) => {
1742
+ if (!(cellValue instanceof Date))
1743
+ return undefined;
1744
+ if (filterValue instanceof Date)
1745
+ return filterValue;
1746
+ if (typeof filterValue !== 'string' || !filterValue)
1747
+ return undefined;
1748
+ const date = new Date(filterValue.includes('T') ? filterValue : `${filterValue}T00:00:00`);
1749
+ return isNaN(+date) ? undefined : date;
1750
+ };
1751
+ //a date filter picks a day, so dates compare by their local day and not by time
1752
+ const getDay = (date) => new Date(date).setHours(0, 0, 0, 0);
1753
+ const fuzzy = (row, columnId, filterValue, addMeta) => {
1754
+ const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), filterValue, {
1755
+ threshold: matchSorterUtils.rankings.MATCHES,
1756
+ });
1757
+ addMeta(itemRank);
1758
+ return itemRank.passed;
1759
+ };
1760
+ fuzzy.autoRemove = isBlankFilterValue;
1761
+ const contains = (row, id, filterValue) => {
1762
+ var _a;
1763
+ return (_a = row
1764
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim());
1765
+ };
1766
+ contains.autoRemove = isBlankFilterValue;
1767
+ const startsWith = (row, id, filterValue) => {
1768
+ var _a;
1769
+ return (_a = row
1770
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim());
1771
+ };
1772
+ startsWith.autoRemove = isBlankFilterValue;
1773
+ const endsWith = (row, id, filterValue) => {
1774
+ var _a;
1775
+ return (_a = row
1776
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim());
1777
+ };
1778
+ endsWith.autoRemove = isBlankFilterValue;
1779
+ const equals = (row, id, filterValue) => {
1780
+ var _a;
1781
+ const dateFilterValue = getDateFilterValue(row.getValue(id), filterValue);
1782
+ if (dateFilterValue) {
1783
+ return getDay(row.getValue(id)) === getDay(dateFilterValue);
1784
+ }
1785
+ return (((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
1786
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim()));
1787
+ };
1788
+ equals.autoRemove = isBlankFilterValue;
1789
+ const notEquals = (row, id, filterValue) => !equals(row, id, filterValue);
1790
+ notEquals.autoRemove = isBlankFilterValue;
1791
+ const greaterThan = (row, id, rawFilterValue) => {
1792
+ var _a;
1793
+ const dateFilterValue = getDateFilterValue(row.getValue(id), rawFilterValue);
1794
+ if (dateFilterValue) {
1795
+ return getDay(row.getValue(id)) > getDay(dateFilterValue);
1796
+ }
1797
+ const filterValue = rawFilterValue;
1798
+ return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
1799
+ ? +row.getValue(id) > +filterValue
1800
+ : ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) >
1801
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
1802
+ };
1803
+ greaterThan.autoRemove = isBlankFilterValue;
1804
+ const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
1805
+ greaterThanOrEqualTo.autoRemove = isBlankFilterValue;
1806
+ const lessThan = (row, id, rawFilterValue) => {
1807
+ var _a;
1808
+ const dateFilterValue = getDateFilterValue(row.getValue(id), rawFilterValue);
1809
+ if (dateFilterValue) {
1810
+ return getDay(row.getValue(id)) < getDay(dateFilterValue);
1811
+ }
1812
+ const filterValue = rawFilterValue;
1813
+ return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
1814
+ ? +row.getValue(id) < +filterValue
1815
+ : ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) <
1816
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
1817
+ };
1818
+ lessThan.autoRemove = isBlankFilterValue;
1819
+ const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
1820
+ lessThanOrEqualTo.autoRemove = isBlankFilterValue;
1821
+ const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
1822
+ greaterThan(row, id, filterValues[0])) &&
1823
+ ((!isNaN(+filterValues[0]) &&
1824
+ !isNaN(+filterValues[1]) &&
1825
+ +filterValues[0] > +filterValues[1]) ||
1826
+ ['', undefined].includes(filterValues[1]) ||
1827
+ lessThan(row, id, filterValues[1]));
1828
+ between.autoRemove = isBlankFilterValue;
1829
+ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
1830
+ greaterThanOrEqualTo(row, id, filterValues[0])) &&
1831
+ ((!isNaN(+filterValues[0]) &&
1832
+ !isNaN(+filterValues[1]) &&
1833
+ +filterValues[0] > +filterValues[1]) ||
1834
+ ['', undefined].includes(filterValues[1]) ||
1835
+ lessThanOrEqualTo(row, id, filterValues[1]));
1836
+ betweenInclusive.autoRemove = isBlankFilterValue;
1837
+ const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
1838
+ empty.autoRemove = isBlankFilterValue;
1839
+ const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
1840
+ notEmpty.autoRemove = isBlankFilterValue;
1841
+ const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { between,
1842
+ betweenInclusive,
1843
+ contains,
1844
+ empty,
1845
+ endsWith,
1846
+ equals,
1847
+ fuzzy,
1848
+ greaterThan,
1849
+ greaterThanOrEqualTo,
1850
+ lessThan,
1851
+ lessThanOrEqualTo,
1852
+ notEmpty,
1853
+ notEquals,
1854
+ startsWith });
1855
+ function localizedFilterOption(localization, option) {
1856
+ var _a;
1857
+ if (!option) {
1858
+ return '';
1859
+ }
1860
+ const key = `filter${option[0].toUpperCase()}${option.slice(1)}`;
1861
+ return (_a = localization[key]) !== null && _a !== void 0 ? _a : '';
1862
+ }
1863
+
1864
+ var classes$j = {"root":"MRT_FilterCheckBox-module_root__59h9r"};
1865
+
1866
+ const MRT_FilterCheckbox = (_a) => {
1867
+ var _b, _c, _d;
1868
+ var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
1869
+ const { getState, options: { localization, mantineFilterCheckboxProps }, } = table;
1870
+ const { density } = getState();
1871
+ const { columnDef } = column;
1872
+ const arg = { column, table };
1873
+ const checkboxProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineFilterCheckboxProps, arg)), parseFromValuesOrFunc(columnDef.mantineFilterCheckboxProps, arg)), rest);
1874
+ const filterLabel = (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', columnDef.header);
1875
+ const value = column.getFilterValue();
1876
+ return (jsxRuntime.jsx(core.Tooltip, { label: (_c = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.Checkbox, Object.assign({ checked: value === 'true', className: clsx('mrt-filter-checkbox', classes$j.root), indeterminate: value === undefined, label: (_d = checkboxProps.title) !== null && _d !== void 0 ? _d : filterLabel, size: density === 'xs' ? 'sm' : 'md' }, checkboxProps, { onChange: (e) => {
1877
+ var _a;
1878
+ column.setFilterValue(column.getFilterValue() === undefined
1879
+ ? 'true'
1880
+ : column.getFilterValue() === 'true'
1881
+ ? 'false'
1882
+ : undefined);
1883
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
1884
+ }, onClick: (e) => {
1885
+ var _a;
1886
+ e.stopPropagation();
1887
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
1888
+ }, title: undefined })) }));
1889
+ };
1890
+
1891
+ var classes$i = {"root":"MRT_FilterRangeFields-module_root__KfCcg"};
1892
+
1893
+ var classes$h = {"root":"MRT_FilterTextInput-module_root__Ss8Ql","date-filter":"MRT_FilterTextInput-module_date-filter__jOBLB","range-filter":"MRT_FilterTextInput-module_range-filter__JQHAL","not-filter-chip":"MRT_FilterTextInput-module_not-filter-chip__u8b1y","filter-chip-badge":"MRT_FilterTextInput-module_filter-chip-badge__Sel2k"};
1894
+
1895
+ const MRT_FilterTextInput = (_a) => {
1896
+ var _b, _c, _d, _e, _f, _g, _h, _j;
1897
+ var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
1898
+ const { options: { columnFilterDisplayMode, columnFilterModeOptions, icons: { IconX }, localization, mantineFilterAutocompleteProps, mantineFilterDateInputProps, mantineFilterMultiSelectProps = {
1899
+ clearable: true,
1900
+ }, mantineFilterSelectProps, mantineFilterTextInputProps, manualFiltering, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
1901
+ const { column } = header;
1902
+ const { columnDef } = column;
1903
+ const arg = { column, rangeFilterIndex, table };
1904
+ const textInputProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineFilterTextInputProps, arg)), parseFromValuesOrFunc(columnDef.mantineFilterTextInputProps, arg)), rest);
1905
+ const selectProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineFilterSelectProps, arg)), parseFromValuesOrFunc(columnDef.mantineFilterSelectProps, arg));
1906
+ const multiSelectProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineFilterMultiSelectProps, arg)), parseFromValuesOrFunc(columnDef.mantineFilterMultiSelectProps, arg));
1907
+ const dateInputProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineFilterDateInputProps, arg)), parseFromValuesOrFunc(columnDef.mantineFilterDateInputProps, arg));
1908
+ const autoCompleteProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineFilterAutocompleteProps, arg)), parseFromValuesOrFunc(columnDef.mantineFilterAutocompleteProps, arg));
1909
+ const isRangeFilter = columnDef.filterVariant === 'range' ||
1910
+ columnDef.filterVariant === 'date-range' ||
1911
+ rangeFilterIndex !== undefined;
1912
+ const isSelectFilter = columnDef.filterVariant === 'select';
1913
+ const isMultiSelectFilter = columnDef.filterVariant === 'multi-select';
1914
+ const isDateFilter = columnDef.filterVariant === 'date' ||
1915
+ columnDef.filterVariant === 'date-range';
1916
+ const isAutoCompleteFilter = columnDef.filterVariant === 'autocomplete';
1917
+ const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
1918
+ const currentFilterOption = columnDef._filterFn;
1919
+ const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
1920
+ ? localizedFilterOption(localization, currentFilterOption)
1921
+ : '';
1922
+ const filterPlaceholder = !isRangeFilter
1923
+ ? ((_c = textInputProps === null || textInputProps === void 0 ? void 0 : textInputProps.placeholder) !== null && _c !== void 0 ? _c : (_d = localization.filterByColumn) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)))
1924
+ : rangeFilterIndex === 0
1925
+ ? localization.min
1926
+ : rangeFilterIndex === 1
1927
+ ? localization.max
1928
+ : '';
1929
+ const facetedUniqueValues = column.getFacetedUniqueValues();
1930
+ const filterSelectOptions = react.useMemo(() => {
1931
+ var _a, _b, _c;
1932
+ return ((_c = (_b = (_a = autoCompleteProps === null || autoCompleteProps === void 0 ? void 0 : autoCompleteProps.data) !== null && _a !== void 0 ? _a : selectProps === null || selectProps === void 0 ? void 0 : selectProps.data) !== null && _b !== void 0 ? _b : multiSelectProps === null || multiSelectProps === void 0 ? void 0 : multiSelectProps.data) !== null && _c !== void 0 ? _c : ((isAutoCompleteFilter || isSelectFilter || isMultiSelectFilter) &&
1933
+ facetedUniqueValues
1934
+ ? Array.from(facetedUniqueValues.keys())
1935
+ .filter((key) => key !== null)
1936
+ .sort((a, b) => a.localeCompare(b))
1937
+ : []))
1938
+ //@ts-ignore
1939
+ .filter((o) => o !== undefined && o !== null);
1940
+ }, [
1941
+ autoCompleteProps === null || autoCompleteProps === void 0 ? void 0 : autoCompleteProps.data,
1942
+ facetedUniqueValues,
1943
+ isAutoCompleteFilter,
1944
+ isMultiSelectFilter,
1945
+ isSelectFilter,
1946
+ multiSelectProps === null || multiSelectProps === void 0 ? void 0 : multiSelectProps.data,
1947
+ selectProps === null || selectProps === void 0 ? void 0 : selectProps.data,
1948
+ ]);
1949
+ const isMounted = react.useRef(false);
1950
+ const [filterValue, setFilterValue] = react.useState(() => {
1951
+ var _a, _b;
1952
+ return isMultiSelectFilter
1953
+ ? column.getFilterValue() || []
1954
+ : isRangeFilter
1955
+ ? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
1956
+ : ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
1957
+ });
1958
+ //the range value of this input that the table last held. The other range input
1959
+ //changes the same filter array, and that must not reset text typed here.
1960
+ const tableRangeValue = react.useRef(isRangeFilter ? filterValue : '');
1961
+ //send filterValue to the table instance once typing pauses. The timer restarts
1962
+ //on every change, so text retyped right after a clear is sent again.
1963
+ react.useEffect(() => {
1964
+ if (!isMounted.current)
1965
+ return;
1966
+ const timeout = setTimeout(() => {
1967
+ if (isRangeFilter) {
1968
+ column.setFilterValue((old) => {
1969
+ const newFilterValues = Array.isArray(old) ? [...old] : ['', '']; //a copy: the previous filter value is table state
1970
+ newFilterValues[rangeFilterIndex] = filterValue;
1971
+ return newFilterValues;
1972
+ });
1973
+ }
1974
+ else {
1975
+ column.setFilterValue(filterValue !== null && filterValue !== void 0 ? filterValue : undefined);
1976
+ }
1977
+ }, manualFiltering ? 400 : 200);
1978
+ return () => clearTimeout(timeout);
1979
+ }, [filterValue]);
1980
+ //receive table filter value and set it to local state
1981
+ react.useEffect(() => {
1982
+ var _a;
1983
+ if (!isMounted.current) {
1984
+ isMounted.current = true;
1985
+ return;
1986
+ }
1987
+ const tableFilterValue = column.getFilterValue();
1988
+ if (tableFilterValue === undefined) {
1989
+ tableRangeValue.current = '';
1990
+ handleClear();
1991
+ }
1992
+ else if (isRangeFilter && rangeFilterIndex !== undefined) {
1993
+ const next = (_a = (tableFilterValue !== null && tableFilterValue !== void 0 ? tableFilterValue : ['', ''])[rangeFilterIndex]) !== null && _a !== void 0 ? _a : '';
1994
+ if (next !== tableRangeValue.current) {
1995
+ tableRangeValue.current = next;
1996
+ setFilterValue(next);
1997
+ }
1998
+ }
1999
+ else {
2000
+ setFilterValue(tableFilterValue !== null && tableFilterValue !== void 0 ? tableFilterValue : '');
2001
+ }
2002
+ }, [column.getFilterValue()]);
2003
+ const handleClear = () => {
2004
+ if (isMultiSelectFilter) {
2005
+ setFilterValue([]);
2006
+ column.setFilterValue([]);
2007
+ }
2008
+ else if (isRangeFilter) {
2009
+ setFilterValue('');
2010
+ column.setFilterValue((old) => {
2011
+ const newFilterValues = Array.isArray(old) ? [...old] : ['', '']; //a copy: the previous filter value is table state
2012
+ newFilterValues[rangeFilterIndex] = undefined;
2013
+ return newFilterValues;
2014
+ });
2015
+ // This is from Mantine v6 but it also applies for v7
2016
+ // https://github.com/mantinedev/mantine/issues/4716#issuecomment-1702699688
2017
+ }
2018
+ else if (isSelectFilter) {
2019
+ setFilterValue(null);
2020
+ column.setFilterValue(null);
2021
+ }
2022
+ else {
2023
+ setFilterValue('');
2024
+ column.setFilterValue(undefined);
2025
+ }
2026
+ };
2027
+ const handleClearEmptyFilterChip = () => {
2028
+ if (isMultiSelectFilter) {
2029
+ setFilterValue([]);
2030
+ column.setFilterValue([]);
2031
+ }
2032
+ else {
2033
+ setFilterValue('');
2034
+ column.setFilterValue(undefined);
2035
+ }
2036
+ setColumnFilterFns((prev) => {
2037
+ var _a;
2038
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
2039
+ });
2040
+ };
2041
+ const _k = {
2042
+ 'aria-label': filterPlaceholder,
2043
+ className: clsx('mrt-filter-text-input', classes$h.root, isDateFilter
2044
+ ? classes$h['date-filter']
2045
+ : isRangeFilter
2046
+ ? classes$h['range-filter']
2047
+ : !filterChipLabel && classes$h['not-filter-chip']),
2048
+ disabled: !!filterChipLabel,
2049
+ onChange: setFilterValue,
2050
+ onClick: (event) => event.stopPropagation(),
2051
+ placeholder: filterPlaceholder,
2052
+ style: Object.assign({}, (isMultiSelectFilter
2053
+ ? multiSelectProps === null || multiSelectProps === void 0 ? void 0 : multiSelectProps.style
2054
+ : isSelectFilter
2055
+ ? selectProps === null || selectProps === void 0 ? void 0 : selectProps.style
2056
+ : isDateFilter
2057
+ ? dateInputProps === null || dateInputProps === void 0 ? void 0 : dateInputProps.style
2058
+ : textInputProps === null || textInputProps === void 0 ? void 0 : textInputProps.style)),
2059
+ title: filterPlaceholder,
2060
+ value: isMultiSelectFilter && !Array.isArray(filterValue) ? [] : filterValue,
2061
+ variant: 'unstyled',
2062
+ }, { className } = _k, commonProps = __rest(_k, ["className"]);
2063
+ const ClearButton = filterValue ? (jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.clearFilter, color: "var(--mantine-color-gray-7)", onClick: handleClear, size: "sm", title: (_e = localization.clearFilter) !== null && _e !== void 0 ? _e : '', variant: "transparent", children: jsxRuntime.jsx(IconX, {}) })) : null;
2064
+ if (columnDef.Filter) {
2065
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (_f = columnDef.Filter) === null || _f === void 0 ? void 0 : _f.call(columnDef, { column, header, rangeFilterIndex, table }) }));
2066
+ }
2067
+ if (filterChipLabel) {
2068
+ return (jsxRuntime.jsx(core.Box, { style: commonProps.style, children: jsxRuntime.jsx(core.Badge, { className: classes$h['filter-chip-badge'], onClick: handleClearEmptyFilterChip, rightSection: ClearButton, size: "lg", children: filterChipLabel }) }));
2069
+ }
2070
+ if (isMultiSelectFilter) {
2071
+ return (jsxRuntime.jsx(core.MultiSelect, Object.assign({}, commonProps, { searchable: true }, multiSelectProps, { className: clsx(className, multiSelectProps.className), data: filterSelectOptions, onChange: (value) => setFilterValue(value), ref: (node) => {
2072
+ if (node) {
2073
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
2074
+ node;
2075
+ assignRef(multiSelectProps.ref, node);
2076
+ }
2077
+ }, rightSection: ((_g = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _g === void 0 ? void 0 : _g.length) && (multiSelectProps === null || multiSelectProps === void 0 ? void 0 : multiSelectProps.clearable)
2078
+ ? ClearButton
2079
+ : undefined, style: commonProps.style })));
2080
+ }
2081
+ if (isSelectFilter) {
2082
+ return (jsxRuntime.jsx(core.Select, Object.assign({}, commonProps, { clearable: true, searchable: true }, selectProps, { className: clsx(className, selectProps.className), clearButtonProps: {
2083
+ size: 'md',
2084
+ }, data: filterSelectOptions, ref: (node) => {
2085
+ if (node) {
2086
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
2087
+ node;
2088
+ assignRef(selectProps.ref, node);
2089
+ }
2090
+ }, style: commonProps.style })));
2091
+ }
2092
+ if (isDateFilter) {
2093
+ return (jsxRuntime.jsx(dates.DateInput, Object.assign({}, commonProps, { allowDeselect: true, clearable: true, popoverProps: { withinPortal: columnFilterDisplayMode !== 'popover' } }, dateInputProps, { className: clsx(className, dateInputProps.className), onChange: (event) => commonProps.onChange(event === null ? '' : event), ref: (node) => {
2094
+ if (node) {
2095
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
2096
+ node;
2097
+ assignRef(dateInputProps.ref, node);
2098
+ }
2099
+ }, style: commonProps.style })));
2100
+ }
2101
+ if (isAutoCompleteFilter) {
2102
+ return (jsxRuntime.jsx(core.Autocomplete, Object.assign({}, commonProps, { onChange: (value) => setFilterValue(value), rightSection: ((_h = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _h === void 0 ? void 0 : _h.length) ? ClearButton : undefined }, autoCompleteProps, { className: clsx(className, autoCompleteProps.className), data: filterSelectOptions, ref: (node) => {
2103
+ if (node) {
2104
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
2105
+ node;
2106
+ assignRef(autoCompleteProps.ref, node);
2107
+ }
2108
+ }, style: commonProps.style })));
2109
+ }
2110
+ return (jsxRuntime.jsx(core.TextInput, Object.assign({}, commonProps, { onChange: (e) => setFilterValue(e.target.value), rightSection: ((_j = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _j === void 0 ? void 0 : _j.length) ? ClearButton : undefined }, textInputProps, { className: clsx(className, textInputProps.className), mt: 0, ref: (node) => {
2111
+ if (node) {
2112
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
2113
+ node;
2114
+ assignRef(textInputProps.ref, node);
2115
+ }
2116
+ }, style: commonProps.style })));
2117
+ };
2118
+
2119
+ const MRT_FilterRangeFields = (_a) => {
2120
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2121
+ return (jsxRuntime.jsxs(core.Box, Object.assign({}, rest, { className: clsx('mrt-filter-range-fields', classes$i.root, rest.className), children: [jsxRuntime.jsx(MRT_FilterTextInput, { header: header, rangeFilterIndex: 0, table: table }), jsxRuntime.jsx(MRT_FilterTextInput, { header: header, rangeFilterIndex: 1, table: table })] })));
2122
+ };
2123
+
2124
+ var classes$g = {"root":"MRT_FilterRangeSlider-module_root__uwYEk"};
2125
+
2126
+ const MRT_FilterRangeSlider = (_a) => {
2127
+ var _b;
2128
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2129
+ const { options: { mantineFilterRangeSliderProps }, refs: { filterInputRefs }, } = table;
2130
+ const { column } = header;
2131
+ const { columnDef } = column;
2132
+ const arg = { column, table };
2133
+ const rangeSliderProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineFilterRangeSliderProps, arg)), parseFromValuesOrFunc(columnDef.mantineFilterRangeSliderProps, arg)), rest);
2134
+ let [min, max] = rangeSliderProps.min !== undefined && rangeSliderProps.max !== undefined
2135
+ ? [rangeSliderProps.min, rangeSliderProps.max]
2136
+ : ((_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1]);
2137
+ //fix potential TanStack Table bugs where min or max is an array
2138
+ if (Array.isArray(min))
2139
+ min = min[0];
2140
+ if (Array.isArray(max))
2141
+ max = max[0];
2142
+ if (min === null)
2143
+ min = 0;
2144
+ if (max === null)
2145
+ max = 1;
2146
+ const [filterValues, setFilterValues] = react.useState([
2147
+ min,
2148
+ max,
2149
+ ]);
2150
+ const columnFilterValue = column.getFilterValue();
2151
+ const isMounted = react.useRef(false);
2152
+ react.useEffect(() => {
2153
+ if (isMounted.current) {
2154
+ if (columnFilterValue === undefined) {
2155
+ setFilterValues([min, max]);
2156
+ }
2157
+ else if (Array.isArray(columnFilterValue)) {
2158
+ setFilterValues(columnFilterValue);
2159
+ }
2160
+ }
2161
+ isMounted.current = true;
2162
+ }, [columnFilterValue, min, max]);
2163
+ return (jsxRuntime.jsx(core.RangeSlider, Object.assign({ className: clsx('mrt-filter-range-slider', classes$g.root), max: max, min: min, onChange: (values) => {
2164
+ setFilterValues(values);
2165
+ }, onChangeEnd: (values) => {
2166
+ if (Array.isArray(values)) {
2167
+ if (values[0] <= min && values[1] >= max) {
2168
+ //if the user has selected the entire range, remove the filter
2169
+ column.setFilterValue(undefined);
2170
+ }
2171
+ else {
2172
+ column.setFilterValue(values);
2173
+ }
2174
+ }
2175
+ }, value: filterValues }, rangeSliderProps, { ref: (node) => {
2176
+ if (node) {
2177
+ //@ts-ignore
2178
+ filterInputRefs.current[`${column.id}-0`] = node;
2179
+ // @ts-ignore
2180
+ if (rangeSliderProps === null || rangeSliderProps === void 0 ? void 0 : rangeSliderProps.ref) {
2181
+ //@ts-ignore
2182
+ rangeSliderProps.ref = node;
2183
+ }
2184
+ }
2185
+ } })));
2186
+ };
2187
+
2188
+ var classes$f = {"symbol":"MRT_FilterOptionMenu-module_symbol__a1Bsy"};
2189
+
2190
+ const mrtFilterOptions = (localization) => [
2191
+ {
2192
+ divider: false,
2193
+ label: localization.filterFuzzy,
2194
+ option: 'fuzzy',
2195
+ symbol: '≈',
2196
+ },
2197
+ {
2198
+ divider: false,
2199
+ label: localization.filterContains,
2200
+ option: 'contains',
2201
+ symbol: '*',
2202
+ },
2203
+ {
2204
+ divider: false,
2205
+ label: localization.filterStartsWith,
2206
+ option: 'startsWith',
2207
+ symbol: 'a',
2208
+ },
2209
+ {
2210
+ divider: true,
2211
+ label: localization.filterEndsWith,
2212
+ option: 'endsWith',
2213
+ symbol: 'z',
2214
+ },
2215
+ {
2216
+ divider: false,
2217
+ label: localization.filterEquals,
2218
+ option: 'equals',
2219
+ symbol: '=',
2220
+ },
2221
+ {
2222
+ divider: true,
2223
+ label: localization.filterNotEquals,
2224
+ option: 'notEquals',
2225
+ symbol: '≠',
2226
+ },
2227
+ {
2228
+ divider: false,
2229
+ label: localization.filterBetween,
2230
+ option: 'between',
2231
+ symbol: '⇿',
2232
+ },
2233
+ {
2234
+ divider: true,
2235
+ label: localization.filterBetweenInclusive,
2236
+ option: 'betweenInclusive',
2237
+ symbol: '⬌',
2238
+ },
2239
+ {
2240
+ divider: false,
2241
+ label: localization.filterGreaterThan,
2242
+ option: 'greaterThan',
2243
+ symbol: '>',
2244
+ },
2245
+ {
2246
+ divider: false,
2247
+ label: localization.filterGreaterThanOrEqualTo,
2248
+ option: 'greaterThanOrEqualTo',
2249
+ symbol: '≥',
2250
+ },
2251
+ {
2252
+ divider: false,
2253
+ label: localization.filterLessThan,
2254
+ option: 'lessThan',
2255
+ symbol: '<',
2256
+ },
2257
+ {
2258
+ divider: true,
2259
+ label: localization.filterLessThanOrEqualTo,
2260
+ option: 'lessThanOrEqualTo',
2261
+ symbol: '≤',
2262
+ },
2263
+ {
2264
+ divider: false,
2265
+ label: localization.filterEmpty,
2266
+ option: 'empty',
2267
+ symbol: '∅',
2268
+ },
2269
+ {
2270
+ divider: false,
2271
+ label: localization.filterNotEmpty,
2272
+ option: 'notEmpty',
2273
+ symbol: '!∅',
2274
+ },
2275
+ ];
2276
+ const defaultGlobalFilterModeOptions = ['fuzzy', 'contains', 'startsWith'];
2277
+ const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
2278
+ const emptyModes = ['empty', 'notEmpty'];
2279
+ const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
2280
+ const rangeVariants = ['range-slider', 'date-range', 'range'];
2281
+ const MRT_FilterOptionMenu = ({ header, onSelect, table, }) => {
2282
+ var _a, _b, _c, _d;
2283
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
2284
+ const { globalFilterFn } = getState();
2285
+ const { column } = header !== null && header !== void 0 ? header : {};
2286
+ const { columnDef } = column !== null && column !== void 0 ? column : {};
2287
+ const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
2288
+ let allowedColumnFilterOptions = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _a !== void 0 ? _a : columnFilterModeOptions;
2289
+ if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
2290
+ allowedColumnFilterOptions = [
2291
+ ...rangeModes,
2292
+ ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
2293
+ ].filter((option) => rangeModes.includes(option));
2294
+ }
2295
+ const internalFilterOptions = react.useMemo(() => {
2296
+ const filterOptions = mrtFilterOptions(localization).filter((filterOption) => columnDef
2297
+ ? allowedColumnFilterOptions === undefined ||
2298
+ (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
2299
+ : (globalFilterModeOptions !== null && globalFilterModeOptions !== void 0 ? globalFilterModeOptions : defaultGlobalFilterModeOptions).includes(filterOption.option));
2300
+ if (filterOptions.length &&
2301
+ filterOptions[filterOptions.length - 1].divider) {
2302
+ filterOptions[filterOptions.length - 1].divider = false;
2303
+ }
2304
+ return filterOptions;
2305
+ }, [columnDef, globalFilterModeOptions]);
2306
+ const handleSelectFilterMode = (option) => {
2307
+ var _a;
2308
+ const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
2309
+ if (!header || !column) {
2310
+ // global filter mode
2311
+ setGlobalFilterFn(option);
2312
+ }
2313
+ else if (option !== prevFilterMode) {
2314
+ // column filter mode
2315
+ setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
2316
+ // reset filter value and/or perform new filter render
2317
+ if (emptyModes.includes(option)) {
2318
+ // will now be empty/notEmpty filter mode
2319
+ if (currentFilterValue !== ' ' &&
2320
+ !emptyModes.includes(prevFilterMode)) {
2321
+ column.setFilterValue(' ');
2322
+ }
2323
+ else if (currentFilterValue) {
2324
+ column.setFilterValue(currentFilterValue); // perform new filter render
2325
+ }
2326
+ }
2327
+ else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
2328
+ arrModes.includes(option)) {
2329
+ // will now be array filter mode
2330
+ if (currentFilterValue instanceof String ||
2331
+ (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
2332
+ column.setFilterValue([]);
2333
+ }
2334
+ else if (currentFilterValue) {
2335
+ column.setFilterValue(currentFilterValue); // perform new filter render
2336
+ }
2337
+ }
2338
+ else if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) ||
2339
+ rangeModes.includes(option)) {
2340
+ // will now be range filter mode
2341
+ if (!Array.isArray(currentFilterValue) ||
2342
+ (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
2343
+ !rangeModes.includes(prevFilterMode))) {
2344
+ column.setFilterValue(['', '']);
2345
+ }
2346
+ else {
2347
+ column.setFilterValue(currentFilterValue); // perform new filter render
2348
+ }
2349
+ }
2350
+ else {
2351
+ // will now be single value filter mode
2352
+ if (Array.isArray(currentFilterValue)) {
2353
+ column.setFilterValue('');
2354
+ }
2355
+ else if (currentFilterValue === ' ' &&
2356
+ emptyModes.includes(prevFilterMode)) {
2357
+ column.setFilterValue(undefined);
2358
+ }
2359
+ else {
2360
+ column.setFilterValue(currentFilterValue); // perform new filter render
2361
+ }
2362
+ }
2363
+ }
2364
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
2365
+ };
2366
+ const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
2367
+ return (jsxRuntime.jsx(core.Menu.Dropdown, { children: (_d = (header && column && columnDef
2368
+ ? ((_c = (_b = columnDef.renderColumnFilterModeMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, {
2369
+ column: column,
2370
+ internalFilterOptions,
2371
+ onSelectFilterMode: handleSelectFilterMode,
2372
+ table,
2373
+ })) !== null && _c !== void 0 ? _c : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
2374
+ column: column,
2375
+ internalFilterOptions,
2376
+ onSelectFilterMode: handleSelectFilterMode,
2377
+ table,
2378
+ }))
2379
+ : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
2380
+ internalFilterOptions,
2381
+ onSelectFilterMode: handleSelectFilterMode,
2382
+ table,
2383
+ }))) !== null && _d !== void 0 ? _d : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxRuntime.jsxs(react.Fragment, { children: [jsxRuntime.jsx(core.Menu.Item, { color: option === filterOption ? 'blue' : undefined, leftSection: jsxRuntime.jsx("span", { className: classes$f.symbol, children: symbol }), onClick: () => handleSelectFilterMode(option), value: option, children: label }), divider && jsxRuntime.jsx(core.Menu.Divider, {})] }, index))) }));
2384
+ };
2385
+
2386
+ const MRT_TableHeadCellFilterContainer = (_a) => {
2387
+ var _b, _c;
2388
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2389
+ const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, icons: { IconFilterCog }, localization, }, refs: { filterInputRefs }, } = table;
2390
+ const { showColumnFilters } = getState();
2391
+ const { column } = header;
2392
+ const { columnDef } = column;
2393
+ const currentFilterOption = columnDef._filterFn;
2394
+ const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2395
+ const showChangeModeButton = enableColumnFilterModes &&
2396
+ columnDef.enableColumnFilterModes !== false &&
2397
+ (allowedColumnFilterOptions === undefined ||
2398
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
2399
+ return (jsxRuntime.jsx(core.Collapse, { expanded: showColumnFilters || columnFilterDisplayMode === 'popover', children: jsxRuntime.jsxs(core.Flex, Object.assign({ direction: "column" }, rest, { children: [jsxRuntime.jsxs(core.Flex, { align: "flex-end", children: [columnDef.filterVariant === 'checkbox' ? (jsxRuntime.jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsxRuntime.jsx(MRT_FilterRangeSlider, { header: header, table: table })) : ['date-range', 'range'].includes((_c = columnDef.filterVariant) !== null && _c !== void 0 ? _c : '') ||
2400
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn) ? (jsxRuntime.jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsxRuntime.jsx(MRT_FilterTextInput, { header: header, table: table })), showChangeModeButton && (jsxRuntime.jsxs(core.Menu, { withinPortal: columnFilterDisplayMode !== 'popover', children: [jsxRuntime.jsx(core.Tooltip, { label: localization.changeFilterMode, position: "bottom-start", withinPortal: true, children: jsxRuntime.jsx(core.Menu.Target, { children: jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.changeFilterMode, color: "gray", size: "md", variant: "subtle", children: jsxRuntime.jsx(IconFilterCog, {}) }) }) }), jsxRuntime.jsx(MRT_FilterOptionMenu, { header: header, onSelect: () => setTimeout(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); }, 100), table: table })] }))] }), showChangeModeButton ? (jsxRuntime.jsx(core.Text, { c: "dimmed", className: classes$k['filter-mode-label'], component: "label", children: localization.filterMode.replace('{filterType}', localizedFilterOption(localization, currentFilterOption)) })) : null] })) }));
2401
+ };
2402
+
2403
+ var classes$e = {"root":"MRT_TableHeadCellFilterLabel-module_root__Rur2R"};
2404
+
2405
+ const MRT_TableHeadCellFilterLabel = (_a) => {
2406
+ var _b, _c, _d;
2407
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2408
+ const { options: { columnFilterDisplayMode, icons: { IconFilter }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
2409
+ const { column } = header;
2410
+ const { columnDef } = column;
2411
+ const filterValue = column.getFilterValue();
2412
+ const [popoverOpened, setPopoverOpened] = react.useState(false);
2413
+ const isFilterActive = (Array.isArray(filterValue) && filterValue.some(Boolean)) ||
2414
+ (!!filterValue && !Array.isArray(filterValue));
2415
+ const isRangeFilter = columnDef.filterVariant === 'range' ||
2416
+ columnDef.filterVariant === 'date-range' ||
2417
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
2418
+ const currentFilterOption = columnDef._filterFn;
2419
+ const filterValueFn = columnDef.filterTooltipValueFn || ((value) => value);
2420
+ const filterTooltip = columnFilterDisplayMode === 'popover' && !isFilterActive
2421
+ ? (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', String(columnDef.header))
2422
+ : localization.filteringByColumn
2423
+ .replace('{column}', String(columnDef.header))
2424
+ .replace('{filterType}', localizedFilterOption(localization, currentFilterOption))
2425
+ .replace('{filterValue}', `"${Array.isArray(column.getFilterValue())
2426
+ ? column.getFilterValue()
2427
+ .map((v) => filterValueFn(v))
2428
+ .join(`" ${isRangeFilter ? localization.and : localization.or} "`)
2429
+ : filterValueFn(column.getFilterValue())}"`)
2430
+ .replace('" "', '');
2431
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(core.Popover, { keepMounted: columnDef.filterVariant === 'range-slider', onChange: setPopoverOpened, onClose: () => setPopoverOpened(false), opened: popoverOpened, position: "top", shadow: "xl", width: 360, withinPortal: true, children: [jsxRuntime.jsx(core.Transition, { mounted: columnFilterDisplayMode === 'popover' ||
2432
+ (!!column.getFilterValue() && !isRangeFilter) ||
2433
+ (isRangeFilter &&
2434
+ (!!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[0]) ||
2435
+ !!((_d = column.getFilterValue()) === null || _d === void 0 ? void 0 : _d[1]))), transition: "scale", children: () => (jsxRuntime.jsx(core.Popover.Target, { children: jsxRuntime.jsx(core.Tooltip, { disabled: popoverOpened, label: filterTooltip, multiline: true, w: filterTooltip.length > 40 ? 300 : undefined, withinPortal: true, children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": filterTooltip, className: clsx('mrt-table-head-cell-filter-label-icon', classes$e.root), size: 18 }, dataVariable('active', isFilterActive), { onClick: (event) => {
2436
+ event.stopPropagation();
2437
+ if (columnFilterDisplayMode === 'popover') {
2438
+ setPopoverOpened((opened) => !opened);
2439
+ }
2440
+ else {
2441
+ setShowColumnFilters(true);
2442
+ }
2443
+ setTimeout(() => {
2444
+ const input = filterInputRefs.current[`${column.id}-0`];
2445
+ input === null || input === void 0 ? void 0 : input.focus();
2446
+ if (typeof (input === null || input === void 0 ? void 0 : input.select) === 'function') {
2447
+ input.select();
2448
+ }
2449
+ }, 100);
2450
+ } }, rest, { children: jsxRuntime.jsx(IconFilter, { size: "100%" }) })) }) })) }), columnFilterDisplayMode === 'popover' && (jsxRuntime.jsx(core.Popover.Dropdown, { onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.key === 'Enter' &&
2451
+ !event.nativeEvent.isComposing &&
2452
+ setPopoverOpened(false), onMouseDown: (event) => event.stopPropagation(), children: jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }))] }) }));
2453
+ };
2454
+
2455
+ const MRT_TableHeadCellGrabHandle = (_a) => {
2456
+ var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
2457
+ const { getState, options: { enableColumnOrdering, mantineColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
2458
+ const { columnDef } = column;
2459
+ const { columnOrder, draggingColumn, hoveredColumn } = getState();
2460
+ const arg = { column, table };
2461
+ const actionIconProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineColumnDragHandleProps, arg)), parseFromValuesOrFunc(columnDef.mantineColumnDragHandleProps, arg)), rest);
2462
+ const handleDragStart = (event) => {
2463
+ var _a;
2464
+ (_a = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(actionIconProps, event);
2465
+ setDraggingColumn(column);
2466
+ event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
2467
+ };
2468
+ const handleDragEnd = (event) => {
2469
+ var _a;
2470
+ (_a = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(actionIconProps, event);
2471
+ if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2472
+ column.toggleGrouping();
2473
+ }
2474
+ else if (enableColumnOrdering &&
2475
+ hoveredColumn &&
2476
+ (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
2477
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
2478
+ }
2479
+ setDraggingColumn(null);
2480
+ setHoveredColumn(null);
2481
+ };
2482
+ return (jsxRuntime.jsx(MRT_GrabHandleButton, { actionIconProps: actionIconProps, onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
2483
+ };
2484
+
2485
+ var classes$d = {"root":"MRT_TableHeadCellResizeHandle-module_root__paufe","root-ltr":"MRT_TableHeadCellResizeHandle-module_root-ltr__652AZ","root-rtl":"MRT_TableHeadCellResizeHandle-module_root-rtl__5VlSo","root-hide":"MRT_TableHeadCellResizeHandle-module_root-hide__-ILlD"};
2486
+
2487
+ const MRT_TableHeadCellResizeHandle = (_a) => {
2488
+ var _b;
2489
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2490
+ const { getState, options: { columnResizeDirection, columnResizeMode }, setColumnSizingInfo, } = table;
2491
+ const { density } = getState();
2492
+ const { column } = header;
2493
+ const handler = header.getResizeHandler();
2494
+ const offset = column.getIsResizing() && columnResizeMode === 'onEnd'
2495
+ ? `translateX(${(columnResizeDirection === 'rtl' ? -1 : 1) *
2496
+ ((_b = getState().columnSizingInfo.deltaOffset) !== null && _b !== void 0 ? _b : 0)}px)`
2497
+ : undefined;
2498
+ return (jsxRuntime.jsx(core.Box, Object.assign({ onDoubleClick: () => {
2499
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2500
+ column.resetSize();
2501
+ }, onMouseDown: handler, onTouchStart: handler, role: "separator" }, rest, { __vars: Object.assign({ '--mrt-transform': offset }, rest.__vars), className: clsx('mrt-table-head-cell-resize-handle', classes$d.root, classes$d[`root-${columnResizeDirection}`], !header.subHeaders.length &&
2502
+ columnResizeMode === 'onChange' &&
2503
+ classes$d['root-hide'], density, rest.className) })));
2504
+ };
2505
+
2506
+ var classes$c = {"sort-icon":"MRT_TableHeadCellSortLabel-module_sort-icon__zs1xA","multi-sort-indicator":"MRT_TableHeadCellSortLabel-module_multi-sort-indicator__MGBj2"};
2507
+
2508
+ const MRT_TableHeadCellSortLabel = (_a) => {
2509
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2510
+ const { getState, options: { icons: { IconArrowsSort, IconSortAscending, IconSortDescending }, localization, }, } = table;
2511
+ const column = header.column;
2512
+ const { columnDef } = column;
2513
+ const { sorting } = getState();
2514
+ const sorted = column.getIsSorted();
2515
+ const sortIndex = column.getSortIndex();
2516
+ const sortTooltip = sorted
2517
+ ? sorted === 'desc'
2518
+ ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
2519
+ : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
2520
+ : column.getNextSortingOrder() === 'desc'
2521
+ ? localization.sortByColumnDesc.replace('{column}', columnDef.header)
2522
+ : localization.sortByColumnAsc.replace('{column}', columnDef.header);
2523
+ const SortActionButton = (jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": sortTooltip }, dataVariable('sorted', sorted), rest, { className: clsx('mrt-table-head-sort-button', classes$c['sort-icon'], rest.className), children: sorted === 'desc' ? (jsxRuntime.jsx(IconSortDescending, { size: "100%" })) : sorted === 'asc' ? (jsxRuntime.jsx(IconSortAscending, { size: "100%" })) : (jsxRuntime.jsx(IconArrowsSort, { size: "100%" })) })));
2524
+ return (jsxRuntime.jsx(core.Tooltip, { label: sortTooltip, openDelay: 1000, withinPortal: true, children: sorting.length < 2 || sortIndex === -1 ? (SortActionButton) : (jsxRuntime.jsx(core.Indicator, { classNames: {
2525
+ root: clsx('mrt-table-head-multi-sort-indicator', classes$c['multi-sort-indicator']),
2526
+ }, inline: true, label: sortIndex + 1, offset: 4, children: SortActionButton })) }));
2527
+ };
2528
+
2529
+ var classes$b = {"left":"MRT_ColumnActionMenu-module_left__cfNmY","right":"MRT_ColumnActionMenu-module_right__-nK56"};
2530
+
2531
+ const MRT_ColumnActionMenu = (_a) => {
2532
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2533
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2534
+ const { getState, options: { columnFilterDisplayMode, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { IconArrowAutofitContent, IconBoxMultiple, IconClearAll, IconColumns, IconDotsVertical, IconEyeOff, IconFilter, IconFilterOff, IconPinned, IconPinnedOff, IconSortAscending, IconSortDescending, }, localization, mantineColumnActionsButtonProps, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
2535
+ const { column } = header;
2536
+ const { columnDef } = column;
2537
+ const { columnSizing, columnVisibility } = getState();
2538
+ const arg = { column, table };
2539
+ const actionIconProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineColumnActionsButtonProps, arg)), parseFromValuesOrFunc(columnDef.mantineColumnActionsButtonProps, arg));
2540
+ const handleClearSort = () => {
2541
+ column.clearSorting();
2542
+ };
2543
+ const handleSortAsc = () => {
2544
+ column.toggleSorting(false);
2545
+ };
2546
+ const handleSortDesc = () => {
2547
+ column.toggleSorting(true);
2548
+ };
2549
+ const handleResetColumnSize = () => {
2550
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2551
+ column.resetSize();
2552
+ };
2553
+ const handleHideColumn = () => {
2554
+ column.toggleVisibility(false);
2555
+ };
2556
+ const handlePinColumn = (pinDirection) => {
2557
+ column.pin(pinDirection);
2558
+ };
2559
+ const handleGroupByColumn = () => {
2560
+ column.toggleGrouping();
2561
+ setColumnOrder((old) => ['mrt-row-expand', ...old]);
2562
+ };
2563
+ const handleClearFilter = () => {
2564
+ column.setFilterValue('');
2565
+ };
2566
+ const handleFilterByColumn = () => {
2567
+ setShowColumnFilters(true);
2568
+ setTimeout(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); }, 100);
2569
+ };
2570
+ const handleShowAllColumns = () => {
2571
+ toggleAllColumnsVisible(true);
2572
+ };
2573
+ const internalColumnMenuItems = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [enableSorting && column.getCanSort() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [enableSortingRemoval !== false && (jsxRuntime.jsx(core.Menu.Item, { disabled: !column.getIsSorted(), leftSection: jsxRuntime.jsx(IconClearAll, {}), onClick: handleClearSort, children: localization.clearSort })), jsxRuntime.jsx(core.Menu.Item, { disabled: column.getIsSorted() === 'asc', leftSection: jsxRuntime.jsx(IconSortAscending, {}), onClick: handleSortAsc, children: (_b = localization.sortByColumnAsc) === null || _b === void 0 ? void 0 : _b.replace('{column}', String(columnDef.header)) }), jsxRuntime.jsx(core.Menu.Item, { disabled: column.getIsSorted() === 'desc', leftSection: jsxRuntime.jsx(IconSortDescending, {}), onClick: handleSortDesc, children: (_c = localization.sortByColumnDesc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header)) }), (enableColumnFilters || enableGrouping || enableHiding) && (jsxRuntime.jsx(core.Menu.Divider, {}, 3))] })), enableColumnFilters &&
2574
+ columnFilterDisplayMode !== 'popover' &&
2575
+ column.getCanFilter() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Menu.Item, { disabled: !column.getFilterValue(), leftSection: jsxRuntime.jsx(IconFilterOff, {}), onClick: handleClearFilter, children: localization.clearFilter }), jsxRuntime.jsx(core.Menu.Item, { leftSection: jsxRuntime.jsx(IconFilter, {}), onClick: handleFilterByColumn, children: (_d = localization.filterByColumn) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)) }), (enableGrouping || enableHiding) && jsxRuntime.jsx(core.Menu.Divider, {}, 2)] })), enableGrouping && column.getCanGroup() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Menu.Item, { leftSection: jsxRuntime.jsx(IconBoxMultiple, {}), onClick: handleGroupByColumn, children: (_e = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header)) }), enableColumnPinning && jsxRuntime.jsx(core.Menu.Divider, {})] })), enableColumnPinning && column.getCanPin() && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Menu.Item, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), leftSection: jsxRuntime.jsx(IconPinned, { className: classes$b.left }), onClick: () => handlePinColumn('left'), children: localization.pinToLeft }), jsxRuntime.jsx(core.Menu.Item, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), leftSection: jsxRuntime.jsx(IconPinned, { className: classes$b.right }), onClick: () => handlePinColumn('right'), children: localization.pinToRight }), jsxRuntime.jsx(core.Menu.Item, { disabled: !column.getIsPinned(), leftSection: jsxRuntime.jsx(IconPinnedOff, {}), onClick: () => handlePinColumn(false), children: localization.unpin }), enableHiding && jsxRuntime.jsx(core.Menu.Divider, {})] })), enableColumnResizing && column.getCanResize() && (jsxRuntime.jsx(core.Menu.Item, { disabled: !columnSizing[column.id], leftSection: jsxRuntime.jsx(IconArrowAutofitContent, {}), onClick: handleResetColumnSize, children: localization.resetColumnSize }, 0)), enableHiding && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Menu.Item, { disabled: !column.getCanHide(), leftSection: jsxRuntime.jsx(IconEyeOff, {}), onClick: handleHideColumn, children: (_f = localization.hideColumn) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)) }, 0), jsxRuntime.jsx(core.Menu.Item, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
2576
+ .length, leftSection: jsxRuntime.jsx(IconColumns, {}), onClick: handleShowAllColumns, children: (_g = localization.showAllColumns) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header)) }, 1)] }))] }));
2577
+ return (jsxRuntime.jsxs(core.Menu, Object.assign({ closeOnItemClick: true, position: "bottom-start", withinPortal: true }, rest, { children: [jsxRuntime.jsx(core.Tooltip, { label: (_h = actionIconProps === null || actionIconProps === void 0 ? void 0 : actionIconProps.title) !== null && _h !== void 0 ? _h : localization.columnActions, openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx(core.Menu.Target, { children: jsxRuntime.jsx(core.ActionIcon, Object.assign({ "aria-label": localization.columnActions, color: "gray", size: "sm", variant: "subtle" }, actionIconProps, { children: jsxRuntime.jsx(IconDotsVertical, { size: "100%" }) })) }) }), jsxRuntime.jsx(core.Menu.Dropdown, { children: (_l = (_k = (_j = columnDef.renderColumnActionsMenuItems) === null || _j === void 0 ? void 0 : _j.call(columnDef, {
2578
+ column,
2579
+ internalColumnMenuItems,
2580
+ table,
2581
+ })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
2582
+ column,
2583
+ internalColumnMenuItems,
2584
+ table,
2585
+ })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })] })));
2586
+ };
2587
+
2588
+ const MRT_TableHeadCell = (_a) => {
2589
+ var _b, _c, _d, _f, _g, _h;
2590
+ var { columnVirtualizer, header: headerProp, renderedHeaderIndex = 0, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "renderedHeaderIndex", "table"]);
2591
+ //a view has a new identity per table reference, which compiled render callbacks need
2592
+ const header = getMRT_HeaderView(table, headerProp);
2593
+ const direction = core.useDirection();
2594
+ const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableHeaderActionsHoverReveal, enableMultiSort, layoutMode, mantineTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
2595
+ const { columnSizingInfo, draggingColumn, grouping, hoveredColumn } = getState();
2596
+ const { column } = header;
2597
+ const { columnDef } = column;
2598
+ const { columnDefType } = columnDef;
2599
+ const arg = { column, table };
2600
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableHeadCellProps, arg)), parseFromValuesOrFunc(columnDef.mantineTableHeadCellProps, arg)), rest);
2601
+ const widthStyles = {
2602
+ minWidth: `max(calc(var(--header-${parseCSSVarId(header === null || header === void 0 ? void 0 : header.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
2603
+ width: `calc(var(--header-${parseCSSVarId(header.id)}-size) * 1px)`,
2604
+ };
2605
+ if (layoutMode === 'grid') {
2606
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
2607
+ ? 0
2608
+ : `var(--header-${parseCSSVarId(header.id)}-size)`} 0 auto`;
2609
+ }
2610
+ else if (layoutMode === 'grid-no-grow') {
2611
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
2612
+ }
2613
+ const isColumnPinned = enableColumnPinning &&
2614
+ columnDef.columnDefType !== 'group' &&
2615
+ column.getIsPinned();
2616
+ const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
2617
+ const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
2618
+ const { hovered: isHoveredHeadCell, ref: isHoveredHeadCellRef } = hooks.useHover();
2619
+ const [isOpenedColumnActions, setIsOpenedColumnActions] = react.useState(false);
2620
+ const columnActionsEnabled = (enableColumnActions || columnDef.enableColumnActions) &&
2621
+ columnDef.enableColumnActions !== false;
2622
+ const showColumnButtons = !enableHeaderActionsHoverReveal ||
2623
+ isOpenedColumnActions ||
2624
+ (isHoveredHeadCell &&
2625
+ !table.getVisibleFlatColumns().find((column) => column.getIsResizing()));
2626
+ const showDragHandle = enableColumnDragging !== false &&
2627
+ columnDef.enableColumnDragging !== false &&
2628
+ (enableColumnDragging ||
2629
+ (enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
2630
+ (enableGrouping &&
2631
+ columnDef.enableGrouping !== false &&
2632
+ !grouping.includes(column.id))) &&
2633
+ showColumnButtons;
2634
+ const headerPL = react.useMemo(() => {
2635
+ let pl = 0;
2636
+ if (column.getCanSort())
2637
+ pl++;
2638
+ // Only add padding for buttons if they will actually be displayed
2639
+ if (showColumnButtons && (columnActionsEnabled || showDragHandle))
2640
+ pl += 1.75;
2641
+ if (showDragHandle)
2642
+ pl += 1.25;
2643
+ return pl;
2644
+ }, [showColumnButtons, showDragHandle, columnActionsEnabled]);
2645
+ const handleDragEnter = (_e) => {
2646
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2647
+ setHoveredColumn(null);
2648
+ }
2649
+ if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
2650
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2651
+ }
2652
+ };
2653
+ const headerElement = (columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) instanceof Function
2654
+ ? (_c = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2655
+ column,
2656
+ header,
2657
+ table,
2658
+ })
2659
+ : ((_d = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) !== null && _d !== void 0 ? _d : columnDef.header);
2660
+ return (jsxRuntime.jsxs(core.TableTh, Object.assign({ colSpan: header.colSpan, "data-column-pinned": isColumnPinned || undefined, "data-dragging-column": isDraggingColumn || undefined, "data-first-right-pinned": (isColumnPinned === 'right' &&
2661
+ column.getIsFirstColumn(isColumnPinned)) ||
2662
+ undefined, "data-hovered-column-target": isHoveredColumn || undefined, "data-index": renderedHeaderIndex, "data-last-left-pinned": (isColumnPinned === 'left' && column.getIsLastColumn(isColumnPinned)) ||
2663
+ undefined, "data-resizing": (columnResizeMode === 'onChange' &&
2664
+ (columnSizingInfo === null || columnSizingInfo === void 0 ? void 0 : columnSizingInfo.isResizingColumn) === column.id &&
2665
+ columnResizeDirection) ||
2666
+ undefined }, tableCellProps, { __vars: {
2667
+ '--mrt-table-cell-left': isColumnPinned === 'left'
2668
+ ? `${column.getStart(isColumnPinned)}`
2669
+ : undefined,
2670
+ '--mrt-table-cell-right': isColumnPinned === 'right'
2671
+ ? `${column.getAfter(isColumnPinned)}`
2672
+ : undefined,
2673
+ }, align: columnDefType === 'group'
2674
+ ? 'center'
2675
+ : direction.dir === 'rtl'
2676
+ ? 'right'
2677
+ : 'left', className: clsx(classes$l.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$l['root-grid'], enableMultiSort && column.getCanSort() && classes$l['root-no-select'], columnVirtualizer && classes$l['root-virtualized'], tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.className), onDragEnter: handleDragEnter, ref: (node) => {
2678
+ var _a;
2679
+ if (node) {
2680
+ tableHeadCellRefs.current[column.id] = node;
2681
+ isHoveredHeadCellRef(node);
2682
+ if (columnDefType !== 'group') {
2683
+ (_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
2684
+ }
2685
+ }
2686
+ }, style: (theme) => (Object.assign(Object.assign({}, widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.style, theme))), children: [header.isPlaceholder
2687
+ ? null
2688
+ : ((_f = tableCellProps.children) !== null && _f !== void 0 ? _f : (jsxRuntime.jsxs(core.Flex, { className: clsx('mrt-table-head-cell-content', classes$l.content, (columnDefType === 'group' ||
2689
+ (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center') &&
2690
+ classes$l['content-center'], (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' && classes$l['content-right'], column.getCanResize() && classes$l['content-spaced']), children: [jsxRuntime.jsxs(core.Flex, { __vars: {
2691
+ '--mrt-table-head-cell-labels-padding-left': `${headerPL}`,
2692
+ }, className: clsx('mrt-table-head-cell-labels', classes$l.labels, column.getCanSort() &&
2693
+ columnDefType !== 'group' &&
2694
+ classes$l['labels-sortable'], (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right'
2695
+ ? classes$l['labels-right']
2696
+ : (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center' &&
2697
+ classes$l['labels-center'], columnDefType === 'data' && classes$l['labels-data']), onClick: column.getToggleSortingHandler(), children: [jsxRuntime.jsx(core.Flex, { className: clsx('mrt-table-head-cell-content-wrapper', classes$l['content-wrapper'], columnDefType === 'data' &&
2698
+ classes$l['content-wrapper-hidden-overflow'], ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20 &&
2699
+ classes$l['content-wrapper-nowrap']), children: headerElement }), column.getCanFilter() &&
2700
+ (column.getIsFiltered() || showColumnButtons) && (jsxRuntime.jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() &&
2701
+ (column.getIsSorted() || showColumnButtons) && (jsxRuntime.jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxRuntime.jsxs(core.Flex, { className: clsx('mrt-table-head-cell-content-actions', classes$l['content-actions']), children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
2702
+ current: tableHeadCellRefs.current[column.id],
2703
+ } })), columnActionsEnabled && showColumnButtons && (jsxRuntime.jsx(MRT_ColumnActionMenu, { header: header, onChange: setIsOpenedColumnActions, opened: isOpenedColumnActions, table: table }))] })), column.getCanResize() && (jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] }))), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
2704
+ };
2705
+
2706
+ const MRT_TableHeadRow = (_a) => {
2707
+ var _b;
2708
+ var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
2709
+ const { getState, options: { enableStickyHeader, layoutMode, mantineTableHeadRowProps }, } = table;
2710
+ const { isFullScreen } = getState();
2711
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2712
+ const virtualGroupHeaders = getVirtualGroupHeaders({
2713
+ headers: headerGroup.headers,
2714
+ table,
2715
+ virtualColumns,
2716
+ });
2717
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableHeadRowProps, {
2718
+ headerGroup,
2719
+ table,
2720
+ })), rest);
2721
+ return (jsxRuntime.jsxs(core.TableTr, Object.assign({}, tableRowProps, { className: clsx(classes$m.root, (enableStickyHeader || isFullScreen) && classes$m.sticky, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$m['layout-mode-grid'], tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.className), children: [virtualPaddingLeft ? (jsxRuntime.jsx(core.Box, { component: "th", display: "flex", w: virtualPaddingLeft })) : null, (_b = virtualGroupHeaders === null || virtualGroupHeaders === void 0 ? void 0 : virtualGroupHeaders.map(({ header, index, style }) => (jsxRuntime.jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, renderedHeaderIndex: index, style: style, table: table }, header.id)))) !== null && _b !== void 0 ? _b : (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader, renderedHeaderIndex) => {
2722
+ let header = headerOrVirtualHeader;
2723
+ if (columnVirtualizer) {
2724
+ renderedHeaderIndex = headerOrVirtualHeader
2725
+ .index;
2726
+ header = headerGroup.headers[renderedHeaderIndex];
2727
+ }
2728
+ return (jsxRuntime.jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, renderedHeaderIndex: renderedHeaderIndex, table: table }, header.id));
2729
+ }), virtualPaddingRight ? (jsxRuntime.jsx(core.Box, { component: "th", display: "flex", w: virtualPaddingRight })) : null] })));
2730
+ };
2731
+
2732
+ var classes$a = {"alert":"MRT_ToolbarAlertBanner-module_alert__PAhUK","alert-stacked":"MRT_ToolbarAlertBanner-module_alert-stacked__HR7Nq","alert-bottom":"MRT_ToolbarAlertBanner-module_alert-bottom__u9L-S","alert-badge":"MRT_ToolbarAlertBanner-module_alert-badge__GwDmX","toolbar-alert":"MRT_ToolbarAlertBanner-module_toolbar-alert__3sJGU","head-overlay":"MRT_ToolbarAlertBanner-module_head-overlay__Hw7jK"};
2733
+
2734
+ const MRT_SelectCheckbox = (_a) => {
2735
+ var _b;
2736
+ var { renderedRowIndex = 0, row, table } = _a, rest = __rest(_a, ["renderedRowIndex", "row", "table"]);
2737
+ const { getState, options: { enableMultiRowSelection, localization, mantineSelectAllCheckboxProps, mantineSelectCheckboxProps, selectAllMode, selectDisplayMode, }, } = table;
2738
+ const { density, isLoading } = getState();
2739
+ const selectAll = !row;
2740
+ const allRowsSelected = selectAll
2741
+ ? selectAllMode === 'page'
2742
+ ? table.getIsAllPageRowsSelected()
2743
+ : table.getIsAllRowsSelected()
2744
+ : undefined;
2745
+ const isChecked = selectAll
2746
+ ? allRowsSelected
2747
+ : getIsRowSelected({ row, table });
2748
+ const checkboxProps = Object.assign(Object.assign({}, (selectAll
2749
+ ? parseFromValuesOrFunc(mantineSelectAllCheckboxProps, { table })
2750
+ : parseFromValuesOrFunc(mantineSelectCheckboxProps, {
2751
+ row,
2752
+ table,
2753
+ }))), rest);
2754
+ const onSelectionChange = row
2755
+ ? getMRT_RowSelectionHandler({
2756
+ renderedRowIndex,
2757
+ row,
2758
+ table,
2759
+ })
2760
+ : undefined;
2761
+ const onSelectAllChange = getMRT_SelectAllHandler({ table });
2762
+ const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
2763
+ ? localization.toggleSelectAll
2764
+ : localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', onChange: (event) => {
2765
+ event.stopPropagation();
2766
+ if (selectAll) {
2767
+ onSelectAllChange(event);
2768
+ }
2769
+ else {
2770
+ onSelectionChange(event);
2771
+ }
2772
+ }, size: density === 'xs' ? 'sm' : 'md' }, checkboxProps), { onClick: (e) => {
2773
+ var _a;
2774
+ e.stopPropagation();
2775
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
2776
+ }, title: undefined });
2777
+ return (jsxRuntime.jsx(core.Tooltip, { label: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
2778
+ ? localization.toggleSelectAll
2779
+ : localization.toggleSelectRow), openDelay: 1000, withinPortal: true, children: jsxRuntime.jsx("span", { children: selectDisplayMode === 'switch' ? (jsxRuntime.jsx(core.Switch, Object.assign({}, commonProps))) : selectDisplayMode === 'radio' ||
2780
+ enableMultiRowSelection === false ? (jsxRuntime.jsx(core.Radio, Object.assign({}, commonProps))) : (jsxRuntime.jsx(core.Checkbox, Object.assign({ indeterminate: !isChecked && selectAll
2781
+ ? table.getIsSomeRowsSelected()
2782
+ : (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) }) }));
2783
+ };
2784
+
2785
+ const MRT_ToolbarAlertBanner = (_a) => {
2786
+ var _b, _c, _d;
2787
+ var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
2788
+ const { getFilteredSelectedRowModel, getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, icons: { IconX }, localization, mantineToolbarAlertBannerBadgeProps, mantineToolbarAlertBannerProps, manualPagination, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, } = table;
2789
+ const { density, grouping, rowSelection, showAlertBanner } = getState();
2790
+ const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineToolbarAlertBannerProps, {
2791
+ table,
2792
+ })), rest);
2793
+ const badgeProps = parseFromValuesOrFunc(mantineToolbarAlertBannerBadgeProps, { table });
2794
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().flatRows.length;
2795
+ const selectedRowCount = react.useMemo(() => manualPagination
2796
+ ? Object.values(rowSelection).filter(Boolean).length
2797
+ : getFilteredSelectedRowModel().rows.length, [rowSelection, totalRowCount, manualPagination]);
2798
+ const selectedAlert = selectedRowCount ? (jsxRuntime.jsxs(core.Flex, { align: "center", gap: "sm", children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.toString()), jsxRuntime.jsx(core.Button, { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "compact-xs", variant: "subtle", children: localization.clearSelection })] })) : null;
2799
+ const groupedAlert = grouping.length > 0 ? (jsxRuntime.jsxs(core.Flex, { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxRuntime.jsxs(react.Fragment, { children: [index > 0 ? localization.thenBy : '', jsxRuntime.jsxs(core.Badge, Object.assign({ className: classes$a['alert-badge'], rightSection: jsxRuntime.jsx(core.ActionIcon, { color: "white", onClick: () => table.getColumn(columnId).toggleGrouping(), size: "xs", variant: "subtle", children: jsxRuntime.jsx(IconX, { style: { transform: 'scale(0.8)' } }) }), variant: "filled" }, badgeProps, { children: [table.getColumn(columnId).columnDef.header, ' '] }))] }, `${index}-${columnId}`)))] })) : null;
2800
+ return (jsxRuntime.jsx(core.Collapse, { expanded: showAlertBanner || !!selectedAlert || !!groupedAlert, transitionDuration: stackAlertBanner ? 200 : 0, children: jsxRuntime.jsx(core.Alert, Object.assign({ color: "blue", icon: false }, alertProps, { className: clsx(classes$a.alert, stackAlertBanner &&
2801
+ !positionToolbarAlertBanner &&
2802
+ classes$a['alert-stacked'], !stackAlertBanner &&
2803
+ positionToolbarAlertBanner === 'bottom' &&
2804
+ classes$a['alert-bottom'], alertProps === null || alertProps === void 0 ? void 0 : alertProps.className), children: (_d = renderToolbarAlertBannerContent === null || renderToolbarAlertBannerContent === void 0 ? void 0 : renderToolbarAlertBannerContent({
2805
+ groupedAlert,
2806
+ selectedAlert,
2807
+ table,
2808
+ })) !== null && _d !== void 0 ? _d : (jsxRuntime.jsxs(core.Flex, { className: clsx(classes$a['toolbar-alert'], positionToolbarAlertBanner === 'head-overlay' &&
2809
+ classes$a['head-overlay'], density), children: [enableRowSelection &&
2810
+ enableSelectAll &&
2811
+ positionToolbarAlertBanner === 'head-overlay' && (jsxRuntime.jsx(MRT_SelectCheckbox, { table: table })), jsxRuntime.jsxs(core.Stack, { children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, selectedAlert, groupedAlert] })] })) })) }));
2812
+ };
2813
+
2814
+ const MRT_TableHead = (_a) => {
2815
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2816
+ const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, mantineTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
2817
+ const { isFullScreen, showAlertBanner } = getState();
2818
+ const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableHeadProps, {
2819
+ table,
2820
+ })), rest);
2821
+ const stickyHeader = enableStickyHeader || isFullScreen;
2822
+ return (jsxRuntime.jsx(core.TableThead, Object.assign({}, tableHeadProps, { className: clsx(classes$n.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
2823
+ ? classes$n['root-grid']
2824
+ : classes$n['root-table-row-group'], stickyHeader && classes$n['root-sticky'], tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.className), pos: stickyHeader && (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'sticky' : 'relative', ref: (ref) => {
2825
+ tableHeadRef.current = ref;
2826
+ assignRef(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref, ref);
2827
+ }, children: positionToolbarAlertBanner === 'head-overlay' &&
2828
+ (showAlertBanner || getSelectedRowModel().rows.length > 0) ? (jsxRuntime.jsx(core.TableTr, { className: clsx(classes$n['banner-tr'], (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$n.grid), children: jsxRuntime.jsx(core.TableTh, { className: clsx(classes$n['banner-th'], (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$n.grid), colSpan: table.getVisibleLeafColumns().length, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
2829
+ };
2830
+
2831
+ var classes$9 = {"root":"MRT_GlobalFilterTextInput-module_root__Xmcpv","collapse":"MRT_GlobalFilterTextInput-module_collapse__v311d"};
2832
+
2833
+ const MRT_GlobalFilterTextInput = (_a) => {
2834
+ var { table } = _a, rest = __rest(_a, ["table"]);
2835
+ const { getState, options: { enableGlobalFilterModes, icons: { IconSearch, IconX }, localization, mantineSearchTextInputProps, manualFiltering, positionGlobalFilter, }, refs: { searchInputRef }, setGlobalFilter, } = table;
2836
+ const { globalFilter, showGlobalFilter } = getState();
2837
+ const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineSearchTextInputProps, {
2838
+ table,
2839
+ })), rest);
2840
+ const isMounted = react.useRef(false);
2841
+ const [searchValue, setSearchValue] = react.useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
2842
+ //send the search value to the table once typing pauses. The timer restarts on
2843
+ //every change, so text retyped right after a clear is sent again.
2844
+ react.useEffect(() => {
2845
+ const timeout = setTimeout(() => setGlobalFilter(searchValue || undefined), manualFiltering ? 500 : 250);
2846
+ return () => clearTimeout(timeout);
2847
+ }, [searchValue]);
2848
+ const handleClear = () => {
2849
+ setSearchValue('');
2850
+ setGlobalFilter(undefined);
2851
+ };
2852
+ react.useEffect(() => {
2853
+ if (isMounted.current) {
2854
+ if (globalFilter === undefined) {
2855
+ handleClear();
2856
+ }
2857
+ else {
2858
+ setSearchValue(globalFilter);
2859
+ }
2860
+ }
2861
+ isMounted.current = true;
2862
+ }, [globalFilter]);
2863
+ return (jsxRuntime.jsxs(core.Collapse, { className: classes$9.collapse, expanded: showGlobalFilter, children: [enableGlobalFilterModes && (jsxRuntime.jsxs(core.Menu, { withinPortal: true, children: [jsxRuntime.jsx(core.Menu.Target, { children: jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.changeSearchMode, color: "gray", size: "sm", variant: "transparent", children: jsxRuntime.jsx(IconSearch, {}) }) }), jsxRuntime.jsx(MRT_FilterOptionMenu, { onSelect: handleClear, table: table })] })), jsxRuntime.jsx(core.TextInput, Object.assign({ leftSection: !enableGlobalFilterModes && jsxRuntime.jsx(IconSearch, {}), mt: 0, mx: positionGlobalFilter !== 'left' ? 'mx' : undefined, onChange: (event) => setSearchValue(event.target.value), placeholder: localization.search, rightSection: jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.clearSearch, color: "gray", disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), hidden: !searchValue, onClick: handleClear, size: "sm", style: {
2864
+ visibility: !searchValue ? 'hidden' : undefined,
2865
+ }, variant: "transparent", children: jsxRuntime.jsx(core.Tooltip, { label: localization.clearSearch, withinPortal: true, children: jsxRuntime.jsx(IconX, {}) }) }), value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "filled" }, textFieldProps, { className: clsx('mrt-global-filter-text-input', classes$9.root, textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.className), ref: (node) => {
2866
+ if (node) {
2867
+ searchInputRef.current = node;
2868
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.ref) {
2869
+ // @ts-ignore
2870
+ textFieldProps.ref = node;
2871
+ }
2872
+ }
2873
+ } }))] }));
2874
+ };
2875
+
2876
+ const flexRender = reactTable.flexRender;
2877
+ function createMRTColumnHelper() {
2878
+ return {
2879
+ accessor: (accessor, column) => {
2880
+ return typeof accessor === 'function'
2881
+ ? Object.assign(Object.assign({}, column), { accessorFn: accessor })
2882
+ : Object.assign(Object.assign({}, column), { accessorKey: accessor });
2883
+ },
2884
+ display: (column) => column,
2885
+ group: (column) => column,
2886
+ };
2887
+ }
2888
+ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => reactTable.createRow(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
2889
+ [getColumnId(col)]: '',
2890
+ }))), rowIndex, depth, subRows, parentId);
2891
+
2892
+ const getMRT_RowActionsColumnDef = (tableOptions) => {
2893
+ return Object.assign({ Cell: ({ cell, row, table }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })) }, defaultDisplayColumnProps({
2894
+ header: 'actions',
2895
+ id: 'mrt-row-actions',
2896
+ size: 70,
2897
+ tableOptions,
2898
+ }));
2899
+ };
2900
+
2901
+ const getMRT_RowDragColumnDef = (tableOptions) => {
2902
+ return Object.assign({ Cell: ({ row, rowRef, table }) => (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
2903
+ header: 'move',
2904
+ id: 'mrt-row-drag',
2905
+ size: 60,
2906
+ tableOptions,
2907
+ }));
2908
+ };
2909
+
2910
+ const getMRT_RowExpandColumnDef = (tableOptions) => {
2911
+ var _a;
2912
+ const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
2913
+ const alignProps = positionExpandColumn === 'last'
2914
+ ? {
2915
+ align: 'right',
2916
+ }
2917
+ : undefined;
2918
+ return Object.assign({ Cell: ({ cell, column, row, table }) => {
2919
+ var _a, _b, _c;
2920
+ const expandButtonProps = { row, table };
2921
+ const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
2922
+ if (tableOptions.groupedColumnMode === 'remove' && row.groupingColumnId) {
2923
+ return (jsxRuntime.jsxs(core.Flex, { align: "center", gap: "0.25rem", children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsxRuntime.jsx(core.Tooltip, { label: table.getColumn(row.groupingColumnId).columnDef.header, openDelay: 1000, position: "right", children: jsxRuntime.jsx("span", { children: row.groupingValue }) }), !!subRowsLength && jsxRuntime.jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
2924
+ }
2925
+ else {
2926
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, { cell, column, row, table })] }));
2927
+ }
2928
+ }, Header: enableExpandAll
2929
+ ? ({ table }) => {
2930
+ var _a;
2931
+ return (jsxRuntime.jsxs(core.Flex, { align: "center", children: [jsxRuntime.jsx(MRT_ExpandAllButton, { table: table }), groupedColumnMode === 'remove' &&
2932
+ ((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
2933
+ }
2934
+ : undefined, mantineTableBodyCellProps: alignProps, mantineTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
2935
+ header: 'expand',
2936
+ id: 'mrt-row-expand',
2937
+ size: groupedColumnMode === 'remove'
2938
+ ? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
2939
+ : renderDetailPanel
2940
+ ? enableExpandAll
2941
+ ? 60
2942
+ : 70
2943
+ : 100,
2944
+ tableOptions,
2945
+ }));
2946
+ };
2947
+
2948
+ const getMRT_RowNumbersColumnDef = (tableOptions) => {
2949
+ const { localization, rowNumberDisplayMode } = tableOptions;
2950
+ const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
2951
+ return Object.assign({ Cell: ({ renderedRowIndex = 0, row }) => {
2952
+ var _a;
2953
+ return ((_a = (rowNumberDisplayMode === 'static'
2954
+ ? renderedRowIndex + pageSize * pageIndex
2955
+ : row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
2956
+ }, grow: false, Header: () => localization.rowNumber }, defaultDisplayColumnProps({
2957
+ header: 'rowNumbers',
2958
+ id: 'mrt-row-numbers',
2959
+ size: 50,
2960
+ tableOptions,
2961
+ }));
2962
+ };
2963
+
2964
+ const getMRT_RowPinningColumnDef = (tableOptions) => {
2965
+ return Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
2966
+ header: 'pin',
2967
+ id: 'mrt-row-pin',
2968
+ size: 60,
2969
+ tableOptions,
2970
+ }));
2971
+ };
2972
+
2973
+ const getMRT_RowSelectColumnDef = (tableOptions) => {
2974
+ const { enableMultiRowSelection, enableSelectAll } = tableOptions;
2975
+ return Object.assign({ Cell: ({ renderedRowIndex, row, table }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { renderedRowIndex: renderedRowIndex, row: row, table: table })), grow: false, Header: enableSelectAll && enableMultiRowSelection
2976
+ ? ({ table }) => jsxRuntime.jsx(MRT_SelectCheckbox, { table: table })
2977
+ : undefined }, defaultDisplayColumnProps({
2978
+ header: 'select',
2979
+ id: 'mrt-row-select',
2980
+ size: enableSelectAll ? 60 : 70,
2981
+ tableOptions,
2982
+ }));
2983
+ };
2984
+
2985
+ const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
2986
+
2987
+ const MRT_Default_Icons = {
2988
+ IconArrowAutofitContent: iconsReact.IconArrowAutofitContent,
2989
+ IconArrowsSort: iconsReact.IconArrowsSort,
2990
+ IconBaselineDensityLarge: iconsReact.IconBaselineDensityLarge,
2991
+ IconBaselineDensityMedium: iconsReact.IconBaselineDensityMedium,
2992
+ IconBaselineDensitySmall: iconsReact.IconBaselineDensitySmall,
2993
+ IconBoxMultiple: iconsReact.IconBoxMultiple,
2994
+ IconChevronDown: iconsReact.IconChevronDown,
2995
+ IconChevronLeft: iconsReact.IconChevronLeft,
2996
+ IconChevronLeftPipe: iconsReact.IconChevronLeftPipe,
2997
+ IconChevronRight: iconsReact.IconChevronRight,
2998
+ IconChevronRightPipe: iconsReact.IconChevronRightPipe,
2999
+ IconChevronsDown: iconsReact.IconChevronsDown,
3000
+ IconCircleX: iconsReact.IconCircleX,
3001
+ IconClearAll: iconsReact.IconClearAll,
3002
+ IconColumns: iconsReact.IconColumns,
3003
+ IconDeviceFloppy: iconsReact.IconDeviceFloppy,
3004
+ IconDots: iconsReact.IconDots,
3005
+ IconDotsVertical: iconsReact.IconDotsVertical,
3006
+ IconEdit: iconsReact.IconEdit,
3007
+ IconEyeOff: iconsReact.IconEyeOff,
3008
+ IconFilter: iconsReact.IconFilter,
3009
+ IconFilterCog: iconsReact.IconFilterCog,
3010
+ IconFilterOff: iconsReact.IconFilterOff,
3011
+ IconGripHorizontal: iconsReact.IconGripHorizontal,
3012
+ IconMaximize: iconsReact.IconMaximize,
3013
+ IconMinimize: iconsReact.IconMinimize,
3014
+ IconPinned: iconsReact.IconPinned,
3015
+ IconPinnedOff: iconsReact.IconPinnedOff,
3016
+ IconSearch: iconsReact.IconSearch,
3017
+ IconSearchOff: iconsReact.IconSearchOff,
3018
+ IconSortAscending: iconsReact.IconSortAscending,
3019
+ IconSortDescending: iconsReact.IconSortDescending,
3020
+ IconX: iconsReact.IconX,
3021
+ };
3022
+
3023
+ const MRT_Localization_EN = {
3024
+ actions: 'Actions',
3025
+ and: 'and',
3026
+ cancel: 'Cancel',
3027
+ changeFilterMode: 'Change filter mode',
3028
+ changeSearchMode: 'Change search mode',
3029
+ clearFilter: 'Clear filter',
3030
+ clearSearch: 'Clear search',
3031
+ clearSelection: 'Clear selection',
3032
+ clearSort: 'Clear sort',
3033
+ clickToCopy: 'Click to copy',
3034
+ copy: 'Copy',
3035
+ collapse: 'Collapse',
3036
+ collapseAll: 'Collapse all',
3037
+ columnActions: 'Column Actions',
3038
+ copiedToClipboard: 'Copied to clipboard',
3039
+ dropToGroupBy: 'Drop to group by {column}',
3040
+ edit: 'Edit',
3041
+ expand: 'Expand',
3042
+ expandAll: 'Expand all',
3043
+ filterArrIncludes: 'Includes',
3044
+ filterArrIncludesAll: 'Includes all',
3045
+ filterArrIncludesSome: 'Includes',
3046
+ filterBetween: 'Between',
3047
+ filterBetweenInclusive: 'Between Inclusive',
3048
+ filterByColumn: 'Filter by {column}',
3049
+ filterContains: 'Contains',
3050
+ filterEmpty: 'Empty',
3051
+ filterEndsWith: 'Ends With',
3052
+ filterEquals: 'Equals',
3053
+ filterEqualsString: 'Equals',
3054
+ filterFuzzy: 'Fuzzy',
3055
+ filterGreaterThan: 'Greater Than',
3056
+ filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
3057
+ filterInNumberRange: 'Between',
3058
+ filterIncludesString: 'Contains',
3059
+ filterIncludesStringSensitive: 'Contains',
3060
+ filterLessThan: 'Less Than',
3061
+ filterLessThanOrEqualTo: 'Less Than Or Equal To',
3062
+ filterMode: 'Filter Mode: {filterType}',
3063
+ filterNotEmpty: 'Not Empty',
3064
+ filterNotEquals: 'Not Equals',
3065
+ filterStartsWith: 'Starts With',
3066
+ filterWeakEquals: 'Equals',
3067
+ filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
3068
+ goToFirstPage: 'Go to first page',
3069
+ goToLastPage: 'Go to last page',
3070
+ goToNextPage: 'Go to next page',
3071
+ goToPreviousPage: 'Go to previous page',
3072
+ grab: 'Grab',
3073
+ groupByColumn: 'Group by {column}',
3074
+ groupedBy: 'Grouped by ',
3075
+ hideAll: 'Hide all',
3076
+ hideColumn: 'Hide {column} column',
3077
+ max: 'Max',
3078
+ min: 'Min',
3079
+ move: 'Move',
3080
+ noRecordsToDisplay: 'No records to display',
3081
+ noResultsFound: 'No results found',
3082
+ of: 'of',
3083
+ or: 'or',
3084
+ pin: 'Pin',
3085
+ pinToLeft: 'Pin to left',
3086
+ pinToRight: 'Pin to right',
3087
+ resetColumnSize: 'Reset column size',
3088
+ resetOrder: 'Reset order',
3089
+ rowActions: 'Row Actions',
3090
+ rowNumber: '#',
3091
+ rowNumbers: 'Row Numbers',
3092
+ rowsPerPage: 'Rows per page',
3093
+ save: 'Save',
3094
+ search: 'Search',
3095
+ selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
3096
+ select: 'Select',
3097
+ showAll: 'Show all',
3098
+ showAllColumns: 'Show all columns',
3099
+ showHideColumns: 'Show/Hide columns',
3100
+ showHideFilters: 'Show/Hide filters',
3101
+ showHideSearch: 'Show/Hide search',
3102
+ sortByColumnAsc: 'Sort by {column} ascending',
3103
+ sortByColumnDesc: 'Sort by {column} descending',
3104
+ sortedByColumnAsc: 'Sorted by {column} ascending',
3105
+ sortedByColumnDesc: 'Sorted by {column} descending',
3106
+ thenBy: ', then by ',
3107
+ toggleDensity: 'Toggle density',
3108
+ toggleFullScreen: 'Toggle full screen',
3109
+ toggleSelectAll: 'Toggle select all',
3110
+ toggleSelectRow: 'Toggle select row',
3111
+ toggleVisibility: 'Toggle visibility',
3112
+ ungroupByColumn: 'Ungroup by {column}',
3113
+ unpin: 'Unpin',
3114
+ unpinAll: 'Unpin all',
3115
+ };
3116
+
3117
+ const MRT_DefaultColumn = {
3118
+ filterVariant: 'text',
3119
+ maxSize: 1000,
3120
+ minSize: 40,
3121
+ size: 180,
3122
+ };
3123
+ const MRT_DefaultDisplayColumn = {
3124
+ columnDefType: 'display',
3125
+ enableClickToCopy: false,
3126
+ enableColumnActions: false,
3127
+ enableColumnDragging: false,
3128
+ enableColumnFilter: false,
3129
+ enableColumnOrdering: false,
3130
+ enableEditing: false,
3131
+ enableGlobalFilter: false,
3132
+ enableGrouping: false,
3133
+ enableHiding: false,
3134
+ enableResizing: false,
3135
+ enableSorting: false,
3136
+ };
3137
+ const globalFilterValueCache = new WeakMap();
3138
+ /**
3139
+ * Finds the first row with a value in the column and checks that the value is
3140
+ * a string or a number. The result is cached for each data array.
3141
+ */
3142
+ const getColumnHasGlobalFilterValue = (data, column) => {
3143
+ if (!(data === null || data === void 0 ? void 0 : data.length) || !column.accessorFn)
3144
+ return false;
3145
+ let cache = globalFilterValueCache.get(data);
3146
+ if (!cache) {
3147
+ cache = new Map();
3148
+ globalFilterValueCache.set(data, cache);
3149
+ }
3150
+ let hasValue = cache.get(column.id);
3151
+ if (hasValue === undefined) {
3152
+ hasValue = false;
3153
+ for (let index = 0; index < data.length; index++) {
3154
+ const value = column.accessorFn(data[index], index);
3155
+ if (value !== null && value !== undefined) {
3156
+ hasValue = typeof value === 'string' || typeof value === 'number';
3157
+ break;
3158
+ }
3159
+ }
3160
+ cache.set(column.id, hasValue);
3161
+ }
3162
+ return hasValue;
3163
+ };
3164
+ const useMRT_TableOptions = (_a) => {
3165
+ var _b;
3166
+ 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, enableHeaderActionsHoverReveal = false, enableHiding = 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, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHeaderActionsHoverReveal", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
3167
+ const direction = core.useDirection();
3168
+ icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
3169
+ localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
3170
+ aggregationFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
3171
+ filterFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
3172
+ sortingFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
3173
+ defaultColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
3174
+ defaultDisplayColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
3175
+ //cannot be changed after initialization
3176
+ [enableColumnVirtualization, enableRowVirtualization] = react.useMemo(() => [enableColumnVirtualization, enableRowVirtualization], []);
3177
+ if (!columnResizeDirection) {
3178
+ columnResizeDirection = direction.dir || 'ltr';
3179
+ }
3180
+ layoutMode =
3181
+ layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
3182
+ if (layoutMode === 'semantic' &&
3183
+ (enableRowVirtualization || enableColumnVirtualization)) {
3184
+ layoutMode = 'grid';
3185
+ }
3186
+ if (enableRowVirtualization) {
3187
+ enableStickyHeader = true;
3188
+ }
3189
+ if (enablePagination === false && manualPagination === undefined) {
3190
+ manualPagination = true;
3191
+ }
3192
+ if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
3193
+ manualFiltering = true;
3194
+ manualGrouping = true;
3195
+ manualPagination = true;
3196
+ manualSorting = true;
3197
+ }
3198
+ return Object.assign({ aggregationFns,
3199
+ autoResetExpanded,
3200
+ columnFilterDisplayMode,
3201
+ columnResizeDirection,
3202
+ columnResizeMode,
3203
+ createDisplayMode,
3204
+ defaultColumn,
3205
+ defaultDisplayColumn,
3206
+ editDisplayMode,
3207
+ enableBatchRowSelection,
3208
+ enableBottomToolbar,
3209
+ enableColumnActions,
3210
+ enableColumnFilters,
3211
+ enableColumnOrdering,
3212
+ enableColumnPinning,
3213
+ enableColumnResizing,
3214
+ enableColumnVirtualization,
3215
+ enableDensityToggle,
3216
+ enableExpandAll,
3217
+ enableExpanding,
3218
+ enableFacetedValues,
3219
+ enableFilterMatchHighlighting,
3220
+ enableFilters,
3221
+ enableFullScreenToggle,
3222
+ enableGlobalFilter,
3223
+ enableGlobalFilterRankedResults,
3224
+ enableGrouping,
3225
+ enableHeaderActionsHoverReveal,
3226
+ enableHiding,
3227
+ enableMultiRowSelection,
3228
+ enableMultiSort,
3229
+ enablePagination,
3230
+ enableRowPinning,
3231
+ enableRowSelection,
3232
+ enableRowVirtualization,
3233
+ enableSelectAll,
3234
+ enableSorting,
3235
+ enableStickyHeader,
3236
+ enableTableFooter,
3237
+ enableTableHead,
3238
+ enableToolbarInternalActions,
3239
+ enableTopToolbar,
3240
+ filterFns,
3241
+ //TanStack only checks the value in the first row, so a null there removes the column from the global filter
3242
+ getColumnCanGlobalFilter: (column) => getColumnHasGlobalFilterValue(rest.data, column), getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: enableExpanding || enableGrouping ? reactTable.getExpandedRowModel() : undefined, getFacetedMinMaxValues: enableFacetedValues
3243
+ ? reactTable.getFacetedMinMaxValues()
3244
+ : undefined, getFacetedRowModel: enableFacetedValues ? reactTable.getFacetedRowModel() : undefined, getFacetedUniqueValues: enableFacetedValues
3245
+ ? reactTable.getFacetedUniqueValues()
3246
+ : undefined, getFilteredRowModel: enableColumnFilters || enableGlobalFilter || enableFilters
3247
+ ? reactTable.getFilteredRowModel()
3248
+ : undefined, getGroupedRowModel: enableGrouping ? reactTable.getGroupedRowModel() : undefined, getPaginationRowModel: enablePagination
3249
+ ? reactTable.getPaginationRowModel()
3250
+ : undefined, getSortedRowModel: enableSorting ? reactTable.getSortedRowModel() : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, icons,
3251
+ layoutMode,
3252
+ localization,
3253
+ manualFiltering,
3254
+ manualGrouping,
3255
+ manualPagination,
3256
+ manualSorting,
3257
+ paginationDisplayMode,
3258
+ positionActionsColumn,
3259
+ positionCreatingRow,
3260
+ positionExpandColumn,
3261
+ positionGlobalFilter,
3262
+ positionPagination,
3263
+ positionToolbarAlertBanner,
3264
+ positionToolbarDropZone,
3265
+ rowNumberDisplayMode,
3266
+ rowPinningDisplayMode,
3267
+ selectAllMode,
3268
+ sortingFns }, rest);
3269
+ };
3270
+
3271
+ const blankColProps = {
3272
+ children: null,
3273
+ style: {
3274
+ minWidth: 0,
3275
+ padding: 0,
3276
+ width: 0,
3277
+ },
3278
+ };
3279
+ const getMRT_RowSpacerColumnDef = (tableOptions) => {
3280
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
3281
+ id: 'mrt-row-spacer',
3282
+ size: 0,
3283
+ tableOptions,
3284
+ })), { grow: true }), MRT_DefaultDisplayColumn), { mantineTableBodyCellProps: blankColProps, mantineTableFooterCellProps: blankColProps, mantineTableHeadCellProps: blankColProps });
3285
+ };
3286
+
3287
+ const useMRT_Effects = (table, rerenderTable) => {
3288
+ const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
3289
+ const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
3290
+ const totalColumnCount = table.options.columns.length;
3291
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
3292
+ //`rerenderTable` also changes the table reference, which compiled consumer code needs
3293
+ const rerenderSelf = react.useReducer(() => ({}), {})[1];
3294
+ const rerender = rerenderTable !== null && rerenderTable !== void 0 ? rerenderTable : rerenderSelf;
3295
+ const initialBodyHeight = react.useRef(undefined);
3296
+ const previousTop = react.useRef(undefined);
3297
+ react.useEffect(() => {
3298
+ if (typeof window !== 'undefined') {
3299
+ initialBodyHeight.current = document.body.style.height;
3300
+ }
3301
+ }, []);
3302
+ //hide scrollbars when table is in full screen mode, preserve body scroll position after full screen exit
3303
+ react.useEffect(() => {
3304
+ if (typeof window !== 'undefined') {
3305
+ if (isFullScreen) {
3306
+ previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
3307
+ document.body.style.height = '100dvh'; //hide page scrollbars when table is in full screen mode
3308
+ }
3309
+ else {
3310
+ document.body.style.height = initialBodyHeight.current;
3311
+ if (!previousTop.current)
3312
+ return;
3313
+ //restore scroll position
3314
+ window.scrollTo({
3315
+ behavior: 'instant',
3316
+ top: -1 * previousTop.current,
3317
+ });
3318
+ }
3319
+ }
3320
+ }, [isFullScreen]);
3321
+ //recalculate column order when columns change or features are toggled on/off
3322
+ react.useEffect(() => {
3323
+ if (totalColumnCount !== columnOrder.length) {
3324
+ table.setColumnOrder(getDefaultColumnOrderIds(table.options));
3325
+ }
3326
+ }, [totalColumnCount]);
3327
+ //if page index is out of bounds, set it to the last page
3328
+ react.useEffect(() => {
3329
+ if (!enablePagination || isLoading || showSkeletons)
3330
+ return;
3331
+ const { pageIndex, pageSize } = pagination;
3332
+ const firstVisibleRowIndex = pageIndex * pageSize;
3333
+ if (firstVisibleRowIndex >= totalRowCount && firstVisibleRowIndex > 0) {
3334
+ table.setPageIndex(Math.ceil(totalRowCount / pageSize) - 1);
3335
+ }
3336
+ }, [totalRowCount]);
3337
+ //turn off sort when global filter is looking for ranked results
3338
+ const appliedSort = react.useRef(sorting);
3339
+ react.useEffect(() => {
3340
+ if (sorting.length) {
3341
+ appliedSort.current = sorting;
3342
+ }
3343
+ }, [sorting]);
3344
+ react.useEffect(() => {
3345
+ if (!getCanRankRows(table))
3346
+ return;
3347
+ if (globalFilter) {
3348
+ table.setSorting([]);
3349
+ }
3350
+ else {
3351
+ table.setSorting(() => appliedSort.current || []);
3352
+ }
3353
+ }, [globalFilter]);
3354
+ //fix pinned row top style when density changes
3355
+ react.useEffect(() => {
3356
+ if (enableRowPinning && getIsSomeRowsPinned()) {
3357
+ setTimeout(() => {
3358
+ rerender();
3359
+ }, 150);
3360
+ }
3361
+ }, [density]);
3362
+ };
3363
+
3364
+ /**
3365
+ * The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
3366
+ * @param definedTableOptions - table options with proper defaults set
3367
+ * @param rerender - re-renders the owner of the table instance and changes the table reference
3368
+ * @returns the MRT table instance
3369
+ */
3370
+ const useMRT_TableInstance = (definedTableOptions, rerender) => {
3371
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
3372
+ const lastSelectedRowId = react.useRef(null);
3373
+ const bottomToolbarRef = react.useRef(null);
3374
+ const editInputRefs = react.useRef({});
3375
+ const filterInputRefs = react.useRef({});
3376
+ const scrollAreaViewportRef = react.useRef(null);
3377
+ const searchInputRef = react.useRef(null);
3378
+ const tableContainerRef = react.useRef(null);
3379
+ const tableHeadCellRefs = react.useRef({});
3380
+ const tablePaperRef = react.useRef(null);
3381
+ const topToolbarRef = react.useRef(null);
3382
+ const tableHeadRef = react.useRef(null);
3383
+ const tableFooterRef = react.useRef(null);
3384
+ //transform initial state with proper column order
3385
+ const initialState = react.useMemo(() => {
3386
+ var _a, _b, _c;
3387
+ const initState = (_a = definedTableOptions.initialState) !== null && _a !== void 0 ? _a : {};
3388
+ initState.columnOrder =
3389
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, definedTableOptions), { state: Object.assign(Object.assign({}, definedTableOptions.initialState), definedTableOptions.state) }));
3390
+ initState.globalFilterFn = (_c = definedTableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
3391
+ return initState;
3392
+ }, []);
3393
+ definedTableOptions.initialState = initialState;
3394
+ const [creatingRow, _setCreatingRow] = react.useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
3395
+ const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
3396
+ var _a, _b, _c, _d;
3397
+ return ({
3398
+ [getColumnId(col)]: col.filterFn instanceof Function
3399
+ ? ((_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom')
3400
+ : ((_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col)),
3401
+ });
3402
+ })));
3403
+ const [columnOrder, onColumnOrderChange] = react.useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
3404
+ const [columnSizingInfo, onColumnSizingInfoChange] = react.useState((_c = initialState.columnSizingInfo) !== null && _c !== void 0 ? _c : {});
3405
+ const [density, setDensity] = react.useState((_d = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _d !== void 0 ? _d : 'md');
3406
+ const [draggingColumn, setDraggingColumn] = react.useState((_e = initialState.draggingColumn) !== null && _e !== void 0 ? _e : null);
3407
+ const [draggingRow, setDraggingRow] = react.useState((_f = initialState.draggingRow) !== null && _f !== void 0 ? _f : null);
3408
+ const [editingCell, setEditingCell] = react.useState((_g = initialState.editingCell) !== null && _g !== void 0 ? _g : null);
3409
+ const [editingRow, setEditingRow] = react.useState((_h = initialState.editingRow) !== null && _h !== void 0 ? _h : null);
3410
+ const [globalFilterFn, setGlobalFilterFn] = react.useState((_j = initialState.globalFilterFn) !== null && _j !== void 0 ? _j : 'fuzzy');
3411
+ const [grouping, onGroupingChange] = react.useState((_k = initialState.grouping) !== null && _k !== void 0 ? _k : []);
3412
+ const [hoveredColumn, setHoveredColumn] = react.useState((_l = initialState.hoveredColumn) !== null && _l !== void 0 ? _l : null);
3413
+ const [hoveredRow, setHoveredRow] = react.useState((_m = initialState.hoveredRow) !== null && _m !== void 0 ? _m : null);
3414
+ const [isFullScreen, setIsFullScreen] = react.useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _o !== void 0 ? _o : false);
3415
+ const [pagination, onPaginationChange] = react.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _p !== void 0 ? _p : { pageIndex: 0, pageSize: 10 });
3416
+ const [showAlertBanner, setShowAlertBanner] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _q !== void 0 ? _q : false);
3417
+ const [showColumnFilters, setShowColumnFilters] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _r !== void 0 ? _r : false);
3418
+ const [showGlobalFilter, setShowGlobalFilter] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _s !== void 0 ? _s : false);
3419
+ const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _t !== void 0 ? _t : false);
3420
+ definedTableOptions.state = Object.assign({ columnFilterFns,
3421
+ columnOrder,
3422
+ columnSizingInfo,
3423
+ creatingRow,
3424
+ density,
3425
+ draggingColumn,
3426
+ draggingRow,
3427
+ editingCell,
3428
+ editingRow,
3429
+ globalFilterFn,
3430
+ grouping,
3431
+ hoveredColumn,
3432
+ hoveredRow,
3433
+ isFullScreen,
3434
+ pagination,
3435
+ showAlertBanner,
3436
+ showColumnFilters,
3437
+ showGlobalFilter,
3438
+ showToolbarDropZone }, definedTableOptions.state);
3439
+ //The table options now include all state needed to help determine column visibility and order logic
3440
+ const statefulTableOptions = definedTableOptions;
3441
+ //don't recompute columnDefs while resizing column or dragging column/row
3442
+ const columnDefsRef = react.useRef([]);
3443
+ statefulTableOptions.columns =
3444
+ statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
3445
+ statefulTableOptions.state.draggingColumn ||
3446
+ statefulTableOptions.state.draggingRow
3447
+ ? columnDefsRef.current
3448
+ : prepareColumns({
3449
+ columnDefs: [
3450
+ ...[
3451
+ showRowPinningColumn(statefulTableOptions) &&
3452
+ getMRT_RowPinningColumnDef(statefulTableOptions),
3453
+ showRowDragColumn(statefulTableOptions) &&
3454
+ getMRT_RowDragColumnDef(statefulTableOptions),
3455
+ showRowActionsColumn(statefulTableOptions) &&
3456
+ getMRT_RowActionsColumnDef(statefulTableOptions),
3457
+ showRowExpandColumn(statefulTableOptions) &&
3458
+ getMRT_RowExpandColumnDef(statefulTableOptions),
3459
+ showRowSelectionColumn(statefulTableOptions) &&
3460
+ getMRT_RowSelectColumnDef(statefulTableOptions),
3461
+ showRowNumbersColumn(statefulTableOptions) &&
3462
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
3463
+ ].filter(Boolean),
3464
+ ...statefulTableOptions.columns,
3465
+ ...[
3466
+ showRowSpacerColumn(statefulTableOptions) &&
3467
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
3468
+ ].filter(Boolean),
3469
+ ],
3470
+ tableOptions: statefulTableOptions,
3471
+ });
3472
+ columnDefsRef.current = statefulTableOptions.columns;
3473
+ //if loading, generate blank rows to show skeleton loaders
3474
+ statefulTableOptions.data = react.useMemo(() => (statefulTableOptions.state.isLoading ||
3475
+ statefulTableOptions.state.showSkeletons) &&
3476
+ !statefulTableOptions.data.length
3477
+ ? [
3478
+ ...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null),
3479
+ ].map(() => Object.assign(
3480
+ //`prepareColumns` skips a custom accessorFn for rows with this key
3481
+ { [Symbol.for('mrt-skeleton-row')]: true }, ...getAllLeafColumnDefs(statefulTableOptions.columns).map((col) => ({
3482
+ [getColumnId(col)]: null,
3483
+ }))))
3484
+ : statefulTableOptions.data, [
3485
+ statefulTableOptions.data,
3486
+ statefulTableOptions.state.isLoading,
3487
+ statefulTableOptions.state.showSkeletons,
3488
+ ]);
3489
+ //@ts-ignore
3490
+ const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
3491
+ onColumnSizingInfoChange,
3492
+ onGroupingChange,
3493
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_u = statefulTableOptions.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
3494
+ table.refs = {
3495
+ bottomToolbarRef,
3496
+ editInputRefs,
3497
+ filterInputRefs,
3498
+ lastSelectedRowId,
3499
+ scrollAreaViewportRef,
3500
+ searchInputRef,
3501
+ tableContainerRef,
3502
+ tableFooterRef,
3503
+ tableHeadCellRefs,
3504
+ tableHeadRef,
3505
+ tablePaperRef,
3506
+ topToolbarRef,
3507
+ };
3508
+ table.setCreatingRow = (row) => {
3509
+ let _row = row;
3510
+ if (row === true) {
3511
+ _row = createRow(table);
3512
+ }
3513
+ if (statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) {
3514
+ statefulTableOptions.onCreatingRowChange(_row);
3515
+ }
3516
+ else {
3517
+ _setCreatingRow(_row);
3518
+ }
3519
+ };
3520
+ table.setColumnFilterFns =
3521
+ (_v = statefulTableOptions.onColumnFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns;
3522
+ table.setDensity = (_w = statefulTableOptions.onDensityChange) !== null && _w !== void 0 ? _w : setDensity;
3523
+ table.setDraggingColumn =
3524
+ (_x = statefulTableOptions.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn;
3525
+ table.setDraggingRow =
3526
+ (_y = statefulTableOptions.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow;
3527
+ table.setEditingCell =
3528
+ (_z = statefulTableOptions.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell;
3529
+ table.setEditingRow =
3530
+ (_0 = statefulTableOptions.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow;
3531
+ table.setGlobalFilterFn =
3532
+ (_1 = statefulTableOptions.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn;
3533
+ table.setHoveredColumn =
3534
+ (_2 = statefulTableOptions.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn;
3535
+ table.setHoveredRow =
3536
+ (_3 = statefulTableOptions.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow;
3537
+ table.setIsFullScreen =
3538
+ (_4 = statefulTableOptions.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen;
3539
+ table.setShowAlertBanner =
3540
+ (_5 = statefulTableOptions.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner;
3541
+ table.setShowColumnFilters =
3542
+ (_6 = statefulTableOptions.onShowColumnFiltersChange) !== null && _6 !== void 0 ? _6 : setShowColumnFilters;
3543
+ table.setShowGlobalFilter =
3544
+ (_7 = statefulTableOptions.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter;
3545
+ table.setShowToolbarDropZone =
3546
+ (_8 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _8 !== void 0 ? _8 : setShowToolbarDropZone;
3547
+ useMRT_Effects(table, rerender);
3548
+ return table;
3549
+ };
3550
+
3551
+ const useMantineReactTable = (tableOptions) => {
3552
+ const [version, rerender] = react.useReducer((v) => v + 1, 0);
3553
+ const table = useMRT_TableInstance(useMRT_TableOptions(tableOptions), rerender);
3554
+ return useMRT_TableSnapshot(table, tableOptions, version);
3555
+ };
3556
+
3557
+ var classes$8 = {"root":"MRT_TablePaper-module_root__q0v5L"};
3558
+
3559
+ var classes$7 = {"root":"MRT_TableContainer-module_root__JIsGB","root-scroll-area":"MRT_TableContainer-module_root-scroll-area__ZTVGY","root-sticky":"MRT_TableContainer-module_root-sticky__uC4qx","root-fullscreen":"MRT_TableContainer-module_root-fullscreen__aM8Jg"};
3560
+
3561
+ var classes$6 = {"root":"MRT_Table-module_root__ms2uS","root-grid":"MRT_Table-module_root-grid__2Pynz"};
3562
+
3563
+ const useMRT_ColumnVirtualizer = (table) => {
3564
+ var _a, _b, _c, _d;
3565
+ const { getLeftLeafColumns, getRightLeafColumns, getState, getVisibleLeafColumns, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { scrollAreaViewportRef, tableContainerRef }, } = table;
3566
+ const { columnPinning, draggingColumn } = getState();
3567
+ if (!enableColumnVirtualization)
3568
+ return undefined;
3569
+ const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
3570
+ table,
3571
+ });
3572
+ const visibleColumns = getVisibleLeafColumns();
3573
+ const [leftPinnedIndexes, rightPinnedIndexes] = react.useMemo(() => enableColumnPinning
3574
+ ? [
3575
+ getLeftLeafColumns().map((c) => c.getPinnedIndex()),
3576
+ getRightLeafColumns()
3577
+ .map((column) => visibleColumns.length - column.getPinnedIndex() - 1)
3578
+ .sort((a, b) => a - b),
3579
+ ]
3580
+ : [[], []], [visibleColumns.length, columnPinning, enableColumnPinning]);
3581
+ const numPinnedLeft = leftPinnedIndexes.length;
3582
+ const numPinnedRight = rightPinnedIndexes.length;
3583
+ const draggingColumnIndex = react.useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
3584
+ ? visibleColumns.findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
3585
+ : undefined, [draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id]);
3586
+ const columnVirtualizer = reactVirtual.useVirtualizer(Object.assign({ count: visibleColumns.length, estimateSize: (index) => visibleColumns[index].getSize(), getScrollElement: () => { var _a; return (_a = scrollAreaViewportRef.current) !== null && _a !== void 0 ? _a : tableContainerRef.current; }, horizontal: true, overscan: 3, rangeExtractor: react.useCallback((range) => {
3587
+ const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
3588
+ if (!numPinnedLeft && !numPinnedRight) {
3589
+ return newIndexes;
3590
+ }
3591
+ return [
3592
+ ...new Set([
3593
+ ...leftPinnedIndexes,
3594
+ ...newIndexes,
3595
+ ...rightPinnedIndexes,
3596
+ ]),
3597
+ ];
3598
+ }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps));
3599
+ useMRT_VirtualizerScrollElement(columnVirtualizer);
3600
+ const virtualColumns = columnVirtualizer.getVirtualItems();
3601
+ columnVirtualizer.virtualColumns = virtualColumns;
3602
+ const numColumns = virtualColumns.length;
3603
+ if (numColumns) {
3604
+ const totalSize = columnVirtualizer.getTotalSize();
3605
+ const leftNonPinnedStart = ((_a = virtualColumns[numPinnedLeft]) === null || _a === void 0 ? void 0 : _a.start) || 0;
3606
+ const leftNonPinnedEnd = ((_b = virtualColumns[leftPinnedIndexes.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0;
3607
+ const rightNonPinnedStart = ((_c = virtualColumns[numColumns - numPinnedRight]) === null || _c === void 0 ? void 0 : _c.start) || 0;
3608
+ const rightNonPinnedEnd = ((_d = virtualColumns[numColumns - numPinnedRight - 1]) === null || _d === void 0 ? void 0 : _d.end) || 0;
3609
+ columnVirtualizer.virtualPaddingLeft =
3610
+ leftNonPinnedStart - leftNonPinnedEnd;
3611
+ columnVirtualizer.virtualPaddingRight =
3612
+ totalSize -
3613
+ rightNonPinnedEnd -
3614
+ (numPinnedRight ? totalSize - rightNonPinnedStart : 0);
3615
+ }
3616
+ if (columnVirtualizerInstanceRef) {
3617
+ //@ts-ignore
3618
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
3619
+ }
3620
+ return columnVirtualizer;
3621
+ };
3622
+
3623
+ const MRT_Table = (_a) => {
3624
+ var { table } = _a, rest = __rest(_a, ["table"]);
3625
+ const { getFlatHeaders, getState, options: { columns, enableTableFooter, enableTableHead, layoutMode, mantineScrollAreaProps, mantineTableProps, memoMode, withScrollArea, }, } = table;
3626
+ const { columnSizing, columnSizingInfo, columnVisibility, density } = getState();
3627
+ const tableProps = Object.assign(Object.assign({ highlightOnHover: true, horizontalSpacing: density, verticalSpacing: density }, parseFromValuesOrFunc(mantineTableProps, { table })), rest);
3628
+ const columnSizeVars = react.useMemo(() => {
3629
+ const headers = getFlatHeaders();
3630
+ const colSizes = {};
3631
+ for (let i = 0; i < headers.length; i++) {
3632
+ const header = headers[i];
3633
+ const colSize = header.getSize();
3634
+ colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
3635
+ colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
3636
+ }
3637
+ return colSizes;
3638
+ }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
3639
+ const columnVirtualizer = useMRT_ColumnVirtualizer(table);
3640
+ const commonTableGroupProps = {
3641
+ columnVirtualizer,
3642
+ table,
3643
+ };
3644
+ const { colorScheme } = core.useMantineColorScheme();
3645
+ const { stripedColor } = tableProps;
3646
+ const tableNode = (jsxRuntime.jsxs(core.Table, Object.assign({ className: clsx('mrt-table', classes$6.root, (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) && classes$6['root-grid'], tableProps.className) }, tableProps, { __vars: Object.assign(Object.assign(Object.assign({}, columnSizeVars), { '--mrt-striped-row-background-color': stripedColor, '--mrt-striped-row-hover-background-color': stripedColor
3647
+ ? colorScheme === 'dark'
3648
+ ? core.lighten(stripedColor, 0.08)
3649
+ : core.darken(stripedColor, 0.12)
3650
+ : undefined }), tableProps.__vars), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps, { tableProps: tableProps }))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps, { tableProps: tableProps }))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
3651
+ if (!withScrollArea)
3652
+ return tableNode;
3653
+ const _b = Object.assign({ h: '100%', minWidth: '100%', offsetScrollbars: 'present', w: '100%' }, parseFromValuesOrFunc(mantineScrollAreaProps, { table })), { ref: scrollAreaRef, viewportRef } = _b, scrollContainerProps = __rest(_b, ["ref", "viewportRef"]);
3654
+ return (jsxRuntime.jsx(core.Table.ScrollContainer, Object.assign({}, scrollContainerProps, { className: clsx('mrt-table-scroll-area', scrollContainerProps.className),
3655
+ //Mantine hands over the viewport itself, and null when it unmounts, so
3656
+ //the ref does not depend on a class name and never keeps a removed node
3657
+ scrollAreaProps: Object.assign(Object.assign({}, scrollContainerProps.scrollAreaProps), { viewportRef: (node) => {
3658
+ var _a;
3659
+ table.refs.scrollAreaViewportRef.current = node;
3660
+ assignRef(scrollAreaRef, node);
3661
+ assignRef(viewportRef, node);
3662
+ assignRef((_a = scrollContainerProps.scrollAreaProps) === null || _a === void 0 ? void 0 : _a.viewportRef, node);
3663
+ } }), children: tableNode })));
3664
+ };
3665
+
3666
+ const MRT_EditRowModal = (_a) => {
3667
+ var _b;
3668
+ var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
3669
+ const { getState, options: { mantineCreateRowModalProps, mantineEditRowModalProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowModalContent, renderEditRowModalContent, }, setCreatingRow, setEditingRow, } = table;
3670
+ const { creatingRow, editingRow } = getState();
3671
+ const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
3672
+ const arg = { row, table };
3673
+ const modalProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineEditRowModalProps, arg)), (creatingRow && parseFromValuesOrFunc(mantineCreateRowModalProps, arg))), rest);
3674
+ const internalEditComponents = row
3675
+ .getAllCells()
3676
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
3677
+ .map((cell) => (jsxRuntime.jsx(MRT_EditCellTextInput, { cell: cell, table: table }, cell.id)));
3678
+ const handleCancel = () => {
3679
+ var _a;
3680
+ if (creatingRow) {
3681
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
3682
+ setCreatingRow(null);
3683
+ }
3684
+ else {
3685
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
3686
+ setEditingRow(null);
3687
+ }
3688
+ row._valuesCache = {}; //reset values cache
3689
+ (_a = modalProps.onClose) === null || _a === void 0 ? void 0 : _a.call(modalProps);
3690
+ };
3691
+ return (react.createElement(core.Modal, Object.assign({ opened: open, withCloseButton: false }, modalProps, { key: row.id, onClose: handleCancel }), (_b = ((creatingRow &&
3692
+ (renderCreateRowModalContent === null || renderCreateRowModalContent === void 0 ? void 0 : renderCreateRowModalContent({
3693
+ internalEditComponents,
3694
+ row,
3695
+ table,
3696
+ }))) ||
3697
+ (renderEditRowModalContent === null || renderEditRowModalContent === void 0 ? void 0 : renderEditRowModalContent({
3698
+ internalEditComponents,
3699
+ row,
3700
+ table,
3701
+ })))) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsxRuntime.jsx(core.Stack, { gap: "lg", pb: 24, pt: 16, children: internalEditComponents }) }), jsxRuntime.jsx(core.Flex, { justify: "flex-end", children: jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] }))));
3702
+ };
3703
+
3704
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react.useLayoutEffect : react.useEffect;
3705
+ const MRT_TableContainer = (_a) => {
3706
+ var _b;
3707
+ var { table } = _a, rest = __rest(_a, ["table"]);
3708
+ const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, mantineLoadingOverlayProps, mantineTableContainerProps, withScrollArea, }, refs: { bottomToolbarRef, tableContainerRef, tableHeadRef, topToolbarRef }, } = table;
3709
+ const { creatingRow, density, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3710
+ const [totalToolbarHeight, setTotalToolbarHeight] = react.useState(0);
3711
+ const [scrollOffset, setScrollOffset] = react.useState(0);
3712
+ const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTableContainerProps, { table })), rest);
3713
+ const loadingOverlayProps = parseFromValuesOrFunc(mantineLoadingOverlayProps, { table });
3714
+ useIsomorphicLayoutEffect(() => {
3715
+ var _a, _b, _c, _d;
3716
+ const topToolbarHeight = typeof document !== 'undefined'
3717
+ ? ((_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0)
3718
+ : 0;
3719
+ const bottomToolbarHeight = typeof document !== 'undefined'
3720
+ ? ((_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)
3721
+ : 0;
3722
+ setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
3723
+ }); //no dependency list: the bottom toolbar ref attaches after this effect first runs
3724
+ useIsomorphicLayoutEffect(() => {
3725
+ const setOffset = () => {
3726
+ var _a, _b;
3727
+ const offset = typeof document !== 'undefined'
3728
+ ? ((_b = (_a = tableHeadRef === null || tableHeadRef === void 0 ? void 0 : tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0)
3729
+ : 0;
3730
+ setScrollOffset(offset);
3731
+ };
3732
+ setOffset();
3733
+ const timeout = setTimeout(setOffset, 150);
3734
+ return () => clearTimeout(timeout);
3735
+ }, [(_b = tableHeadRef === null || tableHeadRef === void 0 ? void 0 : tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight, density]);
3736
+ const createModalOpen = createDisplayMode === 'modal' && creatingRow;
3737
+ const editModalOpen = editDisplayMode === 'modal' && editingRow;
3738
+ return (jsxRuntime.jsxs(core.Box, Object.assign({}, tableContainerProps, { __vars: Object.assign({ '--mrt-scroll-offset': `${scrollOffset}px`, '--mrt-top-toolbar-height': `${totalToolbarHeight}` }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.__vars), className: clsx('mrt-table-container', classes$7.root, enableStickyHeader && classes$7['root-sticky'], isFullScreen && classes$7['root-fullscreen'], withScrollArea && classes$7['root-scroll-area'], tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.className), ref: (node) => {
3739
+ if (node) {
3740
+ tableContainerRef.current = node;
3741
+ assignRef(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref, node);
3742
+ }
3743
+ }, children: [jsxRuntime.jsx(core.LoadingOverlay, Object.assign({ visible: isLoading || showLoadingOverlay, zIndex: 2 }, loadingOverlayProps)), jsxRuntime.jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsxRuntime.jsx(MRT_EditRowModal, { open: true, table: table }))] })));
3744
+ };
3745
+
3746
+ var commonClasses = {"common-toolbar-styles":"common-styles-module_common-toolbar-styles__DnjR8"};
3747
+
3748
+ var classes$5 = {"root":"MRT_BottomToolbar-module_root__VDeWo","root-fullscreen":"MRT_BottomToolbar-module_root-fullscreen__esE15","custom-toolbar-container":"MRT_BottomToolbar-module_custom-toolbar-container__XcDRF","paginator-container":"MRT_BottomToolbar-module_paginator-container__A3eWY","paginator-container-alert-banner":"MRT_BottomToolbar-module_paginator-container-alert-banner__gyqtO"};
3749
+
3750
+ var classes$4 = {"collapse":"MRT_ProgressBar-module_collapse__rOLJH","collapse-top":"MRT_ProgressBar-module_collapse-top__oCi0h"};
3751
+
3752
+ const MRT_ProgressBar = (_a) => {
3753
+ var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
3754
+ const { getState, options: { mantineProgressProps }, } = table;
3755
+ const { isSaving, showProgressBars } = getState();
3756
+ const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineProgressProps, {
3757
+ isTopToolbar,
3758
+ table,
3759
+ })), rest);
3760
+ return (jsxRuntime.jsx(core.Collapse, { className: clsx(classes$4.collapse, isTopToolbar && classes$4['collapse-top']), expanded: isSaving || showProgressBars, children: jsxRuntime.jsx(core.Progress, Object.assign({ animated: true, "aria-busy": "true", "aria-label": "Loading", radius: 0, value: 100 }, linearProgressProps)) }));
3761
+ };
3762
+
3763
+ var classes$3 = {"root":"MRT_TablePagination-module_root__yZ8pm","pagesize":"MRT_TablePagination-module_pagesize__-vmTn","with-top-margin":"MRT_TablePagination-module_with-top-margin__aM5-m"};
3764
+
3765
+ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100].map((x) => x.toString());
3766
+ const MRT_TablePagination = (_a) => {
3767
+ var _b;
3768
+ var { position = 'bottom', table } = _a, props = __rest(_a, ["position", "table"]);
3769
+ const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, icons: { IconChevronLeft, IconChevronLeftPipe, IconChevronRight, IconChevronRightPipe, }, localization, mantinePaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
3770
+ const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
3771
+ const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantinePaginationProps, {
3772
+ table,
3773
+ })), props);
3774
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
3775
+ const numberOfPages = Math.ceil(totalRowCount / pageSize);
3776
+ const showFirstLastPageButtons = numberOfPages > 2;
3777
+ const firstRowIndex = pageIndex * pageSize;
3778
+ const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3779
+ const _c = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { rowsPerPageOptions = defaultRowsPerPage, showRowsPerPage = true, withEdges = showFirstLastPageButtons } = _c, rest = __rest(_c, ["rowsPerPageOptions", "showRowsPerPage", "withEdges"]);
3780
+ const needsTopMargin = position === 'top' && enableToolbarInternalActions && !showGlobalFilter;
3781
+ //the 'pages' mode passes these to the Mantine Pagination component instead
3782
+ const isDefaultDisplayMode = paginationDisplayMode === 'default';
3783
+ const { styleProps } = core.extractStyleProps(rest);
3784
+ return (jsxRuntime.jsxs(core.Box, Object.assign({}, (isDefaultDisplayMode ? styleProps : undefined), { className: clsx('mrt-table-pagination', classes$3.root, needsTopMargin && classes$3['with-top-margin'], isDefaultDisplayMode && rest.className), style: isDefaultDisplayMode ? rest.style : undefined, children: [(paginationProps === null || paginationProps === void 0 ? void 0 : paginationProps.showRowsPerPage) !== false && (jsxRuntime.jsxs(core.Group, { gap: "xs", children: [jsxRuntime.jsx(core.Text, { id: "rpp-label", children: localization.rowsPerPage }), jsxRuntime.jsx(core.Select, { allowDeselect: false, "aria-labelledby": "rpp-label", className: classes$3.pagesize, data: (_b = paginationProps === null || paginationProps === void 0 ? void 0 : paginationProps.rowsPerPageOptions) !== null && _b !== void 0 ? _b : defaultRowsPerPage, onChange: (value) => setPageSize(+value), value: pageSize.toString() })] })), paginationDisplayMode === 'pages' ? (jsxRuntime.jsx(core.Pagination, Object.assign({ firstIcon: IconChevronLeftPipe, lastIcon: IconChevronRightPipe, nextIcon: IconChevronRight, onChange: (newPageIndex) => setPageIndex(newPageIndex - 1), previousIcon: IconChevronLeft, total: numberOfPages, value: pageIndex + 1, withEdges: withEdges }, rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(core.Text, { children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(core.Group, { gap: 6, children: [withEdges && (jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.goToFirstPage, color: "gray", disabled: pageIndex <= 0, onClick: () => setPageIndex(0), variant: "subtle", children: jsxRuntime.jsx(IconChevronLeftPipe, {}) })), jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.goToPreviousPage, color: "gray", disabled: pageIndex <= 0, onClick: () => setPageIndex(pageIndex - 1), variant: "subtle", children: jsxRuntime.jsx(IconChevronLeft, {}) }), jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.goToNextPage, color: "gray", disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(pageIndex + 1), variant: "subtle", children: jsxRuntime.jsx(IconChevronRight, {}) }), withEdges && (jsxRuntime.jsx(core.ActionIcon, { "aria-label": localization.goToLastPage, color: "gray", disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(numberOfPages - 1), variant: "subtle", children: jsxRuntime.jsx(IconChevronRightPipe, {}) }))] })] })) : null] })));
3785
+ };
3786
+
3787
+ var classes$2 = {"root":"MRT_ToolbarDropZone-module_root__eGTXb","hovered":"MRT_ToolbarDropZone-module_hovered__g7PeJ"};
3788
+
3789
+ const MRT_ToolbarDropZone = (_a) => {
3790
+ var { table } = _a, rest = __rest(_a, ["table"]);
3791
+ const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
3792
+ const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = getState();
3793
+ const handleDragEnter = (_event) => {
3794
+ setHoveredColumn({ id: 'drop-zone' });
3795
+ };
3796
+ react.useEffect(() => {
3797
+ var _a;
3798
+ if (((_a = table.options.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
3799
+ setShowToolbarDropZone(!!enableGrouping &&
3800
+ !!draggingColumn &&
3801
+ draggingColumn.columnDef.enableGrouping !== false &&
3802
+ !grouping.includes(draggingColumn.id));
3803
+ }
3804
+ }, [enableGrouping, draggingColumn, grouping]);
3805
+ return (jsxRuntime.jsx(core.Transition, { mounted: showToolbarDropZone, transition: "fade", children: () => {
3806
+ var _a, _b;
3807
+ return (jsxRuntime.jsx(core.Flex, Object.assign({ className: clsx('mrt-toolbar-dropzone', classes$2.root, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' && classes$2.hovered), onDragEnter: handleDragEnter }, rest, { children: jsxRuntime.jsx(core.Text, { children: localization.dropToGroupBy.replace('{column}', (_b = (_a = draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.columnDef) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : '') }) })));
3808
+ } }));
3809
+ };
3810
+
3811
+ const MRT_BottomToolbar = (_a) => {
3812
+ var { table } = _a, rest = __rest(_a, ["table"]);
3813
+ const { getState, options: { enablePagination, mantineBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
3814
+ const { isFullScreen } = getState();
3815
+ const isMobile = hooks.useMediaQuery('(max-width: 720px)');
3816
+ const toolbarProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineBottomToolbarProps, {
3817
+ table,
3818
+ })), rest);
3819
+ const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
3820
+ return (jsxRuntime.jsxs(core.Box, Object.assign({}, toolbarProps, { className: clsx('mrt-bottom-toolbar', classes$5.root, commonClasses['common-toolbar-styles'], isFullScreen && classes$5['root-fullscreen'], toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.className), ref: (node) => {
3821
+ if (node) {
3822
+ bottomToolbarRef.current = node;
3823
+ assignRef(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref, node);
3824
+ }
3825
+ }, children: [jsxRuntime.jsx(MRT_ProgressBar, { isTopToolbar: false, table: table }), positionToolbarAlertBanner === 'bottom' && (jsxRuntime.jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsxRuntime.jsx(MRT_ToolbarDropZone, { table: table })), jsxRuntime.jsxs(core.Box, { className: classes$5['custom-toolbar-container'], children: [renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (jsxRuntime.jsx("span", {})), jsxRuntime.jsx(core.Box, { className: clsx(classes$5['paginator-container'], stackAlertBanner && classes$5['paginator-container-alert-banner']), children: enablePagination &&
3826
+ ['both', 'bottom'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsxRuntime.jsx(MRT_TablePagination, { position: "bottom", table: table })) })] })] })));
3827
+ };
3828
+
3829
+ var classes$1 = {"root":"MRT_TopToolbar-module_root__r4-V9","root-fullscreen":"MRT_TopToolbar-module_root-fullscreen__3itT8","actions-container":"MRT_TopToolbar-module_actions-container__-uL0u","actions-container-stack-alert":"MRT_TopToolbar-module_actions-container-stack-alert__OYDL6"};
3830
+
3831
+ var classes = {"root":"MRT_ToolbarInternalButtons-module_root__NKoUG"};
3832
+
3833
+ const MRT_ToolbarInternalButtons = (_a) => {
3834
+ var _b;
3835
+ var { table } = _a, rest = __rest(_a, ["table"]);
3836
+ const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions, }, } = table;
3837
+ return (jsxRuntime.jsx(core.Flex, Object.assign({}, rest, { className: clsx('mrt-toolbar-internal-buttons', classes.root, rest === null || rest === void 0 ? void 0 : rest.className), children: (_b = renderToolbarInternalActions === null || renderToolbarInternalActions === void 0 ? void 0 : renderToolbarInternalActions({ table })) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [enableFilters &&
3838
+ enableGlobalFilter &&
3839
+ !(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsxRuntime.jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
3840
+ enableColumnFilters &&
3841
+ columnFilterDisplayMode !== 'popover' && (jsxRuntime.jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsxRuntime.jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsxRuntime.jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsxRuntime.jsx(MRT_ToggleFullScreenButton, { table: table }))] })) })));
3842
+ };
3843
+
3844
+ const MRT_TopToolbar = (_a) => {
3845
+ var _b;
3846
+ var { table } = _a, rest = __rest(_a, ["table"]);
3847
+ const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, mantineTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
3848
+ const { isFullScreen, showGlobalFilter } = getState();
3849
+ const isMobile = hooks.useMediaQuery('(max-width:720px)');
3850
+ const isTablet = hooks.useMediaQuery('(max-width:1024px)');
3851
+ const toolbarProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantineTopToolbarProps, { table })), rest);
3852
+ const stackAlertBanner = isMobile ||
3853
+ !!renderTopToolbarCustomActions ||
3854
+ (showGlobalFilter && isTablet);
3855
+ const globalFilterProps = {
3856
+ style: !isTablet
3857
+ ? {
3858
+ zIndex: 3,
3859
+ }
3860
+ : undefined,
3861
+ table,
3862
+ };
3863
+ return (jsxRuntime.jsxs(core.Box, Object.assign({}, toolbarProps, { className: clsx(commonClasses['common-toolbar-styles'], classes$1['root'], isFullScreen && classes$1['root-fullscreen'], toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.className), ref: (node) => {
3864
+ if (node) {
3865
+ topToolbarRef.current = node;
3866
+ assignRef(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref, node);
3867
+ }
3868
+ }, children: [positionToolbarAlertBanner === 'top' && (jsxRuntime.jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsxRuntime.jsx(MRT_ToolbarDropZone, { table: table })), jsxRuntime.jsxs(core.Flex, { className: clsx(classes$1['actions-container'], stackAlertBanner && classes$1['actions-container-stack-alert']), children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsxRuntime.jsx(MRT_GlobalFilterTextInput, Object.assign({}, globalFilterProps))), (_b = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _b !== void 0 ? _b : jsxRuntime.jsx("span", {}), enableToolbarInternalActions ? (jsxRuntime.jsxs(core.Flex, { justify: 'end', wrap: 'wrap-reverse', children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextInput, Object.assign({}, globalFilterProps))), jsxRuntime.jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
3869
+ positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextInput, Object.assign({}, globalFilterProps))))] }), enablePagination &&
3870
+ ['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsxRuntime.jsx(core.Flex, { justify: "end", children: jsxRuntime.jsx(MRT_TablePagination, { position: "top", table: table }) })), jsxRuntime.jsx(MRT_ProgressBar, { isTopToolbar: true, table: table })] })));
3871
+ };
3872
+
3873
+ const MRT_TablePaper = (_a) => {
3874
+ var _b, _c;
3875
+ var { table } = _a, rest = __rest(_a, ["table"]);
3876
+ const { getState, options: { enableBottomToolbar, enableTopToolbar, mantinePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
3877
+ const { isFullScreen } = getState();
3878
+ const tablePaperProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(mantinePaperProps, { table })), rest);
3879
+ return (jsxRuntime.jsxs(core.Paper, Object.assign({ shadow: "xs", withBorder: true }, tablePaperProps, { className: clsx('mrt-table-paper', classes$8.root, isFullScreen && 'mrt-table-paper-fullscreen', tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.className), ref: (ref) => {
3880
+ tablePaperRef.current = ref;
3881
+ assignRef(tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref, ref);
3882
+ },
3883
+ // rare case where we should use inline styles to guarantee highest specificity
3884
+ style: (theme) => (Object.assign(Object.assign({ zIndex: isFullScreen ? 200 : undefined }, parseFromValuesOrFunc(tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style, theme)), (isFullScreen
3885
+ ? {
3886
+ border: 0,
3887
+ borderRadius: 0,
3888
+ bottom: 0,
3889
+ height: '100vh',
3890
+ left: 0,
3891
+ margin: 0,
3892
+ maxHeight: '100vh',
3893
+ maxWidth: '100vw',
3894
+ padding: 0,
3895
+ position: 'fixed',
3896
+ right: 0,
3897
+ top: 0,
3898
+ width: '100vw',
3899
+ }
3900
+ : null))), children: [enableTopToolbar &&
3901
+ ((_b = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(MRT_TopToolbar, { table: table }))), jsxRuntime.jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
3902
+ ((_c = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _c !== void 0 ? _c : (jsxRuntime.jsx(MRT_BottomToolbar, { table: table })))] })));
3903
+ };
3904
+
3905
+ const isTableInstanceProp = (props) => props.table !== undefined;
3906
+ const MRT_TableFromOptions = (props) => jsxRuntime.jsx(MRT_TablePaper, { table: useMantineReactTable(props) });
3907
+ //two components keep the hook call unconditional (Rules of Hooks)
3908
+ const MantineReactTable = (props) => isTableInstanceProp(props) ? (jsxRuntime.jsx(MRT_TablePaper, { table: props.table })) : (jsxRuntime.jsx(MRT_TableFromOptions, Object.assign({}, props)));
3909
+
3910
+ exports.MRT_AggregationFns = MRT_AggregationFns;
3911
+ exports.MRT_BottomToolbar = MRT_BottomToolbar;
3912
+ exports.MRT_ColumnActionMenu = MRT_ColumnActionMenu;
3913
+ exports.MRT_ColumnPinningButtons = MRT_ColumnPinningButtons;
3914
+ exports.MRT_CopyButton = MRT_CopyButton;
3915
+ exports.MRT_DefaultColumn = MRT_DefaultColumn;
3916
+ exports.MRT_DefaultDisplayColumn = MRT_DefaultDisplayColumn;
3917
+ exports.MRT_EditActionButtons = MRT_EditActionButtons;
3918
+ exports.MRT_EditCellTextInput = MRT_EditCellTextInput;
3919
+ exports.MRT_EditRowModal = MRT_EditRowModal;
3920
+ exports.MRT_ExpandAllButton = MRT_ExpandAllButton;
3921
+ exports.MRT_ExpandButton = MRT_ExpandButton;
3922
+ exports.MRT_FilterCheckbox = MRT_FilterCheckbox;
3923
+ exports.MRT_FilterFns = MRT_FilterFns;
3924
+ exports.MRT_FilterOptionMenu = MRT_FilterOptionMenu;
3925
+ exports.MRT_FilterRangeFields = MRT_FilterRangeFields;
3926
+ exports.MRT_FilterRangeSlider = MRT_FilterRangeSlider;
3927
+ exports.MRT_FilterTextInput = MRT_FilterTextInput;
3928
+ exports.MRT_GlobalFilterTextInput = MRT_GlobalFilterTextInput;
3929
+ exports.MRT_GrabHandleButton = MRT_GrabHandleButton;
3930
+ exports.MRT_ProgressBar = MRT_ProgressBar;
3931
+ exports.MRT_RowActionMenu = MRT_RowActionMenu;
3932
+ exports.MRT_RowPinButton = MRT_RowPinButton;
3933
+ exports.MRT_SelectCheckbox = MRT_SelectCheckbox;
3934
+ exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
3935
+ exports.MRT_ShowHideColumnsMenu = MRT_ShowHideColumnsMenu;
3936
+ exports.MRT_ShowHideColumnsMenuItems = MRT_ShowHideColumnsMenuItems;
3937
+ exports.MRT_SortingFns = MRT_SortingFns;
3938
+ exports.MRT_Table = MRT_Table;
3939
+ exports.MRT_TableBody = MRT_TableBody;
3940
+ exports.MRT_TableBodyCell = MRT_TableBodyCell;
3941
+ exports.MRT_TableBodyCellValue = MRT_TableBodyCellValue;
3942
+ exports.MRT_TableBodyEmptyRow = MRT_TableBodyEmptyRow;
3943
+ exports.MRT_TableBodyRow = MRT_TableBodyRow;
3944
+ exports.MRT_TableBodyRowGrabHandle = MRT_TableBodyRowGrabHandle;
3945
+ exports.MRT_TableBodyRowPinButton = MRT_TableBodyRowPinButton;
3946
+ exports.MRT_TableContainer = MRT_TableContainer;
3947
+ exports.MRT_TableDetailPanel = MRT_TableDetailPanel;
3948
+ exports.MRT_TableFooter = MRT_TableFooter;
3949
+ exports.MRT_TableFooterCell = MRT_TableFooterCell;
3950
+ exports.MRT_TableFooterRow = MRT_TableFooterRow;
3951
+ exports.MRT_TableHead = MRT_TableHead;
3952
+ exports.MRT_TableHeadCell = MRT_TableHeadCell;
3953
+ exports.MRT_TableHeadCellFilterContainer = MRT_TableHeadCellFilterContainer;
3954
+ exports.MRT_TableHeadCellFilterLabel = MRT_TableHeadCellFilterLabel;
3955
+ exports.MRT_TableHeadCellGrabHandle = MRT_TableHeadCellGrabHandle;
3956
+ exports.MRT_TableHeadCellResizeHandle = MRT_TableHeadCellResizeHandle;
3957
+ exports.MRT_TableHeadCellSortLabel = MRT_TableHeadCellSortLabel;
3958
+ exports.MRT_TableHeadRow = MRT_TableHeadRow;
3959
+ exports.MRT_TablePagination = MRT_TablePagination;
3960
+ exports.MRT_TablePaper = MRT_TablePaper;
3961
+ exports.MRT_ToggleDensePaddingButton = MRT_ToggleDensePaddingButton;
3962
+ exports.MRT_ToggleFiltersButton = MRT_ToggleFiltersButton;
3963
+ exports.MRT_ToggleFullScreenButton = MRT_ToggleFullScreenButton;
3964
+ exports.MRT_ToggleGlobalFilterButton = MRT_ToggleGlobalFilterButton;
3965
+ exports.MRT_ToggleRowActionMenuButton = MRT_ToggleRowActionMenuButton;
3966
+ exports.MRT_ToolbarAlertBanner = MRT_ToolbarAlertBanner;
3967
+ exports.MRT_ToolbarDropZone = MRT_ToolbarDropZone;
3968
+ exports.MRT_ToolbarInternalButtons = MRT_ToolbarInternalButtons;
3969
+ exports.MRT_TopToolbar = MRT_TopToolbar;
3970
+ exports.MantineReactTable = MantineReactTable;
3971
+ exports.Memo_MRT_TableBody = Memo_MRT_TableBody;
3972
+ exports.Memo_MRT_TableBodyCell = Memo_MRT_TableBodyCell;
3973
+ exports.Memo_MRT_TableBodyRow = Memo_MRT_TableBodyRow;
3974
+ exports.assignRef = assignRef;
3975
+ exports.createMRTColumnHelper = createMRTColumnHelper;
3976
+ exports.createMRT_View = createMRT_View;
3977
+ exports.createRow = createRow;
3978
+ exports.dataVariable = dataVariable;
3979
+ exports.defaultDisplayColumnProps = defaultDisplayColumnProps;
3980
+ exports.flexRender = flexRender;
3981
+ exports.getAllLeafColumnDefs = getAllLeafColumnDefs;
3982
+ exports.getCanRankRows = getCanRankRows;
3983
+ exports.getColumnId = getColumnId;
3984
+ exports.getDefaultColumnFilterFn = getDefaultColumnFilterFn;
3985
+ exports.getDefaultColumnOrderIds = getDefaultColumnOrderIds;
3986
+ exports.getIsRankingRows = getIsRankingRows;
3987
+ exports.getIsRowSelected = getIsRowSelected;
3988
+ exports.getLeadingDisplayColumnIds = getLeadingDisplayColumnIds;
3989
+ exports.getMRT_CellView = getMRT_CellView;
3990
+ exports.getMRT_ColumnView = getMRT_ColumnView;
3991
+ exports.getMRT_HeaderView = getMRT_HeaderView;
3992
+ exports.getMRT_RowSelectionHandler = getMRT_RowSelectionHandler;
3993
+ exports.getMRT_RowView = getMRT_RowView;
3994
+ exports.getMRT_Rows = getMRT_Rows;
3995
+ exports.getMRT_SelectAllHandler = getMRT_SelectAllHandler;
3996
+ exports.getMRT_ViewTarget = getMRT_ViewTarget;
3997
+ exports.getPrimaryColor = getPrimaryColor;
3998
+ exports.getPrimaryShade = getPrimaryShade;
3999
+ exports.getTrailingDisplayColumnIds = getTrailingDisplayColumnIds;
4000
+ exports.isSkeletonRow = isSkeletonRow;
4001
+ exports.localizedFilterOption = localizedFilterOption;
4002
+ exports.mrtFilterOptions = mrtFilterOptions;
4003
+ exports.parseCSSVarId = parseCSSVarId;
4004
+ exports.parseFromValuesOrFunc = parseFromValuesOrFunc;
4005
+ exports.prepareColumns = prepareColumns;
4006
+ exports.rankGlobalFuzzy = rankGlobalFuzzy;
4007
+ exports.reorderColumn = reorderColumn;
4008
+ exports.showRowActionsColumn = showRowActionsColumn;
4009
+ exports.showRowDragColumn = showRowDragColumn;
4010
+ exports.showRowExpandColumn = showRowExpandColumn;
4011
+ exports.showRowNumbersColumn = showRowNumbersColumn;
4012
+ exports.showRowPinningColumn = showRowPinningColumn;
4013
+ exports.showRowSelectionColumn = showRowSelectionColumn;
4014
+ exports.showRowSpacerColumn = showRowSpacerColumn;
4015
+ exports.skeletonRowKey = skeletonRowKey;
4016
+ exports.useMRT_ColumnVirtualizer = useMRT_ColumnVirtualizer;
4017
+ exports.useMRT_Effects = useMRT_Effects;
4018
+ exports.useMRT_RowVirtualizer = useMRT_RowVirtualizer;
4019
+ exports.useMRT_Rows = useMRT_Rows;
4020
+ exports.useMRT_TableInstance = useMRT_TableInstance;
4021
+ exports.useMRT_TableOptions = useMRT_TableOptions;
4022
+ exports.useMantineReactTable = useMantineReactTable;
4023
+ //# sourceMappingURL=index.cjs.map