material-react-table 2.13.1 → 3.0.0-alpha.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/README.md +3 -3
- package/dist/index.d.ts +6 -14
- package/dist/index.esm.js +26 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +26 -21
- package/dist/index.js.map +1 -1
- package/package.json +31 -31
- 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 +3 -14
- package/src/utils/utils.ts +1 -1
package/dist/index.js
CHANGED
@@ -327,7 +327,7 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
|
|
327
327
|
|
328
328
|
const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
|
329
329
|
const getValueAndLabel = (option) => {
|
330
|
-
var _a, _b
|
330
|
+
var _a, _b;
|
331
331
|
let label = '';
|
332
332
|
let value = '';
|
333
333
|
if (option) {
|
@@ -336,8 +336,8 @@ const getValueAndLabel = (option) => {
|
|
336
336
|
value = option;
|
337
337
|
}
|
338
338
|
else {
|
339
|
-
label = (
|
340
|
-
value = (
|
339
|
+
label = (_a = option.label) !== null && _a !== void 0 ? _a : option.value;
|
340
|
+
value = (_b = option.value) !== null && _b !== void 0 ? _b : label;
|
341
341
|
}
|
342
342
|
}
|
343
343
|
return { label, value };
|
@@ -1052,7 +1052,7 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
|
|
1052
1052
|
header: 'expand',
|
1053
1053
|
id: 'mrt-row-expand',
|
1054
1054
|
size: groupedColumnMode === 'remove'
|
1055
|
-
? (_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180
|
1055
|
+
? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
|
1056
1056
|
: renderDetailPanel
|
1057
1057
|
? enableExpandAll
|
1058
1058
|
? 60
|
@@ -1570,8 +1570,8 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1570
1570
|
var _a, _b, _c, _d;
|
1571
1571
|
return ({
|
1572
1572
|
[getColumnId(col)]: col.filterFn instanceof Function
|
1573
|
-
? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
|
1574
|
-
: (_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),
|
1573
|
+
? ((_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom')
|
1574
|
+
: ((_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)),
|
1575
1575
|
});
|
1576
1576
|
})));
|
1577
1577
|
const [columnOrder, onColumnOrderChange] = react.useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
|
@@ -1958,6 +1958,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
1958
1958
|
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
1959
1959
|
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
1960
1960
|
const [value, setValue] = react.useState(() => cell.getValue());
|
1961
|
+
const [completesComposition, setCompletesComposition] = react.useState(true);
|
1961
1962
|
const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
|
1962
1963
|
cell,
|
1963
1964
|
column,
|
@@ -2003,7 +2004,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
2003
2004
|
const handleEnterKeyDown = (event) => {
|
2004
2005
|
var _a, _b;
|
2005
2006
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
2006
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
2007
|
+
if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
|
2007
2008
|
(_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
|
2008
2009
|
}
|
2009
2010
|
};
|
@@ -2030,7 +2031,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
2030
2031
|
var _a;
|
2031
2032
|
e.stopPropagation();
|
2032
2033
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
2033
|
-
}, onKeyDown: handleEnterKeyDown, children: (_c = textFieldProps.children) !== null && _c !== void 0 ? _c : selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.map((option) => {
|
2034
|
+
}, 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) => {
|
2034
2035
|
const { label, value } = getValueAndLabel(option);
|
2035
2036
|
return (jsxRuntime.jsx(MenuItem__default["default"], { sx: {
|
2036
2037
|
alignItems: 'center',
|
@@ -2195,7 +2196,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2195
2196
|
table,
|
2196
2197
|
tableCellProps,
|
2197
2198
|
theme,
|
2198
|
-
})), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.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) ? (jsxRuntime.jsx(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
|
2199
|
+
})), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.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) ? (jsxRuntime.jsx(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
|
2199
2200
|
(['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
|
2200
2201
|
!row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
|
2201
2202
|
cell,
|
@@ -2453,11 +2454,11 @@ const MRT_TableFooterCell = (_a) => {
|
|
2453
2454
|
theme,
|
2454
2455
|
})), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
|
2455
2456
|
? null
|
2456
|
-
: (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
|
2457
|
+
: ((_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
|
2457
2458
|
column,
|
2458
2459
|
footer,
|
2459
2460
|
table,
|
2460
|
-
})) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null) })));
|
2461
|
+
})) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null)) })));
|
2461
2462
|
};
|
2462
2463
|
|
2463
2464
|
const MRT_TableFooterRow = (_a) => {
|
@@ -2689,7 +2690,7 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
2689
2690
|
backgroundColor: menuBackgroundColor,
|
2690
2691
|
},
|
2691
2692
|
}, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
|
2692
|
-
? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
|
2693
|
+
? ((_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
|
2693
2694
|
column: column,
|
2694
2695
|
internalFilterOptions,
|
2695
2696
|
onSelectFilterMode: handleSelectFilterMode,
|
@@ -2699,7 +2700,7 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
2699
2700
|
internalFilterOptions,
|
2700
2701
|
onSelectFilterMode: handleSelectFilterMode,
|
2701
2702
|
table,
|
2702
|
-
})
|
2703
|
+
}))
|
2703
2704
|
: renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
|
2704
2705
|
internalFilterOptions,
|
2705
2706
|
onSelectFilterMode: handleSelectFilterMode,
|
@@ -2914,7 +2915,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2914
2915
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
2915
2916
|
: '';
|
2916
2917
|
const filterPlaceholder = !isRangeFilter
|
2917
|
-
? (_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))
|
2918
|
+
? ((_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)))
|
2918
2919
|
: rangeFilterIndex === 0
|
2919
2920
|
? localization.min
|
2920
2921
|
: rangeFilterIndex === 1
|
@@ -2932,7 +2933,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2932
2933
|
? column.getFilterValue() || []
|
2933
2934
|
: isRangeFilter
|
2934
2935
|
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
2935
|
-
: (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
|
2936
|
+
: ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
|
2936
2937
|
});
|
2937
2938
|
const [autocompleteValue, setAutocompleteValue] = react.useState(isAutocompleteFilter ? filterValue : null);
|
2938
2939
|
const handleChangeDebounced = react.useCallback(utils.debounce((newValue) => {
|
@@ -3113,7 +3114,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3113
3114
|
const sliderProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterSliderProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterSliderProps, { column, table })), rest);
|
3114
3115
|
let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
|
3115
3116
|
? [sliderProps.min, sliderProps.max]
|
3116
|
-
: (_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1];
|
3117
|
+
: ((_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1]);
|
3117
3118
|
//fix potential TanStack Table bugs where min or max is an array
|
3118
3119
|
if (Array.isArray(min))
|
3119
3120
|
min = min[0];
|
@@ -3435,7 +3436,11 @@ const MRT_TableHeadCell = (_a) => {
|
|
3435
3436
|
? 'center'
|
3436
3437
|
: theme.direction === 'rtl'
|
3437
3438
|
? 'right'
|
3438
|
-
: 'left',
|
3439
|
+
: 'left', "aria-sort": column.getIsSorted()
|
3440
|
+
? column.getIsSorted() === 'asc'
|
3441
|
+
? 'ascending'
|
3442
|
+
: 'descending'
|
3443
|
+
: '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) => {
|
3439
3444
|
var _a;
|
3440
3445
|
if (node) {
|
3441
3446
|
tableHeadCellRefs.current[column.id] = node;
|
@@ -3471,7 +3476,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3471
3476
|
theme,
|
3472
3477
|
})), draggingBorders)), children: [header.isPlaceholder
|
3473
3478
|
? null
|
3474
|
-
: (_c = tableCellProps.children) !== null && _c !== void 0 ? _c : (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content", sx: {
|
3479
|
+
: ((_c = tableCellProps.children) !== null && _c !== void 0 ? _c : (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content", sx: {
|
3475
3480
|
alignItems: 'center',
|
3476
3481
|
display: 'flex',
|
3477
3482
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
@@ -3508,7 +3513,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3508
3513
|
whiteSpace: 'nowrap',
|
3509
3514
|
}, children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3510
3515
|
current: tableHeadCellRefs.current[column.id],
|
3511
|
-
} })), showColumnActions && (jsxRuntime.jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] })), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
|
3516
|
+
} })), showColumnActions && (jsxRuntime.jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsxRuntime.jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] }))), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
|
3512
3517
|
};
|
3513
3518
|
|
3514
3519
|
const MRT_TableHeadRow = (_a) => {
|
@@ -3743,10 +3748,10 @@ const MRT_TableContainer = (_a) => {
|
|
3743
3748
|
useIsomorphicLayoutEffect(() => {
|
3744
3749
|
var _a, _b, _c, _d;
|
3745
3750
|
const topToolbarHeight = typeof document !== 'undefined'
|
3746
|
-
? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
|
3751
|
+
? ((_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0)
|
3747
3752
|
: 0;
|
3748
3753
|
const bottomToolbarHeight = typeof document !== 'undefined'
|
3749
|
-
? (_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
|
3754
|
+
? ((_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)
|
3750
3755
|
: 0;
|
3751
3756
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
3752
3757
|
});
|