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.js
CHANGED
@@ -1388,6 +1388,7 @@ const MRT_Default_Icons = {
|
|
1388
1388
|
};
|
1389
1389
|
|
1390
1390
|
const MRT_Localization_EN = {
|
1391
|
+
language: 'en',
|
1391
1392
|
actions: 'Actions',
|
1392
1393
|
and: 'and',
|
1393
1394
|
cancel: 'Cancel',
|
@@ -1669,11 +1670,12 @@ const useMRT_Effects = (table) => {
|
|
1669
1670
|
if (!enablePagination || isLoading || showSkeletons)
|
1670
1671
|
return;
|
1671
1672
|
const { pageIndex, pageSize } = pagination;
|
1672
|
-
const
|
1673
|
-
|
1674
|
-
|
1673
|
+
const totalPages = totalRowCount > 0 ? Math.ceil(totalRowCount / pageSize) : 1;
|
1674
|
+
const isOutOfBounds = pageIndex < 0 || pageIndex >= totalPages;
|
1675
|
+
if (isOutOfBounds) {
|
1676
|
+
table.setPageIndex(totalPages - 1);
|
1675
1677
|
}
|
1676
|
-
}, [totalRowCount]);
|
1678
|
+
}, [totalRowCount, enablePagination, isLoading, showSkeletons]);
|
1677
1679
|
//turn off sort when global filter is looking for ranked results
|
1678
1680
|
const appliedSort = react.useRef(sorting);
|
1679
1681
|
react.useEffect(() => {
|
@@ -1887,6 +1889,11 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1887
1889
|
|
1888
1890
|
const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
|
1889
1891
|
|
1892
|
+
/**
|
1893
|
+
* When scroll, the `draggingRow` or `draggingColumn` can be removed from document because of virtualization,
|
1894
|
+
* then, the `dragEnd` event on `MRT_TableBodyRowGrabHandle` or `MRT_TableHeadCellGrabHandle` will not fire.
|
1895
|
+
* We should keep the `draggingRow` or `draggingColumn` in `getVirtualItems()` to avoid this thing.
|
1896
|
+
*/
|
1890
1897
|
const extraIndexRangeExtractor = (range, draggingIndex) => {
|
1891
1898
|
const newIndexes = reactVirtual.defaultRangeExtractor(range);
|
1892
1899
|
if (draggingIndex === undefined)
|
@@ -1962,7 +1969,6 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1962
1969
|
};
|
1963
1970
|
|
1964
1971
|
const useMRT_RowVirtualizer = (table, rows) => {
|
1965
|
-
var _a;
|
1966
1972
|
const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
|
1967
1973
|
const { density, draggingRow, expanded } = getState();
|
1968
1974
|
if (!enableRowVirtualization)
|
@@ -1970,7 +1976,14 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1970
1976
|
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
1971
1977
|
table,
|
1972
1978
|
});
|
1973
|
-
const
|
1979
|
+
const realRows = rows !== null && rows !== void 0 ? rows : getRowModel().rows;
|
1980
|
+
/**
|
1981
|
+
* when filtering, should find the correct index in filtered rows
|
1982
|
+
*/
|
1983
|
+
const draggingRowIndex = react.useMemo(() => (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id)
|
1984
|
+
? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
|
1985
|
+
: undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
|
1986
|
+
const rowCount = realRows.length;
|
1974
1987
|
const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
|
1975
1988
|
const rowVirtualizer = reactVirtual.useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
|
1976
1989
|
? expanded === true
|
@@ -1980,9 +1993,8 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1980
1993
|
navigator.userAgent.indexOf('Firefox') === -1
|
1981
1994
|
? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
|
1982
1995
|
: undefined, overscan: 4, rangeExtractor: react.useCallback((range) => {
|
1983
|
-
|
1984
|
-
|
1985
|
-
}, [draggingRow]) }, rowVirtualizerProps));
|
1996
|
+
return extraIndexRangeExtractor(range, draggingRowIndex);
|
1997
|
+
}, [draggingRowIndex]) }, rowVirtualizerProps));
|
1986
1998
|
rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
|
1987
1999
|
if (rowVirtualizerInstanceRef) {
|
1988
2000
|
//@ts-expect-error
|
@@ -3093,7 +3105,7 @@ const MRT_FilterCheckbox = (_a) => {
|
|
3093
3105
|
};
|
3094
3106
|
|
3095
3107
|
const MRT_FilterTextField = (_a) => {
|
3096
|
-
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3108
|
+
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
3097
3109
|
var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
|
3098
3110
|
const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
3099
3111
|
const { column } = header;
|
@@ -3130,9 +3142,11 @@ const MRT_FilterTextField = (_a) => {
|
|
3130
3142
|
? column.getFilterValue() || []
|
3131
3143
|
: isRangeFilter
|
3132
3144
|
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
3133
|
-
:
|
3145
|
+
: isAutocompleteFilter
|
3146
|
+
? typeof column.getFilterValue() === 'string' ? column.getFilterValue() : ''
|
3147
|
+
: ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
|
3134
3148
|
});
|
3135
|
-
const [autocompleteValue, setAutocompleteValue] = react.useState(isAutocompleteFilter ?
|
3149
|
+
const [autocompleteValue, setAutocompleteValue] = react.useState(() => isAutocompleteFilter ? (column.getFilterValue() || null) : null);
|
3136
3150
|
const handleChangeDebounced = react.useCallback(utils.debounce((newValue) => {
|
3137
3151
|
if (isRangeFilter) {
|
3138
3152
|
column.setFilterValue((old) => {
|
@@ -3159,9 +3173,12 @@ const MRT_FilterTextField = (_a) => {
|
|
3159
3173
|
handleChange(newValue);
|
3160
3174
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
3161
3175
|
};
|
3176
|
+
const handleAutocompleteInputChange = (_event, newValue, _reason) => {
|
3177
|
+
handleChange(newValue);
|
3178
|
+
};
|
3162
3179
|
const handleAutocompleteChange = (newValue) => {
|
3163
3180
|
setAutocompleteValue(newValue);
|
3164
|
-
|
3181
|
+
handleChangeDebounced(getValueAndLabel(newValue).value);
|
3165
3182
|
};
|
3166
3183
|
const handleClear = () => {
|
3167
3184
|
if (isMultiSelectFilter) {
|
@@ -3176,6 +3193,13 @@ const MRT_FilterTextField = (_a) => {
|
|
3176
3193
|
return newFilterValues;
|
3177
3194
|
});
|
3178
3195
|
}
|
3196
|
+
else if (isAutocompleteFilter) {
|
3197
|
+
setAutocompleteValue(null);
|
3198
|
+
setFilterValue('');
|
3199
|
+
// when using 'autocomplete' this function is called only inside effect and only if the filterValue === undefined
|
3200
|
+
// so the following call is excessive; should be uncommented if the handleClear becomes part of the Autocomplete component callbacks
|
3201
|
+
// column.setFilterValue(undefined)
|
3202
|
+
}
|
3179
3203
|
else {
|
3180
3204
|
setFilterValue('');
|
3181
3205
|
column.setFilterValue(undefined);
|
@@ -3234,11 +3258,10 @@ const MRT_FilterTextField = (_a) => {
|
|
3234
3258
|
lineHeight: '0.8rem',
|
3235
3259
|
whiteSpace: 'nowrap',
|
3236
3260
|
} }, (_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
|
3237
|
-
? { endAdornment, startAdornment }
|
3238
|
-
: { startAdornment }, htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3261
|
+
? 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: {
|
3239
3262
|
textOverflow: 'ellipsis',
|
3240
3263
|
width: filterChipLabel ? 0 : undefined,
|
3241
|
-
}, title: filterPlaceholder }, (
|
3264
|
+
}, title: filterPlaceholder }, (_q = textFieldProps.slotProps) === null || _q === void 0 ? void 0 : _q.htmlInput) }), onKeyDown: (e) => {
|
3242
3265
|
var _a;
|
3243
3266
|
e.stopPropagation();
|
3244
3267
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
@@ -3258,32 +3281,32 @@ const MRT_FilterTextField = (_a) => {
|
|
3258
3281
|
value: filterValue || null,
|
3259
3282
|
};
|
3260
3283
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsxRuntime.jsx(TimePicker.TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: {
|
3261
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3262
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3284
|
+
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),
|
3285
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
3263
3286
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsxRuntime.jsx(DateTimePicker.DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: {
|
3264
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3265
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3287
|
+
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),
|
3288
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_u = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _u === void 0 ? void 0 : _u.textField),
|
3266
3289
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsxRuntime.jsx(DatePicker.DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
|
3267
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3268
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3269
|
-
} }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (
|
3290
|
+
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),
|
3291
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_w = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _w === void 0 ? void 0 : _w.textField),
|
3292
|
+
} }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], 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) => {
|
3270
3293
|
var _a, _b, _c, _d, _f;
|
3271
3294
|
return (jsxRuntime.jsx(TextField__default["default"], 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:
|
3272
3295
|
//@ts-expect-error
|
3273
|
-
(_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) }),
|
3274
|
-
}, value: autocompleteValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { inputLabel: Object.assign({ shrink: isSelectFilter || isMultiSelectFilter }, (
|
3296
|
+
(_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() })));
|
3297
|
+
}, value: autocompleteValue }))) : (jsxRuntime.jsx(TextField__default["default"], 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
|
3275
3298
|
? (selected) => !Array.isArray(selected) || (selected === null || selected === void 0 ? void 0 : selected.length) === 0 ? (jsxRuntime.jsx(Box__default["default"], { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsxRuntime.jsx(Box__default["default"], { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected.map((value) => {
|
3276
3299
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
3277
3300
|
return (jsxRuntime.jsx(Chip__default["default"], { label: getValueAndLabel(selectedValue).label }, value));
|
3278
3301
|
}) }))
|
3279
|
-
: undefined }, (
|
3302
|
+
: undefined }, (_z = commonTextFieldProps.slotProps) === null || _z === void 0 ? void 0 : _z.select) }), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
|
3280
3303
|
? Array.isArray(filterValue)
|
3281
3304
|
? filterValue
|
3282
3305
|
: []
|
3283
3306
|
: filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
|
3284
3307
|
jsxRuntime.jsx(MenuItem__default["default"], { disabled: true, divider: true, hidden: true, value: "", children: jsxRuntime.jsx(Box__default["default"], { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
3285
3308
|
...[
|
3286
|
-
(
|
3309
|
+
(_0 = textFieldProps.children) !== null && _0 !== void 0 ? _0 : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
3287
3310
|
var _a;
|
3288
3311
|
const { label, value } = getValueAndLabel(option);
|
3289
3312
|
return (jsxRuntime.jsxs(MenuItem__default["default"], { sx: {
|
@@ -3449,7 +3472,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3449
3472
|
|
3450
3473
|
const MRT_TableHeadCellGrabHandle = (_a) => {
|
3451
3474
|
var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
|
3452
|
-
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
3475
|
+
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setColumnPinning, setDraggingColumn, setHoveredColumn, } = table;
|
3453
3476
|
const { columnDef } = column;
|
3454
3477
|
const { columnOrder, draggingColumn, hoveredColumn } = getState();
|
3455
3478
|
const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
|
@@ -3476,7 +3499,12 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
3476
3499
|
else if (enableColumnOrdering &&
|
3477
3500
|
hoveredColumn &&
|
3478
3501
|
(hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
|
3479
|
-
|
3502
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
3503
|
+
setColumnOrder(reorderedColumns);
|
3504
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
3505
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
3506
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
3507
|
+
}));
|
3480
3508
|
}
|
3481
3509
|
setDraggingColumn(null);
|
3482
3510
|
setHoveredColumn(null);
|
@@ -3761,10 +3789,11 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
3761
3789
|
table,
|
3762
3790
|
});
|
3763
3791
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getCoreRowModel().rows.length;
|
3792
|
+
const filteredRowCount = getFilteredSelectedRowModel().rows.length;
|
3764
3793
|
const selectedRowCount = react.useMemo(() => manualPagination
|
3765
3794
|
? Object.values(rowSelection).filter(Boolean).length
|
3766
|
-
:
|
3767
|
-
const selectedAlert = selectedRowCount > 0 ? (jsxRuntime.jsxs(Stack__default["default"], { 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.
|
3795
|
+
: filteredRowCount, [rowSelection, totalRowCount, manualPagination, filteredRowCount]);
|
3796
|
+
const selectedAlert = selectedRowCount > 0 ? (jsxRuntime.jsxs(Stack__default["default"], { 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)), jsxRuntime.jsx(Button__default["default"], { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
|
3768
3797
|
const groupedAlert = grouping.length > 0 ? (jsxRuntime.jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxRuntime.jsxs(react.Fragment, { children: [index > 0 ? localization.thenBy : '', jsxRuntime.jsx(Chip__default["default"], Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
3769
3798
|
return (jsxRuntime.jsx(Collapse__default["default"], { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsxRuntime.jsx(Alert__default["default"], Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
3770
3799
|
var _a, _b;
|
@@ -4049,7 +4078,9 @@ const MRT_TablePagination = (_a) => {
|
|
4049
4078
|
last: LastPageIcon,
|
4050
4079
|
next: ChevronRightIcon,
|
4051
4080
|
previous: ChevronLeftIcon,
|
4052
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, restPaginationProps))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0
|
4081
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, restPaginationProps))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0
|
4082
|
+
? 0
|
4083
|
+
: (firstRowIndex + 1).toLocaleString(localization.language)}-${lastRowIndex.toLocaleString(localization.language)} ${localization.of} ${totalRowCount.toLocaleString(localization.language)}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(Tooltip__default["default"], Object.assign({}, tooltipProps, { title: localization.goToFirstPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => table.firstPage(), size: "small", children: jsxRuntime.jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))), jsxRuntime.jsx(Tooltip__default["default"], Object.assign({}, tooltipProps, { title: localization.goToPreviousPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => table.previousPage(), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsxRuntime.jsx(Tooltip__default["default"], Object.assign({}, tooltipProps, { title: localization.goToNextPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => table.nextPage(), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), showLastButton && (jsxRuntime.jsx(Tooltip__default["default"], Object.assign({}, tooltipProps, { title: localization.goToLastPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => table.lastPage(), size: "small", children: jsxRuntime.jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })))] })] })) : null] }));
|
4053
4084
|
};
|
4054
4085
|
|
4055
4086
|
const MRT_ToolbarDropZone = (_a) => {
|
@@ -4123,7 +4154,7 @@ const MRT_ColumnPinningButtons = (_a) => {
|
|
4123
4154
|
const MRT_ShowHideColumnsMenuItems = (_a) => {
|
4124
4155
|
var _b;
|
4125
4156
|
var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
|
4126
|
-
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, } = table;
|
4157
|
+
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, setColumnPinning, } = table;
|
4127
4158
|
const { columnOrder } = getState();
|
4128
4159
|
const { columnDef } = column;
|
4129
4160
|
const { columnDefType } = columnDef;
|
@@ -4154,7 +4185,12 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
4154
4185
|
setIsDragging(false);
|
4155
4186
|
setHoveredColumn(null);
|
4156
4187
|
if (hoveredColumn) {
|
4157
|
-
|
4188
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
4189
|
+
setColumnOrder(reorderedColumns);
|
4190
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
4191
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
4192
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
4193
|
+
}));
|
4158
4194
|
}
|
4159
4195
|
};
|
4160
4196
|
const handleDragEnter = (_e) => {
|
@@ -4292,7 +4328,7 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
4292
4328
|
setShowGlobalFilter(!showGlobalFilter);
|
4293
4329
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
4294
4330
|
};
|
4295
|
-
return (jsxRuntime.jsx(Tooltip__default["default"], { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsxRuntime.jsx(IconButton__default["default"], 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 ? jsxRuntime.jsx(SearchOffIcon, {}) : jsxRuntime.jsx(SearchIcon, {}) })) }));
|
4331
|
+
return (jsxRuntime.jsx(Tooltip__default["default"], { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsxRuntime.jsx(IconButton__default["default"], 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 ? jsxRuntime.jsx(SearchOffIcon, {}) : jsxRuntime.jsx(SearchIcon, {}) })) }));
|
4296
4332
|
};
|
4297
4333
|
|
4298
4334
|
const MRT_ToolbarInternalButtons = (_a) => {
|