material-react-table 1.0.0-beta.8 → 1.0.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/README.md +2 -2
- package/dist/cjs/MaterialReactTable.d.ts +112 -7
- package/dist/cjs/_locales/en.d.ts +2 -0
- package/dist/cjs/_locales/pt-BR.d.ts +2 -0
- package/dist/cjs/column.utils.d.ts +6 -0
- package/dist/cjs/head/MRT_TableHeadCellSortLabel.d.ts +2 -0
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +200 -71
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_FilterCheckbox.d.ts +8 -0
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +3 -3
- package/dist/cjs/table/MRT_TableRoot.d.ts +254 -2
- package/dist/cjs/toolbar/MRT_TablePagination.d.ts +3 -4
- package/dist/cjs/toolbar/MRT_ToolbarInternalButtons.d.ts +3 -4
- package/dist/cjs/toolbar/MRT_TopToolbar.d.ts +1 -0
- package/dist/esm/MaterialReactTable.d.ts +112 -7
- package/dist/esm/_locales/en.d.ts +2 -0
- package/dist/esm/_locales/pt-BR.d.ts +2 -0
- package/dist/esm/column.utils.d.ts +6 -0
- package/dist/esm/head/MRT_TableHeadCellSortLabel.d.ts +2 -0
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/inputs/MRT_FilterCheckbox.d.ts +8 -0
- package/dist/esm/material-react-table.esm.js +200 -73
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +3 -3
- package/dist/esm/table/MRT_TableRoot.d.ts +254 -2
- package/dist/esm/toolbar/MRT_TablePagination.d.ts +3 -4
- package/dist/esm/toolbar/MRT_ToolbarInternalButtons.d.ts +3 -4
- package/dist/esm/toolbar/MRT_TopToolbar.d.ts +1 -0
- package/dist/index.d.ts +61 -28
- package/locales/en.d.ts +2 -0
- package/locales/en.esm.d.ts +2 -0
- package/locales/en.esm.js +92 -0
- package/locales/en.esm.js.map +1 -0
- package/locales/en.js +96 -0
- package/locales/en.js.map +1 -0
- package/locales/pt-BR.d.ts +2 -0
- package/locales/pt-BR.esm.d.ts +2 -0
- package/locales/pt-BR.esm.js +92 -0
- package/locales/pt-BR.esm.js.map +1 -0
- package/locales/pt-BR.js +96 -0
- package/locales/pt-BR.js.map +1 -0
- package/package.json +13 -11
- package/src/MaterialReactTable.tsx +205 -67
- package/src/_locales/de.ts +1 -0
- package/src/{localization.ts → _locales/en.ts} +8 -84
- package/src/_locales/es.ts +1 -0
- package/src/_locales/fr.ts +1 -0
- package/src/_locales/hi.ts +1 -0
- package/src/_locales/id.ts +1 -0
- package/src/_locales/ja.ts +1 -0
- package/src/_locales/nl.ts +1 -0
- package/src/_locales/pt-BR.ts +92 -0
- package/src/_locales/pt.ts +1 -0
- package/src/_locales/ru.ts +1 -0
- package/src/_locales/uk.ts +1 -0
- package/src/_locales/vi.ts +1 -0
- package/src/_locales/zh.ts +1 -0
- package/src/body/MRT_EditRowModal.tsx +3 -2
- package/src/body/MRT_TableBodyCell.tsx +1 -1
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +1 -1
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -1
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +7 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/column.utils.ts +28 -3
- package/src/footer/MRT_TableFooter.tsx +1 -1
- package/src/head/MRT_TableHead.tsx +10 -2
- package/src/head/MRT_TableHeadCell.tsx +10 -2
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +1 -1
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +7 -3
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +5 -1
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
- package/src/head/MRT_TableHeadCellSortLabel.tsx +11 -3
- package/src/index.tsx +6 -3
- package/src/inputs/MRT_FilterCheckbox.tsx +96 -0
- package/src/inputs/MRT_FilterTextField.tsx +19 -13
- package/src/inputs/MRT_GlobalFilterTextField.tsx +18 -5
- package/src/inputs/MRT_SelectCheckbox.tsx +16 -7
- package/src/menus/MRT_FilterOptionMenu.tsx +19 -2
- package/src/table/MRT_TablePaper.tsx +16 -4
- package/src/table/MRT_TableRoot.tsx +8 -7
- package/src/toolbar/MRT_BottomToolbar.tsx +4 -1
- package/src/toolbar/MRT_TablePagination.tsx +45 -8
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +2 -1
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -4
- package/src/toolbar/MRT_TopToolbar.tsx +2 -1
- package/dist/cjs/localization.d.ts +0 -84
- package/dist/esm/localization.d.ts +0 -84
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo, useRef, useState, useCallback,
|
|
1
|
+
import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, memo, useLayoutEffect } from 'react';
|
|
2
2
|
import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
|
3
3
|
import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
|
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
@@ -151,7 +151,7 @@ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
|
|
151
151
|
notEquals,
|
|
152
152
|
startsWith });
|
|
153
153
|
|
|
154
|
-
const
|
|
154
|
+
const MRT_Localization_EN = {
|
|
155
155
|
actions: 'Actions',
|
|
156
156
|
and: 'and',
|
|
157
157
|
cancel: 'Cancel',
|
|
@@ -192,6 +192,10 @@ const MRT_DefaultLocalization_EN = {
|
|
|
192
192
|
filterStartsWith: 'Starts With',
|
|
193
193
|
filterWeakEquals: 'Equals',
|
|
194
194
|
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
195
|
+
goToFirstPage: 'Go to first page',
|
|
196
|
+
goToLastPage: 'Go to last page',
|
|
197
|
+
goToNextPage: 'Go to next page',
|
|
198
|
+
goToPreviousPage: 'Go to previous page',
|
|
195
199
|
grab: 'Grab',
|
|
196
200
|
groupByColumn: 'Group by {column}',
|
|
197
201
|
groupedBy: 'Grouped by ',
|
|
@@ -202,6 +206,7 @@ const MRT_DefaultLocalization_EN = {
|
|
|
202
206
|
move: 'Move',
|
|
203
207
|
noRecordsToDisplay: 'No records to display',
|
|
204
208
|
noResultsFound: 'No results found',
|
|
209
|
+
of: 'of',
|
|
205
210
|
or: 'or',
|
|
206
211
|
pinToLeft: 'Pin to left',
|
|
207
212
|
pinToRight: 'Pin to right',
|
|
@@ -210,6 +215,7 @@ const MRT_DefaultLocalization_EN = {
|
|
|
210
215
|
rowActions: 'Row Actions',
|
|
211
216
|
rowNumber: '#',
|
|
212
217
|
rowNumbers: 'Row Numbers',
|
|
218
|
+
rowsPerPage: 'Rows per page',
|
|
213
219
|
save: 'Save',
|
|
214
220
|
search: 'Search',
|
|
215
221
|
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
@@ -267,7 +273,7 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
|
267
273
|
: getIsSomeRowsExpanded()
|
|
268
274
|
? -90
|
|
269
275
|
: 0}deg)`,
|
|
270
|
-
transition: 'transform 0.
|
|
276
|
+
transition: 'transform 0.1s',
|
|
271
277
|
} })))));
|
|
272
278
|
};
|
|
273
279
|
|
|
@@ -295,7 +301,7 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
|
295
301
|
: row.getIsExpanded()
|
|
296
302
|
? -180
|
|
297
303
|
: 0}deg)`,
|
|
298
|
-
transition: 'transform 0.
|
|
304
|
+
transition: 'transform 0.1s',
|
|
299
305
|
} })))));
|
|
300
306
|
};
|
|
301
307
|
|
|
@@ -385,7 +391,7 @@ const mrtFilterOptions = (localization) => [
|
|
|
385
391
|
divider: false,
|
|
386
392
|
},
|
|
387
393
|
];
|
|
388
|
-
const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table, }) => {
|
|
394
|
+
const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilterValue, table, }) => {
|
|
389
395
|
var _a, _b, _c, _d;
|
|
390
396
|
const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
|
|
391
397
|
const { globalFilterFn, density } = getState();
|
|
@@ -404,11 +410,19 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table,
|
|
|
404
410
|
if (['empty', 'notEmpty'].includes(option)) {
|
|
405
411
|
column.setFilterValue(' ');
|
|
406
412
|
}
|
|
407
|
-
else if (
|
|
413
|
+
else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
|
|
414
|
+
['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'].includes(option)) {
|
|
415
|
+
column.setFilterValue([]);
|
|
416
|
+
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
|
|
417
|
+
}
|
|
418
|
+
else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'range' ||
|
|
419
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(option)) {
|
|
408
420
|
column.setFilterValue(['', '']);
|
|
421
|
+
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
|
|
409
422
|
}
|
|
410
423
|
else {
|
|
411
424
|
column.setFilterValue('');
|
|
425
|
+
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
|
|
412
426
|
}
|
|
413
427
|
}
|
|
414
428
|
else {
|
|
@@ -475,7 +489,7 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
475
489
|
var _a;
|
|
476
490
|
e.stopPropagation();
|
|
477
491
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
478
|
-
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.
|
|
492
|
+
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.1s ease-in-out', '&:hover': {
|
|
479
493
|
backgroundColor: 'transparent',
|
|
480
494
|
opacity: 1,
|
|
481
495
|
}, '&:active': {
|
|
@@ -583,10 +597,11 @@ const getDefaultColumnOrderIds = (props) => [
|
|
|
583
597
|
const getDefaultColumnFilterFn = (columnDef) => {
|
|
584
598
|
if (columnDef.filterVariant === 'multi-select')
|
|
585
599
|
return 'arrIncludesSome';
|
|
586
|
-
if (columnDef.filterVariant === 'select')
|
|
587
|
-
return 'equals';
|
|
588
600
|
if (columnDef.filterVariant === 'range')
|
|
589
601
|
return 'betweenInclusive';
|
|
602
|
+
if (columnDef.filterVariant === 'select' ||
|
|
603
|
+
columnDef.filterVariant === 'checkbox')
|
|
604
|
+
return 'equals';
|
|
590
605
|
return 'fuzzy';
|
|
591
606
|
};
|
|
592
607
|
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
@@ -602,7 +617,7 @@ const getTotalRight = (table, column) => {
|
|
|
602
617
|
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
603
618
|
var _a, _b, _c, _d;
|
|
604
619
|
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
605
|
-
? alpha(lighten(theme.palette.background.default, 0.04), 0.
|
|
620
|
+
? alpha(lighten(theme.palette.background.default, 0.04), 0.97)
|
|
606
621
|
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
607
622
|
? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
608
623
|
: getIsFirstRightPinnedColumn(column)
|
|
@@ -616,10 +631,29 @@ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, })
|
|
|
616
631
|
? 'sticky'
|
|
617
632
|
: undefined, right: column.getIsPinned() === 'right'
|
|
618
633
|
? `${getTotalRight(table, column)}px`
|
|
619
|
-
: undefined, transition: `all ${column.getIsResizing() ? 0 : '0.
|
|
634
|
+
: undefined, transition: `all ${column.getIsResizing() ? 0 : '0.1s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
620
635
|
? tableCellProps.sx(theme)
|
|
621
636
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
|
|
622
637
|
};
|
|
638
|
+
const MRT_DefaultColumn = {
|
|
639
|
+
minSize: 40,
|
|
640
|
+
maxSize: 1000,
|
|
641
|
+
size: 180,
|
|
642
|
+
};
|
|
643
|
+
const MRT_DefaultDisplayColumn = {
|
|
644
|
+
columnDefType: 'display',
|
|
645
|
+
enableClickToCopy: false,
|
|
646
|
+
enableColumnActions: false,
|
|
647
|
+
enableColumnDragging: false,
|
|
648
|
+
enableColumnFilter: false,
|
|
649
|
+
enableColumnOrdering: false,
|
|
650
|
+
enableEditing: false,
|
|
651
|
+
enableGlobalFilter: false,
|
|
652
|
+
enableGrouping: false,
|
|
653
|
+
enableHiding: false,
|
|
654
|
+
enableResizing: false,
|
|
655
|
+
enableSorting: false,
|
|
656
|
+
};
|
|
623
657
|
|
|
624
658
|
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
625
659
|
var _a;
|
|
@@ -971,7 +1005,7 @@ const commonIconButtonStyles = {
|
|
|
971
1005
|
height: '2rem',
|
|
972
1006
|
ml: '10px',
|
|
973
1007
|
opacity: 0.5,
|
|
974
|
-
transition: 'opacity 0.
|
|
1008
|
+
transition: 'opacity 0.1s',
|
|
975
1009
|
width: '2rem',
|
|
976
1010
|
'&:hover': {
|
|
977
1011
|
opacity: 1,
|
|
@@ -1014,15 +1048,24 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
1014
1048
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
|
1015
1049
|
? localization.toggleSelectAll
|
|
1016
1050
|
: localization.toggleSelectRow) },
|
|
1017
|
-
React.createElement(Checkbox, Object.assign({ checked: selectAll
|
|
1051
|
+
React.createElement(Checkbox, Object.assign({ checked: selectAll
|
|
1052
|
+
? selectAllMode === 'page'
|
|
1053
|
+
? table.getIsAllPageRowsSelected()
|
|
1054
|
+
: table.getIsAllRowsSelected()
|
|
1055
|
+
: row === null || row === void 0 ? void 0 : row.getIsSelected(), indeterminate: selectAll
|
|
1056
|
+
? table.getIsSomeRowsSelected() &&
|
|
1057
|
+
!(selectAllMode === 'page'
|
|
1058
|
+
? table.getIsAllPageRowsSelected()
|
|
1059
|
+
: table.getIsAllRowsSelected())
|
|
1060
|
+
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected(), inputProps: {
|
|
1018
1061
|
'aria-label': selectAll
|
|
1019
1062
|
? localization.toggleSelectAll
|
|
1020
1063
|
: localization.toggleSelectRow,
|
|
1021
|
-
}, onChange:
|
|
1022
|
-
?
|
|
1064
|
+
}, onChange: row
|
|
1065
|
+
? row.getToggleSelectedHandler()
|
|
1066
|
+
: selectAllMode === 'all'
|
|
1023
1067
|
? table.getToggleAllRowsSelectedHandler()
|
|
1024
|
-
: table.getToggleAllPageRowsSelectedHandler()
|
|
1025
|
-
: row.getToggleSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
1068
|
+
: table.getToggleAllPageRowsSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
1026
1069
|
var _a;
|
|
1027
1070
|
e.stopPropagation();
|
|
1028
1071
|
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
@@ -1035,6 +1078,9 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1035
1078
|
var _a;
|
|
1036
1079
|
const { getState, setGlobalFilter, options: { enableGlobalFilterModes, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
1037
1080
|
const { globalFilter, showGlobalFilter } = getState();
|
|
1081
|
+
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1082
|
+
? muiSearchTextFieldProps({ table })
|
|
1083
|
+
: muiSearchTextFieldProps;
|
|
1038
1084
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
1039
1085
|
const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
|
1040
1086
|
const handleChangeDebounced = useCallback(debounce((event) => {
|
|
@@ -1052,9 +1098,11 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1052
1098
|
setSearchValue('');
|
|
1053
1099
|
setGlobalFilter(undefined);
|
|
1054
1100
|
};
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1101
|
+
useEffect(() => {
|
|
1102
|
+
if (globalFilter === undefined) {
|
|
1103
|
+
handleClear();
|
|
1104
|
+
}
|
|
1105
|
+
}, [globalFilter]);
|
|
1058
1106
|
return (React.createElement(Collapse, { in: showGlobalFilter, orientation: "horizontal", unmountOnExit: true, mountOnEnter: true },
|
|
1059
1107
|
React.createElement(TextField, Object.assign({ placeholder: localization.search, onChange: handleChange, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard", InputProps: {
|
|
1060
1108
|
startAdornment: enableGlobalFilterModes ? (React.createElement(InputAdornment, { position: "start" },
|
|
@@ -1072,7 +1120,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1072
1120
|
textFieldProps.inputRef = inputRef;
|
|
1073
1121
|
}
|
|
1074
1122
|
} })),
|
|
1075
|
-
React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1123
|
+
React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table, onSelect: handleClear })));
|
|
1076
1124
|
};
|
|
1077
1125
|
|
|
1078
1126
|
const MRT_LinearProgressBar = ({ isTopToolbar, table }) => {
|
|
@@ -1090,8 +1138,8 @@ const MRT_LinearProgressBar = ({ isTopToolbar, table }) => {
|
|
|
1090
1138
|
React.createElement(LinearProgress, Object.assign({ "aria-label": "Loading", "aria-busy": "true", sx: { position: 'relative' } }, linearProgressProps))));
|
|
1091
1139
|
};
|
|
1092
1140
|
|
|
1093
|
-
const MRT_TablePagination = ({ table, position }) => {
|
|
1094
|
-
const { getPrePaginationRowModel, getState, setPageIndex, setPageSize, options: { muiTablePaginationProps, enableToolbarInternalActions, rowCount, }, } = table;
|
|
1141
|
+
const MRT_TablePagination = ({ table, position, }) => {
|
|
1142
|
+
const { getPrePaginationRowModel, getState, setPageIndex, setPageSize, options: { muiTablePaginationProps, enableToolbarInternalActions, localization, rowCount, }, } = table;
|
|
1095
1143
|
const { pagination: { pageSize = 10, pageIndex = 0 }, showGlobalFilter, } = getState();
|
|
1096
1144
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
|
1097
1145
|
const showFirstLastPageButtons = totalRowCount / pageSize > 2;
|
|
@@ -1101,10 +1149,26 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1101
1149
|
const handleChangeRowsPerPage = (event) => {
|
|
1102
1150
|
setPageSize(+event.target.value);
|
|
1103
1151
|
};
|
|
1104
|
-
return (React.createElement(TablePagination, Object.assign({
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1152
|
+
return (React.createElement(TablePagination, Object.assign({ component: "div", count: totalRowCount, getItemAriaLabel: (type) => type === 'first'
|
|
1153
|
+
? localization.goToFirstPage
|
|
1154
|
+
: type === 'last'
|
|
1155
|
+
? localization.goToLastPage
|
|
1156
|
+
: type === 'next'
|
|
1157
|
+
? localization.goToNextPage
|
|
1158
|
+
: localization.goToPreviousPage, labelDisplayedRows: ({ from, to, count }) => `${from}-${to} ${localization.of} ${count}`, labelRowsPerPage: localization.rowsPerPage, onPageChange: (_, newPage) => setPageIndex(newPage), onRowsPerPageChange: handleChangeRowsPerPage, page: pageIndex, rowsPerPage: pageSize, rowsPerPageOptions: [5, 10, 15, 20, 25, 30, 50, 100], showFirstButton: showFirstLastPageButtons, showLastButton: showFirstLastPageButtons }, tablePaginationProps, { SelectProps: Object.assign({ sx: { m: '0 1rem 0 1ch' }, MenuProps: { MenuListProps: { disablePadding: true }, sx: { m: 0 } } }, tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.SelectProps), sx: (theme) => (Object.assign({ '& .MuiTablePagination-toolbar': {
|
|
1159
|
+
display: 'flex',
|
|
1160
|
+
alignItems: 'center',
|
|
1161
|
+
}, '& .MuiTablePagination-selectLabel': {
|
|
1162
|
+
m: '0 -1px',
|
|
1163
|
+
}, '&. MuiInputBase-root': {
|
|
1164
|
+
m: '0 1px',
|
|
1165
|
+
}, '& . MuiTablePagination-select': {
|
|
1166
|
+
m: '0 1px',
|
|
1167
|
+
}, '& .MuiTablePagination-displayedRows': {
|
|
1168
|
+
m: '0 1px',
|
|
1169
|
+
}, '& .MuiTablePagination-actions': {
|
|
1170
|
+
m: '0 1px',
|
|
1171
|
+
}, mt: position === 'top' &&
|
|
1108
1172
|
enableToolbarInternalActions &&
|
|
1109
1173
|
!showGlobalFilter
|
|
1110
1174
|
? '3.5rem'
|
|
@@ -1115,7 +1179,7 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1115
1179
|
|
|
1116
1180
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
1117
1181
|
var _a, _b;
|
|
1118
|
-
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, }, } = table;
|
|
1182
|
+
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, rowCount, }, } = table;
|
|
1119
1183
|
const { grouping, showAlertBanner } = getState();
|
|
1120
1184
|
const alertProps = muiToolbarAlertBannerProps instanceof Function
|
|
1121
1185
|
? muiToolbarAlertBannerProps({ table })
|
|
@@ -1124,7 +1188,7 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
|
1124
1188
|
? muiToolbarAlertBannerChipProps({ table })
|
|
1125
1189
|
: muiToolbarAlertBannerChipProps;
|
|
1126
1190
|
const selectMessage = getSelectedRowModel().rows.length > 0
|
|
1127
|
-
? (_b = (_a = localization.selectedCountOfRowCountRowsSelected) === null || _a === void 0 ? void 0 : _a.replace('{selectedCount}', getSelectedRowModel().rows.length.toString())) === null || _b === void 0 ? void 0 : _b.replace('{rowCount}', getPrePaginationRowModel().rows.length.toString())
|
|
1191
|
+
? (_b = (_a = localization.selectedCountOfRowCountRowsSelected) === null || _a === void 0 ? void 0 : _a.replace('{selectedCount}', getSelectedRowModel().rows.length.toString())) === null || _b === void 0 ? void 0 : _b.replace('{rowCount}', (rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length).toString())
|
|
1128
1192
|
: null;
|
|
1129
1193
|
const groupedByMessage = grouping.length > 0 ? (React.createElement("span", null,
|
|
1130
1194
|
localization.groupedBy,
|
|
@@ -1209,16 +1273,16 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
|
1209
1273
|
var _b;
|
|
1210
1274
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1211
1275
|
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1212
|
-
const { showGlobalFilter } = getState();
|
|
1276
|
+
const { globalFilter, showGlobalFilter } = getState();
|
|
1213
1277
|
const handleToggleSearch = () => {
|
|
1214
1278
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1215
1279
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1216
1280
|
};
|
|
1217
1281
|
return (React.createElement(Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch },
|
|
1218
|
-
React.createElement(IconButton, Object.assign({ onClick: handleToggleSearch }, rest, { title: undefined }), showGlobalFilter ? React.createElement(SearchOffIcon, null) : React.createElement(SearchIcon, null))));
|
|
1282
|
+
React.createElement(IconButton, Object.assign({ disabled: !!globalFilter, onClick: handleToggleSearch }, rest, { title: undefined }), showGlobalFilter ? React.createElement(SearchOffIcon, null) : React.createElement(SearchIcon, null))));
|
|
1219
1283
|
};
|
|
1220
1284
|
|
|
1221
|
-
const MRT_ToolbarInternalButtons = ({ table }) => {
|
|
1285
|
+
const MRT_ToolbarInternalButtons = ({ table, }) => {
|
|
1222
1286
|
var _a;
|
|
1223
1287
|
const { options: { enableColumnFilters, enableColumnOrdering, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, enablePinning, initialState, renderToolbarInternalActions, }, } = table;
|
|
1224
1288
|
return (React.createElement(Box, { sx: {
|
|
@@ -1266,10 +1330,11 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1266
1330
|
backgroundColor: lighten(theme.palette.background.default, 0.04),
|
|
1267
1331
|
backgroundImage: 'none',
|
|
1268
1332
|
display: 'grid',
|
|
1333
|
+
flexWrap: 'wrap-reverse',
|
|
1269
1334
|
minHeight: '3.5rem',
|
|
1270
1335
|
overflow: 'hidden',
|
|
1271
1336
|
p: '0 !important',
|
|
1272
|
-
transition: 'all 0.
|
|
1337
|
+
transition: 'all 0.1s ease-in-out',
|
|
1273
1338
|
zIndex: 1,
|
|
1274
1339
|
});
|
|
1275
1340
|
const MRT_TopToolbar = ({ table }) => {
|
|
@@ -1331,7 +1396,7 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1331
1396
|
// @ts-ignore
|
|
1332
1397
|
toolbarProps.ref.current = ref;
|
|
1333
1398
|
}
|
|
1334
|
-
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow:
|
|
1399
|
+
}, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, commonToolbarStyles({ theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${alpha(theme.palette.common.black, 0.1)} inset`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), ((toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx) instanceof Function
|
|
1335
1400
|
? toolbarProps.sx(theme)
|
|
1336
1401
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1337
1402
|
React.createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
@@ -1379,7 +1444,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1379
1444
|
const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
|
|
1380
1445
|
return (React.createElement(React.Fragment, null,
|
|
1381
1446
|
React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.columnActions },
|
|
1382
|
-
React.createElement(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', mt: '-0.2rem', opacity: 0.5, transition: 'opacity 0.
|
|
1447
|
+
React.createElement(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', mt: '-0.2rem', opacity: 0.5, transition: 'opacity 0.1s', width: '2rem', '&:hover': {
|
|
1383
1448
|
opacity: 1,
|
|
1384
1449
|
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
1385
1450
|
? iconButtonProps.sx(theme)
|
|
@@ -1443,8 +1508,10 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1443
1508
|
});
|
|
1444
1509
|
const handleChangeDebounced = useCallback(debounce((event) => {
|
|
1445
1510
|
let value = textFieldProps.type === 'date'
|
|
1446
|
-
?
|
|
1447
|
-
:
|
|
1511
|
+
? event.target.valueAsDate
|
|
1512
|
+
: textFieldProps.type === 'number'
|
|
1513
|
+
? event.target.valueAsNumber
|
|
1514
|
+
: event.target.value;
|
|
1448
1515
|
if (isRangeFilter) {
|
|
1449
1516
|
column.setFilterValue((old) => {
|
|
1450
1517
|
const newFilterValues = old !== null && old !== void 0 ? old : ['', ''];
|
|
@@ -1487,10 +1554,12 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1487
1554
|
setAnchorEl(event.currentTarget);
|
|
1488
1555
|
};
|
|
1489
1556
|
useEffect(() => {
|
|
1490
|
-
|
|
1491
|
-
|
|
1557
|
+
if (column.getFilterValue() === undefined) {
|
|
1558
|
+
handleClear();
|
|
1559
|
+
}
|
|
1560
|
+
}, [column.getFilterValue()]);
|
|
1492
1561
|
if (columnDef.Filter) {
|
|
1493
|
-
return React.createElement(React.Fragment, null, (_e = columnDef.Filter) === null || _e === void 0 ? void 0 : _e.call(columnDef, { column, header, table }));
|
|
1562
|
+
return (React.createElement(React.Fragment, null, (_e = columnDef.Filter) === null || _e === void 0 ? void 0 : _e.call(columnDef, { column, header, rangeFilterIndex, table })));
|
|
1494
1563
|
}
|
|
1495
1564
|
return (React.createElement(React.Fragment, null,
|
|
1496
1565
|
React.createElement(TextField, Object.assign({ fullWidth: true, inputProps: {
|
|
@@ -1505,7 +1574,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1505
1574
|
localization[`filter${((_f = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _f === void 0 ? void 0 : _f.toUpperCase()) +
|
|
1506
1575
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]))) : null, FormHelperTextProps: {
|
|
1507
1576
|
sx: {
|
|
1508
|
-
fontSize: '0.
|
|
1577
|
+
fontSize: '0.75rem',
|
|
1509
1578
|
lineHeight: '0.8rem',
|
|
1510
1579
|
whiteSpace: 'nowrap',
|
|
1511
1580
|
},
|
|
@@ -1546,11 +1615,11 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1546
1615
|
if (textFieldProps.inputRef) {
|
|
1547
1616
|
textFieldProps.inputRef = inputRef;
|
|
1548
1617
|
}
|
|
1549
|
-
}, sx: (theme) => (Object.assign({ p: 0, minWidth:
|
|
1550
|
-
? '
|
|
1618
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: isRangeFilter
|
|
1619
|
+
? '100px'
|
|
1551
1620
|
: !filterChipLabel
|
|
1552
1621
|
? '120px'
|
|
1553
|
-
: 'auto', width: '100%', '&
|
|
1622
|
+
: 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1554
1623
|
mr: '1.5rem',
|
|
1555
1624
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1556
1625
|
? textFieldProps.sx(theme)
|
|
@@ -1578,7 +1647,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1578
1647
|
isMultiSelectFilter && (React.createElement(Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })),
|
|
1579
1648
|
text));
|
|
1580
1649
|
})),
|
|
1581
|
-
React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
|
|
1650
|
+
React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table, setFilterValue: setFilterValue })));
|
|
1582
1651
|
};
|
|
1583
1652
|
|
|
1584
1653
|
const MRT_FilterRangeFields = ({ header, table }) => {
|
|
@@ -1587,12 +1656,50 @@ const MRT_FilterRangeFields = ({ header, table }) => {
|
|
|
1587
1656
|
React.createElement(MRT_FilterTextField, { header: header, rangeFilterIndex: 1, table: table })));
|
|
1588
1657
|
};
|
|
1589
1658
|
|
|
1659
|
+
const MRT_FilterCheckbox = ({ column, table }) => {
|
|
1660
|
+
var _a, _b, _c;
|
|
1661
|
+
const { getState, options: { localization, muiTableHeadCellFilterCheckboxProps }, } = table;
|
|
1662
|
+
const { density } = getState();
|
|
1663
|
+
const { columnDef } = column;
|
|
1664
|
+
const mTableHeadCellFilterCheckboxProps = muiTableHeadCellFilterCheckboxProps instanceof Function
|
|
1665
|
+
? muiTableHeadCellFilterCheckboxProps({
|
|
1666
|
+
column,
|
|
1667
|
+
table,
|
|
1668
|
+
})
|
|
1669
|
+
: muiTableHeadCellFilterCheckboxProps;
|
|
1670
|
+
const mcTableHeadCellFilterCheckboxProps = columnDef.muiTableHeadCellFilterCheckboxProps instanceof Function
|
|
1671
|
+
? columnDef.muiTableHeadCellFilterCheckboxProps({
|
|
1672
|
+
column,
|
|
1673
|
+
table,
|
|
1674
|
+
})
|
|
1675
|
+
: columnDef.muiTableHeadCellFilterCheckboxProps;
|
|
1676
|
+
const checkboxProps = Object.assign(Object.assign({}, mTableHeadCellFilterCheckboxProps), mcTableHeadCellFilterCheckboxProps);
|
|
1677
|
+
const filterLabel = (_a = localization.filterByColumn) === null || _a === void 0 ? void 0 : _a.replace('{column}', columnDef.header);
|
|
1678
|
+
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : filterLabel },
|
|
1679
|
+
React.createElement(FormControlLabel, { control: React.createElement(Checkbox, Object.assign({ checked: column.getFilterValue() === 'true', indeterminate: column.getFilterValue() === undefined, color: column.getFilterValue() === undefined ? 'default' : 'primary', size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
1680
|
+
var _a;
|
|
1681
|
+
e.stopPropagation();
|
|
1682
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1683
|
+
}, onChange: (e, checked) => {
|
|
1684
|
+
var _a;
|
|
1685
|
+
column.setFilterValue(column.getFilterValue() === undefined
|
|
1686
|
+
? 'true'
|
|
1687
|
+
: column.getFilterValue() === 'true'
|
|
1688
|
+
? 'false'
|
|
1689
|
+
: undefined);
|
|
1690
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
|
|
1691
|
+
}, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
|
|
1692
|
+
? checkboxProps.sx(theme)
|
|
1693
|
+
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) })), disableTypography: true, label: (_c = checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, sx: { color: 'text.secondary', mt: '-4px', fontWeight: 'normal' }, title: undefined })));
|
|
1694
|
+
};
|
|
1695
|
+
|
|
1590
1696
|
const MRT_TableHeadCellFilterContainer = ({ header, table, }) => {
|
|
1591
1697
|
const { getState } = table;
|
|
1592
1698
|
const { showColumnFilters } = getState();
|
|
1593
1699
|
const { column } = header;
|
|
1594
1700
|
const { columnDef } = column;
|
|
1595
|
-
return (React.createElement(Collapse, { in: showColumnFilters, mountOnEnter: true, unmountOnExit: true },
|
|
1701
|
+
return (React.createElement(Collapse, { in: showColumnFilters, mountOnEnter: true, unmountOnExit: true }, columnDef.filterVariant === 'checkbox' ? (React.createElement(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range' ||
|
|
1702
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn) ? (React.createElement(MRT_FilterRangeFields, { header: header, table: table })) : (React.createElement(MRT_FilterTextField, { header: header, table: table }))));
|
|
1596
1703
|
};
|
|
1597
1704
|
|
|
1598
1705
|
const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
@@ -1681,7 +1788,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
|
1681
1788
|
position: 'absolute',
|
|
1682
1789
|
right: '1px',
|
|
1683
1790
|
touchAction: 'none',
|
|
1684
|
-
transition: column.getIsResizing() ? undefined : 'all 0.
|
|
1791
|
+
transition: column.getIsResizing() ? undefined : 'all 0.1s ease-in-out',
|
|
1685
1792
|
userSelect: 'none',
|
|
1686
1793
|
zIndex: 4,
|
|
1687
1794
|
'&:active': {
|
|
@@ -1696,7 +1803,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
|
1696
1803
|
} }));
|
|
1697
1804
|
};
|
|
1698
1805
|
|
|
1699
|
-
const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
1806
|
+
const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
|
|
1700
1807
|
const { options: { localization }, } = table;
|
|
1701
1808
|
const { column } = header;
|
|
1702
1809
|
const { columnDef } = column;
|
|
@@ -1710,7 +1817,9 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
|
1710
1817
|
? column.getIsSorted()
|
|
1711
1818
|
: undefined, sx: {
|
|
1712
1819
|
width: '2ch',
|
|
1713
|
-
transform:
|
|
1820
|
+
transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
|
|
1821
|
+
? 'translateX(-0.5ch)'
|
|
1822
|
+
: undefined,
|
|
1714
1823
|
} })));
|
|
1715
1824
|
};
|
|
1716
1825
|
|
|
@@ -1787,8 +1896,9 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1787
1896
|
header.isPlaceholder ? null : (React.createElement(Box, { sx: {
|
|
1788
1897
|
alignItems: 'flex-start',
|
|
1789
1898
|
display: 'flex',
|
|
1899
|
+
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
|
1790
1900
|
justifyContent: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right'
|
|
1791
|
-
? 'flex-
|
|
1901
|
+
? 'flex-start'
|
|
1792
1902
|
: columnDefType === 'group' ||
|
|
1793
1903
|
(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
|
1794
1904
|
? 'center'
|
|
@@ -1802,6 +1912,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1802
1912
|
? 'pointer'
|
|
1803
1913
|
: undefined,
|
|
1804
1914
|
display: 'flex',
|
|
1915
|
+
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
|
1805
1916
|
flexWrap: 'nowrap',
|
|
1806
1917
|
m: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center' ? 'auto' : undefined,
|
|
1807
1918
|
pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center' && column.getCanSort()
|
|
@@ -1810,7 +1921,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1810
1921
|
whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 24 ? 'nowrap' : 'normal',
|
|
1811
1922
|
} },
|
|
1812
1923
|
headerElement,
|
|
1813
|
-
column.getCanSort() && (React.createElement(MRT_TableHeadCellSortLabel, { header: header, table: table })),
|
|
1924
|
+
column.getCanSort() && (React.createElement(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })),
|
|
1814
1925
|
column.getCanFilter() && (React.createElement(MRT_TableHeadCellFilterLabel, { header: header, table: table }))),
|
|
1815
1926
|
columnDefType !== 'group' && (React.createElement(Box, { sx: { whiteSpace: 'nowrap' } },
|
|
1816
1927
|
enableColumnDragging !== false &&
|
|
@@ -1838,11 +1949,13 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
|
|
|
1838
1949
|
};
|
|
1839
1950
|
|
|
1840
1951
|
const MRT_TableHead = ({ table }) => {
|
|
1841
|
-
const { getHeaderGroups, options: { muiTableHeadProps }, } = table;
|
|
1952
|
+
const { getHeaderGroups, options: { enableStickyHeader, muiTableHeadProps }, } = table;
|
|
1842
1953
|
const tableHeadProps = muiTableHeadProps instanceof Function
|
|
1843
1954
|
? muiTableHeadProps({ table })
|
|
1844
1955
|
: muiTableHeadProps;
|
|
1845
|
-
return (React.createElement(TableHead, Object.assign({}, tableHeadProps
|
|
1956
|
+
return (React.createElement(TableHead, Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ opacity: enableStickyHeader ? 0.97 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
|
|
1957
|
+
? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
|
|
1958
|
+
: tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))) }), getHeaderGroups().map((headerGroup) => (React.createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
|
|
1846
1959
|
};
|
|
1847
1960
|
|
|
1848
1961
|
const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
@@ -1994,7 +2107,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1994
2107
|
? muiTableBodyCellProps({ cell, column, row, table })
|
|
1995
2108
|
: muiTableBodyCellProps;
|
|
1996
2109
|
const mcTableCellBodyProps = columnDef.muiTableBodyCellProps instanceof Function
|
|
1997
|
-
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
2110
|
+
? columnDef.muiTableBodyCellProps({ cell, column, row, table })
|
|
1998
2111
|
: columnDef.muiTableBodyCellProps;
|
|
1999
2112
|
const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
|
|
2000
2113
|
const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
|
|
@@ -2108,7 +2221,7 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2108
2221
|
? muiTableDetailPanelProps({ row, table })
|
|
2109
2222
|
: muiTableDetailPanelProps;
|
|
2110
2223
|
return (React.createElement(TableRow, Object.assign({}, tableRowProps),
|
|
2111
|
-
React.createElement(TableCell, Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 0.
|
|
2224
|
+
React.createElement(TableCell, Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 0.1s ease-in-out', width: `${table.getTotalSize()}px` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
2112
2225
|
? tableCellProps.sx(theme)
|
|
2113
2226
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React.createElement(Collapse, { in: row.getIsExpanded() }, renderDetailPanel({ row, table }))))));
|
|
2114
2227
|
};
|
|
@@ -2143,7 +2256,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2143
2256
|
if (virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.measureRef) {
|
|
2144
2257
|
virtualRow.measureRef = node;
|
|
2145
2258
|
}
|
|
2146
|
-
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all 0.
|
|
2259
|
+
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all 0.1s ease-in-out', '&:hover td': {
|
|
2147
2260
|
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
|
|
2148
2261
|
? theme.palette.mode === 'dark'
|
|
2149
2262
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
|
@@ -2298,7 +2411,7 @@ const MRT_TableFooter = ({ table }) => {
|
|
|
2298
2411
|
? muiTableFooterProps({ table })
|
|
2299
2412
|
: muiTableFooterProps;
|
|
2300
2413
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
|
2301
|
-
return (React.createElement(TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), bottom: stickFooter ? 0 : undefined, opacity: stickFooter ? 0.
|
|
2414
|
+
return (React.createElement(TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), bottom: stickFooter ? 0 : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
|
|
2302
2415
|
? theme.palette.mode === 'light'
|
|
2303
2416
|
? `1px solid ${theme.palette.grey[300]}`
|
|
2304
2417
|
: `1px solid ${theme.palette.grey[700]}`
|
|
@@ -2356,7 +2469,7 @@ const MRT_TableContainer = ({ table }) => {
|
|
|
2356
2469
|
};
|
|
2357
2470
|
|
|
2358
2471
|
const MRT_TablePaper = ({ table }) => {
|
|
2359
|
-
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps }, refs: { tablePaperRef }, } = table;
|
|
2472
|
+
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
|
|
2360
2473
|
const { isFullScreen } = getState();
|
|
2361
2474
|
const tablePaperProps = muiTablePaperProps instanceof Function
|
|
2362
2475
|
? muiTablePaperProps({ table })
|
|
@@ -2367,7 +2480,7 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2367
2480
|
//@ts-ignore
|
|
2368
2481
|
tablePaperProps.ref.current = ref;
|
|
2369
2482
|
}
|
|
2370
|
-
}, sx: (theme) => (Object.assign({ transition: 'all 0.
|
|
2483
|
+
}, sx: (theme) => (Object.assign({ transition: 'all 0.1s ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
|
|
2371
2484
|
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2372
2485
|
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
|
2373
2486
|
? {
|
|
@@ -2379,9 +2492,15 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2379
2492
|
width: '100vw',
|
|
2380
2493
|
}
|
|
2381
2494
|
: {})) }),
|
|
2382
|
-
enableTopToolbar &&
|
|
2495
|
+
enableTopToolbar &&
|
|
2496
|
+
(renderTopToolbar instanceof Function
|
|
2497
|
+
? renderTopToolbar({ table })
|
|
2498
|
+
: renderTopToolbar !== null && renderTopToolbar !== void 0 ? renderTopToolbar : React.createElement(MRT_TopToolbar, { table: table })),
|
|
2383
2499
|
React.createElement(MRT_TableContainer, { table: table }),
|
|
2384
|
-
enableBottomToolbar &&
|
|
2500
|
+
enableBottomToolbar &&
|
|
2501
|
+
(renderBottomToolbar instanceof Function
|
|
2502
|
+
? renderBottomToolbar({ table })
|
|
2503
|
+
: renderBottomToolbar !== null && renderBottomToolbar !== void 0 ? renderBottomToolbar : React.createElement(MRT_BottomToolbar, { table: table }))));
|
|
2385
2504
|
};
|
|
2386
2505
|
|
|
2387
2506
|
const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
@@ -2391,9 +2510,10 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
|
2391
2510
|
React.createElement(DialogContent, null,
|
|
2392
2511
|
React.createElement("form", { onSubmit: (e) => e.preventDefault() },
|
|
2393
2512
|
React.createElement(Stack, { sx: {
|
|
2394
|
-
width: '100%',
|
|
2395
|
-
minWidth: { xs: '300px', sm: '360px', md: '400px' },
|
|
2396
2513
|
gap: '1.5rem',
|
|
2514
|
+
minWidth: { xs: '300px', sm: '360px', md: '400px' },
|
|
2515
|
+
pt: '1rem',
|
|
2516
|
+
width: '100%',
|
|
2397
2517
|
} }, row
|
|
2398
2518
|
.getAllCells()
|
|
2399
2519
|
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
|
@@ -2445,14 +2565,14 @@ const MRT_TableRoot = (props) => {
|
|
|
2445
2565
|
const [showColumnFilters, setShowFilters] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
|
2446
2566
|
const [showGlobalFilter, setShowGlobalFilter] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
|
2447
2567
|
const displayColumns = useMemo(() => {
|
|
2448
|
-
var _a, _b, _c, _d, _e
|
|
2568
|
+
var _a, _b, _c, _d, _e;
|
|
2449
2569
|
return [
|
|
2450
|
-
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header:
|
|
2451
|
-
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React.createElement(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header:
|
|
2570
|
+
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header: props.localization.move, size: 60 }, props.defaultDisplayColumn), (_a = props.displayColumnDefOptions) === null || _a === void 0 ? void 0 : _a['mrt-row-drag']), { id: 'mrt-row-drag' }),
|
|
2571
|
+
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React.createElement(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: props.localization.actions, size: 70 }, props.defaultDisplayColumn), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
|
2452
2572
|
columnOrder.includes('mrt-row-expand') &&
|
|
2453
|
-
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header:
|
|
2454
|
-
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header:
|
|
2455
|
-
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () =>
|
|
2573
|
+
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header: props.localization.expand, size: 60 }, props.defaultDisplayColumn), (_c = props.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
|
2574
|
+
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: props.localization.select, size: 60 }, props.defaultDisplayColumn), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2575
|
+
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => props.localization.rowNumber, header: props.localization.rowNumbers, size: 60 }, props.defaultDisplayColumn), (_e = props.displayColumnDefOptions) === null || _e === void 0 ? void 0 : _e['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
|
2456
2576
|
].filter(Boolean);
|
|
2457
2577
|
}, [
|
|
2458
2578
|
columnOrder,
|
|
@@ -2559,10 +2679,17 @@ const MRT_TableRoot = (props) => {
|
|
|
2559
2679
|
editingRow && props.editingMode === 'modal' && (React.createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2560
2680
|
};
|
|
2561
2681
|
|
|
2562
|
-
|
|
2563
|
-
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn
|
|
2564
|
-
|
|
2682
|
+
const MaterialReactTable = (_a) => {
|
|
2683
|
+
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn, defaultDisplayColumn, editingMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enablePinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, localization, positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'original', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnResizeMode", "defaultColumn", "defaultDisplayColumn", "editingMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "localization", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "selectAllMode", "sortingFns"]);
|
|
2684
|
+
const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), []);
|
|
2685
|
+
const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), []);
|
|
2686
|
+
const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
|
|
2687
|
+
const _filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
|
|
2688
|
+
const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
|
|
2689
|
+
const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), []);
|
|
2690
|
+
const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), []);
|
|
2691
|
+
return (React.createElement(MRT_TableRoot, Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: _filterFns, icons: _icons, localization: _localization, positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: _sortingFns }, rest)));
|
|
2565
2692
|
};
|
|
2566
2693
|
|
|
2567
|
-
export { MRT_CopyButton, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTable as default };
|
|
2694
|
+
export { MRT_CopyButton, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_TablePagination, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MRT_ToolbarInternalButtons, MaterialReactTable as default };
|
|
2568
2695
|
//# sourceMappingURL=material-react-table.esm.js.map
|