material-react-table 2.13.0 → 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 +70 -63
- package/dist/index.esm.js +30 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +30 -21
- package/dist/index.js.map +1 -1
- package/package.json +36 -36
- package/src/components/body/MRT_TableBodyCell.tsx +3 -1
- package/src/components/body/MRT_TableBodyCellValue.tsx +4 -0
- 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 +5 -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_ColumnVirtualizer.ts +1 -1
- package/src/hooks/useMRT_RowVirtualizer.ts +1 -1
- package/src/hooks/useMRT_TableInstance.ts +3 -3
- package/src/types.ts +34 -28
- package/locales/am/index.d.ts +0 -3
- package/locales/am/index.esm.d.ts +0 -3
- package/locales/am/index.esm.js +0 -93
- package/locales/am/index.js +0 -97
- package/locales/am/package.json +0 -6
package/dist/index.js
CHANGED
@@ -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 : []);
|
@@ -1858,6 +1858,8 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowInde
|
|
1858
1858
|
column,
|
1859
1859
|
row,
|
1860
1860
|
table,
|
1861
|
+
staticColumnIndex,
|
1862
|
+
staticRowIndex,
|
1861
1863
|
})
|
1862
1864
|
: row.getIsGrouped() && !cell.getIsGrouped()
|
1863
1865
|
? null
|
@@ -1867,6 +1869,8 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowInde
|
|
1867
1869
|
column,
|
1868
1870
|
row,
|
1869
1871
|
table,
|
1872
|
+
staticColumnIndex,
|
1873
|
+
staticRowIndex,
|
1870
1874
|
})
|
1871
1875
|
: undefined;
|
1872
1876
|
const isGroupedValue = renderedCellValue !== undefined;
|
@@ -1954,6 +1958,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
1954
1958
|
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
1955
1959
|
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
1956
1960
|
const [value, setValue] = react.useState(() => cell.getValue());
|
1961
|
+
const [completesComposition, setCompletesComposition] = react.useState(true);
|
1957
1962
|
const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
|
1958
1963
|
cell,
|
1959
1964
|
column,
|
@@ -1999,7 +2004,7 @@ const MRT_EditCellTextField = (_a) => {
|
|
1999
2004
|
const handleEnterKeyDown = (event) => {
|
2000
2005
|
var _a, _b;
|
2001
2006
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
2002
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
2007
|
+
if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
|
2003
2008
|
(_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
|
2004
2009
|
}
|
2005
2010
|
};
|
@@ -2022,13 +2027,11 @@ const MRT_EditCellTextField = (_a) => {
|
|
2022
2027
|
: {})), textFieldProps.InputProps), { sx: (theme) => {
|
2023
2028
|
var _a;
|
2024
2029
|
return (Object.assign({ mb: 0 }, parseFromValuesOrFunc((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.sx, theme)));
|
2025
|
-
} }), SelectProps: {
|
2026
|
-
MenuProps: { disableScrollLock: true },
|
2027
|
-
}, inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
|
2030
|
+
} }), SelectProps: Object.assign({ MenuProps: { disableScrollLock: true } }, textFieldProps.SelectProps), inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
|
2028
2031
|
var _a;
|
2029
2032
|
e.stopPropagation();
|
2030
2033
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
2031
|
-
}, 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) => {
|
2032
2035
|
const { label, value } = getValueAndLabel(option);
|
2033
2036
|
return (jsxRuntime.jsx(MenuItem__default["default"], { sx: {
|
2034
2037
|
alignItems: 'center',
|
@@ -2133,6 +2136,8 @@ const MRT_TableBodyCell = (_a) => {
|
|
2133
2136
|
const cellValueProps = {
|
2134
2137
|
cell,
|
2135
2138
|
table,
|
2139
|
+
staticColumnIndex,
|
2140
|
+
staticRowIndex,
|
2136
2141
|
};
|
2137
2142
|
const handleDoubleClick = (event) => {
|
2138
2143
|
var _a;
|
@@ -2191,7 +2196,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2191
2196
|
table,
|
2192
2197
|
tableCellProps,
|
2193
2198
|
theme,
|
2194
|
-
})), 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' &&
|
2195
2200
|
(['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
|
2196
2201
|
!row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
|
2197
2202
|
cell,
|
@@ -2449,11 +2454,11 @@ const MRT_TableFooterCell = (_a) => {
|
|
2449
2454
|
theme,
|
2450
2455
|
})), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
|
2451
2456
|
? null
|
2452
|
-
: (_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
|
2457
|
+
: ((_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
|
2453
2458
|
column,
|
2454
2459
|
footer,
|
2455
2460
|
table,
|
2456
|
-
})) !== 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)) })));
|
2457
2462
|
};
|
2458
2463
|
|
2459
2464
|
const MRT_TableFooterRow = (_a) => {
|
@@ -2685,7 +2690,7 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
2685
2690
|
backgroundColor: menuBackgroundColor,
|
2686
2691
|
},
|
2687
2692
|
}, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
|
2688
|
-
? (_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, {
|
2689
2694
|
column: column,
|
2690
2695
|
internalFilterOptions,
|
2691
2696
|
onSelectFilterMode: handleSelectFilterMode,
|
@@ -2695,7 +2700,7 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
2695
2700
|
internalFilterOptions,
|
2696
2701
|
onSelectFilterMode: handleSelectFilterMode,
|
2697
2702
|
table,
|
2698
|
-
})
|
2703
|
+
}))
|
2699
2704
|
: renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
|
2700
2705
|
internalFilterOptions,
|
2701
2706
|
onSelectFilterMode: handleSelectFilterMode,
|
@@ -2910,7 +2915,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2910
2915
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
2911
2916
|
: '';
|
2912
2917
|
const filterPlaceholder = !isRangeFilter
|
2913
|
-
? (_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)))
|
2914
2919
|
: rangeFilterIndex === 0
|
2915
2920
|
? localization.min
|
2916
2921
|
: rangeFilterIndex === 1
|
@@ -2928,7 +2933,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2928
2933
|
? column.getFilterValue() || []
|
2929
2934
|
: isRangeFilter
|
2930
2935
|
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
2931
|
-
: (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
|
2936
|
+
: ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
|
2932
2937
|
});
|
2933
2938
|
const [autocompleteValue, setAutocompleteValue] = react.useState(isAutocompleteFilter ? filterValue : null);
|
2934
2939
|
const handleChangeDebounced = react.useCallback(utils.debounce((newValue) => {
|
@@ -3109,7 +3114,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
3109
3114
|
const sliderProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterSliderProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterSliderProps, { column, table })), rest);
|
3110
3115
|
let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
|
3111
3116
|
? [sliderProps.min, sliderProps.max]
|
3112
|
-
: (_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1];
|
3117
|
+
: ((_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1]);
|
3113
3118
|
//fix potential TanStack Table bugs where min or max is an array
|
3114
3119
|
if (Array.isArray(min))
|
3115
3120
|
min = min[0];
|
@@ -3431,7 +3436,11 @@ const MRT_TableHeadCell = (_a) => {
|
|
3431
3436
|
? 'center'
|
3432
3437
|
: theme.direction === 'rtl'
|
3433
3438
|
? 'right'
|
3434
|
-
: '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) => {
|
3435
3444
|
var _a;
|
3436
3445
|
if (node) {
|
3437
3446
|
tableHeadCellRefs.current[column.id] = node;
|
@@ -3467,7 +3476,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3467
3476
|
theme,
|
3468
3477
|
})), draggingBorders)), children: [header.isPlaceholder
|
3469
3478
|
? null
|
3470
|
-
: (_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: {
|
3471
3480
|
alignItems: 'center',
|
3472
3481
|
display: 'flex',
|
3473
3482
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
@@ -3504,7 +3513,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3504
3513
|
whiteSpace: 'nowrap',
|
3505
3514
|
}, children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3506
3515
|
current: tableHeadCellRefs.current[column.id],
|
3507
|
-
} })), 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 }))] })));
|
3508
3517
|
};
|
3509
3518
|
|
3510
3519
|
const MRT_TableHeadRow = (_a) => {
|
@@ -3739,10 +3748,10 @@ const MRT_TableContainer = (_a) => {
|
|
3739
3748
|
useIsomorphicLayoutEffect(() => {
|
3740
3749
|
var _a, _b, _c, _d;
|
3741
3750
|
const topToolbarHeight = typeof document !== 'undefined'
|
3742
|
-
? (_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)
|
3743
3752
|
: 0;
|
3744
3753
|
const bottomToolbarHeight = typeof document !== 'undefined'
|
3745
|
-
? (_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)
|
3746
3755
|
: 0;
|
3747
3756
|
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
3748
3757
|
});
|