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 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__*/React.createElement(material.Collapse, {
119
+ return /*#__PURE__*/jsxRuntime.jsx(material.Collapse, {
128
120
  "in": show,
129
121
  timeout: "auto",
130
- unmountOnExit: true
131
- }, /*#__PURE__*/React.createElement(material.Box, {
132
- sx: {
133
- width: "100%",
134
- p: 2
135
- }
136
- }, /*#__PURE__*/React.createElement(material.Typography, {
137
- variant: "body2",
138
- color: "text.secondary",
139
- sx: {
140
- mb: 1
141
- }
142
- }, "Loading page ", currentPage, " of ", totalPages, "..."), /*#__PURE__*/React.createElement(material.LinearProgress, {
143
- variant: "determinate",
144
- value: currentPage / totalPages * 100
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__*/React.createElement(material.Collapse, {
358
+ return /*#__PURE__*/jsxRuntime.jsx(material.Collapse, {
364
359
  "in": selected.length > 0,
365
- unmountOnExit: true
366
- }, /*#__PURE__*/React.createElement(material.Box, {
367
- sx: {
368
- p: 2,
369
- display: "flex",
370
- justifyContent: "space-between",
371
- bgcolor: function bgcolor(theme) {
372
- return styles.alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity);
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
- borderRadius: 1,
375
- borderBottomLeftRadius: 0,
376
- borderBottomRightRadius: 0
377
- }
378
- }, /*#__PURE__*/React.createElement(material.Typography, {
379
- variant: "h6",
380
- id: "tableTitle",
381
- component: "div"
382
- }, selected.length, " selected"), /*#__PURE__*/React.createElement(material.IconButton, {
383
- onClick: function onClick() {
384
- return onSelection(selected);
385
- }
386
- }, selectIcon || /*#__PURE__*/React.createElement(iconsMaterial.Task, null))));
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__*/React.createElement(material.Typography, {
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
- }, name);
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__*/React.createElement(material.Tooltip, {
423
- title: "Reload"
424
- }, /*#__PURE__*/React.createElement(material.Button, {
425
- variant: "contained",
426
- color: "primary",
427
- onClick: handleClick,
428
- disabled: loading
429
- }, /*#__PURE__*/React.createElement(RefreshIcon, null)));
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 isUserType = React.useRef(false);
457
- return /*#__PURE__*/React.createElement("form", {
458
- onSubmit: handleSubmit
459
- }, /*#__PURE__*/React.createElement(material.Paper, {
460
- elevation: 0,
461
- sx: {
462
- borderRadius: expanded ? "24px" : "50px",
463
- display: "flex",
464
- alignItems: "center",
465
- transition: "all 0.5s ease-in-out",
466
- p: expanded ? 1 : 0.5,
467
- width: "fit-content",
468
- border: function border(theme) {
469
- return "1px solid ".concat(theme.palette.divider);
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
- mb: 1
472
- },
473
- onMouseEnter: function onMouseEnter() {
474
- return setHover(true);
475
- },
476
- onMouseLeave: handleEndHover,
477
- onKeyDown: function onKeyDown(e) {
478
- return e.key === "Enter" && handleSubmit(e);
479
- }
480
- }, /*#__PURE__*/React.createElement(material.InputBase, {
481
- placeholder: "Search",
482
- value: value,
483
- onChange: function onChange(e) {
484
- isUserType.current = true;
485
- onSubmit(e.target.value);
486
- },
487
- sx: _objectSpread2({
488
- ml: 1,
489
- width: expanded ? "100%" : 0,
490
- transition: "width 0.5s ease-in-out"
491
- }, expanded ? {} : {
492
- margin: 0
493
- }),
494
- onBlur: handleEndHover
495
- }), /*#__PURE__*/React.createElement(material.Collapse, {
496
- "in": Boolean(value),
497
- orientation: "horizontal",
498
- unmountOnExit: true
499
- }, /*#__PURE__*/React.createElement(material.Stack, {
500
- direction: "row",
501
- spacing: 0,
502
- sx: {
503
- mr: 3,
504
- alignItems: "center"
505
- }
506
- }, /*#__PURE__*/React.createElement(material.IconButton, {
507
- onClick: function onClick() {
508
- isUserType.current = false;
509
- // Immediately clear instead of waiting for the debounce
510
- onSubmit("");
511
- }
512
- }, /*#__PURE__*/React.createElement(iconsMaterial.Clear, null)), /*#__PURE__*/React.createElement(material.Divider, {
513
- orientation: "vertical",
514
- flexItem: true
515
- }))), /*#__PURE__*/React.createElement(material.IconButton, {
516
- onClick: handleSubmit,
517
- type: "submit"
518
- }, /*#__PURE__*/React.createElement(iconsMaterial.Search, null))));
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__*/React.createElement("div", {
539
- key: "SearchArea"
540
- }, /*#__PURE__*/React.createElement(FancySearch, {
541
- value: searchVal,
542
- onSubmit: setFinalVal
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__*/React.createElement(material.Toolbar, {
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
- id: "tableTitle"
589
- }, /*#__PURE__*/React.createElement(ReloadBtn, {
590
- onReload: onReload,
591
- loading: reloadBtnLoading
592
- })), /*#__PURE__*/React.createElement(SearchArea, {
593
- current: searchTerm,
594
- setFinalVal: onSearchChange,
595
- searchName: name,
596
- persistSearch: persistSearch
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
- // eslint-disable-next-line react-hooks/set-state-in-effect
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__*/React.createElement(material.TableHead, null, /*#__PURE__*/React.createElement(material.TableRow, null, selectRows && /*#__PURE__*/React.createElement(material.TableCell, {
714
- padding: "checkbox"
715
- }, /*#__PURE__*/React.createElement(material.Checkbox, {
716
- color: "primary",
717
- indeterminate: numSelected > 0 && numSelected < rowCount,
718
- checked: rowCount > 0 && numSelected === rowCount,
719
- onChange: onSelectAllClick
720
- })), props.headings.map(function (headCell) {
721
- return /*#__PURE__*/React.createElement(material.TableCell, {
722
- key: headCell.id,
723
- align: headCell.numeric ? "right" : "left",
724
- padding: "normal",
725
- sortDirection: orderBy === headCell.id ? order : false
726
- }, /*#__PURE__*/React.createElement(material.TableSortLabel, {
727
- active: orderBy === headCell.id,
728
- direction: orderBy === headCell.id ? order : "asc",
729
- onClick: function onClick() {
730
- return onRequestSort(headCell.id, headCell.sortable && async);
731
- },
732
- disabled: headCell.subRow
733
- }, headCell.label, orderBy === headCell.id ? /*#__PURE__*/React.createElement(material.Box, {
734
- component: "span",
735
- sx: visuallyHidden
736
- }, order === "desc" ? "sorted descending" : "sorted ascending") : undefined));
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__*/React.createElement(material.TableCell, null, /*#__PURE__*/React.createElement(material.Tooltip, {
771
- title: isOpen ? "Hide ".concat(header.id) : "Show ".concat(header.id)
772
- }, /*#__PURE__*/React.createElement(material.Box, null, /*#__PURE__*/React.createElement(material.IconButton, {
773
- onClick: function onClick(event) {
774
- event.stopPropagation();
775
- onToggle();
776
- },
777
- disabled: rowValues[header.id].length === 0,
778
- color: header.iconColor || "secondary"
779
- }, /*#__PURE__*/React.createElement(material.Badge, {
780
- badgeContent: rowValues[header.id].length,
781
- invisible: hideBadge,
782
- anchorOrigin: {
783
- vertical: "bottom",
784
- horizontal: "right"
785
- },
786
- sx: {
787
- "& .MuiBadge-badge": {
788
- color: function color(theme) {
789
- return theme.palette.text.primary;
790
- }
791
- }
792
- }
793
- }, isOpen ? (header === null || header === void 0 ? void 0 : header.closeIcon) || /*#__PURE__*/React.createElement(iconsMaterial.RemoveCircle, null) : (header === null || header === void 0 ? void 0 : header.openIcon) || /*#__PURE__*/React.createElement(iconsMaterial.AddCircle, null))))));
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__*/React.createElement(material.TableRow, null, /*#__PURE__*/React.createElement(material.TableCell, {
813
- colSpan: colSpan,
814
- style: {
815
- paddingBottom: 0,
816
- paddingTop: 0
817
- }
818
- }, /*#__PURE__*/React.createElement(material.Collapse, {
819
- "in": isOpen,
820
- timeout: "auto",
821
- unmountOnExit: true
822
- }, /*#__PURE__*/React.createElement(React.Suspense, {
823
- fallback: null
824
- }, /*#__PURE__*/React.createElement(UniversalTable$2, {
825
- loading: table.loading,
826
- setLoading: table.setLoading,
827
- onReload: table.onReload,
828
- data: rowValues[table.id],
829
- headers: table.headers,
830
- name: table.subTitle,
831
- subTable: true
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, index) {
843
- return /*#__PURE__*/React.createElement(material.TableCell, _extends({
844
- key: header.id || index
845
- }, header.cellProps), header.component ? header.component(rowValues) : formatCellValue(header, rowValues));
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__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(material.TableRow, {
881
- tabIndex: selectRows ? 0 : -1,
882
- hover: selectRows,
883
- role: selectRows ? "checkbox" : "row",
884
- selected: isItemSelected,
885
- "aria-checked": isItemSelected,
886
- onKeyDown: handleRowKeyDown
887
- }, selectRows && /*#__PURE__*/React.createElement(material.TableCell, {
888
- padding: "checkbox"
889
- }, /*#__PURE__*/React.createElement(material.Checkbox, {
890
- color: "primary",
891
- checked: isItemSelected,
892
- onClick: function onClick(event) {
893
- return handleClick(event, props.rowID);
894
- }
895
- })), subTables.map(function (header, index) {
896
- return /*#__PURE__*/React.createElement(SubRowToggleCell, {
897
- key: header.id || index,
898
- header: header,
899
- isOpen: reveal[index],
900
- onToggle: function onToggle() {
901
- return toggleSubRow(index);
902
- },
903
- rowValues: rowValues,
904
- hideBadge: hideBadge
905
- });
906
- }), renderDataCells(columns, rowValues)), subTables.map(function (table, index) {
907
- return /*#__PURE__*/React.createElement(SubTableRow, {
908
- key: table.id || index,
909
- table: table,
910
- isOpen: reveal[index],
911
- rowValues: rowValues,
912
- colSpan: props.headers.length + 1
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__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(material.TableHead, null), /*#__PURE__*/React.createElement(material.TableBody, null, Array.from({
928
- length: 5
929
- }).map(function (_, index) {
930
- return /*#__PURE__*/React.createElement(material.TableRow, {
931
- key: index
932
- }, Array.from({
933
- length: 4
934
- }).map(function (_, cellIndex) {
935
- return /*#__PURE__*/React.createElement(material.TableCell, {
936
- key: cellIndex
937
- }, /*#__PURE__*/React.createElement(material.Skeleton, {
938
- height: 30
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__*/React.createElement(material.TableContainer, null, /*#__PURE__*/React.createElement(material.Table, {
985
- sx: {
986
- minWidth: 750
987
- },
988
- size: "small" ,
989
- "aria-label": props.name || "data table"
990
- }, props.loading ? /*#__PURE__*/React.createElement(TableLoader, null) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EnhancedTableHead, {
991
- order: order,
992
- orderBy: orderBy,
993
- onRequestSort: handleSort,
994
- headings: headers,
995
- selectRows: props.selectRows,
996
- numSelected: selected.length,
997
- rowCount: rows.length,
998
- onSelectAllClick: props.handleSelectAllClick,
999
- async: async
1000
- }), /*#__PURE__*/React.createElement(material.TableBody, null, visibleRows.map(function (row, index) {
1001
- var rowKey = selectID ? row[selectID] : "row-".concat(page * effectiveRowsPerPage + index);
1002
- var rowID = getSelectableRowId(row, index, selectID);
1003
- return /*#__PURE__*/React.createElement(DataRow, {
1004
- key: rowKey,
1005
- rowID: rowID,
1006
- headers: headers,
1007
- rowValues: row,
1008
- hideBadge: props.hideBadge,
1009
- selectRows: props.selectRows,
1010
- handleClick: props.handleClick,
1011
- isSelected: isSelected
1012
- });
1013
- }), !subTable && emptyRows > 0 && /*#__PURE__*/React.createElement(material.TableRow, {
1014
- style: {
1015
- height: (33 ) * emptyRows
1016
- }
1017
- }, /*#__PURE__*/React.createElement(material.TableCell, {
1018
- colSpan: headers.length
1019
- }))))), subTable ? /*#__PURE__*/React.createElement(material.Box, {
1020
- sx: {
1021
- mb: 3
1022
- }
1023
- }) : /*#__PURE__*/React.createElement(material.TablePagination, {
1024
- rowsPerPageOptions: props.pageSizeOptions || getPageOptions(rows.length),
1025
- component: "div",
1026
- count: rows.length,
1027
- rowsPerPage: rowsPerPage,
1028
- page: page,
1029
- onPageChange: handleChangePage,
1030
- onRowsPerPageChange: handleChangeRowsPerPage,
1031
- sx: {
1032
- overflow: "visible"
1033
- },
1034
- showFirstButton: true,
1035
- showLastButton: true
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
- setLoading({
1138
- searchTerm: searchTerm,
1139
- direction: order,
1140
- column: orderBy,
1141
- pages: asyncPages
1142
- });
1178
+ if (!async || hasLoadedInitialAsyncPageRef.current) {
1179
+ return;
1143
1180
  }
1144
- // Run the initial async load once on mount; search/sort/reload handlers
1145
- // send their own payloads after user interaction.
1146
- // eslint-disable-next-line react-hooks/exhaustive-deps
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__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LazyLoadingIndicator, {
1163
- show: lazyloading,
1164
- currentPage: currentPage,
1165
- totalPages: totalPages
1166
- }), /*#__PURE__*/React.createElement(Paper, {
1167
- sx: _objectSpread2({}, subTable && {
1168
- boxShadow: "none"
1169
- })
1170
- }, /*#__PURE__*/React.createElement(TableSelectionBanner, {
1171
- selected: selected,
1172
- onSelection: onSelection,
1173
- selectIcon: selectIcon
1174
- }), /*#__PURE__*/React.createElement(TableTitle, {
1175
- name: name,
1176
- subTable: subTable
1177
- }), !subTable && /*#__PURE__*/React.createElement(TableToolbarContent, {
1178
- onReload: typeof onReload === "function" || typeof setLoading === "function" ? handleReload : undefined,
1179
- reloadBtnLoading: reloadBtnLoading,
1180
- searchTerm: searchTerm,
1181
- onSearchChange: handleSearch,
1182
- name: name,
1183
- persistSearch: persistSearch
1184
- }), /*#__PURE__*/React.createElement(EnhancedTable, {
1185
- headers: head,
1186
- rows: rows,
1187
- resetFlag: searchTerm,
1188
- searchTerm: searchTerm,
1189
- subTable: subTable,
1190
- hideBadge: hideBadge,
1191
- loading: loading,
1192
- selectRows: selectRows,
1193
- handleSelectAllClick: handleSelectAllClick,
1194
- handleClick: handleClick,
1195
- selected: selected,
1196
- selectID: selectID,
1197
- pageSizeOptions: pageSizeOptions,
1198
- name: name,
1199
- setLoading: setLoading,
1200
- order: order,
1201
- orderBy: orderBy,
1202
- setOrder: setOrder,
1203
- setOrderBy: setOrderBy,
1204
- asyncPages: asyncPages,
1205
- async: async
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,