@lminii/material-react-table 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (349) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +234 -0
  3. package/dist/index.d.mts +2408 -0
  4. package/dist/index.d.ts +2408 -0
  5. package/dist/index.js +4825 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +4631 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/locales/ar/index.d.mts +3 -0
  10. package/locales/ar/index.d.ts +3 -0
  11. package/locales/ar/index.js +100 -0
  12. package/locales/ar/index.mjs +96 -0
  13. package/locales/ar/package.json +6 -0
  14. package/locales/az/index.d.mts +3 -0
  15. package/locales/az/index.d.ts +3 -0
  16. package/locales/az/index.js +100 -0
  17. package/locales/az/index.mjs +96 -0
  18. package/locales/az/package.json +6 -0
  19. package/locales/bg/index.d.mts +3 -0
  20. package/locales/bg/index.d.ts +3 -0
  21. package/locales/bg/index.js +100 -0
  22. package/locales/bg/index.mjs +96 -0
  23. package/locales/bg/package.json +6 -0
  24. package/locales/cs/index.d.mts +3 -0
  25. package/locales/cs/index.d.ts +3 -0
  26. package/locales/cs/index.js +100 -0
  27. package/locales/cs/index.mjs +96 -0
  28. package/locales/cs/package.json +6 -0
  29. package/locales/da/index.d.mts +3 -0
  30. package/locales/da/index.d.ts +3 -0
  31. package/locales/da/index.js +100 -0
  32. package/locales/da/index.mjs +96 -0
  33. package/locales/da/package.json +6 -0
  34. package/locales/de/index.d.mts +3 -0
  35. package/locales/de/index.d.ts +3 -0
  36. package/locales/de/index.js +100 -0
  37. package/locales/de/index.mjs +96 -0
  38. package/locales/de/package.json +6 -0
  39. package/locales/el/index.d.mts +3 -0
  40. package/locales/el/index.d.ts +3 -0
  41. package/locales/el/index.js +100 -0
  42. package/locales/el/index.mjs +96 -0
  43. package/locales/el/package.json +6 -0
  44. package/locales/en/index.d.mts +3 -0
  45. package/locales/en/index.d.ts +3 -0
  46. package/locales/en/index.js +100 -0
  47. package/locales/en/index.mjs +96 -0
  48. package/locales/en/package.json +6 -0
  49. package/locales/es/index.d.mts +3 -0
  50. package/locales/es/index.d.ts +3 -0
  51. package/locales/es/index.js +100 -0
  52. package/locales/es/index.mjs +96 -0
  53. package/locales/es/package.json +6 -0
  54. package/locales/et/index.d.mts +3 -0
  55. package/locales/et/index.d.ts +3 -0
  56. package/locales/et/index.js +100 -0
  57. package/locales/et/index.mjs +96 -0
  58. package/locales/et/package.json +6 -0
  59. package/locales/fa/index.d.mts +3 -0
  60. package/locales/fa/index.d.ts +3 -0
  61. package/locales/fa/index.js +100 -0
  62. package/locales/fa/index.mjs +96 -0
  63. package/locales/fa/package.json +6 -0
  64. package/locales/fi/index.d.mts +3 -0
  65. package/locales/fi/index.d.ts +3 -0
  66. package/locales/fi/index.js +100 -0
  67. package/locales/fi/index.mjs +96 -0
  68. package/locales/fi/package.json +6 -0
  69. package/locales/fr/index.d.mts +3 -0
  70. package/locales/fr/index.d.ts +3 -0
  71. package/locales/fr/index.js +100 -0
  72. package/locales/fr/index.mjs +96 -0
  73. package/locales/fr/package.json +6 -0
  74. package/locales/he/index.d.mts +3 -0
  75. package/locales/he/index.d.ts +3 -0
  76. package/locales/he/index.js +100 -0
  77. package/locales/he/index.mjs +96 -0
  78. package/locales/he/package.json +6 -0
  79. package/locales/hr/index.d.mts +3 -0
  80. package/locales/hr/index.d.ts +3 -0
  81. package/locales/hr/index.js +100 -0
  82. package/locales/hr/index.mjs +96 -0
  83. package/locales/hr/package.json +6 -0
  84. package/locales/hu/index.d.mts +3 -0
  85. package/locales/hu/index.d.ts +3 -0
  86. package/locales/hu/index.js +100 -0
  87. package/locales/hu/index.mjs +96 -0
  88. package/locales/hu/package.json +6 -0
  89. package/locales/hy/index.d.mts +3 -0
  90. package/locales/hy/index.d.ts +3 -0
  91. package/locales/hy/index.js +100 -0
  92. package/locales/hy/index.mjs +96 -0
  93. package/locales/hy/package.json +6 -0
  94. package/locales/id/index.d.mts +3 -0
  95. package/locales/id/index.d.ts +3 -0
  96. package/locales/id/index.js +100 -0
  97. package/locales/id/index.mjs +96 -0
  98. package/locales/id/package.json +6 -0
  99. package/locales/it/index.d.mts +3 -0
  100. package/locales/it/index.d.ts +3 -0
  101. package/locales/it/index.js +100 -0
  102. package/locales/it/index.mjs +96 -0
  103. package/locales/it/package.json +6 -0
  104. package/locales/ja/index.d.mts +3 -0
  105. package/locales/ja/index.d.ts +3 -0
  106. package/locales/ja/index.js +100 -0
  107. package/locales/ja/index.mjs +96 -0
  108. package/locales/ja/package.json +6 -0
  109. package/locales/ko/index.d.mts +3 -0
  110. package/locales/ko/index.d.ts +3 -0
  111. package/locales/ko/index.js +100 -0
  112. package/locales/ko/index.mjs +96 -0
  113. package/locales/ko/package.json +6 -0
  114. package/locales/nl/index.d.mts +3 -0
  115. package/locales/nl/index.d.ts +3 -0
  116. package/locales/nl/index.js +100 -0
  117. package/locales/nl/index.mjs +96 -0
  118. package/locales/nl/package.json +6 -0
  119. package/locales/no/index.d.mts +3 -0
  120. package/locales/no/index.d.ts +3 -0
  121. package/locales/no/index.js +100 -0
  122. package/locales/no/index.mjs +96 -0
  123. package/locales/no/package.json +6 -0
  124. package/locales/np/index.d.mts +3 -0
  125. package/locales/np/index.d.ts +3 -0
  126. package/locales/np/index.js +100 -0
  127. package/locales/np/index.mjs +96 -0
  128. package/locales/np/package.json +6 -0
  129. package/locales/pl/index.d.mts +3 -0
  130. package/locales/pl/index.d.ts +3 -0
  131. package/locales/pl/index.js +100 -0
  132. package/locales/pl/index.mjs +96 -0
  133. package/locales/pl/package.json +6 -0
  134. package/locales/pt/index.d.mts +3 -0
  135. package/locales/pt/index.d.ts +3 -0
  136. package/locales/pt/index.js +100 -0
  137. package/locales/pt/index.mjs +96 -0
  138. package/locales/pt/package.json +6 -0
  139. package/locales/pt-BR/index.d.mts +3 -0
  140. package/locales/pt-BR/index.d.ts +3 -0
  141. package/locales/pt-BR/index.js +100 -0
  142. package/locales/pt-BR/index.mjs +96 -0
  143. package/locales/pt-BR/package.json +6 -0
  144. package/locales/ro/index.d.mts +3 -0
  145. package/locales/ro/index.d.ts +3 -0
  146. package/locales/ro/index.js +100 -0
  147. package/locales/ro/index.mjs +96 -0
  148. package/locales/ro/package.json +6 -0
  149. package/locales/ru/index.d.mts +3 -0
  150. package/locales/ru/index.d.ts +3 -0
  151. package/locales/ru/index.js +100 -0
  152. package/locales/ru/index.mjs +96 -0
  153. package/locales/ru/package.json +6 -0
  154. package/locales/sk/index.d.mts +3 -0
  155. package/locales/sk/index.d.ts +3 -0
  156. package/locales/sk/index.js +100 -0
  157. package/locales/sk/index.mjs +96 -0
  158. package/locales/sk/package.json +6 -0
  159. package/locales/sr-Cyrl-RS/index.d.mts +3 -0
  160. package/locales/sr-Cyrl-RS/index.d.ts +3 -0
  161. package/locales/sr-Cyrl-RS/index.js +100 -0
  162. package/locales/sr-Cyrl-RS/index.mjs +96 -0
  163. package/locales/sr-Cyrl-RS/package.json +6 -0
  164. package/locales/sr-Latn-RS/index.d.mts +3 -0
  165. package/locales/sr-Latn-RS/index.d.ts +3 -0
  166. package/locales/sr-Latn-RS/index.js +100 -0
  167. package/locales/sr-Latn-RS/index.mjs +96 -0
  168. package/locales/sr-Latn-RS/package.json +6 -0
  169. package/locales/sv/index.d.mts +3 -0
  170. package/locales/sv/index.d.ts +3 -0
  171. package/locales/sv/index.js +100 -0
  172. package/locales/sv/index.mjs +96 -0
  173. package/locales/sv/package.json +6 -0
  174. package/locales/tr/index.d.mts +3 -0
  175. package/locales/tr/index.d.ts +3 -0
  176. package/locales/tr/index.js +100 -0
  177. package/locales/tr/index.mjs +96 -0
  178. package/locales/tr/package.json +6 -0
  179. package/locales/uk/index.d.mts +3 -0
  180. package/locales/uk/index.d.ts +3 -0
  181. package/locales/uk/index.js +100 -0
  182. package/locales/uk/index.mjs +96 -0
  183. package/locales/uk/package.json +6 -0
  184. package/locales/vi/index.d.mts +3 -0
  185. package/locales/vi/index.d.ts +3 -0
  186. package/locales/vi/index.js +100 -0
  187. package/locales/vi/index.mjs +96 -0
  188. package/locales/vi/package.json +6 -0
  189. package/locales/zh-Hans/index.d.mts +3 -0
  190. package/locales/zh-Hans/index.d.ts +3 -0
  191. package/locales/zh-Hans/index.js +100 -0
  192. package/locales/zh-Hans/index.mjs +96 -0
  193. package/locales/zh-Hans/package.json +6 -0
  194. package/locales/zh-Hant/index.d.mts +3 -0
  195. package/locales/zh-Hant/index.d.ts +3 -0
  196. package/locales/zh-Hant/index.js +100 -0
  197. package/locales/zh-Hant/index.mjs +96 -0
  198. package/locales/zh-Hant/package.json +6 -0
  199. package/package.json +147 -0
  200. package/skills/README.md +81 -0
  201. package/skills/composable-components/SKILL.md +189 -0
  202. package/skills/customization/SKILL.md +190 -0
  203. package/skills/drag-and-drop-ordering/SKILL.md +227 -0
  204. package/skills/editing/SKILL.md +243 -0
  205. package/skills/filtering/SKILL.md +213 -0
  206. package/skills/getting-started/SKILL.md +213 -0
  207. package/skills/localization/SKILL.md +182 -0
  208. package/skills/migrate-v3-to-v4/SKILL.md +161 -0
  209. package/skills/state-and-server-data/SKILL.md +200 -0
  210. package/skills/virtualization/SKILL.md +203 -0
  211. package/src/components/MaterialReactTable.tsx +36 -0
  212. package/src/components/body/MRT_TableBody.tsx +221 -0
  213. package/src/components/body/MRT_TableBodyCell.tsx +351 -0
  214. package/src/components/body/MRT_TableBodyCellValue.tsx +130 -0
  215. package/src/components/body/MRT_TableBodyRow.tsx +288 -0
  216. package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +61 -0
  217. package/src/components/body/MRT_TableBodyRowPinButton.tsx +58 -0
  218. package/src/components/body/MRT_TableDetailPanel.tsx +110 -0
  219. package/src/components/buttons/MRT_ColumnPinningButtons.tsx +72 -0
  220. package/src/components/buttons/MRT_CopyButton.tsx +87 -0
  221. package/src/components/buttons/MRT_EditActionButtons.tsx +134 -0
  222. package/src/components/buttons/MRT_ExpandAllButton.tsx +78 -0
  223. package/src/components/buttons/MRT_ExpandButton.tsx +102 -0
  224. package/src/components/buttons/MRT_GrabHandleButton.tsx +65 -0
  225. package/src/components/buttons/MRT_RowPinButton.tsx +84 -0
  226. package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +50 -0
  227. package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +52 -0
  228. package/src/components/buttons/MRT_ToggleFiltersButton.tsx +40 -0
  229. package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +51 -0
  230. package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +46 -0
  231. package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +126 -0
  232. package/src/components/footer/MRT_TableFooter.tsx +88 -0
  233. package/src/components/footer/MRT_TableFooterCell.tsx +107 -0
  234. package/src/components/footer/MRT_TableFooterRow.tsx +95 -0
  235. package/src/components/head/MRT_TableHead.tsx +91 -0
  236. package/src/components/head/MRT_TableHeadCell.tsx +351 -0
  237. package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +96 -0
  238. package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +52 -0
  239. package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +178 -0
  240. package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +91 -0
  241. package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +96 -0
  242. package/src/components/head/MRT_TableHeadCellSortLabel.tsx +101 -0
  243. package/src/components/head/MRT_TableHeadRow.tsx +90 -0
  244. package/src/components/inputs/MRT_EditCellTextField.tsx +202 -0
  245. package/src/components/inputs/MRT_FilterCheckbox.tsx +90 -0
  246. package/src/components/inputs/MRT_FilterRangeFields.tsx +41 -0
  247. package/src/components/inputs/MRT_FilterRangeSlider.tsx +143 -0
  248. package/src/components/inputs/MRT_FilterTextField.tsx +592 -0
  249. package/src/components/inputs/MRT_GlobalFilterTextField.tsx +167 -0
  250. package/src/components/inputs/MRT_SelectCheckbox.tsx +135 -0
  251. package/src/components/menus/MRT_ActionMenuItem.tsx +62 -0
  252. package/src/components/menus/MRT_CellActionMenu.tsx +107 -0
  253. package/src/components/menus/MRT_ColumnActionMenu.tsx +352 -0
  254. package/src/components/menus/MRT_FilterOptionMenu.tsx +292 -0
  255. package/src/components/menus/MRT_RowActionMenu.tsx +88 -0
  256. package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +181 -0
  257. package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +203 -0
  258. package/src/components/modals/MRT_EditRowModal.tsx +114 -0
  259. package/src/components/table/MRT_Table.tsx +84 -0
  260. package/src/components/table/MRT_TableContainer.tsx +111 -0
  261. package/src/components/table/MRT_TableLoadingOverlay.tsx +58 -0
  262. package/src/components/table/MRT_TablePaper.tsx +89 -0
  263. package/src/components/toolbar/MRT_BottomToolbar.tsx +111 -0
  264. package/src/components/toolbar/MRT_LinearProgressBar.tsx +53 -0
  265. package/src/components/toolbar/MRT_TablePagination.tsx +241 -0
  266. package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +184 -0
  267. package/src/components/toolbar/MRT_ToolbarDropZone.tsx +83 -0
  268. package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +72 -0
  269. package/src/components/toolbar/MRT_TopToolbar.tsx +130 -0
  270. package/src/features/mrtCellActionsFeature.ts +67 -0
  271. package/src/features/mrtColumnDraggingFeature.ts +83 -0
  272. package/src/features/mrtDensityFeature.ts +64 -0
  273. package/src/features/mrtEditingFeature.ts +102 -0
  274. package/src/features/mrtFeatures.ts +103 -0
  275. package/src/features/mrtFilterModesFeature.ts +99 -0
  276. package/src/features/mrtFnsFeature.ts +46 -0
  277. package/src/features/mrtFullScreenFeature.ts +63 -0
  278. package/src/features/mrtLoadingFeature.ts +35 -0
  279. package/src/features/mrtRefsFeature.ts +60 -0
  280. package/src/features/mrtRowDraggingFeature.ts +81 -0
  281. package/src/features/mrtStateCompatFeature.ts +43 -0
  282. package/src/features/mrtToolbarsFeature.ts +76 -0
  283. package/src/fns/aggregationFns.ts +3 -0
  284. package/src/fns/filterFns.ts +196 -0
  285. package/src/fns/sortingFns.ts +31 -0
  286. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +28 -0
  287. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +29 -0
  288. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +97 -0
  289. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +30 -0
  290. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +24 -0
  291. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +34 -0
  292. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +33 -0
  293. package/src/hooks/useMRT_ColumnVirtualizer.ts +124 -0
  294. package/src/hooks/useMRT_Effects.ts +108 -0
  295. package/src/hooks/useMRT_RowVirtualizer.ts +88 -0
  296. package/src/hooks/useMRT_Rows.ts +44 -0
  297. package/src/hooks/useMRT_TableInstance.ts +181 -0
  298. package/src/hooks/useMRT_TableOptions.ts +241 -0
  299. package/src/hooks/useMaterialReactTable.ts +12 -0
  300. package/src/icons.ts +73 -0
  301. package/src/index.ts +91 -0
  302. package/src/locales/ar.ts +97 -0
  303. package/src/locales/az.ts +97 -0
  304. package/src/locales/bg.ts +97 -0
  305. package/src/locales/cs.ts +98 -0
  306. package/src/locales/da.ts +97 -0
  307. package/src/locales/de.ts +97 -0
  308. package/src/locales/el.ts +97 -0
  309. package/src/locales/en.ts +97 -0
  310. package/src/locales/es.ts +97 -0
  311. package/src/locales/et.ts +98 -0
  312. package/src/locales/fa.ts +97 -0
  313. package/src/locales/fi.ts +98 -0
  314. package/src/locales/fr.ts +97 -0
  315. package/src/locales/he.ts +97 -0
  316. package/src/locales/hr.ts +97 -0
  317. package/src/locales/hu.ts +97 -0
  318. package/src/locales/hy.ts +97 -0
  319. package/src/locales/id.ts +98 -0
  320. package/src/locales/it.ts +97 -0
  321. package/src/locales/ja.ts +97 -0
  322. package/src/locales/ko.ts +97 -0
  323. package/src/locales/mk.ts +96 -0
  324. package/src/locales/nl.ts +97 -0
  325. package/src/locales/no.ts +99 -0
  326. package/src/locales/np.ts +98 -0
  327. package/src/locales/pl.ts +97 -0
  328. package/src/locales/pt-BR.ts +97 -0
  329. package/src/locales/pt.ts +97 -0
  330. package/src/locales/ro.ts +97 -0
  331. package/src/locales/ru.ts +97 -0
  332. package/src/locales/sk.ts +98 -0
  333. package/src/locales/sr-Cyrl-RS.ts +97 -0
  334. package/src/locales/sr-Latn-RS.ts +97 -0
  335. package/src/locales/sv.ts +97 -0
  336. package/src/locales/tr.ts +97 -0
  337. package/src/locales/uk.ts +97 -0
  338. package/src/locales/vi.ts +97 -0
  339. package/src/locales/zh-Hans.ts +96 -0
  340. package/src/locales/zh-Hant.ts +96 -0
  341. package/src/types.ts +1314 -0
  342. package/src/utils/cell.utils.ts +234 -0
  343. package/src/utils/column.utils.ts +204 -0
  344. package/src/utils/displayColumn.utils.ts +152 -0
  345. package/src/utils/row.utils.ts +258 -0
  346. package/src/utils/style.utils.ts +211 -0
  347. package/src/utils/tanstack.helpers.ts +64 -0
  348. package/src/utils/utils.ts +34 -0
  349. package/src/utils/virtualization.utils.ts +24 -0
@@ -0,0 +1,134 @@
1
+ import Box, { type BoxProps } from '@mui/material/Box';
2
+ import Button from '@mui/material/Button';
3
+ import CircularProgress from '@mui/material/CircularProgress';
4
+ import IconButton from '@mui/material/IconButton';
5
+ import Tooltip from '@mui/material/Tooltip';
6
+ import {
7
+ type MRT_Row,
8
+ type MRT_RowData,
9
+ type MRT_TableInstance,
10
+ } from '../../types';
11
+ import { parseFromValuesOrFunc } from '../../utils/utils';
12
+
13
+ export interface MRT_EditActionButtonsProps<TData extends MRT_RowData>
14
+ extends BoxProps {
15
+ row: MRT_Row<TData>;
16
+ table: MRT_TableInstance<TData>;
17
+ variant?: 'icon' | 'text';
18
+ }
19
+
20
+ export const MRT_EditActionButtons = <TData extends MRT_RowData>({
21
+ row,
22
+ table,
23
+ variant = 'icon',
24
+ ...rest
25
+ }: MRT_EditActionButtonsProps<TData>) => {
26
+ const {
27
+ options: {
28
+ icons: { CancelIcon, SaveIcon },
29
+ localization,
30
+ onCreatingRowCancel,
31
+ onCreatingRowSave,
32
+ onEditingRowCancel,
33
+ onEditingRowSave,
34
+ },
35
+ refs: { editInputRefs },
36
+ setCreatingRow,
37
+ setEditingRow,
38
+ state,
39
+ } = table;
40
+ const { creatingRow, editingRow, isSaving } = state;
41
+
42
+ const isCreating = creatingRow?.id === row.id;
43
+ const isEditing = editingRow?.id === row.id;
44
+
45
+ const handleCancel = () => {
46
+ if (isCreating) {
47
+ onCreatingRowCancel?.({ row, table });
48
+ setCreatingRow(null);
49
+ } else if (isEditing) {
50
+ onEditingRowCancel?.({ row, table });
51
+ setEditingRow(null);
52
+ }
53
+ row._valuesCache = {} as any; //reset values cache
54
+ };
55
+
56
+ const handleSubmitRow = () => {
57
+ //look for auto-filled input values
58
+ Object.values(editInputRefs.current ?? {})
59
+ .filter((inputRef) => row.id === inputRef?.name?.split('_')?.[0])
60
+ ?.forEach((input) => {
61
+ if (
62
+ input.value !== undefined &&
63
+ Object.hasOwn(row?._valuesCache as object, input.name)
64
+ ) {
65
+ // @ts-expect-error
66
+ row._valuesCache[input.name] = input.value;
67
+ }
68
+ });
69
+ if (isCreating)
70
+ onCreatingRowSave?.({
71
+ exitCreatingMode: () => setCreatingRow(null),
72
+ row,
73
+ table,
74
+ values: row._valuesCache,
75
+ });
76
+ else if (isEditing) {
77
+ onEditingRowSave?.({
78
+ exitEditingMode: () => setEditingRow(null),
79
+ row,
80
+ table,
81
+ values: row?._valuesCache,
82
+ });
83
+ }
84
+ };
85
+
86
+ return (
87
+ <Box
88
+ onClick={(e) => e.stopPropagation()}
89
+ sx={(theme) => ({
90
+ display: 'flex',
91
+ gap: '0.75rem',
92
+ ...(parseFromValuesOrFunc(rest?.sx, theme) as any),
93
+ })}
94
+ >
95
+ {variant === 'icon' ? (
96
+ <>
97
+ <Tooltip title={localization.cancel}>
98
+ <IconButton aria-label={localization.cancel} onClick={handleCancel}>
99
+ <CancelIcon />
100
+ </IconButton>
101
+ </Tooltip>
102
+ {((isCreating && onCreatingRowSave) ||
103
+ (isEditing && onEditingRowSave)) && (
104
+ <Tooltip title={localization.save}>
105
+ <IconButton
106
+ aria-label={localization.save}
107
+ color="info"
108
+ disabled={isSaving}
109
+ onClick={handleSubmitRow}
110
+ >
111
+ {isSaving ? <CircularProgress size={18} /> : <SaveIcon />}
112
+ </IconButton>
113
+ </Tooltip>
114
+ )}
115
+ </>
116
+ ) : (
117
+ <>
118
+ <Button onClick={handleCancel} sx={{ minWidth: '100px' }}>
119
+ {localization.cancel}
120
+ </Button>
121
+ <Button
122
+ disabled={isSaving}
123
+ onClick={handleSubmitRow}
124
+ sx={{ minWidth: '100px' }}
125
+ variant="contained"
126
+ >
127
+ {isSaving && <CircularProgress color="inherit" size={18} />}
128
+ {localization.save}
129
+ </Button>
130
+ </>
131
+ )}
132
+ </Box>
133
+ );
134
+ };
@@ -0,0 +1,78 @@
1
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
2
+ import Tooltip from '@mui/material/Tooltip';
3
+ import { type MRT_RowData, type MRT_TableInstance } from '../../types';
4
+ import { getCommonTooltipProps } from '../../utils/style.utils';
5
+ import { parseFromValuesOrFunc } from '../../utils/utils';
6
+
7
+ export interface MRT_ExpandAllButtonProps<TData extends MRT_RowData>
8
+ extends IconButtonProps {
9
+ table: MRT_TableInstance<TData>;
10
+ }
11
+
12
+ export const MRT_ExpandAllButton = <TData extends MRT_RowData>({
13
+ table,
14
+ ...rest
15
+ }: MRT_ExpandAllButtonProps<TData>) => {
16
+ const {
17
+ getCanSomeRowsExpand,
18
+ getIsAllRowsExpanded,
19
+ getIsSomeRowsExpanded,
20
+ options: {
21
+ icons: { KeyboardDoubleArrowDownIcon },
22
+ localization,
23
+ muiExpandAllButtonProps,
24
+ renderDetailPanel,
25
+ },
26
+ state,
27
+ toggleAllRowsExpanded,
28
+ } = table;
29
+ const { density, isLoading } = state;
30
+
31
+ const iconButtonProps = {
32
+ ...parseFromValuesOrFunc(muiExpandAllButtonProps, {
33
+ table,
34
+ }),
35
+ ...rest,
36
+ };
37
+
38
+ const isAllRowsExpanded = getIsAllRowsExpanded();
39
+
40
+ return (
41
+ <Tooltip
42
+ {...getCommonTooltipProps()}
43
+ title={
44
+ iconButtonProps?.title ??
45
+ (isAllRowsExpanded ? localization.collapseAll : localization.expandAll)
46
+ }
47
+ >
48
+ <span>
49
+ <IconButton
50
+ aria-label={localization.expandAll}
51
+ disabled={
52
+ isLoading || (!renderDetailPanel && !getCanSomeRowsExpand())
53
+ }
54
+ onClick={() => toggleAllRowsExpanded(!isAllRowsExpanded)}
55
+ {...iconButtonProps}
56
+ sx={(theme) => ({
57
+ height: density === 'compact' ? '1.75rem' : '2.25rem',
58
+ mt: density !== 'compact' ? '-0.25rem' : undefined,
59
+ width: density === 'compact' ? '1.75rem' : '2.25rem',
60
+ ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
61
+ })}
62
+ title={undefined}
63
+ >
64
+ {iconButtonProps?.children ?? (
65
+ <KeyboardDoubleArrowDownIcon
66
+ style={{
67
+ transform: `rotate(${
68
+ isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0
69
+ }deg)`,
70
+ transition: 'transform 150ms',
71
+ }}
72
+ />
73
+ )}
74
+ </IconButton>
75
+ </span>
76
+ </Tooltip>
77
+ );
78
+ };
@@ -0,0 +1,102 @@
1
+ import { type MouseEvent } from 'react';
2
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
3
+ import { useTheme } from '@mui/material/styles';
4
+ import Tooltip from '@mui/material/Tooltip';
5
+ import {
6
+ type MRT_Row,
7
+ type MRT_RowData,
8
+ type MRT_TableInstance,
9
+ } from '../../types';
10
+ import { getCommonTooltipProps } from '../../utils/style.utils';
11
+ import { parseFromValuesOrFunc } from '../../utils/utils';
12
+
13
+ export interface MRT_ExpandButtonProps<TData extends MRT_RowData>
14
+ extends IconButtonProps {
15
+ row: MRT_Row<TData>;
16
+ staticRowIndex?: number;
17
+ table: MRT_TableInstance<TData>;
18
+ }
19
+
20
+ export const MRT_ExpandButton = <TData extends MRT_RowData>({
21
+ row,
22
+ staticRowIndex,
23
+ table,
24
+ }: MRT_ExpandButtonProps<TData>) => {
25
+ const theme = useTheme();
26
+ const {
27
+ options: {
28
+ icons: { ExpandMoreIcon },
29
+ localization,
30
+ muiExpandButtonProps,
31
+ positionExpandColumn,
32
+ renderDetailPanel,
33
+ },
34
+ state,
35
+ } = table;
36
+ const { density } = state;
37
+
38
+ const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
39
+ row,
40
+ staticRowIndex,
41
+ table,
42
+ });
43
+
44
+ const canExpand = row.getCanExpand();
45
+ const isExpanded = row.getIsExpanded();
46
+
47
+ const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
48
+ event.stopPropagation();
49
+ row.toggleExpanded();
50
+ iconButtonProps?.onClick?.(event);
51
+ };
52
+
53
+ const detailPanel = !!renderDetailPanel?.({ row, table });
54
+
55
+ return (
56
+ <Tooltip
57
+ disableHoverListener={!canExpand && !detailPanel}
58
+ {...getCommonTooltipProps()}
59
+ title={
60
+ iconButtonProps?.title ??
61
+ (isExpanded ? localization.collapse : localization.expand)
62
+ }
63
+ >
64
+ <span>
65
+ <IconButton
66
+ aria-label={localization.expand}
67
+ disabled={!canExpand && !detailPanel}
68
+ {...iconButtonProps}
69
+ onClick={handleToggleExpand}
70
+ sx={(theme) => ({
71
+ height: density === 'compact' ? '1.75rem' : '2.25rem',
72
+ opacity: !canExpand && !detailPanel ? 0.3 : 1,
73
+ [theme.direction === 'rtl' || positionExpandColumn === 'last'
74
+ ? 'mr'
75
+ : 'ml']: `${row.depth * 16}px`,
76
+ width: density === 'compact' ? '1.75rem' : '2.25rem',
77
+ ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
78
+ })}
79
+ title={undefined}
80
+ >
81
+ {iconButtonProps?.children ?? (
82
+ <ExpandMoreIcon
83
+ style={{
84
+ transform: `rotate(${
85
+ !canExpand && !renderDetailPanel
86
+ ? positionExpandColumn === 'last' ||
87
+ theme.direction === 'rtl'
88
+ ? 90
89
+ : -90
90
+ : isExpanded
91
+ ? -180
92
+ : 0
93
+ }deg)`,
94
+ transition: 'transform 150ms',
95
+ }}
96
+ />
97
+ )}
98
+ </IconButton>
99
+ </span>
100
+ </Tooltip>
101
+ );
102
+ };
@@ -0,0 +1,65 @@
1
+ import { type DragEventHandler } from 'react';
2
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
3
+ import Tooltip from '@mui/material/Tooltip';
4
+ import { type MRT_RowData, type MRT_TableInstance } from '../../types';
5
+ import { getCommonTooltipProps } from '../../utils/style.utils';
6
+ import { parseFromValuesOrFunc } from '../../utils/utils';
7
+
8
+ export interface MRT_GrabHandleButtonProps<TData extends MRT_RowData>
9
+ extends IconButtonProps {
10
+ iconButtonProps?: IconButtonProps;
11
+ location?: 'column' | 'row';
12
+ onDragEnd: DragEventHandler<HTMLButtonElement>;
13
+ onDragStart: DragEventHandler<HTMLButtonElement>;
14
+ table: MRT_TableInstance<TData>;
15
+ }
16
+
17
+ export const MRT_GrabHandleButton = <TData extends MRT_RowData>({
18
+ location,
19
+ table,
20
+ ...rest
21
+ }: MRT_GrabHandleButtonProps<TData>) => {
22
+ const {
23
+ options: {
24
+ icons: { DragHandleIcon },
25
+ localization,
26
+ },
27
+ } = table;
28
+
29
+ return (
30
+ <Tooltip
31
+ {...getCommonTooltipProps('top')}
32
+ title={rest?.title ?? localization.move}
33
+ >
34
+ <IconButton
35
+ aria-label={rest.title ?? localization.move}
36
+ disableRipple
37
+ draggable="true"
38
+ size="small"
39
+ {...rest}
40
+ onClick={(e) => {
41
+ e.stopPropagation();
42
+ rest?.onClick?.(e);
43
+ }}
44
+ sx={(theme) => ({
45
+ '&:active': {
46
+ cursor: 'grabbing',
47
+ },
48
+ '&:hover': {
49
+ backgroundColor: 'transparent',
50
+ opacity: 1,
51
+ },
52
+ cursor: 'grab',
53
+ m: '0 -0.1rem',
54
+ opacity: location === 'row' ? 1 : 0.5,
55
+ p: '2px',
56
+ transition: 'all 150ms ease-in-out',
57
+ ...(parseFromValuesOrFunc(rest?.sx, theme) as any),
58
+ })}
59
+ title={undefined}
60
+ >
61
+ <DragHandleIcon />
62
+ </IconButton>
63
+ </Tooltip>
64
+ );
65
+ };
@@ -0,0 +1,84 @@
1
+ import { type MouseEvent, useState } from 'react';
2
+ import { type RowPinningPosition } from '@tanstack/react-table';
3
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
4
+ import Tooltip from '@mui/material/Tooltip';
5
+ import {
6
+ type MRT_Row,
7
+ type MRT_RowData,
8
+ type MRT_TableInstance,
9
+ } from '../../types';
10
+ import { getCommonTooltipProps } from '../../utils/style.utils';
11
+ import { parseFromValuesOrFunc } from '../../utils/utils';
12
+
13
+ export interface MRT_RowPinButtonProps<TData extends MRT_RowData>
14
+ extends IconButtonProps {
15
+ pinningPosition: RowPinningPosition;
16
+ row: MRT_Row<TData>;
17
+ table: MRT_TableInstance<TData>;
18
+ }
19
+
20
+ export const MRT_RowPinButton = <TData extends MRT_RowData>({
21
+ pinningPosition,
22
+ row,
23
+ table,
24
+ ...rest
25
+ }: MRT_RowPinButtonProps<TData>) => {
26
+ const {
27
+ options: {
28
+ icons: { CloseIcon, PushPinIcon },
29
+ localization,
30
+ rowPinningDisplayMode,
31
+ },
32
+ } = table;
33
+
34
+ const isPinned = row.getIsPinned();
35
+
36
+ const [tooltipOpened, setTooltipOpened] = useState(false);
37
+
38
+ const handleTogglePin = (event: MouseEvent<HTMLButtonElement>) => {
39
+ setTooltipOpened(false);
40
+ event.stopPropagation();
41
+ row.pin(isPinned ? false : pinningPosition);
42
+ };
43
+
44
+ return (
45
+ <Tooltip
46
+ {...getCommonTooltipProps()}
47
+ open={tooltipOpened}
48
+ title={isPinned ? localization.unpin : localization.pin}
49
+ >
50
+ <IconButton
51
+ aria-label={localization.pin}
52
+ onBlur={() => setTooltipOpened(false)}
53
+ onClick={handleTogglePin}
54
+ onFocus={() => setTooltipOpened(true)}
55
+ onMouseEnter={() => setTooltipOpened(true)}
56
+ onMouseLeave={() => setTooltipOpened(false)}
57
+ size="small"
58
+ {...rest}
59
+ sx={(theme) => ({
60
+ height: '24px',
61
+ width: '24px',
62
+ ...(parseFromValuesOrFunc(rest?.sx, theme) as any),
63
+ })}
64
+ >
65
+ {isPinned ? (
66
+ <CloseIcon />
67
+ ) : (
68
+ <PushPinIcon
69
+ fontSize="small"
70
+ style={{
71
+ transform: `rotate(${
72
+ rowPinningDisplayMode === 'sticky'
73
+ ? 135
74
+ : pinningPosition === 'top'
75
+ ? 180
76
+ : 0
77
+ }deg)`,
78
+ }}
79
+ />
80
+ )}
81
+ </IconButton>
82
+ </Tooltip>
83
+ );
84
+ };
@@ -0,0 +1,50 @@
1
+ import { type MouseEvent, useState } from 'react';
2
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
3
+ import Tooltip from '@mui/material/Tooltip';
4
+ import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
5
+ import { type MRT_RowData, type MRT_TableInstance } from '../../types';
6
+
7
+ export interface MRT_ShowHideColumnsButtonProps<TData extends MRT_RowData>
8
+ extends IconButtonProps {
9
+ table: MRT_TableInstance<TData>;
10
+ }
11
+
12
+ export const MRT_ShowHideColumnsButton = <TData extends MRT_RowData>({
13
+ table,
14
+ ...rest
15
+ }: MRT_ShowHideColumnsButtonProps<TData>) => {
16
+ const {
17
+ options: {
18
+ icons: { ViewColumnIcon },
19
+ localization,
20
+ },
21
+ } = table;
22
+
23
+ const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
24
+
25
+ const handleClick = (event: MouseEvent<HTMLElement>) => {
26
+ setAnchorEl(event.currentTarget);
27
+ };
28
+
29
+ return (
30
+ <>
31
+ <Tooltip title={rest?.title ?? localization.showHideColumns}>
32
+ <IconButton
33
+ aria-label={localization.showHideColumns}
34
+ onClick={handleClick}
35
+ {...rest}
36
+ title={undefined}
37
+ >
38
+ <ViewColumnIcon />
39
+ </IconButton>
40
+ </Tooltip>
41
+ {anchorEl && (
42
+ <MRT_ShowHideColumnsMenu
43
+ anchorEl={anchorEl}
44
+ setAnchorEl={setAnchorEl}
45
+ table={table}
46
+ />
47
+ )}
48
+ </>
49
+ );
50
+ };
@@ -0,0 +1,52 @@
1
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
2
+ import Tooltip from '@mui/material/Tooltip';
3
+ import { type MRT_RowData, type MRT_TableInstance } from '../../types';
4
+
5
+ export interface MRT_ToggleDensePaddingButtonProps<TData extends MRT_RowData>
6
+ extends IconButtonProps {
7
+ table: MRT_TableInstance<TData>;
8
+ }
9
+
10
+ export const MRT_ToggleDensePaddingButton = <TData extends MRT_RowData>({
11
+ table,
12
+ ...rest
13
+ }: MRT_ToggleDensePaddingButtonProps<TData>) => {
14
+ const {
15
+ options: {
16
+ icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon },
17
+ localization,
18
+ },
19
+ setDensity,
20
+ state,
21
+ } = table;
22
+ const { density } = state;
23
+
24
+ const handleToggleDensePadding = () => {
25
+ const nextDensity =
26
+ density === 'comfortable'
27
+ ? 'compact'
28
+ : density === 'compact'
29
+ ? 'spacious'
30
+ : 'comfortable';
31
+ setDensity(nextDensity);
32
+ };
33
+
34
+ return (
35
+ <Tooltip title={rest?.title ?? localization.toggleDensity}>
36
+ <IconButton
37
+ aria-label={localization.toggleDensity}
38
+ onClick={handleToggleDensePadding}
39
+ {...rest}
40
+ title={undefined}
41
+ >
42
+ {density === 'compact' ? (
43
+ <DensitySmallIcon />
44
+ ) : density === 'comfortable' ? (
45
+ <DensityMediumIcon />
46
+ ) : (
47
+ <DensityLargeIcon />
48
+ )}
49
+ </IconButton>
50
+ </Tooltip>
51
+ );
52
+ };
@@ -0,0 +1,40 @@
1
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
2
+ import Tooltip from '@mui/material/Tooltip';
3
+ import { type MRT_RowData, type MRT_TableInstance } from '../../types';
4
+
5
+ export interface MRT_ToggleFiltersButtonProps<TData extends MRT_RowData>
6
+ extends IconButtonProps {
7
+ table: MRT_TableInstance<TData>;
8
+ }
9
+
10
+ export const MRT_ToggleFiltersButton = <TData extends MRT_RowData>({
11
+ table,
12
+ ...rest
13
+ }: MRT_ToggleFiltersButtonProps<TData>) => {
14
+ const {
15
+ options: {
16
+ icons: { FilterListIcon, FilterListOffIcon },
17
+ localization,
18
+ },
19
+ setShowColumnFilters,
20
+ state,
21
+ } = table;
22
+ const { showColumnFilters } = state;
23
+
24
+ const handleToggleShowFilters = () => {
25
+ setShowColumnFilters(!showColumnFilters);
26
+ };
27
+
28
+ return (
29
+ <Tooltip title={rest?.title ?? localization.showHideFilters}>
30
+ <IconButton
31
+ aria-label={localization.showHideFilters}
32
+ onClick={handleToggleShowFilters}
33
+ {...rest}
34
+ title={undefined}
35
+ >
36
+ {showColumnFilters ? <FilterListOffIcon /> : <FilterListIcon />}
37
+ </IconButton>
38
+ </Tooltip>
39
+ );
40
+ };
@@ -0,0 +1,51 @@
1
+ import { useState } from 'react';
2
+ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
3
+ import Tooltip from '@mui/material/Tooltip';
4
+ import { type MRT_RowData, type MRT_TableInstance } from '../../types';
5
+
6
+ export interface MRT_ToggleFullScreenButtonProps<TData extends MRT_RowData>
7
+ extends IconButtonProps {
8
+ table: MRT_TableInstance<TData>;
9
+ }
10
+
11
+ export const MRT_ToggleFullScreenButton = <TData extends MRT_RowData>({
12
+ table,
13
+ ...rest
14
+ }: MRT_ToggleFullScreenButtonProps<TData>) => {
15
+ const {
16
+ options: {
17
+ icons: { FullscreenExitIcon, FullscreenIcon },
18
+ localization,
19
+ },
20
+ setIsFullScreen,
21
+ state,
22
+ } = table;
23
+ const { isFullScreen } = state;
24
+
25
+ const [tooltipOpened, setTooltipOpened] = useState(false);
26
+
27
+ const handleToggleFullScreen = () => {
28
+ setTooltipOpened(false);
29
+ setIsFullScreen(!isFullScreen);
30
+ };
31
+
32
+ return (
33
+ <Tooltip
34
+ open={tooltipOpened}
35
+ title={rest?.title ?? localization.toggleFullScreen}
36
+ >
37
+ <IconButton
38
+ aria-label={localization.toggleFullScreen}
39
+ onBlur={() => setTooltipOpened(false)}
40
+ onClick={handleToggleFullScreen}
41
+ onFocus={() => setTooltipOpened(true)}
42
+ onMouseEnter={() => setTooltipOpened(true)}
43
+ onMouseLeave={() => setTooltipOpened(false)}
44
+ {...rest}
45
+ title={undefined}
46
+ >
47
+ {isFullScreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
48
+ </IconButton>
49
+ </Tooltip>
50
+ );
51
+ };