@cutting/material-react-table 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/index.d.ts +186 -524
- package/dist/index.js +323 -342
- package/dist/index.js.map +1 -1
- package/locales/ar/index.mjs +1 -2
- package/locales/az/index.mjs +1 -2
- package/locales/bg/index.mjs +1 -2
- package/locales/cs/index.mjs +1 -2
- package/locales/da/index.mjs +1 -2
- package/locales/de/index.mjs +1 -2
- package/locales/el/index.mjs +1 -2
- package/locales/en/index.mjs +1 -2
- package/locales/es/index.mjs +1 -2
- package/locales/et/index.mjs +1 -2
- package/locales/fa/index.mjs +1 -2
- package/locales/fi/index.mjs +1 -2
- package/locales/fr/index.mjs +1 -2
- package/locales/he/index.mjs +1 -2
- package/locales/hr/index.mjs +1 -2
- package/locales/hu/index.mjs +1 -2
- package/locales/hy/index.mjs +1 -2
- package/locales/id/index.mjs +1 -2
- package/locales/it/index.mjs +1 -2
- package/locales/ja/index.mjs +1 -2
- package/locales/ko/index.mjs +1 -2
- package/locales/nl/index.mjs +1 -2
- package/locales/no/index.mjs +1 -2
- package/locales/np/index.mjs +1 -2
- package/locales/pl/index.mjs +1 -2
- package/locales/pt/index.mjs +1 -2
- package/locales/pt-BR/index.mjs +1 -2
- package/locales/ro/index.mjs +1 -2
- package/locales/ru/index.mjs +1 -2
- package/locales/sk/index.mjs +1 -2
- package/locales/sr-Cyrl-RS/index.mjs +1 -2
- package/locales/sr-Latn-RS/index.mjs +1 -2
- package/locales/sv/index.mjs +1 -2
- package/locales/tr/index.mjs +1 -2
- package/locales/uk/index.mjs +1 -2
- package/locales/vi/index.mjs +1 -2
- package/locales/zh-Hans/index.mjs +1 -2
- package/locales/zh-Hant/index.mjs +1 -2
- package/package.json +19 -27
- package/src/MaterialReactTable.smoke.test.tsx +3 -9
- package/src/components/MaterialReactTable.tsx +13 -21
- package/src/components/body/MRT_TableBody.tsx +67 -82
- package/src/components/body/MRT_TableBodyCell.tsx +38 -80
- package/src/components/body/MRT_TableBodyCellValue.tsx +5 -14
- package/src/components/body/MRT_TableBodyRow.tsx +55 -102
- package/src/components/body/MRT_TableBodyRowGrabHandle.test.tsx +2 -6
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +4 -9
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +8 -14
- package/src/components/body/MRT_TableDetailPanel.test.tsx +3 -9
- package/src/components/body/MRT_TableDetailPanel.tsx +8 -14
- package/src/components/buttons/MRT_ColumnPinningButtons.test.tsx +6 -16
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +6 -12
- package/src/components/buttons/MRT_CopyButton.tsx +7 -15
- package/src/components/buttons/MRT_EditActionButtons.test.tsx +2 -6
- package/src/components/buttons/MRT_EditActionButtons.tsx +15 -37
- package/src/components/buttons/MRT_ExpandAllButton.tsx +8 -16
- package/src/components/buttons/MRT_ExpandButton.tsx +9 -21
- package/src/components/buttons/MRT_GrabHandleButton.tsx +6 -10
- package/src/components/buttons/MRT_RowPinButton.tsx +8 -23
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +5 -18
- package/src/components/buttons/MRT_ToggleDensePaddingButton.test.tsx +4 -12
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +4 -11
- package/src/components/buttons/MRT_ToggleFiltersButton.test.tsx +4 -13
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +3 -5
- package/src/components/buttons/MRT_ToggleFullScreenButton.test.tsx +3 -11
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +4 -9
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -5
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +7 -15
- package/src/components/footer/MRT_TableFooter.tsx +9 -16
- package/src/components/footer/MRT_TableFooterCell.tsx +9 -32
- package/src/components/footer/MRT_TableFooterRow.tsx +18 -32
- package/src/components/head/MRT_TableHead.tsx +8 -18
- package/src/components/head/MRT_TableHeadCell.tsx +46 -100
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +10 -30
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +4 -15
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +20 -54
- package/src/components/head/MRT_TableHeadCellGrabHandle.test.tsx +5 -19
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +9 -38
- package/src/components/head/MRT_TableHeadCellResizeHandle.test.tsx +3 -13
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +10 -24
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +10 -26
- package/src/components/head/MRT_TableHeadRow.tsx +24 -36
- package/src/components/inputs/MRT_EditCellTextField.test.tsx +2 -9
- package/src/components/inputs/MRT_EditCellTextField.tsx +9 -28
- package/src/components/inputs/MRT_FilterCheckbox.tsx +9 -23
- package/src/components/inputs/MRT_FilterRangeFields.tsx +6 -15
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +24 -32
- package/src/components/inputs/MRT_FilterTextField.test.tsx +72 -14
- package/src/components/inputs/MRT_FilterTextField.tsx +77 -138
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +10 -32
- package/src/components/inputs/MRT_SelectCheckbox.test.tsx +4 -11
- package/src/components/inputs/MRT_SelectCheckbox.tsx +17 -36
- package/src/components/menus/MRT_ActionMenuItem.tsx +6 -15
- package/src/components/menus/MRT_CellActionMenu.tsx +6 -9
- package/src/components/menus/MRT_ColumnActionMenu.tsx +22 -57
- package/src/components/menus/MRT_FilterOptionMenu.tsx +38 -65
- package/src/components/menus/MRT_RowActionMenu.tsx +33 -22
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +29 -65
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.test.tsx +43 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +14 -50
- package/src/components/modals/MRT_EditRowModal.test.tsx +5 -21
- package/src/components/modals/MRT_EditRowModal.tsx +8 -26
- package/src/components/table/MRT_Table.tsx +12 -20
- package/src/components/table/MRT_TableContainer.test.tsx +147 -0
- package/src/components/table/MRT_TableContainer.tsx +33 -37
- package/src/components/table/MRT_TableLoadingOverlay.tsx +3 -5
- package/src/components/table/MRT_TablePaper.tsx +7 -14
- package/src/components/toolbar/MRT_BottomToolbar.tsx +11 -23
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +4 -11
- package/src/components/toolbar/MRT_TablePagination.tsx +33 -40
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +21 -50
- package/src/components/toolbar/MRT_ToolbarDropZone.test.tsx +26 -10
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +23 -21
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +11 -21
- package/src/components/toolbar/MRT_TopToolbar.tsx +12 -28
- package/src/fns/aggregationFns.test.tsx +1 -3
- package/src/fns/filterFns.test.tsx +8 -37
- package/src/fns/filterFns.ts +71 -96
- package/src/fns/sortingFns.test.tsx +5 -21
- package/src/fns/sortingFns.ts +10 -14
- package/src/fns/tableFeatures.test.tsx +6 -29
- package/src/fns/tableFeatures.ts +5 -4
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +2 -11
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +2 -10
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +8 -17
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +3 -8
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +2 -8
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +3 -13
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -5
- package/src/hooks/useMRT_ColumnVirtualizer.ts +28 -49
- package/src/hooks/useMRT_Effects.test.tsx +114 -0
- package/src/hooks/useMRT_Effects.ts +26 -27
- package/src/hooks/useMRT_RowVirtualizer.ts +18 -33
- package/src/hooks/useMRT_Rows.ts +3 -42
- package/src/hooks/useMRT_TableInstance.ts +63 -129
- package/src/hooks/useMRT_TableOptions.ts +15 -29
- package/src/hooks/useMaterialReactTable.ts +2 -7
- package/src/icons.ts +38 -1
- package/src/index.ts +0 -4
- package/src/locales/ar.ts +1 -2
- package/src/locales/az.ts +1 -2
- package/src/locales/bg.ts +1 -2
- package/src/locales/cs.ts +2 -4
- package/src/locales/da.ts +1 -2
- package/src/locales/de.ts +1 -2
- package/src/locales/el.ts +1 -2
- package/src/locales/en.ts +1 -2
- package/src/locales/es.ts +1 -2
- package/src/locales/et.ts +2 -4
- package/src/locales/fa.ts +1 -2
- package/src/locales/fi.ts +2 -4
- package/src/locales/fr.ts +1 -2
- package/src/locales/he.ts +1 -2
- package/src/locales/hr.ts +1 -2
- package/src/locales/hu.ts +1 -2
- package/src/locales/hy.ts +1 -2
- package/src/locales/id.ts +2 -4
- package/src/locales/it.ts +1 -2
- package/src/locales/ja.ts +1 -2
- package/src/locales/ko.ts +1 -2
- package/src/locales/nl.ts +1 -2
- package/src/locales/no.ts +2 -4
- package/src/locales/np.ts +2 -4
- package/src/locales/pl.ts +1 -2
- package/src/locales/pt-BR.ts +1 -2
- package/src/locales/pt.ts +1 -2
- package/src/locales/ro.ts +1 -2
- package/src/locales/ru.ts +1 -2
- package/src/locales/sk.ts +2 -4
- package/src/locales/sr-Cyrl-RS.ts +1 -2
- package/src/locales/sr-Latn-RS.ts +1 -2
- package/src/locales/sv.ts +1 -2
- package/src/locales/tr.ts +1 -2
- package/src/locales/uk.ts +1 -2
- package/src/locales/vi.ts +1 -2
- package/src/types.ts +156 -349
- package/src/utils/cell.utils.ts +30 -68
- package/src/utils/column.utils.ts +61 -49
- package/src/utils/displayColumn.utils.ts +16 -38
- package/src/utils/highlight.utils.ts +7 -11
- package/src/utils/row.utils.ts +40 -65
- package/src/utils/slotProps.utils.ts +1 -4
- package/src/utils/style.utils.ts +18 -46
- package/src/utils/tanstack.helpers.ts +10 -17
- package/src/utils/utils.ts +6 -10
- package/src/utils/virtualization.utils.ts +5 -9
package/dist/index.js
CHANGED
|
@@ -10,10 +10,10 @@ import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
|
|
10
10
|
import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
|
|
11
11
|
import { TimePicker } from "@mui/x-date-pickers/TimePicker";
|
|
12
12
|
import { ArrowDownward, ArrowRight, Cancel, ChevronLeft, ChevronRight, ClearAll, Close, ContentCopy, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandMore, FilterAlt, FilterList, FilterListOff, FirstPage, Fullscreen, FullscreenExit, KeyboardDoubleArrowDown, LastPage, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, SyncAlt, ViewColumn, VisibilityOff } from "@mui/icons-material";
|
|
13
|
-
|
|
13
|
+
// src/fns/sortingFns.ts
|
|
14
14
|
const fuzzy$1 = (rowA, rowB, columnId) => {
|
|
15
15
|
let dir = 0;
|
|
16
|
-
if (rowA.columnFiltersMeta[columnId]) dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
|
16
|
+
if ("columnFiltersMeta" in rowA && "columnFiltersMeta" in rowB && rowA.columnFiltersMeta[columnId]) dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
|
17
17
|
return dir === 0 ? sortFn_alphanumeric(rowA, rowB, columnId) : dir;
|
|
18
18
|
};
|
|
19
19
|
const MRT_SortingFns = {
|
|
@@ -25,9 +25,8 @@ const MRT_SortingFns = {
|
|
|
25
25
|
text: sortFn_text,
|
|
26
26
|
textCaseSensitive: sortFn_textCaseSensitive
|
|
27
27
|
};
|
|
28
|
-
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((
|
|
29
|
-
|
|
30
|
-
//#region src/utils/utils.ts
|
|
28
|
+
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((meta) => meta.rank)) - Math.max(...Object.values(rowA.columnFiltersMeta).map((meta) => meta.rank));
|
|
29
|
+
// src/utils/utils.ts
|
|
31
30
|
const parseFromValuesOrFunc = (fn, arg) => fn instanceof Function ? fn(arg) : fn;
|
|
32
31
|
const getValueAndLabel = (option) => {
|
|
33
32
|
let label = "";
|
|
@@ -37,8 +36,8 @@ const getValueAndLabel = (option) => {
|
|
|
37
36
|
label = option;
|
|
38
37
|
value = option;
|
|
39
38
|
} else {
|
|
40
|
-
label = option.label ?? option.value;
|
|
41
|
-
value = option.value
|
|
39
|
+
label = option.label ?? String(option.value);
|
|
40
|
+
value = option.value;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
return {
|
|
@@ -46,8 +45,7 @@ const getValueAndLabel = (option) => {
|
|
|
46
45
|
value
|
|
47
46
|
};
|
|
48
47
|
};
|
|
49
|
-
|
|
50
|
-
//#region src/utils/row.utils.ts
|
|
48
|
+
// src/utils/row.utils.ts
|
|
51
49
|
const getMRT_Rows = (table, all) => {
|
|
52
50
|
const { getCenterRows, getPrePaginatedRowModel, getRowModel, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode } } = table;
|
|
53
51
|
const { creatingRow, pagination } = table.state;
|
|
@@ -83,7 +81,7 @@ const getCanRankRows = (table) => {
|
|
|
83
81
|
};
|
|
84
82
|
const getIsRankingRows = (table) => {
|
|
85
83
|
const { globalFilter, sorting } = table.state;
|
|
86
|
-
return getCanRankRows(table) && globalFilter && !Object.values(sorting).some(Boolean);
|
|
84
|
+
return Boolean(getCanRankRows(table) && globalFilter && !Object.values(sorting).some(Boolean));
|
|
87
85
|
};
|
|
88
86
|
const getIsRowSelected = ({ row, table }) => {
|
|
89
87
|
const { options: { enableRowSelection } } = table;
|
|
@@ -99,7 +97,7 @@ const getMRT_RowSelectionHandler = ({ row, staticRowIndex = 0, table }) => (even
|
|
|
99
97
|
});
|
|
100
98
|
row.toggleSelected(value ?? !wasCurrentRowChecked);
|
|
101
99
|
const changedRowIds = /* @__PURE__ */ new Set([row.id]);
|
|
102
|
-
if (enableBatchRowSelection && enableMultiRowSelection && event.nativeEvent.shiftKey && lastSelectedRowId.current !== null) {
|
|
100
|
+
if (enableBatchRowSelection && enableMultiRowSelection && "shiftKey" in event.nativeEvent && event.nativeEvent.shiftKey && lastSelectedRowId.current !== null) {
|
|
103
101
|
const rows = getMRT_Rows(table, true);
|
|
104
102
|
const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
|
|
105
103
|
if (lastIndex !== -1) {
|
|
@@ -123,34 +121,18 @@ const getMRT_RowSelectionHandler = ({ row, staticRowIndex = 0, table }) => (even
|
|
|
123
121
|
};
|
|
124
122
|
const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
|
|
125
123
|
const { options: { enableRowPinning, rowPinningDisplayMode, selectAllMode }, refs: { lastSelectedRowId } } = table;
|
|
126
|
-
|
|
124
|
+
const checked = value ?? event.target.checked;
|
|
125
|
+
if (selectAllMode === "all" || forceAll) table.toggleAllRowsSelected(checked);
|
|
126
|
+
else table.toggleAllPageRowsSelected(checked);
|
|
127
127
|
if (enableRowPinning && rowPinningDisplayMode?.includes("select")) table.setRowPinning({
|
|
128
128
|
bottom: [],
|
|
129
129
|
top: []
|
|
130
130
|
});
|
|
131
131
|
lastSelectedRowId.current = null;
|
|
132
132
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const { getRowModel, options: { data, enableGlobalFilterRankedResults, positionCreatingRow } } = table;
|
|
137
|
-
const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting } = table.state;
|
|
138
|
-
return useMemo(() => getMRT_Rows(table), [
|
|
139
|
-
creatingRow,
|
|
140
|
-
data,
|
|
141
|
-
enableGlobalFilterRankedResults,
|
|
142
|
-
expanded,
|
|
143
|
-
getRowModel().rows,
|
|
144
|
-
globalFilter,
|
|
145
|
-
pagination.pageIndex,
|
|
146
|
-
pagination.pageSize,
|
|
147
|
-
positionCreatingRow,
|
|
148
|
-
rowPinning,
|
|
149
|
-
sorting
|
|
150
|
-
]);
|
|
151
|
-
};
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/utils/virtualization.utils.ts
|
|
133
|
+
// src/hooks/useMRT_Rows.ts
|
|
134
|
+
const useMRT_Rows = (table) => getMRT_Rows(table);
|
|
135
|
+
// src/utils/virtualization.utils.ts
|
|
154
136
|
/**
|
|
155
137
|
* When scroll, the `draggingRow` or `draggingColumn` can be removed from document because of virtualization,
|
|
156
138
|
* then, the `dragEnd` event on `MRT_TableBodyRowGrabHandle` or `MRT_TableHeadCellGrabHandle` will not fire.
|
|
@@ -163,13 +145,11 @@ const extraIndexRangeExtractor = (range, draggingIndex) => {
|
|
|
163
145
|
if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) newIndexes.push(draggingIndex);
|
|
164
146
|
return newIndexes;
|
|
165
147
|
};
|
|
166
|
-
|
|
167
|
-
//#region src/hooks/useMRT_RowVirtualizer.ts
|
|
148
|
+
// src/hooks/useMRT_RowVirtualizer.ts
|
|
168
149
|
const useMRT_RowVirtualizer = (table, rows) => {
|
|
169
150
|
const { getRowModel, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions }, refs: { tableContainerRef } } = table;
|
|
170
151
|
const { density, draggingRow, expanded } = table.state;
|
|
171
|
-
|
|
172
|
-
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, { table });
|
|
152
|
+
const rowVirtualizerProps = enableRowVirtualization ? parseFromValuesOrFunc(rowVirtualizerOptions, { table }) : void 0;
|
|
173
153
|
const realRows = rows ?? getRowModel().rows;
|
|
174
154
|
/**
|
|
175
155
|
* when filtering, should find the correct index in filtered rows
|
|
@@ -179,6 +159,7 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
|
179
159
|
const normalRowHeight = density === "compact" ? 37 : density === "comfortable" ? 58 : 73;
|
|
180
160
|
const rowVirtualizer = useVirtualizer({
|
|
181
161
|
count: renderDetailPanel ? rowCount * 2 : rowCount,
|
|
162
|
+
enabled: !!enableRowVirtualization,
|
|
182
163
|
estimateSize: (index) => renderDetailPanel && index % 2 === 1 ? expanded === true ? 100 : 0 : normalRowHeight,
|
|
183
164
|
getScrollElement: () => tableContainerRef.current,
|
|
184
165
|
measureElement: typeof window !== "undefined" && navigator.userAgent.indexOf("Firefox") === -1 ? (element) => element?.getBoundingClientRect().height : void 0,
|
|
@@ -188,12 +169,12 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
|
188
169
|
}, [draggingRowIndex]),
|
|
189
170
|
...rowVirtualizerProps
|
|
190
171
|
});
|
|
172
|
+
if (!enableRowVirtualization) return;
|
|
191
173
|
rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
|
|
192
174
|
if (rowVirtualizerInstanceRef) rowVirtualizerInstanceRef.current = rowVirtualizer;
|
|
193
175
|
return rowVirtualizer;
|
|
194
176
|
};
|
|
195
|
-
|
|
196
|
-
//#region src/utils/style.utils.ts
|
|
177
|
+
// src/utils/style.utils.ts
|
|
197
178
|
const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, "_");
|
|
198
179
|
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
199
180
|
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
@@ -286,8 +267,7 @@ const getCommonTooltipProps = (placement) => ({
|
|
|
286
267
|
enterNextDelay: 1e3,
|
|
287
268
|
placement
|
|
288
269
|
});
|
|
289
|
-
|
|
290
|
-
//#region src/utils/cell.utils.ts
|
|
270
|
+
// src/utils/cell.utils.ts
|
|
291
271
|
const isWinCtrlMacMeta = (event) => {
|
|
292
272
|
return event.ctrlKey && navigator.platform.toLowerCase().includes("win") || event.metaKey && navigator.platform.toLowerCase().includes("mac");
|
|
293
273
|
};
|
|
@@ -323,7 +303,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
|
|
|
323
303
|
event.preventDefault();
|
|
324
304
|
getMRT_RowSelectionHandler({
|
|
325
305
|
row: cell.row,
|
|
326
|
-
staticRowIndex:
|
|
306
|
+
staticRowIndex: Number(event.target.getAttribute("data-index")),
|
|
327
307
|
table
|
|
328
308
|
})(event);
|
|
329
309
|
} else if (header?.column?.id === "mrt-row-select" && table.options.enableSelectAll) {
|
|
@@ -340,7 +320,8 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
|
|
|
340
320
|
table.toggleAllRowsExpanded();
|
|
341
321
|
} else if (cell?.column.id === "mrt-row-pin") {
|
|
342
322
|
event.preventDefault();
|
|
343
|
-
cell.row.getIsPinned()
|
|
323
|
+
if (cell.row.getIsPinned()) cell.row.pin(false);
|
|
324
|
+
else cell.row.pin(table.options.rowPinningDisplayMode?.includes("bottom") ? "bottom" : "top");
|
|
344
325
|
} else if (header && isWinCtrlMacMeta(event)) {
|
|
345
326
|
const actionsButton = currentCell.querySelector(`button[aria-label="${table.options.localization.columnActions}"]`);
|
|
346
327
|
if (actionsButton) actionsButton.click();
|
|
@@ -404,8 +385,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
|
|
|
404
385
|
if (nextCell) nextCell.focus();
|
|
405
386
|
}
|
|
406
387
|
};
|
|
407
|
-
|
|
408
|
-
//#region src/components/buttons/MRT_CopyButton.tsx
|
|
388
|
+
// src/components/buttons/MRT_CopyButton.tsx
|
|
409
389
|
const MRT_CopyButton = ({ cell, table, ...rest }) => {
|
|
410
390
|
const { options: { localization, muiCopyButtonProps } } = table;
|
|
411
391
|
const { column, row } = cell;
|
|
@@ -460,8 +440,7 @@ const MRT_CopyButton = ({ cell, table, ...rest }) => {
|
|
|
460
440
|
})
|
|
461
441
|
});
|
|
462
442
|
};
|
|
463
|
-
|
|
464
|
-
//#region src/utils/slotProps.utils.ts
|
|
443
|
+
// src/utils/slotProps.utils.ts
|
|
465
444
|
const getTextFieldSlotProps = (slotProps) => ({
|
|
466
445
|
formHelperText: slotProps?.formHelperText,
|
|
467
446
|
htmlInput: slotProps?.htmlInput,
|
|
@@ -469,8 +448,7 @@ const getTextFieldSlotProps = (slotProps) => ({
|
|
|
469
448
|
inputLabel: slotProps?.inputLabel,
|
|
470
449
|
select: slotProps?.select
|
|
471
450
|
});
|
|
472
|
-
|
|
473
|
-
//#region src/components/inputs/MRT_EditCellTextField.tsx
|
|
451
|
+
// src/components/inputs/MRT_EditCellTextField.tsx
|
|
474
452
|
const MRT_EditCellTextField = ({ cell, table, ...rest }) => {
|
|
475
453
|
const { options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow } = table;
|
|
476
454
|
const { column, row } = cell;
|
|
@@ -589,8 +567,7 @@ const MRT_EditCellTextField = ({ cell, table, ...rest }) => {
|
|
|
589
567
|
})
|
|
590
568
|
});
|
|
591
569
|
};
|
|
592
|
-
|
|
593
|
-
//#region src/utils/highlight.utils.ts
|
|
570
|
+
// src/utils/highlight.utils.ts
|
|
594
571
|
const escapeRegExp = (term) => term.replace(/[|\\{}()[\]^$+*?.-]/g, (char) => `\\${char}`);
|
|
595
572
|
const termsToRegExpString = (terms) => terms.replace(/\s{2,}/g, " ").split(" ").join("|");
|
|
596
573
|
const buildRegExp = (terms, matchExactly) => {
|
|
@@ -616,8 +593,7 @@ const highlightWords = ({ matchExactly = false, query, text }) => {
|
|
|
616
593
|
text: str
|
|
617
594
|
}));
|
|
618
595
|
};
|
|
619
|
-
|
|
620
|
-
//#region src/components/body/MRT_TableBodyCellValue.tsx
|
|
596
|
+
// src/components/body/MRT_TableBodyCellValue.tsx
|
|
621
597
|
const allowedTypes = ["string", "number"];
|
|
622
598
|
const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowIndex, table }) => {
|
|
623
599
|
const { options: { enableFilterMatchHighlighting, mrtTheme: { matchHighlightColor } } } = table;
|
|
@@ -676,8 +652,7 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowInde
|
|
|
676
652
|
});
|
|
677
653
|
return renderedCellValue;
|
|
678
654
|
};
|
|
679
|
-
|
|
680
|
-
//#region src/components/body/MRT_TableBodyCell.tsx
|
|
655
|
+
// src/components/body/MRT_TableBodyCell.tsx
|
|
681
656
|
const MRT_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, ...rest }) => {
|
|
682
657
|
const theme = useTheme();
|
|
683
658
|
const { options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps }, setHoveredColumn } = table;
|
|
@@ -707,7 +682,13 @@ const MRT_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRow
|
|
|
707
682
|
if (!isLoading && !showSkeletons || skeletonWidth !== 100) return;
|
|
708
683
|
const size = column.getSize();
|
|
709
684
|
setSkeletonWidth(columnDefType === "display" ? size / 2 : Math.round(Math.random() * (size - size / 3) + size / 3));
|
|
710
|
-
}, [
|
|
685
|
+
}, [
|
|
686
|
+
column,
|
|
687
|
+
columnDefType,
|
|
688
|
+
isLoading,
|
|
689
|
+
showSkeletons,
|
|
690
|
+
skeletonWidth
|
|
691
|
+
]);
|
|
711
692
|
const draggingBorders = useMemo(() => {
|
|
712
693
|
const isDraggingColumn = draggingColumn?.id === column.id;
|
|
713
694
|
const isHoveredColumn = hoveredColumn?.id === column.id;
|
|
@@ -727,12 +708,19 @@ const MRT_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRow
|
|
|
727
708
|
borderTop: isDraggingRow || isHoveredRow ? borderStyle : void 0
|
|
728
709
|
} : void 0;
|
|
729
710
|
}, [
|
|
711
|
+
column,
|
|
712
|
+
columnResizeDirection,
|
|
713
|
+
columnResizeMode,
|
|
730
714
|
columnResizing.isResizingColumn,
|
|
715
|
+
draggingBorderColor,
|
|
731
716
|
draggingColumn,
|
|
732
717
|
draggingRow,
|
|
733
718
|
hoveredColumn,
|
|
734
719
|
hoveredRow,
|
|
735
|
-
|
|
720
|
+
numRows,
|
|
721
|
+
row.id,
|
|
722
|
+
staticRowIndex,
|
|
723
|
+
theme.palette.grey
|
|
736
724
|
]);
|
|
737
725
|
const isColumnPinned = enableColumnPinning && columnDef.columnDefType !== "group" && column.getIsPinned();
|
|
738
726
|
const isEditable = isCellEditable({
|
|
@@ -741,7 +729,8 @@ const MRT_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRow
|
|
|
741
729
|
});
|
|
742
730
|
const isEditing = isEditable && !["custom", "modal"].includes(editDisplayMode) && (editDisplayMode === "table" || editingRow?.id === row.id || editingCell?.id === cell.id) && !row.getIsGrouped();
|
|
743
731
|
const isCreating = isEditable && createDisplayMode === "row" && creatingRow?.id === row.id;
|
|
744
|
-
const
|
|
732
|
+
const columnClickToCopy = parseFromValuesOrFunc(columnDef.enableClickToCopy, cell);
|
|
733
|
+
const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true || columnClickToCopy === true) && columnClickToCopy !== "context-menu" && columnClickToCopy !== false;
|
|
745
734
|
const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
|
|
746
735
|
const cellValueProps = {
|
|
747
736
|
cell,
|
|
@@ -851,8 +840,7 @@ const MRT_TableBodyCell = ({ cell, numRows, rowRef, staticColumnIndex, staticRow
|
|
|
851
840
|
});
|
|
852
841
|
};
|
|
853
842
|
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
|
854
|
-
|
|
855
|
-
//#region src/components/body/MRT_TableDetailPanel.tsx
|
|
843
|
+
// src/components/body/MRT_TableDetailPanel.tsx
|
|
856
844
|
const MRT_TableDetailPanel = ({ parentRowRef, row, rowVirtualizer, staticRowIndex, table, virtualRow, ...rest }) => {
|
|
857
845
|
const { getVisibleLeafColumns, options: { layoutMode, mrtTheme: { baseBackgroundColor }, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel } } = table;
|
|
858
846
|
const { isLoading } = table.state;
|
|
@@ -910,12 +898,11 @@ const MRT_TableDetailPanel = ({ parentRowRef, row, rowVirtualizer, staticRowInde
|
|
|
910
898
|
})
|
|
911
899
|
});
|
|
912
900
|
};
|
|
913
|
-
|
|
914
|
-
//#region src/components/body/MRT_TableBodyRow.tsx
|
|
901
|
+
// src/components/body/MRT_TableBodyRow.tsx
|
|
915
902
|
const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow, ...rest }) => {
|
|
916
903
|
const theme = useTheme();
|
|
917
904
|
const { options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow } = table;
|
|
918
|
-
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen
|
|
905
|
+
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen } = table.state;
|
|
919
906
|
const visibleCells = row.getVisibleCells();
|
|
920
907
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {};
|
|
921
908
|
const isRowSelected = getIsRowSelected({
|
|
@@ -933,15 +920,16 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
|
|
|
933
920
|
}),
|
|
934
921
|
...rest
|
|
935
922
|
};
|
|
936
|
-
const
|
|
923
|
+
const getPinnedIndexes = () => {
|
|
937
924
|
if (!enableRowPinning || !rowPinningDisplayMode?.includes("sticky") || !pinnedRowIds || !row.getIsPinned()) return [];
|
|
938
925
|
return [[...pinnedRowIds].reverse().indexOf(row.id), pinnedRowIds.indexOf(row.id)];
|
|
939
|
-
}
|
|
926
|
+
};
|
|
927
|
+
const [bottomPinnedIndex, topPinnedIndex] = getPinnedIndexes();
|
|
940
928
|
const tableHeadHeight = (enableStickyHeader || isFullScreen) && tableHeadRef.current?.clientHeight || 0;
|
|
941
929
|
const tableFooterHeight = enableStickyFooter && tableFooterRef.current?.clientHeight || 0;
|
|
942
930
|
const sx = parseFromValuesOrFunc(tableRowProps?.sx, theme);
|
|
943
931
|
const defaultRowHeight = density === "compact" ? 37 : density === "comfortable" ? 53 : 69;
|
|
944
|
-
const rowHeight = parseInt(tableRowProps?.style?.height ?? sx?.height, 10) || defaultRowHeight;
|
|
932
|
+
const rowHeight = parseInt(String(tableRowProps?.style?.height ?? sx?.height), 10) || defaultRowHeight;
|
|
945
933
|
const handleDragEnter = (_e) => {
|
|
946
934
|
if (enableRowOrdering && draggingRow) setHoveredRow(row);
|
|
947
935
|
};
|
|
@@ -1031,8 +1019,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVi
|
|
|
1031
1019
|
})] });
|
|
1032
1020
|
};
|
|
1033
1021
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
|
|
1034
|
-
|
|
1035
|
-
//#region src/components/body/MRT_TableBody.tsx
|
|
1022
|
+
// src/components/body/MRT_TableBody.tsx
|
|
1036
1023
|
const MRT_TableBody = ({ columnVirtualizer, table, ...rest }) => {
|
|
1037
1024
|
const { getBottomRows, getIsSomeRowsPinned, getRowModel, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode }, refs: { tableFooterRef, tableHeadRef, tablePaperRef } } = table;
|
|
1038
1025
|
const { columnFilters, globalFilter, isFullScreen, rowPinning } = table.state;
|
|
@@ -1042,10 +1029,11 @@ const MRT_TableBody = ({ columnVirtualizer, table, ...rest }) => {
|
|
|
1042
1029
|
};
|
|
1043
1030
|
const tableHeadHeight = (enableStickyHeader || isFullScreen) && tableHeadRef.current?.clientHeight || 0;
|
|
1044
1031
|
const tableFooterHeight = enableStickyFooter && tableFooterRef.current?.clientHeight || 0;
|
|
1032
|
+
const rowModelRows = getRowModel().rows;
|
|
1045
1033
|
const pinnedRowIds = useMemo(() => {
|
|
1046
1034
|
if (!rowPinning.bottom?.length && !rowPinning.top?.length) return [];
|
|
1047
|
-
return
|
|
1048
|
-
}, [rowPinning,
|
|
1035
|
+
return rowModelRows.filter((row) => row.getIsPinned()).map((r) => r.id);
|
|
1036
|
+
}, [rowPinning, rowModelRows]);
|
|
1049
1037
|
const rows = useMRT_Rows(table);
|
|
1050
1038
|
const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
|
|
1051
1039
|
const { virtualRows } = rowVirtualizer ?? {};
|
|
@@ -1141,8 +1129,7 @@ const MRT_TableBody = ({ columnVirtualizer, table, ...rest }) => {
|
|
|
1141
1129
|
] });
|
|
1142
1130
|
};
|
|
1143
1131
|
const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
|
|
1144
|
-
|
|
1145
|
-
//#region src/components/buttons/MRT_GrabHandleButton.tsx
|
|
1132
|
+
// src/components/buttons/MRT_GrabHandleButton.tsx
|
|
1146
1133
|
const MRT_GrabHandleButton = ({ location, table, ...rest }) => {
|
|
1147
1134
|
const { options: { icons: { DragHandleIcon }, localization } } = table;
|
|
1148
1135
|
return /* @__PURE__ */ jsx(Tooltip, {
|
|
@@ -1176,8 +1163,7 @@ const MRT_GrabHandleButton = ({ location, table, ...rest }) => {
|
|
|
1176
1163
|
})
|
|
1177
1164
|
});
|
|
1178
1165
|
};
|
|
1179
|
-
|
|
1180
|
-
//#region src/components/body/MRT_TableBodyRowGrabHandle.tsx
|
|
1166
|
+
// src/components/body/MRT_TableBodyRowGrabHandle.tsx
|
|
1181
1167
|
const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, ...rest }) => {
|
|
1182
1168
|
const { options: { muiRowDragHandleProps } } = table;
|
|
1183
1169
|
const iconButtonProps = {
|
|
@@ -1209,8 +1195,7 @@ const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, ...rest }) => {
|
|
|
1209
1195
|
table
|
|
1210
1196
|
});
|
|
1211
1197
|
};
|
|
1212
|
-
|
|
1213
|
-
//#region src/components/buttons/MRT_RowPinButton.tsx
|
|
1198
|
+
// src/components/buttons/MRT_RowPinButton.tsx
|
|
1214
1199
|
const MRT_RowPinButton = ({ pinningPosition, row, table, ...rest }) => {
|
|
1215
1200
|
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode } } = table;
|
|
1216
1201
|
const isPinned = row.getIsPinned();
|
|
@@ -1245,8 +1230,7 @@ const MRT_RowPinButton = ({ pinningPosition, row, table, ...rest }) => {
|
|
|
1245
1230
|
})
|
|
1246
1231
|
});
|
|
1247
1232
|
};
|
|
1248
|
-
|
|
1249
|
-
//#region src/components/body/MRT_TableBodyRowPinButton.tsx
|
|
1233
|
+
// src/components/body/MRT_TableBodyRowPinButton.tsx
|
|
1250
1234
|
const MRT_TableBodyRowPinButton = ({ row, table, ...rest }) => {
|
|
1251
1235
|
const { options: { enableRowPinning, rowPinningDisplayMode } } = table;
|
|
1252
1236
|
const { density } = table.state;
|
|
@@ -1274,8 +1258,7 @@ const MRT_TableBodyRowPinButton = ({ row, table, ...rest }) => {
|
|
|
1274
1258
|
...rowPinButtonProps
|
|
1275
1259
|
});
|
|
1276
1260
|
};
|
|
1277
|
-
|
|
1278
|
-
//#region src/components/buttons/MRT_ColumnPinningButtons.tsx
|
|
1261
|
+
// src/components/buttons/MRT_ColumnPinningButtons.tsx
|
|
1279
1262
|
const MRT_ColumnPinningButtons = ({ column, table, ...rest }) => {
|
|
1280
1263
|
const { options: { icons: { PushPinIcon }, localization } } = table;
|
|
1281
1264
|
const handlePinColumn = (pinDirection) => {
|
|
@@ -1312,8 +1295,7 @@ const MRT_ColumnPinningButtons = ({ column, table, ...rest }) => {
|
|
|
1312
1295
|
})] })
|
|
1313
1296
|
});
|
|
1314
1297
|
};
|
|
1315
|
-
|
|
1316
|
-
//#region src/components/buttons/MRT_EditActionButtons.tsx
|
|
1298
|
+
// src/components/buttons/MRT_EditActionButtons.tsx
|
|
1317
1299
|
const MRT_EditActionButtons = ({ row, table, variant = "icon", ...rest }) => {
|
|
1318
1300
|
const { options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave }, refs: { editInputRefs }, setCreatingRow, setEditingRow } = table;
|
|
1319
1301
|
const { creatingRow, editingRow, isSaving } = table.state;
|
|
@@ -1349,7 +1331,7 @@ const MRT_EditActionButtons = ({ row, table, variant = "icon", ...rest }) => {
|
|
|
1349
1331
|
exitEditingMode: () => setEditingRow(null),
|
|
1350
1332
|
row,
|
|
1351
1333
|
table,
|
|
1352
|
-
values: row
|
|
1334
|
+
values: row._valuesCache
|
|
1353
1335
|
});
|
|
1354
1336
|
};
|
|
1355
1337
|
return /* @__PURE__ */ jsx(Box, {
|
|
@@ -1391,8 +1373,7 @@ const MRT_EditActionButtons = ({ row, table, variant = "icon", ...rest }) => {
|
|
|
1391
1373
|
})] })
|
|
1392
1374
|
});
|
|
1393
1375
|
};
|
|
1394
|
-
|
|
1395
|
-
//#region src/components/buttons/MRT_ExpandAllButton.tsx
|
|
1376
|
+
// src/components/buttons/MRT_ExpandAllButton.tsx
|
|
1396
1377
|
const MRT_ExpandAllButton = ({ table, ...rest }) => {
|
|
1397
1378
|
const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel }, toggleAllRowsExpanded } = table;
|
|
1398
1379
|
const { density, isLoading } = table.state;
|
|
@@ -1423,8 +1404,7 @@ const MRT_ExpandAllButton = ({ table, ...rest }) => {
|
|
|
1423
1404
|
}) })
|
|
1424
1405
|
});
|
|
1425
1406
|
};
|
|
1426
|
-
|
|
1427
|
-
//#region src/components/buttons/MRT_ExpandButton.tsx
|
|
1407
|
+
// src/components/buttons/MRT_ExpandButton.tsx
|
|
1428
1408
|
const MRT_ExpandButton = ({ row, staticRowIndex, table }) => {
|
|
1429
1409
|
const theme = useTheme();
|
|
1430
1410
|
const { options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, positionExpandColumn, renderDetailPanel } } = table;
|
|
@@ -1469,8 +1449,7 @@ const MRT_ExpandButton = ({ row, staticRowIndex, table }) => {
|
|
|
1469
1449
|
}) })
|
|
1470
1450
|
});
|
|
1471
1451
|
};
|
|
1472
|
-
|
|
1473
|
-
//#region src/utils/column.utils.ts
|
|
1452
|
+
// src/utils/column.utils.ts
|
|
1474
1453
|
const getSubColumnDefs = (columnDef) => "columns" in columnDef ? columnDef.columns : void 0;
|
|
1475
1454
|
const getColumnId = (columnDef) => columnDef.id ?? ("accessorKey" in columnDef ? columnDef.accessorKey?.toString?.() : void 0) ?? columnDef.header;
|
|
1476
1455
|
const getAllLeafColumnDefs = (columns) => {
|
|
@@ -1520,6 +1499,14 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
|
1520
1499
|
newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
1521
1500
|
return newColumnOrder;
|
|
1522
1501
|
};
|
|
1502
|
+
const moveColumn = (table, draggedColumn, targetColumn) => {
|
|
1503
|
+
const reorderedColumns = reorderColumn(draggedColumn, targetColumn, table.state.columnOrder);
|
|
1504
|
+
table.setColumnOrder(reorderedColumns);
|
|
1505
|
+
table.setColumnPinning(({ end = [], start = [] }) => ({
|
|
1506
|
+
end: reorderedColumns.filter((header) => end.includes(header)),
|
|
1507
|
+
start: reorderedColumns.filter((header) => start.includes(header))
|
|
1508
|
+
}));
|
|
1509
|
+
};
|
|
1523
1510
|
const getDefaultColumnFilterFn = (columnDef) => {
|
|
1524
1511
|
const { filterVariant } = columnDef;
|
|
1525
1512
|
if (filterVariant === "multi-select") return "arrIncludesSome";
|
|
@@ -1527,6 +1514,7 @@ const getDefaultColumnFilterFn = (columnDef) => {
|
|
|
1527
1514
|
if (filterVariant === "select" || filterVariant === "checkbox") return "equals";
|
|
1528
1515
|
return "fuzzy";
|
|
1529
1516
|
};
|
|
1517
|
+
const getFilterOptionLabel = (localization, filterOption) => localization[`filter${filterOption.charAt(0).toUpperCase() + filterOption.slice(1)}`];
|
|
1530
1518
|
const getColumnFilterInfo = ({ header, table }) => {
|
|
1531
1519
|
const { options: { columnFilterModeOptions } } = table;
|
|
1532
1520
|
const { column } = header;
|
|
@@ -1565,12 +1553,12 @@ const useDropdownOptions = ({ header, table }) => {
|
|
|
1565
1553
|
return useMemo(() => columnDef.filterSelectOptions ?? ((isSelectFilter || isMultiSelectFilter || isAutocompleteFilter) && facetedUniqueValues ? Array.from(facetedUniqueValues.keys()).filter((value) => value !== null && value !== void 0).sort((a, b) => a.localeCompare(b)) : void 0), [
|
|
1566
1554
|
columnDef.filterSelectOptions,
|
|
1567
1555
|
facetedUniqueValues,
|
|
1556
|
+
isAutocompleteFilter,
|
|
1568
1557
|
isMultiSelectFilter,
|
|
1569
1558
|
isSelectFilter
|
|
1570
1559
|
]);
|
|
1571
1560
|
};
|
|
1572
|
-
|
|
1573
|
-
//#region src/utils/displayColumn.utils.ts
|
|
1561
|
+
// src/utils/displayColumn.utils.ts
|
|
1574
1562
|
function defaultDisplayColumnProps({ header, id, size, tableOptions }) {
|
|
1575
1563
|
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
|
1576
1564
|
return {
|
|
@@ -1626,11 +1614,9 @@ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
|
|
|
1626
1614
|
...trailingDisplayColIds
|
|
1627
1615
|
];
|
|
1628
1616
|
};
|
|
1629
|
-
|
|
1630
|
-
//#region src/components/menus/MRT_ShowHideColumnsMenuItems.tsx
|
|
1617
|
+
// src/components/menus/MRT_ShowHideColumnsMenuItems.tsx
|
|
1631
1618
|
const MRT_ShowHideColumnsMenuItems = ({ allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table, ...rest }) => {
|
|
1632
|
-
const { options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor } }
|
|
1633
|
-
const { columnOrder } = table.state;
|
|
1619
|
+
const { options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor } } } = table;
|
|
1634
1620
|
const { columnDef } = column;
|
|
1635
1621
|
const { columnDefType } = columnDef;
|
|
1636
1622
|
const switchChecked = column.getIsVisible();
|
|
@@ -1653,14 +1639,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, column, hoveredColumn, isNes
|
|
|
1653
1639
|
const handleDragEnd = (_e) => {
|
|
1654
1640
|
setIsDragging(false);
|
|
1655
1641
|
setHoveredColumn(null);
|
|
1656
|
-
if (hoveredColumn)
|
|
1657
|
-
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
|
1658
|
-
setColumnOrder(reorderedColumns);
|
|
1659
|
-
setColumnPinning(({ end = [], start = [] }) => ({
|
|
1660
|
-
end: reorderedColumns.filter((header) => end.includes(header)),
|
|
1661
|
-
start: reorderedColumns.filter((header) => start.includes(header))
|
|
1662
|
-
}));
|
|
1663
|
-
}
|
|
1642
|
+
if (hoveredColumn) moveColumn(table, column, hoveredColumn);
|
|
1664
1643
|
};
|
|
1665
1644
|
const handleDragEnter = (_e) => {
|
|
1666
1645
|
if (!isDragging && columnDef.enableColumnOrdering !== false) setHoveredColumn(column);
|
|
@@ -1727,11 +1706,10 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, column, hoveredColumn, isNes
|
|
|
1727
1706
|
table
|
|
1728
1707
|
}, `${i}-${c.id}`))] });
|
|
1729
1708
|
};
|
|
1730
|
-
|
|
1731
|
-
//#region src/components/menus/MRT_ShowHideColumnsMenu.tsx
|
|
1709
|
+
// src/components/menus/MRT_ShowHideColumnsMenu.tsx
|
|
1732
1710
|
const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, ...rest }) => {
|
|
1733
1711
|
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, initialState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor } } } = table;
|
|
1734
|
-
const { columnOrder,
|
|
1712
|
+
const { columnOrder, density } = table.state;
|
|
1735
1713
|
const handleToggleAllColumns = (value) => {
|
|
1736
1714
|
const updates = getAllLeafColumns().filter((column) => column.columnDef.enableHiding !== false).reduce((acc, column) => {
|
|
1737
1715
|
acc[column.id] = value ?? !column.getIsVisible();
|
|
@@ -1742,21 +1720,24 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, ...rest }) => {
|
|
|
1742
1720
|
...updates
|
|
1743
1721
|
}));
|
|
1744
1722
|
};
|
|
1723
|
+
const allTableColumns = getAllColumns();
|
|
1724
|
+
const centerLeafColumns = getCenterLeafColumns();
|
|
1725
|
+
const leftLeafColumns = getLeftLeafColumns();
|
|
1726
|
+
const rightLeafColumns = getRightLeafColumns();
|
|
1745
1727
|
const allColumns = useMemo(() => {
|
|
1746
|
-
const columns =
|
|
1728
|
+
const columns = allTableColumns;
|
|
1747
1729
|
if (columnOrder.length > 0 && !columns.some((col) => col.columnDef.columnDefType === "group")) return [
|
|
1748
|
-
...
|
|
1749
|
-
...Array.from(new Set(columnOrder)).map((colId) =>
|
|
1750
|
-
...
|
|
1730
|
+
...leftLeafColumns,
|
|
1731
|
+
...Array.from(new Set(columnOrder)).map((colId) => centerLeafColumns.find((col) => col?.id === colId)),
|
|
1732
|
+
...rightLeafColumns
|
|
1751
1733
|
].filter(Boolean);
|
|
1752
1734
|
return columns;
|
|
1753
1735
|
}, [
|
|
1736
|
+
allTableColumns,
|
|
1737
|
+
centerLeafColumns,
|
|
1754
1738
|
columnOrder,
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
getCenterLeafColumns(),
|
|
1758
|
-
getLeftLeafColumns(),
|
|
1759
|
-
getRightLeafColumns()
|
|
1739
|
+
leftLeafColumns,
|
|
1740
|
+
rightLeafColumns
|
|
1760
1741
|
]);
|
|
1761
1742
|
const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === "group");
|
|
1762
1743
|
const hasColumnOrderChanged = useMemo(() => columnOrder.length !== initialState.columnOrder.length || !columnOrder.every((column, index) => column === initialState.columnOrder[index]), [columnOrder, initialState.columnOrder]);
|
|
@@ -1814,8 +1795,7 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, ...rest }) => {
|
|
|
1814
1795
|
]
|
|
1815
1796
|
});
|
|
1816
1797
|
};
|
|
1817
|
-
|
|
1818
|
-
//#region src/components/buttons/MRT_ShowHideColumnsButton.tsx
|
|
1798
|
+
// src/components/buttons/MRT_ShowHideColumnsButton.tsx
|
|
1819
1799
|
const MRT_ShowHideColumnsButton = ({ table, ...rest }) => {
|
|
1820
1800
|
const { options: { icons: { ViewColumnIcon }, localization } } = table;
|
|
1821
1801
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
@@ -1837,8 +1817,7 @@ const MRT_ShowHideColumnsButton = ({ table, ...rest }) => {
|
|
|
1837
1817
|
table
|
|
1838
1818
|
})] });
|
|
1839
1819
|
};
|
|
1840
|
-
|
|
1841
|
-
//#region src/components/buttons/MRT_ToggleDensePaddingButton.tsx
|
|
1820
|
+
// src/components/buttons/MRT_ToggleDensePaddingButton.tsx
|
|
1842
1821
|
const MRT_ToggleDensePaddingButton = ({ table, ...rest }) => {
|
|
1843
1822
|
const { options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization }, setDensity } = table;
|
|
1844
1823
|
const { density } = table.state;
|
|
@@ -1856,8 +1835,7 @@ const MRT_ToggleDensePaddingButton = ({ table, ...rest }) => {
|
|
|
1856
1835
|
})
|
|
1857
1836
|
});
|
|
1858
1837
|
};
|
|
1859
|
-
|
|
1860
|
-
//#region src/components/buttons/MRT_ToggleFiltersButton.tsx
|
|
1838
|
+
// src/components/buttons/MRT_ToggleFiltersButton.tsx
|
|
1861
1839
|
const MRT_ToggleFiltersButton = ({ table, ...rest }) => {
|
|
1862
1840
|
const { options: { icons: { FilterListIcon, FilterListOffIcon }, localization }, setShowColumnFilters } = table;
|
|
1863
1841
|
const { showColumnFilters } = table.state;
|
|
@@ -1875,8 +1853,7 @@ const MRT_ToggleFiltersButton = ({ table, ...rest }) => {
|
|
|
1875
1853
|
})
|
|
1876
1854
|
});
|
|
1877
1855
|
};
|
|
1878
|
-
|
|
1879
|
-
//#region src/components/buttons/MRT_ToggleFullScreenButton.tsx
|
|
1856
|
+
// src/components/buttons/MRT_ToggleFullScreenButton.tsx
|
|
1880
1857
|
const MRT_ToggleFullScreenButton = ({ table, ...rest }) => {
|
|
1881
1858
|
const { options: { icons: { FullscreenExitIcon, FullscreenIcon }, localization }, setIsFullScreen } = table;
|
|
1882
1859
|
const { isFullScreen } = table.state;
|
|
@@ -1901,8 +1878,7 @@ const MRT_ToggleFullScreenButton = ({ table, ...rest }) => {
|
|
|
1901
1878
|
})
|
|
1902
1879
|
});
|
|
1903
1880
|
};
|
|
1904
|
-
|
|
1905
|
-
//#region src/components/buttons/MRT_ToggleGlobalFilterButton.tsx
|
|
1881
|
+
// src/components/buttons/MRT_ToggleGlobalFilterButton.tsx
|
|
1906
1882
|
const MRT_ToggleGlobalFilterButton = ({ table, ...rest }) => {
|
|
1907
1883
|
const { options: { icons: { SearchIcon, SearchOffIcon }, localization }, refs: { searchInputRef }, setShowGlobalFilter } = table;
|
|
1908
1884
|
const { globalFilter, showGlobalFilter } = table.state;
|
|
@@ -1922,8 +1898,7 @@ const MRT_ToggleGlobalFilterButton = ({ table, ...rest }) => {
|
|
|
1922
1898
|
}) })
|
|
1923
1899
|
});
|
|
1924
1900
|
};
|
|
1925
|
-
|
|
1926
|
-
//#region src/components/menus/MRT_ActionMenuItem.tsx
|
|
1901
|
+
// src/components/menus/MRT_ActionMenuItem.tsx
|
|
1927
1902
|
const MRT_ActionMenuItem = ({ icon, label, onOpenSubMenu, table, ...rest }) => {
|
|
1928
1903
|
const { options: { icons: { ArrowRightIcon } } } = table;
|
|
1929
1904
|
return /* @__PURE__ */ jsxs(MenuItem, {
|
|
@@ -1951,8 +1926,7 @@ const MRT_ActionMenuItem = ({ icon, label, onOpenSubMenu, table, ...rest }) => {
|
|
|
1951
1926
|
})]
|
|
1952
1927
|
});
|
|
1953
1928
|
};
|
|
1954
|
-
|
|
1955
|
-
//#region src/components/menus/MRT_RowActionMenu.tsx
|
|
1929
|
+
// src/components/menus/MRT_RowActionMenu.tsx
|
|
1956
1930
|
const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table, ...rest }) => {
|
|
1957
1931
|
const { options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems } } = table;
|
|
1958
1932
|
const { density } = table.state;
|
|
@@ -1974,8 +1948,14 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, staticRowIn
|
|
|
1974
1948
|
if (rowActionMenuItems?.length) items.push(...rowActionMenuItems);
|
|
1975
1949
|
return items;
|
|
1976
1950
|
}, [
|
|
1951
|
+
EditIcon,
|
|
1952
|
+
editDisplayMode,
|
|
1953
|
+
enableEditing,
|
|
1954
|
+
handleEdit,
|
|
1955
|
+
localization.edit,
|
|
1977
1956
|
renderRowActionMenuItems,
|
|
1978
1957
|
row,
|
|
1958
|
+
setAnchorEl,
|
|
1979
1959
|
staticRowIndex,
|
|
1980
1960
|
table
|
|
1981
1961
|
]);
|
|
@@ -1994,8 +1974,7 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, staticRowIn
|
|
|
1994
1974
|
children: menuItems
|
|
1995
1975
|
});
|
|
1996
1976
|
};
|
|
1997
|
-
|
|
1998
|
-
//#region src/components/buttons/MRT_ToggleRowActionMenuButton.tsx
|
|
1977
|
+
// src/components/buttons/MRT_ToggleRowActionMenuButton.tsx
|
|
1999
1978
|
const commonIconButtonStyles = {
|
|
2000
1979
|
"&:hover": { opacity: 1 },
|
|
2001
1980
|
height: "2rem",
|
|
@@ -2041,6 +2020,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, staticRowIndex, table, ...re
|
|
|
2041
2020
|
})
|
|
2042
2021
|
}) : renderRowActionMenuItems?.({
|
|
2043
2022
|
row,
|
|
2023
|
+
closeMenu: () => {},
|
|
2044
2024
|
staticRowIndex,
|
|
2045
2025
|
table
|
|
2046
2026
|
})?.length ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
@@ -2063,8 +2043,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, staticRowIndex, table, ...re
|
|
|
2063
2043
|
table
|
|
2064
2044
|
})] }) : null });
|
|
2065
2045
|
};
|
|
2066
|
-
|
|
2067
|
-
//#region src/components/footer/MRT_TableFooterCell.tsx
|
|
2046
|
+
// src/components/footer/MRT_TableFooterCell.tsx
|
|
2068
2047
|
const MRT_TableFooterCell = ({ footer, staticColumnIndex, table, ...rest }) => {
|
|
2069
2048
|
const theme = useTheme();
|
|
2070
2049
|
const { options: { enableColumnPinning, enableKeyboardShortcuts, muiTableFooterCellProps } } = table;
|
|
@@ -2119,8 +2098,7 @@ const MRT_TableFooterCell = ({ footer, staticColumnIndex, table, ...rest }) => {
|
|
|
2119
2098
|
}) ?? columnDef.footer ?? null)
|
|
2120
2099
|
});
|
|
2121
2100
|
};
|
|
2122
|
-
|
|
2123
|
-
//#region src/components/footer/MRT_TableFooterRow.tsx
|
|
2101
|
+
// src/components/footer/MRT_TableFooterRow.tsx
|
|
2124
2102
|
const MRT_TableFooterRow = ({ columnVirtualizer, footerGroup, table, ...rest }) => {
|
|
2125
2103
|
const { options: { layoutMode, mrtTheme: { baseBackgroundColor }, muiTableFooterRowProps } } = table;
|
|
2126
2104
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {};
|
|
@@ -2165,8 +2143,7 @@ const MRT_TableFooterRow = ({ columnVirtualizer, footerGroup, table, ...rest })
|
|
|
2165
2143
|
]
|
|
2166
2144
|
});
|
|
2167
2145
|
};
|
|
2168
|
-
|
|
2169
|
-
//#region src/components/footer/MRT_TableFooter.tsx
|
|
2146
|
+
// src/components/footer/MRT_TableFooter.tsx
|
|
2170
2147
|
const MRT_TableFooter = ({ columnVirtualizer, table, ...rest }) => {
|
|
2171
2148
|
const { options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef } } = table;
|
|
2172
2149
|
const { isFullScreen } = table.state;
|
|
@@ -2181,7 +2158,7 @@ const MRT_TableFooter = ({ columnVirtualizer, table, ...rest }) => {
|
|
|
2181
2158
|
...tableFooterProps,
|
|
2182
2159
|
ref: (ref) => {
|
|
2183
2160
|
tableFooterRef.current = ref;
|
|
2184
|
-
if (tableFooterProps?.ref) tableFooterProps.ref.current = ref;
|
|
2161
|
+
if (tableFooterProps?.ref && typeof tableFooterProps.ref === "object") tableFooterProps.ref.current = ref;
|
|
2185
2162
|
},
|
|
2186
2163
|
sx: (theme) => ({
|
|
2187
2164
|
bottom: stickFooter ? 0 : void 0,
|
|
@@ -2199,8 +2176,7 @@ const MRT_TableFooter = ({ columnVirtualizer, table, ...rest }) => {
|
|
|
2199
2176
|
}, footerGroup.id))
|
|
2200
2177
|
});
|
|
2201
2178
|
};
|
|
2202
|
-
|
|
2203
|
-
//#region src/components/inputs/MRT_SelectCheckbox.tsx
|
|
2179
|
+
// src/components/inputs/MRT_SelectCheckbox.tsx
|
|
2204
2180
|
const MRT_SelectCheckbox = ({ row, staticRowIndex, table, ...rest }) => {
|
|
2205
2181
|
const { options: { enableMultiRowSelection, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, selectAllMode } } = table;
|
|
2206
2182
|
const { density, isLoading } = table.state;
|
|
@@ -2230,7 +2206,8 @@ const MRT_SelectCheckbox = ({ row, staticRowIndex, table, ...rest }) => {
|
|
|
2230
2206
|
disabled: isLoading || row && !row.getCanSelect() || row?.id === "mrt-row-create",
|
|
2231
2207
|
onChange: (event) => {
|
|
2232
2208
|
event.stopPropagation();
|
|
2233
|
-
|
|
2209
|
+
if (selectAll) onSelectAllChange(event);
|
|
2210
|
+
else onSelectionChange(event);
|
|
2234
2211
|
},
|
|
2235
2212
|
size: density === "compact" ? "small" : "medium",
|
|
2236
2213
|
slotProps: { input: { "aria-label": selectAll ? localization.toggleSelectAll : localization.toggleSelectRow } },
|
|
@@ -2257,8 +2234,7 @@ const MRT_SelectCheckbox = ({ row, staticRowIndex, table, ...rest }) => {
|
|
|
2257
2234
|
})
|
|
2258
2235
|
});
|
|
2259
2236
|
};
|
|
2260
|
-
|
|
2261
|
-
//#region src/components/toolbar/MRT_ToolbarAlertBanner.tsx
|
|
2237
|
+
// src/components/toolbar/MRT_ToolbarAlertBanner.tsx
|
|
2262
2238
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, ...rest }) => {
|
|
2263
2239
|
const { getCoreRowModel, getFilteredSelectedRowModel, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount }, refs: { tablePaperRef } } = table;
|
|
2264
2240
|
const { density, grouping, rowSelection, showAlertBanner } = table.state;
|
|
@@ -2271,7 +2247,6 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, ...rest }) => {
|
|
|
2271
2247
|
const filteredRowCount = getFilteredSelectedRowModel().rows.length;
|
|
2272
2248
|
const selectedRowCount = useMemo(() => manualPagination ? Object.values(rowSelection).filter(Boolean).length : filteredRowCount, [
|
|
2273
2249
|
rowSelection,
|
|
2274
|
-
totalRowCount,
|
|
2275
2250
|
manualPagination,
|
|
2276
2251
|
filteredRowCount
|
|
2277
2252
|
]);
|
|
@@ -2345,8 +2320,7 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, ...rest }) => {
|
|
|
2345
2320
|
})
|
|
2346
2321
|
});
|
|
2347
2322
|
};
|
|
2348
|
-
|
|
2349
|
-
//#region src/components/menus/MRT_FilterOptionMenu.tsx
|
|
2323
|
+
// src/components/menus/MRT_FilterOptionMenu.tsx
|
|
2350
2324
|
const mrtFilterOptions = (localization) => [
|
|
2351
2325
|
{
|
|
2352
2326
|
divider: false,
|
|
@@ -2458,11 +2432,11 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
|
2458
2432
|
const currentFilterValue = column?.getFilterValue();
|
|
2459
2433
|
let allowedColumnFilterOptions = columnDef?.columnFilterModeOptions ?? columnFilterModeOptions;
|
|
2460
2434
|
if (rangeVariants.includes(columnDef?.filterVariant)) allowedColumnFilterOptions = [...rangeModes, ...allowedColumnFilterOptions ?? []].filter((option) => rangeModes.includes(option));
|
|
2461
|
-
const internalFilterOptions =
|
|
2435
|
+
const [internalFilterOptions] = useState(() => mrtFilterOptions(localization).filter((filterOption) => columnDef ? allowedColumnFilterOptions === void 0 || allowedColumnFilterOptions?.includes(filterOption.option) : (!globalFilterModeOptions || globalFilterModeOptions.includes(filterOption.option)) && [
|
|
2462
2436
|
"contains",
|
|
2463
2437
|
"fuzzy",
|
|
2464
2438
|
"startsWith"
|
|
2465
|
-
].includes(filterOption.option))
|
|
2439
|
+
].includes(filterOption.option)));
|
|
2466
2440
|
const handleSelectFilterMode = (option) => {
|
|
2467
2441
|
const prevFilterMode = columnDef?._filterFn ?? "";
|
|
2468
2442
|
if (!header || !column) setGlobalFilterFn(option);
|
|
@@ -2533,8 +2507,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
|
2533
2507
|
}, index))
|
|
2534
2508
|
});
|
|
2535
2509
|
};
|
|
2536
|
-
|
|
2537
|
-
//#region src/components/menus/MRT_ColumnActionMenu.tsx
|
|
2510
|
+
// src/components/menus/MRT_ColumnActionMenu.tsx
|
|
2538
2511
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, ...rest }) => {
|
|
2539
2512
|
const { getAllLeafColumns, options: { columnFilterDisplayMode, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon }, localization, mrtTheme: { menuBackgroundColor }, renderColumnActionsMenuItems }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnResizing, setShowColumnFilters } = table;
|
|
2540
2513
|
const { column } = header;
|
|
@@ -2727,8 +2700,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, ...rest })
|
|
|
2727
2700
|
}) ?? internalColumnMenuItems
|
|
2728
2701
|
});
|
|
2729
2702
|
};
|
|
2730
|
-
|
|
2731
|
-
//#region src/components/head/MRT_TableHeadCellColumnActionsButton.tsx
|
|
2703
|
+
// src/components/head/MRT_TableHeadCellColumnActionsButton.tsx
|
|
2732
2704
|
const MRT_TableHeadCellColumnActionsButton = ({ header, table, ...rest }) => {
|
|
2733
2705
|
const { options: { icons: { MoreVertIcon }, localization, muiColumnActionsButtonProps } } = table;
|
|
2734
2706
|
const { column } = header;
|
|
@@ -2777,8 +2749,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, ...rest }) => {
|
|
|
2777
2749
|
table
|
|
2778
2750
|
})] });
|
|
2779
2751
|
};
|
|
2780
|
-
|
|
2781
|
-
//#region src/components/inputs/MRT_FilterCheckbox.tsx
|
|
2752
|
+
// src/components/inputs/MRT_FilterCheckbox.tsx
|
|
2782
2753
|
const MRT_FilterCheckbox = ({ column, table, ...rest }) => {
|
|
2783
2754
|
const { options: { localization, muiFilterCheckboxProps } } = table;
|
|
2784
2755
|
const { density } = table.state;
|
|
@@ -2830,8 +2801,7 @@ const MRT_FilterCheckbox = ({ column, table, ...rest }) => {
|
|
|
2830
2801
|
})
|
|
2831
2802
|
});
|
|
2832
2803
|
};
|
|
2833
|
-
|
|
2834
|
-
//#region src/components/inputs/MRT_FilterTextField.tsx
|
|
2804
|
+
// src/components/inputs/MRT_FilterTextField.tsx
|
|
2835
2805
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
2836
2806
|
const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps }, refs: { filterInputRefs }, setColumnFilterFns } = table;
|
|
2837
2807
|
const { column } = header;
|
|
@@ -2871,20 +2841,20 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
2871
2841
|
header,
|
|
2872
2842
|
table
|
|
2873
2843
|
});
|
|
2874
|
-
const filterChipLabel = ["empty", "notEmpty"].includes(currentFilterOption) ? localization
|
|
2844
|
+
const filterChipLabel = ["empty", "notEmpty"].includes(currentFilterOption) ? getFilterOptionLabel(localization, currentFilterOption) : "";
|
|
2875
2845
|
const filterPlaceholder = !isRangeFilter ? textFieldProps?.placeholder ?? localization.filterByColumn?.replace("{column}", String(columnDef.header)) : rangeFilterIndex === 0 ? localization.min : rangeFilterIndex === 1 ? localization.max : "";
|
|
2876
2846
|
const showChangeModeButton = !!(enableColumnFilterModes && columnDef.enableColumnFilterModes !== false && !rangeFilterIndex && (allowedColumnFilterOptions === void 0 || !!allowedColumnFilterOptions?.length));
|
|
2877
2847
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
2878
2848
|
const [filterValue, setFilterValue] = useState(() => isMultiSelectFilter ? column.getFilterValue() || [] : isRangeFilter ? column.getFilterValue()?.[rangeFilterIndex] || "" : isAutocompleteFilter ? typeof column.getFilterValue() === "string" ? column.getFilterValue() : "" : column.getFilterValue() ?? "");
|
|
2879
2849
|
const [autocompleteValue, setAutocompleteValue] = useState(() => isAutocompleteFilter ? column.getFilterValue() || null : null);
|
|
2880
|
-
const handleChangeDebounced =
|
|
2850
|
+
const [handleChangeDebounced] = useState(() => debounce((newValue) => {
|
|
2881
2851
|
if (isRangeFilter) column.setFilterValue((old) => {
|
|
2882
2852
|
const newFilterValues = old ?? ["", ""];
|
|
2883
2853
|
newFilterValues[rangeFilterIndex] = newValue ?? void 0;
|
|
2884
2854
|
return newFilterValues;
|
|
2885
2855
|
});
|
|
2886
2856
|
else column.setFilterValue(newValue ?? void 0);
|
|
2887
|
-
}, isTextboxFilter ? manualFiltering ? 400 : 200 : 1)
|
|
2857
|
+
}, isTextboxFilter ? manualFiltering ? 400 : 200 : 1));
|
|
2888
2858
|
const handleChange = (newValue) => {
|
|
2889
2859
|
setFilterValue(newValue ?? "");
|
|
2890
2860
|
handleChangeDebounced(newValue);
|
|
@@ -2932,15 +2902,24 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
2932
2902
|
setAnchorEl(event.currentTarget);
|
|
2933
2903
|
};
|
|
2934
2904
|
const isMounted = useRef(false);
|
|
2905
|
+
const handleClearRef = useRef(handleClear);
|
|
2906
|
+
const columnFilterValue = column.getFilterValue();
|
|
2907
|
+
useEffect(() => {
|
|
2908
|
+
handleClearRef.current = handleClear;
|
|
2909
|
+
});
|
|
2935
2910
|
useEffect(() => {
|
|
2936
2911
|
if (isMounted.current) {
|
|
2937
|
-
const filterValue =
|
|
2938
|
-
if (filterValue === void 0)
|
|
2912
|
+
const filterValue = columnFilterValue;
|
|
2913
|
+
if (filterValue === void 0) handleClearRef.current();
|
|
2939
2914
|
else if (isRangeFilter && rangeFilterIndex !== void 0) setFilterValue(filterValue[rangeFilterIndex]);
|
|
2940
2915
|
else setFilterValue(filterValue);
|
|
2941
2916
|
}
|
|
2942
2917
|
isMounted.current = true;
|
|
2943
|
-
}, [
|
|
2918
|
+
}, [
|
|
2919
|
+
columnFilterValue,
|
|
2920
|
+
isRangeFilter,
|
|
2921
|
+
rangeFilterIndex
|
|
2922
|
+
]);
|
|
2944
2923
|
if (columnDef.Filter) return /* @__PURE__ */ jsx(Fragment$1, { children: columnDef.Filter?.({
|
|
2945
2924
|
column,
|
|
2946
2925
|
header,
|
|
@@ -2951,7 +2930,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
2951
2930
|
position: "end",
|
|
2952
2931
|
sx: {
|
|
2953
2932
|
mr: isSelectFilter || isMultiSelectFilter ? "20px" : void 0,
|
|
2954
|
-
visibility: (filterValue
|
|
2933
|
+
visibility: (typeof filterValue === "string" || Array.isArray(filterValue)) && filterValue.length > 0 ? "visible" : "hidden"
|
|
2955
2934
|
},
|
|
2956
2935
|
children: /* @__PURE__ */ jsx(Tooltip, {
|
|
2957
2936
|
placement: "right",
|
|
@@ -2991,7 +2970,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
2991
2970
|
}) : null;
|
|
2992
2971
|
const commonTextFieldProps = {
|
|
2993
2972
|
fullWidth: true,
|
|
2994
|
-
helperText: showChangeModeButton ? /* @__PURE__ */ jsx("label", { children: localization.filterMode.replace("{filterType}", localization
|
|
2973
|
+
helperText: showChangeModeButton ? /* @__PURE__ */ jsx("label", { children: localization.filterMode.replace("{filterType}", getFilterOptionLabel(localization, currentFilterOption)) }) : null,
|
|
2995
2974
|
inputRef: (inputRef) => {
|
|
2996
2975
|
filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`] = inputRef;
|
|
2997
2976
|
if (textFieldProps.inputRef) textFieldProps.inputRef = inputRef;
|
|
@@ -3197,8 +3176,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, ...rest }) => {
|
|
|
3197
3176
|
table
|
|
3198
3177
|
})] });
|
|
3199
3178
|
};
|
|
3200
|
-
|
|
3201
|
-
//#region src/components/inputs/MRT_FilterRangeFields.tsx
|
|
3179
|
+
// src/components/inputs/MRT_FilterRangeFields.tsx
|
|
3202
3180
|
const MRT_FilterRangeFields = ({ header, table, ...rest }) => {
|
|
3203
3181
|
return /* @__PURE__ */ jsx(Box, {
|
|
3204
3182
|
...rest,
|
|
@@ -3215,8 +3193,7 @@ const MRT_FilterRangeFields = ({ header, table, ...rest }) => {
|
|
|
3215
3193
|
}, rangeFilterIndex))
|
|
3216
3194
|
});
|
|
3217
3195
|
};
|
|
3218
|
-
|
|
3219
|
-
//#region src/components/inputs/MRT_FilterRangeSlider.tsx
|
|
3196
|
+
// src/components/inputs/MRT_FilterRangeSlider.tsx
|
|
3220
3197
|
const MRT_FilterRangeSlider = ({ header, table, ...rest }) => {
|
|
3221
3198
|
const { options: { enableColumnFilterModes, localization, muiFilterSliderProps }, refs: { filterInputRefs } } = table;
|
|
3222
3199
|
const { column } = header;
|
|
@@ -3279,7 +3256,8 @@ const MRT_FilterRangeSlider = ({ header, table, ...rest }) => {
|
|
|
3279
3256
|
slotProps: { input: { ref: (node) => {
|
|
3280
3257
|
if (node) {
|
|
3281
3258
|
filterInputRefs.current[`${column.id}-0`] = node;
|
|
3282
|
-
|
|
3259
|
+
const inputSlot = sliderProps?.slotProps?.input;
|
|
3260
|
+
if (inputSlot && typeof inputSlot === "object" && inputSlot.ref && typeof inputSlot.ref === "object") inputSlot.ref.current = node;
|
|
3283
3261
|
}
|
|
3284
3262
|
} } },
|
|
3285
3263
|
sx: (theme) => ({
|
|
@@ -3297,11 +3275,10 @@ const MRT_FilterRangeSlider = ({ header, table, ...rest }) => {
|
|
|
3297
3275
|
m: "-3px -6px",
|
|
3298
3276
|
whiteSpace: "nowrap"
|
|
3299
3277
|
},
|
|
3300
|
-
children: localization.filterMode.replace("{filterType}", localization
|
|
3278
|
+
children: localization.filterMode.replace("{filterType}", getFilterOptionLabel(localization, currentFilterOption))
|
|
3301
3279
|
}) : null] });
|
|
3302
3280
|
};
|
|
3303
|
-
|
|
3304
|
-
//#region src/components/head/MRT_TableHeadCellFilterContainer.tsx
|
|
3281
|
+
// src/components/head/MRT_TableHeadCellFilterContainer.tsx
|
|
3305
3282
|
const MRT_TableHeadCellFilterContainer = ({ header, table, ...rest }) => {
|
|
3306
3283
|
const { options: { columnFilterDisplayMode } } = table;
|
|
3307
3284
|
const { showColumnFilters } = table.state;
|
|
@@ -3331,8 +3308,7 @@ const MRT_TableHeadCellFilterContainer = ({ header, table, ...rest }) => {
|
|
|
3331
3308
|
})
|
|
3332
3309
|
});
|
|
3333
3310
|
};
|
|
3334
|
-
|
|
3335
|
-
//#region src/components/head/MRT_TableHeadCellFilterLabel.tsx
|
|
3311
|
+
// src/components/head/MRT_TableHeadCellFilterLabel.tsx
|
|
3336
3312
|
const MRT_TableHeadCellFilterLabel = ({ header, table, ...rest }) => {
|
|
3337
3313
|
const { options: { columnFilterDisplayMode, icons: { FilterAltIcon }, localization }, refs: { filterInputRefs }, setShowColumnFilters } = table;
|
|
3338
3314
|
const { column } = header;
|
|
@@ -3349,7 +3325,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table, ...rest }) => {
|
|
|
3349
3325
|
});
|
|
3350
3326
|
const getSelectLabel = (index) => getValueAndLabel(dropdownOptions?.find((option) => getValueAndLabel(option).value === (index !== void 0 ? filterValue[index] : filterValue))).label;
|
|
3351
3327
|
const isFilterActive = Array.isArray(filterValue) && filterValue.some(Boolean) || !!filterValue && !Array.isArray(filterValue);
|
|
3352
|
-
const filterTooltip = columnFilterDisplayMode === "popover" && !isFilterActive ? localization.filterByColumn?.replace("{column}", String(columnDef.header)) : localization.filteringByColumn.replace("{column}", String(columnDef.header)).replace("{filterType}", currentFilterOption ? localization
|
|
3328
|
+
const filterTooltip = columnFilterDisplayMode === "popover" && !isFilterActive ? localization.filterByColumn?.replace("{column}", String(columnDef.header)) : localization.filteringByColumn.replace("{column}", String(columnDef.header)).replace("{filterType}", currentFilterOption ? getFilterOptionLabel(localization, currentFilterOption) : "").replace("{filterValue}", `"${Array.isArray(filterValue) ? filterValue.map((value, index) => isMultiSelectFilter ? getSelectLabel(index) : value).join(`" ${isRangeFilter ? localization.and : localization.or} "`) : isSelectFilter ? getSelectLabel() : filterValue}"`).replace("\" \"", "");
|
|
3353
3329
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Grow, {
|
|
3354
3330
|
in: columnFilterDisplayMode === "popover" || !!filterValue && !isRangeFilter || isRangeFilter && (!!filterValue?.[0] || !!filterValue?.[1]),
|
|
3355
3331
|
unmountOnExit: true,
|
|
@@ -3395,7 +3371,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table, ...rest }) => {
|
|
|
3395
3371
|
disableScrollLock: true,
|
|
3396
3372
|
onClick: (event) => event.stopPropagation(),
|
|
3397
3373
|
onClose: (event) => {
|
|
3398
|
-
event.stopPropagation();
|
|
3374
|
+
event.stopPropagation?.();
|
|
3399
3375
|
setAnchorEl(null);
|
|
3400
3376
|
},
|
|
3401
3377
|
onKeyDown: (event) => event.key === "Enter" && setAnchorEl(null),
|
|
@@ -3414,12 +3390,11 @@ const MRT_TableHeadCellFilterLabel = ({ header, table, ...rest }) => {
|
|
|
3414
3390
|
})
|
|
3415
3391
|
})] });
|
|
3416
3392
|
};
|
|
3417
|
-
|
|
3418
|
-
//#region src/components/head/MRT_TableHeadCellGrabHandle.tsx
|
|
3393
|
+
// src/components/head/MRT_TableHeadCellGrabHandle.tsx
|
|
3419
3394
|
const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, ...rest }) => {
|
|
3420
|
-
const { options: { enableColumnOrdering, muiColumnDragHandleProps },
|
|
3395
|
+
const { options: { enableColumnOrdering, muiColumnDragHandleProps }, setDraggingColumn, setHoveredColumn } = table;
|
|
3421
3396
|
const { columnDef } = column;
|
|
3422
|
-
const {
|
|
3397
|
+
const { draggingColumn, hoveredColumn } = table.state;
|
|
3423
3398
|
const iconButtonProps = {
|
|
3424
3399
|
...parseFromValuesOrFunc(muiColumnDragHandleProps, {
|
|
3425
3400
|
column,
|
|
@@ -3443,14 +3418,7 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, ...rest
|
|
|
3443
3418
|
const handleDragEnd = (event) => {
|
|
3444
3419
|
iconButtonProps?.onDragEnd?.(event);
|
|
3445
3420
|
if (hoveredColumn?.id === "drop-zone") column.toggleGrouping();
|
|
3446
|
-
else if (enableColumnOrdering && hoveredColumn && hoveredColumn?.id !== draggingColumn?.id)
|
|
3447
|
-
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
|
3448
|
-
setColumnOrder(reorderedColumns);
|
|
3449
|
-
setColumnPinning(({ end = [], start = [] }) => ({
|
|
3450
|
-
end: reorderedColumns.filter((header) => end.includes(header)),
|
|
3451
|
-
start: reorderedColumns.filter((header) => start.includes(header))
|
|
3452
|
-
}));
|
|
3453
|
-
}
|
|
3421
|
+
else if (enableColumnOrdering && hoveredColumn && hoveredColumn?.id !== draggingColumn?.id) moveColumn(table, column, hoveredColumn);
|
|
3454
3422
|
setDraggingColumn(null);
|
|
3455
3423
|
setHoveredColumn(null);
|
|
3456
3424
|
};
|
|
@@ -3461,8 +3429,7 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, ...rest
|
|
|
3461
3429
|
table
|
|
3462
3430
|
});
|
|
3463
3431
|
};
|
|
3464
|
-
|
|
3465
|
-
//#region src/components/head/MRT_TableHeadCellResizeHandle.tsx
|
|
3432
|
+
// src/components/head/MRT_TableHeadCellResizeHandle.tsx
|
|
3466
3433
|
const MRT_TableHeadCellResizeHandle = ({ header, table, ...rest }) => {
|
|
3467
3434
|
const { options: { columnResizeDirection, columnResizeMode }, setColumnResizing } = table;
|
|
3468
3435
|
const { density } = table.state;
|
|
@@ -3513,8 +3480,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table, ...rest }) => {
|
|
|
3513
3480
|
})
|
|
3514
3481
|
});
|
|
3515
3482
|
};
|
|
3516
|
-
|
|
3517
|
-
//#region src/components/head/MRT_TableHeadCellSortLabel.tsx
|
|
3483
|
+
// src/components/head/MRT_TableHeadCellSortLabel.tsx
|
|
3518
3484
|
const MRT_TableHeadCellSortLabel = ({ header, table, ...rest }) => {
|
|
3519
3485
|
const { options: { icons: { ArrowDownwardIcon, SyncAltIcon }, localization } } = table;
|
|
3520
3486
|
const { column } = header;
|
|
@@ -3555,8 +3521,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table, ...rest }) => {
|
|
|
3555
3521
|
})
|
|
3556
3522
|
});
|
|
3557
3523
|
};
|
|
3558
|
-
|
|
3559
|
-
//#region src/components/head/MRT_TableHeadCell.tsx
|
|
3524
|
+
// src/components/head/MRT_TableHeadCell.tsx
|
|
3560
3525
|
const MRT_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex, table, ...rest }) => {
|
|
3561
3526
|
const theme = useTheme();
|
|
3562
3527
|
const { options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps }, refs: { tableHeadCellRefs }, setHoveredColumn } = table;
|
|
@@ -3584,7 +3549,11 @@ const MRT_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex, table
|
|
|
3584
3549
|
if (showColumnActions) pl += 1.75;
|
|
3585
3550
|
if (showDragHandle) pl += 1.5;
|
|
3586
3551
|
return pl;
|
|
3587
|
-
}, [
|
|
3552
|
+
}, [
|
|
3553
|
+
column,
|
|
3554
|
+
showColumnActions,
|
|
3555
|
+
showDragHandle
|
|
3556
|
+
]);
|
|
3588
3557
|
const draggingBorders = useMemo(() => {
|
|
3589
3558
|
const showResizeBorder = columnResizing.isResizingColumn === column.id && columnResizeMode === "onChange" && !header.subHeaders.length;
|
|
3590
3559
|
const borderStyle = showResizeBorder ? `2px solid ${draggingBorderColor} !important` : draggingColumn?.id === column.id ? `1px dashed ${theme.palette.grey[500]}` : hoveredColumn?.id === column.id ? `2px dashed ${draggingBorderColor}` : void 0;
|
|
@@ -3595,9 +3564,15 @@ const MRT_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex, table
|
|
|
3595
3564
|
borderTop: borderStyle
|
|
3596
3565
|
} : void 0;
|
|
3597
3566
|
}, [
|
|
3567
|
+
column.id,
|
|
3568
|
+
columnResizeDirection,
|
|
3569
|
+
columnResizeMode,
|
|
3570
|
+
columnResizing.isResizingColumn,
|
|
3571
|
+
draggingBorderColor,
|
|
3598
3572
|
draggingColumn,
|
|
3573
|
+
header.subHeaders.length,
|
|
3599
3574
|
hoveredColumn,
|
|
3600
|
-
|
|
3575
|
+
theme.palette.grey
|
|
3601
3576
|
]);
|
|
3602
3577
|
const handleDragEnter = (_e) => {
|
|
3603
3578
|
if (enableGrouping && hoveredColumn?.id === "drop-zone") setHoveredColumn(null);
|
|
@@ -3733,8 +3708,7 @@ const MRT_TableHeadCell = ({ columnVirtualizer, header, staticColumnIndex, table
|
|
|
3733
3708
|
})]
|
|
3734
3709
|
});
|
|
3735
3710
|
};
|
|
3736
|
-
|
|
3737
|
-
//#region src/components/head/MRT_TableHeadRow.tsx
|
|
3711
|
+
// src/components/head/MRT_TableHeadRow.tsx
|
|
3738
3712
|
const MRT_TableHeadRow = ({ columnVirtualizer, headerGroup, table, ...rest }) => {
|
|
3739
3713
|
const { options: { enableStickyHeader, layoutMode, mrtTheme: { baseBackgroundColor }, muiTableHeadRowProps } } = table;
|
|
3740
3714
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {};
|
|
@@ -3780,8 +3754,7 @@ const MRT_TableHeadRow = ({ columnVirtualizer, headerGroup, table, ...rest }) =>
|
|
|
3780
3754
|
]
|
|
3781
3755
|
});
|
|
3782
3756
|
};
|
|
3783
|
-
|
|
3784
|
-
//#region src/components/head/MRT_TableHead.tsx
|
|
3757
|
+
// src/components/head/MRT_TableHead.tsx
|
|
3785
3758
|
const MRT_TableHead = ({ columnVirtualizer, table, ...rest }) => {
|
|
3786
3759
|
const { options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner }, refs: { tableHeadRef } } = table;
|
|
3787
3760
|
const { isFullScreen, showAlertBanner } = table.state;
|
|
@@ -3794,7 +3767,7 @@ const MRT_TableHead = ({ columnVirtualizer, table, ...rest }) => {
|
|
|
3794
3767
|
...tableHeadProps,
|
|
3795
3768
|
ref: (ref) => {
|
|
3796
3769
|
tableHeadRef.current = ref;
|
|
3797
|
-
if (tableHeadProps?.ref) tableHeadProps.ref.current = ref;
|
|
3770
|
+
if (tableHeadProps?.ref && typeof tableHeadProps.ref === "object") tableHeadProps.ref.current = ref;
|
|
3798
3771
|
},
|
|
3799
3772
|
sx: (theme) => ({
|
|
3800
3773
|
display: layoutMode?.startsWith("grid") ? "grid" : void 0,
|
|
@@ -3821,8 +3794,7 @@ const MRT_TableHead = ({ columnVirtualizer, table, ...rest }) => {
|
|
|
3821
3794
|
}, headerGroup.id))
|
|
3822
3795
|
});
|
|
3823
3796
|
};
|
|
3824
|
-
|
|
3825
|
-
//#region src/components/inputs/MRT_GlobalFilterTextField.tsx
|
|
3797
|
+
// src/components/inputs/MRT_GlobalFilterTextField.tsx
|
|
3826
3798
|
const MRT_GlobalFilterTextField = ({ table, ...rest }) => {
|
|
3827
3799
|
const { options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps }, refs: { searchInputRef }, setGlobalFilter } = table;
|
|
3828
3800
|
const { globalFilter, showGlobalFilter } = table.state;
|
|
@@ -3833,9 +3805,9 @@ const MRT_GlobalFilterTextField = ({ table, ...rest }) => {
|
|
|
3833
3805
|
const isMounted = useRef(false);
|
|
3834
3806
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
3835
3807
|
const [searchValue, setSearchValue] = useState(globalFilter ?? "");
|
|
3836
|
-
const handleChangeDebounced =
|
|
3808
|
+
const [handleChangeDebounced] = useState(() => debounce((event) => {
|
|
3837
3809
|
setGlobalFilter(event.target.value ?? void 0);
|
|
3838
|
-
}, manualFiltering ? 500 : 250)
|
|
3810
|
+
}, manualFiltering ? 500 : 250));
|
|
3839
3811
|
const handleChange = (event) => {
|
|
3840
3812
|
setSearchValue(event.target.value);
|
|
3841
3813
|
handleChangeDebounced(event);
|
|
@@ -3849,11 +3821,13 @@ const MRT_GlobalFilterTextField = ({ table, ...rest }) => {
|
|
|
3849
3821
|
};
|
|
3850
3822
|
useEffect(() => {
|
|
3851
3823
|
if (isMounted.current) {
|
|
3852
|
-
if (globalFilter === void 0)
|
|
3853
|
-
|
|
3824
|
+
if (globalFilter === void 0) {
|
|
3825
|
+
setSearchValue("");
|
|
3826
|
+
setGlobalFilter(void 0);
|
|
3827
|
+
} else setSearchValue(globalFilter);
|
|
3854
3828
|
}
|
|
3855
3829
|
isMounted.current = true;
|
|
3856
|
-
}, [globalFilter]);
|
|
3830
|
+
}, [globalFilter, setGlobalFilter]);
|
|
3857
3831
|
const consumerSlots = getTextFieldSlotProps(textFieldProps.slotProps);
|
|
3858
3832
|
return /* @__PURE__ */ jsxs(Collapse, {
|
|
3859
3833
|
in: showGlobalFilter,
|
|
@@ -3921,38 +3895,41 @@ const MRT_GlobalFilterTextField = ({ table, ...rest }) => {
|
|
|
3921
3895
|
})]
|
|
3922
3896
|
});
|
|
3923
3897
|
};
|
|
3924
|
-
|
|
3925
|
-
//#region src/fns/aggregationFns.ts
|
|
3898
|
+
// src/fns/aggregationFns.ts
|
|
3926
3899
|
const MRT_AggregationFns = { ...aggregationFns };
|
|
3927
|
-
|
|
3928
|
-
//#region src/fns/filterFns.ts
|
|
3900
|
+
// src/fns/filterFns.ts
|
|
3929
3901
|
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
3930
3902
|
const itemRank = rankItem(row.getValue(columnId), filterValue, { threshold: rankings.MATCHES });
|
|
3931
3903
|
addMeta?.(itemRank);
|
|
3932
3904
|
return itemRank.passed;
|
|
3933
3905
|
};
|
|
3934
3906
|
fuzzy.autoRemove = (val) => !val;
|
|
3935
|
-
const
|
|
3907
|
+
const normalize = (value) => value.toString().toLowerCase().trim();
|
|
3908
|
+
const getNormalizedValue = (row, id) => {
|
|
3909
|
+
const value = row.getValue(id);
|
|
3910
|
+
return value === null || value === void 0 ? void 0 : normalize(value);
|
|
3911
|
+
};
|
|
3912
|
+
const contains = (row, id, filterValue) => !!getNormalizedValue(row, id)?.includes(normalize(filterValue));
|
|
3936
3913
|
contains.autoRemove = (val) => !val;
|
|
3937
|
-
const startsWith = (row, id, filterValue) => !!row
|
|
3914
|
+
const startsWith = (row, id, filterValue) => !!getNormalizedValue(row, id)?.startsWith(normalize(filterValue));
|
|
3938
3915
|
startsWith.autoRemove = (val) => !val;
|
|
3939
|
-
const endsWith = (row, id, filterValue) => !!row
|
|
3916
|
+
const endsWith = (row, id, filterValue) => !!getNormalizedValue(row, id)?.endsWith(normalize(filterValue));
|
|
3940
3917
|
endsWith.autoRemove = (val) => !val;
|
|
3941
|
-
const equals = (row, id, filterValue) => row
|
|
3918
|
+
const equals = (row, id, filterValue) => getNormalizedValue(row, id) === normalize(filterValue);
|
|
3942
3919
|
equals.autoRemove = (val) => !val;
|
|
3943
|
-
const notEquals = (row, id, filterValue) => row
|
|
3920
|
+
const notEquals = (row, id, filterValue) => getNormalizedValue(row, id) !== normalize(filterValue);
|
|
3944
3921
|
notEquals.autoRemove = (val) => !val;
|
|
3945
|
-
const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id)) ? +(row.getValue(id) ?? 0) > +filterValue : (row
|
|
3922
|
+
const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id)) ? +(row.getValue(id) ?? 0) > +filterValue : (getNormalizedValue(row, id) ?? "") > normalize(filterValue);
|
|
3946
3923
|
greaterThan.autoRemove = (val) => !val;
|
|
3947
3924
|
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
|
3948
3925
|
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
|
3949
|
-
const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id)) ? +(row.getValue(id) ?? 0) < +filterValue : (row
|
|
3926
|
+
const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id)) ? +(row.getValue(id) ?? 0) < +filterValue : (getNormalizedValue(row, id) ?? "") < normalize(filterValue);
|
|
3950
3927
|
lessThan.autoRemove = (val) => !val;
|
|
3951
3928
|
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
|
3952
3929
|
lessThanOrEqualTo.autoRemove = (val) => !val;
|
|
3953
|
-
const between = (row, id, filterValues) => ([""
|
|
3930
|
+
const between = (row, id, filterValues) => (filterValues[0] === "" || filterValues[0] === void 0 || greaterThan(row, id, filterValues[0])) && (!isNaN(+filterValues[0]) && !isNaN(+filterValues[1]) && +filterValues[0] > +filterValues[1] || filterValues[1] === "" || filterValues[1] === void 0 || lessThan(row, id, filterValues[1]));
|
|
3954
3931
|
between.autoRemove = (val) => !val;
|
|
3955
|
-
const betweenInclusive = (row, id, filterValues) => ([""
|
|
3932
|
+
const betweenInclusive = (row, id, filterValues) => (filterValues[0] === "" || filterValues[0] === void 0 || greaterThanOrEqualTo(row, id, filterValues[0])) && (!isNaN(+filterValues[0]) && !isNaN(+filterValues[1]) && +filterValues[0] > +filterValues[1] || filterValues[1] === "" || filterValues[1] === void 0 || lessThanOrEqualTo(row, id, filterValues[1]));
|
|
3956
3933
|
betweenInclusive.autoRemove = (val) => !val;
|
|
3957
3934
|
const empty = (row, id, _filterValue) => !row.getValue(id)?.toString().trim();
|
|
3958
3935
|
empty.autoRemove = (val) => !val;
|
|
@@ -4037,9 +4014,8 @@ const MRT_DefaultTableFeatures = tableFeatures({
|
|
|
4037
4014
|
sortedRowModel: createSortedRowModel(),
|
|
4038
4015
|
sortFns: MRT_SortingFns
|
|
4039
4016
|
});
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
const flexRender = flexRender$1;
|
|
4017
|
+
// src/utils/tanstack.helpers.ts
|
|
4018
|
+
const flexRender = (Comp, props) => flexRender$1(Comp, props);
|
|
4043
4019
|
function createMRTColumnHelper() {
|
|
4044
4020
|
return {
|
|
4045
4021
|
accessor: (accessor, column) => {
|
|
@@ -4056,8 +4032,7 @@ function createMRTColumnHelper() {
|
|
|
4056
4032
|
};
|
|
4057
4033
|
}
|
|
4058
4034
|
const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => constructRow(table, "mrt-row-create", originalRow ?? Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({ [getColumnId(col)]: "" }))), rowIndex, depth, subRows, parentId);
|
|
4059
|
-
|
|
4060
|
-
//#region src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx
|
|
4035
|
+
// src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx
|
|
4061
4036
|
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
|
4062
4037
|
return {
|
|
4063
4038
|
Cell: ({ cell, row, staticRowIndex, table }) => /* @__PURE__ */ jsx(MRT_ToggleRowActionMenuButton, {
|
|
@@ -4074,8 +4049,7 @@ const getMRT_RowActionsColumnDef = (tableOptions) => {
|
|
|
4074
4049
|
})
|
|
4075
4050
|
};
|
|
4076
4051
|
};
|
|
4077
|
-
|
|
4078
|
-
//#region src/hooks/display-columns/getMRT_RowDragColumnDef.tsx
|
|
4052
|
+
// src/hooks/display-columns/getMRT_RowDragColumnDef.tsx
|
|
4079
4053
|
const getMRT_RowDragColumnDef = (tableOptions) => {
|
|
4080
4054
|
return {
|
|
4081
4055
|
Cell: ({ row, rowRef, table }) => /* @__PURE__ */ jsx(MRT_TableBodyRowGrabHandle, {
|
|
@@ -4092,8 +4066,7 @@ const getMRT_RowDragColumnDef = (tableOptions) => {
|
|
|
4092
4066
|
})
|
|
4093
4067
|
};
|
|
4094
4068
|
};
|
|
4095
|
-
|
|
4096
|
-
//#region src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx
|
|
4069
|
+
// src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx
|
|
4097
4070
|
const getMRT_RowExpandColumnDef = (tableOptions) => {
|
|
4098
4071
|
const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping } } = tableOptions;
|
|
4099
4072
|
const alignProps = positionExpandColumn === "last" ? { align: "right" } : void 0;
|
|
@@ -4145,8 +4118,7 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
|
|
|
4145
4118
|
})
|
|
4146
4119
|
};
|
|
4147
4120
|
};
|
|
4148
|
-
|
|
4149
|
-
//#region src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx
|
|
4121
|
+
// src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx
|
|
4150
4122
|
const getMRT_RowNumbersColumnDef = (tableOptions) => {
|
|
4151
4123
|
const { localization, rowNumberDisplayMode } = tableOptions;
|
|
4152
4124
|
const { pagination: { pageIndex, pageSize } } = tableOptions.state;
|
|
@@ -4162,8 +4134,7 @@ const getMRT_RowNumbersColumnDef = (tableOptions) => {
|
|
|
4162
4134
|
})
|
|
4163
4135
|
};
|
|
4164
4136
|
};
|
|
4165
|
-
|
|
4166
|
-
//#region src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx
|
|
4137
|
+
// src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx
|
|
4167
4138
|
const getMRT_RowPinningColumnDef = (tableOptions) => {
|
|
4168
4139
|
return {
|
|
4169
4140
|
Cell: ({ row, table }) => /* @__PURE__ */ jsx(MRT_TableBodyRowPinButton, {
|
|
@@ -4179,8 +4150,7 @@ const getMRT_RowPinningColumnDef = (tableOptions) => {
|
|
|
4179
4150
|
})
|
|
4180
4151
|
};
|
|
4181
4152
|
};
|
|
4182
|
-
|
|
4183
|
-
//#region src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx
|
|
4153
|
+
// src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx
|
|
4184
4154
|
const getMRT_RowSelectColumnDef = (tableOptions) => {
|
|
4185
4155
|
const { enableMultiRowSelection, enableSelectAll } = tableOptions;
|
|
4186
4156
|
return {
|
|
@@ -4199,8 +4169,7 @@ const getMRT_RowSelectColumnDef = (tableOptions) => {
|
|
|
4199
4169
|
})
|
|
4200
4170
|
};
|
|
4201
4171
|
};
|
|
4202
|
-
|
|
4203
|
-
//#region src/icons.ts
|
|
4172
|
+
// src/icons.ts
|
|
4204
4173
|
const MRT_Default_Icons = {
|
|
4205
4174
|
ArrowDownwardIcon: ArrowDownward,
|
|
4206
4175
|
ArrowRightIcon: ArrowRight,
|
|
@@ -4237,8 +4206,7 @@ const MRT_Default_Icons = {
|
|
|
4237
4206
|
ViewColumnIcon: ViewColumn,
|
|
4238
4207
|
VisibilityOffIcon: VisibilityOff
|
|
4239
4208
|
};
|
|
4240
|
-
|
|
4241
|
-
//#region src/locales/en.ts
|
|
4209
|
+
// src/locales/en.ts
|
|
4242
4210
|
const MRT_Localization_EN = {
|
|
4243
4211
|
language: "en",
|
|
4244
4212
|
actions: "Actions",
|
|
@@ -4333,8 +4301,7 @@ const MRT_Localization_EN = {
|
|
|
4333
4301
|
unpin: "Unpin",
|
|
4334
4302
|
unpinAll: "Unpin all"
|
|
4335
4303
|
};
|
|
4336
|
-
|
|
4337
|
-
//#region src/hooks/useMRT_TableOptions.ts
|
|
4304
|
+
// src/hooks/useMRT_TableOptions.ts
|
|
4338
4305
|
const MRT_DefaultColumn = {
|
|
4339
4306
|
filterVariant: "text",
|
|
4340
4307
|
maxSize: 1e3,
|
|
@@ -4366,18 +4333,18 @@ const useMRT_TableOptions = ({ aggregationFns, autoResetExpanded = false, column
|
|
|
4366
4333
|
...localization
|
|
4367
4334
|
}), [localization]);
|
|
4368
4335
|
mrtTheme = useMemo(() => getMRTTheme(mrtTheme, theme), [mrtTheme, theme]);
|
|
4369
|
-
aggregationFns =
|
|
4336
|
+
[aggregationFns] = useState(() => ({
|
|
4370
4337
|
...MRT_AggregationFns,
|
|
4371
4338
|
...aggregationFns
|
|
4372
|
-
})
|
|
4373
|
-
filterFns =
|
|
4339
|
+
}));
|
|
4340
|
+
[filterFns] = useState(() => ({
|
|
4374
4341
|
...MRT_FilterFns,
|
|
4375
4342
|
...filterFns
|
|
4376
|
-
})
|
|
4377
|
-
sortFns =
|
|
4343
|
+
}));
|
|
4344
|
+
[sortFns] = useState(() => ({
|
|
4378
4345
|
...MRT_SortingFns,
|
|
4379
4346
|
...sortFns
|
|
4380
|
-
})
|
|
4347
|
+
}));
|
|
4381
4348
|
defaultColumn = useMemo(() => ({
|
|
4382
4349
|
...MRT_DefaultColumn,
|
|
4383
4350
|
...defaultColumn
|
|
@@ -4386,7 +4353,7 @@ const useMRT_TableOptions = ({ aggregationFns, autoResetExpanded = false, column
|
|
|
4386
4353
|
...MRT_DefaultDisplayColumn,
|
|
4387
4354
|
...defaultDisplayColumn
|
|
4388
4355
|
}), [defaultDisplayColumn]);
|
|
4389
|
-
[enableColumnVirtualization, enableRowVirtualization] =
|
|
4356
|
+
[[enableColumnVirtualization, enableRowVirtualization]] = useState(() => [enableColumnVirtualization, enableRowVirtualization]);
|
|
4390
4357
|
if (!columnResizeDirection) columnResizeDirection = theme.direction || "ltr";
|
|
4391
4358
|
layoutMode = layoutMode || (enableColumnResizing ? "grid-no-grow" : "semantic");
|
|
4392
4359
|
if (layoutMode === "semantic" && (enableRowVirtualization || enableColumnVirtualization)) layoutMode = "grid";
|
|
@@ -4443,7 +4410,7 @@ const useMRT_TableOptions = ({ aggregationFns, autoResetExpanded = false, column
|
|
|
4443
4410
|
enableTopToolbar,
|
|
4444
4411
|
filterFns,
|
|
4445
4412
|
getRowCanExpand: rest.getRowCanExpand ?? (rest.renderDetailPanel ? () => true : void 0),
|
|
4446
|
-
getSubRows: (row) => row
|
|
4413
|
+
getSubRows: (row) => "subRows" in row ? row.subRows : void 0,
|
|
4447
4414
|
icons,
|
|
4448
4415
|
id,
|
|
4449
4416
|
layoutMode,
|
|
@@ -4468,8 +4435,7 @@ const useMRT_TableOptions = ({ aggregationFns, autoResetExpanded = false, column
|
|
|
4468
4435
|
...rest
|
|
4469
4436
|
};
|
|
4470
4437
|
};
|
|
4471
|
-
|
|
4472
|
-
//#region src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx
|
|
4438
|
+
// src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx
|
|
4473
4439
|
const blankColProps = {
|
|
4474
4440
|
children: null,
|
|
4475
4441
|
sx: {
|
|
@@ -4492,16 +4458,31 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
|
|
|
4492
4458
|
muiTableHeadCellProps: blankColProps
|
|
4493
4459
|
};
|
|
4494
4460
|
};
|
|
4495
|
-
|
|
4496
|
-
//#region src/hooks/useMRT_Effects.ts
|
|
4461
|
+
// src/hooks/useMRT_Effects.ts
|
|
4497
4462
|
const useMRT_Effects = (table) => {
|
|
4498
|
-
const {
|
|
4463
|
+
const { getPrePaginatedRowModel, options: { enablePagination, enableRowPinning, rowCount } } = table;
|
|
4499
4464
|
const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting } = table.state;
|
|
4500
4465
|
const totalColumnCount = table.options.columns.length;
|
|
4501
4466
|
const totalRowCount = rowCount ?? getPrePaginatedRowModel().rows.length;
|
|
4502
|
-
const rerender = useReducer(() => ({}), {})
|
|
4467
|
+
const [, rerender] = useReducer(() => ({}), {});
|
|
4503
4468
|
const initialBodyHeight = useRef(null);
|
|
4504
4469
|
const previousTop = useRef(null);
|
|
4470
|
+
const effectValues = useRef({
|
|
4471
|
+
columnOrder,
|
|
4472
|
+
enableRowPinning,
|
|
4473
|
+
pagination,
|
|
4474
|
+
table,
|
|
4475
|
+
tableOptions: table.options
|
|
4476
|
+
});
|
|
4477
|
+
useEffect(() => {
|
|
4478
|
+
effectValues.current = {
|
|
4479
|
+
columnOrder,
|
|
4480
|
+
enableRowPinning,
|
|
4481
|
+
pagination,
|
|
4482
|
+
table,
|
|
4483
|
+
tableOptions: table.options
|
|
4484
|
+
};
|
|
4485
|
+
});
|
|
4505
4486
|
useEffect(() => {
|
|
4506
4487
|
if (typeof window !== "undefined") initialBodyHeight.current = document.body.style.height;
|
|
4507
4488
|
}, []);
|
|
@@ -4521,10 +4502,12 @@ const useMRT_Effects = (table) => {
|
|
|
4521
4502
|
}
|
|
4522
4503
|
}, [isFullScreen]);
|
|
4523
4504
|
useEffect(() => {
|
|
4524
|
-
|
|
4505
|
+
const { columnOrder, table, tableOptions } = effectValues.current;
|
|
4506
|
+
if (totalColumnCount !== columnOrder.length) table.setColumnOrder(getDefaultColumnOrderIds(tableOptions));
|
|
4525
4507
|
}, [totalColumnCount]);
|
|
4526
4508
|
useEffect(() => {
|
|
4527
4509
|
if (!enablePagination || isLoading || showSkeletons) return;
|
|
4510
|
+
const { pagination, table } = effectValues.current;
|
|
4528
4511
|
const { pageIndex, pageSize } = pagination;
|
|
4529
4512
|
const totalPages = totalRowCount > 0 ? Math.ceil(totalRowCount / pageSize) : 1;
|
|
4530
4513
|
if (pageIndex < 0 || pageIndex >= totalPages) table.setPageIndex(totalPages - 1);
|
|
@@ -4539,18 +4522,19 @@ const useMRT_Effects = (table) => {
|
|
|
4539
4522
|
if (sorting.length) appliedSort.current = sorting;
|
|
4540
4523
|
}, [sorting]);
|
|
4541
4524
|
useEffect(() => {
|
|
4525
|
+
const { table } = effectValues.current;
|
|
4542
4526
|
if (!getCanRankRows(table)) return;
|
|
4543
4527
|
if (globalFilter) table.setSorting([]);
|
|
4544
4528
|
else table.setSorting(() => appliedSort.current || []);
|
|
4545
4529
|
}, [globalFilter]);
|
|
4546
4530
|
useEffect(() => {
|
|
4547
|
-
|
|
4531
|
+
const { enableRowPinning, table } = effectValues.current;
|
|
4532
|
+
if (enableRowPinning && table.getIsSomeRowsPinned()) setTimeout(() => {
|
|
4548
4533
|
rerender();
|
|
4549
4534
|
}, 150);
|
|
4550
4535
|
}, [density]);
|
|
4551
4536
|
};
|
|
4552
|
-
|
|
4553
|
-
//#region src/hooks/useMRT_TableInstance.ts
|
|
4537
|
+
// src/hooks/useMRT_TableInstance.ts
|
|
4554
4538
|
/**
|
|
4555
4539
|
* The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
|
|
4556
4540
|
* @param definedTableOptions - table options with proper defaults set
|
|
@@ -4569,7 +4553,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
4569
4553
|
const topToolbarRef = useRef(null);
|
|
4570
4554
|
const tableHeadRef = useRef(null);
|
|
4571
4555
|
const tableFooterRef = useRef(null);
|
|
4572
|
-
const initialState =
|
|
4556
|
+
const [initialState] = useState(() => {
|
|
4573
4557
|
const initState = definedTableOptions.initialState ?? {};
|
|
4574
4558
|
initState.columnOrder = initState.columnOrder ?? getDefaultColumnOrderIds({
|
|
4575
4559
|
...definedTableOptions,
|
|
@@ -4580,7 +4564,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
4580
4564
|
});
|
|
4581
4565
|
initState.globalFilterFn = definedTableOptions.globalFilterFn ?? "fuzzy";
|
|
4582
4566
|
return initState;
|
|
4583
|
-
}
|
|
4567
|
+
});
|
|
4584
4568
|
definedTableOptions.initialState = initialState;
|
|
4585
4569
|
const [actionCell, setActionCell] = useState(initialState.actionCell ?? null);
|
|
4586
4570
|
const [creatingRow, _setCreatingRow] = useState(initialState.creatingRow ?? null);
|
|
@@ -4646,9 +4630,10 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
4646
4630
|
tableOptions: statefulTableOptions
|
|
4647
4631
|
});
|
|
4648
4632
|
columnDefsRef.current = statefulTableOptions.columns;
|
|
4649
|
-
statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading || statefulTableOptions.state.showSkeletons) && !statefulTableOptions.data.length ? [...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null)].map(() => Object.assign({}, ...getAllLeafColumnDefs(
|
|
4633
|
+
statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading || statefulTableOptions.state.showSkeletons) && !statefulTableOptions.data.length ? [...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null)].map(() => Object.assign({}, ...getAllLeafColumnDefs(columnDefsRef.current).map((col) => ({ [getColumnId(col)]: null })))) : statefulTableOptions.data, [
|
|
4650
4634
|
statefulTableOptions.data,
|
|
4651
4635
|
statefulTableOptions.state.isLoading,
|
|
4636
|
+
statefulTableOptions.state.pagination.pageSize,
|
|
4652
4637
|
statefulTableOptions.state.showSkeletons
|
|
4653
4638
|
]);
|
|
4654
4639
|
const [features] = useState(() => tableFeatures({
|
|
@@ -4698,7 +4683,8 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
4698
4683
|
setColumnFilterFns: statefulTableOptions.onColumnFilterFnsChange ?? setColumnFilterFns,
|
|
4699
4684
|
setCreatingRow: (row) => {
|
|
4700
4685
|
const nextRow = row === true ? createRow(table) : row;
|
|
4701
|
-
statefulTableOptions?.onCreatingRowChange?.(nextRow)
|
|
4686
|
+
const handled = statefulTableOptions?.onCreatingRowChange?.(nextRow);
|
|
4687
|
+
if (handled === void 0 || handled === null) _setCreatingRow(nextRow);
|
|
4702
4688
|
},
|
|
4703
4689
|
setDensity: statefulTableOptions.onDensityChange ?? setDensity,
|
|
4704
4690
|
setDraggingColumn: statefulTableOptions.onDraggingColumnChange ?? setDraggingColumn,
|
|
@@ -4717,11 +4703,9 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
4717
4703
|
useMRT_Effects(table);
|
|
4718
4704
|
return table;
|
|
4719
4705
|
};
|
|
4720
|
-
|
|
4721
|
-
//#region src/hooks/useMaterialReactTable.ts
|
|
4706
|
+
// src/hooks/useMaterialReactTable.ts
|
|
4722
4707
|
const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
|
|
4723
|
-
|
|
4724
|
-
//#region src/components/toolbar/MRT_LinearProgressBar.tsx
|
|
4708
|
+
// src/components/toolbar/MRT_LinearProgressBar.tsx
|
|
4725
4709
|
const MRT_LinearProgressBar = ({ isTopToolbar, table, ...rest }) => {
|
|
4726
4710
|
const { options: { muiLinearProgressProps } } = table;
|
|
4727
4711
|
const { isSaving, showProgressBars } = table.state;
|
|
@@ -4750,8 +4734,7 @@ const MRT_LinearProgressBar = ({ isTopToolbar, table, ...rest }) => {
|
|
|
4750
4734
|
})
|
|
4751
4735
|
});
|
|
4752
4736
|
};
|
|
4753
|
-
|
|
4754
|
-
//#region src/components/toolbar/MRT_TablePagination.tsx
|
|
4737
|
+
// src/components/toolbar/MRT_TablePagination.tsx
|
|
4755
4738
|
const defaultRowsPerPage = [
|
|
4756
4739
|
5,
|
|
4757
4740
|
10,
|
|
@@ -4818,7 +4801,7 @@ const MRT_TablePagination = ({ position = "bottom", table, ...rest }) => {
|
|
|
4818
4801
|
},
|
|
4819
4802
|
label: localization.rowsPerPage,
|
|
4820
4803
|
MenuProps: { disableScrollLock: true },
|
|
4821
|
-
onChange: (event) => table.setPageSize(
|
|
4804
|
+
onChange: (event) => table.setPageSize(Number(event.target.value)),
|
|
4822
4805
|
sx: { mb: 0 },
|
|
4823
4806
|
value: pageSize,
|
|
4824
4807
|
variant: "standard",
|
|
@@ -4913,8 +4896,7 @@ const MRT_TablePagination = ({ position = "bottom", table, ...rest }) => {
|
|
|
4913
4896
|
})] }) : null]
|
|
4914
4897
|
});
|
|
4915
4898
|
};
|
|
4916
|
-
|
|
4917
|
-
//#region src/components/toolbar/MRT_ToolbarDropZone.tsx
|
|
4899
|
+
// src/components/toolbar/MRT_ToolbarDropZone.tsx
|
|
4918
4900
|
const MRT_ToolbarDropZone = ({ table, ...rest }) => {
|
|
4919
4901
|
const { options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone } = table;
|
|
4920
4902
|
const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = table.state;
|
|
@@ -4924,12 +4906,18 @@ const MRT_ToolbarDropZone = ({ table, ...rest }) => {
|
|
|
4924
4906
|
const handleDragOver = (e) => {
|
|
4925
4907
|
e.preventDefault();
|
|
4926
4908
|
};
|
|
4909
|
+
const isShowToolbarDropZoneControlled = table.options.state?.showToolbarDropZone !== void 0;
|
|
4910
|
+
const setShowToolbarDropZoneRef = useRef(setShowToolbarDropZone);
|
|
4911
|
+
useEffect(() => {
|
|
4912
|
+
setShowToolbarDropZoneRef.current = setShowToolbarDropZone;
|
|
4913
|
+
});
|
|
4927
4914
|
useEffect(() => {
|
|
4928
|
-
if (
|
|
4915
|
+
if (isShowToolbarDropZoneControlled) setShowToolbarDropZoneRef.current(!!enableGrouping && !!draggingColumn && draggingColumn.columnDef.enableGrouping !== false && !grouping.includes(draggingColumn.id));
|
|
4929
4916
|
}, [
|
|
4930
|
-
enableGrouping,
|
|
4931
4917
|
draggingColumn,
|
|
4932
|
-
|
|
4918
|
+
enableGrouping,
|
|
4919
|
+
grouping,
|
|
4920
|
+
isShowToolbarDropZoneControlled
|
|
4933
4921
|
]);
|
|
4934
4922
|
return /* @__PURE__ */ jsx(Fade, {
|
|
4935
4923
|
in: showToolbarDropZone,
|
|
@@ -4959,8 +4947,7 @@ const MRT_ToolbarDropZone = ({ table, ...rest }) => {
|
|
|
4959
4947
|
})
|
|
4960
4948
|
});
|
|
4961
4949
|
};
|
|
4962
|
-
|
|
4963
|
-
//#region src/components/toolbar/MRT_BottomToolbar.tsx
|
|
4950
|
+
// src/components/toolbar/MRT_BottomToolbar.tsx
|
|
4964
4951
|
const MRT_BottomToolbar = ({ table, ...rest }) => {
|
|
4965
4952
|
const { options: { enablePagination, muiBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions }, refs: { bottomToolbarRef } } = table;
|
|
4966
4953
|
const { isFullScreen } = table.state;
|
|
@@ -4975,7 +4962,7 @@ const MRT_BottomToolbar = ({ table, ...rest }) => {
|
|
|
4975
4962
|
ref: (node) => {
|
|
4976
4963
|
if (node) {
|
|
4977
4964
|
bottomToolbarRef.current = node;
|
|
4978
|
-
if (toolbarProps?.ref) toolbarProps.ref.current = node;
|
|
4965
|
+
if (toolbarProps?.ref && typeof toolbarProps.ref === "object") toolbarProps.ref.current = node;
|
|
4979
4966
|
}
|
|
4980
4967
|
},
|
|
4981
4968
|
sx: (theme) => ({
|
|
@@ -5026,8 +5013,7 @@ const MRT_BottomToolbar = ({ table, ...rest }) => {
|
|
|
5026
5013
|
]
|
|
5027
5014
|
});
|
|
5028
5015
|
};
|
|
5029
|
-
|
|
5030
|
-
//#region src/components/toolbar/MRT_ToolbarInternalButtons.tsx
|
|
5016
|
+
// src/components/toolbar/MRT_ToolbarInternalButtons.tsx
|
|
5031
5017
|
const MRT_ToolbarInternalButtons = ({ table, ...rest }) => {
|
|
5032
5018
|
const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions } } = table;
|
|
5033
5019
|
return /* @__PURE__ */ jsx(Box, {
|
|
@@ -5047,8 +5033,7 @@ const MRT_ToolbarInternalButtons = ({ table, ...rest }) => {
|
|
|
5047
5033
|
] })
|
|
5048
5034
|
});
|
|
5049
5035
|
};
|
|
5050
|
-
|
|
5051
|
-
//#region src/components/toolbar/MRT_TopToolbar.tsx
|
|
5036
|
+
// src/components/toolbar/MRT_TopToolbar.tsx
|
|
5052
5037
|
const MRT_TopToolbar = ({ table }) => {
|
|
5053
5038
|
const { options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions }, refs: { topToolbarRef } } = table;
|
|
5054
5039
|
const { isFullScreen, showGlobalFilter } = table.state;
|
|
@@ -5064,7 +5049,7 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
5064
5049
|
...toolbarProps,
|
|
5065
5050
|
ref: (ref) => {
|
|
5066
5051
|
topToolbarRef.current = ref;
|
|
5067
|
-
if (toolbarProps?.ref) toolbarProps.ref.current = ref;
|
|
5052
|
+
if (toolbarProps?.ref && typeof toolbarProps.ref === "object") toolbarProps.ref.current = ref;
|
|
5068
5053
|
},
|
|
5069
5054
|
sx: (theme) => ({
|
|
5070
5055
|
...getCommonToolbarStyles({
|
|
@@ -5120,8 +5105,7 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
5120
5105
|
]
|
|
5121
5106
|
});
|
|
5122
5107
|
};
|
|
5123
|
-
|
|
5124
|
-
//#region src/components/menus/MRT_CellActionMenu.tsx
|
|
5108
|
+
// src/components/menus/MRT_CellActionMenu.tsx
|
|
5125
5109
|
const MRT_CellActionMenu = ({ table, ...rest }) => {
|
|
5126
5110
|
const { options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderCellActionMenuItems }, refs: { actionCellRef } } = table;
|
|
5127
5111
|
const { actionCell, density } = table.state;
|
|
@@ -5130,7 +5114,7 @@ const MRT_CellActionMenu = ({ table, ...rest }) => {
|
|
|
5130
5114
|
const { column } = cell;
|
|
5131
5115
|
const { columnDef } = column;
|
|
5132
5116
|
const handleClose = (event) => {
|
|
5133
|
-
event?.stopPropagation();
|
|
5117
|
+
event?.stopPropagation?.();
|
|
5134
5118
|
table.setActionCell(null);
|
|
5135
5119
|
actionCellRef.current = null;
|
|
5136
5120
|
};
|
|
@@ -5182,8 +5166,7 @@ const MRT_CellActionMenu = ({ table, ...rest }) => {
|
|
|
5182
5166
|
children: menuItems ?? internalMenuItems
|
|
5183
5167
|
});
|
|
5184
5168
|
};
|
|
5185
|
-
|
|
5186
|
-
//#region src/components/modals/MRT_EditRowModal.tsx
|
|
5169
|
+
// src/components/modals/MRT_EditRowModal.tsx
|
|
5187
5170
|
const MRT_EditRowModal = ({ open, table, ...rest }) => {
|
|
5188
5171
|
const { options: { localization, muiCreateRowModalProps, muiEditRowDialogProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowDialogContent, renderEditRowDialogContent }, setCreatingRow, setEditingRow } = table;
|
|
5189
5172
|
const { creatingRow, editingRow } = table.state;
|
|
@@ -5260,24 +5243,19 @@ const MRT_EditRowModal = ({ open, table, ...rest }) => {
|
|
|
5260
5243
|
] })
|
|
5261
5244
|
});
|
|
5262
5245
|
};
|
|
5263
|
-
|
|
5264
|
-
//#region src/hooks/useMRT_ColumnVirtualizer.ts
|
|
5246
|
+
// src/hooks/useMRT_ColumnVirtualizer.ts
|
|
5265
5247
|
const useMRT_ColumnVirtualizer = (table) => {
|
|
5266
5248
|
const { options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization }, refs: { tableContainerRef } } = table;
|
|
5267
|
-
const {
|
|
5268
|
-
|
|
5269
|
-
const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, { table });
|
|
5249
|
+
const { draggingColumn } = table.state;
|
|
5250
|
+
const columnVirtualizerProps = enableColumnVirtualization ? parseFromValuesOrFunc(columnVirtualizerOptions, { table }) : void 0;
|
|
5270
5251
|
const visibleColumns = table.getVisibleLeafColumns();
|
|
5271
|
-
const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnPinning ? [visibleColumns.filter((c) => c.getIsPinned() === "start").map((c) => c.getPinnedIndex()), visibleColumns.filter((c) => c.getIsPinned() === "end").map((column) => visibleColumns.length - column.getPinnedIndex() - 1).sort((a, b) => a - b)] : [[], []], [
|
|
5272
|
-
columnPinning,
|
|
5273
|
-
columnVisibility,
|
|
5274
|
-
enableColumnPinning
|
|
5275
|
-
]);
|
|
5252
|
+
const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnPinning ? [visibleColumns.filter((c) => c.getIsPinned() === "start").map((c) => c.getPinnedIndex()), visibleColumns.filter((c) => c.getIsPinned() === "end").map((column) => visibleColumns.length - column.getPinnedIndex() - 1).sort((a, b) => a - b)] : [[], []], [enableColumnPinning, visibleColumns]);
|
|
5276
5253
|
const numPinnedLeft = leftPinnedIndexes.length;
|
|
5277
5254
|
const numPinnedRight = rightPinnedIndexes.length;
|
|
5278
|
-
const draggingColumnIndex = useMemo(() => draggingColumn?.id ? visibleColumns.findIndex((c) => c.id === draggingColumn?.id) : void 0, [draggingColumn?.id]);
|
|
5255
|
+
const draggingColumnIndex = useMemo(() => draggingColumn?.id ? visibleColumns.findIndex((c) => c.id === draggingColumn?.id) : void 0, [draggingColumn?.id, visibleColumns]);
|
|
5279
5256
|
const columnVirtualizer = useVirtualizer({
|
|
5280
5257
|
count: visibleColumns.length,
|
|
5258
|
+
enabled: !!enableColumnVirtualization,
|
|
5281
5259
|
estimateSize: (index) => visibleColumns[index].getSize(),
|
|
5282
5260
|
getScrollElement: () => tableContainerRef.current,
|
|
5283
5261
|
horizontal: true,
|
|
@@ -5293,10 +5271,13 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
|
5293
5271
|
}, [
|
|
5294
5272
|
leftPinnedIndexes,
|
|
5295
5273
|
rightPinnedIndexes,
|
|
5296
|
-
draggingColumnIndex
|
|
5274
|
+
draggingColumnIndex,
|
|
5275
|
+
numPinnedLeft,
|
|
5276
|
+
numPinnedRight
|
|
5297
5277
|
]),
|
|
5298
5278
|
...columnVirtualizerProps
|
|
5299
5279
|
});
|
|
5280
|
+
if (!enableColumnVirtualization) return;
|
|
5300
5281
|
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
5301
5282
|
columnVirtualizer.virtualColumns = virtualColumns;
|
|
5302
5283
|
const numColumns = virtualColumns.length;
|
|
@@ -5312,32 +5293,23 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
|
5312
5293
|
if (columnVirtualizerInstanceRef) columnVirtualizerInstanceRef.current = columnVirtualizer;
|
|
5313
5294
|
return columnVirtualizer;
|
|
5314
5295
|
};
|
|
5315
|
-
|
|
5316
|
-
//#region src/components/table/MRT_Table.tsx
|
|
5296
|
+
// src/components/table/MRT_Table.tsx
|
|
5317
5297
|
const MRT_Table = ({ table, ...rest }) => {
|
|
5318
|
-
const { getFlatHeaders, options: {
|
|
5319
|
-
const { columnResizing,
|
|
5298
|
+
const { getFlatHeaders, options: { enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, renderCaption } } = table;
|
|
5299
|
+
const { columnResizing, isFullScreen } = table.state;
|
|
5320
5300
|
const tableProps = {
|
|
5321
5301
|
...parseFromValuesOrFunc(muiTableProps, { table }),
|
|
5322
5302
|
...rest
|
|
5323
5303
|
};
|
|
5324
5304
|
const Caption = parseFromValuesOrFunc(renderCaption, { table });
|
|
5325
|
-
const
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
}
|
|
5334
|
-
return colSizes;
|
|
5335
|
-
}, [
|
|
5336
|
-
columns,
|
|
5337
|
-
columnSizing,
|
|
5338
|
-
columnResizing,
|
|
5339
|
-
columnVisibility
|
|
5340
|
-
]);
|
|
5305
|
+
const headers = getFlatHeaders();
|
|
5306
|
+
const columnSizeVars = {};
|
|
5307
|
+
for (let i = 0; i < headers.length; i++) {
|
|
5308
|
+
const header = headers[i];
|
|
5309
|
+
const colSize = header.getSize();
|
|
5310
|
+
columnSizeVars[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
|
5311
|
+
columnSizeVars[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
|
5312
|
+
}
|
|
5341
5313
|
const commonTableGroupProps = {
|
|
5342
5314
|
columnVirtualizer: useMRT_ColumnVirtualizer(table),
|
|
5343
5315
|
table
|
|
@@ -5363,8 +5335,7 @@ const MRT_Table = ({ table, ...rest }) => {
|
|
|
5363
5335
|
]
|
|
5364
5336
|
});
|
|
5365
5337
|
};
|
|
5366
|
-
|
|
5367
|
-
//#region src/components/table/MRT_TableLoadingOverlay.tsx
|
|
5338
|
+
// src/components/table/MRT_TableLoadingOverlay.tsx
|
|
5368
5339
|
const MRT_TableLoadingOverlay = ({ table, ...rest }) => {
|
|
5369
5340
|
const { options: { id, localization, mrtTheme: { baseBackgroundColor }, muiCircularProgressProps } } = table;
|
|
5370
5341
|
const circularProgressProps = {
|
|
@@ -5393,11 +5364,10 @@ const MRT_TableLoadingOverlay = ({ table, ...rest }) => {
|
|
|
5393
5364
|
})
|
|
5394
5365
|
});
|
|
5395
5366
|
};
|
|
5396
|
-
|
|
5397
|
-
//#region src/components/table/MRT_TableContainer.tsx
|
|
5367
|
+
// src/components/table/MRT_TableContainer.tsx
|
|
5398
5368
|
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
5399
5369
|
const MRT_TableContainer = ({ table, ...rest }) => {
|
|
5400
|
-
const { options: { createDisplayMode, editDisplayMode, enableCellActions, enableStickyHeader, muiTableContainerProps }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef } } = table;
|
|
5370
|
+
const { options: { createDisplayMode, editDisplayMode, enableBottomToolbar, enableCellActions, enableStickyHeader, enableTopToolbar, muiTableContainerProps }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef } } = table;
|
|
5401
5371
|
const { actionCell, creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay } = table.state;
|
|
5402
5372
|
const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
|
|
5403
5373
|
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
|
@@ -5406,10 +5376,25 @@ const MRT_TableContainer = ({ table, ...rest }) => {
|
|
|
5406
5376
|
...rest
|
|
5407
5377
|
};
|
|
5408
5378
|
useIsomorphicLayoutEffect(() => {
|
|
5409
|
-
const
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5379
|
+
const measureToolbars = () => {
|
|
5380
|
+
setTotalToolbarHeight((topToolbarRef.current?.offsetHeight ?? 0) + (bottomToolbarRef.current?.offsetHeight ?? 0));
|
|
5381
|
+
};
|
|
5382
|
+
measureToolbars();
|
|
5383
|
+
if (typeof ResizeObserver === "undefined" || !tableContainerRef.current) return;
|
|
5384
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
5385
|
+
for (const toolbar of [topToolbarRef.current, bottomToolbarRef.current]) if (toolbar) resizeObserver.observe(toolbar);
|
|
5386
|
+
measureToolbars();
|
|
5387
|
+
});
|
|
5388
|
+
resizeObserver.observe(tableContainerRef.current);
|
|
5389
|
+
return () => resizeObserver.disconnect();
|
|
5390
|
+
}, [
|
|
5391
|
+
bottomToolbarRef,
|
|
5392
|
+
enableBottomToolbar,
|
|
5393
|
+
enableTopToolbar,
|
|
5394
|
+
isFullScreen,
|
|
5395
|
+
tableContainerRef,
|
|
5396
|
+
topToolbarRef
|
|
5397
|
+
]);
|
|
5413
5398
|
const createModalOpen = createDisplayMode === "modal" && creatingRow;
|
|
5414
5399
|
const editModalOpen = editDisplayMode === "modal" && editingRow;
|
|
5415
5400
|
return /* @__PURE__ */ jsxs(TableContainer, {
|
|
@@ -5419,7 +5404,7 @@ const MRT_TableContainer = ({ table, ...rest }) => {
|
|
|
5419
5404
|
ref: (node) => {
|
|
5420
5405
|
if (node) {
|
|
5421
5406
|
tableContainerRef.current = node;
|
|
5422
|
-
if (tableContainerProps?.ref) tableContainerProps.ref.current = node;
|
|
5407
|
+
if (tableContainerProps?.ref && typeof tableContainerProps.ref === "object") tableContainerProps.ref.current = node;
|
|
5423
5408
|
}
|
|
5424
5409
|
},
|
|
5425
5410
|
style: {
|
|
@@ -5444,8 +5429,7 @@ const MRT_TableContainer = ({ table, ...rest }) => {
|
|
|
5444
5429
|
]
|
|
5445
5430
|
});
|
|
5446
5431
|
};
|
|
5447
|
-
|
|
5448
|
-
//#region src/components/table/MRT_TablePaper.tsx
|
|
5432
|
+
// src/components/table/MRT_TablePaper.tsx
|
|
5449
5433
|
const MRT_TablePaper = ({ table, ...rest }) => {
|
|
5450
5434
|
const { options: { enableBottomToolbar, enableTopToolbar, mrtTheme: { baseBackgroundColor }, muiTablePaperProps, renderBottomToolbar, renderTopToolbar }, refs: { tablePaperRef } } = table;
|
|
5451
5435
|
const { isFullScreen } = table.state;
|
|
@@ -5460,7 +5444,7 @@ const MRT_TablePaper = ({ table, ...rest }) => {
|
|
|
5460
5444
|
...paperProps,
|
|
5461
5445
|
ref: (ref) => {
|
|
5462
5446
|
tablePaperRef.current = ref;
|
|
5463
|
-
if (paperProps?.ref) paperProps.ref.current = ref;
|
|
5447
|
+
if (paperProps?.ref && typeof paperProps.ref === "object") paperProps.ref.current = ref;
|
|
5464
5448
|
},
|
|
5465
5449
|
style: {
|
|
5466
5450
|
...isFullScreen ? {
|
|
@@ -5493,16 +5477,13 @@ const MRT_TablePaper = ({ table, ...rest }) => {
|
|
|
5493
5477
|
]
|
|
5494
5478
|
});
|
|
5495
5479
|
};
|
|
5496
|
-
|
|
5497
|
-
//#region src/components/MaterialReactTable.tsx
|
|
5480
|
+
// src/components/MaterialReactTable.tsx
|
|
5498
5481
|
const isTableInstanceProp = (props) => props.table !== void 0;
|
|
5499
|
-
const
|
|
5500
|
-
|
|
5501
|
-
if (isTableInstanceProp(props)) table = props.table;
|
|
5502
|
-
else table = useMaterialReactTable(props);
|
|
5482
|
+
const MRT_TableFromOptions = ({ tableOptions }) => {
|
|
5483
|
+
const table = useMaterialReactTable(tableOptions);
|
|
5503
5484
|
return /* @__PURE__ */ jsx(MRT_TablePaper, { table });
|
|
5504
5485
|
};
|
|
5505
|
-
|
|
5506
|
-
export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, cellKeyboardShortcuts, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getSubColumnDefs, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
|
5486
|
+
const MaterialReactTable = (props) => isTableInstanceProp(props) ? /* @__PURE__ */ jsx(MRT_TablePaper, { table: props.table }) : /* @__PURE__ */ jsx(MRT_TableFromOptions, { tableOptions: props });
|
|
5487
|
+
export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, cellKeyboardShortcuts, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getFilterOptionLabel, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getSubColumnDefs, getTrailingDisplayColumnIds, isCellEditable, moveColumn, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
|
5507
5488
|
|
|
5508
5489
|
//# sourceMappingURL=index.js.map
|