mui-universal-table 2.1.18 → 2.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +470 -643
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +470 -643
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -5
package/dist/index.esm.js
CHANGED
|
@@ -2,138 +2,38 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Paper$1 from '@mui/material/Paper';
|
|
4
4
|
import { Collapse, Box, Typography, LinearProgress, IconButton, Tooltip, Button, Paper, InputBase, Stack, Divider, Toolbar, TableHead, TableRow, TableCell, Checkbox, TableSortLabel, Badge, TableBody, Skeleton, TableContainer, Table, TablePagination } from '@mui/material';
|
|
5
|
-
import {
|
|
5
|
+
import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
|
|
6
6
|
import { alpha } from '@mui/material/styles';
|
|
7
7
|
import { Task, Clear, Search, RemoveCircle, AddCircle } from '@mui/icons-material';
|
|
8
8
|
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
function _arrayWithoutHoles(r) {
|
|
19
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
20
|
-
}
|
|
21
|
-
function _defineProperty(e, r, t) {
|
|
22
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
23
|
-
value: t,
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true
|
|
27
|
-
}) : e[r] = t, e;
|
|
28
|
-
}
|
|
29
|
-
function _iterableToArray(r) {
|
|
30
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
31
|
-
}
|
|
32
|
-
function _iterableToArrayLimit(r, l) {
|
|
33
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
34
|
-
if (null != t) {
|
|
35
|
-
var e,
|
|
36
|
-
n,
|
|
37
|
-
i,
|
|
38
|
-
u,
|
|
39
|
-
a = [],
|
|
40
|
-
f = true,
|
|
41
|
-
o = false;
|
|
42
|
-
try {
|
|
43
|
-
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
44
|
-
} catch (r) {
|
|
45
|
-
o = true, n = r;
|
|
46
|
-
} finally {
|
|
47
|
-
try {
|
|
48
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
49
|
-
} finally {
|
|
50
|
-
if (o) throw n;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return a;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function _nonIterableRest() {
|
|
57
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
-
}
|
|
59
|
-
function _nonIterableSpread() {
|
|
60
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
61
|
-
}
|
|
62
|
-
function ownKeys(e, r) {
|
|
63
|
-
var t = Object.keys(e);
|
|
64
|
-
if (Object.getOwnPropertySymbols) {
|
|
65
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
66
|
-
r && (o = o.filter(function (r) {
|
|
67
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
68
|
-
})), t.push.apply(t, o);
|
|
69
|
-
}
|
|
70
|
-
return t;
|
|
71
|
-
}
|
|
72
|
-
function _objectSpread2(e) {
|
|
73
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
74
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
75
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
76
|
-
_defineProperty(e, r, t[r]);
|
|
77
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
78
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return e;
|
|
82
|
-
}
|
|
83
|
-
function _slicedToArray(r, e) {
|
|
84
|
-
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
85
|
-
}
|
|
86
|
-
function _toConsumableArray(r) {
|
|
87
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
88
|
-
}
|
|
89
|
-
function _toPrimitive(t, r) {
|
|
90
|
-
if ("object" != typeof t || !t) return t;
|
|
91
|
-
var e = t[Symbol.toPrimitive];
|
|
92
|
-
if (void 0 !== e) {
|
|
93
|
-
var i = e.call(t, r);
|
|
94
|
-
if ("object" != typeof i) return i;
|
|
95
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
96
|
-
}
|
|
97
|
-
return ("string" === r ? String : Number)(t);
|
|
98
|
-
}
|
|
99
|
-
function _toPropertyKey(t) {
|
|
100
|
-
var i = _toPrimitive(t, "string");
|
|
101
|
-
return "symbol" == typeof i ? i : i + "";
|
|
102
|
-
}
|
|
103
|
-
function _unsupportedIterableToArray(r, a) {
|
|
104
|
-
if (r) {
|
|
105
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
106
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
107
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
var LazyLoadingIndicator = function LazyLoadingIndicator(_ref) {
|
|
112
|
-
var show = _ref.show,
|
|
113
|
-
currentPage = _ref.currentPage,
|
|
114
|
-
totalPages = _ref.totalPages;
|
|
115
|
-
return /*#__PURE__*/jsx(Collapse, {
|
|
116
|
-
"in": show,
|
|
10
|
+
const LazyLoadingIndicator = ({
|
|
11
|
+
show,
|
|
12
|
+
currentPage,
|
|
13
|
+
totalPages
|
|
14
|
+
}) => {
|
|
15
|
+
return /*#__PURE__*/jsxDEV(Collapse, {
|
|
16
|
+
in: show,
|
|
117
17
|
timeout: "auto",
|
|
118
18
|
unmountOnExit: true,
|
|
119
|
-
children: /*#__PURE__*/
|
|
19
|
+
children: /*#__PURE__*/jsxDEV(Box, {
|
|
120
20
|
sx: {
|
|
121
21
|
width: "100%",
|
|
122
22
|
p: 2
|
|
123
23
|
},
|
|
124
|
-
children: [/*#__PURE__*/
|
|
24
|
+
children: [/*#__PURE__*/jsxDEV(Typography, {
|
|
125
25
|
variant: "body2",
|
|
126
26
|
color: "text.secondary",
|
|
127
27
|
sx: {
|
|
128
28
|
mb: 1
|
|
129
29
|
},
|
|
130
30
|
children: ["Loading page ", currentPage, " of ", totalPages, "..."]
|
|
131
|
-
}), /*#__PURE__*/
|
|
31
|
+
}, void 0, true), /*#__PURE__*/jsxDEV(LinearProgress, {
|
|
132
32
|
variant: "determinate",
|
|
133
33
|
value: currentPage / totalPages * 100
|
|
134
|
-
})]
|
|
135
|
-
})
|
|
136
|
-
});
|
|
34
|
+
}, void 0, false)]
|
|
35
|
+
}, void 0, true)
|
|
36
|
+
}, void 0, false);
|
|
137
37
|
};
|
|
138
38
|
LazyLoadingIndicator.propTypes = {
|
|
139
39
|
show: PropTypes.bool.isRequired,
|
|
@@ -146,7 +46,7 @@ LazyLoadingIndicator.propTypes = {
|
|
|
146
46
|
* but invisible on screen. Defined locally to avoid importing from
|
|
147
47
|
* @mui/utils which is not a declared peer dependency.
|
|
148
48
|
*/
|
|
149
|
-
|
|
49
|
+
const visuallyHidden = {
|
|
150
50
|
border: 0,
|
|
151
51
|
clip: "rect(0 0 0 0)",
|
|
152
52
|
height: "1px",
|
|
@@ -161,22 +61,14 @@ function getSelectableRowId(row, index, selectID) {
|
|
|
161
61
|
return selectID ? row[selectID] : index;
|
|
162
62
|
}
|
|
163
63
|
function getSearchableColumnIds(headers) {
|
|
164
|
-
return headers.filter(
|
|
165
|
-
return column.searchable;
|
|
166
|
-
}).map(function (column) {
|
|
167
|
-
return column.id;
|
|
168
|
-
});
|
|
64
|
+
return headers.filter(column => column.searchable).map(column => column.id);
|
|
169
65
|
}
|
|
170
66
|
function filterRows(data, searchTerm, filterOptions) {
|
|
171
67
|
if (!searchTerm) {
|
|
172
68
|
return data;
|
|
173
69
|
}
|
|
174
|
-
|
|
175
|
-
return data.filter(
|
|
176
|
-
return filterOptions.some(function (filterOption) {
|
|
177
|
-
return String(row[filterOption]).toLocaleLowerCase().includes(term);
|
|
178
|
-
});
|
|
179
|
-
});
|
|
70
|
+
const term = searchTerm.toLocaleLowerCase();
|
|
71
|
+
return data.filter(row => filterOptions.some(filterOption => String(row[filterOption]).toLocaleLowerCase().includes(term)));
|
|
180
72
|
}
|
|
181
73
|
function getPageOptions(rowCount) {
|
|
182
74
|
if (rowCount <= 5) return [5];
|
|
@@ -187,7 +79,7 @@ function getPageOptions(rowCount) {
|
|
|
187
79
|
return [5, 10, 25, 50, 100, rowCount];
|
|
188
80
|
}
|
|
189
81
|
function splitHeaders(headers) {
|
|
190
|
-
return headers.reduce(
|
|
82
|
+
return headers.reduce((groups, header) => {
|
|
191
83
|
if (header.subRow) {
|
|
192
84
|
groups.subTables.push(header);
|
|
193
85
|
} else {
|
|
@@ -209,13 +101,9 @@ function descendingComparator(a, b, orderBy) {
|
|
|
209
101
|
return 0;
|
|
210
102
|
}
|
|
211
103
|
function getComparator(order, orderBy) {
|
|
212
|
-
return order === "desc" ?
|
|
213
|
-
return descendingComparator(a, b, orderBy);
|
|
214
|
-
} : function (a, b) {
|
|
215
|
-
return -descendingComparator(a, b, orderBy);
|
|
216
|
-
};
|
|
104
|
+
return order === "desc" ? (a, b) => descendingComparator(a, b, orderBy) : (a, b) => -descendingComparator(a, b, orderBy);
|
|
217
105
|
}
|
|
218
|
-
|
|
106
|
+
const browserDateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
219
107
|
year: "numeric",
|
|
220
108
|
month: "short",
|
|
221
109
|
day: "numeric",
|
|
@@ -234,7 +122,7 @@ var browserDateTimeFormatter = new Intl.DateTimeFormat(undefined, {
|
|
|
234
122
|
* formats that Date.parse may reject.
|
|
235
123
|
*/
|
|
236
124
|
function formatCellValue(header, rowValues) {
|
|
237
|
-
|
|
125
|
+
const raw = rowValues[header.id];
|
|
238
126
|
if (!header.date) {
|
|
239
127
|
return raw;
|
|
240
128
|
}
|
|
@@ -243,32 +131,28 @@ function formatCellValue(header, rowValues) {
|
|
|
243
131
|
if (raw === null || raw === undefined) {
|
|
244
132
|
return raw;
|
|
245
133
|
}
|
|
246
|
-
|
|
134
|
+
const d = new Date(raw);
|
|
247
135
|
if (Number.isNaN(d.getTime())) {
|
|
248
136
|
return raw;
|
|
249
137
|
}
|
|
250
138
|
return browserDateTimeFormatter.format(d);
|
|
251
139
|
}
|
|
252
140
|
function stableSort(array, comparator, headers, orderBy) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}).map(function (value) {
|
|
256
|
-
return value.id;
|
|
257
|
-
}));
|
|
258
|
-
var findHeader = headers.find(function (header) {
|
|
259
|
-
return header.id === orderBy;
|
|
260
|
-
});
|
|
141
|
+
const dateColumns = new Set(headers.filter(object => object.date).map(value => value.id));
|
|
142
|
+
const findHeader = headers.find(header => header.id === orderBy);
|
|
261
143
|
|
|
262
144
|
// Build stable entries — compare pre-computed sort keys so we never
|
|
263
145
|
// mutate the original data or its shallow copies.
|
|
264
146
|
// Each entry is [originalRow, sortKey, index] so that the comparator
|
|
265
147
|
// works on numeric-converted date values while the original rows are
|
|
266
148
|
// returned unchanged (preserving the data seen by header.component).
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
149
|
+
const stabilizedThis = array.map((el, index) => {
|
|
150
|
+
const sortKey = {
|
|
151
|
+
...el
|
|
152
|
+
};
|
|
153
|
+
for (const property in sortKey) {
|
|
270
154
|
if (dateColumns.has(property)) {
|
|
271
|
-
|
|
155
|
+
const parsed = Number(new Date(sortKey[property]));
|
|
272
156
|
// Preserve the original value for invalid dates so formatCellValue
|
|
273
157
|
// can display the fallback instead of passing NaN to React children.
|
|
274
158
|
if (!Number.isNaN(parsed)) {
|
|
@@ -278,107 +162,87 @@ function stableSort(array, comparator, headers, orderBy) {
|
|
|
278
162
|
}
|
|
279
163
|
return [el, sortKey, index];
|
|
280
164
|
});
|
|
281
|
-
if (
|
|
282
|
-
stabilizedThis.sort(
|
|
283
|
-
|
|
165
|
+
if (findHeader?.sortable === undefined || findHeader?.sortable === false) {
|
|
166
|
+
stabilizedThis.sort((a, b) => {
|
|
167
|
+
const order = comparator(a[1], b[1]);
|
|
284
168
|
if (order !== 0) return order;
|
|
285
169
|
return a[2] - b[2];
|
|
286
170
|
});
|
|
287
171
|
}
|
|
288
|
-
return stabilizedThis.map(
|
|
289
|
-
return el[0];
|
|
290
|
-
});
|
|
172
|
+
return stabilizedThis.map(el => el[0]);
|
|
291
173
|
}
|
|
292
174
|
|
|
293
175
|
function useSearchableRows(data, headers, async) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
setSearchTerm = _React$useState2[1];
|
|
298
|
-
var filterOptions = React.useMemo(function () {
|
|
299
|
-
return getSearchableColumnIds(headers);
|
|
300
|
-
}, [headers]);
|
|
301
|
-
var rows = React.useMemo(function () {
|
|
302
|
-
return async ? data : filterRows(data, searchTerm, filterOptions);
|
|
303
|
-
}, [async, data, filterOptions, searchTerm]);
|
|
176
|
+
const [searchTerm, setSearchTerm] = React.useState("");
|
|
177
|
+
const filterOptions = React.useMemo(() => getSearchableColumnIds(headers), [headers]);
|
|
178
|
+
const rows = React.useMemo(() => async ? data : filterRows(data, searchTerm, filterOptions), [async, data, filterOptions, searchTerm]);
|
|
304
179
|
return {
|
|
305
|
-
rows
|
|
306
|
-
searchTerm
|
|
307
|
-
setSearchTerm
|
|
180
|
+
rows,
|
|
181
|
+
searchTerm,
|
|
182
|
+
setSearchTerm
|
|
308
183
|
};
|
|
309
184
|
}
|
|
310
185
|
|
|
311
|
-
function useSelectableRows(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
setSelected = _React$useState2[1];
|
|
319
|
-
var clearSelection = React.useCallback(function () {
|
|
186
|
+
function useSelectableRows({
|
|
187
|
+
rows,
|
|
188
|
+
selectRows,
|
|
189
|
+
selectID
|
|
190
|
+
}) {
|
|
191
|
+
const [selected, setSelected] = React.useState([]);
|
|
192
|
+
const clearSelection = React.useCallback(() => {
|
|
320
193
|
setSelected([]);
|
|
321
194
|
}, []);
|
|
322
|
-
|
|
195
|
+
const handleSelectAllClick = React.useCallback(event => {
|
|
323
196
|
if (!event.target.checked) {
|
|
324
197
|
setSelected([]);
|
|
325
198
|
return;
|
|
326
199
|
}
|
|
327
|
-
|
|
328
|
-
return getSelectableRowId(row, index, selectID);
|
|
329
|
-
});
|
|
200
|
+
const newSelected = rows.map((row, index) => getSelectableRowId(row, index, selectID));
|
|
330
201
|
setSelected(newSelected);
|
|
331
202
|
}, [rows, selectID]);
|
|
332
|
-
|
|
203
|
+
const handleClick = React.useCallback((event, id) => {
|
|
333
204
|
if (!selectRows) {
|
|
334
205
|
return;
|
|
335
206
|
}
|
|
336
|
-
setSelected(
|
|
337
|
-
return previous.includes(id) ? previous.filter(function (selectedId) {
|
|
338
|
-
return selectedId !== id;
|
|
339
|
-
}) : [].concat(_toConsumableArray(previous), [id]);
|
|
340
|
-
});
|
|
207
|
+
setSelected(previous => previous.includes(id) ? previous.filter(selectedId => selectedId !== id) : [...previous, id]);
|
|
341
208
|
}, [selectRows]);
|
|
342
209
|
return {
|
|
343
|
-
selected
|
|
344
|
-
clearSelection
|
|
345
|
-
handleSelectAllClick
|
|
346
|
-
handleClick
|
|
210
|
+
selected,
|
|
211
|
+
clearSelection,
|
|
212
|
+
handleSelectAllClick,
|
|
213
|
+
handleClick
|
|
347
214
|
};
|
|
348
215
|
}
|
|
349
216
|
|
|
350
|
-
function TableSelectionBanner(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
217
|
+
function TableSelectionBanner({
|
|
218
|
+
selected,
|
|
219
|
+
onSelection,
|
|
220
|
+
selectIcon
|
|
221
|
+
}) {
|
|
222
|
+
return /*#__PURE__*/jsxDEV(Collapse, {
|
|
223
|
+
in: selected.length > 0,
|
|
356
224
|
unmountOnExit: true,
|
|
357
|
-
children: /*#__PURE__*/
|
|
225
|
+
children: /*#__PURE__*/jsxDEV(Box, {
|
|
358
226
|
sx: {
|
|
359
227
|
p: 2,
|
|
360
228
|
display: "flex",
|
|
361
229
|
justifyContent: "space-between",
|
|
362
|
-
bgcolor:
|
|
363
|
-
return alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity);
|
|
364
|
-
},
|
|
230
|
+
bgcolor: theme => alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
|
|
365
231
|
borderRadius: 1,
|
|
366
232
|
borderBottomLeftRadius: 0,
|
|
367
233
|
borderBottomRightRadius: 0
|
|
368
234
|
},
|
|
369
|
-
children: [/*#__PURE__*/
|
|
235
|
+
children: [/*#__PURE__*/jsxDEV(Typography, {
|
|
370
236
|
variant: "h6",
|
|
371
237
|
id: "tableTitle",
|
|
372
238
|
component: "div",
|
|
373
239
|
children: [selected.length, " selected"]
|
|
374
|
-
}), /*#__PURE__*/
|
|
375
|
-
onClick:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
})
|
|
381
|
-
});
|
|
240
|
+
}, void 0, true), /*#__PURE__*/jsxDEV(IconButton, {
|
|
241
|
+
onClick: () => onSelection(selected),
|
|
242
|
+
children: selectIcon || /*#__PURE__*/jsxDEV(Task, {}, void 0, false)
|
|
243
|
+
}, void 0, false)]
|
|
244
|
+
}, void 0, true)
|
|
245
|
+
}, void 0, false);
|
|
382
246
|
}
|
|
383
247
|
TableSelectionBanner.propTypes = {
|
|
384
248
|
selected: PropTypes.array.isRequired,
|
|
@@ -386,45 +250,47 @@ TableSelectionBanner.propTypes = {
|
|
|
386
250
|
selectIcon: PropTypes.element
|
|
387
251
|
};
|
|
388
252
|
|
|
389
|
-
function TableTitle(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
253
|
+
function TableTitle({
|
|
254
|
+
name,
|
|
255
|
+
subTable
|
|
256
|
+
}) {
|
|
257
|
+
return /*#__PURE__*/jsxDEV(Typography, {
|
|
393
258
|
variant: subTable ? "h6" : "h5",
|
|
394
259
|
color: subTable ? "secondary" : "primary",
|
|
395
260
|
sx: {
|
|
396
261
|
p: 2
|
|
397
262
|
},
|
|
398
263
|
children: name
|
|
399
|
-
});
|
|
264
|
+
}, void 0, false);
|
|
400
265
|
}
|
|
401
266
|
TableTitle.propTypes = {
|
|
402
267
|
name: PropTypes.string,
|
|
403
268
|
subTable: PropTypes.bool
|
|
404
269
|
};
|
|
405
270
|
|
|
406
|
-
function ReloadBtn(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
271
|
+
function ReloadBtn({
|
|
272
|
+
loading,
|
|
273
|
+
onReload
|
|
274
|
+
}) {
|
|
275
|
+
const canReload = typeof onReload === "function";
|
|
410
276
|
if (!canReload) {
|
|
411
277
|
return null;
|
|
412
278
|
}
|
|
413
|
-
|
|
279
|
+
const handleClick = () => {
|
|
414
280
|
if (typeof onReload === "function") {
|
|
415
281
|
onReload();
|
|
416
282
|
}
|
|
417
283
|
};
|
|
418
|
-
return /*#__PURE__*/
|
|
284
|
+
return /*#__PURE__*/jsxDEV(Tooltip, {
|
|
419
285
|
title: "Reload",
|
|
420
|
-
children: /*#__PURE__*/
|
|
286
|
+
children: /*#__PURE__*/jsxDEV(Button, {
|
|
421
287
|
variant: "contained",
|
|
422
288
|
color: "primary",
|
|
423
289
|
onClick: handleClick,
|
|
424
290
|
disabled: loading,
|
|
425
|
-
children: /*#__PURE__*/
|
|
426
|
-
})
|
|
427
|
-
});
|
|
291
|
+
children: /*#__PURE__*/jsxDEV(RefreshIcon, {}, void 0, false)
|
|
292
|
+
}, void 0, false)
|
|
293
|
+
}, void 0, false);
|
|
428
294
|
}
|
|
429
295
|
ReloadBtn.propTypes = {
|
|
430
296
|
loading: PropTypes.bool,
|
|
@@ -432,29 +298,27 @@ ReloadBtn.propTypes = {
|
|
|
432
298
|
onReload: PropTypes.func
|
|
433
299
|
};
|
|
434
300
|
|
|
435
|
-
function FancySearch(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
var expanded = hover || Boolean(value);
|
|
443
|
-
var handleSubmit = function handleSubmit(e) {
|
|
301
|
+
function FancySearch({
|
|
302
|
+
value,
|
|
303
|
+
onSubmit
|
|
304
|
+
}) {
|
|
305
|
+
const [hover, setHover] = React.useState(Boolean(value));
|
|
306
|
+
const expanded = hover || Boolean(value);
|
|
307
|
+
const handleSubmit = e => {
|
|
444
308
|
e.preventDefault();
|
|
445
309
|
onSubmit(value);
|
|
446
310
|
};
|
|
447
|
-
|
|
311
|
+
const handleEndHover = () => {
|
|
448
312
|
setHover(false);
|
|
449
313
|
};
|
|
450
314
|
|
|
451
315
|
// Sync internal state when the parent clears/changes the search term.
|
|
452
316
|
// A ref tracks whether this sync came from the user typing or from a parent
|
|
453
317
|
// update, so the debounce only fires for genuine user input.
|
|
454
|
-
|
|
455
|
-
return /*#__PURE__*/
|
|
318
|
+
const isUserTypingRef = React.useRef(false);
|
|
319
|
+
return /*#__PURE__*/jsxDEV("form", {
|
|
456
320
|
onSubmit: handleSubmit,
|
|
457
|
-
children: /*#__PURE__*/
|
|
321
|
+
children: /*#__PURE__*/jsxDEV(Paper, {
|
|
458
322
|
elevation: 0,
|
|
459
323
|
sx: {
|
|
460
324
|
borderRadius: expanded ? "24px" : "50px",
|
|
@@ -463,63 +327,58 @@ function FancySearch(_ref) {
|
|
|
463
327
|
transition: "all 0.5s ease-in-out",
|
|
464
328
|
p: expanded ? 1 : 0.5,
|
|
465
329
|
width: "fit-content",
|
|
466
|
-
border:
|
|
467
|
-
return "1px solid ".concat(theme.palette.divider);
|
|
468
|
-
},
|
|
330
|
+
border: theme => `1px solid ${theme.palette.divider}`,
|
|
469
331
|
mb: 1
|
|
470
332
|
},
|
|
471
|
-
onMouseEnter:
|
|
472
|
-
return setHover(true);
|
|
473
|
-
},
|
|
333
|
+
onMouseEnter: () => setHover(true),
|
|
474
334
|
onMouseLeave: handleEndHover,
|
|
475
|
-
onKeyDown:
|
|
476
|
-
|
|
477
|
-
},
|
|
478
|
-
children: [/*#__PURE__*/jsx(InputBase, {
|
|
335
|
+
onKeyDown: e => e.key === "Enter" && handleSubmit(e),
|
|
336
|
+
children: [/*#__PURE__*/jsxDEV(InputBase, {
|
|
479
337
|
placeholder: "Search",
|
|
480
338
|
value: value,
|
|
481
|
-
onChange:
|
|
339
|
+
onChange: e => {
|
|
482
340
|
isUserTypingRef.current = true;
|
|
483
341
|
onSubmit(e.target.value);
|
|
484
342
|
},
|
|
485
|
-
sx:
|
|
343
|
+
sx: {
|
|
486
344
|
ml: 1,
|
|
487
345
|
width: expanded ? "100%" : 0,
|
|
488
|
-
transition: "width 0.5s ease-in-out"
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
346
|
+
transition: "width 0.5s ease-in-out",
|
|
347
|
+
...(expanded ? {} : {
|
|
348
|
+
margin: 0
|
|
349
|
+
})
|
|
350
|
+
},
|
|
492
351
|
onBlur: handleEndHover
|
|
493
|
-
}), /*#__PURE__*/
|
|
494
|
-
|
|
352
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(Collapse, {
|
|
353
|
+
in: Boolean(value),
|
|
495
354
|
orientation: "horizontal",
|
|
496
355
|
unmountOnExit: true,
|
|
497
|
-
children: /*#__PURE__*/
|
|
356
|
+
children: /*#__PURE__*/jsxDEV(Stack, {
|
|
498
357
|
direction: "row",
|
|
499
358
|
spacing: 0,
|
|
500
359
|
sx: {
|
|
501
360
|
mr: 3,
|
|
502
361
|
alignItems: "center"
|
|
503
362
|
},
|
|
504
|
-
children: [/*#__PURE__*/
|
|
505
|
-
onClick:
|
|
363
|
+
children: [/*#__PURE__*/jsxDEV(IconButton, {
|
|
364
|
+
onClick: () => {
|
|
506
365
|
isUserTypingRef.current = false;
|
|
507
366
|
// Immediately clear instead of waiting for the debounce
|
|
508
367
|
onSubmit("");
|
|
509
368
|
},
|
|
510
|
-
children: /*#__PURE__*/
|
|
511
|
-
}), /*#__PURE__*/
|
|
369
|
+
children: /*#__PURE__*/jsxDEV(Clear, {}, void 0, false)
|
|
370
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(Divider, {
|
|
512
371
|
orientation: "vertical",
|
|
513
372
|
flexItem: true
|
|
514
|
-
})]
|
|
515
|
-
})
|
|
516
|
-
}), /*#__PURE__*/
|
|
373
|
+
}, void 0, false)]
|
|
374
|
+
}, void 0, true)
|
|
375
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(IconButton, {
|
|
517
376
|
onClick: handleSubmit,
|
|
518
377
|
type: "submit",
|
|
519
|
-
children: /*#__PURE__*/
|
|
520
|
-
})]
|
|
521
|
-
})
|
|
522
|
-
});
|
|
378
|
+
children: /*#__PURE__*/jsxDEV(Search, {}, void 0, false)
|
|
379
|
+
}, void 0, false)]
|
|
380
|
+
}, void 0, true)
|
|
381
|
+
}, void 0, false);
|
|
523
382
|
}
|
|
524
383
|
FancySearch.propTypes = {
|
|
525
384
|
value: PropTypes.string,
|
|
@@ -527,24 +386,25 @@ FancySearch.propTypes = {
|
|
|
527
386
|
};
|
|
528
387
|
|
|
529
388
|
function SearchArea(props) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
389
|
+
const {
|
|
390
|
+
current,
|
|
391
|
+
setFinalVal,
|
|
392
|
+
searchName,
|
|
393
|
+
persistSearch
|
|
394
|
+
} = props;
|
|
395
|
+
const searchVal = React.useMemo(() => {
|
|
535
396
|
if (current !== undefined && current !== null) return current;
|
|
536
397
|
if (persistSearch && searchName) {
|
|
537
|
-
|
|
538
|
-
return (_sessionStorage$getIt = sessionStorage.getItem("searchVal:".concat(searchName))) !== null && _sessionStorage$getIt !== void 0 ? _sessionStorage$getIt : "";
|
|
398
|
+
return sessionStorage.getItem(`searchVal:${searchName}`) ?? "";
|
|
539
399
|
}
|
|
540
400
|
return "";
|
|
541
401
|
}, [current, persistSearch, searchName]);
|
|
542
|
-
return /*#__PURE__*/
|
|
543
|
-
children: /*#__PURE__*/
|
|
402
|
+
return /*#__PURE__*/jsxDEV("div", {
|
|
403
|
+
children: /*#__PURE__*/jsxDEV(FancySearch, {
|
|
544
404
|
value: searchVal,
|
|
545
405
|
onSubmit: setFinalVal
|
|
546
|
-
})
|
|
547
|
-
}, "SearchArea");
|
|
406
|
+
}, void 0, false)
|
|
407
|
+
}, "SearchArea", false);
|
|
548
408
|
}
|
|
549
409
|
SearchArea.propTypes = {
|
|
550
410
|
current: PropTypes.string,
|
|
@@ -554,14 +414,15 @@ SearchArea.propTypes = {
|
|
|
554
414
|
persistSearch: PropTypes.bool
|
|
555
415
|
};
|
|
556
416
|
|
|
557
|
-
function TableToolbarContent(
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
417
|
+
function TableToolbarContent({
|
|
418
|
+
onReload,
|
|
419
|
+
reloadBtnLoading,
|
|
420
|
+
searchTerm,
|
|
421
|
+
onSearchChange,
|
|
422
|
+
name,
|
|
423
|
+
persistSearch
|
|
424
|
+
}) {
|
|
425
|
+
return /*#__PURE__*/jsxDEV(Toolbar, {
|
|
565
426
|
sx: {
|
|
566
427
|
pl: {
|
|
567
428
|
sm: 2
|
|
@@ -572,7 +433,7 @@ function TableToolbarContent(_ref) {
|
|
|
572
433
|
},
|
|
573
434
|
pt: 2
|
|
574
435
|
},
|
|
575
|
-
children: /*#__PURE__*/
|
|
436
|
+
children: /*#__PURE__*/jsxDEV(Stack, {
|
|
576
437
|
spacing: 2,
|
|
577
438
|
direction: {
|
|
578
439
|
xs: "column",
|
|
@@ -585,23 +446,23 @@ function TableToolbarContent(_ref) {
|
|
|
585
446
|
md: "center"
|
|
586
447
|
}
|
|
587
448
|
},
|
|
588
|
-
children: [/*#__PURE__*/
|
|
449
|
+
children: [/*#__PURE__*/jsxDEV(Box, {
|
|
589
450
|
sx: {
|
|
590
451
|
flex: "1 1 100%"
|
|
591
452
|
},
|
|
592
453
|
id: "tableTitle",
|
|
593
|
-
children: /*#__PURE__*/
|
|
454
|
+
children: /*#__PURE__*/jsxDEV(ReloadBtn, {
|
|
594
455
|
onReload: onReload,
|
|
595
456
|
loading: reloadBtnLoading
|
|
596
|
-
})
|
|
597
|
-
}), /*#__PURE__*/
|
|
457
|
+
}, void 0, false)
|
|
458
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(SearchArea, {
|
|
598
459
|
current: searchTerm,
|
|
599
460
|
setFinalVal: onSearchChange,
|
|
600
461
|
searchName: name,
|
|
601
462
|
persistSearch: persistSearch
|
|
602
|
-
})]
|
|
603
|
-
})
|
|
604
|
-
});
|
|
463
|
+
}, void 0, false)]
|
|
464
|
+
}, void 0, true)
|
|
465
|
+
}, void 0, false);
|
|
605
466
|
}
|
|
606
467
|
TableToolbarContent.propTypes = {
|
|
607
468
|
onReload: PropTypes.func,
|
|
@@ -612,86 +473,82 @@ TableToolbarContent.propTypes = {
|
|
|
612
473
|
persistSearch: PropTypes.bool
|
|
613
474
|
};
|
|
614
475
|
|
|
615
|
-
function getInitialRowsPerPage(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
476
|
+
function getInitialRowsPerPage({
|
|
477
|
+
rows,
|
|
478
|
+
subTable,
|
|
479
|
+
pageSizeOptions
|
|
480
|
+
}) {
|
|
619
481
|
if (subTable) return rows.length;
|
|
620
482
|
if (Array.isArray(pageSizeOptions) && pageSizeOptions.length > 0) {
|
|
621
483
|
return pageSizeOptions[0];
|
|
622
484
|
}
|
|
623
485
|
return 5;
|
|
624
486
|
}
|
|
625
|
-
function useEnhancedTableState(
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
}),
|
|
645
|
-
resetFlag: resetFlag
|
|
646
|
-
};
|
|
487
|
+
function useEnhancedTableState({
|
|
488
|
+
rows,
|
|
489
|
+
subTable,
|
|
490
|
+
pageSizeOptions,
|
|
491
|
+
resetFlag,
|
|
492
|
+
apiCall,
|
|
493
|
+
searchTerm,
|
|
494
|
+
setOrder,
|
|
495
|
+
setOrderBy,
|
|
496
|
+
order,
|
|
497
|
+
orderBy,
|
|
498
|
+
asyncPages
|
|
499
|
+
}) {
|
|
500
|
+
const [pagination, setPagination] = React.useState(() => ({
|
|
501
|
+
page: 0,
|
|
502
|
+
rowsPerPage: getInitialRowsPerPage({
|
|
503
|
+
rows,
|
|
504
|
+
subTable,
|
|
505
|
+
pageSizeOptions
|
|
647
506
|
}),
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
React.useEffect(function () {
|
|
507
|
+
resetFlag
|
|
508
|
+
}));
|
|
509
|
+
React.useEffect(() => {
|
|
652
510
|
// Resetting derived pagination state here intentionally preserves the
|
|
653
511
|
// current rows-per-page choice while jumping back to the first page.
|
|
654
512
|
// eslint-disable-next-line @eslint-react/set-state-in-effect
|
|
655
|
-
setPagination(
|
|
513
|
+
setPagination(previous => {
|
|
656
514
|
if (previous.resetFlag === resetFlag) {
|
|
657
515
|
return previous;
|
|
658
516
|
}
|
|
659
|
-
return
|
|
517
|
+
return {
|
|
518
|
+
...previous,
|
|
660
519
|
page: 0,
|
|
661
|
-
resetFlag
|
|
662
|
-
}
|
|
520
|
+
resetFlag
|
|
521
|
+
};
|
|
663
522
|
});
|
|
664
523
|
}, [resetFlag]);
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
524
|
+
const page = pagination.page;
|
|
525
|
+
const rowsPerPage = subTable ? rows.length : pagination.rowsPerPage;
|
|
526
|
+
const handleRequestSort = React.useCallback(property => {
|
|
527
|
+
const isAsc = orderBy === property && order === "asc";
|
|
669
528
|
setOrder(isAsc ? "desc" : "asc");
|
|
670
529
|
setOrderBy(property);
|
|
671
530
|
}, [order, orderBy, setOrder, setOrderBy]);
|
|
672
|
-
|
|
673
|
-
setPagination(
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
});
|
|
531
|
+
const handleChangePage = React.useCallback((event, newPage) => {
|
|
532
|
+
setPagination(previous => ({
|
|
533
|
+
...previous,
|
|
534
|
+
page: newPage
|
|
535
|
+
}));
|
|
678
536
|
}, []);
|
|
679
|
-
|
|
680
|
-
setPagination(
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
});
|
|
537
|
+
const handleChangeRowsPerPage = React.useCallback(event => {
|
|
538
|
+
setPagination(previous => ({
|
|
539
|
+
...previous,
|
|
540
|
+
page: 0,
|
|
541
|
+
rowsPerPage: Number.parseInt(event.target.value, 10)
|
|
542
|
+
}));
|
|
686
543
|
}, []);
|
|
687
|
-
|
|
544
|
+
const handleSort = (column, apiSortable) => {
|
|
688
545
|
if (apiSortable) {
|
|
689
|
-
|
|
546
|
+
const direction = order === "asc" ? "desc" : "asc";
|
|
690
547
|
apiCall({
|
|
691
|
-
searchTerm
|
|
692
|
-
column
|
|
693
|
-
direction
|
|
694
|
-
pages: asyncPages
|
|
548
|
+
searchTerm,
|
|
549
|
+
column,
|
|
550
|
+
direction,
|
|
551
|
+
pages: asyncPages ?? 1
|
|
695
552
|
});
|
|
696
553
|
setOrder(direction);
|
|
697
554
|
setOrderBy(column);
|
|
@@ -700,57 +557,55 @@ function useEnhancedTableState(_ref2) {
|
|
|
700
557
|
handleRequestSort(column);
|
|
701
558
|
};
|
|
702
559
|
return {
|
|
703
|
-
order
|
|
704
|
-
orderBy
|
|
705
|
-
page
|
|
706
|
-
rowsPerPage
|
|
707
|
-
handleChangePage
|
|
708
|
-
handleChangeRowsPerPage
|
|
709
|
-
handleSort
|
|
560
|
+
order,
|
|
561
|
+
orderBy,
|
|
562
|
+
page,
|
|
563
|
+
rowsPerPage,
|
|
564
|
+
handleChangePage,
|
|
565
|
+
handleChangeRowsPerPage,
|
|
566
|
+
handleSort
|
|
710
567
|
};
|
|
711
568
|
}
|
|
712
569
|
|
|
713
570
|
function EnhancedTableHead(props) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
571
|
+
const {
|
|
572
|
+
order,
|
|
573
|
+
orderBy,
|
|
574
|
+
onRequestSort,
|
|
575
|
+
selectRows,
|
|
576
|
+
numSelected,
|
|
577
|
+
rowCount,
|
|
578
|
+
onSelectAllClick,
|
|
579
|
+
async
|
|
580
|
+
} = props;
|
|
581
|
+
return /*#__PURE__*/jsxDEV(TableHead, {
|
|
582
|
+
children: /*#__PURE__*/jsxDEV(TableRow, {
|
|
583
|
+
children: [selectRows && /*#__PURE__*/jsxDEV(TableCell, {
|
|
725
584
|
padding: "checkbox",
|
|
726
|
-
children: /*#__PURE__*/
|
|
585
|
+
children: /*#__PURE__*/jsxDEV(Checkbox, {
|
|
727
586
|
color: "primary",
|
|
728
587
|
indeterminate: numSelected > 0 && numSelected < rowCount,
|
|
729
588
|
checked: rowCount > 0 && numSelected === rowCount,
|
|
730
589
|
onChange: onSelectAllClick
|
|
731
|
-
})
|
|
732
|
-
}), props.headings.map(
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
children:
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
}, headCell.id);
|
|
751
|
-
})]
|
|
752
|
-
})
|
|
753
|
-
});
|
|
590
|
+
}, void 0, false)
|
|
591
|
+
}, void 0, false), props.headings.map(headCell => /*#__PURE__*/jsxDEV(TableCell, {
|
|
592
|
+
align: headCell.numeric ? "right" : "left",
|
|
593
|
+
padding: "normal",
|
|
594
|
+
sortDirection: orderBy === headCell.id ? order : false,
|
|
595
|
+
children: /*#__PURE__*/jsxDEV(TableSortLabel, {
|
|
596
|
+
active: orderBy === headCell.id,
|
|
597
|
+
direction: orderBy === headCell.id ? order : "asc",
|
|
598
|
+
onClick: () => onRequestSort(headCell.id, headCell.sortable && async),
|
|
599
|
+
disabled: headCell.subRow,
|
|
600
|
+
children: [headCell.label, orderBy === headCell.id ? /*#__PURE__*/jsxDEV(Box, {
|
|
601
|
+
component: "span",
|
|
602
|
+
sx: visuallyHidden,
|
|
603
|
+
children: order === "desc" ? "sorted descending" : "sorted ascending"
|
|
604
|
+
}, void 0, false) : undefined]
|
|
605
|
+
}, void 0, true)
|
|
606
|
+
}, headCell.id, false))]
|
|
607
|
+
}, void 0, true)
|
|
608
|
+
}, void 0, false);
|
|
754
609
|
}
|
|
755
610
|
EnhancedTableHead.propTypes = {
|
|
756
611
|
onRequestSort: PropTypes.func.isRequired,
|
|
@@ -764,32 +619,31 @@ EnhancedTableHead.propTypes = {
|
|
|
764
619
|
async: PropTypes.bool
|
|
765
620
|
};
|
|
766
621
|
|
|
767
|
-
|
|
768
|
-
return Promise.resolve().then(function () { return UniversalTable$1; });
|
|
769
|
-
});
|
|
622
|
+
const UniversalTable$2 = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return UniversalTable$1; }));
|
|
770
623
|
|
|
771
624
|
// ---------------------------------------------------------------------------
|
|
772
625
|
// SubRowToggleCell
|
|
773
626
|
// ---------------------------------------------------------------------------
|
|
774
627
|
|
|
775
|
-
function SubRowToggleCell(
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
628
|
+
function SubRowToggleCell({
|
|
629
|
+
header,
|
|
630
|
+
isOpen,
|
|
631
|
+
onToggle,
|
|
632
|
+
rowValues,
|
|
633
|
+
hideBadge
|
|
634
|
+
}) {
|
|
635
|
+
return /*#__PURE__*/jsxDEV(TableCell, {
|
|
636
|
+
children: /*#__PURE__*/jsxDEV(Tooltip, {
|
|
637
|
+
title: isOpen ? `Hide ${header.id}` : `Show ${header.id}`,
|
|
638
|
+
children: /*#__PURE__*/jsxDEV(Box, {
|
|
639
|
+
children: /*#__PURE__*/jsxDEV(IconButton, {
|
|
640
|
+
onClick: event => {
|
|
787
641
|
event.stopPropagation();
|
|
788
642
|
onToggle();
|
|
789
643
|
},
|
|
790
644
|
disabled: rowValues[header.id].length === 0,
|
|
791
645
|
color: header.iconColor || "secondary",
|
|
792
|
-
children: /*#__PURE__*/
|
|
646
|
+
children: /*#__PURE__*/jsxDEV(Badge, {
|
|
793
647
|
badgeContent: rowValues[header.id].length,
|
|
794
648
|
invisible: hideBadge,
|
|
795
649
|
anchorOrigin: {
|
|
@@ -798,17 +652,15 @@ function SubRowToggleCell(_ref) {
|
|
|
798
652
|
},
|
|
799
653
|
sx: {
|
|
800
654
|
"& .MuiBadge-badge": {
|
|
801
|
-
color:
|
|
802
|
-
return theme.palette.text.primary;
|
|
803
|
-
}
|
|
655
|
+
color: theme => theme.palette.text.primary
|
|
804
656
|
}
|
|
805
657
|
},
|
|
806
|
-
children: isOpen ?
|
|
807
|
-
})
|
|
808
|
-
})
|
|
809
|
-
})
|
|
810
|
-
})
|
|
811
|
-
});
|
|
658
|
+
children: isOpen ? header?.closeIcon || /*#__PURE__*/jsxDEV(RemoveCircle, {}, void 0, false) : header?.openIcon || /*#__PURE__*/jsxDEV(AddCircle, {}, void 0, false)
|
|
659
|
+
}, void 0, false)
|
|
660
|
+
}, void 0, false)
|
|
661
|
+
}, void 0, false)
|
|
662
|
+
}, void 0, false)
|
|
663
|
+
}, void 0, false);
|
|
812
664
|
}
|
|
813
665
|
SubRowToggleCell.propTypes = {
|
|
814
666
|
header: PropTypes.object.isRequired,
|
|
@@ -822,25 +674,26 @@ SubRowToggleCell.propTypes = {
|
|
|
822
674
|
// SubTableRow
|
|
823
675
|
// ---------------------------------------------------------------------------
|
|
824
676
|
|
|
825
|
-
function SubTableRow(
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
677
|
+
function SubTableRow({
|
|
678
|
+
table,
|
|
679
|
+
isOpen,
|
|
680
|
+
rowValues,
|
|
681
|
+
colSpan
|
|
682
|
+
}) {
|
|
683
|
+
return /*#__PURE__*/jsxDEV(TableRow, {
|
|
684
|
+
children: /*#__PURE__*/jsxDEV(TableCell, {
|
|
832
685
|
colSpan: colSpan,
|
|
833
686
|
style: {
|
|
834
687
|
paddingBottom: 0,
|
|
835
688
|
paddingTop: 0
|
|
836
689
|
},
|
|
837
|
-
children: /*#__PURE__*/
|
|
838
|
-
|
|
690
|
+
children: /*#__PURE__*/jsxDEV(Collapse, {
|
|
691
|
+
in: isOpen,
|
|
839
692
|
timeout: "auto",
|
|
840
693
|
unmountOnExit: true,
|
|
841
|
-
children: /*#__PURE__*/
|
|
694
|
+
children: /*#__PURE__*/jsxDEV(React.Suspense, {
|
|
842
695
|
fallback: null,
|
|
843
|
-
children: /*#__PURE__*/
|
|
696
|
+
children: /*#__PURE__*/jsxDEV(UniversalTable$2, {
|
|
844
697
|
loading: table.loading,
|
|
845
698
|
setLoading: table.setLoading,
|
|
846
699
|
onReload: table.onReload,
|
|
@@ -848,11 +701,11 @@ function SubTableRow(_ref2) {
|
|
|
848
701
|
headers: table.headers,
|
|
849
702
|
name: table.subTitle,
|
|
850
703
|
subTable: true
|
|
851
|
-
})
|
|
852
|
-
})
|
|
853
|
-
})
|
|
854
|
-
})
|
|
855
|
-
});
|
|
704
|
+
}, void 0, false)
|
|
705
|
+
}, void 0, false)
|
|
706
|
+
}, void 0, false)
|
|
707
|
+
}, void 0, false)
|
|
708
|
+
}, void 0, false);
|
|
856
709
|
}
|
|
857
710
|
SubTableRow.propTypes = {
|
|
858
711
|
table: PropTypes.object.isRequired,
|
|
@@ -862,84 +715,70 @@ SubTableRow.propTypes = {
|
|
|
862
715
|
};
|
|
863
716
|
|
|
864
717
|
function renderDataCells(headers, rowValues) {
|
|
865
|
-
return headers.map(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
}), (_header$id = header.id) !== null && _header$id !== void 0 ? _header$id : header.label);
|
|
870
|
-
});
|
|
718
|
+
return headers.map(header => /*#__PURE__*/jsxDEV(TableCell, {
|
|
719
|
+
...header.cellProps,
|
|
720
|
+
children: header.component ? header.component(rowValues) : formatCellValue(header, rowValues)
|
|
721
|
+
}, header.id ?? header.label, false));
|
|
871
722
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
subTables
|
|
882
|
-
columns
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
setReveal
|
|
891
|
-
|
|
892
|
-
setReveal(function (previous) {
|
|
893
|
-
var next = _toConsumableArray(previous);
|
|
723
|
+
const DataRow = /*#__PURE__*/React.memo(function DataRow(props) {
|
|
724
|
+
const {
|
|
725
|
+
rowValues,
|
|
726
|
+
headers,
|
|
727
|
+
selectRows,
|
|
728
|
+
isSelected,
|
|
729
|
+
handleClick
|
|
730
|
+
} = props;
|
|
731
|
+
const {
|
|
732
|
+
subTables,
|
|
733
|
+
columns
|
|
734
|
+
} = React.useMemo(() => splitHeaders(headers), [headers]);
|
|
735
|
+
const hideBadge = props.hideBadge || false;
|
|
736
|
+
const isItemSelected = isSelected(props.rowID);
|
|
737
|
+
const [reveal, setReveal] = React.useState(Array.from({
|
|
738
|
+
length: subTables.length
|
|
739
|
+
}).fill(false));
|
|
740
|
+
const toggleSubRow = React.useCallback(index => {
|
|
741
|
+
setReveal(previous => {
|
|
742
|
+
const next = [...previous];
|
|
894
743
|
next[index] = !next[index];
|
|
895
744
|
return next;
|
|
896
745
|
});
|
|
897
746
|
}, []);
|
|
898
|
-
|
|
747
|
+
const handleRowKeyDown = React.useCallback(event => {
|
|
899
748
|
if (selectRows && (event.key === " " || event.key === "Enter")) {
|
|
900
749
|
event.preventDefault();
|
|
901
750
|
handleClick(event, props.rowID);
|
|
902
751
|
}
|
|
903
752
|
}, [selectRows, handleClick, props.rowID]);
|
|
904
|
-
return /*#__PURE__*/
|
|
905
|
-
children: [/*#__PURE__*/
|
|
753
|
+
return /*#__PURE__*/jsxDEV(Fragment, {
|
|
754
|
+
children: [/*#__PURE__*/jsxDEV(TableRow, {
|
|
906
755
|
tabIndex: selectRows ? 0 : -1,
|
|
907
756
|
hover: selectRows,
|
|
908
757
|
role: selectRows ? "checkbox" : "row",
|
|
909
758
|
selected: isItemSelected,
|
|
910
759
|
"aria-checked": isItemSelected,
|
|
911
760
|
onKeyDown: handleRowKeyDown,
|
|
912
|
-
children: [selectRows && /*#__PURE__*/
|
|
761
|
+
children: [selectRows && /*#__PURE__*/jsxDEV(TableCell, {
|
|
913
762
|
padding: "checkbox",
|
|
914
|
-
children: /*#__PURE__*/
|
|
763
|
+
children: /*#__PURE__*/jsxDEV(Checkbox, {
|
|
915
764
|
color: "primary",
|
|
916
765
|
checked: isItemSelected,
|
|
917
|
-
onClick:
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}), subTables.map(function (header, index) {
|
|
922
|
-
var _header$id2;
|
|
923
|
-
return /*#__PURE__*/jsx(SubRowToggleCell, {
|
|
924
|
-
header: header,
|
|
925
|
-
isOpen: reveal[index],
|
|
926
|
-
onToggle: function onToggle() {
|
|
927
|
-
return toggleSubRow(index);
|
|
928
|
-
},
|
|
929
|
-
rowValues: rowValues,
|
|
930
|
-
hideBadge: hideBadge
|
|
931
|
-
}, (_header$id2 = header.id) !== null && _header$id2 !== void 0 ? _header$id2 : header.label);
|
|
932
|
-
}), renderDataCells(columns, rowValues)]
|
|
933
|
-
}), subTables.map(function (table, index) {
|
|
934
|
-
var _table$id;
|
|
935
|
-
return /*#__PURE__*/jsx(SubTableRow, {
|
|
936
|
-
table: table,
|
|
766
|
+
onClick: event => handleClick(event, props.rowID)
|
|
767
|
+
}, void 0, false)
|
|
768
|
+
}, void 0, false), subTables.map((header, index) => /*#__PURE__*/jsxDEV(SubRowToggleCell, {
|
|
769
|
+
header: header,
|
|
937
770
|
isOpen: reveal[index],
|
|
771
|
+
onToggle: () => toggleSubRow(index),
|
|
938
772
|
rowValues: rowValues,
|
|
939
|
-
|
|
940
|
-
},
|
|
941
|
-
})
|
|
942
|
-
|
|
773
|
+
hideBadge: hideBadge
|
|
774
|
+
}, header.id ?? header.label, false)), renderDataCells(columns, rowValues)]
|
|
775
|
+
}, void 0, true), subTables.map((table, index) => /*#__PURE__*/jsxDEV(SubTableRow, {
|
|
776
|
+
table: table,
|
|
777
|
+
isOpen: reveal[index],
|
|
778
|
+
rowValues: rowValues,
|
|
779
|
+
colSpan: props.headers.length + 1
|
|
780
|
+
}, table.id ?? table.label, false))]
|
|
781
|
+
}, void 0, true);
|
|
943
782
|
});
|
|
944
783
|
DataRow.propTypes = {
|
|
945
784
|
rowValues: PropTypes.object.isRequired,
|
|
@@ -951,75 +790,72 @@ DataRow.propTypes = {
|
|
|
951
790
|
rowID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
|
952
791
|
};
|
|
953
792
|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
return /*#__PURE__*/
|
|
958
|
-
children: [/*#__PURE__*/
|
|
959
|
-
children: skeletonRows.map(
|
|
960
|
-
|
|
961
|
-
children:
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
}, rowKey);
|
|
969
|
-
})
|
|
970
|
-
})]
|
|
971
|
-
});
|
|
793
|
+
const skeletonRows = ["row-1", "row-2", "row-3", "row-4", "row-5"];
|
|
794
|
+
const skeletonCells = ["cell-1", "cell-2", "cell-3", "cell-4"];
|
|
795
|
+
const TableLoader = () => {
|
|
796
|
+
return /*#__PURE__*/jsxDEV(Fragment, {
|
|
797
|
+
children: [/*#__PURE__*/jsxDEV(TableHead, {}, void 0, false), /*#__PURE__*/jsxDEV(TableBody, {
|
|
798
|
+
children: skeletonRows.map(rowKey => /*#__PURE__*/jsxDEV(TableRow, {
|
|
799
|
+
children: skeletonCells.map(cellKey => /*#__PURE__*/jsxDEV(TableCell, {
|
|
800
|
+
children: /*#__PURE__*/jsxDEV(Skeleton, {
|
|
801
|
+
height: 30
|
|
802
|
+
}, void 0, false)
|
|
803
|
+
}, cellKey, false))
|
|
804
|
+
}, rowKey, false))
|
|
805
|
+
}, void 0, false)]
|
|
806
|
+
}, void 0, true);
|
|
972
807
|
};
|
|
973
808
|
|
|
974
809
|
function EnhancedTable(props) {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
810
|
+
const {
|
|
811
|
+
headers,
|
|
812
|
+
rows,
|
|
813
|
+
subTable,
|
|
814
|
+
selected,
|
|
815
|
+
selectID,
|
|
816
|
+
setLoading,
|
|
817
|
+
searchTerm,
|
|
818
|
+
setOrder,
|
|
819
|
+
setOrderBy,
|
|
820
|
+
order,
|
|
821
|
+
orderBy,
|
|
822
|
+
async,
|
|
823
|
+
asyncPages
|
|
824
|
+
} = props;
|
|
825
|
+
const {
|
|
826
|
+
page,
|
|
827
|
+
rowsPerPage,
|
|
828
|
+
handleSort,
|
|
829
|
+
handleChangePage,
|
|
830
|
+
handleChangeRowsPerPage
|
|
831
|
+
} = useEnhancedTableState({
|
|
832
|
+
rows,
|
|
833
|
+
subTable,
|
|
834
|
+
pageSizeOptions: props.pageSizeOptions,
|
|
835
|
+
resetFlag: props.resetFlag,
|
|
836
|
+
apiCall: setLoading,
|
|
837
|
+
searchTerm,
|
|
838
|
+
setOrder,
|
|
839
|
+
setOrderBy,
|
|
840
|
+
order,
|
|
841
|
+
orderBy,
|
|
842
|
+
asyncPages
|
|
843
|
+
});
|
|
844
|
+
const effectiveRowsPerPage = rowsPerPage === -1 ? rows.length : rowsPerPage;
|
|
845
|
+
const emptyRows = Math.max(0, effectiveRowsPerPage - Math.min(effectiveRowsPerPage, rows.length - page * effectiveRowsPerPage));
|
|
846
|
+
const isSelected = React.useCallback(id => selected.includes(id), [selected]);
|
|
847
|
+
const visibleRows = React.useMemo(() => {
|
|
1012
848
|
return stableSort(rows, getComparator(order, orderBy), headers, orderBy).slice(page * effectiveRowsPerPage, page * effectiveRowsPerPage + effectiveRowsPerPage);
|
|
1013
849
|
}, [effectiveRowsPerPage, headers, order, orderBy, page, rows]);
|
|
1014
|
-
return /*#__PURE__*/
|
|
1015
|
-
children: [/*#__PURE__*/
|
|
850
|
+
return /*#__PURE__*/jsxDEV(TableContainer, {
|
|
851
|
+
children: [/*#__PURE__*/jsxDEV(Table, {
|
|
1016
852
|
sx: {
|
|
1017
853
|
minWidth: 750
|
|
1018
854
|
},
|
|
1019
855
|
size: "small" ,
|
|
1020
856
|
"aria-label": props.name || "data table",
|
|
1021
|
-
children: props.loading ? /*#__PURE__*/
|
|
1022
|
-
children: [/*#__PURE__*/
|
|
857
|
+
children: props.loading ? /*#__PURE__*/jsxDEV(TableLoader, {}, void 0, false) : /*#__PURE__*/jsxDEV(Fragment, {
|
|
858
|
+
children: [/*#__PURE__*/jsxDEV(EnhancedTableHead, {
|
|
1023
859
|
order: order,
|
|
1024
860
|
orderBy: orderBy,
|
|
1025
861
|
onRequestSort: handleSort,
|
|
@@ -1029,11 +865,11 @@ function EnhancedTable(props) {
|
|
|
1029
865
|
rowCount: rows.length,
|
|
1030
866
|
onSelectAllClick: props.handleSelectAllClick,
|
|
1031
867
|
async: async
|
|
1032
|
-
}), /*#__PURE__*/
|
|
1033
|
-
children: [visibleRows.map(
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
return /*#__PURE__*/
|
|
868
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(TableBody, {
|
|
869
|
+
children: [visibleRows.map((row, index) => {
|
|
870
|
+
const rowKey = selectID ? row[selectID] : `row-${page * effectiveRowsPerPage + index}`;
|
|
871
|
+
const rowID = getSelectableRowId(row, index, selectID);
|
|
872
|
+
return /*#__PURE__*/jsxDEV(DataRow, {
|
|
1037
873
|
rowID: rowID,
|
|
1038
874
|
headers: headers,
|
|
1039
875
|
rowValues: row,
|
|
@@ -1041,22 +877,22 @@ function EnhancedTable(props) {
|
|
|
1041
877
|
selectRows: props.selectRows,
|
|
1042
878
|
handleClick: props.handleClick,
|
|
1043
879
|
isSelected: isSelected
|
|
1044
|
-
}, rowKey);
|
|
1045
|
-
}), !subTable && emptyRows > 0 && /*#__PURE__*/
|
|
880
|
+
}, rowKey, false);
|
|
881
|
+
}), !subTable && emptyRows > 0 && /*#__PURE__*/jsxDEV(TableRow, {
|
|
1046
882
|
style: {
|
|
1047
883
|
height: (33 ) * emptyRows
|
|
1048
884
|
},
|
|
1049
|
-
children: /*#__PURE__*/
|
|
885
|
+
children: /*#__PURE__*/jsxDEV(TableCell, {
|
|
1050
886
|
colSpan: headers.length
|
|
1051
|
-
})
|
|
1052
|
-
})]
|
|
1053
|
-
})]
|
|
1054
|
-
})
|
|
1055
|
-
}), subTable ? /*#__PURE__*/
|
|
887
|
+
}, void 0, false)
|
|
888
|
+
}, void 0, false)]
|
|
889
|
+
}, void 0, true)]
|
|
890
|
+
}, void 0, true)
|
|
891
|
+
}, void 0, false), subTable ? /*#__PURE__*/jsxDEV(Box, {
|
|
1056
892
|
sx: {
|
|
1057
893
|
mb: 3
|
|
1058
894
|
}
|
|
1059
|
-
}) : /*#__PURE__*/
|
|
895
|
+
}, void 0, false) : /*#__PURE__*/jsxDEV(TablePagination, {
|
|
1060
896
|
rowsPerPageOptions: props.pageSizeOptions || getPageOptions(rows.length),
|
|
1061
897
|
component: "div",
|
|
1062
898
|
count: rows.length,
|
|
@@ -1069,8 +905,8 @@ function EnhancedTable(props) {
|
|
|
1069
905
|
},
|
|
1070
906
|
showFirstButton: true,
|
|
1071
907
|
showLastButton: true
|
|
1072
|
-
})]
|
|
1073
|
-
});
|
|
908
|
+
}, void 0, false)]
|
|
909
|
+
}, void 0, true);
|
|
1074
910
|
}
|
|
1075
911
|
EnhancedTable.propTypes = {
|
|
1076
912
|
headers: PropTypes.array.isRequired,
|
|
@@ -1096,77 +932,68 @@ EnhancedTable.propTypes = {
|
|
|
1096
932
|
asyncPages: PropTypes.number
|
|
1097
933
|
};
|
|
1098
934
|
|
|
1099
|
-
function UniversalTable(
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
selectID: selectID
|
|
1143
|
-
}),
|
|
1144
|
-
selected = _useSelectableRows.selected,
|
|
1145
|
-
clearSelection = _useSelectableRows.clearSelection,
|
|
1146
|
-
handleSelectAllClick = _useSelectableRows.handleSelectAllClick,
|
|
1147
|
-
handleClick = _useSelectableRows.handleClick;
|
|
1148
|
-
var handleSearchChange = React.useCallback(function (value) {
|
|
935
|
+
function UniversalTable({
|
|
936
|
+
loading,
|
|
937
|
+
setLoading,
|
|
938
|
+
onReload,
|
|
939
|
+
lazyloading = false,
|
|
940
|
+
currentPage,
|
|
941
|
+
totalPages,
|
|
942
|
+
data,
|
|
943
|
+
headers,
|
|
944
|
+
name,
|
|
945
|
+
reloadBtnLoading,
|
|
946
|
+
subTable = false,
|
|
947
|
+
hideBadge = false,
|
|
948
|
+
selectRows = false,
|
|
949
|
+
selectID,
|
|
950
|
+
selectIcon,
|
|
951
|
+
onSelection,
|
|
952
|
+
pageSizeOptions,
|
|
953
|
+
persistSearch,
|
|
954
|
+
asyncPages
|
|
955
|
+
}) {
|
|
956
|
+
const debounceRef = React.useRef(null);
|
|
957
|
+
const hasLoadedInitialAsyncPageRef = React.useRef(false);
|
|
958
|
+
const async = typeof asyncPages === "number" && asyncPages > 0;
|
|
959
|
+
const head = headers || [];
|
|
960
|
+
const {
|
|
961
|
+
rows,
|
|
962
|
+
searchTerm,
|
|
963
|
+
setSearchTerm
|
|
964
|
+
} = useSearchableRows(data, head, async);
|
|
965
|
+
const [order, setOrder] = React.useState("asc");
|
|
966
|
+
const [orderBy, setOrderBy] = React.useState("");
|
|
967
|
+
const {
|
|
968
|
+
selected,
|
|
969
|
+
clearSelection,
|
|
970
|
+
handleSelectAllClick,
|
|
971
|
+
handleClick
|
|
972
|
+
} = useSelectableRows({
|
|
973
|
+
rows,
|
|
974
|
+
selectRows,
|
|
975
|
+
selectID
|
|
976
|
+
});
|
|
977
|
+
const handleSearchChange = React.useCallback(value => {
|
|
1149
978
|
clearSelection();
|
|
1150
979
|
setSearchTerm(value);
|
|
1151
980
|
}, [clearSelection, setSearchTerm]);
|
|
1152
|
-
|
|
981
|
+
const handleSelection = React.useCallback(selectedIds => {
|
|
1153
982
|
if (typeof onSelection !== "function") {
|
|
1154
983
|
return;
|
|
1155
984
|
}
|
|
1156
|
-
|
|
985
|
+
const result = onSelection(selectedIds);
|
|
1157
986
|
if (result instanceof Promise) {
|
|
1158
|
-
result.then(
|
|
1159
|
-
return clearSelection();
|
|
1160
|
-
});
|
|
987
|
+
result.then(() => clearSelection());
|
|
1161
988
|
return;
|
|
1162
989
|
}
|
|
1163
990
|
clearSelection();
|
|
1164
991
|
}, [onSelection, clearSelection]);
|
|
1165
|
-
|
|
992
|
+
const handleSearch = searchValue => {
|
|
1166
993
|
if (async) {
|
|
1167
994
|
setSearchTerm(searchValue);
|
|
1168
995
|
clearTimeout(debounceRef.current);
|
|
1169
|
-
debounceRef.current = setTimeout(
|
|
996
|
+
debounceRef.current = setTimeout(() => {
|
|
1170
997
|
setLoading({
|
|
1171
998
|
searchTerm: searchValue,
|
|
1172
999
|
direction: order,
|
|
@@ -1178,61 +1005,61 @@ function UniversalTable(_ref) {
|
|
|
1178
1005
|
handleSearchChange(searchValue);
|
|
1179
1006
|
}
|
|
1180
1007
|
};
|
|
1181
|
-
React.useEffect(
|
|
1182
|
-
return
|
|
1183
|
-
return clearTimeout(debounceRef.current);
|
|
1184
|
-
};
|
|
1008
|
+
React.useEffect(() => {
|
|
1009
|
+
return () => clearTimeout(debounceRef.current);
|
|
1185
1010
|
}, []);
|
|
1186
|
-
React.useEffect(
|
|
1011
|
+
React.useEffect(() => {
|
|
1187
1012
|
if (!async || hasLoadedInitialAsyncPageRef.current) {
|
|
1188
1013
|
return;
|
|
1189
1014
|
}
|
|
1190
1015
|
hasLoadedInitialAsyncPageRef.current = true;
|
|
1191
1016
|
setLoading({
|
|
1192
|
-
searchTerm
|
|
1017
|
+
searchTerm,
|
|
1193
1018
|
direction: order,
|
|
1194
1019
|
column: orderBy,
|
|
1195
1020
|
pages: asyncPages
|
|
1196
1021
|
});
|
|
1197
1022
|
}, [async, asyncPages, order, orderBy, searchTerm, setLoading]);
|
|
1198
|
-
|
|
1023
|
+
const handleReload = React.useCallback(() => {
|
|
1199
1024
|
if (typeof onReload === "function") {
|
|
1200
1025
|
onReload();
|
|
1201
1026
|
return;
|
|
1202
1027
|
}
|
|
1203
1028
|
if (typeof setLoading === "function") {
|
|
1204
1029
|
setLoading(async ? {
|
|
1205
|
-
searchTerm
|
|
1030
|
+
searchTerm,
|
|
1206
1031
|
direction: order,
|
|
1207
1032
|
column: orderBy,
|
|
1208
1033
|
pages: asyncPages
|
|
1209
1034
|
} : true);
|
|
1210
1035
|
}
|
|
1211
1036
|
}, [async, onReload, setLoading, searchTerm, order, orderBy, asyncPages]);
|
|
1212
|
-
return /*#__PURE__*/
|
|
1213
|
-
children: [/*#__PURE__*/
|
|
1037
|
+
return /*#__PURE__*/jsxDEV(Fragment, {
|
|
1038
|
+
children: [/*#__PURE__*/jsxDEV(LazyLoadingIndicator, {
|
|
1214
1039
|
show: lazyloading,
|
|
1215
1040
|
currentPage: currentPage,
|
|
1216
1041
|
totalPages: totalPages
|
|
1217
|
-
}), /*#__PURE__*/
|
|
1218
|
-
sx:
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1042
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(Paper$1, {
|
|
1043
|
+
sx: {
|
|
1044
|
+
...(subTable && {
|
|
1045
|
+
boxShadow: "none"
|
|
1046
|
+
})
|
|
1047
|
+
},
|
|
1048
|
+
children: [/*#__PURE__*/jsxDEV(TableSelectionBanner, {
|
|
1222
1049
|
selected: selected,
|
|
1223
1050
|
onSelection: handleSelection,
|
|
1224
1051
|
selectIcon: selectIcon
|
|
1225
|
-
}), /*#__PURE__*/
|
|
1052
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(TableTitle, {
|
|
1226
1053
|
name: name,
|
|
1227
1054
|
subTable: subTable
|
|
1228
|
-
}), !subTable && /*#__PURE__*/
|
|
1055
|
+
}, void 0, false), !subTable && /*#__PURE__*/jsxDEV(TableToolbarContent, {
|
|
1229
1056
|
onReload: typeof onReload === "function" || typeof setLoading === "function" ? handleReload : undefined,
|
|
1230
1057
|
reloadBtnLoading: reloadBtnLoading,
|
|
1231
1058
|
searchTerm: searchTerm,
|
|
1232
1059
|
onSearchChange: handleSearch,
|
|
1233
1060
|
name: name,
|
|
1234
1061
|
persistSearch: persistSearch
|
|
1235
|
-
}), /*#__PURE__*/
|
|
1062
|
+
}, void 0, false), /*#__PURE__*/jsxDEV(EnhancedTable, {
|
|
1236
1063
|
headers: head,
|
|
1237
1064
|
rows: rows,
|
|
1238
1065
|
resetFlag: searchTerm,
|
|
@@ -1254,9 +1081,9 @@ function UniversalTable(_ref) {
|
|
|
1254
1081
|
setOrderBy: setOrderBy,
|
|
1255
1082
|
asyncPages: asyncPages,
|
|
1256
1083
|
async: async
|
|
1257
|
-
})]
|
|
1258
|
-
})]
|
|
1259
|
-
});
|
|
1084
|
+
}, void 0, false)]
|
|
1085
|
+
}, void 0, true)]
|
|
1086
|
+
}, void 0, true);
|
|
1260
1087
|
}
|
|
1261
1088
|
UniversalTable.propTypes = {
|
|
1262
1089
|
loading: PropTypes.bool,
|