material-react-table 3.0.2 → 3.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/dist/index.d.ts +22 -73
- package/dist/index.esm.js +95 -97
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +95 -97
- package/dist/index.js.map +1 -1
- package/package.json +31 -32
- package/src/components/body/MRT_TableBodyCell.tsx +2 -2
- package/src/components/body/MRT_TableBodyCellValue.tsx +1 -1
- package/src/components/body/MRT_TableBodyRow.tsx +1 -1
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +1 -1
- package/src/components/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/components/buttons/MRT_EditActionButtons.tsx +2 -2
- package/src/components/footer/MRT_TableFooter.tsx +1 -1
- package/src/components/head/MRT_TableHead.tsx +1 -1
- package/src/components/head/MRT_TableHeadCell.tsx +2 -2
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +8 -10
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +1 -1
- package/src/components/inputs/MRT_EditCellTextField.tsx +5 -3
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +12 -5
- package/src/components/inputs/MRT_FilterTextField.tsx +89 -67
- package/src/components/menus/MRT_ColumnActionMenu.tsx +3 -2
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +12 -0
- package/src/components/table/MRT_TableContainer.tsx +1 -1
- package/src/components/table/MRT_TablePaper.tsx +1 -1
- package/src/components/toolbar/MRT_BottomToolbar.tsx +1 -1
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +2 -2
- package/src/components/toolbar/MRT_TopToolbar.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -1
- package/src/hooks/useMRT_ColumnVirtualizer.ts +1 -1
- package/src/hooks/useMRT_Effects.ts +2 -2
- package/src/hooks/useMRT_RowVirtualizer.ts +1 -1
- package/src/hooks/useMRT_TableInstance.ts +1 -1
- package/src/types.ts +15 -67
- package/src/utils/cell.utils.ts +2 -2
- package/src/utils/column.utils.ts +1 -1
- package/src/utils/tanstack.helpers.ts +1 -1
package/dist/index.esm.js
CHANGED
@@ -141,7 +141,7 @@ const prepareColumns = ({ columnDefs, tableOptions, }) => {
|
|
141
141
|
}
|
142
142
|
//assign sortingFns
|
143
143
|
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
144
|
-
// @ts-
|
144
|
+
// @ts-expect-error
|
145
145
|
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
146
146
|
}
|
147
147
|
}
|
@@ -423,11 +423,11 @@ const openEditingCell = ({ cell, table, }) => {
|
|
423
423
|
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
|
424
424
|
table.setEditingCell(cell);
|
425
425
|
queueMicrotask(() => {
|
426
|
-
var _a;
|
427
|
-
const textField = editInputRefs.current[column.id];
|
426
|
+
var _a, _b;
|
427
|
+
const textField = (_a = editInputRefs.current) === null || _a === void 0 ? void 0 : _a[column.id];
|
428
428
|
if (textField) {
|
429
429
|
textField.focus();
|
430
|
-
(
|
430
|
+
(_b = textField.select) === null || _b === void 0 ? void 0 : _b.call(textField);
|
431
431
|
}
|
432
432
|
});
|
433
433
|
}
|
@@ -448,7 +448,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
|
|
448
448
|
getMRT_RowSelectionHandler({
|
449
449
|
row: cell.row,
|
450
450
|
table,
|
451
|
-
//@ts-
|
451
|
+
//@ts-expect-error
|
452
452
|
staticRowIndex: +event.target.getAttribute('data-index'),
|
453
453
|
})(event);
|
454
454
|
}
|
@@ -775,13 +775,13 @@ const MRT_EditActionButtons = (_a) => {
|
|
775
775
|
row._valuesCache = {}; //reset values cache
|
776
776
|
};
|
777
777
|
const handleSubmitRow = () => {
|
778
|
-
var _a;
|
778
|
+
var _a, _b;
|
779
779
|
//look for auto-filled input values
|
780
|
-
(
|
781
|
-
.filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null ||
|
780
|
+
(_b = Object.values((_a = editInputRefs.current) !== null && _a !== void 0 ? _a : {})
|
781
|
+
.filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _b === void 0 ? void 0 : _b.forEach((input) => {
|
782
782
|
if (input.value !== undefined &&
|
783
783
|
Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
|
784
|
-
// @ts-
|
784
|
+
// @ts-expect-error
|
785
785
|
row._valuesCache[input.name] = input.value;
|
786
786
|
}
|
787
787
|
});
|
@@ -1542,8 +1542,8 @@ const useMRT_Effects = (table) => {
|
|
1542
1542
|
const totalColumnCount = table.options.columns.length;
|
1543
1543
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
1544
1544
|
const rerender = useReducer(() => ({}), {})[1];
|
1545
|
-
const initialBodyHeight = useRef();
|
1546
|
-
const previousTop = useRef();
|
1545
|
+
const initialBodyHeight = useRef(null);
|
1546
|
+
const previousTop = useRef(null);
|
1547
1547
|
useEffect(() => {
|
1548
1548
|
if (typeof window !== 'undefined') {
|
1549
1549
|
initialBodyHeight.current = document.body.style.height;
|
@@ -1735,7 +1735,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1735
1735
|
statefulTableOptions.state.isLoading,
|
1736
1736
|
statefulTableOptions.state.showSkeletons,
|
1737
1737
|
]);
|
1738
|
-
//@ts-
|
1738
|
+
//@ts-expect-error
|
1739
1739
|
const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
|
1740
1740
|
onColumnSizingInfoChange,
|
1741
1741
|
onGroupingChange,
|
@@ -1865,7 +1865,7 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1865
1865
|
(numPinnedRight ? totalSize - rightNonPinnedStart : 0);
|
1866
1866
|
}
|
1867
1867
|
if (columnVirtualizerInstanceRef) {
|
1868
|
-
//@ts-
|
1868
|
+
//@ts-expect-error
|
1869
1869
|
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
1870
1870
|
}
|
1871
1871
|
return columnVirtualizer;
|
@@ -1895,7 +1895,7 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1895
1895
|
}, [draggingRow]) }, rowVirtualizerProps));
|
1896
1896
|
rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
|
1897
1897
|
if (rowVirtualizerInstanceRef) {
|
1898
|
-
//@ts-
|
1898
|
+
//@ts-expect-error
|
1899
1899
|
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
1900
1900
|
}
|
1901
1901
|
return rowVirtualizer;
|
@@ -2054,7 +2054,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
2054
2054
|
});
|
2055
2055
|
const isSelectEdit = editVariant === 'select' || (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select);
|
2056
2056
|
const saveInputValueToRowCache = (newValue) => {
|
2057
|
-
//@ts-
|
2057
|
+
//@ts-expect-error
|
2058
2058
|
row._valuesCache[column.id] = newValue;
|
2059
2059
|
if (isCreating) {
|
2060
2060
|
setCreatingRow(row);
|
@@ -2078,10 +2078,10 @@ const MRT_EditCellTextField = (_a) => {
|
|
2078
2078
|
setEditingCell(null);
|
2079
2079
|
};
|
2080
2080
|
const handleEnterKeyDown = (event) => {
|
2081
|
-
var _a, _b;
|
2081
|
+
var _a, _b, _c;
|
2082
2082
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
2083
2083
|
if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
|
2084
|
-
(_b = editInputRefs.current[column.id]) === null ||
|
2084
|
+
(_c = (_b = editInputRefs.current) === null || _b === void 0 ? void 0 : _b[column.id]) === null || _c === void 0 ? void 0 : _c.blur();
|
2085
2085
|
}
|
2086
2086
|
};
|
2087
2087
|
if (columnDef.Edit) {
|
@@ -2089,7 +2089,9 @@ const MRT_EditCellTextField = (_a) => {
|
|
2089
2089
|
}
|
2090
2090
|
return (jsx(TextField, Object.assign({ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false, fullWidth: true, inputRef: (inputRef) => {
|
2091
2091
|
if (inputRef) {
|
2092
|
-
editInputRefs.current[column.id] =
|
2092
|
+
editInputRefs.current[column.id] = isSelectEdit
|
2093
|
+
? inputRef.node
|
2094
|
+
: inputRef;
|
2093
2095
|
if (textFieldProps.inputRef) {
|
2094
2096
|
textFieldProps.inputRef = inputRef;
|
2095
2097
|
}
|
@@ -2206,7 +2208,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2206
2208
|
const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
|
2207
2209
|
parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
|
2208
2210
|
!['context-menu', false].includes(
|
2209
|
-
// @ts-
|
2211
|
+
// @ts-expect-error
|
2210
2212
|
parseFromValuesOrFunc(columnDef.enableClickToCopy, cell));
|
2211
2213
|
const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
|
2212
2214
|
const cellValueProps = {
|
@@ -2362,7 +2364,7 @@ const MRT_TableBodyRow = (_a) => {
|
|
2362
2364
|
const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
|
2363
2365
|
const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
|
2364
2366
|
const customRowHeight =
|
2365
|
-
// @ts-
|
2367
|
+
// @ts-expect-error
|
2366
2368
|
parseInt((_f = (_d = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _d === void 0 ? void 0 : _d.height) !== null && _f !== void 0 ? _f : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
|
2367
2369
|
const rowHeight = customRowHeight || defaultRowHeight;
|
2368
2370
|
const handleDragEnter = (_e) => {
|
@@ -2604,7 +2606,7 @@ const MRT_TableFooter = (_a) => {
|
|
2604
2606
|
return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
|
2605
2607
|
tableFooterRef.current = ref;
|
2606
2608
|
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
2607
|
-
// @ts-
|
2609
|
+
// @ts-expect-error
|
2608
2610
|
tableFooterProps.ref.current = ref;
|
2609
2611
|
}
|
2610
2612
|
}, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
|
@@ -2865,7 +2867,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2865
2867
|
};
|
2866
2868
|
const handleFilterByColumn = () => {
|
2867
2869
|
setShowColumnFilters(true);
|
2868
|
-
queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null ||
|
2870
|
+
queueMicrotask(() => { var _a, _b; return (_b = (_a = filterInputRefs.current) === null || _a === void 0 ? void 0 : _a[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.focus(); });
|
2869
2871
|
setAnchorEl(null);
|
2870
2872
|
};
|
2871
2873
|
const handleShowAllColumns = () => {
|
@@ -2888,7 +2890,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2888
2890
|
const internalColumnMenuItems = [
|
2889
2891
|
...(enableSorting && column.getCanSort()
|
2890
2892
|
? [
|
2891
|
-
enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
|
2893
|
+
enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === false, icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
|
2892
2894
|
jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'asc', icon: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }), label: (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header)), onClick: handleSortAsc, table: table }, 1),
|
2893
2895
|
jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, icon: jsx(SortIcon, {}), label: (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)), onClick: handleSortDesc, table: table }, 2),
|
2894
2896
|
]
|
@@ -2918,7 +2920,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2918
2920
|
: []),
|
2919
2921
|
...(enableColumnResizing && column.getCanResize()
|
2920
2922
|
? [
|
2921
|
-
jsx(MRT_ActionMenuItem, { disabled:
|
2923
|
+
jsx(MRT_ActionMenuItem, { disabled: columnSizing[column.id] === undefined, icon: jsx(RestartAltIcon, {}), label: localization.resetColumnSize, onClick: handleResetColumnSize, table: table }, 10),
|
2922
2924
|
]
|
2923
2925
|
: []),
|
2924
2926
|
...(enableHiding
|
@@ -3001,7 +3003,7 @@ const MRT_FilterCheckbox = (_a) => {
|
|
3001
3003
|
};
|
3002
3004
|
|
3003
3005
|
const MRT_FilterTextField = (_a) => {
|
3004
|
-
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
3006
|
+
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3005
3007
|
var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
|
3006
3008
|
const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
3007
3009
|
const { column } = header;
|
@@ -3016,9 +3018,8 @@ const MRT_FilterTextField = (_a) => {
|
|
3016
3018
|
const { allowedColumnFilterOptions, currentFilterOption, facetedUniqueValues, isAutocompleteFilter, isDateFilter, isMultiSelectFilter, isRangeFilter, isSelectFilter, isTextboxFilter, } = getColumnFilterInfo({ header, table });
|
3017
3019
|
const dropdownOptions = useDropdownOptions({ header, table });
|
3018
3020
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
3019
|
-
?
|
3020
|
-
|
3021
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
3021
|
+
? localization[`filter${((_c = (_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt) === null || _b === void 0 ? void 0 : _b.call(currentFilterOption, 0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
|
3022
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
3022
3023
|
: '';
|
3023
3024
|
const filterPlaceholder = !isRangeFilter
|
3024
3025
|
? ((_d = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.placeholder) !== null && _d !== void 0 ? _d : (_f = localization.filterByColumn) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)))
|
@@ -3120,33 +3121,17 @@ const MRT_FilterTextField = (_a) => {
|
|
3120
3121
|
if (columnDef.Filter) {
|
3121
3122
|
return (jsx(Fragment, { children: (_g = columnDef.Filter) === null || _g === void 0 ? void 0 : _g.call(columnDef, { column, header, rangeFilterIndex, table }) }));
|
3122
3123
|
}
|
3123
|
-
const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsx(InputAdornment, { position: "end", sx: {
|
3124
|
+
const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsx(InputAdornment, { position: "end", sx: {
|
3125
|
+
mr: isSelectFilter || isMultiSelectFilter ? '20px' : undefined,
|
3126
|
+
visibility: ((_h = filterValue === null || filterValue === void 0 ? void 0 : filterValue.length) !== null && _h !== void 0 ? _h : 0) > 0 ? 'visible' : 'hidden',
|
3127
|
+
}, children: jsx(Tooltip, { placement: "right", title: (_j = localization.clearFilter) !== null && _j !== void 0 ? _j : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearFilter, disabled: !((_k = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _k === void 0 ? void 0 : _k.length), onClick: handleClear, size: "small", sx: {
|
3124
3128
|
height: '2rem',
|
3125
3129
|
transform: 'scale(0.9)',
|
3126
3130
|
width: '2rem',
|
3127
3131
|
}, children: jsx(CloseIcon, {}) }) }) }) })) : null;
|
3128
3132
|
const startAdornment = showChangeModeButton ? (jsxs(InputAdornment, { position: "start", children: [jsx(Tooltip, { title: localization.changeFilterMode, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.changeFilterMode, onClick: handleFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(FilterListIcon, {}) }) }) }), filterChipLabel && (jsx(Chip, { label: filterChipLabel, onDelete: handleClearEmptyFilterChip }))] })) : null;
|
3129
|
-
const commonTextFieldProps = Object.assign(Object.assign({
|
3130
|
-
|
3131
|
-
fontSize: '0.75rem',
|
3132
|
-
lineHeight: '0.8rem',
|
3133
|
-
whiteSpace: 'nowrap',
|
3134
|
-
},
|
3135
|
-
}, InputProps: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
|
3136
|
-
? { endAdornment, startAdornment }
|
3137
|
-
: { startAdornment }, fullWidth: true, helperText: showChangeModeButton ? (jsx("label", { children: localization.filterMode.replace('{filterType}',
|
3138
|
-
// @ts-ignore
|
3139
|
-
localization[`filter${((_k = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _k === void 0 ? void 0 : _k.toUpperCase()) +
|
3140
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputProps: {
|
3141
|
-
'aria-label': filterPlaceholder,
|
3142
|
-
autoComplete: 'off',
|
3143
|
-
disabled: !!filterChipLabel,
|
3144
|
-
sx: {
|
3145
|
-
textOverflow: 'ellipsis',
|
3146
|
-
width: filterChipLabel ? 0 : undefined,
|
3147
|
-
},
|
3148
|
-
title: filterPlaceholder,
|
3149
|
-
}, inputRef: (inputRef) => {
|
3133
|
+
const commonTextFieldProps = Object.assign(Object.assign({ fullWidth: true, helperText: showChangeModeButton ? (jsx("label", { children: localization.filterMode.replace('{filterType}', localization[`filter${((_l = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _l === void 0 ? void 0 : _l.toUpperCase()) +
|
3134
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputRef: (inputRef) => {
|
3150
3135
|
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
3151
3136
|
inputRef;
|
3152
3137
|
if (textFieldProps.inputRef) {
|
@@ -3154,7 +3139,16 @@ const MRT_FilterTextField = (_a) => {
|
|
3154
3139
|
}
|
3155
3140
|
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
3156
3141
|
? undefined
|
3157
|
-
: filterPlaceholder, variant: 'standard' }, textFieldProps), {
|
3142
|
+
: filterPlaceholder, variant: 'standard' }, textFieldProps), { slotProps: Object.assign(Object.assign({}, textFieldProps.slotProps), { formHelperText: Object.assign({ sx: {
|
3143
|
+
fontSize: '0.75rem',
|
3144
|
+
lineHeight: '0.8rem',
|
3145
|
+
whiteSpace: 'nowrap',
|
3146
|
+
} }, (_m = textFieldProps.slotProps) === null || _m === void 0 ? void 0 : _m.formHelperText), input: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
|
3147
|
+
? { endAdornment, startAdornment }
|
3148
|
+
: { startAdornment }, htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3149
|
+
textOverflow: 'ellipsis',
|
3150
|
+
width: filterChipLabel ? 0 : undefined,
|
3151
|
+
}, title: filterPlaceholder }, (_o = textFieldProps.slotProps) === null || _o === void 0 ? void 0 : _o.htmlInput) }), onKeyDown: (e) => {
|
3158
3152
|
var _a;
|
3159
3153
|
e.stopPropagation();
|
3160
3154
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
@@ -3174,32 +3168,32 @@ const MRT_FilterTextField = (_a) => {
|
|
3174
3168
|
value: filterValue || null,
|
3175
3169
|
};
|
3176
3170
|
return (jsxs(Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsx(TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: {
|
3177
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3178
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3171
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_p = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _p === void 0 ? void 0 : _p.field),
|
3172
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_q = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _q === void 0 ? void 0 : _q.textField),
|
3179
3173
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsx(DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: {
|
3180
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3181
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3174
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_r = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.field),
|
3175
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
3182
3176
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
|
3183
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3184
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3185
|
-
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label,
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
3190
|
-
}, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, {
|
3191
|
-
|
3192
|
-
|
3193
|
-
|
3194
|
-
|
3195
|
-
|
3177
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_t = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _t === void 0 ? void 0 : _t.field),
|
3178
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_u = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _u === void 0 ? void 0 : _u.textField),
|
3179
|
+
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_v = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _v !== void 0 ? _v : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
3180
|
+
var _a, _b, _c, _d, _f;
|
3181
|
+
return (jsx(TextField, Object.assign({}, commonTextFieldProps, builtinTextFieldProps, { slotProps: Object.assign(Object.assign(Object.assign({}, builtinTextFieldProps.slotProps), commonTextFieldProps.slotProps), { input: Object.assign(Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), (_a = builtinTextFieldProps.slotProps) === null || _a === void 0 ? void 0 : _a.input), { startAdornment:
|
3182
|
+
//@ts-expect-error
|
3183
|
+
(_c = (_b = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.slotProps) === null || _b === void 0 ? void 0 : _b.input) === null || _c === void 0 ? void 0 : _c.startAdornment }), htmlInput: Object.assign(Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), (_d = builtinTextFieldProps.slotProps) === null || _d === void 0 ? void 0 : _d.htmlInput), (_f = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.slotProps) === null || _f === void 0 ? void 0 : _f.htmlInput) }), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
|
3184
|
+
}, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { inputLabel: Object.assign({ shrink: isSelectFilter || isMultiSelectFilter }, (_w = commonTextFieldProps.slotProps) === null || _w === void 0 ? void 0 : _w.inputLabel), select: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
3185
|
+
? (selected) => !Array.isArray(selected) || (selected === null || selected === void 0 ? void 0 : selected.length) === 0 ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected.map((value) => {
|
3186
|
+
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
3187
|
+
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
3188
|
+
}) }))
|
3189
|
+
: undefined }, (_x = commonTextFieldProps.slotProps) === null || _x === void 0 ? void 0 : _x.select) }), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
|
3196
3190
|
? Array.isArray(filterValue)
|
3197
3191
|
? filterValue
|
3198
3192
|
: []
|
3199
|
-
:
|
3193
|
+
: filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
|
3200
3194
|
jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
3201
3195
|
...[
|
3202
|
-
(
|
3196
|
+
(_y = textFieldProps.children) !== null && _y !== void 0 ? _y : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
3203
3197
|
var _a;
|
3204
3198
|
const { label, value } = getValueAndLabel(option);
|
3205
3199
|
return (jsxs(MenuItem, { sx: {
|
@@ -3243,6 +3237,12 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3243
3237
|
const [filterValues, setFilterValues] = useState([min, max]);
|
3244
3238
|
const columnFilterValue = column.getFilterValue();
|
3245
3239
|
const isMounted = useRef(false);
|
3240
|
+
// prevent moving the focus to the next/prev cell when using the arrow keys
|
3241
|
+
const handleKeyDown = (event) => {
|
3242
|
+
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
3243
|
+
event.stopPropagation();
|
3244
|
+
}
|
3245
|
+
};
|
3246
3246
|
useEffect(() => {
|
3247
3247
|
if (isMounted.current) {
|
3248
3248
|
if (columnFilterValue === undefined) {
|
@@ -3266,15 +3266,15 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3266
3266
|
column.setFilterValue(value);
|
3267
3267
|
}
|
3268
3268
|
}
|
3269
|
-
}, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
|
3269
|
+
}, onKeyDown: handleKeyDown, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
|
3270
3270
|
input: {
|
3271
3271
|
ref: (node) => {
|
3272
3272
|
var _a, _b;
|
3273
3273
|
if (node) {
|
3274
3274
|
filterInputRefs.current[`${column.id}-0`] = node;
|
3275
|
-
// @ts-
|
3275
|
+
// @ts-expect-error
|
3276
3276
|
if ((_b = (_a = sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.slotProps) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.ref) {
|
3277
|
-
//@ts-
|
3277
|
+
//@ts-expect-error
|
3278
3278
|
sliderProps.slotProps.input.ref = node;
|
3279
3279
|
}
|
3280
3280
|
}
|
@@ -3285,9 +3285,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3285
3285
|
lineHeight: '0.8rem',
|
3286
3286
|
m: '-3px -6px',
|
3287
3287
|
whiteSpace: 'nowrap',
|
3288
|
-
}, children: localization.filterMode.replace('{filterType}',
|
3289
|
-
// @ts-ignore
|
3290
|
-
localization[`filter${((_c = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
|
3288
|
+
}, children: localization.filterMode.replace('{filterType}', localization[`filter${((_c = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
|
3291
3289
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
|
3292
3290
|
};
|
3293
3291
|
|
@@ -3302,7 +3300,7 @@ const MRT_TableHeadCellFilterContainer = (_a) => {
|
|
3302
3300
|
};
|
3303
3301
|
|
3304
3302
|
const MRT_TableHeadCellFilterLabel = (_a) => {
|
3305
|
-
var _b
|
3303
|
+
var _b;
|
3306
3304
|
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
3307
3305
|
const { options: { columnFilterDisplayMode, icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
|
3308
3306
|
const { column } = header;
|
@@ -3320,9 +3318,8 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3320
3318
|
: localization.filteringByColumn
|
3321
3319
|
.replace('{column}', String(columnDef.header))
|
3322
3320
|
.replace('{filterType}', currentFilterOption
|
3323
|
-
?
|
3324
|
-
|
3325
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
3321
|
+
? localization[`filter${currentFilterOption.charAt(0).toUpperCase() +
|
3322
|
+
currentFilterOption.slice(1)}`]
|
3326
3323
|
: '')
|
3327
3324
|
.replace('{filterValue}', `"${Array.isArray(filterValue)
|
3328
3325
|
? filterValue
|
@@ -3334,8 +3331,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3334
3331
|
.replace('" "', '');
|
3335
3332
|
return (jsxs(Fragment, { children: [jsx(Grow, { in: columnFilterDisplayMode === 'popover' ||
|
3336
3333
|
(!!filterValue && !isRangeFilter) ||
|
3337
|
-
(isRangeFilter &&
|
3338
|
-
(!!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[0]) || !!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[1]))), unmountOnExit: true, children: jsx(Box, { component: "span", sx: { flex: '0 0' }, children: jsx(Tooltip, { placement: "top", title: filterTooltip, children: jsx(IconButton, Object.assign({ disableRipple: true, onClick: (event) => {
|
3334
|
+
(isRangeFilter && (!!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[0]) || !!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[1]))), unmountOnExit: true, children: jsx(Box, { component: "span", sx: { flex: '0 0' }, children: jsx(Tooltip, { placement: "top", title: filterTooltip, children: jsx(IconButton, Object.assign({ disableRipple: true, onClick: (event) => {
|
3339
3335
|
if (columnFilterDisplayMode === 'popover') {
|
3340
3336
|
setAnchorEl(event.currentTarget);
|
3341
3337
|
}
|
@@ -3343,16 +3339,16 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3343
3339
|
setShowColumnFilters(true);
|
3344
3340
|
}
|
3345
3341
|
queueMicrotask(() => {
|
3346
|
-
var _a, _b, _c, _d;
|
3347
|
-
(_b = (_a = filterInputRefs.current[`${column.id}-0`]) === null ||
|
3348
|
-
(
|
3342
|
+
var _a, _b, _c, _d, _e, _f;
|
3343
|
+
(_c = (_b = (_a = filterInputRefs.current) === null || _a === void 0 ? void 0 : _a[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.focus) === null || _c === void 0 ? void 0 : _c.call(_b);
|
3344
|
+
(_f = (_e = (_d = filterInputRefs.current) === null || _d === void 0 ? void 0 : _d[`${column.id}-0`]) === null || _e === void 0 ? void 0 : _e.select) === null || _f === void 0 ? void 0 : _f.call(_e);
|
3349
3345
|
});
|
3350
3346
|
event.stopPropagation();
|
3351
3347
|
}, size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '16px', ml: '4px', opacity: isFilterActive ? 1 : 0.3, p: '8px', transform: 'scale(0.75)', transition: 'all 150ms ease-in-out', width: '16px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(FilterAltIcon, {}) })) }) }) }), columnFilterDisplayMode === 'popover' && (jsx(Popover, { anchorEl: anchorEl, anchorOrigin: {
|
3352
3348
|
horizontal: 'center',
|
3353
3349
|
vertical: 'top',
|
3354
3350
|
}, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
|
3355
|
-
//@ts-
|
3351
|
+
//@ts-expect-error
|
3356
3352
|
event.stopPropagation();
|
3357
3353
|
setAnchorEl(null);
|
3358
3354
|
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, slotProps: { paper: { sx: { overflow: 'visible' } } }, transformOrigin: {
|
@@ -3471,7 +3467,7 @@ const MRT_TableHeadCellSortLabel = (_a) => {
|
|
3471
3467
|
};
|
3472
3468
|
|
3473
3469
|
const MRT_TableHeadCell = (_a) => {
|
3474
|
-
var _b, _c, _d, _f, _g, _h;
|
3470
|
+
var _b, _c, _d, _f, _g, _h, _j;
|
3475
3471
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
3476
3472
|
const theme = useTheme();
|
3477
3473
|
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableKeyboardShortcuts, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
@@ -3638,7 +3634,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3638
3634
|
}, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
3639
3635
|
whiteSpace: 'nowrap',
|
3640
3636
|
}, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3641
|
-
current: tableHeadCellRefs.current[column.id],
|
3637
|
+
current: (_j = tableHeadCellRefs.current) === null || _j === void 0 ? void 0 : _j[column.id],
|
3642
3638
|
} })), showColumnActions && (jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] }))), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
|
3643
3639
|
};
|
3644
3640
|
|
@@ -3666,7 +3662,7 @@ const MRT_TableHeadRow = (_a) => {
|
|
3666
3662
|
const MRT_ToolbarAlertBanner = (_a) => {
|
3667
3663
|
var _b, _c, _d;
|
3668
3664
|
var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
|
3669
|
-
const { getFilteredSelectedRowModel,
|
3665
|
+
const { getFilteredSelectedRowModel, getCoreRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
|
3670
3666
|
const { density, grouping, rowSelection, showAlertBanner } = getState();
|
3671
3667
|
const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
3672
3668
|
table,
|
@@ -3674,7 +3670,7 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
3674
3670
|
const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
|
3675
3671
|
table,
|
3676
3672
|
});
|
3677
|
-
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount :
|
3673
|
+
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getCoreRowModel().rows.length;
|
3678
3674
|
const selectedRowCount = useMemo(() => manualPagination
|
3679
3675
|
? Object.values(rowSelection).filter(Boolean).length
|
3680
3676
|
: getFilteredSelectedRowModel().rows.length, [rowSelection, totalRowCount, manualPagination]);
|
@@ -3716,7 +3712,7 @@ const MRT_TableHead = (_a) => {
|
|
3716
3712
|
return (jsx(TableHead, Object.assign({}, tableHeadProps, { ref: (ref) => {
|
3717
3713
|
tableHeadRef.current = ref;
|
3718
3714
|
if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
|
3719
|
-
// @ts-
|
3715
|
+
// @ts-expect-error
|
3720
3716
|
tableHeadProps.ref.current = ref;
|
3721
3717
|
}
|
3722
3718
|
}, sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, parseFromValuesOrFunc(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx, theme))), children: positionToolbarAlertBanner === 'head-overlay' &&
|
@@ -3887,7 +3883,7 @@ const MRT_TableContainer = (_a) => {
|
|
3887
3883
|
if (node) {
|
3888
3884
|
tableContainerRef.current = node;
|
3889
3885
|
if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
|
3890
|
-
//@ts-
|
3886
|
+
//@ts-expect-error
|
3891
3887
|
tableContainerProps.ref.current = node;
|
3892
3888
|
}
|
3893
3889
|
}
|
@@ -4000,7 +3996,7 @@ const MRT_BottomToolbar = (_a) => {
|
|
4000
3996
|
if (node) {
|
4001
3997
|
bottomToolbarRef.current = node;
|
4002
3998
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
4003
|
-
// @ts-
|
3999
|
+
// @ts-expect-error
|
4004
4000
|
toolbarProps.ref.current = node;
|
4005
4001
|
}
|
4006
4002
|
}
|
@@ -4103,7 +4099,7 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
4103
4099
|
|
4104
4100
|
const MRT_ShowHideColumnsMenu = (_a) => {
|
4105
4101
|
var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
|
4106
|
-
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
|
4102
|
+
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, initialState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
|
4107
4103
|
const { columnOrder, columnPinning, density } = getState();
|
4108
4104
|
const handleToggleAllColumns = (value) => {
|
4109
4105
|
getAllLeafColumns()
|
@@ -4130,6 +4126,8 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
4130
4126
|
getRightLeafColumns(),
|
4131
4127
|
]);
|
4132
4128
|
const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === 'group');
|
4129
|
+
const hasColumnOrderChanged = useMemo(() => columnOrder.length !== initialState.columnOrder.length ||
|
4130
|
+
!columnOrder.every((column, index) => column === initialState.columnOrder[index]), [columnOrder, initialState.columnOrder]);
|
4133
4131
|
const [hoveredColumn, setHoveredColumn] = useState(null);
|
4134
4132
|
return (jsxs(Menu, Object.assign({ MenuListProps: {
|
4135
4133
|
dense: density === 'compact',
|
@@ -4141,7 +4139,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
4141
4139
|
justifyContent: 'space-between',
|
4142
4140
|
p: '0.5rem',
|
4143
4141
|
pt: 0,
|
4144
|
-
}, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
|
4142
|
+
}, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), disabled: !hasColumnOrderChanged, children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
|
4145
4143
|
};
|
4146
4144
|
|
4147
4145
|
const MRT_ShowHideColumnsButton = (_a) => {
|
@@ -4289,7 +4287,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
4289
4287
|
return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
|
4290
4288
|
topToolbarRef.current = ref;
|
4291
4289
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
4292
|
-
// @ts-
|
4290
|
+
// @ts-expect-error
|
4293
4291
|
toolbarProps.ref.current = ref;
|
4294
4292
|
}
|
4295
4293
|
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, getCommonToolbarStyles({ table, theme })), { position: isFullScreen ? 'sticky' : 'relative', top: isFullScreen ? '0' : undefined }), parseFromValuesOrFunc(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx, theme))), children: [positionToolbarAlertBanner === 'top' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
|
@@ -4324,7 +4322,7 @@ const MRT_TablePaper = (_a) => {
|
|
4324
4322
|
return (jsxs(Paper, Object.assign({ elevation: 2, onKeyDown: (e) => e.key === 'Escape' && table.setIsFullScreen(false) }, paperProps, { ref: (ref) => {
|
4325
4323
|
tablePaperRef.current = ref;
|
4326
4324
|
if (paperProps === null || paperProps === void 0 ? void 0 : paperProps.ref) {
|
4327
|
-
//@ts-
|
4325
|
+
//@ts-expect-error
|
4328
4326
|
paperProps.ref.current = ref;
|
4329
4327
|
}
|
4330
4328
|
}, style: Object.assign(Object.assign({}, (isFullScreen
|