mui-universal-table 2.1.0 → 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 +438 -394
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +438 -394
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -7
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var PropTypes = require('prop-types');
|
|
7
7
|
var Paper = require('@mui/material/Paper');
|
|
8
8
|
var material = require('@mui/material');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
10
|
var styles = require('@mui/material/styles');
|
|
10
11
|
var iconsMaterial = require('@mui/icons-material');
|
|
11
12
|
var RefreshIcon = require('@mui/icons-material/Refresh');
|
|
@@ -29,15 +30,6 @@ function _defineProperty(e, r, t) {
|
|
|
29
30
|
writable: true
|
|
30
31
|
}) : e[r] = t, e;
|
|
31
32
|
}
|
|
32
|
-
function _extends() {
|
|
33
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
34
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
35
|
-
var t = arguments[e];
|
|
36
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
37
|
-
}
|
|
38
|
-
return n;
|
|
39
|
-
}, _extends.apply(null, arguments);
|
|
40
|
-
}
|
|
41
33
|
function _iterableToArray(r) {
|
|
42
34
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
43
35
|
}
|
|
@@ -124,25 +116,28 @@ var LazyLoadingIndicator = function LazyLoadingIndicator(_ref) {
|
|
|
124
116
|
var show = _ref.show,
|
|
125
117
|
currentPage = _ref.currentPage,
|
|
126
118
|
totalPages = _ref.totalPages;
|
|
127
|
-
return /*#__PURE__*/
|
|
119
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.Collapse, {
|
|
128
120
|
"in": show,
|
|
129
121
|
timeout: "auto",
|
|
130
|
-
unmountOnExit: true
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
122
|
+
unmountOnExit: true,
|
|
123
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
|
|
124
|
+
sx: {
|
|
125
|
+
width: "100%",
|
|
126
|
+
p: 2
|
|
127
|
+
},
|
|
128
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
|
|
129
|
+
variant: "body2",
|
|
130
|
+
color: "text.secondary",
|
|
131
|
+
sx: {
|
|
132
|
+
mb: 1
|
|
133
|
+
},
|
|
134
|
+
children: ["Loading page ", currentPage, " of ", totalPages, "..."]
|
|
135
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.LinearProgress, {
|
|
136
|
+
variant: "determinate",
|
|
137
|
+
value: currentPage / totalPages * 100
|
|
138
|
+
})]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
146
141
|
};
|
|
147
142
|
LazyLoadingIndicator.propTypes = {
|
|
148
143
|
show: PropTypes.bool.isRequired,
|
|
@@ -360,30 +355,34 @@ function TableSelectionBanner(_ref) {
|
|
|
360
355
|
var selected = _ref.selected,
|
|
361
356
|
onSelection = _ref.onSelection,
|
|
362
357
|
selectIcon = _ref.selectIcon;
|
|
363
|
-
return /*#__PURE__*/
|
|
358
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.Collapse, {
|
|
364
359
|
"in": selected.length > 0,
|
|
365
|
-
unmountOnExit: true
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
360
|
+
unmountOnExit: true,
|
|
361
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
|
|
362
|
+
sx: {
|
|
363
|
+
p: 2,
|
|
364
|
+
display: "flex",
|
|
365
|
+
justifyContent: "space-between",
|
|
366
|
+
bgcolor: function bgcolor(theme) {
|
|
367
|
+
return styles.alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity);
|
|
368
|
+
},
|
|
369
|
+
borderRadius: 1,
|
|
370
|
+
borderBottomLeftRadius: 0,
|
|
371
|
+
borderBottomRightRadius: 0
|
|
373
372
|
},
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
}
|
|
373
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(material.Typography, {
|
|
374
|
+
variant: "h6",
|
|
375
|
+
id: "tableTitle",
|
|
376
|
+
component: "div",
|
|
377
|
+
children: [selected.length, " selected"]
|
|
378
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
|
|
379
|
+
onClick: function onClick() {
|
|
380
|
+
return onSelection(selected);
|
|
381
|
+
},
|
|
382
|
+
children: selectIcon || /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Task, {})
|
|
383
|
+
})]
|
|
384
|
+
})
|
|
385
|
+
});
|
|
387
386
|
}
|
|
388
387
|
TableSelectionBanner.propTypes = {
|
|
389
388
|
selected: PropTypes.array.isRequired,
|
|
@@ -394,13 +393,14 @@ TableSelectionBanner.propTypes = {
|
|
|
394
393
|
function TableTitle(_ref) {
|
|
395
394
|
var name = _ref.name,
|
|
396
395
|
subTable = _ref.subTable;
|
|
397
|
-
return /*#__PURE__*/
|
|
396
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
|
|
398
397
|
variant: subTable ? "h6" : "h5",
|
|
399
398
|
color: subTable ? "secondary" : "primary",
|
|
400
399
|
sx: {
|
|
401
400
|
p: 2
|
|
402
|
-
}
|
|
403
|
-
|
|
401
|
+
},
|
|
402
|
+
children: name
|
|
403
|
+
});
|
|
404
404
|
}
|
|
405
405
|
TableTitle.propTypes = {
|
|
406
406
|
name: PropTypes.string,
|
|
@@ -419,14 +419,16 @@ function ReloadBtn(_ref) {
|
|
|
419
419
|
onReload();
|
|
420
420
|
}
|
|
421
421
|
};
|
|
422
|
-
return /*#__PURE__*/
|
|
423
|
-
title: "Reload"
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
422
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.Tooltip, {
|
|
423
|
+
title: "Reload",
|
|
424
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Button, {
|
|
425
|
+
variant: "contained",
|
|
426
|
+
color: "primary",
|
|
427
|
+
onClick: handleClick,
|
|
428
|
+
disabled: loading,
|
|
429
|
+
children: /*#__PURE__*/jsxRuntime.jsx(RefreshIcon, {})
|
|
430
|
+
})
|
|
431
|
+
});
|
|
430
432
|
}
|
|
431
433
|
ReloadBtn.propTypes = {
|
|
432
434
|
loading: PropTypes.bool,
|
|
@@ -453,69 +455,75 @@ function FancySearch(_ref) {
|
|
|
453
455
|
// Sync internal state when the parent clears/changes the search term.
|
|
454
456
|
// A ref tracks whether this sync came from the user typing or from a parent
|
|
455
457
|
// update, so the debounce only fires for genuine user input.
|
|
456
|
-
var
|
|
457
|
-
return /*#__PURE__*/
|
|
458
|
-
onSubmit: handleSubmit
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
458
|
+
var isUserTypingRef = React.useRef(false);
|
|
459
|
+
return /*#__PURE__*/jsxRuntime.jsx("form", {
|
|
460
|
+
onSubmit: handleSubmit,
|
|
461
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.Paper, {
|
|
462
|
+
elevation: 0,
|
|
463
|
+
sx: {
|
|
464
|
+
borderRadius: expanded ? "24px" : "50px",
|
|
465
|
+
display: "flex",
|
|
466
|
+
alignItems: "center",
|
|
467
|
+
transition: "all 0.5s ease-in-out",
|
|
468
|
+
p: expanded ? 1 : 0.5,
|
|
469
|
+
width: "fit-content",
|
|
470
|
+
border: function border(theme) {
|
|
471
|
+
return "1px solid ".concat(theme.palette.divider);
|
|
472
|
+
},
|
|
473
|
+
mb: 1
|
|
470
474
|
},
|
|
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
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
475
|
+
onMouseEnter: function onMouseEnter() {
|
|
476
|
+
return setHover(true);
|
|
477
|
+
},
|
|
478
|
+
onMouseLeave: handleEndHover,
|
|
479
|
+
onKeyDown: function onKeyDown(e) {
|
|
480
|
+
return e.key === "Enter" && handleSubmit(e);
|
|
481
|
+
},
|
|
482
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.InputBase, {
|
|
483
|
+
placeholder: "Search",
|
|
484
|
+
value: value,
|
|
485
|
+
onChange: function onChange(e) {
|
|
486
|
+
isUserTypingRef.current = true;
|
|
487
|
+
onSubmit(e.target.value);
|
|
488
|
+
},
|
|
489
|
+
sx: _objectSpread2({
|
|
490
|
+
ml: 1,
|
|
491
|
+
width: expanded ? "100%" : 0,
|
|
492
|
+
transition: "width 0.5s ease-in-out"
|
|
493
|
+
}, expanded ? {} : {
|
|
494
|
+
margin: 0
|
|
495
|
+
}),
|
|
496
|
+
onBlur: handleEndHover
|
|
497
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Collapse, {
|
|
498
|
+
"in": Boolean(value),
|
|
499
|
+
orientation: "horizontal",
|
|
500
|
+
unmountOnExit: true,
|
|
501
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.Stack, {
|
|
502
|
+
direction: "row",
|
|
503
|
+
spacing: 0,
|
|
504
|
+
sx: {
|
|
505
|
+
mr: 3,
|
|
506
|
+
alignItems: "center"
|
|
507
|
+
},
|
|
508
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
|
|
509
|
+
onClick: function onClick() {
|
|
510
|
+
isUserTypingRef.current = false;
|
|
511
|
+
// Immediately clear instead of waiting for the debounce
|
|
512
|
+
onSubmit("");
|
|
513
|
+
},
|
|
514
|
+
children: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Clear, {})
|
|
515
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.Divider, {
|
|
516
|
+
orientation: "vertical",
|
|
517
|
+
flexItem: true
|
|
518
|
+
})]
|
|
519
|
+
})
|
|
520
|
+
}), /*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
|
|
521
|
+
onClick: handleSubmit,
|
|
522
|
+
type: "submit",
|
|
523
|
+
children: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Search, {})
|
|
524
|
+
})]
|
|
525
|
+
})
|
|
526
|
+
});
|
|
519
527
|
}
|
|
520
528
|
FancySearch.propTypes = {
|
|
521
529
|
value: PropTypes.string,
|
|
@@ -535,12 +543,12 @@ function SearchArea(props) {
|
|
|
535
543
|
}
|
|
536
544
|
return "";
|
|
537
545
|
}, [current, persistSearch, searchName]);
|
|
538
|
-
return /*#__PURE__*/
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
})
|
|
546
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
547
|
+
children: /*#__PURE__*/jsxRuntime.jsx(FancySearch, {
|
|
548
|
+
value: searchVal,
|
|
549
|
+
onSubmit: setFinalVal
|
|
550
|
+
})
|
|
551
|
+
}, "SearchArea");
|
|
544
552
|
}
|
|
545
553
|
SearchArea.propTypes = {
|
|
546
554
|
current: PropTypes.string,
|
|
@@ -557,7 +565,7 @@ function TableToolbarContent(_ref) {
|
|
|
557
565
|
onSearchChange = _ref.onSearchChange,
|
|
558
566
|
name = _ref.name,
|
|
559
567
|
persistSearch = _ref.persistSearch;
|
|
560
|
-
return /*#__PURE__*/
|
|
568
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.Toolbar, {
|
|
561
569
|
sx: {
|
|
562
570
|
pl: {
|
|
563
571
|
sm: 2
|
|
@@ -567,34 +575,37 @@ function TableToolbarContent(_ref) {
|
|
|
567
575
|
sm: 1
|
|
568
576
|
},
|
|
569
577
|
pt: 2
|
|
570
|
-
}
|
|
571
|
-
}, /*#__PURE__*/React.createElement(material.Stack, {
|
|
572
|
-
spacing: 2,
|
|
573
|
-
direction: {
|
|
574
|
-
xs: "column",
|
|
575
|
-
md: "row"
|
|
576
|
-
},
|
|
577
|
-
sx: {
|
|
578
|
-
width: "100%",
|
|
579
|
-
alignItems: {
|
|
580
|
-
xs: "flex-start",
|
|
581
|
-
md: "center"
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
}, /*#__PURE__*/React.createElement(material.Box, {
|
|
585
|
-
sx: {
|
|
586
|
-
flex: "1 1 100%"
|
|
587
578
|
},
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
579
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.Stack, {
|
|
580
|
+
spacing: 2,
|
|
581
|
+
direction: {
|
|
582
|
+
xs: "column",
|
|
583
|
+
md: "row"
|
|
584
|
+
},
|
|
585
|
+
sx: {
|
|
586
|
+
width: "100%",
|
|
587
|
+
alignItems: {
|
|
588
|
+
xs: "flex-start",
|
|
589
|
+
md: "center"
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
|
|
593
|
+
sx: {
|
|
594
|
+
flex: "1 1 100%"
|
|
595
|
+
},
|
|
596
|
+
id: "tableTitle",
|
|
597
|
+
children: /*#__PURE__*/jsxRuntime.jsx(ReloadBtn, {
|
|
598
|
+
onReload: onReload,
|
|
599
|
+
loading: reloadBtnLoading
|
|
600
|
+
})
|
|
601
|
+
}), /*#__PURE__*/jsxRuntime.jsx(SearchArea, {
|
|
602
|
+
current: searchTerm,
|
|
603
|
+
setFinalVal: onSearchChange,
|
|
604
|
+
searchName: name,
|
|
605
|
+
persistSearch: persistSearch
|
|
606
|
+
})]
|
|
607
|
+
})
|
|
608
|
+
});
|
|
598
609
|
}
|
|
599
610
|
TableToolbarContent.propTypes = {
|
|
600
611
|
onReload: PropTypes.func,
|
|
@@ -642,7 +653,9 @@ function useEnhancedTableState(_ref2) {
|
|
|
642
653
|
pagination = _React$useState2[0],
|
|
643
654
|
setPagination = _React$useState2[1];
|
|
644
655
|
React.useEffect(function () {
|
|
645
|
-
//
|
|
656
|
+
// Resetting derived pagination state here intentionally preserves the
|
|
657
|
+
// current rows-per-page choice while jumping back to the first page.
|
|
658
|
+
// eslint-disable-next-line @eslint-react/set-state-in-effect
|
|
646
659
|
setPagination(function (previous) {
|
|
647
660
|
if (previous.resetFlag === resetFlag) {
|
|
648
661
|
return previous;
|
|
@@ -710,31 +723,38 @@ function EnhancedTableHead(props) {
|
|
|
710
723
|
rowCount = props.rowCount,
|
|
711
724
|
onSelectAllClick = props.onSelectAllClick,
|
|
712
725
|
async = props.async;
|
|
713
|
-
return /*#__PURE__*/
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
726
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.TableHead, {
|
|
727
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.TableRow, {
|
|
728
|
+
children: [selectRows && /*#__PURE__*/jsxRuntime.jsx(material.TableCell, {
|
|
729
|
+
padding: "checkbox",
|
|
730
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Checkbox, {
|
|
731
|
+
color: "primary",
|
|
732
|
+
indeterminate: numSelected > 0 && numSelected < rowCount,
|
|
733
|
+
checked: rowCount > 0 && numSelected === rowCount,
|
|
734
|
+
onChange: onSelectAllClick
|
|
735
|
+
})
|
|
736
|
+
}), props.headings.map(function (headCell) {
|
|
737
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.TableCell, {
|
|
738
|
+
align: headCell.numeric ? "right" : "left",
|
|
739
|
+
padding: "normal",
|
|
740
|
+
sortDirection: orderBy === headCell.id ? order : false,
|
|
741
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(material.TableSortLabel, {
|
|
742
|
+
active: orderBy === headCell.id,
|
|
743
|
+
direction: orderBy === headCell.id ? order : "asc",
|
|
744
|
+
onClick: function onClick() {
|
|
745
|
+
return onRequestSort(headCell.id, headCell.sortable && async);
|
|
746
|
+
},
|
|
747
|
+
disabled: headCell.subRow,
|
|
748
|
+
children: [headCell.label, orderBy === headCell.id ? /*#__PURE__*/jsxRuntime.jsx(material.Box, {
|
|
749
|
+
component: "span",
|
|
750
|
+
sx: visuallyHidden,
|
|
751
|
+
children: order === "desc" ? "sorted descending" : "sorted ascending"
|
|
752
|
+
}) : undefined]
|
|
753
|
+
})
|
|
754
|
+
}, headCell.id);
|
|
755
|
+
})]
|
|
756
|
+
})
|
|
757
|
+
});
|
|
738
758
|
}
|
|
739
759
|
EnhancedTableHead.propTypes = {
|
|
740
760
|
onRequestSort: PropTypes.func.isRequired,
|
|
@@ -748,11 +768,6 @@ EnhancedTableHead.propTypes = {
|
|
|
748
768
|
async: PropTypes.bool
|
|
749
769
|
};
|
|
750
770
|
|
|
751
|
-
/**
|
|
752
|
-
* Lazily import UniversalTable to statically break the circular dependency:
|
|
753
|
-
* UniversalTable → EnhancedTable → DataRow → SubTableRow → UniversalTable
|
|
754
|
-
* React.lazy resolves the import at render time, so the module graph stays acyclic.
|
|
755
|
-
*/
|
|
756
771
|
var UniversalTable$2 = /*#__PURE__*/React.lazy(function () {
|
|
757
772
|
return Promise.resolve().then(function () { return UniversalTable$1; });
|
|
758
773
|
});
|
|
@@ -767,30 +782,37 @@ function SubRowToggleCell(_ref) {
|
|
|
767
782
|
onToggle = _ref.onToggle,
|
|
768
783
|
rowValues = _ref.rowValues,
|
|
769
784
|
hideBadge = _ref.hideBadge;
|
|
770
|
-
return /*#__PURE__*/
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
785
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.TableCell, {
|
|
786
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Tooltip, {
|
|
787
|
+
title: isOpen ? "Hide ".concat(header.id) : "Show ".concat(header.id),
|
|
788
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
|
|
789
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.IconButton, {
|
|
790
|
+
onClick: function onClick(event) {
|
|
791
|
+
event.stopPropagation();
|
|
792
|
+
onToggle();
|
|
793
|
+
},
|
|
794
|
+
disabled: rowValues[header.id].length === 0,
|
|
795
|
+
color: header.iconColor || "secondary",
|
|
796
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Badge, {
|
|
797
|
+
badgeContent: rowValues[header.id].length,
|
|
798
|
+
invisible: hideBadge,
|
|
799
|
+
anchorOrigin: {
|
|
800
|
+
vertical: "bottom",
|
|
801
|
+
horizontal: "right"
|
|
802
|
+
},
|
|
803
|
+
sx: {
|
|
804
|
+
"& .MuiBadge-badge": {
|
|
805
|
+
color: function color(theme) {
|
|
806
|
+
return theme.palette.text.primary;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
children: isOpen ? (header === null || header === void 0 ? void 0 : header.closeIcon) || /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.RemoveCircle, {}) : (header === null || header === void 0 ? void 0 : header.openIcon) || /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.AddCircle, {})
|
|
811
|
+
})
|
|
812
|
+
})
|
|
813
|
+
})
|
|
814
|
+
})
|
|
815
|
+
});
|
|
794
816
|
}
|
|
795
817
|
SubRowToggleCell.propTypes = {
|
|
796
818
|
header: PropTypes.object.isRequired,
|
|
@@ -809,27 +831,32 @@ function SubTableRow(_ref2) {
|
|
|
809
831
|
isOpen = _ref2.isOpen,
|
|
810
832
|
rowValues = _ref2.rowValues,
|
|
811
833
|
colSpan = _ref2.colSpan;
|
|
812
|
-
return /*#__PURE__*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
834
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.TableRow, {
|
|
835
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.TableCell, {
|
|
836
|
+
colSpan: colSpan,
|
|
837
|
+
style: {
|
|
838
|
+
paddingBottom: 0,
|
|
839
|
+
paddingTop: 0
|
|
840
|
+
},
|
|
841
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Collapse, {
|
|
842
|
+
"in": isOpen,
|
|
843
|
+
timeout: "auto",
|
|
844
|
+
unmountOnExit: true,
|
|
845
|
+
children: /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
|
|
846
|
+
fallback: null,
|
|
847
|
+
children: /*#__PURE__*/jsxRuntime.jsx(UniversalTable$2, {
|
|
848
|
+
loading: table.loading,
|
|
849
|
+
setLoading: table.setLoading,
|
|
850
|
+
onReload: table.onReload,
|
|
851
|
+
data: rowValues[table.id],
|
|
852
|
+
headers: table.headers,
|
|
853
|
+
name: table.subTitle,
|
|
854
|
+
subTable: true
|
|
855
|
+
})
|
|
856
|
+
})
|
|
857
|
+
})
|
|
858
|
+
})
|
|
859
|
+
});
|
|
833
860
|
}
|
|
834
861
|
SubTableRow.propTypes = {
|
|
835
862
|
table: PropTypes.object.isRequired,
|
|
@@ -839,10 +866,11 @@ SubTableRow.propTypes = {
|
|
|
839
866
|
};
|
|
840
867
|
|
|
841
868
|
function renderDataCells(headers, rowValues) {
|
|
842
|
-
return headers.map(function (header
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
869
|
+
return headers.map(function (header) {
|
|
870
|
+
var _header$id;
|
|
871
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.TableCell, _objectSpread2(_objectSpread2({}, header.cellProps), {}, {
|
|
872
|
+
children: header.component ? header.component(rowValues) : formatCellValue(header, rowValues)
|
|
873
|
+
}), (_header$id = header.id) !== null && _header$id !== void 0 ? _header$id : header.label);
|
|
846
874
|
});
|
|
847
875
|
}
|
|
848
876
|
var DataRow = /*#__PURE__*/React.memo(function DataRow(props) {
|
|
@@ -877,41 +905,45 @@ var DataRow = /*#__PURE__*/React.memo(function DataRow(props) {
|
|
|
877
905
|
handleClick(event, props.rowID);
|
|
878
906
|
}
|
|
879
907
|
}, [selectRows, handleClick, props.rowID]);
|
|
880
|
-
return /*#__PURE__*/
|
|
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
|
-
|
|
908
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
909
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(material.TableRow, {
|
|
910
|
+
tabIndex: selectRows ? 0 : -1,
|
|
911
|
+
hover: selectRows,
|
|
912
|
+
role: selectRows ? "checkbox" : "row",
|
|
913
|
+
selected: isItemSelected,
|
|
914
|
+
"aria-checked": isItemSelected,
|
|
915
|
+
onKeyDown: handleRowKeyDown,
|
|
916
|
+
children: [selectRows && /*#__PURE__*/jsxRuntime.jsx(material.TableCell, {
|
|
917
|
+
padding: "checkbox",
|
|
918
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Checkbox, {
|
|
919
|
+
color: "primary",
|
|
920
|
+
checked: isItemSelected,
|
|
921
|
+
onClick: function onClick(event) {
|
|
922
|
+
return handleClick(event, props.rowID);
|
|
923
|
+
}
|
|
924
|
+
})
|
|
925
|
+
}), subTables.map(function (header, index) {
|
|
926
|
+
var _header$id2;
|
|
927
|
+
return /*#__PURE__*/jsxRuntime.jsx(SubRowToggleCell, {
|
|
928
|
+
header: header,
|
|
929
|
+
isOpen: reveal[index],
|
|
930
|
+
onToggle: function onToggle() {
|
|
931
|
+
return toggleSubRow(index);
|
|
932
|
+
},
|
|
933
|
+
rowValues: rowValues,
|
|
934
|
+
hideBadge: hideBadge
|
|
935
|
+
}, (_header$id2 = header.id) !== null && _header$id2 !== void 0 ? _header$id2 : header.label);
|
|
936
|
+
}), renderDataCells(columns, rowValues)]
|
|
937
|
+
}), subTables.map(function (table, index) {
|
|
938
|
+
var _table$id;
|
|
939
|
+
return /*#__PURE__*/jsxRuntime.jsx(SubTableRow, {
|
|
940
|
+
table: table,
|
|
941
|
+
isOpen: reveal[index],
|
|
942
|
+
rowValues: rowValues,
|
|
943
|
+
colSpan: props.headers.length + 1
|
|
944
|
+
}, (_table$id = table.id) !== null && _table$id !== void 0 ? _table$id : table.label);
|
|
945
|
+
})]
|
|
946
|
+
});
|
|
915
947
|
});
|
|
916
948
|
DataRow.propTypes = {
|
|
917
949
|
rowValues: PropTypes.object.isRequired,
|
|
@@ -923,22 +955,24 @@ DataRow.propTypes = {
|
|
|
923
955
|
rowID: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
|
|
924
956
|
};
|
|
925
957
|
|
|
958
|
+
var skeletonRows = ["row-1", "row-2", "row-3", "row-4", "row-5"];
|
|
959
|
+
var skeletonCells = ["cell-1", "cell-2", "cell-3", "cell-4"];
|
|
926
960
|
var TableLoader = function TableLoader() {
|
|
927
|
-
return /*#__PURE__*/
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
})
|
|
940
|
-
})
|
|
941
|
-
})
|
|
961
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
962
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.TableHead, {}), /*#__PURE__*/jsxRuntime.jsx(material.TableBody, {
|
|
963
|
+
children: skeletonRows.map(function (rowKey) {
|
|
964
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.TableRow, {
|
|
965
|
+
children: skeletonCells.map(function (cellKey) {
|
|
966
|
+
return /*#__PURE__*/jsxRuntime.jsx(material.TableCell, {
|
|
967
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.Skeleton, {
|
|
968
|
+
height: 30
|
|
969
|
+
})
|
|
970
|
+
}, cellKey);
|
|
971
|
+
})
|
|
972
|
+
}, rowKey);
|
|
973
|
+
})
|
|
974
|
+
})]
|
|
975
|
+
});
|
|
942
976
|
};
|
|
943
977
|
|
|
944
978
|
function EnhancedTable(props) {
|
|
@@ -981,59 +1015,66 @@ function EnhancedTable(props) {
|
|
|
981
1015
|
var visibleRows = React.useMemo(function () {
|
|
982
1016
|
return stableSort(rows, getComparator(order, orderBy), headers, orderBy).slice(page * effectiveRowsPerPage, page * effectiveRowsPerPage + effectiveRowsPerPage);
|
|
983
1017
|
}, [effectiveRowsPerPage, headers, order, orderBy, page, rows]);
|
|
984
|
-
return /*#__PURE__*/
|
|
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
|
-
|
|
1036
|
-
|
|
1018
|
+
return /*#__PURE__*/jsxRuntime.jsxs(material.TableContainer, {
|
|
1019
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(material.Table, {
|
|
1020
|
+
sx: {
|
|
1021
|
+
minWidth: 750
|
|
1022
|
+
},
|
|
1023
|
+
size: "small" ,
|
|
1024
|
+
"aria-label": props.name || "data table",
|
|
1025
|
+
children: props.loading ? /*#__PURE__*/jsxRuntime.jsx(TableLoader, {}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1026
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(EnhancedTableHead, {
|
|
1027
|
+
order: order,
|
|
1028
|
+
orderBy: orderBy,
|
|
1029
|
+
onRequestSort: handleSort,
|
|
1030
|
+
headings: headers,
|
|
1031
|
+
selectRows: props.selectRows,
|
|
1032
|
+
numSelected: selected.length,
|
|
1033
|
+
rowCount: rows.length,
|
|
1034
|
+
onSelectAllClick: props.handleSelectAllClick,
|
|
1035
|
+
async: async
|
|
1036
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(material.TableBody, {
|
|
1037
|
+
children: [visibleRows.map(function (row, index) {
|
|
1038
|
+
var rowKey = selectID ? row[selectID] : "row-".concat(page * effectiveRowsPerPage + index);
|
|
1039
|
+
var rowID = getSelectableRowId(row, index, selectID);
|
|
1040
|
+
return /*#__PURE__*/jsxRuntime.jsx(DataRow, {
|
|
1041
|
+
rowID: rowID,
|
|
1042
|
+
headers: headers,
|
|
1043
|
+
rowValues: row,
|
|
1044
|
+
hideBadge: props.hideBadge,
|
|
1045
|
+
selectRows: props.selectRows,
|
|
1046
|
+
handleClick: props.handleClick,
|
|
1047
|
+
isSelected: isSelected
|
|
1048
|
+
}, rowKey);
|
|
1049
|
+
}), !subTable && emptyRows > 0 && /*#__PURE__*/jsxRuntime.jsx(material.TableRow, {
|
|
1050
|
+
style: {
|
|
1051
|
+
height: (33 ) * emptyRows
|
|
1052
|
+
},
|
|
1053
|
+
children: /*#__PURE__*/jsxRuntime.jsx(material.TableCell, {
|
|
1054
|
+
colSpan: headers.length
|
|
1055
|
+
})
|
|
1056
|
+
})]
|
|
1057
|
+
})]
|
|
1058
|
+
})
|
|
1059
|
+
}), subTable ? /*#__PURE__*/jsxRuntime.jsx(material.Box, {
|
|
1060
|
+
sx: {
|
|
1061
|
+
mb: 3
|
|
1062
|
+
}
|
|
1063
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(material.TablePagination, {
|
|
1064
|
+
rowsPerPageOptions: props.pageSizeOptions || getPageOptions(rows.length),
|
|
1065
|
+
component: "div",
|
|
1066
|
+
count: rows.length,
|
|
1067
|
+
rowsPerPage: rowsPerPage,
|
|
1068
|
+
page: page,
|
|
1069
|
+
onPageChange: handleChangePage,
|
|
1070
|
+
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
1071
|
+
sx: {
|
|
1072
|
+
overflow: "visible"
|
|
1073
|
+
},
|
|
1074
|
+
showFirstButton: true,
|
|
1075
|
+
showLastButton: true
|
|
1076
|
+
})]
|
|
1077
|
+
});
|
|
1037
1078
|
}
|
|
1038
1079
|
EnhancedTable.propTypes = {
|
|
1039
1080
|
headers: PropTypes.array.isRequired,
|
|
@@ -1084,6 +1125,7 @@ function UniversalTable(_ref) {
|
|
|
1084
1125
|
persistSearch = _ref.persistSearch,
|
|
1085
1126
|
asyncPages = _ref.asyncPages;
|
|
1086
1127
|
var debounceRef = React.useRef(null);
|
|
1128
|
+
var hasLoadedInitialAsyncPageRef = React.useRef(false);
|
|
1087
1129
|
var async = typeof asyncPages === "number" && asyncPages > 0;
|
|
1088
1130
|
var head = headers || [];
|
|
1089
1131
|
var _useSearchableRows = useSearchableRows(data, head, async),
|
|
@@ -1133,18 +1175,17 @@ function UniversalTable(_ref) {
|
|
|
1133
1175
|
};
|
|
1134
1176
|
}, []);
|
|
1135
1177
|
React.useEffect(function () {
|
|
1136
|
-
if (async) {
|
|
1137
|
-
|
|
1138
|
-
searchTerm: searchTerm,
|
|
1139
|
-
direction: order,
|
|
1140
|
-
column: orderBy,
|
|
1141
|
-
pages: asyncPages
|
|
1142
|
-
});
|
|
1178
|
+
if (!async || hasLoadedInitialAsyncPageRef.current) {
|
|
1179
|
+
return;
|
|
1143
1180
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1181
|
+
hasLoadedInitialAsyncPageRef.current = true;
|
|
1182
|
+
setLoading({
|
|
1183
|
+
searchTerm: searchTerm,
|
|
1184
|
+
direction: order,
|
|
1185
|
+
column: orderBy,
|
|
1186
|
+
pages: asyncPages
|
|
1187
|
+
});
|
|
1188
|
+
}, [async, asyncPages, order, orderBy, searchTerm, setLoading]);
|
|
1148
1189
|
var handleReload = React.useCallback(function () {
|
|
1149
1190
|
if (typeof onReload === "function") {
|
|
1150
1191
|
onReload();
|
|
@@ -1159,51 +1200,54 @@ function UniversalTable(_ref) {
|
|
|
1159
1200
|
} : true);
|
|
1160
1201
|
}
|
|
1161
1202
|
}, [async, onReload, setLoading, searchTerm, order, orderBy, asyncPages]);
|
|
1162
|
-
return /*#__PURE__*/
|
|
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
|
-
|
|
1206
|
-
|
|
1203
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1204
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LazyLoadingIndicator, {
|
|
1205
|
+
show: lazyloading,
|
|
1206
|
+
currentPage: currentPage,
|
|
1207
|
+
totalPages: totalPages
|
|
1208
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Paper, {
|
|
1209
|
+
sx: _objectSpread2({}, subTable && {
|
|
1210
|
+
boxShadow: "none"
|
|
1211
|
+
}),
|
|
1212
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(TableSelectionBanner, {
|
|
1213
|
+
selected: selected,
|
|
1214
|
+
onSelection: onSelection,
|
|
1215
|
+
selectIcon: selectIcon
|
|
1216
|
+
}), /*#__PURE__*/jsxRuntime.jsx(TableTitle, {
|
|
1217
|
+
name: name,
|
|
1218
|
+
subTable: subTable
|
|
1219
|
+
}), !subTable && /*#__PURE__*/jsxRuntime.jsx(TableToolbarContent, {
|
|
1220
|
+
onReload: typeof onReload === "function" || typeof setLoading === "function" ? handleReload : undefined,
|
|
1221
|
+
reloadBtnLoading: reloadBtnLoading,
|
|
1222
|
+
searchTerm: searchTerm,
|
|
1223
|
+
onSearchChange: handleSearch,
|
|
1224
|
+
name: name,
|
|
1225
|
+
persistSearch: persistSearch
|
|
1226
|
+
}), /*#__PURE__*/jsxRuntime.jsx(EnhancedTable, {
|
|
1227
|
+
headers: head,
|
|
1228
|
+
rows: rows,
|
|
1229
|
+
resetFlag: searchTerm,
|
|
1230
|
+
searchTerm: searchTerm,
|
|
1231
|
+
subTable: subTable,
|
|
1232
|
+
hideBadge: hideBadge,
|
|
1233
|
+
loading: loading,
|
|
1234
|
+
selectRows: selectRows,
|
|
1235
|
+
handleSelectAllClick: handleSelectAllClick,
|
|
1236
|
+
handleClick: handleClick,
|
|
1237
|
+
selected: selected,
|
|
1238
|
+
selectID: selectID,
|
|
1239
|
+
pageSizeOptions: pageSizeOptions,
|
|
1240
|
+
name: name,
|
|
1241
|
+
setLoading: setLoading,
|
|
1242
|
+
order: order,
|
|
1243
|
+
orderBy: orderBy,
|
|
1244
|
+
setOrder: setOrder,
|
|
1245
|
+
setOrderBy: setOrderBy,
|
|
1246
|
+
asyncPages: asyncPages,
|
|
1247
|
+
async: async
|
|
1248
|
+
})]
|
|
1249
|
+
})]
|
|
1250
|
+
});
|
|
1207
1251
|
}
|
|
1208
1252
|
UniversalTable.propTypes = {
|
|
1209
1253
|
loading: PropTypes.bool,
|