@kissesses/mantine-react-table-open 9.0.3
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/LICENSE +21 -0
- package/README.md +196 -0
- package/dist/index.cjs +3769 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1488 -0
- package/dist/index.esm.d.mts +1488 -0
- package/dist/index.esm.mjs +3664 -0
- package/dist/index.esm.mjs.map +1 -0
- package/locales/ar/index.cjs +97 -0
- package/locales/ar/index.d.cts +3 -0
- package/locales/ar/index.esm.d.mts +3 -0
- package/locales/ar/index.esm.mjs +95 -0
- package/locales/ar/package.json +19 -0
- package/locales/az/index.cjs +97 -0
- package/locales/az/index.d.cts +3 -0
- package/locales/az/index.esm.d.mts +3 -0
- package/locales/az/index.esm.mjs +95 -0
- package/locales/az/package.json +19 -0
- package/locales/bg/index.cjs +97 -0
- package/locales/bg/index.d.cts +3 -0
- package/locales/bg/index.esm.d.mts +3 -0
- package/locales/bg/index.esm.mjs +95 -0
- package/locales/bg/package.json +19 -0
- package/locales/cs/index.cjs +97 -0
- package/locales/cs/index.d.cts +3 -0
- package/locales/cs/index.esm.d.mts +3 -0
- package/locales/cs/index.esm.mjs +95 -0
- package/locales/cs/package.json +19 -0
- package/locales/da/index.cjs +97 -0
- package/locales/da/index.d.cts +3 -0
- package/locales/da/index.esm.d.mts +3 -0
- package/locales/da/index.esm.mjs +95 -0
- package/locales/da/package.json +19 -0
- package/locales/de/index.cjs +97 -0
- package/locales/de/index.d.cts +3 -0
- package/locales/de/index.esm.d.mts +3 -0
- package/locales/de/index.esm.mjs +95 -0
- package/locales/de/package.json +19 -0
- package/locales/el/index.cjs +97 -0
- package/locales/el/index.d.cts +3 -0
- package/locales/el/index.esm.d.mts +3 -0
- package/locales/el/index.esm.mjs +95 -0
- package/locales/el/package.json +19 -0
- package/locales/en/index.cjs +97 -0
- package/locales/en/index.d.cts +3 -0
- package/locales/en/index.esm.d.mts +3 -0
- package/locales/en/index.esm.mjs +95 -0
- package/locales/en/package.json +19 -0
- package/locales/es/index.cjs +97 -0
- package/locales/es/index.d.cts +3 -0
- package/locales/es/index.esm.d.mts +3 -0
- package/locales/es/index.esm.mjs +95 -0
- package/locales/es/package.json +19 -0
- package/locales/et/index.cjs +97 -0
- package/locales/et/index.d.cts +3 -0
- package/locales/et/index.esm.d.mts +3 -0
- package/locales/et/index.esm.mjs +95 -0
- package/locales/et/package.json +19 -0
- package/locales/fa/index.cjs +97 -0
- package/locales/fa/index.d.cts +3 -0
- package/locales/fa/index.esm.d.mts +3 -0
- package/locales/fa/index.esm.mjs +95 -0
- package/locales/fa/package.json +19 -0
- package/locales/fi/index.cjs +97 -0
- package/locales/fi/index.d.cts +3 -0
- package/locales/fi/index.esm.d.mts +3 -0
- package/locales/fi/index.esm.mjs +95 -0
- package/locales/fi/package.json +19 -0
- package/locales/fr/index.cjs +97 -0
- package/locales/fr/index.d.cts +3 -0
- package/locales/fr/index.esm.d.mts +3 -0
- package/locales/fr/index.esm.mjs +95 -0
- package/locales/fr/package.json +19 -0
- package/locales/he/index.cjs +97 -0
- package/locales/he/index.d.cts +3 -0
- package/locales/he/index.esm.d.mts +3 -0
- package/locales/he/index.esm.mjs +95 -0
- package/locales/he/package.json +19 -0
- package/locales/hr/index.cjs +97 -0
- package/locales/hr/index.d.cts +3 -0
- package/locales/hr/index.esm.d.mts +3 -0
- package/locales/hr/index.esm.mjs +95 -0
- package/locales/hr/package.json +19 -0
- package/locales/hu/index.cjs +97 -0
- package/locales/hu/index.d.cts +3 -0
- package/locales/hu/index.esm.d.mts +3 -0
- package/locales/hu/index.esm.mjs +95 -0
- package/locales/hu/package.json +19 -0
- package/locales/hy/index.cjs +97 -0
- package/locales/hy/index.d.cts +3 -0
- package/locales/hy/index.esm.d.mts +3 -0
- package/locales/hy/index.esm.mjs +95 -0
- package/locales/hy/package.json +19 -0
- package/locales/id/index.cjs +97 -0
- package/locales/id/index.d.cts +3 -0
- package/locales/id/index.esm.d.mts +3 -0
- package/locales/id/index.esm.mjs +95 -0
- package/locales/id/package.json +19 -0
- package/locales/it/index.cjs +97 -0
- package/locales/it/index.d.cts +3 -0
- package/locales/it/index.esm.d.mts +3 -0
- package/locales/it/index.esm.mjs +95 -0
- package/locales/it/package.json +19 -0
- package/locales/ja/index.cjs +97 -0
- package/locales/ja/index.d.cts +3 -0
- package/locales/ja/index.esm.d.mts +3 -0
- package/locales/ja/index.esm.mjs +95 -0
- package/locales/ja/package.json +19 -0
- package/locales/ko/index.cjs +97 -0
- package/locales/ko/index.d.cts +3 -0
- package/locales/ko/index.esm.d.mts +3 -0
- package/locales/ko/index.esm.mjs +95 -0
- package/locales/ko/package.json +19 -0
- package/locales/nl/index.cjs +97 -0
- package/locales/nl/index.d.cts +3 -0
- package/locales/nl/index.esm.d.mts +3 -0
- package/locales/nl/index.esm.mjs +95 -0
- package/locales/nl/package.json +19 -0
- package/locales/no/index.cjs +97 -0
- package/locales/no/index.d.cts +3 -0
- package/locales/no/index.esm.d.mts +3 -0
- package/locales/no/index.esm.mjs +95 -0
- package/locales/no/package.json +19 -0
- package/locales/np/index.cjs +97 -0
- package/locales/np/index.d.cts +3 -0
- package/locales/np/index.esm.d.mts +3 -0
- package/locales/np/index.esm.mjs +95 -0
- package/locales/np/package.json +19 -0
- package/locales/pl/index.cjs +97 -0
- package/locales/pl/index.d.cts +3 -0
- package/locales/pl/index.esm.d.mts +3 -0
- package/locales/pl/index.esm.mjs +95 -0
- package/locales/pl/package.json +19 -0
- package/locales/pt/index.cjs +97 -0
- package/locales/pt/index.d.cts +3 -0
- package/locales/pt/index.esm.d.mts +3 -0
- package/locales/pt/index.esm.mjs +95 -0
- package/locales/pt/package.json +19 -0
- package/locales/pt-BR/index.cjs +97 -0
- package/locales/pt-BR/index.d.cts +3 -0
- package/locales/pt-BR/index.esm.d.mts +3 -0
- package/locales/pt-BR/index.esm.mjs +95 -0
- package/locales/pt-BR/package.json +19 -0
- package/locales/ro/index.cjs +97 -0
- package/locales/ro/index.d.cts +3 -0
- package/locales/ro/index.esm.d.mts +3 -0
- package/locales/ro/index.esm.mjs +95 -0
- package/locales/ro/package.json +19 -0
- package/locales/ru/index.cjs +97 -0
- package/locales/ru/index.d.cts +3 -0
- package/locales/ru/index.esm.d.mts +3 -0
- package/locales/ru/index.esm.mjs +95 -0
- package/locales/ru/package.json +19 -0
- package/locales/sk/index.cjs +97 -0
- package/locales/sk/index.d.cts +3 -0
- package/locales/sk/index.esm.d.mts +3 -0
- package/locales/sk/index.esm.mjs +95 -0
- package/locales/sk/package.json +19 -0
- package/locales/sr-Cyrl-RS/index.cjs +97 -0
- package/locales/sr-Cyrl-RS/index.d.cts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.d.mts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.mjs +95 -0
- package/locales/sr-Cyrl-RS/package.json +19 -0
- package/locales/sr-Latn-RS/index.cjs +97 -0
- package/locales/sr-Latn-RS/index.d.cts +3 -0
- package/locales/sr-Latn-RS/index.esm.d.mts +3 -0
- package/locales/sr-Latn-RS/index.esm.mjs +95 -0
- package/locales/sr-Latn-RS/package.json +19 -0
- package/locales/sv/index.cjs +97 -0
- package/locales/sv/index.d.cts +3 -0
- package/locales/sv/index.esm.d.mts +3 -0
- package/locales/sv/index.esm.mjs +95 -0
- package/locales/sv/package.json +19 -0
- package/locales/tr/index.cjs +97 -0
- package/locales/tr/index.d.cts +3 -0
- package/locales/tr/index.esm.d.mts +3 -0
- package/locales/tr/index.esm.mjs +95 -0
- package/locales/tr/package.json +19 -0
- package/locales/uk/index.cjs +97 -0
- package/locales/uk/index.d.cts +3 -0
- package/locales/uk/index.esm.d.mts +3 -0
- package/locales/uk/index.esm.mjs +95 -0
- package/locales/uk/package.json +19 -0
- package/locales/vi/index.cjs +97 -0
- package/locales/vi/index.d.cts +3 -0
- package/locales/vi/index.esm.d.mts +3 -0
- package/locales/vi/index.esm.mjs +95 -0
- package/locales/vi/package.json +19 -0
- package/locales/zh-Hans/index.cjs +97 -0
- package/locales/zh-Hans/index.d.cts +3 -0
- package/locales/zh-Hans/index.esm.d.mts +3 -0
- package/locales/zh-Hans/index.esm.mjs +95 -0
- package/locales/zh-Hans/package.json +19 -0
- package/locales/zh-Hant/index.cjs +97 -0
- package/locales/zh-Hant/index.d.cts +3 -0
- package/locales/zh-Hant/index.esm.d.mts +3 -0
- package/locales/zh-Hant/index.esm.mjs +95 -0
- package/locales/zh-Hant/package.json +19 -0
- package/package.json +154 -0
- package/src/components/MantineReactTable.tsx +37 -0
- package/src/components/body/MRT_TableBody.module.css +42 -0
- package/src/components/body/MRT_TableBody.tsx +215 -0
- package/src/components/body/MRT_TableBodyCell.module.css +107 -0
- package/src/components/body/MRT_TableBodyCell.tsx +351 -0
- package/src/components/body/MRT_TableBodyCellValue.tsx +113 -0
- package/src/components/body/MRT_TableBodyEmptyRow.tsx +110 -0
- package/src/components/body/MRT_TableBodyRow.module.css +252 -0
- package/src/components/body/MRT_TableBodyRow.tsx +263 -0
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +58 -0
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +58 -0
- package/src/components/body/MRT_TableDetailPanel.module.css +35 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +131 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.module.css +11 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +68 -0
- package/src/components/buttons/MRT_CopyButton.module.css +27 -0
- package/src/components/buttons/MRT_CopyButton.tsx +83 -0
- package/src/components/buttons/MRT_EditActionButtons.module.css +4 -0
- package/src/components/buttons/MRT_EditActionButtons.tsx +128 -0
- package/src/components/buttons/MRT_ExpandAllButton.module.css +26 -0
- package/src/components/buttons/MRT_ExpandAllButton.tsx +83 -0
- package/src/components/buttons/MRT_ExpandButton.module.css +37 -0
- package/src/components/buttons/MRT_ExpandButton.tsx +120 -0
- package/src/components/buttons/MRT_GrabHandleButton.module.css +6 -0
- package/src/components/buttons/MRT_GrabHandleButton.tsx +64 -0
- package/src/components/buttons/MRT_RowPinButton.tsx +83 -0
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +45 -0
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +65 -0
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +44 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +58 -0
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +51 -0
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +86 -0
- package/src/components/footer/MRT_TableFooter.module.css +17 -0
- package/src/components/footer/MRT_TableFooter.tsx +72 -0
- package/src/components/footer/MRT_TableFooterCell.module.css +50 -0
- package/src/components/footer/MRT_TableFooterCell.tsx +122 -0
- package/src/components/footer/MRT_TableFooterRow.module.css +10 -0
- package/src/components/footer/MRT_TableFooterRow.tsx +94 -0
- package/src/components/head/MRT_TableHead.module.css +32 -0
- package/src/components/head/MRT_TableHead.tsx +108 -0
- package/src/components/head/MRT_TableHeadCell.module.css +163 -0
- package/src/components/head/MRT_TableHeadCell.tsx +322 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.module.css +5 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +147 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.module.css +14 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +171 -0
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +81 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.module.css +44 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +67 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.module.css +22 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +89 -0
- package/src/components/head/MRT_TableHeadRow.module.css +12 -0
- package/src/components/head/MRT_TableHeadRow.tsx +87 -0
- package/src/components/inputs/MRT_EditCellTextInput.tsx +218 -0
- package/src/components/inputs/MRT_FilterCheckBox.module.css +4 -0
- package/src/components/inputs/MRT_FilterCheckbox.tsx +79 -0
- package/src/components/inputs/MRT_FilterRangeFields.module.css +5 -0
- package/src/components/inputs/MRT_FilterRangeFields.tsx +35 -0
- package/src/components/inputs/MRT_FilterRangeSlider.module.css +6 -0
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +106 -0
- package/src/components/inputs/MRT_FilterTextInput.module.css +27 -0
- package/src/components/inputs/MRT_FilterTextInput.tsx +417 -0
- package/src/components/inputs/MRT_GlobalFilterTextInput.module.css +11 -0
- package/src/components/inputs/MRT_GlobalFilterTextInput.tsx +141 -0
- package/src/components/inputs/MRT_SelectCheckbox.tsx +137 -0
- package/src/components/menus/MRT_ColumnActionMenu.module.css +7 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +287 -0
- package/src/components/menus/MRT_FilterOptionMenu.module.css +6 -0
- package/src/components/menus/MRT_FilterOptionMenu.tsx +274 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +74 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.module.css +10 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +135 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.module.css +35 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +170 -0
- package/src/components/modals/MRT_EditRowModal.tsx +97 -0
- package/src/components/table/MRT_Table.module.css +7 -0
- package/src/components/table/MRT_Table.tsx +110 -0
- package/src/components/table/MRT_TableContainer.module.css +20 -0
- package/src/components/table/MRT_TableContainer.tsx +109 -0
- package/src/components/table/MRT_TablePaper.module.css +88 -0
- package/src/components/table/MRT_TablePaper.tsx +92 -0
- package/src/components/toolbar/MRT_BottomToolbar.module.css +40 -0
- package/src/components/toolbar/MRT_BottomToolbar.tsx +100 -0
- package/src/components/toolbar/MRT_ProgressBar.module.css +10 -0
- package/src/components/toolbar/MRT_ProgressBar.tsx +53 -0
- package/src/components/toolbar/MRT_TablePagination.module.css +20 -0
- package/src/components/toolbar/MRT_TablePagination.tsx +166 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.module.css +37 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +168 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.module.css +23 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +67 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.module.css +6 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +73 -0
- package/src/components/toolbar/MRT_TopToolbar.module.css +24 -0
- package/src/components/toolbar/MRT_TopToolbar.tsx +128 -0
- package/src/components/toolbar/common.styles.module.css +10 -0
- package/src/fns/aggregationFns.ts +3 -0
- package/src/fns/filterFns.ts +272 -0
- package/src/fns/sortingFns.ts +34 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +23 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +30 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +92 -0
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +30 -0
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +24 -0
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +34 -0
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +34 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +129 -0
- package/src/hooks/useMRT_Effects.ts +105 -0
- package/src/hooks/useMRT_RowVirtualizer.ts +95 -0
- package/src/hooks/useMRT_Rows.ts +46 -0
- package/src/hooks/useMRT_TableInstance.ts +314 -0
- package/src/hooks/useMRT_TableOptions.ts +264 -0
- package/src/hooks/useMantineReactTable.ts +14 -0
- package/src/icons.ts +73 -0
- package/src/index.ts +90 -0
- package/src/locales/ar.ts +96 -0
- package/src/locales/az.ts +96 -0
- package/src/locales/bg.ts +96 -0
- package/src/locales/cs.ts +97 -0
- package/src/locales/da.ts +96 -0
- package/src/locales/de.ts +96 -0
- package/src/locales/el.ts +96 -0
- package/src/locales/en.ts +96 -0
- package/src/locales/es.ts +96 -0
- package/src/locales/et.ts +97 -0
- package/src/locales/fa.ts +96 -0
- package/src/locales/fi.ts +97 -0
- package/src/locales/fr.ts +96 -0
- package/src/locales/he.ts +96 -0
- package/src/locales/hr.ts +96 -0
- package/src/locales/hu.ts +96 -0
- package/src/locales/hy.ts +96 -0
- package/src/locales/id.ts +97 -0
- package/src/locales/it.ts +96 -0
- package/src/locales/ja.ts +96 -0
- package/src/locales/ko.ts +96 -0
- package/src/locales/nl.ts +96 -0
- package/src/locales/no.ts +97 -0
- package/src/locales/np.ts +97 -0
- package/src/locales/pl.ts +96 -0
- package/src/locales/pt-BR.ts +96 -0
- package/src/locales/pt.ts +96 -0
- package/src/locales/ro.ts +96 -0
- package/src/locales/ru.ts +96 -0
- package/src/locales/sk.ts +97 -0
- package/src/locales/sr-Cyrl-RS.ts +96 -0
- package/src/locales/sr-Latn-RS.ts +96 -0
- package/src/locales/sv.ts +96 -0
- package/src/locales/tr.ts +96 -0
- package/src/locales/uk.ts +96 -0
- package/src/locales/vi.ts +96 -0
- package/src/locales/zh-Hans.ts +95 -0
- package/src/locales/zh-Hant.ts +95 -0
- package/src/types.ts +1276 -0
- package/src/typings.d.ts +1 -0
- package/src/utils/column.utils.ts +124 -0
- package/src/utils/displayColumn.utils.ts +153 -0
- package/src/utils/row.utils.ts +263 -0
- package/src/utils/style.utils.ts +32 -0
- package/src/utils/tanstack.helpers.ts +66 -0
- package/src/utils/utils.ts +4 -0
- package/src/utils/virtualization.utils.ts +19 -0
- package/styles.css +1320 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Flex, Modal, type ModalProps, Stack } from '@mantine/core';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type MRT_Row,
|
|
5
|
+
type MRT_RowData,
|
|
6
|
+
type MRT_TableInstance,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
9
|
+
import { MRT_EditActionButtons } from '../buttons/MRT_EditActionButtons';
|
|
10
|
+
import { MRT_EditCellTextInput } from '../inputs/MRT_EditCellTextInput';
|
|
11
|
+
|
|
12
|
+
interface Props<TData extends MRT_RowData> extends Partial<ModalProps> {
|
|
13
|
+
open: boolean;
|
|
14
|
+
table: MRT_TableInstance<TData>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const MRT_EditRowModal = <TData extends MRT_RowData>({
|
|
18
|
+
open,
|
|
19
|
+
table,
|
|
20
|
+
...rest
|
|
21
|
+
}: Props<TData>) => {
|
|
22
|
+
'use no memo';
|
|
23
|
+
const {
|
|
24
|
+
getState,
|
|
25
|
+
options: {
|
|
26
|
+
mantineCreateRowModalProps,
|
|
27
|
+
mantineEditRowModalProps,
|
|
28
|
+
onCreatingRowCancel,
|
|
29
|
+
onEditingRowCancel,
|
|
30
|
+
renderCreateRowModalContent,
|
|
31
|
+
renderEditRowModalContent,
|
|
32
|
+
},
|
|
33
|
+
setCreatingRow,
|
|
34
|
+
setEditingRow,
|
|
35
|
+
} = table;
|
|
36
|
+
const { creatingRow, editingRow } = getState();
|
|
37
|
+
const row = (creatingRow ?? editingRow) as MRT_Row<TData>;
|
|
38
|
+
|
|
39
|
+
const arg = { row, table };
|
|
40
|
+
const modalProps = {
|
|
41
|
+
...parseFromValuesOrFunc(mantineEditRowModalProps, arg),
|
|
42
|
+
...(creatingRow && parseFromValuesOrFunc(mantineCreateRowModalProps, arg)),
|
|
43
|
+
...rest,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const internalEditComponents = row
|
|
47
|
+
.getAllCells()
|
|
48
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
49
|
+
.map((cell) => (
|
|
50
|
+
<MRT_EditCellTextInput cell={cell} key={cell.id} table={table} />
|
|
51
|
+
));
|
|
52
|
+
|
|
53
|
+
const handleCancel = () => {
|
|
54
|
+
if (creatingRow) {
|
|
55
|
+
onCreatingRowCancel?.({ row, table });
|
|
56
|
+
setCreatingRow(null);
|
|
57
|
+
} else {
|
|
58
|
+
onEditingRowCancel?.({ row, table });
|
|
59
|
+
setEditingRow(null);
|
|
60
|
+
}
|
|
61
|
+
row._valuesCache = {} as any; //reset values cache
|
|
62
|
+
modalProps.onClose?.();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Modal
|
|
67
|
+
opened={open}
|
|
68
|
+
withCloseButton={false}
|
|
69
|
+
{...modalProps}
|
|
70
|
+
key={row.id}
|
|
71
|
+
onClose={handleCancel}
|
|
72
|
+
>
|
|
73
|
+
{((creatingRow &&
|
|
74
|
+
renderCreateRowModalContent?.({
|
|
75
|
+
internalEditComponents,
|
|
76
|
+
row,
|
|
77
|
+
table,
|
|
78
|
+
})) ||
|
|
79
|
+
renderEditRowModalContent?.({
|
|
80
|
+
internalEditComponents,
|
|
81
|
+
row,
|
|
82
|
+
table,
|
|
83
|
+
})) ?? (
|
|
84
|
+
<>
|
|
85
|
+
<form onSubmit={(e) => e.preventDefault()}>
|
|
86
|
+
<Stack gap="lg" pb={24} pt={16}>
|
|
87
|
+
{internalEditComponents}
|
|
88
|
+
</Stack>
|
|
89
|
+
</form>
|
|
90
|
+
<Flex justify="flex-end">
|
|
91
|
+
<MRT_EditActionButtons row={row} table={table} variant="text" />
|
|
92
|
+
</Flex>
|
|
93
|
+
</>
|
|
94
|
+
)}
|
|
95
|
+
</Modal>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
3
|
+
import classes from './MRT_Table.module.css';
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
darken,
|
|
9
|
+
lighten,
|
|
10
|
+
Table,
|
|
11
|
+
type TableProps,
|
|
12
|
+
useMantineColorScheme,
|
|
13
|
+
} from '@mantine/core';
|
|
14
|
+
|
|
15
|
+
import { useMRT_ColumnVirtualizer } from '../../hooks/useMRT_ColumnVirtualizer';
|
|
16
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
17
|
+
import { parseCSSVarId } from '../../utils/style.utils';
|
|
18
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
19
|
+
import { Memo_MRT_TableBody, MRT_TableBody } from '../body/MRT_TableBody';
|
|
20
|
+
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
|
21
|
+
import { MRT_TableHead } from '../head/MRT_TableHead';
|
|
22
|
+
|
|
23
|
+
interface Props<TData extends MRT_RowData> extends TableProps {
|
|
24
|
+
table: MRT_TableInstance<TData>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const MRT_Table = <TData extends MRT_RowData>({
|
|
28
|
+
table,
|
|
29
|
+
...rest
|
|
30
|
+
}: Props<TData>) => {
|
|
31
|
+
'use no memo';
|
|
32
|
+
const {
|
|
33
|
+
getFlatHeaders,
|
|
34
|
+
getState,
|
|
35
|
+
options: {
|
|
36
|
+
columns,
|
|
37
|
+
enableTableFooter,
|
|
38
|
+
enableTableHead,
|
|
39
|
+
layoutMode,
|
|
40
|
+
mantineTableProps,
|
|
41
|
+
memoMode,
|
|
42
|
+
},
|
|
43
|
+
} = table;
|
|
44
|
+
const { columnSizing, columnSizingInfo, columnVisibility, density } =
|
|
45
|
+
getState();
|
|
46
|
+
|
|
47
|
+
const tableProps = {
|
|
48
|
+
highlightOnHover: true,
|
|
49
|
+
horizontalSpacing: density,
|
|
50
|
+
verticalSpacing: density,
|
|
51
|
+
...parseFromValuesOrFunc(mantineTableProps, { table }),
|
|
52
|
+
...rest,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const columnSizeVars = useMemo(() => {
|
|
56
|
+
const headers = getFlatHeaders();
|
|
57
|
+
const colSizes: { [key: string]: number } = {};
|
|
58
|
+
for (let i = 0; i < headers.length; i++) {
|
|
59
|
+
const header = headers[i];
|
|
60
|
+
const colSize = header.getSize();
|
|
61
|
+
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
|
62
|
+
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
|
63
|
+
}
|
|
64
|
+
return colSizes;
|
|
65
|
+
}, [columns, columnSizing, columnSizingInfo, columnVisibility]);
|
|
66
|
+
|
|
67
|
+
const columnVirtualizer = useMRT_ColumnVirtualizer(table);
|
|
68
|
+
|
|
69
|
+
const commonTableGroupProps = {
|
|
70
|
+
columnVirtualizer,
|
|
71
|
+
table,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const { colorScheme } = useMantineColorScheme();
|
|
75
|
+
|
|
76
|
+
const { stripedColor } = tableProps;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Table
|
|
80
|
+
className={clsx(
|
|
81
|
+
'mrt-table',
|
|
82
|
+
classes.root,
|
|
83
|
+
layoutMode?.startsWith('grid') && classes['root-grid'],
|
|
84
|
+
tableProps.className,
|
|
85
|
+
)}
|
|
86
|
+
{...tableProps}
|
|
87
|
+
__vars={{
|
|
88
|
+
...columnSizeVars,
|
|
89
|
+
'--mrt-striped-row-background-color': stripedColor,
|
|
90
|
+
'--mrt-striped-row-hover-background-color': stripedColor
|
|
91
|
+
? colorScheme === 'dark'
|
|
92
|
+
? lighten(stripedColor, 0.08)
|
|
93
|
+
: darken(stripedColor, 0.12)
|
|
94
|
+
: undefined,
|
|
95
|
+
...tableProps.__vars,
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{enableTableHead && <MRT_TableHead {...commonTableGroupProps} />}
|
|
99
|
+
{memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (
|
|
100
|
+
<Memo_MRT_TableBody
|
|
101
|
+
{...commonTableGroupProps}
|
|
102
|
+
tableProps={tableProps}
|
|
103
|
+
/>
|
|
104
|
+
) : (
|
|
105
|
+
<MRT_TableBody {...commonTableGroupProps} tableProps={tableProps} />
|
|
106
|
+
)}
|
|
107
|
+
{enableTableFooter && <MRT_TableFooter {...commonTableGroupProps} />}
|
|
108
|
+
</Table>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--mrt-base-background-color);
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
overflow: auto;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.root-sticky {
|
|
9
|
+
max-height: clamp(
|
|
10
|
+
350px,
|
|
11
|
+
calc(100vh - calc(var(--mrt-top-toolbar-height) * 1px)),
|
|
12
|
+
9999px
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.root-fullscreen {
|
|
17
|
+
max-height: calc(
|
|
18
|
+
100vh - calc(var(--mrt-top-toolbar-height) * 1px)
|
|
19
|
+
) !important;
|
|
20
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
3
|
+
import classes from './MRT_TableContainer.module.css';
|
|
4
|
+
|
|
5
|
+
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Box, type BoxProps, LoadingOverlay } from '@mantine/core';
|
|
8
|
+
|
|
9
|
+
import { MRT_Table } from './MRT_Table';
|
|
10
|
+
|
|
11
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
12
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
13
|
+
import { MRT_EditRowModal } from '../modals/MRT_EditRowModal';
|
|
14
|
+
|
|
15
|
+
const useIsomorphicLayoutEffect =
|
|
16
|
+
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
17
|
+
|
|
18
|
+
interface Props<TData extends MRT_RowData> extends BoxProps {
|
|
19
|
+
table: MRT_TableInstance<TData>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const MRT_TableContainer = <TData extends MRT_RowData>({
|
|
23
|
+
table,
|
|
24
|
+
...rest
|
|
25
|
+
}: Props<TData>) => {
|
|
26
|
+
'use no memo';
|
|
27
|
+
const {
|
|
28
|
+
getState,
|
|
29
|
+
options: {
|
|
30
|
+
createDisplayMode,
|
|
31
|
+
editDisplayMode,
|
|
32
|
+
enableStickyHeader,
|
|
33
|
+
mantineLoadingOverlayProps,
|
|
34
|
+
mantineTableContainerProps,
|
|
35
|
+
},
|
|
36
|
+
refs: { bottomToolbarRef, tableContainerRef, topToolbarRef },
|
|
37
|
+
} = table;
|
|
38
|
+
const {
|
|
39
|
+
creatingRow,
|
|
40
|
+
editingRow,
|
|
41
|
+
isFullScreen,
|
|
42
|
+
isLoading,
|
|
43
|
+
showLoadingOverlay,
|
|
44
|
+
} = getState();
|
|
45
|
+
|
|
46
|
+
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
|
47
|
+
|
|
48
|
+
const tableContainerProps = {
|
|
49
|
+
...parseFromValuesOrFunc(mantineTableContainerProps, { table }),
|
|
50
|
+
...rest,
|
|
51
|
+
};
|
|
52
|
+
const loadingOverlayProps = parseFromValuesOrFunc(
|
|
53
|
+
mantineLoadingOverlayProps,
|
|
54
|
+
{ table },
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
useIsomorphicLayoutEffect(() => {
|
|
58
|
+
const topToolbarHeight =
|
|
59
|
+
typeof document !== 'undefined'
|
|
60
|
+
? (topToolbarRef.current?.offsetHeight ?? 0)
|
|
61
|
+
: 0;
|
|
62
|
+
|
|
63
|
+
const bottomToolbarHeight =
|
|
64
|
+
typeof document !== 'undefined'
|
|
65
|
+
? (bottomToolbarRef?.current?.offsetHeight ?? 0)
|
|
66
|
+
: 0;
|
|
67
|
+
|
|
68
|
+
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const createModalOpen = createDisplayMode === 'modal' && creatingRow;
|
|
72
|
+
const editModalOpen = editDisplayMode === 'modal' && editingRow;
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<Box
|
|
76
|
+
{...tableContainerProps}
|
|
77
|
+
__vars={{
|
|
78
|
+
'--mrt-top-toolbar-height': `${totalToolbarHeight}`,
|
|
79
|
+
...tableContainerProps?.__vars,
|
|
80
|
+
}}
|
|
81
|
+
className={clsx(
|
|
82
|
+
'mrt-table-container',
|
|
83
|
+
classes.root,
|
|
84
|
+
enableStickyHeader && classes['root-sticky'],
|
|
85
|
+
isFullScreen && classes['root-fullscreen'],
|
|
86
|
+
tableContainerProps?.className,
|
|
87
|
+
)}
|
|
88
|
+
ref={(node: HTMLDivElement) => {
|
|
89
|
+
if (node) {
|
|
90
|
+
tableContainerRef.current = node;
|
|
91
|
+
if (tableContainerProps?.ref) {
|
|
92
|
+
//@ts-ignore
|
|
93
|
+
tableContainerProps.ref.current = node;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
<LoadingOverlay
|
|
99
|
+
visible={isLoading || showLoadingOverlay}
|
|
100
|
+
zIndex={2}
|
|
101
|
+
{...loadingOverlayProps}
|
|
102
|
+
/>
|
|
103
|
+
<MRT_Table table={table} />
|
|
104
|
+
{(createModalOpen || editModalOpen) && (
|
|
105
|
+
<MRT_EditRowModal open table={table} />
|
|
106
|
+
)}
|
|
107
|
+
</Box>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* default background color for everything */
|
|
3
|
+
--mrt-base-background-color: var(--mantine-color-body);
|
|
4
|
+
|
|
5
|
+
@mixin light-root {
|
|
6
|
+
--mrt-striped-row-background-color: darken(
|
|
7
|
+
var(--mrt-base-background-color),
|
|
8
|
+
0.05
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
@mixin dark-root {
|
|
12
|
+
--mrt-striped-row-background-color: lighten(
|
|
13
|
+
var(--mrt-base-background-color),
|
|
14
|
+
0.04
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* row hover */
|
|
19
|
+
@mixin light-root {
|
|
20
|
+
--mrt-row-hover-background-color: darken(
|
|
21
|
+
var(--mrt-base-background-color),
|
|
22
|
+
0.08
|
|
23
|
+
);
|
|
24
|
+
--mrt-striped-row-hover-background-color: darken(
|
|
25
|
+
var(--mrt-striped-row-background-color),
|
|
26
|
+
0.12
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
@mixin dark-root {
|
|
30
|
+
--mrt-row-hover-background-color: lighten(
|
|
31
|
+
var(--mrt-base-background-color),
|
|
32
|
+
0.08
|
|
33
|
+
);
|
|
34
|
+
--mrt-striped-row-hover-background-color: lighten(
|
|
35
|
+
var(--mrt-striped-row-background-color),
|
|
36
|
+
0.08
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* row selection */
|
|
41
|
+
--mrt-selected-row-background-color: alpha(
|
|
42
|
+
var(--mantine-primary-color-light),
|
|
43
|
+
0.8
|
|
44
|
+
);
|
|
45
|
+
@mixin light-root {
|
|
46
|
+
--mrt-selected-row-hover-background-color: darken(
|
|
47
|
+
var(--mantine-primary-color-light-hover),
|
|
48
|
+
0.05
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
@mixin dark-root {
|
|
52
|
+
--mrt-selected-row-hover-background-color: lighten(
|
|
53
|
+
var(--mantine-primary-color-light-hover),
|
|
54
|
+
0.05
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* row pinning */
|
|
59
|
+
--mrt-pinned-row-background-color: var(--mrt-selected-row-background-color);
|
|
60
|
+
--mrt-pinned-row-hover-background-color: var(
|
|
61
|
+
--mrt-selected-row-hover-background-color
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/* column pinning */
|
|
65
|
+
@mixin light-root {
|
|
66
|
+
--mrt-pinned-column-background-color: darken(
|
|
67
|
+
var(--mrt-base-background-color),
|
|
68
|
+
0.01
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
@mixin dark-root {
|
|
72
|
+
--mrt-pinned-column-background-color: darken(
|
|
73
|
+
var(--mrt-base-background-color),
|
|
74
|
+
0.05
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* cell borders */
|
|
79
|
+
--mrt-dragging-hovered-border-color: var(--mantine-primary-color-filled);
|
|
80
|
+
--mrt-dragging-drag-border-color: var(--mantine-color-gray-7);
|
|
81
|
+
--mrt-resize-column-border-color: var(--mantine-primary-color-filled);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.root {
|
|
85
|
+
background-color: var(--mrt-base-background-color);
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
transition: all 150ms ease-in-out;
|
|
88
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
3
|
+
import classes from './MRT_TablePaper.module.css';
|
|
4
|
+
|
|
5
|
+
import { Paper, type PaperProps } from '@mantine/core';
|
|
6
|
+
|
|
7
|
+
import { MRT_TableContainer } from './MRT_TableContainer';
|
|
8
|
+
|
|
9
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
11
|
+
import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar';
|
|
12
|
+
import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar';
|
|
13
|
+
|
|
14
|
+
interface Props<TData extends MRT_RowData> extends PaperProps {
|
|
15
|
+
table: MRT_TableInstance<TData>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
19
|
+
table,
|
|
20
|
+
...rest
|
|
21
|
+
}: Props<TData>) => {
|
|
22
|
+
'use no memo';
|
|
23
|
+
const {
|
|
24
|
+
getState,
|
|
25
|
+
options: {
|
|
26
|
+
enableBottomToolbar,
|
|
27
|
+
enableTopToolbar,
|
|
28
|
+
mantinePaperProps,
|
|
29
|
+
renderBottomToolbar,
|
|
30
|
+
renderTopToolbar,
|
|
31
|
+
},
|
|
32
|
+
refs: { tablePaperRef },
|
|
33
|
+
} = table;
|
|
34
|
+
const { isFullScreen } = getState();
|
|
35
|
+
|
|
36
|
+
const tablePaperProps = {
|
|
37
|
+
...parseFromValuesOrFunc(mantinePaperProps, { table }),
|
|
38
|
+
...rest,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Paper
|
|
43
|
+
shadow="xs"
|
|
44
|
+
withBorder
|
|
45
|
+
{...tablePaperProps}
|
|
46
|
+
className={clsx(
|
|
47
|
+
'mrt-table-paper',
|
|
48
|
+
classes.root,
|
|
49
|
+
isFullScreen && 'mrt-table-paper-fullscreen',
|
|
50
|
+
tablePaperProps?.className,
|
|
51
|
+
)}
|
|
52
|
+
ref={(ref: HTMLDivElement) => {
|
|
53
|
+
tablePaperRef.current = ref;
|
|
54
|
+
if (tablePaperProps?.ref) {
|
|
55
|
+
tablePaperProps.ref.current = ref;
|
|
56
|
+
}
|
|
57
|
+
}}
|
|
58
|
+
// rare case where we should use inline styles to guarantee highest specificity
|
|
59
|
+
style={(theme) => ({
|
|
60
|
+
zIndex: isFullScreen ? 200 : undefined,
|
|
61
|
+
...parseFromValuesOrFunc(tablePaperProps?.style, theme),
|
|
62
|
+
...(isFullScreen
|
|
63
|
+
? {
|
|
64
|
+
border: 0,
|
|
65
|
+
borderRadius: 0,
|
|
66
|
+
bottom: 0,
|
|
67
|
+
height: '100vh',
|
|
68
|
+
left: 0,
|
|
69
|
+
margin: 0,
|
|
70
|
+
maxHeight: '100vh',
|
|
71
|
+
maxWidth: '100vw',
|
|
72
|
+
padding: 0,
|
|
73
|
+
position: 'fixed',
|
|
74
|
+
right: 0,
|
|
75
|
+
top: 0,
|
|
76
|
+
width: '100vw',
|
|
77
|
+
}
|
|
78
|
+
: null),
|
|
79
|
+
})}
|
|
80
|
+
>
|
|
81
|
+
{enableTopToolbar &&
|
|
82
|
+
(parseFromValuesOrFunc(renderTopToolbar, { table }) ?? (
|
|
83
|
+
<MRT_TopToolbar table={table} />
|
|
84
|
+
))}
|
|
85
|
+
<MRT_TableContainer table={table} />
|
|
86
|
+
{enableBottomToolbar &&
|
|
87
|
+
(parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? (
|
|
88
|
+
<MRT_BottomToolbar table={table} />
|
|
89
|
+
))}
|
|
90
|
+
</Paper>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--mrt-base-background-color);
|
|
3
|
+
border-top: 1px solid
|
|
4
|
+
light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-4));
|
|
5
|
+
bottom: var(--mrt-bottom-toolbar-bottom);
|
|
6
|
+
box-shadow: 0 1px 2px -1px color-mix(
|
|
7
|
+
in srgb,
|
|
8
|
+
var(--mantine-color-black) 10%,
|
|
9
|
+
transparent
|
|
10
|
+
) inset;
|
|
11
|
+
left: 0;
|
|
12
|
+
right: 0;
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.root-fullscreen {
|
|
17
|
+
position: fixed !important;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.custom-toolbar-container {
|
|
22
|
+
align-items: center;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
padding: rem(8px);
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.paginator-container {
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: flex-end;
|
|
33
|
+
right: 0;
|
|
34
|
+
top: 0;
|
|
35
|
+
position: absolute;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.paginator-container-alert-banner {
|
|
39
|
+
position: relative !important;
|
|
40
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
3
|
+
import commonClasses from './common.styles.module.css';
|
|
4
|
+
import classes from './MRT_BottomToolbar.module.css';
|
|
5
|
+
|
|
6
|
+
import { Box, type BoxProps } from '@mantine/core';
|
|
7
|
+
import { useMediaQuery } from '@mantine/hooks';
|
|
8
|
+
|
|
9
|
+
import { MRT_ProgressBar } from './MRT_ProgressBar';
|
|
10
|
+
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
11
|
+
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
12
|
+
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
|
13
|
+
|
|
14
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
15
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
16
|
+
|
|
17
|
+
interface Props<TData extends MRT_RowData> extends BoxProps {
|
|
18
|
+
table: MRT_TableInstance<TData>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const MRT_BottomToolbar = <TData extends MRT_RowData>({
|
|
22
|
+
table,
|
|
23
|
+
...rest
|
|
24
|
+
}: Props<TData>) => {
|
|
25
|
+
'use no memo';
|
|
26
|
+
const {
|
|
27
|
+
getState,
|
|
28
|
+
options: {
|
|
29
|
+
enablePagination,
|
|
30
|
+
mantineBottomToolbarProps,
|
|
31
|
+
positionPagination,
|
|
32
|
+
positionToolbarAlertBanner,
|
|
33
|
+
positionToolbarDropZone,
|
|
34
|
+
renderBottomToolbarCustomActions,
|
|
35
|
+
},
|
|
36
|
+
refs: { bottomToolbarRef },
|
|
37
|
+
} = table;
|
|
38
|
+
const { isFullScreen } = getState();
|
|
39
|
+
|
|
40
|
+
const isMobile = useMediaQuery('(max-width: 720px)');
|
|
41
|
+
|
|
42
|
+
const toolbarProps = {
|
|
43
|
+
...parseFromValuesOrFunc(mantineBottomToolbarProps, {
|
|
44
|
+
table,
|
|
45
|
+
}),
|
|
46
|
+
...rest,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Box
|
|
53
|
+
{...toolbarProps}
|
|
54
|
+
className={clsx(
|
|
55
|
+
'mrt-bottom-toolbar',
|
|
56
|
+
classes.root,
|
|
57
|
+
commonClasses['common-toolbar-styles'],
|
|
58
|
+
isFullScreen && classes['root-fullscreen'],
|
|
59
|
+
toolbarProps?.className,
|
|
60
|
+
)}
|
|
61
|
+
ref={(node: HTMLDivElement) => {
|
|
62
|
+
if (node) {
|
|
63
|
+
bottomToolbarRef.current = node;
|
|
64
|
+
if (toolbarProps?.ref) {
|
|
65
|
+
toolbarProps.ref.current = node;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<MRT_ProgressBar isTopToolbar={false} table={table} />
|
|
71
|
+
{positionToolbarAlertBanner === 'bottom' && (
|
|
72
|
+
<MRT_ToolbarAlertBanner
|
|
73
|
+
stackAlertBanner={stackAlertBanner}
|
|
74
|
+
table={table}
|
|
75
|
+
/>
|
|
76
|
+
)}
|
|
77
|
+
{['both', 'bottom'].includes(positionToolbarDropZone ?? '') && (
|
|
78
|
+
<MRT_ToolbarDropZone table={table} />
|
|
79
|
+
)}
|
|
80
|
+
<Box className={classes['custom-toolbar-container']}>
|
|
81
|
+
{renderBottomToolbarCustomActions ? (
|
|
82
|
+
renderBottomToolbarCustomActions({ table })
|
|
83
|
+
) : (
|
|
84
|
+
<span />
|
|
85
|
+
)}
|
|
86
|
+
<Box
|
|
87
|
+
className={clsx(
|
|
88
|
+
classes['paginator-container'],
|
|
89
|
+
stackAlertBanner && classes['paginator-container-alert-banner'],
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
{enablePagination &&
|
|
93
|
+
['both', 'bottom'].includes(positionPagination ?? '') && (
|
|
94
|
+
<MRT_TablePagination position="bottom" table={table} />
|
|
95
|
+
)}
|
|
96
|
+
</Box>
|
|
97
|
+
</Box>
|
|
98
|
+
</Box>
|
|
99
|
+
);
|
|
100
|
+
};
|