@novastera-oss/material-react-table 4.0.0-beta.11
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 +203 -0
- package/dist/index.cjs +5207 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1871 -0
- package/dist/index.js +5101 -0
- package/dist/index.js.map +1 -0
- package/locales/ar/index.d.ts +3 -0
- package/locales/ar/index.esm.d.ts +3 -0
- package/locales/ar/index.esm.js +96 -0
- package/locales/ar/index.js +98 -0
- package/locales/ar/package.json +6 -0
- package/locales/az/index.d.ts +3 -0
- package/locales/az/index.esm.d.ts +3 -0
- package/locales/az/index.esm.js +96 -0
- package/locales/az/index.js +98 -0
- package/locales/az/package.json +6 -0
- package/locales/bg/index.d.ts +3 -0
- package/locales/bg/index.esm.d.ts +3 -0
- package/locales/bg/index.esm.js +96 -0
- package/locales/bg/index.js +98 -0
- package/locales/bg/package.json +6 -0
- package/locales/cs/index.d.ts +3 -0
- package/locales/cs/index.esm.d.ts +3 -0
- package/locales/cs/index.esm.js +96 -0
- package/locales/cs/index.js +98 -0
- package/locales/cs/package.json +6 -0
- package/locales/da/index.d.ts +3 -0
- package/locales/da/index.esm.d.ts +3 -0
- package/locales/da/index.esm.js +96 -0
- package/locales/da/index.js +98 -0
- package/locales/da/package.json +6 -0
- package/locales/de/index.d.ts +3 -0
- package/locales/de/index.esm.d.ts +3 -0
- package/locales/de/index.esm.js +96 -0
- package/locales/de/index.js +98 -0
- package/locales/de/package.json +6 -0
- package/locales/el/index.d.ts +3 -0
- package/locales/el/index.esm.d.ts +3 -0
- package/locales/el/index.esm.js +96 -0
- package/locales/el/index.js +98 -0
- package/locales/el/package.json +6 -0
- package/locales/en/index.d.ts +3 -0
- package/locales/en/index.esm.d.ts +3 -0
- package/locales/en/index.esm.js +96 -0
- package/locales/en/index.js +98 -0
- package/locales/en/package.json +6 -0
- package/locales/es/index.d.ts +3 -0
- package/locales/es/index.esm.d.ts +3 -0
- package/locales/es/index.esm.js +96 -0
- package/locales/es/index.js +98 -0
- package/locales/es/package.json +6 -0
- package/locales/et/index.d.ts +3 -0
- package/locales/et/index.esm.d.ts +3 -0
- package/locales/et/index.esm.js +96 -0
- package/locales/et/index.js +98 -0
- package/locales/et/package.json +6 -0
- package/locales/fa/index.d.ts +3 -0
- package/locales/fa/index.esm.d.ts +3 -0
- package/locales/fa/index.esm.js +96 -0
- package/locales/fa/index.js +98 -0
- package/locales/fa/package.json +6 -0
- package/locales/fi/index.d.ts +3 -0
- package/locales/fi/index.esm.d.ts +3 -0
- package/locales/fi/index.esm.js +96 -0
- package/locales/fi/index.js +98 -0
- package/locales/fi/package.json +6 -0
- package/locales/fr/index.d.ts +3 -0
- package/locales/fr/index.esm.d.ts +3 -0
- package/locales/fr/index.esm.js +96 -0
- package/locales/fr/index.js +98 -0
- package/locales/fr/package.json +6 -0
- package/locales/he/index.d.ts +3 -0
- package/locales/he/index.esm.d.ts +3 -0
- package/locales/he/index.esm.js +96 -0
- package/locales/he/index.js +98 -0
- package/locales/he/package.json +6 -0
- package/locales/hr/index.d.ts +3 -0
- package/locales/hr/index.esm.d.ts +3 -0
- package/locales/hr/index.esm.js +96 -0
- package/locales/hr/index.js +98 -0
- package/locales/hr/package.json +6 -0
- package/locales/hu/index.d.ts +3 -0
- package/locales/hu/index.esm.d.ts +3 -0
- package/locales/hu/index.esm.js +96 -0
- package/locales/hu/index.js +98 -0
- package/locales/hu/package.json +6 -0
- package/locales/hy/index.d.ts +3 -0
- package/locales/hy/index.esm.d.ts +3 -0
- package/locales/hy/index.esm.js +96 -0
- package/locales/hy/index.js +98 -0
- package/locales/hy/package.json +6 -0
- package/locales/id/index.d.ts +3 -0
- package/locales/id/index.esm.d.ts +3 -0
- package/locales/id/index.esm.js +96 -0
- package/locales/id/index.js +98 -0
- package/locales/id/package.json +6 -0
- package/locales/it/index.d.ts +3 -0
- package/locales/it/index.esm.d.ts +3 -0
- package/locales/it/index.esm.js +96 -0
- package/locales/it/index.js +98 -0
- package/locales/it/package.json +6 -0
- package/locales/ja/index.d.ts +3 -0
- package/locales/ja/index.esm.d.ts +3 -0
- package/locales/ja/index.esm.js +96 -0
- package/locales/ja/index.js +98 -0
- package/locales/ja/package.json +6 -0
- package/locales/ko/index.d.ts +3 -0
- package/locales/ko/index.esm.d.ts +3 -0
- package/locales/ko/index.esm.js +96 -0
- package/locales/ko/index.js +98 -0
- package/locales/ko/package.json +6 -0
- package/locales/nl/index.d.ts +3 -0
- package/locales/nl/index.esm.d.ts +3 -0
- package/locales/nl/index.esm.js +96 -0
- package/locales/nl/index.js +98 -0
- package/locales/nl/package.json +6 -0
- package/locales/no/index.d.ts +3 -0
- package/locales/no/index.esm.d.ts +3 -0
- package/locales/no/index.esm.js +96 -0
- package/locales/no/index.js +98 -0
- package/locales/no/package.json +6 -0
- package/locales/np/index.d.ts +3 -0
- package/locales/np/index.esm.d.ts +3 -0
- package/locales/np/index.esm.js +96 -0
- package/locales/np/index.js +98 -0
- package/locales/np/package.json +6 -0
- package/locales/pl/index.d.ts +3 -0
- package/locales/pl/index.esm.d.ts +3 -0
- package/locales/pl/index.esm.js +96 -0
- package/locales/pl/index.js +98 -0
- package/locales/pl/package.json +6 -0
- package/locales/pt/index.d.ts +3 -0
- package/locales/pt/index.esm.d.ts +3 -0
- package/locales/pt/index.esm.js +96 -0
- package/locales/pt/index.js +98 -0
- package/locales/pt/package.json +6 -0
- package/locales/pt-BR/index.d.ts +3 -0
- package/locales/pt-BR/index.esm.d.ts +3 -0
- package/locales/pt-BR/index.esm.js +96 -0
- package/locales/pt-BR/index.js +98 -0
- package/locales/pt-BR/package.json +6 -0
- package/locales/ro/index.d.ts +3 -0
- package/locales/ro/index.esm.d.ts +3 -0
- package/locales/ro/index.esm.js +96 -0
- package/locales/ro/index.js +98 -0
- package/locales/ro/package.json +6 -0
- package/locales/ru/index.d.ts +3 -0
- package/locales/ru/index.esm.d.ts +3 -0
- package/locales/ru/index.esm.js +96 -0
- package/locales/ru/index.js +98 -0
- package/locales/ru/package.json +6 -0
- package/locales/sk/index.d.ts +3 -0
- package/locales/sk/index.esm.d.ts +3 -0
- package/locales/sk/index.esm.js +96 -0
- package/locales/sk/index.js +98 -0
- package/locales/sk/package.json +6 -0
- package/locales/sr-Cyrl-RS/index.d.ts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.d.ts +3 -0
- package/locales/sr-Cyrl-RS/index.esm.js +96 -0
- package/locales/sr-Cyrl-RS/index.js +98 -0
- package/locales/sr-Cyrl-RS/package.json +6 -0
- package/locales/sr-Latn-RS/index.d.ts +3 -0
- package/locales/sr-Latn-RS/index.esm.d.ts +3 -0
- package/locales/sr-Latn-RS/index.esm.js +96 -0
- package/locales/sr-Latn-RS/index.js +98 -0
- package/locales/sr-Latn-RS/package.json +6 -0
- package/locales/sv/index.d.ts +3 -0
- package/locales/sv/index.esm.d.ts +3 -0
- package/locales/sv/index.esm.js +96 -0
- package/locales/sv/index.js +98 -0
- package/locales/sv/package.json +6 -0
- package/locales/tr/index.d.ts +3 -0
- package/locales/tr/index.esm.d.ts +3 -0
- package/locales/tr/index.esm.js +96 -0
- package/locales/tr/index.js +98 -0
- package/locales/tr/package.json +6 -0
- package/locales/uk/index.d.ts +3 -0
- package/locales/uk/index.esm.d.ts +3 -0
- package/locales/uk/index.esm.js +96 -0
- package/locales/uk/index.js +98 -0
- package/locales/uk/package.json +6 -0
- package/locales/vi/index.d.ts +3 -0
- package/locales/vi/index.esm.d.ts +3 -0
- package/locales/vi/index.esm.js +96 -0
- package/locales/vi/index.js +98 -0
- package/locales/vi/package.json +6 -0
- package/locales/zh-Hans/index.d.ts +3 -0
- package/locales/zh-Hans/index.esm.d.ts +3 -0
- package/locales/zh-Hans/index.esm.js +96 -0
- package/locales/zh-Hans/index.js +98 -0
- package/locales/zh-Hans/package.json +6 -0
- package/locales/zh-Hant/index.d.ts +3 -0
- package/locales/zh-Hant/index.esm.d.ts +3 -0
- package/locales/zh-Hant/index.esm.js +96 -0
- package/locales/zh-Hant/index.js +98 -0
- package/locales/zh-Hant/package.json +6 -0
- package/package.json +103 -0
- package/src/components/MaterialReactTable.tsx +36 -0
- package/src/components/body/MRT_TableBody.tsx +233 -0
- package/src/components/body/MRT_TableBodyCell.tsx +356 -0
- package/src/components/body/MRT_TableBodyCellValue.tsx +130 -0
- package/src/components/body/MRT_TableBodyRow.tsx +306 -0
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +61 -0
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +58 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +118 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +73 -0
- package/src/components/buttons/MRT_CopyButton.tsx +91 -0
- package/src/components/buttons/MRT_EditActionButtons.tsx +135 -0
- package/src/components/buttons/MRT_ExpandAllButton.tsx +82 -0
- package/src/components/buttons/MRT_ExpandButton.tsx +106 -0
- package/src/components/buttons/MRT_GrabHandleButton.tsx +66 -0
- package/src/components/buttons/MRT_RowPinButton.tsx +84 -0
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +50 -0
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +52 -0
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +40 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +51 -0
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +46 -0
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +126 -0
- package/src/components/footer/MRT_TableFooter.tsx +92 -0
- package/src/components/footer/MRT_TableFooterCell.tsx +111 -0
- package/src/components/footer/MRT_TableFooterRow.tsx +99 -0
- package/src/components/head/MRT_TableHead.tsx +95 -0
- package/src/components/head/MRT_TableHeadCell.tsx +357 -0
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +100 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +52 -0
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +180 -0
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +91 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +96 -0
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +102 -0
- package/src/components/head/MRT_TableHeadRow.tsx +94 -0
- package/src/components/inputs/MRT_EditCellTextField.tsx +195 -0
- package/src/components/inputs/MRT_FilterCheckbox.tsx +107 -0
- package/src/components/inputs/MRT_FilterRangeFields.tsx +42 -0
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +145 -0
- package/src/components/inputs/MRT_FilterTextField.tsx +629 -0
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +165 -0
- package/src/components/inputs/MRT_SelectCheckbox.tsx +142 -0
- package/src/components/menus/MRT_ActionMenuItem.tsx +62 -0
- package/src/components/menus/MRT_CellActionMenu.tsx +109 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +354 -0
- package/src/components/menus/MRT_FilterOptionMenu.tsx +294 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +90 -0
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +181 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +204 -0
- package/src/components/modals/MRT_EditRowModal.tsx +114 -0
- package/src/components/table/MRT_Table.tsx +86 -0
- package/src/components/table/MRT_TableContainer.tsx +115 -0
- package/src/components/table/MRT_TableLoadingOverlay.tsx +58 -0
- package/src/components/table/MRT_TablePaper.tsx +91 -0
- package/src/components/toolbar/MRT_BottomToolbar.tsx +112 -0
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +53 -0
- package/src/components/toolbar/MRT_TablePagination.tsx +250 -0
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +182 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +82 -0
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +73 -0
- package/src/components/toolbar/MRT_TopToolbar.tsx +134 -0
- package/src/fns/aggregationFns.ts +3 -0
- package/src/fns/filterFns.ts +196 -0
- package/src/fns/sortingFns.ts +33 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +28 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +29 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +91 -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 +33 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +124 -0
- package/src/hooks/useMRT_Effects.ts +106 -0
- package/src/hooks/useMRT_RowVirtualizer.ts +88 -0
- package/src/hooks/useMRT_Rows.ts +44 -0
- package/src/hooks/useMRT_TableInstance.ts +317 -0
- package/src/hooks/useMRT_TableOptions.ts +270 -0
- package/src/hooks/useMaterialReactTable.ts +12 -0
- package/src/icons.ts +73 -0
- package/src/index.ts +91 -0
- package/src/locales/ar.ts +97 -0
- package/src/locales/az.ts +97 -0
- package/src/locales/bg.ts +97 -0
- package/src/locales/cs.ts +98 -0
- package/src/locales/da.ts +97 -0
- package/src/locales/de.ts +97 -0
- package/src/locales/el.ts +97 -0
- package/src/locales/en.ts +97 -0
- package/src/locales/es.ts +97 -0
- package/src/locales/et.ts +98 -0
- package/src/locales/fa.ts +97 -0
- package/src/locales/fi.ts +98 -0
- package/src/locales/fr.ts +97 -0
- package/src/locales/he.ts +97 -0
- package/src/locales/hr.ts +97 -0
- package/src/locales/hu.ts +97 -0
- package/src/locales/hy.ts +97 -0
- package/src/locales/id.ts +98 -0
- package/src/locales/it.ts +97 -0
- package/src/locales/ja.ts +97 -0
- package/src/locales/ko.ts +97 -0
- package/src/locales/mk.ts +96 -0
- package/src/locales/nl.ts +97 -0
- package/src/locales/no.ts +99 -0
- package/src/locales/np.ts +98 -0
- package/src/locales/pl.ts +97 -0
- package/src/locales/pt-BR.ts +97 -0
- package/src/locales/pt.ts +97 -0
- package/src/locales/ro.ts +97 -0
- package/src/locales/ru.ts +97 -0
- package/src/locales/sk.ts +98 -0
- package/src/locales/sr-Cyrl-RS.ts +97 -0
- package/src/locales/sr-Latn-RS.ts +97 -0
- package/src/locales/sv.ts +97 -0
- package/src/locales/tr.ts +97 -0
- package/src/locales/uk.ts +97 -0
- package/src/locales/vi.ts +97 -0
- package/src/locales/zh-Hans.ts +96 -0
- package/src/locales/zh-Hant.ts +96 -0
- package/src/types.ts +1295 -0
- package/src/utils/cell.utils.ts +234 -0
- package/src/utils/column.utils.ts +209 -0
- package/src/utils/displayColumn.utils.ts +152 -0
- package/src/utils/row.utils.ts +260 -0
- package/src/utils/style.utils.ts +221 -0
- package/src/utils/tanstack.helpers.ts +64 -0
- package/src/utils/utils.ts +56 -0
- package/src/utils/virtualization.utils.ts +24 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useReactTable } from '@tanstack/react-table';
|
|
3
|
+
import {
|
|
4
|
+
type MRT_Cell,
|
|
5
|
+
type MRT_Column,
|
|
6
|
+
type MRT_ColumnDef,
|
|
7
|
+
type MRT_ColumnFilterFnsState,
|
|
8
|
+
type MRT_ColumnOrderState,
|
|
9
|
+
type MRT_ColumnSizingInfoState,
|
|
10
|
+
type MRT_DefinedTableOptions,
|
|
11
|
+
type MRT_DensityState,
|
|
12
|
+
type MRT_FilterOption,
|
|
13
|
+
type MRT_GroupingState,
|
|
14
|
+
type MRT_PaginationState,
|
|
15
|
+
type MRT_Row,
|
|
16
|
+
type MRT_RowData,
|
|
17
|
+
type MRT_StatefulTableOptions,
|
|
18
|
+
type MRT_TableInstance,
|
|
19
|
+
type MRT_TableState,
|
|
20
|
+
type MRT_Updater,
|
|
21
|
+
} from '../types';
|
|
22
|
+
import {
|
|
23
|
+
getAllLeafColumnDefs,
|
|
24
|
+
getColumnId,
|
|
25
|
+
getDefaultColumnFilterFn,
|
|
26
|
+
prepareColumns,
|
|
27
|
+
} from '../utils/column.utils';
|
|
28
|
+
import {
|
|
29
|
+
getDefaultColumnOrderIds,
|
|
30
|
+
showRowActionsColumn,
|
|
31
|
+
showRowDragColumn,
|
|
32
|
+
showRowExpandColumn,
|
|
33
|
+
showRowNumbersColumn,
|
|
34
|
+
showRowPinningColumn,
|
|
35
|
+
showRowSelectionColumn,
|
|
36
|
+
showRowSpacerColumn,
|
|
37
|
+
} from '../utils/displayColumn.utils';
|
|
38
|
+
import { createRow } from '../utils/tanstack.helpers';
|
|
39
|
+
import { getMRT_RowActionsColumnDef } from './display-columns/getMRT_RowActionsColumnDef';
|
|
40
|
+
import { getMRT_RowDragColumnDef } from './display-columns/getMRT_RowDragColumnDef';
|
|
41
|
+
import { getMRT_RowExpandColumnDef } from './display-columns/getMRT_RowExpandColumnDef';
|
|
42
|
+
import { getMRT_RowNumbersColumnDef } from './display-columns/getMRT_RowNumbersColumnDef';
|
|
43
|
+
import { getMRT_RowPinningColumnDef } from './display-columns/getMRT_RowPinningColumnDef';
|
|
44
|
+
import { getMRT_RowSelectColumnDef } from './display-columns/getMRT_RowSelectColumnDef';
|
|
45
|
+
import { getMRT_RowSpacerColumnDef } from './display-columns/getMRT_RowSpacerColumnDef';
|
|
46
|
+
import { useMRT_Effects } from './useMRT_Effects';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
|
|
50
|
+
* @param definedTableOptions - table options with proper defaults set
|
|
51
|
+
* @returns the MRT table instance
|
|
52
|
+
*/
|
|
53
|
+
export const useMRT_TableInstance = <TData extends MRT_RowData>(
|
|
54
|
+
definedTableOptions: MRT_DefinedTableOptions<TData>,
|
|
55
|
+
): MRT_TableInstance<TData> => {
|
|
56
|
+
const lastSelectedRowId = useRef<null | string>(null);
|
|
57
|
+
const actionCellRef = useRef<HTMLTableCellElement>(null);
|
|
58
|
+
const bottomToolbarRef = useRef<HTMLDivElement>(null);
|
|
59
|
+
const editInputRefs = useRef<Record<string, HTMLInputElement>>({});
|
|
60
|
+
const filterInputRefs = useRef<Record<string, HTMLInputElement>>({});
|
|
61
|
+
const searchInputRef = useRef<HTMLInputElement>(null);
|
|
62
|
+
const tableContainerRef = useRef<HTMLDivElement>(null);
|
|
63
|
+
const tableHeadCellRefs = useRef<Record<string, HTMLTableCellElement>>({});
|
|
64
|
+
const tablePaperRef = useRef<HTMLDivElement>(null);
|
|
65
|
+
const topToolbarRef = useRef<HTMLDivElement>(null);
|
|
66
|
+
const tableHeadRef = useRef<HTMLTableSectionElement>(null);
|
|
67
|
+
const tableFooterRef = useRef<HTMLTableSectionElement>(null);
|
|
68
|
+
|
|
69
|
+
//transform initial state with proper column order
|
|
70
|
+
const initialState: Partial<MRT_TableState<TData>> = useMemo(() => {
|
|
71
|
+
const initState = definedTableOptions.initialState ?? {};
|
|
72
|
+
initState.columnOrder =
|
|
73
|
+
initState.columnOrder ??
|
|
74
|
+
getDefaultColumnOrderIds({
|
|
75
|
+
...definedTableOptions,
|
|
76
|
+
state: {
|
|
77
|
+
...definedTableOptions.initialState,
|
|
78
|
+
...definedTableOptions.state,
|
|
79
|
+
},
|
|
80
|
+
} as MRT_StatefulTableOptions<TData>);
|
|
81
|
+
initState.globalFilterFn = definedTableOptions.globalFilterFn ?? 'fuzzy';
|
|
82
|
+
return initState;
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
definedTableOptions.initialState = initialState;
|
|
86
|
+
|
|
87
|
+
const [actionCell, setActionCell] = useState<MRT_Cell<TData> | null>(
|
|
88
|
+
initialState.actionCell ?? null,
|
|
89
|
+
);
|
|
90
|
+
const [creatingRow, _setCreatingRow] = useState<MRT_Row<TData> | null>(
|
|
91
|
+
initialState.creatingRow ?? null,
|
|
92
|
+
);
|
|
93
|
+
const [columnFilterFns, setColumnFilterFns] =
|
|
94
|
+
useState<MRT_ColumnFilterFnsState>(() =>
|
|
95
|
+
Object.assign(
|
|
96
|
+
{},
|
|
97
|
+
...getAllLeafColumnDefs(
|
|
98
|
+
definedTableOptions.columns as MRT_ColumnDef<TData>[],
|
|
99
|
+
).map((col) => ({
|
|
100
|
+
[getColumnId(col)]:
|
|
101
|
+
col.filterFn instanceof Function
|
|
102
|
+
? (col.filterFn.name ?? 'custom')
|
|
103
|
+
: (col.filterFn ??
|
|
104
|
+
initialState?.columnFilterFns?.[getColumnId(col)] ??
|
|
105
|
+
getDefaultColumnFilterFn(col)),
|
|
106
|
+
})),
|
|
107
|
+
),
|
|
108
|
+
);
|
|
109
|
+
const [columnOrder, onColumnOrderChange] = useState<MRT_ColumnOrderState>(
|
|
110
|
+
initialState.columnOrder ?? [],
|
|
111
|
+
);
|
|
112
|
+
const [columnSizingInfo, onColumnSizingInfoChange] =
|
|
113
|
+
useState<MRT_ColumnSizingInfoState>(
|
|
114
|
+
initialState.columnSizingInfo ?? ({} as MRT_ColumnSizingInfoState),
|
|
115
|
+
);
|
|
116
|
+
const [density, setDensity] = useState<MRT_DensityState>(
|
|
117
|
+
initialState?.density ?? 'comfortable',
|
|
118
|
+
);
|
|
119
|
+
const [draggingColumn, setDraggingColumn] =
|
|
120
|
+
useState<MRT_Column<TData> | null>(initialState.draggingColumn ?? null);
|
|
121
|
+
const [draggingRow, setDraggingRow] = useState<MRT_Row<TData> | null>(
|
|
122
|
+
initialState.draggingRow ?? null,
|
|
123
|
+
);
|
|
124
|
+
const [editingCell, setEditingCell] = useState<MRT_Cell<TData> | null>(
|
|
125
|
+
initialState.editingCell ?? null,
|
|
126
|
+
);
|
|
127
|
+
const [editingRow, setEditingRow] = useState<MRT_Row<TData> | null>(
|
|
128
|
+
initialState.editingRow ?? null,
|
|
129
|
+
);
|
|
130
|
+
const [globalFilterFn, setGlobalFilterFn] = useState<MRT_FilterOption>(
|
|
131
|
+
initialState.globalFilterFn ?? 'fuzzy',
|
|
132
|
+
);
|
|
133
|
+
const [grouping, onGroupingChange] = useState<MRT_GroupingState>(
|
|
134
|
+
initialState.grouping ?? [],
|
|
135
|
+
);
|
|
136
|
+
const [hoveredColumn, setHoveredColumn] = useState<Partial<
|
|
137
|
+
MRT_Column<TData>
|
|
138
|
+
> | null>(initialState.hoveredColumn ?? null);
|
|
139
|
+
const [hoveredRow, setHoveredRow] = useState<Partial<MRT_Row<TData>> | null>(
|
|
140
|
+
initialState.hoveredRow ?? null,
|
|
141
|
+
);
|
|
142
|
+
const [isFullScreen, setIsFullScreen] = useState<boolean>(
|
|
143
|
+
initialState?.isFullScreen ?? false,
|
|
144
|
+
);
|
|
145
|
+
const [pagination, onPaginationChange] = useState<MRT_PaginationState>(
|
|
146
|
+
initialState?.pagination ?? { pageIndex: 0, pageSize: 10 },
|
|
147
|
+
);
|
|
148
|
+
const [showAlertBanner, setShowAlertBanner] = useState<boolean>(
|
|
149
|
+
initialState?.showAlertBanner ?? false,
|
|
150
|
+
);
|
|
151
|
+
const [showColumnFilters, setShowColumnFilters] = useState<boolean>(
|
|
152
|
+
initialState?.showColumnFilters ?? false,
|
|
153
|
+
);
|
|
154
|
+
const [showGlobalFilter, setShowGlobalFilter] = useState<boolean>(
|
|
155
|
+
initialState?.showGlobalFilter ?? false,
|
|
156
|
+
);
|
|
157
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = useState<boolean>(
|
|
158
|
+
initialState?.showToolbarDropZone ?? false,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
definedTableOptions.state = {
|
|
162
|
+
actionCell,
|
|
163
|
+
columnFilterFns,
|
|
164
|
+
columnOrder,
|
|
165
|
+
columnSizingInfo,
|
|
166
|
+
creatingRow,
|
|
167
|
+
density,
|
|
168
|
+
draggingColumn,
|
|
169
|
+
draggingRow,
|
|
170
|
+
editingCell,
|
|
171
|
+
editingRow,
|
|
172
|
+
globalFilterFn,
|
|
173
|
+
grouping,
|
|
174
|
+
hoveredColumn,
|
|
175
|
+
hoveredRow,
|
|
176
|
+
isFullScreen,
|
|
177
|
+
pagination,
|
|
178
|
+
showAlertBanner,
|
|
179
|
+
showColumnFilters,
|
|
180
|
+
showGlobalFilter,
|
|
181
|
+
showToolbarDropZone,
|
|
182
|
+
...definedTableOptions.state,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
//The table options now include all state needed to help determine column visibility and order logic
|
|
186
|
+
const statefulTableOptions =
|
|
187
|
+
definedTableOptions as MRT_StatefulTableOptions<TData>;
|
|
188
|
+
|
|
189
|
+
//don't recompute columnDefs while resizing column or dragging column/row
|
|
190
|
+
const columnDefsRef = useRef<MRT_ColumnDef<TData>[]>([]);
|
|
191
|
+
statefulTableOptions.columns =
|
|
192
|
+
statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
|
|
193
|
+
statefulTableOptions.state.draggingColumn ||
|
|
194
|
+
statefulTableOptions.state.draggingRow
|
|
195
|
+
? columnDefsRef.current
|
|
196
|
+
: prepareColumns({
|
|
197
|
+
columnDefs: [
|
|
198
|
+
...([
|
|
199
|
+
showRowPinningColumn(statefulTableOptions) &&
|
|
200
|
+
getMRT_RowPinningColumnDef(statefulTableOptions),
|
|
201
|
+
showRowDragColumn(statefulTableOptions) &&
|
|
202
|
+
getMRT_RowDragColumnDef(statefulTableOptions),
|
|
203
|
+
showRowActionsColumn(statefulTableOptions) &&
|
|
204
|
+
getMRT_RowActionsColumnDef(statefulTableOptions),
|
|
205
|
+
showRowExpandColumn(statefulTableOptions) &&
|
|
206
|
+
getMRT_RowExpandColumnDef(statefulTableOptions),
|
|
207
|
+
showRowSelectionColumn(statefulTableOptions) &&
|
|
208
|
+
getMRT_RowSelectColumnDef(statefulTableOptions),
|
|
209
|
+
showRowNumbersColumn(statefulTableOptions) &&
|
|
210
|
+
getMRT_RowNumbersColumnDef(statefulTableOptions),
|
|
211
|
+
].filter(Boolean) as MRT_ColumnDef<TData>[]),
|
|
212
|
+
...statefulTableOptions.columns,
|
|
213
|
+
...([
|
|
214
|
+
showRowSpacerColumn(statefulTableOptions) &&
|
|
215
|
+
getMRT_RowSpacerColumnDef(statefulTableOptions),
|
|
216
|
+
].filter(Boolean) as MRT_ColumnDef<TData>[]),
|
|
217
|
+
],
|
|
218
|
+
tableOptions: statefulTableOptions,
|
|
219
|
+
});
|
|
220
|
+
columnDefsRef.current = statefulTableOptions.columns;
|
|
221
|
+
|
|
222
|
+
//if loading, generate blank rows to show skeleton loaders
|
|
223
|
+
statefulTableOptions.data = useMemo(
|
|
224
|
+
() =>
|
|
225
|
+
(statefulTableOptions.state.isLoading ||
|
|
226
|
+
statefulTableOptions.state.showSkeletons) &&
|
|
227
|
+
!statefulTableOptions.data.length
|
|
228
|
+
? [
|
|
229
|
+
...Array(
|
|
230
|
+
Math.min(statefulTableOptions.state.pagination.pageSize, 20),
|
|
231
|
+
).fill(null),
|
|
232
|
+
].map(() =>
|
|
233
|
+
Object.assign(
|
|
234
|
+
{},
|
|
235
|
+
...getAllLeafColumnDefs(statefulTableOptions.columns).map(
|
|
236
|
+
(col) => ({
|
|
237
|
+
[getColumnId(col)]: null,
|
|
238
|
+
}),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
)
|
|
242
|
+
: statefulTableOptions.data,
|
|
243
|
+
[
|
|
244
|
+
statefulTableOptions.data,
|
|
245
|
+
statefulTableOptions.state.isLoading,
|
|
246
|
+
statefulTableOptions.state.showSkeletons,
|
|
247
|
+
],
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
//@ts-expect-error
|
|
251
|
+
const table = useReactTable({
|
|
252
|
+
onColumnOrderChange,
|
|
253
|
+
onColumnSizingInfoChange,
|
|
254
|
+
onGroupingChange,
|
|
255
|
+
onPaginationChange,
|
|
256
|
+
...statefulTableOptions,
|
|
257
|
+
globalFilterFn: statefulTableOptions.filterFns?.[globalFilterFn ?? 'fuzzy'],
|
|
258
|
+
}) as MRT_TableInstance<TData>;
|
|
259
|
+
|
|
260
|
+
table.refs = {
|
|
261
|
+
actionCellRef,
|
|
262
|
+
bottomToolbarRef,
|
|
263
|
+
editInputRefs,
|
|
264
|
+
filterInputRefs,
|
|
265
|
+
lastSelectedRowId,
|
|
266
|
+
searchInputRef,
|
|
267
|
+
tableContainerRef,
|
|
268
|
+
tableFooterRef,
|
|
269
|
+
tableHeadCellRefs,
|
|
270
|
+
tableHeadRef,
|
|
271
|
+
tablePaperRef,
|
|
272
|
+
topToolbarRef,
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
table.setActionCell =
|
|
276
|
+
statefulTableOptions.onActionCellChange ?? setActionCell;
|
|
277
|
+
table.setCreatingRow = (row: MRT_Updater<MRT_Row<TData> | null | true>) => {
|
|
278
|
+
let _row = row;
|
|
279
|
+
if (row === true) {
|
|
280
|
+
_row = createRow(table);
|
|
281
|
+
}
|
|
282
|
+
statefulTableOptions?.onCreatingRowChange?.(
|
|
283
|
+
_row as MRT_Row<TData> | null,
|
|
284
|
+
) ?? _setCreatingRow(_row as MRT_Row<TData> | null);
|
|
285
|
+
};
|
|
286
|
+
table.setColumnFilterFns =
|
|
287
|
+
statefulTableOptions.onColumnFilterFnsChange ?? setColumnFilterFns;
|
|
288
|
+
table.setDensity = statefulTableOptions.onDensityChange ?? setDensity;
|
|
289
|
+
table.setDraggingColumn =
|
|
290
|
+
statefulTableOptions.onDraggingColumnChange ?? setDraggingColumn;
|
|
291
|
+
table.setDraggingRow =
|
|
292
|
+
statefulTableOptions.onDraggingRowChange ?? setDraggingRow;
|
|
293
|
+
table.setEditingCell =
|
|
294
|
+
statefulTableOptions.onEditingCellChange ?? setEditingCell;
|
|
295
|
+
table.setEditingRow =
|
|
296
|
+
statefulTableOptions.onEditingRowChange ?? setEditingRow;
|
|
297
|
+
table.setGlobalFilterFn =
|
|
298
|
+
statefulTableOptions.onGlobalFilterFnChange ?? setGlobalFilterFn;
|
|
299
|
+
table.setHoveredColumn =
|
|
300
|
+
statefulTableOptions.onHoveredColumnChange ?? setHoveredColumn;
|
|
301
|
+
table.setHoveredRow =
|
|
302
|
+
statefulTableOptions.onHoveredRowChange ?? setHoveredRow;
|
|
303
|
+
table.setIsFullScreen =
|
|
304
|
+
statefulTableOptions.onIsFullScreenChange ?? setIsFullScreen;
|
|
305
|
+
table.setShowAlertBanner =
|
|
306
|
+
statefulTableOptions.onShowAlertBannerChange ?? setShowAlertBanner;
|
|
307
|
+
table.setShowColumnFilters =
|
|
308
|
+
statefulTableOptions.onShowColumnFiltersChange ?? setShowColumnFilters;
|
|
309
|
+
table.setShowGlobalFilter =
|
|
310
|
+
statefulTableOptions.onShowGlobalFilterChange ?? setShowGlobalFilter;
|
|
311
|
+
table.setShowToolbarDropZone =
|
|
312
|
+
statefulTableOptions.onShowToolbarDropZoneChange ?? setShowToolbarDropZone;
|
|
313
|
+
|
|
314
|
+
useMRT_Effects(table);
|
|
315
|
+
|
|
316
|
+
return table;
|
|
317
|
+
};
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { useId, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
getCoreRowModel,
|
|
4
|
+
getExpandedRowModel,
|
|
5
|
+
getFacetedMinMaxValues,
|
|
6
|
+
getFacetedRowModel,
|
|
7
|
+
getFacetedUniqueValues,
|
|
8
|
+
getFilteredRowModel,
|
|
9
|
+
getGroupedRowModel,
|
|
10
|
+
getPaginationRowModel,
|
|
11
|
+
getSortedRowModel,
|
|
12
|
+
} from '@tanstack/react-table';
|
|
13
|
+
import { useTheme } from '@mui/material/styles';
|
|
14
|
+
import { MRT_AggregationFns } from '../fns/aggregationFns';
|
|
15
|
+
import { MRT_FilterFns } from '../fns/filterFns';
|
|
16
|
+
import { MRT_SortingFns } from '../fns/sortingFns';
|
|
17
|
+
import { MRT_Default_Icons } from '../icons';
|
|
18
|
+
import { MRT_Localization_EN } from '../locales/en';
|
|
19
|
+
import {
|
|
20
|
+
type MRT_DefinedTableOptions,
|
|
21
|
+
type MRT_RowData,
|
|
22
|
+
type MRT_TableOptions,
|
|
23
|
+
} from '../types';
|
|
24
|
+
import { getMRTTheme } from '../utils/style.utils';
|
|
25
|
+
|
|
26
|
+
export const MRT_DefaultColumn = {
|
|
27
|
+
filterVariant: 'text',
|
|
28
|
+
maxSize: 1000,
|
|
29
|
+
minSize: 40,
|
|
30
|
+
size: 180,
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
export const MRT_DefaultDisplayColumn = {
|
|
34
|
+
columnDefType: 'display',
|
|
35
|
+
enableClickToCopy: false,
|
|
36
|
+
enableColumnActions: false,
|
|
37
|
+
enableColumnDragging: false,
|
|
38
|
+
enableColumnFilter: false,
|
|
39
|
+
enableColumnOrdering: false,
|
|
40
|
+
enableEditing: false,
|
|
41
|
+
enableGlobalFilter: false,
|
|
42
|
+
enableGrouping: false,
|
|
43
|
+
enableHiding: false,
|
|
44
|
+
enableResizing: false,
|
|
45
|
+
enableSorting: false,
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
49
|
+
tableOptions: MRT_TableOptions<TData>,
|
|
50
|
+
) => MRT_DefinedTableOptions<TData> = <TData extends MRT_RowData>({
|
|
51
|
+
aggregationFns,
|
|
52
|
+
autoResetExpanded = false,
|
|
53
|
+
columnFilterDisplayMode = 'subheader',
|
|
54
|
+
columnResizeDirection,
|
|
55
|
+
columnResizeMode = 'onChange',
|
|
56
|
+
createDisplayMode = 'modal',
|
|
57
|
+
defaultColumn,
|
|
58
|
+
defaultDisplayColumn,
|
|
59
|
+
editDisplayMode = 'modal',
|
|
60
|
+
enableBatchRowSelection = true,
|
|
61
|
+
enableBottomToolbar = true,
|
|
62
|
+
enableColumnActions = true,
|
|
63
|
+
enableColumnFilters = true,
|
|
64
|
+
enableColumnOrdering = false,
|
|
65
|
+
enableColumnPinning = false,
|
|
66
|
+
enableColumnResizing = false,
|
|
67
|
+
enableColumnVirtualization,
|
|
68
|
+
enableDensityToggle = true,
|
|
69
|
+
enableExpandAll = true,
|
|
70
|
+
enableExpanding,
|
|
71
|
+
enableFacetedValues = false,
|
|
72
|
+
enableFilterMatchHighlighting = true,
|
|
73
|
+
enableFilters = true,
|
|
74
|
+
enableFullScreenToggle = true,
|
|
75
|
+
enableGlobalFilter = true,
|
|
76
|
+
enableGlobalFilterRankedResults = true,
|
|
77
|
+
enableGrouping = false,
|
|
78
|
+
enableHiding = true,
|
|
79
|
+
enableKeyboardShortcuts = true,
|
|
80
|
+
enableMultiRowSelection = true,
|
|
81
|
+
enableMultiSort = true,
|
|
82
|
+
enablePagination = true,
|
|
83
|
+
enableRowPinning = false,
|
|
84
|
+
enableRowSelection = false,
|
|
85
|
+
enableRowVirtualization,
|
|
86
|
+
enableSelectAll = true,
|
|
87
|
+
enableSorting = true,
|
|
88
|
+
enableStickyHeader = false,
|
|
89
|
+
enableTableFooter = true,
|
|
90
|
+
enableTableHead = true,
|
|
91
|
+
enableToolbarInternalActions = true,
|
|
92
|
+
enableTopToolbar = true,
|
|
93
|
+
filterFns,
|
|
94
|
+
icons,
|
|
95
|
+
id = useId(),
|
|
96
|
+
layoutMode,
|
|
97
|
+
localization,
|
|
98
|
+
manualFiltering,
|
|
99
|
+
manualGrouping,
|
|
100
|
+
manualPagination,
|
|
101
|
+
manualSorting,
|
|
102
|
+
mrtTheme,
|
|
103
|
+
paginationDisplayMode = 'default',
|
|
104
|
+
positionActionsColumn = 'first',
|
|
105
|
+
positionCreatingRow = 'top',
|
|
106
|
+
positionExpandColumn = 'first',
|
|
107
|
+
positionGlobalFilter = 'right',
|
|
108
|
+
positionPagination = 'bottom',
|
|
109
|
+
positionToolbarAlertBanner = 'top',
|
|
110
|
+
positionToolbarDropZone = 'top',
|
|
111
|
+
rowNumberDisplayMode = 'static',
|
|
112
|
+
rowPinningDisplayMode = 'sticky',
|
|
113
|
+
selectAllMode = 'page',
|
|
114
|
+
sortingFns,
|
|
115
|
+
...rest
|
|
116
|
+
}: MRT_TableOptions<TData>) => {
|
|
117
|
+
const theme = useTheme();
|
|
118
|
+
|
|
119
|
+
icons = useMemo(() => ({ ...MRT_Default_Icons, ...icons }), [icons]);
|
|
120
|
+
localization = useMemo(
|
|
121
|
+
() => ({
|
|
122
|
+
...MRT_Localization_EN,
|
|
123
|
+
...localization,
|
|
124
|
+
}),
|
|
125
|
+
[localization],
|
|
126
|
+
);
|
|
127
|
+
mrtTheme = useMemo(() => getMRTTheme(mrtTheme, theme), [mrtTheme, theme]);
|
|
128
|
+
aggregationFns = useMemo(
|
|
129
|
+
() => ({ ...MRT_AggregationFns, ...aggregationFns }),
|
|
130
|
+
[],
|
|
131
|
+
);
|
|
132
|
+
filterFns = useMemo(() => ({ ...MRT_FilterFns, ...filterFns }), []);
|
|
133
|
+
sortingFns = useMemo(() => ({ ...MRT_SortingFns, ...sortingFns }), []);
|
|
134
|
+
defaultColumn = useMemo(
|
|
135
|
+
() => ({ ...MRT_DefaultColumn, ...defaultColumn }),
|
|
136
|
+
[defaultColumn],
|
|
137
|
+
);
|
|
138
|
+
defaultDisplayColumn = useMemo(
|
|
139
|
+
() => ({
|
|
140
|
+
...MRT_DefaultDisplayColumn,
|
|
141
|
+
...defaultDisplayColumn,
|
|
142
|
+
}),
|
|
143
|
+
[defaultDisplayColumn],
|
|
144
|
+
);
|
|
145
|
+
//cannot be changed after initialization
|
|
146
|
+
[enableColumnVirtualization, enableRowVirtualization] = useMemo(
|
|
147
|
+
() => [enableColumnVirtualization, enableRowVirtualization],
|
|
148
|
+
[],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (!columnResizeDirection) {
|
|
152
|
+
columnResizeDirection = theme.direction || 'ltr';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
layoutMode =
|
|
156
|
+
layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
|
|
157
|
+
if (
|
|
158
|
+
layoutMode === 'semantic' &&
|
|
159
|
+
(enableRowVirtualization || enableColumnVirtualization)
|
|
160
|
+
) {
|
|
161
|
+
layoutMode = 'grid';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (enableRowVirtualization) {
|
|
165
|
+
enableStickyHeader = true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (enablePagination === false && manualPagination === undefined) {
|
|
169
|
+
manualPagination = true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!rest.data?.length) {
|
|
173
|
+
manualFiltering = true;
|
|
174
|
+
manualGrouping = true;
|
|
175
|
+
manualPagination = true;
|
|
176
|
+
manualSorting = true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
aggregationFns,
|
|
181
|
+
autoResetExpanded,
|
|
182
|
+
columnFilterDisplayMode,
|
|
183
|
+
columnResizeDirection,
|
|
184
|
+
columnResizeMode,
|
|
185
|
+
createDisplayMode,
|
|
186
|
+
defaultColumn,
|
|
187
|
+
defaultDisplayColumn,
|
|
188
|
+
editDisplayMode,
|
|
189
|
+
enableBatchRowSelection,
|
|
190
|
+
enableBottomToolbar,
|
|
191
|
+
enableColumnActions,
|
|
192
|
+
enableColumnFilters,
|
|
193
|
+
enableColumnOrdering,
|
|
194
|
+
enableColumnPinning,
|
|
195
|
+
enableColumnResizing,
|
|
196
|
+
enableColumnVirtualization,
|
|
197
|
+
enableDensityToggle,
|
|
198
|
+
enableExpandAll,
|
|
199
|
+
enableExpanding,
|
|
200
|
+
enableFacetedValues,
|
|
201
|
+
enableFilterMatchHighlighting,
|
|
202
|
+
enableFilters,
|
|
203
|
+
enableFullScreenToggle,
|
|
204
|
+
enableGlobalFilter,
|
|
205
|
+
enableGlobalFilterRankedResults,
|
|
206
|
+
enableGrouping,
|
|
207
|
+
enableHiding,
|
|
208
|
+
enableKeyboardShortcuts,
|
|
209
|
+
enableMultiRowSelection,
|
|
210
|
+
enableMultiSort,
|
|
211
|
+
enablePagination,
|
|
212
|
+
enableRowPinning,
|
|
213
|
+
enableRowSelection,
|
|
214
|
+
enableRowVirtualization,
|
|
215
|
+
enableSelectAll,
|
|
216
|
+
enableSorting,
|
|
217
|
+
enableStickyHeader,
|
|
218
|
+
enableTableFooter,
|
|
219
|
+
enableTableHead,
|
|
220
|
+
enableToolbarInternalActions,
|
|
221
|
+
enableTopToolbar,
|
|
222
|
+
filterFns,
|
|
223
|
+
getCoreRowModel: getCoreRowModel(),
|
|
224
|
+
getExpandedRowModel:
|
|
225
|
+
enableExpanding || enableGrouping ? getExpandedRowModel() : undefined,
|
|
226
|
+
getFacetedMinMaxValues: enableFacetedValues
|
|
227
|
+
? getFacetedMinMaxValues()
|
|
228
|
+
: undefined,
|
|
229
|
+
getFacetedRowModel: enableFacetedValues ? getFacetedRowModel() : undefined,
|
|
230
|
+
getFacetedUniqueValues: enableFacetedValues
|
|
231
|
+
? getFacetedUniqueValues()
|
|
232
|
+
: undefined,
|
|
233
|
+
getFilteredRowModel:
|
|
234
|
+
(enableColumnFilters || enableGlobalFilter || enableFilters) &&
|
|
235
|
+
!manualFiltering
|
|
236
|
+
? getFilteredRowModel()
|
|
237
|
+
: undefined,
|
|
238
|
+
getGroupedRowModel:
|
|
239
|
+
enableGrouping && !manualGrouping ? getGroupedRowModel() : undefined,
|
|
240
|
+
getPaginationRowModel:
|
|
241
|
+
enablePagination && !manualPagination
|
|
242
|
+
? getPaginationRowModel()
|
|
243
|
+
: undefined,
|
|
244
|
+
getSortedRowModel:
|
|
245
|
+
enableSorting && !manualSorting ? getSortedRowModel() : undefined,
|
|
246
|
+
getSubRows: (row) => row?.subRows,
|
|
247
|
+
icons,
|
|
248
|
+
id,
|
|
249
|
+
layoutMode,
|
|
250
|
+
localization,
|
|
251
|
+
manualFiltering,
|
|
252
|
+
manualGrouping,
|
|
253
|
+
manualPagination,
|
|
254
|
+
manualSorting,
|
|
255
|
+
mrtTheme,
|
|
256
|
+
paginationDisplayMode,
|
|
257
|
+
positionActionsColumn,
|
|
258
|
+
positionCreatingRow,
|
|
259
|
+
positionExpandColumn,
|
|
260
|
+
positionGlobalFilter,
|
|
261
|
+
positionPagination,
|
|
262
|
+
positionToolbarAlertBanner,
|
|
263
|
+
positionToolbarDropZone,
|
|
264
|
+
rowNumberDisplayMode,
|
|
265
|
+
rowPinningDisplayMode,
|
|
266
|
+
selectAllMode,
|
|
267
|
+
sortingFns,
|
|
268
|
+
...rest,
|
|
269
|
+
} as MRT_DefinedTableOptions<TData>;
|
|
270
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type MRT_RowData,
|
|
3
|
+
type MRT_TableInstance,
|
|
4
|
+
type MRT_TableOptions,
|
|
5
|
+
} from '../types';
|
|
6
|
+
import { useMRT_TableInstance } from './useMRT_TableInstance';
|
|
7
|
+
import { useMRT_TableOptions } from './useMRT_TableOptions';
|
|
8
|
+
|
|
9
|
+
export const useMaterialReactTable = <TData extends MRT_RowData>(
|
|
10
|
+
tableOptions: MRT_TableOptions<TData>,
|
|
11
|
+
): MRT_TableInstance<TData> =>
|
|
12
|
+
useMRT_TableInstance(useMRT_TableOptions(tableOptions));
|
package/src/icons.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
|
2
|
+
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
3
|
+
import CancelIcon from '@mui/icons-material/Cancel';
|
|
4
|
+
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
|
|
5
|
+
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
6
|
+
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
7
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
8
|
+
import ContentCopy from '@mui/icons-material/ContentCopy';
|
|
9
|
+
import DensityLargeIcon from '@mui/icons-material/DensityLarge';
|
|
10
|
+
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
11
|
+
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
12
|
+
import DragHandleIcon from '@mui/icons-material/DragHandle';
|
|
13
|
+
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
14
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
15
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
16
|
+
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
|
17
|
+
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
18
|
+
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
19
|
+
import FirstPageIcon from '@mui/icons-material/FirstPage';
|
|
20
|
+
import FullscreenIcon from '@mui/icons-material/Fullscreen';
|
|
21
|
+
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
|
22
|
+
import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
23
|
+
import LastPageIcon from '@mui/icons-material/LastPage';
|
|
24
|
+
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
25
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
26
|
+
import PushPinIcon from '@mui/icons-material/PushPin';
|
|
27
|
+
import RestartAltIcon from '@mui/icons-material/RestartAlt';
|
|
28
|
+
import SaveIcon from '@mui/icons-material/Save';
|
|
29
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
30
|
+
import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
31
|
+
import SortIcon from '@mui/icons-material/Sort';
|
|
32
|
+
import SyncAltIcon from '@mui/icons-material/SyncAlt';
|
|
33
|
+
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
34
|
+
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
35
|
+
|
|
36
|
+
export const MRT_Default_Icons = {
|
|
37
|
+
ArrowDownwardIcon,
|
|
38
|
+
ArrowRightIcon,
|
|
39
|
+
CancelIcon,
|
|
40
|
+
ChevronLeftIcon,
|
|
41
|
+
ChevronRightIcon,
|
|
42
|
+
ClearAllIcon,
|
|
43
|
+
CloseIcon,
|
|
44
|
+
ContentCopy,
|
|
45
|
+
DensityLargeIcon,
|
|
46
|
+
DensityMediumIcon,
|
|
47
|
+
DensitySmallIcon,
|
|
48
|
+
DragHandleIcon,
|
|
49
|
+
DynamicFeedIcon,
|
|
50
|
+
EditIcon,
|
|
51
|
+
ExpandMoreIcon,
|
|
52
|
+
FilterAltIcon,
|
|
53
|
+
FilterListIcon,
|
|
54
|
+
FilterListOffIcon,
|
|
55
|
+
FirstPageIcon,
|
|
56
|
+
FullscreenExitIcon,
|
|
57
|
+
FullscreenIcon,
|
|
58
|
+
KeyboardDoubleArrowDownIcon,
|
|
59
|
+
LastPageIcon,
|
|
60
|
+
MoreHorizIcon,
|
|
61
|
+
MoreVertIcon,
|
|
62
|
+
PushPinIcon,
|
|
63
|
+
RestartAltIcon,
|
|
64
|
+
SaveIcon,
|
|
65
|
+
SearchIcon,
|
|
66
|
+
SearchOffIcon,
|
|
67
|
+
SortIcon,
|
|
68
|
+
SyncAltIcon,
|
|
69
|
+
ViewColumnIcon,
|
|
70
|
+
VisibilityOffIcon,
|
|
71
|
+
} as const;
|
|
72
|
+
|
|
73
|
+
export type MRT_Icons = Record<keyof typeof MRT_Default_Icons, any>;
|