material-react-table 0.36.2 → 0.37.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 -0
- package/dist/cjs/MaterialReactTable.d.ts +32 -14
- package/dist/cjs/index.js +119 -79
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +32 -14
- package/dist/esm/material-react-table.esm.js +119 -79
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +32 -14
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +47 -11
- package/src/body/MRT_EditRowModal.tsx +21 -19
- package/src/body/MRT_TableBodyCell.tsx +8 -10
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +3 -2
- package/src/buttons/MRT_CopyButton.tsx +2 -2
- package/src/buttons/MRT_EditActionButtons.tsx +13 -4
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -16
- package/src/column.utils.ts +2 -3
- package/src/inputs/MRT_EditCellTextField.tsx +16 -5
- package/src/inputs/MRT_FilterTextField.tsx +9 -6
- package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +2 -12
- package/src/table/MRT_TableContainer.tsx +10 -10
- package/src/table/MRT_TableRoot.tsx +22 -18
- package/src/toolbar/MRT_BottomToolbar.tsx +8 -2
- package/src/toolbar/MRT_TopToolbar.tsx +8 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, DragEvent, ReactNode, SetStateAction } from 'react';
|
|
1
|
+
import { Dispatch, DragEvent, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
2
2
|
import type { AlertProps, ButtonProps, CheckboxProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
3
3
|
import type { Cell, Column, ColumnDef, DeepKeys, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
|
|
4
4
|
import type { Options as VirtualizerOptions } from 'react-virtual';
|
|
@@ -32,9 +32,16 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
|
|
|
32
32
|
getState: () => MRT_TableState<TData>;
|
|
33
33
|
options: MaterialReactTableProps<TData> & {
|
|
34
34
|
icons: MRT_Icons;
|
|
35
|
-
tableId: string;
|
|
36
35
|
localization: MRT_Localization;
|
|
37
36
|
};
|
|
37
|
+
refs: {
|
|
38
|
+
bottomToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
39
|
+
editInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
40
|
+
filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
41
|
+
searchInputRef: MutableRefObject<HTMLInputElement>;
|
|
42
|
+
tableContainerRef: MutableRefObject<HTMLDivElement>;
|
|
43
|
+
topToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
44
|
+
};
|
|
38
45
|
setColumnFilterFns: Dispatch<SetStateAction<{
|
|
39
46
|
[key: string]: MRT_FilterOption;
|
|
40
47
|
}>>;
|
|
@@ -78,19 +85,22 @@ export declare type MRT_TableState<TData extends Record<string, any> = {}> = Tab
|
|
|
78
85
|
showSkeletons: boolean;
|
|
79
86
|
};
|
|
80
87
|
export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<ColumnDef<TData, unknown>, 'aggregatedCell' | 'cell' | 'columns' | 'filterFn' | 'footer' | 'header' | 'id' | 'sortingFn'> & {
|
|
81
|
-
AggregatedCell?: ({ cell, column, table, }: {
|
|
88
|
+
AggregatedCell?: ({ cell, column, row, table, }: {
|
|
82
89
|
cell: MRT_Cell<TData>;
|
|
83
90
|
column: MRT_Column<TData>;
|
|
91
|
+
row: MRT_Row<TData>;
|
|
84
92
|
table: MRT_TableInstance<TData>;
|
|
85
93
|
}) => ReactNode;
|
|
86
|
-
Cell?: ({ cell, column, table, }: {
|
|
94
|
+
Cell?: ({ cell, column, row, table, }: {
|
|
87
95
|
cell: MRT_Cell<TData>;
|
|
88
96
|
column: MRT_Column<TData>;
|
|
97
|
+
row: MRT_Row<TData>;
|
|
89
98
|
table: MRT_TableInstance<TData>;
|
|
90
99
|
}) => ReactNode;
|
|
91
|
-
Edit?: ({ cell, column, table, }: {
|
|
100
|
+
Edit?: ({ cell, column, row, table, }: {
|
|
92
101
|
cell: MRT_Cell<TData>;
|
|
93
102
|
column: MRT_Column<TData>;
|
|
103
|
+
row: MRT_Row<TData>;
|
|
94
104
|
table: MRT_TableInstance<TData>;
|
|
95
105
|
}) => ReactNode;
|
|
96
106
|
Filter?: ({ column, header, table, }: {
|
|
@@ -169,8 +179,10 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
169
179
|
table: MRT_TableInstance<TData>;
|
|
170
180
|
cell: MRT_Cell<TData>;
|
|
171
181
|
}) => ButtonProps);
|
|
172
|
-
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, table, }: {
|
|
182
|
+
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
|
|
173
183
|
cell: MRT_Cell<TData>;
|
|
184
|
+
column: MRT_Column<TData>;
|
|
185
|
+
row: MRT_Row<TData>;
|
|
174
186
|
table: MRT_TableInstance<TData>;
|
|
175
187
|
}) => TextFieldProps);
|
|
176
188
|
muiTableBodyCellProps?: TableCellProps | (({ cell, table, }: {
|
|
@@ -231,7 +243,7 @@ export declare type MRT_SortingOption = LiteralUnion<string & keyof typeof MRT_S
|
|
|
231
243
|
export declare type MRT_SortingFn<TData extends Record<string, any> = {}> = SortingFn<TData> | MRT_SortingOption;
|
|
232
244
|
export declare type MRT_FilterOption = LiteralUnion<string & keyof typeof MRT_FilterFns>;
|
|
233
245
|
export declare type MRT_FilterFn<TData extends Record<string, any> = {}> = FilterFn<TData> | MRT_FilterOption;
|
|
234
|
-
export declare type MRT_DisplayColumnIds = 'mrt-row-
|
|
246
|
+
export declare type MRT_DisplayColumnIds = 'mrt-row-actions' | 'mrt-row-drag' | 'mrt-row-expand' | 'mrt-row-numbers' | 'mrt-row-select';
|
|
235
247
|
/**
|
|
236
248
|
* `columns` and `data` props are the only required props, but there are over 150 other optional props.
|
|
237
249
|
*
|
|
@@ -301,17 +313,23 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
301
313
|
table: MRT_TableInstance<TData>;
|
|
302
314
|
row: MRT_Row<TData>;
|
|
303
315
|
}) => CheckboxProps);
|
|
304
|
-
muiTableBodyCellCopyButtonProps?: ButtonProps | (({
|
|
305
|
-
table: MRT_TableInstance<TData>;
|
|
316
|
+
muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, column, row, table, }: {
|
|
306
317
|
cell: MRT_Cell<TData>;
|
|
318
|
+
column: MRT_Column<TData>;
|
|
319
|
+
row: MRT_Row<TData>;
|
|
320
|
+
table: MRT_TableInstance<TData>;
|
|
307
321
|
}) => ButtonProps);
|
|
308
|
-
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, table, }: {
|
|
322
|
+
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
|
|
309
323
|
cell: MRT_Cell<TData>;
|
|
324
|
+
column: MRT_Column<TData>;
|
|
325
|
+
row: MRT_Row<TData>;
|
|
310
326
|
table: MRT_TableInstance<TData>;
|
|
311
327
|
}) => TextFieldProps);
|
|
312
|
-
muiTableBodyCellProps?: TableCellProps | (({
|
|
313
|
-
table: MRT_TableInstance<TData>;
|
|
328
|
+
muiTableBodyCellProps?: TableCellProps | (({ cell, column, row, table, }: {
|
|
314
329
|
cell: MRT_Cell<TData>;
|
|
330
|
+
column: MRT_Column<TData>;
|
|
331
|
+
row: MRT_Row<TData>;
|
|
332
|
+
table: MRT_TableInstance<TData>;
|
|
315
333
|
}) => TableCellProps);
|
|
316
334
|
muiTableBodyCellSkeletonProps?: SkeletonProps | (({ table, cell, }: {
|
|
317
335
|
table: MRT_TableInstance<TData>;
|
|
@@ -398,7 +416,8 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
398
416
|
onDensityChange?: OnChangeFn<boolean>;
|
|
399
417
|
onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
400
418
|
onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
401
|
-
onEditingRowSave?: ({ row, table, values, }: {
|
|
419
|
+
onEditingRowSave?: ({ exitEditingMode, row, table, values, }: {
|
|
420
|
+
exitEditingMode: () => void;
|
|
402
421
|
row: MRT_Row<TData>;
|
|
403
422
|
table: MRT_TableInstance<TData>;
|
|
404
423
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
|
@@ -454,7 +473,6 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
454
473
|
rowNumberMode?: 'original' | 'static';
|
|
455
474
|
selectAllMode?: 'all' | 'page';
|
|
456
475
|
state?: Partial<MRT_TableState<TData>>;
|
|
457
|
-
tableId?: string;
|
|
458
476
|
virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement>> | (({ table, }: {
|
|
459
477
|
table: MRT_TableInstance<TData>;
|
|
460
478
|
}) => Partial<VirtualizerOptions<HTMLDivElement>>);
|
|
@@ -500,10 +500,9 @@ const prepareColumns = (columnDefs, columnFilterFns, filterFns, sortingFns) => c
|
|
|
500
500
|
else if (columnDef.columnDefType === 'data') {
|
|
501
501
|
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
502
502
|
columnDef.filterFn =
|
|
503
|
-
// @ts-ignore
|
|
504
503
|
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
505
|
-
|
|
506
|
-
|
|
504
|
+
columnDef._filterFn =
|
|
505
|
+
columnFilterFns[columnDef.id];
|
|
507
506
|
}
|
|
508
507
|
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
509
508
|
// @ts-ignore
|
|
@@ -704,7 +703,7 @@ const commonListItemStyles = {
|
|
|
704
703
|
};
|
|
705
704
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
706
705
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
707
|
-
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { enableColumnFilterChangeMode, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, columnFilterModeOptions, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, },
|
|
706
|
+
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { enableColumnFilterChangeMode, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, columnFilterModeOptions, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, }, localization, }, refs: { filterInputRefs }, setShowFilters, } = table;
|
|
708
707
|
const { column } = header;
|
|
709
708
|
const { columnDef } = column;
|
|
710
709
|
const { columnSizing, columnVisibility, density } = getState();
|
|
@@ -745,13 +744,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
745
744
|
};
|
|
746
745
|
const handleFilterByColumn = () => {
|
|
747
746
|
setShowFilters(true);
|
|
748
|
-
|
|
749
|
-
var _a, _b, _c;
|
|
750
|
-
return (_c = document
|
|
751
|
-
.getElementById(
|
|
752
|
-
// @ts-ignore
|
|
753
|
-
(_b = (_a = header.muiTableHeadCellFilterTextFieldProps) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : `mrt-${tableId}-${header.id}-filter-text-field`)) === null || _c === void 0 ? void 0 : _c.focus();
|
|
754
|
-
}, 200);
|
|
747
|
+
queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
755
748
|
setAnchorEl(null);
|
|
756
749
|
};
|
|
757
750
|
const handleShowAllColumns = () => {
|
|
@@ -882,19 +875,25 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
|
|
|
882
875
|
};
|
|
883
876
|
|
|
884
877
|
const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
|
885
|
-
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, setEditingRow, } = table;
|
|
878
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, refs: { editInputRefs }, setEditingRow, } = table;
|
|
886
879
|
const { editingRow } = getState();
|
|
887
|
-
const handleCancel = () =>
|
|
888
|
-
setEditingRow(null);
|
|
889
|
-
};
|
|
880
|
+
const handleCancel = () => setEditingRow(null);
|
|
890
881
|
const handleSave = () => {
|
|
891
|
-
var _a;
|
|
882
|
+
var _a, _b;
|
|
883
|
+
//look for auto-filled input values
|
|
884
|
+
(_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
|
|
885
|
+
if (input.value !== undefined &&
|
|
886
|
+
Object.hasOwn(editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache, input.name)) {
|
|
887
|
+
// @ts-ignore
|
|
888
|
+
editingRow._valuesCache[input.name] = input.value;
|
|
889
|
+
}
|
|
890
|
+
});
|
|
892
891
|
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
892
|
+
exitEditingMode: () => setEditingRow(null),
|
|
893
893
|
row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
|
|
894
894
|
table,
|
|
895
|
-
values: (
|
|
895
|
+
values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
|
|
896
896
|
});
|
|
897
|
-
setEditingRow(null);
|
|
898
897
|
};
|
|
899
898
|
return (React.createElement(Box, { sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React.createElement(React.Fragment, null,
|
|
900
899
|
React.createElement(Tooltip, { arrow: true, title: localization.cancel },
|
|
@@ -965,7 +964,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
965
964
|
|
|
966
965
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
967
966
|
var _a;
|
|
968
|
-
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps,
|
|
967
|
+
const { getState, setGlobalFilter, options: { enableGlobalFilterChangeMode, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
969
968
|
const { globalFilter, showGlobalFilter } = getState();
|
|
970
969
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
971
970
|
const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
|
@@ -988,7 +987,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
988
987
|
? muiSearchTextFieldProps({ table })
|
|
989
988
|
: muiSearchTextFieldProps;
|
|
990
989
|
return (React.createElement(Collapse, { in: showGlobalFilter, orientation: "horizontal" },
|
|
991
|
-
React.createElement(TextField, Object.assign({
|
|
990
|
+
React.createElement(TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
|
|
992
991
|
startAdornment: enableGlobalFilterChangeMode ? (React.createElement(InputAdornment, { position: "start" },
|
|
993
992
|
React.createElement(Tooltip, { arrow: true, title: localization.changeSearchMode },
|
|
994
993
|
React.createElement(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' } },
|
|
@@ -998,7 +997,12 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
998
997
|
React.createElement("span", null,
|
|
999
998
|
React.createElement(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small" },
|
|
1000
999
|
React.createElement(CloseIcon, null)))))),
|
|
1001
|
-
} }, textFieldProps)
|
|
1000
|
+
} }, textFieldProps, { inputRef: (inputRef) => {
|
|
1001
|
+
searchInputRef.current = inputRef;
|
|
1002
|
+
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
|
|
1003
|
+
textFieldProps.inputRef = inputRef;
|
|
1004
|
+
}
|
|
1005
|
+
} })),
|
|
1002
1006
|
React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1003
1007
|
};
|
|
1004
1008
|
|
|
@@ -1123,18 +1127,11 @@ const MRT_ToggleFiltersButton = (_a) => {
|
|
|
1123
1127
|
|
|
1124
1128
|
const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
1125
1129
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1126
|
-
const { getState, options: { icons: { SearchIcon, SearchOffIcon },
|
|
1130
|
+
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1127
1131
|
const { showGlobalFilter } = getState();
|
|
1128
|
-
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1129
|
-
? muiSearchTextFieldProps({ table })
|
|
1130
|
-
: muiSearchTextFieldProps;
|
|
1131
1132
|
const handleToggleSearch = () => {
|
|
1132
1133
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1133
|
-
|
|
1134
|
-
var _a, _b;
|
|
1135
|
-
return (_b = document
|
|
1136
|
-
.getElementById((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.id) !== null && _a !== void 0 ? _a : `mrt-${tableId}-search-text-field`)) === null || _b === void 0 ? void 0 : _b.focus();
|
|
1137
|
-
}, 200);
|
|
1134
|
+
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1138
1135
|
};
|
|
1139
1136
|
return (React.createElement(Tooltip, { arrow: true, title: localization.showHideSearch },
|
|
1140
1137
|
React.createElement(IconButton, Object.assign({ onClick: handleToggleSearch }, rest), showGlobalFilter ? React.createElement(SearchOffIcon, null) : React.createElement(SearchIcon, null))));
|
|
@@ -1193,14 +1190,20 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1193
1190
|
});
|
|
1194
1191
|
const MRT_TopToolbar = ({ table }) => {
|
|
1195
1192
|
var _a;
|
|
1196
|
-
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions,
|
|
1193
|
+
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTableTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
|
1197
1194
|
const { isFullScreen, showGlobalFilter } = getState();
|
|
1198
1195
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
1199
1196
|
const toolbarProps = muiTableTopToolbarProps instanceof Function
|
|
1200
1197
|
? muiTableTopToolbarProps({ table })
|
|
1201
1198
|
: muiTableTopToolbarProps;
|
|
1202
1199
|
const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
|
1203
|
-
return (React.createElement(Toolbar, Object.assign({
|
|
1200
|
+
return (React.createElement(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1201
|
+
topToolbarRef.current = ref;
|
|
1202
|
+
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
|
1203
|
+
// @ts-ignore
|
|
1204
|
+
toolbarProps.ref.current = ref;
|
|
1205
|
+
}
|
|
1206
|
+
}, sx: (theme) => (Object.assign(Object.assign({ position: isFullScreen ? 'sticky' : undefined, top: isFullScreen ? '0' : undefined }, commonToolbarStyles({ theme })), ((toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx) instanceof Function
|
|
1204
1207
|
? toolbarProps.sx(theme)
|
|
1205
1208
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1206
1209
|
positionToolbarAlertBanner === 'top' && (React.createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
@@ -1225,14 +1228,20 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1225
1228
|
};
|
|
1226
1229
|
|
|
1227
1230
|
const MRT_BottomToolbar = ({ table }) => {
|
|
1228
|
-
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions,
|
|
1231
|
+
const { getState, options: { enablePagination, muiTableBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
|
|
1229
1232
|
const { isFullScreen } = getState();
|
|
1230
1233
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
1231
1234
|
const toolbarProps = muiTableBottomToolbarProps instanceof Function
|
|
1232
1235
|
? muiTableBottomToolbarProps({ table })
|
|
1233
1236
|
: muiTableBottomToolbarProps;
|
|
1234
1237
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
1235
|
-
return (React.createElement(Toolbar, Object.assign({
|
|
1238
|
+
return (React.createElement(Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1239
|
+
bottomToolbarRef.current = ref;
|
|
1240
|
+
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
|
1241
|
+
// @ts-ignore
|
|
1242
|
+
toolbarProps.ref.current = ref;
|
|
1243
|
+
}
|
|
1244
|
+
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `-3px 0 6px ${alpha(theme.palette.common.black, 0.1)}`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), ((toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx) instanceof Function
|
|
1236
1245
|
? toolbarProps.sx(theme)
|
|
1237
1246
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1238
1247
|
React.createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
@@ -1287,7 +1296,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1287
1296
|
|
|
1288
1297
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1289
1298
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1290
|
-
const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps,
|
|
1299
|
+
const { getState, options: { enableColumnFilterChangeMode, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
|
1291
1300
|
const { column } = header;
|
|
1292
1301
|
const { columnDef } = column;
|
|
1293
1302
|
const { columnFilterFns } = getState();
|
|
@@ -1312,7 +1321,6 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1312
1321
|
const isTextboxFilter = columnDef.filterVariant === 'text' ||
|
|
1313
1322
|
(!isSelectFilter && !isMultiSelectFilter);
|
|
1314
1323
|
const currentFilterOption = columnFilterFns === null || columnFilterFns === void 0 ? void 0 : columnFilterFns[header.id];
|
|
1315
|
-
const filterId = `mrt-${tableId}-${header.id}-filter-text-field${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : ''}`;
|
|
1316
1324
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
|
1317
1325
|
? //@ts-ignore
|
|
1318
1326
|
localization[`filter${((_b = (_a = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt) === null || _a === void 0 ? void 0 : _a.call(currentFilterOption, 0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
|
@@ -1389,14 +1397,14 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1389
1397
|
return React.createElement(React.Fragment, null, (_e = columnDef.Filter) === null || _e === void 0 ? void 0 : _e.call(columnDef, { column, header, table }));
|
|
1390
1398
|
}
|
|
1391
1399
|
return (React.createElement(React.Fragment, null,
|
|
1392
|
-
React.createElement(TextField, Object.assign({ fullWidth: true,
|
|
1400
|
+
React.createElement(TextField, Object.assign({ fullWidth: true, inputProps: {
|
|
1393
1401
|
disabled: !!filterChipLabel,
|
|
1394
1402
|
sx: {
|
|
1395
1403
|
textOverflow: 'ellipsis',
|
|
1396
1404
|
width: filterChipLabel ? 0 : undefined,
|
|
1397
1405
|
},
|
|
1398
1406
|
title: filterPlaceholder,
|
|
1399
|
-
}, helperText: showChangeModeButton ? (React.createElement("label",
|
|
1407
|
+
}, helperText: showChangeModeButton ? (React.createElement("label", null, localization.filterMode.replace('{filterType}',
|
|
1400
1408
|
// @ts-ignore
|
|
1401
1409
|
localization[`filter${((_f = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _f === void 0 ? void 0 : _f.toUpperCase()) +
|
|
1402
1410
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
|
|
@@ -1428,7 +1436,13 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1428
1436
|
renderValue: isMultiSelectFilter
|
|
1429
1437
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (React.createElement(Box, { sx: { opacity: 0.5 } }, filterPlaceholder)) : (React.createElement(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' } }, selected === null || selected === void 0 ? void 0 : selected.map((value) => (React.createElement(Chip, { key: value, label: value })))))
|
|
1430
1438
|
: undefined,
|
|
1431
|
-
} }, textFieldProps, {
|
|
1439
|
+
} }, textFieldProps, { inputRef: (inputRef) => {
|
|
1440
|
+
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
|
1441
|
+
inputRef;
|
|
1442
|
+
if (textFieldProps.inputRef) {
|
|
1443
|
+
textFieldProps.inputRef = inputRef;
|
|
1444
|
+
}
|
|
1445
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '6rem' : 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1432
1446
|
mr: '1.5rem',
|
|
1433
1447
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1434
1448
|
? textFieldProps.sx(theme)
|
|
@@ -1742,17 +1756,19 @@ const MRT_TableHead = ({ table }) => {
|
|
|
1742
1756
|
|
|
1743
1757
|
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
1744
1758
|
var _a;
|
|
1745
|
-
const { getState, options: {
|
|
1746
|
-
const { column } = cell;
|
|
1759
|
+
const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
|
|
1760
|
+
const { column, row } = cell;
|
|
1747
1761
|
const { columnDef } = column;
|
|
1748
1762
|
const { editingRow } = getState();
|
|
1749
1763
|
const [value, setValue] = useState(() => cell.getValue());
|
|
1750
1764
|
const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1751
|
-
? muiTableBodyCellEditTextFieldProps({ cell, table })
|
|
1765
|
+
? muiTableBodyCellEditTextFieldProps({ cell, column, row, table })
|
|
1752
1766
|
: muiTableBodyCellEditTextFieldProps;
|
|
1753
1767
|
const mcTableBodyCellEditTextFieldProps = columnDef.muiTableBodyCellEditTextFieldProps instanceof Function
|
|
1754
1768
|
? columnDef.muiTableBodyCellEditTextFieldProps({
|
|
1755
1769
|
cell,
|
|
1770
|
+
column,
|
|
1771
|
+
row,
|
|
1756
1772
|
table,
|
|
1757
1773
|
})
|
|
1758
1774
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
@@ -1771,14 +1787,21 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1771
1787
|
setEditingCell(null);
|
|
1772
1788
|
};
|
|
1773
1789
|
if (columnDef.Edit) {
|
|
1774
|
-
return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table }));
|
|
1790
|
+
return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
|
|
1775
1791
|
}
|
|
1776
|
-
return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true,
|
|
1792
|
+
return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: cell.id, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
|
|
1793
|
+
if (inputRef) {
|
|
1794
|
+
editInputRefs.current[column.id] = inputRef;
|
|
1795
|
+
if (textFieldProps.inputRef) {
|
|
1796
|
+
textFieldProps.inputRef = inputRef;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1777
1800
|
};
|
|
1778
1801
|
|
|
1779
1802
|
const MRT_CopyButton = ({ cell, children, table }) => {
|
|
1780
1803
|
const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
|
|
1781
|
-
const { column } = cell;
|
|
1804
|
+
const { column, row } = cell;
|
|
1782
1805
|
const { columnDef } = column;
|
|
1783
1806
|
const [copied, setCopied] = useState(false);
|
|
1784
1807
|
const handleCopy = (text) => {
|
|
@@ -1787,7 +1810,7 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1787
1810
|
setTimeout(() => setCopied(false), 4000);
|
|
1788
1811
|
};
|
|
1789
1812
|
const mTableBodyCellCopyButtonProps = muiTableBodyCellCopyButtonProps instanceof Function
|
|
1790
|
-
? muiTableBodyCellCopyButtonProps({ cell, table })
|
|
1813
|
+
? muiTableBodyCellCopyButtonProps({ cell, column, row, table })
|
|
1791
1814
|
: muiTableBodyCellCopyButtonProps;
|
|
1792
1815
|
const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
|
|
1793
1816
|
? columnDef.muiTableBodyCellCopyButtonProps({
|
|
@@ -1804,12 +1827,13 @@ const MRT_CopyButton = ({ cell, children, table }) => {
|
|
|
1804
1827
|
|
|
1805
1828
|
const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
1806
1829
|
const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
|
|
1830
|
+
const { row } = cell;
|
|
1807
1831
|
const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
|
|
1808
|
-
? muiTableBodyRowDragHandleProps({ row
|
|
1832
|
+
? muiTableBodyRowDragHandleProps({ row, table })
|
|
1809
1833
|
: muiTableBodyRowDragHandleProps;
|
|
1810
1834
|
const handleDragStart = (e) => {
|
|
1811
1835
|
e.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1812
|
-
table.setDraggingRow(
|
|
1836
|
+
table.setDraggingRow(row);
|
|
1813
1837
|
};
|
|
1814
1838
|
const handleDragEnd = (event) => {
|
|
1815
1839
|
onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
|
|
@@ -1826,13 +1850,13 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1826
1850
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1827
1851
|
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
1828
1852
|
const theme = useTheme();
|
|
1829
|
-
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode,
|
|
1853
|
+
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
|
1830
1854
|
const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
|
|
1831
1855
|
const { column, row } = cell;
|
|
1832
1856
|
const { columnDef } = column;
|
|
1833
1857
|
const { columnDefType } = columnDef;
|
|
1834
1858
|
const mTableCellBodyProps = muiTableBodyCellProps instanceof Function
|
|
1835
|
-
? muiTableBodyCellProps({ cell, table })
|
|
1859
|
+
? muiTableBodyCellProps({ cell, column, row, table })
|
|
1836
1860
|
: muiTableBodyCellProps;
|
|
1837
1861
|
const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
|
|
1838
1862
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
@@ -1857,13 +1881,13 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1857
1881
|
columnDef.enableEditing !== false &&
|
|
1858
1882
|
editingMode === 'cell') {
|
|
1859
1883
|
setEditingCell(cell);
|
|
1860
|
-
|
|
1861
|
-
const textField =
|
|
1884
|
+
queueMicrotask(() => {
|
|
1885
|
+
const textField = editInputRefs.current[column.id];
|
|
1862
1886
|
if (textField) {
|
|
1863
1887
|
textField.focus();
|
|
1864
1888
|
textField.select();
|
|
1865
1889
|
}
|
|
1866
|
-
}
|
|
1890
|
+
});
|
|
1867
1891
|
}
|
|
1868
1892
|
};
|
|
1869
1893
|
const getIsLastLeftPinnedColumn = () => {
|
|
@@ -1953,19 +1977,19 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1953
1977
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
|
1954
1978
|
(column.id === 'mrt-row-select' ||
|
|
1955
1979
|
column.id === 'mrt-row-expand' ||
|
|
1956
|
-
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table })) : isEditing ? (React.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
1980
|
+
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) : isEditing ? (React.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
1957
1981
|
columnDef.enableClickToCopy !== false ? (React.createElement(React.Fragment, null,
|
|
1958
1982
|
React.createElement(MRT_CopyButton, { cell: cell, table: table },
|
|
1959
1983
|
React.createElement(React.Fragment, null, row.getIsGrouped() && !cell.getIsGrouped()
|
|
1960
1984
|
? null
|
|
1961
|
-
: (_c = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, table })) !== null && _c !== void 0 ? _c : cell.renderValue())),
|
|
1985
|
+
: (_c = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table })) !== null && _c !== void 0 ? _c : cell.renderValue())),
|
|
1962
1986
|
cell.getIsGrouped() && React.createElement(React.Fragment, null,
|
|
1963
1987
|
" (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
|
|
1964
1988
|
_d.length,
|
|
1965
1989
|
")"))) : (React.createElement(React.Fragment, null,
|
|
1966
1990
|
row.getIsGrouped() && !cell.getIsGrouped()
|
|
1967
1991
|
? null
|
|
1968
|
-
: (_g = (_f = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _f === void 0 ? void 0 : _f.call(columnDef, { cell, column, table })) !== null && _g !== void 0 ? _g : cell.renderValue(),
|
|
1992
|
+
: (_g = (_f = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _f === void 0 ? void 0 : _f.call(columnDef, { cell, column, row, table })) !== null && _g !== void 0 ? _g : cell.renderValue(),
|
|
1969
1993
|
cell.getIsGrouped() && React.createElement(React.Fragment, null,
|
|
1970
1994
|
" (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
|
|
1971
1995
|
")"))))));
|
|
@@ -2018,7 +2042,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
|
2018
2042
|
: undefined,
|
|
2019
2043
|
} }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
2020
2044
|
? tableRowProps.sx(theme)
|
|
2021
|
-
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => (React.createElement(MRT_TableBodyCell, { cell: cell,
|
|
2045
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }), (_b = (_a = row === null || row === void 0 ? void 0 : row.getVisibleCells()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (cell) => (React.createElement(MRT_TableBodyCell, { cell: cell, enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false, key: cell.id, rowIndex: rowIndex, rowRef: rowRef, table: table })))),
|
|
2022
2046
|
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2023
2047
|
};
|
|
2024
2048
|
|
|
@@ -2166,25 +2190,29 @@ const MRT_Table = ({ tableContainerRef, table }) => {
|
|
|
2166
2190
|
|
|
2167
2191
|
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
2168
2192
|
const MRT_TableContainer = ({ table }) => {
|
|
2169
|
-
|
|
2170
|
-
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, tableId, }, } = table;
|
|
2193
|
+
const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
|
|
2171
2194
|
const { isFullScreen } = getState();
|
|
2172
2195
|
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
|
2173
2196
|
const tableContainerProps = muiTableContainerProps instanceof Function
|
|
2174
2197
|
? muiTableContainerProps({ table })
|
|
2175
2198
|
: muiTableContainerProps;
|
|
2176
|
-
const tableContainerRef = (_a = tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) !== null && _a !== void 0 ? _a : useRef(null);
|
|
2177
2199
|
useIsomorphicLayoutEffect(() => {
|
|
2178
2200
|
var _a, _b, _c, _d;
|
|
2179
2201
|
const topToolbarHeight = typeof document !== 'undefined'
|
|
2180
|
-
? (_b = (_a =
|
|
2202
|
+
? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
|
|
2181
2203
|
: 0;
|
|
2182
2204
|
const bottomToolbarHeight = typeof document !== 'undefined'
|
|
2183
|
-
? (_d = (_c =
|
|
2205
|
+
? (_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0
|
|
2184
2206
|
: 0;
|
|
2185
2207
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
|
2186
2208
|
});
|
|
2187
|
-
return (React.createElement(TableContainer, Object.assign({
|
|
2209
|
+
return (React.createElement(TableContainer, Object.assign({}, tableContainerProps, { ref: (ref) => {
|
|
2210
|
+
tableContainerRef.current = ref;
|
|
2211
|
+
if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
|
|
2212
|
+
//@ts-ignore
|
|
2213
|
+
tableContainerProps.ref.current = ref;
|
|
2214
|
+
}
|
|
2215
|
+
}, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
|
|
2188
2216
|
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
|
2189
2217
|
: undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
|
|
2190
2218
|
? tableContainerProps.sx(theme)
|
|
@@ -2221,22 +2249,27 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
|
2221
2249
|
return (React.createElement(Dialog, { open: open },
|
|
2222
2250
|
React.createElement(DialogTitle, { textAlign: "center" }, localization.edit),
|
|
2223
2251
|
React.createElement(DialogContent, null,
|
|
2224
|
-
React.createElement(
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2252
|
+
React.createElement("form", { onSubmit: (e) => e.preventDefault() },
|
|
2253
|
+
React.createElement(Stack, { sx: {
|
|
2254
|
+
width: '100%',
|
|
2255
|
+
minWidth: { xs: '300px', sm: '360px', md: '400px' },
|
|
2256
|
+
gap: '1.5rem',
|
|
2257
|
+
} }, row
|
|
2258
|
+
.getAllCells()
|
|
2259
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
2260
|
+
.map((cell) => (React.createElement(MRT_EditCellTextField, { cell: cell, key: cell.id, showLabel: true, table: table })))))),
|
|
2232
2261
|
React.createElement(DialogActions, { sx: { p: '1.25rem' } },
|
|
2233
2262
|
React.createElement(MRT_EditActionButtons, { row: row, table: table, variant: "text" }))));
|
|
2234
2263
|
};
|
|
2235
2264
|
|
|
2236
2265
|
const MRT_TableRoot = (props) => {
|
|
2237
2266
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2267
|
+
const bottomToolbarRef = useRef(null);
|
|
2268
|
+
const editInputRefs = useRef({});
|
|
2269
|
+
const filterInputRefs = useRef({});
|
|
2270
|
+
const searchInputRef = useRef(null);
|
|
2271
|
+
const tableContainerRef = useRef(null);
|
|
2272
|
+
const topToolbarRef = useRef(null);
|
|
2240
2273
|
const initialState = useMemo(() => {
|
|
2241
2274
|
var _a, _b;
|
|
2242
2275
|
const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
|
|
@@ -2273,10 +2306,10 @@ const MRT_TableRoot = (props) => {
|
|
|
2273
2306
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2274
2307
|
return [
|
|
2275
2308
|
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header: (_a = props.localization) === null || _a === void 0 ? void 0 : _a.move, size: 60 }, defaultDisplayColumnDefOptions), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-drag']), { id: 'mrt-row-drag' }),
|
|
2276
|
-
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({
|
|
2277
|
-
columnOrder.includes('mrt-row-expand') && Object.assign(Object.assign(Object.assign({ Cell: ({
|
|
2278
|
-
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({
|
|
2279
|
-
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({
|
|
2309
|
+
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ToggleRowActionMenuButton, { row: row, table: table })), header: (_c = props.localization) === null || _c === void 0 ? void 0 : _c.actions, size: 70 }, defaultDisplayColumnDefOptions), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
|
2310
|
+
columnOrder.includes('mrt-row-expand') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header: (_e = props.localization) === null || _e === void 0 ? void 0 : _e.expand, size: 60 }, defaultDisplayColumnDefOptions), (_f = props.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
|
2311
|
+
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: (_g = props.localization) === null || _g === void 0 ? void 0 : _g.select, size: 60 }, defaultDisplayColumnDefOptions), (_h = props.displayColumnDefOptions) === null || _h === void 0 ? void 0 : _h['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2312
|
+
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => { var _a; return (_a = props.localization) === null || _a === void 0 ? void 0 : _a.rowNumber; }, header: (_j = props.localization) === null || _j === void 0 ? void 0 : _j.rowNumbers, size: 60 }, defaultDisplayColumnDefOptions), (_k = props.displayColumnDefOptions) === null || _k === void 0 ? void 0 : _k['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
|
2280
2313
|
].filter(Boolean);
|
|
2281
2314
|
}, [
|
|
2282
2315
|
columnOrder,
|
|
@@ -2330,7 +2363,14 @@ const MRT_TableRoot = (props) => {
|
|
|
2330
2363
|
isFullScreen,
|
|
2331
2364
|
showAlertBanner,
|
|
2332
2365
|
showColumnFilters,
|
|
2333
|
-
showGlobalFilter }, props.state)
|
|
2366
|
+
showGlobalFilter }, props.state) }))), { refs: {
|
|
2367
|
+
bottomToolbarRef,
|
|
2368
|
+
editInputRefs,
|
|
2369
|
+
filterInputRefs,
|
|
2370
|
+
searchInputRef,
|
|
2371
|
+
tableContainerRef,
|
|
2372
|
+
topToolbarRef,
|
|
2373
|
+
}, setColumnFilterFns: (_v = props.onFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns, setDensity: (_w = props.onDensityChange) !== null && _w !== void 0 ? _w : setDensity, setDraggingColumn: (_x = props.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn, setDraggingRow: (_y = props.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow, setEditingCell: (_z = props.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell, setEditingRow: (_0 = props.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow, setGlobalFilterFn: (_1 = props.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn, setHoveredColumn: (_2 = props.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn, setHoveredRow: (_3 = props.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow, setIsFullScreen: (_4 = props.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen, setShowAlertBanner: (_5 = props.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner, setShowFilters: (_6 = props.onShowFiltersChange) !== null && _6 !== void 0 ? _6 : setShowFilters, setShowGlobalFilter: (_7 = props.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter });
|
|
2334
2374
|
return (React.createElement(React.Fragment, null,
|
|
2335
2375
|
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2336
2376
|
React.createElement(MRT_TablePaper, { table: table })),
|
|
@@ -2339,7 +2379,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2339
2379
|
};
|
|
2340
2380
|
|
|
2341
2381
|
var MaterialReactTable = (_a) => {
|
|
2342
|
-
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, editingMode = '
|
|
2382
|
+
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn = { minSize: 40, maxSize: 1000, size: 180 }, editingMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilterChangeMode = false, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterChangeMode = false, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enablePinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, localization, positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'original', selectAllMode = 'all', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnResizeMode", "defaultColumn", "editingMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilterChangeMode", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterChangeMode", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "localization", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "selectAllMode", "sortingFns"]);
|
|
2343
2383
|
return (React.createElement(MRT_TableRoot, Object.assign({ aggregationFns: Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns), autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: defaultColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilterChangeMode: enableColumnFilterChangeMode, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterChangeMode: enableGlobalFilterChangeMode, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: Object.assign(Object.assign({}, MRT_FilterFns), filterFns), icons: Object.assign(Object.assign({}, MRT_Default_Icons), icons), localization: Object.assign(Object.assign({}, MRT_DefaultLocalization_EN), localization), positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: Object.assign(Object.assign({}, MRT_SortingFns), sortingFns) }, rest)));
|
|
2344
2384
|
};
|
|
2345
2385
|
|