material-react-table 2.0.0-alpha.2 → 2.0.0-alpha.4
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/cjs/index.js +208 -144
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/icons.d.ts +4 -0
- package/dist/cjs/types/locales/np.d.ts +2 -0
- package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/cjs/types/types.d.ts +29 -3
- package/dist/esm/material-react-table.esm.js +200 -144
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/icons.d.ts +4 -0
- package/dist/esm/types/locales/np.d.ts +2 -0
- package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/esm/types/types.d.ts +29 -3
- package/dist/index.d.ts +35 -5
- package/locales/np.d.ts +2 -0
- package/locales/np.esm.d.ts +2 -0
- package/locales/np.esm.js +94 -0
- package/locales/np.esm.js.map +1 -0
- package/locales/np.js +98 -0
- package/locales/np.js.map +1 -0
- package/package.json +26 -26
- package/src/column.utils.ts +1 -5
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +1 -1
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +6 -6
- package/src/hooks/useMRT_Effects.ts +13 -2
- package/src/icons.ts +12 -0
- package/src/inputs/MRT_FilterTextField.tsx +302 -223
- package/src/locales/np.ts +94 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +34 -31
- package/src/menus/MRT_FilterOptionMenu.tsx +1 -1
- package/src/toolbar/MRT_TablePagination.tsx +124 -67
- package/src/types.ts +44 -5
package/dist/cjs/index.js
CHANGED
@@ -30,9 +30,11 @@ var ListItemIcon = require('@mui/material/ListItemIcon');
|
|
30
30
|
var Menu = require('@mui/material/Menu');
|
31
31
|
var Checkbox = require('@mui/material/Checkbox');
|
32
32
|
var FormControlLabel = require('@mui/material/FormControlLabel');
|
33
|
+
var Autocomplete = require('@mui/material/Autocomplete');
|
33
34
|
var Chip = require('@mui/material/Chip');
|
34
35
|
var InputAdornment = require('@mui/material/InputAdornment');
|
35
36
|
var utils = require('@mui/material/utils');
|
37
|
+
var DatePicker = require('@mui/x-date-pickers/DatePicker');
|
36
38
|
var FormHelperText = require('@mui/material/FormHelperText');
|
37
39
|
var Slider = require('@mui/material/Slider');
|
38
40
|
var Stack = require('@mui/material/Stack');
|
@@ -49,7 +51,10 @@ var CircularProgress = require('@mui/material/CircularProgress');
|
|
49
51
|
var Toolbar = require('@mui/material/Toolbar');
|
50
52
|
var useMediaQuery = require('@mui/material/useMediaQuery');
|
51
53
|
var LinearProgress = require('@mui/material/LinearProgress');
|
52
|
-
var
|
54
|
+
var InputLabel = require('@mui/material/InputLabel');
|
55
|
+
var Pagination = require('@mui/material/Pagination');
|
56
|
+
var PaginationItem = require('@mui/material/PaginationItem');
|
57
|
+
var Select = require('@mui/material/Select');
|
53
58
|
var Alert = require('@mui/material/Alert');
|
54
59
|
var AlertTitle = require('@mui/material/AlertTitle');
|
55
60
|
var Fade = require('@mui/material/Fade');
|
@@ -58,6 +63,8 @@ var Radio = require('@mui/material/Radio');
|
|
58
63
|
var ArrowDownwardIcon = require('@mui/icons-material/ArrowDownward');
|
59
64
|
var ArrowRightIcon = require('@mui/icons-material/ArrowRight');
|
60
65
|
var CancelIcon = require('@mui/icons-material/Cancel');
|
66
|
+
var ChevronLefIcon = require('@mui/icons-material/ChevronLeft');
|
67
|
+
var ChevronRightIcon = require('@mui/icons-material/ChevronRight');
|
61
68
|
var ClearAllIcon = require('@mui/icons-material/ClearAll');
|
62
69
|
var CloseIcon = require('@mui/icons-material/Close');
|
63
70
|
var DensityLargeIcon = require('@mui/icons-material/DensityLarge');
|
@@ -70,9 +77,11 @@ var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
|
|
70
77
|
var FilterAltIcon = require('@mui/icons-material/FilterAlt');
|
71
78
|
var FilterListIcon = require('@mui/icons-material/FilterList');
|
72
79
|
var FilterListOffIcon = require('@mui/icons-material/FilterListOff');
|
80
|
+
var FirstPageIcon = require('@mui/icons-material/FirstPage');
|
73
81
|
var FullscreenIcon = require('@mui/icons-material/Fullscreen');
|
74
82
|
var FullscreenExitIcon = require('@mui/icons-material/FullscreenExit');
|
75
83
|
var KeyboardDoubleArrowDownIcon = require('@mui/icons-material/KeyboardDoubleArrowDown');
|
84
|
+
var LastPageIcon = require('@mui/icons-material/LastPage');
|
76
85
|
var MoreHorizIcon = require('@mui/icons-material/MoreHoriz');
|
77
86
|
var MoreVertIcon = require('@mui/icons-material/MoreVert');
|
78
87
|
var PushPinIcon = require('@mui/icons-material/PushPin');
|
@@ -108,6 +117,7 @@ var ListItemIcon__default = /*#__PURE__*/_interopDefaultLegacy(ListItemIcon);
|
|
108
117
|
var Menu__default = /*#__PURE__*/_interopDefaultLegacy(Menu);
|
109
118
|
var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
|
110
119
|
var FormControlLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormControlLabel);
|
120
|
+
var Autocomplete__default = /*#__PURE__*/_interopDefaultLegacy(Autocomplete);
|
111
121
|
var Chip__default = /*#__PURE__*/_interopDefaultLegacy(Chip);
|
112
122
|
var InputAdornment__default = /*#__PURE__*/_interopDefaultLegacy(InputAdornment);
|
113
123
|
var FormHelperText__default = /*#__PURE__*/_interopDefaultLegacy(FormHelperText);
|
@@ -126,7 +136,10 @@ var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgr
|
|
126
136
|
var Toolbar__default = /*#__PURE__*/_interopDefaultLegacy(Toolbar);
|
127
137
|
var useMediaQuery__default = /*#__PURE__*/_interopDefaultLegacy(useMediaQuery);
|
128
138
|
var LinearProgress__default = /*#__PURE__*/_interopDefaultLegacy(LinearProgress);
|
129
|
-
var
|
139
|
+
var InputLabel__default = /*#__PURE__*/_interopDefaultLegacy(InputLabel);
|
140
|
+
var Pagination__default = /*#__PURE__*/_interopDefaultLegacy(Pagination);
|
141
|
+
var PaginationItem__default = /*#__PURE__*/_interopDefaultLegacy(PaginationItem);
|
142
|
+
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
130
143
|
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
131
144
|
var AlertTitle__default = /*#__PURE__*/_interopDefaultLegacy(AlertTitle);
|
132
145
|
var Fade__default = /*#__PURE__*/_interopDefaultLegacy(Fade);
|
@@ -135,6 +148,8 @@ var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
|
|
135
148
|
var ArrowDownwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownwardIcon);
|
136
149
|
var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
|
137
150
|
var CancelIcon__default = /*#__PURE__*/_interopDefaultLegacy(CancelIcon);
|
151
|
+
var ChevronLefIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronLefIcon);
|
152
|
+
var ChevronRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronRightIcon);
|
138
153
|
var ClearAllIcon__default = /*#__PURE__*/_interopDefaultLegacy(ClearAllIcon);
|
139
154
|
var CloseIcon__default = /*#__PURE__*/_interopDefaultLegacy(CloseIcon);
|
140
155
|
var DensityLargeIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityLargeIcon);
|
@@ -147,9 +162,11 @@ var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon)
|
|
147
162
|
var FilterAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltIcon);
|
148
163
|
var FilterListIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListIcon);
|
149
164
|
var FilterListOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListOffIcon);
|
165
|
+
var FirstPageIcon__default = /*#__PURE__*/_interopDefaultLegacy(FirstPageIcon);
|
150
166
|
var FullscreenIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenIcon);
|
151
167
|
var FullscreenExitIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenExitIcon);
|
152
168
|
var KeyboardDoubleArrowDownIcon__default = /*#__PURE__*/_interopDefaultLegacy(KeyboardDoubleArrowDownIcon);
|
169
|
+
var LastPageIcon__default = /*#__PURE__*/_interopDefaultLegacy(LastPageIcon);
|
153
170
|
var MoreHorizIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreHorizIcon);
|
154
171
|
var MoreVertIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreVertIcon);
|
155
172
|
var PushPinIcon__default = /*#__PURE__*/_interopDefaultLegacy(PushPinIcon);
|
@@ -346,10 +363,10 @@ const getDefaultColumnOrderIds = (props) => {
|
|
346
363
|
return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
|
347
364
|
};
|
348
365
|
const getDefaultColumnFilterFn = (columnDef) => {
|
366
|
+
var _a;
|
349
367
|
if (columnDef.filterVariant === 'multi-select')
|
350
368
|
return 'arrIncludesSome';
|
351
|
-
if (columnDef.filterVariant === 'range'
|
352
|
-
columnDef.filterVariant === 'range-slider')
|
369
|
+
if ((_a = columnDef.filterVariant) === null || _a === void 0 ? void 0 : _a.includes('range'))
|
353
370
|
return 'betweenInclusive';
|
354
371
|
if (columnDef.filterVariant === 'select' ||
|
355
372
|
columnDef.filterVariant === 'checkbox')
|
@@ -1217,7 +1234,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
1217
1234
|
globalFilterModeOptions.includes(filterOption.option)) &&
|
1218
1235
|
['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
|
1219
1236
|
const handleSelectFilterMode = (option) => {
|
1220
|
-
var _a;
|
1237
|
+
var _a, _b;
|
1221
1238
|
const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
|
1222
1239
|
if (!header || !column) {
|
1223
1240
|
// global filter mode
|
@@ -1249,7 +1266,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
1249
1266
|
column.setFilterValue(currentFilterValue); // perform new filter render
|
1250
1267
|
}
|
1251
1268
|
}
|
1252
|
-
else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'range' ||
|
1269
|
+
else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
|
1253
1270
|
rangeModes.includes(option)) {
|
1254
1271
|
// will now be range filter mode
|
1255
1272
|
if (!Array.isArray(currentFilterValue) ||
|
@@ -1316,7 +1333,7 @@ const commonListItemStyles = {
|
|
1316
1333
|
};
|
1317
1334
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
1318
1335
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
1319
|
-
const { getState, options: { columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
|
1336
|
+
const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
|
1320
1337
|
const { column } = header;
|
1321
1338
|
const { columnDef } = column;
|
1322
1339
|
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
@@ -1389,11 +1406,11 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
1389
1406
|
jsxRuntime.jsx(MenuItem__default["default"], { disabled: !columnFilterValue ||
|
1390
1407
|
(Array.isArray(columnFilterValue) &&
|
1391
1408
|
!columnFilterValue.filter((value) => value).length), onClick: handleClearFilter, sx: commonMenuItemStyles, children: jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(FilterListOffIcon, {}) }), localization.clearFilter] }) }, 3),
|
1392
|
-
jsxRuntime.jsxs(MenuItem__default["default"], { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, onClick: showColumnFilters
|
1409
|
+
columnFilterDisplayMode === 'subheader' && (jsxRuntime.jsxs(MenuItem__default["default"], { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, onClick: showColumnFilters
|
1393
1410
|
? handleOpenFilterModeMenu
|
1394
|
-
: handleFilterByColumn, sx: commonMenuItemStyles, children: [jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(FilterListIcon, {}) }), (_d = localization.filterByColumn) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))] }), showFilterModeSubMenu && (jsxRuntime.jsx(IconButton__default["default"], { onClick: handleOpenFilterModeMenu, onMouseEnter: handleOpenFilterModeMenu, size: "small", sx: { p: 0 }, children: jsxRuntime.jsx(ArrowRightIcon, {}) }))] }, 4),
|
1411
|
+
: handleFilterByColumn, sx: commonMenuItemStyles, children: [jsxRuntime.jsxs(Box__default["default"], { sx: commonListItemStyles, children: [jsxRuntime.jsx(ListItemIcon__default["default"], { children: jsxRuntime.jsx(FilterListIcon, {}) }), (_d = localization.filterByColumn) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))] }), showFilterModeSubMenu && (jsxRuntime.jsx(IconButton__default["default"], { onClick: handleOpenFilterModeMenu, onMouseEnter: handleOpenFilterModeMenu, size: "small", sx: { p: 0 }, children: jsxRuntime.jsx(ArrowRightIcon, {}) }))] }, 4)),
|
1395
1412
|
showFilterModeSubMenu && (jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
|
1396
|
-
]
|
1413
|
+
].filter(Boolean)
|
1397
1414
|
: []),
|
1398
1415
|
...(enableGrouping && column.getCanGroup()
|
1399
1416
|
? [
|
@@ -1487,18 +1504,29 @@ const MRT_FilterCheckbox = ({ column, table, }) => {
|
|
1487
1504
|
};
|
1488
1505
|
|
1489
1506
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
1490
|
-
var _a, _b, _c, _d,
|
1491
|
-
const { options: { columnFilterModeOptions, enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
1507
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o;
|
1508
|
+
const { options: { columnFilterModeOptions, enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
1492
1509
|
const { column } = header;
|
1493
1510
|
const { columnDef } = column;
|
1511
|
+
const { filterVariant } = columnDef;
|
1494
1512
|
const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTextFieldProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterTextFieldProps, {
|
1495
1513
|
column,
|
1496
1514
|
table,
|
1497
1515
|
}));
|
1498
|
-
const
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1516
|
+
const autocompleteProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterAutocompleteProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterAutocompleteProps, {
|
1517
|
+
column,
|
1518
|
+
table,
|
1519
|
+
}));
|
1520
|
+
const datePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterDatePickerProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterDatePickerProps, {
|
1521
|
+
column,
|
1522
|
+
table,
|
1523
|
+
}));
|
1524
|
+
const isDateFilter = filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date');
|
1525
|
+
const isAutocompleteFilter = filterVariant === 'autocomplete';
|
1526
|
+
const isRangeFilter = (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range')) || rangeFilterIndex !== undefined;
|
1527
|
+
const isSelectFilter = filterVariant === 'select';
|
1528
|
+
const isMultiSelectFilter = filterVariant === 'multi-select';
|
1529
|
+
const isTextboxFilter = ['autocomplete', 'text'].includes(filterVariant) ||
|
1502
1530
|
(!isSelectFilter && !isMultiSelectFilter);
|
1503
1531
|
const currentFilterOption = columnDef._filterFn;
|
1504
1532
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
@@ -1513,55 +1541,48 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1513
1541
|
: rangeFilterIndex === 1
|
1514
1542
|
? localization.max
|
1515
1543
|
: '';
|
1516
|
-
const allowedColumnFilterOptions = (
|
1544
|
+
const allowedColumnFilterOptions = (_f = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _f !== void 0 ? _f : columnFilterModeOptions;
|
1517
1545
|
const showChangeModeButton = enableColumnFilterModes &&
|
1518
1546
|
columnDef.enableColumnFilterModes !== false &&
|
1519
1547
|
!rangeFilterIndex &&
|
1520
1548
|
(allowedColumnFilterOptions === undefined ||
|
1521
1549
|
!!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
|
1522
1550
|
const facetedUniqueValues = column.getFacetedUniqueValues();
|
1523
|
-
const filterSelectOptions = react.useMemo(() => {
|
1524
|
-
var _a;
|
1525
|
-
return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter) && facetedUniqueValues
|
1526
|
-
? Array.from(facetedUniqueValues.keys())
|
1527
|
-
.filter((value) => value !== null && value !== undefined)
|
1528
|
-
.sort((a, b) => a.localeCompare(b))
|
1529
|
-
: undefined);
|
1530
|
-
}, [
|
1531
|
-
columnDef.filterSelectOptions,
|
1532
|
-
facetedUniqueValues,
|
1533
|
-
isMultiSelectFilter,
|
1534
|
-
isSelectFilter,
|
1535
|
-
]);
|
1536
1551
|
const [anchorEl, setAnchorEl] = react.useState(null);
|
1537
1552
|
const [filterValue, setFilterValue] = react.useState(() => {
|
1538
1553
|
var _a, _b;
|
1539
1554
|
return isMultiSelectFilter
|
1540
1555
|
? column.getFilterValue() || []
|
1541
1556
|
: isRangeFilter
|
1542
|
-
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) ||
|
1557
|
+
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
|
1543
1558
|
: (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
|
1544
1559
|
});
|
1545
|
-
const handleChangeDebounced = react.useCallback(utils.debounce((
|
1546
|
-
const value = textFieldProps.type === 'date'
|
1547
|
-
? event.target.valueAsDate
|
1548
|
-
: textFieldProps.type === 'number'
|
1549
|
-
? event.target.valueAsNumber
|
1550
|
-
: event.target.value;
|
1560
|
+
const handleChangeDebounced = react.useCallback(utils.debounce((newValue) => {
|
1551
1561
|
if (isRangeFilter) {
|
1552
1562
|
column.setFilterValue((old) => {
|
1553
1563
|
const newFilterValues = old !== null && old !== void 0 ? old : ['', ''];
|
1554
|
-
newFilterValues[rangeFilterIndex] =
|
1564
|
+
newFilterValues[rangeFilterIndex] = newValue;
|
1555
1565
|
return newFilterValues;
|
1556
1566
|
});
|
1557
1567
|
}
|
1558
1568
|
else {
|
1559
|
-
column.setFilterValue(
|
1569
|
+
column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
|
1560
1570
|
}
|
1561
1571
|
}, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
|
1562
|
-
const handleChange = (
|
1563
|
-
|
1564
|
-
|
1572
|
+
const handleChange = (newValue) => {
|
1573
|
+
var _a;
|
1574
|
+
setFilterValue((_a = newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== null && _a !== void 0 ? _a : '');
|
1575
|
+
handleChangeDebounced(newValue);
|
1576
|
+
};
|
1577
|
+
const handleTextFieldChange = (event) => {
|
1578
|
+
var _a;
|
1579
|
+
const newValue = textFieldProps.type === 'date'
|
1580
|
+
? event.target.valueAsDate
|
1581
|
+
: textFieldProps.type === 'number'
|
1582
|
+
? event.target.valueAsNumber
|
1583
|
+
: event.target.value;
|
1584
|
+
handleChange(newValue);
|
1585
|
+
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
1565
1586
|
};
|
1566
1587
|
const handleClear = () => {
|
1567
1588
|
if (isMultiSelectFilter) {
|
@@ -1609,26 +1630,76 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1609
1630
|
isMounted.current = true;
|
1610
1631
|
}, [column.getFilterValue()]);
|
1611
1632
|
if (columnDef.Filter) {
|
1612
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (
|
1633
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: (_g = columnDef.Filter) === null || _g === void 0 ? void 0 : _g.call(columnDef, { column, header, rangeFilterIndex, table }) }));
|
1613
1634
|
}
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1635
|
+
const dropdownOptions = react.useMemo(() => {
|
1636
|
+
var _a;
|
1637
|
+
return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter || isAutocompleteFilter) &&
|
1638
|
+
facetedUniqueValues
|
1639
|
+
? Array.from(facetedUniqueValues.keys())
|
1640
|
+
.filter((value) => value !== null && value !== undefined)
|
1641
|
+
.sort((a, b) => a.localeCompare(b))
|
1642
|
+
: undefined);
|
1643
|
+
}, [
|
1644
|
+
columnDef.filterSelectOptions,
|
1645
|
+
facetedUniqueValues,
|
1646
|
+
isMultiSelectFilter,
|
1647
|
+
isSelectFilter,
|
1648
|
+
]);
|
1649
|
+
const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsxRuntime.jsx(InputAdornment__default["default"], { position: "end", sx: { mr: isSelectFilter || isMultiSelectFilter ? '20px' : undefined }, children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, placement: "right", title: (_h = localization.clearFilter) !== null && _h !== void 0 ? _h : '', children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.clearFilter, disabled: !((_j = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _j === void 0 ? void 0 : _j.length), onClick: handleClear, size: "small", sx: {
|
1650
|
+
height: '2rem',
|
1651
|
+
transform: 'scale(0.9)',
|
1652
|
+
width: '2rem'
|
1653
|
+
}, children: jsxRuntime.jsx(CloseIcon, {}) }) }) }) })) : null;
|
1654
|
+
const startAdornment = showChangeModeButton ? (jsxRuntime.jsxs(InputAdornment__default["default"], { position: "start", children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.changeFilterMode, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.changeFilterMode, onClick: handleFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsxRuntime.jsx(FilterListIcon, {}) }) }) }), filterChipLabel && (jsxRuntime.jsx(Chip__default["default"], { label: filterChipLabel, onDelete: handleClearEmptyFilterChip }))] })) : null;
|
1655
|
+
const commonTextFieldProps = Object.assign(Object.assign({ FormHelperTextProps: {
|
1656
|
+
sx: {
|
1657
|
+
fontSize: '0.75rem',
|
1658
|
+
lineHeight: '0.8rem',
|
1659
|
+
whiteSpace: 'nowrap',
|
1660
|
+
},
|
1661
|
+
}, InputProps: endAdornment //hack because mui looks for presense of endAdornment key instead of undefined
|
1662
|
+
? { endAdornment, startAdornment }
|
1663
|
+
: { startAdornment }, fullWidth: true, helperText: showChangeModeButton ? (jsxRuntime.jsx("label", { children: localization.filterMode.replace('{filterType}',
|
1664
|
+
// @ts-ignore
|
1665
|
+
localization[`filter${((_k = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _k === void 0 ? void 0 : _k.toUpperCase()) +
|
1666
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputProps: {
|
1667
|
+
autoComplete: 'new-password',
|
1668
|
+
disabled: !!filterChipLabel,
|
1669
|
+
sx: {
|
1670
|
+
textOverflow: 'ellipsis',
|
1671
|
+
width: filterChipLabel ? 0 : undefined,
|
1672
|
+
},
|
1673
|
+
title: filterPlaceholder,
|
1674
|
+
}, inputRef: (inputRef) => {
|
1675
|
+
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
1676
|
+
inputRef;
|
1677
|
+
if (textFieldProps.inputRef) {
|
1678
|
+
textFieldProps.inputRef = inputRef;
|
1679
|
+
}
|
1680
|
+
}, margin: 'none', onClick: (e) => e.stopPropagation(), placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
1681
|
+
? undefined
|
1682
|
+
: filterPlaceholder, variant: 'standard' }, textFieldProps), { sx: (theme) => (Object.assign({ minWidth: isDateFilter
|
1683
|
+
? '160px'
|
1684
|
+
: isRangeFilter
|
1685
|
+
? '100px'
|
1686
|
+
: !filterChipLabel
|
1687
|
+
? '120px'
|
1688
|
+
: 'auto', mx: '-2px', p: 0, width: 'calc(100% + 4px)' }, parseFromValuesOrFunc(textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx, theme))) });
|
1689
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isDateFilter ? (jsxRuntime.jsx(DatePicker.DatePicker, Object.assign({ onChange: (newDate) => {
|
1690
|
+
handleChange(newDate);
|
1691
|
+
}, value: filterValue || null }, datePickerProps, { slotProps: {
|
1692
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_l = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _l === void 0 ? void 0 : _l.field),
|
1693
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_m = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _m === void 0 ? void 0 : _m.textField),
|
1694
|
+
} }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], Object.assign({ getOptionLabel: (option) => option, onChange: (_e, newValue) => handleChange(newValue), options: dropdownOptions !== null && dropdownOptions !== void 0 ? dropdownOptions : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
1695
|
+
var _a;
|
1696
|
+
return (jsxRuntime.jsx(TextField__default["default"], Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange })));
|
1697
|
+
}, value: filterValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ SelectProps: {
|
1627
1698
|
displayEmpty: true,
|
1628
1699
|
multiple: isMultiSelectFilter,
|
1629
1700
|
renderValue: isMultiSelectFilter
|
1630
1701
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (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 === null || selected === void 0 ? void 0 : selected.map((value) => {
|
1631
|
-
const selectedValue =
|
1702
|
+
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => option instanceof Object
|
1632
1703
|
? option.value === value
|
1633
1704
|
: option === value);
|
1634
1705
|
return (jsxRuntime.jsx(Chip__default["default"], { label: selectedValue instanceof Object
|
@@ -1636,52 +1707,33 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1636
1707
|
: selectedValue }, value));
|
1637
1708
|
}) }))
|
1638
1709
|
: undefined,
|
1639
|
-
},
|
1640
|
-
|
1641
|
-
|
1642
|
-
(
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
return '';
|
1667
|
-
let value;
|
1668
|
-
let text;
|
1669
|
-
if (typeof option !== 'object') {
|
1670
|
-
value = option;
|
1671
|
-
text = option;
|
1672
|
-
}
|
1673
|
-
else {
|
1674
|
-
value = option.value;
|
1675
|
-
text = option.text;
|
1676
|
-
}
|
1677
|
-
return (jsxRuntime.jsxs(MenuItem__default["default"], { sx: {
|
1678
|
-
alignItems: 'center',
|
1679
|
-
display: 'flex',
|
1680
|
-
gap: '0.5rem',
|
1681
|
-
m: 0,
|
1682
|
-
}, value: value, children: [isMultiSelectFilter && (jsxRuntime.jsx(Checkbox__default["default"], { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), text, ' ', !columnDef.filterSelectOptions &&
|
1683
|
-
`(${facetedUniqueValues.get(value)})`] }, value));
|
1684
|
-
})] })), jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, setFilterValue: setFilterValue, table: table })] }));
|
1710
|
+
}, onChange: handleTextFieldChange, select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
1711
|
+
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"),
|
1712
|
+
...[
|
1713
|
+
(_o = textFieldProps.children) !== null && _o !== void 0 ? _o : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
1714
|
+
var _a;
|
1715
|
+
if (!option)
|
1716
|
+
return '';
|
1717
|
+
let value;
|
1718
|
+
let text;
|
1719
|
+
if (typeof option !== 'object') {
|
1720
|
+
value = option;
|
1721
|
+
text = option;
|
1722
|
+
}
|
1723
|
+
else {
|
1724
|
+
value = option.value;
|
1725
|
+
text = option.text;
|
1726
|
+
}
|
1727
|
+
return (jsxRuntime.jsxs(MenuItem__default["default"], { sx: {
|
1728
|
+
alignItems: 'center',
|
1729
|
+
display: 'flex',
|
1730
|
+
gap: '0.5rem',
|
1731
|
+
m: 0,
|
1732
|
+
}, value: value, children: [isMultiSelectFilter && (jsxRuntime.jsx(Checkbox__default["default"], { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), text, ' ', !columnDef.filterSelectOptions &&
|
1733
|
+
`(${facetedUniqueValues.get(value)})`] }, `${index}-${value}`));
|
1734
|
+
}),
|
1735
|
+
],
|
1736
|
+
] }))), jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, setFilterValue: setFilterValue, table: table })] }));
|
1685
1737
|
};
|
1686
1738
|
|
1687
1739
|
const MRT_FilterRangeFields = ({ header, table, }) => {
|
@@ -1760,16 +1812,17 @@ const MRT_FilterRangeSlider = ({ header, table, }) => {
|
|
1760
1812
|
};
|
1761
1813
|
|
1762
1814
|
const MRT_TableHeadCellFilterContainer = ({ header, table, }) => {
|
1815
|
+
var _a;
|
1763
1816
|
const { getState, options: { columnFilterDisplayMode }, } = table;
|
1764
1817
|
const { showColumnFilters } = getState();
|
1765
1818
|
const { column } = header;
|
1766
1819
|
const { columnDef } = column;
|
1767
|
-
return (jsxRuntime.jsx(Collapse__default["default"], { in: showColumnFilters || columnFilterDisplayMode === 'popover', mountOnEnter: true, unmountOnExit: true, children: columnDef.filterVariant === 'checkbox' ? (jsxRuntime.jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsxRuntime.jsx(MRT_FilterRangeSlider, { header: header, table: table })) : columnDef.filterVariant === 'range' ||
|
1820
|
+
return (jsxRuntime.jsx(Collapse__default["default"], { in: showColumnFilters || columnFilterDisplayMode === 'popover', mountOnEnter: true, unmountOnExit: true, children: columnDef.filterVariant === 'checkbox' ? (jsxRuntime.jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsxRuntime.jsx(MRT_FilterRangeSlider, { header: header, table: table })) : ((_a = columnDef.filterVariant) === null || _a === void 0 ? void 0 : _a.includes('range')) ||
|
1768
1821
|
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn) ? (jsxRuntime.jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsxRuntime.jsx(MRT_FilterTextField, { header: header, table: table })) }));
|
1769
1822
|
};
|
1770
1823
|
|
1771
1824
|
const MRT_TableHeadCellFilterLabel = ({ header, table, }) => {
|
1772
|
-
var _a, _b, _c
|
1825
|
+
var _a, _b, _c;
|
1773
1826
|
const { options: { columnFilterDisplayMode, icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
|
1774
1827
|
const { column } = header;
|
1775
1828
|
const { columnDef } = column;
|
@@ -1777,26 +1830,26 @@ const MRT_TableHeadCellFilterLabel = ({ header, table, }) => {
|
|
1777
1830
|
const [anchorEl, setAnchorEl] = react.useState(null);
|
1778
1831
|
const isFilterActive = (Array.isArray(filterValue) && filterValue.some(Boolean)) ||
|
1779
1832
|
(!!filterValue && !Array.isArray(filterValue));
|
1780
|
-
const isRangeFilter = columnDef.filterVariant === 'range' ||
|
1833
|
+
const isRangeFilter = ((_a = columnDef.filterVariant) === null || _a === void 0 ? void 0 : _a.includes('range')) ||
|
1781
1834
|
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
|
1782
1835
|
const currentFilterOption = columnDef._filterFn;
|
1783
1836
|
const filterTooltip = columnFilterDisplayMode === 'popover' && !isFilterActive
|
1784
|
-
? (
|
1837
|
+
? (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', String(columnDef.header))
|
1785
1838
|
: localization.filteringByColumn
|
1786
1839
|
.replace('{column}', String(columnDef.header))
|
1787
1840
|
.replace('{filterType}', currentFilterOption
|
1788
1841
|
? // @ts-ignore
|
1789
|
-
localization[`filter${((
|
1842
|
+
localization[`filter${((_c = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
|
1790
1843
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
1791
1844
|
: '')
|
1792
|
-
.replace('{filterValue}', `"${Array.isArray(
|
1793
|
-
?
|
1794
|
-
:
|
1845
|
+
.replace('{filterValue}', `"${Array.isArray(filterValue)
|
1846
|
+
? filterValue.join(`" ${isRangeFilter ? localization.and : localization.or} "`)
|
1847
|
+
: filterValue}"`)
|
1795
1848
|
.replace('" "', '');
|
1796
1849
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Grow__default["default"], { in: columnFilterDisplayMode === 'popover' ||
|
1797
|
-
(!!
|
1850
|
+
(!!filterValue && !isRangeFilter) ||
|
1798
1851
|
(isRangeFilter && // @ts-ignore
|
1799
|
-
(!!(
|
1852
|
+
(!!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[0]) || !!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[1]))), unmountOnExit: true, children: jsxRuntime.jsx(Box__default["default"], { component: "span", sx: { flex: '0 0' }, children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, placement: "top", title: filterTooltip, children: jsxRuntime.jsx(IconButton__default["default"], { disableRipple: true, onClick: (event) => {
|
1800
1853
|
if (columnFilterDisplayMode === 'popover') {
|
1801
1854
|
setAnchorEl(event.currentTarget);
|
1802
1855
|
}
|
@@ -2273,41 +2326,40 @@ const MRT_LinearProgressBar = ({ isTopToolbar, table, }) => {
|
|
2273
2326
|
}, unmountOnExit: true, children: jsxRuntime.jsx(LinearProgress__default["default"], Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
|
2274
2327
|
};
|
2275
2328
|
|
2329
|
+
const defaultPageSizeOptions = [5, 10, 15, 20, 25, 30, 50, 100];
|
2276
2330
|
const MRT_TablePagination = ({ position = 'bottom', table, }) => {
|
2277
|
-
const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, localization, muiTablePaginationProps, rowCount, }, setPageIndex, setPageSize, } = table;
|
2331
|
+
const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, icons: { ChevronLefIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, localization, muiTablePaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
|
2278
2332
|
const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
|
2279
|
-
const
|
2280
|
-
const showFirstLastPageButtons = totalRowCount / pageSize > 2;
|
2281
|
-
const tablePaginationProps = parseFromValuesOrFunc(muiTablePaginationProps, {
|
2333
|
+
const paginationProps = parseFromValuesOrFunc(muiTablePaginationProps, {
|
2282
2334
|
table,
|
2283
2335
|
});
|
2284
|
-
const
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
}, '& .MuiTablePagination-displayedRows': {
|
2298
|
-
m: '0 1px',
|
2299
|
-
}, '& .MuiTablePagination-selectLabel': {
|
2300
|
-
m: '0 -1px',
|
2301
|
-
}, '& .MuiTablePagination-toolbar': {
|
2302
|
-
alignItems: 'center',
|
2303
|
-
display: 'flex',
|
2304
|
-
}, '&. MuiInputBase-root': {
|
2305
|
-
m: '0 1px',
|
2306
|
-
}, mt: position === 'top' &&
|
2336
|
+
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
2337
|
+
const numberOfPages = Math.ceil(totalRowCount / pageSize);
|
2338
|
+
const showFirstLastPageButtons = numberOfPages > 2;
|
2339
|
+
const showFirstButton = showFirstLastPageButtons && (paginationProps === null || paginationProps === void 0 ? void 0 : paginationProps.showFirstButton) !== false;
|
2340
|
+
const showLastButton = showFirstLastPageButtons && (paginationProps === null || paginationProps === void 0 ? void 0 : paginationProps.showLastButton) !== false;
|
2341
|
+
const firstRowIndex = pageIndex * pageSize;
|
2342
|
+
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
|
2343
|
+
return (jsxRuntime.jsxs(Box__default["default"], { sx: {
|
2344
|
+
alignItems: 'center',
|
2345
|
+
display: 'flex',
|
2346
|
+
gap: '8px',
|
2347
|
+
justifyContent: 'space-between',
|
2348
|
+
mt: position === 'top' &&
|
2307
2349
|
enableToolbarInternalActions &&
|
2308
2350
|
!showGlobalFilter
|
2309
|
-
? '
|
2310
|
-
: undefined,
|
2351
|
+
? '3rem'
|
2352
|
+
: undefined,
|
2353
|
+
position: 'relative',
|
2354
|
+
px: '4px',
|
2355
|
+
py: '12px',
|
2356
|
+
zIndex: 2,
|
2357
|
+
}, children: [(paginationProps === null || paginationProps === void 0 ? void 0 : paginationProps.showRowsPerPage) !== false && (jsxRuntime.jsxs(Box__default["default"], { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsxRuntime.jsx(InputLabel__default["default"], { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsxRuntime.jsx(Select__default["default"], { id: "mrt-rows-per-page", label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { '&::before': { border: 'none' }, mb: 0 }, value: pageSize, variant: "standard", children: defaultPageSizeOptions.map((value) => (jsxRuntime.jsx(MenuItem__default["default"], { sx: { m: 0 }, value: value, children: value }, value))) })] })), paginationDisplayMode === 'pages' ? (jsxRuntime.jsx(Pagination__default["default"], Object.assign({ count: numberOfPages, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsxRuntime.jsx(PaginationItem__default["default"], Object.assign({ slots: {
|
2358
|
+
first: FirstPageIcon,
|
2359
|
+
last: LastPageIcon,
|
2360
|
+
next: ChevronRightIcon,
|
2361
|
+
previous: ChevronLefIcon,
|
2362
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, paginationProps))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { mb: "0", mx: "8px", variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) })), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLefIcon, {}) }), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }), showLastButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }))] })] })) : null] }));
|
2311
2363
|
};
|
2312
2364
|
|
2313
2365
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
@@ -2955,8 +3007,9 @@ const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOption
|
|
2955
3007
|
};
|
2956
3008
|
|
2957
3009
|
const useMRT_Effects = (table) => {
|
2958
|
-
const { getState, options: { enablePagination, rowCount }, } = table;
|
2959
|
-
const { globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
|
3010
|
+
const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
|
3011
|
+
const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
|
3012
|
+
const rerender = react.useReducer(() => ({}), {})[1];
|
2960
3013
|
const isMounted = react.useRef(false);
|
2961
3014
|
const initialBodyHeight = react.useRef();
|
2962
3015
|
const previousTop = react.useRef();
|
@@ -3012,6 +3065,13 @@ const useMRT_Effects = (table) => {
|
|
3012
3065
|
table.setSorting(() => appliedSort.current || []);
|
3013
3066
|
}
|
3014
3067
|
}, [globalFilter]);
|
3068
|
+
react.useEffect(() => {
|
3069
|
+
if (enableRowPinning && getIsSomeRowsPinned()) {
|
3070
|
+
setTimeout(() => {
|
3071
|
+
rerender();
|
3072
|
+
}, 150);
|
3073
|
+
}
|
3074
|
+
}, [density]);
|
3015
3075
|
};
|
3016
3076
|
|
3017
3077
|
const useMRT_TableInstance = (tableOptions) => {
|
@@ -3280,6 +3340,8 @@ const MRT_Default_Icons = {
|
|
3280
3340
|
ArrowDownwardIcon: ArrowDownwardIcon__default["default"],
|
3281
3341
|
ArrowRightIcon: ArrowRightIcon__default["default"],
|
3282
3342
|
CancelIcon: CancelIcon__default["default"],
|
3343
|
+
ChevronLefIcon: ChevronLefIcon__default["default"],
|
3344
|
+
ChevronRightIcon: ChevronRightIcon__default["default"],
|
3283
3345
|
ClearAllIcon: ClearAllIcon__default["default"],
|
3284
3346
|
CloseIcon: CloseIcon__default["default"],
|
3285
3347
|
DensityLargeIcon: DensityLargeIcon__default["default"],
|
@@ -3292,9 +3354,11 @@ const MRT_Default_Icons = {
|
|
3292
3354
|
FilterAltIcon: FilterAltIcon__default["default"],
|
3293
3355
|
FilterListIcon: FilterListIcon__default["default"],
|
3294
3356
|
FilterListOffIcon: FilterListOffIcon__default["default"],
|
3357
|
+
FirstPageIcon: FirstPageIcon__default["default"],
|
3295
3358
|
FullscreenExitIcon: FullscreenExitIcon__default["default"],
|
3296
3359
|
FullscreenIcon: FullscreenIcon__default["default"],
|
3297
3360
|
KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDownIcon__default["default"],
|
3361
|
+
LastPageIcon: LastPageIcon__default["default"],
|
3298
3362
|
MoreHorizIcon: MoreHorizIcon__default["default"],
|
3299
3363
|
MoreVertIcon: MoreVertIcon__default["default"],
|
3300
3364
|
PushPinIcon: PushPinIcon__default["default"],
|