material-react-table 2.3.0 → 2.4.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 +47 -33
- package/dist/index.esm.js +67 -44
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +67 -44
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/body/MRT_TableBody.tsx +11 -17
- package/src/body/MRT_TableBodyRow.tsx +6 -7
- package/src/buttons/MRT_EditActionButtons.tsx +12 -9
- package/src/footer/MRT_TableFooter.tsx +8 -7
- package/src/footer/MRT_TableFooterRow.tsx +5 -4
- package/src/head/MRT_TableHead.tsx +8 -7
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +3 -1
- package/src/head/MRT_TableHeadRow.tsx +5 -4
- package/src/hooks/useMRT_ColumnVirtualizer.ts +9 -10
- package/src/hooks/useMRT_RowVirtualizer.ts +11 -9
- package/src/hooks/useMRT_Rows.ts +1 -8
- package/src/inputs/MRT_FilterTextField.tsx +69 -6
- package/src/inputs/MRT_SelectCheckbox.tsx +2 -1
- package/src/menus/MRT_FilterOptionMenu.tsx +1 -1
- package/src/table/MRT_Table.tsx +3 -11
- package/src/toolbar/MRT_TablePagination.tsx +33 -24
- package/src/types.ts +53 -10
package/dist/index.js
CHANGED
@@ -71,6 +71,8 @@ var Chip = require('@mui/material/Chip');
|
|
71
71
|
var InputAdornment = require('@mui/material/InputAdornment');
|
72
72
|
var utils = require('@mui/material/utils');
|
73
73
|
var DatePicker = require('@mui/x-date-pickers/DatePicker');
|
74
|
+
var DateTimePicker = require('@mui/x-date-pickers/DateTimePicker');
|
75
|
+
var TimePicker = require('@mui/x-date-pickers/TimePicker');
|
74
76
|
var FormHelperText = require('@mui/material/FormHelperText');
|
75
77
|
var Slider = require('@mui/material/Slider');
|
76
78
|
var Stack = require('@mui/material/Stack');
|
@@ -891,11 +893,12 @@ const MRT_TableDetailPanel = (_a) => {
|
|
891
893
|
: undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: renderDetailPanel && (jsxRuntime.jsx(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
|
892
894
|
};
|
893
895
|
|
894
|
-
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualColumns,
|
896
|
+
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualColumns, virtualRow, }) => {
|
895
897
|
var _a, _b, _c, _d;
|
896
898
|
const theme = styles.useTheme();
|
897
899
|
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
898
900
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
901
|
+
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
899
902
|
const isPinned = enableRowPinning && row.getIsPinned();
|
900
903
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
901
904
|
row,
|
@@ -980,7 +983,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
980
983
|
rowIndex,
|
981
984
|
rowRef,
|
982
985
|
table,
|
983
|
-
|
986
|
+
virtualColumnIndex: columnVirtualizer
|
984
987
|
? cellOrVirtualCell.index
|
985
988
|
: undefined,
|
986
989
|
};
|
@@ -1012,8 +1015,9 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1012
1015
|
//get first 16 column widths and average them if calc is needed
|
1013
1016
|
const averageColumnWidth = react.useMemo(() => {
|
1014
1017
|
var _a, _b, _c, _d;
|
1015
|
-
if (!enableColumnVirtualization || (columnVirtualizerProps === null || columnVirtualizerProps === void 0 ? void 0 : columnVirtualizerProps.estimateSize))
|
1018
|
+
if (!enableColumnVirtualization || (columnVirtualizerProps === null || columnVirtualizerProps === void 0 ? void 0 : columnVirtualizerProps.estimateSize)) {
|
1016
1019
|
return 0;
|
1020
|
+
}
|
1017
1021
|
const columnsWidths = (_d = (_c = (_b = (_a = table
|
1018
1022
|
.getRowModel()
|
1019
1023
|
.rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
|
@@ -1171,7 +1175,8 @@ const MRT_EditActionButtons = (_a) => {
|
|
1171
1175
|
});
|
1172
1176
|
}
|
1173
1177
|
};
|
1174
|
-
return (jsxRuntime.jsx(Box__default["default"], { onClick: (e) => e.stopPropagation(), sx: (theme) => (Object.assign({ display: 'flex', gap: '0.75rem' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { title: localization.cancel, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }),
|
1178
|
+
return (jsxRuntime.jsx(Box__default["default"], { onClick: (e) => e.stopPropagation(), sx: (theme) => (Object.assign({ display: 'flex', gap: '0.75rem' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { title: localization.cancel, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }), ((isCreating && onCreatingRowSave) ||
|
1179
|
+
(isEditing && onEditingRowSave)) && (jsxRuntime.jsx(Tooltip__default["default"], { title: localization.save, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsxRuntime.jsx(CircularProgress__default["default"], { size: 18 }) : jsxRuntime.jsx(SaveIcon, {}) }) }))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button__default["default"], { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxRuntime.jsxs(Button__default["default"], { onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsxRuntime.jsx(CircularProgress__default["default"], { color: "inherit", size: 18 }), localization.save] })] })) }));
|
1175
1180
|
};
|
1176
1181
|
|
1177
1182
|
const mrtFilterOptions = (localization) => [
|
@@ -1263,7 +1268,7 @@ const mrtFilterOptions = (localization) => [
|
|
1263
1268
|
const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
|
1264
1269
|
const emptyModes = ['empty', 'notEmpty'];
|
1265
1270
|
const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
|
1266
|
-
const rangeVariants = ['range-slider', 'date-range', 'range'];
|
1271
|
+
const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
|
1267
1272
|
const MRT_FilterOptionMenu = (_a) => {
|
1268
1273
|
var _b, _c, _d, _e;
|
1269
1274
|
var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
|
@@ -1566,7 +1571,7 @@ const MRT_SelectCheckbox = (_a) => {
|
|
1566
1571
|
? table.getIsAllPageRowsSelected()
|
1567
1572
|
: table.getIsAllRowsSelected()
|
1568
1573
|
: undefined;
|
1569
|
-
const commonProps = Object.assign(Object.assign({ checked: selectAll ? allRowsSelected : row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading || (row && !row.getCanSelect()), inputProps: {
|
1574
|
+
const commonProps = Object.assign(Object.assign({ checked: selectAll ? allRowsSelected : row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
1570
1575
|
'aria-label': selectAll
|
1571
1576
|
? localization.toggleSelectAll
|
1572
1577
|
: localization.toggleSelectRow,
|
@@ -1779,14 +1784,15 @@ const useMRT_Effects = (table) => {
|
|
1779
1784
|
}, [density]);
|
1780
1785
|
};
|
1781
1786
|
|
1782
|
-
const useMRT_RowVirtualizer = (table) => {
|
1787
|
+
const useMRT_RowVirtualizer = (table, rows) => {
|
1788
|
+
var _a;
|
1783
1789
|
const { getRowModel, getState, options: { enableRowVirtualization, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
|
1784
1790
|
const { density, draggingRow } = getState();
|
1785
1791
|
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
1786
1792
|
table,
|
1787
1793
|
});
|
1788
1794
|
const rowVirtualizer = enableRowVirtualization
|
1789
|
-
? reactVirtual.useVirtualizer(Object.assign({ count: getRowModel().rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
|
1795
|
+
? reactVirtual.useVirtualizer(Object.assign({ count: (_a = rows === null || rows === void 0 ? void 0 : rows.length) !== null && _a !== void 0 ? _a : getRowModel().rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
|
1790
1796
|
navigator.userAgent.indexOf('Firefox') === -1
|
1791
1797
|
? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
|
1792
1798
|
: undefined, overscan: 4, rangeExtractor: react.useCallback((range) => {
|
@@ -1815,7 +1821,7 @@ const MRT_SortingFns = Object.assign(Object.assign({}, reactTable.sortingFns), {
|
|
1815
1821
|
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
1816
1822
|
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
1817
1823
|
|
1818
|
-
const useMRT_Rows = (table) => {
|
1824
|
+
const useMRT_Rows = (table, pinnedRowIds = []) => {
|
1819
1825
|
const { getBottomRows, getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { enableGlobalFilterRankedResults, enablePagination, enableRowPinning, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, rowPinningDisplayMode, }, } = table;
|
1820
1826
|
const { expanded, globalFilter, pagination, rowPinning, sorting } = getState();
|
1821
1827
|
const shouldRankRows = react.useMemo(() => getCanRankRows(table) &&
|
@@ -1830,9 +1836,6 @@ const useMRT_Rows = (table) => {
|
|
1830
1836
|
manualSorting,
|
1831
1837
|
sorting,
|
1832
1838
|
]);
|
1833
|
-
const pinnedRowIds = react.useMemo(() => getRowModel()
|
1834
|
-
.rows.filter((row) => row.getIsPinned())
|
1835
|
-
.map((r) => r.id), [rowPinning, table.getRowModel().rows]);
|
1836
1839
|
const rows = react.useMemo(() => {
|
1837
1840
|
let rows = [];
|
1838
1841
|
if (!shouldRankRows) {
|
@@ -2358,7 +2361,7 @@ const useMRT_TableOptions = (_a) => {
|
|
2358
2361
|
|
2359
2362
|
const MRT_TableBody = (_a) => {
|
2360
2363
|
var _b, _c, _d, _e, _f, _g;
|
2361
|
-
var { columnVirtualizer, table, virtualColumns
|
2364
|
+
var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
|
2362
2365
|
const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
2363
2366
|
const { columnFilters, creatingRow, globalFilter, isFullScreen, rowPinning } = getState();
|
2364
2367
|
const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
|
@@ -2366,11 +2369,16 @@ const MRT_TableBody = (_a) => {
|
|
2366
2369
|
((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
|
2367
2370
|
0;
|
2368
2371
|
const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
|
2369
|
-
const pinnedRowIds = react.useMemo(() =>
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2372
|
+
const pinnedRowIds = react.useMemo(() => {
|
2373
|
+
var _a, _b;
|
2374
|
+
if (!((_a = rowPinning.bottom) === null || _a === void 0 ? void 0 : _a.length) && !((_b = rowPinning.top) === null || _b === void 0 ? void 0 : _b.length))
|
2375
|
+
return [];
|
2376
|
+
return getRowModel()
|
2377
|
+
.rows.filter((row) => row.getIsPinned())
|
2378
|
+
.map((r) => r.id);
|
2379
|
+
}, [rowPinning, getRowModel().rows]);
|
2380
|
+
const rows = useMRT_Rows(table, pinnedRowIds);
|
2381
|
+
const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
|
2374
2382
|
const virtualRows = rowVirtualizer
|
2375
2383
|
? rowVirtualizer.getVirtualItems()
|
2376
2384
|
: undefined;
|
@@ -2379,8 +2387,6 @@ const MRT_TableBody = (_a) => {
|
|
2379
2387
|
numRows: rows.length,
|
2380
2388
|
table,
|
2381
2389
|
virtualColumns,
|
2382
|
-
virtualPaddingLeft,
|
2383
|
-
virtualPaddingRight,
|
2384
2390
|
};
|
2385
2391
|
const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow, rowIndex: -1 })));
|
2386
2392
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
@@ -2451,8 +2457,9 @@ const MRT_TableFooterCell = (_a) => {
|
|
2451
2457
|
|
2452
2458
|
const MRT_TableFooterRow = (_a) => {
|
2453
2459
|
var _b;
|
2454
|
-
var { footerGroup, table, virtualColumns
|
2460
|
+
var { columnVirtualizer, footerGroup, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table", "virtualColumns"]);
|
2455
2461
|
const { options: { layoutMode, muiTableFooterRowProps }, } = table;
|
2462
|
+
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
2456
2463
|
// if no content in row, skip row
|
2457
2464
|
if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
2458
2465
|
!!header.column.columnDef.footer) ||
|
@@ -2471,7 +2478,7 @@ const MRT_TableFooterRow = (_a) => {
|
|
2471
2478
|
};
|
2472
2479
|
|
2473
2480
|
const MRT_TableFooter = (_a) => {
|
2474
|
-
var { table, virtualColumns
|
2481
|
+
var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
|
2475
2482
|
const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
2476
2483
|
const { isFullScreen } = getState();
|
2477
2484
|
const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
|
@@ -2488,11 +2495,11 @@ const MRT_TableFooter = (_a) => {
|
|
2488
2495
|
? theme.palette.mode === 'light'
|
2489
2496
|
? `1px solid ${theme.palette.grey[300]}`
|
2490
2497
|
: `1px solid ${theme.palette.grey[700]}`
|
2491
|
-
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { footerGroup: footerGroup, table: table, virtualColumns: virtualColumns
|
2498
|
+
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table, virtualColumns: virtualColumns }, footerGroup.id))) })));
|
2492
2499
|
};
|
2493
2500
|
|
2494
2501
|
const MRT_TableHeadCellColumnActionsButton = (_a) => {
|
2495
|
-
var _b;
|
2502
|
+
var _b, _c;
|
2496
2503
|
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
2497
2504
|
const { options: { icons: { MoreVertIcon }, localization, muiColumnActionsButtonProps, }, } = table;
|
2498
2505
|
const { column } = header;
|
@@ -2512,7 +2519,7 @@ const MRT_TableHeadCellColumnActionsButton = (_a) => {
|
|
2512
2519
|
})), rest);
|
2513
2520
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.columnActions, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ '&:hover': {
|
2514
2521
|
opacity: 1,
|
2515
|
-
}, height: '2rem', m: '-8px -4px', opacity: 0.3, transition: 'all 150ms', width: '2rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: jsxRuntime.jsx(MoreVertIcon, { style: { transform: 'scale(0.9)' } }) })) }), anchorEl && (jsxRuntime.jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
|
2522
|
+
}, height: '2rem', m: '-8px -4px', opacity: 0.3, transition: 'all 150ms', width: '2rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsxRuntime.jsx(MoreVertIcon, { style: { transform: 'scale(0.9)' } })) })) }), anchorEl && (jsxRuntime.jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
|
2516
2523
|
};
|
2517
2524
|
|
2518
2525
|
const MRT_FilterCheckbox = (_a) => {
|
@@ -2545,9 +2552,9 @@ const MRT_FilterCheckbox = (_a) => {
|
|
2545
2552
|
};
|
2546
2553
|
|
2547
2554
|
const MRT_FilterTextField = (_a) => {
|
2548
|
-
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
2555
|
+
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
2549
2556
|
var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
|
2550
|
-
const { options: { columnFilterModeOptions, enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
2557
|
+
const { options: { columnFilterModeOptions, enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
2551
2558
|
const { column } = header;
|
2552
2559
|
const { columnDef } = column;
|
2553
2560
|
const { filterVariant } = columnDef;
|
@@ -2563,7 +2570,15 @@ const MRT_FilterTextField = (_a) => {
|
|
2563
2570
|
column,
|
2564
2571
|
table,
|
2565
2572
|
}));
|
2566
|
-
const
|
2573
|
+
const dateTimePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterDateTimePickerProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterDateTimePickerProps, {
|
2574
|
+
column,
|
2575
|
+
table,
|
2576
|
+
}));
|
2577
|
+
const timePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTimePickerProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterTimePickerProps, {
|
2578
|
+
column,
|
2579
|
+
table,
|
2580
|
+
}));
|
2581
|
+
const isDateFilter = (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) || (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time'));
|
2567
2582
|
const isAutocompleteFilter = filterVariant === 'autocomplete';
|
2568
2583
|
const isRangeFilter = (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range')) || rangeFilterIndex !== undefined;
|
2569
2584
|
const isSelectFilter = filterVariant === 'select';
|
@@ -2730,12 +2745,22 @@ const MRT_FilterTextField = (_a) => {
|
|
2730
2745
|
: !filterChipLabel
|
2731
2746
|
? '120px'
|
2732
2747
|
: 'auto', mx: '-2px', p: 0, width: 'calc(100% + 4px)' }, parseFromValuesOrFunc(textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx, theme))) });
|
2733
|
-
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2748
|
+
const commonDatePickerProps = {
|
2749
|
+
onChange: (newDate) => {
|
2750
|
+
handleChange(newDate);
|
2751
|
+
},
|
2752
|
+
value: filterValue || null,
|
2753
|
+
};
|
2754
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsxRuntime.jsx(TimePicker.TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: {
|
2755
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_m = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _m === void 0 ? void 0 : _m.field),
|
2756
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_o = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _o === void 0 ? void 0 : _o.textField),
|
2757
|
+
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsxRuntime.jsx(DateTimePicker.DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: {
|
2758
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_p = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _p === void 0 ? void 0 : _p.field),
|
2759
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_q = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _q === void 0 ? void 0 : _q.textField),
|
2760
|
+
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsxRuntime.jsx(DatePicker.DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
|
2761
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_r = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.field),
|
2762
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
2763
|
+
} }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleChange(getValueAndLabel(newValue).value), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
2739
2764
|
var _a;
|
2740
2765
|
return (jsxRuntime.jsx(TextField__default["default"], Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange })));
|
2741
2766
|
}, value: filterValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ SelectProps: {
|
@@ -2750,7 +2775,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2750
2775
|
}, onChange: handleTextFieldChange, select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2751
2776
|
jsxRuntime.jsx(MenuItem__default["default"], { disabled: true, divider: true, hidden: true, value: "", children: jsxRuntime.jsx(Box__default["default"], { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
2752
2777
|
...[
|
2753
|
-
(
|
2778
|
+
(_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
2754
2779
|
var _a;
|
2755
2780
|
const { label, value } = getValueAndLabel(option);
|
2756
2781
|
return (jsxRuntime.jsxs(MenuItem__default["default"], { sx: {
|
@@ -3159,8 +3184,9 @@ const MRT_TableHeadCell = (_a) => {
|
|
3159
3184
|
};
|
3160
3185
|
|
3161
3186
|
const MRT_TableHeadRow = (_a) => {
|
3162
|
-
var { headerGroup, table, virtualColumns
|
3187
|
+
var { columnVirtualizer, headerGroup, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table", "virtualColumns"]);
|
3163
3188
|
const { options: { layoutMode, muiTableHeadRowProps }, } = table;
|
3189
|
+
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
3164
3190
|
const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
|
3165
3191
|
headerGroup,
|
3166
3192
|
table,
|
@@ -3229,7 +3255,7 @@ const MRT_TablePagination = (_a) => {
|
|
3229
3255
|
last: LastPageIcon,
|
3230
3256
|
next: ChevronRightIcon,
|
3231
3257
|
previous: ChevronLeftIcon,
|
3232
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) })), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }), showLastButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }))] })] })) : null] }));
|
3258
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToFirstPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) }) })), jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToPreviousPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }) }), jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToNextPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }) }), showLastButton && (jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToLastPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }) }))] })] })) : null] }));
|
3233
3259
|
};
|
3234
3260
|
|
3235
3261
|
const MRT_GlobalFilterTextField = (_a) => {
|
@@ -3601,7 +3627,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3601
3627
|
};
|
3602
3628
|
|
3603
3629
|
const MRT_TableHead = (_a) => {
|
3604
|
-
var { table, virtualColumns
|
3630
|
+
var { columnVirtualizer, table, virtualColumns } = _a, rest = __rest(_a, ["columnVirtualizer", "table", "virtualColumns"]);
|
3605
3631
|
const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
|
3606
3632
|
const { isFullScreen, showAlertBanner } = getState();
|
3607
3633
|
const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
|
@@ -3618,7 +3644,7 @@ const MRT_TableHead = (_a) => {
|
|
3618
3644
|
}, children: jsxRuntime.jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
|
3619
3645
|
display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
|
3620
3646
|
padding: 0,
|
3621
|
-
}, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { headerGroup: headerGroup, table: table, virtualColumns: virtualColumns
|
3647
|
+
}, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table, virtualColumns: virtualColumns }, headerGroup.id)))) })));
|
3622
3648
|
};
|
3623
3649
|
|
3624
3650
|
const MRT_Table = (_a) => {
|
@@ -3641,18 +3667,15 @@ const MRT_Table = (_a) => {
|
|
3641
3667
|
return colSizes;
|
3642
3668
|
}, [columns, columnSizing, columnSizingInfo, columnVisibility]);
|
3643
3669
|
const columnVirtualizer = useMRT_ColumnVirtualizer(table);
|
3644
|
-
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
3645
3670
|
const virtualColumns = columnVirtualizer
|
3646
3671
|
? columnVirtualizer.getVirtualItems()
|
3647
3672
|
: undefined;
|
3648
3673
|
const commonTableGroupProps = {
|
3674
|
+
columnVirtualizer,
|
3649
3675
|
table,
|
3650
3676
|
virtualColumns,
|
3651
|
-
virtualPaddingLeft,
|
3652
|
-
virtualPaddingRight,
|
3653
3677
|
};
|
3654
|
-
|
3655
|
-
return (jsxRuntime.jsxs(Table__default["default"], Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({}, commonTableBodyProps))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({}, commonTableBodyProps))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
|
3678
|
+
return (jsxRuntime.jsxs(Table__default["default"], Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
|
3656
3679
|
};
|
3657
3680
|
|
3658
3681
|
const MRT_TableLoadingOverlay = (_a) => {
|