material-react-table 3.1.0 → 3.2.1
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 +1 -0
- package/dist/index.esm.js +71 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +71 -35
- 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 +1 -1
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +1 -1
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +7 -3
- package/src/components/inputs/MRT_FilterTextField.tsx +20 -6
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -1
- package/src/components/toolbar/MRT_TablePagination.tsx +5 -3
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +5 -4
- package/src/hooks/useMRT_Effects.ts +7 -4
- package/src/hooks/useMRT_RowVirtualizer.ts +16 -4
- 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 +2 -0
- package/src/utils/virtualization.utils.ts +5 -0
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
@@ -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',
|
@@ -1579,11 +1580,12 @@ const useMRT_Effects = (table) => {
|
|
1579
1580
|
if (!enablePagination || isLoading || showSkeletons)
|
1580
1581
|
return;
|
1581
1582
|
const { pageIndex, pageSize } = pagination;
|
1582
|
-
const
|
1583
|
-
|
1584
|
-
|
1583
|
+
const totalPages = totalRowCount > 0 ? Math.ceil(totalRowCount / pageSize) : 1;
|
1584
|
+
const isOutOfBounds = pageIndex < 0 || pageIndex >= totalPages;
|
1585
|
+
if (isOutOfBounds) {
|
1586
|
+
table.setPageIndex(totalPages - 1);
|
1585
1587
|
}
|
1586
|
-
}, [totalRowCount]);
|
1588
|
+
}, [totalRowCount, enablePagination, isLoading, showSkeletons]);
|
1587
1589
|
//turn off sort when global filter is looking for ranked results
|
1588
1590
|
const appliedSort = useRef(sorting);
|
1589
1591
|
useEffect(() => {
|
@@ -1797,6 +1799,11 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1797
1799
|
|
1798
1800
|
const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
|
1799
1801
|
|
1802
|
+
/**
|
1803
|
+
* When scroll, the `draggingRow` or `draggingColumn` can be removed from document because of virtualization,
|
1804
|
+
* then, the `dragEnd` event on `MRT_TableBodyRowGrabHandle` or `MRT_TableHeadCellGrabHandle` will not fire.
|
1805
|
+
* We should keep the `draggingRow` or `draggingColumn` in `getVirtualItems()` to avoid this thing.
|
1806
|
+
*/
|
1800
1807
|
const extraIndexRangeExtractor = (range, draggingIndex) => {
|
1801
1808
|
const newIndexes = defaultRangeExtractor(range);
|
1802
1809
|
if (draggingIndex === undefined)
|
@@ -1872,7 +1879,6 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1872
1879
|
};
|
1873
1880
|
|
1874
1881
|
const useMRT_RowVirtualizer = (table, rows) => {
|
1875
|
-
var _a;
|
1876
1882
|
const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
|
1877
1883
|
const { density, draggingRow, expanded } = getState();
|
1878
1884
|
if (!enableRowVirtualization)
|
@@ -1880,7 +1886,14 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1880
1886
|
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
1881
1887
|
table,
|
1882
1888
|
});
|
1883
|
-
const
|
1889
|
+
const realRows = rows !== null && rows !== void 0 ? rows : getRowModel().rows;
|
1890
|
+
/**
|
1891
|
+
* when filtering, should find the correct index in filtered rows
|
1892
|
+
*/
|
1893
|
+
const draggingRowIndex = useMemo(() => (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id)
|
1894
|
+
? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
|
1895
|
+
: undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
|
1896
|
+
const rowCount = realRows.length;
|
1884
1897
|
const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
|
1885
1898
|
const rowVirtualizer = useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
|
1886
1899
|
? expanded === true
|
@@ -1890,9 +1903,8 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1890
1903
|
navigator.userAgent.indexOf('Firefox') === -1
|
1891
1904
|
? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
|
1892
1905
|
: undefined, overscan: 4, rangeExtractor: useCallback((range) => {
|
1893
|
-
|
1894
|
-
|
1895
|
-
}, [draggingRow]) }, rowVirtualizerProps));
|
1906
|
+
return extraIndexRangeExtractor(range, draggingRowIndex);
|
1907
|
+
}, [draggingRowIndex]) }, rowVirtualizerProps));
|
1896
1908
|
rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
|
1897
1909
|
if (rowVirtualizerInstanceRef) {
|
1898
1910
|
//@ts-expect-error
|
@@ -3003,7 +3015,7 @@ const MRT_FilterCheckbox = (_a) => {
|
|
3003
3015
|
};
|
3004
3016
|
|
3005
3017
|
const MRT_FilterTextField = (_a) => {
|
3006
|
-
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3018
|
+
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
3007
3019
|
var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
|
3008
3020
|
const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
3009
3021
|
const { column } = header;
|
@@ -3040,9 +3052,11 @@ const MRT_FilterTextField = (_a) => {
|
|
3040
3052
|
? column.getFilterValue() || []
|
3041
3053
|
: isRangeFilter
|
3042
3054
|
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
3043
|
-
:
|
3055
|
+
: isAutocompleteFilter
|
3056
|
+
? typeof column.getFilterValue() === 'string' ? column.getFilterValue() : ''
|
3057
|
+
: ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
|
3044
3058
|
});
|
3045
|
-
const [autocompleteValue, setAutocompleteValue] = useState(isAutocompleteFilter ?
|
3059
|
+
const [autocompleteValue, setAutocompleteValue] = useState(() => isAutocompleteFilter ? (column.getFilterValue() || null) : null);
|
3046
3060
|
const handleChangeDebounced = useCallback(debounce((newValue) => {
|
3047
3061
|
if (isRangeFilter) {
|
3048
3062
|
column.setFilterValue((old) => {
|
@@ -3069,9 +3083,12 @@ const MRT_FilterTextField = (_a) => {
|
|
3069
3083
|
handleChange(newValue);
|
3070
3084
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
3071
3085
|
};
|
3086
|
+
const handleAutocompleteInputChange = (_event, newValue, _reason) => {
|
3087
|
+
handleChange(newValue);
|
3088
|
+
};
|
3072
3089
|
const handleAutocompleteChange = (newValue) => {
|
3073
3090
|
setAutocompleteValue(newValue);
|
3074
|
-
|
3091
|
+
handleChangeDebounced(getValueAndLabel(newValue).value);
|
3075
3092
|
};
|
3076
3093
|
const handleClear = () => {
|
3077
3094
|
if (isMultiSelectFilter) {
|
@@ -3086,6 +3103,13 @@ const MRT_FilterTextField = (_a) => {
|
|
3086
3103
|
return newFilterValues;
|
3087
3104
|
});
|
3088
3105
|
}
|
3106
|
+
else if (isAutocompleteFilter) {
|
3107
|
+
setAutocompleteValue(null);
|
3108
|
+
setFilterValue('');
|
3109
|
+
// when using 'autocomplete' this function is called only inside effect and only if the filterValue === undefined
|
3110
|
+
// so the following call is excessive; should be uncommented if the handleClear becomes part of the Autocomplete component callbacks
|
3111
|
+
// column.setFilterValue(undefined)
|
3112
|
+
}
|
3089
3113
|
else {
|
3090
3114
|
setFilterValue('');
|
3091
3115
|
column.setFilterValue(undefined);
|
@@ -3144,11 +3168,10 @@ const MRT_FilterTextField = (_a) => {
|
|
3144
3168
|
lineHeight: '0.8rem',
|
3145
3169
|
whiteSpace: 'nowrap',
|
3146
3170
|
} }, (_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
|
3147
|
-
? { endAdornment, startAdornment }
|
3148
|
-
: { startAdornment }, htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3171
|
+
? Object.assign({ endAdornment, startAdornment }, (_o = textFieldProps.slotProps) === null || _o === void 0 ? void 0 : _o.input) : Object.assign({ startAdornment }, (_p = textFieldProps.slotProps) === null || _p === void 0 ? void 0 : _p.input), htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3149
3172
|
textOverflow: 'ellipsis',
|
3150
3173
|
width: filterChipLabel ? 0 : undefined,
|
3151
|
-
}, title: filterPlaceholder }, (
|
3174
|
+
}, title: filterPlaceholder }, (_q = textFieldProps.slotProps) === null || _q === void 0 ? void 0 : _q.htmlInput) }), onKeyDown: (e) => {
|
3152
3175
|
var _a;
|
3153
3176
|
e.stopPropagation();
|
3154
3177
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
@@ -3168,32 +3191,32 @@ const MRT_FilterTextField = (_a) => {
|
|
3168
3191
|
value: filterValue || null,
|
3169
3192
|
};
|
3170
3193
|
return (jsxs(Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsx(TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: {
|
3171
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3172
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3194
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_r = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.field),
|
3195
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
3173
3196
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsx(DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: {
|
3174
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3175
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3197
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_t = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _t === void 0 ? void 0 : _t.field),
|
3198
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_u = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _u === void 0 ? void 0 : _u.textField),
|
3176
3199
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
|
3177
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3178
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3179
|
-
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (
|
3200
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_v = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _v === void 0 ? void 0 : _v.field),
|
3201
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_w = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _w === void 0 ? void 0 : _w.textField),
|
3202
|
+
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_x = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _x !== void 0 ? _x : [], inputValue: filterValue, onInputChange: handleAutocompleteInputChange }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
3180
3203
|
var _a, _b, _c, _d, _f;
|
3181
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:
|
3182
3205
|
//@ts-expect-error
|
3183
|
-
(_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) }),
|
3184
|
-
}, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { inputLabel: Object.assign({ shrink: isSelectFilter || isMultiSelectFilter }, (
|
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 }, (_y = commonTextFieldProps.slotProps) === null || _y === void 0 ? void 0 : _y.inputLabel), select: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
3185
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) => {
|
3186
3209
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
3187
3210
|
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
3188
3211
|
}) }))
|
3189
|
-
: undefined }, (
|
3212
|
+
: undefined }, (_z = commonTextFieldProps.slotProps) === null || _z === void 0 ? void 0 : _z.select) }), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
|
3190
3213
|
? Array.isArray(filterValue)
|
3191
3214
|
? filterValue
|
3192
3215
|
: []
|
3193
3216
|
: filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
|
3194
3217
|
jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
3195
3218
|
...[
|
3196
|
-
(
|
3219
|
+
(_0 = textFieldProps.children) !== null && _0 !== void 0 ? _0 : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
3197
3220
|
var _a;
|
3198
3221
|
const { label, value } = getValueAndLabel(option);
|
3199
3222
|
return (jsxs(MenuItem, { sx: {
|
@@ -3359,7 +3382,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3359
3382
|
|
3360
3383
|
const MRT_TableHeadCellGrabHandle = (_a) => {
|
3361
3384
|
var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
|
3362
|
-
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
3385
|
+
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setColumnPinning, setDraggingColumn, setHoveredColumn, } = table;
|
3363
3386
|
const { columnDef } = column;
|
3364
3387
|
const { columnOrder, draggingColumn, hoveredColumn } = getState();
|
3365
3388
|
const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
|
@@ -3386,7 +3409,12 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
3386
3409
|
else if (enableColumnOrdering &&
|
3387
3410
|
hoveredColumn &&
|
3388
3411
|
(hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
|
3389
|
-
|
3412
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
3413
|
+
setColumnOrder(reorderedColumns);
|
3414
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
3415
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
3416
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
3417
|
+
}));
|
3390
3418
|
}
|
3391
3419
|
setDraggingColumn(null);
|
3392
3420
|
setHoveredColumn(null);
|
@@ -3671,10 +3699,11 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
3671
3699
|
table,
|
3672
3700
|
});
|
3673
3701
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getCoreRowModel().rows.length;
|
3702
|
+
const filteredRowCount = getFilteredSelectedRowModel().rows.length;
|
3674
3703
|
const selectedRowCount = useMemo(() => manualPagination
|
3675
3704
|
? Object.values(rowSelection).filter(Boolean).length
|
3676
|
-
:
|
3677
|
-
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.
|
3705
|
+
: filteredRowCount, [rowSelection, totalRowCount, manualPagination, filteredRowCount]);
|
3706
|
+
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;
|
3678
3707
|
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;
|
3679
3708
|
return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
3680
3709
|
var _a, _b;
|
@@ -3959,7 +3988,9 @@ const MRT_TablePagination = (_a) => {
|
|
3959
3988
|
last: LastPageIcon,
|
3960
3989
|
next: ChevronRightIcon,
|
3961
3990
|
previous: ChevronLeftIcon,
|
3962
|
-
} }, 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
|
3991
|
+
} }, 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
|
3992
|
+
? 0
|
3993
|
+
: (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] }));
|
3963
3994
|
};
|
3964
3995
|
|
3965
3996
|
const MRT_ToolbarDropZone = (_a) => {
|
@@ -4033,7 +4064,7 @@ const MRT_ColumnPinningButtons = (_a) => {
|
|
4033
4064
|
const MRT_ShowHideColumnsMenuItems = (_a) => {
|
4034
4065
|
var _b;
|
4035
4066
|
var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
|
4036
|
-
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, } = table;
|
4067
|
+
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, setColumnPinning, } = table;
|
4037
4068
|
const { columnOrder } = getState();
|
4038
4069
|
const { columnDef } = column;
|
4039
4070
|
const { columnDefType } = columnDef;
|
@@ -4064,7 +4095,12 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
4064
4095
|
setIsDragging(false);
|
4065
4096
|
setHoveredColumn(null);
|
4066
4097
|
if (hoveredColumn) {
|
4067
|
-
|
4098
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
4099
|
+
setColumnOrder(reorderedColumns);
|
4100
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
4101
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
4102
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
4103
|
+
}));
|
4068
4104
|
}
|
4069
4105
|
};
|
4070
4106
|
const handleDragEnter = (_e) => {
|
@@ -4202,7 +4238,7 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
4202
4238
|
setShowGlobalFilter(!showGlobalFilter);
|
4203
4239
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
4204
4240
|
};
|
4205
|
-
return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }));
|
4241
|
+
return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter && showGlobalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }));
|
4206
4242
|
};
|
4207
4243
|
|
4208
4244
|
const MRT_ToolbarInternalButtons = (_a) => {
|