material-react-table 2.0.0-alpha.5 → 2.0.0-alpha.6
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/cjs/index.js +49 -25
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/column.utils.d.ts +2 -0
- package/dist/cjs/types/types.d.ts +6 -18
- package/dist/esm/material-react-table.esm.js +50 -27
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/column.utils.d.ts +2 -0
- package/dist/esm/types/types.d.ts +6 -18
- package/dist/index.d.ts +9 -20
- package/package.json +1 -1
- package/src/body/MRT_TableBody.tsx +20 -4
- package/src/column.utils.ts +19 -0
- package/src/filterFns.ts +3 -3
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +2 -0
- package/src/hooks/useMRT_TableInstance.ts +6 -6
- package/src/inputs/MRT_FilterTextField.tsx +4 -3
- package/src/table/MRT_Table.tsx +20 -10
- package/src/toolbar/MRT_TablePagination.tsx +3 -4
- package/src/types.ts +6 -10
@@ -1,5 +1,6 @@
|
|
1
1
|
import { type ReactNode } from 'react';
|
2
2
|
import { type Renderable, type Row } from '@tanstack/react-table';
|
3
|
+
import { type Range } from '@tanstack/react-virtual';
|
3
4
|
import { type TableCellProps } from '@mui/material/TableCell';
|
4
5
|
import { type Theme } from '@mui/material/styles';
|
5
6
|
import { type MRT_AggregationFns } from './aggregationFns';
|
@@ -144,3 +145,4 @@ export declare const parseFromValuesOrFunc: <T, U>(fn: T | ((arg: U) => T) | und
|
|
144
145
|
export declare const parseCSSVarId: (id: string) => string;
|
145
146
|
export declare const flexRender: (Comp: Renderable<any>, props: any) => JSX.Element | ReactNode;
|
146
147
|
export declare const createRow: <TData extends Record<string, any>>(table: MRT_TableInstance<TData>, originalRow?: TData | undefined) => MRT_Row<TData>;
|
148
|
+
export declare const extraIndexRangeExtractor: (range: Range, draggingIndex: number) => number[];
|
@@ -180,12 +180,8 @@ export type MRT_TableInstance<TData extends Record<string, any>> = Omit<Table<TD
|
|
180
180
|
setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
|
181
181
|
setEditingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
|
182
182
|
setGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
|
183
|
-
setHoveredColumn: Dispatch<SetStateAction<
|
184
|
-
|
185
|
-
} | MRT_Column<TData> | null>>;
|
186
|
-
setHoveredRow: Dispatch<SetStateAction<{
|
187
|
-
id: string;
|
188
|
-
} | MRT_Row<TData> | null>>;
|
183
|
+
setHoveredColumn: Dispatch<SetStateAction<Partial<MRT_Column<TData>> | null>>;
|
184
|
+
setHoveredRow: Dispatch<SetStateAction<Partial<MRT_Row<TData>> | null>>;
|
189
185
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
190
186
|
setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
|
191
187
|
setShowColumnFilters: Dispatch<SetStateAction<boolean>>;
|
@@ -205,12 +201,8 @@ export type MRT_TableState<TData extends Record<string, any>> = TableState & {
|
|
205
201
|
editingCell: MRT_Cell<TData> | null;
|
206
202
|
editingRow: MRT_Row<TData> | null;
|
207
203
|
globalFilterFn: MRT_FilterOption;
|
208
|
-
hoveredColumn:
|
209
|
-
|
210
|
-
} | MRT_Column<TData> | null;
|
211
|
-
hoveredRow: {
|
212
|
-
id: string;
|
213
|
-
} | MRT_Row<TData> | null;
|
204
|
+
hoveredColumn: Partial<MRT_Column<TData>> | null;
|
205
|
+
hoveredRow: Partial<MRT_Row<TData>> | null;
|
214
206
|
isFullScreen: boolean;
|
215
207
|
isLoading: boolean;
|
216
208
|
isSaving: boolean;
|
@@ -727,12 +719,8 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<Partial<T
|
|
727
719
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
728
720
|
}) => Promise<void> | void;
|
729
721
|
onGlobalFilterFnChange?: OnChangeFn<MRT_FilterOption>;
|
730
|
-
onHoveredColumnChange?: OnChangeFn<
|
731
|
-
|
732
|
-
} | MRT_Column<TData> | null>;
|
733
|
-
onHoveredRowChange?: OnChangeFn<{
|
734
|
-
id: string;
|
735
|
-
} | MRT_Row<TData> | null>;
|
722
|
+
onHoveredColumnChange?: OnChangeFn<Partial<MRT_Column<TData>> | null>;
|
723
|
+
onHoveredRowChange?: OnChangeFn<Partial<MRT_Row<TData>> | null>;
|
736
724
|
onIsFullScreenChange?: OnChangeFn<boolean>;
|
737
725
|
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
738
726
|
onShowColumnFiltersChange?: OnChangeFn<boolean>;
|
@@ -2,7 +2,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import Paper from '@mui/material/Paper';
|
3
3
|
import { useState, memo, useEffect, useMemo, useRef, useCallback, Fragment as Fragment$1, useLayoutEffect, useReducer } from 'react';
|
4
4
|
import TableContainer from '@mui/material/TableContainer';
|
5
|
-
import {
|
5
|
+
import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
|
6
6
|
import Table from '@mui/material/Table';
|
7
7
|
import TableBody from '@mui/material/TableBody';
|
8
8
|
import Typography from '@mui/material/Typography';
|
@@ -392,6 +392,17 @@ const flexRender = flexRender$1;
|
|
392
392
|
const createRow = (table, originalRow) => createRow$1(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
|
393
393
|
[getColumnId(col)]: '',
|
394
394
|
}))), -1, 0);
|
395
|
+
const extraIndexRangeExtractor = (range, draggingIndex) => {
|
396
|
+
const newIndexs = defaultRangeExtractor(range);
|
397
|
+
if (draggingIndex >= 0 &&
|
398
|
+
draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
|
399
|
+
newIndexs.unshift(draggingIndex);
|
400
|
+
}
|
401
|
+
if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
|
402
|
+
newIndexs.push(draggingIndex);
|
403
|
+
}
|
404
|
+
return newIndexs;
|
405
|
+
};
|
395
406
|
|
396
407
|
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
397
408
|
var _a;
|
@@ -836,7 +847,7 @@ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFil
|
|
836
847
|
const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
837
848
|
var _a, _b, _c, _d, _e, _f;
|
838
849
|
const { getBottomRows, getCenterRows, getIsSomeRowsPinned, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { enableGlobalFilterRankedResults, enablePagination, enableRowPinning, enableRowVirtualization, enableStickyFooter, enableStickyHeader, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef, tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
839
|
-
const { columnFilters, density, expanded, globalFilter, isFullScreen, pagination, rowPinning, sorting, } = getState();
|
850
|
+
const { columnFilters, density, draggingRow, expanded, globalFilter, isFullScreen, pagination, rowPinning, sorting, } = getState();
|
840
851
|
const tableBodyProps = parseFromValuesOrFunc(muiTableBodyProps, { table });
|
841
852
|
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
842
853
|
table,
|
@@ -894,7 +905,10 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
|
|
894
905
|
? useVirtualizer(Object.assign({ count: rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
|
895
906
|
navigator.userAgent.indexOf('Firefox') === -1
|
896
907
|
? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
|
897
|
-
: undefined, overscan: 4
|
908
|
+
: undefined, overscan: 4, rangeExtractor: useCallback((range) => {
|
909
|
+
var _a;
|
910
|
+
return extraIndexRangeExtractor(range, (_a = draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.index) !== null && _a !== void 0 ? _a : 0);
|
911
|
+
}, [draggingRow]) }, rowVirtualizerProps))
|
898
912
|
: undefined;
|
899
913
|
if (rowVirtualizerInstanceRef && rowVirtualizer) {
|
900
914
|
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
@@ -918,8 +932,12 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
|
|
918
932
|
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
919
933
|
}) }))), jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
|
920
934
|
? `${rowVirtualizer.getTotalSize()}px`
|
921
|
-
: 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: (_c = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _c !== void 0 ? _c : (!rows.length ? (jsx("tr", { style: {
|
922
|
-
|
935
|
+
: 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: (_c = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _c !== void 0 ? _c : (!rows.length ? (jsx("tr", { style: {
|
936
|
+
display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
|
937
|
+
}, children: jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
|
938
|
+
display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
|
939
|
+
? 'grid'
|
940
|
+
: 'table-cell',
|
923
941
|
}, children: (_d = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _d !== void 0 ? _d : (jsx(Typography, { sx: {
|
924
942
|
color: 'text.secondary',
|
925
943
|
fontStyle: 'italic',
|
@@ -1470,7 +1488,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1470
1488
|
if (isRangeFilter) {
|
1471
1489
|
column.setFilterValue((old) => {
|
1472
1490
|
const newFilterValues = old !== null && old !== void 0 ? old : ['', ''];
|
1473
|
-
newFilterValues[rangeFilterIndex] = newValue;
|
1491
|
+
newFilterValues[rangeFilterIndex] = newValue !== null && newValue !== void 0 ? newValue : undefined;
|
1474
1492
|
return newFilterValues;
|
1475
1493
|
});
|
1476
1494
|
}
|
@@ -1479,8 +1497,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1479
1497
|
}
|
1480
1498
|
}, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
|
1481
1499
|
const handleChange = (newValue) => {
|
1482
|
-
|
1483
|
-
setFilterValue((_a = newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== null && _a !== void 0 ? _a : '');
|
1500
|
+
setFilterValue(newValue !== null && newValue !== void 0 ? newValue : '');
|
1484
1501
|
handleChangeDebounced(newValue);
|
1485
1502
|
};
|
1486
1503
|
const handleTextFieldChange = (event) => {
|
@@ -1558,7 +1575,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1558
1575
|
const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsx(InputAdornment, { position: "end", sx: { mr: isSelectFilter || isMultiSelectFilter ? '20px' : undefined }, children: jsx(Tooltip, { arrow: true, placement: "right", title: (_h = localization.clearFilter) !== null && _h !== void 0 ? _h : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearFilter, disabled: !((_j = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _j === void 0 ? void 0 : _j.length), onClick: handleClear, size: "small", sx: {
|
1559
1576
|
height: '2rem',
|
1560
1577
|
transform: 'scale(0.9)',
|
1561
|
-
width: '2rem'
|
1578
|
+
width: '2rem',
|
1562
1579
|
}, children: jsx(CloseIcon, {}) }) }) }) })) : null;
|
1563
1580
|
const startAdornment = showChangeModeButton ? (jsxs(InputAdornment, { position: "start", children: [jsx(Tooltip, { arrow: true, 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;
|
1564
1581
|
const commonTextFieldProps = Object.assign(Object.assign({ FormHelperTextProps: {
|
@@ -1600,7 +1617,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1600
1617
|
}, value: filterValue || null }, datePickerProps, { slotProps: {
|
1601
1618
|
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_l = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _l === void 0 ? void 0 : _l.field),
|
1602
1619
|
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_m = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _m === void 0 ? void 0 : _m.textField),
|
1603
|
-
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ getOptionLabel: (option) => option, onChange: (_e, newValue) => handleChange(newValue), options: dropdownOptions !== null && dropdownOptions !== void 0 ? dropdownOptions : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
1620
|
+
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => option, onChange: (_e, newValue) => handleChange(newValue), options: dropdownOptions !== null && dropdownOptions !== void 0 ? dropdownOptions : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
1604
1621
|
var _a;
|
1605
1622
|
return (jsx(TextField, 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 })));
|
1606
1623
|
}, value: filterValue }))) : (jsx(TextField, Object.assign({ SelectProps: {
|
@@ -1780,11 +1797,11 @@ const MRT_TableHeadCellFilterLabel = ({ header, table, }) => {
|
|
1780
1797
|
}, children: jsx(FilterAltIcon, {}) }) }) }) }), jsx(Popover, { anchorEl: anchorEl, anchorOrigin: {
|
1781
1798
|
horizontal: 'center',
|
1782
1799
|
vertical: 'top',
|
1783
|
-
}, onClose: (event) => {
|
1800
|
+
}, onClick: (event) => event.stopPropagation(), onClose: (event) => {
|
1784
1801
|
//@ts-ignore
|
1785
1802
|
event.stopPropagation();
|
1786
1803
|
setAnchorEl(null);
|
1787
|
-
}, open: !!anchorEl, transformOrigin: {
|
1804
|
+
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, transformOrigin: {
|
1788
1805
|
horizontal: 'center',
|
1789
1806
|
vertical: 'bottom',
|
1790
1807
|
}, children: jsx(Box, { sx: { p: '1rem' }, children: jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }) })] }));
|
@@ -2072,7 +2089,7 @@ const MRT_TablePagination = ({ position = 'bottom', table, }) => {
|
|
2072
2089
|
const showFirstLastPageButtons = numberOfPages > 2;
|
2073
2090
|
const firstRowIndex = pageIndex * pageSize;
|
2074
2091
|
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
|
2075
|
-
const _a = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, {
|
2092
|
+
const _a = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _a, rest = __rest(_a, ["rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
|
2076
2093
|
return (jsxs(Box, { sx: {
|
2077
2094
|
alignItems: 'center',
|
2078
2095
|
display: 'flex',
|
@@ -2088,12 +2105,12 @@ const MRT_TablePagination = ({ position = 'bottom', table, }) => {
|
|
2088
2105
|
px: '4px',
|
2089
2106
|
py: '12px',
|
2090
2107
|
zIndex: 2,
|
2091
|
-
}, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, { inputProps: { 'aria-label': localization.rowsPerPage },
|
2108
|
+
}, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, { id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { '&::before': { border: 'none' }, mb: 0 }, value: pageSize, variant: "standard", children: rowsPerPageOptions.map((value) => (jsx(MenuItem, { sx: { m: 0 }, value: value, children: value }, value))) })] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, Object.assign({ count: numberOfPages, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsx(PaginationItem, Object.assign({ slots: {
|
2092
2109
|
first: FirstPageIcon,
|
2093
2110
|
last: LastPageIcon,
|
2094
2111
|
next: ChevronRightIcon,
|
2095
2112
|
previous: ChevronLeftIcon,
|
2096
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { sx: { mb: 0,
|
2113
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { sx: { mb: 0, minWidth: '10ch', mx: '4px' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, {}) })), jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, {}) }), jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, {}) }), showLastButton && (jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, {}) }))] })] })) : null] }));
|
2097
2114
|
};
|
2098
2115
|
|
2099
2116
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
@@ -2556,7 +2573,7 @@ const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddi
|
|
2556
2573
|
const MRT_Table = ({ table, }) => {
|
2557
2574
|
var _a, _b, _c, _d;
|
2558
2575
|
const { getFlatHeaders, getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, columns, enableColumnPinning, enableColumnResizing, enableColumnVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
|
2559
|
-
const { columnPinning, columnSizing, columnSizingInfo, columnVisibility, isFullScreen, } = getState();
|
2576
|
+
const { columnPinning, columnSizing, columnSizingInfo, columnVisibility, draggingColumn, isFullScreen, } = getState();
|
2560
2577
|
const tableProps = parseFromValuesOrFunc(muiTableProps, { table });
|
2561
2578
|
const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, { table });
|
2562
2579
|
const columnSizeVars = useMemo(() => {
|
@@ -2588,14 +2605,20 @@ const MRT_Table = ({ table, }) => {
|
|
2588
2605
|
.map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
|
2589
2606
|
]
|
2590
2607
|
: [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
|
2608
|
+
const draggingColumnIndex = table
|
2609
|
+
.getVisibleLeafColumns()
|
2610
|
+
.findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id));
|
2591
2611
|
const columnVirtualizer = enableColumnVirtualization
|
2592
|
-
? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) =>
|
2593
|
-
|
2594
|
-
|
2595
|
-
...
|
2596
|
-
|
2597
|
-
|
2598
|
-
|
2612
|
+
? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
|
2613
|
+
const newIndexs = extraIndexRangeExtractor(range, draggingColumnIndex);
|
2614
|
+
return [
|
2615
|
+
...new Set([
|
2616
|
+
...leftPinnedIndexes,
|
2617
|
+
...newIndexs,
|
2618
|
+
...rightPinnedIndexes,
|
2619
|
+
]),
|
2620
|
+
];
|
2621
|
+
}, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps))
|
2599
2622
|
: undefined;
|
2600
2623
|
if (columnVirtualizerInstanceRef && columnVirtualizer) {
|
2601
2624
|
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
@@ -3217,7 +3240,7 @@ const endsWith = (row, id, filterValue) => row
|
|
3217
3240
|
.endsWith(filterValue.toString().toLowerCase().trim());
|
3218
3241
|
endsWith.autoRemove = (val) => !val;
|
3219
3242
|
const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
|
3220
|
-
filterValue.toString().toLowerCase().trim();
|
3243
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3221
3244
|
equals.autoRemove = (val) => !val;
|
3222
3245
|
const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
|
3223
3246
|
filterValue.toString().toLowerCase().trim();
|
@@ -3225,14 +3248,14 @@ notEquals.autoRemove = (val) => !val;
|
|
3225
3248
|
const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3226
3249
|
? +row.getValue(id) > +filterValue
|
3227
3250
|
: row.getValue(id).toString().toLowerCase().trim() >
|
3228
|
-
filterValue.toString().toLowerCase().trim();
|
3251
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3229
3252
|
greaterThan.autoRemove = (val) => !val;
|
3230
3253
|
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
3231
3254
|
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
3232
3255
|
const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3233
3256
|
? +row.getValue(id) < +filterValue
|
3234
3257
|
: row.getValue(id).toString().toLowerCase().trim() <
|
3235
|
-
filterValue.toString().toLowerCase().trim();
|
3258
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3236
3259
|
lessThan.autoRemove = (val) => !val;
|
3237
3260
|
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
3238
3261
|
lessThanOrEqualTo.autoRemove = (val) => !val;
|
@@ -3493,5 +3516,5 @@ const MaterialReactTable = (props) => {
|
|
3493
3516
|
return jsx(MRT_TablePaper, { table: table });
|
3494
3517
|
};
|
3495
3518
|
|
3496
|
-
export { MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, commonListItemStyles, commonMenuItemStyles, commonToolbarStyles, createRow, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonCellStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMaterialReactTable };
|
3519
|
+
export { MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, commonListItemStyles, commonMenuItemStyles, commonToolbarStyles, createRow, extraIndexRangeExtractor, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonCellStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMaterialReactTable };
|
3497
3520
|
//# sourceMappingURL=material-react-table.esm.js.map
|