material-react-table 3.0.3 → 3.2.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 +23 -73
- package/dist/index.esm.js +130 -107
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +130 -107
- package/dist/index.js.map +1 -1
- package/locales/ar/index.esm.js +1 -0
- package/locales/ar/index.js +1 -0
- package/locales/az/index.esm.js +1 -0
- package/locales/az/index.js +1 -0
- package/locales/bg/index.esm.js +1 -0
- package/locales/bg/index.js +1 -0
- package/locales/cs/index.esm.js +1 -0
- package/locales/cs/index.js +1 -0
- package/locales/da/index.esm.js +1 -0
- package/locales/da/index.js +1 -0
- package/locales/de/index.esm.js +1 -0
- package/locales/de/index.js +1 -0
- package/locales/el/index.esm.js +1 -0
- package/locales/el/index.js +1 -0
- package/locales/en/index.esm.js +1 -0
- package/locales/en/index.js +1 -0
- package/locales/es/index.esm.js +1 -0
- package/locales/es/index.js +1 -0
- package/locales/et/index.esm.js +1 -0
- package/locales/et/index.js +1 -0
- package/locales/fa/index.esm.js +1 -0
- package/locales/fa/index.js +1 -0
- package/locales/fi/index.esm.js +1 -0
- package/locales/fi/index.js +1 -0
- package/locales/fr/index.esm.js +1 -0
- package/locales/fr/index.js +1 -0
- package/locales/he/index.esm.js +1 -0
- package/locales/he/index.js +1 -0
- package/locales/hr/index.esm.js +1 -0
- package/locales/hr/index.js +1 -0
- package/locales/hu/index.esm.js +1 -0
- package/locales/hu/index.js +1 -0
- package/locales/hy/index.esm.js +1 -0
- package/locales/hy/index.js +1 -0
- package/locales/id/index.esm.js +1 -0
- package/locales/id/index.js +1 -0
- package/locales/it/index.esm.js +1 -0
- package/locales/it/index.js +1 -0
- package/locales/ja/index.esm.js +1 -0
- package/locales/ja/index.js +1 -0
- package/locales/ko/index.esm.js +1 -0
- package/locales/ko/index.js +1 -0
- package/locales/nl/index.esm.js +1 -0
- package/locales/nl/index.js +1 -0
- package/locales/no/index.esm.js +1 -0
- package/locales/no/index.js +1 -0
- package/locales/np/index.esm.js +1 -0
- package/locales/np/index.js +1 -0
- package/locales/pl/index.esm.js +1 -0
- package/locales/pl/index.js +1 -0
- package/locales/pt/index.esm.js +1 -0
- package/locales/pt/index.js +1 -0
- package/locales/pt-BR/index.esm.js +1 -0
- package/locales/pt-BR/index.js +1 -0
- package/locales/ro/index.esm.js +1 -0
- package/locales/ro/index.js +1 -0
- package/locales/ru/index.esm.js +1 -0
- package/locales/ru/index.js +1 -0
- package/locales/sk/index.esm.js +1 -0
- package/locales/sk/index.js +1 -0
- package/locales/sr-Cyrl-RS/index.esm.js +1 -0
- package/locales/sr-Cyrl-RS/index.js +1 -0
- package/locales/sr-Latn-RS/index.esm.js +1 -0
- package/locales/sr-Latn-RS/index.js +1 -0
- package/locales/sv/index.esm.js +1 -0
- package/locales/sv/index.js +1 -0
- package/locales/tr/index.esm.js +1 -0
- package/locales/tr/index.js +1 -0
- package/locales/uk/index.esm.js +1 -0
- package/locales/uk/index.js +1 -0
- package/locales/vi/index.esm.js +1 -0
- package/locales/vi/index.js +1 -0
- package/locales/zh-Hans/index.esm.js +1 -0
- package/locales/zh-Hans/index.js +1 -0
- package/locales/zh-Hant/index.esm.js +1 -0
- package/locales/zh-Hant/index.js +1 -0
- 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 +106 -70
- 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_TablePagination.tsx +5 -3
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +4 -4
- 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 +3 -3
- package/src/hooks/useMRT_RowVirtualizer.ts +17 -5
- package/src/hooks/useMRT_TableInstance.ts +1 -1
- package/src/locales/ar.ts +1 -0
- package/src/locales/az.ts +1 -0
- package/src/locales/bg.ts +1 -0
- package/src/locales/cs.ts +1 -0
- package/src/locales/da.ts +1 -0
- package/src/locales/de.ts +1 -0
- package/src/locales/el.ts +1 -0
- package/src/locales/en.ts +1 -0
- package/src/locales/es.ts +1 -0
- package/src/locales/et.ts +1 -0
- package/src/locales/fa.ts +1 -0
- package/src/locales/fi.ts +1 -0
- package/src/locales/fr.ts +1 -0
- package/src/locales/he.ts +1 -0
- package/src/locales/hr.ts +1 -0
- package/src/locales/hu.ts +1 -0
- package/src/locales/hy.ts +1 -0
- package/src/locales/id.ts +1 -0
- package/src/locales/it.ts +1 -0
- package/src/locales/ja.ts +1 -0
- package/src/locales/ko.ts +1 -0
- package/src/locales/nl.ts +1 -0
- package/src/locales/no.ts +1 -0
- package/src/locales/np.ts +1 -0
- package/src/locales/pl.ts +1 -0
- package/src/locales/pt-BR.ts +1 -0
- package/src/locales/pt.ts +1 -0
- package/src/locales/ro.ts +1 -0
- package/src/locales/ru.ts +1 -0
- package/src/locales/sk.ts +1 -0
- package/src/locales/sr-Cyrl-RS.ts +1 -0
- package/src/locales/sr-Latn-RS.ts +1 -0
- package/src/locales/sv.ts +1 -0
- package/src/locales/tr.ts +1 -0
- package/src/locales/uk.ts +1 -0
- package/src/locales/vi.ts +1 -0
- package/src/locales/zh-Hans.ts +1 -0
- package/src/locales/zh-Hant.ts +1 -0
- package/src/types.ts +17 -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/src/utils/virtualization.utils.ts +5 -0
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
|
});
|
@@ -1298,6 +1298,7 @@ const MRT_Default_Icons = {
|
|
1298
1298
|
};
|
1299
1299
|
|
1300
1300
|
const MRT_Localization_EN = {
|
1301
|
+
language: 'en',
|
1301
1302
|
actions: 'Actions',
|
1302
1303
|
and: 'and',
|
1303
1304
|
cancel: 'Cancel',
|
@@ -1542,8 +1543,8 @@ const useMRT_Effects = (table) => {
|
|
1542
1543
|
const totalColumnCount = table.options.columns.length;
|
1543
1544
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
1544
1545
|
const rerender = useReducer(() => ({}), {})[1];
|
1545
|
-
const initialBodyHeight = useRef();
|
1546
|
-
const previousTop = useRef();
|
1546
|
+
const initialBodyHeight = useRef(null);
|
1547
|
+
const previousTop = useRef(null);
|
1547
1548
|
useEffect(() => {
|
1548
1549
|
if (typeof window !== 'undefined') {
|
1549
1550
|
initialBodyHeight.current = document.body.style.height;
|
@@ -1583,7 +1584,7 @@ const useMRT_Effects = (table) => {
|
|
1583
1584
|
if (firstVisibleRowIndex >= totalRowCount) {
|
1584
1585
|
table.setPageIndex(Math.ceil(totalRowCount / pageSize) - 1);
|
1585
1586
|
}
|
1586
|
-
}, [totalRowCount]);
|
1587
|
+
}, [totalRowCount, enablePagination, isLoading, showSkeletons]);
|
1587
1588
|
//turn off sort when global filter is looking for ranked results
|
1588
1589
|
const appliedSort = useRef(sorting);
|
1589
1590
|
useEffect(() => {
|
@@ -1735,7 +1736,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1735
1736
|
statefulTableOptions.state.isLoading,
|
1736
1737
|
statefulTableOptions.state.showSkeletons,
|
1737
1738
|
]);
|
1738
|
-
//@ts-
|
1739
|
+
//@ts-expect-error
|
1739
1740
|
const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
|
1740
1741
|
onColumnSizingInfoChange,
|
1741
1742
|
onGroupingChange,
|
@@ -1797,6 +1798,11 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1797
1798
|
|
1798
1799
|
const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
|
1799
1800
|
|
1801
|
+
/**
|
1802
|
+
* When scroll, the `draggingRow` or `draggingColumn` can be removed from document because of virtualization,
|
1803
|
+
* then, the `dragEnd` event on `MRT_TableBodyRowGrabHandle` or `MRT_TableHeadCellGrabHandle` will not fire.
|
1804
|
+
* We should keep the `draggingRow` or `draggingColumn` in `getVirtualItems()` to avoid this thing.
|
1805
|
+
*/
|
1800
1806
|
const extraIndexRangeExtractor = (range, draggingIndex) => {
|
1801
1807
|
const newIndexes = defaultRangeExtractor(range);
|
1802
1808
|
if (draggingIndex === undefined)
|
@@ -1865,14 +1871,13 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1865
1871
|
(numPinnedRight ? totalSize - rightNonPinnedStart : 0);
|
1866
1872
|
}
|
1867
1873
|
if (columnVirtualizerInstanceRef) {
|
1868
|
-
//@ts-
|
1874
|
+
//@ts-expect-error
|
1869
1875
|
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
1870
1876
|
}
|
1871
1877
|
return columnVirtualizer;
|
1872
1878
|
};
|
1873
1879
|
|
1874
1880
|
const useMRT_RowVirtualizer = (table, rows) => {
|
1875
|
-
var _a;
|
1876
1881
|
const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
|
1877
1882
|
const { density, draggingRow, expanded } = getState();
|
1878
1883
|
if (!enableRowVirtualization)
|
@@ -1880,7 +1885,14 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1880
1885
|
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
1881
1886
|
table,
|
1882
1887
|
});
|
1883
|
-
const
|
1888
|
+
const realRows = rows !== null && rows !== void 0 ? rows : getRowModel().rows;
|
1889
|
+
/**
|
1890
|
+
* when filtering, should find the correct index in filtered rows
|
1891
|
+
*/
|
1892
|
+
const draggingRowIndex = useMemo(() => (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id)
|
1893
|
+
? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
|
1894
|
+
: undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
|
1895
|
+
const rowCount = realRows.length;
|
1884
1896
|
const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
|
1885
1897
|
const rowVirtualizer = useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
|
1886
1898
|
? expanded === true
|
@@ -1890,12 +1902,11 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1890
1902
|
navigator.userAgent.indexOf('Firefox') === -1
|
1891
1903
|
? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
|
1892
1904
|
: undefined, overscan: 4, rangeExtractor: useCallback((range) => {
|
1893
|
-
|
1894
|
-
|
1895
|
-
}, [draggingRow]) }, rowVirtualizerProps));
|
1905
|
+
return extraIndexRangeExtractor(range, draggingRowIndex);
|
1906
|
+
}, [draggingRowIndex]) }, rowVirtualizerProps));
|
1896
1907
|
rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
|
1897
1908
|
if (rowVirtualizerInstanceRef) {
|
1898
|
-
//@ts-
|
1909
|
+
//@ts-expect-error
|
1899
1910
|
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
1900
1911
|
}
|
1901
1912
|
return rowVirtualizer;
|
@@ -2054,7 +2065,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
2054
2065
|
});
|
2055
2066
|
const isSelectEdit = editVariant === 'select' || (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select);
|
2056
2067
|
const saveInputValueToRowCache = (newValue) => {
|
2057
|
-
//@ts-
|
2068
|
+
//@ts-expect-error
|
2058
2069
|
row._valuesCache[column.id] = newValue;
|
2059
2070
|
if (isCreating) {
|
2060
2071
|
setCreatingRow(row);
|
@@ -2078,10 +2089,10 @@ const MRT_EditCellTextField = (_a) => {
|
|
2078
2089
|
setEditingCell(null);
|
2079
2090
|
};
|
2080
2091
|
const handleEnterKeyDown = (event) => {
|
2081
|
-
var _a, _b;
|
2092
|
+
var _a, _b, _c;
|
2082
2093
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
2083
2094
|
if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
|
2084
|
-
(_b = editInputRefs.current[column.id]) === null ||
|
2095
|
+
(_c = (_b = editInputRefs.current) === null || _b === void 0 ? void 0 : _b[column.id]) === null || _c === void 0 ? void 0 : _c.blur();
|
2085
2096
|
}
|
2086
2097
|
};
|
2087
2098
|
if (columnDef.Edit) {
|
@@ -2089,7 +2100,9 @@ const MRT_EditCellTextField = (_a) => {
|
|
2089
2100
|
}
|
2090
2101
|
return (jsx(TextField, Object.assign({ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false, fullWidth: true, inputRef: (inputRef) => {
|
2091
2102
|
if (inputRef) {
|
2092
|
-
editInputRefs.current[column.id] =
|
2103
|
+
editInputRefs.current[column.id] = isSelectEdit
|
2104
|
+
? inputRef.node
|
2105
|
+
: inputRef;
|
2093
2106
|
if (textFieldProps.inputRef) {
|
2094
2107
|
textFieldProps.inputRef = inputRef;
|
2095
2108
|
}
|
@@ -2206,7 +2219,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2206
2219
|
const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
|
2207
2220
|
parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
|
2208
2221
|
!['context-menu', false].includes(
|
2209
|
-
// @ts-
|
2222
|
+
// @ts-expect-error
|
2210
2223
|
parseFromValuesOrFunc(columnDef.enableClickToCopy, cell));
|
2211
2224
|
const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
|
2212
2225
|
const cellValueProps = {
|
@@ -2362,7 +2375,7 @@ const MRT_TableBodyRow = (_a) => {
|
|
2362
2375
|
const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
|
2363
2376
|
const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
|
2364
2377
|
const customRowHeight =
|
2365
|
-
// @ts-
|
2378
|
+
// @ts-expect-error
|
2366
2379
|
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
2380
|
const rowHeight = customRowHeight || defaultRowHeight;
|
2368
2381
|
const handleDragEnter = (_e) => {
|
@@ -2604,7 +2617,7 @@ const MRT_TableFooter = (_a) => {
|
|
2604
2617
|
return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
|
2605
2618
|
tableFooterRef.current = ref;
|
2606
2619
|
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
2607
|
-
// @ts-
|
2620
|
+
// @ts-expect-error
|
2608
2621
|
tableFooterProps.ref.current = ref;
|
2609
2622
|
}
|
2610
2623
|
}, 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 +2878,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2865
2878
|
};
|
2866
2879
|
const handleFilterByColumn = () => {
|
2867
2880
|
setShowColumnFilters(true);
|
2868
|
-
queueMicrotask(() => { var _a; return (_a = filterInputRefs.current[`${column.id}-0`]) === null ||
|
2881
|
+
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
2882
|
setAnchorEl(null);
|
2870
2883
|
};
|
2871
2884
|
const handleShowAllColumns = () => {
|
@@ -2888,7 +2901,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2888
2901
|
const internalColumnMenuItems = [
|
2889
2902
|
...(enableSorting && column.getCanSort()
|
2890
2903
|
? [
|
2891
|
-
enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
|
2904
|
+
enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === false, icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
|
2892
2905
|
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
2906
|
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
2907
|
]
|
@@ -2918,7 +2931,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2918
2931
|
: []),
|
2919
2932
|
...(enableColumnResizing && column.getCanResize()
|
2920
2933
|
? [
|
2921
|
-
jsx(MRT_ActionMenuItem, { disabled:
|
2934
|
+
jsx(MRT_ActionMenuItem, { disabled: columnSizing[column.id] === undefined, icon: jsx(RestartAltIcon, {}), label: localization.resetColumnSize, onClick: handleResetColumnSize, table: table }, 10),
|
2922
2935
|
]
|
2923
2936
|
: []),
|
2924
2937
|
...(enableHiding
|
@@ -3001,7 +3014,7 @@ const MRT_FilterCheckbox = (_a) => {
|
|
3001
3014
|
};
|
3002
3015
|
|
3003
3016
|
const MRT_FilterTextField = (_a) => {
|
3004
|
-
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
3017
|
+
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3005
3018
|
var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
|
3006
3019
|
const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
3007
3020
|
const { column } = header;
|
@@ -3016,9 +3029,8 @@ const MRT_FilterTextField = (_a) => {
|
|
3016
3029
|
const { allowedColumnFilterOptions, currentFilterOption, facetedUniqueValues, isAutocompleteFilter, isDateFilter, isMultiSelectFilter, isRangeFilter, isSelectFilter, isTextboxFilter, } = getColumnFilterInfo({ header, table });
|
3017
3030
|
const dropdownOptions = useDropdownOptions({ header, table });
|
3018
3031
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
3019
|
-
?
|
3020
|
-
|
3021
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
3032
|
+
? 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()) +
|
3033
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
3022
3034
|
: '';
|
3023
3035
|
const filterPlaceholder = !isRangeFilter
|
3024
3036
|
? ((_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)))
|
@@ -3039,9 +3051,11 @@ const MRT_FilterTextField = (_a) => {
|
|
3039
3051
|
? column.getFilterValue() || []
|
3040
3052
|
: isRangeFilter
|
3041
3053
|
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
3042
|
-
:
|
3054
|
+
: isAutocompleteFilter
|
3055
|
+
? typeof column.getFilterValue() === 'string' ? column.getFilterValue() : ''
|
3056
|
+
: ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
|
3043
3057
|
});
|
3044
|
-
const [autocompleteValue, setAutocompleteValue] = useState(isAutocompleteFilter ?
|
3058
|
+
const [autocompleteValue, setAutocompleteValue] = useState(() => isAutocompleteFilter ? (column.getFilterValue() || null) : null);
|
3045
3059
|
const handleChangeDebounced = useCallback(debounce((newValue) => {
|
3046
3060
|
if (isRangeFilter) {
|
3047
3061
|
column.setFilterValue((old) => {
|
@@ -3068,9 +3082,12 @@ const MRT_FilterTextField = (_a) => {
|
|
3068
3082
|
handleChange(newValue);
|
3069
3083
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
3070
3084
|
};
|
3085
|
+
const handleAutocompleteInputChange = (_event, newValue, _reason) => {
|
3086
|
+
handleChange(newValue);
|
3087
|
+
};
|
3071
3088
|
const handleAutocompleteChange = (newValue) => {
|
3072
3089
|
setAutocompleteValue(newValue);
|
3073
|
-
|
3090
|
+
handleChangeDebounced(getValueAndLabel(newValue).value);
|
3074
3091
|
};
|
3075
3092
|
const handleClear = () => {
|
3076
3093
|
if (isMultiSelectFilter) {
|
@@ -3085,6 +3102,13 @@ const MRT_FilterTextField = (_a) => {
|
|
3085
3102
|
return newFilterValues;
|
3086
3103
|
});
|
3087
3104
|
}
|
3105
|
+
else if (isAutocompleteFilter) {
|
3106
|
+
setAutocompleteValue(null);
|
3107
|
+
setFilterValue('');
|
3108
|
+
// when using 'autocomplete' this function is called only inside effect and only if the filterValue === undefined
|
3109
|
+
// so the following call is excessive; should be uncommented if the handleClear becomes part of the Autocomplete component callbacks
|
3110
|
+
// column.setFilterValue(undefined)
|
3111
|
+
}
|
3088
3112
|
else {
|
3089
3113
|
setFilterValue('');
|
3090
3114
|
column.setFilterValue(undefined);
|
@@ -3120,33 +3144,17 @@ const MRT_FilterTextField = (_a) => {
|
|
3120
3144
|
if (columnDef.Filter) {
|
3121
3145
|
return (jsx(Fragment, { children: (_g = columnDef.Filter) === null || _g === void 0 ? void 0 : _g.call(columnDef, { column, header, rangeFilterIndex, table }) }));
|
3122
3146
|
}
|
3123
|
-
const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsx(InputAdornment, { position: "end", sx: {
|
3147
|
+
const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsx(InputAdornment, { position: "end", sx: {
|
3148
|
+
mr: isSelectFilter || isMultiSelectFilter ? '20px' : undefined,
|
3149
|
+
visibility: ((_h = filterValue === null || filterValue === void 0 ? void 0 : filterValue.length) !== null && _h !== void 0 ? _h : 0) > 0 ? 'visible' : 'hidden',
|
3150
|
+
}, 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
3151
|
height: '2rem',
|
3125
3152
|
transform: 'scale(0.9)',
|
3126
3153
|
width: '2rem',
|
3127
3154
|
}, children: jsx(CloseIcon, {}) }) }) }) })) : null;
|
3128
3155
|
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) => {
|
3156
|
+
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()) +
|
3157
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputRef: (inputRef) => {
|
3150
3158
|
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
3151
3159
|
inputRef;
|
3152
3160
|
if (textFieldProps.inputRef) {
|
@@ -3154,7 +3162,16 @@ const MRT_FilterTextField = (_a) => {
|
|
3154
3162
|
}
|
3155
3163
|
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
3156
3164
|
? undefined
|
3157
|
-
: filterPlaceholder, variant: 'standard' }, textFieldProps), {
|
3165
|
+
: filterPlaceholder, variant: 'standard' }, textFieldProps), { slotProps: Object.assign(Object.assign({}, textFieldProps.slotProps), { formHelperText: Object.assign({ sx: {
|
3166
|
+
fontSize: '0.75rem',
|
3167
|
+
lineHeight: '0.8rem',
|
3168
|
+
whiteSpace: 'nowrap',
|
3169
|
+
} }, (_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
|
3170
|
+
? { endAdornment, startAdornment }
|
3171
|
+
: { startAdornment }, htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3172
|
+
textOverflow: 'ellipsis',
|
3173
|
+
width: filterChipLabel ? 0 : undefined,
|
3174
|
+
}, title: filterPlaceholder }, (_o = textFieldProps.slotProps) === null || _o === void 0 ? void 0 : _o.htmlInput) }), onKeyDown: (e) => {
|
3158
3175
|
var _a;
|
3159
3176
|
e.stopPropagation();
|
3160
3177
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
@@ -3174,32 +3191,32 @@ const MRT_FilterTextField = (_a) => {
|
|
3174
3191
|
value: filterValue || null,
|
3175
3192
|
};
|
3176
3193
|
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), (
|
3194
|
+
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),
|
3195
|
+
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
3196
|
} }))) : (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), (
|
3197
|
+
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),
|
3198
|
+
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
3199
|
} }))) : (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
|
-
|
3200
|
+
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),
|
3201
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_u = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _u === void 0 ? void 0 : _u.textField),
|
3202
|
+
} }))) : 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 : [], inputValue: filterValue, onInputChange: handleAutocompleteInputChange }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
3203
|
+
var _a, _b, _c, _d, _f;
|
3204
|
+
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:
|
3205
|
+
//@ts-expect-error
|
3206
|
+
(_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) }), onClick: (e) => e.stopPropagation() })));
|
3207
|
+
}, 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
|
3208
|
+
? (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) => {
|
3209
|
+
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
3210
|
+
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
3211
|
+
}) }))
|
3212
|
+
: undefined }, (_x = commonTextFieldProps.slotProps) === null || _x === void 0 ? void 0 : _x.select) }), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
|
3196
3213
|
? Array.isArray(filterValue)
|
3197
3214
|
? filterValue
|
3198
3215
|
: []
|
3199
3216
|
: filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
|
3200
3217
|
jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
3201
3218
|
...[
|
3202
|
-
(
|
3219
|
+
(_y = textFieldProps.children) !== null && _y !== void 0 ? _y : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
3203
3220
|
var _a;
|
3204
3221
|
const { label, value } = getValueAndLabel(option);
|
3205
3222
|
return (jsxs(MenuItem, { sx: {
|
@@ -3243,6 +3260,12 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3243
3260
|
const [filterValues, setFilterValues] = useState([min, max]);
|
3244
3261
|
const columnFilterValue = column.getFilterValue();
|
3245
3262
|
const isMounted = useRef(false);
|
3263
|
+
// prevent moving the focus to the next/prev cell when using the arrow keys
|
3264
|
+
const handleKeyDown = (event) => {
|
3265
|
+
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
3266
|
+
event.stopPropagation();
|
3267
|
+
}
|
3268
|
+
};
|
3246
3269
|
useEffect(() => {
|
3247
3270
|
if (isMounted.current) {
|
3248
3271
|
if (columnFilterValue === undefined) {
|
@@ -3266,15 +3289,15 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3266
3289
|
column.setFilterValue(value);
|
3267
3290
|
}
|
3268
3291
|
}
|
3269
|
-
}, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
|
3292
|
+
}, onKeyDown: handleKeyDown, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
|
3270
3293
|
input: {
|
3271
3294
|
ref: (node) => {
|
3272
3295
|
var _a, _b;
|
3273
3296
|
if (node) {
|
3274
3297
|
filterInputRefs.current[`${column.id}-0`] = node;
|
3275
|
-
// @ts-
|
3298
|
+
// @ts-expect-error
|
3276
3299
|
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-
|
3300
|
+
//@ts-expect-error
|
3278
3301
|
sliderProps.slotProps.input.ref = node;
|
3279
3302
|
}
|
3280
3303
|
}
|
@@ -3285,9 +3308,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3285
3308
|
lineHeight: '0.8rem',
|
3286
3309
|
m: '-3px -6px',
|
3287
3310
|
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()) +
|
3311
|
+
}, 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
3312
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
|
3292
3313
|
};
|
3293
3314
|
|
@@ -3302,7 +3323,7 @@ const MRT_TableHeadCellFilterContainer = (_a) => {
|
|
3302
3323
|
};
|
3303
3324
|
|
3304
3325
|
const MRT_TableHeadCellFilterLabel = (_a) => {
|
3305
|
-
var _b
|
3326
|
+
var _b;
|
3306
3327
|
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
3307
3328
|
const { options: { columnFilterDisplayMode, icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
|
3308
3329
|
const { column } = header;
|
@@ -3320,9 +3341,8 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3320
3341
|
: localization.filteringByColumn
|
3321
3342
|
.replace('{column}', String(columnDef.header))
|
3322
3343
|
.replace('{filterType}', currentFilterOption
|
3323
|
-
?
|
3324
|
-
|
3325
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
3344
|
+
? localization[`filter${currentFilterOption.charAt(0).toUpperCase() +
|
3345
|
+
currentFilterOption.slice(1)}`]
|
3326
3346
|
: '')
|
3327
3347
|
.replace('{filterValue}', `"${Array.isArray(filterValue)
|
3328
3348
|
? filterValue
|
@@ -3334,8 +3354,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3334
3354
|
.replace('" "', '');
|
3335
3355
|
return (jsxs(Fragment, { children: [jsx(Grow, { in: columnFilterDisplayMode === 'popover' ||
|
3336
3356
|
(!!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) => {
|
3357
|
+
(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
3358
|
if (columnFilterDisplayMode === 'popover') {
|
3340
3359
|
setAnchorEl(event.currentTarget);
|
3341
3360
|
}
|
@@ -3343,16 +3362,16 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3343
3362
|
setShowColumnFilters(true);
|
3344
3363
|
}
|
3345
3364
|
queueMicrotask(() => {
|
3346
|
-
var _a, _b, _c, _d;
|
3347
|
-
(_b = (_a = filterInputRefs.current[`${column.id}-0`]) === null ||
|
3348
|
-
(
|
3365
|
+
var _a, _b, _c, _d, _e, _f;
|
3366
|
+
(_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);
|
3367
|
+
(_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
3368
|
});
|
3350
3369
|
event.stopPropagation();
|
3351
3370
|
}, 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
3371
|
horizontal: 'center',
|
3353
3372
|
vertical: 'top',
|
3354
3373
|
}, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
|
3355
|
-
//@ts-
|
3374
|
+
//@ts-expect-error
|
3356
3375
|
event.stopPropagation();
|
3357
3376
|
setAnchorEl(null);
|
3358
3377
|
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, slotProps: { paper: { sx: { overflow: 'visible' } } }, transformOrigin: {
|
@@ -3471,7 +3490,7 @@ const MRT_TableHeadCellSortLabel = (_a) => {
|
|
3471
3490
|
};
|
3472
3491
|
|
3473
3492
|
const MRT_TableHeadCell = (_a) => {
|
3474
|
-
var _b, _c, _d, _f, _g, _h;
|
3493
|
+
var _b, _c, _d, _f, _g, _h, _j;
|
3475
3494
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
3476
3495
|
const theme = useTheme();
|
3477
3496
|
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableKeyboardShortcuts, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
@@ -3638,7 +3657,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3638
3657
|
}, 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
3658
|
whiteSpace: 'nowrap',
|
3640
3659
|
}, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3641
|
-
current: tableHeadCellRefs.current[column.id],
|
3660
|
+
current: (_j = tableHeadCellRefs.current) === null || _j === void 0 ? void 0 : _j[column.id],
|
3642
3661
|
} })), 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
3662
|
};
|
3644
3663
|
|
@@ -3666,7 +3685,7 @@ const MRT_TableHeadRow = (_a) => {
|
|
3666
3685
|
const MRT_ToolbarAlertBanner = (_a) => {
|
3667
3686
|
var _b, _c, _d;
|
3668
3687
|
var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
|
3669
|
-
const { getFilteredSelectedRowModel,
|
3688
|
+
const { getFilteredSelectedRowModel, getCoreRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
|
3670
3689
|
const { density, grouping, rowSelection, showAlertBanner } = getState();
|
3671
3690
|
const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
3672
3691
|
table,
|
@@ -3674,11 +3693,11 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
3674
3693
|
const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
|
3675
3694
|
table,
|
3676
3695
|
});
|
3677
|
-
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount :
|
3696
|
+
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getCoreRowModel().rows.length;
|
3678
3697
|
const selectedRowCount = useMemo(() => manualPagination
|
3679
3698
|
? Object.values(rowSelection).filter(Boolean).length
|
3680
3699
|
: getFilteredSelectedRowModel().rows.length, [rowSelection, totalRowCount, manualPagination]);
|
3681
|
-
const selectedAlert = selectedRowCount > 0 ? (jsxs(Stack, { alignItems: "center", direction: "row", gap: "16px", children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.
|
3700
|
+
const selectedAlert = selectedRowCount > 0 ? (jsxs(Stack, { alignItems: "center", direction: "row", gap: "16px", children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString(localization.language))) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.toLocaleString(localization.language)), jsx(Button, { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
|
3682
3701
|
const groupedAlert = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
3683
3702
|
return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
3684
3703
|
var _a, _b;
|
@@ -3716,7 +3735,7 @@ const MRT_TableHead = (_a) => {
|
|
3716
3735
|
return (jsx(TableHead, Object.assign({}, tableHeadProps, { ref: (ref) => {
|
3717
3736
|
tableHeadRef.current = ref;
|
3718
3737
|
if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
|
3719
|
-
// @ts-
|
3738
|
+
// @ts-expect-error
|
3720
3739
|
tableHeadProps.ref.current = ref;
|
3721
3740
|
}
|
3722
3741
|
}, 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 +3906,7 @@ const MRT_TableContainer = (_a) => {
|
|
3887
3906
|
if (node) {
|
3888
3907
|
tableContainerRef.current = node;
|
3889
3908
|
if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
|
3890
|
-
//@ts-
|
3909
|
+
//@ts-expect-error
|
3891
3910
|
tableContainerProps.ref.current = node;
|
3892
3911
|
}
|
3893
3912
|
}
|
@@ -3963,7 +3982,9 @@ const MRT_TablePagination = (_a) => {
|
|
3963
3982
|
last: LastPageIcon,
|
3964
3983
|
next: ChevronRightIcon,
|
3965
3984
|
previous: ChevronLeftIcon,
|
3966
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, restPaginationProps))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0
|
3985
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, restPaginationProps))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0
|
3986
|
+
? 0
|
3987
|
+
: (firstRowIndex + 1).toLocaleString(localization.language)}-${lastRowIndex.toLocaleString(localization.language)} ${localization.of} ${totalRowCount.toLocaleString(localization.language)}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => table.firstPage(), size: "small", children: jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => table.previousPage(), size: "small", children: jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => table.nextPage(), size: "small", children: jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), showLastButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => table.lastPage(), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })))] })] })) : null] }));
|
3967
3988
|
};
|
3968
3989
|
|
3969
3990
|
const MRT_ToolbarDropZone = (_a) => {
|
@@ -4000,7 +4021,7 @@ const MRT_BottomToolbar = (_a) => {
|
|
4000
4021
|
if (node) {
|
4001
4022
|
bottomToolbarRef.current = node;
|
4002
4023
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
4003
|
-
// @ts-
|
4024
|
+
// @ts-expect-error
|
4004
4025
|
toolbarProps.ref.current = node;
|
4005
4026
|
}
|
4006
4027
|
}
|
@@ -4103,7 +4124,7 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
4103
4124
|
|
4104
4125
|
const MRT_ShowHideColumnsMenu = (_a) => {
|
4105
4126
|
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;
|
4127
|
+
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, initialState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
|
4107
4128
|
const { columnOrder, columnPinning, density } = getState();
|
4108
4129
|
const handleToggleAllColumns = (value) => {
|
4109
4130
|
getAllLeafColumns()
|
@@ -4130,6 +4151,8 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
4130
4151
|
getRightLeafColumns(),
|
4131
4152
|
]);
|
4132
4153
|
const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === 'group');
|
4154
|
+
const hasColumnOrderChanged = useMemo(() => columnOrder.length !== initialState.columnOrder.length ||
|
4155
|
+
!columnOrder.every((column, index) => column === initialState.columnOrder[index]), [columnOrder, initialState.columnOrder]);
|
4133
4156
|
const [hoveredColumn, setHoveredColumn] = useState(null);
|
4134
4157
|
return (jsxs(Menu, Object.assign({ MenuListProps: {
|
4135
4158
|
dense: density === 'compact',
|
@@ -4141,7 +4164,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
4141
4164
|
justifyContent: 'space-between',
|
4142
4165
|
p: '0.5rem',
|
4143
4166
|
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}`)))] })));
|
4167
|
+
}, 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
4168
|
};
|
4146
4169
|
|
4147
4170
|
const MRT_ShowHideColumnsButton = (_a) => {
|
@@ -4289,7 +4312,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
4289
4312
|
return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
|
4290
4313
|
topToolbarRef.current = ref;
|
4291
4314
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
4292
|
-
// @ts-
|
4315
|
+
// @ts-expect-error
|
4293
4316
|
toolbarProps.ref.current = ref;
|
4294
4317
|
}
|
4295
4318
|
}, 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 +4347,7 @@ const MRT_TablePaper = (_a) => {
|
|
4324
4347
|
return (jsxs(Paper, Object.assign({ elevation: 2, onKeyDown: (e) => e.key === 'Escape' && table.setIsFullScreen(false) }, paperProps, { ref: (ref) => {
|
4325
4348
|
tablePaperRef.current = ref;
|
4326
4349
|
if (paperProps === null || paperProps === void 0 ? void 0 : paperProps.ref) {
|
4327
|
-
//@ts-
|
4350
|
+
//@ts-expect-error
|
4328
4351
|
paperProps.ref.current = ref;
|
4329
4352
|
}
|
4330
4353
|
}, style: Object.assign(Object.assign({}, (isFullScreen
|