material-react-table-narender 3.0.4 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4363 @@
1
+ import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, aggregationFns, filterFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
2
+ import { useMemo, useState, useId, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
3
+ import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import IconButton from '@mui/material/IconButton';
6
+ import Tooltip from '@mui/material/Tooltip';
7
+ import Box from '@mui/material/Box';
8
+ import Button from '@mui/material/Button';
9
+ import CircularProgress from '@mui/material/CircularProgress';
10
+ import { lighten, darken, alpha, useTheme } from '@mui/material/styles';
11
+ import Menu from '@mui/material/Menu';
12
+ import ListItemIcon from '@mui/material/ListItemIcon';
13
+ import MenuItem from '@mui/material/MenuItem';
14
+ import Stack from '@mui/material/Stack';
15
+ import Checkbox from '@mui/material/Checkbox';
16
+ import Radio from '@mui/material/Radio';
17
+ import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
18
+ import ArrowRightIcon from '@mui/icons-material/ArrowRight';
19
+ import CancelIcon from '@mui/icons-material/Cancel';
20
+ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
21
+ import ChevronRightIcon from '@mui/icons-material/ChevronRight';
22
+ import ClearAllIcon from '@mui/icons-material/ClearAll';
23
+ import CloseIcon from '@mui/icons-material/Close';
24
+ import ContentCopy from '@mui/icons-material/ContentCopy';
25
+ import DensityLargeIcon from '@mui/icons-material/DensityLarge';
26
+ import DensityMediumIcon from '@mui/icons-material/DensityMedium';
27
+ import DensitySmallIcon from '@mui/icons-material/DensitySmall';
28
+ import DragHandleIcon from '@mui/icons-material/DragHandle';
29
+ import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
30
+ import EditIcon from '@mui/icons-material/Edit';
31
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
32
+ import FilterAltIcon from '@mui/icons-material/FilterAlt';
33
+ import FilterListIcon from '@mui/icons-material/FilterList';
34
+ import FilterListOffIcon from '@mui/icons-material/FilterListOff';
35
+ import FirstPageIcon from '@mui/icons-material/FirstPage';
36
+ import FullscreenIcon from '@mui/icons-material/Fullscreen';
37
+ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
38
+ import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
39
+ import LastPageIcon from '@mui/icons-material/LastPage';
40
+ import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
41
+ import MoreVertIcon from '@mui/icons-material/MoreVert';
42
+ import PushPinIcon from '@mui/icons-material/PushPin';
43
+ import RestartAltIcon from '@mui/icons-material/RestartAlt';
44
+ import SaveIcon from '@mui/icons-material/Save';
45
+ import SearchIcon from '@mui/icons-material/Search';
46
+ import SearchOffIcon from '@mui/icons-material/SearchOff';
47
+ import SortIcon from '@mui/icons-material/Sort';
48
+ import SyncAltIcon from '@mui/icons-material/SyncAlt';
49
+ import ViewColumnIcon from '@mui/icons-material/ViewColumn';
50
+ import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
51
+ import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
52
+ import Paper from '@mui/material/Paper';
53
+ import TableContainer from '@mui/material/TableContainer';
54
+ import Table from '@mui/material/Table';
55
+ import TableBody from '@mui/material/TableBody';
56
+ import Typography from '@mui/material/Typography';
57
+ import TableRow from '@mui/material/TableRow';
58
+ import Skeleton from '@mui/material/Skeleton';
59
+ import TableCell from '@mui/material/TableCell';
60
+ import highlightWords from 'highlight-words';
61
+ import TextField from '@mui/material/TextField';
62
+ import Collapse from '@mui/material/Collapse';
63
+ import TableFooter from '@mui/material/TableFooter';
64
+ import TableHead from '@mui/material/TableHead';
65
+ import FormControlLabel from '@mui/material/FormControlLabel';
66
+ import Autocomplete from '@mui/material/Autocomplete';
67
+ import Chip from '@mui/material/Chip';
68
+ import InputAdornment from '@mui/material/InputAdornment';
69
+ import { debounce } from '@mui/material/utils';
70
+ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
71
+ import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
72
+ import { TimePicker } from '@mui/x-date-pickers/TimePicker';
73
+ import FormHelperText from '@mui/material/FormHelperText';
74
+ import Slider from '@mui/material/Slider';
75
+ import Grow from '@mui/material/Grow';
76
+ import Popover from '@mui/material/Popover';
77
+ import Divider from '@mui/material/Divider';
78
+ import Badge from '@mui/material/Badge';
79
+ import TableSortLabel from '@mui/material/TableSortLabel';
80
+ import Alert from '@mui/material/Alert';
81
+ import AlertTitle from '@mui/material/AlertTitle';
82
+ import Dialog from '@mui/material/Dialog';
83
+ import DialogActions from '@mui/material/DialogActions';
84
+ import DialogContent from '@mui/material/DialogContent';
85
+ import DialogTitle from '@mui/material/DialogTitle';
86
+ import useMediaQuery from '@mui/material/useMediaQuery';
87
+ import LinearProgress from '@mui/material/LinearProgress';
88
+ import InputLabel from '@mui/material/InputLabel';
89
+ import Pagination from '@mui/material/Pagination';
90
+ import PaginationItem from '@mui/material/PaginationItem';
91
+ import Select from '@mui/material/Select';
92
+ import Fade from '@mui/material/Fade';
93
+ import Switch from '@mui/material/Switch';
94
+
95
+ 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; };
96
+ const getAllLeafColumnDefs = (columns) => {
97
+ const allLeafColumnDefs = [];
98
+ const getLeafColumns = (cols) => {
99
+ cols.forEach((col) => {
100
+ if (col.columns) {
101
+ getLeafColumns(col.columns);
102
+ }
103
+ else {
104
+ allLeafColumnDefs.push(col);
105
+ }
106
+ });
107
+ };
108
+ getLeafColumns(columns);
109
+ return allLeafColumnDefs;
110
+ };
111
+ const prepareColumns = ({ columnDefs, tableOptions, }) => {
112
+ const { aggregationFns = {}, defaultDisplayColumn, filterFns = {}, sortingFns = {}, state: { columnFilterFns = {} } = {}, } = tableOptions;
113
+ return columnDefs.map((columnDef) => {
114
+ var _a, _b;
115
+ //assign columnId
116
+ if (!columnDef.id)
117
+ columnDef.id = getColumnId(columnDef);
118
+ //assign columnDefType
119
+ if (!columnDef.columnDefType)
120
+ columnDef.columnDefType = 'data';
121
+ if ((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length) {
122
+ columnDef.columnDefType = 'group';
123
+ //recursively prepare columns if this is a group column
124
+ columnDef.columns = prepareColumns({
125
+ columnDefs: columnDef.columns,
126
+ tableOptions,
127
+ });
128
+ }
129
+ else if (columnDef.columnDefType === 'data') {
130
+ //assign aggregationFns if multiple aggregationFns are provided
131
+ if (Array.isArray(columnDef.aggregationFn)) {
132
+ const aggFns = columnDef.aggregationFn;
133
+ columnDef.aggregationFn = (columnId, leafRows, childRows) => aggFns.map((fn) => { var _a; return (_a = aggregationFns[fn]) === null || _a === void 0 ? void 0 : _a.call(aggregationFns, columnId, leafRows, childRows); });
134
+ }
135
+ //assign filterFns
136
+ if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
137
+ columnDef.filterFn =
138
+ (_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
139
+ columnDef._filterFn =
140
+ columnFilterFns[columnDef.id];
141
+ }
142
+ //assign sortingFns
143
+ if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
144
+ // @ts-ignore
145
+ columnDef.sortingFn = sortingFns[columnDef.sortingFn];
146
+ }
147
+ }
148
+ else if (columnDef.columnDefType === 'display') {
149
+ columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
150
+ }
151
+ return columnDef;
152
+ });
153
+ };
154
+ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
155
+ if (draggedColumn.getCanPin()) {
156
+ draggedColumn.pin(targetColumn.getIsPinned());
157
+ }
158
+ const newColumnOrder = [...columnOrder];
159
+ newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
160
+ return newColumnOrder;
161
+ };
162
+ const getDefaultColumnFilterFn = (columnDef) => {
163
+ const { filterVariant } = columnDef;
164
+ if (filterVariant === 'multi-select')
165
+ return 'arrIncludesSome';
166
+ if (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range'))
167
+ return 'betweenInclusive';
168
+ if (filterVariant === 'select' || filterVariant === 'checkbox')
169
+ return 'equals';
170
+ return 'fuzzy';
171
+ };
172
+ const getColumnFilterInfo = ({ header, table, }) => {
173
+ var _a;
174
+ const { options: { columnFilterModeOptions }, } = table;
175
+ const { column } = header;
176
+ const { columnDef } = column;
177
+ const { filterVariant } = columnDef;
178
+ const isDateFilter = !!((filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) || (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')));
179
+ const isAutocompleteFilter = filterVariant === 'autocomplete';
180
+ const isRangeFilter = (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range')) ||
181
+ ['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
182
+ const isSelectFilter = filterVariant === 'select';
183
+ const isMultiSelectFilter = filterVariant === 'multi-select';
184
+ const isTextboxFilter = ['autocomplete', 'text'].includes(filterVariant) ||
185
+ (!isSelectFilter && !isMultiSelectFilter);
186
+ const currentFilterOption = columnDef._filterFn;
187
+ const allowedColumnFilterOptions = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _a !== void 0 ? _a : columnFilterModeOptions;
188
+ const facetedUniqueValues = column.getFacetedUniqueValues();
189
+ return {
190
+ allowedColumnFilterOptions,
191
+ currentFilterOption,
192
+ facetedUniqueValues,
193
+ isAutocompleteFilter,
194
+ isDateFilter,
195
+ isMultiSelectFilter,
196
+ isRangeFilter,
197
+ isSelectFilter,
198
+ isTextboxFilter,
199
+ };
200
+ };
201
+ const useDropdownOptions = ({ header, table, }) => {
202
+ const { column } = header;
203
+ const { columnDef } = column;
204
+ const { facetedUniqueValues, isAutocompleteFilter, isMultiSelectFilter, isSelectFilter, } = getColumnFilterInfo({ header, table });
205
+ return useMemo(() => {
206
+ var _a;
207
+ return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter || isAutocompleteFilter) &&
208
+ facetedUniqueValues
209
+ ? Array.from(facetedUniqueValues.keys())
210
+ .filter((value) => value !== null && value !== undefined)
211
+ .sort((a, b) => a.localeCompare(b))
212
+ : undefined);
213
+ }, [
214
+ columnDef.filterSelectOptions,
215
+ facetedUniqueValues,
216
+ isMultiSelectFilter,
217
+ isSelectFilter,
218
+ ]);
219
+ };
220
+
221
+ const flexRender = flexRender$1;
222
+ function createMRTColumnHelper() {
223
+ return {
224
+ accessor: (accessor, column) => {
225
+ return typeof accessor === 'function'
226
+ ? Object.assign(Object.assign({}, column), { accessorFn: accessor })
227
+ : Object.assign(Object.assign({}, column), { accessorKey: accessor });
228
+ },
229
+ display: (column) => column,
230
+ group: (column) => column,
231
+ };
232
+ }
233
+ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => createRow$1(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
234
+ [getColumnId(col)]: '',
235
+ }))), rowIndex, depth, subRows, parentId);
236
+
237
+ const fuzzy$1 = (rowA, rowB, columnId) => {
238
+ let dir = 0;
239
+ if (rowA.columnFiltersMeta[columnId]) {
240
+ dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
241
+ }
242
+ // Provide a fallback for when the item ranks are equal
243
+ return dir === 0
244
+ ? sortingFns.alphanumeric(rowA, rowB, columnId)
245
+ : dir;
246
+ };
247
+ const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
248
+ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
249
+ Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
250
+
251
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
252
+ const getValueAndLabel = (option) => {
253
+ var _a, _b;
254
+ let label = '';
255
+ let value = '';
256
+ if (option) {
257
+ if (typeof option !== 'object') {
258
+ label = option;
259
+ value = option;
260
+ }
261
+ else {
262
+ label = (_a = option.label) !== null && _a !== void 0 ? _a : option.value;
263
+ value = (_b = option.value) !== null && _b !== void 0 ? _b : label;
264
+ }
265
+ }
266
+ return { label, value };
267
+ };
268
+
269
+ const getMRT_Rows = (table, all) => {
270
+ const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
271
+ const { creatingRow, pagination } = getState();
272
+ const isRankingRows = getIsRankingRows(table);
273
+ let rows = [];
274
+ if (!isRankingRows) {
275
+ rows =
276
+ !enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
277
+ ? all
278
+ ? getPrePaginationRowModel().rows
279
+ : getRowModel().rows
280
+ : getCenterRows();
281
+ }
282
+ else {
283
+ // fuzzy ranking adjustments
284
+ rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
285
+ if (enablePagination && !manualPagination && !all) {
286
+ const start = pagination.pageIndex * pagination.pageSize;
287
+ rows = rows.slice(start, start + pagination.pageSize);
288
+ }
289
+ if (enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
290
+ // "re-center-ize" the rows (no top or bottom pinned rows unless sticky)
291
+ rows = rows.filter((row) => !row.getIsPinned());
292
+ }
293
+ }
294
+ // row pinning adjustments
295
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
296
+ const centerPinnedRowIds = rows
297
+ .filter((row) => row.getIsPinned())
298
+ .map((r) => r.id);
299
+ rows = [
300
+ ...getTopRows().filter((row) => !centerPinnedRowIds.includes(row.id)),
301
+ ...rows,
302
+ ];
303
+ }
304
+ // blank inserted creating row adjustments
305
+ if (positionCreatingRow !== undefined &&
306
+ creatingRow &&
307
+ createDisplayMode === 'row') {
308
+ const creatingRowIndex = !isNaN(+positionCreatingRow)
309
+ ? +positionCreatingRow
310
+ : positionCreatingRow === 'top'
311
+ ? 0
312
+ : rows.length;
313
+ rows = [
314
+ ...rows.slice(0, creatingRowIndex),
315
+ creatingRow,
316
+ ...rows.slice(creatingRowIndex),
317
+ ];
318
+ }
319
+ return rows;
320
+ };
321
+ const getCanRankRows = (table) => {
322
+ const { getState, options: { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, }, } = table;
323
+ const { expanded, globalFilterFn } = getState();
324
+ return (!manualExpanding &&
325
+ !manualFiltering &&
326
+ !manualGrouping &&
327
+ !manualSorting &&
328
+ enableGlobalFilterRankedResults &&
329
+ globalFilterFn === 'fuzzy' &&
330
+ expanded !== true &&
331
+ !Object.values(expanded).some(Boolean));
332
+ };
333
+ const getIsRankingRows = (table) => {
334
+ const { globalFilter, sorting } = table.getState();
335
+ return (getCanRankRows(table) &&
336
+ globalFilter &&
337
+ !Object.values(sorting).some(Boolean));
338
+ };
339
+ const getIsRowSelected = ({ row, table, }) => {
340
+ const { options: { enableRowSelection }, } = table;
341
+ return (row.getIsSelected() ||
342
+ (parseFromValuesOrFunc(enableRowSelection, row) &&
343
+ row.getCanSelectSubRows() &&
344
+ row.getIsAllSubRowsSelected()));
345
+ };
346
+ const getMRT_RowSelectionHandler = ({ row, staticRowIndex = 0, table, }) => (event, value) => {
347
+ var _a;
348
+ const { getState, options: { enableBatchRowSelection, enableMultiRowSelection, enableRowPinning, manualPagination, rowPinningDisplayMode, }, refs: { lastSelectedRowId: lastSelectedRowId }, } = table;
349
+ const { pagination: { pageIndex, pageSize }, } = getState();
350
+ const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
351
+ const wasCurrentRowChecked = getIsRowSelected({ row, table });
352
+ // toggle selection of this row
353
+ row.toggleSelected(value !== null && value !== void 0 ? value : !wasCurrentRowChecked);
354
+ const changedRowIds = new Set([row.id]);
355
+ // if shift key is pressed, select all rows between last selected and this one
356
+ if (enableBatchRowSelection &&
357
+ enableMultiRowSelection &&
358
+ event.nativeEvent.shiftKey &&
359
+ lastSelectedRowId.current !== null) {
360
+ const rows = getMRT_Rows(table, true);
361
+ const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
362
+ if (lastIndex !== -1) {
363
+ const isLastIndexChecked = getIsRowSelected({
364
+ row: rows === null || rows === void 0 ? void 0 : rows[lastIndex],
365
+ table,
366
+ });
367
+ const currentIndex = staticRowIndex + paginationOffset;
368
+ const [start, end] = lastIndex < currentIndex
369
+ ? [lastIndex, currentIndex]
370
+ : [currentIndex, lastIndex];
371
+ // toggle selection of all rows between last selected and this one
372
+ // but only if the last selected row is not the same as the current one
373
+ if (wasCurrentRowChecked !== isLastIndexChecked) {
374
+ for (let i = start; i <= end; i++) {
375
+ rows[i].toggleSelected(!wasCurrentRowChecked);
376
+ changedRowIds.add(rows[i].id);
377
+ }
378
+ }
379
+ }
380
+ }
381
+ // record the last selected row id
382
+ lastSelectedRowId.current = row.id;
383
+ // if all sub rows were selected, unselect them
384
+ if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
385
+ (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
386
+ }
387
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
388
+ changedRowIds.forEach((rowId) => {
389
+ const rowToTogglePin = table.getRow(rowId);
390
+ rowToTogglePin.pin(!wasCurrentRowChecked //was not previously pinned or selected
391
+ ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
392
+ ? 'bottom'
393
+ : 'top'
394
+ : false);
395
+ });
396
+ }
397
+ };
398
+ const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
399
+ const { options: { enableRowPinning, rowPinningDisplayMode, selectAllMode }, refs: { lastSelectedRowId }, } = table;
400
+ selectAllMode === 'all' || forceAll
401
+ ? table.toggleAllRowsSelected(value !== null && value !== void 0 ? value : event.target.checked)
402
+ : table.toggleAllPageRowsSelected(value !== null && value !== void 0 ? value : event.target.checked);
403
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
404
+ table.setRowPinning({ bottom: [], top: [] });
405
+ }
406
+ lastSelectedRowId.current = null;
407
+ };
408
+
409
+ const isWinCtrlMacMeta = (event) => {
410
+ return ((event.ctrlKey && navigator.platform.toLowerCase().includes('win')) ||
411
+ (event.metaKey && navigator.platform.toLowerCase().includes('mac')));
412
+ };
413
+ const isCellEditable = ({ cell, table, }) => {
414
+ const { enableEditing } = table.options;
415
+ const { column: { columnDef }, row, } = cell;
416
+ return (!cell.getIsPlaceholder() &&
417
+ parseFromValuesOrFunc(enableEditing, row) &&
418
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
419
+ };
420
+ const openEditingCell = ({ cell, table, }) => {
421
+ const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
422
+ const { column } = cell;
423
+ if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
424
+ table.setEditingCell(cell);
425
+ queueMicrotask(() => {
426
+ var _a, _b;
427
+ const textField = (_a = editInputRefs.current) === null || _a === void 0 ? void 0 : _a[column.id];
428
+ if (textField) {
429
+ textField.focus();
430
+ (_b = textField.select) === null || _b === void 0 ? void 0 : _b.call(textField);
431
+ }
432
+ });
433
+ }
434
+ };
435
+ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
436
+ var _a, _b, _c, _d, _e, _f, _g, _h;
437
+ if (!table.options.enableKeyboardShortcuts)
438
+ return;
439
+ if (event.isPropagationStopped())
440
+ return;
441
+ const currentCell = event.currentTarget;
442
+ if (cellValue && isWinCtrlMacMeta(event) && event.key === 'c') {
443
+ navigator.clipboard.writeText(cellValue);
444
+ }
445
+ else if (['Enter', ' '].includes(event.key)) {
446
+ if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
447
+ event.preventDefault();
448
+ getMRT_RowSelectionHandler({
449
+ row: cell.row,
450
+ table,
451
+ //@ts-ignore
452
+ staticRowIndex: +event.target.getAttribute('data-index'),
453
+ })(event);
454
+ }
455
+ else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
456
+ table.options.enableSelectAll) {
457
+ event.preventDefault();
458
+ getMRT_SelectAllHandler({
459
+ table,
460
+ })(event);
461
+ }
462
+ else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
463
+ (cell.row.getCanExpand() ||
464
+ ((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
465
+ event.preventDefault();
466
+ cell.row.toggleExpanded();
467
+ }
468
+ else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
469
+ table.options.enableExpandAll) {
470
+ event.preventDefault();
471
+ table.toggleAllRowsExpanded();
472
+ }
473
+ else if ((cell === null || cell === void 0 ? void 0 : cell.column.id) === 'mrt-row-pin') {
474
+ event.preventDefault();
475
+ cell.row.getIsPinned()
476
+ ? cell.row.pin(false)
477
+ : cell.row.pin(((_g = table.options.rowPinningDisplayMode) === null || _g === void 0 ? void 0 : _g.includes('bottom'))
478
+ ? 'bottom'
479
+ : 'top');
480
+ }
481
+ else if (header && isWinCtrlMacMeta(event)) {
482
+ const actionsButton = currentCell.querySelector(`button[aria-label="${table.options.localization.columnActions}"]`);
483
+ if (actionsButton) {
484
+ actionsButton.click();
485
+ }
486
+ }
487
+ else if ((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.getCanSort()) {
488
+ event.preventDefault();
489
+ header.column.toggleSorting();
490
+ }
491
+ }
492
+ else if ([
493
+ 'ArrowRight',
494
+ 'ArrowLeft',
495
+ 'ArrowUp',
496
+ 'ArrowDown',
497
+ 'Home',
498
+ 'End',
499
+ 'PageUp',
500
+ 'PageDown',
501
+ ].includes(event.key)) {
502
+ event.preventDefault();
503
+ const currentRow = parentElement || currentCell.closest('tr');
504
+ const tableElement = containerElement || currentCell.closest('table');
505
+ const allCells = cellElements ||
506
+ Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
507
+ const currentCellIndex = allCells.indexOf(currentCell);
508
+ const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
509
+ let nextCell = undefined;
510
+ //home/end first or last cell in row
511
+ const findEdgeCell = (rowIndex, edge) => {
512
+ var _a;
513
+ const row = rowIndex === 'c'
514
+ ? currentRow
515
+ : rowIndex === 'f'
516
+ ? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
517
+ : (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
518
+ const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
519
+ const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
520
+ return targetCell;
521
+ };
522
+ //page up/down first or last cell in column
523
+ const findBottomTopCell = (columnIndex, edge) => {
524
+ var _a;
525
+ const row = edge === 't'
526
+ ? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
527
+ : (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
528
+ const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
529
+ const targetCell = rowCells[columnIndex];
530
+ return targetCell;
531
+ };
532
+ const findAdjacentCell = (columnIndex, searchDirection) => {
533
+ const searchArray = searchDirection === 'f'
534
+ ? allCells.slice(currentCellIndex + 1)
535
+ : allCells.slice(0, currentCellIndex).reverse();
536
+ return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
537
+ };
538
+ switch (event.key) {
539
+ case 'ArrowRight':
540
+ nextCell = findAdjacentCell(currentIndex + 1, 'f');
541
+ break;
542
+ case 'ArrowLeft':
543
+ nextCell = findAdjacentCell(currentIndex - 1, 'b');
544
+ break;
545
+ case 'ArrowUp':
546
+ nextCell = findAdjacentCell(currentIndex, 'b');
547
+ break;
548
+ case 'ArrowDown':
549
+ nextCell = findAdjacentCell(currentIndex, 'f');
550
+ break;
551
+ case 'Home':
552
+ nextCell = findEdgeCell(isWinCtrlMacMeta(event) ? 'f' : 'c', 'f');
553
+ break;
554
+ case 'End':
555
+ nextCell = findEdgeCell(isWinCtrlMacMeta(event) ? 'l' : 'c', 'l');
556
+ break;
557
+ case 'PageUp':
558
+ nextCell = findBottomTopCell(currentIndex, 't');
559
+ break;
560
+ case 'PageDown':
561
+ nextCell = findBottomTopCell(currentIndex, 'b');
562
+ break;
563
+ }
564
+ if (nextCell) {
565
+ nextCell.focus();
566
+ }
567
+ }
568
+ };
569
+
570
+ function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
571
+ const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
572
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
573
+ }
574
+ const showRowPinningColumn = (tableOptions) => {
575
+ const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
576
+ return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
577
+ };
578
+ const showRowDragColumn = (tableOptions) => {
579
+ const { enableRowDragging, enableRowOrdering } = tableOptions;
580
+ return !!(enableRowDragging || enableRowOrdering);
581
+ };
582
+ const showRowExpandColumn = (tableOptions) => {
583
+ const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
584
+ return !!(enableExpanding ||
585
+ (enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
586
+ renderDetailPanel);
587
+ };
588
+ const showRowActionsColumn = (tableOptions) => {
589
+ const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
590
+ return !!(enableRowActions ||
591
+ (creatingRow && createDisplayMode === 'row') ||
592
+ (enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
593
+ };
594
+ const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
595
+ const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
596
+ const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
597
+ const getLeadingDisplayColumnIds = (tableOptions) => [
598
+ showRowPinningColumn(tableOptions) && 'mrt-row-pin',
599
+ showRowDragColumn(tableOptions) && 'mrt-row-drag',
600
+ tableOptions.positionActionsColumn === 'first' &&
601
+ showRowActionsColumn(tableOptions) &&
602
+ 'mrt-row-actions',
603
+ tableOptions.positionExpandColumn === 'first' &&
604
+ showRowExpandColumn(tableOptions) &&
605
+ 'mrt-row-expand',
606
+ showRowSelectionColumn(tableOptions) && 'mrt-row-select',
607
+ showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
608
+ ].filter(Boolean);
609
+ const getTrailingDisplayColumnIds = (tableOptions) => [
610
+ tableOptions.positionActionsColumn === 'last' &&
611
+ showRowActionsColumn(tableOptions) &&
612
+ 'mrt-row-actions',
613
+ tableOptions.positionExpandColumn === 'last' &&
614
+ showRowExpandColumn(tableOptions) &&
615
+ 'mrt-row-expand',
616
+ showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
617
+ ].filter(Boolean);
618
+ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
619
+ const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
620
+ const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
621
+ const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
622
+ const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
623
+ let allLeafColumnDefIds = reset
624
+ ? defaultColumnDefIds
625
+ : Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
626
+ allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
627
+ !trailingDisplayColIds.includes(colId));
628
+ return [
629
+ ...leadingDisplayColIds,
630
+ ...allLeafColumnDefIds,
631
+ ...trailingDisplayColIds,
632
+ ];
633
+ };
634
+
635
+ const MRT_AggregationFns = Object.assign({}, aggregationFns);
636
+
637
+ const fuzzy = (row, columnId, filterValue, addMeta) => {
638
+ const itemRank = rankItem(row.getValue(columnId), filterValue, {
639
+ threshold: rankings.MATCHES,
640
+ });
641
+ addMeta(itemRank);
642
+ return itemRank.passed;
643
+ };
644
+ fuzzy.autoRemove = (val) => !val;
645
+ const contains = (row, id, filterValue) => {
646
+ var _a;
647
+ return !!((_a = row
648
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
649
+ };
650
+ contains.autoRemove = (val) => !val;
651
+ const startsWith = (row, id, filterValue) => {
652
+ var _a;
653
+ return !!((_a = row
654
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
655
+ };
656
+ startsWith.autoRemove = (val) => !val;
657
+ const endsWith = (row, id, filterValue) => {
658
+ var _a;
659
+ return !!((_a = row
660
+ .getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
661
+ };
662
+ endsWith.autoRemove = (val) => !val;
663
+ const equals = (row, id, filterValue) => {
664
+ var _a;
665
+ return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
666
+ filterValue.toString().toLowerCase().trim();
667
+ };
668
+ equals.autoRemove = (val) => !val;
669
+ const notEquals = (row, id, filterValue) => {
670
+ var _a;
671
+ return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
672
+ filterValue.toString().toLowerCase().trim();
673
+ };
674
+ notEquals.autoRemove = (val) => !val;
675
+ const greaterThan = (row, id, filterValue) => {
676
+ var _a, _b, _c;
677
+ return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
678
+ ? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
679
+ : ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
680
+ };
681
+ greaterThan.autoRemove = (val) => !val;
682
+ const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
683
+ greaterThanOrEqualTo.autoRemove = (val) => !val;
684
+ const lessThan = (row, id, filterValue) => {
685
+ var _a, _b, _c;
686
+ return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
687
+ ? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
688
+ : ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
689
+ };
690
+ lessThan.autoRemove = (val) => !val;
691
+ const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
692
+ lessThanOrEqualTo.autoRemove = (val) => !val;
693
+ const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
694
+ greaterThan(row, id, filterValues[0])) &&
695
+ ((!isNaN(+filterValues[0]) &&
696
+ !isNaN(+filterValues[1]) &&
697
+ +filterValues[0] > +filterValues[1]) ||
698
+ ['', undefined].includes(filterValues[1]) ||
699
+ lessThan(row, id, filterValues[1]));
700
+ between.autoRemove = (val) => !val;
701
+ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
702
+ greaterThanOrEqualTo(row, id, filterValues[0])) &&
703
+ ((!isNaN(+filterValues[0]) &&
704
+ !isNaN(+filterValues[1]) &&
705
+ +filterValues[0] > +filterValues[1]) ||
706
+ ['', undefined].includes(filterValues[1]) ||
707
+ lessThanOrEqualTo(row, id, filterValues[1]));
708
+ betweenInclusive.autoRemove = (val) => !val;
709
+ const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
710
+ empty.autoRemove = (val) => !val;
711
+ const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
712
+ notEmpty.autoRemove = (val) => !val;
713
+ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
714
+ betweenInclusive,
715
+ contains,
716
+ empty,
717
+ endsWith,
718
+ equals,
719
+ fuzzy,
720
+ greaterThan,
721
+ greaterThanOrEqualTo,
722
+ lessThan,
723
+ lessThanOrEqualTo,
724
+ notEmpty,
725
+ notEquals,
726
+ startsWith });
727
+
728
+ /******************************************************************************
729
+ Copyright (c) Microsoft Corporation.
730
+
731
+ Permission to use, copy, modify, and/or distribute this software for any
732
+ purpose with or without fee is hereby granted.
733
+
734
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
735
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
736
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
737
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
738
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
739
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
740
+ PERFORMANCE OF THIS SOFTWARE.
741
+ ***************************************************************************** */
742
+
743
+ function __rest(s, e) {
744
+ var t = {};
745
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
746
+ t[p] = s[p];
747
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
748
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
749
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
750
+ t[p[i]] = s[p[i]];
751
+ }
752
+ return t;
753
+ }
754
+
755
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
756
+ var e = new Error(message);
757
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
758
+ };
759
+
760
+ const MRT_EditActionButtons = (_a) => {
761
+ var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
762
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
763
+ const { creatingRow, editingRow, isSaving } = getState();
764
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
765
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
766
+ const handleCancel = () => {
767
+ if (isCreating) {
768
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
769
+ setCreatingRow(null);
770
+ }
771
+ else if (isEditing) {
772
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
773
+ setEditingRow(null);
774
+ }
775
+ row._valuesCache = {}; //reset values cache
776
+ };
777
+ const handleSubmitRow = () => {
778
+ var _a, _b;
779
+ //look for auto-filled input values
780
+ (_b = Object.values((_a = editInputRefs.current) !== null && _a !== void 0 ? _a : {})
781
+ .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 || _b === void 0 ? void 0 : _b.forEach((input) => {
782
+ if (input.value !== undefined &&
783
+ Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
784
+ // @ts-ignore
785
+ row._valuesCache[input.name] = input.value;
786
+ }
787
+ });
788
+ if (isCreating)
789
+ onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
790
+ exitCreatingMode: () => setCreatingRow(null),
791
+ row,
792
+ table,
793
+ values: row._valuesCache,
794
+ });
795
+ else if (isEditing) {
796
+ onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
797
+ exitEditingMode: () => setEditingRow(null),
798
+ row,
799
+ table,
800
+ values: row === null || row === void 0 ? void 0 : row._valuesCache,
801
+ });
802
+ }
803
+ };
804
+ return (jsx(Box, { onClick: (e) => e.stopPropagation(), sx: (theme) => (Object.assign({ display: 'flex', gap: '0.75rem' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: variant === 'icon' ? (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.cancel, children: jsx(IconButton, { "aria-label": localization.cancel, onClick: handleCancel, children: jsx(CancelIcon, {}) }) }), ((isCreating && onCreatingRowSave) ||
805
+ (isEditing && onEditingRowSave)) && (jsx(Tooltip, { title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", disabled: isSaving, 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, { disabled: isSaving, onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
806
+ };
807
+
808
+ const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
809
+ const getMRTTheme = (mrtTheme, muiTheme) => {
810
+ var _a;
811
+ const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
812
+ const baseBackgroundColor = (_a = mrtThemeOverrides === null || mrtThemeOverrides === void 0 ? void 0 : mrtThemeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (muiTheme.palette.mode === 'dark'
813
+ ? lighten(muiTheme.palette.background.default, 0.05)
814
+ : muiTheme.palette.background.default);
815
+ return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
816
+ ? darken(muiTheme.palette.warning.dark, 0.25)
817
+ : lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
818
+ };
819
+ const commonCellBeforeAfterStyles = {
820
+ content: '""',
821
+ height: '100%',
822
+ left: 0,
823
+ position: 'absolute',
824
+ top: 0,
825
+ width: '100%',
826
+ zIndex: -1,
827
+ };
828
+ const getCommonPinnedCellStyles = ({ column, table, theme, }) => {
829
+ const { baseBackgroundColor } = table.options.mrtTheme;
830
+ const isPinned = column === null || column === void 0 ? void 0 : column.getIsPinned();
831
+ return {
832
+ '&[data-pinned="true"]': {
833
+ '&:before': Object.assign({ backgroundColor: alpha(darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97), boxShadow: column
834
+ ? isPinned === 'left' && column.getIsLastColumn(isPinned)
835
+ ? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
836
+ : isPinned === 'right' && column.getIsFirstColumn(isPinned)
837
+ ? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
838
+ : undefined
839
+ : undefined }, commonCellBeforeAfterStyles),
840
+ },
841
+ };
842
+ };
843
+ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
844
+ var _a, _b, _c, _d, _e, _f;
845
+ const { getState, options: { enableColumnVirtualization, layoutMode }, } = table;
846
+ const { draggingColumn } = getState();
847
+ const { columnDef } = column;
848
+ const { columnDefType } = columnDef;
849
+ const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
850
+ const widthStyles = {
851
+ minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
852
+ width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px)`,
853
+ };
854
+ if (layoutMode === 'grid') {
855
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
856
+ ? 0
857
+ : `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_d = header === null || header === void 0 ? void 0 : header.id) !== null && _d !== void 0 ? _d : column.id)}-size)`} 0 auto`;
858
+ }
859
+ else if (layoutMode === 'grid-no-grow') {
860
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
861
+ }
862
+ const pinnedStyles = isColumnPinned
863
+ ? Object.assign(Object.assign({}, getCommonPinnedCellStyles({ column, table, theme })), { left: isColumnPinned === 'left'
864
+ ? `${column.getStart('left')}px`
865
+ : undefined, opacity: 0.97, position: 'sticky', right: isColumnPinned === 'right'
866
+ ? `${column.getAfter('right')}px`
867
+ : undefined }) : {};
868
+ return Object.assign(Object.assign(Object.assign({ backgroundColor: 'inherit', backgroundImage: 'inherit', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, justifyContent: columnDefType === 'group'
869
+ ? 'center'
870
+ : (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
871
+ ? tableCellProps.align
872
+ : undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
873
+ ((_f = table.getState().hoveredColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id
874
+ ? 0.5
875
+ : 1, position: 'relative', transition: enableColumnVirtualization
876
+ ? 'none'
877
+ : `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
878
+ ? 2
879
+ : columnDefType !== 'group' && isColumnPinned
880
+ ? 1
881
+ : 0, '&:focus-visible': {
882
+ outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
883
+ outlineOffset: '-2px',
884
+ } }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
885
+ };
886
+ const getCommonToolbarStyles = ({ table, }) => ({
887
+ alignItems: 'flex-start',
888
+ backgroundColor: table.options.mrtTheme.baseBackgroundColor,
889
+ display: 'grid',
890
+ flexWrap: 'wrap-reverse',
891
+ minHeight: '3.5rem',
892
+ overflow: 'hidden',
893
+ position: 'relative',
894
+ transition: 'all 150ms ease-in-out',
895
+ zIndex: 1,
896
+ });
897
+ const flipIconStyles = (theme) => theme.direction === 'rtl'
898
+ ? { style: { transform: 'scaleX(-1)' } }
899
+ : undefined;
900
+ const getCommonTooltipProps = (placement) => ({
901
+ disableInteractive: true,
902
+ enterDelay: 1000,
903
+ enterNextDelay: 1000,
904
+ placement,
905
+ });
906
+
907
+ const MRT_ActionMenuItem = (_a) => {
908
+ var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
909
+ const { options: { icons: { ArrowRightIcon }, }, } = table;
910
+ return (jsxs(MenuItem, Object.assign({ sx: {
911
+ alignItems: 'center',
912
+ justifyContent: 'space-between',
913
+ minWidth: '120px',
914
+ my: 0,
915
+ py: '6px',
916
+ }, tabIndex: 0 }, rest, { children: [jsxs(Box, { sx: {
917
+ alignItems: 'center',
918
+ display: 'flex',
919
+ }, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: onOpenSubMenu, onMouseEnter: onOpenSubMenu, size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
920
+ };
921
+
922
+ const MRT_RowActionMenu = (_a) => {
923
+ var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
924
+ const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
925
+ const { density } = getState();
926
+ const menuItems = useMemo(() => {
927
+ const items = [];
928
+ const editItem = parseFromValuesOrFunc(enableEditing, row) &&
929
+ ['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }, 'edit'));
930
+ if (editItem)
931
+ items.push(editItem);
932
+ const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
933
+ closeMenu: () => setAnchorEl(null),
934
+ row,
935
+ staticRowIndex,
936
+ table,
937
+ });
938
+ if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
939
+ items.push(...rowActionMenuItems);
940
+ return items;
941
+ }, [renderRowActionMenuItems, row, staticRowIndex, table]);
942
+ if (!menuItems.length)
943
+ return null;
944
+ return (jsx(Menu, Object.assign({ MenuListProps: {
945
+ dense: density === 'compact',
946
+ sx: {
947
+ backgroundColor: menuBackgroundColor,
948
+ },
949
+ }, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
950
+ };
951
+
952
+ const commonIconButtonStyles = {
953
+ '&:hover': {
954
+ opacity: 1,
955
+ },
956
+ height: '2rem',
957
+ ml: '10px',
958
+ opacity: 0.5,
959
+ transition: 'opacity 150ms',
960
+ width: '2rem',
961
+ };
962
+ const MRT_ToggleRowActionMenuButton = (_a) => {
963
+ var _b;
964
+ var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
965
+ const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
966
+ const { creatingRow, editingRow } = getState();
967
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
968
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
969
+ const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
970
+ (isEditing && editDisplayMode === 'row');
971
+ const [anchorEl, setAnchorEl] = useState(null);
972
+ const handleOpenRowActionMenu = (event) => {
973
+ event.stopPropagation();
974
+ event.preventDefault();
975
+ setAnchorEl(event.currentTarget);
976
+ };
977
+ const handleStartEditMode = (event) => {
978
+ event.stopPropagation();
979
+ setEditingRow(Object.assign({}, row));
980
+ setAnchorEl(null);
981
+ };
982
+ return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
983
+ parseFromValuesOrFunc(enableEditing, row) &&
984
+ ['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
985
+ row,
986
+ staticRowIndex,
987
+ table,
988
+ })) === null || _b === void 0 ? void 0 : _b.length) ? (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsx(MoreHorizIcon, {}) })) })), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
989
+ };
990
+
991
+ const getMRT_RowActionsColumnDef = (tableOptions) => {
992
+ return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
993
+ header: 'actions',
994
+ id: 'mrt-row-actions',
995
+ size: 70,
996
+ tableOptions,
997
+ }));
998
+ };
999
+
1000
+ const MRT_GrabHandleButton = (_a) => {
1001
+ var _b, _c;
1002
+ var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
1003
+ const { options: { icons: { DragHandleIcon }, localization, }, } = table;
1004
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, rest, { onClick: (e) => {
1005
+ var _a;
1006
+ e.stopPropagation();
1007
+ (_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
1008
+ }, sx: (theme) => (Object.assign({ '&:active': {
1009
+ cursor: 'grabbing',
1010
+ }, '&:hover': {
1011
+ backgroundColor: 'transparent',
1012
+ opacity: 1,
1013
+ }, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.5, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) })));
1014
+ };
1015
+
1016
+ const MRT_TableBodyRowGrabHandle = (_a) => {
1017
+ var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
1018
+ const { options: { muiRowDragHandleProps }, } = table;
1019
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
1020
+ row,
1021
+ table,
1022
+ })), rest);
1023
+ const handleDragStart = (event) => {
1024
+ var _a;
1025
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1026
+ try {
1027
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
1028
+ }
1029
+ catch (e) {
1030
+ console.error(e);
1031
+ }
1032
+ table.setDraggingRow(row);
1033
+ };
1034
+ const handleDragEnd = (event) => {
1035
+ var _a;
1036
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1037
+ table.setDraggingRow(null);
1038
+ table.setHoveredRow(null);
1039
+ };
1040
+ return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
1041
+ };
1042
+
1043
+ const getMRT_RowDragColumnDef = (tableOptions) => {
1044
+ return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
1045
+ header: 'move',
1046
+ id: 'mrt-row-drag',
1047
+ size: 60,
1048
+ tableOptions,
1049
+ }));
1050
+ };
1051
+
1052
+ const MRT_ExpandAllButton = (_a) => {
1053
+ var _b, _c;
1054
+ var { table } = _a, rest = __rest(_a, ["table"]);
1055
+ const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1056
+ const { density, isLoading } = getState();
1057
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
1058
+ table,
1059
+ })), rest);
1060
+ const isAllRowsExpanded = getIsAllRowsExpanded();
1061
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : (isAllRowsExpanded ? localization.collapseAll : 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: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsx(KeyboardDoubleArrowDownIcon, { style: {
1062
+ transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
1063
+ transition: 'transform 150ms',
1064
+ } })) })) }) })));
1065
+ };
1066
+
1067
+ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1068
+ var _a, _b;
1069
+ const theme = useTheme();
1070
+ const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
1071
+ const { density } = getState();
1072
+ const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
1073
+ row,
1074
+ staticRowIndex,
1075
+ table,
1076
+ });
1077
+ const canExpand = row.getCanExpand();
1078
+ const isExpanded = row.getIsExpanded();
1079
+ const handleToggleExpand = (event) => {
1080
+ var _a;
1081
+ event.stopPropagation();
1082
+ row.toggleExpanded();
1083
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1084
+ };
1085
+ const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
1086
+ return (jsx(Tooltip, Object.assign({ disableHoverListener: !canExpand && !detailPanel }, getCommonTooltipProps(), { title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : (isExpanded ? localization.collapse : localization.expand), children: jsx("span", { children: jsx(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !detailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', opacity: !canExpand && !detailPanel ? 0.3 : 1, [theme.direction === 'rtl' || positionExpandColumn === 'last'
1087
+ ? 'mr'
1088
+ : 'ml']: `${row.depth * 16}px`, 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: {
1089
+ transform: `rotate(${!canExpand && !renderDetailPanel
1090
+ ? positionExpandColumn === 'last' ||
1091
+ theme.direction === 'rtl'
1092
+ ? 90
1093
+ : -90
1094
+ : isExpanded
1095
+ ? -180
1096
+ : 0}deg)`,
1097
+ transition: 'transform 150ms',
1098
+ } })) })) }) })));
1099
+ };
1100
+
1101
+ const getMRT_RowExpandColumnDef = (tableOptions) => {
1102
+ var _a;
1103
+ const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
1104
+ const alignProps = positionExpandColumn === 'last'
1105
+ ? {
1106
+ align: 'right',
1107
+ }
1108
+ : undefined;
1109
+ return Object.assign({ Cell: ({ cell, column, row, staticRowIndex, table }) => {
1110
+ var _a, _b, _c;
1111
+ const expandButtonProps = { row, staticRowIndex, table };
1112
+ const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
1113
+ if (groupedColumnMode === 'remove' && row.groupingColumnId) {
1114
+ return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: "0.25rem", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsx(Tooltip, Object.assign({}, getCommonTooltipProps('right'), { title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) })), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
1115
+ }
1116
+ else {
1117
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, { cell, column, row, table })] }));
1118
+ }
1119
+ }, Header: enableExpandAll
1120
+ ? ({ table }) => {
1121
+ var _a;
1122
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandAllButton, { table: table }), groupedColumnMode === 'remove' &&
1123
+ ((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
1124
+ }
1125
+ : undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
1126
+ header: 'expand',
1127
+ id: 'mrt-row-expand',
1128
+ size: groupedColumnMode === 'remove'
1129
+ ? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
1130
+ : renderDetailPanel
1131
+ ? enableExpandAll
1132
+ ? 60
1133
+ : 70
1134
+ : 100,
1135
+ tableOptions,
1136
+ }));
1137
+ };
1138
+
1139
+ const getMRT_RowNumbersColumnDef = (tableOptions) => {
1140
+ const { localization, rowNumberDisplayMode } = tableOptions;
1141
+ const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
1142
+ return Object.assign({ Cell: ({ row, staticRowIndex }) => {
1143
+ var _a;
1144
+ return ((_a = (rowNumberDisplayMode === 'static'
1145
+ ? (staticRowIndex || 0) + (pageSize || 0) * (pageIndex || 0)
1146
+ : row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
1147
+ }, Header: () => localization.rowNumber, grow: false }, defaultDisplayColumnProps({
1148
+ header: 'rowNumbers',
1149
+ id: 'mrt-row-numbers',
1150
+ size: 50,
1151
+ tableOptions,
1152
+ }));
1153
+ };
1154
+
1155
+ const MRT_RowPinButton = (_a) => {
1156
+ var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
1157
+ const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
1158
+ const isPinned = row.getIsPinned();
1159
+ const [tooltipOpened, setTooltipOpened] = useState(false);
1160
+ const handleTogglePin = (event) => {
1161
+ setTooltipOpened(false);
1162
+ event.stopPropagation();
1163
+ row.pin(isPinned ? false : pinningPosition);
1164
+ };
1165
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, Object.assign({ "aria-label": localization.pin, onBlur: () => setTooltipOpened(false), onClick: handleTogglePin, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '24px', width: '24px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: isPinned ? (jsx(CloseIcon, {})) : (jsx(PushPinIcon, { fontSize: "small", style: {
1166
+ transform: `rotate(${rowPinningDisplayMode === 'sticky'
1167
+ ? 135
1168
+ : pinningPosition === 'top'
1169
+ ? 180
1170
+ : 0}deg)`,
1171
+ } })) })) })));
1172
+ };
1173
+
1174
+ const MRT_TableBodyRowPinButton = (_a) => {
1175
+ var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
1176
+ const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
1177
+ const { density } = getState();
1178
+ const canPin = parseFromValuesOrFunc(enableRowPinning, row);
1179
+ if (!canPin)
1180
+ return null;
1181
+ const rowPinButtonProps = Object.assign({ row,
1182
+ table }, rest);
1183
+ if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
1184
+ return (jsxs(Box, { sx: {
1185
+ display: 'flex',
1186
+ flexDirection: density === 'compact' ? 'row' : 'column',
1187
+ }, children: [jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
1188
+ }
1189
+ return (jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
1190
+ };
1191
+
1192
+ const getMRT_RowPinningColumnDef = (tableOptions) => {
1193
+ return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
1194
+ header: 'pin',
1195
+ id: 'mrt-row-pin',
1196
+ size: 60,
1197
+ tableOptions,
1198
+ }));
1199
+ };
1200
+
1201
+ const MRT_SelectCheckbox = (_a) => {
1202
+ var _b;
1203
+ var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
1204
+ const { getState, options: { enableMultiRowSelection, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, selectAllMode, }, } = table;
1205
+ const { density, isLoading } = getState();
1206
+ const selectAll = !row;
1207
+ const allRowsSelected = selectAll
1208
+ ? selectAllMode === 'page'
1209
+ ? table.getIsAllPageRowsSelected()
1210
+ : table.getIsAllRowsSelected()
1211
+ : undefined;
1212
+ const isChecked = selectAll
1213
+ ? allRowsSelected
1214
+ : getIsRowSelected({ row, table });
1215
+ const checkboxProps = Object.assign(Object.assign({}, (selectAll
1216
+ ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
1217
+ : parseFromValuesOrFunc(muiSelectCheckboxProps, {
1218
+ row,
1219
+ staticRowIndex,
1220
+ table,
1221
+ }))), rest);
1222
+ const onSelectionChange = row
1223
+ ? getMRT_RowSelectionHandler({
1224
+ row,
1225
+ staticRowIndex,
1226
+ table,
1227
+ })
1228
+ : undefined;
1229
+ const onSelectAllChange = getMRT_SelectAllHandler({ table });
1230
+ const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
1231
+ ? localization.toggleSelectAll
1232
+ : localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
1233
+ 'aria-label': selectAll
1234
+ ? localization.toggleSelectAll
1235
+ : localization.toggleSelectRow,
1236
+ }, onChange: (event) => {
1237
+ event.stopPropagation();
1238
+ selectAll ? onSelectAllChange(event) : onSelectionChange(event);
1239
+ }, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
1240
+ var _a;
1241
+ e.stopPropagation();
1242
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
1243
+ }, 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 });
1244
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
1245
+ ? localization.toggleSelectAll
1246
+ : localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: !isChecked && selectAll
1247
+ ? table.getIsSomeRowsSelected()
1248
+ : (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
1249
+ };
1250
+
1251
+ const getMRT_RowSelectColumnDef = (tableOptions) => {
1252
+ const { enableMultiRowSelection, enableSelectAll } = tableOptions;
1253
+ return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
1254
+ ? ({ table }) => jsx(MRT_SelectCheckbox, { table: table })
1255
+ : undefined, grow: false }, defaultDisplayColumnProps({
1256
+ header: 'select',
1257
+ id: 'mrt-row-select',
1258
+ size: enableSelectAll ? 60 : 70,
1259
+ tableOptions,
1260
+ }));
1261
+ };
1262
+
1263
+ const MRT_Default_Icons = {
1264
+ ArrowDownwardIcon,
1265
+ ArrowRightIcon,
1266
+ CancelIcon,
1267
+ ChevronLeftIcon,
1268
+ ChevronRightIcon,
1269
+ ClearAllIcon,
1270
+ CloseIcon,
1271
+ ContentCopy,
1272
+ DensityLargeIcon,
1273
+ DensityMediumIcon,
1274
+ DensitySmallIcon,
1275
+ DragHandleIcon,
1276
+ DynamicFeedIcon,
1277
+ EditIcon,
1278
+ ExpandMoreIcon,
1279
+ FilterAltIcon,
1280
+ FilterListIcon,
1281
+ FilterListOffIcon,
1282
+ FirstPageIcon,
1283
+ FullscreenExitIcon,
1284
+ FullscreenIcon,
1285
+ KeyboardDoubleArrowDownIcon,
1286
+ LastPageIcon,
1287
+ MoreHorizIcon,
1288
+ MoreVertIcon,
1289
+ PushPinIcon,
1290
+ RestartAltIcon,
1291
+ SaveIcon,
1292
+ SearchIcon,
1293
+ SearchOffIcon,
1294
+ SortIcon,
1295
+ SyncAltIcon,
1296
+ ViewColumnIcon,
1297
+ VisibilityOffIcon,
1298
+ };
1299
+
1300
+ const MRT_Localization_EN = {
1301
+ actions: 'Actions',
1302
+ and: 'and',
1303
+ cancel: 'Cancel',
1304
+ changeFilterMode: 'Change filter mode',
1305
+ changeSearchMode: 'Change search mode',
1306
+ clearFilter: 'Clear filter',
1307
+ clearSearch: 'Clear search',
1308
+ clearSelection: 'Clear selection',
1309
+ clearSort: 'Clear sort',
1310
+ clickToCopy: 'Click to copy',
1311
+ copy: 'Copy',
1312
+ collapse: 'Collapse',
1313
+ collapseAll: 'Collapse all',
1314
+ columnActions: 'Column Actions',
1315
+ copiedToClipboard: 'Copied to clipboard',
1316
+ dropToGroupBy: 'Drop to group by {column}',
1317
+ edit: 'Edit',
1318
+ expand: 'Expand',
1319
+ expandAll: 'Expand all',
1320
+ filterArrIncludes: 'Includes',
1321
+ filterArrIncludesAll: 'Includes all',
1322
+ filterArrIncludesSome: 'Includes',
1323
+ filterBetween: 'Between',
1324
+ filterBetweenInclusive: 'Between Inclusive',
1325
+ filterByColumn: 'Filter by {column}',
1326
+ filterContains: 'Contains',
1327
+ filterEmpty: 'Empty',
1328
+ filterEndsWith: 'Ends With',
1329
+ filterEquals: 'Equals',
1330
+ filterEqualsString: 'Equals',
1331
+ filterFuzzy: 'Fuzzy',
1332
+ filterGreaterThan: 'Greater Than',
1333
+ filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
1334
+ filterInNumberRange: 'Between',
1335
+ filterIncludesString: 'Contains',
1336
+ filterIncludesStringSensitive: 'Contains',
1337
+ filterLessThan: 'Less Than',
1338
+ filterLessThanOrEqualTo: 'Less Than Or Equal To',
1339
+ filterMode: 'Filter Mode: {filterType}',
1340
+ filterNotEmpty: 'Not Empty',
1341
+ filterNotEquals: 'Not Equals',
1342
+ filterStartsWith: 'Starts With',
1343
+ filterWeakEquals: 'Equals',
1344
+ filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
1345
+ goToFirstPage: 'Go to first page',
1346
+ goToLastPage: 'Go to last page',
1347
+ goToNextPage: 'Go to next page',
1348
+ goToPreviousPage: 'Go to previous page',
1349
+ grab: 'Grab',
1350
+ groupByColumn: 'Group by {column}',
1351
+ groupedBy: 'Grouped by ',
1352
+ hideAll: 'Hide all',
1353
+ hideColumn: 'Hide {column} column',
1354
+ max: 'Max',
1355
+ min: 'Min',
1356
+ move: 'Move',
1357
+ noRecordsToDisplay: 'No records to display',
1358
+ noResultsFound: 'No results found',
1359
+ of: 'of',
1360
+ or: 'or',
1361
+ pin: 'Pin',
1362
+ pinToLeft: 'Pin to left',
1363
+ pinToRight: 'Pin to right',
1364
+ resetColumnSize: 'Reset column size',
1365
+ resetOrder: 'Reset order',
1366
+ rowActions: 'Row Actions',
1367
+ rowNumber: '#',
1368
+ rowNumbers: 'Row Numbers',
1369
+ rowsPerPage: 'Rows per page',
1370
+ save: 'Save',
1371
+ search: 'Search',
1372
+ selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
1373
+ select: 'Select',
1374
+ showAll: 'Show all',
1375
+ showAllColumns: 'Show all columns',
1376
+ showHideColumns: 'Show/Hide columns',
1377
+ showHideFilters: 'Show/Hide filters',
1378
+ showHideSearch: 'Show/Hide search',
1379
+ sortByColumnAsc: 'Sort by {column} ascending',
1380
+ sortByColumnDesc: 'Sort by {column} descending',
1381
+ sortedByColumnAsc: 'Sorted by {column} ascending',
1382
+ sortedByColumnDesc: 'Sorted by {column} descending',
1383
+ thenBy: ', then by ',
1384
+ toggleDensity: 'Toggle density',
1385
+ toggleFullScreen: 'Toggle full screen',
1386
+ toggleSelectAll: 'Toggle select all',
1387
+ toggleSelectRow: 'Toggle select row',
1388
+ toggleVisibility: 'Toggle visibility',
1389
+ ungroupByColumn: 'Ungroup by {column}',
1390
+ unpin: 'Unpin',
1391
+ unpinAll: 'Unpin all',
1392
+ };
1393
+
1394
+ const MRT_DefaultColumn = {
1395
+ filterVariant: 'text',
1396
+ maxSize: 1000,
1397
+ minSize: 40,
1398
+ size: 180,
1399
+ };
1400
+ const MRT_DefaultDisplayColumn = {
1401
+ columnDefType: 'display',
1402
+ enableClickToCopy: false,
1403
+ enableColumnActions: false,
1404
+ enableColumnDragging: false,
1405
+ enableColumnFilter: false,
1406
+ enableColumnOrdering: false,
1407
+ enableEditing: false,
1408
+ enableGlobalFilter: false,
1409
+ enableGrouping: false,
1410
+ enableHiding: false,
1411
+ enableResizing: false,
1412
+ enableSorting: false,
1413
+ };
1414
+ const useMRT_TableOptions = (_a) => {
1415
+ var _b;
1416
+ var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
1417
+ const theme = useTheme();
1418
+ icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
1419
+ localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
1420
+ mrtTheme = useMemo(() => getMRTTheme(mrtTheme, theme), [mrtTheme, theme]);
1421
+ aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
1422
+ filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
1423
+ sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
1424
+ defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
1425
+ defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
1426
+ //cannot be changed after initialization
1427
+ [enableColumnVirtualization, enableRowVirtualization] = useMemo(() => [enableColumnVirtualization, enableRowVirtualization], []);
1428
+ if (!columnResizeDirection) {
1429
+ columnResizeDirection = theme.direction || 'ltr';
1430
+ }
1431
+ layoutMode =
1432
+ layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
1433
+ if (layoutMode === 'semantic' &&
1434
+ (enableRowVirtualization || enableColumnVirtualization)) {
1435
+ layoutMode = 'grid';
1436
+ }
1437
+ if (enableRowVirtualization) {
1438
+ enableStickyHeader = true;
1439
+ }
1440
+ if (enablePagination === false && manualPagination === undefined) {
1441
+ manualPagination = true;
1442
+ }
1443
+ if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
1444
+ manualFiltering = true;
1445
+ manualGrouping = true;
1446
+ manualPagination = true;
1447
+ manualSorting = true;
1448
+ }
1449
+ return Object.assign({ aggregationFns,
1450
+ autoResetExpanded,
1451
+ columnFilterDisplayMode,
1452
+ columnResizeDirection,
1453
+ columnResizeMode,
1454
+ createDisplayMode,
1455
+ defaultColumn,
1456
+ defaultDisplayColumn,
1457
+ editDisplayMode,
1458
+ enableBatchRowSelection,
1459
+ enableBottomToolbar,
1460
+ enableColumnActions,
1461
+ enableColumnFilters,
1462
+ enableColumnOrdering,
1463
+ enableColumnPinning,
1464
+ enableColumnResizing,
1465
+ enableColumnVirtualization,
1466
+ enableDensityToggle,
1467
+ enableExpandAll,
1468
+ enableExpanding,
1469
+ enableFacetedValues,
1470
+ enableFilterMatchHighlighting,
1471
+ enableFilters,
1472
+ enableFullScreenToggle,
1473
+ enableGlobalFilter,
1474
+ enableGlobalFilterRankedResults,
1475
+ enableGrouping,
1476
+ enableHiding,
1477
+ enableKeyboardShortcuts,
1478
+ enableMultiRowSelection,
1479
+ enableMultiSort,
1480
+ enablePagination,
1481
+ enableRowPinning,
1482
+ enableRowSelection,
1483
+ enableRowVirtualization,
1484
+ enableSelectAll,
1485
+ enableSorting,
1486
+ enableStickyHeader,
1487
+ enableTableFooter,
1488
+ enableTableHead,
1489
+ enableToolbarInternalActions,
1490
+ enableTopToolbar,
1491
+ filterFns, getCoreRowModel: getCoreRowModel(), getExpandedRowModel: enableExpanding || enableGrouping ? getExpandedRowModel() : undefined, getFacetedMinMaxValues: enableFacetedValues
1492
+ ? getFacetedMinMaxValues()
1493
+ : undefined, getFacetedRowModel: enableFacetedValues ? getFacetedRowModel() : undefined, getFacetedUniqueValues: enableFacetedValues
1494
+ ? getFacetedUniqueValues()
1495
+ : undefined, getFilteredRowModel: (enableColumnFilters || enableGlobalFilter || enableFilters) &&
1496
+ !manualFiltering
1497
+ ? getFilteredRowModel()
1498
+ : undefined, getGroupedRowModel: enableGrouping && !manualGrouping ? getGroupedRowModel() : undefined, getPaginationRowModel: enablePagination && !manualPagination
1499
+ ? getPaginationRowModel()
1500
+ : undefined, getSortedRowModel: enableSorting && !manualSorting ? getSortedRowModel() : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, icons,
1501
+ id,
1502
+ layoutMode,
1503
+ localization,
1504
+ manualFiltering,
1505
+ manualGrouping,
1506
+ manualPagination,
1507
+ manualSorting,
1508
+ mrtTheme,
1509
+ paginationDisplayMode,
1510
+ positionActionsColumn,
1511
+ positionCreatingRow,
1512
+ positionExpandColumn,
1513
+ positionGlobalFilter,
1514
+ positionPagination,
1515
+ positionToolbarAlertBanner,
1516
+ positionToolbarDropZone,
1517
+ rowNumberDisplayMode,
1518
+ rowPinningDisplayMode,
1519
+ selectAllMode,
1520
+ sortingFns }, rest);
1521
+ };
1522
+
1523
+ const blankColProps = {
1524
+ children: null,
1525
+ sx: {
1526
+ minWidth: 0,
1527
+ p: 0,
1528
+ width: 0,
1529
+ },
1530
+ };
1531
+ const getMRT_RowSpacerColumnDef = (tableOptions) => {
1532
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
1533
+ id: 'mrt-row-spacer',
1534
+ size: 0,
1535
+ tableOptions,
1536
+ })), { grow: true }), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
1537
+ };
1538
+
1539
+ const useMRT_Effects = (table) => {
1540
+ const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
1541
+ const { columnOrder, density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1542
+ const totalColumnCount = table.options.columns.length;
1543
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
1544
+ const rerender = useReducer(() => ({}), {})[1];
1545
+ const initialBodyHeight = useRef(null);
1546
+ const previousTop = useRef(null);
1547
+ useEffect(() => {
1548
+ if (typeof window !== 'undefined') {
1549
+ initialBodyHeight.current = document.body.style.height;
1550
+ }
1551
+ }, []);
1552
+ //hide scrollbars when table is in full screen mode, preserve body scroll position after full screen exit
1553
+ useEffect(() => {
1554
+ if (typeof window !== 'undefined') {
1555
+ if (isFullScreen) {
1556
+ previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
1557
+ document.body.style.height = '100dvh'; //hide page scrollbars when table is in full screen mode
1558
+ }
1559
+ else {
1560
+ document.body.style.height = initialBodyHeight.current;
1561
+ if (!previousTop.current)
1562
+ return;
1563
+ //restore scroll position
1564
+ window.scrollTo({
1565
+ behavior: 'instant',
1566
+ top: -1 * previousTop.current,
1567
+ });
1568
+ }
1569
+ }
1570
+ }, [isFullScreen]);
1571
+ //recalculate column order when columns change or features are toggled on/off
1572
+ useEffect(() => {
1573
+ if (totalColumnCount !== columnOrder.length) {
1574
+ table.setColumnOrder(getDefaultColumnOrderIds(table.options));
1575
+ }
1576
+ }, [totalColumnCount]);
1577
+ //if page index is out of bounds, set it to the last page
1578
+ useEffect(() => {
1579
+ if (!enablePagination || isLoading || showSkeletons)
1580
+ return;
1581
+ const { pageIndex, pageSize } = pagination;
1582
+ const firstVisibleRowIndex = pageIndex * pageSize;
1583
+ if (firstVisibleRowIndex >= totalRowCount) {
1584
+ table.setPageIndex(Math.ceil(totalRowCount / pageSize) - 1);
1585
+ }
1586
+ }, [totalRowCount]);
1587
+ //turn off sort when global filter is looking for ranked results
1588
+ const appliedSort = useRef(sorting);
1589
+ useEffect(() => {
1590
+ if (sorting.length) {
1591
+ appliedSort.current = sorting;
1592
+ }
1593
+ }, [sorting]);
1594
+ useEffect(() => {
1595
+ if (!getCanRankRows(table))
1596
+ return;
1597
+ if (globalFilter) {
1598
+ table.setSorting([]);
1599
+ }
1600
+ else {
1601
+ table.setSorting(() => appliedSort.current || []);
1602
+ }
1603
+ }, [globalFilter]);
1604
+ //fix pinned row top style when density changes
1605
+ useEffect(() => {
1606
+ if (enableRowPinning && getIsSomeRowsPinned()) {
1607
+ setTimeout(() => {
1608
+ rerender();
1609
+ }, 150);
1610
+ }
1611
+ }, [density]);
1612
+ };
1613
+
1614
+ /**
1615
+ * The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
1616
+ * @param definedTableOptions - table options with proper defaults set
1617
+ * @returns the MRT table instance
1618
+ */
1619
+ const useMRT_TableInstance = (definedTableOptions) => {
1620
+ 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;
1621
+ const lastSelectedRowId = useRef(null);
1622
+ const actionCellRef = useRef(null);
1623
+ const bottomToolbarRef = useRef(null);
1624
+ const editInputRefs = useRef({});
1625
+ const filterInputRefs = useRef({});
1626
+ const searchInputRef = useRef(null);
1627
+ const tableContainerRef = useRef(null);
1628
+ const tableHeadCellRefs = useRef({});
1629
+ const tablePaperRef = useRef(null);
1630
+ const topToolbarRef = useRef(null);
1631
+ const tableHeadRef = useRef(null);
1632
+ const tableFooterRef = useRef(null);
1633
+ //transform initial state with proper column order
1634
+ const initialState = useMemo(() => {
1635
+ var _a, _b, _c;
1636
+ const initState = (_a = definedTableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1637
+ initState.columnOrder =
1638
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, definedTableOptions), { state: Object.assign(Object.assign({}, definedTableOptions.initialState), definedTableOptions.state) }));
1639
+ initState.globalFilterFn = (_c = definedTableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1640
+ return initState;
1641
+ }, []);
1642
+ definedTableOptions.initialState = initialState;
1643
+ const [actionCell, setActionCell] = useState((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null);
1644
+ const [creatingRow, _setCreatingRow] = useState((_b = initialState.creatingRow) !== null && _b !== void 0 ? _b : null);
1645
+ const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
1646
+ var _a, _b, _c, _d;
1647
+ return ({
1648
+ [getColumnId(col)]: col.filterFn instanceof Function
1649
+ ? ((_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom')
1650
+ : ((_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)),
1651
+ });
1652
+ })));
1653
+ const [columnOrder, onColumnOrderChange] = useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
1654
+ const [columnSizingInfo, onColumnSizingInfoChange] = useState((_d = initialState.columnSizingInfo) !== null && _d !== void 0 ? _d : {});
1655
+ const [density, setDensity] = useState((_e = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _e !== void 0 ? _e : 'comfortable');
1656
+ const [draggingColumn, setDraggingColumn] = useState((_f = initialState.draggingColumn) !== null && _f !== void 0 ? _f : null);
1657
+ const [draggingRow, setDraggingRow] = useState((_g = initialState.draggingRow) !== null && _g !== void 0 ? _g : null);
1658
+ const [editingCell, setEditingCell] = useState((_h = initialState.editingCell) !== null && _h !== void 0 ? _h : null);
1659
+ const [editingRow, setEditingRow] = useState((_j = initialState.editingRow) !== null && _j !== void 0 ? _j : null);
1660
+ const [globalFilterFn, setGlobalFilterFn] = useState((_k = initialState.globalFilterFn) !== null && _k !== void 0 ? _k : 'fuzzy');
1661
+ const [grouping, onGroupingChange] = useState((_l = initialState.grouping) !== null && _l !== void 0 ? _l : []);
1662
+ const [hoveredColumn, setHoveredColumn] = useState((_m = initialState.hoveredColumn) !== null && _m !== void 0 ? _m : null);
1663
+ const [hoveredRow, setHoveredRow] = useState((_o = initialState.hoveredRow) !== null && _o !== void 0 ? _o : null);
1664
+ const [isFullScreen, setIsFullScreen] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _p !== void 0 ? _p : false);
1665
+ const [pagination, onPaginationChange] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _q !== void 0 ? _q : { pageIndex: 0, pageSize: 10 });
1666
+ const [showAlertBanner, setShowAlertBanner] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
1667
+ const [showColumnFilters, setShowColumnFilters] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
1668
+ const [showGlobalFilter, setShowGlobalFilter] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
1669
+ const [showToolbarDropZone, setShowToolbarDropZone] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
1670
+ definedTableOptions.state = Object.assign({ actionCell,
1671
+ columnFilterFns,
1672
+ columnOrder,
1673
+ columnSizingInfo,
1674
+ creatingRow,
1675
+ density,
1676
+ draggingColumn,
1677
+ draggingRow,
1678
+ editingCell,
1679
+ editingRow,
1680
+ globalFilterFn,
1681
+ grouping,
1682
+ hoveredColumn,
1683
+ hoveredRow,
1684
+ isFullScreen,
1685
+ pagination,
1686
+ showAlertBanner,
1687
+ showColumnFilters,
1688
+ showGlobalFilter,
1689
+ showToolbarDropZone }, definedTableOptions.state);
1690
+ //The table options now include all state needed to help determine column visibility and order logic
1691
+ const statefulTableOptions = definedTableOptions;
1692
+ //don't recompute columnDefs while resizing column or dragging column/row
1693
+ const columnDefsRef = useRef([]);
1694
+ statefulTableOptions.columns =
1695
+ statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
1696
+ statefulTableOptions.state.draggingColumn ||
1697
+ statefulTableOptions.state.draggingRow
1698
+ ? columnDefsRef.current
1699
+ : prepareColumns({
1700
+ columnDefs: [
1701
+ ...[
1702
+ showRowPinningColumn(statefulTableOptions) &&
1703
+ getMRT_RowPinningColumnDef(statefulTableOptions),
1704
+ showRowDragColumn(statefulTableOptions) &&
1705
+ getMRT_RowDragColumnDef(statefulTableOptions),
1706
+ showRowActionsColumn(statefulTableOptions) &&
1707
+ getMRT_RowActionsColumnDef(statefulTableOptions),
1708
+ showRowExpandColumn(statefulTableOptions) &&
1709
+ getMRT_RowExpandColumnDef(statefulTableOptions),
1710
+ showRowSelectionColumn(statefulTableOptions) &&
1711
+ getMRT_RowSelectColumnDef(statefulTableOptions),
1712
+ showRowNumbersColumn(statefulTableOptions) &&
1713
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
1714
+ ].filter(Boolean),
1715
+ ...statefulTableOptions.columns,
1716
+ ...[
1717
+ showRowSpacerColumn(statefulTableOptions) &&
1718
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
1719
+ ].filter(Boolean),
1720
+ ],
1721
+ tableOptions: statefulTableOptions,
1722
+ });
1723
+ columnDefsRef.current = statefulTableOptions.columns;
1724
+ //if loading, generate blank rows to show skeleton loaders
1725
+ statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading ||
1726
+ statefulTableOptions.state.showSkeletons) &&
1727
+ !statefulTableOptions.data.length
1728
+ ? [
1729
+ ...Array(Math.min(statefulTableOptions.state.pagination.pageSize, 20)).fill(null),
1730
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(statefulTableOptions.columns).map((col) => ({
1731
+ [getColumnId(col)]: null,
1732
+ }))))
1733
+ : statefulTableOptions.data, [
1734
+ statefulTableOptions.data,
1735
+ statefulTableOptions.state.isLoading,
1736
+ statefulTableOptions.state.showSkeletons,
1737
+ ]);
1738
+ //@ts-ignore
1739
+ const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
1740
+ onColumnSizingInfoChange,
1741
+ onGroupingChange,
1742
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_v = statefulTableOptions.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1743
+ table.refs = {
1744
+ actionCellRef,
1745
+ bottomToolbarRef,
1746
+ editInputRefs,
1747
+ filterInputRefs,
1748
+ lastSelectedRowId,
1749
+ searchInputRef,
1750
+ tableContainerRef,
1751
+ tableFooterRef,
1752
+ tableHeadCellRefs,
1753
+ tableHeadRef,
1754
+ tablePaperRef,
1755
+ topToolbarRef,
1756
+ };
1757
+ table.setActionCell =
1758
+ (_w = statefulTableOptions.onActionCellChange) !== null && _w !== void 0 ? _w : setActionCell;
1759
+ table.setCreatingRow = (row) => {
1760
+ var _a, _b;
1761
+ let _row = row;
1762
+ if (row === true) {
1763
+ _row = createRow(table);
1764
+ }
1765
+ (_b = (_a = statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(statefulTableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
1766
+ };
1767
+ table.setColumnFilterFns =
1768
+ (_x = statefulTableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
1769
+ table.setDensity = (_y = statefulTableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
1770
+ table.setDraggingColumn =
1771
+ (_z = statefulTableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
1772
+ table.setDraggingRow =
1773
+ (_0 = statefulTableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
1774
+ table.setEditingCell =
1775
+ (_1 = statefulTableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
1776
+ table.setEditingRow =
1777
+ (_2 = statefulTableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
1778
+ table.setGlobalFilterFn =
1779
+ (_3 = statefulTableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
1780
+ table.setHoveredColumn =
1781
+ (_4 = statefulTableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
1782
+ table.setHoveredRow =
1783
+ (_5 = statefulTableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
1784
+ table.setIsFullScreen =
1785
+ (_6 = statefulTableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
1786
+ table.setShowAlertBanner =
1787
+ (_7 = statefulTableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
1788
+ table.setShowColumnFilters =
1789
+ (_8 = statefulTableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
1790
+ table.setShowGlobalFilter =
1791
+ (_9 = statefulTableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
1792
+ table.setShowToolbarDropZone =
1793
+ (_10 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
1794
+ useMRT_Effects(table);
1795
+ return table;
1796
+ };
1797
+
1798
+ const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
1799
+
1800
+ const extraIndexRangeExtractor = (range, draggingIndex) => {
1801
+ const newIndexes = defaultRangeExtractor(range);
1802
+ if (draggingIndex === undefined)
1803
+ return newIndexes;
1804
+ if (draggingIndex >= 0 &&
1805
+ draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
1806
+ newIndexes.unshift(draggingIndex);
1807
+ }
1808
+ if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
1809
+ newIndexes.push(draggingIndex);
1810
+ }
1811
+ return newIndexes;
1812
+ };
1813
+
1814
+ const useMRT_ColumnVirtualizer = (table) => {
1815
+ var _a, _b, _c, _d;
1816
+ const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
1817
+ const { columnPinning, columnVisibility, draggingColumn } = getState();
1818
+ if (!enableColumnVirtualization)
1819
+ return undefined;
1820
+ const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
1821
+ table,
1822
+ });
1823
+ const visibleColumns = table.getVisibleLeafColumns();
1824
+ const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnPinning
1825
+ ? [
1826
+ table.getLeftVisibleLeafColumns().map((c) => c.getPinnedIndex()),
1827
+ table
1828
+ .getRightVisibleLeafColumns()
1829
+ .map((column) => visibleColumns.length - column.getPinnedIndex() - 1)
1830
+ .sort((a, b) => a - b),
1831
+ ]
1832
+ : [[], []], [columnPinning, columnVisibility, enableColumnPinning]);
1833
+ const numPinnedLeft = leftPinnedIndexes.length;
1834
+ const numPinnedRight = rightPinnedIndexes.length;
1835
+ const draggingColumnIndex = useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
1836
+ ? visibleColumns.findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
1837
+ : undefined, [draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id]);
1838
+ const columnVirtualizer = useVirtualizer(Object.assign({ count: visibleColumns.length, estimateSize: (index) => visibleColumns[index].getSize(), getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
1839
+ const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
1840
+ if (!numPinnedLeft && !numPinnedRight) {
1841
+ return newIndexes;
1842
+ }
1843
+ return [
1844
+ ...new Set([
1845
+ ...leftPinnedIndexes,
1846
+ ...newIndexes,
1847
+ ...rightPinnedIndexes,
1848
+ ]),
1849
+ ];
1850
+ }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps));
1851
+ const virtualColumns = columnVirtualizer.getVirtualItems();
1852
+ columnVirtualizer.virtualColumns = virtualColumns;
1853
+ const numColumns = virtualColumns.length;
1854
+ if (numColumns) {
1855
+ const totalSize = columnVirtualizer.getTotalSize();
1856
+ const leftNonPinnedStart = ((_a = virtualColumns[numPinnedLeft]) === null || _a === void 0 ? void 0 : _a.start) || 0;
1857
+ const leftNonPinnedEnd = ((_b = virtualColumns[leftPinnedIndexes.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0;
1858
+ const rightNonPinnedStart = ((_c = virtualColumns[numColumns - numPinnedRight]) === null || _c === void 0 ? void 0 : _c.start) || 0;
1859
+ const rightNonPinnedEnd = ((_d = virtualColumns[numColumns - numPinnedRight - 1]) === null || _d === void 0 ? void 0 : _d.end) || 0;
1860
+ columnVirtualizer.virtualPaddingLeft =
1861
+ leftNonPinnedStart - leftNonPinnedEnd;
1862
+ columnVirtualizer.virtualPaddingRight =
1863
+ totalSize -
1864
+ rightNonPinnedEnd -
1865
+ (numPinnedRight ? totalSize - rightNonPinnedStart : 0);
1866
+ }
1867
+ if (columnVirtualizerInstanceRef) {
1868
+ //@ts-ignore
1869
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
1870
+ }
1871
+ return columnVirtualizer;
1872
+ };
1873
+
1874
+ const useMRT_RowVirtualizer = (table, rows) => {
1875
+ var _a;
1876
+ const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
1877
+ const { density, draggingRow, expanded } = getState();
1878
+ if (!enableRowVirtualization)
1879
+ return undefined;
1880
+ const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
1881
+ table,
1882
+ });
1883
+ const rowCount = (_a = rows === null || rows === void 0 ? void 0 : rows.length) !== null && _a !== void 0 ? _a : getRowModel().rows.length;
1884
+ const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
1885
+ const rowVirtualizer = useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
1886
+ ? expanded === true
1887
+ ? 100
1888
+ : 0
1889
+ : normalRowHeight, getScrollElement: () => tableContainerRef.current, measureElement: typeof window !== 'undefined' &&
1890
+ navigator.userAgent.indexOf('Firefox') === -1
1891
+ ? (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height
1892
+ : undefined, overscan: 4, rangeExtractor: useCallback((range) => {
1893
+ var _a;
1894
+ return extraIndexRangeExtractor(range, (_a = draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.index) !== null && _a !== void 0 ? _a : 0);
1895
+ }, [draggingRow]) }, rowVirtualizerProps));
1896
+ rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
1897
+ if (rowVirtualizerInstanceRef) {
1898
+ //@ts-ignore
1899
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
1900
+ }
1901
+ return rowVirtualizer;
1902
+ };
1903
+
1904
+ const useMRT_Rows = (table) => {
1905
+ const { getRowModel, getState, options: { data, enableGlobalFilterRankedResults, positionCreatingRow }, } = table;
1906
+ const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = getState();
1907
+ const rows = useMemo(() => getMRT_Rows(table), [
1908
+ creatingRow,
1909
+ data,
1910
+ enableGlobalFilterRankedResults,
1911
+ expanded,
1912
+ getRowModel().rows,
1913
+ globalFilter,
1914
+ pagination.pageIndex,
1915
+ pagination.pageSize,
1916
+ positionCreatingRow,
1917
+ rowPinning,
1918
+ sorting,
1919
+ ]);
1920
+ return rows;
1921
+ };
1922
+
1923
+ const allowedTypes = ['string', 'number'];
1924
+ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowIndex, table, }) => {
1925
+ var _a, _b, _c;
1926
+ const { getState, options: { enableFilterMatchHighlighting, mrtTheme: { matchHighlightColor }, }, } = table;
1927
+ const { column, row } = cell;
1928
+ const { columnDef } = column;
1929
+ const { globalFilter, globalFilterFn } = getState();
1930
+ const filterValue = column.getFilterValue();
1931
+ let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
1932
+ ? columnDef.AggregatedCell({
1933
+ cell,
1934
+ column,
1935
+ row,
1936
+ table,
1937
+ staticColumnIndex,
1938
+ staticRowIndex,
1939
+ })
1940
+ : row.getIsGrouped() && !cell.getIsGrouped()
1941
+ ? null
1942
+ : cell.getIsGrouped() && columnDef.GroupedCell
1943
+ ? columnDef.GroupedCell({
1944
+ cell,
1945
+ column,
1946
+ row,
1947
+ table,
1948
+ staticColumnIndex,
1949
+ staticRowIndex,
1950
+ })
1951
+ : undefined;
1952
+ const isGroupedValue = renderedCellValue !== undefined;
1953
+ if (!isGroupedValue) {
1954
+ renderedCellValue = cell.renderValue();
1955
+ }
1956
+ if (enableFilterMatchHighlighting &&
1957
+ columnDef.enableFilterMatchHighlighting !== false &&
1958
+ String(renderedCellValue) &&
1959
+ allowedTypes.includes(typeof renderedCellValue) &&
1960
+ ((filterValue &&
1961
+ allowedTypes.includes(typeof filterValue) &&
1962
+ ['autocomplete', 'text'].includes(columnDef.filterVariant)) ||
1963
+ (globalFilter &&
1964
+ allowedTypes.includes(typeof globalFilter) &&
1965
+ column.getCanGlobalFilter()))) {
1966
+ const chunks = highlightWords === null || highlightWords === void 0 ? void 0 : highlightWords({
1967
+ matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
1968
+ query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
1969
+ text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
1970
+ });
1971
+ 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)) {
1972
+ 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
1973
+ ? {
1974
+ backgroundColor: matchHighlightColor,
1975
+ borderRadius: '2px',
1976
+ color: (theme) => theme.palette.mode === 'dark'
1977
+ ? theme.palette.common.white
1978
+ : theme.palette.common.black,
1979
+ padding: '2px 1px',
1980
+ }
1981
+ : undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
1982
+ }
1983
+ }
1984
+ if (columnDef.Cell && !isGroupedValue) {
1985
+ renderedCellValue = columnDef.Cell({
1986
+ cell,
1987
+ column,
1988
+ renderedCellValue,
1989
+ row,
1990
+ rowRef,
1991
+ staticColumnIndex,
1992
+ staticRowIndex,
1993
+ table,
1994
+ });
1995
+ }
1996
+ return renderedCellValue;
1997
+ };
1998
+
1999
+ const MRT_CopyButton = (_a) => {
2000
+ var _b;
2001
+ var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
2002
+ const { options: { localization, muiCopyButtonProps }, } = table;
2003
+ const { column, row } = cell;
2004
+ const { columnDef } = column;
2005
+ const [copied, setCopied] = useState(false);
2006
+ const handleCopy = (event, text) => {
2007
+ event.stopPropagation();
2008
+ navigator.clipboard.writeText(text);
2009
+ setCopied(true);
2010
+ setTimeout(() => setCopied(false), 4000);
2011
+ };
2012
+ const buttonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCopyButtonProps, {
2013
+ cell,
2014
+ column,
2015
+ row,
2016
+ table,
2017
+ })), parseFromValuesOrFunc(columnDef.muiCopyButtonProps, {
2018
+ cell,
2019
+ column,
2020
+ row,
2021
+ table,
2022
+ })), rest);
2023
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _b !== void 0 ? _b : (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', py: 0, textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) })));
2024
+ };
2025
+
2026
+ const MRT_EditCellTextField = (_a) => {
2027
+ var _b, _c;
2028
+ var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
2029
+ const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
2030
+ const { column, row } = cell;
2031
+ const { columnDef } = column;
2032
+ const { creatingRow, editingRow } = getState();
2033
+ const { editSelectOptions, editVariant } = columnDef;
2034
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
2035
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
2036
+ const [value, setValue] = useState(() => cell.getValue());
2037
+ const [completesComposition, setCompletesComposition] = useState(true);
2038
+ const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
2039
+ cell,
2040
+ column,
2041
+ row,
2042
+ table,
2043
+ })), parseFromValuesOrFunc(columnDef.muiEditTextFieldProps, {
2044
+ cell,
2045
+ column,
2046
+ row,
2047
+ table,
2048
+ })), rest);
2049
+ const selectOptions = parseFromValuesOrFunc(editSelectOptions, {
2050
+ cell,
2051
+ column,
2052
+ row,
2053
+ table,
2054
+ });
2055
+ const isSelectEdit = editVariant === 'select' || (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select);
2056
+ const saveInputValueToRowCache = (newValue) => {
2057
+ //@ts-ignore
2058
+ row._valuesCache[column.id] = newValue;
2059
+ if (isCreating) {
2060
+ setCreatingRow(row);
2061
+ }
2062
+ else if (isEditing) {
2063
+ setEditingRow(row);
2064
+ }
2065
+ };
2066
+ const handleChange = (event) => {
2067
+ var _a;
2068
+ (_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2069
+ setValue(event.target.value);
2070
+ if (isSelectEdit) {
2071
+ saveInputValueToRowCache(event.target.value);
2072
+ }
2073
+ };
2074
+ const handleBlur = (event) => {
2075
+ var _a;
2076
+ (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2077
+ saveInputValueToRowCache(value);
2078
+ setEditingCell(null);
2079
+ };
2080
+ const handleEnterKeyDown = (event) => {
2081
+ var _a, _b, _c;
2082
+ (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2083
+ if (event.key === 'Enter' && !event.shiftKey && completesComposition) {
2084
+ (_c = (_b = editInputRefs.current) === null || _b === void 0 ? void 0 : _b[column.id]) === null || _c === void 0 ? void 0 : _c.blur();
2085
+ }
2086
+ };
2087
+ if (columnDef.Edit) {
2088
+ return jsx(Fragment, { children: (_b = columnDef.Edit) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table }) });
2089
+ }
2090
+ return (jsx(TextField, Object.assign({ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false, fullWidth: true, inputRef: (inputRef) => {
2091
+ if (inputRef) {
2092
+ editInputRefs.current[column.id] = inputRef;
2093
+ if (textFieldProps.inputRef) {
2094
+ textFieldProps.inputRef = inputRef;
2095
+ }
2096
+ }
2097
+ }, label: ['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
2098
+ ? columnDef.header
2099
+ : undefined, margin: "none", name: column.id, placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
2100
+ ? columnDef.header
2101
+ : undefined, select: isSelectEdit, size: "small", value: value !== null && value !== void 0 ? value : '', variant: "standard" }, textFieldProps, { InputProps: Object.assign(Object.assign(Object.assign({}, (textFieldProps.variant !== 'outlined'
2102
+ ? { disableUnderline: editDisplayMode === 'table' }
2103
+ : {})), textFieldProps.InputProps), { sx: (theme) => {
2104
+ var _a;
2105
+ return (Object.assign({ mb: 0 }, parseFromValuesOrFunc((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.sx, theme)));
2106
+ } }), SelectProps: Object.assign({ MenuProps: { disableScrollLock: true } }, textFieldProps.SelectProps), inputProps: Object.assign({ autoComplete: 'off' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
2107
+ var _a;
2108
+ e.stopPropagation();
2109
+ (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
2110
+ }, onKeyDown: handleEnterKeyDown, onCompositionStart: () => setCompletesComposition(false), onCompositionEnd: () => setCompletesComposition(true), children: (_c = textFieldProps.children) !== null && _c !== void 0 ? _c : selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.map((option) => {
2111
+ const { label, value } = getValueAndLabel(option);
2112
+ return (jsx(MenuItem, { sx: {
2113
+ alignItems: 'center',
2114
+ display: 'flex',
2115
+ gap: '0.5rem',
2116
+ m: 0,
2117
+ }, value: value, children: label }, value));
2118
+ }) })));
2119
+ };
2120
+
2121
+ const MRT_TableBodyCell = (_a) => {
2122
+ var _b, _c, _d, _e, _f;
2123
+ var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
2124
+ const theme = useTheme();
2125
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
2126
+ const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
2127
+ const { column, row } = cell;
2128
+ const { columnDef } = column;
2129
+ const { columnDefType } = columnDef;
2130
+ const args = { cell, column, row, table };
2131
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, args)), rest);
2132
+ const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
2133
+ cell,
2134
+ column,
2135
+ row,
2136
+ table,
2137
+ });
2138
+ const [skeletonWidth, setSkeletonWidth] = useState(100);
2139
+ useEffect(() => {
2140
+ if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
2141
+ return;
2142
+ const size = column.getSize();
2143
+ setSkeletonWidth(columnDefType === 'display'
2144
+ ? size / 2
2145
+ : Math.round(Math.random() * (size - size / 3) + size / 3));
2146
+ }, [isLoading, showSkeletons]);
2147
+ const draggingBorders = useMemo(() => {
2148
+ const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
2149
+ const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
2150
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
2151
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
2152
+ const isFirstColumn = column.getIsFirstColumn();
2153
+ const isLastColumn = column.getIsLastColumn();
2154
+ const isLastRow = numRows && staticRowIndex === numRows - 1;
2155
+ const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
2156
+ const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
2157
+ const borderStyle = showResizeBorder
2158
+ ? `2px solid ${draggingBorderColor} !important`
2159
+ : isDraggingColumn || isDraggingRow
2160
+ ? `1px dashed ${theme.palette.grey[500]} !important`
2161
+ : isHoveredColumn || isHoveredRow || isResizingColumn
2162
+ ? `2px dashed ${draggingBorderColor} !important`
2163
+ : undefined;
2164
+ if (showResizeBorder) {
2165
+ return columnResizeDirection === 'ltr'
2166
+ ? { borderRight: borderStyle }
2167
+ : { borderLeft: borderStyle };
2168
+ }
2169
+ return borderStyle
2170
+ ? {
2171
+ borderBottom: isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn)
2172
+ ? borderStyle
2173
+ : undefined,
2174
+ borderLeft: isDraggingColumn ||
2175
+ isHoveredColumn ||
2176
+ ((isDraggingRow || isHoveredRow) && isFirstColumn)
2177
+ ? borderStyle
2178
+ : undefined,
2179
+ borderRight: isDraggingColumn ||
2180
+ isHoveredColumn ||
2181
+ ((isDraggingRow || isHoveredRow) && isLastColumn)
2182
+ ? borderStyle
2183
+ : undefined,
2184
+ borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
2185
+ }
2186
+ : undefined;
2187
+ }, [
2188
+ columnSizingInfo.isResizingColumn,
2189
+ draggingColumn,
2190
+ draggingRow,
2191
+ hoveredColumn,
2192
+ hoveredRow,
2193
+ staticRowIndex,
2194
+ ]);
2195
+ const isColumnPinned = enableColumnPinning &&
2196
+ columnDef.columnDefType !== 'group' &&
2197
+ column.getIsPinned();
2198
+ const isEditable = isCellEditable({ cell, table });
2199
+ const isEditing = isEditable &&
2200
+ !['custom', 'modal'].includes(editDisplayMode) &&
2201
+ (editDisplayMode === 'table' ||
2202
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
2203
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
2204
+ !row.getIsGrouped();
2205
+ const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
2206
+ const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
2207
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) === true) &&
2208
+ !['context-menu', false].includes(
2209
+ // @ts-ignore
2210
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell));
2211
+ const isRightClickable = parseFromValuesOrFunc(enableCellActions, cell);
2212
+ const cellValueProps = {
2213
+ cell,
2214
+ table,
2215
+ staticColumnIndex,
2216
+ staticRowIndex,
2217
+ };
2218
+ const handleDoubleClick = (event) => {
2219
+ var _a;
2220
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2221
+ openEditingCell({ cell, table });
2222
+ };
2223
+ const handleDragEnter = (e) => {
2224
+ var _a;
2225
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
2226
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2227
+ setHoveredColumn(null);
2228
+ }
2229
+ if (enableColumnOrdering && draggingColumn) {
2230
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2231
+ }
2232
+ };
2233
+ const handleDragOver = (e) => {
2234
+ if (columnDef.enableColumnOrdering !== false) {
2235
+ e.preventDefault();
2236
+ }
2237
+ };
2238
+ const handleContextMenu = (e) => {
2239
+ var _a;
2240
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onContextMenu) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
2241
+ if (isRightClickable) {
2242
+ e.preventDefault();
2243
+ table.setActionCell(cell);
2244
+ table.refs.actionCellRef.current = e.currentTarget;
2245
+ }
2246
+ };
2247
+ const handleKeyDown = (event) => {
2248
+ var _a;
2249
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2250
+ cellKeyboardShortcuts({
2251
+ cell,
2252
+ cellValue: cell.getValue(),
2253
+ event,
2254
+ table,
2255
+ });
2256
+ };
2257
+ return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2258
+ outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
2259
+ (editDisplayMode === 'cell' && isEditable) ||
2260
+ (editDisplayMode === 'table' && (isCreating || isEditing))
2261
+ ? `1px solid ${theme.palette.grey[500]}`
2262
+ : undefined,
2263
+ textOverflow: 'clip',
2264
+ }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isRightClickable
2265
+ ? 'context-menu'
2266
+ : isEditable && editDisplayMode === 'cell'
2267
+ ? 'pointer'
2268
+ : 'inherit', outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id
2269
+ ? `1px solid ${theme.palette.grey[500]}`
2270
+ : undefined, outlineOffset: '-1px', overflow: 'hidden', p: density === 'compact'
2271
+ ? columnDefType === 'display'
2272
+ ? '0 0.5rem'
2273
+ : '0.5rem'
2274
+ : density === 'comfortable'
2275
+ ? columnDefType === 'display'
2276
+ ? '0.5rem 0.75rem'
2277
+ : '1rem'
2278
+ : columnDefType === 'display'
2279
+ ? '1rem 1.25rem'
2280
+ : '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal' }, getCommonMRTCellStyles({
2281
+ column,
2282
+ table,
2283
+ tableCellProps,
2284
+ theme,
2285
+ })), draggingBorders)), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [cell.getIsPlaceholder() ? (((_d = (_c = columnDef.PlaceholderCell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : null)) : showSkeletons !== false && (isLoading || showSkeletons) ? (jsx(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : columnDefType === 'display' &&
2286
+ (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
2287
+ !row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
2288
+ cell,
2289
+ column,
2290
+ renderedCellValue: cell.renderValue(),
2291
+ row,
2292
+ rowRef,
2293
+ staticColumnIndex,
2294
+ staticRowIndex,
2295
+ table,
2296
+ })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : showClickToCopyButton && columnDef.enableClickToCopy !== false ? (jsx(MRT_CopyButton, { cell: cell, table: table, children: jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps)) })) : (jsx(MRT_TableBodyCellValue, Object.assign({}, cellValueProps))), cell.getIsGrouped() && !columnDef.GroupedCell && (jsxs(Fragment, { children: [" (", (_f = row.subRows) === null || _f === void 0 ? void 0 : _f.length, ")"] }))] })) })));
2297
+ };
2298
+ const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2299
+
2300
+ const MRT_TableDetailPanel = (_a) => {
2301
+ var { parentRowRef, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["parentRowRef", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
2302
+ const { getState, getVisibleLeafColumns, options: { layoutMode, mrtTheme: { baseBackgroundColor }, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel, }, } = table;
2303
+ const { isLoading } = getState();
2304
+ const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
2305
+ isDetailPanel: true,
2306
+ row,
2307
+ staticRowIndex,
2308
+ table,
2309
+ });
2310
+ const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiDetailPanelProps, {
2311
+ row,
2312
+ table,
2313
+ })), rest);
2314
+ const DetailPanel = !isLoading && (renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
2315
+ return (jsx(TableRow, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", "data-index": renderDetailPanel ? staticRowIndex * 2 + 1 : staticRowIndex, ref: (node) => {
2316
+ var _a;
2317
+ if (node) {
2318
+ (_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
2319
+ }
2320
+ } }, tableRowProps, { sx: (theme) => {
2321
+ var _a, _b;
2322
+ return (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: virtualRow ? 'absolute' : undefined, top: virtualRow
2323
+ ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
2324
+ : undefined, transform: virtualRow
2325
+ ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2326
+ : undefined, width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme)));
2327
+ }, children: jsx(TableCell, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow ? baseBackgroundColor : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: !!DetailPanel && row.getIsExpanded() ? '1rem' : 0, transition: !virtualRow ? 'all 150ms ease-in-out' : undefined, width: `100%` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: virtualRow ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: DetailPanel })) })) })));
2328
+ };
2329
+
2330
+ const MRT_TableBodyRow = (_a) => {
2331
+ var _b, _c, _d, _f;
2332
+ var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
2333
+ const theme = useTheme();
2334
+ const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
2335
+ const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
2336
+ const visibleCells = row.getVisibleCells();
2337
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2338
+ const isRowSelected = getIsRowSelected({ row, table });
2339
+ const isRowPinned = enableRowPinning && row.getIsPinned();
2340
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
2341
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
2342
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyRowProps, {
2343
+ row,
2344
+ staticRowIndex,
2345
+ table,
2346
+ })), rest);
2347
+ const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
2348
+ if (!enableRowPinning ||
2349
+ !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) ||
2350
+ !pinnedRowIds ||
2351
+ !row.getIsPinned())
2352
+ return [];
2353
+ return [
2354
+ [...pinnedRowIds].reverse().indexOf(row.id),
2355
+ pinnedRowIds.indexOf(row.id),
2356
+ ];
2357
+ }, [pinnedRowIds, rowPinning]);
2358
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
2359
+ ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
2360
+ 0;
2361
+ const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
2362
+ const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
2363
+ const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
2364
+ const customRowHeight =
2365
+ // @ts-ignore
2366
+ parseInt((_f = (_d = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _d === void 0 ? void 0 : _d.height) !== null && _f !== void 0 ? _f : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
2367
+ const rowHeight = customRowHeight || defaultRowHeight;
2368
+ const handleDragEnter = (_e) => {
2369
+ if (enableRowOrdering && draggingRow) {
2370
+ setHoveredRow(row);
2371
+ }
2372
+ };
2373
+ const handleDragOver = (e) => {
2374
+ e.preventDefault();
2375
+ };
2376
+ const rowRef = useRef(null);
2377
+ const cellHighlightColor = isRowSelected
2378
+ ? selectedRowBackgroundColor
2379
+ : isRowPinned
2380
+ ? pinnedRowBackgroundColor
2381
+ : undefined;
2382
+ const cellHighlightColorHover = (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
2383
+ ? isRowSelected
2384
+ ? cellHighlightColor
2385
+ : theme.palette.mode === 'dark'
2386
+ ? `${lighten(baseBackgroundColor, 0.3)}`
2387
+ : `${darken(baseBackgroundColor, 0.3)}`
2388
+ : undefined;
2389
+ return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": renderDetailPanel ? staticRowIndex * 2 : staticRowIndex, "data-pinned": !!isRowPinned || undefined, "data-selected": isRowSelected || undefined, onDragEnter: handleDragEnter, onDragOver: handleDragOver, ref: (node) => {
2390
+ if (node) {
2391
+ rowRef.current = node;
2392
+ rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement(node);
2393
+ }
2394
+ }, selected: isRowSelected }, tableRowProps, { style: Object.assign({ transform: virtualRow
2395
+ ? `translateY(${virtualRow.start}px)`
2396
+ : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), sx: (theme) => (Object.assign({ '&:hover td:after': cellHighlightColorHover
2397
+ ? Object.assign({ backgroundColor: alpha(cellHighlightColorHover, 0.3) }, commonCellBeforeAfterStyles) : undefined, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
2398
+ ? `${bottomPinnedIndex * rowHeight +
2399
+ (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
2400
+ : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
2401
+ ? 'absolute'
2402
+ : (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned
2403
+ ? 'sticky'
2404
+ : 'relative', td: Object.assign({}, getCommonPinnedCellStyles({ table, theme })), 'td:after': cellHighlightColor
2405
+ ? Object.assign({ backgroundColor: cellHighlightColor }, commonCellBeforeAfterStyles) : undefined, top: virtualRow
2406
+ ? 0
2407
+ : topPinnedIndex !== undefined && isRowPinned
2408
+ ? `${topPinnedIndex * rowHeight +
2409
+ (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
2410
+ : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned ? 2 : 0 }, sx)), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : visibleCells).map((cellOrVirtualCell, staticColumnIndex) => {
2411
+ let cell = cellOrVirtualCell;
2412
+ if (columnVirtualizer) {
2413
+ staticColumnIndex = cellOrVirtualCell.index;
2414
+ cell = visibleCells[staticColumnIndex];
2415
+ }
2416
+ const props = {
2417
+ cell,
2418
+ numRows,
2419
+ rowRef,
2420
+ staticColumnIndex,
2421
+ staticRowIndex,
2422
+ table,
2423
+ };
2424
+ const key = `${cell.id}-${staticRowIndex}`;
2425
+ return cell ? (memoMode === 'cells' &&
2426
+ cell.column.columnDef.columnDefType === 'data' &&
2427
+ !draggingColumn &&
2428
+ !draggingRow &&
2429
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
2430
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
2431
+ }), virtualPaddingRight ? (jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
2432
+ };
2433
+ const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
2434
+
2435
+ const MRT_TableBody = (_a) => {
2436
+ var _b, _c, _d, _e, _f, _g;
2437
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2438
+ const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
2439
+ const { columnFilters, globalFilter, isFullScreen, rowPinning } = getState();
2440
+ const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
2441
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
2442
+ ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
2443
+ 0;
2444
+ const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
2445
+ const pinnedRowIds = useMemo(() => {
2446
+ var _a, _b;
2447
+ if (!((_a = rowPinning.bottom) === null || _a === void 0 ? void 0 : _a.length) && !((_b = rowPinning.top) === null || _b === void 0 ? void 0 : _b.length))
2448
+ return [];
2449
+ return getRowModel()
2450
+ .rows.filter((row) => row.getIsPinned())
2451
+ .map((r) => r.id);
2452
+ }, [rowPinning, getRowModel().rows]);
2453
+ const rows = useMRT_Rows(table);
2454
+ const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
2455
+ const { virtualRows } = rowVirtualizer !== null && rowVirtualizer !== void 0 ? rowVirtualizer : {};
2456
+ const commonRowProps = {
2457
+ columnVirtualizer,
2458
+ numRows: rows.length,
2459
+ table,
2460
+ };
2461
+ return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
2462
+ getIsSomeRowsPinned('top') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, staticRowIndex) => {
2463
+ const props = Object.assign(Object.assign({}, commonRowProps), { row,
2464
+ staticRowIndex });
2465
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2466
+ }) }))), jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
2467
+ ? `${rowVirtualizer.getTotalSize()}px`
2468
+ : undefined, minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: (_d = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _d !== void 0 ? _d : (!rows.length ? (jsx("tr", { style: {
2469
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
2470
+ }, children: jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
2471
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
2472
+ }, children: (_e = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _e !== void 0 ? _e : (jsx(Typography, { sx: {
2473
+ color: 'text.secondary',
2474
+ fontStyle: 'italic',
2475
+ maxWidth: `min(100vw, ${(_g = (_f = tablePaperRef.current) === null || _f === void 0 ? void 0 : _f.clientWidth) !== null && _g !== void 0 ? _g : 360}px)`,
2476
+ py: '2rem',
2477
+ textAlign: 'center',
2478
+ width: '100%',
2479
+ }, children: globalFilter || columnFilters.length
2480
+ ? localization.noResultsFound
2481
+ : localization.noRecordsToDisplay })) }) })) : (jsx(Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, staticRowIndex) => {
2482
+ let row = rowOrVirtualRow;
2483
+ if (rowVirtualizer) {
2484
+ if (renderDetailPanel) {
2485
+ if (rowOrVirtualRow.index % 2 === 1) {
2486
+ return null;
2487
+ }
2488
+ else {
2489
+ staticRowIndex = rowOrVirtualRow.index / 2;
2490
+ }
2491
+ }
2492
+ else {
2493
+ staticRowIndex = rowOrVirtualRow.index;
2494
+ }
2495
+ row = rows[staticRowIndex];
2496
+ }
2497
+ const props = Object.assign(Object.assign({}, commonRowProps), { pinnedRowIds,
2498
+ row,
2499
+ rowVirtualizer,
2500
+ staticRowIndex, virtualRow: rowVirtualizer
2501
+ ? rowOrVirtualRow
2502
+ : undefined });
2503
+ const key = `${row.id}-${row.index}`;
2504
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
2505
+ }) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
2506
+ getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, staticRowIndex) => {
2507
+ const props = Object.assign(Object.assign({}, commonRowProps), { row,
2508
+ staticRowIndex });
2509
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2510
+ }) })))] }));
2511
+ };
2512
+ const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2513
+
2514
+ const MRT_TableFooterCell = (_a) => {
2515
+ var _b, _c, _d;
2516
+ var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
2517
+ const theme = useTheme();
2518
+ const { getState, options: { enableColumnPinning, muiTableFooterCellProps, enableKeyboardShortcuts, }, } = table;
2519
+ const { density } = getState();
2520
+ const { column } = footer;
2521
+ const { columnDef } = column;
2522
+ const { columnDefType } = columnDef;
2523
+ const isColumnPinned = enableColumnPinning &&
2524
+ columnDef.columnDefType !== 'group' &&
2525
+ column.getIsPinned();
2526
+ const args = { column, table };
2527
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
2528
+ const handleKeyDown = (event) => {
2529
+ var _a;
2530
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2531
+ cellKeyboardShortcuts({
2532
+ event,
2533
+ cellValue: footer.column.columnDef.footer,
2534
+ table,
2535
+ });
2536
+ };
2537
+ return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
2538
+ ? 'center'
2539
+ : theme.direction === 'rtl'
2540
+ ? 'right'
2541
+ : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined, variant: "footer" }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
2542
+ ? '0.5rem'
2543
+ : density === 'comfortable'
2544
+ ? '1rem'
2545
+ : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
2546
+ column,
2547
+ header: footer,
2548
+ table,
2549
+ tableCellProps,
2550
+ theme,
2551
+ })), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: (_b = tableCellProps.children) !== null && _b !== void 0 ? _b : (footer.isPlaceholder
2552
+ ? null
2553
+ : ((_d = (_c = parseFromValuesOrFunc(columnDef.Footer, {
2554
+ column,
2555
+ footer,
2556
+ table,
2557
+ })) !== null && _c !== void 0 ? _c : columnDef.footer) !== null && _d !== void 0 ? _d : null)) })));
2558
+ };
2559
+
2560
+ const MRT_TableFooterRow = (_a) => {
2561
+ var _b;
2562
+ var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
2563
+ const { options: { layoutMode, mrtTheme: { baseBackgroundColor }, muiTableFooterRowProps, }, } = table;
2564
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2565
+ // if no content in row, skip row
2566
+ if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2567
+ !!header.column.columnDef.footer) ||
2568
+ header.column.columnDef.Footer))) {
2569
+ return null;
2570
+ }
2571
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterRowProps, {
2572
+ footerGroup,
2573
+ table,
2574
+ })), rest);
2575
+ return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: baseBackgroundColor, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: 'relative', 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, staticColumnIndex) => {
2576
+ let footer = footerOrVirtualFooter;
2577
+ if (columnVirtualizer) {
2578
+ staticColumnIndex = footerOrVirtualFooter
2579
+ .index;
2580
+ footer = footerGroup.headers[staticColumnIndex];
2581
+ }
2582
+ return footer ? (jsx(MRT_TableFooterCell, { footer: footer, staticColumnIndex: staticColumnIndex, table: table }, footer.id)) : null;
2583
+ }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2584
+ };
2585
+
2586
+ const MRT_TableFooter = (_a) => {
2587
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2588
+ const { getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
2589
+ const { isFullScreen } = getState();
2590
+ const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
2591
+ table,
2592
+ })), rest);
2593
+ const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2594
+ const footerGroups = table.getFooterGroups();
2595
+ //if no footer cells at all, skip footer
2596
+ if (!footerGroups.some((footerGroup) => {
2597
+ var _a;
2598
+ return (_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2599
+ !!header.column.columnDef.footer) ||
2600
+ header.column.columnDef.Footer);
2601
+ })) {
2602
+ return null;
2603
+ }
2604
+ return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
2605
+ tableFooterRef.current = ref;
2606
+ if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
2607
+ // @ts-ignore
2608
+ tableFooterProps.ref.current = ref;
2609
+ }
2610
+ }, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
2611
+ ? theme.palette.mode === 'light'
2612
+ ? `1px solid ${theme.palette.grey[300]}`
2613
+ : `1px solid ${theme.palette.grey[700]}`
2614
+ : undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: footerGroups.map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
2615
+ };
2616
+
2617
+ const mrtFilterOptions = (localization) => [
2618
+ {
2619
+ divider: false,
2620
+ label: localization.filterFuzzy,
2621
+ option: 'fuzzy',
2622
+ symbol: '≈',
2623
+ },
2624
+ {
2625
+ divider: false,
2626
+ label: localization.filterContains,
2627
+ option: 'contains',
2628
+ symbol: '*',
2629
+ },
2630
+ {
2631
+ divider: false,
2632
+ label: localization.filterStartsWith,
2633
+ option: 'startsWith',
2634
+ symbol: 'a',
2635
+ },
2636
+ {
2637
+ divider: true,
2638
+ label: localization.filterEndsWith,
2639
+ option: 'endsWith',
2640
+ symbol: 'z',
2641
+ },
2642
+ {
2643
+ divider: false,
2644
+ label: localization.filterEquals,
2645
+ option: 'equals',
2646
+ symbol: '=',
2647
+ },
2648
+ {
2649
+ divider: true,
2650
+ label: localization.filterNotEquals,
2651
+ option: 'notEquals',
2652
+ symbol: '≠',
2653
+ },
2654
+ {
2655
+ divider: false,
2656
+ label: localization.filterBetween,
2657
+ option: 'between',
2658
+ symbol: '⇿',
2659
+ },
2660
+ {
2661
+ divider: true,
2662
+ label: localization.filterBetweenInclusive,
2663
+ option: 'betweenInclusive',
2664
+ symbol: '⬌',
2665
+ },
2666
+ {
2667
+ divider: false,
2668
+ label: localization.filterGreaterThan,
2669
+ option: 'greaterThan',
2670
+ symbol: '>',
2671
+ },
2672
+ {
2673
+ divider: false,
2674
+ label: localization.filterGreaterThanOrEqualTo,
2675
+ option: 'greaterThanOrEqualTo',
2676
+ symbol: '≥',
2677
+ },
2678
+ {
2679
+ divider: false,
2680
+ label: localization.filterLessThan,
2681
+ option: 'lessThan',
2682
+ symbol: '<',
2683
+ },
2684
+ {
2685
+ divider: true,
2686
+ label: localization.filterLessThanOrEqualTo,
2687
+ option: 'lessThanOrEqualTo',
2688
+ symbol: '≤',
2689
+ },
2690
+ {
2691
+ divider: false,
2692
+ label: localization.filterEmpty,
2693
+ option: 'empty',
2694
+ symbol: '∅',
2695
+ },
2696
+ {
2697
+ divider: false,
2698
+ label: localization.filterNotEmpty,
2699
+ option: 'notEmpty',
2700
+ symbol: '!∅',
2701
+ },
2702
+ ];
2703
+ const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
2704
+ const emptyModes = ['empty', 'notEmpty'];
2705
+ const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
2706
+ const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
2707
+ const MRT_FilterOptionMenu = (_a) => {
2708
+ var _b, _c, _d, _e;
2709
+ var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
2710
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, mrtTheme: { menuBackgroundColor }, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
2711
+ const { density, globalFilterFn } = getState();
2712
+ const { column } = header !== null && header !== void 0 ? header : {};
2713
+ const { columnDef } = column !== null && column !== void 0 ? column : {};
2714
+ const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
2715
+ let allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2716
+ if (rangeVariants.includes(columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant)) {
2717
+ allowedColumnFilterOptions = [
2718
+ ...rangeModes,
2719
+ ...(allowedColumnFilterOptions !== null && allowedColumnFilterOptions !== void 0 ? allowedColumnFilterOptions : []),
2720
+ ].filter((option) => rangeModes.includes(option));
2721
+ }
2722
+ const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
2723
+ ? allowedColumnFilterOptions === undefined ||
2724
+ (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
2725
+ : (!globalFilterModeOptions ||
2726
+ globalFilterModeOptions.includes(filterOption.option)) &&
2727
+ ['contains', 'fuzzy', 'startsWith'].includes(filterOption.option)), []);
2728
+ const handleSelectFilterMode = (option) => {
2729
+ var _a, _b;
2730
+ const prevFilterMode = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef._filterFn) !== null && _a !== void 0 ? _a : '';
2731
+ if (!header || !column) {
2732
+ // global filter mode
2733
+ setGlobalFilterFn(option);
2734
+ }
2735
+ else if (option !== prevFilterMode) {
2736
+ // column filter mode
2737
+ setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
2738
+ // reset filter value and/or perform new filter render
2739
+ if (emptyModes.includes(option)) {
2740
+ // will now be empty/notEmpty filter mode
2741
+ if (currentFilterValue !== ' ' &&
2742
+ !emptyModes.includes(prevFilterMode)) {
2743
+ column.setFilterValue(' ');
2744
+ }
2745
+ else if (currentFilterValue) {
2746
+ column.setFilterValue(currentFilterValue); // perform new filter render
2747
+ }
2748
+ }
2749
+ else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
2750
+ arrModes.includes(option)) {
2751
+ // will now be array filter mode
2752
+ if (currentFilterValue instanceof String ||
2753
+ (currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.length)) {
2754
+ column.setFilterValue([]);
2755
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue([]);
2756
+ }
2757
+ else if (currentFilterValue) {
2758
+ column.setFilterValue(currentFilterValue); // perform new filter render
2759
+ }
2760
+ }
2761
+ else if (((_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === null || _b === void 0 ? void 0 : _b.includes('range')) ||
2762
+ rangeModes.includes(option)) {
2763
+ // will now be range filter mode
2764
+ if (!Array.isArray(currentFilterValue) ||
2765
+ (!(currentFilterValue === null || currentFilterValue === void 0 ? void 0 : currentFilterValue.every((v) => v === '')) &&
2766
+ !rangeModes.includes(prevFilterMode))) {
2767
+ column.setFilterValue(['', '']);
2768
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2769
+ }
2770
+ else {
2771
+ column.setFilterValue(currentFilterValue); // perform new filter render
2772
+ }
2773
+ }
2774
+ else {
2775
+ // will now be single value filter mode
2776
+ if (Array.isArray(currentFilterValue)) {
2777
+ column.setFilterValue('');
2778
+ setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
2779
+ }
2780
+ else if (currentFilterValue === ' ' &&
2781
+ emptyModes.includes(prevFilterMode)) {
2782
+ column.setFilterValue(undefined);
2783
+ }
2784
+ else {
2785
+ column.setFilterValue(currentFilterValue); // perform new filter render
2786
+ }
2787
+ }
2788
+ }
2789
+ setAnchorEl(null);
2790
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
2791
+ };
2792
+ const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
2793
+ return (jsx(Menu, Object.assign({ MenuListProps: {
2794
+ dense: density === 'compact',
2795
+ sx: {
2796
+ backgroundColor: menuBackgroundColor,
2797
+ },
2798
+ }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
2799
+ ? ((_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
2800
+ column: column,
2801
+ internalFilterOptions,
2802
+ onSelectFilterMode: handleSelectFilterMode,
2803
+ table,
2804
+ })) !== null && _d !== void 0 ? _d : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
2805
+ column: column,
2806
+ internalFilterOptions,
2807
+ onSelectFilterMode: handleSelectFilterMode,
2808
+ table,
2809
+ }))
2810
+ : renderGlobalFilterModeMenuItems === null || renderGlobalFilterModeMenuItems === void 0 ? void 0 : renderGlobalFilterModeMenuItems({
2811
+ internalFilterOptions,
2812
+ onSelectFilterMode: handleSelectFilterMode,
2813
+ table,
2814
+ }))) !== null && _e !== void 0 ? _e : internalFilterOptions.map(({ divider, label, option, symbol }, index) => (jsx(MRT_ActionMenuItem, { divider: divider, icon: symbol, label: label, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, table: table, value: option }, index))) })));
2815
+ };
2816
+
2817
+ const MRT_ColumnActionMenu = (_a) => {
2818
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2819
+ var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
2820
+ const { getAllLeafColumns, getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, mrtTheme: { menuBackgroundColor }, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, } = table;
2821
+ const { column } = header;
2822
+ const { columnDef } = column;
2823
+ const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
2824
+ const columnFilterValue = column.getFilterValue();
2825
+ const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
2826
+ const handleClearSort = () => {
2827
+ column.clearSorting();
2828
+ setAnchorEl(null);
2829
+ };
2830
+ const handleSortAsc = () => {
2831
+ column.toggleSorting(false);
2832
+ setAnchorEl(null);
2833
+ };
2834
+ const handleSortDesc = () => {
2835
+ column.toggleSorting(true);
2836
+ setAnchorEl(null);
2837
+ };
2838
+ const handleResetColumnSize = () => {
2839
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
2840
+ column.resetSize();
2841
+ setAnchorEl(null);
2842
+ };
2843
+ const handleHideColumn = () => {
2844
+ column.toggleVisibility(false);
2845
+ setAnchorEl(null);
2846
+ };
2847
+ const handlePinColumn = (pinDirection) => {
2848
+ column.pin(pinDirection);
2849
+ setAnchorEl(null);
2850
+ };
2851
+ const handleGroupByColumn = () => {
2852
+ column.toggleGrouping();
2853
+ setColumnOrder((old) => ['mrt-row-expand', ...old]);
2854
+ setAnchorEl(null);
2855
+ };
2856
+ const handleClearFilter = () => {
2857
+ column.setFilterValue(undefined);
2858
+ setAnchorEl(null);
2859
+ if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
2860
+ setColumnFilterFns((prev) => {
2861
+ var _a;
2862
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
2863
+ });
2864
+ }
2865
+ };
2866
+ const handleFilterByColumn = () => {
2867
+ setShowColumnFilters(true);
2868
+ queueMicrotask(() => { var _a, _b; return (_b = (_a = filterInputRefs.current) === null || _a === void 0 ? void 0 : _a[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.focus(); });
2869
+ setAnchorEl(null);
2870
+ };
2871
+ const handleShowAllColumns = () => {
2872
+ getAllLeafColumns()
2873
+ .filter((col) => col.columnDef.enableHiding !== false)
2874
+ .forEach((col) => col.toggleVisibility(true));
2875
+ setAnchorEl(null);
2876
+ };
2877
+ const handleOpenFilterModeMenu = (event) => {
2878
+ event.stopPropagation();
2879
+ setFilterMenuAnchorEl(event.currentTarget);
2880
+ };
2881
+ const isSelectFilter = !!columnDef.filterSelectOptions;
2882
+ const allowedColumnFilterOptions = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _b !== void 0 ? _b : columnFilterModeOptions;
2883
+ const showFilterModeSubMenu = enableColumnFilterModes &&
2884
+ columnDef.enableColumnFilterModes !== false &&
2885
+ !isSelectFilter &&
2886
+ (allowedColumnFilterOptions === undefined ||
2887
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
2888
+ const internalColumnMenuItems = [
2889
+ ...(enableSorting && column.getCanSort()
2890
+ ? [
2891
+ enableSortingRemoval !== false && (jsx(MRT_ActionMenuItem, { icon: jsx(ClearAllIcon, {}), label: localization.clearSort, onClick: handleClearSort, table: table }, 0)),
2892
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'asc', icon: jsx(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } }), label: (_c = localization.sortByColumnAsc) === null || _c === void 0 ? void 0 : _c.replace('{column}', String(columnDef.header)), onClick: handleSortAsc, table: table }, 1),
2893
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsSorted() === 'desc', divider: enableColumnFilters || enableGrouping || enableHiding, icon: jsx(SortIcon, {}), label: (_d = localization.sortByColumnDesc) === null || _d === void 0 ? void 0 : _d.replace('{column}', String(columnDef.header)), onClick: handleSortDesc, table: table }, 2),
2894
+ ]
2895
+ : []),
2896
+ ...(enableColumnFilters && column.getCanFilter()
2897
+ ? [
2898
+ jsx(MRT_ActionMenuItem, { disabled: !columnFilterValue ||
2899
+ (Array.isArray(columnFilterValue) &&
2900
+ !columnFilterValue.filter((value) => value).length), icon: jsx(FilterListOffIcon, {}), label: localization.clearFilter, onClick: handleClearFilter, table: table }, 3),
2901
+ columnFilterDisplayMode === 'subheader' && (jsx(MRT_ActionMenuItem, { disabled: showColumnFilters && !enableColumnFilterModes, divider: enableGrouping || enableHiding, icon: jsx(FilterListIcon, {}), label: (_e = localization.filterByColumn) === null || _e === void 0 ? void 0 : _e.replace('{column}', String(columnDef.header)), onClick: showColumnFilters
2902
+ ? handleOpenFilterModeMenu
2903
+ : handleFilterByColumn, onOpenSubMenu: showFilterModeSubMenu ? handleOpenFilterModeMenu : undefined, table: table }, 4)),
2904
+ showFilterModeSubMenu && (jsx(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table }, 5)),
2905
+ ].filter(Boolean)
2906
+ : []),
2907
+ ...(enableGrouping && column.getCanGroup()
2908
+ ? [
2909
+ jsx(MRT_ActionMenuItem, { divider: enableColumnPinning, icon: jsx(DynamicFeedIcon, {}), label: (_f = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)), onClick: handleGroupByColumn, table: table }, 6),
2910
+ ]
2911
+ : []),
2912
+ ...(enableColumnPinning && column.getCanPin()
2913
+ ? [
2914
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'left' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(90deg)' } }), label: localization.pinToLeft, onClick: () => handlePinColumn('left'), table: table }, 7),
2915
+ jsx(MRT_ActionMenuItem, { disabled: column.getIsPinned() === 'right' || !column.getCanPin(), icon: jsx(PushPinIcon, { style: { transform: 'rotate(-90deg)' } }), label: localization.pinToRight, onClick: () => handlePinColumn('right'), table: table }, 8),
2916
+ jsx(MRT_ActionMenuItem, { disabled: !column.getIsPinned(), divider: enableHiding, icon: jsx(PushPinIcon, {}), label: localization.unpin, onClick: () => handlePinColumn(false), table: table }, 9),
2917
+ ]
2918
+ : []),
2919
+ ...(enableColumnResizing && column.getCanResize()
2920
+ ? [
2921
+ jsx(MRT_ActionMenuItem, { disabled: !columnSizing[column.id], icon: jsx(RestartAltIcon, {}), label: localization.resetColumnSize, onClick: handleResetColumnSize, table: table }, 10),
2922
+ ]
2923
+ : []),
2924
+ ...(enableHiding
2925
+ ? [
2926
+ jsx(MRT_ActionMenuItem, { disabled: !column.getCanHide(), icon: jsx(VisibilityOffIcon, {}), label: (_g = localization.hideColumn) === null || _g === void 0 ? void 0 : _g.replace('{column}', String(columnDef.header)), onClick: handleHideColumn, table: table }, 11),
2927
+ jsx(MRT_ActionMenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
2928
+ .length, icon: jsx(ViewColumnIcon, {}), label: (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header)), onClick: handleShowAllColumns, table: table }, 12),
2929
+ ]
2930
+ : []),
2931
+ ].filter(Boolean);
2932
+ return (jsx(Menu, Object.assign({ MenuListProps: {
2933
+ dense: density === 'compact',
2934
+ sx: {
2935
+ backgroundColor: menuBackgroundColor,
2936
+ },
2937
+ }, anchorEl: anchorEl, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_l = (_k = (_j = columnDef.renderColumnActionsMenuItems) === null || _j === void 0 ? void 0 : _j.call(columnDef, {
2938
+ closeMenu: () => setAnchorEl(null),
2939
+ column,
2940
+ internalColumnMenuItems,
2941
+ table,
2942
+ })) !== null && _k !== void 0 ? _k : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
2943
+ closeMenu: () => setAnchorEl(null),
2944
+ column,
2945
+ internalColumnMenuItems,
2946
+ table,
2947
+ })) !== null && _l !== void 0 ? _l : internalColumnMenuItems })));
2948
+ };
2949
+
2950
+ const MRT_TableHeadCellColumnActionsButton = (_a) => {
2951
+ var _b, _c;
2952
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
2953
+ const { options: { icons: { MoreVertIcon }, localization, muiColumnActionsButtonProps, }, } = table;
2954
+ const { column } = header;
2955
+ const { columnDef } = column;
2956
+ const [anchorEl, setAnchorEl] = useState(null);
2957
+ const handleClick = (event) => {
2958
+ event.stopPropagation();
2959
+ event.preventDefault();
2960
+ setAnchorEl(event.currentTarget);
2961
+ };
2962
+ const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnActionsButtonProps, {
2963
+ column,
2964
+ table,
2965
+ })), parseFromValuesOrFunc(columnDef.muiColumnActionsButtonProps, {
2966
+ column,
2967
+ table,
2968
+ })), rest);
2969
+ return (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.columnActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ '&:hover': {
2970
+ opacity: 1,
2971
+ }, height: '2rem', m: '-8px -4px', opacity: 0.3, transition: 'all 150ms', width: '2rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsx(MoreVertIcon, { style: { transform: 'scale(0.9)' } })) })) })), anchorEl && (jsx(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table }))] }));
2972
+ };
2973
+
2974
+ const MRT_FilterCheckbox = (_a) => {
2975
+ var _b, _c, _d;
2976
+ var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
2977
+ const { getState, options: { localization, muiFilterCheckboxProps }, } = table;
2978
+ const { density } = getState();
2979
+ const { columnDef } = column;
2980
+ const checkboxProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterCheckboxProps, {
2981
+ column,
2982
+ table,
2983
+ })), parseFromValuesOrFunc(columnDef.muiFilterCheckboxProps, {
2984
+ column,
2985
+ table,
2986
+ })), rest);
2987
+ const filterLabel = (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', columnDef.header);
2988
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_c = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _c !== void 0 ? _c : 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) => {
2989
+ var _a;
2990
+ column.setFilterValue(column.getFilterValue() === undefined
2991
+ ? 'true'
2992
+ : column.getFilterValue() === 'true'
2993
+ ? 'false'
2994
+ : undefined);
2995
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onChange) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e, checked);
2996
+ }, onClick: (e) => {
2997
+ var _a;
2998
+ e.stopPropagation();
2999
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
3000
+ }, sx: (theme) => (Object.assign({ height: '2.5rem', width: '2.5rem' }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))) })), disableTypography: true, label: (_d = checkboxProps.title) !== null && _d !== void 0 ? _d : filterLabel, sx: { color: 'text.secondary', fontWeight: 'normal', mt: '-4px' }, title: undefined }) })));
3001
+ };
3002
+
3003
+ const MRT_FilterTextField = (_a) => {
3004
+ var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
3005
+ var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
3006
+ const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
3007
+ const { column } = header;
3008
+ const { columnDef } = column;
3009
+ const { filterVariant } = columnDef;
3010
+ const args = { column, rangeFilterIndex, table };
3011
+ const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTextFieldProps, args)), parseFromValuesOrFunc(columnDef.muiFilterTextFieldProps, args)), rest);
3012
+ const autocompleteProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterAutocompleteProps, args)), parseFromValuesOrFunc(columnDef.muiFilterAutocompleteProps, args));
3013
+ const datePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterDatePickerProps, args)), parseFromValuesOrFunc(columnDef.muiFilterDatePickerProps, args));
3014
+ const dateTimePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterDateTimePickerProps, args)), parseFromValuesOrFunc(columnDef.muiFilterDateTimePickerProps, args));
3015
+ const timePickerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterTimePickerProps, args)), parseFromValuesOrFunc(columnDef.muiFilterTimePickerProps, args));
3016
+ const { allowedColumnFilterOptions, currentFilterOption, facetedUniqueValues, isAutocompleteFilter, isDateFilter, isMultiSelectFilter, isRangeFilter, isSelectFilter, isTextboxFilter, } = getColumnFilterInfo({ header, table });
3017
+ const dropdownOptions = useDropdownOptions({ header, table });
3018
+ const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
3019
+ ? //@ts-ignore
3020
+ localization[`filter${((_c = (_b = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt) === null || _b === void 0 ? void 0 : _b.call(currentFilterOption, 0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
3021
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
3022
+ : '';
3023
+ const filterPlaceholder = !isRangeFilter
3024
+ ? ((_d = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.placeholder) !== null && _d !== void 0 ? _d : (_f = localization.filterByColumn) === null || _f === void 0 ? void 0 : _f.replace('{column}', String(columnDef.header)))
3025
+ : rangeFilterIndex === 0
3026
+ ? localization.min
3027
+ : rangeFilterIndex === 1
3028
+ ? localization.max
3029
+ : '';
3030
+ const showChangeModeButton = !!(enableColumnFilterModes &&
3031
+ columnDef.enableColumnFilterModes !== false &&
3032
+ !rangeFilterIndex &&
3033
+ (allowedColumnFilterOptions === undefined ||
3034
+ !!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length)));
3035
+ const [anchorEl, setAnchorEl] = useState(null);
3036
+ const [filterValue, setFilterValue] = useState(() => {
3037
+ var _a, _b;
3038
+ return isMultiSelectFilter
3039
+ ? column.getFilterValue() || []
3040
+ : isRangeFilter
3041
+ ? ((_a = column.getFilterValue()) === null || _a === void 0 ? void 0 : _a[rangeFilterIndex]) || ''
3042
+ : ((_b = column.getFilterValue()) !== null && _b !== void 0 ? _b : '');
3043
+ });
3044
+ const [autocompleteValue, setAutocompleteValue] = useState(isAutocompleteFilter ? filterValue : null);
3045
+ const handleChangeDebounced = useCallback(debounce((newValue) => {
3046
+ if (isRangeFilter) {
3047
+ column.setFilterValue((old) => {
3048
+ const newFilterValues = old !== null && old !== void 0 ? old : ['', ''];
3049
+ newFilterValues[rangeFilterIndex] = newValue !== null && newValue !== void 0 ? newValue : undefined;
3050
+ return newFilterValues;
3051
+ });
3052
+ }
3053
+ else {
3054
+ column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
3055
+ }
3056
+ }, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
3057
+ const handleChange = (newValue) => {
3058
+ setFilterValue(newValue !== null && newValue !== void 0 ? newValue : '');
3059
+ handleChangeDebounced(newValue);
3060
+ };
3061
+ const handleTextFieldChange = (event) => {
3062
+ var _a;
3063
+ const newValue = textFieldProps.type === 'date'
3064
+ ? event.target.valueAsDate
3065
+ : textFieldProps.type === 'number'
3066
+ ? event.target.valueAsNumber
3067
+ : event.target.value;
3068
+ handleChange(newValue);
3069
+ (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
3070
+ };
3071
+ const handleAutocompleteChange = (newValue) => {
3072
+ setAutocompleteValue(newValue);
3073
+ handleChange(getValueAndLabel(newValue).value);
3074
+ };
3075
+ const handleClear = () => {
3076
+ if (isMultiSelectFilter) {
3077
+ setFilterValue([]);
3078
+ column.setFilterValue([]);
3079
+ }
3080
+ else if (isRangeFilter) {
3081
+ setFilterValue('');
3082
+ column.setFilterValue((old) => {
3083
+ const newFilterValues = (Array.isArray(old) && old) || ['', ''];
3084
+ newFilterValues[rangeFilterIndex] = undefined;
3085
+ return newFilterValues;
3086
+ });
3087
+ }
3088
+ else {
3089
+ setFilterValue('');
3090
+ column.setFilterValue(undefined);
3091
+ }
3092
+ };
3093
+ const handleClearEmptyFilterChip = () => {
3094
+ setFilterValue('');
3095
+ column.setFilterValue(undefined);
3096
+ setColumnFilterFns((prev) => {
3097
+ var _a;
3098
+ return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
3099
+ });
3100
+ };
3101
+ const handleFilterMenuOpen = (event) => {
3102
+ setAnchorEl(event.currentTarget);
3103
+ };
3104
+ const isMounted = useRef(false);
3105
+ useEffect(() => {
3106
+ if (isMounted.current) {
3107
+ const filterValue = column.getFilterValue();
3108
+ if (filterValue === undefined) {
3109
+ handleClear();
3110
+ }
3111
+ else if (isRangeFilter && rangeFilterIndex !== undefined) {
3112
+ setFilterValue(filterValue[rangeFilterIndex]);
3113
+ }
3114
+ else {
3115
+ setFilterValue(filterValue);
3116
+ }
3117
+ }
3118
+ isMounted.current = true;
3119
+ }, [column.getFilterValue()]);
3120
+ if (columnDef.Filter) {
3121
+ return (jsx(Fragment, { children: (_g = columnDef.Filter) === null || _g === void 0 ? void 0 : _g.call(columnDef, { column, header, rangeFilterIndex, table }) }));
3122
+ }
3123
+ const endAdornment = !isAutocompleteFilter && !isDateFilter && !filterChipLabel ? (jsx(InputAdornment, { position: "end", sx: { mr: isSelectFilter || isMultiSelectFilter ? '20px' : undefined }, children: jsx(Tooltip, { 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: {
3124
+ height: '2rem',
3125
+ transform: 'scale(0.9)',
3126
+ width: '2rem',
3127
+ }, children: jsx(CloseIcon, {}) }) }) }) })) : null;
3128
+ const startAdornment = showChangeModeButton ? (jsxs(InputAdornment, { position: "start", children: [jsx(Tooltip, { 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;
3129
+ const commonTextFieldProps = Object.assign(Object.assign({ FormHelperTextProps: {
3130
+ sx: {
3131
+ fontSize: '0.75rem',
3132
+ lineHeight: '0.8rem',
3133
+ whiteSpace: 'nowrap',
3134
+ },
3135
+ }, InputProps: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
3136
+ ? { endAdornment, startAdornment }
3137
+ : { startAdornment }, fullWidth: true, helperText: showChangeModeButton ? (jsx("label", { children: localization.filterMode.replace('{filterType}',
3138
+ // @ts-ignore
3139
+ localization[`filter${((_k = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _k === void 0 ? void 0 : _k.toUpperCase()) +
3140
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputProps: {
3141
+ 'aria-label': filterPlaceholder,
3142
+ autoComplete: 'off',
3143
+ disabled: !!filterChipLabel,
3144
+ sx: {
3145
+ textOverflow: 'ellipsis',
3146
+ width: filterChipLabel ? 0 : undefined,
3147
+ },
3148
+ title: filterPlaceholder,
3149
+ }, inputRef: (inputRef) => {
3150
+ filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
3151
+ inputRef;
3152
+ if (textFieldProps.inputRef) {
3153
+ textFieldProps.inputRef = inputRef;
3154
+ }
3155
+ }, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
3156
+ ? undefined
3157
+ : filterPlaceholder, variant: 'standard' }, textFieldProps), { onKeyDown: (e) => {
3158
+ var _a;
3159
+ e.stopPropagation();
3160
+ (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
3161
+ }, sx: (theme) => (Object.assign({ minWidth: isDateFilter
3162
+ ? '160px'
3163
+ : enableColumnFilterModes && rangeFilterIndex === 0
3164
+ ? '110px'
3165
+ : isRangeFilter
3166
+ ? '100px'
3167
+ : !filterChipLabel
3168
+ ? '120px'
3169
+ : 'auto', mx: '-2px', p: 0, width: 'calc(100% + 4px)' }, parseFromValuesOrFunc(textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx, theme))) });
3170
+ const commonDatePickerProps = {
3171
+ onChange: (newDate) => {
3172
+ handleChange(newDate);
3173
+ },
3174
+ value: filterValue || null,
3175
+ };
3176
+ return (jsxs(Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsx(TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: {
3177
+ field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_l = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _l === void 0 ? void 0 : _l.field),
3178
+ textField: Object.assign(Object.assign({}, commonTextFieldProps), (_m = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _m === void 0 ? void 0 : _m.textField),
3179
+ } }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsx(DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: {
3180
+ field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_o = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _o === void 0 ? void 0 : _o.field),
3181
+ textField: Object.assign(Object.assign({}, commonTextFieldProps), (_p = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _p === void 0 ? void 0 : _p.textField),
3182
+ } }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
3183
+ field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_q = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _q === void 0 ? void 0 : _q.field),
3184
+ textField: Object.assign(Object.assign({}, commonTextFieldProps), (_r = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.textField),
3185
+ } }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label,
3186
+ // @ts-ignore
3187
+ onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_s = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _s !== void 0 ? _s : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
3188
+ var _a;
3189
+ return (jsx(TextField, Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
3190
+ }, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
3191
+ ? (selected) => !Array.isArray(selected) || selected.length === 0 ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected.map((value) => {
3192
+ const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
3193
+ return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
3194
+ }) }))
3195
+ : undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
3196
+ ? Array.isArray(filterValue)
3197
+ ? filterValue
3198
+ : []
3199
+ : filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
3200
+ jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
3201
+ ...[
3202
+ (_t = textFieldProps.children) !== null && _t !== void 0 ? _t : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
3203
+ var _a;
3204
+ const { label, value } = getValueAndLabel(option);
3205
+ return (jsxs(MenuItem, { sx: {
3206
+ alignItems: 'center',
3207
+ display: 'flex',
3208
+ gap: '0.5rem',
3209
+ m: 0,
3210
+ }, value: value, children: [isMultiSelectFilter && (jsx(Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })), label, ' ', !columnDef.filterSelectOptions &&
3211
+ `(${facetedUniqueValues.get(value)})`] }, `${index}-${value}`));
3212
+ }),
3213
+ ],
3214
+ ] }))), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, setFilterValue: setFilterValue, table: table })] }));
3215
+ };
3216
+
3217
+ const MRT_FilterRangeFields = (_a) => {
3218
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
3219
+ return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ display: 'grid', gap: '1rem', gridTemplateColumns: '1fr 1fr' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: [0, 1].map((rangeFilterIndex) => (jsx(MRT_FilterTextField, { header: header, rangeFilterIndex: rangeFilterIndex, table: table }, rangeFilterIndex))) })));
3220
+ };
3221
+
3222
+ const MRT_FilterRangeSlider = (_a) => {
3223
+ var _b, _c;
3224
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
3225
+ const { options: { enableColumnFilterModes, localization, muiFilterSliderProps }, refs: { filterInputRefs }, } = table;
3226
+ const { column } = header;
3227
+ const { columnDef } = column;
3228
+ const currentFilterOption = columnDef._filterFn;
3229
+ const showChangeModeButton = enableColumnFilterModes && columnDef.enableColumnFilterModes !== false;
3230
+ const sliderProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiFilterSliderProps, { column, table })), parseFromValuesOrFunc(columnDef.muiFilterSliderProps, { column, table })), rest);
3231
+ let [min, max] = sliderProps.min !== undefined && sliderProps.max !== undefined
3232
+ ? [sliderProps.min, sliderProps.max]
3233
+ : ((_b = column.getFacetedMinMaxValues()) !== null && _b !== void 0 ? _b : [0, 1]);
3234
+ //fix potential TanStack Table bugs where min or max is an array
3235
+ if (Array.isArray(min))
3236
+ min = min[0];
3237
+ if (Array.isArray(max))
3238
+ max = max[0];
3239
+ if (min === null)
3240
+ min = 0;
3241
+ if (max === null)
3242
+ max = 1;
3243
+ const [filterValues, setFilterValues] = useState([min, max]);
3244
+ const columnFilterValue = column.getFilterValue();
3245
+ const isMounted = useRef(false);
3246
+ useEffect(() => {
3247
+ if (isMounted.current) {
3248
+ if (columnFilterValue === undefined) {
3249
+ setFilterValues([min, max]);
3250
+ }
3251
+ else if (Array.isArray(columnFilterValue)) {
3252
+ setFilterValues(columnFilterValue);
3253
+ }
3254
+ }
3255
+ isMounted.current = true;
3256
+ }, [columnFilterValue, min, max]);
3257
+ return (jsxs(Stack, { children: [jsx(Slider, Object.assign({ disableSwap: true, max: max, min: min, onChange: (_event, values) => {
3258
+ setFilterValues(values);
3259
+ }, onChangeCommitted: (_event, value) => {
3260
+ if (Array.isArray(value)) {
3261
+ if (value[0] <= min && value[1] >= max) {
3262
+ //if the user has selected the entire range, remove the filter
3263
+ column.setFilterValue(undefined);
3264
+ }
3265
+ else {
3266
+ column.setFilterValue(value);
3267
+ }
3268
+ }
3269
+ }, value: filterValues, valueLabelDisplay: "auto" }, sliderProps, { slotProps: {
3270
+ input: {
3271
+ ref: (node) => {
3272
+ var _a, _b;
3273
+ if (node) {
3274
+ filterInputRefs.current[`${column.id}-0`] = node;
3275
+ // @ts-ignore
3276
+ 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) {
3277
+ //@ts-ignore
3278
+ sliderProps.slotProps.input.ref = node;
3279
+ }
3280
+ }
3281
+ },
3282
+ },
3283
+ }, sx: (theme) => (Object.assign({ m: 'auto', minWidth: `${column.getSize() - 50}px`, 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: {
3284
+ fontSize: '0.75rem',
3285
+ lineHeight: '0.8rem',
3286
+ m: '-3px -6px',
3287
+ whiteSpace: 'nowrap',
3288
+ }, children: localization.filterMode.replace('{filterType}',
3289
+ // @ts-ignore
3290
+ localization[`filter${((_c = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
3291
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null] }));
3292
+ };
3293
+
3294
+ const MRT_TableHeadCellFilterContainer = (_a) => {
3295
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
3296
+ const { getState, options: { columnFilterDisplayMode }, } = table;
3297
+ const { showColumnFilters } = getState();
3298
+ const { column } = header;
3299
+ const { columnDef } = column;
3300
+ const { isRangeFilter } = getColumnFilterInfo({ header, table });
3301
+ return (jsx(Collapse, Object.assign({ in: showColumnFilters || columnFilterDisplayMode === 'popover', mountOnEnter: true, unmountOnExit: true }, rest, { children: columnDef.filterVariant === 'checkbox' ? (jsx(MRT_FilterCheckbox, { column: column, table: table })) : columnDef.filterVariant === 'range-slider' ? (jsx(MRT_FilterRangeSlider, { header: header, table: table })) : isRangeFilter ? (jsx(MRT_FilterRangeFields, { header: header, table: table })) : (jsx(MRT_FilterTextField, { header: header, table: table })) })));
3302
+ };
3303
+
3304
+ const MRT_TableHeadCellFilterLabel = (_a) => {
3305
+ var _b, _c;
3306
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
3307
+ const { options: { columnFilterDisplayMode, icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowColumnFilters, } = table;
3308
+ const { column } = header;
3309
+ const { columnDef } = column;
3310
+ const filterValue = column.getFilterValue();
3311
+ const [anchorEl, setAnchorEl] = useState(null);
3312
+ const { currentFilterOption, isMultiSelectFilter, isRangeFilter, isSelectFilter, } = getColumnFilterInfo({ header, table });
3313
+ const dropdownOptions = useDropdownOptions({ header, table });
3314
+ const getSelectLabel = (index) => getValueAndLabel(dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value ===
3315
+ (index !== undefined ? filterValue[index] : filterValue))).label;
3316
+ const isFilterActive = (Array.isArray(filterValue) && filterValue.some(Boolean)) ||
3317
+ (!!filterValue && !Array.isArray(filterValue));
3318
+ const filterTooltip = columnFilterDisplayMode === 'popover' && !isFilterActive
3319
+ ? (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', String(columnDef.header))
3320
+ : localization.filteringByColumn
3321
+ .replace('{column}', String(columnDef.header))
3322
+ .replace('{filterType}', currentFilterOption
3323
+ ? // @ts-ignore
3324
+ localization[`filter${((_c = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _c === void 0 ? void 0 : _c.toUpperCase()) +
3325
+ (currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]
3326
+ : '')
3327
+ .replace('{filterValue}', `"${Array.isArray(filterValue)
3328
+ ? filterValue
3329
+ .map((value, index) => isMultiSelectFilter ? getSelectLabel(index) : value)
3330
+ .join(`" ${isRangeFilter ? localization.and : localization.or} "`)
3331
+ : isSelectFilter
3332
+ ? getSelectLabel()
3333
+ : filterValue}"`)
3334
+ .replace('" "', '');
3335
+ return (jsxs(Fragment, { children: [jsx(Grow, { in: columnFilterDisplayMode === 'popover' ||
3336
+ (!!filterValue && !isRangeFilter) ||
3337
+ (isRangeFilter && // @ts-ignore
3338
+ (!!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[0]) || !!(filterValue === null || filterValue === void 0 ? void 0 : filterValue[1]))), unmountOnExit: true, children: jsx(Box, { component: "span", sx: { flex: '0 0' }, children: jsx(Tooltip, { placement: "top", title: filterTooltip, children: jsx(IconButton, Object.assign({ disableRipple: true, onClick: (event) => {
3339
+ if (columnFilterDisplayMode === 'popover') {
3340
+ setAnchorEl(event.currentTarget);
3341
+ }
3342
+ else {
3343
+ setShowColumnFilters(true);
3344
+ }
3345
+ queueMicrotask(() => {
3346
+ var _a, _b, _c, _d, _e, _f;
3347
+ (_c = (_b = (_a = filterInputRefs.current) === null || _a === void 0 ? void 0 : _a[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.focus) === null || _c === void 0 ? void 0 : _c.call(_b);
3348
+ (_f = (_e = (_d = filterInputRefs.current) === null || _d === void 0 ? void 0 : _d[`${column.id}-0`]) === null || _e === void 0 ? void 0 : _e.select) === null || _f === void 0 ? void 0 : _f.call(_e);
3349
+ });
3350
+ event.stopPropagation();
3351
+ }, size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '16px', ml: '4px', opacity: isFilterActive ? 1 : 0.3, p: '8px', transform: 'scale(0.75)', transition: 'all 150ms ease-in-out', width: '16px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(FilterAltIcon, {}) })) }) }) }), columnFilterDisplayMode === 'popover' && (jsx(Popover, { anchorEl: anchorEl, anchorOrigin: {
3352
+ horizontal: 'center',
3353
+ vertical: 'top',
3354
+ }, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: (event) => {
3355
+ //@ts-ignore
3356
+ event.stopPropagation();
3357
+ setAnchorEl(null);
3358
+ }, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, slotProps: { paper: { sx: { overflow: 'visible' } } }, transformOrigin: {
3359
+ horizontal: 'center',
3360
+ vertical: 'bottom',
3361
+ }, children: jsx(Box, { sx: { p: '1rem' }, children: jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }) }))] }));
3362
+ };
3363
+
3364
+ const MRT_TableHeadCellGrabHandle = (_a) => {
3365
+ var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
3366
+ const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
3367
+ const { columnDef } = column;
3368
+ const { columnOrder, draggingColumn, hoveredColumn } = getState();
3369
+ const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
3370
+ column,
3371
+ table,
3372
+ })), rest);
3373
+ const handleDragStart = (event) => {
3374
+ var _a;
3375
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
3376
+ setDraggingColumn(column);
3377
+ try {
3378
+ event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
3379
+ }
3380
+ catch (e) {
3381
+ console.error(e);
3382
+ }
3383
+ };
3384
+ const handleDragEnd = (event) => {
3385
+ var _a;
3386
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
3387
+ if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
3388
+ column.toggleGrouping();
3389
+ }
3390
+ else if (enableColumnOrdering &&
3391
+ hoveredColumn &&
3392
+ (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
3393
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
3394
+ }
3395
+ setDraggingColumn(null);
3396
+ setHoveredColumn(null);
3397
+ };
3398
+ return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
3399
+ };
3400
+
3401
+ const MRT_TableHeadCellResizeHandle = (_a) => {
3402
+ var _b;
3403
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
3404
+ const { getState, options: { columnResizeDirection, columnResizeMode }, setColumnSizingInfo, } = table;
3405
+ const { density } = getState();
3406
+ const { column } = header;
3407
+ const handler = header.getResizeHandler();
3408
+ const mx = density === 'compact'
3409
+ ? '-8px'
3410
+ : density === 'comfortable'
3411
+ ? '-16px'
3412
+ : '-24px';
3413
+ const lr = column.columnDef.columnDefType === 'display' ? '4px' : '0';
3414
+ return (jsx(Box, { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
3415
+ setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
3416
+ column.resetSize();
3417
+ }, onMouseDown: handler, onTouchStart: handler, style: {
3418
+ transform: column.getIsResizing() && columnResizeMode === 'onEnd'
3419
+ ? `translateX(${(columnResizeDirection === 'rtl' ? -1 : 1) *
3420
+ ((_b = getState().columnSizingInfo.deltaOffset) !== null && _b !== void 0 ? _b : 0)}px)`
3421
+ : undefined,
3422
+ }, sx: (theme) => ({
3423
+ '&:active > hr': {
3424
+ backgroundColor: theme.palette.info.main,
3425
+ opacity: header.subHeaders.length || columnResizeMode === 'onEnd' ? 1 : 0,
3426
+ },
3427
+ cursor: 'col-resize',
3428
+ left: columnResizeDirection === 'rtl' ? lr : undefined,
3429
+ ml: columnResizeDirection === 'rtl' ? mx : undefined,
3430
+ mr: columnResizeDirection === 'ltr' ? mx : undefined,
3431
+ position: 'absolute',
3432
+ px: '4px',
3433
+ right: columnResizeDirection === 'ltr' ? lr : undefined,
3434
+ }), children: jsx(Divider, { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: (theme) => (Object.assign({ borderRadius: '2px', borderWidth: '2px', height: '24px', touchAction: 'none', transform: 'translateX(4px)', transition: column.getIsResizing()
3435
+ ? undefined
3436
+ : 'all 150ms ease-in-out', userSelect: 'none', zIndex: 4 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) }) }));
3437
+ };
3438
+
3439
+ const MRT_TableHeadCellSortLabel = (_a) => {
3440
+ var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
3441
+ const { getState, options: { icons: { ArrowDownwardIcon, SyncAltIcon }, localization, }, } = table;
3442
+ const { column } = header;
3443
+ const { columnDef } = column;
3444
+ const { isLoading, showSkeletons, sorting } = getState();
3445
+ const isSorted = !!column.getIsSorted();
3446
+ const sortTooltip = isLoading || showSkeletons
3447
+ ? ''
3448
+ : column.getIsSorted()
3449
+ ? column.getIsSorted() === 'desc'
3450
+ ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
3451
+ : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
3452
+ : column.getNextSortingOrder() === 'desc'
3453
+ ? localization.sortByColumnDesc.replace('{column}', columnDef.header)
3454
+ : localization.sortByColumnAsc.replace('{column}', columnDef.header);
3455
+ const direction = isSorted
3456
+ ? column.getIsSorted()
3457
+ : undefined;
3458
+ return (jsx(Tooltip, { placement: "top", title: sortTooltip, children: jsx(Badge, { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular", children: jsx(TableSortLabel, Object.assign({ IconComponent: !isSorted
3459
+ ? (props) => (jsx(SyncAltIcon, Object.assign({}, props, { direction: direction, style: {
3460
+ transform: 'rotate(-90deg) scaleX(0.9) translateX(-1px)',
3461
+ } })))
3462
+ : ArrowDownwardIcon, active: true, "aria-label": sortTooltip, direction: direction, onClick: (e) => {
3463
+ var _a;
3464
+ e.stopPropagation();
3465
+ (_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
3466
+ } }, rest, { sx: (theme) => (Object.assign({ '.MuiTableSortLabel-icon': {
3467
+ color: `${theme.palette.mode === 'dark'
3468
+ ? theme.palette.text.primary
3469
+ : theme.palette.text.secondary} !important`,
3470
+ }, flex: '0 0', opacity: isSorted ? 1 : 0.3, transition: 'all 150ms ease-in-out', width: '3ch' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) })) }) }));
3471
+ };
3472
+
3473
+ const MRT_TableHeadCell = (_a) => {
3474
+ var _b, _c, _d, _f, _g, _h, _j;
3475
+ var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
3476
+ const theme = useTheme();
3477
+ const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableKeyboardShortcuts, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
3478
+ const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
3479
+ const { column } = header;
3480
+ const { columnDef } = column;
3481
+ const { columnDefType } = columnDef;
3482
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
3483
+ column,
3484
+ table,
3485
+ })), rest);
3486
+ const isColumnPinned = enableColumnPinning &&
3487
+ columnDef.columnDefType !== 'group' &&
3488
+ column.getIsPinned();
3489
+ const showColumnActions = (enableColumnActions || columnDef.enableColumnActions) &&
3490
+ columnDef.enableColumnActions !== false;
3491
+ const showDragHandle = enableColumnDragging !== false &&
3492
+ columnDef.enableColumnDragging !== false &&
3493
+ (enableColumnDragging ||
3494
+ (enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
3495
+ (enableGrouping &&
3496
+ columnDef.enableGrouping !== false &&
3497
+ !grouping.includes(column.id)));
3498
+ const headerPL = useMemo(() => {
3499
+ let pl = 0;
3500
+ if (column.getCanSort())
3501
+ pl += 1;
3502
+ if (showColumnActions)
3503
+ pl += 1.75;
3504
+ if (showDragHandle)
3505
+ pl += 1.5;
3506
+ return pl;
3507
+ }, [showColumnActions, showDragHandle]);
3508
+ const draggingBorders = useMemo(() => {
3509
+ const showResizeBorder = columnSizingInfo.isResizingColumn === column.id &&
3510
+ columnResizeMode === 'onChange' &&
3511
+ !header.subHeaders.length;
3512
+ const borderStyle = showResizeBorder
3513
+ ? `2px solid ${draggingBorderColor} !important`
3514
+ : (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
3515
+ ? `1px dashed ${theme.palette.grey[500]}`
3516
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
3517
+ ? `2px dashed ${draggingBorderColor}`
3518
+ : undefined;
3519
+ if (showResizeBorder) {
3520
+ return columnResizeDirection === 'ltr'
3521
+ ? { borderRight: borderStyle }
3522
+ : { borderLeft: borderStyle };
3523
+ }
3524
+ const draggingBorders = borderStyle
3525
+ ? {
3526
+ borderLeft: borderStyle,
3527
+ borderRight: borderStyle,
3528
+ borderTop: borderStyle,
3529
+ }
3530
+ : undefined;
3531
+ return draggingBorders;
3532
+ }, [draggingColumn, hoveredColumn, columnSizingInfo.isResizingColumn]);
3533
+ const handleDragEnter = (_e) => {
3534
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
3535
+ setHoveredColumn(null);
3536
+ }
3537
+ if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
3538
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
3539
+ }
3540
+ };
3541
+ const handleDragOver = (e) => {
3542
+ if (columnDef.enableColumnOrdering !== false) {
3543
+ e.preventDefault();
3544
+ }
3545
+ };
3546
+ const handleKeyDown = (event) => {
3547
+ var _a;
3548
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
3549
+ cellKeyboardShortcuts({
3550
+ event,
3551
+ cellValue: header.column.columnDef.header,
3552
+ table,
3553
+ header,
3554
+ });
3555
+ };
3556
+ const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
3557
+ column,
3558
+ header,
3559
+ table,
3560
+ })) !== null && _b !== void 0 ? _b : columnDef.header;
3561
+ return (jsxs(TableCell, Object.assign({ align: columnDefType === 'group'
3562
+ ? 'center'
3563
+ : theme.direction === 'rtl'
3564
+ ? 'right'
3565
+ : 'left', "aria-sort": column.getIsSorted()
3566
+ ? column.getIsSorted() === 'asc'
3567
+ ? 'ascending'
3568
+ : 'descending'
3569
+ : 'none', colSpan: header.colSpan, "data-can-sort": column.getCanSort() || undefined, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, "data-sort": column.getIsSorted() || undefined, onDragEnter: handleDragEnter, onDragOver: handleDragOver, ref: (node) => {
3570
+ var _a;
3571
+ if (node) {
3572
+ tableHeadCellRefs.current[column.id] = node;
3573
+ if (columnDefType !== 'group') {
3574
+ (_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
3575
+ }
3576
+ }
3577
+ }, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
3578
+ '.MuiButtonBase-root': {
3579
+ opacity: 1,
3580
+ },
3581
+ }, flexDirection: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
3582
+ ? '0.5rem'
3583
+ : density === 'comfortable'
3584
+ ? columnDefType === 'display'
3585
+ ? '0.75rem'
3586
+ : '1rem'
3587
+ : columnDefType === 'display'
3588
+ ? '1rem 1.25rem'
3589
+ : '1.5rem', pb: columnDefType === 'display'
3590
+ ? 0
3591
+ : showColumnFilters || density === 'compact'
3592
+ ? '0.4rem'
3593
+ : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
3594
+ ? '0.25rem'
3595
+ : density === 'comfortable'
3596
+ ? '.75rem'
3597
+ : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top' }, getCommonMRTCellStyles({
3598
+ column,
3599
+ header,
3600
+ table,
3601
+ tableCellProps,
3602
+ theme,
3603
+ })), draggingBorders)), children: [header.isPlaceholder
3604
+ ? null
3605
+ : ((_c = tableCellProps.children) !== null && _c !== void 0 ? _c : (jsxs(Box, { className: "Mui-TableHeadCell-Content", sx: {
3606
+ alignItems: 'center',
3607
+ display: 'flex',
3608
+ flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
3609
+ justifyContent: columnDefType === 'group' ||
3610
+ (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
3611
+ ? 'center'
3612
+ : column.getCanResize()
3613
+ ? 'space-between'
3614
+ : 'flex-start',
3615
+ position: 'relative',
3616
+ width: '100%',
3617
+ }, children: [jsxs(Box, { className: "Mui-TableHeadCell-Content-Labels", onClick: column.getToggleSortingHandler(), sx: {
3618
+ alignItems: 'center',
3619
+ cursor: column.getCanSort() && columnDefType !== 'group'
3620
+ ? 'pointer'
3621
+ : undefined,
3622
+ display: 'flex',
3623
+ flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
3624
+ overflow: columnDefType === 'data' ? 'hidden' : undefined,
3625
+ pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
3626
+ ? `${headerPL}rem`
3627
+ : undefined,
3628
+ }, children: [jsx(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
3629
+ '&:hover': {
3630
+ textOverflow: 'clip',
3631
+ },
3632
+ minWidth: `${Math.min((_f = (_d = columnDef.header) === null || _d === void 0 ? void 0 : _d.length) !== null && _f !== void 0 ? _f : 0, 4)}ch`,
3633
+ overflow: columnDefType === 'data' ? 'hidden' : undefined,
3634
+ textOverflow: 'ellipsis',
3635
+ whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
3636
+ ? 'nowrap'
3637
+ : 'normal',
3638
+ }, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
3639
+ whiteSpace: 'nowrap',
3640
+ }, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
3641
+ current: (_j = tableHeadCellRefs.current) === null || _j === void 0 ? void 0 : _j[column.id],
3642
+ } })), 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 }))] })));
3643
+ };
3644
+
3645
+ const MRT_TableHeadRow = (_a) => {
3646
+ var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
3647
+ const { options: { enableStickyHeader, layoutMode, mrtTheme: { baseBackgroundColor }, muiTableHeadRowProps, }, } = table;
3648
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
3649
+ const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
3650
+ headerGroup,
3651
+ table,
3652
+ })), rest);
3653
+ return (jsxs(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: baseBackgroundColor, boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: enableStickyHeader && layoutMode === 'semantic'
3654
+ ? 'sticky'
3655
+ : 'relative', 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, staticColumnIndex) => {
3656
+ let header = headerOrVirtualHeader;
3657
+ if (columnVirtualizer) {
3658
+ staticColumnIndex = headerOrVirtualHeader
3659
+ .index;
3660
+ header = headerGroup.headers[staticColumnIndex];
3661
+ }
3662
+ return header ? (jsx(MRT_TableHeadCell, { columnVirtualizer: columnVirtualizer, header: header, staticColumnIndex: staticColumnIndex, table: table }, header.id)) : null;
3663
+ }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3664
+ };
3665
+
3666
+ const MRT_ToolbarAlertBanner = (_a) => {
3667
+ var _b, _c, _d;
3668
+ var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
3669
+ const { getFilteredSelectedRowModel, getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
3670
+ const { density, grouping, rowSelection, showAlertBanner } = getState();
3671
+ const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
3672
+ table,
3673
+ })), rest);
3674
+ const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
3675
+ table,
3676
+ });
3677
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().flatRows.length;
3678
+ const selectedRowCount = useMemo(() => manualPagination
3679
+ ? Object.values(rowSelection).filter(Boolean).length
3680
+ : getFilteredSelectedRowModel().rows.length, [rowSelection, totalRowCount, manualPagination]);
3681
+ const selectedAlert = selectedRowCount > 0 ? (jsxs(Stack, { alignItems: "center", direction: "row", gap: "16px", children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.toString()), jsx(Button, { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
3682
+ const groupedAlert = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
3683
+ return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
3684
+ var _a, _b;
3685
+ return (Object.assign({ '& .MuiAlert-message': {
3686
+ maxWidth: `calc(${(_b = (_a = tablePaperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 360}px - 1rem)`,
3687
+ width: '100%',
3688
+ }, borderRadius: 0, fontSize: '1rem', left: 0, mb: stackAlertBanner
3689
+ ? 0
3690
+ : positionToolbarAlertBanner === 'bottom'
3691
+ ? '-1rem'
3692
+ : undefined, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, parseFromValuesOrFunc(alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx, theme)));
3693
+ }, children: (_d = renderToolbarAlertBannerContent === null || renderToolbarAlertBannerContent === void 0 ? void 0 : renderToolbarAlertBannerContent({
3694
+ groupedAlert,
3695
+ selectedAlert,
3696
+ table,
3697
+ })) !== null && _d !== void 0 ? _d : (jsxs(Fragment, { children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsx(AlertTitle, { children: alertProps.title }), jsxs(Stack, { sx: {
3698
+ p: positionToolbarAlertBanner !== 'head-overlay'
3699
+ ? '0.5rem 1rem'
3700
+ : density === 'spacious'
3701
+ ? '0.75rem 1.25rem'
3702
+ : density === 'comfortable'
3703
+ ? '0.5rem 0.75rem'
3704
+ : '0.25rem 0.5rem',
3705
+ }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectedAlert || groupedAlert) && (jsx("br", {})), jsxs(Box, { sx: { display: 'flex' }, children: [enableRowSelection &&
3706
+ enableSelectAll &&
3707
+ positionToolbarAlertBanner === 'head-overlay' && (jsx(MRT_SelectCheckbox, { table: table })), ' ', selectedAlert] }), selectedAlert && groupedAlert && jsx("br", {}), groupedAlert] })] })) })) }));
3708
+ };
3709
+
3710
+ const MRT_TableHead = (_a) => {
3711
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
3712
+ const { getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
3713
+ const { isFullScreen, showAlertBanner } = getState();
3714
+ const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
3715
+ const stickyHeader = enableStickyHeader || isFullScreen;
3716
+ return (jsx(TableHead, Object.assign({}, tableHeadProps, { ref: (ref) => {
3717
+ tableHeadRef.current = ref;
3718
+ if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
3719
+ // @ts-ignore
3720
+ tableHeadProps.ref.current = ref;
3721
+ }
3722
+ }, sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, parseFromValuesOrFunc(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx, theme))), children: positionToolbarAlertBanner === 'head-overlay' &&
3723
+ (showAlertBanner || table.getSelectedRowModel().rows.length > 0) ? (jsx("tr", { style: {
3724
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3725
+ }, children: jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
3726
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3727
+ padding: 0,
3728
+ }, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (table
3729
+ .getHeaderGroups()
3730
+ .map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
3731
+ };
3732
+
3733
+ const MRT_Table = (_a) => {
3734
+ var { table } = _a, rest = __rest(_a, ["table"]);
3735
+ const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, renderCaption, }, } = table;
3736
+ const { columnSizing, columnSizingInfo, columnVisibility, isFullScreen } = getState();
3737
+ const tableProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableProps, { table })), rest);
3738
+ const Caption = parseFromValuesOrFunc(renderCaption, { table });
3739
+ const columnSizeVars = useMemo(() => {
3740
+ const headers = getFlatHeaders();
3741
+ const colSizes = {};
3742
+ for (let i = 0; i < headers.length; i++) {
3743
+ const header = headers[i];
3744
+ const colSize = header.getSize();
3745
+ colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
3746
+ colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
3747
+ }
3748
+ return colSizes;
3749
+ }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
3750
+ const columnVirtualizer = useMRT_ColumnVirtualizer(table);
3751
+ const commonTableGroupProps = {
3752
+ columnVirtualizer,
3753
+ table,
3754
+ };
3755
+ return (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 === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [!!Caption && jsx("caption", { children: Caption }), enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
3756
+ };
3757
+
3758
+ const MRT_TableLoadingOverlay = (_a) => {
3759
+ var _b;
3760
+ var { table } = _a, rest = __rest(_a, ["table"]);
3761
+ const { options: { id, localization, mrtTheme: { baseBackgroundColor }, muiCircularProgressProps, }, } = table;
3762
+ const circularProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCircularProgressProps, { table })), rest);
3763
+ return (jsx(Box, { sx: {
3764
+ alignItems: 'center',
3765
+ backgroundColor: alpha(baseBackgroundColor, 0.5),
3766
+ bottom: 0,
3767
+ display: 'flex',
3768
+ justifyContent: 'center',
3769
+ left: 0,
3770
+ maxHeight: '100vh',
3771
+ position: 'absolute',
3772
+ right: 0,
3773
+ top: 0,
3774
+ width: '100%',
3775
+ zIndex: 3,
3776
+ }, children: (_b = circularProgressProps === null || circularProgressProps === void 0 ? void 0 : circularProgressProps.Component) !== null && _b !== void 0 ? _b : (jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: `mrt-progress-${id}` }, circularProgressProps))) }));
3777
+ };
3778
+
3779
+ const MRT_CellActionMenu = (_a) => {
3780
+ var _b, _c;
3781
+ var { table } = _a, rest = __rest(_a, ["table"]);
3782
+ const { getState, options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
3783
+ const { actionCell, density } = getState();
3784
+ const cell = actionCell;
3785
+ const { row } = cell;
3786
+ const { column } = cell;
3787
+ const { columnDef } = column;
3788
+ const handleClose = (event) => {
3789
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
3790
+ table.setActionCell(null);
3791
+ actionCellRef.current = null;
3792
+ };
3793
+ const internalMenuItems = [
3794
+ (parseFromValuesOrFunc(enableClickToCopy, cell) === 'context-menu' ||
3795
+ parseFromValuesOrFunc(columnDef.enableClickToCopy, cell) ===
3796
+ 'context-menu') && (jsx(MRT_ActionMenuItem, { icon: jsx(ContentCopy, {}), label: localization.copy, onClick: (event) => {
3797
+ event.stopPropagation();
3798
+ navigator.clipboard.writeText(cell.getValue());
3799
+ handleClose();
3800
+ }, table: table }, 'mrt-copy')),
3801
+ parseFromValuesOrFunc(enableEditing, row) && editDisplayMode === 'cell' && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: () => {
3802
+ openEditingCell({ cell, table });
3803
+ handleClose();
3804
+ }, table: table }, 'mrt-edit')),
3805
+ ].filter(Boolean);
3806
+ const renderActionProps = {
3807
+ cell,
3808
+ closeMenu: handleClose,
3809
+ column,
3810
+ internalMenuItems,
3811
+ row,
3812
+ table,
3813
+ };
3814
+ const menuItems = (_c = (_b = columnDef.renderCellActionMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, renderActionProps)) !== null && _c !== void 0 ? _c : renderCellActionMenuItems === null || renderCellActionMenuItems === void 0 ? void 0 : renderCellActionMenuItems(renderActionProps);
3815
+ return ((!!(menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) || !!(internalMenuItems === null || internalMenuItems === void 0 ? void 0 : internalMenuItems.length)) && (jsx(Menu, Object.assign({ MenuListProps: {
3816
+ dense: density === 'compact',
3817
+ sx: {
3818
+ backgroundColor: menuBackgroundColor,
3819
+ },
3820
+ }, anchorEl: actionCellRef.current, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: handleClose, open: !!cell, transformOrigin: { horizontal: -100, vertical: 8 } }, rest, { children: menuItems !== null && menuItems !== void 0 ? menuItems : internalMenuItems }))));
3821
+ };
3822
+
3823
+ const MRT_EditRowModal = (_a) => {
3824
+ var _b;
3825
+ var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
3826
+ const { getState, options: { localization, muiCreateRowModalProps, muiEditRowDialogProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowDialogContent, renderEditRowDialogContent, }, setCreatingRow, setEditingRow, } = table;
3827
+ const { creatingRow, editingRow } = getState();
3828
+ const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
3829
+ const dialogProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowDialogProps, { row, table })), (creatingRow &&
3830
+ parseFromValuesOrFunc(muiCreateRowModalProps, { row, table }))), rest);
3831
+ const internalEditComponents = row
3832
+ .getAllCells()
3833
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
3834
+ .map((cell) => (jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
3835
+ return (jsx(Dialog, Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
3836
+ var _a;
3837
+ if (creatingRow) {
3838
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
3839
+ setCreatingRow(null);
3840
+ }
3841
+ else {
3842
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
3843
+ setEditingRow(null);
3844
+ }
3845
+ row._valuesCache = {}; //reset values cache
3846
+ (_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
3847
+ }, open: open }, dialogProps, { children: (_b = ((creatingRow &&
3848
+ (renderCreateRowDialogContent === null || renderCreateRowDialogContent === void 0 ? void 0 : renderCreateRowDialogContent({
3849
+ internalEditComponents,
3850
+ row,
3851
+ table,
3852
+ }))) ||
3853
+ (renderEditRowDialogContent === null || renderEditRowDialogContent === void 0 ? void 0 : renderEditRowDialogContent({
3854
+ internalEditComponents,
3855
+ row,
3856
+ table,
3857
+ })))) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [jsx(DialogTitle, { sx: { textAlign: 'center' }, children: localization.edit }), jsx(DialogContent, { children: jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsx(Stack, { sx: {
3858
+ gap: '32px',
3859
+ paddingTop: '16px',
3860
+ width: '100%',
3861
+ }, children: internalEditComponents }) }) }), jsx(DialogActions, { sx: { p: '1.25rem' }, children: jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
3862
+ };
3863
+
3864
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3865
+ const MRT_TableContainer = (_a) => {
3866
+ var { table } = _a, rest = __rest(_a, ["table"]);
3867
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3868
+ const { actionCell, creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3869
+ const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
3870
+ const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3871
+ const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
3872
+ table,
3873
+ })), rest);
3874
+ useIsomorphicLayoutEffect(() => {
3875
+ var _a, _b, _c, _d;
3876
+ const topToolbarHeight = typeof document !== 'undefined'
3877
+ ? ((_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0)
3878
+ : 0;
3879
+ const bottomToolbarHeight = typeof document !== 'undefined'
3880
+ ? ((_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)
3881
+ : 0;
3882
+ setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
3883
+ });
3884
+ const createModalOpen = createDisplayMode === 'modal' && creatingRow;
3885
+ const editModalOpen = editDisplayMode === 'modal' && editingRow;
3886
+ return (jsxs(TableContainer, Object.assign({ "aria-busy": loading, "aria-describedby": loading ? 'mrt-progress' : undefined }, tableContainerProps, { ref: (node) => {
3887
+ if (node) {
3888
+ tableContainerRef.current = node;
3889
+ if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
3890
+ //@ts-ignore
3891
+ tableContainerProps.ref.current = node;
3892
+ }
3893
+ }
3894
+ }, style: Object.assign({ maxHeight: isFullScreen
3895
+ ? `calc(100vh - ${totalToolbarHeight}px)`
3896
+ : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
3897
+ ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3898
+ : undefined, maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table })), enableCellActions && actionCell && jsx(MRT_CellActionMenu, { table: table })] })));
3899
+ };
3900
+
3901
+ const MRT_LinearProgressBar = (_a) => {
3902
+ var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
3903
+ const { getState, options: { muiLinearProgressProps }, } = table;
3904
+ const { isSaving, showProgressBars } = getState();
3905
+ const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
3906
+ isTopToolbar,
3907
+ table,
3908
+ })), rest);
3909
+ return (jsx(Collapse, { in: showProgressBars !== false && (showProgressBars || isSaving), mountOnEnter: true, sx: {
3910
+ bottom: isTopToolbar ? 0 : undefined,
3911
+ position: 'absolute',
3912
+ top: !isTopToolbar ? 0 : undefined,
3913
+ width: '100%',
3914
+ }, unmountOnExit: true, children: jsx(LinearProgress, Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
3915
+ };
3916
+
3917
+ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
3918
+ const MRT_TablePagination = (_a) => {
3919
+ var { position = 'bottom', table } = _a, rest = __rest(_a, ["position", "table"]);
3920
+ const theme = useTheme();
3921
+ const isMobile = useMediaQuery('(max-width: 720px)');
3922
+ const { getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, id, localization, muiPaginationProps, paginationDisplayMode, }, } = table;
3923
+ const { pagination: { pageIndex = 0, pageSize = 10 }, } = getState();
3924
+ const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiPaginationProps, {
3925
+ table,
3926
+ })), rest);
3927
+ const totalRowCount = table.getRowCount();
3928
+ const numberOfPages = table.getPageCount();
3929
+ const showFirstLastPageButtons = numberOfPages > 2;
3930
+ const firstRowIndex = pageIndex * pageSize;
3931
+ const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3932
+ const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps = {}, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, restPaginationProps = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
3933
+ const disableBack = pageIndex <= 0 || disabled;
3934
+ const disableNext = lastRowIndex >= totalRowCount || disabled;
3935
+ if (isMobile && (SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.native) !== false) {
3936
+ SelectProps.native = true;
3937
+ }
3938
+ const tooltipProps = getCommonTooltipProps();
3939
+ return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
3940
+ alignItems: 'center',
3941
+ display: 'flex',
3942
+ flexWrap: 'wrap',
3943
+ gap: '8px',
3944
+ justifyContent: { md: 'space-between', sm: 'center' },
3945
+ justifySelf: 'flex-end',
3946
+ mt: position === 'top' && enableToolbarInternalActions
3947
+ ? '3rem'
3948
+ : undefined,
3949
+ position: 'relative',
3950
+ px: '8px',
3951
+ py: '12px',
3952
+ zIndex: 2,
3953
+ }, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: `mrt-rows-per-page-${id}`, sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ MenuProps: { disableScrollLock: true }, disableUnderline: true, disabled: disabled, inputProps: {
3954
+ 'aria-label': localization.rowsPerPage,
3955
+ id: `mrt-rows-per-page-${id}`,
3956
+ }, label: localization.rowsPerPage, onChange: (event) => table.setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
3957
+ var _a;
3958
+ const value = typeof option !== 'number' ? option.value : option;
3959
+ const label = typeof option !== 'number' ? option.label : `${option}`;
3960
+ return ((_a = SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.children) !== null && _a !== void 0 ? _a : ((SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.native) ? (jsx("option", { value: value, children: label }, value)) : (jsx(MenuItem, { sx: { m: 0 }, value: value, children: label }, value))));
3961
+ }) }))] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, Object.assign({ count: numberOfPages, disabled: disabled, onChange: (_e, newPageIndex) => table.setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsx(PaginationItem, Object.assign({ slots: {
3962
+ first: FirstPageIcon,
3963
+ last: LastPageIcon,
3964
+ next: ChevronRightIcon,
3965
+ previous: ChevronLeftIcon,
3966
+ } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, restPaginationProps))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => table.firstPage(), size: "small", children: jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => table.previousPage(), size: "small", children: jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => table.nextPage(), size: "small", children: jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), showLastButton && (jsx(Tooltip, Object.assign({}, tooltipProps, { title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => table.lastPage(), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })))] })] })) : null] }));
3967
+ };
3968
+
3969
+ const MRT_ToolbarDropZone = (_a) => {
3970
+ var _b, _c;
3971
+ var { table } = _a, rest = __rest(_a, ["table"]);
3972
+ const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
3973
+ const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = getState();
3974
+ const handleDragEnter = (_event) => {
3975
+ setHoveredColumn({ id: 'drop-zone' });
3976
+ };
3977
+ const handleDragOver = (e) => {
3978
+ e.preventDefault();
3979
+ };
3980
+ useEffect(() => {
3981
+ var _a;
3982
+ if (((_a = table.options.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
3983
+ setShowToolbarDropZone(!!enableGrouping &&
3984
+ !!draggingColumn &&
3985
+ draggingColumn.columnDef.enableGrouping !== false &&
3986
+ !grouping.includes(draggingColumn.id));
3987
+ }
3988
+ }, [enableGrouping, draggingColumn, grouping]);
3989
+ return (jsx(Fade, { in: showToolbarDropZone, children: jsx(Box, Object.assign({ className: "Mui-ToolbarDropZone", onDragEnter: handleDragEnter, onDragOver: handleDragOver }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', backdropFilter: 'blur(4px)', backgroundColor: alpha(theme.palette.info.main, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1), border: `dashed ${theme.palette.info.main} 2px`, boxSizing: 'border-box', display: 'flex', height: '100%', justifyContent: 'center', position: 'absolute', width: '100%', zIndex: 4 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(Typography, { fontStyle: "italic", children: localization.dropToGroupBy.replace('{column}', (_c = (_b = draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.columnDef) === null || _b === void 0 ? void 0 : _b.header) !== null && _c !== void 0 ? _c : '') }) })) }));
3990
+ };
3991
+
3992
+ const MRT_BottomToolbar = (_a) => {
3993
+ var { table } = _a, rest = __rest(_a, ["table"]);
3994
+ const { getState, options: { enablePagination, muiBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
3995
+ const { isFullScreen } = getState();
3996
+ const isMobile = useMediaQuery('(max-width:720px)');
3997
+ const toolbarProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiBottomToolbarProps, { table })), rest);
3998
+ const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
3999
+ return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (node) => {
4000
+ if (node) {
4001
+ bottomToolbarRef.current = node;
4002
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
4003
+ // @ts-ignore
4004
+ toolbarProps.ref.current = node;
4005
+ }
4006
+ }
4007
+ }, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, getCommonToolbarStyles({ table, theme })), { bottom: isFullScreen ? '0' : undefined, boxShadow: `0 1px 2px -1px ${alpha(theme.palette.grey[700], 0.5)} inset`, left: 0, position: isFullScreen ? 'fixed' : 'relative', right: 0 }), parseFromValuesOrFunc(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx, theme))), children: [jsx(MRT_LinearProgressBar, { isTopToolbar: false, table: table }), positionToolbarAlertBanner === 'bottom' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
4008
+ alignItems: 'center',
4009
+ boxSizing: 'border-box',
4010
+ display: 'flex',
4011
+ justifyContent: 'space-between',
4012
+ p: '0.5rem',
4013
+ width: '100%',
4014
+ }, children: [renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (jsx("span", {})), jsx(Box, { sx: {
4015
+ display: 'flex',
4016
+ justifyContent: 'flex-end',
4017
+ position: stackAlertBanner ? 'relative' : 'absolute',
4018
+ right: 0,
4019
+ top: 0,
4020
+ }, children: enablePagination &&
4021
+ ['both', 'bottom'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "bottom", table: table })) })] })] })));
4022
+ };
4023
+
4024
+ const MRT_ColumnPinningButtons = (_a) => {
4025
+ var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
4026
+ const { options: { icons: { PushPinIcon }, localization, }, } = table;
4027
+ const handlePinColumn = (pinDirection) => {
4028
+ column.pin(pinDirection);
4029
+ };
4030
+ return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ minWidth: '70px', textAlign: 'center' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: column.getIsPinned() ? (jsx(Tooltip, { title: localization.unpin, children: jsx(IconButton, { onClick: () => handlePinColumn(false), size: "small", children: jsx(PushPinIcon, {}) }) })) : (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.pinToLeft, children: jsx(IconButton, { onClick: () => handlePinColumn('left'), size: "small", children: jsx(PushPinIcon, { style: {
4031
+ transform: 'rotate(90deg)',
4032
+ } }) }) }), jsx(Tooltip, { title: localization.pinToRight, children: jsx(IconButton, { onClick: () => handlePinColumn('right'), size: "small", children: jsx(PushPinIcon, { style: {
4033
+ transform: 'rotate(-90deg)',
4034
+ } }) }) })] })) })));
4035
+ };
4036
+
4037
+ const MRT_ShowHideColumnsMenuItems = (_a) => {
4038
+ var _b;
4039
+ var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
4040
+ const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, } = table;
4041
+ const { columnOrder } = getState();
4042
+ const { columnDef } = column;
4043
+ const { columnDefType } = columnDef;
4044
+ const switchChecked = column.getIsVisible();
4045
+ const handleToggleColumnHidden = (column) => {
4046
+ var _a, _b;
4047
+ if (columnDefType === 'group') {
4048
+ (_b = (_a = column === null || column === void 0 ? void 0 : column.columns) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (childColumn) => {
4049
+ childColumn.toggleVisibility(!switchChecked);
4050
+ });
4051
+ }
4052
+ else {
4053
+ column.toggleVisibility();
4054
+ }
4055
+ };
4056
+ const menuItemRef = useRef(null);
4057
+ const [isDragging, setIsDragging] = useState(false);
4058
+ const handleDragStart = (e) => {
4059
+ setIsDragging(true);
4060
+ try {
4061
+ e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
4062
+ }
4063
+ catch (e) {
4064
+ console.error(e);
4065
+ }
4066
+ };
4067
+ const handleDragEnd = (_e) => {
4068
+ setIsDragging(false);
4069
+ setHoveredColumn(null);
4070
+ if (hoveredColumn) {
4071
+ setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
4072
+ }
4073
+ };
4074
+ const handleDragEnter = (_e) => {
4075
+ if (!isDragging && columnDef.enableColumnOrdering !== false) {
4076
+ setHoveredColumn(column);
4077
+ }
4078
+ };
4079
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
4080
+ return null;
4081
+ }
4082
+ return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging
4083
+ ? `2px dashed ${theme.palette.grey[500]}`
4084
+ : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
4085
+ ? `2px dashed ${draggingBorderColor}`
4086
+ : 'none', outlineOffset: '-2px', pl: `${(column.depth + 0.5) * 2}rem`, py: '6px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsxs(Box, { sx: {
4087
+ display: 'flex',
4088
+ flexWrap: 'nowrap',
4089
+ gap: '8px',
4090
+ }, children: [columnDefType !== 'group' &&
4091
+ enableColumnOrdering &&
4092
+ !isNestedColumns &&
4093
+ (columnDef.enableColumnOrdering !== false ? (jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsx(Box, { sx: { width: '28px' } }))), enableColumnPinning &&
4094
+ (column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { sx: { width: '70px' } }))), enableHiding ? (jsx(FormControlLabel, { checked: switchChecked, componentsProps: {
4095
+ typography: {
4096
+ sx: {
4097
+ mb: 0,
4098
+ opacity: columnDefType !== 'display' ? 1 : 0.5,
4099
+ },
4100
+ },
4101
+ }, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, {}) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
4102
+ };
4103
+
4104
+ const MRT_ShowHideColumnsMenu = (_a) => {
4105
+ var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
4106
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
4107
+ const { columnOrder, columnPinning, density } = getState();
4108
+ const handleToggleAllColumns = (value) => {
4109
+ getAllLeafColumns()
4110
+ .filter((col) => col.columnDef.enableHiding !== false)
4111
+ .forEach((col) => col.toggleVisibility(value));
4112
+ };
4113
+ const allColumns = useMemo(() => {
4114
+ const columns = getAllColumns();
4115
+ if (columnOrder.length > 0 &&
4116
+ !columns.some((col) => col.columnDef.columnDefType === 'group')) {
4117
+ return [
4118
+ ...getLeftLeafColumns(),
4119
+ ...Array.from(new Set(columnOrder)).map((colId) => getCenterLeafColumns().find((col) => (col === null || col === void 0 ? void 0 : col.id) === colId)),
4120
+ ...getRightLeafColumns(),
4121
+ ].filter(Boolean);
4122
+ }
4123
+ return columns;
4124
+ }, [
4125
+ columnOrder,
4126
+ columnPinning,
4127
+ getAllColumns(),
4128
+ getCenterLeafColumns(),
4129
+ getLeftLeafColumns(),
4130
+ getRightLeafColumns(),
4131
+ ]);
4132
+ const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === 'group');
4133
+ const [hoveredColumn, setHoveredColumn] = useState(null);
4134
+ return (jsxs(Menu, Object.assign({ MenuListProps: {
4135
+ dense: density === 'compact',
4136
+ sx: {
4137
+ backgroundColor: menuBackgroundColor,
4138
+ },
4139
+ }, anchorEl: anchorEl, disableScrollLock: true, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [jsxs(Box, { sx: {
4140
+ display: 'flex',
4141
+ justifyContent: 'space-between',
4142
+ p: '0.5rem',
4143
+ pt: 0,
4144
+ }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
4145
+ };
4146
+
4147
+ const MRT_ShowHideColumnsButton = (_a) => {
4148
+ var _b;
4149
+ var { table } = _a, rest = __rest(_a, ["table"]);
4150
+ const { options: { icons: { ViewColumnIcon }, localization, }, } = table;
4151
+ const [anchorEl, setAnchorEl] = useState(null);
4152
+ const handleClick = (event) => {
4153
+ setAnchorEl(event.currentTarget);
4154
+ };
4155
+ return (jsxs(Fragment, { children: [jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideColumns, children: jsx(IconButton, Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick }, rest, { title: undefined, children: jsx(ViewColumnIcon, {}) })) }), anchorEl && (jsx(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table }))] }));
4156
+ };
4157
+
4158
+ const MRT_ToggleDensePaddingButton = (_a) => {
4159
+ var _b;
4160
+ var { table } = _a, rest = __rest(_a, ["table"]);
4161
+ const { getState, options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, setDensity, } = table;
4162
+ const { density } = getState();
4163
+ const handleToggleDensePadding = () => {
4164
+ const nextDensity = density === 'comfortable'
4165
+ ? 'compact'
4166
+ : density === 'compact'
4167
+ ? 'spacious'
4168
+ : 'comfortable';
4169
+ setDensity(nextDensity);
4170
+ };
4171
+ return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleDensity, children: jsx(IconButton, Object.assign({ "aria-label": localization.toggleDensity, onClick: handleToggleDensePadding }, rest, { title: undefined, children: density === 'compact' ? (jsx(DensitySmallIcon, {})) : density === 'comfortable' ? (jsx(DensityMediumIcon, {})) : (jsx(DensityLargeIcon, {})) })) }));
4172
+ };
4173
+
4174
+ const MRT_ToggleFiltersButton = (_a) => {
4175
+ var _b;
4176
+ var { table } = _a, rest = __rest(_a, ["table"]);
4177
+ const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowColumnFilters, } = table;
4178
+ const { showColumnFilters } = getState();
4179
+ const handleToggleShowFilters = () => {
4180
+ setShowColumnFilters(!showColumnFilters);
4181
+ };
4182
+ return (jsx(Tooltip, { 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, {}) })) }));
4183
+ };
4184
+
4185
+ const MRT_ToggleFullScreenButton = (_a) => {
4186
+ var _b;
4187
+ var { table } = _a, rest = __rest(_a, ["table"]);
4188
+ const { getState, options: { icons: { FullscreenExitIcon, FullscreenIcon }, localization, }, setIsFullScreen, } = table;
4189
+ const { isFullScreen } = getState();
4190
+ const [tooltipOpened, setTooltipOpened] = useState(false);
4191
+ const handleToggleFullScreen = () => {
4192
+ setTooltipOpened(false);
4193
+ setIsFullScreen(!isFullScreen);
4194
+ };
4195
+ return (jsx(Tooltip, { 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.toggleFullScreen, onBlur: () => setTooltipOpened(false), onClick: handleToggleFullScreen, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsx(FullscreenExitIcon, {}) : jsx(FullscreenIcon, {}) })) }));
4196
+ };
4197
+
4198
+ const MRT_ToggleGlobalFilterButton = (_a) => {
4199
+ var _b, _c;
4200
+ var { table } = _a, rest = __rest(_a, ["table"]);
4201
+ const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
4202
+ const { globalFilter, showGlobalFilter } = getState();
4203
+ const handleToggleSearch = () => {
4204
+ setShowGlobalFilter(!showGlobalFilter);
4205
+ queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
4206
+ };
4207
+ return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }));
4208
+ };
4209
+
4210
+ const MRT_ToolbarInternalButtons = (_a) => {
4211
+ var _b;
4212
+ var { table } = _a, rest = __rest(_a, ["table"]);
4213
+ const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableHiding, initialState, renderToolbarInternalActions, }, } = table;
4214
+ return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', display: 'flex', zIndex: 3 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: (_b = renderToolbarInternalActions === null || renderToolbarInternalActions === void 0 ? void 0 : renderToolbarInternalActions({
4215
+ table,
4216
+ })) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [enableFilters &&
4217
+ enableGlobalFilter &&
4218
+ !(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
4219
+ enableColumnFilters &&
4220
+ 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 }))] })) })));
4221
+ };
4222
+
4223
+ const MRT_GlobalFilterTextField = (_a) => {
4224
+ var _b;
4225
+ var { table } = _a, rest = __rest(_a, ["table"]);
4226
+ const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
4227
+ const { globalFilter, showGlobalFilter } = getState();
4228
+ const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiSearchTextFieldProps, {
4229
+ table,
4230
+ })), rest);
4231
+ const isMounted = useRef(false);
4232
+ const [anchorEl, setAnchorEl] = useState(null);
4233
+ const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
4234
+ const handleChangeDebounced = useCallback(debounce((event) => {
4235
+ var _a;
4236
+ setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
4237
+ }, manualFiltering ? 500 : 250), []);
4238
+ const handleChange = (event) => {
4239
+ setSearchValue(event.target.value);
4240
+ handleChangeDebounced(event);
4241
+ };
4242
+ const handleGlobalFilterMenuOpen = (event) => {
4243
+ setAnchorEl(event.currentTarget);
4244
+ };
4245
+ const handleClear = () => {
4246
+ setSearchValue('');
4247
+ setGlobalFilter(undefined);
4248
+ };
4249
+ useEffect(() => {
4250
+ if (isMounted.current) {
4251
+ if (globalFilter === undefined) {
4252
+ handleClear();
4253
+ }
4254
+ else {
4255
+ setSearchValue(globalFilter);
4256
+ }
4257
+ }
4258
+ isMounted.current = true;
4259
+ }, [globalFilter]);
4260
+ return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ inputProps: Object.assign({ autoComplete: 'off' }, textFieldProps.inputProps), onChange: handleChange, placeholder: localization.search, size: "small", value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "outlined" }, textFieldProps, { InputProps: Object.assign(Object.assign({ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { title: (_b = localization.clearSearch) !== null && _b !== void 0 ? _b : '', 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, {}) }) }) }) })), startAdornment: enableGlobalFilterModes ? (jsx(InputAdornment, { position: "start", children: jsx(Tooltip, { 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' } })) }, textFieldProps.InputProps), { sx: (theme) => {
4261
+ var _a;
4262
+ return (Object.assign({ mb: 0 }, parseFromValuesOrFunc((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.sx, theme)));
4263
+ } }), inputRef: (inputRef) => {
4264
+ searchInputRef.current = inputRef;
4265
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
4266
+ textFieldProps.inputRef = inputRef;
4267
+ }
4268
+ } })), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, onSelect: handleClear, setAnchorEl: setAnchorEl, table: table })] }));
4269
+ };
4270
+
4271
+ const MRT_TopToolbar = ({ table, }) => {
4272
+ var _a;
4273
+ const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
4274
+ const { isFullScreen, showGlobalFilter } = getState();
4275
+ const isMobile = useMediaQuery('(max-width:720px)');
4276
+ const isTablet = useMediaQuery('(max-width:1024px)');
4277
+ const toolbarProps = parseFromValuesOrFunc(muiTopToolbarProps, { table });
4278
+ const stackAlertBanner = isMobile ||
4279
+ !!renderTopToolbarCustomActions ||
4280
+ (showGlobalFilter && isTablet);
4281
+ const globalFilterProps = {
4282
+ sx: !isTablet
4283
+ ? {
4284
+ zIndex: 2,
4285
+ }
4286
+ : undefined,
4287
+ table,
4288
+ };
4289
+ return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
4290
+ topToolbarRef.current = ref;
4291
+ if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
4292
+ // @ts-ignore
4293
+ toolbarProps.ref.current = ref;
4294
+ }
4295
+ }, sx: (theme) => (Object.assign(Object.assign(Object.assign({}, getCommonToolbarStyles({ table, theme })), { position: isFullScreen ? 'sticky' : 'relative', top: isFullScreen ? '0' : undefined }), parseFromValuesOrFunc(toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx, theme))), children: [positionToolbarAlertBanner === 'top' && (jsx(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), jsxs(Box, { sx: {
4296
+ alignItems: 'flex-start',
4297
+ boxSizing: 'border-box',
4298
+ display: 'flex',
4299
+ gap: '0.5rem',
4300
+ justifyContent: 'space-between',
4301
+ p: '0.5rem',
4302
+ position: stackAlertBanner ? 'relative' : 'absolute',
4303
+ right: 0,
4304
+ top: 0,
4305
+ width: '100%',
4306
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsx("span", {}), enableToolbarInternalActions ? (jsxs(Box, { sx: {
4307
+ alignItems: 'center',
4308
+ display: 'flex',
4309
+ flexWrap: 'wrap-reverse',
4310
+ gap: '0.5rem',
4311
+ justifyContent: 'flex-end',
4312
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
4313
+ positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), enablePagination &&
4314
+ ['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
4315
+ };
4316
+
4317
+ const MRT_TablePaper = (_a) => {
4318
+ var _b, _c;
4319
+ var { table } = _a, rest = __rest(_a, ["table"]);
4320
+ const { getState, options: { enableBottomToolbar, enableTopToolbar, mrtTheme: { baseBackgroundColor }, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
4321
+ const { isFullScreen } = getState();
4322
+ const paperProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTablePaperProps, { table })), rest);
4323
+ const theme = useTheme();
4324
+ return (jsxs(Paper, Object.assign({ elevation: 2, onKeyDown: (e) => e.key === 'Escape' && table.setIsFullScreen(false) }, paperProps, { ref: (ref) => {
4325
+ tablePaperRef.current = ref;
4326
+ if (paperProps === null || paperProps === void 0 ? void 0 : paperProps.ref) {
4327
+ //@ts-ignore
4328
+ paperProps.ref.current = ref;
4329
+ }
4330
+ }, style: Object.assign(Object.assign({}, (isFullScreen
4331
+ ? {
4332
+ bottom: 0,
4333
+ height: '100dvh',
4334
+ left: 0,
4335
+ margin: 0,
4336
+ maxHeight: '100dvh',
4337
+ maxWidth: '100dvw',
4338
+ padding: 0,
4339
+ position: 'fixed',
4340
+ right: 0,
4341
+ top: 0,
4342
+ width: '100dvw',
4343
+ zIndex: theme.zIndex.modal,
4344
+ }
4345
+ : {})), paperProps === null || paperProps === void 0 ? void 0 : paperProps.style), sx: (theme) => (Object.assign({ backgroundColor: baseBackgroundColor, backgroundImage: 'unset', overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(paperProps === null || paperProps === void 0 ? void 0 : paperProps.sx, theme))), children: [enableTopToolbar &&
4346
+ ((_b = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _b !== void 0 ? _b : (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
4347
+ ((_c = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _c !== void 0 ? _c : (jsx(MRT_BottomToolbar, { table: table })))] })));
4348
+ };
4349
+
4350
+ const isTableInstanceProp = (props) => props.table !== undefined;
4351
+ const MaterialReactTable = (props) => {
4352
+ let table;
4353
+ if (isTableInstanceProp(props)) {
4354
+ table = props.table;
4355
+ }
4356
+ else {
4357
+ table = useMaterialReactTable(props);
4358
+ }
4359
+ return jsx(MRT_TablePaper, { table: table });
4360
+ };
4361
+
4362
+ export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, cellKeyboardShortcuts, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
4363
+ //# sourceMappingURL=index.esm.js.map