material-react-table 2.0.0-alpha.1 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/index.js +2400 -2365
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/cjs/types/column.utils.d.ts +6 -6
- package/dist/cjs/types/filterFns.d.ts +14 -14
- package/dist/cjs/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/cjs/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/cjs/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/cjs/types/icons.d.ts +1 -1
- package/dist/cjs/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/cjs/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/cjs/types/types.d.ts +198 -198
- package/dist/esm/material-react-table.esm.js +2027 -1993
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/esm/types/column.utils.d.ts +6 -6
- package/dist/esm/types/filterFns.d.ts +14 -14
- package/dist/esm/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/esm/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/esm/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/esm/types/icons.d.ts +1 -1
- package/dist/esm/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/esm/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/esm/types/types.d.ts +198 -198
- package/dist/index.d.ts +239 -239
- package/locales/fr.esm.js +1 -1
- package/locales/fr.esm.js.map +1 -1
- package/locales/fr.js +1 -1
- package/locales/fr.js.map +1 -1
- package/locales/tr.d.ts +2 -0
- package/locales/tr.esm.d.ts +2 -0
- package/locales/tr.esm.js +93 -0
- package/locales/tr.esm.js.map +1 -0
- package/locales/tr.js +97 -0
- package/locales/tr.js.map +1 -0
- package/locales/uk.d.ts +2 -0
- package/locales/uk.esm.d.ts +2 -0
- package/locales/uk.esm.js +93 -0
- package/locales/uk.esm.js.map +1 -0
- package/locales/uk.js +97 -0
- package/locales/uk.js.map +1 -0
- package/locales/vi.d.ts +2 -0
- package/locales/vi.esm.d.ts +2 -0
- package/locales/vi.esm.js +93 -0
- package/locales/vi.esm.js.map +1 -0
- package/locales/vi.js +97 -0
- package/locales/vi.js.map +1 -0
- package/locales/zh-Hans.d.ts +2 -0
- package/locales/zh-Hans.esm.d.ts +2 -0
- package/locales/zh-Hans.esm.js +93 -0
- package/locales/zh-Hans.esm.js.map +1 -0
- package/locales/zh-Hans.js +97 -0
- package/locales/zh-Hans.js.map +1 -0
- package/locales/zh-Hant.d.ts +2 -0
- package/locales/zh-Hant.esm.d.ts +2 -0
- package/locales/zh-Hant.esm.js +93 -0
- package/locales/zh-Hant.esm.js.map +1 -0
- package/locales/zh-Hant.js +97 -0
- package/locales/zh-Hant.js.map +1 -0
- package/package.json +2 -1
- package/src/MaterialReactTable.tsx +2 -2
- package/src/body/MRT_TableBody.tsx +9 -9
- package/src/body/MRT_TableBodyCell.tsx +22 -22
- package/src/body/MRT_TableBodyCellValue.tsx +5 -5
- package/src/body/MRT_TableBodyRow.tsx +32 -32
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +2 -2
- package/src/body/MRT_TableBodyRowPinButton.tsx +3 -3
- package/src/body/MRT_TableDetailPanel.tsx +3 -3
- package/src/buttons/MRT_CopyButton.tsx +1 -1
- package/src/buttons/MRT_EditActionButtons.tsx +4 -4
- package/src/buttons/MRT_ExpandAllButton.tsx +3 -3
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +10 -10
- package/src/buttons/MRT_RowPinButton.tsx +5 -5
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -1
- package/src/buttons/MRT_ToggleFullScreenButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +8 -8
- package/src/column.utils.ts +23 -17
- package/src/filterFns.ts +29 -29
- package/src/footer/MRT_TableFooter.tsx +9 -9
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +2 -2
- package/src/head/MRT_TableHead.tsx +9 -9
- package/src/head/MRT_TableHeadCell.tsx +10 -6
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +9 -6
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +11 -4
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +106 -61
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +2 -2
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +11 -11
- package/src/head/MRT_TableHeadCellSortLabel.tsx +8 -8
- package/src/head/MRT_TableHeadRow.tsx +2 -2
- package/src/hooks/useMRT_DisplayColumns.tsx +5 -5
- package/src/hooks/useMRT_Effects.ts +3 -3
- package/src/hooks/useMRT_TableInstance.ts +15 -14
- package/src/hooks/useMRT_TableOptions.ts +3 -3
- package/src/icons.ts +2 -2
- package/src/inputs/MRT_EditCellTextField.tsx +9 -9
- package/src/inputs/MRT_FilterCheckbox.tsx +7 -7
- package/src/inputs/MRT_FilterRangeFields.tsx +1 -1
- package/src/inputs/MRT_FilterRangeSlider.tsx +6 -6
- package/src/inputs/MRT_FilterTextField.tsx +75 -75
- package/src/inputs/MRT_GlobalFilterTextField.tsx +26 -26
- package/src/inputs/MRT_SelectCheckbox.tsx +7 -7
- package/src/locales/fr.ts +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +14 -14
- package/src/menus/MRT_FilterOptionMenu.tsx +35 -35
- package/src/menus/MRT_RowActionMenu.tsx +7 -7
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +6 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +5 -5
- package/src/modals/MRT_EditRowModal.tsx +8 -8
- package/src/sortingFns.ts +1 -1
- package/src/table/MRT_Table.tsx +7 -7
- package/src/table/MRT_TableContainer.tsx +10 -10
- package/src/table/MRT_TablePaper.tsx +9 -9
- package/src/toolbar/MRT_BottomToolbar.tsx +5 -5
- package/src/toolbar/MRT_LinearProgressBar.tsx +4 -4
- package/src/toolbar/MRT_TablePagination.tsx +19 -19
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +4 -4
- package/src/toolbar/MRT_ToolbarDropZone.tsx +6 -6
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -5
- package/src/toolbar/MRT_TopToolbar.tsx +7 -7
- package/src/types.ts +263 -263
- package/src/useMaterialReactTable.ts +1 -1
@@ -1,8 +1,56 @@
|
|
1
|
-
import { jsx,
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import
|
5
|
-
import {
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
2
|
+
import Paper from '@mui/material/Paper';
|
3
|
+
import { useState, memo, useEffect, useMemo, useRef, useCallback, useLayoutEffect, Fragment as Fragment$1 } from 'react';
|
4
|
+
import TableContainer from '@mui/material/TableContainer';
|
5
|
+
import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
|
6
|
+
import Table from '@mui/material/Table';
|
7
|
+
import TableBody from '@mui/material/TableBody';
|
8
|
+
import Typography from '@mui/material/Typography';
|
9
|
+
import TableRow from '@mui/material/TableRow';
|
10
|
+
import { darken, lighten, alpha, useTheme } from '@mui/material/styles';
|
11
|
+
import Skeleton from '@mui/material/Skeleton';
|
12
|
+
import TableCell from '@mui/material/TableCell';
|
13
|
+
import Box from '@mui/material/Box';
|
14
|
+
import highlightWords from 'highlight-words';
|
15
|
+
import IconButton from '@mui/material/IconButton';
|
16
|
+
import Tooltip from '@mui/material/Tooltip';
|
17
|
+
import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, aggregationFns, filterFns } from '@tanstack/react-table';
|
18
|
+
import Button from '@mui/material/Button';
|
19
|
+
import MenuItem from '@mui/material/MenuItem';
|
20
|
+
import TextField from '@mui/material/TextField';
|
21
|
+
import Collapse from '@mui/material/Collapse';
|
22
|
+
import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
|
23
|
+
import TableFooter from '@mui/material/TableFooter';
|
24
|
+
import TableHead from '@mui/material/TableHead';
|
25
|
+
import ListItemIcon from '@mui/material/ListItemIcon';
|
26
|
+
import Menu from '@mui/material/Menu';
|
27
|
+
import Checkbox from '@mui/material/Checkbox';
|
28
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
29
|
+
import Chip from '@mui/material/Chip';
|
30
|
+
import InputAdornment from '@mui/material/InputAdornment';
|
31
|
+
import { debounce } from '@mui/material/utils';
|
32
|
+
import FormHelperText from '@mui/material/FormHelperText';
|
33
|
+
import Slider from '@mui/material/Slider';
|
34
|
+
import Stack from '@mui/material/Stack';
|
35
|
+
import Grow from '@mui/material/Grow';
|
36
|
+
import Popover from '@mui/material/Popover';
|
37
|
+
import Divider from '@mui/material/Divider';
|
38
|
+
import Badge from '@mui/material/Badge';
|
39
|
+
import TableSortLabel from '@mui/material/TableSortLabel';
|
40
|
+
import Dialog from '@mui/material/Dialog';
|
41
|
+
import DialogActions from '@mui/material/DialogActions';
|
42
|
+
import DialogContent from '@mui/material/DialogContent';
|
43
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
44
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
45
|
+
import Toolbar from '@mui/material/Toolbar';
|
46
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
47
|
+
import LinearProgress from '@mui/material/LinearProgress';
|
48
|
+
import TablePagination from '@mui/material/TablePagination';
|
49
|
+
import Alert from '@mui/material/Alert';
|
50
|
+
import AlertTitle from '@mui/material/AlertTitle';
|
51
|
+
import Fade from '@mui/material/Fade';
|
52
|
+
import Switch from '@mui/material/Switch';
|
53
|
+
import Radio from '@mui/material/Radio';
|
6
54
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
7
55
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
8
56
|
import CancelIcon from '@mui/icons-material/Cancel';
|
@@ -18,8 +66,8 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
18
66
|
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
19
67
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
20
68
|
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
21
|
-
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
22
69
|
import FullscreenIcon from '@mui/icons-material/Fullscreen';
|
70
|
+
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
23
71
|
import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
24
72
|
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
25
73
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
@@ -31,196 +79,91 @@ import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
31
79
|
import SortIcon from '@mui/icons-material/Sort';
|
32
80
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
33
81
|
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
34
|
-
import Box from '@mui/material/Box';
|
35
|
-
import IconButton from '@mui/material/IconButton';
|
36
|
-
import Tooltip from '@mui/material/Tooltip';
|
37
|
-
import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
|
38
|
-
import TableBody from '@mui/material/TableBody';
|
39
|
-
import Typography from '@mui/material/Typography';
|
40
|
-
import TableRow from '@mui/material/TableRow';
|
41
|
-
import Skeleton from '@mui/material/Skeleton';
|
42
|
-
import TableCell from '@mui/material/TableCell';
|
43
|
-
import TextField from '@mui/material/TextField';
|
44
|
-
import MenuItem from '@mui/material/MenuItem';
|
45
|
-
import Button from '@mui/material/Button';
|
46
|
-
import highlightWords from 'highlight-words';
|
47
|
-
import Collapse from '@mui/material/Collapse';
|
48
|
-
import ListItemIcon from '@mui/material/ListItemIcon';
|
49
|
-
import Menu from '@mui/material/Menu';
|
50
|
-
import CircularProgress from '@mui/material/CircularProgress';
|
51
|
-
import Checkbox from '@mui/material/Checkbox';
|
52
|
-
import Radio from '@mui/material/Radio';
|
53
|
-
import Paper from '@mui/material/Paper';
|
54
|
-
import Toolbar from '@mui/material/Toolbar';
|
55
|
-
import useMediaQuery from '@mui/material/useMediaQuery';
|
56
|
-
import InputAdornment from '@mui/material/InputAdornment';
|
57
|
-
import { debounce } from '@mui/material/utils';
|
58
|
-
import LinearProgress from '@mui/material/LinearProgress';
|
59
|
-
import TablePagination from '@mui/material/TablePagination';
|
60
|
-
import Alert from '@mui/material/Alert';
|
61
|
-
import AlertTitle from '@mui/material/AlertTitle';
|
62
|
-
import Chip from '@mui/material/Chip';
|
63
|
-
import Divider from '@mui/material/Divider';
|
64
|
-
import FormControlLabel from '@mui/material/FormControlLabel';
|
65
|
-
import Switch from '@mui/material/Switch';
|
66
|
-
import Fade from '@mui/material/Fade';
|
67
|
-
import TableContainer from '@mui/material/TableContainer';
|
68
|
-
import Table from '@mui/material/Table';
|
69
|
-
import TableHead from '@mui/material/TableHead';
|
70
|
-
import Slider from '@mui/material/Slider';
|
71
|
-
import Stack from '@mui/material/Stack';
|
72
|
-
import FormHelperText from '@mui/material/FormHelperText';
|
73
|
-
import Grow from '@mui/material/Grow';
|
74
|
-
import Badge from '@mui/material/Badge';
|
75
|
-
import TableSortLabel from '@mui/material/TableSortLabel';
|
76
|
-
import TableFooter from '@mui/material/TableFooter';
|
77
|
-
import Dialog from '@mui/material/Dialog';
|
78
|
-
import DialogActions from '@mui/material/DialogActions';
|
79
|
-
import DialogContent from '@mui/material/DialogContent';
|
80
|
-
import DialogTitle from '@mui/material/DialogTitle';
|
81
82
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
83
|
+
const allowedTypes = ['string', 'number'];
|
84
|
+
const MRT_TableBodyCellValue = ({ cell, table, }) => {
|
85
|
+
var _a, _b, _c;
|
86
|
+
const { getState, options: { enableFilterMatchHighlighting }, } = table;
|
87
|
+
const { column, row } = cell;
|
88
|
+
const { columnDef } = column;
|
89
|
+
const { globalFilter, globalFilterFn } = getState();
|
90
|
+
const filterValue = column.getFilterValue();
|
91
|
+
let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
|
92
|
+
? columnDef.AggregatedCell({
|
93
|
+
cell,
|
94
|
+
column,
|
95
|
+
row,
|
96
|
+
table,
|
97
|
+
})
|
98
|
+
: row.getIsGrouped() && !cell.getIsGrouped()
|
99
|
+
? null
|
100
|
+
: cell.getIsGrouped() && columnDef.GroupedCell
|
101
|
+
? columnDef.GroupedCell({
|
102
|
+
cell,
|
103
|
+
column,
|
104
|
+
row,
|
105
|
+
table,
|
106
|
+
})
|
107
|
+
: undefined;
|
108
|
+
const isGroupedValue = renderedCellValue !== undefined;
|
109
|
+
if (!isGroupedValue) {
|
110
|
+
renderedCellValue = cell.renderValue();
|
111
|
+
}
|
112
|
+
if (enableFilterMatchHighlighting &&
|
113
|
+
columnDef.enableFilterMatchHighlighting !== false &&
|
114
|
+
renderedCellValue &&
|
115
|
+
allowedTypes.includes(typeof renderedCellValue) &&
|
116
|
+
((filterValue &&
|
117
|
+
allowedTypes.includes(typeof filterValue) &&
|
118
|
+
columnDef.filterVariant === 'text') ||
|
119
|
+
(globalFilter &&
|
120
|
+
allowedTypes.includes(typeof globalFilter) &&
|
121
|
+
column.getCanGlobalFilter()))) {
|
122
|
+
const chunks = highlightWords === null || highlightWords === void 0 ? void 0 : highlightWords({
|
123
|
+
matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
|
124
|
+
query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
|
125
|
+
text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
|
126
|
+
});
|
127
|
+
if ((chunks === null || chunks === void 0 ? void 0 : chunks.length) > 1 || ((_b = chunks === null || chunks === void 0 ? void 0 : chunks[0]) === null || _b === void 0 ? void 0 : _b.match)) {
|
128
|
+
renderedCellValue = (jsx("span", { "aria-label": renderedCellValue, role: "note", children: (_c = chunks === null || chunks === void 0 ? void 0 : chunks.map(({ key, match, text }) => (jsx(Box, { "aria-hidden": "true", component: "span", sx: match
|
129
|
+
? {
|
130
|
+
backgroundColor: (theme) => theme.palette.mode === 'dark'
|
131
|
+
? darken(theme.palette.warning.dark, 0.25)
|
132
|
+
: lighten(theme.palette.warning.light, 0.5),
|
133
|
+
borderRadius: '2px',
|
134
|
+
color: (theme) => theme.palette.mode === 'dark' ? 'white' : 'black',
|
135
|
+
padding: '2px 1px',
|
136
|
+
}
|
137
|
+
: undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
|
138
|
+
}
|
139
|
+
}
|
140
|
+
if (columnDef.Cell && !isGroupedValue) {
|
141
|
+
renderedCellValue = columnDef.Cell({
|
142
|
+
cell,
|
143
|
+
column,
|
144
|
+
renderedCellValue,
|
145
|
+
row,
|
146
|
+
table,
|
147
|
+
});
|
148
|
+
}
|
149
|
+
return jsx(Fragment, { children: renderedCellValue });
|
107
150
|
};
|
108
151
|
|
109
|
-
const
|
110
|
-
|
111
|
-
const
|
112
|
-
const
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
.includes(filterValue.toString().toLowerCase().trim());
|
125
|
-
contains.autoRemove = (val) => !val;
|
126
|
-
const startsWith = (row, id, filterValue) => row
|
127
|
-
.getValue(id)
|
128
|
-
.toString()
|
129
|
-
.toLowerCase()
|
130
|
-
.trim()
|
131
|
-
.startsWith(filterValue.toString().toLowerCase().trim());
|
132
|
-
startsWith.autoRemove = (val) => !val;
|
133
|
-
const endsWith = (row, id, filterValue) => row
|
134
|
-
.getValue(id)
|
135
|
-
.toString()
|
136
|
-
.toLowerCase()
|
137
|
-
.trim()
|
138
|
-
.endsWith(filterValue.toString().toLowerCase().trim());
|
139
|
-
endsWith.autoRemove = (val) => !val;
|
140
|
-
const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
|
141
|
-
filterValue.toString().toLowerCase().trim();
|
142
|
-
equals.autoRemove = (val) => !val;
|
143
|
-
const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
|
144
|
-
filterValue.toString().toLowerCase().trim();
|
145
|
-
notEquals.autoRemove = (val) => !val;
|
146
|
-
const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
147
|
-
? +row.getValue(id) > +filterValue
|
148
|
-
: row.getValue(id).toString().toLowerCase().trim() >
|
149
|
-
filterValue.toString().toLowerCase().trim();
|
150
|
-
greaterThan.autoRemove = (val) => !val;
|
151
|
-
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
152
|
-
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
153
|
-
const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
154
|
-
? +row.getValue(id) < +filterValue
|
155
|
-
: row.getValue(id).toString().toLowerCase().trim() <
|
156
|
-
filterValue.toString().toLowerCase().trim();
|
157
|
-
lessThan.autoRemove = (val) => !val;
|
158
|
-
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
159
|
-
lessThanOrEqualTo.autoRemove = (val) => !val;
|
160
|
-
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
161
|
-
greaterThan(row, id, filterValues[0])) &&
|
162
|
-
((!isNaN(+filterValues[0]) &&
|
163
|
-
!isNaN(+filterValues[1]) &&
|
164
|
-
+filterValues[0] > +filterValues[1]) ||
|
165
|
-
['', undefined].includes(filterValues[1]) ||
|
166
|
-
lessThan(row, id, filterValues[1]));
|
167
|
-
between.autoRemove = (val) => !val;
|
168
|
-
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
169
|
-
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
170
|
-
((!isNaN(+filterValues[0]) &&
|
171
|
-
!isNaN(+filterValues[1]) &&
|
172
|
-
+filterValues[0] > +filterValues[1]) ||
|
173
|
-
['', undefined].includes(filterValues[1]) ||
|
174
|
-
lessThanOrEqualTo(row, id, filterValues[1]));
|
175
|
-
betweenInclusive.autoRemove = (val) => !val;
|
176
|
-
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
177
|
-
empty.autoRemove = (val) => !val;
|
178
|
-
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
179
|
-
notEmpty.autoRemove = (val) => !val;
|
180
|
-
const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
181
|
-
betweenInclusive,
|
182
|
-
contains,
|
183
|
-
empty,
|
184
|
-
endsWith,
|
185
|
-
equals,
|
186
|
-
fuzzy: fuzzy$1,
|
187
|
-
greaterThan,
|
188
|
-
greaterThanOrEqualTo,
|
189
|
-
lessThan,
|
190
|
-
lessThanOrEqualTo,
|
191
|
-
notEmpty,
|
192
|
-
notEquals,
|
193
|
-
startsWith });
|
194
|
-
|
195
|
-
const fuzzy = (rowA, rowB, columnId) => {
|
196
|
-
let dir = 0;
|
197
|
-
if (rowA.columnFiltersMeta[columnId]) {
|
198
|
-
dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
199
|
-
}
|
200
|
-
// Provide a fallback for when the item ranks are equal
|
201
|
-
return dir === 0
|
202
|
-
? sortingFns.alphanumeric(rowA, rowB, columnId)
|
203
|
-
: dir;
|
204
|
-
};
|
205
|
-
const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy });
|
206
|
-
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
207
|
-
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
208
|
-
|
209
|
-
const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
|
210
|
-
const getAllLeafColumnDefs = (columns) => {
|
211
|
-
const allLeafColumnDefs = [];
|
212
|
-
const getLeafColumns = (cols) => {
|
213
|
-
cols.forEach((col) => {
|
214
|
-
if (col.columns) {
|
215
|
-
getLeafColumns(col.columns);
|
216
|
-
}
|
217
|
-
else {
|
218
|
-
allLeafColumnDefs.push(col);
|
219
|
-
}
|
220
|
-
});
|
221
|
-
};
|
222
|
-
getLeafColumns(columns);
|
223
|
-
return allLeafColumnDefs;
|
152
|
+
const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
|
153
|
+
const getAllLeafColumnDefs = (columns) => {
|
154
|
+
const allLeafColumnDefs = [];
|
155
|
+
const getLeafColumns = (cols) => {
|
156
|
+
cols.forEach((col) => {
|
157
|
+
if (col.columns) {
|
158
|
+
getLeafColumns(col.columns);
|
159
|
+
}
|
160
|
+
else {
|
161
|
+
allLeafColumnDefs.push(col);
|
162
|
+
}
|
163
|
+
});
|
164
|
+
};
|
165
|
+
getLeafColumns(columns);
|
166
|
+
return allLeafColumnDefs;
|
224
167
|
};
|
225
168
|
const prepareColumns = ({ aggregationFns, columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
|
226
169
|
var _a, _b;
|
@@ -290,7 +233,7 @@ const getLeadingDisplayColumnIds = (props) => {
|
|
290
233
|
props.positionActionsColumn === 'first' &&
|
291
234
|
(props.enableRowActions ||
|
292
235
|
(props.enableEditing &&
|
293
|
-
['
|
236
|
+
['modal', 'row'].includes((_b = props.editDisplayMode) !== null && _b !== void 0 ? _b : ''))) &&
|
294
237
|
'mrt-row-actions',
|
295
238
|
props.positionExpandColumn === 'first' &&
|
296
239
|
showExpandColumn(props) &&
|
@@ -305,7 +248,7 @@ const getTrailingDisplayColumnIds = (props) => {
|
|
305
248
|
props.positionActionsColumn === 'last' &&
|
306
249
|
(props.enableRowActions ||
|
307
250
|
(props.enableEditing &&
|
308
|
-
['
|
251
|
+
['modal', 'row'].includes((_a = props.editDisplayMode) !== null && _a !== void 0 ? _a : ''))) &&
|
309
252
|
'mrt-row-actions',
|
310
253
|
props.positionExpandColumn === 'last' &&
|
311
254
|
showExpandColumn(props) &&
|
@@ -333,11 +276,17 @@ const getDefaultColumnFilterFn = (columnDef) => {
|
|
333
276
|
return 'fuzzy';
|
334
277
|
};
|
335
278
|
const getIsFirstColumn = (column, table) => {
|
336
|
-
|
279
|
+
const leftColumns = table.getLeftVisibleLeafColumns();
|
280
|
+
return leftColumns.length
|
281
|
+
? leftColumns[0].id === column.id
|
282
|
+
: table.getVisibleLeafColumns()[0].id === column.id;
|
337
283
|
};
|
338
284
|
const getIsLastColumn = (column, table) => {
|
285
|
+
const rightColumns = table.getRightVisibleLeafColumns();
|
339
286
|
const columns = table.getVisibleLeafColumns();
|
340
|
-
return
|
287
|
+
return rightColumns.length
|
288
|
+
? rightColumns[rightColumns.length - 1].id === column.id
|
289
|
+
: columns[columns.length - 1].id === column.id;
|
341
290
|
};
|
342
291
|
const getIsLastLeftPinnedColumn = (table, column) => {
|
343
292
|
return (column.getIsPinned() === 'left' &&
|
@@ -353,9 +302,9 @@ const getTotalRight = (table, column) => {
|
|
353
302
|
.reduce((acc, col) => acc + col.getSize(), 0);
|
354
303
|
};
|
355
304
|
const getCanRankRows = (table) => {
|
356
|
-
const {
|
357
|
-
const { manualExpanding, manualFiltering, manualGrouping, manualSorting,
|
358
|
-
const {
|
305
|
+
const { getState, options } = table;
|
306
|
+
const { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, } = options;
|
307
|
+
const { expanded, globalFilterFn } = getState();
|
359
308
|
return (!manualExpanding &&
|
360
309
|
!manualFiltering &&
|
361
310
|
!manualGrouping &&
|
@@ -405,8 +354,8 @@ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, })
|
|
405
354
|
};
|
406
355
|
const MRT_DefaultColumn = {
|
407
356
|
filterVariant: 'text',
|
408
|
-
minSize: 40,
|
409
357
|
maxSize: 1000,
|
358
|
+
minSize: 40,
|
410
359
|
size: 180,
|
411
360
|
};
|
412
361
|
const MRT_DefaultDisplayColumn = {
|
@@ -430,240 +379,71 @@ const createRow = (table, originalRow) => createRow$1(table, 'mrt-row-create', o
|
|
430
379
|
[getColumnId(col)]: '',
|
431
380
|
}))), -1, 0);
|
432
381
|
|
433
|
-
const
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
copiedToClipboard: 'Copied to clipboard',
|
447
|
-
dropToGroupBy: 'Drop to group by {column}',
|
448
|
-
edit: 'Edit',
|
449
|
-
expand: 'Expand',
|
450
|
-
expandAll: 'Expand all',
|
451
|
-
filterArrIncludes: 'Includes',
|
452
|
-
filterArrIncludesAll: 'Includes all',
|
453
|
-
filterArrIncludesSome: 'Includes',
|
454
|
-
filterBetween: 'Between',
|
455
|
-
filterBetweenInclusive: 'Between Inclusive',
|
456
|
-
filterByColumn: 'Filter by {column}',
|
457
|
-
filterContains: 'Contains',
|
458
|
-
filterEmpty: 'Empty',
|
459
|
-
filterEndsWith: 'Ends With',
|
460
|
-
filterEquals: 'Equals',
|
461
|
-
filterEqualsString: 'Equals',
|
462
|
-
filterFuzzy: 'Fuzzy',
|
463
|
-
filterGreaterThan: 'Greater Than',
|
464
|
-
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
465
|
-
filterInNumberRange: 'Between',
|
466
|
-
filterIncludesString: 'Contains',
|
467
|
-
filterIncludesStringSensitive: 'Contains',
|
468
|
-
filterLessThan: 'Less Than',
|
469
|
-
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
470
|
-
filterMode: 'Filter Mode: {filterType}',
|
471
|
-
filterNotEmpty: 'Not Empty',
|
472
|
-
filterNotEquals: 'Not Equals',
|
473
|
-
filterStartsWith: 'Starts With',
|
474
|
-
filterWeakEquals: 'Equals',
|
475
|
-
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
476
|
-
goToFirstPage: 'Go to first page',
|
477
|
-
goToLastPage: 'Go to last page',
|
478
|
-
goToNextPage: 'Go to next page',
|
479
|
-
goToPreviousPage: 'Go to previous page',
|
480
|
-
grab: 'Grab',
|
481
|
-
groupByColumn: 'Group by {column}',
|
482
|
-
groupedBy: 'Grouped by ',
|
483
|
-
hideAll: 'Hide all',
|
484
|
-
hideColumn: 'Hide {column} column',
|
485
|
-
max: 'Max',
|
486
|
-
min: 'Min',
|
487
|
-
move: 'Move',
|
488
|
-
noRecordsToDisplay: 'No records to display',
|
489
|
-
noResultsFound: 'No results found',
|
490
|
-
of: 'of',
|
491
|
-
or: 'or',
|
492
|
-
pin: 'Pin',
|
493
|
-
pinToLeft: 'Pin to left',
|
494
|
-
pinToRight: 'Pin to right',
|
495
|
-
resetColumnSize: 'Reset column size',
|
496
|
-
resetOrder: 'Reset order',
|
497
|
-
rowActions: 'Row Actions',
|
498
|
-
rowNumber: '#',
|
499
|
-
rowNumbers: 'Row Numbers',
|
500
|
-
rowsPerPage: 'Rows per page',
|
501
|
-
save: 'Save',
|
502
|
-
search: 'Search',
|
503
|
-
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
504
|
-
select: 'Select',
|
505
|
-
showAll: 'Show all',
|
506
|
-
showAllColumns: 'Show all columns',
|
507
|
-
showHideColumns: 'Show/Hide columns',
|
508
|
-
showHideFilters: 'Show/Hide filters',
|
509
|
-
showHideSearch: 'Show/Hide search',
|
510
|
-
sortByColumnAsc: 'Sort by {column} ascending',
|
511
|
-
sortByColumnDesc: 'Sort by {column} descending',
|
512
|
-
sortedByColumnAsc: 'Sorted by {column} ascending',
|
513
|
-
sortedByColumnDesc: 'Sorted by {column} descending',
|
514
|
-
thenBy: ', then by ',
|
515
|
-
toggleDensity: 'Toggle density',
|
516
|
-
toggleFullScreen: 'Toggle full screen',
|
517
|
-
toggleSelectAll: 'Toggle select all',
|
518
|
-
toggleSelectRow: 'Toggle select row',
|
519
|
-
toggleVisibility: 'Toggle visibility',
|
520
|
-
ungroupByColumn: 'Ungroup by {column}',
|
521
|
-
unpin: 'Unpin',
|
522
|
-
unpinAll: 'Unpin all',
|
382
|
+
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
383
|
+
var _a;
|
384
|
+
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
385
|
+
return (jsx(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.move, children: jsx(IconButton, Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
|
386
|
+
var _a;
|
387
|
+
e.stopPropagation();
|
388
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
389
|
+
}, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
|
390
|
+
cursor: 'grabbing',
|
391
|
+
}, '&:hover': {
|
392
|
+
backgroundColor: 'transparent',
|
393
|
+
opacity: 1,
|
394
|
+
}, cursor: 'grab', m: '0 -0.1rem', opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) }));
|
523
395
|
};
|
524
396
|
|
525
|
-
const
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
MoreHorizIcon,
|
545
|
-
MoreVertIcon,
|
546
|
-
PushPinIcon,
|
547
|
-
RestartAltIcon,
|
548
|
-
SaveIcon,
|
549
|
-
SearchIcon,
|
550
|
-
SearchOffIcon,
|
551
|
-
SortIcon,
|
552
|
-
ViewColumnIcon,
|
553
|
-
VisibilityOffIcon,
|
397
|
+
const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, }) => {
|
398
|
+
const { options: { muiRowDragHandleProps }, } = table;
|
399
|
+
const iconButtonProps = parseFromValuesOrFunc(muiRowDragHandleProps, {
|
400
|
+
row,
|
401
|
+
table,
|
402
|
+
});
|
403
|
+
const handleDragStart = (event) => {
|
404
|
+
var _a;
|
405
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
406
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
407
|
+
table.setDraggingRow(row);
|
408
|
+
};
|
409
|
+
const handleDragEnd = (event) => {
|
410
|
+
var _a;
|
411
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
412
|
+
table.setDraggingRow(null);
|
413
|
+
table.setHoveredRow(null);
|
414
|
+
};
|
415
|
+
return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
|
554
416
|
};
|
555
417
|
|
556
|
-
const
|
557
|
-
var
|
558
|
-
|
559
|
-
const
|
560
|
-
const
|
561
|
-
const
|
562
|
-
const
|
563
|
-
const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
|
564
|
-
const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
|
565
|
-
const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
|
566
|
-
if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
|
567
|
-
layoutMode = 'grid';
|
568
|
-
}
|
569
|
-
if (rest.enableRowVirtualization) {
|
570
|
-
enableStickyHeader = true;
|
571
|
-
}
|
572
|
-
if (enablePagination === false && manualPagination === undefined) {
|
573
|
-
manualPagination = true;
|
574
|
-
}
|
575
|
-
if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
|
576
|
-
manualFiltering = true;
|
577
|
-
manualGrouping = true;
|
578
|
-
manualPagination = true;
|
579
|
-
manualSorting = true;
|
580
|
-
}
|
581
|
-
return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
|
582
|
-
columnFilterDisplayMode,
|
583
|
-
columnResizeMode,
|
584
|
-
createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
|
585
|
-
enableBottomToolbar,
|
586
|
-
enableColumnActions,
|
587
|
-
enableColumnFilters,
|
588
|
-
enableColumnOrdering,
|
589
|
-
enableColumnPinning,
|
590
|
-
enableColumnResizing,
|
591
|
-
enableDensityToggle,
|
592
|
-
enableExpandAll,
|
593
|
-
enableExpanding,
|
594
|
-
enableFilterMatchHighlighting,
|
595
|
-
enableFilters,
|
596
|
-
enableFullScreenToggle,
|
597
|
-
enableGlobalFilter,
|
598
|
-
enableGlobalFilterRankedResults,
|
599
|
-
enableGrouping,
|
600
|
-
enableHiding,
|
601
|
-
enableMultiRowSelection,
|
602
|
-
enableMultiSort,
|
603
|
-
enablePagination,
|
604
|
-
enableRowPinning,
|
605
|
-
enableRowSelection,
|
606
|
-
enableSelectAll,
|
607
|
-
enableSorting,
|
608
|
-
enableStickyHeader,
|
609
|
-
enableTableFooter,
|
610
|
-
enableTableHead,
|
611
|
-
enableToolbarInternalActions,
|
612
|
-
enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode, localization: _localization, manualFiltering,
|
613
|
-
manualGrouping,
|
614
|
-
manualPagination,
|
615
|
-
manualSorting,
|
616
|
-
paginationDisplayMode,
|
617
|
-
positionActionsColumn,
|
618
|
-
positionExpandColumn,
|
619
|
-
positionGlobalFilter,
|
620
|
-
positionPagination,
|
621
|
-
positionToolbarAlertBanner,
|
622
|
-
positionToolbarDropZone,
|
623
|
-
rowNumberMode,
|
624
|
-
rowPinningDisplayMode,
|
625
|
-
selectAllMode, sortingFns: _sortingFns }, rest);
|
626
|
-
};
|
627
|
-
|
628
|
-
const MRT_RowPinButton = ({ row, table, pinningPosition, }) => {
|
629
|
-
const { options: { icons: { PushPinIcon, CloseIcon }, localization, rowPinningDisplayMode, }, } = table;
|
630
|
-
const isPinned = row.getIsPinned();
|
631
|
-
const [tooltipOpened, setTooltipOpened] = useState(false);
|
632
|
-
const handleTogglePin = (event) => {
|
633
|
-
setTooltipOpened(false);
|
418
|
+
const MRT_CopyButton = ({ cell, children, table, }) => {
|
419
|
+
var _a;
|
420
|
+
const { options: { localization, muiCopyButtonProps }, } = table;
|
421
|
+
const { column, row } = cell;
|
422
|
+
const { columnDef } = column;
|
423
|
+
const [copied, setCopied] = useState(false);
|
424
|
+
const handleCopy = (event, text) => {
|
634
425
|
event.stopPropagation();
|
635
|
-
|
426
|
+
navigator.clipboard.writeText(text);
|
427
|
+
setCopied(true);
|
428
|
+
setTimeout(() => setCopied(false), 4000);
|
636
429
|
};
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
};
|
648
|
-
|
649
|
-
const MRT_TableBodyRowPinButton = ({ row, table, }) => {
|
650
|
-
const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
|
651
|
-
const { density } = getState();
|
652
|
-
const canPin = parseFromValuesOrFunc(enableRowPinning, row);
|
653
|
-
if (!canPin)
|
654
|
-
return null;
|
655
|
-
if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
|
656
|
-
return (jsxs(Box, { sx: {
|
657
|
-
display: 'flex',
|
658
|
-
flexDirection: density === 'compact' ? 'row' : 'column',
|
659
|
-
}, children: [jsx(MRT_RowPinButton, { row: row, table: table, pinningPosition: "top" }), jsx(MRT_RowPinButton, { row: row, table: table, pinningPosition: "bottom" })] }));
|
660
|
-
}
|
661
|
-
return (jsx(MRT_RowPinButton, { row: row, table: table, pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }));
|
430
|
+
const buttonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCopyButtonProps, {
|
431
|
+
cell,
|
432
|
+
column,
|
433
|
+
row,
|
434
|
+
table,
|
435
|
+
})), parseFromValuesOrFunc(columnDef.muiCopyButtonProps, {
|
436
|
+
cell,
|
437
|
+
column,
|
438
|
+
row,
|
439
|
+
table,
|
440
|
+
}));
|
441
|
+
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined, children: children })) }));
|
662
442
|
};
|
663
443
|
|
664
444
|
const MRT_EditCellTextField = ({ cell, table, }) => {
|
665
445
|
var _a, _b, _c;
|
666
|
-
const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow,
|
446
|
+
const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
|
667
447
|
const { column, row } = cell;
|
668
448
|
const { columnDef } = column;
|
669
449
|
const { creatingRow, editingRow } = getState();
|
@@ -723,15 +503,15 @@ const MRT_EditCellTextField = ({ cell, table, }) => {
|
|
723
503
|
textFieldProps.inputRef = inputRef;
|
724
504
|
}
|
725
505
|
}
|
726
|
-
}, label: ['
|
506
|
+
}, label: ['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
|
727
507
|
? column.columnDef.header
|
728
|
-
: undefined, margin: "none", name: column.id, placeholder: !['
|
508
|
+
: undefined, margin: "none", name: column.id, placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
|
729
509
|
? columnDef.header
|
730
|
-
: undefined, select: isSelectEdit, value: value, variant: "standard" }, textFieldProps, { onClick: (e) => {
|
510
|
+
: undefined, select: isSelectEdit, value: value, variant: "standard" }, textFieldProps, { onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
|
731
511
|
var _a;
|
732
512
|
e.stopPropagation();
|
733
513
|
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
734
|
-
},
|
514
|
+
}, onKeyDown: handleEnterKeyDown, children: (_b = textFieldProps.children) !== null && _b !== void 0 ? _b : (_c = columnDef === null || columnDef === void 0 ? void 0 : columnDef.editSelectOptions) === null || _c === void 0 ? void 0 : _c.map((option) => {
|
735
515
|
let value;
|
736
516
|
let text;
|
737
517
|
if (typeof option !== 'object') {
|
@@ -743,150 +523,19 @@ const MRT_EditCellTextField = ({ cell, table, }) => {
|
|
743
523
|
text = option.text;
|
744
524
|
}
|
745
525
|
return (jsx(MenuItem, { sx: {
|
746
|
-
display: 'flex',
|
747
|
-
m: 0,
|
748
526
|
alignItems: 'center',
|
527
|
+
display: 'flex',
|
749
528
|
gap: '0.5rem',
|
529
|
+
m: 0,
|
750
530
|
}, value: value, children: text }, value));
|
751
531
|
}) })));
|
752
532
|
};
|
753
533
|
|
754
|
-
const MRT_CopyButton = ({ cell, children, table, }) => {
|
755
|
-
var _a;
|
756
|
-
const { options: { localization, muiCopyButtonProps }, } = table;
|
757
|
-
const { column, row } = cell;
|
758
|
-
const { columnDef } = column;
|
759
|
-
const [copied, setCopied] = useState(false);
|
760
|
-
const handleCopy = (event, text) => {
|
761
|
-
event.stopPropagation();
|
762
|
-
navigator.clipboard.writeText(text);
|
763
|
-
setCopied(true);
|
764
|
-
setTimeout(() => setCopied(false), 4000);
|
765
|
-
};
|
766
|
-
const buttonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCopyButtonProps, {
|
767
|
-
cell,
|
768
|
-
column,
|
769
|
-
row,
|
770
|
-
table,
|
771
|
-
})), parseFromValuesOrFunc(columnDef.muiCopyButtonProps, {
|
772
|
-
cell,
|
773
|
-
column,
|
774
|
-
row,
|
775
|
-
table,
|
776
|
-
}));
|
777
|
-
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? localization.copiedToClipboard : localization.clickToCopy), children: jsx(Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined, children: children })) }));
|
778
|
-
};
|
779
|
-
|
780
|
-
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
781
|
-
var _a;
|
782
|
-
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
783
|
-
return (jsx(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.move, children: jsx(IconButton, Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
|
784
|
-
var _a;
|
785
|
-
e.stopPropagation();
|
786
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
787
|
-
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: '0 -0.1rem', opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
788
|
-
backgroundColor: 'transparent',
|
789
|
-
opacity: 1,
|
790
|
-
}, '&:active': {
|
791
|
-
cursor: 'grabbing',
|
792
|
-
} }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) }));
|
793
|
-
};
|
794
|
-
|
795
|
-
const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, }) => {
|
796
|
-
const { options: { muiRowDragHandleProps }, } = table;
|
797
|
-
const iconButtonProps = parseFromValuesOrFunc(muiRowDragHandleProps, {
|
798
|
-
row,
|
799
|
-
table,
|
800
|
-
});
|
801
|
-
const handleDragStart = (event) => {
|
802
|
-
var _a;
|
803
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
804
|
-
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
805
|
-
table.setDraggingRow(row);
|
806
|
-
};
|
807
|
-
const handleDragEnd = (event) => {
|
808
|
-
var _a;
|
809
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
810
|
-
table.setDraggingRow(null);
|
811
|
-
table.setHoveredRow(null);
|
812
|
-
};
|
813
|
-
return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
814
|
-
};
|
815
|
-
|
816
|
-
const allowedTypes = ['string', 'number'];
|
817
|
-
const MRT_TableBodyCellValue = ({ cell, table, }) => {
|
818
|
-
var _a, _b, _c;
|
819
|
-
const { getState, options: { enableFilterMatchHighlighting }, } = table;
|
820
|
-
const { column, row } = cell;
|
821
|
-
const { columnDef } = column;
|
822
|
-
const { globalFilter, globalFilterFn } = getState();
|
823
|
-
const filterValue = column.getFilterValue();
|
824
|
-
let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
|
825
|
-
? columnDef.AggregatedCell({
|
826
|
-
cell,
|
827
|
-
column,
|
828
|
-
row,
|
829
|
-
table,
|
830
|
-
})
|
831
|
-
: row.getIsGrouped() && !cell.getIsGrouped()
|
832
|
-
? null
|
833
|
-
: cell.getIsGrouped() && columnDef.GroupedCell
|
834
|
-
? columnDef.GroupedCell({
|
835
|
-
cell,
|
836
|
-
column,
|
837
|
-
row,
|
838
|
-
table,
|
839
|
-
})
|
840
|
-
: undefined;
|
841
|
-
const isGroupedValue = renderedCellValue !== undefined;
|
842
|
-
if (!isGroupedValue) {
|
843
|
-
renderedCellValue = cell.renderValue();
|
844
|
-
}
|
845
|
-
if (enableFilterMatchHighlighting &&
|
846
|
-
columnDef.enableFilterMatchHighlighting !== false &&
|
847
|
-
renderedCellValue &&
|
848
|
-
allowedTypes.includes(typeof renderedCellValue) &&
|
849
|
-
((filterValue &&
|
850
|
-
allowedTypes.includes(typeof filterValue) &&
|
851
|
-
columnDef.filterVariant === 'text') ||
|
852
|
-
(globalFilter &&
|
853
|
-
allowedTypes.includes(typeof globalFilter) &&
|
854
|
-
column.getCanGlobalFilter()))) {
|
855
|
-
const chunks = highlightWords === null || highlightWords === void 0 ? void 0 : highlightWords({
|
856
|
-
text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
|
857
|
-
query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
|
858
|
-
matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
|
859
|
-
});
|
860
|
-
if ((chunks === null || chunks === void 0 ? void 0 : chunks.length) > 1 || ((_b = chunks === null || chunks === void 0 ? void 0 : chunks[0]) === null || _b === void 0 ? void 0 : _b.match)) {
|
861
|
-
renderedCellValue = (jsx("span", { "aria-label": renderedCellValue, role: "note", children: (_c = chunks === null || chunks === void 0 ? void 0 : chunks.map(({ key, match, text }) => (jsx(Box, { "aria-hidden": "true", component: "span", sx: match
|
862
|
-
? {
|
863
|
-
backgroundColor: (theme) => theme.palette.mode === 'dark'
|
864
|
-
? darken(theme.palette.warning.dark, 0.25)
|
865
|
-
: lighten(theme.palette.warning.light, 0.5),
|
866
|
-
borderRadius: '2px',
|
867
|
-
color: (theme) => theme.palette.mode === 'dark' ? 'white' : 'black',
|
868
|
-
padding: '2px 1px',
|
869
|
-
}
|
870
|
-
: undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
|
871
|
-
}
|
872
|
-
}
|
873
|
-
if (columnDef.Cell && !isGroupedValue) {
|
874
|
-
renderedCellValue = columnDef.Cell({
|
875
|
-
cell,
|
876
|
-
renderedCellValue,
|
877
|
-
column,
|
878
|
-
row,
|
879
|
-
table,
|
880
|
-
});
|
881
|
-
}
|
882
|
-
return jsx(Fragment, { children: renderedCellValue });
|
883
|
-
};
|
884
|
-
|
885
534
|
const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
|
886
535
|
var _a, _b, _c, _d;
|
887
536
|
const theme = useTheme();
|
888
|
-
const { getState, options: { createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode,
|
889
|
-
const { creatingRow, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow,
|
537
|
+
const { getState, options: { createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiSkeletonProps, muiTableBodyCellProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
538
|
+
const { creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
890
539
|
const { column, row } = cell;
|
891
540
|
const { columnDef } = column;
|
892
541
|
const { columnDefType } = columnDef;
|
@@ -931,6 +580,9 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
931
580
|
: undefined;
|
932
581
|
return borderStyle
|
933
582
|
? {
|
583
|
+
borderBottom: isDraggingRow || isHoveredRow || isLastRow
|
584
|
+
? borderStyle
|
585
|
+
: undefined,
|
934
586
|
borderLeft: isDraggingColumn ||
|
935
587
|
isHoveredColumn ||
|
936
588
|
((isDraggingRow || isHoveredRow) && isFirstColumn)
|
@@ -941,9 +593,6 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
941
593
|
((isDraggingRow || isHoveredRow) && isLastColumn)
|
942
594
|
? borderStyle
|
943
595
|
: undefined,
|
944
|
-
borderBottom: isDraggingRow || isHoveredRow || isLastRow
|
945
|
-
? borderStyle
|
946
|
-
: undefined,
|
947
596
|
borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
|
948
597
|
}
|
949
598
|
: undefined;
|
@@ -951,7 +600,7 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
951
600
|
const isEditable = parseFromValuesOrFunc(enableEditing, row) &&
|
952
601
|
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
|
953
602
|
const isEditing = isEditable &&
|
954
|
-
!['
|
603
|
+
!['custom', 'modal'].includes(editDisplayMode) &&
|
955
604
|
(editDisplayMode === 'table' ||
|
956
605
|
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
|
957
606
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
|
@@ -986,7 +635,13 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
986
635
|
if (node) {
|
987
636
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
988
637
|
}
|
989
|
-
} }, tableCellProps, {
|
638
|
+
} }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
|
639
|
+
outline: ['cell', 'table'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')
|
640
|
+
? `1px solid ${theme.palette.text.secondary}`
|
641
|
+
: undefined,
|
642
|
+
outlineOffset: '-1px',
|
643
|
+
textOverflow: 'clip',
|
644
|
+
}, alignItems: layoutMode === 'grid' ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', justifyContent: layoutMode === 'grid' ? tableCellProps.align : undefined, overflow: 'hidden', p: density === 'compact'
|
990
645
|
? columnDefType === 'display'
|
991
646
|
? '0 0.5rem'
|
992
647
|
: '0.5rem'
|
@@ -1003,17 +658,11 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
1003
658
|
: density === 'comfortable'
|
1004
659
|
? 0.75
|
1005
660
|
: 1.25)}rem`
|
1006
|
-
: undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0,
|
1007
|
-
outline: ['table', 'cell'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')
|
1008
|
-
? `1px solid ${theme.palette.text.secondary}`
|
1009
|
-
: undefined,
|
1010
|
-
outlineOffset: '-1px',
|
1011
|
-
textOverflow: 'clip',
|
1012
|
-
} }, getCommonCellStyles({
|
661
|
+
: undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0 }, getCommonCellStyles({
|
1013
662
|
column,
|
1014
663
|
table,
|
1015
|
-
theme,
|
1016
664
|
tableCellProps,
|
665
|
+
theme,
|
1017
666
|
})), draggingBorders)), children: jsxs(Fragment, { children: [cell.getIsPlaceholder() ? ((_b = (_a = columnDef.PlaceholderCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : null) : (isLoading || showSkeletons) && cell.getValue() === null ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
1018
667
|
rowNumberMode === 'static' &&
|
1019
668
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
@@ -1021,8 +670,8 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
1021
670
|
column.id === 'mrt-row-expand' ||
|
1022
671
|
!row.getIsGrouped()) ? ((_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
|
1023
672
|
cell,
|
1024
|
-
renderedCellValue: cell.renderValue(),
|
1025
673
|
column,
|
674
|
+
renderedCellValue: cell.renderValue(),
|
1026
675
|
row,
|
1027
676
|
table,
|
1028
677
|
})) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
@@ -1031,7 +680,7 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
|
|
1031
680
|
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
1032
681
|
|
1033
682
|
const MRT_TableDetailPanel = ({ parentRowRef, row, rowIndex, table, virtualRow, }) => {
|
1034
|
-
const {
|
683
|
+
const { getState, getVisibleLeafColumns, options: { layoutMode, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel, }, } = table;
|
1035
684
|
const { isLoading } = getState();
|
1036
685
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
1037
686
|
isDetailPanel: true,
|
@@ -1058,7 +707,7 @@ const MRT_TableDetailPanel = ({ parentRowRef, row, rowIndex, table, virtualRow,
|
|
1058
707
|
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
|
1059
708
|
var _a, _b, _c, _d;
|
1060
709
|
const theme = useTheme();
|
1061
|
-
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode,
|
710
|
+
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
1062
711
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
1063
712
|
const isPinned = enableRowPinning && row.getIsPinned();
|
1064
713
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
@@ -1092,15 +741,25 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
1092
741
|
}
|
1093
742
|
};
|
1094
743
|
const rowRef = useRef(null);
|
1095
|
-
return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, onDragEnter: handleDragEnter,
|
744
|
+
return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, onDragEnter: handleDragEnter, ref: (node) => {
|
1096
745
|
if (node) {
|
1097
746
|
rowRef.current = node;
|
1098
747
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
1099
748
|
}
|
1100
|
-
} }, tableRowProps, {
|
749
|
+
}, selected: row.getIsSelected() }, tableRowProps, { style: Object.assign({ transform: virtualRow
|
750
|
+
? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
|
751
|
+
: undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), sx: (theme) => (Object.assign({ '&:hover td': {
|
752
|
+
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
|
753
|
+
? row.getIsSelected()
|
754
|
+
? `${alpha(theme.palette.primary.main, 0.2)}`
|
755
|
+
: theme.palette.mode === 'dark'
|
756
|
+
? `${lighten(theme.palette.background.default, 0.12)}`
|
757
|
+
: `${darken(theme.palette.background.default, 0.05)}`
|
758
|
+
: undefined,
|
759
|
+
}, backgroundColor: `${lighten(theme.palette.background.default, 0.06)} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
|
1101
760
|
? `${bottomPinnedIndex * rowHeight +
|
1102
761
|
(enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
|
1103
|
-
: undefined, display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: isPinned
|
762
|
+
: undefined, boxSizing: 'border-box', display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: isPinned
|
1104
763
|
? 0.98
|
1105
764
|
: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
|
1106
765
|
? 0.5
|
@@ -1108,30 +767,20 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
1108
767
|
? 'absolute'
|
1109
768
|
: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
1110
769
|
? 'sticky'
|
1111
|
-
: undefined,
|
1112
|
-
? 0
|
1113
|
-
: topPinnedIndex !== undefined && isPinned
|
1114
|
-
? `${topPinnedIndex * rowHeight +
|
1115
|
-
(enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
|
1116
|
-
: undefined, width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
1117
|
-
? 1
|
1118
|
-
: undefined, td: {
|
770
|
+
: undefined, td: {
|
1119
771
|
backgroundColor: row.getIsSelected()
|
1120
772
|
? alpha(theme.palette.primary.main, 0.2)
|
1121
773
|
: isPinned
|
1122
774
|
? alpha(theme.palette.primary.main, 0.1)
|
1123
775
|
: undefined,
|
1124
|
-
},
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
} }, sx)), style: Object.assign({ transform: virtualRow
|
1133
|
-
? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
|
1134
|
-
: undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
|
776
|
+
}, top: virtualRow
|
777
|
+
? 0
|
778
|
+
: topPinnedIndex !== undefined && isPinned
|
779
|
+
? `${topPinnedIndex * rowHeight +
|
780
|
+
(enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
|
781
|
+
: undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
782
|
+
? 1
|
783
|
+
: undefined }, sx)), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
|
1135
784
|
const cell = columnVirtualizer
|
1136
785
|
? row.getVisibleCells()[cellOrVirtualCell.index]
|
1137
786
|
: cellOrVirtualCell;
|
@@ -1156,18 +805,32 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
1156
805
|
};
|
1157
806
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
|
1158
807
|
|
1159
|
-
const
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
808
|
+
const fuzzy$1 = (rowA, rowB, columnId) => {
|
809
|
+
let dir = 0;
|
810
|
+
if (rowA.columnFiltersMeta[columnId]) {
|
811
|
+
dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
|
812
|
+
}
|
813
|
+
// Provide a fallback for when the item ranks are equal
|
814
|
+
return dir === 0
|
815
|
+
? sortingFns.alphanumeric(rowA, rowB, columnId)
|
816
|
+
: dir;
|
817
|
+
};
|
818
|
+
const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
|
819
|
+
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
|
820
|
+
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
821
|
+
|
822
|
+
const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
823
|
+
var _a, _b, _c, _d, _e, _f;
|
824
|
+
const { getBottomRows, getCenterRows, getIsSomeRowsPinned, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { enableGlobalFilterRankedResults, enablePagination, enableRowPinning, enableRowVirtualization, enableStickyFooter, enableStickyHeader, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef, tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
825
|
+
const { columnFilters, density, expanded, globalFilter, globalFilterFn, isFullScreen, pagination, rowPinning, sorting, } = getState();
|
826
|
+
const tableBodyProps = parseFromValuesOrFunc(muiTableBodyProps, { table });
|
827
|
+
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
828
|
+
table,
|
829
|
+
});
|
830
|
+
const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
|
831
|
+
((_a = tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight)) ||
|
832
|
+
0;
|
833
|
+
const tableFooterHeight = (enableStickyFooter && ((_b = tableFooterRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
|
1171
834
|
const shouldRankResults = useMemo(() => !manualExpanding &&
|
1172
835
|
!manualFiltering &&
|
1173
836
|
!manualGrouping &&
|
@@ -1280,7 +943,7 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
|
|
1280
943
|
};
|
1281
944
|
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1282
945
|
}) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
1283
|
-
getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', position: 'sticky',
|
946
|
+
getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: layoutMode === 'grid' ? 'grid' : 'table-row-group', position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, rowIndex) => {
|
1284
947
|
const props = {
|
1285
948
|
columnVirtualizer,
|
1286
949
|
measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
|
@@ -1297,130 +960,155 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
|
|
1297
960
|
};
|
1298
961
|
const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
|
1299
962
|
|
1300
|
-
const
|
963
|
+
const MRT_TableFooterCell = ({ footer, table, }) => {
|
1301
964
|
var _a, _b;
|
1302
|
-
const {
|
1303
|
-
const { density
|
1304
|
-
const
|
965
|
+
const { getState, options: { layoutMode, muiTableFooterCellProps }, } = table;
|
966
|
+
const { density } = getState();
|
967
|
+
const { column } = footer;
|
968
|
+
const { columnDef } = column;
|
969
|
+
const { columnDefType } = columnDef;
|
970
|
+
const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, {
|
971
|
+
column,
|
972
|
+
table,
|
973
|
+
}));
|
974
|
+
return (jsx(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-cell', fontWeight: 'bold', justifyContent: columnDefType === 'group' ? 'center' : undefined, p: density === 'compact'
|
975
|
+
? '0.5rem'
|
976
|
+
: density === 'comfortable'
|
977
|
+
? '1rem'
|
978
|
+
: '1.5rem', verticalAlign: 'top', zIndex: column.getIsPinned() && columnDefType !== 'group' ? 2 : 1 }, getCommonCellStyles({
|
979
|
+
column,
|
980
|
+
table,
|
981
|
+
tableCellProps,
|
982
|
+
theme,
|
983
|
+
}))), children: jsx(Fragment, { children: footer.isPlaceholder
|
984
|
+
? null
|
985
|
+
: (_b = (_a = parseFromValuesOrFunc(columnDef.Footer, { column, footer, table })) !== null && _a !== void 0 ? _a : columnDef.footer) !== null && _b !== void 0 ? _b : null }) })));
|
986
|
+
};
|
987
|
+
|
988
|
+
const MRT_TableFooterRow = ({ footerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
989
|
+
var _a;
|
990
|
+
const { options: { layoutMode, muiTableFooterRowProps }, } = table;
|
991
|
+
// if no content in row, skip row
|
992
|
+
if (!((_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
993
|
+
!!header.column.columnDef.footer) ||
|
994
|
+
header.column.columnDef.Footer)))
|
995
|
+
return null;
|
996
|
+
const tableRowProps = parseFromValuesOrFunc(muiTableFooterRowProps, {
|
997
|
+
footerGroup,
|
1305
998
|
table,
|
1306
999
|
});
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
} })) })) }) }));
|
1000
|
+
return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.04), display: layoutMode === 'grid' ? 'flex' : 'table-row', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter) => {
|
1001
|
+
const footer = virtualColumns
|
1002
|
+
? footerGroup.headers[footerOrVirtualFooter.index]
|
1003
|
+
: footerOrVirtualFooter;
|
1004
|
+
return (jsx(MRT_TableFooterCell, { footer: footer, table: table }, footer.id));
|
1005
|
+
}), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
|
1314
1006
|
};
|
1315
1007
|
|
1316
|
-
const
|
1317
|
-
|
1318
|
-
const {
|
1319
|
-
const
|
1320
|
-
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
1321
|
-
row,
|
1008
|
+
const MRT_TableFooter = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
1009
|
+
const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
1010
|
+
const { isFullScreen } = getState();
|
1011
|
+
const tableFooterProps = parseFromValuesOrFunc(muiTableFooterProps, {
|
1322
1012
|
table,
|
1323
1013
|
});
|
1324
|
-
const
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
transition: 'transform 150ms',
|
1337
|
-
} })) })) }) }));
|
1014
|
+
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
1015
|
+
return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
|
1016
|
+
tableFooterRef.current = ref;
|
1017
|
+
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
1018
|
+
// @ts-ignore
|
1019
|
+
tableFooterProps.ref.current = ref;
|
1020
|
+
}
|
1021
|
+
}, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
|
1022
|
+
? theme.palette.mode === 'light'
|
1023
|
+
? `1px solid ${theme.palette.grey[300]}`
|
1024
|
+
: `1px solid ${theme.palette.grey[700]}`
|
1025
|
+
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { footerGroup: footerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, footerGroup.id))) })));
|
1338
1026
|
};
|
1339
1027
|
|
1340
1028
|
const mrtFilterOptions = (localization) => [
|
1341
1029
|
{
|
1030
|
+
divider: false,
|
1031
|
+
label: localization.filterFuzzy,
|
1342
1032
|
option: 'fuzzy',
|
1343
1033
|
symbol: '≈',
|
1344
|
-
label: localization.filterFuzzy,
|
1345
|
-
divider: false,
|
1346
1034
|
},
|
1347
1035
|
{
|
1036
|
+
divider: false,
|
1037
|
+
label: localization.filterContains,
|
1348
1038
|
option: 'contains',
|
1349
1039
|
symbol: '*',
|
1350
|
-
label: localization.filterContains,
|
1351
|
-
divider: false,
|
1352
1040
|
},
|
1353
1041
|
{
|
1042
|
+
divider: false,
|
1043
|
+
label: localization.filterStartsWith,
|
1354
1044
|
option: 'startsWith',
|
1355
1045
|
symbol: 'a',
|
1356
|
-
label: localization.filterStartsWith,
|
1357
|
-
divider: false,
|
1358
1046
|
},
|
1359
1047
|
{
|
1048
|
+
divider: true,
|
1049
|
+
label: localization.filterEndsWith,
|
1360
1050
|
option: 'endsWith',
|
1361
1051
|
symbol: 'z',
|
1362
|
-
label: localization.filterEndsWith,
|
1363
|
-
divider: true,
|
1364
1052
|
},
|
1365
1053
|
{
|
1054
|
+
divider: false,
|
1055
|
+
label: localization.filterEquals,
|
1366
1056
|
option: 'equals',
|
1367
1057
|
symbol: '=',
|
1368
|
-
label: localization.filterEquals,
|
1369
|
-
divider: false,
|
1370
1058
|
},
|
1371
1059
|
{
|
1060
|
+
divider: true,
|
1061
|
+
label: localization.filterNotEquals,
|
1372
1062
|
option: 'notEquals',
|
1373
1063
|
symbol: '≠',
|
1374
|
-
label: localization.filterNotEquals,
|
1375
|
-
divider: true,
|
1376
1064
|
},
|
1377
1065
|
{
|
1066
|
+
divider: false,
|
1067
|
+
label: localization.filterBetween,
|
1378
1068
|
option: 'between',
|
1379
1069
|
symbol: '⇿',
|
1380
|
-
label: localization.filterBetween,
|
1381
|
-
divider: false,
|
1382
1070
|
},
|
1383
1071
|
{
|
1072
|
+
divider: true,
|
1073
|
+
label: localization.filterBetweenInclusive,
|
1384
1074
|
option: 'betweenInclusive',
|
1385
1075
|
symbol: '⬌',
|
1386
|
-
label: localization.filterBetweenInclusive,
|
1387
|
-
divider: true,
|
1388
1076
|
},
|
1389
1077
|
{
|
1078
|
+
divider: false,
|
1079
|
+
label: localization.filterGreaterThan,
|
1390
1080
|
option: 'greaterThan',
|
1391
1081
|
symbol: '>',
|
1392
|
-
label: localization.filterGreaterThan,
|
1393
|
-
divider: false,
|
1394
1082
|
},
|
1395
1083
|
{
|
1084
|
+
divider: false,
|
1085
|
+
label: localization.filterGreaterThanOrEqualTo,
|
1396
1086
|
option: 'greaterThanOrEqualTo',
|
1397
1087
|
symbol: '≥',
|
1398
|
-
label: localization.filterGreaterThanOrEqualTo,
|
1399
|
-
divider: false,
|
1400
1088
|
},
|
1401
1089
|
{
|
1090
|
+
divider: false,
|
1091
|
+
label: localization.filterLessThan,
|
1402
1092
|
option: 'lessThan',
|
1403
1093
|
symbol: '<',
|
1404
|
-
label: localization.filterLessThan,
|
1405
|
-
divider: false,
|
1406
1094
|
},
|
1407
1095
|
{
|
1096
|
+
divider: true,
|
1097
|
+
label: localization.filterLessThanOrEqualTo,
|
1408
1098
|
option: 'lessThanOrEqualTo',
|
1409
1099
|
symbol: '≤',
|
1410
|
-
label: localization.filterLessThanOrEqualTo,
|
1411
|
-
divider: true,
|
1412
1100
|
},
|
1413
1101
|
{
|
1102
|
+
divider: false,
|
1103
|
+
label: localization.filterEmpty,
|
1414
1104
|
option: 'empty',
|
1415
1105
|
symbol: '∅',
|
1416
|
-
label: localization.filterEmpty,
|
1417
|
-
divider: false,
|
1418
1106
|
},
|
1419
1107
|
{
|
1108
|
+
divider: false,
|
1109
|
+
label: localization.filterNotEmpty,
|
1420
1110
|
option: 'notEmpty',
|
1421
1111
|
symbol: '!∅',
|
1422
|
-
label: localization.filterNotEmpty,
|
1423
|
-
divider: false,
|
1424
1112
|
},
|
1425
1113
|
];
|
1426
1114
|
const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
|
@@ -1430,7 +1118,7 @@ const rangeVariants = ['range-slider', 'date-range', 'range'];
|
|
1430
1118
|
const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilterValue, table, }) => {
|
1431
1119
|
var _a, _b, _c, _d;
|
1432
1120
|
const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
|
1433
|
-
const {
|
1121
|
+
const { density, globalFilterFn } = getState();
|
1434
1122
|
const { column } = header !== null && header !== void 0 ? header : {};
|
1435
1123
|
const { columnDef } = column !== null && column !== void 0 ? column : {};
|
1436
1124
|
const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
|
@@ -1446,7 +1134,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
1446
1134
|
(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
|
1447
1135
|
: (!globalFilterModeOptions ||
|
1448
1136
|
globalFilterModeOptions.includes(filterOption.option)) &&
|
1449
|
-
['
|
1137
|
+
['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
|
1450
1138
|
const handleSelectFilterMode = (option) => {
|
1451
1139
|
var _a;
|
1452
1140
|
const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
|
@@ -1508,9 +1196,9 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
1508
1196
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
1509
1197
|
};
|
1510
1198
|
const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
|
1511
|
-
return (jsx(Menu, {
|
1199
|
+
return (jsx(Menu, { MenuListProps: {
|
1512
1200
|
dense: density === 'compact',
|
1513
|
-
}, children: (_d = (header && column && columnDef
|
1201
|
+
}, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, onClose: () => setAnchorEl(null), open: !!anchorEl, children: (_d = (header && column && columnDef
|
1514
1202
|
? (_c = (_b = columnDef.renderColumnFilterModeMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, {
|
1515
1203
|
column: column,
|
1516
1204
|
internalFilterOptions,
|
@@ -1526,7 +1214,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
1526
1214
|
internalFilterOptions,
|
1527
1215
|
onSelectFilterMode: handleSelectFilterMode,
|
1528
1216
|
table,
|
1529
|
-
}))) !== null && _d !== void 0 ? _d : internalFilterOptions.map(({
|
1217
|
+
}))) !== null && _d !== void 0 ? _d : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsxs(MenuItem, { divider: divider, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, sx: {
|
1530
1218
|
alignItems: 'center',
|
1531
1219
|
display: 'flex',
|
1532
1220
|
gap: '2ch',
|
@@ -1536,18 +1224,18 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
1536
1224
|
};
|
1537
1225
|
|
1538
1226
|
const commonMenuItemStyles = {
|
1539
|
-
py: '6px',
|
1540
|
-
my: 0,
|
1541
|
-
justifyContent: 'space-between',
|
1542
1227
|
alignItems: 'center',
|
1228
|
+
justifyContent: 'space-between',
|
1229
|
+
my: 0,
|
1230
|
+
py: '6px',
|
1543
1231
|
};
|
1544
1232
|
const commonListItemStyles = {
|
1545
|
-
display: 'flex',
|
1546
1233
|
alignItems: 'center',
|
1234
|
+
display: 'flex',
|
1547
1235
|
};
|
1548
1236
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
1549
1237
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
1550
|
-
const { getState,
|
1238
|
+
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;
|
1551
1239
|
const { column } = header;
|
1552
1240
|
const { columnDef } = column;
|
1553
1241
|
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
@@ -1612,7 +1300,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
1612
1300
|
? [
|
1613
1301
|
enableSortingRemoval !== false && (jsx(MenuItem, { disabled: !column.getIsSorted(), onClick: handleClearSort, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(ClearAllIcon, {}) }), localization.clearSort] }) }, 0)),
|
1614
1302
|
jsx(MenuItem, { disabled: column.getIsSorted() === 'asc', onClick: handleSortAsc, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }) }), (_b = localization.sortByColumnAsc) === null || _b === void 0 ? void 0 : _b.replace('{column}', String(columnDef.header))] }) }, 1),
|
1615
|
-
jsx(MenuItem, {
|
1303
|
+
jsx(MenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, onClick: handleSortDesc, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(SortIcon, {}) }), (_c = localization.sortByColumnDesc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header))] }) }, 2),
|
1616
1304
|
]
|
1617
1305
|
: []),
|
1618
1306
|
...(enableColumnFilters && column.getCanFilter()
|
@@ -1651,9 +1339,9 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
1651
1339
|
]
|
1652
1340
|
: []),
|
1653
1341
|
].filter(Boolean);
|
1654
|
-
return (jsx(Menu, {
|
1342
|
+
return (jsx(Menu, { MenuListProps: {
|
1655
1343
|
dense: density === 'compact',
|
1656
|
-
}, children: (_k = (_j = (_h = columnDef.renderColumnActionsMenuItems) === null || _h === void 0 ? void 0 : _h.call(columnDef, {
|
1344
|
+
}, anchorEl: anchorEl, onClose: () => setAnchorEl(null), open: !!anchorEl, children: (_k = (_j = (_h = columnDef.renderColumnActionsMenuItems) === null || _h === void 0 ? void 0 : _h.call(columnDef, {
|
1657
1345
|
closeMenu: () => setAnchorEl(null),
|
1658
1346
|
column,
|
1659
1347
|
internalColumnMenuItems,
|
@@ -1666,497 +1354,847 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
1666
1354
|
})) !== null && _k !== void 0 ? _k : internalColumnMenuItems }));
|
1667
1355
|
};
|
1668
1356
|
|
1669
|
-
const
|
1670
|
-
|
1671
|
-
const {
|
1672
|
-
|
1673
|
-
|
1674
|
-
}, children: [parseFromValuesOrFunc(enableEditing, row) && (jsx(MenuItem, { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
1675
|
-
row,
|
1676
|
-
table,
|
1677
|
-
closeMenu: () => setAnchorEl(null),
|
1678
|
-
})] }));
|
1679
|
-
};
|
1680
|
-
|
1681
|
-
const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
1682
|
-
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowSave, onEditingRowCancel, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
|
1683
|
-
const { creatingRow, editingRow, isSaving } = getState();
|
1684
|
-
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
1685
|
-
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
1686
|
-
const handleCancel = () => {
|
1687
|
-
if (isCreating) {
|
1688
|
-
onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
|
1689
|
-
setCreatingRow(null);
|
1690
|
-
}
|
1691
|
-
else if (isEditing) {
|
1692
|
-
onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
|
1693
|
-
setEditingRow(null);
|
1694
|
-
}
|
1695
|
-
row._valuesCache = {}; //reset values cache
|
1696
|
-
};
|
1697
|
-
const handleSubmitRow = () => {
|
1698
|
-
var _a;
|
1699
|
-
//look for auto-filled input values
|
1700
|
-
(_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)
|
1701
|
-
.filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
|
1702
|
-
if (input.value !== undefined &&
|
1703
|
-
Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
|
1704
|
-
// @ts-ignore
|
1705
|
-
row._valuesCache[input.name] = input.value;
|
1706
|
-
}
|
1707
|
-
});
|
1708
|
-
if (isCreating)
|
1709
|
-
onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
|
1710
|
-
exitCreatingMode: () => setCreatingRow(null),
|
1711
|
-
row,
|
1712
|
-
table,
|
1713
|
-
values: row._valuesCache,
|
1714
|
-
});
|
1715
|
-
else if (isEditing) {
|
1716
|
-
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
1717
|
-
exitEditingMode: () => setEditingRow(null),
|
1718
|
-
row,
|
1719
|
-
table,
|
1720
|
-
values: row === null || row === void 0 ? void 0 : row._valuesCache,
|
1721
|
-
});
|
1722
|
-
}
|
1723
|
-
};
|
1724
|
-
return (jsx(Box, { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' }, children: variant === 'icon' ? (jsxs(Fragment, { children: [jsx(Tooltip, { arrow: true, title: localization.cancel, children: jsx(IconButton, { "aria-label": localization.cancel, onClick: handleCancel, children: jsx(CancelIcon, {}) }) }), jsx(Tooltip, { arrow: true, title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsx(CircularProgress, { size: 18 }) : jsx(SaveIcon, {}) }) })] })) : (jsxs(Fragment, { children: [jsx(Button, { sx: { minWidth: '100px' }, onClick: handleCancel, children: localization.cancel }), jsxs(Button, { sx: { minWidth: '100px' }, onClick: handleSubmitRow, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
|
1725
|
-
};
|
1726
|
-
|
1727
|
-
const commonIconButtonStyles = {
|
1728
|
-
height: '2rem',
|
1729
|
-
ml: '10px',
|
1730
|
-
opacity: 0.5,
|
1731
|
-
transition: 'opacity 150ms',
|
1732
|
-
width: '2rem',
|
1733
|
-
'&:hover': {
|
1734
|
-
opacity: 1,
|
1735
|
-
},
|
1736
|
-
};
|
1737
|
-
const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
1738
|
-
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
1739
|
-
const { creatingRow, editingRow } = getState();
|
1740
|
-
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
1741
|
-
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
1742
|
-
const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
|
1743
|
-
(isEditing && editDisplayMode === 'row');
|
1357
|
+
const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
1358
|
+
var _a;
|
1359
|
+
const { options: { columnFilterDisplayMode, icons: { MoreVertIcon }, localization, muiColumnActionsButtonProps, }, } = table;
|
1360
|
+
const { column } = header;
|
1361
|
+
const { columnDef } = column;
|
1744
1362
|
const [anchorEl, setAnchorEl] = useState(null);
|
1745
|
-
const
|
1363
|
+
const handleClick = (event) => {
|
1746
1364
|
event.stopPropagation();
|
1747
1365
|
event.preventDefault();
|
1748
1366
|
setAnchorEl(event.currentTarget);
|
1749
1367
|
};
|
1750
|
-
const
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
}
|
1758
|
-
|
1759
|
-
|
1760
|
-
var _a;
|
1761
|
-
const { getState, options: { localization, enableMultiRowSelection, rowPinningDisplayMode, enableRowPinning, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
1762
|
-
const { density, isLoading } = getState();
|
1763
|
-
const checkboxProps = !row
|
1764
|
-
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
1765
|
-
: parseFromValuesOrFunc(muiSelectCheckboxProps, { row, table });
|
1766
|
-
const allRowsSelected = selectAll
|
1767
|
-
? selectAllMode === 'page'
|
1768
|
-
? table.getIsAllPageRowsSelected()
|
1769
|
-
: table.getIsAllRowsSelected()
|
1770
|
-
: undefined;
|
1771
|
-
const commonProps = Object.assign(Object.assign({ checked: selectAll ? allRowsSelected : row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading || (row && !row.getCanSelect()), inputProps: {
|
1772
|
-
'aria-label': selectAll
|
1773
|
-
? localization.toggleSelectAll
|
1774
|
-
: localization.toggleSelectRow,
|
1775
|
-
}, onChange: (event) => {
|
1776
|
-
event.stopPropagation();
|
1777
|
-
row
|
1778
|
-
? row.getToggleSelectedHandler()(event)
|
1779
|
-
: selectAllMode === 'all'
|
1780
|
-
? table.getToggleAllRowsSelectedHandler()(event)
|
1781
|
-
: table.getToggleAllPageRowsSelectedHandler()(event);
|
1782
|
-
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
|
1783
|
-
if (row) {
|
1784
|
-
row.pin(!row.getIsPinned() && event.target.checked
|
1785
|
-
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
1786
|
-
? 'bottom'
|
1787
|
-
: 'top'
|
1788
|
-
: false);
|
1789
|
-
}
|
1790
|
-
else {
|
1791
|
-
table.setRowPinning({ bottom: [], top: [] });
|
1792
|
-
}
|
1793
|
-
}
|
1794
|
-
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
1795
|
-
var _a;
|
1796
|
-
e.stopPropagation();
|
1797
|
-
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
1798
|
-
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
|
1799
|
-
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
1800
|
-
? localization.toggleSelectAll
|
1801
|
-
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: selectAll
|
1802
|
-
? table.getIsSomeRowsSelected() && !allRowsSelected
|
1803
|
-
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps))) }));
|
1368
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnActionsButtonProps, {
|
1369
|
+
column,
|
1370
|
+
table,
|
1371
|
+
})), parseFromValuesOrFunc(columnDef.muiColumnActionsButtonProps, {
|
1372
|
+
column,
|
1373
|
+
table,
|
1374
|
+
}));
|
1375
|
+
return (jsxs(Fragment, { children: [jsx(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, children: jsx(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ '&:hover': {
|
1376
|
+
opacity: 1,
|
1377
|
+
}, height: '2rem', m: '-8px -4px', opacity: 0.5, transform: `scale(0.85) ${columnFilterDisplayMode !== 'popover' ? 'translateX(-4px)' : ''}`, transition: 'opacity 150ms', width: '2rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: jsx(MoreVertIcon, {}) })) }), anchorEl && (jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
|
1804
1378
|
};
|
1805
1379
|
|
1806
|
-
const
|
1807
|
-
var _a, _b;
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
tableOptions.enableColumnOrdering,
|
1833
|
-
tableOptions.enableEditing,
|
1834
|
-
tableOptions.enableExpandAll,
|
1835
|
-
tableOptions.enableExpanding,
|
1836
|
-
tableOptions.enableGrouping,
|
1837
|
-
tableOptions.enableRowActions,
|
1838
|
-
tableOptions.enableRowDragging,
|
1839
|
-
tableOptions.enableRowNumbers,
|
1840
|
-
tableOptions.enableRowOrdering,
|
1841
|
-
tableOptions.enableRowSelection,
|
1842
|
-
tableOptions.enableSelectAll,
|
1843
|
-
tableOptions.localization,
|
1844
|
-
tableOptions.positionActionsColumn,
|
1845
|
-
tableOptions.renderDetailPanel,
|
1846
|
-
tableOptions.renderRowActionMenuItems,
|
1847
|
-
tableOptions.renderRowActions,
|
1848
|
-
(_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder,
|
1849
|
-
(_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.grouping,
|
1850
|
-
]);
|
1380
|
+
const MRT_FilterCheckbox = ({ column, table, }) => {
|
1381
|
+
var _a, _b, _c;
|
1382
|
+
const { getState, options: { localization, muiFilterCheckboxProps }, } = table;
|
1383
|
+
const { density } = getState();
|
1384
|
+
const { columnDef } = column;
|
1385
|
+
const checkboxProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterCheckboxProps, {
|
1386
|
+
column,
|
1387
|
+
table,
|
1388
|
+
})), parseFromValuesOrFunc(columnDef.muiFilterCheckboxProps, {
|
1389
|
+
column,
|
1390
|
+
table,
|
1391
|
+
}));
|
1392
|
+
const filterLabel = (_a = localization.filterByColumn) === null || _a === void 0 ? void 0 : _a.replace('{column}', columnDef.header);
|
1393
|
+
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : filterLabel, children: jsx(FormControlLabel, { control: jsx(Checkbox, Object.assign({ checked: column.getFilterValue() === 'true', color: column.getFilterValue() === undefined ? 'default' : 'primary', indeterminate: column.getFilterValue() === undefined, size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onChange: (e, checked) => {
|
1394
|
+
var _a;
|
1395
|
+
column.setFilterValue(column.getFilterValue() === undefined
|
1396
|
+
? 'true'
|
1397
|
+
: column.getFilterValue() === 'true'
|
1398
|
+
? 'false'
|
1399
|
+
: undefined);
|
1400
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
|
1401
|
+
}, onClick: (e) => {
|
1402
|
+
var _a;
|
1403
|
+
e.stopPropagation();
|
1404
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
1405
|
+
}, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))) })), disableTypography: true, label: (_c = checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, sx: { color: 'text.secondary', fontWeight: 'normal', mt: '-4px' }, title: undefined }) }));
|
1851
1406
|
};
|
1852
1407
|
|
1853
|
-
const
|
1854
|
-
|
1855
|
-
const {
|
1856
|
-
const
|
1857
|
-
const
|
1858
|
-
const
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1408
|
+
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
1409
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
1410
|
+
const { options: { columnFilterModeOptions, enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
1411
|
+
const { column } = header;
|
1412
|
+
const { columnDef } = column;
|
1413
|
+
const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTextFieldProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterTextFieldProps, {
|
1414
|
+
column,
|
1415
|
+
table,
|
1416
|
+
}));
|
1417
|
+
const isRangeFilter = columnDef.filterVariant === 'range' || rangeFilterIndex !== undefined;
|
1418
|
+
const isSelectFilter = columnDef.filterVariant === 'select';
|
1419
|
+
const isMultiSelectFilter = columnDef.filterVariant === 'multi-select';
|
1420
|
+
const isTextboxFilter = columnDef.filterVariant === 'text' ||
|
1421
|
+
(!isSelectFilter && !isMultiSelectFilter);
|
1422
|
+
const currentFilterOption = columnDef._filterFn;
|
1423
|
+
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
1424
|
+
? //@ts-ignore
|
1425
|
+
localization[`filter${((_b = (_a = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt) === null || _a === void 0 ? void 0 : _a.call(currentFilterOption, 0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
1426
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
1427
|
+
: '';
|
1428
|
+
const filterPlaceholder = !isRangeFilter
|
1429
|
+
? (_c = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.placeholder) !== null && _c !== void 0 ? _c : (_d = localization.filterByColumn) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))
|
1430
|
+
: rangeFilterIndex === 0
|
1431
|
+
? localization.min
|
1432
|
+
: rangeFilterIndex === 1
|
1433
|
+
? localization.max
|
1434
|
+
: '';
|
1435
|
+
const allowedColumnFilterOptions = (_e = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _e !== void 0 ? _e : columnFilterModeOptions;
|
1436
|
+
const showChangeModeButton = enableColumnFilterModes &&
|
1437
|
+
columnDef.enableColumnFilterModes !== false &&
|
1438
|
+
!rangeFilterIndex &&
|
1439
|
+
(allowedColumnFilterOptions === undefined ||
|
1440
|
+
!!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
|
1441
|
+
const facetedUniqueValues = column.getFacetedUniqueValues();
|
1442
|
+
const filterSelectOptions = useMemo(() => {
|
1443
|
+
var _a;
|
1444
|
+
return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter) && facetedUniqueValues
|
1445
|
+
? Array.from(facetedUniqueValues.keys())
|
1446
|
+
.filter((value) => value !== null && value !== undefined)
|
1447
|
+
.sort((a, b) => a.localeCompare(b))
|
1448
|
+
: undefined);
|
1449
|
+
}, [
|
1450
|
+
columnDef.filterSelectOptions,
|
1451
|
+
facetedUniqueValues,
|
1452
|
+
isMultiSelectFilter,
|
1453
|
+
isSelectFilter,
|
1454
|
+
]);
|
1455
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
1456
|
+
const [filterValue, setFilterValue] = useState(() => {
|
1457
|
+
var _a, _b;
|
1458
|
+
return isMultiSelectFilter
|
1459
|
+
? column.getFilterValue() || []
|
1460
|
+
: isRangeFilter
|
1461
|
+
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || []
|
1462
|
+
: (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
|
1463
|
+
});
|
1464
|
+
const handleChangeDebounced = useCallback(debounce((event) => {
|
1465
|
+
const value = textFieldProps.type === 'date'
|
1466
|
+
? event.target.valueAsDate
|
1467
|
+
: textFieldProps.type === 'number'
|
1468
|
+
? event.target.valueAsNumber
|
1469
|
+
: event.target.value;
|
1470
|
+
if (isRangeFilter) {
|
1471
|
+
column.setFilterValue((old) => {
|
1472
|
+
const newFilterValues = old !== null && old !== void 0 ? old : ['', ''];
|
1473
|
+
newFilterValues[rangeFilterIndex] = value;
|
1474
|
+
return newFilterValues;
|
1475
|
+
});
|
1862
1476
|
}
|
1863
|
-
|
1477
|
+
else {
|
1478
|
+
column.setFilterValue(value !== null && value !== void 0 ? value : undefined);
|
1479
|
+
}
|
1480
|
+
}, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
|
1481
|
+
const handleChange = (event) => {
|
1482
|
+
setFilterValue(event.target.value);
|
1483
|
+
handleChangeDebounced(event);
|
1484
|
+
};
|
1485
|
+
const handleClear = () => {
|
1486
|
+
if (isMultiSelectFilter) {
|
1487
|
+
setFilterValue([]);
|
1488
|
+
column.setFilterValue([]);
|
1489
|
+
}
|
1490
|
+
else if (isRangeFilter) {
|
1491
|
+
setFilterValue('');
|
1492
|
+
column.setFilterValue((old) => {
|
1493
|
+
const newFilterValues = (Array.isArray(old) && old) || ['', ''];
|
1494
|
+
newFilterValues[rangeFilterIndex] = undefined;
|
1495
|
+
return newFilterValues;
|
1496
|
+
});
|
1497
|
+
}
|
1498
|
+
else {
|
1499
|
+
setFilterValue('');
|
1500
|
+
column.setFilterValue(undefined);
|
1501
|
+
}
|
1502
|
+
};
|
1503
|
+
const handleClearEmptyFilterChip = () => {
|
1504
|
+
setFilterValue('');
|
1505
|
+
column.setFilterValue(undefined);
|
1506
|
+
setColumnFilterFns((prev) => {
|
1507
|
+
var _a;
|
1508
|
+
return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
|
1509
|
+
});
|
1510
|
+
};
|
1511
|
+
const handleFilterMenuOpen = (event) => {
|
1512
|
+
setAnchorEl(event.currentTarget);
|
1513
|
+
};
|
1514
|
+
const isMounted = useRef(false);
|
1864
1515
|
useEffect(() => {
|
1865
|
-
if (isMounted
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1516
|
+
if (isMounted.current) {
|
1517
|
+
const filterValue = column.getFilterValue();
|
1518
|
+
if (filterValue === undefined) {
|
1519
|
+
handleClear();
|
1520
|
+
}
|
1521
|
+
else if (isRangeFilter && rangeFilterIndex !== undefined) {
|
1522
|
+
setFilterValue(filterValue[rangeFilterIndex]);
|
1869
1523
|
}
|
1870
1524
|
else {
|
1871
|
-
|
1872
|
-
if (!previousTop.current)
|
1873
|
-
return;
|
1874
|
-
//restore scroll position
|
1875
|
-
window.scrollTo({
|
1876
|
-
top: -1 * previousTop.current,
|
1877
|
-
behavior: 'instant',
|
1878
|
-
});
|
1525
|
+
setFilterValue(filterValue);
|
1879
1526
|
}
|
1880
1527
|
}
|
1881
1528
|
isMounted.current = true;
|
1882
|
-
}, [
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1529
|
+
}, [column.getFilterValue()]);
|
1530
|
+
if (columnDef.Filter) {
|
1531
|
+
return (jsx(Fragment, { children: (_f = columnDef.Filter) === null || _f === void 0 ? void 0 : _f.call(columnDef, { column, header, rangeFilterIndex, table }) }));
|
1532
|
+
}
|
1533
|
+
return (jsxs(Fragment, { children: [jsxs(TextField, Object.assign({ FormHelperTextProps: {
|
1534
|
+
sx: {
|
1535
|
+
fontSize: '0.75rem',
|
1536
|
+
lineHeight: '0.8rem',
|
1537
|
+
whiteSpace: 'nowrap',
|
1538
|
+
},
|
1539
|
+
}, InputProps: {
|
1540
|
+
endAdornment: !filterChipLabel && (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { arrow: true, placement: "right", title: (_g = localization.clearFilter) !== null && _g !== void 0 ? _g : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearFilter, disabled: !((_h = filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString()) === null || _h === void 0 ? void 0 : _h.length), onClick: handleClear, size: "small", sx: {
|
1541
|
+
height: '1.75rem',
|
1542
|
+
width: '1.75rem',
|
1543
|
+
}, children: jsx(CloseIcon, {}) }) }) }) })),
|
1544
|
+
startAdornment: showChangeModeButton ? (jsxs(InputAdornment, { position: "start", children: [jsx(Tooltip, { arrow: true, title: localization.changeFilterMode, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.changeFilterMode, onClick: handleFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(FilterListIcon, {}) }) }) }), filterChipLabel && (jsx(Chip, { label: filterChipLabel, onDelete: handleClearEmptyFilterChip }))] })) : null,
|
1545
|
+
}, SelectProps: {
|
1546
|
+
displayEmpty: true,
|
1547
|
+
multiple: isMultiSelectFilter,
|
1548
|
+
renderValue: isMultiSelectFilter
|
1549
|
+
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
|
1550
|
+
const selectedValue = filterSelectOptions === null || filterSelectOptions === void 0 ? void 0 : filterSelectOptions.find((option) => option instanceof Object
|
1551
|
+
? option.value === value
|
1552
|
+
: option === value);
|
1553
|
+
return (jsx(Chip, { label: selectedValue instanceof Object
|
1554
|
+
? selectedValue.text
|
1555
|
+
: selectedValue }, value));
|
1556
|
+
}) }))
|
1557
|
+
: undefined,
|
1558
|
+
}, fullWidth: true, helperText: showChangeModeButton ? (jsx("label", { children: localization.filterMode.replace('{filterType}',
|
1559
|
+
// @ts-ignore
|
1560
|
+
localization[`filter${((_j = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _j === void 0 ? void 0 : _j.toUpperCase()) +
|
1561
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputProps: {
|
1562
|
+
disabled: !!filterChipLabel,
|
1563
|
+
sx: {
|
1564
|
+
textOverflow: 'ellipsis',
|
1565
|
+
width: filterChipLabel ? 0 : undefined,
|
1566
|
+
},
|
1567
|
+
title: filterPlaceholder,
|
1568
|
+
}, margin: "none", onChange: handleChange, onClick: (e) => e.stopPropagation(), placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
1569
|
+
? undefined
|
1570
|
+
: filterPlaceholder, select: isSelectFilter || isMultiSelectFilter, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
|
1571
|
+
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
1572
|
+
inputRef;
|
1573
|
+
if (textFieldProps.inputRef) {
|
1574
|
+
textFieldProps.inputRef = inputRef;
|
1575
|
+
}
|
1576
|
+
}, sx: (theme) => (Object.assign({ '& .MuiSelect-icon': {
|
1577
|
+
mr: '1.5rem',
|
1578
|
+
}, minWidth: isRangeFilter
|
1579
|
+
? '100px'
|
1580
|
+
: !filterChipLabel
|
1581
|
+
? '120px'
|
1582
|
+
: 'auto', mx: '-2px', p: 0, width: 'calc(100% + 4px)' }, parseFromValuesOrFunc(textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx, theme))), children: [(isSelectFilter || isMultiSelectFilter) && (jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) })), (_k = textFieldProps.children) !== null && _k !== void 0 ? _k : filterSelectOptions === null || filterSelectOptions === void 0 ? void 0 : filterSelectOptions.map((option) => {
|
1583
|
+
var _a;
|
1584
|
+
if (!option)
|
1585
|
+
return '';
|
1586
|
+
let value;
|
1587
|
+
let text;
|
1588
|
+
if (typeof option !== 'object') {
|
1589
|
+
value = option;
|
1590
|
+
text = option;
|
1591
|
+
}
|
1592
|
+
else {
|
1593
|
+
value = option.value;
|
1594
|
+
text = option.text;
|
1595
|
+
}
|
1596
|
+
return (jsxs(MenuItem, { sx: {
|
1597
|
+
alignItems: 'center',
|
1598
|
+
display: 'flex',
|
1599
|
+
gap: '0.5rem',
|
1600
|
+
m: 0,
|
1601
|
+
}, value: value, children: [isMultiSelectFilter && (jsx(Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), text, ' ', !columnDef.filterSelectOptions &&
|
1602
|
+
`(${facetedUniqueValues.get(value)})`] }, value));
|
1603
|
+
})] })), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, setFilterValue: setFilterValue, table: table })] }));
|
1604
|
+
};
|
1605
|
+
|
1606
|
+
const MRT_FilterRangeFields = ({ header, table, }) => {
|
1607
|
+
return (jsxs(Box, { sx: { display: 'grid', gap: '1rem', gridTemplateColumns: '1fr 1fr' }, children: [jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: 0, table: table }), jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: 1, table: table })] }));
|
1608
|
+
};
|
1609
|
+
|
1610
|
+
const MRT_FilterRangeSlider = ({ header, table, }) => {
|
1611
|
+
var _a, _b;
|
1612
|
+
const { options: { enableColumnFilterModes, localization, muiFilterSliderProps }, refs: { filterInputRefs }, } = table;
|
1613
|
+
const { column } = header;
|
1614
|
+
const { columnDef } = column;
|
1615
|
+
const currentFilterOption = columnDef._filterFn;
|
1616
|
+
const showChangeModeButton = enableColumnFilterModes && columnDef.enableColumnFilterModes !== false;
|
1617
|
+
const sliderProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterSliderProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterSliderProps, { column, table }));
|
1618
|
+
let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
|
1619
|
+
? [sliderProps.min, sliderProps.max]
|
1620
|
+
: (_a = column.getFacetedMinMaxValues()) !== null && _a !== void 0 ? _a : [0, 1];
|
1621
|
+
//fix potential TanStack Table bugs where min or max is an array
|
1622
|
+
if (Array.isArray(min))
|
1623
|
+
min = min[0];
|
1624
|
+
if (Array.isArray(max))
|
1625
|
+
max = max[0];
|
1626
|
+
if (min === null)
|
1627
|
+
min = 0;
|
1628
|
+
if (max === null)
|
1629
|
+
max = 1;
|
1630
|
+
const [filterValues, setFilterValues] = useState([min, max]);
|
1631
|
+
const columnFilterValue = column.getFilterValue();
|
1632
|
+
const isMounted = useRef(false);
|
1896
1633
|
useEffect(() => {
|
1897
|
-
if (
|
1898
|
-
|
1634
|
+
if (isMounted.current) {
|
1635
|
+
if (columnFilterValue === undefined) {
|
1636
|
+
setFilterValues([min, max]);
|
1637
|
+
}
|
1638
|
+
else if (Array.isArray(columnFilterValue)) {
|
1639
|
+
setFilterValues(columnFilterValue);
|
1640
|
+
}
|
1899
1641
|
}
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1642
|
+
isMounted.current = true;
|
1643
|
+
}, [columnFilterValue, min, max]);
|
1644
|
+
return (jsxs(Stack, { children: [jsx(Slider, Object.assign({ disableSwap: true, max: max, min: min, onChange: (_event, values) => {
|
1645
|
+
setFilterValues(values);
|
1646
|
+
}, onChangeCommitted: (_event, value) => {
|
1647
|
+
if (Array.isArray(value)) {
|
1648
|
+
if (value[0] <= min && value[1] >= max) {
|
1649
|
+
//if the user has selected the entire range, remove the filter
|
1650
|
+
column.setFilterValue(undefined);
|
1651
|
+
}
|
1652
|
+
else {
|
1653
|
+
column.setFilterValue(value);
|
1654
|
+
}
|
1655
|
+
}
|
1656
|
+
}, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
|
1657
|
+
input: {
|
1658
|
+
ref: (node) => {
|
1659
|
+
var _a, _b;
|
1660
|
+
if (node) {
|
1661
|
+
filterInputRefs.current[`${column.id}-0`] = node;
|
1662
|
+
// @ts-ignore
|
1663
|
+
if ((_b = (_a = sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.slotProps) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.ref) {
|
1664
|
+
//@ts-ignore
|
1665
|
+
sliderProps.slotProps.input.ref = node;
|
1666
|
+
}
|
1667
|
+
}
|
1668
|
+
},
|
1669
|
+
},
|
1670
|
+
}, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsx(FormHelperText, { sx: {
|
1671
|
+
fontSize: '0.75rem',
|
1672
|
+
lineHeight: '0.8rem',
|
1673
|
+
m: '-3px -6px',
|
1674
|
+
whiteSpace: 'nowrap',
|
1675
|
+
}, children: localization.filterMode.replace('{filterType}',
|
1676
|
+
// @ts-ignore
|
1677
|
+
localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
1678
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
|
1679
|
+
};
|
1680
|
+
|
1681
|
+
const MRT_TableHeadCellFilterContainer = ({ header, table, }) => {
|
1682
|
+
const { getState, options: { columnFilterDisplayMode }, } = table;
|
1683
|
+
const { showColumnFilters } = getState();
|
1684
|
+
const { column } = header;
|
1685
|
+
const { columnDef } = column;
|
1686
|
+
return (jsx(Collapse, { in: showColumnFilters || columnFilterDisplayMode === 'popover', mountOnEnter: true, unmountOnExit: true, children: columnDef.filterVariant === 'checkbox' ? (jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsx(MRT_FilterRangeSlider, { header: header, table: table })) : columnDef.filterVariant === 'range' ||
|
1687
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn) ? (jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsx(MRT_FilterTextField, { header: header, table: table })) }));
|
1688
|
+
};
|
1689
|
+
|
1690
|
+
const MRT_TableHeadCellFilterLabel = ({ header, table, }) => {
|
1691
|
+
var _a, _b, _c, _d;
|
1692
|
+
const { options: { columnFilterDisplayMode, icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
|
1693
|
+
const { column } = header;
|
1694
|
+
const { columnDef } = column;
|
1695
|
+
const filterValue = column.getFilterValue();
|
1696
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
1697
|
+
const isFilterActive = (Array.isArray(filterValue) && filterValue.some(Boolean)) ||
|
1698
|
+
(!!filterValue && !Array.isArray(filterValue));
|
1699
|
+
const isRangeFilter = columnDef.filterVariant === 'range' ||
|
1700
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
|
1701
|
+
const currentFilterOption = columnDef._filterFn;
|
1702
|
+
const filterTooltip = columnFilterDisplayMode === 'popover' && !isFilterActive
|
1703
|
+
? (_a = localization.filterByColumn) === null || _a === void 0 ? void 0 : _a.replace('{column}', String(columnDef.header))
|
1704
|
+
: localization.filteringByColumn
|
1705
|
+
.replace('{column}', String(columnDef.header))
|
1706
|
+
.replace('{filterType}', currentFilterOption
|
1707
|
+
? // @ts-ignore
|
1708
|
+
localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
1709
|
+
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
1710
|
+
: '')
|
1711
|
+
.replace('{filterValue}', `"${Array.isArray(column.getFilterValue())
|
1712
|
+
? column.getFilterValue().join(`" ${isRangeFilter ? localization.and : localization.or} "`)
|
1713
|
+
: column.getFilterValue()}"`)
|
1714
|
+
.replace('" "', '');
|
1715
|
+
return (jsxs(Fragment, { children: [jsx(Grow, { in: columnFilterDisplayMode === 'popover' ||
|
1716
|
+
(!!column.getFilterValue() && !isRangeFilter) ||
|
1717
|
+
(isRangeFilter && // @ts-ignore
|
1718
|
+
(!!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[0]) || !!((_d = column.getFilterValue()) === null || _d === void 0 ? void 0 : _d[1]))), unmountOnExit: true, children: jsx(Box, { component: "span", sx: { flex: '0 0' }, children: jsx(Tooltip, { arrow: true, placement: "top", title: filterTooltip, children: jsx(IconButton, { disableRipple: true, onClick: (event) => {
|
1719
|
+
if (columnFilterDisplayMode === 'popover') {
|
1720
|
+
setAnchorEl(event.currentTarget);
|
1721
|
+
}
|
1722
|
+
else {
|
1723
|
+
setShowColumnFilters(true);
|
1724
|
+
}
|
1725
|
+
queueMicrotask(() => {
|
1726
|
+
var _a, _b;
|
1727
|
+
(_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus();
|
1728
|
+
(_b = filterInputRefs.current[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.select();
|
1729
|
+
});
|
1730
|
+
event.stopPropagation();
|
1731
|
+
}, sx: {
|
1732
|
+
height: '16px',
|
1733
|
+
opacity: 0.8,
|
1734
|
+
p: '8px',
|
1735
|
+
transform: 'scale(0.75)',
|
1736
|
+
width: '16px',
|
1737
|
+
}, children: jsx(FilterAltIcon, {}) }) }) }) }), jsx(Popover, { anchorEl: anchorEl, anchorOrigin: {
|
1738
|
+
horizontal: 'center',
|
1739
|
+
vertical: 'top',
|
1740
|
+
}, onClose: (event) => {
|
1741
|
+
//@ts-ignore
|
1742
|
+
event.stopPropagation();
|
1743
|
+
setAnchorEl(null);
|
1744
|
+
}, open: !!anchorEl, transformOrigin: {
|
1745
|
+
horizontal: 'center',
|
1746
|
+
vertical: 'bottom',
|
1747
|
+
}, children: jsx(Box, { sx: { p: '1rem' }, children: jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }) })] }));
|
1748
|
+
};
|
1749
|
+
|
1750
|
+
const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
1751
|
+
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
1752
|
+
const { columnDef } = column;
|
1753
|
+
const { columnOrder, draggingColumn, hoveredColumn } = getState();
|
1754
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
|
1755
|
+
column,
|
1756
|
+
table,
|
1757
|
+
}));
|
1758
|
+
const handleDragStart = (event) => {
|
1759
|
+
var _a;
|
1760
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
1761
|
+
setDraggingColumn(column);
|
1762
|
+
event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
1763
|
+
};
|
1764
|
+
const handleDragEnd = (event) => {
|
1765
|
+
var _a;
|
1766
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
1767
|
+
if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
1768
|
+
column.toggleGrouping();
|
1906
1769
|
}
|
1907
|
-
else
|
1908
|
-
|
1770
|
+
else if (enableColumnOrdering &&
|
1771
|
+
hoveredColumn &&
|
1772
|
+
(hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
|
1773
|
+
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
1909
1774
|
}
|
1910
|
-
|
1775
|
+
setDraggingColumn(null);
|
1776
|
+
setHoveredColumn(null);
|
1777
|
+
};
|
1778
|
+
return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
|
1911
1779
|
};
|
1912
1780
|
|
1913
|
-
const
|
1914
|
-
var _a
|
1915
|
-
const
|
1916
|
-
const
|
1917
|
-
const
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
:
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
const
|
1950
|
-
const
|
1951
|
-
const
|
1952
|
-
const
|
1953
|
-
const
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
const
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
:
|
2014
|
-
|
2015
|
-
:
|
2016
|
-
//@ts-ignore
|
2017
|
-
columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ creatingRow,
|
2018
|
-
columnFilterFns,
|
2019
|
-
columnOrder,
|
2020
|
-
density,
|
2021
|
-
draggingColumn,
|
2022
|
-
draggingRow,
|
2023
|
-
editingCell,
|
2024
|
-
editingRow,
|
2025
|
-
globalFilterFn,
|
2026
|
-
grouping,
|
2027
|
-
hoveredColumn,
|
2028
|
-
hoveredRow,
|
2029
|
-
isFullScreen,
|
2030
|
-
showAlertBanner,
|
2031
|
-
showColumnFilters,
|
2032
|
-
showGlobalFilter,
|
2033
|
-
showToolbarDropZone }, tableOptions.state) }));
|
2034
|
-
// @ts-ignore
|
2035
|
-
table.refs = {
|
2036
|
-
// @ts-ignore
|
2037
|
-
bottomToolbarRef,
|
2038
|
-
editInputRefs,
|
2039
|
-
filterInputRefs,
|
2040
|
-
// @ts-ignore
|
2041
|
-
searchInputRef,
|
2042
|
-
// @ts-ignore
|
2043
|
-
tableContainerRef,
|
2044
|
-
tableHeadCellRefs,
|
2045
|
-
// @ts-ignore
|
2046
|
-
tablePaperRef,
|
2047
|
-
// @ts-ignore
|
2048
|
-
topToolbarRef,
|
2049
|
-
// @ts-ignore
|
2050
|
-
tableFooterRef,
|
2051
|
-
// @ts-ignore
|
2052
|
-
tableHeadRef,
|
2053
|
-
};
|
2054
|
-
const setCreatingRow = (row) => {
|
2055
|
-
if (row === true) {
|
2056
|
-
table.setCreatingRow(createRow(table));
|
1781
|
+
const MRT_TableHeadCellResizeHandle = ({ header, table, }) => {
|
1782
|
+
var _a;
|
1783
|
+
const { getState, options: { columnResizeMode }, setColumnSizingInfo, } = table;
|
1784
|
+
const { density } = getState();
|
1785
|
+
const { column } = header;
|
1786
|
+
return (jsx(Box, { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
|
1787
|
+
setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
|
1788
|
+
column.resetSize();
|
1789
|
+
}, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), style: {
|
1790
|
+
transform: column.getIsResizing() && columnResizeMode === 'onEnd'
|
1791
|
+
? `translateX(${(_a = getState().columnSizingInfo.deltaOffset) !== null && _a !== void 0 ? _a : 0}px)`
|
1792
|
+
: undefined,
|
1793
|
+
}, sx: (theme) => ({
|
1794
|
+
'&:active > hr': {
|
1795
|
+
backgroundColor: theme.palette.info.main,
|
1796
|
+
opacity: 1,
|
1797
|
+
},
|
1798
|
+
cursor: 'col-resize',
|
1799
|
+
mr: density === 'compact' ? '-0.75rem' : '-1rem',
|
1800
|
+
position: 'absolute',
|
1801
|
+
px: '4px',
|
1802
|
+
right: '4px',
|
1803
|
+
}), children: jsx(Divider, { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: {
|
1804
|
+
borderRadius: '2px',
|
1805
|
+
borderWidth: '2px',
|
1806
|
+
height: '24px',
|
1807
|
+
touchAction: 'none',
|
1808
|
+
transition: column.getIsResizing()
|
1809
|
+
? undefined
|
1810
|
+
: 'all 150ms ease-in-out',
|
1811
|
+
userSelect: 'none',
|
1812
|
+
zIndex: 4,
|
1813
|
+
} }) }));
|
1814
|
+
};
|
1815
|
+
|
1816
|
+
const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
|
1817
|
+
const { getState, options: { icons: { ArrowDownwardIcon }, localization, }, } = table;
|
1818
|
+
const { column } = header;
|
1819
|
+
const { columnDef } = column;
|
1820
|
+
const { sorting } = getState();
|
1821
|
+
const sortTooltip = column.getIsSorted()
|
1822
|
+
? column.getIsSorted() === 'desc'
|
1823
|
+
? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
|
1824
|
+
: localization.sortedByColumnAsc.replace('{column}', columnDef.header)
|
1825
|
+
: column.getNextSortingOrder() === 'desc'
|
1826
|
+
? localization.sortByColumnDesc.replace('{column}', columnDef.header)
|
1827
|
+
: localization.sortByColumnAsc.replace('{column}', columnDef.header);
|
1828
|
+
return (jsx(Tooltip, { arrow: true, placement: "top", title: sortTooltip, children: jsx(Badge, { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular", children: jsx(TableSortLabel, { IconComponent: ArrowDownwardIcon, active: !!column.getIsSorted(), "aria-label": sortTooltip, direction: column.getIsSorted()
|
1829
|
+
? column.getIsSorted()
|
1830
|
+
: undefined, onClick: (e) => {
|
1831
|
+
var _a;
|
1832
|
+
e.stopPropagation();
|
1833
|
+
(_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
|
1834
|
+
}, sx: {
|
1835
|
+
flex: '0 0',
|
1836
|
+
transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
|
1837
|
+
? 'translateX(-0.5ch)'
|
1838
|
+
: undefined,
|
1839
|
+
width: '2.4ch',
|
1840
|
+
} }) }) }));
|
1841
|
+
};
|
1842
|
+
|
1843
|
+
const MRT_TableHeadCell = ({ header, table, }) => {
|
1844
|
+
var _a, _b, _c, _d, _f;
|
1845
|
+
const theme = useTheme();
|
1846
|
+
const { getState, options: { columnFilterDisplayMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, layoutMode, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
1847
|
+
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
1848
|
+
const { column } = header;
|
1849
|
+
const { columnDef } = column;
|
1850
|
+
const { columnDefType } = columnDef;
|
1851
|
+
const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
|
1852
|
+
column,
|
1853
|
+
table,
|
1854
|
+
}));
|
1855
|
+
const showColumnActions = (enableColumnActions || columnDef.enableColumnActions) &&
|
1856
|
+
columnDef.enableColumnActions !== false;
|
1857
|
+
const showDragHandle = enableColumnDragging !== false &&
|
1858
|
+
columnDef.enableColumnDragging !== false &&
|
1859
|
+
(enableColumnDragging ||
|
1860
|
+
(enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
|
1861
|
+
(enableGrouping &&
|
1862
|
+
columnDef.enableGrouping !== false &&
|
1863
|
+
!grouping.includes(column.id)));
|
1864
|
+
const headerPL = useMemo(() => {
|
1865
|
+
let pl = 0;
|
1866
|
+
if (column.getCanSort())
|
1867
|
+
pl++;
|
1868
|
+
if (showColumnActions)
|
1869
|
+
pl += 1.75;
|
1870
|
+
if (showDragHandle)
|
1871
|
+
pl += 1.25;
|
1872
|
+
return pl;
|
1873
|
+
}, [showColumnActions, showDragHandle]);
|
1874
|
+
const draggingBorder = useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
1875
|
+
? `1px dashed ${theme.palette.text.secondary}`
|
1876
|
+
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
1877
|
+
? `2px dashed ${theme.palette.primary.main}`
|
1878
|
+
: undefined, [draggingColumn, hoveredColumn]);
|
1879
|
+
const draggingBorders = draggingBorder
|
1880
|
+
? {
|
1881
|
+
borderLeft: draggingBorder,
|
1882
|
+
borderRight: draggingBorder,
|
1883
|
+
borderTop: draggingBorder,
|
2057
1884
|
}
|
2058
|
-
|
2059
|
-
|
1885
|
+
: undefined;
|
1886
|
+
const handleDragEnter = (_e) => {
|
1887
|
+
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
1888
|
+
setHoveredColumn(null);
|
1889
|
+
}
|
1890
|
+
if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
|
1891
|
+
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
2060
1892
|
}
|
2061
1893
|
};
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
1894
|
+
const headerElement = (_a = parseFromValuesOrFunc(columnDef.Header, {
|
1895
|
+
column,
|
1896
|
+
header,
|
1897
|
+
table,
|
1898
|
+
})) !== null && _a !== void 0 ? _a : columnDef.header;
|
1899
|
+
return (jsxs(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
|
1900
|
+
if (node) {
|
1901
|
+
tableHeadCellRefs.current[column.id] = node;
|
1902
|
+
}
|
1903
|
+
} }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: layoutMode === 'grid' ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
|
1904
|
+
? '0.5rem'
|
1905
|
+
: density === 'comfortable'
|
1906
|
+
? columnDefType === 'display'
|
1907
|
+
? '0.75rem'
|
1908
|
+
: '1rem'
|
1909
|
+
: columnDefType === 'display'
|
1910
|
+
? '1rem 1.25rem'
|
1911
|
+
: '1.5rem', pb: columnDefType === 'display'
|
1912
|
+
? 0
|
1913
|
+
: showColumnFilters || density === 'compact'
|
1914
|
+
? '0.4rem'
|
1915
|
+
: '0.6rem', pt: columnDefType === 'group' || density === 'compact'
|
1916
|
+
? '0.25rem'
|
1917
|
+
: density === 'comfortable'
|
1918
|
+
? '.75rem'
|
1919
|
+
: '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
1920
|
+
? 3
|
1921
|
+
: column.getIsPinned() && columnDefType !== 'group'
|
1922
|
+
? 2
|
1923
|
+
: 1 }, getCommonCellStyles({
|
1924
|
+
column,
|
1925
|
+
header,
|
1926
|
+
table,
|
1927
|
+
tableCellProps,
|
1928
|
+
theme,
|
1929
|
+
})), draggingBorders)), children: [header.isPlaceholder ? null : (jsxs(Box, { className: "Mui-TableHeadCell-Content", sx: {
|
1930
|
+
alignItems: 'center',
|
1931
|
+
display: 'flex',
|
1932
|
+
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
1933
|
+
justifyContent: columnDefType === 'group' || (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
1934
|
+
? 'center'
|
1935
|
+
: column.getCanResize()
|
1936
|
+
? 'space-between'
|
1937
|
+
: 'flex-start',
|
1938
|
+
position: 'relative',
|
1939
|
+
width: '100%',
|
1940
|
+
}, children: [jsxs(Box, { className: "Mui-TableHeadCell-Content-Labels", onClick: column.getToggleSortingHandler(), sx: {
|
1941
|
+
alignItems: 'center',
|
1942
|
+
cursor: column.getCanSort() && columnDefType !== 'group'
|
1943
|
+
? 'pointer'
|
1944
|
+
: undefined,
|
1945
|
+
display: 'flex',
|
1946
|
+
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
1947
|
+
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
1948
|
+
pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
1949
|
+
? `${headerPL}rem`
|
1950
|
+
: undefined,
|
1951
|
+
}, children: [jsx(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
1952
|
+
'&:hover': {
|
1953
|
+
textOverflow: 'clip',
|
1954
|
+
},
|
1955
|
+
minWidth: `${Math.min((_c = (_b = columnDef.header) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0, 5)}ch`,
|
1956
|
+
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
1957
|
+
textOverflow: 'ellipsis',
|
1958
|
+
whiteSpace: ((_f = (_d = columnDef.header) === null || _d === void 0 ? void 0 : _d.length) !== null && _f !== void 0 ? _f : 0) < 20 ? 'nowrap' : 'normal',
|
1959
|
+
}, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: { whiteSpace: 'nowrap' }, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
1960
|
+
current: tableHeadCellRefs.current[column.id],
|
1961
|
+
} })), showColumnActions && (jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] })), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
|
1962
|
+
};
|
1963
|
+
|
1964
|
+
const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
1965
|
+
const { options: { layoutMode, muiTableHeadRowProps }, } = table;
|
1966
|
+
const tableRowProps = parseFromValuesOrFunc(muiTableHeadRowProps, {
|
1967
|
+
headerGroup,
|
1968
|
+
table,
|
1969
|
+
});
|
1970
|
+
return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.04), boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', top: 0 }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
|
1971
|
+
const header = virtualColumns
|
1972
|
+
? headerGroup.headers[headerOrVirtualHeader.index]
|
1973
|
+
: headerOrVirtualHeader;
|
1974
|
+
return (jsx(MRT_TableHeadCell, { header: header, table: table }, header.id));
|
1975
|
+
}), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
|
2087
1976
|
};
|
2088
1977
|
|
2089
|
-
const
|
2090
|
-
const
|
2091
|
-
const
|
2092
|
-
|
1978
|
+
const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
|
1979
|
+
const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, refs: { tableHeadRef }, } = table;
|
1980
|
+
const { isFullScreen } = getState();
|
1981
|
+
const tableHeadProps = parseFromValuesOrFunc(muiTableHeadProps, { table });
|
1982
|
+
const stickyHeader = enableStickyHeader || isFullScreen;
|
1983
|
+
return (jsx(TableHead, Object.assign({}, tableHeadProps, { ref: (ref) => {
|
1984
|
+
tableHeadRef.current = ref;
|
1985
|
+
if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
|
1986
|
+
// @ts-ignore
|
1987
|
+
tableHeadProps.ref.current = ref;
|
1988
|
+
}
|
1989
|
+
}, sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, parseFromValuesOrFunc(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx, theme))), children: getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { headerGroup: headerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, headerGroup.id))) })));
|
2093
1990
|
};
|
2094
1991
|
|
2095
|
-
const
|
2096
|
-
var _a;
|
2097
|
-
const {
|
2098
|
-
const {
|
2099
|
-
const
|
1992
|
+
const MRT_Table = ({ table, }) => {
|
1993
|
+
var _a, _b, _c, _d;
|
1994
|
+
const { getFlatHeaders, getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, columns, enableColumnPinning, enableColumnResizing, enableColumnVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
|
1995
|
+
const { columnPinning, columnSizing, columnSizingInfo, columnVisibility, isFullScreen, } = getState();
|
1996
|
+
const tableProps = parseFromValuesOrFunc(muiTableProps, { table });
|
1997
|
+
const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, { table });
|
1998
|
+
const columnSizeVars = useMemo(() => {
|
1999
|
+
const headers = getFlatHeaders();
|
2000
|
+
const colSizes = {};
|
2001
|
+
for (let i = 0; i < headers.length; i++) {
|
2002
|
+
const header = headers[i];
|
2003
|
+
const colSize = header.getSize();
|
2004
|
+
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
2005
|
+
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
2006
|
+
}
|
2007
|
+
return colSizes;
|
2008
|
+
}, [columns, columnSizing, columnSizingInfo, columnVisibility]);
|
2009
|
+
//get first 16 column widths and average them
|
2010
|
+
const averageColumnWidth = useMemo(() => {
|
2011
|
+
var _a, _b, _c, _d;
|
2012
|
+
if (!enableColumnVirtualization)
|
2013
|
+
return 0;
|
2014
|
+
const columnsWidths = (_d = (_c = (_b = (_a = table
|
2015
|
+
.getRowModel()
|
2016
|
+
.rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
|
2017
|
+
return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
|
2018
|
+
}, [table.getRowModel().rows, columnPinning, columnVisibility]);
|
2019
|
+
const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnVirtualization && enableColumnPinning
|
2020
|
+
? [
|
2021
|
+
table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
|
2022
|
+
table
|
2023
|
+
.getRightLeafColumns()
|
2024
|
+
.map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
|
2025
|
+
]
|
2026
|
+
: [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
|
2027
|
+
const columnVirtualizer = enableColumnVirtualization
|
2028
|
+
? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => [
|
2029
|
+
...new Set([
|
2030
|
+
...leftPinnedIndexes,
|
2031
|
+
...defaultRangeExtractor(range),
|
2032
|
+
...rightPinnedIndexes,
|
2033
|
+
]),
|
2034
|
+
], [leftPinnedIndexes, rightPinnedIndexes]) }, columnVirtualizerProps))
|
2035
|
+
: undefined;
|
2036
|
+
if (columnVirtualizerInstanceRef && columnVirtualizer) {
|
2037
|
+
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
2038
|
+
}
|
2039
|
+
const virtualColumns = columnVirtualizer
|
2040
|
+
? columnVirtualizer.getVirtualItems()
|
2041
|
+
: undefined;
|
2042
|
+
let virtualPaddingLeft;
|
2043
|
+
let virtualPaddingRight;
|
2044
|
+
if (columnVirtualizer && (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)) {
|
2045
|
+
virtualPaddingLeft = (_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0;
|
2046
|
+
virtualPaddingRight =
|
2047
|
+
columnVirtualizer.getTotalSize() -
|
2048
|
+
((_d = (_c = virtualColumns[virtualColumns.length - 1 - rightPinnedIndexes.length]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
|
2049
|
+
}
|
2050
|
+
const props = {
|
2100
2051
|
table,
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
2105
|
-
const handleChangeDebounced = useCallback(debounce((event) => {
|
2106
|
-
var _a;
|
2107
|
-
setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
|
2108
|
-
}, manualFiltering ? 500 : 250), []);
|
2109
|
-
const handleChange = (event) => {
|
2110
|
-
setSearchValue(event.target.value);
|
2111
|
-
handleChangeDebounced(event);
|
2052
|
+
virtualColumns,
|
2053
|
+
virtualPaddingLeft,
|
2054
|
+
virtualPaddingRight,
|
2112
2055
|
};
|
2113
|
-
|
2114
|
-
|
2056
|
+
return (jsx(Fragment, { children: jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, props))] })) }));
|
2057
|
+
};
|
2058
|
+
|
2059
|
+
const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
2060
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
|
2061
|
+
const { creatingRow, editingRow, isSaving } = getState();
|
2062
|
+
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
2063
|
+
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
2064
|
+
const handleCancel = () => {
|
2065
|
+
if (isCreating) {
|
2066
|
+
onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
|
2067
|
+
setCreatingRow(null);
|
2068
|
+
}
|
2069
|
+
else if (isEditing) {
|
2070
|
+
onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
|
2071
|
+
setEditingRow(null);
|
2072
|
+
}
|
2073
|
+
row._valuesCache = {}; //reset values cache
|
2115
2074
|
};
|
2116
|
-
const
|
2117
|
-
|
2118
|
-
|
2075
|
+
const handleSubmitRow = () => {
|
2076
|
+
var _a;
|
2077
|
+
//look for auto-filled input values
|
2078
|
+
(_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)
|
2079
|
+
.filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
|
2080
|
+
if (input.value !== undefined &&
|
2081
|
+
Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
|
2082
|
+
// @ts-ignore
|
2083
|
+
row._valuesCache[input.name] = input.value;
|
2084
|
+
}
|
2085
|
+
});
|
2086
|
+
if (isCreating)
|
2087
|
+
onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
|
2088
|
+
exitCreatingMode: () => setCreatingRow(null),
|
2089
|
+
row,
|
2090
|
+
table,
|
2091
|
+
values: row._valuesCache,
|
2092
|
+
});
|
2093
|
+
else if (isEditing) {
|
2094
|
+
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
2095
|
+
exitEditingMode: () => setEditingRow(null),
|
2096
|
+
row,
|
2097
|
+
table,
|
2098
|
+
values: row === null || row === void 0 ? void 0 : row._valuesCache,
|
2099
|
+
});
|
2100
|
+
}
|
2119
2101
|
};
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2102
|
+
return (jsx(Box, { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' }, children: variant === 'icon' ? (jsxs(Fragment, { children: [jsx(Tooltip, { arrow: true, title: localization.cancel, children: jsx(IconButton, { "aria-label": localization.cancel, onClick: handleCancel, children: jsx(CancelIcon, {}) }) }), jsx(Tooltip, { arrow: true, title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsx(CircularProgress, { size: 18 }) : jsx(SaveIcon, {}) }) })] })) : (jsxs(Fragment, { children: [jsx(Button, { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxs(Button, { onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
|
2103
|
+
};
|
2104
|
+
|
2105
|
+
const MRT_EditRowModal = ({ open, table, }) => {
|
2106
|
+
var _a;
|
2107
|
+
const { getState, options: { localization, muiCreateRowModalProps, muiEditRowModalProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowModalContent, renderEditRowModalContent, }, setCreatingRow, setEditingRow, } = table;
|
2108
|
+
const { creatingRow, editingRow } = getState();
|
2109
|
+
const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
|
2110
|
+
const dialogProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowModalProps, { row, table })), (creatingRow &&
|
2111
|
+
parseFromValuesOrFunc(muiCreateRowModalProps, { row, table })));
|
2112
|
+
const internalEditComponents = row
|
2113
|
+
.getAllCells()
|
2114
|
+
.filter((cell) => cell.column.columnDef.columnDefType === 'data')
|
2115
|
+
.map((cell) => (jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
|
2116
|
+
return (jsx(Dialog, Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
|
2117
|
+
var _a;
|
2118
|
+
if (creatingRow) {
|
2119
|
+
onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
|
2120
|
+
setCreatingRow(null);
|
2124
2121
|
}
|
2125
2122
|
else {
|
2126
|
-
|
2123
|
+
onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
|
2124
|
+
setEditingRow(null);
|
2127
2125
|
}
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2126
|
+
row._valuesCache = {}; //reset values cache
|
2127
|
+
(_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
|
2128
|
+
}, open: open }, dialogProps, { children: (_a = ((creatingRow &&
|
2129
|
+
(renderCreateRowModalContent === null || renderCreateRowModalContent === void 0 ? void 0 : renderCreateRowModalContent({
|
2130
|
+
internalEditComponents,
|
2131
|
+
row,
|
2132
|
+
table,
|
2133
|
+
}))) ||
|
2134
|
+
(renderEditRowModalContent === null || renderEditRowModalContent === void 0 ? void 0 : renderEditRowModalContent({
|
2135
|
+
internalEditComponents,
|
2136
|
+
row,
|
2137
|
+
table,
|
2138
|
+
})))) !== null && _a !== void 0 ? _a : (jsxs(Fragment, { children: [jsx(DialogTitle, { sx: { textAlign: 'center' }, children: localization.edit }), jsx(DialogContent, { children: jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsx(Stack, { sx: {
|
2139
|
+
gap: '24px',
|
2140
|
+
paddingTop: '16px',
|
2141
|
+
width: '100%',
|
2142
|
+
}, children: internalEditComponents }) }) }), jsx(DialogActions, { sx: { p: '1.25rem' }, children: jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
|
2143
|
+
};
|
2144
|
+
|
2145
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
2146
|
+
const MRT_TableContainer = ({ table, }) => {
|
2147
|
+
const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
|
2148
|
+
const { creatingRow, editingRow, isFullScreen } = getState();
|
2149
|
+
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
2150
|
+
const tableContainerProps = parseFromValuesOrFunc(muiTableContainerProps, {
|
2151
|
+
table,
|
2152
|
+
});
|
2153
|
+
useIsomorphicLayoutEffect(() => {
|
2154
|
+
var _a, _b, _c, _d;
|
2155
|
+
const topToolbarHeight = typeof document !== 'undefined'
|
2156
|
+
? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
|
2157
|
+
: 0;
|
2158
|
+
const bottomToolbarHeight = typeof document !== 'undefined'
|
2159
|
+
? (_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0
|
2160
|
+
: 0;
|
2161
|
+
setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
|
2162
|
+
});
|
2163
|
+
const createModalOpen = createDisplayMode === 'modal' && creatingRow;
|
2164
|
+
const editModalOpen = editDisplayMode === 'modal' && editingRow;
|
2165
|
+
return (jsxs(TableContainer, Object.assign({}, tableContainerProps, { ref: (node) => {
|
2166
|
+
if (node) {
|
2167
|
+
tableContainerRef.current = node;
|
2168
|
+
if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
|
2169
|
+
//@ts-ignore
|
2170
|
+
tableContainerProps.ref.current = node;
|
2171
|
+
}
|
2172
|
+
}
|
2173
|
+
}, style: Object.assign({ maxHeight: isFullScreen
|
2174
|
+
? `calc(100vh - ${totalToolbarHeight}px)`
|
2175
|
+
: undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
|
2176
|
+
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
2177
|
+
: undefined, maxWidth: '100%', overflow: 'auto' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table }))] })));
|
2140
2178
|
};
|
2141
2179
|
|
2142
2180
|
const MRT_LinearProgressBar = ({ isTopToolbar, table, }) => {
|
2143
|
-
const { options: { muiLinearProgressProps },
|
2181
|
+
const { getState, options: { muiLinearProgressProps }, } = table;
|
2144
2182
|
const { isLoading, showProgressBars } = getState();
|
2145
2183
|
const linearProgressProps = parseFromValuesOrFunc(muiLinearProgressProps, {
|
2146
2184
|
isTopToolbar,
|
2147
2185
|
table,
|
2148
2186
|
});
|
2149
|
-
return (jsx(Collapse, { in: isLoading || showProgressBars, mountOnEnter: true,
|
2187
|
+
return (jsx(Collapse, { in: isLoading || showProgressBars, mountOnEnter: true, sx: {
|
2150
2188
|
bottom: isTopToolbar ? 0 : undefined,
|
2151
2189
|
position: 'absolute',
|
2152
2190
|
top: !isTopToolbar ? 0 : undefined,
|
2153
2191
|
width: '100%',
|
2154
|
-
}, children: jsx(LinearProgress, Object.assign({ "aria-
|
2192
|
+
}, unmountOnExit: true, children: jsx(LinearProgress, Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
|
2155
2193
|
};
|
2156
2194
|
|
2157
|
-
const MRT_TablePagination = ({
|
2158
|
-
const { getPrePaginationRowModel, getState,
|
2159
|
-
const { pagination: {
|
2195
|
+
const MRT_TablePagination = ({ position = 'bottom', table, }) => {
|
2196
|
+
const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, localization, muiTablePaginationProps, rowCount, }, setPageIndex, setPageSize, } = table;
|
2197
|
+
const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
|
2160
2198
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
2161
2199
|
const showFirstLastPageButtons = totalRowCount / pageSize > 2;
|
2162
2200
|
const tablePaginationProps = parseFromValuesOrFunc(muiTablePaginationProps, {
|
@@ -2171,18 +2209,18 @@ const MRT_TablePagination = ({ table, position = 'bottom', }) => {
|
|
2171
2209
|
? localization.goToLastPage
|
2172
2210
|
: type === 'next'
|
2173
2211
|
? localization.goToNextPage
|
2174
|
-
: localization.goToPreviousPage, labelDisplayedRows: ({ from, to
|
2175
|
-
display: 'flex',
|
2176
|
-
alignItems: 'center',
|
2177
|
-
}, '& .MuiTablePagination-selectLabel': {
|
2178
|
-
m: '0 -1px',
|
2179
|
-
}, '&. MuiInputBase-root': {
|
2212
|
+
: localization.goToPreviousPage, labelDisplayedRows: ({ count, from, to }) => `${from}-${to} ${localization.of} ${count}`, labelRowsPerPage: localization.rowsPerPage, onPageChange: (_, newPage) => setPageIndex(newPage), onRowsPerPageChange: handleChangeRowsPerPage, page: Math.max(Math.min(pageIndex, Math.ceil(totalRowCount / pageSize) - 1), 0), rowsPerPage: pageSize, rowsPerPageOptions: [5, 10, 15, 20, 25, 30, 50, 100], showFirstButton: showFirstLastPageButtons, showLastButton: showFirstLastPageButtons }, tablePaginationProps, { SelectProps: Object.assign({ MenuProps: { MenuListProps: { disablePadding: true }, sx: { m: 0 } }, sx: { m: '0 1rem 0 1ch' } }, tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.SelectProps), sx: (theme) => (Object.assign({ '& . MuiTablePagination-select': {
|
2180
2213
|
m: '0 1px',
|
2181
|
-
}, '& .
|
2214
|
+
}, '& .MuiTablePagination-actions': {
|
2182
2215
|
m: '0 1px',
|
2183
2216
|
}, '& .MuiTablePagination-displayedRows': {
|
2184
2217
|
m: '0 1px',
|
2185
|
-
}, '& .MuiTablePagination-
|
2218
|
+
}, '& .MuiTablePagination-selectLabel': {
|
2219
|
+
m: '0 -1px',
|
2220
|
+
}, '& .MuiTablePagination-toolbar': {
|
2221
|
+
alignItems: 'center',
|
2222
|
+
display: 'flex',
|
2223
|
+
}, '&. MuiInputBase-root': {
|
2186
2224
|
m: '0 1px',
|
2187
2225
|
}, mt: position === 'top' &&
|
2188
2226
|
enableToolbarInternalActions &&
|
@@ -2193,7 +2231,7 @@ const MRT_TablePagination = ({ table, position = 'bottom', }) => {
|
|
2193
2231
|
|
2194
2232
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
2195
2233
|
var _a, _b;
|
2196
|
-
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization,
|
2234
|
+
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, rowCount, }, } = table;
|
2197
2235
|
const { grouping, showAlertBanner } = getState();
|
2198
2236
|
const alertProps = parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
2199
2237
|
table,
|
@@ -2205,24 +2243,69 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
2205
2243
|
? (_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())
|
2206
2244
|
: null;
|
2207
2245
|
const groupedByMessage = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
2208
|
-
return (jsx(Collapse, { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0, children: jsxs(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0,
|
2246
|
+
return (jsx(Collapse, { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0, children: jsxs(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, mb: stackAlertBanner
|
2209
2247
|
? 0
|
2210
2248
|
: positionToolbarAlertBanner === 'bottom'
|
2211
2249
|
? '-1rem'
|
2212
|
-
: undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, parseFromValuesOrFunc(alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx, theme))), children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsx(AlertTitle, { children: alertProps.title }), jsxs(Box, { sx: { p: '0.5rem 1rem' }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectMessage || groupedByMessage) && (jsx("br", {})), selectMessage, selectMessage && groupedByMessage && jsx("br", {}), groupedByMessage] })] })) }));
|
2250
|
+
: undefined, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, parseFromValuesOrFunc(alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx, theme))), children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsx(AlertTitle, { children: alertProps.title }), jsxs(Box, { sx: { p: '0.5rem 1rem' }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectMessage || groupedByMessage) && (jsx("br", {})), selectMessage, selectMessage && groupedByMessage && jsx("br", {}), groupedByMessage] })] })) }));
|
2251
|
+
};
|
2252
|
+
|
2253
|
+
const MRT_ToolbarDropZone = ({ table, }) => {
|
2254
|
+
var _a, _b;
|
2255
|
+
const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
|
2256
|
+
const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = getState();
|
2257
|
+
const handleDragEnter = (_event) => {
|
2258
|
+
setHoveredColumn({ id: 'drop-zone' });
|
2259
|
+
};
|
2260
|
+
useEffect(() => {
|
2261
|
+
var _a;
|
2262
|
+
if (((_a = table.options.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
|
2263
|
+
setShowToolbarDropZone(!!enableGrouping &&
|
2264
|
+
!!draggingColumn &&
|
2265
|
+
draggingColumn.columnDef.enableGrouping !== false &&
|
2266
|
+
!grouping.includes(draggingColumn.id));
|
2267
|
+
}
|
2268
|
+
}, [enableGrouping, draggingColumn, grouping]);
|
2269
|
+
return (jsx(Fade, { in: showToolbarDropZone, children: jsx(Box, { className: "Mui-ToolbarDropZone", onDragEnter: handleDragEnter, sx: (theme) => ({
|
2270
|
+
alignItems: 'center',
|
2271
|
+
backdropFilter: 'blur(4px)',
|
2272
|
+
backgroundColor: alpha(theme.palette.info.main, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1),
|
2273
|
+
border: `dashed ${theme.palette.info.main} 2px`,
|
2274
|
+
boxSizing: 'border-box',
|
2275
|
+
display: 'flex',
|
2276
|
+
height: '100%',
|
2277
|
+
justifyContent: 'center',
|
2278
|
+
position: 'absolute',
|
2279
|
+
width: '100%',
|
2280
|
+
zIndex: 4,
|
2281
|
+
}), children: jsx(Typography, { fontStyle: "italic", children: localization.dropToGroupBy.replace('{column}', (_b = (_a = draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.columnDef) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : '') }) }) }));
|
2213
2282
|
};
|
2214
2283
|
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2284
|
+
/******************************************************************************
|
2285
|
+
Copyright (c) Microsoft Corporation.
|
2286
|
+
|
2287
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
2288
|
+
purpose with or without fee is hereby granted.
|
2289
|
+
|
2290
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
2291
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
2292
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
2293
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
2294
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
2295
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
2296
|
+
PERFORMANCE OF THIS SOFTWARE.
|
2297
|
+
***************************************************************************** */
|
2298
|
+
function __rest(s, e) {
|
2299
|
+
var t = {};
|
2300
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
2301
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
2302
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
2303
|
+
}
|
2304
|
+
return t;
|
2305
|
+
}
|
2306
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
2307
|
+
var e = new Error(message);
|
2308
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
2226
2309
|
};
|
2227
2310
|
|
2228
2311
|
const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
@@ -2237,9 +2320,9 @@ const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
2237
2320
|
} }) }) })] })) }));
|
2238
2321
|
};
|
2239
2322
|
|
2240
|
-
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn,
|
2323
|
+
const MRT_ShowHideColumnsMenuItems = ({ allColumns, column, hoveredColumn, setHoveredColumn, table, }) => {
|
2241
2324
|
var _a;
|
2242
|
-
const { getState, options: { enableColumnOrdering,
|
2325
|
+
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, setColumnOrder, } = table;
|
2243
2326
|
const { columnOrder } = getState();
|
2244
2327
|
const { columnDef } = column;
|
2245
2328
|
const { columnDefType } = columnDef;
|
@@ -2275,17 +2358,17 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredCol
|
|
2275
2358
|
setHoveredColumn(column);
|
2276
2359
|
}
|
2277
2360
|
};
|
2278
|
-
return (jsxs(Fragment, { children: [jsx(MenuItem, { disableRipple: true,
|
2361
|
+
return (jsxs(Fragment, { children: [jsx(MenuItem, { disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef, sx: (theme) => ({
|
2279
2362
|
alignItems: 'center',
|
2280
2363
|
justifyContent: 'flex-start',
|
2281
2364
|
my: 0,
|
2282
2365
|
opacity: isDragging ? 0.5 : 1,
|
2283
|
-
outlineOffset: '-2px',
|
2284
2366
|
outline: isDragging
|
2285
2367
|
? `2px dashed ${theme.palette.divider}`
|
2286
2368
|
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
2287
2369
|
? `2px dashed ${theme.palette.primary.main}`
|
2288
2370
|
: 'none',
|
2371
|
+
outlineOffset: '-2px',
|
2289
2372
|
pl: `${(column.depth + 0.5) * 2}rem`,
|
2290
2373
|
py: '6px',
|
2291
2374
|
}), children: jsxs(Box, { sx: {
|
@@ -2296,19 +2379,19 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredCol
|
|
2296
2379
|
enableColumnOrdering &&
|
2297
2380
|
!allColumns.some((col) => col.columnDef.columnDefType === 'group') &&
|
2298
2381
|
(columnDef.enableColumnOrdering !== false ? (jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsx(Box, { sx: { width: '28px' } }))), enableColumnPinning &&
|
2299
|
-
(column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { sx: { width: '70px' } }))), enableHiding ? (jsx(FormControlLabel, { componentsProps: {
|
2382
|
+
(column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { sx: { width: '70px' } }))), enableHiding ? (jsx(FormControlLabel, { checked: switchChecked, componentsProps: {
|
2300
2383
|
typography: {
|
2301
2384
|
sx: {
|
2302
2385
|
mb: 0,
|
2303
2386
|
opacity: columnDefType !== 'display' ? 1 : 0.5,
|
2304
2387
|
},
|
2305
2388
|
},
|
2306
|
-
},
|
2389
|
+
}, control: jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.toggleVisibility, children: jsx(Switch, {}) }), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) }), (_a = column.columns) === null || _a === void 0 ? void 0 : _a.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
|
2307
2390
|
};
|
2308
2391
|
|
2309
2392
|
const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, }) => {
|
2310
|
-
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState,
|
2311
|
-
const {
|
2393
|
+
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, }, toggleAllColumnsVisible, } = table;
|
2394
|
+
const { columnOrder, columnPinning, density } = getState();
|
2312
2395
|
const hideAllColumns = () => {
|
2313
2396
|
getAllLeafColumns()
|
2314
2397
|
.filter((col) => col.columnDef.enableHiding !== false)
|
@@ -2334,9 +2417,9 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, setAnchorEl, table, }) => {
|
|
2334
2417
|
getRightLeafColumns(),
|
2335
2418
|
]);
|
2336
2419
|
const [hoveredColumn, setHoveredColumn] = useState(null);
|
2337
|
-
return (jsxs(Menu, {
|
2420
|
+
return (jsxs(Menu, { MenuListProps: {
|
2338
2421
|
dense: density === 'compact',
|
2339
|
-
}, children: [jsxs(Box, { sx: {
|
2422
|
+
}, anchorEl: anchorEl, onClose: () => setAnchorEl(null), open: !!anchorEl, children: [jsxs(Box, { sx: {
|
2340
2423
|
display: 'flex',
|
2341
2424
|
justifyContent: 'space-between',
|
2342
2425
|
p: '0.5rem',
|
@@ -2382,6 +2465,19 @@ const MRT_ToggleFiltersButton = (_a) => {
|
|
2382
2465
|
return (jsx(Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideFilters, children: jsx(IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleShowFilters }, rest, { title: undefined, children: showColumnFilters ? jsx(FilterListOffIcon, {}) : jsx(FilterListIcon, {}) })) }));
|
2383
2466
|
};
|
2384
2467
|
|
2468
|
+
const MRT_ToggleFullScreenButton = (_a) => {
|
2469
|
+
var _b;
|
2470
|
+
var { table } = _a, rest = __rest(_a, ["table"]);
|
2471
|
+
const { getState, options: { icons: { FullscreenExitIcon, FullscreenIcon }, localization, }, setIsFullScreen, } = table;
|
2472
|
+
const { isFullScreen } = getState();
|
2473
|
+
const [tooltipOpened, setTooltipOpened] = useState(false);
|
2474
|
+
const handleToggleFullScreen = () => {
|
2475
|
+
setTooltipOpened(false);
|
2476
|
+
setIsFullScreen(!isFullScreen);
|
2477
|
+
};
|
2478
|
+
return (jsx(Tooltip, { arrow: true, open: tooltipOpened, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsx(IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsx(FullscreenExitIcon, {}) : jsx(FullscreenIcon, {}) })) }));
|
2479
|
+
};
|
2480
|
+
|
2385
2481
|
const MRT_ToggleGlobalFilterButton = (_a) => {
|
2386
2482
|
var _b, _c;
|
2387
2483
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
@@ -2396,7 +2492,7 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
2396
2492
|
|
2397
2493
|
const MRT_ToolbarInternalButtons = ({ table, }) => {
|
2398
2494
|
var _a;
|
2399
|
-
const { options: { enableColumnFilters, enableColumnOrdering, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding,
|
2495
|
+
const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions, }, } = table;
|
2400
2496
|
return (jsx(Box, { sx: {
|
2401
2497
|
alignItems: 'center',
|
2402
2498
|
display: 'flex',
|
@@ -2405,38 +2501,56 @@ const MRT_ToolbarInternalButtons = ({ table, }) => {
|
|
2405
2501
|
table,
|
2406
2502
|
})) !== null && _a !== void 0 ? _a : (jsxs(Fragment, { children: [enableFilters &&
|
2407
2503
|
enableGlobalFilter &&
|
2408
|
-
!(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
|
2504
|
+
!(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
|
2505
|
+
enableColumnFilters &&
|
2506
|
+
columnFilterDisplayMode !== 'popover' && (jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsx(MRT_ToggleFullScreenButton, { table: table }))] })) }));
|
2409
2507
|
};
|
2410
2508
|
|
2411
|
-
const
|
2412
|
-
var _a
|
2413
|
-
const { getState, options: {
|
2414
|
-
const {
|
2415
|
-
const
|
2416
|
-
|
2509
|
+
const MRT_GlobalFilterTextField = ({ table, }) => {
|
2510
|
+
var _a;
|
2511
|
+
const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
|
2512
|
+
const { globalFilter, showGlobalFilter } = getState();
|
2513
|
+
const textFieldProps = parseFromValuesOrFunc(muiSearchTextFieldProps, {
|
2514
|
+
table,
|
2515
|
+
});
|
2516
|
+
const isMounted = useRef(false);
|
2517
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
2518
|
+
const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
|
2519
|
+
const handleChangeDebounced = useCallback(debounce((event) => {
|
2520
|
+
var _a;
|
2521
|
+
setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
|
2522
|
+
}, manualFiltering ? 500 : 250), []);
|
2523
|
+
const handleChange = (event) => {
|
2524
|
+
setSearchValue(event.target.value);
|
2525
|
+
handleChangeDebounced(event);
|
2526
|
+
};
|
2527
|
+
const handleGlobalFilterMenuOpen = (event) => {
|
2528
|
+
setAnchorEl(event.currentTarget);
|
2529
|
+
};
|
2530
|
+
const handleClear = () => {
|
2531
|
+
setSearchValue('');
|
2532
|
+
setGlobalFilter(undefined);
|
2417
2533
|
};
|
2418
2534
|
useEffect(() => {
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2423
|
-
|
2424
|
-
|
2535
|
+
if (isMounted.current) {
|
2536
|
+
if (globalFilter === undefined) {
|
2537
|
+
handleClear();
|
2538
|
+
}
|
2539
|
+
else {
|
2540
|
+
setSearchValue(globalFilter);
|
2541
|
+
}
|
2425
2542
|
}
|
2426
|
-
|
2427
|
-
|
2428
|
-
|
2429
|
-
|
2430
|
-
|
2431
|
-
|
2432
|
-
|
2433
|
-
|
2434
|
-
|
2435
|
-
|
2436
|
-
|
2437
|
-
width: '100%',
|
2438
|
-
zIndex: 4,
|
2439
|
-
}), onDragEnter: handleDragEnter, children: jsx(Typography, { fontStyle: "italic", children: localization.dropToGroupBy.replace('{column}', (_b = (_a = draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.columnDef) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : '') }) }) }));
|
2543
|
+
isMounted.current = true;
|
2544
|
+
}, [globalFilter]);
|
2545
|
+
return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ InputProps: {
|
2546
|
+
endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { arrow: true, title: (_a = localization.clearSearch) !== null && _a !== void 0 ? _a : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsx(CloseIcon, {}) }) }) }) })),
|
2547
|
+
startAdornment: enableGlobalFilterModes ? (jsx(InputAdornment, { position: "start", children: jsx(Tooltip, { arrow: true, title: localization.changeSearchMode, children: jsx(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(SearchIcon, {}) }) }) })) : (jsx(SearchIcon, { style: { marginRight: '4px' } })),
|
2548
|
+
}, onChange: handleChange, placeholder: localization.search, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
|
2549
|
+
searchInputRef.current = inputRef;
|
2550
|
+
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
|
2551
|
+
textFieldProps.inputRef = inputRef;
|
2552
|
+
}
|
2553
|
+
} })), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, onSelect: handleClear, setAnchorEl: setAnchorEl, table: table })] }));
|
2440
2554
|
};
|
2441
2555
|
|
2442
2556
|
const commonToolbarStyles = ({ theme }) => ({
|
@@ -2480,7 +2594,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
2480
2594
|
justifyContent: 'flex-end',
|
2481
2595
|
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, { table: table })), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
|
2482
2596
|
positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, { table: table })))] }), enablePagination &&
|
2483
|
-
['
|
2597
|
+
['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
|
2484
2598
|
};
|
2485
2599
|
|
2486
2600
|
const MRT_BottomToolbar = ({ table, }) => {
|
@@ -2511,855 +2625,775 @@ const MRT_BottomToolbar = ({ table, }) => {
|
|
2511
2625
|
right: 0,
|
2512
2626
|
top: 0,
|
2513
2627
|
}, children: enablePagination &&
|
2514
|
-
['
|
2515
|
-
};
|
2516
|
-
|
2517
|
-
const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
2518
|
-
var _a;
|
2519
|
-
const { options: { icons: { MoreVertIcon }, localization, muiColumnActionsButtonProps, }, } = table;
|
2520
|
-
const { column } = header;
|
2521
|
-
const { columnDef } = column;
|
2522
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
2523
|
-
const handleClick = (event) => {
|
2524
|
-
event.stopPropagation();
|
2525
|
-
event.preventDefault();
|
2526
|
-
setAnchorEl(event.currentTarget);
|
2527
|
-
};
|
2528
|
-
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnActionsButtonProps, {
|
2529
|
-
column,
|
2530
|
-
table,
|
2531
|
-
})), parseFromValuesOrFunc(columnDef.muiColumnActionsButtonProps, {
|
2532
|
-
column,
|
2533
|
-
table,
|
2534
|
-
}));
|
2535
|
-
return (jsxs(Fragment, { children: [jsx(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, children: jsx(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', m: '-8px -4px', opacity: 0.5, transform: 'scale(0.85) translateX(-4px)', transition: 'opacity 150ms', width: '2rem', '&:hover': {
|
2536
|
-
opacity: 1,
|
2537
|
-
} }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: jsx(MoreVertIcon, {}) })) }), anchorEl && (jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
|
2628
|
+
['both', 'bottom'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "bottom", table: table })) })] })] })));
|
2538
2629
|
};
|
2539
2630
|
|
2540
|
-
const
|
2541
|
-
var _a, _b
|
2542
|
-
const {
|
2543
|
-
const {
|
2544
|
-
const {
|
2545
|
-
|
2546
|
-
|
2547
|
-
|
2548
|
-
|
2549
|
-
|
2550
|
-
const isSelectFilter = columnDef.filterVariant === 'select';
|
2551
|
-
const isMultiSelectFilter = columnDef.filterVariant === 'multi-select';
|
2552
|
-
const isTextboxFilter = columnDef.filterVariant === 'text' ||
|
2553
|
-
(!isSelectFilter && !isMultiSelectFilter);
|
2554
|
-
const currentFilterOption = columnDef._filterFn;
|
2555
|
-
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
2556
|
-
? //@ts-ignore
|
2557
|
-
localization[`filter${((_b = (_a = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt) === null || _a === void 0 ? void 0 : _a.call(currentFilterOption, 0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
2558
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
|
2559
|
-
: '';
|
2560
|
-
const filterPlaceholder = !isRangeFilter
|
2561
|
-
? (_c = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.placeholder) !== null && _c !== void 0 ? _c : (_d = localization.filterByColumn) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header))
|
2562
|
-
: rangeFilterIndex === 0
|
2563
|
-
? localization.min
|
2564
|
-
: rangeFilterIndex === 1
|
2565
|
-
? localization.max
|
2566
|
-
: '';
|
2567
|
-
const allowedColumnFilterOptions = (_e = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _e !== void 0 ? _e : columnFilterModeOptions;
|
2568
|
-
const showChangeModeButton = enableColumnFilterModes &&
|
2569
|
-
columnDef.enableColumnFilterModes !== false &&
|
2570
|
-
!rangeFilterIndex &&
|
2571
|
-
(allowedColumnFilterOptions === undefined ||
|
2572
|
-
!!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
|
2573
|
-
const facetedUniqueValues = column.getFacetedUniqueValues();
|
2574
|
-
const filterSelectOptions = useMemo(() => {
|
2575
|
-
var _a;
|
2576
|
-
return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter) && facetedUniqueValues
|
2577
|
-
? Array.from(facetedUniqueValues.keys())
|
2578
|
-
.filter((value) => value !== null && value !== undefined)
|
2579
|
-
.sort((a, b) => a.localeCompare(b))
|
2580
|
-
: undefined);
|
2581
|
-
}, [
|
2582
|
-
columnDef.filterSelectOptions,
|
2583
|
-
facetedUniqueValues,
|
2584
|
-
isMultiSelectFilter,
|
2585
|
-
isSelectFilter,
|
2586
|
-
]);
|
2587
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
2588
|
-
const [filterValue, setFilterValue] = useState(() => {
|
2589
|
-
var _a, _b;
|
2590
|
-
return isMultiSelectFilter
|
2591
|
-
? column.getFilterValue() || []
|
2592
|
-
: isRangeFilter
|
2593
|
-
? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || []
|
2594
|
-
: (_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '';
|
2595
|
-
});
|
2596
|
-
const handleChangeDebounced = useCallback(debounce((event) => {
|
2597
|
-
const value = textFieldProps.type === 'date'
|
2598
|
-
? event.target.valueAsDate
|
2599
|
-
: textFieldProps.type === 'number'
|
2600
|
-
? event.target.valueAsNumber
|
2601
|
-
: event.target.value;
|
2602
|
-
if (isRangeFilter) {
|
2603
|
-
column.setFilterValue((old) => {
|
2604
|
-
const newFilterValues = old !== null && old !== void 0 ? old : ['', ''];
|
2605
|
-
newFilterValues[rangeFilterIndex] = value;
|
2606
|
-
return newFilterValues;
|
2607
|
-
});
|
2608
|
-
}
|
2609
|
-
else {
|
2610
|
-
column.setFilterValue(value !== null && value !== void 0 ? value : undefined);
|
2611
|
-
}
|
2612
|
-
}, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
|
2613
|
-
const handleChange = (event) => {
|
2614
|
-
setFilterValue(event.target.value);
|
2615
|
-
handleChangeDebounced(event);
|
2616
|
-
};
|
2617
|
-
const handleClear = () => {
|
2618
|
-
if (isMultiSelectFilter) {
|
2619
|
-
setFilterValue([]);
|
2620
|
-
column.setFilterValue([]);
|
2621
|
-
}
|
2622
|
-
else if (isRangeFilter) {
|
2623
|
-
setFilterValue('');
|
2624
|
-
column.setFilterValue((old) => {
|
2625
|
-
const newFilterValues = (Array.isArray(old) && old) || ['', ''];
|
2626
|
-
newFilterValues[rangeFilterIndex] = undefined;
|
2627
|
-
return newFilterValues;
|
2628
|
-
});
|
2629
|
-
}
|
2630
|
-
else {
|
2631
|
-
setFilterValue('');
|
2632
|
-
column.setFilterValue(undefined);
|
2633
|
-
}
|
2634
|
-
};
|
2635
|
-
const handleClearEmptyFilterChip = () => {
|
2636
|
-
setFilterValue('');
|
2637
|
-
column.setFilterValue(undefined);
|
2638
|
-
setColumnFilterFns((prev) => {
|
2639
|
-
var _a;
|
2640
|
-
return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
|
2641
|
-
});
|
2642
|
-
};
|
2643
|
-
const handleFilterMenuOpen = (event) => {
|
2644
|
-
setAnchorEl(event.currentTarget);
|
2645
|
-
};
|
2646
|
-
const isMounted = useRef(false);
|
2647
|
-
useEffect(() => {
|
2648
|
-
if (isMounted.current) {
|
2649
|
-
const filterValue = column.getFilterValue();
|
2650
|
-
if (filterValue === undefined) {
|
2651
|
-
handleClear();
|
2652
|
-
}
|
2653
|
-
else if (isRangeFilter && rangeFilterIndex !== undefined) {
|
2654
|
-
setFilterValue(filterValue[rangeFilterIndex]);
|
2631
|
+
const MRT_TablePaper = ({ table, }) => {
|
2632
|
+
var _a, _b;
|
2633
|
+
const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
|
2634
|
+
const { isFullScreen } = getState();
|
2635
|
+
const tablePaperProps = parseFromValuesOrFunc(muiTablePaperProps, { table });
|
2636
|
+
return (jsxs(Paper, Object.assign({ elevation: 2 }, tablePaperProps, { ref: (ref) => {
|
2637
|
+
tablePaperRef.current = ref;
|
2638
|
+
if (tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref) {
|
2639
|
+
//@ts-ignore
|
2640
|
+
tablePaperProps.ref.current = ref;
|
2655
2641
|
}
|
2656
|
-
|
2657
|
-
|
2642
|
+
}, style: Object.assign(Object.assign({}, (isFullScreen
|
2643
|
+
? {
|
2644
|
+
bottom: 0,
|
2645
|
+
height: '100vh',
|
2646
|
+
left: 0,
|
2647
|
+
margin: 0,
|
2648
|
+
maxHeight: '100vh',
|
2649
|
+
maxWidth: '100vw',
|
2650
|
+
padding: 0,
|
2651
|
+
position: 'fixed',
|
2652
|
+
right: 0,
|
2653
|
+
top: 0,
|
2654
|
+
width: '100vw',
|
2655
|
+
zIndex: 10,
|
2658
2656
|
}
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
if (columnDef.Filter) {
|
2663
|
-
return (jsx(Fragment, { children: (_f = columnDef.Filter) === null || _f === void 0 ? void 0 : _f.call(columnDef, { column, header, rangeFilterIndex, table }) }));
|
2664
|
-
}
|
2665
|
-
return (jsxs(Fragment, { children: [jsxs(TextField, Object.assign({ fullWidth: true, inputProps: {
|
2666
|
-
disabled: !!filterChipLabel,
|
2667
|
-
sx: {
|
2668
|
-
textOverflow: 'ellipsis',
|
2669
|
-
width: filterChipLabel ? 0 : undefined,
|
2670
|
-
},
|
2671
|
-
title: filterPlaceholder,
|
2672
|
-
}, helperText: showChangeModeButton ? (jsx("label", { children: localization.filterMode.replace('{filterType}',
|
2673
|
-
// @ts-ignore
|
2674
|
-
localization[`filter${((_g = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _g === void 0 ? void 0 : _g.toUpperCase()) +
|
2675
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, FormHelperTextProps: {
|
2676
|
-
sx: {
|
2677
|
-
fontSize: '0.75rem',
|
2678
|
-
lineHeight: '0.8rem',
|
2679
|
-
whiteSpace: 'nowrap',
|
2680
|
-
},
|
2681
|
-
}, margin: "none", placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
2682
|
-
? undefined
|
2683
|
-
: filterPlaceholder, onChange: handleChange, onClick: (e) => e.stopPropagation(), select: isSelectFilter || isMultiSelectFilter, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', variant: "standard", InputProps: {
|
2684
|
-
startAdornment: showChangeModeButton ? (jsxs(InputAdornment, { position: "start", children: [jsx(Tooltip, { arrow: true, title: localization.changeFilterMode, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.changeFilterMode, onClick: handleFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(FilterListIcon, {}) }) }) }), filterChipLabel && (jsx(Chip, { onDelete: handleClearEmptyFilterChip, label: filterChipLabel }))] })) : null,
|
2685
|
-
endAdornment: !filterChipLabel && (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { arrow: true, placement: "right", title: (_h = localization.clearFilter) !== null && _h !== void 0 ? _h : '', children: jsx("span", { children: jsx(IconButton, { "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: {
|
2686
|
-
height: '1.75rem',
|
2687
|
-
width: '1.75rem',
|
2688
|
-
}, children: jsx(CloseIcon, {}) }) }) }) })),
|
2689
|
-
}, SelectProps: {
|
2690
|
-
displayEmpty: true,
|
2691
|
-
multiple: isMultiSelectFilter,
|
2692
|
-
renderValue: isMultiSelectFilter
|
2693
|
-
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected === null || selected === void 0 ? void 0 : selected.map((value) => {
|
2694
|
-
const selectedValue = filterSelectOptions === null || filterSelectOptions === void 0 ? void 0 : filterSelectOptions.find((option) => option instanceof Object
|
2695
|
-
? option.value === value
|
2696
|
-
: option === value);
|
2697
|
-
return (jsx(Chip, { label: selectedValue instanceof Object
|
2698
|
-
? selectedValue.text
|
2699
|
-
: selectedValue }, value));
|
2700
|
-
}) }))
|
2701
|
-
: undefined,
|
2702
|
-
} }, textFieldProps, { inputRef: (inputRef) => {
|
2703
|
-
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
2704
|
-
inputRef;
|
2705
|
-
if (textFieldProps.inputRef) {
|
2706
|
-
textFieldProps.inputRef = inputRef;
|
2707
|
-
}
|
2708
|
-
}, sx: (theme) => (Object.assign({ p: 0, minWidth: isRangeFilter
|
2709
|
-
? '100px'
|
2710
|
-
: !filterChipLabel
|
2711
|
-
? '120px'
|
2712
|
-
: 'auto', width: 'calc(100% + 4px)', mx: '-2px', '& .MuiSelect-icon': {
|
2713
|
-
mr: '1.5rem',
|
2714
|
-
} }, parseFromValuesOrFunc(textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx, theme))), children: [(isSelectFilter || isMultiSelectFilter) && (jsx(MenuItem, { divider: true, disabled: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) })), (_k = textFieldProps.children) !== null && _k !== void 0 ? _k : filterSelectOptions === null || filterSelectOptions === void 0 ? void 0 : filterSelectOptions.map((option) => {
|
2715
|
-
var _a;
|
2716
|
-
if (!option)
|
2717
|
-
return '';
|
2718
|
-
let value;
|
2719
|
-
let text;
|
2720
|
-
if (typeof option !== 'object') {
|
2721
|
-
value = option;
|
2722
|
-
text = option;
|
2723
|
-
}
|
2724
|
-
else {
|
2725
|
-
value = option.value;
|
2726
|
-
text = option.text;
|
2727
|
-
}
|
2728
|
-
return (jsxs(MenuItem, { sx: {
|
2729
|
-
display: 'flex',
|
2730
|
-
m: 0,
|
2731
|
-
alignItems: 'center',
|
2732
|
-
gap: '0.5rem',
|
2733
|
-
}, value: value, children: [isMultiSelectFilter && (jsx(Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), text, ' ', !columnDef.filterSelectOptions &&
|
2734
|
-
`(${facetedUniqueValues.get(value)})`] }, value));
|
2735
|
-
})] })), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table, setFilterValue: setFilterValue })] }));
|
2657
|
+
: {})), tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), sx: (theme) => (Object.assign({ overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx, theme))), children: [enableTopToolbar &&
|
2658
|
+
((_a = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _a !== void 0 ? _a : (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
|
2659
|
+
((_b = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _b !== void 0 ? _b : (jsx(MRT_BottomToolbar, { table: table })))] })));
|
2736
2660
|
};
|
2737
2661
|
|
2738
|
-
const
|
2739
|
-
|
2662
|
+
const MRT_RowPinButton = ({ pinningPosition, row, table, }) => {
|
2663
|
+
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
|
2664
|
+
const isPinned = row.getIsPinned();
|
2665
|
+
const [tooltipOpened, setTooltipOpened] = useState(false);
|
2666
|
+
const handleTogglePin = (event) => {
|
2667
|
+
setTooltipOpened(false);
|
2668
|
+
event.stopPropagation();
|
2669
|
+
row.pin(isPinned ? false : pinningPosition);
|
2670
|
+
};
|
2671
|
+
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, { "aria-label": localization.pin, onClick: handleTogglePin, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small", sx: {
|
2672
|
+
height: '24px',
|
2673
|
+
width: '24px',
|
2674
|
+
}, children: isPinned ? (jsx(CloseIcon, {})) : (jsx(PushPinIcon, { fontSize: "small", style: {
|
2675
|
+
transform: `rotate(${rowPinningDisplayMode === 'sticky'
|
2676
|
+
? 135
|
2677
|
+
: pinningPosition === 'top'
|
2678
|
+
? 180
|
2679
|
+
: 0}deg)`,
|
2680
|
+
} })) }) }));
|
2740
2681
|
};
|
2741
2682
|
|
2742
|
-
const
|
2743
|
-
|
2744
|
-
const { getState, options: { localization, muiFilterCheckboxProps }, } = table;
|
2683
|
+
const MRT_TableBodyRowPinButton = ({ row, table, }) => {
|
2684
|
+
const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
|
2745
2685
|
const { density } = getState();
|
2746
|
-
const
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
|
2751
|
-
|
2686
|
+
const canPin = parseFromValuesOrFunc(enableRowPinning, row);
|
2687
|
+
if (!canPin)
|
2688
|
+
return null;
|
2689
|
+
if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
|
2690
|
+
return (jsxs(Box, { sx: {
|
2691
|
+
display: 'flex',
|
2692
|
+
flexDirection: density === 'compact' ? 'row' : 'column',
|
2693
|
+
}, children: [jsx(MRT_RowPinButton, { pinningPosition: "top", row: row, table: table }), jsx(MRT_RowPinButton, { pinningPosition: "bottom", row: row, table: table })] }));
|
2694
|
+
}
|
2695
|
+
return (jsx(MRT_RowPinButton, { pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top', row: row, table: table }));
|
2696
|
+
};
|
2697
|
+
|
2698
|
+
const MRT_ExpandAllButton = ({ table, }) => {
|
2699
|
+
var _a, _b;
|
2700
|
+
const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
2701
|
+
const { density, isLoading } = getState();
|
2702
|
+
const iconButtonProps = parseFromValuesOrFunc(muiExpandAllButtonProps, {
|
2752
2703
|
table,
|
2753
|
-
})
|
2754
|
-
const
|
2755
|
-
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
column.setFilterValue(column.getFilterValue() === undefined
|
2762
|
-
? 'true'
|
2763
|
-
: column.getFilterValue() === 'true'
|
2764
|
-
? 'false'
|
2765
|
-
: undefined);
|
2766
|
-
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
|
2767
|
-
}, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))) })), disableTypography: true, label: (_c = checkboxProps.title) !== null && _c !== void 0 ? _c : filterLabel, sx: { color: 'text.secondary', mt: '-4px', fontWeight: 'normal' }, title: undefined }) }));
|
2704
|
+
});
|
2705
|
+
const isAllRowsExpanded = getIsAllRowsExpanded();
|
2706
|
+
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isAllRowsExpanded)
|
2707
|
+
? localization.collapseAll
|
2708
|
+
: localization.expandAll, children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsx(KeyboardDoubleArrowDownIcon, { style: {
|
2709
|
+
transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
|
2710
|
+
transition: 'transform 150ms',
|
2711
|
+
} })) })) }) }));
|
2768
2712
|
};
|
2769
2713
|
|
2770
|
-
const
|
2714
|
+
const MRT_ExpandButton = ({ row, table, }) => {
|
2771
2715
|
var _a, _b;
|
2772
|
-
const { options: {
|
2773
|
-
const {
|
2774
|
-
const
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
const isMounted = useRef(false);
|
2793
|
-
useEffect(() => {
|
2794
|
-
if (isMounted.current) {
|
2795
|
-
if (columnFilterValue === undefined) {
|
2796
|
-
setFilterValues([min, max]);
|
2797
|
-
}
|
2798
|
-
else if (Array.isArray(columnFilterValue)) {
|
2799
|
-
setFilterValues(columnFilterValue);
|
2800
|
-
}
|
2801
|
-
}
|
2802
|
-
isMounted.current = true;
|
2803
|
-
}, [columnFilterValue, min, max]);
|
2804
|
-
return (jsxs(Stack, { children: [jsx(Slider, Object.assign({ disableSwap: true, min: min, max: max, onChange: (_event, values) => {
|
2805
|
-
setFilterValues(values);
|
2806
|
-
}, onChangeCommitted: (_event, value) => {
|
2807
|
-
if (Array.isArray(value)) {
|
2808
|
-
if (value[0] <= min && value[1] >= max) {
|
2809
|
-
//if the user has selected the entire range, remove the filter
|
2810
|
-
column.setFilterValue(undefined);
|
2811
|
-
}
|
2812
|
-
else {
|
2813
|
-
column.setFilterValue(value);
|
2814
|
-
}
|
2815
|
-
}
|
2816
|
-
}, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
|
2817
|
-
input: {
|
2818
|
-
ref: (node) => {
|
2819
|
-
var _a, _b;
|
2820
|
-
if (node) {
|
2821
|
-
filterInputRefs.current[`${column.id}-0`] = node;
|
2822
|
-
// @ts-ignore
|
2823
|
-
if ((_b = (_a = sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.slotProps) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.ref) {
|
2824
|
-
//@ts-ignore
|
2825
|
-
sliderProps.slotProps.input.ref = node;
|
2826
|
-
}
|
2827
|
-
}
|
2828
|
-
},
|
2829
|
-
},
|
2830
|
-
}, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsx(FormHelperText, { sx: {
|
2831
|
-
m: '-3px -6px',
|
2832
|
-
fontSize: '0.75rem',
|
2833
|
-
lineHeight: '0.8rem',
|
2834
|
-
whiteSpace: 'nowrap',
|
2835
|
-
}, children: localization.filterMode.replace('{filterType}',
|
2836
|
-
// @ts-ignore
|
2837
|
-
localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
2838
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
|
2716
|
+
const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, renderDetailPanel, }, } = table;
|
2717
|
+
const { density } = getState();
|
2718
|
+
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
2719
|
+
row,
|
2720
|
+
table,
|
2721
|
+
});
|
2722
|
+
const canExpand = row.getCanExpand();
|
2723
|
+
const isExpanded = row.getIsExpanded();
|
2724
|
+
const handleToggleExpand = (event) => {
|
2725
|
+
var _a;
|
2726
|
+
event.stopPropagation();
|
2727
|
+
row.toggleExpanded();
|
2728
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
2729
|
+
};
|
2730
|
+
return (jsx(Tooltip, { arrow: true, disableHoverListener: !canExpand && !renderDetailPanel, enterDelay: 1000, enterNextDelay: 1000, title: ((_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : isExpanded)
|
2731
|
+
? localization.collapse
|
2732
|
+
: localization.expand, children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsx(ExpandMoreIcon, { style: {
|
2733
|
+
transform: `rotate(${!canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0}deg)`,
|
2734
|
+
transition: 'transform 150ms',
|
2735
|
+
} })) })) }) }));
|
2839
2736
|
};
|
2840
2737
|
|
2841
|
-
const
|
2842
|
-
const { getState } = table;
|
2843
|
-
const {
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2738
|
+
const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) => {
|
2739
|
+
const { getState, options: { enableEditing, icons: { EditIcon }, localization, renderRowActionMenuItems, }, } = table;
|
2740
|
+
const { density } = getState();
|
2741
|
+
return (jsxs(Menu, { MenuListProps: {
|
2742
|
+
dense: density === 'compact',
|
2743
|
+
}, anchorEl: anchorEl, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl, children: [parseFromValuesOrFunc(enableEditing, row) && (jsx(MenuItem, { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
2744
|
+
closeMenu: () => setAnchorEl(null),
|
2745
|
+
row,
|
2746
|
+
table,
|
2747
|
+
})] }));
|
2848
2748
|
};
|
2849
2749
|
|
2850
|
-
const
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
|
2859
|
-
.replace('{column}', String(columnDef.header))
|
2860
|
-
.replace('{filterType}',
|
2861
|
-
// @ts-ignore
|
2862
|
-
localization[`filter${((_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _b === void 0 ? void 0 : _b.toUpperCase()) +
|
2863
|
-
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`])
|
2864
|
-
.replace('{filterValue}', `"${Array.isArray(column.getFilterValue())
|
2865
|
-
? column.getFilterValue().join(`" ${isRangeFilter ? localization.and : localization.or} "`)
|
2866
|
-
: column.getFilterValue()}"`)
|
2867
|
-
.replace('" "', '');
|
2868
|
-
return (jsx(Grow, { unmountOnExit: true, in: (!!column.getFilterValue() && !isRangeFilter) ||
|
2869
|
-
(isRangeFilter && // @ts-ignore
|
2870
|
-
(!!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[0]) || !!((_d = column.getFilterValue()) === null || _d === void 0 ? void 0 : _d[1]))), children: jsx(Box, { component: "span", sx: { flex: '0 0' }, children: jsx(Tooltip, { arrow: true, placement: "top", title: filterTooltip, children: jsx(IconButton, { disableRipple: true, onClick: (event) => {
|
2871
|
-
setShowColumnFilters(true);
|
2872
|
-
queueMicrotask(() => {
|
2873
|
-
var _a, _b;
|
2874
|
-
(_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus();
|
2875
|
-
(_b = filterInputRefs.current[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.select();
|
2876
|
-
});
|
2877
|
-
event.stopPropagation();
|
2878
|
-
}, size: "small", sx: {
|
2879
|
-
height: '12px',
|
2880
|
-
m: 0,
|
2881
|
-
opacity: 0.8,
|
2882
|
-
p: '2px',
|
2883
|
-
transform: 'scale(0.66)',
|
2884
|
-
width: '12px',
|
2885
|
-
}, children: jsx(FilterAltIcon, {}) }) }) }) }));
|
2750
|
+
const commonIconButtonStyles = {
|
2751
|
+
'&:hover': {
|
2752
|
+
opacity: 1,
|
2753
|
+
},
|
2754
|
+
height: '2rem',
|
2755
|
+
ml: '10px',
|
2756
|
+
opacity: 0.5,
|
2757
|
+
transition: 'opacity 150ms',
|
2758
|
+
width: '2rem',
|
2886
2759
|
};
|
2887
|
-
|
2888
|
-
const
|
2889
|
-
const {
|
2890
|
-
const
|
2891
|
-
const
|
2892
|
-
const
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
(
|
2899
|
-
setDraggingColumn(column);
|
2900
|
-
event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
2760
|
+
const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
2761
|
+
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
2762
|
+
const { creatingRow, editingRow } = getState();
|
2763
|
+
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
2764
|
+
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
|
2765
|
+
const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
|
2766
|
+
(isEditing && editDisplayMode === 'row');
|
2767
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
2768
|
+
const handleOpenRowActionMenu = (event) => {
|
2769
|
+
event.stopPropagation();
|
2770
|
+
event.preventDefault();
|
2771
|
+
setAnchorEl(event.currentTarget);
|
2901
2772
|
};
|
2902
|
-
const
|
2903
|
-
|
2904
|
-
(
|
2905
|
-
|
2906
|
-
column.toggleGrouping();
|
2907
|
-
}
|
2908
|
-
else if (enableColumnOrdering &&
|
2909
|
-
hoveredColumn &&
|
2910
|
-
(hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
|
2911
|
-
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
2912
|
-
}
|
2913
|
-
setDraggingColumn(null);
|
2914
|
-
setHoveredColumn(null);
|
2773
|
+
const handleStartEditMode = (event) => {
|
2774
|
+
event.stopPropagation();
|
2775
|
+
setEditingRow(Object.assign({}, row));
|
2776
|
+
setAnchorEl(null);
|
2915
2777
|
};
|
2916
|
-
return (jsx(
|
2778
|
+
return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
2779
|
+
parseFromValuesOrFunc(enableEditing, row) ? (jsx(Tooltip, { arrow: true, placement: "right", title: localization.edit, children: jsx(IconButton, { "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles, children: jsx(EditIcon, {}) }) })) : renderRowActionMenuItems ? (jsxs(Fragment, { children: [jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsx(IconButton, { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles, children: jsx(MoreHorizIcon, {}) }) }), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
|
2917
2780
|
};
|
2918
2781
|
|
2919
|
-
const
|
2782
|
+
const MRT_SelectCheckbox = ({ row, selectAll, table, }) => {
|
2920
2783
|
var _a;
|
2921
|
-
const { getState, options: {
|
2922
|
-
const { density } = getState();
|
2923
|
-
const
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2927
|
-
|
2928
|
-
|
2929
|
-
|
2930
|
-
|
2931
|
-
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2784
|
+
const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
|
2785
|
+
const { density, isLoading } = getState();
|
2786
|
+
const checkboxProps = !row
|
2787
|
+
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
2788
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, { row, table });
|
2789
|
+
const allRowsSelected = selectAll
|
2790
|
+
? selectAllMode === 'page'
|
2791
|
+
? table.getIsAllPageRowsSelected()
|
2792
|
+
: table.getIsAllRowsSelected()
|
2793
|
+
: undefined;
|
2794
|
+
const commonProps = Object.assign(Object.assign({ checked: selectAll ? allRowsSelected : row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading || (row && !row.getCanSelect()), inputProps: {
|
2795
|
+
'aria-label': selectAll
|
2796
|
+
? localization.toggleSelectAll
|
2797
|
+
: localization.toggleSelectRow,
|
2798
|
+
}, onChange: (event) => {
|
2799
|
+
event.stopPropagation();
|
2800
|
+
row
|
2801
|
+
? row.getToggleSelectedHandler()(event)
|
2802
|
+
: selectAllMode === 'all'
|
2803
|
+
? table.getToggleAllRowsSelectedHandler()(event)
|
2804
|
+
: table.getToggleAllPageRowsSelectedHandler()(event);
|
2805
|
+
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
|
2806
|
+
if (row) {
|
2807
|
+
row.pin(!row.getIsPinned() && event.target.checked
|
2808
|
+
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
|
2809
|
+
? 'bottom'
|
2810
|
+
: 'top'
|
2811
|
+
: false);
|
2812
|
+
}
|
2813
|
+
else {
|
2814
|
+
table.setRowPinning({ bottom: [], top: [] });
|
2815
|
+
}
|
2816
|
+
}
|
2817
|
+
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
2818
|
+
var _a;
|
2819
|
+
e.stopPropagation();
|
2820
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
2821
|
+
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.5rem', zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
|
2822
|
+
return (jsx(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
2823
|
+
? localization.toggleSelectAll
|
2824
|
+
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: selectAll
|
2825
|
+
? table.getIsSomeRowsSelected() && !allRowsSelected
|
2826
|
+
: row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps))) }));
|
2952
2827
|
};
|
2953
2828
|
|
2954
|
-
const
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
2961
|
-
?
|
2962
|
-
|
2963
|
-
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
|
2977
|
-
|
2978
|
-
|
2829
|
+
const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOptions, }) => {
|
2830
|
+
var _a, _b;
|
2831
|
+
return useMemo(() => {
|
2832
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
2833
|
+
return [
|
2834
|
+
((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-pin') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), header: tableOptions.localization.pin, size: 60 }, tableOptions.defaultDisplayColumn), (_c = tableOptions.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-pin']), { id: 'mrt-row-pin' }),
|
2835
|
+
((_e = (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), header: tableOptions.localization.move, size: 60 }, tableOptions.defaultDisplayColumn), (_f = tableOptions.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-drag']), { id: 'mrt-row-drag' }),
|
2836
|
+
(((_h = (_g = tableOptions.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-actions') ||
|
2837
|
+
(creatingRow && tableOptions.createDisplayMode === 'row')) && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: tableOptions.localization.actions, size: 70 }, tableOptions.defaultDisplayColumn), (_j = tableOptions.displayColumnDefOptions) === null || _j === void 0 ? void 0 : _j['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
2838
|
+
((_l = (_k = tableOptions.state) === null || _k === void 0 ? void 0 : _k.columnOrder) !== null && _l !== void 0 ? _l : columnOrder).includes('mrt-row-expand') &&
|
2839
|
+
showExpandColumn(tableOptions, (_o = (_m = tableOptions.state) === null || _m === void 0 ? void 0 : _m.grouping) !== null && _o !== void 0 ? _o : grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_ExpandButton, { row: row, table: table })), Header: tableOptions.enableExpandAll
|
2840
|
+
? ({ table }) => jsx(MRT_ExpandAllButton, { table: table })
|
2841
|
+
: null, header: tableOptions.localization.expand, size: 60 }, tableOptions.defaultDisplayColumn), (_p = tableOptions.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
2842
|
+
((_r = (_q = tableOptions.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: tableOptions.enableSelectAll &&
|
2843
|
+
tableOptions.enableMultiRowSelection
|
2844
|
+
? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
2845
|
+
: null, header: tableOptions.localization.select, size: 60 }, tableOptions.defaultDisplayColumn), (_s = tableOptions.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-select']), { id: 'mrt-row-select' }),
|
2846
|
+
((_u = (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnOrder) !== null && _u !== void 0 ? _u : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber, header: tableOptions.localization.rowNumbers, size: 60 }, tableOptions.defaultDisplayColumn), (_v = tableOptions.displayColumnDefOptions) === null || _v === void 0 ? void 0 : _v['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
2847
|
+
].filter(Boolean);
|
2848
|
+
}, [
|
2849
|
+
columnOrder,
|
2850
|
+
grouping,
|
2851
|
+
tableOptions.displayColumnDefOptions,
|
2852
|
+
tableOptions.editDisplayMode,
|
2853
|
+
tableOptions.enableColumnDragging,
|
2854
|
+
tableOptions.enableColumnFilterModes,
|
2855
|
+
tableOptions.enableColumnOrdering,
|
2856
|
+
tableOptions.enableEditing,
|
2857
|
+
tableOptions.enableExpandAll,
|
2858
|
+
tableOptions.enableExpanding,
|
2859
|
+
tableOptions.enableGrouping,
|
2860
|
+
tableOptions.enableRowActions,
|
2861
|
+
tableOptions.enableRowDragging,
|
2862
|
+
tableOptions.enableRowNumbers,
|
2863
|
+
tableOptions.enableRowOrdering,
|
2864
|
+
tableOptions.enableRowSelection,
|
2865
|
+
tableOptions.enableSelectAll,
|
2866
|
+
tableOptions.localization,
|
2867
|
+
tableOptions.positionActionsColumn,
|
2868
|
+
tableOptions.renderDetailPanel,
|
2869
|
+
tableOptions.renderRowActionMenuItems,
|
2870
|
+
tableOptions.renderRowActions,
|
2871
|
+
(_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder,
|
2872
|
+
(_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.grouping,
|
2873
|
+
]);
|
2979
2874
|
};
|
2980
2875
|
|
2981
|
-
const
|
2982
|
-
|
2983
|
-
const
|
2984
|
-
const
|
2985
|
-
const
|
2986
|
-
const
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
2876
|
+
const useMRT_Effects = (table) => {
|
2877
|
+
const { getState, options: { enablePagination, rowCount }, } = table;
|
2878
|
+
const { globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
|
2879
|
+
const isMounted = useRef(false);
|
2880
|
+
const initialBodyHeight = useRef();
|
2881
|
+
const previousTop = useRef();
|
2882
|
+
useEffect(() => {
|
2883
|
+
if (typeof window !== 'undefined') {
|
2884
|
+
initialBodyHeight.current = document.body.style.height;
|
2885
|
+
}
|
2886
|
+
}, []);
|
2887
|
+
useEffect(() => {
|
2888
|
+
if (isMounted && typeof window !== 'undefined') {
|
2889
|
+
if (isFullScreen) {
|
2890
|
+
previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
|
2891
|
+
document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
|
2892
|
+
}
|
2893
|
+
else {
|
2894
|
+
document.body.style.height = initialBodyHeight.current;
|
2895
|
+
if (!previousTop.current)
|
2896
|
+
return;
|
2897
|
+
//restore scroll position
|
2898
|
+
window.scrollTo({
|
2899
|
+
behavior: 'instant',
|
2900
|
+
top: -1 * previousTop.current,
|
2901
|
+
});
|
2902
|
+
}
|
2903
|
+
}
|
2904
|
+
isMounted.current = true;
|
2905
|
+
}, [isFullScreen]);
|
2906
|
+
//if page index is out of bounds, set it to the last page
|
2907
|
+
useEffect(() => {
|
2908
|
+
if (!enablePagination || isLoading || showSkeletons)
|
2909
|
+
return;
|
2910
|
+
const { pageIndex, pageSize } = pagination;
|
2911
|
+
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
|
2912
|
+
const firstVisibleRowIndex = pageIndex * pageSize;
|
2913
|
+
if (firstVisibleRowIndex > totalRowCount) {
|
2914
|
+
table.setPageIndex(Math.floor(totalRowCount / pageSize));
|
3019
2915
|
}
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
2916
|
+
}, [rowCount, table.getPrePaginationRowModel().rows.length]);
|
2917
|
+
//turn off sort when global filter is looking for ranked results
|
2918
|
+
const appliedSort = useRef(sorting);
|
2919
|
+
useEffect(() => {
|
2920
|
+
if (sorting.length) {
|
2921
|
+
appliedSort.current = sorting;
|
3024
2922
|
}
|
3025
|
-
|
3026
|
-
|
2923
|
+
}, [sorting]);
|
2924
|
+
useEffect(() => {
|
2925
|
+
if (!getCanRankRows(table))
|
2926
|
+
return;
|
2927
|
+
if (globalFilter) {
|
2928
|
+
table.setSorting([]);
|
3027
2929
|
}
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
table,
|
3033
|
-
})) !== null && _a !== void 0 ? _a : columnDef.header;
|
3034
|
-
return (jsxs(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
|
3035
|
-
if (node) {
|
3036
|
-
tableHeadCellRefs.current[column.id] = node;
|
3037
|
-
}
|
3038
|
-
} }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: layoutMode === 'grid' ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
|
3039
|
-
? '0.5rem'
|
3040
|
-
: density === 'comfortable'
|
3041
|
-
? columnDefType === 'display'
|
3042
|
-
? '0.75rem'
|
3043
|
-
: '1rem'
|
3044
|
-
: columnDefType === 'display'
|
3045
|
-
? '1rem 1.25rem'
|
3046
|
-
: '1.5rem', pb: columnDefType === 'display'
|
3047
|
-
? 0
|
3048
|
-
: showColumnFilters || density === 'compact'
|
3049
|
-
? '0.4rem'
|
3050
|
-
: '0.6rem', pt: columnDefType === 'group' || density === 'compact'
|
3051
|
-
? '0.25rem'
|
3052
|
-
: density === 'comfortable'
|
3053
|
-
? '.75rem'
|
3054
|
-
: '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
3055
|
-
? 3
|
3056
|
-
: column.getIsPinned() && columnDefType !== 'group'
|
3057
|
-
? 2
|
3058
|
-
: 1 }, getCommonCellStyles({
|
3059
|
-
column,
|
3060
|
-
header,
|
3061
|
-
table,
|
3062
|
-
tableCellProps,
|
3063
|
-
theme,
|
3064
|
-
})), draggingBorders)), children: [header.isPlaceholder ? null : (jsxs(Box, { className: "Mui-TableHeadCell-Content", sx: {
|
3065
|
-
alignItems: 'center',
|
3066
|
-
display: 'flex',
|
3067
|
-
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
3068
|
-
justifyContent: columnDefType === 'group' || (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
3069
|
-
? 'center'
|
3070
|
-
: column.getCanResize()
|
3071
|
-
? 'space-between'
|
3072
|
-
: 'flex-start',
|
3073
|
-
position: 'relative',
|
3074
|
-
width: '100%',
|
3075
|
-
}, children: [jsxs(Box, { className: "Mui-TableHeadCell-Content-Labels", onClick: column.getToggleSortingHandler(), sx: {
|
3076
|
-
alignItems: 'center',
|
3077
|
-
cursor: column.getCanSort() && columnDefType !== 'group'
|
3078
|
-
? 'pointer'
|
3079
|
-
: undefined,
|
3080
|
-
display: 'flex',
|
3081
|
-
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
3082
|
-
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
3083
|
-
pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
3084
|
-
? `${headerPL}rem`
|
3085
|
-
: undefined,
|
3086
|
-
}, children: [jsx(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
3087
|
-
minWidth: `${Math.min((_c = (_b = columnDef.header) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0, 5)}ch`,
|
3088
|
-
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
3089
|
-
textOverflow: 'ellipsis',
|
3090
|
-
whiteSpace: ((_f = (_d = columnDef.header) === null || _d === void 0 ? void 0 : _d.length) !== null && _f !== void 0 ? _f : 0) < 20 ? 'nowrap' : 'normal',
|
3091
|
-
'&:hover': {
|
3092
|
-
textOverflow: 'clip',
|
3093
|
-
},
|
3094
|
-
}, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: { whiteSpace: 'nowrap' }, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3095
|
-
current: tableHeadCellRefs.current[column.id],
|
3096
|
-
} })), showColumnActions && (jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] })), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
|
2930
|
+
else {
|
2931
|
+
table.setSorting(() => appliedSort.current || []);
|
2932
|
+
}
|
2933
|
+
}, [globalFilter]);
|
3097
2934
|
};
|
3098
2935
|
|
3099
|
-
const
|
3100
|
-
|
3101
|
-
const
|
3102
|
-
|
3103
|
-
|
2936
|
+
const useMRT_TableInstance = (tableOptions) => {
|
2937
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
2938
|
+
const bottomToolbarRef = useRef(null);
|
2939
|
+
const editInputRefs = useRef({});
|
2940
|
+
const filterInputRefs = useRef({});
|
2941
|
+
const searchInputRef = useRef(null);
|
2942
|
+
const tableContainerRef = useRef(null);
|
2943
|
+
const tableHeadCellRefs = useRef({});
|
2944
|
+
const tablePaperRef = useRef(null);
|
2945
|
+
const topToolbarRef = useRef(null);
|
2946
|
+
const tableHeadRef = useRef(null);
|
2947
|
+
const tableFooterRef = useRef(null);
|
2948
|
+
const initialState = useMemo(() => {
|
2949
|
+
var _a, _b, _c;
|
2950
|
+
const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
|
2951
|
+
initState.columnOrder =
|
2952
|
+
(_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
|
2953
|
+
initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
|
2954
|
+
return initState;
|
2955
|
+
}, []);
|
2956
|
+
const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
|
2957
|
+
const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
|
2958
|
+
var _a, _b, _c, _d;
|
2959
|
+
return ({
|
2960
|
+
[getColumnId(col)]: col.filterFn instanceof Function
|
2961
|
+
? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
|
2962
|
+
: (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
|
2963
|
+
});
|
2964
|
+
})));
|
2965
|
+
const [columnOrder, setColumnOrder] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
|
2966
|
+
const [density, setDensity] = useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
|
2967
|
+
const [draggingColumn, setDraggingColumn] = useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
|
2968
|
+
const [draggingRow, setDraggingRow] = useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
|
2969
|
+
const [editingCell, setEditingCell] = useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
|
2970
|
+
const [editingRow, setEditingRow] = useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
|
2971
|
+
const [globalFilterFn, setGlobalFilterFn] = useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
|
2972
|
+
const [grouping, setGrouping] = useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
|
2973
|
+
const [hoveredColumn, setHoveredColumn] = useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
|
2974
|
+
const [hoveredRow, setHoveredRow] = useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
|
2975
|
+
const [isFullScreen, setIsFullScreen] = useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
|
2976
|
+
const [showAlertBanner, setShowAlertBanner] = useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
|
2977
|
+
const [showColumnFilters, setShowColumnFilters] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
|
2978
|
+
const [showGlobalFilter, setShowGlobalFilter] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
|
2979
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
|
2980
|
+
const displayColumns = useMRT_DisplayColumns({
|
2981
|
+
columnOrder,
|
2982
|
+
creatingRow,
|
2983
|
+
grouping,
|
2984
|
+
tableOptions,
|
3104
2985
|
});
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
}
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
|
3121
|
-
|
3122
|
-
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3126
|
-
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
|
2986
|
+
const columnDefs = useMemo(() => {
|
2987
|
+
var _a, _b, _c;
|
2988
|
+
return prepareColumns({
|
2989
|
+
aggregationFns: tableOptions.aggregationFns,
|
2990
|
+
columnDefs: [...displayColumns, ...tableOptions.columns],
|
2991
|
+
columnFilterFns: (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
|
2992
|
+
defaultDisplayColumn: (_c = tableOptions.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
|
2993
|
+
filterFns: tableOptions.filterFns,
|
2994
|
+
sortingFns: tableOptions.sortingFns,
|
2995
|
+
});
|
2996
|
+
}, [
|
2997
|
+
columnFilterFns,
|
2998
|
+
displayColumns,
|
2999
|
+
tableOptions.columns,
|
3000
|
+
(_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnFilterFns,
|
3001
|
+
]);
|
3002
|
+
const data = useMemo(() => {
|
3003
|
+
var _a, _b, _c, _d, _e;
|
3004
|
+
return (((_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
|
3005
|
+
!tableOptions.data.length
|
3006
|
+
? [
|
3007
|
+
...Array(((_d = (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
|
3008
|
+
((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
|
3009
|
+
10).fill(null),
|
3010
|
+
].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
|
3011
|
+
[getColumnId(col)]: null,
|
3012
|
+
}))))
|
3013
|
+
: tableOptions.data;
|
3014
|
+
}, [
|
3015
|
+
tableOptions.data,
|
3016
|
+
(_u = tableOptions.state) === null || _u === void 0 ? void 0 : _u.isLoading,
|
3017
|
+
(_v = tableOptions.state) === null || _v === void 0 ? void 0 : _v.showSkeletons,
|
3018
|
+
]);
|
3019
|
+
//@ts-ignore
|
3020
|
+
const table = useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
|
3021
|
+
? getExpandedRowModel()
|
3022
|
+
: undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
|
3023
|
+
? getFacetedMinMaxValues()
|
3024
|
+
: undefined, getFacetedRowModel: tableOptions.enableFacetedValues
|
3025
|
+
? getFacetedRowModel()
|
3026
|
+
: undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
|
3027
|
+
? getFacetedUniqueValues()
|
3028
|
+
: undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
|
3029
|
+
tableOptions.enableGlobalFilter ||
|
3030
|
+
tableOptions.enableFilters
|
3031
|
+
? getFilteredRowModel()
|
3032
|
+
: undefined, getGroupedRowModel: tableOptions.enableGrouping
|
3033
|
+
? getGroupedRowModel()
|
3034
|
+
: undefined, getPaginationRowModel: tableOptions.enablePagination
|
3035
|
+
? getPaginationRowModel()
|
3036
|
+
: undefined, getSortedRowModel: tableOptions.enableSorting
|
3037
|
+
? getSortedRowModel()
|
3038
|
+
: undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping }, tableOptions), {
|
3039
|
+
//@ts-ignore
|
3040
|
+
columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ columnFilterFns,
|
3041
|
+
columnOrder,
|
3042
|
+
creatingRow,
|
3043
|
+
density,
|
3044
|
+
draggingColumn,
|
3045
|
+
draggingRow,
|
3046
|
+
editingCell,
|
3047
|
+
editingRow,
|
3048
|
+
globalFilterFn,
|
3049
|
+
grouping,
|
3050
|
+
hoveredColumn,
|
3051
|
+
hoveredRow,
|
3052
|
+
isFullScreen,
|
3053
|
+
showAlertBanner,
|
3054
|
+
showColumnFilters,
|
3055
|
+
showGlobalFilter,
|
3056
|
+
showToolbarDropZone }, tableOptions.state) }));
|
3057
|
+
// @ts-ignore
|
3058
|
+
table.refs = {
|
3059
|
+
// @ts-ignore
|
3060
|
+
bottomToolbarRef,
|
3061
|
+
editInputRefs,
|
3062
|
+
filterInputRefs,
|
3063
|
+
// @ts-ignore
|
3064
|
+
searchInputRef,
|
3065
|
+
// @ts-ignore
|
3066
|
+
tableContainerRef,
|
3067
|
+
// @ts-ignore
|
3068
|
+
tableFooterRef,
|
3069
|
+
tableHeadCellRefs,
|
3070
|
+
// @ts-ignore
|
3071
|
+
tableHeadRef,
|
3072
|
+
// @ts-ignore
|
3073
|
+
tablePaperRef,
|
3074
|
+
// @ts-ignore
|
3075
|
+
topToolbarRef,
|
3076
|
+
};
|
3077
|
+
const setCreatingRow = (row) => {
|
3078
|
+
var _a, _b;
|
3079
|
+
let _row = row;
|
3080
|
+
if (row === true) {
|
3081
|
+
_row = createRow(table);
|
3082
|
+
}
|
3083
|
+
(_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
|
3084
|
+
};
|
3085
|
+
table.setCreatingRow = setCreatingRow;
|
3086
|
+
table.setColumnFilterFns =
|
3087
|
+
(_x = tableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
|
3088
|
+
table.setDensity = (_y = tableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
|
3089
|
+
table.setDraggingColumn =
|
3090
|
+
(_z = tableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
|
3091
|
+
table.setDraggingRow = (_0 = tableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
|
3092
|
+
table.setEditingCell = (_1 = tableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
|
3093
|
+
table.setEditingRow = (_2 = tableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
|
3094
|
+
table.setGlobalFilterFn =
|
3095
|
+
(_3 = tableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
|
3096
|
+
table.setHoveredColumn =
|
3097
|
+
(_4 = tableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
|
3098
|
+
table.setHoveredRow = (_5 = tableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
|
3099
|
+
table.setIsFullScreen = (_6 = tableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
|
3100
|
+
table.setShowAlertBanner =
|
3101
|
+
(_7 = tableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
|
3102
|
+
table.setShowColumnFilters =
|
3103
|
+
(_8 = tableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
|
3104
|
+
table.setShowGlobalFilter =
|
3105
|
+
(_9 = tableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
|
3106
|
+
table.setShowToolbarDropZone =
|
3107
|
+
(_10 = tableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
|
3108
|
+
useMRT_Effects(table);
|
3109
|
+
return table;
|
3150
3110
|
};
|
3151
3111
|
|
3152
|
-
const
|
3153
|
-
var _a;
|
3154
|
-
const { options: { layoutMode, muiTableFooterRowProps }, } = table;
|
3155
|
-
// if no content in row, skip row
|
3156
|
-
if (!((_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
3157
|
-
!!header.column.columnDef.footer) ||
|
3158
|
-
header.column.columnDef.Footer)))
|
3159
|
-
return null;
|
3160
|
-
const tableRowProps = parseFromValuesOrFunc(muiTableFooterRowProps, {
|
3161
|
-
footerGroup,
|
3162
|
-
table,
|
3163
|
-
});
|
3164
|
-
return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.04), display: layoutMode === 'grid' ? 'flex' : 'table-row', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter) => {
|
3165
|
-
const footer = virtualColumns
|
3166
|
-
? footerGroup.headers[footerOrVirtualFooter.index]
|
3167
|
-
: footerOrVirtualFooter;
|
3168
|
-
return (jsx(MRT_TableFooterCell, { footer: footer, table: table }, footer.id));
|
3169
|
-
}), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
|
3170
|
-
};
|
3112
|
+
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
3171
3113
|
|
3172
|
-
const
|
3173
|
-
const
|
3174
|
-
|
3175
|
-
const tableFooterProps = parseFromValuesOrFunc(muiTableFooterProps, {
|
3176
|
-
table,
|
3114
|
+
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
3115
|
+
const itemRank = rankItem(row.getValue(columnId), filterValue, {
|
3116
|
+
threshold: rankings.MATCHES,
|
3177
3117
|
});
|
3178
|
-
|
3179
|
-
return
|
3180
|
-
? theme.palette.mode === 'light'
|
3181
|
-
? `1px solid ${theme.palette.grey[300]}`
|
3182
|
-
: `1px solid ${theme.palette.grey[700]}`
|
3183
|
-
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), ref: (ref) => {
|
3184
|
-
tableFooterRef.current = ref;
|
3185
|
-
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
3186
|
-
// @ts-ignore
|
3187
|
-
tableFooterProps.ref.current = ref;
|
3188
|
-
}
|
3189
|
-
}, children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { footerGroup: footerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, footerGroup.id))) })));
|
3118
|
+
addMeta(itemRank);
|
3119
|
+
return itemRank.passed;
|
3190
3120
|
};
|
3121
|
+
fuzzy.autoRemove = (val) => !val;
|
3122
|
+
const contains = (row, id, filterValue) => row
|
3123
|
+
.getValue(id)
|
3124
|
+
.toString()
|
3125
|
+
.toLowerCase()
|
3126
|
+
.trim()
|
3127
|
+
.includes(filterValue.toString().toLowerCase().trim());
|
3128
|
+
contains.autoRemove = (val) => !val;
|
3129
|
+
const startsWith = (row, id, filterValue) => row
|
3130
|
+
.getValue(id)
|
3131
|
+
.toString()
|
3132
|
+
.toLowerCase()
|
3133
|
+
.trim()
|
3134
|
+
.startsWith(filterValue.toString().toLowerCase().trim());
|
3135
|
+
startsWith.autoRemove = (val) => !val;
|
3136
|
+
const endsWith = (row, id, filterValue) => row
|
3137
|
+
.getValue(id)
|
3138
|
+
.toString()
|
3139
|
+
.toLowerCase()
|
3140
|
+
.trim()
|
3141
|
+
.endsWith(filterValue.toString().toLowerCase().trim());
|
3142
|
+
endsWith.autoRemove = (val) => !val;
|
3143
|
+
const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
|
3144
|
+
filterValue.toString().toLowerCase().trim();
|
3145
|
+
equals.autoRemove = (val) => !val;
|
3146
|
+
const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
|
3147
|
+
filterValue.toString().toLowerCase().trim();
|
3148
|
+
notEquals.autoRemove = (val) => !val;
|
3149
|
+
const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3150
|
+
? +row.getValue(id) > +filterValue
|
3151
|
+
: row.getValue(id).toString().toLowerCase().trim() >
|
3152
|
+
filterValue.toString().toLowerCase().trim();
|
3153
|
+
greaterThan.autoRemove = (val) => !val;
|
3154
|
+
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
3155
|
+
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
3156
|
+
const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3157
|
+
? +row.getValue(id) < +filterValue
|
3158
|
+
: row.getValue(id).toString().toLowerCase().trim() <
|
3159
|
+
filterValue.toString().toLowerCase().trim();
|
3160
|
+
lessThan.autoRemove = (val) => !val;
|
3161
|
+
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
3162
|
+
lessThanOrEqualTo.autoRemove = (val) => !val;
|
3163
|
+
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
3164
|
+
greaterThan(row, id, filterValues[0])) &&
|
3165
|
+
((!isNaN(+filterValues[0]) &&
|
3166
|
+
!isNaN(+filterValues[1]) &&
|
3167
|
+
+filterValues[0] > +filterValues[1]) ||
|
3168
|
+
['', undefined].includes(filterValues[1]) ||
|
3169
|
+
lessThan(row, id, filterValues[1]));
|
3170
|
+
between.autoRemove = (val) => !val;
|
3171
|
+
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
3172
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
3173
|
+
((!isNaN(+filterValues[0]) &&
|
3174
|
+
!isNaN(+filterValues[1]) &&
|
3175
|
+
+filterValues[0] > +filterValues[1]) ||
|
3176
|
+
['', undefined].includes(filterValues[1]) ||
|
3177
|
+
lessThanOrEqualTo(row, id, filterValues[1]));
|
3178
|
+
betweenInclusive.autoRemove = (val) => !val;
|
3179
|
+
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
3180
|
+
empty.autoRemove = (val) => !val;
|
3181
|
+
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
3182
|
+
notEmpty.autoRemove = (val) => !val;
|
3183
|
+
const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
3184
|
+
betweenInclusive,
|
3185
|
+
contains,
|
3186
|
+
empty,
|
3187
|
+
endsWith,
|
3188
|
+
equals,
|
3189
|
+
fuzzy,
|
3190
|
+
greaterThan,
|
3191
|
+
greaterThanOrEqualTo,
|
3192
|
+
lessThan,
|
3193
|
+
lessThanOrEqualTo,
|
3194
|
+
notEmpty,
|
3195
|
+
notEquals,
|
3196
|
+
startsWith });
|
3191
3197
|
|
3192
|
-
const
|
3193
|
-
|
3194
|
-
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3200
|
-
|
3201
|
-
|
3202
|
-
|
3203
|
-
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
3209
|
-
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
|
3222
|
-
table
|
3223
|
-
.getRightLeafColumns()
|
3224
|
-
.map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
|
3225
|
-
]
|
3226
|
-
: [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
|
3227
|
-
const columnVirtualizer = enableColumnVirtualization
|
3228
|
-
? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => [
|
3229
|
-
...new Set([
|
3230
|
-
...leftPinnedIndexes,
|
3231
|
-
...defaultRangeExtractor(range),
|
3232
|
-
...rightPinnedIndexes,
|
3233
|
-
]),
|
3234
|
-
], [leftPinnedIndexes, rightPinnedIndexes]) }, columnVirtualizerProps))
|
3235
|
-
: undefined;
|
3236
|
-
if (columnVirtualizerInstanceRef && columnVirtualizer) {
|
3237
|
-
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
3238
|
-
}
|
3239
|
-
const virtualColumns = columnVirtualizer
|
3240
|
-
? columnVirtualizer.getVirtualItems()
|
3241
|
-
: undefined;
|
3242
|
-
let virtualPaddingLeft;
|
3243
|
-
let virtualPaddingRight;
|
3244
|
-
if (columnVirtualizer && (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)) {
|
3245
|
-
virtualPaddingLeft = (_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0;
|
3246
|
-
virtualPaddingRight =
|
3247
|
-
columnVirtualizer.getTotalSize() -
|
3248
|
-
((_d = (_c = virtualColumns[virtualColumns.length - 1 - rightPinnedIndexes.length]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
|
3249
|
-
}
|
3250
|
-
const props = {
|
3251
|
-
table,
|
3252
|
-
virtualColumns,
|
3253
|
-
virtualPaddingLeft,
|
3254
|
-
virtualPaddingRight,
|
3255
|
-
};
|
3256
|
-
return (jsx(Fragment, { children: jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), children: [enableTableHead && jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, props))] })) }));
|
3198
|
+
const MRT_Default_Icons = {
|
3199
|
+
ArrowDownwardIcon,
|
3200
|
+
ArrowRightIcon,
|
3201
|
+
CancelIcon,
|
3202
|
+
ClearAllIcon,
|
3203
|
+
CloseIcon,
|
3204
|
+
DensityLargeIcon,
|
3205
|
+
DensityMediumIcon,
|
3206
|
+
DensitySmallIcon,
|
3207
|
+
DragHandleIcon,
|
3208
|
+
DynamicFeedIcon,
|
3209
|
+
EditIcon,
|
3210
|
+
ExpandMoreIcon,
|
3211
|
+
FilterAltIcon,
|
3212
|
+
FilterListIcon,
|
3213
|
+
FilterListOffIcon,
|
3214
|
+
FullscreenExitIcon,
|
3215
|
+
FullscreenIcon,
|
3216
|
+
KeyboardDoubleArrowDownIcon,
|
3217
|
+
MoreHorizIcon,
|
3218
|
+
MoreVertIcon,
|
3219
|
+
PushPinIcon,
|
3220
|
+
RestartAltIcon,
|
3221
|
+
SaveIcon,
|
3222
|
+
SearchIcon,
|
3223
|
+
SearchOffIcon,
|
3224
|
+
SortIcon,
|
3225
|
+
ViewColumnIcon,
|
3226
|
+
VisibilityOffIcon,
|
3257
3227
|
};
|
3258
3228
|
|
3259
|
-
const
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
|
3290
|
-
|
3291
|
-
|
3292
|
-
|
3293
|
-
|
3294
|
-
|
3295
|
-
|
3296
|
-
|
3229
|
+
const MRT_Localization_EN = {
|
3230
|
+
actions: 'Actions',
|
3231
|
+
and: 'and',
|
3232
|
+
cancel: 'Cancel',
|
3233
|
+
changeFilterMode: 'Change filter mode',
|
3234
|
+
changeSearchMode: 'Change search mode',
|
3235
|
+
clearFilter: 'Clear filter',
|
3236
|
+
clearSearch: 'Clear search',
|
3237
|
+
clearSort: 'Clear sort',
|
3238
|
+
clickToCopy: 'Click to copy',
|
3239
|
+
collapse: 'Collapse',
|
3240
|
+
collapseAll: 'Collapse all',
|
3241
|
+
columnActions: 'Column Actions',
|
3242
|
+
copiedToClipboard: 'Copied to clipboard',
|
3243
|
+
dropToGroupBy: 'Drop to group by {column}',
|
3244
|
+
edit: 'Edit',
|
3245
|
+
expand: 'Expand',
|
3246
|
+
expandAll: 'Expand all',
|
3247
|
+
filterArrIncludes: 'Includes',
|
3248
|
+
filterArrIncludesAll: 'Includes all',
|
3249
|
+
filterArrIncludesSome: 'Includes',
|
3250
|
+
filterBetween: 'Between',
|
3251
|
+
filterBetweenInclusive: 'Between Inclusive',
|
3252
|
+
filterByColumn: 'Filter by {column}',
|
3253
|
+
filterContains: 'Contains',
|
3254
|
+
filterEmpty: 'Empty',
|
3255
|
+
filterEndsWith: 'Ends With',
|
3256
|
+
filterEquals: 'Equals',
|
3257
|
+
filterEqualsString: 'Equals',
|
3258
|
+
filterFuzzy: 'Fuzzy',
|
3259
|
+
filterGreaterThan: 'Greater Than',
|
3260
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
3261
|
+
filterInNumberRange: 'Between',
|
3262
|
+
filterIncludesString: 'Contains',
|
3263
|
+
filterIncludesStringSensitive: 'Contains',
|
3264
|
+
filterLessThan: 'Less Than',
|
3265
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
3266
|
+
filterMode: 'Filter Mode: {filterType}',
|
3267
|
+
filterNotEmpty: 'Not Empty',
|
3268
|
+
filterNotEquals: 'Not Equals',
|
3269
|
+
filterStartsWith: 'Starts With',
|
3270
|
+
filterWeakEquals: 'Equals',
|
3271
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
3272
|
+
goToFirstPage: 'Go to first page',
|
3273
|
+
goToLastPage: 'Go to last page',
|
3274
|
+
goToNextPage: 'Go to next page',
|
3275
|
+
goToPreviousPage: 'Go to previous page',
|
3276
|
+
grab: 'Grab',
|
3277
|
+
groupByColumn: 'Group by {column}',
|
3278
|
+
groupedBy: 'Grouped by ',
|
3279
|
+
hideAll: 'Hide all',
|
3280
|
+
hideColumn: 'Hide {column} column',
|
3281
|
+
max: 'Max',
|
3282
|
+
min: 'Min',
|
3283
|
+
move: 'Move',
|
3284
|
+
noRecordsToDisplay: 'No records to display',
|
3285
|
+
noResultsFound: 'No results found',
|
3286
|
+
of: 'of',
|
3287
|
+
or: 'or',
|
3288
|
+
pin: 'Pin',
|
3289
|
+
pinToLeft: 'Pin to left',
|
3290
|
+
pinToRight: 'Pin to right',
|
3291
|
+
resetColumnSize: 'Reset column size',
|
3292
|
+
resetOrder: 'Reset order',
|
3293
|
+
rowActions: 'Row Actions',
|
3294
|
+
rowNumber: '#',
|
3295
|
+
rowNumbers: 'Row Numbers',
|
3296
|
+
rowsPerPage: 'Rows per page',
|
3297
|
+
save: 'Save',
|
3298
|
+
search: 'Search',
|
3299
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
3300
|
+
select: 'Select',
|
3301
|
+
showAll: 'Show all',
|
3302
|
+
showAllColumns: 'Show all columns',
|
3303
|
+
showHideColumns: 'Show/Hide columns',
|
3304
|
+
showHideFilters: 'Show/Hide filters',
|
3305
|
+
showHideSearch: 'Show/Hide search',
|
3306
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
3307
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
3308
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
3309
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
3310
|
+
thenBy: ', then by ',
|
3311
|
+
toggleDensity: 'Toggle density',
|
3312
|
+
toggleFullScreen: 'Toggle full screen',
|
3313
|
+
toggleSelectAll: 'Toggle select all',
|
3314
|
+
toggleSelectRow: 'Toggle select row',
|
3315
|
+
toggleVisibility: 'Toggle visibility',
|
3316
|
+
ungroupByColumn: 'Ungroup by {column}',
|
3317
|
+
unpin: 'Unpin',
|
3318
|
+
unpinAll: 'Unpin all',
|
3297
3319
|
};
|
3298
3320
|
|
3299
|
-
const
|
3300
|
-
|
3301
|
-
|
3302
|
-
const
|
3303
|
-
const
|
3304
|
-
const
|
3305
|
-
|
3306
|
-
});
|
3307
|
-
|
3308
|
-
|
3309
|
-
|
3310
|
-
|
3311
|
-
|
3312
|
-
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
|
3327
|
-
|
3328
|
-
|
3329
|
-
|
3330
|
-
|
3331
|
-
|
3321
|
+
const useMRT_TableOptions = (_a) => {
|
3322
|
+
var _b;
|
3323
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode = 'semantic', localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
3324
|
+
const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
3325
|
+
const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
3326
|
+
const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
|
3327
|
+
const _filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
|
3328
|
+
const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
|
3329
|
+
const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
|
3330
|
+
const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
|
3331
|
+
if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
|
3332
|
+
layoutMode = 'grid';
|
3333
|
+
}
|
3334
|
+
if (rest.enableRowVirtualization) {
|
3335
|
+
enableStickyHeader = true;
|
3336
|
+
}
|
3337
|
+
if (enablePagination === false && manualPagination === undefined) {
|
3338
|
+
manualPagination = true;
|
3339
|
+
}
|
3340
|
+
if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
|
3341
|
+
manualFiltering = true;
|
3342
|
+
manualGrouping = true;
|
3343
|
+
manualPagination = true;
|
3344
|
+
manualSorting = true;
|
3345
|
+
}
|
3346
|
+
return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
|
3347
|
+
columnFilterDisplayMode,
|
3348
|
+
columnResizeMode,
|
3349
|
+
createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
|
3350
|
+
enableBottomToolbar,
|
3351
|
+
enableColumnActions,
|
3352
|
+
enableColumnFilters,
|
3353
|
+
enableColumnOrdering,
|
3354
|
+
enableColumnPinning,
|
3355
|
+
enableColumnResizing,
|
3356
|
+
enableDensityToggle,
|
3357
|
+
enableExpandAll,
|
3358
|
+
enableExpanding,
|
3359
|
+
enableFilterMatchHighlighting,
|
3360
|
+
enableFilters,
|
3361
|
+
enableFullScreenToggle,
|
3362
|
+
enableGlobalFilter,
|
3363
|
+
enableGlobalFilterRankedResults,
|
3364
|
+
enableGrouping,
|
3365
|
+
enableHiding,
|
3366
|
+
enableMultiRowSelection,
|
3367
|
+
enableMultiSort,
|
3368
|
+
enablePagination,
|
3369
|
+
enableRowPinning,
|
3370
|
+
enableRowSelection,
|
3371
|
+
enableSelectAll,
|
3372
|
+
enableSorting,
|
3373
|
+
enableStickyHeader,
|
3374
|
+
enableTableFooter,
|
3375
|
+
enableTableHead,
|
3376
|
+
enableToolbarInternalActions,
|
3377
|
+
enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode, localization: _localization, manualFiltering,
|
3378
|
+
manualGrouping,
|
3379
|
+
manualPagination,
|
3380
|
+
manualSorting,
|
3381
|
+
paginationDisplayMode,
|
3382
|
+
positionActionsColumn,
|
3383
|
+
positionExpandColumn,
|
3384
|
+
positionGlobalFilter,
|
3385
|
+
positionPagination,
|
3386
|
+
positionToolbarAlertBanner,
|
3387
|
+
positionToolbarDropZone,
|
3388
|
+
rowNumberMode,
|
3389
|
+
rowPinningDisplayMode,
|
3390
|
+
selectAllMode, sortingFns: _sortingFns }, rest);
|
3332
3391
|
};
|
3333
3392
|
|
3334
|
-
const
|
3335
|
-
|
3336
|
-
const
|
3337
|
-
|
3338
|
-
const tablePaperProps = parseFromValuesOrFunc(muiTablePaperProps, { table });
|
3339
|
-
return (jsxs(Paper, Object.assign({ elevation: 2 }, tablePaperProps, { ref: (ref) => {
|
3340
|
-
tablePaperRef.current = ref;
|
3341
|
-
if (tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref) {
|
3342
|
-
//@ts-ignore
|
3343
|
-
tablePaperProps.ref.current = ref;
|
3344
|
-
}
|
3345
|
-
}, sx: (theme) => (Object.assign({ overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx, theme))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), (isFullScreen
|
3346
|
-
? {
|
3347
|
-
bottom: 0,
|
3348
|
-
height: '100vh',
|
3349
|
-
left: 0,
|
3350
|
-
margin: 0,
|
3351
|
-
maxHeight: '100vh',
|
3352
|
-
maxWidth: '100vw',
|
3353
|
-
padding: 0,
|
3354
|
-
position: 'fixed',
|
3355
|
-
right: 0,
|
3356
|
-
top: 0,
|
3357
|
-
width: '100vw',
|
3358
|
-
zIndex: 10,
|
3359
|
-
}
|
3360
|
-
: {})), children: [enableTopToolbar &&
|
3361
|
-
((_a = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _a !== void 0 ? _a : (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
|
3362
|
-
((_b = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _b !== void 0 ? _b : (jsx(MRT_BottomToolbar, { table: table })))] })));
|
3393
|
+
const useMaterialReactTable = (tableOptions) => {
|
3394
|
+
const parsedTableOptions = useMRT_TableOptions(tableOptions);
|
3395
|
+
const tableInstance = useMRT_TableInstance(parsedTableOptions);
|
3396
|
+
return tableInstance;
|
3363
3397
|
};
|
3364
3398
|
|
3365
3399
|
const isTableInstanceProp = (props) => props.table !== undefined;
|