mui-universal-table 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +451 -410
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +451 -410
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React
|
|
1
|
+
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 { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
6
|
import { alpha } from '@mui/material/styles';
|
|
6
7
|
import { Task, Clear, Search, RemoveCircle, AddCircle } from '@mui/icons-material';
|
|
7
8
|
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
@@ -25,15 +26,6 @@ function _defineProperty(e, r, t) {
|
|
|
25
26
|
writable: true
|
|
26
27
|
}) : e[r] = t, e;
|
|
27
28
|
}
|
|
28
|
-
function _extends() {
|
|
29
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
30
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
31
|
-
var t = arguments[e];
|
|
32
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
33
|
-
}
|
|
34
|
-
return n;
|
|
35
|
-
}, _extends.apply(null, arguments);
|
|
36
|
-
}
|
|
37
29
|
function _iterableToArray(r) {
|
|
38
30
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
39
31
|
}
|
|
@@ -120,25 +112,28 @@ var LazyLoadingIndicator = function LazyLoadingIndicator(_ref) {
|
|
|
120
112
|
var show = _ref.show,
|
|
121
113
|
currentPage = _ref.currentPage,
|
|
122
114
|
totalPages = _ref.totalPages;
|
|
123
|
-
return /*#__PURE__*/
|
|
115
|
+
return /*#__PURE__*/jsx(Collapse, {
|
|
124
116
|
"in": show,
|
|
125
117
|
timeout: "auto",
|
|
126
|
-
unmountOnExit: true
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
118
|
+
unmountOnExit: true,
|
|
119
|
+
children: /*#__PURE__*/jsxs(Box, {
|
|
120
|
+
sx: {
|
|
121
|
+
width: "100%",
|
|
122
|
+
p: 2
|
|
123
|
+
},
|
|
124
|
+
children: [/*#__PURE__*/jsxs(Typography, {
|
|
125
|
+
variant: "body2",
|
|
126
|
+
color: "text.secondary",
|
|
127
|
+
sx: {
|
|
128
|
+
mb: 1
|
|
129
|
+
},
|
|
130
|
+
children: ["Loading page ", currentPage, " of ", totalPages, "..."]
|
|
131
|
+
}), /*#__PURE__*/jsx(LinearProgress, {
|
|
132
|
+
variant: "determinate",
|
|
133
|
+
value: currentPage / totalPages * 100
|
|
134
|
+
})]
|
|
135
|
+
})
|
|
136
|
+
});
|
|
142
137
|
};
|
|
143
138
|
LazyLoadingIndicator.propTypes = {
|
|
144
139
|
show: PropTypes.bool.isRequired,
|
|
@@ -296,14 +291,14 @@ function stableSort(array, comparator, headers, orderBy) {
|
|
|
296
291
|
}
|
|
297
292
|
|
|
298
293
|
function useSearchableRows(data, headers, async) {
|
|
299
|
-
var _React$useState = React
|
|
294
|
+
var _React$useState = React.useState(""),
|
|
300
295
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
301
296
|
searchTerm = _React$useState2[0],
|
|
302
297
|
setSearchTerm = _React$useState2[1];
|
|
303
|
-
var filterOptions = React
|
|
298
|
+
var filterOptions = React.useMemo(function () {
|
|
304
299
|
return getSearchableColumnIds(headers);
|
|
305
300
|
}, [headers]);
|
|
306
|
-
var rows = React
|
|
301
|
+
var rows = React.useMemo(function () {
|
|
307
302
|
return async ? data : filterRows(data, searchTerm, filterOptions);
|
|
308
303
|
}, [async, data, filterOptions, searchTerm]);
|
|
309
304
|
return {
|
|
@@ -317,14 +312,14 @@ function useSelectableRows(_ref) {
|
|
|
317
312
|
var rows = _ref.rows,
|
|
318
313
|
selectRows = _ref.selectRows,
|
|
319
314
|
selectID = _ref.selectID;
|
|
320
|
-
var _React$useState = React
|
|
315
|
+
var _React$useState = React.useState([]),
|
|
321
316
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
322
317
|
selected = _React$useState2[0],
|
|
323
318
|
setSelected = _React$useState2[1];
|
|
324
|
-
var clearSelection = React
|
|
319
|
+
var clearSelection = React.useCallback(function () {
|
|
325
320
|
setSelected([]);
|
|
326
321
|
}, []);
|
|
327
|
-
var handleSelectAllClick = React
|
|
322
|
+
var handleSelectAllClick = React.useCallback(function (event) {
|
|
328
323
|
if (!event.target.checked) {
|
|
329
324
|
setSelected([]);
|
|
330
325
|
return;
|
|
@@ -334,7 +329,7 @@ function useSelectableRows(_ref) {
|
|
|
334
329
|
});
|
|
335
330
|
setSelected(newSelected);
|
|
336
331
|
}, [rows, selectID]);
|
|
337
|
-
var handleClick = React
|
|
332
|
+
var handleClick = React.useCallback(function (event, id) {
|
|
338
333
|
if (!selectRows) {
|
|
339
334
|
return;
|
|
340
335
|
}
|
|
@@ -356,30 +351,34 @@ function TableSelectionBanner(_ref) {
|
|
|
356
351
|
var selected = _ref.selected,
|
|
357
352
|
onSelection = _ref.onSelection,
|
|
358
353
|
selectIcon = _ref.selectIcon;
|
|
359
|
-
return /*#__PURE__*/
|
|
354
|
+
return /*#__PURE__*/jsx(Collapse, {
|
|
360
355
|
"in": selected.length > 0,
|
|
361
|
-
unmountOnExit: true
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
356
|
+
unmountOnExit: true,
|
|
357
|
+
children: /*#__PURE__*/jsxs(Box, {
|
|
358
|
+
sx: {
|
|
359
|
+
p: 2,
|
|
360
|
+
display: "flex",
|
|
361
|
+
justifyContent: "space-between",
|
|
362
|
+
bgcolor: function bgcolor(theme) {
|
|
363
|
+
return alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity);
|
|
364
|
+
},
|
|
365
|
+
borderRadius: 1,
|
|
366
|
+
borderBottomLeftRadius: 0,
|
|
367
|
+
borderBottomRightRadius: 0
|
|
369
368
|
},
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
}
|
|
369
|
+
children: [/*#__PURE__*/jsxs(Typography, {
|
|
370
|
+
variant: "h6",
|
|
371
|
+
id: "tableTitle",
|
|
372
|
+
component: "div",
|
|
373
|
+
children: [selected.length, " selected"]
|
|
374
|
+
}), /*#__PURE__*/jsx(IconButton, {
|
|
375
|
+
onClick: function onClick() {
|
|
376
|
+
return onSelection(selected);
|
|
377
|
+
},
|
|
378
|
+
children: selectIcon || /*#__PURE__*/jsx(Task, {})
|
|
379
|
+
})]
|
|
380
|
+
})
|
|
381
|
+
});
|
|
383
382
|
}
|
|
384
383
|
TableSelectionBanner.propTypes = {
|
|
385
384
|
selected: PropTypes.array.isRequired,
|
|
@@ -390,13 +389,14 @@ TableSelectionBanner.propTypes = {
|
|
|
390
389
|
function TableTitle(_ref) {
|
|
391
390
|
var name = _ref.name,
|
|
392
391
|
subTable = _ref.subTable;
|
|
393
|
-
return /*#__PURE__*/
|
|
392
|
+
return /*#__PURE__*/jsx(Typography, {
|
|
394
393
|
variant: subTable ? "h6" : "h5",
|
|
395
394
|
color: subTable ? "secondary" : "primary",
|
|
396
395
|
sx: {
|
|
397
396
|
p: 2
|
|
398
|
-
}
|
|
399
|
-
|
|
397
|
+
},
|
|
398
|
+
children: name
|
|
399
|
+
});
|
|
400
400
|
}
|
|
401
401
|
TableTitle.propTypes = {
|
|
402
402
|
name: PropTypes.string,
|
|
@@ -415,14 +415,16 @@ function ReloadBtn(_ref) {
|
|
|
415
415
|
onReload();
|
|
416
416
|
}
|
|
417
417
|
};
|
|
418
|
-
return /*#__PURE__*/
|
|
419
|
-
title: "Reload"
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
418
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
419
|
+
title: "Reload",
|
|
420
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
421
|
+
variant: "contained",
|
|
422
|
+
color: "primary",
|
|
423
|
+
onClick: handleClick,
|
|
424
|
+
disabled: loading,
|
|
425
|
+
children: /*#__PURE__*/jsx(RefreshIcon, {})
|
|
426
|
+
})
|
|
427
|
+
});
|
|
426
428
|
}
|
|
427
429
|
ReloadBtn.propTypes = {
|
|
428
430
|
loading: PropTypes.bool,
|
|
@@ -433,7 +435,7 @@ ReloadBtn.propTypes = {
|
|
|
433
435
|
function FancySearch(_ref) {
|
|
434
436
|
var value = _ref.value,
|
|
435
437
|
onSubmit = _ref.onSubmit;
|
|
436
|
-
var _React$useState = React
|
|
438
|
+
var _React$useState = React.useState(Boolean(value)),
|
|
437
439
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
438
440
|
hover = _React$useState2[0],
|
|
439
441
|
setHover = _React$useState2[1];
|
|
@@ -449,69 +451,75 @@ function FancySearch(_ref) {
|
|
|
449
451
|
// Sync internal state when the parent clears/changes the search term.
|
|
450
452
|
// A ref tracks whether this sync came from the user typing or from a parent
|
|
451
453
|
// update, so the debounce only fires for genuine user input.
|
|
452
|
-
var isUserTypingRef = React
|
|
453
|
-
return /*#__PURE__*/
|
|
454
|
-
onSubmit: handleSubmit
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
454
|
+
var isUserTypingRef = React.useRef(false);
|
|
455
|
+
return /*#__PURE__*/jsx("form", {
|
|
456
|
+
onSubmit: handleSubmit,
|
|
457
|
+
children: /*#__PURE__*/jsxs(Paper, {
|
|
458
|
+
elevation: 0,
|
|
459
|
+
sx: {
|
|
460
|
+
borderRadius: expanded ? "24px" : "50px",
|
|
461
|
+
display: "flex",
|
|
462
|
+
alignItems: "center",
|
|
463
|
+
transition: "all 0.5s ease-in-out",
|
|
464
|
+
p: expanded ? 1 : 0.5,
|
|
465
|
+
width: "fit-content",
|
|
466
|
+
border: function border(theme) {
|
|
467
|
+
return "1px solid ".concat(theme.palette.divider);
|
|
468
|
+
},
|
|
469
|
+
mb: 1
|
|
466
470
|
},
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
471
|
+
onMouseEnter: function onMouseEnter() {
|
|
472
|
+
return setHover(true);
|
|
473
|
+
},
|
|
474
|
+
onMouseLeave: handleEndHover,
|
|
475
|
+
onKeyDown: function onKeyDown(e) {
|
|
476
|
+
return e.key === "Enter" && handleSubmit(e);
|
|
477
|
+
},
|
|
478
|
+
children: [/*#__PURE__*/jsx(InputBase, {
|
|
479
|
+
placeholder: "Search",
|
|
480
|
+
value: value,
|
|
481
|
+
onChange: function onChange(e) {
|
|
482
|
+
isUserTypingRef.current = true;
|
|
483
|
+
onSubmit(e.target.value);
|
|
484
|
+
},
|
|
485
|
+
sx: _objectSpread2({
|
|
486
|
+
ml: 1,
|
|
487
|
+
width: expanded ? "100%" : 0,
|
|
488
|
+
transition: "width 0.5s ease-in-out"
|
|
489
|
+
}, expanded ? {} : {
|
|
490
|
+
margin: 0
|
|
491
|
+
}),
|
|
492
|
+
onBlur: handleEndHover
|
|
493
|
+
}), /*#__PURE__*/jsx(Collapse, {
|
|
494
|
+
"in": Boolean(value),
|
|
495
|
+
orientation: "horizontal",
|
|
496
|
+
unmountOnExit: true,
|
|
497
|
+
children: /*#__PURE__*/jsxs(Stack, {
|
|
498
|
+
direction: "row",
|
|
499
|
+
spacing: 0,
|
|
500
|
+
sx: {
|
|
501
|
+
mr: 3,
|
|
502
|
+
alignItems: "center"
|
|
503
|
+
},
|
|
504
|
+
children: [/*#__PURE__*/jsx(IconButton, {
|
|
505
|
+
onClick: function onClick() {
|
|
506
|
+
isUserTypingRef.current = false;
|
|
507
|
+
// Immediately clear instead of waiting for the debounce
|
|
508
|
+
onSubmit("");
|
|
509
|
+
},
|
|
510
|
+
children: /*#__PURE__*/jsx(Clear, {})
|
|
511
|
+
}), /*#__PURE__*/jsx(Divider, {
|
|
512
|
+
orientation: "vertical",
|
|
513
|
+
flexItem: true
|
|
514
|
+
})]
|
|
515
|
+
})
|
|
516
|
+
}), /*#__PURE__*/jsx(IconButton, {
|
|
517
|
+
onClick: handleSubmit,
|
|
518
|
+
type: "submit",
|
|
519
|
+
children: /*#__PURE__*/jsx(Search, {})
|
|
520
|
+
})]
|
|
521
|
+
})
|
|
522
|
+
});
|
|
515
523
|
}
|
|
516
524
|
FancySearch.propTypes = {
|
|
517
525
|
value: PropTypes.string,
|
|
@@ -523,7 +531,7 @@ function SearchArea(props) {
|
|
|
523
531
|
setFinalVal = props.setFinalVal,
|
|
524
532
|
searchName = props.searchName,
|
|
525
533
|
persistSearch = props.persistSearch;
|
|
526
|
-
var searchVal = React
|
|
534
|
+
var searchVal = React.useMemo(function () {
|
|
527
535
|
if (current !== undefined && current !== null) return current;
|
|
528
536
|
if (persistSearch && searchName) {
|
|
529
537
|
var _sessionStorage$getIt;
|
|
@@ -531,12 +539,12 @@ function SearchArea(props) {
|
|
|
531
539
|
}
|
|
532
540
|
return "";
|
|
533
541
|
}, [current, persistSearch, searchName]);
|
|
534
|
-
return /*#__PURE__*/
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
})
|
|
542
|
+
return /*#__PURE__*/jsx("div", {
|
|
543
|
+
children: /*#__PURE__*/jsx(FancySearch, {
|
|
544
|
+
value: searchVal,
|
|
545
|
+
onSubmit: setFinalVal
|
|
546
|
+
})
|
|
547
|
+
}, "SearchArea");
|
|
540
548
|
}
|
|
541
549
|
SearchArea.propTypes = {
|
|
542
550
|
current: PropTypes.string,
|
|
@@ -553,7 +561,7 @@ function TableToolbarContent(_ref) {
|
|
|
553
561
|
onSearchChange = _ref.onSearchChange,
|
|
554
562
|
name = _ref.name,
|
|
555
563
|
persistSearch = _ref.persistSearch;
|
|
556
|
-
return /*#__PURE__*/
|
|
564
|
+
return /*#__PURE__*/jsx(Toolbar, {
|
|
557
565
|
sx: {
|
|
558
566
|
pl: {
|
|
559
567
|
sm: 2
|
|
@@ -563,34 +571,37 @@ function TableToolbarContent(_ref) {
|
|
|
563
571
|
sm: 1
|
|
564
572
|
},
|
|
565
573
|
pt: 2
|
|
566
|
-
}
|
|
567
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
568
|
-
spacing: 2,
|
|
569
|
-
direction: {
|
|
570
|
-
xs: "column",
|
|
571
|
-
md: "row"
|
|
572
574
|
},
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
xs: "
|
|
577
|
-
md: "
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
575
|
+
children: /*#__PURE__*/jsxs(Stack, {
|
|
576
|
+
spacing: 2,
|
|
577
|
+
direction: {
|
|
578
|
+
xs: "column",
|
|
579
|
+
md: "row"
|
|
580
|
+
},
|
|
581
|
+
sx: {
|
|
582
|
+
width: "100%",
|
|
583
|
+
alignItems: {
|
|
584
|
+
xs: "flex-start",
|
|
585
|
+
md: "center"
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
children: [/*#__PURE__*/jsx(Box, {
|
|
589
|
+
sx: {
|
|
590
|
+
flex: "1 1 100%"
|
|
591
|
+
},
|
|
592
|
+
id: "tableTitle",
|
|
593
|
+
children: /*#__PURE__*/jsx(ReloadBtn, {
|
|
594
|
+
onReload: onReload,
|
|
595
|
+
loading: reloadBtnLoading
|
|
596
|
+
})
|
|
597
|
+
}), /*#__PURE__*/jsx(SearchArea, {
|
|
598
|
+
current: searchTerm,
|
|
599
|
+
setFinalVal: onSearchChange,
|
|
600
|
+
searchName: name,
|
|
601
|
+
persistSearch: persistSearch
|
|
602
|
+
})]
|
|
603
|
+
})
|
|
604
|
+
});
|
|
594
605
|
}
|
|
595
606
|
TableToolbarContent.propTypes = {
|
|
596
607
|
onReload: PropTypes.func,
|
|
@@ -623,7 +634,7 @@ function useEnhancedTableState(_ref2) {
|
|
|
623
634
|
order = _ref2.order,
|
|
624
635
|
orderBy = _ref2.orderBy,
|
|
625
636
|
asyncPages = _ref2.asyncPages;
|
|
626
|
-
var _React$useState = React
|
|
637
|
+
var _React$useState = React.useState(function () {
|
|
627
638
|
return {
|
|
628
639
|
page: 0,
|
|
629
640
|
rowsPerPage: getInitialRowsPerPage({
|
|
@@ -637,7 +648,7 @@ function useEnhancedTableState(_ref2) {
|
|
|
637
648
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
638
649
|
pagination = _React$useState2[0],
|
|
639
650
|
setPagination = _React$useState2[1];
|
|
640
|
-
React
|
|
651
|
+
React.useEffect(function () {
|
|
641
652
|
// Resetting derived pagination state here intentionally preserves the
|
|
642
653
|
// current rows-per-page choice while jumping back to the first page.
|
|
643
654
|
// eslint-disable-next-line @eslint-react/set-state-in-effect
|
|
@@ -653,19 +664,19 @@ function useEnhancedTableState(_ref2) {
|
|
|
653
664
|
}, [resetFlag]);
|
|
654
665
|
var page = pagination.page;
|
|
655
666
|
var rowsPerPage = subTable ? rows.length : pagination.rowsPerPage;
|
|
656
|
-
var handleRequestSort = React
|
|
667
|
+
var handleRequestSort = React.useCallback(function (property) {
|
|
657
668
|
var isAsc = orderBy === property && order === "asc";
|
|
658
669
|
setOrder(isAsc ? "desc" : "asc");
|
|
659
670
|
setOrderBy(property);
|
|
660
671
|
}, [order, orderBy, setOrder, setOrderBy]);
|
|
661
|
-
var handleChangePage = React
|
|
672
|
+
var handleChangePage = React.useCallback(function (event, newPage) {
|
|
662
673
|
setPagination(function (previous) {
|
|
663
674
|
return _objectSpread2(_objectSpread2({}, previous), {}, {
|
|
664
675
|
page: newPage
|
|
665
676
|
});
|
|
666
677
|
});
|
|
667
678
|
}, []);
|
|
668
|
-
var handleChangeRowsPerPage = React
|
|
679
|
+
var handleChangeRowsPerPage = React.useCallback(function (event) {
|
|
669
680
|
setPagination(function (previous) {
|
|
670
681
|
return _objectSpread2(_objectSpread2({}, previous), {}, {
|
|
671
682
|
page: 0,
|
|
@@ -708,31 +719,38 @@ function EnhancedTableHead(props) {
|
|
|
708
719
|
rowCount = props.rowCount,
|
|
709
720
|
onSelectAllClick = props.onSelectAllClick,
|
|
710
721
|
async = props.async;
|
|
711
|
-
return /*#__PURE__*/
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
722
|
+
return /*#__PURE__*/jsx(TableHead, {
|
|
723
|
+
children: /*#__PURE__*/jsxs(TableRow, {
|
|
724
|
+
children: [selectRows && /*#__PURE__*/jsx(TableCell, {
|
|
725
|
+
padding: "checkbox",
|
|
726
|
+
children: /*#__PURE__*/jsx(Checkbox, {
|
|
727
|
+
color: "primary",
|
|
728
|
+
indeterminate: numSelected > 0 && numSelected < rowCount,
|
|
729
|
+
checked: rowCount > 0 && numSelected === rowCount,
|
|
730
|
+
onChange: onSelectAllClick
|
|
731
|
+
})
|
|
732
|
+
}), props.headings.map(function (headCell) {
|
|
733
|
+
return /*#__PURE__*/jsx(TableCell, {
|
|
734
|
+
align: headCell.numeric ? "right" : "left",
|
|
735
|
+
padding: "normal",
|
|
736
|
+
sortDirection: orderBy === headCell.id ? order : false,
|
|
737
|
+
children: /*#__PURE__*/jsxs(TableSortLabel, {
|
|
738
|
+
active: orderBy === headCell.id,
|
|
739
|
+
direction: orderBy === headCell.id ? order : "asc",
|
|
740
|
+
onClick: function onClick() {
|
|
741
|
+
return onRequestSort(headCell.id, headCell.sortable && async);
|
|
742
|
+
},
|
|
743
|
+
disabled: headCell.subRow,
|
|
744
|
+
children: [headCell.label, orderBy === headCell.id ? /*#__PURE__*/jsx(Box, {
|
|
745
|
+
component: "span",
|
|
746
|
+
sx: visuallyHidden,
|
|
747
|
+
children: order === "desc" ? "sorted descending" : "sorted ascending"
|
|
748
|
+
}) : undefined]
|
|
749
|
+
})
|
|
750
|
+
}, headCell.id);
|
|
751
|
+
})]
|
|
752
|
+
})
|
|
753
|
+
});
|
|
736
754
|
}
|
|
737
755
|
EnhancedTableHead.propTypes = {
|
|
738
756
|
onRequestSort: PropTypes.func.isRequired,
|
|
@@ -746,12 +764,7 @@ EnhancedTableHead.propTypes = {
|
|
|
746
764
|
async: PropTypes.bool
|
|
747
765
|
};
|
|
748
766
|
|
|
749
|
-
|
|
750
|
-
* Lazily import UniversalTable to statically break the circular dependency:
|
|
751
|
-
* UniversalTable → EnhancedTable → DataRow → SubTableRow → UniversalTable
|
|
752
|
-
* React.lazy resolves the import at render time, so the module graph stays acyclic.
|
|
753
|
-
*/
|
|
754
|
-
var UniversalTable$2 = /*#__PURE__*/React$1.lazy(function () {
|
|
767
|
+
var UniversalTable$2 = /*#__PURE__*/React.lazy(function () {
|
|
755
768
|
return Promise.resolve().then(function () { return UniversalTable$1; });
|
|
756
769
|
});
|
|
757
770
|
|
|
@@ -765,30 +778,37 @@ function SubRowToggleCell(_ref) {
|
|
|
765
778
|
onToggle = _ref.onToggle,
|
|
766
779
|
rowValues = _ref.rowValues,
|
|
767
780
|
hideBadge = _ref.hideBadge;
|
|
768
|
-
return /*#__PURE__*/
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
781
|
+
return /*#__PURE__*/jsx(TableCell, {
|
|
782
|
+
children: /*#__PURE__*/jsx(Tooltip, {
|
|
783
|
+
title: isOpen ? "Hide ".concat(header.id) : "Show ".concat(header.id),
|
|
784
|
+
children: /*#__PURE__*/jsx(Box, {
|
|
785
|
+
children: /*#__PURE__*/jsx(IconButton, {
|
|
786
|
+
onClick: function onClick(event) {
|
|
787
|
+
event.stopPropagation();
|
|
788
|
+
onToggle();
|
|
789
|
+
},
|
|
790
|
+
disabled: rowValues[header.id].length === 0,
|
|
791
|
+
color: header.iconColor || "secondary",
|
|
792
|
+
children: /*#__PURE__*/jsx(Badge, {
|
|
793
|
+
badgeContent: rowValues[header.id].length,
|
|
794
|
+
invisible: hideBadge,
|
|
795
|
+
anchorOrigin: {
|
|
796
|
+
vertical: "bottom",
|
|
797
|
+
horizontal: "right"
|
|
798
|
+
},
|
|
799
|
+
sx: {
|
|
800
|
+
"& .MuiBadge-badge": {
|
|
801
|
+
color: function color(theme) {
|
|
802
|
+
return theme.palette.text.primary;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
children: isOpen ? (header === null || header === void 0 ? void 0 : header.closeIcon) || /*#__PURE__*/jsx(RemoveCircle, {}) : (header === null || header === void 0 ? void 0 : header.openIcon) || /*#__PURE__*/jsx(AddCircle, {})
|
|
807
|
+
})
|
|
808
|
+
})
|
|
809
|
+
})
|
|
810
|
+
})
|
|
811
|
+
});
|
|
792
812
|
}
|
|
793
813
|
SubRowToggleCell.propTypes = {
|
|
794
814
|
header: PropTypes.object.isRequired,
|
|
@@ -807,27 +827,32 @@ function SubTableRow(_ref2) {
|
|
|
807
827
|
isOpen = _ref2.isOpen,
|
|
808
828
|
rowValues = _ref2.rowValues,
|
|
809
829
|
colSpan = _ref2.colSpan;
|
|
810
|
-
return /*#__PURE__*/
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
830
|
+
return /*#__PURE__*/jsx(TableRow, {
|
|
831
|
+
children: /*#__PURE__*/jsx(TableCell, {
|
|
832
|
+
colSpan: colSpan,
|
|
833
|
+
style: {
|
|
834
|
+
paddingBottom: 0,
|
|
835
|
+
paddingTop: 0
|
|
836
|
+
},
|
|
837
|
+
children: /*#__PURE__*/jsx(Collapse, {
|
|
838
|
+
"in": isOpen,
|
|
839
|
+
timeout: "auto",
|
|
840
|
+
unmountOnExit: true,
|
|
841
|
+
children: /*#__PURE__*/jsx(React.Suspense, {
|
|
842
|
+
fallback: null,
|
|
843
|
+
children: /*#__PURE__*/jsx(UniversalTable$2, {
|
|
844
|
+
loading: table.loading,
|
|
845
|
+
setLoading: table.setLoading,
|
|
846
|
+
onReload: table.onReload,
|
|
847
|
+
data: rowValues[table.id],
|
|
848
|
+
headers: table.headers,
|
|
849
|
+
name: table.subTitle,
|
|
850
|
+
subTable: true
|
|
851
|
+
})
|
|
852
|
+
})
|
|
853
|
+
})
|
|
854
|
+
})
|
|
855
|
+
});
|
|
831
856
|
}
|
|
832
857
|
SubTableRow.propTypes = {
|
|
833
858
|
table: PropTypes.object.isRequired,
|
|
@@ -839,80 +864,82 @@ SubTableRow.propTypes = {
|
|
|
839
864
|
function renderDataCells(headers, rowValues) {
|
|
840
865
|
return headers.map(function (header) {
|
|
841
866
|
var _header$id;
|
|
842
|
-
return /*#__PURE__*/
|
|
843
|
-
|
|
844
|
-
}, header.
|
|
867
|
+
return /*#__PURE__*/jsx(TableCell, _objectSpread2(_objectSpread2({}, header.cellProps), {}, {
|
|
868
|
+
children: header.component ? header.component(rowValues) : formatCellValue(header, rowValues)
|
|
869
|
+
}), (_header$id = header.id) !== null && _header$id !== void 0 ? _header$id : header.label);
|
|
845
870
|
});
|
|
846
871
|
}
|
|
847
|
-
var DataRow = /*#__PURE__*/React
|
|
872
|
+
var DataRow = /*#__PURE__*/React.memo(function DataRow(props) {
|
|
848
873
|
var rowValues = props.rowValues,
|
|
849
874
|
headers = props.headers,
|
|
850
875
|
selectRows = props.selectRows,
|
|
851
876
|
isSelected = props.isSelected,
|
|
852
877
|
handleClick = props.handleClick;
|
|
853
|
-
var _React$useMemo = React
|
|
878
|
+
var _React$useMemo = React.useMemo(function () {
|
|
854
879
|
return splitHeaders(headers);
|
|
855
880
|
}, [headers]),
|
|
856
881
|
subTables = _React$useMemo.subTables,
|
|
857
882
|
columns = _React$useMemo.columns;
|
|
858
883
|
var hideBadge = props.hideBadge || false;
|
|
859
884
|
var isItemSelected = isSelected(props.rowID);
|
|
860
|
-
var _React$useState = React
|
|
885
|
+
var _React$useState = React.useState(Array.from({
|
|
861
886
|
length: subTables.length
|
|
862
887
|
}).fill(false)),
|
|
863
888
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
864
889
|
reveal = _React$useState2[0],
|
|
865
890
|
setReveal = _React$useState2[1];
|
|
866
|
-
var toggleSubRow = React
|
|
891
|
+
var toggleSubRow = React.useCallback(function (index) {
|
|
867
892
|
setReveal(function (previous) {
|
|
868
893
|
var next = _toConsumableArray(previous);
|
|
869
894
|
next[index] = !next[index];
|
|
870
895
|
return next;
|
|
871
896
|
});
|
|
872
897
|
}, []);
|
|
873
|
-
var handleRowKeyDown = React
|
|
898
|
+
var handleRowKeyDown = React.useCallback(function (event) {
|
|
874
899
|
if (selectRows && (event.key === " " || event.key === "Enter")) {
|
|
875
900
|
event.preventDefault();
|
|
876
901
|
handleClick(event, props.rowID);
|
|
877
902
|
}
|
|
878
903
|
}, [selectRows, handleClick, props.rowID]);
|
|
879
|
-
return /*#__PURE__*/
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
904
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
905
|
+
children: [/*#__PURE__*/jsxs(TableRow, {
|
|
906
|
+
tabIndex: selectRows ? 0 : -1,
|
|
907
|
+
hover: selectRows,
|
|
908
|
+
role: selectRows ? "checkbox" : "row",
|
|
909
|
+
selected: isItemSelected,
|
|
910
|
+
"aria-checked": isItemSelected,
|
|
911
|
+
onKeyDown: handleRowKeyDown,
|
|
912
|
+
children: [selectRows && /*#__PURE__*/jsx(TableCell, {
|
|
913
|
+
padding: "checkbox",
|
|
914
|
+
children: /*#__PURE__*/jsx(Checkbox, {
|
|
915
|
+
color: "primary",
|
|
916
|
+
checked: isItemSelected,
|
|
917
|
+
onClick: function onClick(event) {
|
|
918
|
+
return handleClick(event, props.rowID);
|
|
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,
|
|
937
|
+
isOpen: reveal[index],
|
|
938
|
+
rowValues: rowValues,
|
|
939
|
+
colSpan: props.headers.length + 1
|
|
940
|
+
}, (_table$id = table.id) !== null && _table$id !== void 0 ? _table$id : table.label);
|
|
941
|
+
})]
|
|
942
|
+
});
|
|
916
943
|
});
|
|
917
944
|
DataRow.propTypes = {
|
|
918
945
|
rowValues: PropTypes.object.isRequired,
|
|
@@ -927,17 +954,21 @@ DataRow.propTypes = {
|
|
|
927
954
|
var skeletonRows = ["row-1", "row-2", "row-3", "row-4", "row-5"];
|
|
928
955
|
var skeletonCells = ["cell-1", "cell-2", "cell-3", "cell-4"];
|
|
929
956
|
var TableLoader = function TableLoader() {
|
|
930
|
-
return /*#__PURE__*/
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
957
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
958
|
+
children: [/*#__PURE__*/jsx(TableHead, {}), /*#__PURE__*/jsx(TableBody, {
|
|
959
|
+
children: skeletonRows.map(function (rowKey) {
|
|
960
|
+
return /*#__PURE__*/jsx(TableRow, {
|
|
961
|
+
children: skeletonCells.map(function (cellKey) {
|
|
962
|
+
return /*#__PURE__*/jsx(TableCell, {
|
|
963
|
+
children: /*#__PURE__*/jsx(Skeleton, {
|
|
964
|
+
height: 30
|
|
965
|
+
})
|
|
966
|
+
}, cellKey);
|
|
967
|
+
})
|
|
968
|
+
}, rowKey);
|
|
969
|
+
})
|
|
970
|
+
})]
|
|
971
|
+
});
|
|
941
972
|
};
|
|
942
973
|
|
|
943
974
|
function EnhancedTable(props) {
|
|
@@ -974,65 +1005,72 @@ function EnhancedTable(props) {
|
|
|
974
1005
|
handleChangeRowsPerPage = _useEnhancedTableStat.handleChangeRowsPerPage;
|
|
975
1006
|
var effectiveRowsPerPage = rowsPerPage === -1 ? rows.length : rowsPerPage;
|
|
976
1007
|
var emptyRows = Math.max(0, effectiveRowsPerPage - Math.min(effectiveRowsPerPage, rows.length - page * effectiveRowsPerPage));
|
|
977
|
-
var isSelected = React
|
|
1008
|
+
var isSelected = React.useCallback(function (id) {
|
|
978
1009
|
return selected.includes(id);
|
|
979
1010
|
}, [selected]);
|
|
980
|
-
var visibleRows = React
|
|
1011
|
+
var visibleRows = React.useMemo(function () {
|
|
981
1012
|
return stableSort(rows, getComparator(order, orderBy), headers, orderBy).slice(page * effectiveRowsPerPage, page * effectiveRowsPerPage + effectiveRowsPerPage);
|
|
982
1013
|
}, [effectiveRowsPerPage, headers, order, orderBy, page, rows]);
|
|
983
|
-
return /*#__PURE__*/
|
|
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
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1014
|
+
return /*#__PURE__*/jsxs(TableContainer, {
|
|
1015
|
+
children: [/*#__PURE__*/jsx(Table, {
|
|
1016
|
+
sx: {
|
|
1017
|
+
minWidth: 750
|
|
1018
|
+
},
|
|
1019
|
+
size: "small" ,
|
|
1020
|
+
"aria-label": props.name || "data table",
|
|
1021
|
+
children: props.loading ? /*#__PURE__*/jsx(TableLoader, {}) : /*#__PURE__*/jsxs(Fragment, {
|
|
1022
|
+
children: [/*#__PURE__*/jsx(EnhancedTableHead, {
|
|
1023
|
+
order: order,
|
|
1024
|
+
orderBy: orderBy,
|
|
1025
|
+
onRequestSort: handleSort,
|
|
1026
|
+
headings: headers,
|
|
1027
|
+
selectRows: props.selectRows,
|
|
1028
|
+
numSelected: selected.length,
|
|
1029
|
+
rowCount: rows.length,
|
|
1030
|
+
onSelectAllClick: props.handleSelectAllClick,
|
|
1031
|
+
async: async
|
|
1032
|
+
}), /*#__PURE__*/jsxs(TableBody, {
|
|
1033
|
+
children: [visibleRows.map(function (row, index) {
|
|
1034
|
+
var rowKey = selectID ? row[selectID] : "row-".concat(page * effectiveRowsPerPage + index);
|
|
1035
|
+
var rowID = getSelectableRowId(row, index, selectID);
|
|
1036
|
+
return /*#__PURE__*/jsx(DataRow, {
|
|
1037
|
+
rowID: rowID,
|
|
1038
|
+
headers: headers,
|
|
1039
|
+
rowValues: row,
|
|
1040
|
+
hideBadge: props.hideBadge,
|
|
1041
|
+
selectRows: props.selectRows,
|
|
1042
|
+
handleClick: props.handleClick,
|
|
1043
|
+
isSelected: isSelected
|
|
1044
|
+
}, rowKey);
|
|
1045
|
+
}), !subTable && emptyRows > 0 && /*#__PURE__*/jsx(TableRow, {
|
|
1046
|
+
style: {
|
|
1047
|
+
height: (33 ) * emptyRows
|
|
1048
|
+
},
|
|
1049
|
+
children: /*#__PURE__*/jsx(TableCell, {
|
|
1050
|
+
colSpan: headers.length
|
|
1051
|
+
})
|
|
1052
|
+
})]
|
|
1053
|
+
})]
|
|
1054
|
+
})
|
|
1055
|
+
}), subTable ? /*#__PURE__*/jsx(Box, {
|
|
1056
|
+
sx: {
|
|
1057
|
+
mb: 3
|
|
1058
|
+
}
|
|
1059
|
+
}) : /*#__PURE__*/jsx(TablePagination, {
|
|
1060
|
+
rowsPerPageOptions: props.pageSizeOptions || getPageOptions(rows.length),
|
|
1061
|
+
component: "div",
|
|
1062
|
+
count: rows.length,
|
|
1063
|
+
rowsPerPage: rowsPerPage,
|
|
1064
|
+
page: page,
|
|
1065
|
+
onPageChange: handleChangePage,
|
|
1066
|
+
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
1067
|
+
sx: {
|
|
1068
|
+
overflow: "visible"
|
|
1069
|
+
},
|
|
1070
|
+
showFirstButton: true,
|
|
1071
|
+
showLastButton: true
|
|
1072
|
+
})]
|
|
1073
|
+
});
|
|
1036
1074
|
}
|
|
1037
1075
|
EnhancedTable.propTypes = {
|
|
1038
1076
|
headers: PropTypes.array.isRequired,
|
|
@@ -1082,19 +1120,19 @@ function UniversalTable(_ref) {
|
|
|
1082
1120
|
pageSizeOptions = _ref.pageSizeOptions,
|
|
1083
1121
|
persistSearch = _ref.persistSearch,
|
|
1084
1122
|
asyncPages = _ref.asyncPages;
|
|
1085
|
-
var debounceRef = React
|
|
1086
|
-
var hasLoadedInitialAsyncPageRef = React
|
|
1123
|
+
var debounceRef = React.useRef(null);
|
|
1124
|
+
var hasLoadedInitialAsyncPageRef = React.useRef(false);
|
|
1087
1125
|
var async = typeof asyncPages === "number" && asyncPages > 0;
|
|
1088
1126
|
var head = headers || [];
|
|
1089
1127
|
var _useSearchableRows = useSearchableRows(data, head, async),
|
|
1090
1128
|
rows = _useSearchableRows.rows,
|
|
1091
1129
|
searchTerm = _useSearchableRows.searchTerm,
|
|
1092
1130
|
setSearchTerm = _useSearchableRows.setSearchTerm;
|
|
1093
|
-
var _React$useState = React
|
|
1131
|
+
var _React$useState = React.useState("asc"),
|
|
1094
1132
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1095
1133
|
order = _React$useState2[0],
|
|
1096
1134
|
setOrder = _React$useState2[1];
|
|
1097
|
-
var _React$useState3 = React
|
|
1135
|
+
var _React$useState3 = React.useState(""),
|
|
1098
1136
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
1099
1137
|
orderBy = _React$useState4[0],
|
|
1100
1138
|
setOrderBy = _React$useState4[1];
|
|
@@ -1107,7 +1145,7 @@ function UniversalTable(_ref) {
|
|
|
1107
1145
|
clearSelection = _useSelectableRows.clearSelection,
|
|
1108
1146
|
handleSelectAllClick = _useSelectableRows.handleSelectAllClick,
|
|
1109
1147
|
handleClick = _useSelectableRows.handleClick;
|
|
1110
|
-
var handleSearchChange = React
|
|
1148
|
+
var handleSearchChange = React.useCallback(function (value) {
|
|
1111
1149
|
clearSelection();
|
|
1112
1150
|
setSearchTerm(value);
|
|
1113
1151
|
}, [clearSelection, setSearchTerm]);
|
|
@@ -1127,12 +1165,12 @@ function UniversalTable(_ref) {
|
|
|
1127
1165
|
handleSearchChange(searchValue);
|
|
1128
1166
|
}
|
|
1129
1167
|
};
|
|
1130
|
-
React
|
|
1168
|
+
React.useEffect(function () {
|
|
1131
1169
|
return function () {
|
|
1132
1170
|
return clearTimeout(debounceRef.current);
|
|
1133
1171
|
};
|
|
1134
1172
|
}, []);
|
|
1135
|
-
React
|
|
1173
|
+
React.useEffect(function () {
|
|
1136
1174
|
if (!async || hasLoadedInitialAsyncPageRef.current) {
|
|
1137
1175
|
return;
|
|
1138
1176
|
}
|
|
@@ -1144,7 +1182,7 @@ function UniversalTable(_ref) {
|
|
|
1144
1182
|
pages: asyncPages
|
|
1145
1183
|
});
|
|
1146
1184
|
}, [async, asyncPages, order, orderBy, searchTerm, setLoading]);
|
|
1147
|
-
var handleReload = React
|
|
1185
|
+
var handleReload = React.useCallback(function () {
|
|
1148
1186
|
if (typeof onReload === "function") {
|
|
1149
1187
|
onReload();
|
|
1150
1188
|
return;
|
|
@@ -1158,51 +1196,54 @@ function UniversalTable(_ref) {
|
|
|
1158
1196
|
} : true);
|
|
1159
1197
|
}
|
|
1160
1198
|
}, [async, onReload, setLoading, searchTerm, order, orderBy, asyncPages]);
|
|
1161
|
-
return /*#__PURE__*/
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1199
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
1200
|
+
children: [/*#__PURE__*/jsx(LazyLoadingIndicator, {
|
|
1201
|
+
show: lazyloading,
|
|
1202
|
+
currentPage: currentPage,
|
|
1203
|
+
totalPages: totalPages
|
|
1204
|
+
}), /*#__PURE__*/jsxs(Paper$1, {
|
|
1205
|
+
sx: _objectSpread2({}, subTable && {
|
|
1206
|
+
boxShadow: "none"
|
|
1207
|
+
}),
|
|
1208
|
+
children: [/*#__PURE__*/jsx(TableSelectionBanner, {
|
|
1209
|
+
selected: selected,
|
|
1210
|
+
onSelection: onSelection,
|
|
1211
|
+
selectIcon: selectIcon
|
|
1212
|
+
}), /*#__PURE__*/jsx(TableTitle, {
|
|
1213
|
+
name: name,
|
|
1214
|
+
subTable: subTable
|
|
1215
|
+
}), !subTable && /*#__PURE__*/jsx(TableToolbarContent, {
|
|
1216
|
+
onReload: typeof onReload === "function" || typeof setLoading === "function" ? handleReload : undefined,
|
|
1217
|
+
reloadBtnLoading: reloadBtnLoading,
|
|
1218
|
+
searchTerm: searchTerm,
|
|
1219
|
+
onSearchChange: handleSearch,
|
|
1220
|
+
name: name,
|
|
1221
|
+
persistSearch: persistSearch
|
|
1222
|
+
}), /*#__PURE__*/jsx(EnhancedTable, {
|
|
1223
|
+
headers: head,
|
|
1224
|
+
rows: rows,
|
|
1225
|
+
resetFlag: searchTerm,
|
|
1226
|
+
searchTerm: searchTerm,
|
|
1227
|
+
subTable: subTable,
|
|
1228
|
+
hideBadge: hideBadge,
|
|
1229
|
+
loading: loading,
|
|
1230
|
+
selectRows: selectRows,
|
|
1231
|
+
handleSelectAllClick: handleSelectAllClick,
|
|
1232
|
+
handleClick: handleClick,
|
|
1233
|
+
selected: selected,
|
|
1234
|
+
selectID: selectID,
|
|
1235
|
+
pageSizeOptions: pageSizeOptions,
|
|
1236
|
+
name: name,
|
|
1237
|
+
setLoading: setLoading,
|
|
1238
|
+
order: order,
|
|
1239
|
+
orderBy: orderBy,
|
|
1240
|
+
setOrder: setOrder,
|
|
1241
|
+
setOrderBy: setOrderBy,
|
|
1242
|
+
asyncPages: asyncPages,
|
|
1243
|
+
async: async
|
|
1244
|
+
})]
|
|
1245
|
+
})]
|
|
1246
|
+
});
|
|
1206
1247
|
}
|
|
1207
1248
|
UniversalTable.propTypes = {
|
|
1208
1249
|
loading: PropTypes.bool,
|