material-react-table 2.6.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/index.d.ts +390 -260
  2. package/dist/index.esm.js +1977 -1921
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +2372 -2318
  5. package/dist/index.js.map +1 -1
  6. package/package.json +20 -20
  7. package/src/{MaterialReactTable.tsx → components/MaterialReactTable.tsx} +3 -3
  8. package/src/{body → components/body}/MRT_TableBody.tsx +6 -28
  9. package/src/{body → components/body}/MRT_TableBodyCell.tsx +6 -23
  10. package/src/{body → components/body}/MRT_TableBodyCellValue.tsx +2 -2
  11. package/src/{body → components/body}/MRT_TableBodyRow.tsx +7 -5
  12. package/src/{body → components/body}/MRT_TableBodyRowGrabHandle.tsx +3 -3
  13. package/src/{body → components/body}/MRT_TableBodyRowPinButton.tsx +3 -3
  14. package/src/{body → components/body}/MRT_TableDetailPanel.tsx +6 -6
  15. package/src/{buttons → components/buttons}/MRT_ColumnPinningButtons.tsx +2 -2
  16. package/src/{buttons → components/buttons}/MRT_CopyButton.tsx +4 -5
  17. package/src/{buttons → components/buttons}/MRT_EditActionButtons.tsx +2 -2
  18. package/src/{buttons → components/buttons}/MRT_ExpandAllButton.tsx +4 -4
  19. package/src/{buttons → components/buttons}/MRT_ExpandButton.tsx +10 -4
  20. package/src/{buttons → components/buttons}/MRT_GrabHandleButton.tsx +4 -5
  21. package/src/{buttons → components/buttons}/MRT_RowPinButton.tsx +4 -4
  22. package/src/{buttons → components/buttons}/MRT_ShowHideColumnsButton.tsx +1 -1
  23. package/src/{buttons → components/buttons}/MRT_ToggleDensePaddingButton.tsx +1 -1
  24. package/src/{buttons → components/buttons}/MRT_ToggleFiltersButton.tsx +1 -1
  25. package/src/{buttons → components/buttons}/MRT_ToggleFullScreenButton.tsx +1 -1
  26. package/src/{buttons → components/buttons}/MRT_ToggleGlobalFilterButton.tsx +1 -1
  27. package/src/{buttons → components/buttons}/MRT_ToggleRowActionMenuButton.tsx +9 -9
  28. package/src/{footer → components/footer}/MRT_TableFooter.tsx +2 -2
  29. package/src/{footer → components/footer}/MRT_TableFooterCell.tsx +3 -3
  30. package/src/{footer → components/footer}/MRT_TableFooterRow.tsx +3 -3
  31. package/src/{head → components/head}/MRT_TableHead.tsx +3 -3
  32. package/src/{head → components/head}/MRT_TableHeadCell.tsx +3 -3
  33. package/src/{head → components/head}/MRT_TableHeadCellColumnActionsButton.tsx +5 -6
  34. package/src/{head → components/head}/MRT_TableHeadCellFilterContainer.tsx +5 -5
  35. package/src/{head → components/head}/MRT_TableHeadCellFilterLabel.tsx +2 -2
  36. package/src/{head → components/head}/MRT_TableHeadCellGrabHandle.tsx +4 -3
  37. package/src/{head → components/head}/MRT_TableHeadCellResizeHandle.tsx +2 -2
  38. package/src/{head → components/head}/MRT_TableHeadCellSortLabel.tsx +2 -2
  39. package/src/{head → components/head}/MRT_TableHeadRow.tsx +3 -3
  40. package/src/{inputs → components/inputs}/MRT_EditCellTextField.tsx +12 -4
  41. package/src/{inputs → components/inputs}/MRT_FilterCheckbox.tsx +4 -4
  42. package/src/{inputs → components/inputs}/MRT_FilterRangeFields.tsx +2 -2
  43. package/src/{inputs → components/inputs}/MRT_FilterRangeSlider.tsx +2 -2
  44. package/src/{inputs → components/inputs}/MRT_FilterTextField.tsx +3 -3
  45. package/src/{inputs → components/inputs}/MRT_GlobalFilterTextField.tsx +2 -2
  46. package/src/{inputs → components/inputs}/MRT_SelectCheckbox.tsx +4 -4
  47. package/src/{menus → components/menus}/MRT_ColumnActionMenu.tsx +9 -1
  48. package/src/{menus → components/menus}/MRT_FilterOptionMenu.tsx +9 -1
  49. package/src/{menus → components/menus}/MRT_RowActionMenu.tsx +13 -2
  50. package/src/{menus → components/menus}/MRT_ShowHideColumnsMenu.tsx +11 -5
  51. package/src/{menus → components/menus}/MRT_ShowHideColumnsMenuItems.tsx +7 -7
  52. package/src/{modals → components/modals}/MRT_EditRowModal.tsx +4 -4
  53. package/src/{table → components/table}/MRT_Table.tsx +4 -4
  54. package/src/{table → components/table}/MRT_TableContainer.tsx +3 -3
  55. package/src/{table → components/table}/MRT_TableLoadingOverlay.tsx +3 -3
  56. package/src/{table → components/table}/MRT_TablePaper.tsx +3 -3
  57. package/src/{toolbar → components/toolbar}/MRT_BottomToolbar.tsx +3 -3
  58. package/src/{toolbar → components/toolbar}/MRT_LinearProgressBar.tsx +2 -2
  59. package/src/{toolbar → components/toolbar}/MRT_TablePagination.tsx +9 -7
  60. package/src/{toolbar → components/toolbar}/MRT_ToolbarAlertBanner.tsx +3 -3
  61. package/src/{toolbar → components/toolbar}/MRT_ToolbarDropZone.tsx +2 -2
  62. package/src/{toolbar → components/toolbar}/MRT_ToolbarInternalButtons.tsx +2 -2
  63. package/src/{toolbar → components/toolbar}/MRT_TopToolbar.tsx +3 -3
  64. package/src/{filterFns.ts → fns/filterFns.ts} +1 -1
  65. package/src/{sortingFns.ts → fns/sortingFns.ts} +1 -1
  66. package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +26 -0
  67. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +34 -0
  68. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +35 -0
  69. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +96 -0
  70. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +36 -0
  71. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +30 -0
  72. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +40 -0
  73. package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +40 -0
  74. package/src/hooks/useMRT_ColumnVirtualizer.ts +2 -4
  75. package/src/hooks/useMRT_Effects.ts +7 -6
  76. package/src/hooks/useMRT_RowVirtualizer.ts +2 -4
  77. package/src/hooks/useMRT_Rows.ts +32 -6
  78. package/src/hooks/useMRT_TableInstance.ts +91 -87
  79. package/src/hooks/useMRT_TableOptions.ts +5 -3
  80. package/src/{useMaterialReactTable.ts → hooks/useMaterialReactTable.ts} +3 -3
  81. package/src/icons.ts +4 -38
  82. package/src/index.ts +88 -17
  83. package/src/types.ts +59 -26
  84. package/src/utils/column.utils.ts +173 -0
  85. package/src/utils/displayColumn.utils.ts +134 -0
  86. package/src/utils/row.utils.ts +26 -0
  87. package/src/{style.utils.ts → utils/style.utils.ts} +50 -28
  88. package/src/utils/tanstack.helpers.ts +64 -0
  89. package/src/utils/utils.ts +23 -0
  90. package/src/utils/virtualization.utils.ts +19 -0
  91. package/src/utils.ts +0 -0
  92. package/src/body/index.ts +0 -7
  93. package/src/buttons/index.ts +0 -13
  94. package/src/column.utils.ts +0 -368
  95. package/src/footer/index.ts +0 -3
  96. package/src/head/index.ts +0 -9
  97. package/src/hooks/index.ts +0 -7
  98. package/src/hooks/useMRT_DisplayColumns.tsx +0 -299
  99. package/src/inputs/index.ts +0 -7
  100. package/src/menus/index.ts +0 -5
  101. package/src/modals/index.ts +0 -1
  102. package/src/table/index.ts +0 -5
  103. package/src/toolbar/index.ts +0 -7
  104. /package/src/{aggregationFns.ts → fns/aggregationFns.ts} +0 -0
package/dist/index.esm.js CHANGED
@@ -1,31 +1,19 @@
1
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
- import Paper from '@mui/material/Paper';
3
- import { useState, memo, useEffect, useMemo, useRef, useCallback, useReducer, Fragment as Fragment$1, useLayoutEffect } from 'react';
4
- import TableContainer from '@mui/material/TableContainer';
5
- import Table from '@mui/material/Table';
6
- import TableBody from '@mui/material/TableBody';
7
- import Typography from '@mui/material/Typography';
8
- import TableRow from '@mui/material/TableRow';
9
- import { lighten, darken, alpha, useTheme } from '@mui/material/styles';
10
- import Skeleton from '@mui/material/Skeleton';
11
- import TableCell from '@mui/material/TableCell';
1
+ import { flexRender as flexRender$1, createRow as createRow$1, aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
2
+ import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
3
+ import { useMemo, useState, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
4
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
+ import IconButton from '@mui/material/IconButton';
6
+ import Tooltip from '@mui/material/Tooltip';
12
7
  import Box from '@mui/material/Box';
13
- import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, aggregationFns, filterFns } from '@tanstack/react-table';
14
- import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
15
- import highlightWords from 'highlight-words';
16
8
  import Button from '@mui/material/Button';
17
- import Tooltip from '@mui/material/Tooltip';
18
- import MenuItem from '@mui/material/MenuItem';
19
- import TextField from '@mui/material/TextField';
20
- import Collapse from '@mui/material/Collapse';
21
- import Stack from '@mui/material/Stack';
22
- import IconButton from '@mui/material/IconButton';
23
9
  import CircularProgress from '@mui/material/CircularProgress';
10
+ import { lighten, darken, alpha, useTheme } from '@mui/material/styles';
24
11
  import ListItemIcon from '@mui/material/ListItemIcon';
25
12
  import Menu from '@mui/material/Menu';
13
+ import MenuItem from '@mui/material/MenuItem';
14
+ import Stack from '@mui/material/Stack';
26
15
  import Checkbox from '@mui/material/Checkbox';
27
16
  import Radio from '@mui/material/Radio';
28
- import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
29
17
  import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
30
18
  import ArrowRightIcon from '@mui/icons-material/ArrowRight';
31
19
  import CancelIcon from '@mui/icons-material/Cancel';
@@ -59,6 +47,18 @@ import SortIcon from '@mui/icons-material/Sort';
59
47
  import SyncAltIcon from '@mui/icons-material/SyncAlt';
60
48
  import ViewColumnIcon from '@mui/icons-material/ViewColumn';
61
49
  import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
50
+ import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
51
+ import Paper from '@mui/material/Paper';
52
+ import TableContainer from '@mui/material/TableContainer';
53
+ import Table from '@mui/material/Table';
54
+ import TableBody from '@mui/material/TableBody';
55
+ import Typography from '@mui/material/Typography';
56
+ import TableRow from '@mui/material/TableRow';
57
+ import Skeleton from '@mui/material/Skeleton';
58
+ import TableCell from '@mui/material/TableCell';
59
+ import highlightWords from 'highlight-words';
60
+ import TextField from '@mui/material/TextField';
61
+ import Collapse from '@mui/material/Collapse';
62
62
  import TableFooter from '@mui/material/TableFooter';
63
63
  import TableHead from '@mui/material/TableHead';
64
64
  import FormControlLabel from '@mui/material/FormControlLabel';
@@ -76,52 +76,20 @@ import Popover from '@mui/material/Popover';
76
76
  import Divider from '@mui/material/Divider';
77
77
  import Badge from '@mui/material/Badge';
78
78
  import TableSortLabel from '@mui/material/TableSortLabel';
79
+ import Alert from '@mui/material/Alert';
80
+ import AlertTitle from '@mui/material/AlertTitle';
81
+ import Dialog from '@mui/material/Dialog';
82
+ import DialogActions from '@mui/material/DialogActions';
83
+ import DialogContent from '@mui/material/DialogContent';
84
+ import DialogTitle from '@mui/material/DialogTitle';
79
85
  import useMediaQuery from '@mui/material/useMediaQuery';
80
86
  import LinearProgress from '@mui/material/LinearProgress';
81
87
  import InputLabel from '@mui/material/InputLabel';
82
88
  import Pagination from '@mui/material/Pagination';
83
89
  import PaginationItem from '@mui/material/PaginationItem';
84
90
  import Select from '@mui/material/Select';
85
- import Alert from '@mui/material/Alert';
86
- import AlertTitle from '@mui/material/AlertTitle';
87
91
  import Fade from '@mui/material/Fade';
88
92
  import Switch from '@mui/material/Switch';
89
- import Dialog from '@mui/material/Dialog';
90
- import DialogActions from '@mui/material/DialogActions';
91
- import DialogContent from '@mui/material/DialogContent';
92
- import DialogTitle from '@mui/material/DialogTitle';
93
-
94
- /******************************************************************************
95
- Copyright (c) Microsoft Corporation.
96
-
97
- Permission to use, copy, modify, and/or distribute this software for any
98
- purpose with or without fee is hereby granted.
99
-
100
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
101
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
102
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
103
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
104
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
105
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
106
- PERFORMANCE OF THIS SOFTWARE.
107
- ***************************************************************************** */
108
-
109
- function __rest(s, e) {
110
- var t = {};
111
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
112
- t[p] = s[p];
113
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
114
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
115
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
116
- t[p[i]] = s[p[i]];
117
- }
118
- return t;
119
- }
120
-
121
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
122
- var e = new Error(message);
123
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
124
- };
125
93
 
126
94
  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; };
127
95
  const getAllLeafColumnDefs = (columns) => {
@@ -139,53 +107,49 @@ const getAllLeafColumnDefs = (columns) => {
139
107
  getLeafColumns(columns);
140
108
  return allLeafColumnDefs;
141
109
  };
142
- const prepareColumns = ({ aggregationFns, columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
143
- var _a, _b;
144
- //assign columnId
145
- if (!columnDef.id)
146
- columnDef.id = getColumnId(columnDef);
147
- if (process.env.NODE_ENV !== 'production' && !columnDef.id) {
148
- console.error('Column definitions must have a valid `accessorKey` or `id` property');
149
- }
150
- //assign columnDefType
151
- if (!columnDef.columnDefType)
152
- columnDef.columnDefType = 'data';
153
- if ((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length) {
154
- columnDef.columnDefType = 'group';
155
- //recursively prepare columns if this is a group column
156
- columnDef.columns = prepareColumns({
157
- aggregationFns,
158
- columnDefs: columnDef.columns,
159
- columnFilterFns,
160
- defaultDisplayColumn,
161
- filterFns,
162
- sortingFns,
163
- });
164
- }
165
- else if (columnDef.columnDefType === 'data') {
166
- //assign aggregationFns if multiple aggregationFns are provided
167
- if (Array.isArray(columnDef.aggregationFn)) {
168
- const aggFns = columnDef.aggregationFn;
169
- 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); });
170
- }
171
- //assign filterFns
172
- if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
173
- columnDef.filterFn =
174
- (_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
175
- columnDef._filterFn =
176
- columnFilterFns[columnDef.id];
177
- }
178
- //assign sortingFns
179
- if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
180
- // @ts-ignore
181
- columnDef.sortingFn = sortingFns[columnDef.sortingFn];
110
+ const prepareColumns = ({ columnDefs, tableOptions, }) => {
111
+ const { aggregationFns = {}, defaultDisplayColumn, filterFns = {}, sortingFns = {}, state: { columnFilterFns = {} } = {}, } = tableOptions;
112
+ return columnDefs.map((columnDef) => {
113
+ var _a, _b;
114
+ //assign columnId
115
+ if (!columnDef.id)
116
+ columnDef.id = getColumnId(columnDef);
117
+ //assign columnDefType
118
+ if (!columnDef.columnDefType)
119
+ columnDef.columnDefType = 'data';
120
+ if ((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length) {
121
+ columnDef.columnDefType = 'group';
122
+ //recursively prepare columns if this is a group column
123
+ columnDef.columns = prepareColumns({
124
+ columnDefs: columnDef.columns,
125
+ tableOptions,
126
+ });
182
127
  }
183
- }
184
- else if (columnDef.columnDefType === 'display') {
185
- columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
186
- }
187
- return columnDef;
188
- });
128
+ else if (columnDef.columnDefType === 'data') {
129
+ //assign aggregationFns if multiple aggregationFns are provided
130
+ if (Array.isArray(columnDef.aggregationFn)) {
131
+ const aggFns = columnDef.aggregationFn;
132
+ 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); });
133
+ }
134
+ //assign filterFns
135
+ if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
136
+ columnDef.filterFn =
137
+ (_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
138
+ columnDef._filterFn =
139
+ columnFilterFns[columnDef.id];
140
+ }
141
+ //assign sortingFns
142
+ if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
143
+ // @ts-ignore
144
+ columnDef.sortingFn = sortingFns[columnDef.sortingFn];
145
+ }
146
+ }
147
+ else if (columnDef.columnDefType === 'display') {
148
+ columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
149
+ }
150
+ return columnDef;
151
+ });
152
+ };
189
153
  const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
190
154
  if (draggedColumn.getCanPin()) {
191
155
  draggedColumn.pin(targetColumn.getIsPinned());
@@ -194,51 +158,6 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
194
158
  newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
195
159
  return newColumnOrder;
196
160
  };
197
- const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
198
- (props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
199
- props.renderDetailPanel);
200
- const getLeadingDisplayColumnIds = (props) => {
201
- var _a, _b;
202
- return [
203
- props.enableRowPinning &&
204
- !((_a = props.rowPinningDisplayMode) === null || _a === void 0 ? void 0 : _a.startsWith('select')) &&
205
- 'mrt-row-pin',
206
- (props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
207
- props.positionActionsColumn === 'first' &&
208
- (props.enableRowActions ||
209
- (props.enableEditing &&
210
- ['modal', 'row'].includes((_b = props.editDisplayMode) !== null && _b !== void 0 ? _b : ''))) &&
211
- 'mrt-row-actions',
212
- props.positionExpandColumn === 'first' &&
213
- showExpandColumn(props) &&
214
- 'mrt-row-expand',
215
- props.enableRowSelection && 'mrt-row-select',
216
- props.enableRowNumbers && 'mrt-row-numbers',
217
- ].filter(Boolean);
218
- };
219
- const getTrailingDisplayColumnIds = (props) => {
220
- var _a;
221
- return [
222
- props.positionActionsColumn === 'last' &&
223
- (props.enableRowActions ||
224
- (props.enableEditing &&
225
- ['modal', 'row'].includes((_a = props.editDisplayMode) !== null && _a !== void 0 ? _a : ''))) &&
226
- 'mrt-row-actions',
227
- props.positionExpandColumn === 'last' &&
228
- showExpandColumn(props) &&
229
- 'mrt-row-expand',
230
- props.layoutMode === 'grid-no-grow' && 'mrt-row-spacer',
231
- ].filter(Boolean);
232
- };
233
- const getDefaultColumnOrderIds = (props) => {
234
- const leadingDisplayCols = getLeadingDisplayColumnIds(props);
235
- const trailingDisplayCols = getTrailingDisplayColumnIds(props);
236
- const allLeafColumnDefs = getAllLeafColumnDefs(props.columns)
237
- .map((columnDef) => getColumnId(columnDef))
238
- .filter((columnId) => !leadingDisplayCols.includes(columnId) &&
239
- !trailingDisplayCols.includes(columnId));
240
- return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
241
- };
242
161
  const getDefaultColumnFilterFn = (columnDef) => {
243
162
  var _a;
244
163
  if (columnDef.filterVariant === 'multi-select')
@@ -276,37 +195,8 @@ const getTotalRight = (table, column) => {
276
195
  .slice(column.getPinnedIndex() + 1)
277
196
  .reduce((acc, col) => acc + col.getSize(), 0);
278
197
  };
279
- const getCanRankRows = (table) => {
280
- const { getState, options } = table;
281
- const { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, } = options;
282
- const { expanded, globalFilterFn } = getState();
283
- return (!manualExpanding &&
284
- !manualFiltering &&
285
- !manualGrouping &&
286
- !manualSorting &&
287
- enableGlobalFilterRankedResults &&
288
- globalFilterFn === 'fuzzy' &&
289
- expanded !== true &&
290
- !Object.values(expanded).some(Boolean));
291
- };
292
- const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
198
+
293
199
  const flexRender = flexRender$1;
294
- const createRow = (table, originalRow) => createRow$1(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
295
- [getColumnId(col)]: '',
296
- }))), -1, 0);
297
- const extraIndexRangeExtractor = (range, draggingIndex) => {
298
- const newIndexes = defaultRangeExtractor(range);
299
- if (draggingIndex === undefined)
300
- return newIndexes;
301
- if (draggingIndex >= 0 &&
302
- draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
303
- newIndexes.unshift(draggingIndex);
304
- }
305
- if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
306
- newIndexes.push(draggingIndex);
307
- }
308
- return newIndexes;
309
- };
310
200
  function createMRTColumnHelper() {
311
201
  return {
312
202
  accessor: (accessor, column) => {
@@ -318,807 +208,346 @@ function createMRTColumnHelper() {
318
208
  group: (column) => column,
319
209
  };
320
210
  }
321
- const getValueAndLabel = (option) => {
322
- var _a, _b, _c;
323
- let label = '';
324
- let value = '';
325
- if (option) {
326
- if (typeof option !== 'object') {
327
- label = option;
328
- value = option;
329
- }
330
- else {
331
- label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
332
- value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
333
- }
334
- }
335
- return { label, value };
211
+ 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) => ({
212
+ [getColumnId(col)]: '',
213
+ }))), rowIndex, depth, subRows, parentId);
214
+
215
+ function defaultDisplayColumnProps({ header, id, size = 60, tableOptions, }) {
216
+ const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
217
+ 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 });
218
+ }
219
+ const showRowPinningColumn = (tableOptions) => {
220
+ const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
221
+ return enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select'));
222
+ };
223
+ const showRowDragColumn = (tableOptions) => {
224
+ const { enableRowDragging, enableRowOrdering } = tableOptions;
225
+ return enableRowDragging || enableRowOrdering;
226
+ };
227
+ const showRowExpandColumn = (tableOptions) => {
228
+ const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
229
+ return !!(enableExpanding ||
230
+ (enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
231
+ renderDetailPanel);
232
+ };
233
+ const showRowActionsColumn = (tableOptions) => {
234
+ const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
235
+ return (enableRowActions ||
236
+ (creatingRow && createDisplayMode === 'row') ||
237
+ (enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
238
+ };
239
+ const showRowSelectionColumn = (tableOptions) => tableOptions.enableRowSelection;
240
+ const showRowNumbersColumn = (tableOptions) => tableOptions.enableRowNumbers;
241
+ const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
242
+ const getLeadingDisplayColumnIds = (tableOptions) => [
243
+ showRowPinningColumn(tableOptions) && 'mrt-row-pin',
244
+ showRowDragColumn(tableOptions) && 'mrt-row-drag',
245
+ tableOptions.positionActionsColumn === 'first' &&
246
+ showRowActionsColumn(tableOptions) &&
247
+ 'mrt-row-actions',
248
+ tableOptions.positionExpandColumn === 'first' &&
249
+ showRowExpandColumn(tableOptions) &&
250
+ 'mrt-row-expand',
251
+ showRowSelectionColumn(tableOptions) && 'mrt-row-select',
252
+ showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
253
+ ].filter(Boolean);
254
+ const getTrailingDisplayColumnIds = (tableOptions) => [
255
+ tableOptions.positionActionsColumn === 'last' &&
256
+ showRowActionsColumn(tableOptions) &&
257
+ 'mrt-row-actions',
258
+ tableOptions.positionExpandColumn === 'last' &&
259
+ showRowExpandColumn(tableOptions) &&
260
+ 'mrt-row-expand',
261
+ showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
262
+ ].filter(Boolean);
263
+ const getDefaultColumnOrderIds = (tableOptions) => {
264
+ const leadingDisplayCols = getLeadingDisplayColumnIds(tableOptions);
265
+ const trailingDisplayCols = getTrailingDisplayColumnIds(tableOptions);
266
+ const allLeafColumnDefs = getAllLeafColumnDefs(tableOptions.columns)
267
+ .map((columnDef) => getColumnId(columnDef))
268
+ .filter((columnId) => !leadingDisplayCols.includes(columnId) &&
269
+ !trailingDisplayCols.includes(columnId));
270
+ return [...leadingDisplayCols, ...allLeafColumnDefs, ...trailingDisplayCols];
336
271
  };
337
272
 
338
- const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
339
- const getMRTTheme = (table, theme) => (Object.assign({ baseBackgroundColor: theme.palette.mode === 'dark'
340
- ? lighten(theme.palette.background.default, 0.05)
341
- : theme.palette.background.default, draggingBorderColor: theme.palette.primary.main, matchHighlightColor: theme.palette.mode === 'dark'
342
- ? darken(theme.palette.warning.dark, 0.25)
343
- : lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, parseFromValuesOrFunc(table.options.mrtTheme, theme)));
344
- const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
345
- var _a, _b, _c, _d, _e, _f, _g, _h;
346
- const { options: { layoutMode }, } = table;
347
- const widthStyles = {
348
- 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 = column.columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
349
- 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${header ? ` + ${(_e = (_d = header === null || header === void 0 ? void 0 : header.subHeaders) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0}rem` : ''})`,
350
- };
351
- if (layoutMode === 'grid') {
352
- widthStyles.flex = `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_f = header === null || header === void 0 ? void 0 : header.id) !== null && _f !== void 0 ? _f : column.id)}-size) 0 auto`;
353
- }
354
- else if (layoutMode === 'grid-no-grow') {
355
- widthStyles.flex = '0 0 auto';
356
- }
357
- return Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
358
- ? alpha(darken(getMRTTheme(table, theme).baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97)
359
- : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
360
- ? `-4px 0 8px -6px ${alpha(theme.palette.grey[700], 0.5)} inset`
361
- : getIsFirstRightPinnedColumn(column)
362
- ? `4px 0 8px -6px ${alpha(theme.palette.grey[700], 0.5)} inset`
363
- : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
364
- ? `${column.getStart('left')}px`
365
- : undefined, opacity: ((_g = table.getState().draggingColumn) === null || _g === void 0 ? void 0 : _g.id) === column.id ||
366
- ((_h = table.getState().hoveredColumn) === null || _h === void 0 ? void 0 : _h.id) === column.id
367
- ? 0.5
368
- : 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
369
- ? 'sticky'
370
- : undefined, right: column.getIsPinned() === 'right'
371
- ? `${getTotalRight(table, column)}px`
372
- : undefined, transition: table.options.enableColumnVirtualization
373
- ? 'none'
374
- : `padding 150ms ease-in-out` }, widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
273
+ const getCanRankRows = (table) => {
274
+ const { getState, options } = table;
275
+ const { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, } = options;
276
+ const { expanded, globalFilterFn } = getState();
277
+ return (!manualExpanding &&
278
+ !manualFiltering &&
279
+ !manualGrouping &&
280
+ !manualSorting &&
281
+ enableGlobalFilterRankedResults &&
282
+ globalFilterFn === 'fuzzy' &&
283
+ expanded !== true &&
284
+ !Object.values(expanded).some(Boolean));
375
285
  };
376
- const getCommonToolbarStyles = ({ table, theme, }) => ({
377
- alignItems: 'flex-start',
378
- backgroundColor: getMRTTheme(table, theme).baseBackgroundColor,
379
- display: 'grid',
380
- flexWrap: 'wrap-reverse',
381
- minHeight: '3.5rem',
382
- overflow: 'hidden',
383
- position: 'relative',
384
- transition: 'all 150ms ease-in-out',
385
- zIndex: 1,
386
- });
387
- const flipIconStyles = (theme) => theme.direction === 'rtl'
388
- ? { style: { transform: 'scaleX(-1)' } }
389
- : undefined;
390
286
 
391
- const allowedTypes = ['string', 'number'];
392
- const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
393
- var _a, _b, _c;
394
- const { getState, options: { enableFilterMatchHighlighting }, } = table;
395
- const { column, row } = cell;
396
- const { columnDef } = column;
397
- const { globalFilter, globalFilterFn } = getState();
398
- const filterValue = column.getFilterValue();
399
- let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
400
- ? columnDef.AggregatedCell({
401
- cell,
402
- column,
403
- row,
404
- table,
405
- })
406
- : row.getIsGrouped() && !cell.getIsGrouped()
407
- ? null
408
- : cell.getIsGrouped() && columnDef.GroupedCell
409
- ? columnDef.GroupedCell({
410
- cell,
411
- column,
412
- row,
413
- table,
414
- })
415
- : undefined;
416
- const isGroupedValue = renderedCellValue !== undefined;
417
- if (!isGroupedValue) {
418
- renderedCellValue = cell.renderValue();
419
- }
420
- if (enableFilterMatchHighlighting &&
421
- columnDef.enableFilterMatchHighlighting !== false &&
422
- String(renderedCellValue) &&
423
- allowedTypes.includes(typeof renderedCellValue) &&
424
- ((filterValue &&
425
- allowedTypes.includes(typeof filterValue) &&
426
- ['autocomplete', 'text'].includes(columnDef.filterVariant)) ||
427
- (globalFilter &&
428
- allowedTypes.includes(typeof globalFilter) &&
429
- column.getCanGlobalFilter()))) {
430
- const chunks = highlightWords === null || highlightWords === void 0 ? void 0 : highlightWords({
431
- matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
432
- query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
433
- text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
434
- });
435
- 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)) {
436
- 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
437
- ? {
438
- backgroundColor: (theme) => getMRTTheme(table, theme).matchHighlightColor,
439
- borderRadius: '2px',
440
- color: (theme) => theme.palette.mode === 'dark'
441
- ? theme.palette.common.white
442
- : theme.palette.common.black,
443
- padding: '2px 1px',
444
- }
445
- : undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
446
- }
447
- }
448
- if (columnDef.Cell && !isGroupedValue) {
449
- renderedCellValue = columnDef.Cell({
450
- cell,
451
- column,
452
- renderedCellValue,
453
- row,
454
- rowRef,
455
- staticRowIndex,
456
- table,
457
- });
287
+ const MRT_AggregationFns = Object.assign({}, aggregationFns);
288
+
289
+ const fuzzy$1 = (row, columnId, filterValue, addMeta) => {
290
+ const itemRank = rankItem(row.getValue(columnId), filterValue, {
291
+ threshold: rankings.MATCHES,
292
+ });
293
+ addMeta(itemRank);
294
+ return itemRank.passed;
295
+ };
296
+ fuzzy$1.autoRemove = (val) => !val;
297
+ const contains = (row, id, filterValue) => row
298
+ .getValue(id)
299
+ .toString()
300
+ .toLowerCase()
301
+ .trim()
302
+ .includes(filterValue.toString().toLowerCase().trim());
303
+ contains.autoRemove = (val) => !val;
304
+ const startsWith = (row, id, filterValue) => row
305
+ .getValue(id)
306
+ .toString()
307
+ .toLowerCase()
308
+ .trim()
309
+ .startsWith(filterValue.toString().toLowerCase().trim());
310
+ startsWith.autoRemove = (val) => !val;
311
+ const endsWith = (row, id, filterValue) => row
312
+ .getValue(id)
313
+ .toString()
314
+ .toLowerCase()
315
+ .trim()
316
+ .endsWith(filterValue.toString().toLowerCase().trim());
317
+ endsWith.autoRemove = (val) => !val;
318
+ const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
319
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
320
+ equals.autoRemove = (val) => !val;
321
+ const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
322
+ filterValue.toString().toLowerCase().trim();
323
+ notEquals.autoRemove = (val) => !val;
324
+ const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
325
+ ? +row.getValue(id) > +filterValue
326
+ : row.getValue(id).toString().toLowerCase().trim() >
327
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
328
+ greaterThan.autoRemove = (val) => !val;
329
+ const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
330
+ greaterThanOrEqualTo.autoRemove = (val) => !val;
331
+ const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
332
+ ? +row.getValue(id) < +filterValue
333
+ : row.getValue(id).toString().toLowerCase().trim() <
334
+ (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
335
+ lessThan.autoRemove = (val) => !val;
336
+ const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
337
+ lessThanOrEqualTo.autoRemove = (val) => !val;
338
+ const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
339
+ greaterThan(row, id, filterValues[0])) &&
340
+ ((!isNaN(+filterValues[0]) &&
341
+ !isNaN(+filterValues[1]) &&
342
+ +filterValues[0] > +filterValues[1]) ||
343
+ ['', undefined].includes(filterValues[1]) ||
344
+ lessThan(row, id, filterValues[1]));
345
+ between.autoRemove = (val) => !val;
346
+ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
347
+ greaterThanOrEqualTo(row, id, filterValues[0])) &&
348
+ ((!isNaN(+filterValues[0]) &&
349
+ !isNaN(+filterValues[1]) &&
350
+ +filterValues[0] > +filterValues[1]) ||
351
+ ['', undefined].includes(filterValues[1]) ||
352
+ lessThanOrEqualTo(row, id, filterValues[1]));
353
+ betweenInclusive.autoRemove = (val) => !val;
354
+ const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
355
+ empty.autoRemove = (val) => !val;
356
+ const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
357
+ notEmpty.autoRemove = (val) => !val;
358
+ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
359
+ betweenInclusive,
360
+ contains,
361
+ empty,
362
+ endsWith,
363
+ equals,
364
+ fuzzy: fuzzy$1,
365
+ greaterThan,
366
+ greaterThanOrEqualTo,
367
+ lessThan,
368
+ lessThanOrEqualTo,
369
+ notEmpty,
370
+ notEquals,
371
+ startsWith });
372
+
373
+ const fuzzy = (rowA, rowB, columnId) => {
374
+ let dir = 0;
375
+ if (rowA.columnFiltersMeta[columnId]) {
376
+ dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
458
377
  }
459
- return renderedCellValue;
378
+ // Provide a fallback for when the item ranks are equal
379
+ return dir === 0
380
+ ? sortingFns.alphanumeric(rowA, rowB, columnId)
381
+ : dir;
460
382
  };
383
+ const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy });
384
+ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
385
+ Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
461
386
 
462
- const MRT_CopyButton = (_a) => {
463
- var _b;
464
- var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
465
- const { options: { localization, muiCopyButtonProps }, } = table;
466
- const { column, row } = cell;
467
- const { columnDef } = column;
468
- const [copied, setCopied] = useState(false);
469
- const handleCopy = (event, text) => {
470
- event.stopPropagation();
471
- navigator.clipboard.writeText(text);
472
- setCopied(true);
473
- setTimeout(() => setCopied(false), 4000);
474
- };
475
- const buttonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCopyButtonProps, {
476
- cell,
477
- column,
478
- row,
479
- table,
480
- })), parseFromValuesOrFunc(columnDef.muiCopyButtonProps, {
481
- cell,
482
- column,
483
- row,
484
- table,
485
- })), rest);
486
- return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "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', textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) }));
387
+ /******************************************************************************
388
+ Copyright (c) Microsoft Corporation.
389
+
390
+ Permission to use, copy, modify, and/or distribute this software for any
391
+ purpose with or without fee is hereby granted.
392
+
393
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
394
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
395
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
396
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
397
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
398
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
399
+ PERFORMANCE OF THIS SOFTWARE.
400
+ ***************************************************************************** */
401
+
402
+ function __rest(s, e) {
403
+ var t = {};
404
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
405
+ t[p] = s[p];
406
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
407
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
408
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
409
+ t[p[i]] = s[p[i]];
410
+ }
411
+ return t;
412
+ }
413
+
414
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
415
+ var e = new Error(message);
416
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
487
417
  };
488
418
 
489
- const MRT_EditCellTextField = (_a) => {
490
- var _b, _c, _d;
491
- var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
492
- const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
493
- const { column, row } = cell;
494
- const { columnDef } = column;
495
- const { creatingRow, editingRow } = getState();
419
+ const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
420
+ const getValueAndLabel = (option) => {
421
+ var _a, _b, _c;
422
+ let label = '';
423
+ let value = '';
424
+ if (option) {
425
+ if (typeof option !== 'object') {
426
+ label = option;
427
+ value = option;
428
+ }
429
+ else {
430
+ label = (_b = (_a = option.label) !== null && _a !== void 0 ? _a : option.text) !== null && _b !== void 0 ? _b : option.value;
431
+ value = (_c = option.value) !== null && _c !== void 0 ? _c : label;
432
+ }
433
+ }
434
+ return { label, value };
435
+ };
436
+
437
+ const MRT_EditActionButtons = (_a) => {
438
+ var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
439
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
440
+ const { creatingRow, editingRow, isSaving } = getState();
496
441
  const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
497
442
  const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
498
- const isSelectEdit = columnDef.editVariant === 'select';
499
- const [value, setValue] = useState(() => cell.getValue());
500
- const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
501
- cell,
502
- column,
503
- row,
504
- table,
505
- })), parseFromValuesOrFunc(columnDef.muiEditTextFieldProps, {
506
- cell,
507
- column,
508
- row,
509
- table,
510
- })), rest);
511
- const saveInputValueToRowCache = (newValue) => {
512
- //@ts-ignore
513
- row._valuesCache[column.id] = newValue;
443
+ const handleCancel = () => {
514
444
  if (isCreating) {
515
- setCreatingRow(row);
445
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
446
+ setCreatingRow(null);
516
447
  }
517
448
  else if (isEditing) {
518
- setEditingRow(row);
449
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
450
+ setEditingRow(null);
519
451
  }
452
+ row._valuesCache = {}; //reset values cache
520
453
  };
521
- const handleChange = (event) => {
454
+ const handleSubmitRow = () => {
522
455
  var _a;
523
- (_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
524
- setValue(event.target.value);
525
- if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) {
526
- saveInputValueToRowCache(event.target.value);
456
+ //look for auto-filled input values
457
+ (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)
458
+ .filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
459
+ if (input.value !== undefined &&
460
+ Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
461
+ // @ts-ignore
462
+ row._valuesCache[input.name] = input.value;
463
+ }
464
+ });
465
+ if (isCreating)
466
+ onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
467
+ exitCreatingMode: () => setCreatingRow(null),
468
+ row,
469
+ table,
470
+ values: row._valuesCache,
471
+ });
472
+ else if (isEditing) {
473
+ onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
474
+ exitEditingMode: () => setEditingRow(null),
475
+ row,
476
+ table,
477
+ values: row === null || row === void 0 ? void 0 : row._valuesCache,
478
+ });
527
479
  }
528
480
  };
529
- const handleBlur = (event) => {
530
- var _a;
531
- (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
532
- saveInputValueToRowCache(value);
533
- setEditingCell(null);
534
- };
535
- const handleEnterKeyDown = (event) => {
536
- var _a, _b;
537
- (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
538
- if (event.key === 'Enter' && !event.shiftKey) {
539
- (_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
540
- }
541
- };
542
- if (columnDef.Edit) {
543
- return jsx(Fragment, { children: (_b = columnDef.Edit) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table }) });
544
- }
545
- return (jsx(TextField, Object.assign({ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false, fullWidth: true, inputRef: (inputRef) => {
546
- if (inputRef) {
547
- editInputRefs.current[column.id] = inputRef;
548
- if (textFieldProps.inputRef) {
549
- textFieldProps.inputRef = inputRef;
550
- }
551
- }
552
- }, label: ['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
553
- ? columnDef.header
554
- : undefined, margin: "none", name: column.id, placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
555
- ? columnDef.header
556
- : undefined, select: isSelectEdit, size: "small", value: value, variant: "standard" }, textFieldProps, { InputProps: Object.assign(Object.assign(Object.assign({}, (textFieldProps.variant !== 'outlined'
557
- ? { disableUnderline: editDisplayMode === 'table' }
558
- : {})), textFieldProps.InputProps), { sx: (theme) => {
559
- var _a;
560
- 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)));
561
- } }), inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
562
- var _a;
563
- e.stopPropagation();
564
- (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
565
- }, onKeyDown: handleEnterKeyDown, children: (_c = textFieldProps.children) !== null && _c !== void 0 ? _c : (_d = columnDef === null || columnDef === void 0 ? void 0 : columnDef.editSelectOptions) === null || _d === void 0 ? void 0 : _d.map((option) => {
566
- const { label, value } = getValueAndLabel(option);
567
- return (jsx(MenuItem, { sx: {
568
- alignItems: 'center',
569
- display: 'flex',
570
- gap: '0.5rem',
571
- m: 0,
572
- }, value: value, children: label }, value));
573
- }) })));
481
+ 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) ||
482
+ (isEditing && onEditingRowSave)) && (jsx(Tooltip, { title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsx(CircularProgress, { size: 18 }) : jsx(SaveIcon, {}) }) }))] })) : (jsxs(Fragment, { children: [jsx(Button, { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxs(Button, { onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
574
483
  };
575
484
 
576
- const MRT_TableBodyCell = (_a) => {
577
- var _b, _c, _d, _e, _f;
578
- var { cell, measureElement, numRows, rowRef, staticRowIndex, table, virtualColumnIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowRef", "staticRowIndex", "table", "virtualColumnIndex"]);
579
- const theme = useTheme();
580
- const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, positionExpandColumn, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
581
- const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
582
- const { column, row } = cell;
485
+ const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
486
+ const getMRTTheme = (table, theme) => {
487
+ var _a;
488
+ const themeOverrides = parseFromValuesOrFunc(table.options.mrtTheme, theme);
489
+ const baseBackgroundColor = (_a = themeOverrides === null || themeOverrides === void 0 ? void 0 : themeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (theme.palette.mode === 'dark'
490
+ ? lighten(theme.palette.background.default, 0.05)
491
+ : theme.palette.background.default);
492
+ return Object.assign({ baseBackgroundColor, draggingBorderColor: theme.palette.primary.main, matchHighlightColor: theme.palette.mode === 'dark'
493
+ ? darken(theme.palette.warning.dark, 0.25)
494
+ : lighten(theme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, themeOverrides);
495
+ };
496
+ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
497
+ var _a, _b, _c, _d, _e, _f, _g, _h;
498
+ const { options: { layoutMode }, } = table;
583
499
  const { columnDef } = column;
584
- const { columnDefType } = columnDef;
585
- const args = { cell, column, row, table };
586
- const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, args)), rest);
587
- const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
588
- cell,
589
- column,
590
- row,
591
- table,
592
- });
593
- const { draggingBorderColor } = getMRTTheme(table, theme);
594
- const [skeletonWidth, setSkeletonWidth] = useState(100);
595
- useEffect(() => {
596
- if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
597
- return;
598
- const size = column.getSize();
599
- setSkeletonWidth(columnDefType === 'display'
600
- ? size / 2
601
- : Math.round(Math.random() * (size - size / 3) + size / 3));
602
- }, [isLoading, showSkeletons]);
603
- const draggingBorders = useMemo(() => {
604
- const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
605
- const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
606
- const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
607
- const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
608
- const isFirstColumn = getIsFirstColumn(column, table);
609
- const isLastColumn = getIsLastColumn(column, table);
610
- const isLastRow = numRows && staticRowIndex === numRows - 1;
611
- const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
612
- const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
613
- const borderStyle = showResizeBorder
614
- ? `2px solid ${draggingBorderColor} !important`
615
- : isDraggingColumn || isDraggingRow
616
- ? `1px dashed ${theme.palette.grey[500]} !important`
617
- : isHoveredColumn || isHoveredRow || isResizingColumn
618
- ? `2px dashed ${draggingBorderColor} !important`
619
- : undefined;
620
- if (showResizeBorder) {
621
- return columnResizeDirection === 'ltr'
622
- ? { borderRight: borderStyle }
623
- : { borderLeft: borderStyle };
624
- }
625
- return borderStyle
626
- ? {
627
- borderBottom: isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn)
628
- ? borderStyle
629
- : undefined,
630
- borderLeft: isDraggingColumn ||
631
- isHoveredColumn ||
632
- ((isDraggingRow || isHoveredRow) && isFirstColumn)
633
- ? borderStyle
634
- : undefined,
635
- borderRight: isDraggingColumn ||
636
- isHoveredColumn ||
637
- ((isDraggingRow || isHoveredRow) && isLastColumn)
638
- ? borderStyle
639
- : undefined,
640
- borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
641
- }
642
- : undefined;
643
- }, [
644
- columnSizingInfo.isResizingColumn,
645
- draggingColumn,
646
- draggingRow,
647
- hoveredColumn,
648
- hoveredRow,
649
- staticRowIndex,
650
- ]);
651
- const isEditable = !cell.getIsPlaceholder() &&
652
- parseFromValuesOrFunc(enableEditing, row) &&
653
- parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
654
- const isEditing = isEditable &&
655
- !['custom', 'modal'].includes(editDisplayMode) &&
656
- (editDisplayMode === 'table' ||
657
- (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
658
- (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
659
- !row.getIsGrouped();
660
- const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
661
- const handleDoubleClick = (event) => {
662
- var _a;
663
- (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
664
- if (isEditable && editDisplayMode === 'cell') {
665
- setEditingCell(cell);
666
- queueMicrotask(() => {
667
- var _a;
668
- const textField = editInputRefs.current[column.id];
669
- if (textField) {
670
- textField.focus();
671
- (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
672
- }
673
- });
674
- }
675
- };
676
- const handleDragEnter = (e) => {
677
- var _a;
678
- (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
679
- if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
680
- setHoveredColumn(null);
681
- }
682
- if (enableColumnOrdering && draggingColumn) {
683
- setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
684
- }
685
- };
686
- const cellValueProps = {
687
- cell,
688
- table,
500
+ const widthStyles = {
501
+ 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)`,
502
+ 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${header && layoutMode === 'grid-no-grow' ? ` + ${(_e = (_d = header === null || header === void 0 ? void 0 : header.subHeaders) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0}rem` : ''})`,
689
503
  };
690
- return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": virtualColumnIndex, ref: (node) => {
691
- if (node) {
692
- measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
693
- }
694
- } }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
695
- outline: (editDisplayMode === 'cell' && isEditable) ||
696
- (editDisplayMode === 'table' && (isCreating || isEditing))
697
- ? `1px solid ${theme.palette.grey[500]}`
698
- : undefined,
699
- outlineOffset: '-1px',
700
- textOverflow: 'clip',
701
- }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', justifyContent: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
702
- ? tableCellProps.align
703
- : undefined, overflow: 'hidden', p: density === 'compact'
704
- ? columnDefType === 'display'
705
- ? '0 0.5rem'
706
- : '0.5rem'
707
- : density === 'comfortable'
708
- ? columnDefType === 'display'
709
- ? '0.5rem 0.75rem'
710
- : '1rem'
711
- : columnDefType === 'display'
712
- ? '1rem 1.25rem'
713
- : '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, [theme.direction === 'rtl' || positionExpandColumn === 'last'
714
- ? 'pr'
715
- : 'pl']: column.id === 'mrt-row-expand'
716
- ? `${row.depth +
717
- (density === 'compact'
718
- ? 0.5
719
- : density === 'comfortable'
720
- ? 0.75
721
- : 1.25)}rem`
722
- : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0 }, getCommonMRTCellStyles({
723
- column,
724
- table,
725
- tableCellProps,
726
- theme,
727
- })), 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' &&
728
- (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
729
- !row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
730
- cell,
731
- column,
732
- renderedCellValue: cell.renderValue(),
733
- row,
734
- rowRef,
735
- staticRowIndex,
736
- table,
737
- })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
738
- 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, ")"] }))] })) })));
739
- };
740
- const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
741
-
742
- const MRT_TableDetailPanel = (_a) => {
743
- var { parentRowRef, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["parentRowRef", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
744
- const { getState, getVisibleLeafColumns, options: { enableRowVirtualization, layoutMode, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel, }, } = table;
745
- const { isLoading } = getState();
746
- const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
747
- isDetailPanel: true,
748
- row,
749
- staticRowIndex,
750
- table,
751
- });
752
- const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiDetailPanelProps, {
753
- row,
754
- table,
755
- })), rest);
756
- const DetailPanel = !isLoading && (renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
757
- return (jsx(TableRow, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", "data-index": renderDetailPanel ? staticRowIndex * 2 + 1 : staticRowIndex, ref: (node) => {
758
- var _a;
759
- if (node) {
760
- (_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
761
- }
762
- } }, tableRowProps, { sx: (theme) => {
763
- var _a, _b;
764
- return (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: virtualRow ? 'absolute' : undefined, top: virtualRow
765
- ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
766
- : undefined, transform: virtualRow
767
- ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
768
- : undefined, width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme)));
769
- }, children: jsx(TableCell, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
770
- ? getMRTTheme(table, theme).baseBackgroundColor
771
- : 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: !enableRowVirtualization
772
- ? 'all 150ms ease-in-out'
773
- : undefined, width: `100%` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: enableRowVirtualization ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { in: !!row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: DetailPanel })) })) })));
774
- };
775
-
776
- const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow, }) => {
777
- var _a, _b, _c, _d;
778
- const theme = useTheme();
779
- const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
780
- const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
781
- const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
782
- const isPinned = enableRowPinning && row.getIsPinned();
783
- const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
784
- const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
785
- const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
786
- row,
787
- staticRowIndex,
788
- table,
789
- });
790
- const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
791
- if (!enableRowPinning ||
792
- !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) ||
793
- !pinnedRowIds ||
794
- !row.getIsPinned())
795
- return [];
796
- return [
797
- [...pinnedRowIds].reverse().indexOf(row.id),
798
- pinnedRowIds.indexOf(row.id),
799
- ];
800
- }, [pinnedRowIds, rowPinning]);
801
- const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
802
- ((_a = tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight)) ||
803
- 0;
804
- const tableFooterHeight = (enableStickyFooter && ((_b = tableFooterRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
805
- const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
806
- const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
807
- const customRowHeight =
808
- // @ts-ignore
809
- parseInt((_d = (_c = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
810
- const rowHeight = customRowHeight || defaultRowHeight;
811
- const handleDragEnter = (_e) => {
812
- if (enableRowOrdering && draggingRow) {
813
- setHoveredRow(row);
814
- }
815
- };
816
- const rowRef = useRef(null);
817
- const { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, } = getMRTTheme(table, theme);
818
- return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": renderDetailPanel ? staticRowIndex * 2 : staticRowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || row.getIsAllSubRowsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
819
- var _a;
820
- if (node) {
821
- rowRef.current = node;
822
- (_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
823
- }
824
- }, selected: row.getIsSelected() }, tableRowProps, { style: Object.assign({ transform: virtualRow
825
- ? `translateY(${virtualRow.start}px)`
826
- : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), sx: (theme) => (Object.assign({ '&:hover td': {
827
- backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
828
- ? row.getIsSelected()
829
- ? `${alpha(selectedRowBackgroundColor, 0.3)}`
830
- : theme.palette.mode === 'dark'
831
- ? `${lighten(baseBackgroundColor, 0.05)}`
832
- : `${darken(baseBackgroundColor, 0.05)}`
833
- : undefined,
834
- }, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
835
- ? `${bottomPinnedIndex * rowHeight +
836
- (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
837
- : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
838
- ? 'absolute'
839
- : (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
840
- ? 'sticky'
841
- : undefined, td: {
842
- backgroundColor: row.getIsSelected()
843
- ? selectedRowBackgroundColor
844
- : isPinned
845
- ? pinnedRowBackgroundColor
846
- : undefined,
847
- }, top: virtualRow
848
- ? 0
849
- : topPinnedIndex !== undefined && isPinned
850
- ? `${topPinnedIndex * rowHeight +
851
- (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
852
- : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
853
- ? 2
854
- : undefined }, sx)), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
855
- const cell = columnVirtualizer
856
- ? row.getVisibleCells()[cellOrVirtualCell.index]
857
- : cellOrVirtualCell;
858
- const props = {
859
- cell,
860
- measureElement: !isDraggingRow && !isHoveredRow
861
- ? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
862
- : undefined,
863
- numRows,
864
- rowRef,
865
- staticRowIndex,
866
- table,
867
- virtualColumnIndex: columnVirtualizer
868
- ? cellOrVirtualCell.index
869
- : undefined,
870
- };
871
- return cell ? (memoMode === 'cells' &&
872
- cell.column.columnDef.columnDefType === 'data' &&
873
- !draggingColumn &&
874
- !draggingRow &&
875
- (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
876
- (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), cell.id)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), cell.id))) : null;
877
- }), 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 }))] }));
878
- };
879
- const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
880
-
881
- const useMRT_ColumnVirtualizer = (table) => {
882
- var _a, _b, _c, _d, _e, _f, _g, _h;
883
- const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
884
- const { columnPinning, columnVisibility, draggingColumn } = getState();
885
- const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
886
- table,
887
- });
888
- const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnVirtualization && enableColumnPinning
889
- ? [
890
- table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
891
- table
892
- .getRightLeafColumns()
893
- .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
894
- .sort((a, b) => a - b),
895
- ]
896
- : [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
897
- //get first 16 column widths and average them if calc is needed
898
- const averageColumnWidth = useMemo(() => {
899
- var _a, _b, _c, _d;
900
- if (!enableColumnVirtualization || (columnVirtualizerProps === null || columnVirtualizerProps === void 0 ? void 0 : columnVirtualizerProps.estimateSize)) {
901
- return 0;
902
- }
903
- const columnsWidths = (_d = (_c = (_b = (_a = table
904
- .getRowModel()
905
- .rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
906
- return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
907
- }, [table.getRowModel().rows, columnPinning, columnVisibility]);
908
- const draggingColumnIndex = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
909
- ? table
910
- .getVisibleLeafColumns()
911
- .findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
912
- : undefined;
913
- const columnVirtualizer = enableColumnVirtualization
914
- ? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
915
- const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
916
- return [
917
- ...new Set([
918
- ...leftPinnedIndexes,
919
- ...newIndexes,
920
- ...rightPinnedIndexes,
921
- ]),
922
- ];
923
- }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps))
924
- : undefined;
925
- if (columnVirtualizer) {
926
- const virtualColumns = columnVirtualizer.getVirtualItems();
927
- columnVirtualizer.virtualColumns = virtualColumns;
928
- if (virtualColumns.length) {
929
- columnVirtualizer.virtualPaddingLeft =
930
- ((_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0) -
931
- ((_d = (_c = virtualColumns[leftPinnedIndexes.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
932
- columnVirtualizer.virtualPaddingRight =
933
- columnVirtualizer.getTotalSize() -
934
- ((_f = (_e = virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : 0) -
935
- (rightPinnedIndexes.length
936
- ? columnVirtualizer.getTotalSize() -
937
- ((_h = (_g = virtualColumns[virtualColumns.length - rightPinnedIndexes.length]) === null || _g === void 0 ? void 0 : _g.start) !== null && _h !== void 0 ? _h : 0)
938
- : 0);
939
- }
940
- if (columnVirtualizerInstanceRef) {
941
- //@ts-ignore
942
- columnVirtualizerInstanceRef.current = columnVirtualizer;
943
- }
944
- }
945
- return columnVirtualizer;
946
- };
947
-
948
- const MRT_GrabHandleButton = (_a) => {
949
- var _b, _c;
950
- var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
951
- const { options: { icons: { DragHandleIcon }, localization, }, } = table;
952
- const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
953
- return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_b = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
954
- var _a;
955
- e.stopPropagation();
956
- (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
957
- }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
958
- cursor: 'grabbing',
959
- }, '&:hover': {
960
- backgroundColor: 'transparent',
961
- opacity: 1,
962
- }, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.3, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(_iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) }));
963
- };
964
-
965
- const MRT_TableBodyRowGrabHandle = (_a) => {
966
- var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
967
- const { options: { muiRowDragHandleProps }, } = table;
968
- const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
969
- row,
970
- table,
971
- })), rest);
972
- const handleDragStart = (event) => {
973
- var _a;
974
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
975
- try {
976
- event.dataTransfer.setDragImage(rowRef.current, 0, 0);
977
- }
978
- catch (e) {
979
- console.error(e);
980
- }
981
- table.setDraggingRow(row);
982
- };
983
- const handleDragEnd = (event) => {
984
- var _a;
985
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
986
- table.setDraggingRow(null);
987
- table.setHoveredRow(null);
988
- };
989
- return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
990
- };
991
-
992
- const MRT_RowPinButton = (_a) => {
993
- var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
994
- const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
995
- const isPinned = row.getIsPinned();
996
- const [tooltipOpened, setTooltipOpened] = useState(false);
997
- const handleTogglePin = (event) => {
998
- setTooltipOpened(false);
999
- event.stopPropagation();
1000
- row.pin(isPinned ? false : pinningPosition);
1001
- };
1002
- return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, Object.assign({ "aria-label": localization.pin, onClick: handleTogglePin, 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: {
1003
- transform: `rotate(${rowPinningDisplayMode === 'sticky'
1004
- ? 135
1005
- : pinningPosition === 'top'
1006
- ? 180
1007
- : 0}deg)`,
1008
- } })) })) }));
1009
- };
1010
-
1011
- const MRT_TableBodyRowPinButton = (_a) => {
1012
- var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
1013
- const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
1014
- const { density } = getState();
1015
- const canPin = parseFromValuesOrFunc(enableRowPinning, row);
1016
- if (!canPin)
1017
- return null;
1018
- const rowPinButtonProps = Object.assign({ row,
1019
- table }, rest);
1020
- if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
1021
- return (jsxs(Box, { sx: {
1022
- display: 'flex',
1023
- flexDirection: density === 'compact' ? 'row' : 'column',
1024
- }, children: [jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
1025
- }
1026
- return (jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
1027
- };
1028
-
1029
- const MRT_ExpandAllButton = (_a) => {
1030
- var _b, _c;
1031
- var { table } = _a, rest = __rest(_a, ["table"]);
1032
- const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1033
- const { density, isLoading } = getState();
1034
- const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
1035
- table,
1036
- })), rest);
1037
- const isAllRowsExpanded = getIsAllRowsExpanded();
1038
- return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, 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: {
1039
- transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
1040
- transition: 'transform 150ms',
1041
- } })) })) }) }));
1042
- };
1043
-
1044
- const MRT_ExpandButton = ({ row, table, }) => {
1045
- var _a, _b;
1046
- const theme = useTheme();
1047
- const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
1048
- const { density } = getState();
1049
- const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
1050
- row,
1051
- table,
1052
- });
1053
- const canExpand = row.getCanExpand();
1054
- const isExpanded = row.getIsExpanded();
1055
- const handleToggleExpand = (event) => {
1056
- var _a;
1057
- event.stopPropagation();
1058
- row.toggleExpanded();
1059
- (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1060
- };
1061
- const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
1062
- return (jsx(Tooltip, { disableHoverListener: !canExpand && !detailPanel, enterDelay: 1000, enterNextDelay: 1000, 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, 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: {
1063
- transform: `rotate(${!canExpand && !renderDetailPanel
1064
- ? positionExpandColumn === 'last' ||
1065
- theme.direction === 'rtl'
1066
- ? 90
1067
- : -90
1068
- : isExpanded
1069
- ? -180
1070
- : 0}deg)`,
1071
- transition: 'transform 150ms',
1072
- } })) })) }) }));
1073
- };
1074
-
1075
- const MRT_EditActionButtons = (_a) => {
1076
- var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
1077
- const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
1078
- const { creatingRow, editingRow, isSaving } = getState();
1079
- const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1080
- const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
1081
- const handleCancel = () => {
1082
- if (isCreating) {
1083
- onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
1084
- setCreatingRow(null);
1085
- }
1086
- else if (isEditing) {
1087
- onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
1088
- setEditingRow(null);
1089
- }
1090
- row._valuesCache = {}; //reset values cache
1091
- };
1092
- const handleSubmitRow = () => {
1093
- var _a;
1094
- //look for auto-filled input values
1095
- (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)
1096
- .filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
1097
- if (input.value !== undefined &&
1098
- Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
1099
- // @ts-ignore
1100
- row._valuesCache[input.name] = input.value;
1101
- }
1102
- });
1103
- if (isCreating)
1104
- onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
1105
- exitCreatingMode: () => setCreatingRow(null),
1106
- row,
1107
- table,
1108
- values: row._valuesCache,
1109
- });
1110
- else if (isEditing) {
1111
- onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
1112
- exitEditingMode: () => setEditingRow(null),
1113
- row,
1114
- table,
1115
- values: row === null || row === void 0 ? void 0 : row._valuesCache,
1116
- });
1117
- }
1118
- };
1119
- 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) ||
1120
- (isEditing && onEditingRowSave)) && (jsx(Tooltip, { title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsx(CircularProgress, { size: 18 }) : jsx(SaveIcon, {}) }) }))] })) : (jsxs(Fragment, { children: [jsx(Button, { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxs(Button, { onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
504
+ if (layoutMode === 'grid') {
505
+ widthStyles.flex = `${[0, false].includes(columnDef.grow)
506
+ ? 0
507
+ : `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_f = header === null || header === void 0 ? void 0 : header.id) !== null && _f !== void 0 ? _f : column.id)}-size)`} 0 auto`;
508
+ }
509
+ else if (layoutMode === 'grid-no-grow') {
510
+ widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
511
+ }
512
+ return Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && columnDef.columnDefType !== 'group'
513
+ ? alpha(darken(getMRTTheme(table, theme).baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97)
514
+ : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
515
+ ? `-4px 0 8px -6px ${alpha(theme.palette.grey[700], 0.5)} inset`
516
+ : getIsFirstRightPinnedColumn(column)
517
+ ? `4px 0 8px -6px ${alpha(theme.palette.grey[700], 0.5)} inset`
518
+ : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
519
+ ? `${column.getStart('left')}px`
520
+ : undefined, opacity: ((_g = table.getState().draggingColumn) === null || _g === void 0 ? void 0 : _g.id) === column.id ||
521
+ ((_h = table.getState().hoveredColumn) === null || _h === void 0 ? void 0 : _h.id) === column.id
522
+ ? 0.5
523
+ : 1, position: column.getIsPinned() && columnDef.columnDefType !== 'group'
524
+ ? 'sticky'
525
+ : undefined, right: column.getIsPinned() === 'right'
526
+ ? `${getTotalRight(table, column)}px`
527
+ : undefined, transition: table.options.enableColumnVirtualization
528
+ ? 'none'
529
+ : `padding 150ms ease-in-out` }, widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
1121
530
  };
531
+ const getCommonToolbarStyles = ({ table, theme, }) => ({
532
+ alignItems: 'flex-start',
533
+ backgroundColor: getMRTTheme(table, theme).baseBackgroundColor,
534
+ display: 'grid',
535
+ flexWrap: 'wrap-reverse',
536
+ minHeight: '3.5rem',
537
+ overflow: 'hidden',
538
+ position: 'relative',
539
+ transition: 'all 150ms ease-in-out',
540
+ zIndex: 1,
541
+ });
542
+ const flipIconStyles = (theme) => theme.direction === 'rtl'
543
+ ? { style: { transform: 'scaleX(-1)' } }
544
+ : undefined;
545
+ const getCommonTooltipProps = (placement) => ({
546
+ disableInteractive: true,
547
+ enterDelay: 1000,
548
+ enterNextDelay: 1000,
549
+ placement,
550
+ });
1122
551
 
1123
552
  const mrtFilterOptions = (localization) => [
1124
553
  {
@@ -1296,8 +725,13 @@ const MRT_FilterOptionMenu = (_a) => {
1296
725
  onSelect === null || onSelect === void 0 ? void 0 : onSelect();
1297
726
  };
1298
727
  const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
728
+ const theme = useTheme();
729
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
1299
730
  return (jsx(Menu, Object.assign({ MenuListProps: {
1300
731
  dense: density === 'compact',
732
+ sx: {
733
+ backgroundColor: menuBackgroundColor,
734
+ },
1301
735
  }, anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'center' }, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_e = (header && column && columnDef
1302
736
  ? (_d = (_c = columnDef.renderColumnFilterModeMenuItems) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
1303
737
  column: column,
@@ -1446,8 +880,13 @@ const MRT_ColumnActionMenu = (_a) => {
1446
880
  ]
1447
881
  : []),
1448
882
  ].filter(Boolean);
883
+ const theme = useTheme();
884
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
1449
885
  return (jsx(Menu, Object.assign({ MenuListProps: {
1450
886
  dense: density === 'compact',
887
+ sx: {
888
+ backgroundColor: menuBackgroundColor,
889
+ },
1451
890
  }, anchorEl: anchorEl, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: (_l = (_k = (_j = columnDef.renderColumnActionsMenuItems) === null || _j === void 0 ? void 0 : _j.call(columnDef, {
1452
891
  closeMenu: () => setAnchorEl(null),
1453
892
  column,
@@ -1462,15 +901,21 @@ const MRT_ColumnActionMenu = (_a) => {
1462
901
  };
1463
902
 
1464
903
  const MRT_RowActionMenu = (_a) => {
1465
- var { anchorEl, handleEdit, row, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "table"]);
904
+ var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
1466
905
  const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, renderRowActionMenuItems, }, } = table;
1467
906
  const { density } = getState();
907
+ const theme = useTheme();
908
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
1468
909
  return (jsxs(Menu, Object.assign({ MenuListProps: {
1469
910
  dense: density === 'compact',
911
+ sx: {
912
+ backgroundColor: menuBackgroundColor,
913
+ },
1470
914
  }, anchorEl: anchorEl, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [parseFromValuesOrFunc(enableEditing, row) &&
1471
915
  ['modal', 'row'].includes(editDisplayMode) && (jsx(MenuItem, { onClick: handleEdit, sx: commonMenuItemStyles, children: jsxs(Box, { sx: commonListItemStyles, children: [jsx(ListItemIcon, { children: jsx(EditIcon, {}) }), localization.edit] }) })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
1472
916
  closeMenu: () => setAnchorEl(null),
1473
917
  row,
918
+ staticRowIndex,
1474
919
  table,
1475
920
  })] })));
1476
921
  };
@@ -1486,7 +931,7 @@ const commonIconButtonStyles = {
1486
931
  width: '2rem',
1487
932
  };
1488
933
  const MRT_ToggleRowActionMenuButton = (_a) => {
1489
- var { cell, row, table } = _a, rest = __rest(_a, ["cell", "row", "table"]);
934
+ var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
1490
935
  const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
1491
936
  const { creatingRow, editingRow } = getState();
1492
937
  const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
@@ -1504,9 +949,228 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
1504
949
  setEditingRow(Object.assign({}, row));
1505
950
  setAnchorEl(null);
1506
951
  };
1507
- return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
952
+ return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
1508
953
  parseFromValuesOrFunc(enableEditing, row) &&
1509
- ['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, {}) })) })) : renderRowActionMenuItems ? (jsxs(Fragment, { children: [jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, 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, table: table })] })) : null }));
954
+ ['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, {}) })) })) : renderRowActionMenuItems ? (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 }));
955
+ };
956
+
957
+ const getMRT_RowActionsColumnDef = (tableOptions) => {
958
+ if (!showRowActionsColumn(tableOptions)) {
959
+ return null;
960
+ }
961
+ return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
962
+ header: 'actions',
963
+ id: 'mrt-row-actions',
964
+ tableOptions,
965
+ }));
966
+ };
967
+
968
+ const MRT_GrabHandleButton = (_a) => {
969
+ var _b, _c;
970
+ var { iconButtonProps, location, onDragEnd, onDragStart, table } = _a, rest = __rest(_a, ["iconButtonProps", "location", "onDragEnd", "onDragStart", "table"]);
971
+ const { options: { icons: { DragHandleIcon }, localization, }, } = table;
972
+ const _iconButtonProps = Object.assign(Object.assign({}, iconButtonProps), rest);
973
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.title) !== null && _b !== void 0 ? _b : localization.move, children: jsx(IconButton, Object.assign({ "aria-label": (_c = _iconButtonProps.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, _iconButtonProps, { onClick: (e) => {
974
+ var _a;
975
+ e.stopPropagation();
976
+ (_a = _iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(_iconButtonProps, e);
977
+ }, onDragEnd: onDragEnd, onDragStart: onDragStart, sx: (theme) => (Object.assign({ '&:active': {
978
+ cursor: 'grabbing',
979
+ }, '&:hover': {
980
+ backgroundColor: 'transparent',
981
+ opacity: 1,
982
+ }, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.3, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(_iconButtonProps === null || _iconButtonProps === void 0 ? void 0 : _iconButtonProps.sx, theme))), title: undefined, children: jsx(DragHandleIcon, {}) })) })));
983
+ };
984
+
985
+ const MRT_TableBodyRowGrabHandle = (_a) => {
986
+ var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
987
+ const { options: { muiRowDragHandleProps }, } = table;
988
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
989
+ row,
990
+ table,
991
+ })), rest);
992
+ const handleDragStart = (event) => {
993
+ var _a;
994
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
995
+ try {
996
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
997
+ }
998
+ catch (e) {
999
+ console.error(e);
1000
+ }
1001
+ table.setDraggingRow(row);
1002
+ };
1003
+ const handleDragEnd = (event) => {
1004
+ var _a;
1005
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1006
+ table.setDraggingRow(null);
1007
+ table.setHoveredRow(null);
1008
+ };
1009
+ return (jsx(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table }));
1010
+ };
1011
+
1012
+ const getMRT_RowDragColumnDef = (tableOptions) => {
1013
+ if (!showRowDragColumn(tableOptions)) {
1014
+ return null;
1015
+ }
1016
+ return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
1017
+ header: 'move',
1018
+ id: 'mrt-row-drag',
1019
+ tableOptions,
1020
+ }));
1021
+ };
1022
+
1023
+ const MRT_ExpandAllButton = (_a) => {
1024
+ var _b, _c;
1025
+ var { table } = _a, rest = __rest(_a, ["table"]);
1026
+ const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1027
+ const { density, isLoading } = getState();
1028
+ const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
1029
+ table,
1030
+ })), rest);
1031
+ const isAllRowsExpanded = getIsAllRowsExpanded();
1032
+ 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: {
1033
+ transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
1034
+ transition: 'transform 150ms',
1035
+ } })) })) }) })));
1036
+ };
1037
+
1038
+ const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1039
+ var _a, _b;
1040
+ const theme = useTheme();
1041
+ const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
1042
+ const { density } = getState();
1043
+ const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
1044
+ row,
1045
+ staticRowIndex,
1046
+ table,
1047
+ });
1048
+ const canExpand = row.getCanExpand();
1049
+ const isExpanded = row.getIsExpanded();
1050
+ const handleToggleExpand = (event) => {
1051
+ var _a;
1052
+ event.stopPropagation();
1053
+ row.toggleExpanded();
1054
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1055
+ };
1056
+ const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
1057
+ 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'
1058
+ ? 'mr'
1059
+ : '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: {
1060
+ transform: `rotate(${!canExpand && !renderDetailPanel
1061
+ ? positionExpandColumn === 'last' ||
1062
+ theme.direction === 'rtl'
1063
+ ? 90
1064
+ : -90
1065
+ : isExpanded
1066
+ ? -180
1067
+ : 0}deg)`,
1068
+ transition: 'transform 150ms',
1069
+ } })) })) }) })));
1070
+ };
1071
+
1072
+ const getMRT_RowExpandColumnDef = (tableOptions) => {
1073
+ if (!showRowExpandColumn(tableOptions)) {
1074
+ return null;
1075
+ }
1076
+ const { defaultColumn, enableExpandAll, groupedColumnMode, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
1077
+ const alignProps = positionExpandColumn === 'last'
1078
+ ? {
1079
+ align: 'right',
1080
+ }
1081
+ : undefined;
1082
+ return Object.assign({ Cell: ({ cell, column, row, staticRowIndex, table }) => {
1083
+ var _a, _b, _c;
1084
+ const expandButtonProps = { row, staticRowIndex, table };
1085
+ const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
1086
+ if (groupedColumnMode === 'remove' && row.groupingColumnId) {
1087
+ 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, ")"] })] }));
1088
+ }
1089
+ else {
1090
+ 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 })] }));
1091
+ }
1092
+ }, Header: enableExpandAll
1093
+ ? ({ table }) => {
1094
+ var _a;
1095
+ return (jsxs(Fragment, { children: [jsx(MRT_ExpandAllButton, { table: table }), groupedColumnMode === 'remove' &&
1096
+ ((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
1097
+ }
1098
+ : undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
1099
+ header: 'expand',
1100
+ id: 'mrt-row-expand',
1101
+ size: groupedColumnMode === 'remove'
1102
+ ? defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size
1103
+ : renderDetailPanel
1104
+ ? 60
1105
+ : 100,
1106
+ tableOptions,
1107
+ }));
1108
+ };
1109
+
1110
+ const getMRT_RowNumbersColumnDef = (tableOptions) => {
1111
+ if (!showRowNumbersColumn(tableOptions)) {
1112
+ return null;
1113
+ }
1114
+ const { localization, rowNumberDisplayMode } = tableOptions;
1115
+ const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
1116
+ return Object.assign({ Cell: ({ row, staticRowIndex }) => {
1117
+ var _a;
1118
+ return ((_a = (rowNumberDisplayMode === 'static'
1119
+ ? (staticRowIndex || 0) + (pageSize || 0) * (pageIndex || 0)
1120
+ : row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
1121
+ }, Header: () => localization.rowNumber, grow: false }, defaultDisplayColumnProps({
1122
+ header: 'rowNumbers',
1123
+ id: 'mrt-row-numbers',
1124
+ tableOptions,
1125
+ }));
1126
+ };
1127
+
1128
+ const MRT_RowPinButton = (_a) => {
1129
+ var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
1130
+ const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
1131
+ const isPinned = row.getIsPinned();
1132
+ const [tooltipOpened, setTooltipOpened] = useState(false);
1133
+ const handleTogglePin = (event) => {
1134
+ setTooltipOpened(false);
1135
+ event.stopPropagation();
1136
+ row.pin(isPinned ? false : pinningPosition);
1137
+ };
1138
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, Object.assign({ "aria-label": localization.pin, onClick: handleTogglePin, 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: {
1139
+ transform: `rotate(${rowPinningDisplayMode === 'sticky'
1140
+ ? 135
1141
+ : pinningPosition === 'top'
1142
+ ? 180
1143
+ : 0}deg)`,
1144
+ } })) })) })));
1145
+ };
1146
+
1147
+ const MRT_TableBodyRowPinButton = (_a) => {
1148
+ var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
1149
+ const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
1150
+ const { density } = getState();
1151
+ const canPin = parseFromValuesOrFunc(enableRowPinning, row);
1152
+ if (!canPin)
1153
+ return null;
1154
+ const rowPinButtonProps = Object.assign({ row,
1155
+ table }, rest);
1156
+ if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
1157
+ return (jsxs(Box, { sx: {
1158
+ display: 'flex',
1159
+ flexDirection: density === 'compact' ? 'row' : 'column',
1160
+ }, children: [jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
1161
+ }
1162
+ return (jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
1163
+ };
1164
+
1165
+ const getMRT_RowPinningColumnDef = (tableOptions) => {
1166
+ if (!showRowPinningColumn(tableOptions)) {
1167
+ return null;
1168
+ }
1169
+ return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
1170
+ header: 'pin',
1171
+ id: 'mrt-row-pin',
1172
+ tableOptions,
1173
+ }));
1510
1174
  };
1511
1175
 
1512
1176
  const MRT_SelectCheckbox = (_a) => {
@@ -1566,156 +1230,291 @@ const MRT_SelectCheckbox = (_a) => {
1566
1230
  e.stopPropagation();
1567
1231
  (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
1568
1232
  }, 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 });
1569
- return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
1233
+ return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
1570
1234
  ? localization.toggleSelectAll
1571
1235
  : localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ indeterminate: selectAll
1572
1236
  ? table.getIsSomeRowsSelected() && !allRowsSelected
1573
- : (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) }));
1237
+ : (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
1238
+ };
1239
+
1240
+ const getMRT_RowSelectColumnDef = (tableOptions) => {
1241
+ if (!showRowSelectionColumn(tableOptions)) {
1242
+ return null;
1243
+ }
1244
+ const { enableMultiRowSelection, enableSelectAll } = tableOptions;
1245
+ return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
1246
+ ? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
1247
+ : undefined, grow: false }, defaultDisplayColumnProps({
1248
+ header: 'select',
1249
+ id: 'mrt-row-select',
1250
+ tableOptions,
1251
+ }));
1252
+ };
1253
+
1254
+ const MRT_Default_Icons = {
1255
+ ArrowDownwardIcon,
1256
+ ArrowRightIcon,
1257
+ CancelIcon,
1258
+ ChevronLeftIcon,
1259
+ ChevronRightIcon,
1260
+ ClearAllIcon,
1261
+ CloseIcon,
1262
+ DensityLargeIcon,
1263
+ DensityMediumIcon,
1264
+ DensitySmallIcon,
1265
+ DragHandleIcon,
1266
+ DynamicFeedIcon,
1267
+ EditIcon,
1268
+ ExpandMoreIcon,
1269
+ FilterAltIcon,
1270
+ FilterListIcon,
1271
+ FilterListOffIcon,
1272
+ FirstPageIcon,
1273
+ FullscreenExitIcon,
1274
+ FullscreenIcon,
1275
+ KeyboardDoubleArrowDownIcon,
1276
+ LastPageIcon,
1277
+ MoreHorizIcon,
1278
+ MoreVertIcon,
1279
+ PushPinIcon,
1280
+ RestartAltIcon,
1281
+ SaveIcon,
1282
+ SearchIcon,
1283
+ SearchOffIcon,
1284
+ SortIcon,
1285
+ SyncAltIcon,
1286
+ ViewColumnIcon,
1287
+ VisibilityOffIcon,
1288
+ };
1289
+
1290
+ const MRT_Localization_EN = {
1291
+ actions: 'Actions',
1292
+ and: 'and',
1293
+ cancel: 'Cancel',
1294
+ changeFilterMode: 'Change filter mode',
1295
+ changeSearchMode: 'Change search mode',
1296
+ clearFilter: 'Clear filter',
1297
+ clearSearch: 'Clear search',
1298
+ clearSort: 'Clear sort',
1299
+ clickToCopy: 'Click to copy',
1300
+ collapse: 'Collapse',
1301
+ collapseAll: 'Collapse all',
1302
+ columnActions: 'Column Actions',
1303
+ copiedToClipboard: 'Copied to clipboard',
1304
+ dropToGroupBy: 'Drop to group by {column}',
1305
+ edit: 'Edit',
1306
+ expand: 'Expand',
1307
+ expandAll: 'Expand all',
1308
+ filterArrIncludes: 'Includes',
1309
+ filterArrIncludesAll: 'Includes all',
1310
+ filterArrIncludesSome: 'Includes',
1311
+ filterBetween: 'Between',
1312
+ filterBetweenInclusive: 'Between Inclusive',
1313
+ filterByColumn: 'Filter by {column}',
1314
+ filterContains: 'Contains',
1315
+ filterEmpty: 'Empty',
1316
+ filterEndsWith: 'Ends With',
1317
+ filterEquals: 'Equals',
1318
+ filterEqualsString: 'Equals',
1319
+ filterFuzzy: 'Fuzzy',
1320
+ filterGreaterThan: 'Greater Than',
1321
+ filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
1322
+ filterInNumberRange: 'Between',
1323
+ filterIncludesString: 'Contains',
1324
+ filterIncludesStringSensitive: 'Contains',
1325
+ filterLessThan: 'Less Than',
1326
+ filterLessThanOrEqualTo: 'Less Than Or Equal To',
1327
+ filterMode: 'Filter Mode: {filterType}',
1328
+ filterNotEmpty: 'Not Empty',
1329
+ filterNotEquals: 'Not Equals',
1330
+ filterStartsWith: 'Starts With',
1331
+ filterWeakEquals: 'Equals',
1332
+ filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
1333
+ goToFirstPage: 'Go to first page',
1334
+ goToLastPage: 'Go to last page',
1335
+ goToNextPage: 'Go to next page',
1336
+ goToPreviousPage: 'Go to previous page',
1337
+ grab: 'Grab',
1338
+ groupByColumn: 'Group by {column}',
1339
+ groupedBy: 'Grouped by ',
1340
+ hideAll: 'Hide all',
1341
+ hideColumn: 'Hide {column} column',
1342
+ max: 'Max',
1343
+ min: 'Min',
1344
+ move: 'Move',
1345
+ noRecordsToDisplay: 'No records to display',
1346
+ noResultsFound: 'No results found',
1347
+ of: 'of',
1348
+ or: 'or',
1349
+ pin: 'Pin',
1350
+ pinToLeft: 'Pin to left',
1351
+ pinToRight: 'Pin to right',
1352
+ resetColumnSize: 'Reset column size',
1353
+ resetOrder: 'Reset order',
1354
+ rowActions: 'Row Actions',
1355
+ rowNumber: '#',
1356
+ rowNumbers: 'Row Numbers',
1357
+ rowsPerPage: 'Rows per page',
1358
+ save: 'Save',
1359
+ search: 'Search',
1360
+ selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
1361
+ select: 'Select',
1362
+ showAll: 'Show all',
1363
+ showAllColumns: 'Show all columns',
1364
+ showHideColumns: 'Show/Hide columns',
1365
+ showHideFilters: 'Show/Hide filters',
1366
+ showHideSearch: 'Show/Hide search',
1367
+ sortByColumnAsc: 'Sort by {column} ascending',
1368
+ sortByColumnDesc: 'Sort by {column} descending',
1369
+ sortedByColumnAsc: 'Sorted by {column} ascending',
1370
+ sortedByColumnDesc: 'Sorted by {column} descending',
1371
+ thenBy: ', then by ',
1372
+ toggleDensity: 'Toggle density',
1373
+ toggleFullScreen: 'Toggle full screen',
1374
+ toggleSelectAll: 'Toggle select all',
1375
+ toggleSelectRow: 'Toggle select row',
1376
+ toggleVisibility: 'Toggle visibility',
1377
+ ungroupByColumn: 'Ungroup by {column}',
1378
+ unpin: 'Unpin',
1379
+ unpinAll: 'Unpin all',
1574
1380
  };
1575
1381
 
1576
- const useMRT_DisplayColumns = (params) => {
1577
- var _a, _b, _c, _d;
1578
- const { columnOrder, creatingRow, grouping, tableOptions } = params;
1579
- const order = (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder;
1580
- return useMemo(() => [
1581
- makeRowPinColumn,
1582
- makeRowDragColumn,
1583
- makeRowActionsColumn,
1584
- makeRowExpandColumn,
1585
- makeRowSelectColumn,
1586
- makeRowNumbersColumn,
1587
- makeSpacerColumn,
1588
- ]
1589
- .map((makeCol) => makeCol(params, order))
1590
- .filter(Boolean), [
1591
- columnOrder,
1592
- creatingRow,
1593
- grouping,
1594
- tableOptions.displayColumnDefOptions,
1595
- tableOptions.editDisplayMode,
1596
- tableOptions.enableColumnDragging,
1597
- tableOptions.enableColumnFilterModes,
1598
- tableOptions.enableColumnOrdering,
1599
- tableOptions.enableEditing,
1600
- tableOptions.enableExpandAll,
1601
- tableOptions.enableExpanding,
1602
- tableOptions.enableGrouping,
1603
- tableOptions.enableRowActions,
1604
- tableOptions.enableRowDragging,
1605
- tableOptions.enableRowNumbers,
1606
- tableOptions.enableRowOrdering,
1607
- tableOptions.enableRowSelection,
1608
- tableOptions.enableSelectAll,
1609
- tableOptions.groupedColumnMode,
1610
- tableOptions.localization,
1611
- tableOptions.positionActionsColumn,
1612
- tableOptions.positionExpandColumn,
1613
- tableOptions.renderDetailPanel,
1614
- tableOptions.renderRowActionMenuItems,
1615
- tableOptions.renderRowActions,
1616
- (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.columnOrder,
1617
- (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.grouping,
1618
- ]);
1382
+ const MRT_DefaultColumn = {
1383
+ filterVariant: 'text',
1384
+ maxSize: 1000,
1385
+ minSize: 40,
1386
+ size: 180,
1619
1387
  };
1620
- function defaultDisplayColumnProps({ defaultDisplayColumn, displayColumnDefOptions, localization, }, id, header, size = 60) {
1621
- 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 });
1622
- }
1623
- function makeRowPinColumn({ tableOptions }, order) {
1624
- const id = 'mrt-row-pin';
1625
- if (order.includes(id)) {
1626
- return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'pin'));
1388
+ const MRT_DefaultDisplayColumn = {
1389
+ columnDefType: 'display',
1390
+ enableClickToCopy: false,
1391
+ enableColumnActions: false,
1392
+ enableColumnDragging: false,
1393
+ enableColumnFilter: false,
1394
+ enableColumnOrdering: false,
1395
+ enableEditing: false,
1396
+ enableGlobalFilter: false,
1397
+ enableGrouping: false,
1398
+ enableHiding: false,
1399
+ enableResizing: false,
1400
+ enableSorting: false,
1401
+ };
1402
+ const useMRT_TableOptions = (_a) => {
1403
+ var _b;
1404
+ var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, 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", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
1405
+ const theme = useTheme();
1406
+ const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
1407
+ const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
1408
+ const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
1409
+ const _filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
1410
+ const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
1411
+ const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
1412
+ const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
1413
+ if (!columnResizeDirection) {
1414
+ columnResizeDirection = theme.direction || 'ltr';
1627
1415
  }
1628
- return null;
1629
- }
1630
- function makeRowDragColumn({ tableOptions }, order) {
1631
- const id = 'mrt-row-drag';
1632
- if (order.includes(id)) {
1633
- return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'move'));
1416
+ layoutMode =
1417
+ layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
1418
+ if (layoutMode === 'semantic' &&
1419
+ (rest.enableRowVirtualization || rest.enableColumnVirtualization)) {
1420
+ layoutMode = 'grid';
1634
1421
  }
1635
- return null;
1636
- }
1637
- function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
1638
- const id = 'mrt-row-actions';
1639
- if (order.includes(id) ||
1640
- (creatingRow && tableOptions.createDisplayMode === 'row')) {
1641
- return Object.assign({ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'actions'));
1422
+ if (rest.enableRowVirtualization) {
1423
+ enableStickyHeader = true;
1642
1424
  }
1643
- return null;
1644
- }
1645
- function makeRowExpandColumn({ grouping, tableOptions }, order) {
1646
- var _a, _b, _c;
1647
- const id = 'mrt-row-expand';
1648
- if (order.includes(id) &&
1649
- showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
1650
- const alignProps = tableOptions.positionExpandColumn === 'last'
1651
- ? {
1652
- align: 'right',
1653
- }
1654
- : undefined;
1655
- return Object.assign({ Cell: ({ cell, column, row, table }) => {
1656
- var _a, _b, _c;
1657
- const expandButtonProps = { row, table };
1658
- const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
1659
- if (tableOptions.groupedColumnMode === 'remove' &&
1660
- row.groupingColumnId) {
1661
- return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: "0.25rem", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "right", title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) }), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
1662
- }
1663
- else {
1664
- 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 })] }));
1665
- }
1666
- }, Header: tableOptions.enableExpandAll
1667
- ? ({ table }) => {
1668
- return (jsxs(Fragment, { children: [jsx(MRT_ExpandAllButton, { table: table }), tableOptions.groupedColumnMode === 'remove' &&
1669
- grouping
1670
- .map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)
1671
- .join(', ')] }));
1672
- }
1673
- : undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps(tableOptions, id, 'expand', tableOptions.groupedColumnMode === 'remove'
1674
- ? (_c = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.defaultColumn) === null || _c === void 0 ? void 0 : _c.size
1675
- : 60));
1425
+ if (enablePagination === false && manualPagination === undefined) {
1426
+ manualPagination = true;
1676
1427
  }
1677
- return null;
1678
- }
1679
- function makeRowSelectColumn({ tableOptions }, order) {
1680
- const id = 'mrt-row-select';
1681
- if (order.includes(id)) {
1682
- return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
1683
- ? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
1684
- : undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
1428
+ if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
1429
+ manualFiltering = true;
1430
+ manualGrouping = true;
1431
+ manualPagination = true;
1432
+ manualSorting = true;
1685
1433
  }
1686
- return null;
1687
- }
1688
- function makeRowNumbersColumn({ tableOptions }, order) {
1689
- const id = 'mrt-row-numbers';
1690
- if (order.includes(id) || tableOptions.enableRowNumbers)
1691
- return Object.assign({ Cell: ({ row, staticRowIndex }) => {
1692
- var _a;
1693
- return ((_a = (tableOptions.rowNumberDisplayMode === 'static'
1694
- ? staticRowIndex
1695
- : row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
1696
- }, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
1697
- return null;
1698
- }
1434
+ return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
1435
+ columnFilterDisplayMode,
1436
+ columnResizeDirection,
1437
+ columnResizeMode,
1438
+ createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
1439
+ enableBottomToolbar,
1440
+ enableColumnActions,
1441
+ enableColumnFilters,
1442
+ enableColumnOrdering,
1443
+ enableColumnPinning,
1444
+ enableColumnResizing,
1445
+ enableDensityToggle,
1446
+ enableExpandAll,
1447
+ enableExpanding,
1448
+ enableFilterMatchHighlighting,
1449
+ enableFilters,
1450
+ enableFullScreenToggle,
1451
+ enableGlobalFilter,
1452
+ enableGlobalFilterRankedResults,
1453
+ enableGrouping,
1454
+ enableHiding,
1455
+ enableMultiRowSelection,
1456
+ enableMultiSort,
1457
+ enablePagination,
1458
+ enableRowPinning,
1459
+ enableRowSelection,
1460
+ enableSelectAll,
1461
+ enableSorting,
1462
+ enableStickyHeader,
1463
+ enableTableFooter,
1464
+ enableTableHead,
1465
+ enableToolbarInternalActions,
1466
+ enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode, localization: _localization, manualFiltering,
1467
+ manualGrouping,
1468
+ manualPagination,
1469
+ manualSorting,
1470
+ paginationDisplayMode,
1471
+ positionActionsColumn,
1472
+ positionCreatingRow,
1473
+ positionExpandColumn,
1474
+ positionGlobalFilter,
1475
+ positionPagination,
1476
+ positionToolbarAlertBanner,
1477
+ positionToolbarDropZone,
1478
+ rowNumberDisplayMode,
1479
+ rowPinningDisplayMode,
1480
+ selectAllMode, sortingFns: _sortingFns }, rest);
1481
+ };
1482
+
1699
1483
  const blankColProps = {
1700
1484
  children: null,
1701
1485
  sx: {
1702
- flex: '1 0 auto',
1703
1486
  minWidth: 0,
1704
1487
  p: 0,
1705
1488
  width: 0,
1706
1489
  },
1707
1490
  };
1708
- function makeSpacerColumn({ tableOptions }, order) {
1709
- const id = 'mrt-row-spacer';
1710
- if (order.includes(id)) {
1711
- return Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps(tableOptions, id, undefined, 0)), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
1491
+ const getMRT_RowSpacerColumnDef = (tableOptions) => {
1492
+ if (!showRowSpacerColumn(tableOptions)) {
1493
+ return null;
1712
1494
  }
1713
- return null;
1714
- }
1495
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumnProps({
1496
+ id: 'mrt-row-spacer',
1497
+ size: 0,
1498
+ tableOptions,
1499
+ })), { grow: true }), MRT_DefaultDisplayColumn), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
1500
+ };
1501
+
1502
+ const getMRT_DisplayColumns = (tableOptions) => {
1503
+ return [
1504
+ getMRT_RowNumbersColumnDef(tableOptions),
1505
+ getMRT_RowSelectColumnDef(tableOptions),
1506
+ getMRT_RowExpandColumnDef(tableOptions),
1507
+ getMRT_RowActionsColumnDef(tableOptions),
1508
+ getMRT_RowDragColumnDef(tableOptions),
1509
+ getMRT_RowPinningColumnDef(tableOptions),
1510
+ getMRT_RowSpacerColumnDef(tableOptions),
1511
+ ].filter(Boolean);
1512
+ };
1715
1513
 
1716
1514
  const useMRT_Effects = (table) => {
1717
- const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
1515
+ const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
1718
1516
  const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
1517
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
1719
1518
  const rerender = useReducer(() => ({}), {})[1];
1720
1519
  const isMounted = useRef(false);
1721
1520
  const initialBodyHeight = useRef();
@@ -1749,36 +1548,289 @@ const useMRT_Effects = (table) => {
1749
1548
  if (!enablePagination || isLoading || showSkeletons)
1750
1549
  return;
1751
1550
  const { pageIndex, pageSize } = pagination;
1752
- const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
1753
1551
  const firstVisibleRowIndex = pageIndex * pageSize;
1754
- if (firstVisibleRowIndex > totalRowCount) {
1755
- table.setPageIndex(Math.floor(totalRowCount / pageSize));
1552
+ if (firstVisibleRowIndex >= totalRowCount) {
1553
+ table.setPageIndex(Math.ceil(totalRowCount / pageSize) - 1);
1756
1554
  }
1757
- }, [rowCount, table.getPrePaginationRowModel().rows.length]);
1555
+ }, [totalRowCount]);
1758
1556
  //turn off sort when global filter is looking for ranked results
1759
1557
  const appliedSort = useRef(sorting);
1760
1558
  useEffect(() => {
1761
1559
  if (sorting.length) {
1762
1560
  appliedSort.current = sorting;
1763
1561
  }
1764
- }, [sorting]);
1765
- useEffect(() => {
1766
- if (!getCanRankRows(table))
1767
- return;
1768
- if (globalFilter) {
1769
- table.setSorting([]);
1562
+ }, [sorting]);
1563
+ useEffect(() => {
1564
+ if (!getCanRankRows(table))
1565
+ return;
1566
+ if (globalFilter) {
1567
+ table.setSorting([]);
1568
+ }
1569
+ else {
1570
+ table.setSorting(() => appliedSort.current || []);
1571
+ }
1572
+ }, [globalFilter]);
1573
+ useEffect(() => {
1574
+ if (enableRowPinning && getIsSomeRowsPinned()) {
1575
+ setTimeout(() => {
1576
+ rerender();
1577
+ }, 150);
1578
+ }
1579
+ }, [density]);
1580
+ };
1581
+
1582
+ const useMRT_TableInstance = (_tableOptions) => {
1583
+ 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;
1584
+ const bottomToolbarRef = useRef(null);
1585
+ const editInputRefs = useRef({});
1586
+ const filterInputRefs = useRef({});
1587
+ const searchInputRef = useRef(null);
1588
+ const tableContainerRef = useRef(null);
1589
+ const tableHeadCellRefs = useRef({});
1590
+ const tablePaperRef = useRef(null);
1591
+ const topToolbarRef = useRef(null);
1592
+ const tableHeadRef = useRef(null);
1593
+ const tableFooterRef = useRef(null);
1594
+ const initialState = useMemo(() => {
1595
+ var _a, _b, _c;
1596
+ const initState = (_a = _tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1597
+ initState.columnOrder =
1598
+ (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(Object.assign(Object.assign({}, _tableOptions), { state: Object.assign(Object.assign({}, _tableOptions.initialState), _tableOptions.state) }));
1599
+ initState.globalFilterFn = (_c = _tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1600
+ return initState;
1601
+ }, []);
1602
+ _tableOptions.initialState = initialState;
1603
+ const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
1604
+ const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(_tableOptions.columns).map((col) => {
1605
+ var _a, _b, _c, _d;
1606
+ return ({
1607
+ [getColumnId(col)]: col.filterFn instanceof Function
1608
+ ? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
1609
+ : (_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),
1610
+ });
1611
+ })));
1612
+ const [columnOrder, onColumnOrderChange] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
1613
+ const [columnSizingInfo, onColumnSizingInfoChange] = useState((_c = initialState.columnSizingInfo) !== null && _c !== void 0 ? _c : {});
1614
+ const [density, setDensity] = useState((_d = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _d !== void 0 ? _d : 'comfortable');
1615
+ const [draggingColumn, setDraggingColumn] = useState((_e = initialState.draggingColumn) !== null && _e !== void 0 ? _e : null);
1616
+ const [draggingRow, setDraggingRow] = useState((_f = initialState.draggingRow) !== null && _f !== void 0 ? _f : null);
1617
+ const [editingCell, setEditingCell] = useState((_g = initialState.editingCell) !== null && _g !== void 0 ? _g : null);
1618
+ const [editingRow, setEditingRow] = useState((_h = initialState.editingRow) !== null && _h !== void 0 ? _h : null);
1619
+ const [globalFilterFn, setGlobalFilterFn] = useState((_j = initialState.globalFilterFn) !== null && _j !== void 0 ? _j : 'fuzzy');
1620
+ const [grouping, onGroupingChange] = useState((_k = initialState.grouping) !== null && _k !== void 0 ? _k : []);
1621
+ const [hoveredColumn, setHoveredColumn] = useState((_l = initialState.hoveredColumn) !== null && _l !== void 0 ? _l : null);
1622
+ const [hoveredRow, setHoveredRow] = useState((_m = initialState.hoveredRow) !== null && _m !== void 0 ? _m : null);
1623
+ const [isFullScreen, setIsFullScreen] = useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _o !== void 0 ? _o : false);
1624
+ const [pagination, onPaginationChange] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _p !== void 0 ? _p : { pageIndex: 0, pageSize: 10 });
1625
+ const [showAlertBanner, setShowAlertBanner] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _q !== void 0 ? _q : false);
1626
+ const [showColumnFilters, setShowColumnFilters] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _r !== void 0 ? _r : false);
1627
+ const [showGlobalFilter, setShowGlobalFilter] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _s !== void 0 ? _s : false);
1628
+ const [showToolbarDropZone, setShowToolbarDropZone] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _t !== void 0 ? _t : false);
1629
+ _tableOptions.state = Object.assign({ columnFilterFns,
1630
+ columnOrder,
1631
+ columnSizingInfo,
1632
+ creatingRow,
1633
+ density,
1634
+ draggingColumn,
1635
+ draggingRow,
1636
+ editingCell,
1637
+ editingRow,
1638
+ globalFilterFn,
1639
+ grouping,
1640
+ hoveredColumn,
1641
+ hoveredRow,
1642
+ isFullScreen,
1643
+ pagination,
1644
+ showAlertBanner,
1645
+ showColumnFilters,
1646
+ showGlobalFilter,
1647
+ showToolbarDropZone }, _tableOptions.state);
1648
+ const tableOptions = _tableOptions;
1649
+ //don't recompute columnDefs while resizing column or dragging column/row
1650
+ const columnDefsRef = useRef([]);
1651
+ tableOptions.columns =
1652
+ tableOptions.state.columnSizingInfo.isResizingColumn ||
1653
+ tableOptions.state.draggingColumn ||
1654
+ tableOptions.state.draggingRow
1655
+ ? columnDefsRef.current
1656
+ : prepareColumns({
1657
+ columnDefs: [
1658
+ ...getMRT_DisplayColumns(tableOptions),
1659
+ ...tableOptions.columns,
1660
+ ],
1661
+ tableOptions,
1662
+ });
1663
+ columnDefsRef.current = tableOptions.columns;
1664
+ tableOptions.data = useMemo(() => (tableOptions.state.isLoading || tableOptions.state.showSkeletons) &&
1665
+ !tableOptions.data.length
1666
+ ? [
1667
+ ...Array(Math.min(tableOptions.state.pagination.pageSize, 20)).fill(null),
1668
+ ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
1669
+ [getColumnId(col)]: null,
1670
+ }))))
1671
+ : tableOptions.data, [
1672
+ tableOptions.data,
1673
+ tableOptions.state.isLoading,
1674
+ tableOptions.state.showSkeletons,
1675
+ ]);
1676
+ //@ts-ignore
1677
+ const table = useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
1678
+ ? getExpandedRowModel()
1679
+ : undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
1680
+ ? getFacetedMinMaxValues()
1681
+ : undefined, getFacetedRowModel: tableOptions.enableFacetedValues
1682
+ ? getFacetedRowModel()
1683
+ : undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
1684
+ ? getFacetedUniqueValues()
1685
+ : undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
1686
+ tableOptions.enableGlobalFilter ||
1687
+ tableOptions.enableFilters
1688
+ ? getFilteredRowModel()
1689
+ : undefined, getGroupedRowModel: tableOptions.enableGrouping
1690
+ ? getGroupedRowModel()
1691
+ : undefined, getPaginationRowModel: tableOptions.enablePagination
1692
+ ? getPaginationRowModel()
1693
+ : undefined, getSortedRowModel: tableOptions.enableSorting
1694
+ ? getSortedRowModel()
1695
+ : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, onColumnOrderChange,
1696
+ onColumnSizingInfoChange,
1697
+ onGroupingChange,
1698
+ onPaginationChange }, tableOptions), { globalFilterFn: (_u = tableOptions.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1699
+ //@ts-ignore
1700
+ table.refs = {
1701
+ //@ts-ignore
1702
+ bottomToolbarRef,
1703
+ editInputRefs,
1704
+ filterInputRefs,
1705
+ //@ts-ignore
1706
+ searchInputRef,
1707
+ //@ts-ignore
1708
+ tableContainerRef,
1709
+ //@ts-ignore
1710
+ tableFooterRef,
1711
+ tableHeadCellRefs,
1712
+ //@ts-ignore
1713
+ tableHeadRef,
1714
+ //@ts-ignore
1715
+ tablePaperRef,
1716
+ //@ts-ignore
1717
+ topToolbarRef,
1718
+ };
1719
+ table.setCreatingRow = (row) => {
1720
+ var _a, _b;
1721
+ let _row = row;
1722
+ if (row === true) {
1723
+ _row = createRow(table);
1724
+ }
1725
+ (_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
1726
+ };
1727
+ table.setColumnFilterFns =
1728
+ (_v = tableOptions.onColumnFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns;
1729
+ table.setDensity = (_w = tableOptions.onDensityChange) !== null && _w !== void 0 ? _w : setDensity;
1730
+ table.setDraggingColumn =
1731
+ (_x = tableOptions.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn;
1732
+ table.setDraggingRow = (_y = tableOptions.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow;
1733
+ table.setEditingCell = (_z = tableOptions.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell;
1734
+ table.setEditingRow = (_0 = tableOptions.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow;
1735
+ table.setGlobalFilterFn =
1736
+ (_1 = tableOptions.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn;
1737
+ table.setHoveredColumn =
1738
+ (_2 = tableOptions.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn;
1739
+ table.setHoveredRow = (_3 = tableOptions.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow;
1740
+ table.setIsFullScreen = (_4 = tableOptions.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen;
1741
+ table.setShowAlertBanner =
1742
+ (_5 = tableOptions.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner;
1743
+ table.setShowColumnFilters =
1744
+ (_6 = tableOptions.onShowColumnFiltersChange) !== null && _6 !== void 0 ? _6 : setShowColumnFilters;
1745
+ table.setShowGlobalFilter =
1746
+ (_7 = tableOptions.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter;
1747
+ table.setShowToolbarDropZone =
1748
+ (_8 = tableOptions.onShowToolbarDropZoneChange) !== null && _8 !== void 0 ? _8 : setShowToolbarDropZone;
1749
+ useMRT_Effects(table);
1750
+ return table;
1751
+ };
1752
+
1753
+ const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
1754
+
1755
+ const extraIndexRangeExtractor = (range, draggingIndex) => {
1756
+ const newIndexes = defaultRangeExtractor(range);
1757
+ if (draggingIndex === undefined)
1758
+ return newIndexes;
1759
+ if (draggingIndex >= 0 &&
1760
+ draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
1761
+ newIndexes.unshift(draggingIndex);
1762
+ }
1763
+ if (draggingIndex >= 0 && draggingIndex > range.endIndex + range.overscan) {
1764
+ newIndexes.push(draggingIndex);
1765
+ }
1766
+ return newIndexes;
1767
+ };
1768
+
1769
+ const useMRT_ColumnVirtualizer = (table) => {
1770
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1771
+ const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
1772
+ const { columnPinning, columnVisibility, draggingColumn } = getState();
1773
+ const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
1774
+ table,
1775
+ });
1776
+ const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(() => enableColumnVirtualization && enableColumnPinning
1777
+ ? [
1778
+ table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
1779
+ table
1780
+ .getRightLeafColumns()
1781
+ .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
1782
+ .sort((a, b) => a - b),
1783
+ ]
1784
+ : [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
1785
+ //get first 16 column widths and average them if calc is needed
1786
+ const averageColumnWidth = useMemo(() => {
1787
+ var _a, _b, _c, _d;
1788
+ if (!enableColumnVirtualization || (columnVirtualizerProps === null || columnVirtualizerProps === void 0 ? void 0 : columnVirtualizerProps.estimateSize)) {
1789
+ return 0;
1770
1790
  }
1771
- else {
1772
- table.setSorting(() => appliedSort.current || []);
1791
+ const columnsWidths = (_d = (_c = (_b = (_a = table
1792
+ .getRowModel()
1793
+ .rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
1794
+ return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
1795
+ }, [table.getRowModel().rows, columnPinning, columnVisibility]);
1796
+ const draggingColumnIndex = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
1797
+ ? table
1798
+ .getVisibleLeafColumns()
1799
+ .findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
1800
+ : undefined;
1801
+ const columnVirtualizer = enableColumnVirtualization
1802
+ ? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
1803
+ const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
1804
+ return [
1805
+ ...new Set([
1806
+ ...leftPinnedIndexes,
1807
+ ...newIndexes,
1808
+ ...rightPinnedIndexes,
1809
+ ]),
1810
+ ];
1811
+ }, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps))
1812
+ : undefined;
1813
+ if (columnVirtualizer) {
1814
+ const virtualColumns = columnVirtualizer.getVirtualItems();
1815
+ columnVirtualizer.virtualColumns = virtualColumns;
1816
+ if (virtualColumns.length) {
1817
+ columnVirtualizer.virtualPaddingLeft =
1818
+ ((_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0) -
1819
+ ((_d = (_c = virtualColumns[leftPinnedIndexes.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
1820
+ columnVirtualizer.virtualPaddingRight =
1821
+ columnVirtualizer.getTotalSize() -
1822
+ ((_f = (_e = virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : 0) -
1823
+ (rightPinnedIndexes.length
1824
+ ? columnVirtualizer.getTotalSize() -
1825
+ ((_h = (_g = virtualColumns[virtualColumns.length - rightPinnedIndexes.length]) === null || _g === void 0 ? void 0 : _g.start) !== null && _h !== void 0 ? _h : 0)
1826
+ : 0);
1773
1827
  }
1774
- }, [globalFilter]);
1775
- useEffect(() => {
1776
- if (enableRowPinning && getIsSomeRowsPinned()) {
1777
- setTimeout(() => {
1778
- rerender();
1779
- }, 150);
1828
+ if (columnVirtualizerInstanceRef) {
1829
+ //@ts-ignore
1830
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
1780
1831
  }
1781
- }, [density]);
1832
+ }
1833
+ return columnVirtualizer;
1782
1834
  };
1783
1835
 
1784
1836
  const useMRT_RowVirtualizer = (table, rows) => {
@@ -1814,23 +1866,9 @@ const useMRT_RowVirtualizer = (table, rows) => {
1814
1866
  return rowVirtualizer;
1815
1867
  };
1816
1868
 
1817
- const fuzzy$1 = (rowA, rowB, columnId) => {
1818
- let dir = 0;
1819
- if (rowA.columnFiltersMeta[columnId]) {
1820
- dir = compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
1821
- }
1822
- // Provide a fallback for when the item ranks are equal
1823
- return dir === 0
1824
- ? sortingFns.alphanumeric(rowA, rowB, columnId)
1825
- : dir;
1826
- };
1827
- const MRT_SortingFns = Object.assign(Object.assign({}, sortingFns), { fuzzy: fuzzy$1 });
1828
- const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
1829
- Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
1830
-
1831
1869
  const useMRT_Rows = (table, pinnedRowIds = []) => {
1832
- const { getBottomRows, getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { enableGlobalFilterRankedResults, enablePagination, enableRowPinning, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, rowPinningDisplayMode, }, } = table;
1833
- const { expanded, globalFilter, pagination, rowPinning, sorting } = getState();
1870
+ const { getBottomRows, getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enableGlobalFilterRankedResults, enablePagination, enableRowPinning, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, positionCreatingRow, rowPinningDisplayMode, }, } = table;
1871
+ const { creatingRow, expanded, globalFilter, pagination, rowPinning, sorting, } = getState();
1834
1872
  const shouldRankRows = useMemo(() => getCanRankRows(table) &&
1835
1873
  !Object.values(sorting).some(Boolean) &&
1836
1874
  globalFilter, [
@@ -1851,526 +1889,541 @@ const useMRT_Rows = (table, pinnedRowIds = []) => {
1851
1889
  ? getRowModel().rows
1852
1890
  : getCenterRows();
1853
1891
  }
1854
- else {
1855
- rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
1856
- if (enablePagination && !manualPagination) {
1857
- const start = pagination.pageIndex * pagination.pageSize;
1858
- rows = rows.slice(start, start + pagination.pageSize);
1859
- }
1892
+ else {
1893
+ rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
1894
+ if (enablePagination && !manualPagination) {
1895
+ const start = pagination.pageIndex * pagination.pageSize;
1896
+ rows = rows.slice(start, start + pagination.pageSize);
1897
+ }
1898
+ }
1899
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
1900
+ rows = [
1901
+ ...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
1902
+ ...rows,
1903
+ ...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
1904
+ ];
1905
+ }
1906
+ if (positionCreatingRow !== undefined &&
1907
+ creatingRow &&
1908
+ createDisplayMode === 'row') {
1909
+ const creatingRowIndex = !isNaN(+positionCreatingRow)
1910
+ ? +positionCreatingRow
1911
+ : positionCreatingRow === 'top'
1912
+ ? 0
1913
+ : rows.length;
1914
+ rows = [
1915
+ ...rows.slice(0, creatingRowIndex),
1916
+ creatingRow,
1917
+ ...rows.slice(creatingRowIndex),
1918
+ ];
1919
+ }
1920
+ return rows;
1921
+ }, [
1922
+ creatingRow,
1923
+ pagination.pageIndex,
1924
+ pagination.pageSize,
1925
+ positionCreatingRow,
1926
+ rowPinning,
1927
+ shouldRankRows ? getPrePaginationRowModel().rows : getRowModel().rows,
1928
+ shouldRankRows,
1929
+ ]);
1930
+ return rows;
1931
+ };
1932
+
1933
+ const allowedTypes = ['string', 'number'];
1934
+ const MRT_TableBodyCellValue = ({ cell, rowRef, staticRowIndex, table, }) => {
1935
+ var _a, _b, _c;
1936
+ const { getState, options: { enableFilterMatchHighlighting }, } = table;
1937
+ const { column, row } = cell;
1938
+ const { columnDef } = column;
1939
+ const { globalFilter, globalFilterFn } = getState();
1940
+ const filterValue = column.getFilterValue();
1941
+ let renderedCellValue = cell.getIsAggregated() && columnDef.AggregatedCell
1942
+ ? columnDef.AggregatedCell({
1943
+ cell,
1944
+ column,
1945
+ row,
1946
+ table,
1947
+ })
1948
+ : row.getIsGrouped() && !cell.getIsGrouped()
1949
+ ? null
1950
+ : cell.getIsGrouped() && columnDef.GroupedCell
1951
+ ? columnDef.GroupedCell({
1952
+ cell,
1953
+ column,
1954
+ row,
1955
+ table,
1956
+ })
1957
+ : undefined;
1958
+ const isGroupedValue = renderedCellValue !== undefined;
1959
+ if (!isGroupedValue) {
1960
+ renderedCellValue = cell.renderValue();
1961
+ }
1962
+ if (enableFilterMatchHighlighting &&
1963
+ columnDef.enableFilterMatchHighlighting !== false &&
1964
+ String(renderedCellValue) &&
1965
+ allowedTypes.includes(typeof renderedCellValue) &&
1966
+ ((filterValue &&
1967
+ allowedTypes.includes(typeof filterValue) &&
1968
+ ['autocomplete', 'text'].includes(columnDef.filterVariant)) ||
1969
+ (globalFilter &&
1970
+ allowedTypes.includes(typeof globalFilter) &&
1971
+ column.getCanGlobalFilter()))) {
1972
+ const chunks = highlightWords === null || highlightWords === void 0 ? void 0 : highlightWords({
1973
+ matchExactly: (filterValue ? columnDef._filterFn : globalFilterFn) !== 'fuzzy',
1974
+ query: ((_a = filterValue !== null && filterValue !== void 0 ? filterValue : globalFilter) !== null && _a !== void 0 ? _a : '').toString(),
1975
+ text: renderedCellValue === null || renderedCellValue === void 0 ? void 0 : renderedCellValue.toString(),
1976
+ });
1977
+ 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)) {
1978
+ 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
1979
+ ? {
1980
+ backgroundColor: (theme) => getMRTTheme(table, theme).matchHighlightColor,
1981
+ borderRadius: '2px',
1982
+ color: (theme) => theme.palette.mode === 'dark'
1983
+ ? theme.palette.common.white
1984
+ : theme.palette.common.black,
1985
+ padding: '2px 1px',
1986
+ }
1987
+ : undefined, children: text }, key)))) !== null && _c !== void 0 ? _c : renderedCellValue }));
1988
+ }
1989
+ }
1990
+ if (columnDef.Cell && !isGroupedValue) {
1991
+ renderedCellValue = columnDef.Cell({
1992
+ cell,
1993
+ column,
1994
+ renderedCellValue,
1995
+ row,
1996
+ rowRef,
1997
+ staticRowIndex,
1998
+ table,
1999
+ });
2000
+ }
2001
+ return renderedCellValue;
2002
+ };
2003
+
2004
+ const MRT_CopyButton = (_a) => {
2005
+ var _b;
2006
+ var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
2007
+ const { options: { localization, muiCopyButtonProps }, } = table;
2008
+ const { column, row } = cell;
2009
+ const { columnDef } = column;
2010
+ const [copied, setCopied] = useState(false);
2011
+ const handleCopy = (event, text) => {
2012
+ event.stopPropagation();
2013
+ navigator.clipboard.writeText(text);
2014
+ setCopied(true);
2015
+ setTimeout(() => setCopied(false), 4000);
2016
+ };
2017
+ const buttonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCopyButtonProps, {
2018
+ cell,
2019
+ column,
2020
+ row,
2021
+ table,
2022
+ })), parseFromValuesOrFunc(columnDef.muiCopyButtonProps, {
2023
+ cell,
2024
+ column,
2025
+ row,
2026
+ table,
2027
+ })), rest);
2028
+ 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', textAlign: 'inherit', textTransform: 'inherit' }, parseFromValuesOrFunc(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx, theme))), title: undefined })) })));
2029
+ };
2030
+
2031
+ const MRT_EditCellTextField = (_a) => {
2032
+ var _b, _c;
2033
+ var { cell, table } = _a, rest = __rest(_a, ["cell", "table"]);
2034
+ const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
2035
+ const { column, row } = cell;
2036
+ const { columnDef } = column;
2037
+ const { creatingRow, editingRow } = getState();
2038
+ const { editSelectOptions } = columnDef;
2039
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
2040
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
2041
+ const isSelectEdit = columnDef.editVariant === 'select';
2042
+ const [value, setValue] = useState(() => cell.getValue());
2043
+ const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
2044
+ cell,
2045
+ column,
2046
+ row,
2047
+ table,
2048
+ })), parseFromValuesOrFunc(columnDef.muiEditTextFieldProps, {
2049
+ cell,
2050
+ column,
2051
+ row,
2052
+ table,
2053
+ })), rest);
2054
+ const selectOptions = parseFromValuesOrFunc(editSelectOptions, {
2055
+ cell,
2056
+ column,
2057
+ row,
2058
+ table,
2059
+ });
2060
+ const saveInputValueToRowCache = (newValue) => {
2061
+ //@ts-ignore
2062
+ row._valuesCache[column.id] = newValue;
2063
+ if (isCreating) {
2064
+ setCreatingRow(row);
2065
+ }
2066
+ else if (isEditing) {
2067
+ setEditingRow(row);
1860
2068
  }
1861
- if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
1862
- rows = [
1863
- ...getTopRows().filter((row) => !pinnedRowIds.includes(row.id)),
1864
- ...rows,
1865
- ...getBottomRows().filter((row) => !pinnedRowIds.includes(row.id)),
1866
- ];
2069
+ };
2070
+ const handleChange = (event) => {
2071
+ var _a;
2072
+ (_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2073
+ setValue(event.target.value);
2074
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) {
2075
+ saveInputValueToRowCache(event.target.value);
1867
2076
  }
1868
- return rows;
1869
- }, [
1870
- shouldRankRows,
1871
- shouldRankRows ? getPrePaginationRowModel().rows : getRowModel().rows,
1872
- pagination.pageIndex,
1873
- pagination.pageSize,
1874
- rowPinning,
1875
- ]);
1876
- return rows;
2077
+ };
2078
+ const handleBlur = (event) => {
2079
+ var _a;
2080
+ (_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2081
+ saveInputValueToRowCache(value);
2082
+ setEditingCell(null);
2083
+ };
2084
+ const handleEnterKeyDown = (event) => {
2085
+ var _a, _b;
2086
+ (_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
2087
+ if (event.key === 'Enter' && !event.shiftKey) {
2088
+ (_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
2089
+ }
2090
+ };
2091
+ if (columnDef.Edit) {
2092
+ return jsx(Fragment, { children: (_b = columnDef.Edit) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table }) });
2093
+ }
2094
+ return (jsx(TextField, Object.assign({ disabled: parseFromValuesOrFunc(columnDef.enableEditing, row) === false, fullWidth: true, inputRef: (inputRef) => {
2095
+ if (inputRef) {
2096
+ editInputRefs.current[column.id] = inputRef;
2097
+ if (textFieldProps.inputRef) {
2098
+ textFieldProps.inputRef = inputRef;
2099
+ }
2100
+ }
2101
+ }, label: ['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
2102
+ ? columnDef.header
2103
+ : undefined, margin: "none", name: column.id, placeholder: !['custom', 'modal'].includes((isCreating ? createDisplayMode : editDisplayMode))
2104
+ ? columnDef.header
2105
+ : 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'
2106
+ ? { disableUnderline: editDisplayMode === 'table' }
2107
+ : {})), textFieldProps.InputProps), { sx: (theme) => {
2108
+ var _a;
2109
+ 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)));
2110
+ } }), inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onBlur: handleBlur, onChange: handleChange, onClick: (e) => {
2111
+ var _a;
2112
+ e.stopPropagation();
2113
+ (_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
2114
+ }, onKeyDown: handleEnterKeyDown, children: (_c = textFieldProps.children) !== null && _c !== void 0 ? _c : selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.map((option) => {
2115
+ const { label, value } = getValueAndLabel(option);
2116
+ return (jsx(MenuItem, { sx: {
2117
+ alignItems: 'center',
2118
+ display: 'flex',
2119
+ gap: '0.5rem',
2120
+ m: 0,
2121
+ }, value: value, children: label }, value));
2122
+ }) })));
1877
2123
  };
1878
2124
 
1879
- const useMRT_TableInstance = (tableOptions) => {
1880
- 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;
1881
- const bottomToolbarRef = useRef(null);
1882
- const editInputRefs = useRef({});
1883
- const filterInputRefs = useRef({});
1884
- const searchInputRef = useRef(null);
1885
- const tableContainerRef = useRef(null);
1886
- const tableHeadCellRefs = useRef({});
1887
- const tablePaperRef = useRef(null);
1888
- const topToolbarRef = useRef(null);
1889
- const tableHeadRef = useRef(null);
1890
- const tableFooterRef = useRef(null);
1891
- const initialState = useMemo(() => {
1892
- var _a, _b, _c;
1893
- const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
1894
- initState.columnOrder =
1895
- (_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
1896
- initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
1897
- return initState;
1898
- }, []);
1899
- const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
1900
- const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
1901
- var _a, _b, _c, _d;
1902
- return ({
1903
- [getColumnId(col)]: col.filterFn instanceof Function
1904
- ? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
1905
- : (_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),
1906
- });
1907
- })));
1908
- const [columnOrder, setColumnOrder] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
1909
- const [density, setDensity] = useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
1910
- const [draggingColumn, setDraggingColumn] = useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
1911
- const [draggingRow, setDraggingRow] = useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
1912
- const [editingCell, setEditingCell] = useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
1913
- const [editingRow, setEditingRow] = useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
1914
- const [globalFilterFn, setGlobalFilterFn] = useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
1915
- const [grouping, setGrouping] = useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
1916
- const [hoveredColumn, setHoveredColumn] = useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
1917
- const [hoveredRow, setHoveredRow] = useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
1918
- const [isFullScreen, setIsFullScreen] = useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
1919
- const [showAlertBanner, setShowAlertBanner] = useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
1920
- const [showColumnFilters, setShowColumnFilters] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
1921
- const [showGlobalFilter, setShowGlobalFilter] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
1922
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
1923
- const displayColumns = useMRT_DisplayColumns({
1924
- columnOrder,
1925
- creatingRow,
1926
- grouping,
1927
- tableOptions,
2125
+ const MRT_TableBodyCell = (_a) => {
2126
+ var _b, _c, _d, _e, _f;
2127
+ var { cell, measureElement, numRows, rowRef, staticRowIndex, table, virtualColumnIndex } = _a, rest = __rest(_a, ["cell", "measureElement", "numRows", "rowRef", "staticRowIndex", "table", "virtualColumnIndex"]);
2128
+ const theme = useTheme();
2129
+ const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, layoutMode, muiSkeletonProps, muiTableBodyCellProps, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
2130
+ const { columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
2131
+ const { column, row } = cell;
2132
+ const { columnDef } = column;
2133
+ const { columnDefType } = columnDef;
2134
+ const args = { cell, column, row, table };
2135
+ const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, args)), rest);
2136
+ const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
2137
+ cell,
2138
+ column,
2139
+ row,
2140
+ table,
1928
2141
  });
1929
- const columnDefs = useMemo(() => {
1930
- var _a, _b, _c;
1931
- return prepareColumns({
1932
- aggregationFns: tableOptions.aggregationFns,
1933
- columnDefs: [...displayColumns, ...tableOptions.columns],
1934
- columnFilterFns: (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns,
1935
- defaultDisplayColumn: (_c = tableOptions.defaultDisplayColumn) !== null && _c !== void 0 ? _c : {},
1936
- filterFns: tableOptions.filterFns,
1937
- sortingFns: tableOptions.sortingFns,
1938
- });
1939
- }, [
1940
- columnFilterFns,
1941
- displayColumns,
1942
- tableOptions.columns,
1943
- (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnFilterFns,
1944
- ]);
1945
- const data = useMemo(() => {
1946
- var _a, _b, _c, _d, _e;
1947
- return (((_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
1948
- !tableOptions.data.length
1949
- ? [
1950
- ...Array(((_d = (_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.pagination) === null || _d === void 0 ? void 0 : _d.pageSize) ||
1951
- ((_e = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) === null || _e === void 0 ? void 0 : _e.pageSize) ||
1952
- 10).fill(null),
1953
- ].map(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => ({
1954
- [getColumnId(col)]: null,
1955
- }))))
1956
- : tableOptions.data;
2142
+ const { draggingBorderColor } = getMRTTheme(table, theme);
2143
+ const [skeletonWidth, setSkeletonWidth] = useState(100);
2144
+ useEffect(() => {
2145
+ if ((!isLoading && !showSkeletons) || skeletonWidth !== 100)
2146
+ return;
2147
+ const size = column.getSize();
2148
+ setSkeletonWidth(columnDefType === 'display'
2149
+ ? size / 2
2150
+ : Math.round(Math.random() * (size - size / 3) + size / 3));
2151
+ }, [isLoading, showSkeletons]);
2152
+ const draggingBorders = useMemo(() => {
2153
+ const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
2154
+ const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
2155
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
2156
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
2157
+ const isFirstColumn = getIsFirstColumn(column, table);
2158
+ const isLastColumn = getIsLastColumn(column, table);
2159
+ const isLastRow = numRows && staticRowIndex === numRows - 1;
2160
+ const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
2161
+ const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
2162
+ const borderStyle = showResizeBorder
2163
+ ? `2px solid ${draggingBorderColor} !important`
2164
+ : isDraggingColumn || isDraggingRow
2165
+ ? `1px dashed ${theme.palette.grey[500]} !important`
2166
+ : isHoveredColumn || isHoveredRow || isResizingColumn
2167
+ ? `2px dashed ${draggingBorderColor} !important`
2168
+ : undefined;
2169
+ if (showResizeBorder) {
2170
+ return columnResizeDirection === 'ltr'
2171
+ ? { borderRight: borderStyle }
2172
+ : { borderLeft: borderStyle };
2173
+ }
2174
+ return borderStyle
2175
+ ? {
2176
+ borderBottom: isDraggingRow || isHoveredRow || (isLastRow && !isResizingColumn)
2177
+ ? borderStyle
2178
+ : undefined,
2179
+ borderLeft: isDraggingColumn ||
2180
+ isHoveredColumn ||
2181
+ ((isDraggingRow || isHoveredRow) && isFirstColumn)
2182
+ ? borderStyle
2183
+ : undefined,
2184
+ borderRight: isDraggingColumn ||
2185
+ isHoveredColumn ||
2186
+ ((isDraggingRow || isHoveredRow) && isLastColumn)
2187
+ ? borderStyle
2188
+ : undefined,
2189
+ borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
2190
+ }
2191
+ : undefined;
1957
2192
  }, [
1958
- tableOptions.data,
1959
- (_u = tableOptions.state) === null || _u === void 0 ? void 0 : _u.isLoading,
1960
- (_v = tableOptions.state) === null || _v === void 0 ? void 0 : _v.showSkeletons,
2193
+ columnSizingInfo.isResizingColumn,
2194
+ draggingColumn,
2195
+ draggingRow,
2196
+ hoveredColumn,
2197
+ hoveredRow,
2198
+ staticRowIndex,
1961
2199
  ]);
1962
- //@ts-ignore
1963
- const table = useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: tableOptions.enableExpanding || tableOptions.enableGrouping
1964
- ? getExpandedRowModel()
1965
- : undefined, getFacetedMinMaxValues: tableOptions.enableFacetedValues
1966
- ? getFacetedMinMaxValues()
1967
- : undefined, getFacetedRowModel: tableOptions.enableFacetedValues
1968
- ? getFacetedRowModel()
1969
- : undefined, getFacetedUniqueValues: tableOptions.enableFacetedValues
1970
- ? getFacetedUniqueValues()
1971
- : undefined, getFilteredRowModel: tableOptions.enableColumnFilters ||
1972
- tableOptions.enableGlobalFilter ||
1973
- tableOptions.enableFilters
1974
- ? getFilteredRowModel()
1975
- : undefined, getGroupedRowModel: tableOptions.enableGrouping
1976
- ? getGroupedRowModel()
1977
- : undefined, getPaginationRowModel: tableOptions.enablePagination
1978
- ? getPaginationRowModel()
1979
- : undefined, getSortedRowModel: tableOptions.enableSorting
1980
- ? getSortedRowModel()
1981
- : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping }, tableOptions), {
1982
- //@ts-ignore
1983
- columns: columnDefs, data, globalFilterFn: (_w = tableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'], initialState, state: Object.assign({ columnFilterFns,
1984
- columnOrder,
1985
- creatingRow,
1986
- density,
1987
- draggingColumn,
1988
- draggingRow,
1989
- editingCell,
1990
- editingRow,
1991
- globalFilterFn,
1992
- grouping,
1993
- hoveredColumn,
1994
- hoveredRow,
1995
- isFullScreen,
1996
- showAlertBanner,
1997
- showColumnFilters,
1998
- showGlobalFilter,
1999
- showToolbarDropZone }, tableOptions.state) }));
2000
- // @ts-ignore
2001
- table.refs = {
2002
- // @ts-ignore
2003
- bottomToolbarRef,
2004
- editInputRefs,
2005
- filterInputRefs,
2006
- // @ts-ignore
2007
- searchInputRef,
2008
- // @ts-ignore
2009
- tableContainerRef,
2010
- // @ts-ignore
2011
- tableFooterRef,
2012
- tableHeadCellRefs,
2013
- // @ts-ignore
2014
- tableHeadRef,
2015
- // @ts-ignore
2016
- tablePaperRef,
2017
- // @ts-ignore
2018
- topToolbarRef,
2200
+ const isEditable = !cell.getIsPlaceholder() &&
2201
+ parseFromValuesOrFunc(enableEditing, row) &&
2202
+ parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
2203
+ const isEditing = isEditable &&
2204
+ !['custom', 'modal'].includes(editDisplayMode) &&
2205
+ (editDisplayMode === 'table' ||
2206
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
2207
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
2208
+ !row.getIsGrouped();
2209
+ const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
2210
+ const handleDoubleClick = (event) => {
2211
+ var _a;
2212
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDoubleClick) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2213
+ if (isEditable && editDisplayMode === 'cell') {
2214
+ setEditingCell(cell);
2215
+ queueMicrotask(() => {
2216
+ var _a;
2217
+ const textField = editInputRefs.current[column.id];
2218
+ if (textField) {
2219
+ textField.focus();
2220
+ (_a = textField.select) === null || _a === void 0 ? void 0 : _a.call(textField);
2221
+ }
2222
+ });
2223
+ }
2019
2224
  };
2020
- const setCreatingRow = (row) => {
2021
- var _a, _b;
2022
- let _row = row;
2023
- if (row === true) {
2024
- _row = createRow(table);
2225
+ const handleDragEnter = (e) => {
2226
+ var _a;
2227
+ (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
2228
+ if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
2229
+ setHoveredColumn(null);
2230
+ }
2231
+ if (enableColumnOrdering && draggingColumn) {
2232
+ setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2025
2233
  }
2026
- (_b = (_a = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(tableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
2027
2234
  };
2028
- table.setCreatingRow = setCreatingRow;
2029
- table.setColumnFilterFns =
2030
- (_x = tableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
2031
- table.setDensity = (_y = tableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
2032
- table.setDraggingColumn =
2033
- (_z = tableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
2034
- table.setDraggingRow = (_0 = tableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
2035
- table.setEditingCell = (_1 = tableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
2036
- table.setEditingRow = (_2 = tableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
2037
- table.setGlobalFilterFn =
2038
- (_3 = tableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
2039
- table.setHoveredColumn =
2040
- (_4 = tableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
2041
- table.setHoveredRow = (_5 = tableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
2042
- table.setIsFullScreen = (_6 = tableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
2043
- table.setShowAlertBanner =
2044
- (_7 = tableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
2045
- table.setShowColumnFilters =
2046
- (_8 = tableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
2047
- table.setShowGlobalFilter =
2048
- (_9 = tableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
2049
- table.setShowToolbarDropZone =
2050
- (_10 = tableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
2051
- useMRT_Effects(table);
2052
- return table;
2053
- };
2054
-
2055
- const MRT_AggregationFns = Object.assign({}, aggregationFns);
2056
-
2057
- const fuzzy = (row, columnId, filterValue, addMeta) => {
2058
- const itemRank = rankItem(row.getValue(columnId), filterValue, {
2059
- threshold: rankings.MATCHES,
2060
- });
2061
- addMeta(itemRank);
2062
- return itemRank.passed;
2063
- };
2064
- fuzzy.autoRemove = (val) => !val;
2065
- const contains = (row, id, filterValue) => row
2066
- .getValue(id)
2067
- .toString()
2068
- .toLowerCase()
2069
- .trim()
2070
- .includes(filterValue.toString().toLowerCase().trim());
2071
- contains.autoRemove = (val) => !val;
2072
- const startsWith = (row, id, filterValue) => row
2073
- .getValue(id)
2074
- .toString()
2075
- .toLowerCase()
2076
- .trim()
2077
- .startsWith(filterValue.toString().toLowerCase().trim());
2078
- startsWith.autoRemove = (val) => !val;
2079
- const endsWith = (row, id, filterValue) => row
2080
- .getValue(id)
2081
- .toString()
2082
- .toLowerCase()
2083
- .trim()
2084
- .endsWith(filterValue.toString().toLowerCase().trim());
2085
- endsWith.autoRemove = (val) => !val;
2086
- const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
2087
- (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
2088
- equals.autoRemove = (val) => !val;
2089
- const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
2090
- filterValue.toString().toLowerCase().trim();
2091
- notEquals.autoRemove = (val) => !val;
2092
- const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
2093
- ? +row.getValue(id) > +filterValue
2094
- : row.getValue(id).toString().toLowerCase().trim() >
2095
- (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
2096
- greaterThan.autoRemove = (val) => !val;
2097
- const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
2098
- greaterThanOrEqualTo.autoRemove = (val) => !val;
2099
- const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
2100
- ? +row.getValue(id) < +filterValue
2101
- : row.getValue(id).toString().toLowerCase().trim() <
2102
- (filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
2103
- lessThan.autoRemove = (val) => !val;
2104
- const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
2105
- lessThanOrEqualTo.autoRemove = (val) => !val;
2106
- const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
2107
- greaterThan(row, id, filterValues[0])) &&
2108
- ((!isNaN(+filterValues[0]) &&
2109
- !isNaN(+filterValues[1]) &&
2110
- +filterValues[0] > +filterValues[1]) ||
2111
- ['', undefined].includes(filterValues[1]) ||
2112
- lessThan(row, id, filterValues[1]));
2113
- between.autoRemove = (val) => !val;
2114
- const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
2115
- greaterThanOrEqualTo(row, id, filterValues[0])) &&
2116
- ((!isNaN(+filterValues[0]) &&
2117
- !isNaN(+filterValues[1]) &&
2118
- +filterValues[0] > +filterValues[1]) ||
2119
- ['', undefined].includes(filterValues[1]) ||
2120
- lessThanOrEqualTo(row, id, filterValues[1]));
2121
- betweenInclusive.autoRemove = (val) => !val;
2122
- const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
2123
- empty.autoRemove = (val) => !val;
2124
- const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
2125
- notEmpty.autoRemove = (val) => !val;
2126
- const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
2127
- betweenInclusive,
2128
- contains,
2129
- empty,
2130
- endsWith,
2131
- equals,
2132
- fuzzy,
2133
- greaterThan,
2134
- greaterThanOrEqualTo,
2135
- lessThan,
2136
- lessThanOrEqualTo,
2137
- notEmpty,
2138
- notEquals,
2139
- startsWith });
2140
-
2141
- const MRT_Default_Icons = {
2142
- ArrowDownwardIcon,
2143
- ArrowRightIcon,
2144
- CancelIcon,
2145
- ChevronLeftIcon,
2146
- ChevronRightIcon,
2147
- ClearAllIcon,
2148
- CloseIcon,
2149
- DensityLargeIcon,
2150
- DensityMediumIcon,
2151
- DensitySmallIcon,
2152
- DragHandleIcon,
2153
- DynamicFeedIcon,
2154
- EditIcon,
2155
- ExpandMoreIcon,
2156
- FilterAltIcon,
2157
- FilterListIcon,
2158
- FilterListOffIcon,
2159
- FirstPageIcon,
2160
- FullscreenExitIcon,
2161
- FullscreenIcon,
2162
- KeyboardDoubleArrowDownIcon,
2163
- LastPageIcon,
2164
- MoreHorizIcon,
2165
- MoreVertIcon,
2166
- PushPinIcon,
2167
- RestartAltIcon,
2168
- SaveIcon,
2169
- SearchIcon,
2170
- SearchOffIcon,
2171
- SortIcon,
2172
- SyncAltIcon,
2173
- ViewColumnIcon,
2174
- VisibilityOffIcon,
2175
- };
2176
-
2177
- const MRT_Localization_EN = {
2178
- actions: 'Actions',
2179
- and: 'and',
2180
- cancel: 'Cancel',
2181
- changeFilterMode: 'Change filter mode',
2182
- changeSearchMode: 'Change search mode',
2183
- clearFilter: 'Clear filter',
2184
- clearSearch: 'Clear search',
2185
- clearSort: 'Clear sort',
2186
- clickToCopy: 'Click to copy',
2187
- collapse: 'Collapse',
2188
- collapseAll: 'Collapse all',
2189
- columnActions: 'Column Actions',
2190
- copiedToClipboard: 'Copied to clipboard',
2191
- dropToGroupBy: 'Drop to group by {column}',
2192
- edit: 'Edit',
2193
- expand: 'Expand',
2194
- expandAll: 'Expand all',
2195
- filterArrIncludes: 'Includes',
2196
- filterArrIncludesAll: 'Includes all',
2197
- filterArrIncludesSome: 'Includes',
2198
- filterBetween: 'Between',
2199
- filterBetweenInclusive: 'Between Inclusive',
2200
- filterByColumn: 'Filter by {column}',
2201
- filterContains: 'Contains',
2202
- filterEmpty: 'Empty',
2203
- filterEndsWith: 'Ends With',
2204
- filterEquals: 'Equals',
2205
- filterEqualsString: 'Equals',
2206
- filterFuzzy: 'Fuzzy',
2207
- filterGreaterThan: 'Greater Than',
2208
- filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
2209
- filterInNumberRange: 'Between',
2210
- filterIncludesString: 'Contains',
2211
- filterIncludesStringSensitive: 'Contains',
2212
- filterLessThan: 'Less Than',
2213
- filterLessThanOrEqualTo: 'Less Than Or Equal To',
2214
- filterMode: 'Filter Mode: {filterType}',
2215
- filterNotEmpty: 'Not Empty',
2216
- filterNotEquals: 'Not Equals',
2217
- filterStartsWith: 'Starts With',
2218
- filterWeakEquals: 'Equals',
2219
- filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
2220
- goToFirstPage: 'Go to first page',
2221
- goToLastPage: 'Go to last page',
2222
- goToNextPage: 'Go to next page',
2223
- goToPreviousPage: 'Go to previous page',
2224
- grab: 'Grab',
2225
- groupByColumn: 'Group by {column}',
2226
- groupedBy: 'Grouped by ',
2227
- hideAll: 'Hide all',
2228
- hideColumn: 'Hide {column} column',
2229
- max: 'Max',
2230
- min: 'Min',
2231
- move: 'Move',
2232
- noRecordsToDisplay: 'No records to display',
2233
- noResultsFound: 'No results found',
2234
- of: 'of',
2235
- or: 'or',
2236
- pin: 'Pin',
2237
- pinToLeft: 'Pin to left',
2238
- pinToRight: 'Pin to right',
2239
- resetColumnSize: 'Reset column size',
2240
- resetOrder: 'Reset order',
2241
- rowActions: 'Row Actions',
2242
- rowNumber: '#',
2243
- rowNumbers: 'Row Numbers',
2244
- rowsPerPage: 'Rows per page',
2245
- save: 'Save',
2246
- search: 'Search',
2247
- selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
2248
- select: 'Select',
2249
- showAll: 'Show all',
2250
- showAllColumns: 'Show all columns',
2251
- showHideColumns: 'Show/Hide columns',
2252
- showHideFilters: 'Show/Hide filters',
2253
- showHideSearch: 'Show/Hide search',
2254
- sortByColumnAsc: 'Sort by {column} ascending',
2255
- sortByColumnDesc: 'Sort by {column} descending',
2256
- sortedByColumnAsc: 'Sorted by {column} ascending',
2257
- sortedByColumnDesc: 'Sorted by {column} descending',
2258
- thenBy: ', then by ',
2259
- toggleDensity: 'Toggle density',
2260
- toggleFullScreen: 'Toggle full screen',
2261
- toggleSelectAll: 'Toggle select all',
2262
- toggleSelectRow: 'Toggle select row',
2263
- toggleVisibility: 'Toggle visibility',
2264
- ungroupByColumn: 'Ungroup by {column}',
2265
- unpin: 'Unpin',
2266
- unpinAll: 'Unpin all',
2235
+ const cellValueProps = {
2236
+ cell,
2237
+ table,
2238
+ };
2239
+ return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": virtualColumnIndex, ref: (node) => {
2240
+ if (node) {
2241
+ measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2242
+ }
2243
+ } }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
2244
+ outline: (editDisplayMode === 'cell' && isEditable) ||
2245
+ (editDisplayMode === 'table' && (isCreating || isEditing))
2246
+ ? `1px solid ${theme.palette.grey[500]}`
2247
+ : undefined,
2248
+ outlineOffset: '-1px',
2249
+ textOverflow: 'clip',
2250
+ }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', justifyContent: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
2251
+ ? tableCellProps.align
2252
+ : undefined, overflow: 'hidden', p: density === 'compact'
2253
+ ? columnDefType === 'display'
2254
+ ? '0 0.5rem'
2255
+ : '0.5rem'
2256
+ : density === 'comfortable'
2257
+ ? columnDefType === 'display'
2258
+ ? '0.5rem 0.75rem'
2259
+ : '1rem'
2260
+ : columnDefType === 'display'
2261
+ ? '1rem 1.25rem'
2262
+ : '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0 }, getCommonMRTCellStyles({
2263
+ column,
2264
+ table,
2265
+ tableCellProps,
2266
+ theme,
2267
+ })), 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' &&
2268
+ (['mrt-row-expand', 'mrt-row-numbers', 'mrt-row-select'].includes(column.id) ||
2269
+ !row.getIsGrouped()) ? ((_e = columnDef.Cell) === null || _e === void 0 ? void 0 : _e.call(columnDef, {
2270
+ cell,
2271
+ column,
2272
+ renderedCellValue: cell.renderValue(),
2273
+ row,
2274
+ rowRef,
2275
+ staticRowIndex,
2276
+ table,
2277
+ })) : isCreating || isEditing ? (jsx(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
2278
+ 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, ")"] }))] })) })));
2267
2279
  };
2280
+ const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2268
2281
 
2269
- const MRT_DefaultColumn = {
2270
- filterVariant: 'text',
2271
- maxSize: 1000,
2272
- minSize: 40,
2273
- size: 180,
2274
- };
2275
- const MRT_DefaultDisplayColumn = {
2276
- columnDefType: 'display',
2277
- enableClickToCopy: false,
2278
- enableColumnActions: false,
2279
- enableColumnDragging: false,
2280
- enableColumnFilter: false,
2281
- enableColumnOrdering: false,
2282
- enableEditing: false,
2283
- enableGlobalFilter: false,
2284
- enableGrouping: false,
2285
- enableHiding: false,
2286
- enableResizing: false,
2287
- enableSorting: false,
2282
+ const MRT_TableDetailPanel = (_a) => {
2283
+ var { parentRowRef, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["parentRowRef", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
2284
+ const { getState, getVisibleLeafColumns, options: { enableRowVirtualization, layoutMode, muiDetailPanelProps, muiTableBodyRowProps, renderDetailPanel, }, } = table;
2285
+ const { isLoading } = getState();
2286
+ const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
2287
+ isDetailPanel: true,
2288
+ row,
2289
+ staticRowIndex,
2290
+ table,
2291
+ });
2292
+ const tableCellProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiDetailPanelProps, {
2293
+ row,
2294
+ table,
2295
+ })), rest);
2296
+ const DetailPanel = !isLoading && (renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
2297
+ return (jsx(TableRow, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", "data-index": renderDetailPanel ? staticRowIndex * 2 + 1 : staticRowIndex, ref: (node) => {
2298
+ var _a;
2299
+ if (node) {
2300
+ (_a = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(rowVirtualizer, node);
2301
+ }
2302
+ } }, tableRowProps, { sx: (theme) => {
2303
+ var _a, _b;
2304
+ return (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: virtualRow ? 'absolute' : undefined, top: virtualRow
2305
+ ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
2306
+ : undefined, transform: virtualRow
2307
+ ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2308
+ : undefined, width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme)));
2309
+ }, children: jsx(TableCell, Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
2310
+ ? getMRTTheme(table, theme).baseBackgroundColor
2311
+ : 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: !enableRowVirtualization
2312
+ ? 'all 150ms ease-in-out'
2313
+ : undefined, width: `100%` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: enableRowVirtualization ? (row.getIsExpanded() && DetailPanel) : (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: DetailPanel })) })) })));
2288
2314
  };
2289
- const useMRT_TableOptions = (_a) => {
2290
- var _b;
2291
- var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', 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", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
2315
+
2316
+ const MRT_TableBodyRow = ({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow, }) => {
2317
+ var _a, _b, _c, _d;
2292
2318
  const theme = useTheme();
2293
- const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
2294
- const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
2295
- const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
2296
- const _filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
2297
- const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
2298
- const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
2299
- const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
2300
- if (!columnResizeDirection) {
2301
- columnResizeDirection = theme.direction || 'ltr';
2302
- }
2303
- layoutMode =
2304
- layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
2305
- if (layoutMode === 'semantic' &&
2306
- (rest.enableRowVirtualization || rest.enableColumnVirtualization)) {
2307
- layoutMode = 'grid';
2308
- }
2309
- if (rest.enableRowVirtualization) {
2310
- enableStickyHeader = true;
2311
- }
2312
- if (enablePagination === false && manualPagination === undefined) {
2313
- manualPagination = true;
2314
- }
2315
- if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
2316
- manualFiltering = true;
2317
- manualGrouping = true;
2318
- manualPagination = true;
2319
- manualSorting = true;
2320
- }
2321
- return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
2322
- columnFilterDisplayMode,
2323
- columnResizeDirection,
2324
- columnResizeMode,
2325
- createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
2326
- enableBottomToolbar,
2327
- enableColumnActions,
2328
- enableColumnFilters,
2329
- enableColumnOrdering,
2330
- enableColumnPinning,
2331
- enableColumnResizing,
2332
- enableDensityToggle,
2333
- enableExpandAll,
2334
- enableExpanding,
2335
- enableFilterMatchHighlighting,
2336
- enableFilters,
2337
- enableFullScreenToggle,
2338
- enableGlobalFilter,
2339
- enableGlobalFilterRankedResults,
2340
- enableGrouping,
2341
- enableHiding,
2342
- enableMultiRowSelection,
2343
- enableMultiSort,
2344
- enablePagination,
2345
- enableRowPinning,
2346
- enableRowSelection,
2347
- enableSelectAll,
2348
- enableSorting,
2349
- enableStickyHeader,
2350
- enableTableFooter,
2351
- enableTableHead,
2352
- enableToolbarInternalActions,
2353
- enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode, localization: _localization, manualFiltering,
2354
- manualGrouping,
2355
- manualPagination,
2356
- manualSorting,
2357
- paginationDisplayMode,
2358
- positionActionsColumn,
2359
- positionExpandColumn,
2360
- positionGlobalFilter,
2361
- positionPagination,
2362
- positionToolbarAlertBanner,
2363
- positionToolbarDropZone,
2364
- rowNumberDisplayMode,
2365
- rowPinningDisplayMode,
2366
- selectAllMode, sortingFns: _sortingFns }, rest);
2319
+ const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
2320
+ const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
2321
+ const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
2322
+ const isPinned = enableRowPinning && row.getIsPinned();
2323
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
2324
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
2325
+ const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
2326
+ row,
2327
+ staticRowIndex,
2328
+ table,
2329
+ });
2330
+ const [bottomPinnedIndex, topPinnedIndex] = useMemo(() => {
2331
+ if (!enableRowPinning ||
2332
+ !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) ||
2333
+ !pinnedRowIds ||
2334
+ !row.getIsPinned())
2335
+ return [];
2336
+ return [
2337
+ [...pinnedRowIds].reverse().indexOf(row.id),
2338
+ pinnedRowIds.indexOf(row.id),
2339
+ ];
2340
+ }, [pinnedRowIds, rowPinning]);
2341
+ const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
2342
+ ((_a = tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight)) ||
2343
+ 0;
2344
+ const tableFooterHeight = (enableStickyFooter && ((_b = tableFooterRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
2345
+ const sx = parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme);
2346
+ const defaultRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
2347
+ const customRowHeight =
2348
+ // @ts-ignore
2349
+ parseInt((_d = (_c = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
2350
+ const rowHeight = customRowHeight || defaultRowHeight;
2351
+ const handleDragEnter = (_e) => {
2352
+ if (enableRowOrdering && draggingRow) {
2353
+ setHoveredRow(row);
2354
+ }
2355
+ };
2356
+ const rowRef = useRef(null);
2357
+ const { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, } = getMRTTheme(table, theme);
2358
+ return (jsxs(Fragment, { children: [jsxs(TableRow, Object.assign({ "data-index": renderDetailPanel ? staticRowIndex * 2 : staticRowIndex, "data-pinned": !!isPinned || undefined, "data-selected": (row === null || row === void 0 ? void 0 : row.getIsSelected()) ||
2359
+ ((row === null || row === void 0 ? void 0 : row.getIsAllSubRowsSelected()) && row.getCanSelectSubRows()) ||
2360
+ undefined, onDragEnter: handleDragEnter, ref: (node) => {
2361
+ if (node) {
2362
+ rowRef.current = node;
2363
+ rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement(node);
2364
+ }
2365
+ }, selected: row.getIsSelected() }, tableRowProps, { style: Object.assign({ transform: virtualRow
2366
+ ? `translateY(${virtualRow.start}px)`
2367
+ : undefined }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style), sx: (theme) => (Object.assign({ '&:hover td': {
2368
+ backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
2369
+ ? row.getIsSelected()
2370
+ ? `${alpha(selectedRowBackgroundColor, 0.3)}`
2371
+ : theme.palette.mode === 'dark'
2372
+ ? `${lighten(baseBackgroundColor, 0.05)}`
2373
+ : `${darken(baseBackgroundColor, 0.05)}`
2374
+ : undefined,
2375
+ }, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
2376
+ ? `${bottomPinnedIndex * rowHeight +
2377
+ (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
2378
+ : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
2379
+ ? 'absolute'
2380
+ : (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
2381
+ ? 'sticky'
2382
+ : undefined, td: {
2383
+ backgroundColor: row.getIsSelected()
2384
+ ? selectedRowBackgroundColor
2385
+ : isPinned
2386
+ ? pinnedRowBackgroundColor
2387
+ : undefined,
2388
+ }, top: virtualRow
2389
+ ? 0
2390
+ : topPinnedIndex !== undefined && isPinned
2391
+ ? `${topPinnedIndex * rowHeight +
2392
+ (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
2393
+ : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
2394
+ ? 2
2395
+ : undefined }, sx)), children: [virtualPaddingLeft ? (jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
2396
+ const cell = columnVirtualizer
2397
+ ? row.getVisibleCells()[cellOrVirtualCell.index]
2398
+ : cellOrVirtualCell;
2399
+ const props = {
2400
+ cell,
2401
+ measureElement: !isDraggingRow && !isHoveredRow
2402
+ ? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
2403
+ : undefined,
2404
+ numRows,
2405
+ rowRef,
2406
+ staticRowIndex,
2407
+ table,
2408
+ virtualColumnIndex: columnVirtualizer
2409
+ ? cellOrVirtualCell.index
2410
+ : undefined,
2411
+ };
2412
+ return cell ? (memoMode === 'cells' &&
2413
+ cell.column.columnDef.columnDefType === 'data' &&
2414
+ !draggingColumn &&
2415
+ !draggingRow &&
2416
+ (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
2417
+ (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), cell.id)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), cell.id))) : null;
2418
+ }), 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 }))] }));
2367
2419
  };
2420
+ const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
2368
2421
 
2369
2422
  const MRT_TableBody = (_a) => {
2370
2423
  var _b, _c, _d, _e, _f, _g;
2371
2424
  var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
2372
- const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
2373
- const { columnFilters, creatingRow, globalFilter, isFullScreen, rowPinning } = getState();
2425
+ const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
2426
+ const { columnFilters, globalFilter, isFullScreen, rowPinning } = getState();
2374
2427
  const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
2375
2428
  const tableHeadHeight = ((enableStickyHeader || isFullScreen) &&
2376
2429
  ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) ||
@@ -2392,53 +2445,52 @@ const MRT_TableBody = (_a) => {
2392
2445
  numRows: rows.length,
2393
2446
  table,
2394
2447
  };
2395
- const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow, staticRowIndex: -1 })));
2396
2448
  return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
2397
2449
  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) => {
2398
2450
  const props = Object.assign(Object.assign({}, commonRowProps), { row,
2399
2451
  staticRowIndex });
2400
2452
  return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
2401
- }) }))), rowVirtualizer && CreatingRow && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: CreatingRow }))), jsxs(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
2453
+ }) }))), jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
2402
2454
  ? `${rowVirtualizer.getTotalSize()}px`
2403
- : undefined, minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: [!rowVirtualizer && CreatingRow, (_d = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _d !== void 0 ? _d : (!rows.length && !CreatingRow ? (jsx("tr", { style: {
2455
+ : 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: {
2456
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
2457
+ }, children: jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
2404
2458
  display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
2405
- }, children: jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
2406
- display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
2407
- }, children: (_e = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _e !== void 0 ? _e : (jsx(Typography, { sx: {
2408
- color: 'text.secondary',
2409
- fontStyle: 'italic',
2410
- maxWidth: `min(100vw, ${(_g = (_f = tablePaperRef.current) === null || _f === void 0 ? void 0 : _f.clientWidth) !== null && _g !== void 0 ? _g : 360}px)`,
2411
- py: '2rem',
2412
- textAlign: 'center',
2413
- width: '100%',
2414
- }, children: globalFilter || columnFilters.length
2415
- ? localization.noResultsFound
2416
- : localization.noRecordsToDisplay })) }) })) : (jsx(Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, staticRowIndex) => {
2417
- if (rowVirtualizer) {
2418
- if (renderDetailPanel) {
2419
- if (rowOrVirtualRow.index % 2 === 1) {
2420
- return null;
2421
- }
2422
- else {
2423
- staticRowIndex = rowOrVirtualRow.index / 2;
2424
- }
2459
+ }, children: (_e = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _e !== void 0 ? _e : (jsx(Typography, { sx: {
2460
+ color: 'text.secondary',
2461
+ fontStyle: 'italic',
2462
+ maxWidth: `min(100vw, ${(_g = (_f = tablePaperRef.current) === null || _f === void 0 ? void 0 : _f.clientWidth) !== null && _g !== void 0 ? _g : 360}px)`,
2463
+ py: '2rem',
2464
+ textAlign: 'center',
2465
+ width: '100%',
2466
+ }, children: globalFilter || columnFilters.length
2467
+ ? localization.noResultsFound
2468
+ : localization.noRecordsToDisplay })) }) })) : (jsx(Fragment, { children: (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, staticRowIndex) => {
2469
+ if (rowVirtualizer) {
2470
+ if (renderDetailPanel) {
2471
+ if (rowOrVirtualRow.index % 2 === 1) {
2472
+ return null;
2425
2473
  }
2426
2474
  else {
2427
- staticRowIndex = rowOrVirtualRow.index;
2475
+ staticRowIndex = rowOrVirtualRow.index / 2;
2428
2476
  }
2429
2477
  }
2430
- const row = rowVirtualizer
2431
- ? rows[staticRowIndex]
2432
- : rowOrVirtualRow;
2433
- const props = Object.assign(Object.assign({}, commonRowProps), { pinnedRowIds,
2434
- row,
2435
- rowVirtualizer,
2436
- staticRowIndex, virtualRow: rowVirtualizer
2437
- ? rowOrVirtualRow
2438
- : undefined });
2439
- const key = `${row.id}-${row.index}`;
2440
- return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
2441
- }) })))] })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
2478
+ else {
2479
+ staticRowIndex = rowOrVirtualRow.index;
2480
+ }
2481
+ }
2482
+ const row = rowVirtualizer
2483
+ ? rows[staticRowIndex]
2484
+ : rowOrVirtualRow;
2485
+ const props = Object.assign(Object.assign({}, commonRowProps), { pinnedRowIds,
2486
+ row,
2487
+ rowVirtualizer,
2488
+ staticRowIndex, virtualRow: rowVirtualizer
2489
+ ? rowOrVirtualRow
2490
+ : undefined });
2491
+ const key = `${row.id}-${row.index}`;
2492
+ return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
2493
+ }) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
2442
2494
  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) => {
2443
2495
  const props = Object.assign(Object.assign({}, commonRowProps), { row,
2444
2496
  staticRowIndex });
@@ -2542,9 +2594,9 @@ const MRT_TableHeadCellColumnActionsButton = (_a) => {
2542
2594
  column,
2543
2595
  table,
2544
2596
  })), rest);
2545
- return (jsxs(Fragment, { children: [jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, placement: "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': {
2597
+ 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': {
2546
2598
  opacity: 1,
2547
- }, 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 }))] }));
2599
+ }, 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 }))] }));
2548
2600
  };
2549
2601
 
2550
2602
  const MRT_FilterCheckbox = (_a) => {
@@ -2561,7 +2613,7 @@ const MRT_FilterCheckbox = (_a) => {
2561
2613
  table,
2562
2614
  })), rest);
2563
2615
  const filterLabel = (_b = localization.filterByColumn) === null || _b === void 0 ? void 0 : _b.replace('{column}', columnDef.header);
2564
- return (jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, 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) => {
2616
+ 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) => {
2565
2617
  var _a;
2566
2618
  column.setFilterValue(column.getFilterValue() === undefined
2567
2619
  ? 'true'
@@ -2573,7 +2625,7 @@ const MRT_FilterCheckbox = (_a) => {
2573
2625
  var _a;
2574
2626
  e.stopPropagation();
2575
2627
  (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
2576
- }, 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 }) }));
2628
+ }, 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 }) })));
2577
2629
  };
2578
2630
 
2579
2631
  const MRT_FilterTextField = (_a) => {
@@ -3229,116 +3281,6 @@ const MRT_TableHeadRow = (_a) => {
3229
3281
  }), virtualPaddingRight ? (jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
3230
3282
  };
3231
3283
 
3232
- const MRT_LinearProgressBar = (_a) => {
3233
- var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
3234
- const { getState, options: { muiLinearProgressProps }, } = table;
3235
- const { isSaving, showProgressBars } = getState();
3236
- const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
3237
- isTopToolbar,
3238
- table,
3239
- })), rest);
3240
- return (jsx(Collapse, { in: showProgressBars !== false && (showProgressBars || isSaving), mountOnEnter: true, sx: {
3241
- bottom: isTopToolbar ? 0 : undefined,
3242
- position: 'absolute',
3243
- top: !isTopToolbar ? 0 : undefined,
3244
- width: '100%',
3245
- }, unmountOnExit: true, children: jsx(LinearProgress, Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
3246
- };
3247
-
3248
- const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
3249
- const MRT_TablePagination = (_a) => {
3250
- var { position = 'bottom', table } = _a, rest = __rest(_a, ["position", "table"]);
3251
- const theme = useTheme();
3252
- const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, localization, muiPaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
3253
- const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
3254
- const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiPaginationProps, {
3255
- table,
3256
- })), rest);
3257
- const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
3258
- const numberOfPages = Math.ceil(totalRowCount / pageSize);
3259
- const showFirstLastPageButtons = numberOfPages > 2;
3260
- const firstRowIndex = pageIndex * pageSize;
3261
- const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3262
- const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
3263
- const disableBack = pageIndex <= 0 || disabled;
3264
- const disableNext = lastRowIndex >= totalRowCount || disabled;
3265
- return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
3266
- alignItems: 'center',
3267
- display: 'flex',
3268
- flexWrap: 'wrap',
3269
- gap: '8px',
3270
- justifyContent: { md: 'space-between', sm: 'center' },
3271
- justifySelf: 'flex-end',
3272
- mt: position === 'top' &&
3273
- enableToolbarInternalActions &&
3274
- !showGlobalFilter
3275
- ? '3rem'
3276
- : undefined,
3277
- position: 'relative',
3278
- px: '8px',
3279
- py: '12px',
3280
- zIndex: 2,
3281
- }, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ disableUnderline: true, disabled: disabled, id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
3282
- var _a;
3283
- const value = typeof option !== 'number' ? option.value : option;
3284
- const label = typeof option !== 'number' ? option.label : `${option}`;
3285
- 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))));
3286
- }) }))] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, Object.assign({ count: numberOfPages, disabled: disabled, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsx(PaginationItem, Object.assign({ slots: {
3287
- first: FirstPageIcon,
3288
- last: LastPageIcon,
3289
- next: ChevronRightIcon,
3290
- previous: ChevronLeftIcon,
3291
- } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : 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, { enterDelay: 1000, title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })), jsx(Tooltip, { enterDelay: 1000, title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, Object.assign({}, flipIconStyles(theme))) }) }) }), jsx(Tooltip, { enterDelay: 1000, title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, Object.assign({}, flipIconStyles(theme))) }) }) }), showLastButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) }))] })] })) : null] }));
3292
- };
3293
-
3294
- const MRT_GlobalFilterTextField = (_a) => {
3295
- var _b;
3296
- var { table } = _a, rest = __rest(_a, ["table"]);
3297
- const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
3298
- const { globalFilter, showGlobalFilter } = getState();
3299
- const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiSearchTextFieldProps, {
3300
- table,
3301
- })), rest);
3302
- const isMounted = useRef(false);
3303
- const [anchorEl, setAnchorEl] = useState(null);
3304
- const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
3305
- const handleChangeDebounced = useCallback(debounce((event) => {
3306
- var _a;
3307
- setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
3308
- }, manualFiltering ? 500 : 250), []);
3309
- const handleChange = (event) => {
3310
- setSearchValue(event.target.value);
3311
- handleChangeDebounced(event);
3312
- };
3313
- const handleGlobalFilterMenuOpen = (event) => {
3314
- setAnchorEl(event.currentTarget);
3315
- };
3316
- const handleClear = () => {
3317
- setSearchValue('');
3318
- setGlobalFilter(undefined);
3319
- };
3320
- useEffect(() => {
3321
- if (isMounted.current) {
3322
- if (globalFilter === undefined) {
3323
- handleClear();
3324
- }
3325
- else {
3326
- setSearchValue(globalFilter);
3327
- }
3328
- }
3329
- isMounted.current = true;
3330
- }, [globalFilter]);
3331
- return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ inputProps: Object.assign({ autoComplete: 'new-password' }, 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) => {
3332
- var _a;
3333
- 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)));
3334
- } }), inputRef: (inputRef) => {
3335
- searchInputRef.current = inputRef;
3336
- if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
3337
- textFieldProps.inputRef = inputRef;
3338
- }
3339
- } })), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, onSelect: handleClear, setAnchorEl: setAnchorEl, table: table })] }));
3340
- };
3341
-
3342
3284
  const MRT_ToolbarAlertBanner = (_a) => {
3343
3285
  var _b, _c, _d;
3344
3286
  var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
@@ -3382,6 +3324,212 @@ const MRT_ToolbarAlertBanner = (_a) => {
3382
3324
  positionToolbarAlertBanner === 'head-overlay' && (jsx(MRT_SelectCheckbox, { selectAll: true, table: table })), ' ', selectedAlert] }), selectedAlert && groupedAlert && jsx("br", {}), groupedAlert] })] })) })) }));
3383
3325
  };
3384
3326
 
3327
+ const MRT_TableHead = (_a) => {
3328
+ var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
3329
+ const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
3330
+ const { isFullScreen, showAlertBanner } = getState();
3331
+ const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
3332
+ const stickyHeader = enableStickyHeader || isFullScreen;
3333
+ return (jsx(TableHead, Object.assign({}, tableHeadProps, { ref: (ref) => {
3334
+ tableHeadRef.current = ref;
3335
+ if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
3336
+ // @ts-ignore
3337
+ tableHeadProps.ref.current = ref;
3338
+ }
3339
+ }, 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' &&
3340
+ (showAlertBanner || getSelectedRowModel().rows.length > 0) ? (jsx("tr", { style: {
3341
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3342
+ }, children: jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
3343
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3344
+ padding: 0,
3345
+ }, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
3346
+ };
3347
+
3348
+ const MRT_Table = (_a) => {
3349
+ var { table } = _a, rest = __rest(_a, ["table"]);
3350
+ const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, } = table;
3351
+ const { columnSizing, columnSizingInfo, columnVisibility, isFullScreen } = getState();
3352
+ const tableProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableProps, { table })), rest);
3353
+ const columnSizeVars = useMemo(() => {
3354
+ const headers = getFlatHeaders();
3355
+ const colSizes = {};
3356
+ for (let i = 0; i < headers.length; i++) {
3357
+ const header = headers[i];
3358
+ const colSize = header.getSize();
3359
+ colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
3360
+ colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
3361
+ }
3362
+ return colSizes;
3363
+ }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
3364
+ const columnVirtualizer = useMRT_ColumnVirtualizer(table);
3365
+ const commonTableGroupProps = {
3366
+ columnVirtualizer,
3367
+ table,
3368
+ };
3369
+ 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 }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [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))] })));
3370
+ };
3371
+
3372
+ const MRT_TableLoadingOverlay = (_a) => {
3373
+ var { table } = _a, rest = __rest(_a, ["table"]);
3374
+ const { options: { localization, muiCircularProgressProps }, } = table;
3375
+ const circularProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCircularProgressProps, { table })), rest);
3376
+ return (jsx(Box, { sx: (theme) => ({
3377
+ alignItems: 'center',
3378
+ backgroundColor: alpha(getMRTTheme(table, theme).baseBackgroundColor, 0.5),
3379
+ bottom: 0,
3380
+ display: 'flex',
3381
+ justifyContent: 'center',
3382
+ left: 0,
3383
+ maxHeight: '100vh',
3384
+ position: 'absolute',
3385
+ right: 0,
3386
+ top: 0,
3387
+ width: '100%',
3388
+ zIndex: 2,
3389
+ }), children: jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps)) }));
3390
+ };
3391
+
3392
+ const MRT_EditRowModal = (_a) => {
3393
+ var _b;
3394
+ var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
3395
+ const { getState, options: { localization, muiCreateRowModalProps, muiEditRowDialogProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowDialogContent, renderEditRowDialogContent, }, setCreatingRow, setEditingRow, } = table;
3396
+ const { creatingRow, editingRow } = getState();
3397
+ const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
3398
+ const dialogProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowDialogProps, { row, table })), (creatingRow &&
3399
+ parseFromValuesOrFunc(muiCreateRowModalProps, { row, table }))), rest);
3400
+ const internalEditComponents = row
3401
+ .getAllCells()
3402
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
3403
+ .map((cell) => (jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
3404
+ return (jsx(Dialog, Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
3405
+ var _a;
3406
+ if (creatingRow) {
3407
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
3408
+ setCreatingRow(null);
3409
+ }
3410
+ else {
3411
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
3412
+ setEditingRow(null);
3413
+ }
3414
+ row._valuesCache = {}; //reset values cache
3415
+ (_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
3416
+ }, open: open }, dialogProps, { children: (_b = ((creatingRow &&
3417
+ (renderCreateRowDialogContent === null || renderCreateRowDialogContent === void 0 ? void 0 : renderCreateRowDialogContent({
3418
+ internalEditComponents,
3419
+ row,
3420
+ table,
3421
+ }))) ||
3422
+ (renderEditRowDialogContent === null || renderEditRowDialogContent === void 0 ? void 0 : renderEditRowDialogContent({
3423
+ internalEditComponents,
3424
+ row,
3425
+ table,
3426
+ })))) !== 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: {
3427
+ gap: '32px',
3428
+ paddingTop: '16px',
3429
+ width: '100%',
3430
+ }, children: internalEditComponents }) }) }), jsx(DialogActions, { sx: { p: '1.25rem' }, children: jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
3431
+ };
3432
+
3433
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3434
+ const MRT_TableContainer = (_a) => {
3435
+ var { table } = _a, rest = __rest(_a, ["table"]);
3436
+ const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3437
+ const { creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3438
+ const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
3439
+ const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3440
+ const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
3441
+ table,
3442
+ })), rest);
3443
+ useIsomorphicLayoutEffect(() => {
3444
+ var _a, _b, _c, _d;
3445
+ const topToolbarHeight = typeof document !== 'undefined'
3446
+ ? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
3447
+ : 0;
3448
+ const bottomToolbarHeight = typeof document !== 'undefined'
3449
+ ? (_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
3450
+ : 0;
3451
+ setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
3452
+ });
3453
+ const createModalOpen = createDisplayMode === 'modal' && creatingRow;
3454
+ const editModalOpen = editDisplayMode === 'modal' && editingRow;
3455
+ return (jsxs(TableContainer, Object.assign({ "aria-busy": loading, "aria-describedby": loading ? 'mrt-progress' : undefined }, tableContainerProps, { ref: (node) => {
3456
+ if (node) {
3457
+ tableContainerRef.current = node;
3458
+ if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
3459
+ //@ts-ignore
3460
+ tableContainerProps.ref.current = node;
3461
+ }
3462
+ }
3463
+ }, style: Object.assign({ maxHeight: isFullScreen
3464
+ ? `calc(100vh - ${totalToolbarHeight}px)`
3465
+ : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
3466
+ ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3467
+ : 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 }))] })));
3468
+ };
3469
+
3470
+ const MRT_LinearProgressBar = (_a) => {
3471
+ var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
3472
+ const { getState, options: { muiLinearProgressProps }, } = table;
3473
+ const { isSaving, showProgressBars } = getState();
3474
+ const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
3475
+ isTopToolbar,
3476
+ table,
3477
+ })), rest);
3478
+ return (jsx(Collapse, { in: showProgressBars !== false && (showProgressBars || isSaving), mountOnEnter: true, sx: {
3479
+ bottom: isTopToolbar ? 0 : undefined,
3480
+ position: 'absolute',
3481
+ top: !isTopToolbar ? 0 : undefined,
3482
+ width: '100%',
3483
+ }, unmountOnExit: true, children: jsx(LinearProgress, Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
3484
+ };
3485
+
3486
+ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
3487
+ const MRT_TablePagination = (_a) => {
3488
+ var { position = 'bottom', table } = _a, rest = __rest(_a, ["position", "table"]);
3489
+ const theme = useTheme();
3490
+ const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, localization, muiPaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
3491
+ const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
3492
+ const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiPaginationProps, {
3493
+ table,
3494
+ })), rest);
3495
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
3496
+ const numberOfPages = Math.ceil(totalRowCount / pageSize);
3497
+ const showFirstLastPageButtons = numberOfPages > 2;
3498
+ const firstRowIndex = pageIndex * pageSize;
3499
+ const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
3500
+ const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
3501
+ const disableBack = pageIndex <= 0 || disabled;
3502
+ const disableNext = lastRowIndex >= totalRowCount || disabled;
3503
+ const tooltipProps = getCommonTooltipProps();
3504
+ return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
3505
+ alignItems: 'center',
3506
+ display: 'flex',
3507
+ flexWrap: 'wrap',
3508
+ gap: '8px',
3509
+ justifyContent: { md: 'space-between', sm: 'center' },
3510
+ justifySelf: 'flex-end',
3511
+ mt: position === 'top' &&
3512
+ enableToolbarInternalActions &&
3513
+ !showGlobalFilter
3514
+ ? '3rem'
3515
+ : undefined,
3516
+ position: 'relative',
3517
+ px: '8px',
3518
+ py: '12px',
3519
+ zIndex: 2,
3520
+ }, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ disableUnderline: true, disabled: disabled, id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
3521
+ var _a;
3522
+ const value = typeof option !== 'number' ? option.value : option;
3523
+ const label = typeof option !== 'number' ? option.label : `${option}`;
3524
+ 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))));
3525
+ }) }))] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, Object.assign({ count: numberOfPages, disabled: disabled, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsx(PaginationItem, Object.assign({ slots: {
3526
+ first: FirstPageIcon,
3527
+ last: LastPageIcon,
3528
+ next: ChevronRightIcon,
3529
+ previous: ChevronLeftIcon,
3530
+ } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : 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: () => setPageIndex(0), 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: () => setPageIndex(pageIndex - 1), 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: () => setPageIndex(pageIndex + 1), 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: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, Object.assign({}, flipIconStyles(theme))) }) }) })))] })] })) : null] }));
3531
+ };
3532
+
3385
3533
  const MRT_ToolbarDropZone = (_a) => {
3386
3534
  var _b, _c;
3387
3535
  var { table } = _a, rest = __rest(_a, ["table"]);
@@ -3513,7 +3661,7 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
3513
3661
  opacity: columnDefType !== 'display' ? 1 : 0.5,
3514
3662
  },
3515
3663
  },
3516
- }, control: jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, title: localization.toggleVisibility, children: jsx(Switch, {}) }), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
3664
+ }, 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, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
3517
3665
  };
3518
3666
 
3519
3667
  const MRT_ShowHideColumnsMenu = (_a) => {
@@ -3545,8 +3693,13 @@ const MRT_ShowHideColumnsMenu = (_a) => {
3545
3693
  getRightLeafColumns(),
3546
3694
  ]);
3547
3695
  const [hoveredColumn, setHoveredColumn] = useState(null);
3696
+ const theme = useTheme();
3697
+ const { menuBackgroundColor } = getMRTTheme(table, theme);
3548
3698
  return (jsxs(Menu, Object.assign({ MenuListProps: {
3549
3699
  dense: density === 'compact',
3700
+ sx: {
3701
+ backgroundColor: menuBackgroundColor,
3702
+ },
3550
3703
  }, anchorEl: anchorEl, onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: [jsxs(Box, { sx: {
3551
3704
  display: 'flex',
3552
3705
  justifyContent: 'space-between',
@@ -3631,6 +3784,54 @@ const MRT_ToolbarInternalButtons = (_a) => {
3631
3784
  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 }))] })) })));
3632
3785
  };
3633
3786
 
3787
+ const MRT_GlobalFilterTextField = (_a) => {
3788
+ var _b;
3789
+ var { table } = _a, rest = __rest(_a, ["table"]);
3790
+ const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
3791
+ const { globalFilter, showGlobalFilter } = getState();
3792
+ const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiSearchTextFieldProps, {
3793
+ table,
3794
+ })), rest);
3795
+ const isMounted = useRef(false);
3796
+ const [anchorEl, setAnchorEl] = useState(null);
3797
+ const [searchValue, setSearchValue] = useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
3798
+ const handleChangeDebounced = useCallback(debounce((event) => {
3799
+ var _a;
3800
+ setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
3801
+ }, manualFiltering ? 500 : 250), []);
3802
+ const handleChange = (event) => {
3803
+ setSearchValue(event.target.value);
3804
+ handleChangeDebounced(event);
3805
+ };
3806
+ const handleGlobalFilterMenuOpen = (event) => {
3807
+ setAnchorEl(event.currentTarget);
3808
+ };
3809
+ const handleClear = () => {
3810
+ setSearchValue('');
3811
+ setGlobalFilter(undefined);
3812
+ };
3813
+ useEffect(() => {
3814
+ if (isMounted.current) {
3815
+ if (globalFilter === undefined) {
3816
+ handleClear();
3817
+ }
3818
+ else {
3819
+ setSearchValue(globalFilter);
3820
+ }
3821
+ }
3822
+ isMounted.current = true;
3823
+ }, [globalFilter]);
3824
+ return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ inputProps: Object.assign({ autoComplete: 'new-password' }, 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) => {
3825
+ var _a;
3826
+ 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)));
3827
+ } }), inputRef: (inputRef) => {
3828
+ searchInputRef.current = inputRef;
3829
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
3830
+ textFieldProps.inputRef = inputRef;
3831
+ }
3832
+ } })), jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, onSelect: handleClear, setAnchorEl: setAnchorEl, table: table })] }));
3833
+ };
3834
+
3634
3835
  const MRT_TopToolbar = ({ table, }) => {
3635
3836
  var _a;
3636
3837
  const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
@@ -3677,149 +3878,6 @@ const MRT_TopToolbar = ({ table, }) => {
3677
3878
  ['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
3678
3879
  };
3679
3880
 
3680
- const MRT_TableHead = (_a) => {
3681
- var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
3682
- const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
3683
- const { isFullScreen, showAlertBanner } = getState();
3684
- const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
3685
- const stickyHeader = enableStickyHeader || isFullScreen;
3686
- return (jsx(TableHead, Object.assign({}, tableHeadProps, { ref: (ref) => {
3687
- tableHeadRef.current = ref;
3688
- if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
3689
- // @ts-ignore
3690
- tableHeadProps.ref.current = ref;
3691
- }
3692
- }, 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' &&
3693
- (showAlertBanner || getSelectedRowModel().rows.length > 0) ? (jsx("tr", { style: {
3694
- display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3695
- }, children: jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
3696
- display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
3697
- padding: 0,
3698
- }, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
3699
- };
3700
-
3701
- const MRT_Table = (_a) => {
3702
- var { table } = _a, rest = __rest(_a, ["table"]);
3703
- const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, } = table;
3704
- const { columnSizing, columnSizingInfo, columnVisibility, isFullScreen } = getState();
3705
- const tableProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableProps, { table })), rest);
3706
- const columnSizeVars = useMemo(() => {
3707
- const headers = getFlatHeaders();
3708
- const colSizes = {};
3709
- for (let i = 0; i < headers.length; i++) {
3710
- const header = headers[i];
3711
- const colSize = header.getSize();
3712
- colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
3713
- colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
3714
- }
3715
- return colSizes;
3716
- }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
3717
- const columnVirtualizer = useMRT_ColumnVirtualizer(table);
3718
- const commonTableGroupProps = {
3719
- columnVirtualizer,
3720
- table,
3721
- };
3722
- 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 }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [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))] })));
3723
- };
3724
-
3725
- const MRT_TableLoadingOverlay = (_a) => {
3726
- var { table } = _a, rest = __rest(_a, ["table"]);
3727
- const { options: { localization, muiCircularProgressProps }, } = table;
3728
- const circularProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCircularProgressProps, { table })), rest);
3729
- return (jsx(Box, { sx: (theme) => ({
3730
- alignItems: 'center',
3731
- backgroundColor: alpha(getMRTTheme(table, theme).baseBackgroundColor, 0.5),
3732
- bottom: 0,
3733
- display: 'flex',
3734
- justifyContent: 'center',
3735
- left: 0,
3736
- maxHeight: '100vh',
3737
- position: 'absolute',
3738
- right: 0,
3739
- top: 0,
3740
- width: '100%',
3741
- zIndex: 2,
3742
- }), children: jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: "mrt-progress" }, circularProgressProps)) }));
3743
- };
3744
-
3745
- const MRT_EditRowModal = (_a) => {
3746
- var _b;
3747
- var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
3748
- const { getState, options: { localization, muiCreateRowModalProps, muiEditRowDialogProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowDialogContent, renderEditRowDialogContent, }, setCreatingRow, setEditingRow, } = table;
3749
- const { creatingRow, editingRow } = getState();
3750
- const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
3751
- const dialogProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowDialogProps, { row, table })), (creatingRow &&
3752
- parseFromValuesOrFunc(muiCreateRowModalProps, { row, table }))), rest);
3753
- const internalEditComponents = row
3754
- .getAllCells()
3755
- .filter((cell) => cell.column.columnDef.columnDefType === 'data')
3756
- .map((cell) => (jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
3757
- return (jsx(Dialog, Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
3758
- var _a;
3759
- if (creatingRow) {
3760
- onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
3761
- setCreatingRow(null);
3762
- }
3763
- else {
3764
- onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
3765
- setEditingRow(null);
3766
- }
3767
- row._valuesCache = {}; //reset values cache
3768
- (_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
3769
- }, open: open }, dialogProps, { children: (_b = ((creatingRow &&
3770
- (renderCreateRowDialogContent === null || renderCreateRowDialogContent === void 0 ? void 0 : renderCreateRowDialogContent({
3771
- internalEditComponents,
3772
- row,
3773
- table,
3774
- }))) ||
3775
- (renderEditRowDialogContent === null || renderEditRowDialogContent === void 0 ? void 0 : renderEditRowDialogContent({
3776
- internalEditComponents,
3777
- row,
3778
- table,
3779
- })))) !== 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: {
3780
- gap: '32px',
3781
- paddingTop: '16px',
3782
- width: '100%',
3783
- }, children: internalEditComponents }) }) }), jsx(DialogActions, { sx: { p: '1.25rem' }, children: jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
3784
- };
3785
-
3786
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3787
- const MRT_TableContainer = (_a) => {
3788
- var { table } = _a, rest = __rest(_a, ["table"]);
3789
- const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
3790
- const { creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay, } = getState();
3791
- const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
3792
- const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3793
- const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
3794
- table,
3795
- })), rest);
3796
- useIsomorphicLayoutEffect(() => {
3797
- var _a, _b, _c, _d;
3798
- const topToolbarHeight = typeof document !== 'undefined'
3799
- ? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
3800
- : 0;
3801
- const bottomToolbarHeight = typeof document !== 'undefined'
3802
- ? (_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
3803
- : 0;
3804
- setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
3805
- });
3806
- const createModalOpen = createDisplayMode === 'modal' && creatingRow;
3807
- const editModalOpen = editDisplayMode === 'modal' && editingRow;
3808
- return (jsxs(TableContainer, Object.assign({ "aria-busy": loading, "aria-describedby": loading ? 'mrt-progress' : undefined }, tableContainerProps, { ref: (node) => {
3809
- if (node) {
3810
- tableContainerRef.current = node;
3811
- if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
3812
- //@ts-ignore
3813
- tableContainerProps.ref.current = node;
3814
- }
3815
- }
3816
- }, style: Object.assign({ maxHeight: isFullScreen
3817
- ? `calc(100vh - ${totalToolbarHeight}px)`
3818
- : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
3819
- ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3820
- : 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 }))] })));
3821
- };
3822
-
3823
3881
  const MRT_TablePaper = (_a) => {
3824
3882
  var _b, _c;
3825
3883
  var { table } = _a, rest = __rest(_a, ["table"]);
@@ -3852,8 +3910,6 @@ const MRT_TablePaper = (_a) => {
3852
3910
  ((_c = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _c !== void 0 ? _c : (jsx(MRT_BottomToolbar, { table: table })))] })));
3853
3911
  };
3854
3912
 
3855
- const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
3856
-
3857
3913
  const isTableInstanceProp = (props) => props.table !== undefined;
3858
3914
  const MaterialReactTable = (props) => {
3859
3915
  let table;
@@ -3866,5 +3922,5 @@ const MaterialReactTable = (props) => {
3866
3922
  return jsx(MRT_TablePaper, { table: table });
3867
3923
  };
3868
3924
 
3869
- export { 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, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, extraIndexRangeExtractor, flexRender, flipIconStyles, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonMRTCellStyles, getCommonToolbarStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getMRTTheme, getTotalRight, getTrailingDisplayColumnIds, getValueAndLabel, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMRT_ColumnVirtualizer, useMRT_DisplayColumns, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
3925
+ export { 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, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getTotalRight, getTrailingDisplayColumnIds, mrtFilterOptions, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
3870
3926
  //# sourceMappingURL=index.esm.js.map