material-react-table 2.13.1 → 2.13.2
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 +3 -3
- package/dist/index.esm.js +23 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/package.json +22 -22
- package/src/components/body/MRT_TableBody.tsx +1 -1
- package/src/components/body/MRT_TableBodyCell.tsx +1 -1
- package/src/components/body/MRT_TableBodyRow.tsx +1 -1
- package/src/components/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/components/footer/MRT_TableFooterCell.tsx +2 -2
- package/src/components/head/MRT_TableHeadCell.tsx +11 -2
- package/src/components/inputs/MRT_EditCellTextField.tsx +4 -1
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +1 -1
- package/src/components/inputs/MRT_FilterTextField.tsx +6 -3
- package/src/components/menus/MRT_FilterOptionMenu.tsx +2 -2
- package/src/components/table/MRT_TableContainer.tsx +2 -2
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +1 -1
- package/src/hooks/useMRT_TableInstance.ts +3 -3
- package/src/types.ts +1 -1
package/dist/index.d.ts
CHANGED
@@ -267,7 +267,7 @@ type MRT_PaginationState = PaginationState;
|
|
267
267
|
type MRT_RowSelectionState = RowSelectionState;
|
268
268
|
type MRT_SortingState = SortingState;
|
269
269
|
type MRT_Updater<T> = Updater<T>;
|
270
|
-
type MRT_VirtualItem
|
270
|
+
type MRT_VirtualItem = VirtualItem;
|
271
271
|
type MRT_VisibilityState = VisibilityState;
|
272
272
|
type MRT_VirtualizerOptions<TScrollElement extends Element | Window = Element | Window, TItemElement extends Element = Element> = VirtualizerOptions<TScrollElement, TItemElement>;
|
273
273
|
type MRT_ColumnVirtualizer<TScrollElement extends Element | Window = HTMLDivElement, TItemElement extends Element = HTMLTableCellElement> = Virtualizer<TScrollElement, TItemElement> & {
|
@@ -1502,7 +1502,7 @@ interface MRT_TableBodyRowProps<TData extends MRT_RowData> extends TableRowProps
|
|
1502
1502
|
rowVirtualizer?: MRT_RowVirtualizer;
|
1503
1503
|
staticRowIndex: number;
|
1504
1504
|
table: MRT_TableInstance<TData>;
|
1505
|
-
virtualRow?: VirtualItem
|
1505
|
+
virtualRow?: VirtualItem;
|
1506
1506
|
}
|
1507
1507
|
declare const MRT_TableBodyRow: <TData extends MRT_RowData>({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow, ...rest }: MRT_TableBodyRowProps<TData>) => react_jsx_runtime.JSX.Element;
|
1508
1508
|
declare const Memo_MRT_TableBodyRow: typeof MRT_TableBodyRow;
|
@@ -1526,7 +1526,7 @@ interface MRT_TableDetailPanelProps<TData extends MRT_RowData> extends TableCell
|
|
1526
1526
|
rowVirtualizer?: MRT_RowVirtualizer;
|
1527
1527
|
staticRowIndex: number;
|
1528
1528
|
table: MRT_TableInstance<TData>;
|
1529
|
-
virtualRow?: MRT_VirtualItem
|
1529
|
+
virtualRow?: MRT_VirtualItem;
|
1530
1530
|
}
|
1531
1531
|
declare const MRT_TableDetailPanel: <TData extends MRT_RowData>({ parentRowRef, row, rowVirtualizer, staticRowIndex, table, virtualRow, ...rest }: MRT_TableDetailPanelProps<TData>) => react_jsx_runtime.JSX.Element;
|
1532
1532
|
|
package/dist/index.esm.js
CHANGED
@@ -962,7 +962,7 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
|
|
962
962
|
header: 'expand',
|
963
963
|
id: 'mrt-row-expand',
|
964
964
|
size: groupedColumnMode === 'remove'
|
965
|
-
? (_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180
|
965
|
+
? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
|
966
966
|
: renderDetailPanel
|
967
967
|
? enableExpandAll
|
968
968
|
? 60
|
@@ -1480,8 +1480,8 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1480
1480
|
var _a, _b, _c, _d;
|
1481
1481
|
return ({
|
1482
1482
|
[getColumnId(col)]: col.filterFn instanceof Function
|
1483
|
-
? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
|
1484
|
-
: (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
|
1483
|
+
? ((_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom')
|
1484
|
+
: ((_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col)),
|
1485
1485
|
});
|
1486
1486
|
})));
|
1487
1487
|
const [columnOrder, onColumnOrderChange] = useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
|
@@ -1868,6 +1868,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
1868
1868
|
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
1869
1869
|
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
1870
1870
|
const [value, setValue] = useState(() => cell.getValue());
|
1871
|
+
const [completesComposition, setCompletesComposition] = useState(true);
|
1871
1872
|
const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
|
1872
1873
|
cell,
|
1873
1874
|
column,
|
@@ -1913,7 +1914,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
1913
1914
|
const handleEnterKeyDown = (event) => {
|
1914
1915
|
var _a, _b;
|
1915
1916
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
1916
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
1917
|
+
if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
|
1917
1918
|
(_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
|
1918
1919
|
}
|
1919
1920
|
};
|
@@ -1940,7 +1941,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
1940
1941
|
var _a;
|
1941
1942
|
e.stopPropagation();
|
1942
1943
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
1943
|
-
}, onKeyDown: handleEnterKeyDown, children: (_c = textFieldProps.children) !== null && _c !== void 0 ? _c : selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.map((option) => {
|
1944
|
+
}, onKeyDown: handleEnterKeyDown, onCompositionStart: () => setCompletesComposition(false), onCompositionEnd: () => setCompletesComposition(true), children: (_c = textFieldProps.children) !== null && _c !== void 0 ? _c : selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.map((option) => {
|
1944
1945
|
const { label, value } = getValueAndLabel(option);
|
1945
1946
|
return (jsx(MenuItem, { sx: {
|
1946
1947
|
alignItems: 'center',
|
@@ -2105,7 +2106,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2105
2106
|
table,
|
2106
2107
|
tableCellProps,
|
2107
2108
|
theme,
|
2108
|
-
})), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? ((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
|
2109
|
+
})), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? (((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null)) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
|
2109
2110
|
(['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
|
2110
2111
|
!row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
|
2111
2112
|
cell,
|
@@ -2363,11 +2364,11 @@ const MRT_TableFooterCell = (_a) => {
|
|
2363
2364
|
theme,
|
2364
2365
|
})), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
|
2365
2366
|
? null
|
2366
|
-
: (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
|
2367
|
+
: ((_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
|
2367
2368
|
column,
|
2368
2369
|
footer,
|
2369
2370
|
table,
|
2370
|
-
})) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
|
2371
|
+
})) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null)) })));
|
2371
2372
|
};
|
2372
2373
|
|
2373
2374
|
const MRT_TableFooterRow = (_a) => {
|
@@ -2599,7 +2600,7 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
2599
2600
|
backgroundColor: menuBackgroundColor,
|
2600
2601
|
},
|
2601
2602
|
}, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
|
2602
|
-
? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
|
2603
|
+
? ((_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
|
2603
2604
|
column: column,
|
2604
2605
|
internalFilterOptions,
|
2605
2606
|
onSelectFilterMode: handleSelectFilterMode,
|
@@ -2609,7 +2610,7 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
2609
2610
|
internalFilterOptions,
|
2610
2611
|
onSelectFilterMode: handleSelectFilterMode,
|
2611
2612
|
table,
|
2612
|
-
})
|
2613
|
+
}))
|
2613
2614
|
: renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
|
2614
2615
|
internalFilterOptions,
|
2615
2616
|
onSelectFilterMode: handleSelectFilterMode,
|
@@ -2824,7 +2825,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2824
2825
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
2825
2826
|
: '';
|
2826
2827
|
const filterPlaceholder = !isRangeFilter
|
2827
|
-
? (_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))
|
2828
|
+
? ((_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)))
|
2828
2829
|
: rangeFilterIndex === 0
|
2829
2830
|
? localization.min
|
2830
2831
|
: rangeFilterIndex === 1
|
@@ -2842,7 +2843,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2842
2843
|
? column.getFilterValue() || []
|
2843
2844
|
: isRangeFilter
|
2844
2845
|
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
2845
|
-
: (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
|
2846
|
+
: ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
|
2846
2847
|
});
|
2847
2848
|
const [autocompleteValue, setAutocompleteValue] = useState(isAutocompleteFilter ? filterValue : null);
|
2848
2849
|
const handleChangeDebounced = useCallback(debounce((newValue) => {
|
@@ -3023,7 +3024,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3023
3024
|
const sliderProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterSliderProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterSliderProps, { column, table })), rest);
|
3024
3025
|
let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
|
3025
3026
|
? [sliderProps.min, sliderProps.max]
|
3026
|
-
: (_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1];
|
3027
|
+
: ((_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1]);
|
3027
3028
|
//fix potential TanStack Table bugs where min or max is an array
|
3028
3029
|
if (Array.isArray(min))
|
3029
3030
|
min = min[0];
|
@@ -3345,7 +3346,11 @@ const MRT_TableHeadCell = (_a) => {
|
|
3345
3346
|
? 'center'
|
3346
3347
|
: theme.direction === 'rtl'
|
3347
3348
|
? 'right'
|
3348
|
-
: 'left',
|
3349
|
+
: 'left', "aria-sort": column.getIsSorted()
|
3350
|
+
? column.getIsSorted() === 'asc'
|
3351
|
+
? 'ascending'
|
3352
|
+
: 'descending'
|
3353
|
+
: 'none', colSpan: header.colSpan, "data-can-sort": column.getCanSort() || undefined, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, "data-sort": column.getIsSorted() || undefined, onDragEnter: handleDragEnter, onDragOver: handleDragOver, ref: (node) => {
|
3349
3354
|
var _a;
|
3350
3355
|
if (node) {
|
3351
3356
|
tableHeadCellRefs.current[column.id] = node;
|
@@ -3381,7 +3386,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3381
3386
|
theme,
|
3382
3387
|
})), draggingBorders)), children: [header.isPlaceholder
|
3383
3388
|
? null
|
3384
|
-
: (_c = tableCellProps.children) !== null && _c !== void 0 ? _c : (jsxs(Box, { className: "Mui-TableHeadCell-Content", sx: {
|
3389
|
+
: ((_c = tableCellProps.children) !== null && _c !== void 0 ? _c : (jsxs(Box, { className: "Mui-TableHeadCell-Content", sx: {
|
3385
3390
|
alignItems: 'center',
|
3386
3391
|
display: 'flex',
|
3387
3392
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
@@ -3418,7 +3423,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3418
3423
|
whiteSpace: 'nowrap',
|
3419
3424
|
}, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3420
3425
|
current: tableHeadCellRefs.current[column.id],
|
3421
|
-
} })), 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 }))] })));
|
3426
|
+
} })), 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 }))] })));
|
3422
3427
|
};
|
3423
3428
|
|
3424
3429
|
const MRT_TableHeadRow = (_a) => {
|
@@ -3653,10 +3658,10 @@ const MRT_TableContainer = (_a) => {
|
|
3653
3658
|
useIsomorphicLayoutEffect(() => {
|
3654
3659
|
var _a, _b, _c, _d;
|
3655
3660
|
const topToolbarHeight = typeof document !== 'undefined'
|
3656
|
-
? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
|
3661
|
+
? ((_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0)
|
3657
3662
|
: 0;
|
3658
3663
|
const bottomToolbarHeight = typeof document !== 'undefined'
|
3659
|
-
? (_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0
|
3664
|
+
? ((_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0)
|
3660
3665
|
: 0;
|
3661
3666
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
3662
3667
|
});
|