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