material-react-table 1.15.0 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1624 -1269
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +7 -11
- package/dist/cjs/types/body/MRT_TableBody.d.ts +4 -5
- package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +5 -5
- package/dist/cjs/types/body/MRT_TableBodyCellValue.d.ts +4 -4
- package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +6 -6
- package/dist/cjs/types/body/MRT_TableBodyRowGrabHandle.d.ts +5 -5
- package/dist/cjs/types/body/MRT_TableBodyRowPinButton.d.ts +7 -0
- package/dist/cjs/types/body/MRT_TableDetailPanel.d.ts +6 -6
- package/dist/cjs/types/body/index.d.ts +7 -0
- package/dist/cjs/types/buttons/MRT_ColumnPinningButtons.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_CopyButton.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_EditActionButtons.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_ExpandAllButton.d.ts +3 -3
- package/dist/cjs/types/buttons/MRT_ExpandButton.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_GrabHandleButton.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_RowPinButton.d.ts +9 -0
- package/dist/cjs/types/buttons/MRT_ShowHideColumnsButton.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_ToggleFiltersButton.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_ToggleFullScreenButton.d.ts +7 -0
- package/dist/cjs/types/buttons/MRT_ToggleGlobalFilterButton.d.ts +2 -2
- package/dist/cjs/types/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -2
- package/dist/cjs/types/buttons/index.d.ts +13 -0
- package/dist/cjs/types/column.utils.d.ts +40 -51
- package/dist/cjs/types/filterFns.d.ts +14 -14
- package/dist/cjs/types/footer/MRT_TableFooter.d.ts +3 -3
- package/dist/cjs/types/footer/MRT_TableFooterCell.d.ts +4 -4
- package/dist/cjs/types/footer/MRT_TableFooterRow.d.ts +4 -4
- package/dist/cjs/types/footer/index.d.ts +3 -0
- package/dist/cjs/types/head/MRT_TableHead.d.ts +3 -3
- package/dist/cjs/types/head/MRT_TableHeadCell.d.ts +4 -4
- package/dist/cjs/types/head/MRT_TableHeadCellColumnActionsButton.d.ts +4 -4
- package/dist/cjs/types/head/MRT_TableHeadCellFilterContainer.d.ts +4 -4
- package/dist/cjs/types/head/MRT_TableHeadCellFilterLabel.d.ts +4 -4
- package/dist/cjs/types/head/MRT_TableHeadCellGrabHandle.d.ts +4 -4
- package/dist/cjs/types/head/MRT_TableHeadCellResizeHandle.d.ts +4 -4
- package/dist/cjs/types/head/MRT_TableHeadCellSortLabel.d.ts +4 -4
- package/dist/cjs/types/head/MRT_TableHeadRow.d.ts +4 -4
- package/dist/cjs/types/head/index.d.ts +9 -0
- package/dist/cjs/types/hooks/useMRT_DisplayColumns.d.ts +9 -0
- package/dist/cjs/types/hooks/useMRT_Effects.d.ts +2 -0
- package/dist/cjs/types/hooks/useMRT_TableInstance.d.ts +2 -0
- package/dist/cjs/types/hooks/useMRT_TableOptions.d.ts +2 -0
- package/dist/cjs/types/index.d.ts +14 -25
- package/dist/cjs/types/inputs/MRT_EditCellTextField.d.ts +2 -3
- package/dist/cjs/types/inputs/MRT_FilterCheckbox.d.ts +4 -4
- package/dist/cjs/types/inputs/MRT_FilterRangeFields.d.ts +4 -4
- package/dist/cjs/types/inputs/MRT_FilterRangeSlider.d.ts +4 -4
- package/dist/cjs/types/inputs/MRT_FilterTextField.d.ts +4 -4
- package/dist/cjs/types/inputs/MRT_GlobalFilterTextField.d.ts +2 -2
- package/dist/cjs/types/inputs/MRT_SelectCheckbox.d.ts +4 -4
- package/dist/cjs/types/inputs/index.d.ts +7 -0
- package/dist/cjs/types/locales/ar.d.ts +2 -0
- package/dist/cjs/types/locales/bg.d.ts +2 -0
- package/dist/cjs/types/locales/et.d.ts +2 -0
- package/dist/cjs/types/locales/ko.d.ts +2 -0
- package/dist/cjs/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/cjs/types/menus/MRT_FilterOptionMenu.d.ts +2 -2
- package/dist/cjs/types/menus/MRT_RowActionMenu.d.ts +4 -4
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenu.d.ts +2 -2
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -2
- package/dist/cjs/types/menus/index.d.ts +5 -0
- package/dist/cjs/types/modals/MRT_EditRowModal.d.ts +7 -0
- package/dist/cjs/types/modals/index.d.ts +1 -0
- package/dist/cjs/types/sortingFns.d.ts +3 -2
- package/dist/cjs/types/table/MRT_Table.d.ts +3 -3
- package/dist/cjs/types/table/MRT_TableContainer.d.ts +3 -3
- package/dist/cjs/types/table/MRT_TablePaper.d.ts +3 -3
- package/dist/cjs/types/table/index.d.ts +4 -0
- package/dist/cjs/types/toolbar/MRT_BottomToolbar.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_LinearProgressBar.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_ToolbarAlertBanner.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_ToolbarDropZone.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_ToolbarInternalButtons.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_TopToolbar.d.ts +2 -2
- package/dist/cjs/types/toolbar/index.d.ts +7 -0
- package/dist/cjs/types/types.d.ts +128 -91
- package/dist/cjs/types/useMaterialReactTable.d.ts +2 -0
- package/dist/esm/material-react-table.esm.js +1567 -1279
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +7 -11
- package/dist/esm/types/body/MRT_TableBody.d.ts +4 -5
- package/dist/esm/types/body/MRT_TableBodyCell.d.ts +5 -5
- package/dist/esm/types/body/MRT_TableBodyCellValue.d.ts +4 -4
- package/dist/esm/types/body/MRT_TableBodyRow.d.ts +6 -6
- package/dist/esm/types/body/MRT_TableBodyRowGrabHandle.d.ts +5 -5
- package/dist/esm/types/body/MRT_TableBodyRowPinButton.d.ts +7 -0
- package/dist/esm/types/body/MRT_TableDetailPanel.d.ts +6 -6
- package/dist/esm/types/body/index.d.ts +7 -0
- package/dist/esm/types/buttons/MRT_ColumnPinningButtons.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_CopyButton.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_EditActionButtons.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_ExpandAllButton.d.ts +3 -3
- package/dist/esm/types/buttons/MRT_ExpandButton.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_GrabHandleButton.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_RowPinButton.d.ts +9 -0
- package/dist/esm/types/buttons/MRT_ShowHideColumnsButton.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_ToggleFiltersButton.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_ToggleFullScreenButton.d.ts +7 -0
- package/dist/esm/types/buttons/MRT_ToggleGlobalFilterButton.d.ts +2 -2
- package/dist/esm/types/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -2
- package/dist/esm/types/buttons/index.d.ts +13 -0
- package/dist/esm/types/column.utils.d.ts +40 -51
- package/dist/esm/types/filterFns.d.ts +14 -14
- package/dist/esm/types/footer/MRT_TableFooter.d.ts +3 -3
- package/dist/esm/types/footer/MRT_TableFooterCell.d.ts +4 -4
- package/dist/esm/types/footer/MRT_TableFooterRow.d.ts +4 -4
- package/dist/esm/types/footer/index.d.ts +3 -0
- package/dist/esm/types/head/MRT_TableHead.d.ts +3 -3
- package/dist/esm/types/head/MRT_TableHeadCell.d.ts +4 -4
- package/dist/esm/types/head/MRT_TableHeadCellColumnActionsButton.d.ts +4 -4
- package/dist/esm/types/head/MRT_TableHeadCellFilterContainer.d.ts +4 -4
- package/dist/esm/types/head/MRT_TableHeadCellFilterLabel.d.ts +4 -4
- package/dist/esm/types/head/MRT_TableHeadCellGrabHandle.d.ts +4 -4
- package/dist/esm/types/head/MRT_TableHeadCellResizeHandle.d.ts +4 -4
- package/dist/esm/types/head/MRT_TableHeadCellSortLabel.d.ts +4 -4
- package/dist/esm/types/head/MRT_TableHeadRow.d.ts +4 -4
- package/dist/esm/types/head/index.d.ts +9 -0
- package/dist/esm/types/hooks/useMRT_DisplayColumns.d.ts +9 -0
- package/dist/esm/types/hooks/useMRT_Effects.d.ts +2 -0
- package/dist/esm/types/hooks/useMRT_TableInstance.d.ts +2 -0
- package/dist/esm/types/hooks/useMRT_TableOptions.d.ts +2 -0
- package/dist/esm/types/index.d.ts +14 -25
- package/dist/esm/types/inputs/MRT_EditCellTextField.d.ts +2 -3
- package/dist/esm/types/inputs/MRT_FilterCheckbox.d.ts +4 -4
- package/dist/esm/types/inputs/MRT_FilterRangeFields.d.ts +4 -4
- package/dist/esm/types/inputs/MRT_FilterRangeSlider.d.ts +4 -4
- package/dist/esm/types/inputs/MRT_FilterTextField.d.ts +4 -4
- package/dist/esm/types/inputs/MRT_GlobalFilterTextField.d.ts +2 -2
- package/dist/esm/types/inputs/MRT_SelectCheckbox.d.ts +4 -4
- package/dist/esm/types/inputs/index.d.ts +7 -0
- package/dist/esm/types/locales/ar.d.ts +2 -0
- package/dist/esm/types/locales/bg.d.ts +2 -0
- package/dist/esm/types/locales/et.d.ts +2 -0
- package/dist/esm/types/locales/ko.d.ts +2 -0
- package/dist/esm/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/esm/types/menus/MRT_FilterOptionMenu.d.ts +2 -2
- package/dist/esm/types/menus/MRT_RowActionMenu.d.ts +4 -4
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenu.d.ts +2 -2
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -2
- package/dist/esm/types/menus/index.d.ts +5 -0
- package/dist/esm/types/modals/MRT_EditRowModal.d.ts +7 -0
- package/dist/esm/types/modals/index.d.ts +1 -0
- package/dist/esm/types/sortingFns.d.ts +3 -2
- package/dist/esm/types/table/MRT_Table.d.ts +3 -3
- package/dist/esm/types/table/MRT_TableContainer.d.ts +3 -3
- package/dist/esm/types/table/MRT_TablePaper.d.ts +3 -3
- package/dist/esm/types/table/index.d.ts +4 -0
- package/dist/esm/types/toolbar/MRT_BottomToolbar.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_LinearProgressBar.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_ToolbarAlertBanner.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_ToolbarDropZone.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_ToolbarInternalButtons.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_TopToolbar.d.ts +2 -2
- package/dist/esm/types/toolbar/index.d.ts +7 -0
- package/dist/esm/types/types.d.ts +128 -91
- package/dist/esm/types/useMaterialReactTable.d.ts +2 -0
- package/dist/index.d.ts +626 -155
- package/locales/ar.d.ts +2 -0
- package/locales/ar.esm.d.ts +2 -0
- package/locales/ar.esm.js +93 -0
- package/locales/ar.esm.js.map +1 -0
- package/locales/ar.js +97 -0
- package/locales/ar.js.map +1 -0
- package/locales/bg.d.ts +2 -0
- package/locales/bg.esm.d.ts +2 -0
- package/locales/bg.esm.js +93 -0
- package/locales/bg.esm.js.map +1 -0
- package/locales/bg.js +97 -0
- package/locales/bg.js.map +1 -0
- package/locales/cs.esm.js +1 -2
- package/locales/cs.esm.js.map +1 -1
- package/locales/cs.js +1 -2
- package/locales/cs.js.map +1 -1
- package/locales/da.esm.js +0 -1
- package/locales/da.esm.js.map +1 -1
- package/locales/da.js +0 -1
- package/locales/da.js.map +1 -1
- package/locales/de.esm.js +0 -1
- package/locales/de.esm.js.map +1 -1
- package/locales/de.js +0 -1
- package/locales/de.js.map +1 -1
- package/locales/en.esm.js +1 -1
- package/locales/en.esm.js.map +1 -1
- package/locales/en.js +1 -1
- package/locales/en.js.map +1 -1
- package/locales/es.esm.js +0 -1
- package/locales/es.esm.js.map +1 -1
- package/locales/es.js +0 -1
- package/locales/es.js.map +1 -1
- package/locales/et.d.ts +2 -0
- package/locales/et.esm.d.ts +2 -0
- package/locales/et.esm.js +93 -0
- package/locales/et.esm.js.map +1 -0
- package/locales/et.js +97 -0
- package/locales/et.js.map +1 -0
- package/locales/fa.esm.js +0 -1
- package/locales/fa.esm.js.map +1 -1
- package/locales/fa.js +0 -1
- package/locales/fa.js.map +1 -1
- package/locales/fi.esm.js +0 -1
- package/locales/fi.esm.js.map +1 -1
- package/locales/fi.js +0 -1
- package/locales/fi.js.map +1 -1
- package/locales/fr.esm.js +0 -1
- package/locales/fr.esm.js.map +1 -1
- package/locales/fr.js +0 -1
- package/locales/fr.js.map +1 -1
- package/locales/hu.esm.js +0 -1
- package/locales/hu.esm.js.map +1 -1
- package/locales/hu.js +0 -1
- package/locales/hu.js.map +1 -1
- package/locales/id.esm.js +0 -1
- package/locales/id.esm.js.map +1 -1
- package/locales/id.js +0 -1
- package/locales/id.js.map +1 -1
- package/locales/it.esm.js +0 -1
- package/locales/it.esm.js.map +1 -1
- package/locales/it.js +0 -1
- package/locales/it.js.map +1 -1
- package/locales/ja.esm.js +0 -1
- package/locales/ja.esm.js.map +1 -1
- package/locales/ja.js +0 -1
- package/locales/ja.js.map +1 -1
- package/locales/ko.d.ts +2 -0
- package/locales/ko.esm.d.ts +2 -0
- package/locales/ko.esm.js +93 -0
- package/locales/ko.esm.js.map +1 -0
- package/locales/ko.js +97 -0
- package/locales/ko.js.map +1 -0
- package/locales/nl.esm.js +0 -1
- package/locales/nl.esm.js.map +1 -1
- package/locales/nl.js +0 -1
- package/locales/nl.js.map +1 -1
- package/locales/no.esm.js +0 -1
- package/locales/no.esm.js.map +1 -1
- package/locales/no.js +0 -1
- package/locales/no.js.map +1 -1
- package/locales/pl.esm.js +0 -1
- package/locales/pl.esm.js.map +1 -1
- package/locales/pl.js +0 -1
- package/locales/pl.js.map +1 -1
- package/locales/pt-BR.esm.js +0 -1
- package/locales/pt-BR.esm.js.map +1 -1
- package/locales/pt-BR.js +0 -1
- package/locales/pt-BR.js.map +1 -1
- package/locales/pt.esm.js +0 -1
- package/locales/pt.esm.js.map +1 -1
- package/locales/pt.js +0 -1
- package/locales/pt.js.map +1 -1
- package/locales/ro.esm.js +0 -1
- package/locales/ro.esm.js.map +1 -1
- package/locales/ro.js +0 -1
- package/locales/ro.js.map +1 -1
- package/locales/ru.esm.js +0 -1
- package/locales/ru.esm.js.map +1 -1
- package/locales/ru.js +0 -1
- package/locales/ru.js.map +1 -1
- package/locales/sk.esm.js +0 -1
- package/locales/sk.esm.js.map +1 -1
- package/locales/sk.js +0 -1
- package/locales/sk.js.map +1 -1
- package/locales/sr-Cyrl-RS.esm.js +0 -1
- package/locales/sr-Cyrl-RS.esm.js.map +1 -1
- package/locales/sr-Cyrl-RS.js +0 -1
- package/locales/sr-Cyrl-RS.js.map +1 -1
- package/locales/sr-Latn-RS.esm.js +0 -1
- package/locales/sr-Latn-RS.esm.js.map +1 -1
- package/locales/sr-Latn-RS.js +0 -1
- package/locales/sr-Latn-RS.js.map +1 -1
- package/locales/sv.esm.js +0 -1
- package/locales/sv.esm.js.map +1 -1
- package/locales/sv.js +0 -1
- package/locales/sv.js.map +1 -1
- package/package.json +18 -16
- package/src/MaterialReactTable.tsx +31 -168
- package/src/body/MRT_TableBody.tsx +184 -93
- package/src/body/MRT_TableBodyCell.tsx +55 -56
- package/src/body/MRT_TableBodyCellValue.tsx +7 -4
- package/src/body/MRT_TableBodyRow.tsx +111 -23
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +15 -11
- package/src/body/MRT_TableBodyRowPinButton.tsx +46 -0
- package/src/body/MRT_TableDetailPanel.tsx +21 -27
- package/src/body/index.ts +7 -0
- package/src/buttons/MRT_ColumnPinningButtons.tsx +2 -4
- package/src/buttons/MRT_CopyButton.tsx +17 -23
- package/src/buttons/MRT_EditActionButtons.tsx +56 -25
- package/src/buttons/MRT_ExpandAllButton.tsx +10 -10
- package/src/buttons/MRT_ExpandButton.tsx +8 -9
- package/src/buttons/MRT_GrabHandleButton.tsx +4 -5
- package/src/buttons/MRT_RowPinButton.tsx +74 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +2 -5
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -3
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -5
- package/src/buttons/{MRT_FullScreenToggleButton.tsx → MRT_ToggleFullScreenButton.tsx} +13 -6
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -5
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +18 -11
- package/src/buttons/index.ts +13 -0
- package/src/column.utils.ts +107 -50
- package/src/filterFns.ts +14 -14
- package/src/footer/MRT_TableFooter.tsx +17 -11
- package/src/footer/MRT_TableFooterCell.tsx +14 -24
- package/src/footer/MRT_TableFooterRow.tsx +12 -13
- package/src/footer/index.ts +3 -0
- package/src/head/MRT_TableHead.tsx +15 -11
- package/src/head/MRT_TableHeadCell.tsx +16 -24
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +18 -24
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +9 -4
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +9 -4
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +13 -20
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +9 -4
- package/src/head/MRT_TableHeadCellSortLabel.tsx +8 -6
- package/src/head/MRT_TableHeadRow.tsx +12 -13
- package/src/head/index.ts +9 -0
- package/src/hooks/useMRT_DisplayColumns.tsx +155 -0
- package/src/hooks/useMRT_Effects.ts +77 -0
- package/src/hooks/useMRT_TableInstance.ts +297 -0
- package/src/hooks/useMRT_TableOptions.ts +173 -0
- package/src/index.ts +16 -0
- package/src/inputs/MRT_EditCellTextField.tsx +47 -41
- package/src/inputs/MRT_FilterCheckbox.tsx +19 -28
- package/src/inputs/MRT_FilterRangeFields.tsx +7 -4
- package/src/inputs/MRT_FilterRangeSlider.tsx +14 -32
- package/src/inputs/MRT_FilterTextField.tsx +18 -34
- package/src/inputs/MRT_GlobalFilterTextField.tsx +6 -8
- package/src/inputs/MRT_SelectCheckbox.tsx +39 -21
- package/src/inputs/index.ts +7 -0
- package/src/locales/ar.ts +94 -0
- package/src/locales/bg.ts +93 -0
- package/src/{_locales → locales}/cs.ts +1 -2
- package/src/{_locales → locales}/da.ts +0 -1
- package/src/{_locales → locales}/de.ts +0 -1
- package/src/{_locales → locales}/en.ts +1 -1
- package/src/{_locales → locales}/es.ts +0 -1
- package/src/locales/et.ts +94 -0
- package/src/{_locales → locales}/fa.ts +0 -1
- package/src/{_locales → locales}/fi.ts +0 -1
- package/src/{_locales → locales}/fr.ts +0 -1
- package/src/{_locales → locales}/hu.ts +0 -1
- package/src/{_locales → locales}/id.ts +0 -1
- package/src/{_locales → locales}/it.ts +0 -1
- package/src/{_locales → locales}/ja.ts +0 -1
- package/src/locales/ko.ts +93 -0
- package/src/{_locales → locales}/nl.ts +0 -1
- package/src/{_locales → locales}/no.ts +1 -1
- package/src/{_locales → locales}/pl.ts +0 -1
- package/src/{_locales → locales}/pt-BR.ts +0 -1
- package/src/{_locales → locales}/pt.ts +0 -1
- package/src/{_locales → locales}/ro.ts +0 -1
- package/src/{_locales → locales}/ru.ts +0 -1
- package/src/{_locales → locales}/sk.ts +0 -1
- package/src/{_locales → locales}/sr-Cyrl-RS.ts +0 -1
- package/src/{_locales → locales}/sr-Latn-RS.ts +0 -1
- package/src/{_locales → locales}/sv.ts +0 -1
- package/src/{_locales → locales}/tr.ts +0 -1
- package/src/{_locales → locales}/uk.ts +0 -1
- package/src/{_locales → locales}/vi.ts +0 -1
- package/src/{_locales → locales}/zh-Hans.ts +7 -8
- package/src/{_locales → locales}/zh-Hant.ts +1 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +8 -8
- package/src/menus/MRT_FilterOptionMenu.tsx +4 -3
- package/src/menus/MRT_RowActionMenu.tsx +16 -17
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +4 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +4 -4
- package/src/menus/index.ts +5 -0
- package/src/modals/MRT_EditRowModal.tsx +107 -0
- package/src/modals/index.ts +1 -0
- package/src/sortingFns.ts +6 -2
- package/src/table/MRT_Table.tsx +42 -40
- package/src/table/MRT_TableContainer.tsx +24 -12
- package/src/table/MRT_TablePaper.tsx +22 -17
- package/src/table/index.ts +4 -0
- package/src/toolbar/MRT_BottomToolbar.tsx +16 -22
- package/src/toolbar/MRT_LinearProgressBar.tsx +7 -6
- package/src/toolbar/MRT_TablePagination.tsx +7 -9
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +10 -13
- package/src/toolbar/MRT_ToolbarDropZone.tsx +2 -2
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +6 -8
- package/src/toolbar/MRT_TopToolbar.tsx +10 -16
- package/src/toolbar/index.ts +7 -0
- package/src/types.ts +803 -770
- package/src/useMaterialReactTable.ts +11 -0
- package/dist/cjs/types/body/MRT_EditRowModal.d.ts +0 -8
- package/dist/cjs/types/buttons/MRT_FullScreenToggleButton.d.ts +0 -7
- package/dist/cjs/types/table/MRT_TableRoot.d.ts +0 -1
- package/dist/esm/types/body/MRT_EditRowModal.d.ts +0 -8
- package/dist/esm/types/buttons/MRT_FullScreenToggleButton.d.ts +0 -7
- package/dist/esm/types/table/MRT_TableRoot.d.ts +0 -1
- package/locales/tr.d.ts +0 -2
- package/locales/tr.esm.d.ts +0 -2
- package/locales/tr.esm.js +0 -94
- package/locales/tr.esm.js.map +0 -1
- package/locales/tr.js +0 -98
- package/locales/tr.js.map +0 -1
- package/locales/uk.d.ts +0 -2
- package/locales/uk.esm.d.ts +0 -2
- package/locales/uk.esm.js +0 -94
- package/locales/uk.esm.js.map +0 -1
- package/locales/uk.js +0 -98
- package/locales/uk.js.map +0 -1
- package/locales/vi.d.ts +0 -2
- package/locales/vi.esm.d.ts +0 -2
- package/locales/vi.esm.js +0 -94
- package/locales/vi.esm.js.map +0 -1
- package/locales/vi.js +0 -98
- package/locales/vi.js.map +0 -1
- package/locales/zh-Hans.d.ts +0 -2
- package/locales/zh-Hans.esm.d.ts +0 -2
- package/locales/zh-Hans.esm.js +0 -94
- package/locales/zh-Hans.esm.js.map +0 -1
- package/locales/zh-Hans.js +0 -98
- package/locales/zh-Hans.js.map +0 -1
- package/locales/zh-Hant.d.ts +0 -2
- package/locales/zh-Hant.esm.d.ts +0 -2
- package/locales/zh-Hant.esm.js +0 -94
- package/locales/zh-Hant.esm.js.map +0 -1
- package/locales/zh-Hant.js +0 -98
- package/locales/zh-Hant.js.map +0 -1
- package/src/body/MRT_EditRowModal.tsx +0 -57
- package/src/index.tsx +0 -50
- package/src/table/MRT_TableRoot.tsx +0 -421
- /package/dist/cjs/types/{_locales → locales}/cs.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/da.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/de.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/en.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/es.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/fa.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/fi.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/fr.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/hu.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/id.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/it.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/ja.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/nl.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/no.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/pl.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/pt-BR.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/pt.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/ro.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/ru.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/sk.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/sr-Cyrl-RS.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/sr-Latn-RS.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/sv.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/tr.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/uk.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/vi.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/zh-Hans.d.ts +0 -0
- /package/dist/cjs/types/{_locales → locales}/zh-Hant.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/cs.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/da.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/de.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/en.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/es.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/fa.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/fi.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/fr.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/hu.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/id.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/it.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/ja.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/nl.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/no.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/pl.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/pt-BR.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/pt.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/ro.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/ru.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/sk.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/sr-Cyrl-RS.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/sr-Latn-RS.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/sv.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/tr.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/uk.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/vi.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/zh-Hans.d.ts +0 -0
- /package/dist/esm/types/{_locales → locales}/zh-Hant.d.ts +0 -0
@@ -9,30 +9,38 @@ import Typography from '@mui/material/Typography';
|
|
9
9
|
import { Memo_MRT_TableBodyRow, MRT_TableBodyRow } from './MRT_TableBodyRow';
|
10
10
|
import { rankGlobalFuzzy } from '../sortingFns';
|
11
11
|
import { type MRT_Row, type MRT_TableInstance } from '../types';
|
12
|
+
import { parseFromValuesOrFunc } from '../column.utils';
|
12
13
|
|
13
|
-
interface Props {
|
14
|
+
interface Props<TData extends Record<string, any>> {
|
14
15
|
columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
15
|
-
table: MRT_TableInstance
|
16
|
+
table: MRT_TableInstance<TData>;
|
16
17
|
virtualColumns?: VirtualItem[];
|
17
18
|
virtualPaddingLeft?: number;
|
18
19
|
virtualPaddingRight?: number;
|
19
20
|
}
|
20
21
|
|
21
|
-
export const MRT_TableBody = ({
|
22
|
+
export const MRT_TableBody = <TData extends Record<string, any>>({
|
22
23
|
columnVirtualizer,
|
23
24
|
table,
|
24
25
|
virtualColumns,
|
25
26
|
virtualPaddingLeft,
|
26
27
|
virtualPaddingRight,
|
27
|
-
}: Props) => {
|
28
|
+
}: Props<TData>) => {
|
28
29
|
const {
|
29
|
-
|
30
|
+
getBottomRows,
|
31
|
+
getCenterRows,
|
30
32
|
getPrePaginationRowModel,
|
33
|
+
getRowModel,
|
31
34
|
getState,
|
35
|
+
getIsSomeRowsPinned,
|
36
|
+
getTopRows,
|
32
37
|
options: {
|
33
38
|
enableGlobalFilterRankedResults,
|
34
39
|
enablePagination,
|
40
|
+
enableRowPinning,
|
35
41
|
enableRowVirtualization,
|
42
|
+
enableStickyHeader,
|
43
|
+
enableStickyFooter,
|
36
44
|
layoutMode,
|
37
45
|
localization,
|
38
46
|
manualExpanding,
|
@@ -43,12 +51,11 @@ export const MRT_TableBody = ({
|
|
43
51
|
memoMode,
|
44
52
|
muiTableBodyProps,
|
45
53
|
renderEmptyRowsFallback,
|
54
|
+
rowPinningDisplayMode,
|
46
55
|
rowVirtualizerInstanceRef,
|
47
|
-
|
48
|
-
virtualizerInstanceRef,
|
49
|
-
virtualizerProps,
|
56
|
+
rowVirtualizerOptions,
|
50
57
|
},
|
51
|
-
refs: { tableContainerRef, tablePaperRef },
|
58
|
+
refs: { tableContainerRef, tablePaperRef, tableFooterRef, tableHeadRef },
|
52
59
|
} = table;
|
53
60
|
const {
|
54
61
|
columnFilters,
|
@@ -58,22 +65,21 @@ export const MRT_TableBody = ({
|
|
58
65
|
globalFilterFn,
|
59
66
|
pagination,
|
60
67
|
sorting,
|
68
|
+
rowPinning,
|
69
|
+
isFullScreen,
|
61
70
|
} = getState();
|
62
71
|
|
63
|
-
const tableBodyProps =
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
const tableBodyProps = parseFromValuesOrFunc(muiTableBodyProps, { table });
|
73
|
+
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
74
|
+
table,
|
75
|
+
});
|
67
76
|
|
68
|
-
const
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
rowVirtualizerProps instanceof Function
|
75
|
-
? rowVirtualizerProps({ table })
|
76
|
-
: rowVirtualizerProps;
|
77
|
+
const tableHeadHeight =
|
78
|
+
((enableStickyHeader || isFullScreen) &&
|
79
|
+
tableHeadRef.current?.clientHeight) ||
|
80
|
+
0;
|
81
|
+
const tableFooterHeight =
|
82
|
+
(enableStickyFooter && tableFooterRef.current?.clientHeight) || 0;
|
77
83
|
|
78
84
|
const shouldRankResults = useMemo(
|
79
85
|
() =>
|
@@ -99,21 +105,45 @@ export const MRT_TableBody = ({
|
|
99
105
|
],
|
100
106
|
);
|
101
107
|
|
108
|
+
const pinnedRowIds = useMemo(
|
109
|
+
() =>
|
110
|
+
getRowModel()
|
111
|
+
.rows.filter((row) => row.getIsPinned())
|
112
|
+
.map((r) => r.id),
|
113
|
+
[rowPinning, table.getRowModel().rows],
|
114
|
+
);
|
115
|
+
|
102
116
|
const rows = useMemo(() => {
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
117
|
+
let rows = [];
|
118
|
+
if (!shouldRankResults) {
|
119
|
+
rows =
|
120
|
+
!enableRowPinning || rowPinningDisplayMode?.includes('sticky')
|
121
|
+
? getRowModel().rows
|
122
|
+
: getCenterRows();
|
123
|
+
} else {
|
124
|
+
rows = getPrePaginationRowModel().rows.sort((a, b) =>
|
125
|
+
rankGlobalFuzzy(a, b),
|
126
|
+
);
|
127
|
+
if (enablePagination && !manualPagination) {
|
128
|
+
const start = pagination.pageIndex * pagination.pageSize;
|
129
|
+
rows = rows.slice(start, start + pagination.pageSize);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
if (enableRowPinning && rowPinningDisplayMode?.includes('sticky')) {
|
133
|
+
rows = [
|
134
|
+
...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
135
|
+
...rows,
|
136
|
+
...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
|
137
|
+
];
|
110
138
|
}
|
111
|
-
|
139
|
+
|
140
|
+
return rows;
|
112
141
|
}, [
|
113
142
|
shouldRankResults,
|
114
143
|
shouldRankResults ? getPrePaginationRowModel().rows : getRowModel().rows,
|
115
144
|
pagination.pageIndex,
|
116
145
|
pagination.pageSize,
|
146
|
+
rowPinning,
|
117
147
|
]);
|
118
148
|
|
119
149
|
const rowVirtualizer:
|
@@ -130,8 +160,7 @@ export const MRT_TableBody = ({
|
|
130
160
|
? (element) => element?.getBoundingClientRect().height
|
131
161
|
: undefined,
|
132
162
|
overscan: 4,
|
133
|
-
...
|
134
|
-
...vProps,
|
163
|
+
...rowVirtualizerProps,
|
135
164
|
})
|
136
165
|
: undefined;
|
137
166
|
|
@@ -139,78 +168,140 @@ export const MRT_TableBody = ({
|
|
139
168
|
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
140
169
|
}
|
141
170
|
|
142
|
-
//deprecated
|
143
|
-
if (virtualizerInstanceRef && rowVirtualizer) {
|
144
|
-
virtualizerInstanceRef.current = rowVirtualizer;
|
145
|
-
}
|
146
|
-
|
147
171
|
const virtualRows = rowVirtualizer
|
148
172
|
? rowVirtualizer.getVirtualItems()
|
149
173
|
: undefined;
|
150
174
|
|
151
175
|
return (
|
152
|
-
|
153
|
-
{
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
176
|
+
<>
|
177
|
+
{!rowPinningDisplayMode?.includes('sticky') &&
|
178
|
+
getIsSomeRowsPinned('top') && (
|
179
|
+
<TableBody
|
180
|
+
{...tableBodyProps}
|
181
|
+
sx={(theme) => ({
|
182
|
+
display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
|
183
|
+
position: 'sticky',
|
184
|
+
top: tableHeadHeight - 1,
|
185
|
+
zIndex: 1,
|
186
|
+
...(parseFromValuesOrFunc(tableBodyProps?.sx, theme) as any),
|
187
|
+
})}
|
188
|
+
>
|
189
|
+
{getTopRows().map((row, rowIndex) => {
|
190
|
+
const props = {
|
191
|
+
columnVirtualizer,
|
192
|
+
measureElement: rowVirtualizer?.measureElement,
|
193
|
+
numRows: rows.length,
|
194
|
+
row,
|
195
|
+
rowIndex,
|
196
|
+
table,
|
197
|
+
virtualColumns,
|
198
|
+
virtualPaddingLeft,
|
199
|
+
virtualPaddingRight,
|
200
|
+
};
|
201
|
+
return memoMode === 'rows' ? (
|
202
|
+
<Memo_MRT_TableBodyRow key={row.id} {...props} />
|
203
|
+
) : (
|
204
|
+
<MRT_TableBodyRow key={row.id} {...props} />
|
205
|
+
);
|
206
|
+
})}
|
207
|
+
</TableBody>
|
208
|
+
)}
|
209
|
+
<TableBody
|
210
|
+
{...tableBodyProps}
|
211
|
+
sx={(theme) => ({
|
212
|
+
display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
|
213
|
+
height: rowVirtualizer
|
214
|
+
? `${rowVirtualizer.getTotalSize()}px`
|
215
|
+
: 'inherit',
|
216
|
+
minHeight: !rows.length ? '100px' : undefined,
|
217
|
+
position: 'relative',
|
218
|
+
...(parseFromValuesOrFunc(tableBodyProps?.sx, theme) as any),
|
219
|
+
})}
|
220
|
+
>
|
221
|
+
{tableBodyProps?.children ??
|
222
|
+
(!rows.length ? (
|
223
|
+
<tr
|
224
|
+
style={{ display: layoutMode === 'grid' ? 'grid' : 'table-row' }}
|
174
225
|
>
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
226
|
+
<td
|
227
|
+
colSpan={table.getVisibleLeafColumns().length}
|
228
|
+
style={{
|
229
|
+
display: layoutMode === 'grid' ? 'grid' : 'table-cell',
|
230
|
+
}}
|
231
|
+
>
|
232
|
+
{renderEmptyRowsFallback?.({ table }) ?? (
|
233
|
+
<Typography
|
234
|
+
sx={{
|
235
|
+
color: 'text.secondary',
|
236
|
+
fontStyle: 'italic',
|
237
|
+
maxWidth: `min(100vw, ${
|
238
|
+
tablePaperRef.current?.clientWidth ?? 360
|
239
|
+
}px)`,
|
240
|
+
py: '2rem',
|
241
|
+
textAlign: 'center',
|
242
|
+
width: '100%',
|
243
|
+
}}
|
244
|
+
>
|
245
|
+
{globalFilter || columnFilters.length
|
246
|
+
? localization.noResultsFound
|
247
|
+
: localization.noRecordsToDisplay}
|
248
|
+
</Typography>
|
249
|
+
)}
|
250
|
+
</td>
|
251
|
+
</tr>
|
252
|
+
) : (
|
253
|
+
<>
|
254
|
+
{(virtualRows ?? rows).map((rowOrVirtualRow, rowIndex) => {
|
255
|
+
const row = rowVirtualizer
|
256
|
+
? rows[rowOrVirtualRow.index]
|
257
|
+
: (rowOrVirtualRow as MRT_Row<TData>);
|
258
|
+
const props = {
|
259
|
+
columnVirtualizer,
|
260
|
+
measureElement: rowVirtualizer?.measureElement,
|
261
|
+
numRows: rows.length,
|
262
|
+
pinnedRowIds,
|
263
|
+
row,
|
264
|
+
rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex,
|
265
|
+
table,
|
266
|
+
virtualColumns,
|
267
|
+
virtualPaddingLeft,
|
268
|
+
virtualPaddingRight,
|
269
|
+
virtualRow: rowVirtualizer
|
270
|
+
? (rowOrVirtualRow as VirtualItem)
|
271
|
+
: undefined,
|
272
|
+
};
|
273
|
+
return memoMode === 'rows' ? (
|
274
|
+
<Memo_MRT_TableBodyRow key={row.id} {...props} />
|
275
|
+
) : (
|
276
|
+
<MRT_TableBodyRow key={row.id} {...props} />
|
277
|
+
);
|
278
|
+
})}
|
279
|
+
</>
|
280
|
+
))}
|
281
|
+
</TableBody>
|
282
|
+
{!rowPinningDisplayMode?.includes('sticky') &&
|
283
|
+
getIsSomeRowsPinned('bottom') && (
|
284
|
+
<TableBody
|
285
|
+
{...tableBodyProps}
|
286
|
+
sx={(theme) => ({
|
287
|
+
display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
|
288
|
+
position: 'sticky',
|
289
|
+
bottom: tableFooterHeight - 1,
|
290
|
+
zIndex: 1,
|
291
|
+
...(parseFromValuesOrFunc(tableBodyProps?.sx, theme) as any),
|
292
|
+
})}
|
293
|
+
>
|
294
|
+
{getBottomRows().map((row, rowIndex) => {
|
201
295
|
const props = {
|
202
296
|
columnVirtualizer,
|
203
297
|
measureElement: rowVirtualizer?.measureElement,
|
204
298
|
numRows: rows.length,
|
205
299
|
row,
|
206
|
-
rowIndex
|
300
|
+
rowIndex,
|
207
301
|
table,
|
208
302
|
virtualColumns,
|
209
303
|
virtualPaddingLeft,
|
210
304
|
virtualPaddingRight,
|
211
|
-
virtualRow: rowVirtualizer
|
212
|
-
? (rowOrVirtualRow as VirtualItem)
|
213
|
-
: undefined,
|
214
305
|
};
|
215
306
|
return memoMode === 'rows' ? (
|
216
307
|
<Memo_MRT_TableBodyRow key={row.id} {...props} />
|
@@ -218,13 +309,13 @@ export const MRT_TableBody = ({
|
|
218
309
|
<MRT_TableBodyRow key={row.id} {...props} />
|
219
310
|
);
|
220
311
|
})}
|
221
|
-
|
222
|
-
)
|
223
|
-
|
312
|
+
</TableBody>
|
313
|
+
)}
|
314
|
+
</>
|
224
315
|
);
|
225
316
|
};
|
226
317
|
|
227
318
|
export const Memo_MRT_TableBody = memo(
|
228
319
|
MRT_TableBody,
|
229
320
|
(prev, next) => prev.table.options.data === next.table.options.data,
|
230
|
-
);
|
321
|
+
) as typeof MRT_TableBody;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
|
-
type DragEvent,
|
3
2
|
memo,
|
3
|
+
type DragEvent,
|
4
4
|
type MouseEvent,
|
5
5
|
type RefObject,
|
6
6
|
useEffect,
|
@@ -18,21 +18,22 @@ import {
|
|
18
18
|
getCommonCellStyles,
|
19
19
|
getIsFirstColumn,
|
20
20
|
getIsLastColumn,
|
21
|
+
parseFromValuesOrFunc,
|
21
22
|
} from '../column.utils';
|
22
23
|
import { type VirtualItem } from '@tanstack/react-virtual';
|
23
24
|
import { type MRT_Cell, type MRT_TableInstance } from '../types';
|
24
25
|
|
25
|
-
interface Props {
|
26
|
-
cell: MRT_Cell
|
26
|
+
interface Props<TData extends Record<string, any>> {
|
27
|
+
cell: MRT_Cell<TData>;
|
27
28
|
measureElement?: (element: HTMLTableCellElement) => void;
|
28
29
|
numRows: number;
|
29
30
|
rowIndex: number;
|
30
31
|
rowRef: RefObject<HTMLTableRowElement>;
|
31
|
-
table: MRT_TableInstance
|
32
|
+
table: MRT_TableInstance<TData>;
|
32
33
|
virtualCell?: VirtualItem;
|
33
34
|
}
|
34
35
|
|
35
|
-
export const MRT_TableBodyCell = ({
|
36
|
+
export const MRT_TableBodyCell = <TData extends Record<string, any>>({
|
36
37
|
cell,
|
37
38
|
measureElement,
|
38
39
|
numRows,
|
@@ -40,12 +41,13 @@ export const MRT_TableBodyCell = ({
|
|
40
41
|
rowRef,
|
41
42
|
table,
|
42
43
|
virtualCell,
|
43
|
-
}: Props) => {
|
44
|
+
}: Props<TData>) => {
|
44
45
|
const theme = useTheme();
|
45
46
|
const {
|
46
47
|
getState,
|
47
48
|
options: {
|
48
|
-
|
49
|
+
createDisplayMode,
|
50
|
+
editDisplayMode,
|
49
51
|
enableClickToCopy,
|
50
52
|
enableColumnOrdering,
|
51
53
|
enableEditing,
|
@@ -53,7 +55,7 @@ export const MRT_TableBodyCell = ({
|
|
53
55
|
enableRowNumbers,
|
54
56
|
layoutMode,
|
55
57
|
muiTableBodyCellProps,
|
56
|
-
|
58
|
+
muiSkeletonProps,
|
57
59
|
rowNumberMode,
|
58
60
|
},
|
59
61
|
refs: { editInputRefs },
|
@@ -61,6 +63,7 @@ export const MRT_TableBodyCell = ({
|
|
61
63
|
setHoveredColumn,
|
62
64
|
} = table;
|
63
65
|
const {
|
66
|
+
creatingRow,
|
64
67
|
draggingColumn,
|
65
68
|
draggingRow,
|
66
69
|
editingCell,
|
@@ -75,41 +78,38 @@ export const MRT_TableBodyCell = ({
|
|
75
78
|
const { columnDef } = column;
|
76
79
|
const { columnDefType } = columnDef;
|
77
80
|
|
78
|
-
const mTableCellBodyProps =
|
79
|
-
muiTableBodyCellProps instanceof Function
|
80
|
-
? muiTableBodyCellProps({ cell, column, row, table })
|
81
|
-
: muiTableBodyCellProps;
|
82
|
-
|
83
|
-
const mcTableCellBodyProps =
|
84
|
-
columnDef.muiTableBodyCellProps instanceof Function
|
85
|
-
? columnDef.muiTableBodyCellProps({ cell, column, row, table })
|
86
|
-
: columnDef.muiTableBodyCellProps;
|
87
|
-
|
88
81
|
const tableCellProps = {
|
89
|
-
...
|
90
|
-
|
82
|
+
...parseFromValuesOrFunc(muiTableBodyCellProps, {
|
83
|
+
cell,
|
84
|
+
column,
|
85
|
+
row,
|
86
|
+
table,
|
87
|
+
}),
|
88
|
+
...parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, {
|
89
|
+
cell,
|
90
|
+
column,
|
91
|
+
row,
|
92
|
+
table,
|
93
|
+
}),
|
91
94
|
};
|
92
95
|
|
93
|
-
const skeletonProps =
|
94
|
-
|
95
|
-
|
96
|
-
|
96
|
+
const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
|
97
|
+
cell,
|
98
|
+
column,
|
99
|
+
row,
|
100
|
+
table,
|
101
|
+
});
|
97
102
|
|
98
|
-
const [skeletonWidth, setSkeletonWidth] = useState(
|
99
|
-
useEffect(
|
100
|
-
()
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
)
|
109
|
-
: 100,
|
110
|
-
),
|
111
|
-
[],
|
112
|
-
);
|
103
|
+
const [skeletonWidth, setSkeletonWidth] = useState(100);
|
104
|
+
useEffect(() => {
|
105
|
+
if ((!isLoading && !showSkeletons) || skeletonWidth !== 100) return;
|
106
|
+
const size = column.getSize();
|
107
|
+
setSkeletonWidth(
|
108
|
+
columnDefType === 'display'
|
109
|
+
? size / 2
|
110
|
+
: Math.round(Math.random() * (size - size / 3) + size / 3),
|
111
|
+
);
|
112
|
+
}, [isLoading, showSkeletons]);
|
113
113
|
|
114
114
|
const draggingBorders = useMemo(() => {
|
115
115
|
const isDraggingColumn = draggingColumn?.id === column.id;
|
@@ -151,22 +151,23 @@ export const MRT_TableBodyCell = ({
|
|
151
151
|
}, [draggingColumn, draggingRow, hoveredColumn, hoveredRow, rowIndex]);
|
152
152
|
|
153
153
|
const isEditable =
|
154
|
-
(enableEditing
|
155
|
-
(columnDef.enableEditing
|
156
|
-
? columnDef.enableEditing(row)
|
157
|
-
: columnDef.enableEditing) !== false;
|
154
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
155
|
+
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
|
158
156
|
|
159
157
|
const isEditing =
|
160
158
|
isEditable &&
|
161
|
-
|
162
|
-
(
|
159
|
+
!['modal', 'custom'].includes(editDisplayMode as string) &&
|
160
|
+
(editDisplayMode === 'table' ||
|
163
161
|
editingRow?.id === row.id ||
|
164
162
|
editingCell?.id === cell.id) &&
|
165
163
|
!row.getIsGrouped();
|
166
164
|
|
165
|
+
const isCreating =
|
166
|
+
isEditable && createDisplayMode === 'row' && creatingRow?.id === row.id;
|
167
|
+
|
167
168
|
const handleDoubleClick = (event: MouseEvent<HTMLTableCellElement>) => {
|
168
169
|
tableCellProps?.onDoubleClick?.(event);
|
169
|
-
if (isEditable &&
|
170
|
+
if (isEditable && editDisplayMode === 'cell') {
|
170
171
|
setEditingCell(cell);
|
171
172
|
queueMicrotask(() => {
|
172
173
|
const textField = editInputRefs.current[column.id];
|
@@ -203,7 +204,8 @@ export const MRT_TableBodyCell = ({
|
|
203
204
|
onDoubleClick={handleDoubleClick}
|
204
205
|
sx={(theme) => ({
|
205
206
|
alignItems: layoutMode === 'grid' ? 'center' : undefined,
|
206
|
-
cursor:
|
207
|
+
cursor:
|
208
|
+
isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit',
|
207
209
|
justifyContent:
|
208
210
|
layoutMode === 'grid' ? tableCellProps.align : undefined,
|
209
211
|
overflow: 'hidden',
|
@@ -231,11 +233,12 @@ export const MRT_TableBodyCell = ({
|
|
231
233
|
}rem`
|
232
234
|
: undefined,
|
233
235
|
textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined,
|
234
|
-
whiteSpace:
|
236
|
+
whiteSpace:
|
237
|
+
row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal',
|
235
238
|
zIndex:
|
236
239
|
draggingColumn?.id === column.id ? 2 : column.getIsPinned() ? 1 : 0,
|
237
240
|
'&:hover': {
|
238
|
-
outline: ['table', 'cell'].includes(
|
241
|
+
outline: ['table', 'cell'].includes(editDisplayMode ?? '')
|
239
242
|
? `1px solid ${theme.palette.text.secondary}`
|
240
243
|
: undefined,
|
241
244
|
outlineOffset: '-1px',
|
@@ -265,11 +268,7 @@ export const MRT_TableBodyCell = ({
|
|
265
268
|
column.id === 'mrt-row-numbers' ? (
|
266
269
|
rowIndex + 1
|
267
270
|
) : column.id === 'mrt-row-drag' ? (
|
268
|
-
<MRT_TableBodyRowGrabHandle
|
269
|
-
cell={cell}
|
270
|
-
rowRef={rowRef}
|
271
|
-
table={table}
|
272
|
-
/>
|
271
|
+
<MRT_TableBodyRowGrabHandle row={row} rowRef={rowRef} table={table} />
|
273
272
|
) : columnDefType === 'display' &&
|
274
273
|
(column.id === 'mrt-row-select' ||
|
275
274
|
column.id === 'mrt-row-expand' ||
|
@@ -281,7 +280,7 @@ export const MRT_TableBodyCell = ({
|
|
281
280
|
row,
|
282
281
|
table,
|
283
282
|
})
|
284
|
-
) : isEditing ? (
|
283
|
+
) : isCreating || isEditing ? (
|
285
284
|
<MRT_EditCellTextField cell={cell} table={table} />
|
286
285
|
) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
287
286
|
columnDef.enableClickToCopy !== false ? (
|
@@ -302,4 +301,4 @@ export const MRT_TableBodyCell = ({
|
|
302
301
|
export const Memo_MRT_TableBodyCell = memo(
|
303
302
|
MRT_TableBodyCell,
|
304
303
|
(prev, next) => next.cell === prev.cell,
|
305
|
-
);
|
304
|
+
) as typeof MRT_TableBodyCell;
|
@@ -6,12 +6,15 @@ import { type MRT_Cell, type MRT_TableInstance } from '../types';
|
|
6
6
|
|
7
7
|
const allowedTypes = ['string', 'number'];
|
8
8
|
|
9
|
-
interface Props {
|
10
|
-
cell: MRT_Cell
|
11
|
-
table: MRT_TableInstance
|
9
|
+
interface Props<TData extends Record<string, any>> {
|
10
|
+
cell: MRT_Cell<TData>;
|
11
|
+
table: MRT_TableInstance<TData>;
|
12
12
|
}
|
13
13
|
|
14
|
-
export const MRT_TableBodyCellValue =
|
14
|
+
export const MRT_TableBodyCellValue = <TData extends Record<string, any>>({
|
15
|
+
cell,
|
16
|
+
table,
|
17
|
+
}: Props<TData>) => {
|
15
18
|
const {
|
16
19
|
getState,
|
17
20
|
options: { enableFilterMatchHighlighting },
|