material-react-table 2.0.0-alpha.3 → 2.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cjs/index.js +489 -435
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/icons.d.ts +4 -0
  4. package/dist/cjs/types/locales/hy.d.ts +2 -0
  5. package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
  6. package/dist/cjs/types/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  7. package/dist/cjs/types/types.d.ts +18 -7
  8. package/dist/esm/material-react-table.esm.js +457 -410
  9. package/dist/esm/material-react-table.esm.js.map +1 -1
  10. package/dist/esm/types/icons.d.ts +4 -0
  11. package/dist/esm/types/locales/hy.d.ts +2 -0
  12. package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
  13. package/dist/esm/types/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  14. package/dist/esm/types/types.d.ts +18 -7
  15. package/dist/index.d.ts +25 -10
  16. package/locales/hy.d.ts +2 -0
  17. package/locales/hy.esm.d.ts +2 -0
  18. package/locales/hy.esm.js +93 -0
  19. package/locales/hy.esm.js.map +1 -0
  20. package/locales/hy.js +97 -0
  21. package/locales/hy.js.map +1 -0
  22. package/package.json +7 -7
  23. package/src/body/MRT_TableBody.tsx +13 -21
  24. package/src/body/MRT_TableBodyCell.tsx +2 -2
  25. package/src/body/MRT_TableBodyRow.tsx +3 -3
  26. package/src/body/MRT_TableDetailPanel.tsx +3 -3
  27. package/src/buttons/MRT_GrabHandleButton.tsx +1 -2
  28. package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -2
  29. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +1 -2
  30. package/src/buttons/MRT_ToggleFiltersButton.tsx +1 -2
  31. package/src/buttons/MRT_ToggleFullScreenButton.tsx +2 -3
  32. package/src/column.utils.ts +15 -9
  33. package/src/footer/MRT_TableFooter.tsx +1 -1
  34. package/src/footer/MRT_TableFooterCell.tsx +1 -1
  35. package/src/footer/MRT_TableFooterRow.tsx +2 -2
  36. package/src/head/MRT_TableHead.tsx +36 -14
  37. package/src/head/MRT_TableHeadCell.tsx +1 -1
  38. package/src/head/MRT_TableHeadRow.tsx +2 -2
  39. package/src/hooks/useMRT_Effects.ts +13 -2
  40. package/src/hooks/useMRT_TableOptions.ts +7 -2
  41. package/src/icons.ts +12 -0
  42. package/src/locales/hy.ts +93 -0
  43. package/src/table/MRT_Table.tsx +4 -2
  44. package/src/toolbar/MRT_TablePagination.tsx +135 -68
  45. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +53 -15
  46. package/src/toolbar/MRT_TopToolbar.tsx +1 -1
  47. package/src/types.ts +22 -9
package/dist/cjs/index.js CHANGED
@@ -43,23 +43,28 @@ var Popover = require('@mui/material/Popover');
43
43
  var Divider = require('@mui/material/Divider');
44
44
  var Badge = require('@mui/material/Badge');
45
45
  var TableSortLabel = require('@mui/material/TableSortLabel');
46
- var Dialog = require('@mui/material/Dialog');
47
- var DialogActions = require('@mui/material/DialogActions');
48
- var DialogContent = require('@mui/material/DialogContent');
49
- var DialogTitle = require('@mui/material/DialogTitle');
50
- var CircularProgress = require('@mui/material/CircularProgress');
51
46
  var Toolbar = require('@mui/material/Toolbar');
52
47
  var useMediaQuery = require('@mui/material/useMediaQuery');
53
48
  var LinearProgress = require('@mui/material/LinearProgress');
54
- var TablePagination = require('@mui/material/TablePagination');
49
+ var InputLabel = require('@mui/material/InputLabel');
50
+ var Pagination = require('@mui/material/Pagination');
51
+ var PaginationItem = require('@mui/material/PaginationItem');
52
+ var Select = require('@mui/material/Select');
55
53
  var Alert = require('@mui/material/Alert');
56
54
  var AlertTitle = require('@mui/material/AlertTitle');
55
+ var Radio = require('@mui/material/Radio');
57
56
  var Fade = require('@mui/material/Fade');
58
57
  var Switch = require('@mui/material/Switch');
59
- var Radio = require('@mui/material/Radio');
58
+ var Dialog = require('@mui/material/Dialog');
59
+ var DialogActions = require('@mui/material/DialogActions');
60
+ var DialogContent = require('@mui/material/DialogContent');
61
+ var DialogTitle = require('@mui/material/DialogTitle');
62
+ var CircularProgress = require('@mui/material/CircularProgress');
60
63
  var ArrowDownwardIcon = require('@mui/icons-material/ArrowDownward');
61
64
  var ArrowRightIcon = require('@mui/icons-material/ArrowRight');
62
65
  var CancelIcon = require('@mui/icons-material/Cancel');
66
+ var ChevronLeftIcon = require('@mui/icons-material/ChevronLeft');
67
+ var ChevronRightIcon = require('@mui/icons-material/ChevronRight');
63
68
  var ClearAllIcon = require('@mui/icons-material/ClearAll');
64
69
  var CloseIcon = require('@mui/icons-material/Close');
65
70
  var DensityLargeIcon = require('@mui/icons-material/DensityLarge');
@@ -72,9 +77,11 @@ var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
72
77
  var FilterAltIcon = require('@mui/icons-material/FilterAlt');
73
78
  var FilterListIcon = require('@mui/icons-material/FilterList');
74
79
  var FilterListOffIcon = require('@mui/icons-material/FilterListOff');
80
+ var FirstPageIcon = require('@mui/icons-material/FirstPage');
75
81
  var FullscreenIcon = require('@mui/icons-material/Fullscreen');
76
82
  var FullscreenExitIcon = require('@mui/icons-material/FullscreenExit');
77
83
  var KeyboardDoubleArrowDownIcon = require('@mui/icons-material/KeyboardDoubleArrowDown');
84
+ var LastPageIcon = require('@mui/icons-material/LastPage');
78
85
  var MoreHorizIcon = require('@mui/icons-material/MoreHoriz');
79
86
  var MoreVertIcon = require('@mui/icons-material/MoreVert');
80
87
  var PushPinIcon = require('@mui/icons-material/PushPin');
@@ -121,23 +128,28 @@ var Popover__default = /*#__PURE__*/_interopDefaultLegacy(Popover);
121
128
  var Divider__default = /*#__PURE__*/_interopDefaultLegacy(Divider);
122
129
  var Badge__default = /*#__PURE__*/_interopDefaultLegacy(Badge);
123
130
  var TableSortLabel__default = /*#__PURE__*/_interopDefaultLegacy(TableSortLabel);
124
- var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
125
- var DialogActions__default = /*#__PURE__*/_interopDefaultLegacy(DialogActions);
126
- var DialogContent__default = /*#__PURE__*/_interopDefaultLegacy(DialogContent);
127
- var DialogTitle__default = /*#__PURE__*/_interopDefaultLegacy(DialogTitle);
128
- var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgress);
129
131
  var Toolbar__default = /*#__PURE__*/_interopDefaultLegacy(Toolbar);
130
132
  var useMediaQuery__default = /*#__PURE__*/_interopDefaultLegacy(useMediaQuery);
131
133
  var LinearProgress__default = /*#__PURE__*/_interopDefaultLegacy(LinearProgress);
132
- var TablePagination__default = /*#__PURE__*/_interopDefaultLegacy(TablePagination);
134
+ var InputLabel__default = /*#__PURE__*/_interopDefaultLegacy(InputLabel);
135
+ var Pagination__default = /*#__PURE__*/_interopDefaultLegacy(Pagination);
136
+ var PaginationItem__default = /*#__PURE__*/_interopDefaultLegacy(PaginationItem);
137
+ var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
133
138
  var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
134
139
  var AlertTitle__default = /*#__PURE__*/_interopDefaultLegacy(AlertTitle);
140
+ var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
135
141
  var Fade__default = /*#__PURE__*/_interopDefaultLegacy(Fade);
136
142
  var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
137
- var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
143
+ var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
144
+ var DialogActions__default = /*#__PURE__*/_interopDefaultLegacy(DialogActions);
145
+ var DialogContent__default = /*#__PURE__*/_interopDefaultLegacy(DialogContent);
146
+ var DialogTitle__default = /*#__PURE__*/_interopDefaultLegacy(DialogTitle);
147
+ var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgress);
138
148
  var ArrowDownwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownwardIcon);
139
149
  var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
140
150
  var CancelIcon__default = /*#__PURE__*/_interopDefaultLegacy(CancelIcon);
151
+ var ChevronLeftIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronLeftIcon);
152
+ var ChevronRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronRightIcon);
141
153
  var ClearAllIcon__default = /*#__PURE__*/_interopDefaultLegacy(ClearAllIcon);
142
154
  var CloseIcon__default = /*#__PURE__*/_interopDefaultLegacy(CloseIcon);
143
155
  var DensityLargeIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityLargeIcon);
@@ -150,9 +162,11 @@ var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon)
150
162
  var FilterAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltIcon);
151
163
  var FilterListIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListIcon);
152
164
  var FilterListOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListOffIcon);
165
+ var FirstPageIcon__default = /*#__PURE__*/_interopDefaultLegacy(FirstPageIcon);
153
166
  var FullscreenIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenIcon);
154
167
  var FullscreenExitIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenExitIcon);
155
168
  var KeyboardDoubleArrowDownIcon__default = /*#__PURE__*/_interopDefaultLegacy(KeyboardDoubleArrowDownIcon);
169
+ var LastPageIcon__default = /*#__PURE__*/_interopDefaultLegacy(LastPageIcon);
156
170
  var MoreHorizIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreHorizIcon);
157
171
  var MoreVertIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreVertIcon);
158
172
  var PushPinIcon__default = /*#__PURE__*/_interopDefaultLegacy(PushPinIcon);
@@ -400,19 +414,24 @@ const getCanRankRows = (table) => {
400
414
  };
401
415
  const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
402
416
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
417
+ const { options: { layoutMode }, } = table;
403
418
  const widthStyles = {
404
419
  minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = column.columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
405
420
  width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px)`,
406
421
  };
422
+ if (layoutMode === 'grid') {
423
+ widthStyles.flex = `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_d = header === null || header === void 0 ? void 0 : header.id) !== null && _d !== void 0 ? _d : column.id)}-size) 0 auto`;
424
+ }
425
+ else if (layoutMode === 'grid-no-grow') {
426
+ widthStyles.flex = '0 0 auto';
427
+ }
407
428
  return Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
408
429
  ? styles.alpha(styles.lighten(theme.palette.background.default, 0.04), 0.97)
409
430
  : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
410
431
  ? `-4px 0 8px -6px ${styles.alpha(theme.palette.common.black, 0.2)} inset`
411
432
  : getIsFirstRightPinnedColumn(column)
412
433
  ? `4px 0 8px -6px ${styles.alpha(theme.palette.common.black, 0.2)} inset`
413
- : undefined, display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell', flex: table.options.layoutMode === 'grid'
414
- ? `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_d = header === null || header === void 0 ? void 0 : header.id) !== null && _d !== void 0 ? _d : column.id)}-size) 0 auto`
415
- : undefined, left: column.getIsPinned() === 'left'
434
+ : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
416
435
  ? `${column.getStart('left')}px`
417
436
  : undefined, ml: table.options.enableColumnVirtualization &&
418
437
  column.getIsPinned() === 'left' &&
@@ -725,7 +744,7 @@ const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, ta
725
744
  : undefined,
726
745
  outlineOffset: '-1px',
727
746
  textOverflow: 'clip',
728
- }, alignItems: layoutMode === 'grid' ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', justifyContent: layoutMode === 'grid' ? tableCellProps.align : undefined, overflow: 'hidden', p: density === 'compact'
747
+ }, alignItems: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'center' : undefined, cursor: isEditable && editDisplayMode === 'cell' ? 'pointer' : 'inherit', justifyContent: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? tableCellProps.align : undefined, overflow: 'hidden', p: density === 'compact'
729
748
  ? columnDefType === 'display'
730
749
  ? '0 0.5rem'
731
750
  : '0.5rem'
@@ -778,14 +797,14 @@ const MRT_TableDetailPanel = ({ parentRowRef, row, rowIndex, table, virtualRow,
778
797
  });
779
798
  return (jsxRuntime.jsx(TableRow__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel" }, tableRowProps, { sx: (theme) => {
780
799
  var _a, _b;
781
- return (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row', position: virtualRow ? 'absolute' : undefined, top: virtualRow
800
+ return (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, position: virtualRow ? 'absolute' : undefined, top: virtualRow
782
801
  ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
783
802
  : undefined, transform: virtualRow
784
803
  ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
785
804
  : undefined, width: '100%', zIndex: virtualRow ? 2 : undefined }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme)));
786
805
  }, children: jsxRuntime.jsx(TableCell__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
787
- ? styles.lighten(theme.palette.background.default, 0.06)
788
- : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: layoutMode === 'grid' ? 'flex' : 'table-cell', pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: renderDetailPanel && (jsxRuntime.jsx(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
806
+ ? styles.lighten(theme.palette.background.default, 0.05)
807
+ : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : 'table-cell', pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: renderDetailPanel && (jsxRuntime.jsx(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
789
808
  };
790
809
 
791
810
  const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
@@ -840,10 +859,10 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
840
859
  ? `${styles.lighten(theme.palette.background.default, 0.12)}`
841
860
  : `${styles.darken(theme.palette.background.default, 0.05)}`
842
861
  : undefined,
843
- }, backgroundColor: `${styles.lighten(theme.palette.background.default, 0.06)} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
862
+ }, backgroundColor: `${styles.lighten(theme.palette.background.default, 0.05)} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
844
863
  ? `${bottomPinnedIndex * rowHeight +
845
864
  (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
846
- : undefined, boxSizing: 'border-box', display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: isPinned
865
+ : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned
847
866
  ? 0.98
848
867
  : (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
849
868
  ? 0.5
@@ -863,7 +882,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
863
882
  ? `${topPinnedIndex * rowHeight +
864
883
  (enableStickyHeader || isFullScreen ? tableHeadHeight - 1 : 0)}px`
865
884
  : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', zIndex: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
866
- ? 1
885
+ ? 2
867
886
  : undefined }, sx)), children: [virtualPaddingLeft ? (jsxRuntime.jsx("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
868
887
  const cell = columnVirtualizer
869
888
  ? row.getVisibleCells()[cellOrVirtualCell.index]
@@ -906,7 +925,7 @@ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFil
906
925
  const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
907
926
  var _a, _b, _c, _d, _e, _f;
908
927
  const { getBottomRows, getCenterRows, getIsSomeRowsPinned, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { enableGlobalFilterRankedResults, enablePagination, enableRowPinning, enableRowVirtualization, enableStickyFooter, enableStickyHeader, layoutMode, localization, manualExpanding, manualFiltering, manualGrouping, manualPagination, manualSorting, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef, tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
909
- const { columnFilters, density, expanded, globalFilter, globalFilterFn, isFullScreen, pagination, rowPinning, sorting, } = getState();
928
+ const { columnFilters, density, expanded, globalFilter, isFullScreen, pagination, rowPinning, sorting, } = getState();
910
929
  const tableBodyProps = parseFromValuesOrFunc(muiTableBodyProps, { table });
911
930
  const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
912
931
  table,
@@ -915,16 +934,9 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
915
934
  ((_a = tableHeadRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight)) ||
916
935
  0;
917
936
  const tableFooterHeight = (enableStickyFooter && ((_b = tableFooterRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
918
- const shouldRankResults = react.useMemo(() => !manualExpanding &&
919
- !manualFiltering &&
920
- !manualGrouping &&
921
- !manualSorting &&
922
- enableGlobalFilterRankedResults &&
923
- globalFilter &&
924
- globalFilterFn === 'fuzzy' &&
925
- expanded !== true &&
937
+ const shouldRankRows = react.useMemo(() => getCanRankRows(table) &&
926
938
  !Object.values(sorting).some(Boolean) &&
927
- !Object.values(expanded).some(Boolean), [
939
+ globalFilter, [
928
940
  enableGlobalFilterRankedResults,
929
941
  expanded,
930
942
  globalFilter,
@@ -939,7 +951,7 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
939
951
  .map((r) => r.id), [rowPinning, table.getRowModel().rows]);
940
952
  const rows = react.useMemo(() => {
941
953
  let rows = [];
942
- if (!shouldRankResults) {
954
+ if (!shouldRankRows) {
943
955
  rows =
944
956
  !enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
945
957
  ? getRowModel().rows
@@ -961,8 +973,8 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
961
973
  }
962
974
  return rows;
963
975
  }, [
964
- shouldRankResults,
965
- shouldRankResults ? getPrePaginationRowModel().rows : getRowModel().rows,
976
+ shouldRankRows,
977
+ shouldRankRows ? getPrePaginationRowModel().rows : getRowModel().rows,
966
978
  pagination.pageIndex,
967
979
  pagination.pageSize,
968
980
  rowPinning,
@@ -980,7 +992,7 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
980
992
  ? rowVirtualizer.getVirtualItems()
981
993
  : undefined;
982
994
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
983
- getIsSomeRowsPinned('top') && (jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, rowIndex) => {
995
+ getIsSomeRowsPinned('top') && (jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, rowIndex) => {
984
996
  const props = {
985
997
  columnVirtualizer,
986
998
  measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
@@ -993,10 +1005,10 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
993
1005
  virtualPaddingRight,
994
1006
  };
995
1007
  return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
996
- }) }))), jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', height: rowVirtualizer
1008
+ }) }))), jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
997
1009
  ? `${rowVirtualizer.getTotalSize()}px`
998
- : 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: (_c = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _c !== void 0 ? _c : (!rows.length ? (jsxRuntime.jsx("tr", { style: { display: layoutMode === 'grid' ? 'grid' : 'table-row' }, children: jsxRuntime.jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
999
- display: layoutMode === 'grid' ? 'grid' : 'table-cell',
1010
+ : 'inherit', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: (_c = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _c !== void 0 ? _c : (!rows.length ? (jsxRuntime.jsx("tr", { style: { display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, children: jsxRuntime.jsx("td", { colSpan: table.getVisibleLeafColumns().length, style: {
1011
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : 'table-cell',
1000
1012
  }, children: (_d = renderEmptyRowsFallback === null || renderEmptyRowsFallback === void 0 ? void 0 : renderEmptyRowsFallback({ table })) !== null && _d !== void 0 ? _d : (jsxRuntime.jsx(Typography__default["default"], { sx: {
1001
1013
  color: 'text.secondary',
1002
1014
  fontStyle: 'italic',
@@ -1027,7 +1039,7 @@ const MRT_TableBody = ({ columnVirtualizer, table, virtualColumns, virtualPaddin
1027
1039
  };
1028
1040
  return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
1029
1041
  }) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
1030
- getIsSomeRowsPinned('bottom') && (jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: layoutMode === 'grid' ? 'grid' : 'table-row-group', position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, rowIndex) => {
1042
+ getIsSomeRowsPinned('bottom') && (jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, rowIndex) => {
1031
1043
  const props = {
1032
1044
  columnVirtualizer,
1033
1045
  measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
@@ -1055,7 +1067,7 @@ const MRT_TableFooterCell = ({ footer, table, }) => {
1055
1067
  column,
1056
1068
  table,
1057
1069
  }));
1058
- return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-cell', fontWeight: 'bold', justifyContent: columnDefType === 'group' ? 'center' : undefined, p: density === 'compact'
1070
+ return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : 'table-cell', fontWeight: 'bold', justifyContent: columnDefType === 'group' ? 'center' : undefined, p: density === 'compact'
1059
1071
  ? '0.5rem'
1060
1072
  : density === 'comfortable'
1061
1073
  ? '1rem'
@@ -1081,7 +1093,7 @@ const MRT_TableFooterRow = ({ footerGroup, table, virtualColumns, virtualPadding
1081
1093
  footerGroup,
1082
1094
  table,
1083
1095
  });
1084
- return (jsxRuntime.jsxs(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.04), display: layoutMode === 'grid' ? 'flex' : 'table-row', width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter) => {
1096
+ return (jsxRuntime.jsxs(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.05), display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, width: '100%' }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : footerGroup.headers).map((footerOrVirtualFooter) => {
1085
1097
  const footer = virtualColumns
1086
1098
  ? footerGroup.headers[footerOrVirtualFooter.index]
1087
1099
  : footerOrVirtualFooter;
@@ -1102,7 +1114,7 @@ const MRT_TableFooter = ({ table, virtualColumns, virtualPaddingLeft, virtualPad
1102
1114
  // @ts-ignore
1103
1115
  tableFooterProps.ref.current = ref;
1104
1116
  }
1105
- }, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
1117
+ }, sx: (theme) => (Object.assign({ bottom: stickFooter ? 0 : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
1106
1118
  ? theme.palette.mode === 'light'
1107
1119
  ? `1px solid ${theme.palette.grey[300]}`
1108
1120
  : `1px solid ${theme.palette.grey[700]}`
@@ -2020,7 +2032,7 @@ const MRT_TableHeadCell = ({ header, table, }) => {
2020
2032
  if (node) {
2021
2033
  tableHeadCellRefs.current[column.id] = node;
2022
2034
  }
2023
- } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: layoutMode === 'grid' ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
2035
+ } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
2024
2036
  ? '0.5rem'
2025
2037
  : density === 'comfortable'
2026
2038
  ? columnDefType === 'display'
@@ -2087,7 +2099,7 @@ const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLe
2087
2099
  headerGroup,
2088
2100
  table,
2089
2101
  });
2090
- return (jsxRuntime.jsxs(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.04), boxShadow: `4px 0 8px ${styles.alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', top: 0 }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
2102
+ return (jsxRuntime.jsxs(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.05), boxShadow: `4px 0 8px ${styles.alpha(theme.palette.common.black, 0.1)}`, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, top: 0 }, parseFromValuesOrFunc(tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx, theme))), children: [virtualPaddingLeft ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingLeft } })) : null, (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : headerGroup.headers).map((headerOrVirtualHeader) => {
2091
2103
  const header = virtualColumns
2092
2104
  ? headerGroup.headers[headerOrVirtualHeader.index]
2093
2105
  : headerOrVirtualHeader;
@@ -2095,208 +2107,6 @@ const MRT_TableHeadRow = ({ headerGroup, table, virtualColumns, virtualPaddingLe
2095
2107
  }), virtualPaddingRight ? (jsxRuntime.jsx("th", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })));
2096
2108
  };
2097
2109
 
2098
- const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
2099
- const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, refs: { tableHeadRef }, } = table;
2100
- const { isFullScreen } = getState();
2101
- const tableHeadProps = parseFromValuesOrFunc(muiTableHeadProps, { table });
2102
- const stickyHeader = enableStickyHeader || isFullScreen;
2103
- return (jsxRuntime.jsx(TableHead__default["default"], Object.assign({}, tableHeadProps, { ref: (ref) => {
2104
- tableHeadRef.current = ref;
2105
- if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
2106
- // @ts-ignore
2107
- tableHeadProps.ref.current = ref;
2108
- }
2109
- }, sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, parseFromValuesOrFunc(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx, theme))), children: getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { headerGroup: headerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, headerGroup.id))) })));
2110
- };
2111
-
2112
- const MRT_Table = ({ table, }) => {
2113
- var _a, _b, _c, _d;
2114
- const { getFlatHeaders, getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, columns, enableColumnPinning, enableColumnResizing, enableColumnVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
2115
- const { columnPinning, columnSizing, columnSizingInfo, columnVisibility, isFullScreen, } = getState();
2116
- const tableProps = parseFromValuesOrFunc(muiTableProps, { table });
2117
- const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, { table });
2118
- const columnSizeVars = react.useMemo(() => {
2119
- const headers = getFlatHeaders();
2120
- const colSizes = {};
2121
- for (let i = 0; i < headers.length; i++) {
2122
- const header = headers[i];
2123
- const colSize = header.getSize();
2124
- colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
2125
- colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
2126
- }
2127
- return colSizes;
2128
- }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
2129
- //get first 16 column widths and average them
2130
- const averageColumnWidth = react.useMemo(() => {
2131
- var _a, _b, _c, _d;
2132
- if (!enableColumnVirtualization)
2133
- return 0;
2134
- const columnsWidths = (_d = (_c = (_b = (_a = table
2135
- .getRowModel()
2136
- .rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
2137
- return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
2138
- }, [table.getRowModel().rows, columnPinning, columnVisibility]);
2139
- const [leftPinnedIndexes, rightPinnedIndexes] = react.useMemo(() => enableColumnVirtualization && enableColumnPinning
2140
- ? [
2141
- table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
2142
- table
2143
- .getRightLeafColumns()
2144
- .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
2145
- ]
2146
- : [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
2147
- const columnVirtualizer = enableColumnVirtualization
2148
- ? reactVirtual.useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: react.useCallback((range) => [
2149
- ...new Set([
2150
- ...leftPinnedIndexes,
2151
- ...reactVirtual.defaultRangeExtractor(range),
2152
- ...rightPinnedIndexes,
2153
- ]),
2154
- ], [leftPinnedIndexes, rightPinnedIndexes]) }, columnVirtualizerProps))
2155
- : undefined;
2156
- if (columnVirtualizerInstanceRef && columnVirtualizer) {
2157
- columnVirtualizerInstanceRef.current = columnVirtualizer;
2158
- }
2159
- const virtualColumns = columnVirtualizer
2160
- ? columnVirtualizer.getVirtualItems()
2161
- : undefined;
2162
- let virtualPaddingLeft;
2163
- let virtualPaddingRight;
2164
- if (columnVirtualizer && (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)) {
2165
- virtualPaddingLeft = (_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0;
2166
- virtualPaddingRight =
2167
- columnVirtualizer.getTotalSize() -
2168
- ((_d = (_c = virtualColumns[virtualColumns.length - 1 - rightPinnedIndexes.length]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
2169
- }
2170
- const props = {
2171
- table,
2172
- virtualColumns,
2173
- virtualPaddingLeft,
2174
- virtualPaddingRight,
2175
- };
2176
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Table__default["default"], Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: layoutMode !== 'grid' && enableColumnResizing ? 'fixed' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, props))] })) }));
2177
- };
2178
-
2179
- const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
2180
- const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
2181
- const { creatingRow, editingRow, isSaving } = getState();
2182
- const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
2183
- const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
2184
- const handleCancel = () => {
2185
- if (isCreating) {
2186
- onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
2187
- setCreatingRow(null);
2188
- }
2189
- else if (isEditing) {
2190
- onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
2191
- setEditingRow(null);
2192
- }
2193
- row._valuesCache = {}; //reset values cache
2194
- };
2195
- const handleSubmitRow = () => {
2196
- var _a;
2197
- //look for auto-filled input values
2198
- (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)
2199
- .filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
2200
- if (input.value !== undefined &&
2201
- Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
2202
- // @ts-ignore
2203
- row._valuesCache[input.name] = input.value;
2204
- }
2205
- });
2206
- if (isCreating)
2207
- onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
2208
- exitCreatingMode: () => setCreatingRow(null),
2209
- row,
2210
- table,
2211
- values: row._valuesCache,
2212
- });
2213
- else if (isEditing) {
2214
- onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
2215
- exitEditingMode: () => setEditingRow(null),
2216
- row,
2217
- table,
2218
- values: row === null || row === void 0 ? void 0 : row._valuesCache,
2219
- });
2220
- }
2221
- };
2222
- return (jsxRuntime.jsx(Box__default["default"], { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' }, children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.cancel, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }), jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.save, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsxRuntime.jsx(CircularProgress__default["default"], { size: 18 }) : jsxRuntime.jsx(SaveIcon, {}) }) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button__default["default"], { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxRuntime.jsxs(Button__default["default"], { onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsxRuntime.jsx(CircularProgress__default["default"], { color: "inherit", size: 18 }), localization.save] })] })) }));
2223
- };
2224
-
2225
- const MRT_EditRowModal = ({ open, table, }) => {
2226
- var _a;
2227
- const { getState, options: { localization, muiCreateRowModalProps, muiEditRowModalProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowModalContent, renderEditRowModalContent, }, setCreatingRow, setEditingRow, } = table;
2228
- const { creatingRow, editingRow } = getState();
2229
- const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
2230
- const dialogProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowModalProps, { row, table })), (creatingRow &&
2231
- parseFromValuesOrFunc(muiCreateRowModalProps, { row, table })));
2232
- const internalEditComponents = row
2233
- .getAllCells()
2234
- .filter((cell) => cell.column.columnDef.columnDefType === 'data')
2235
- .map((cell) => (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
2236
- return (jsxRuntime.jsx(Dialog__default["default"], Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
2237
- var _a;
2238
- if (creatingRow) {
2239
- onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
2240
- setCreatingRow(null);
2241
- }
2242
- else {
2243
- onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
2244
- setEditingRow(null);
2245
- }
2246
- row._valuesCache = {}; //reset values cache
2247
- (_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
2248
- }, open: open }, dialogProps, { children: (_a = ((creatingRow &&
2249
- (renderCreateRowModalContent === null || renderCreateRowModalContent === void 0 ? void 0 : renderCreateRowModalContent({
2250
- internalEditComponents,
2251
- row,
2252
- table,
2253
- }))) ||
2254
- (renderEditRowModalContent === null || renderEditRowModalContent === void 0 ? void 0 : renderEditRowModalContent({
2255
- internalEditComponents,
2256
- row,
2257
- table,
2258
- })))) !== null && _a !== void 0 ? _a : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DialogTitle__default["default"], { sx: { textAlign: 'center' }, children: localization.edit }), jsxRuntime.jsx(DialogContent__default["default"], { children: jsxRuntime.jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsxRuntime.jsx(Stack__default["default"], { sx: {
2259
- gap: '24px',
2260
- paddingTop: '16px',
2261
- width: '100%',
2262
- }, children: internalEditComponents }) }) }), jsxRuntime.jsx(DialogActions__default["default"], { sx: { p: '1.25rem' }, children: jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
2263
- };
2264
-
2265
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react.useLayoutEffect : react.useEffect;
2266
- const MRT_TableContainer = ({ table, }) => {
2267
- const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
2268
- const { creatingRow, editingRow, isFullScreen } = getState();
2269
- const [totalToolbarHeight, setTotalToolbarHeight] = react.useState(0);
2270
- const tableContainerProps = parseFromValuesOrFunc(muiTableContainerProps, {
2271
- table,
2272
- });
2273
- useIsomorphicLayoutEffect(() => {
2274
- var _a, _b, _c, _d;
2275
- const topToolbarHeight = typeof document !== 'undefined'
2276
- ? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
2277
- : 0;
2278
- const bottomToolbarHeight = typeof document !== 'undefined'
2279
- ? (_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0
2280
- : 0;
2281
- setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
2282
- });
2283
- const createModalOpen = createDisplayMode === 'modal' && creatingRow;
2284
- const editModalOpen = editDisplayMode === 'modal' && editingRow;
2285
- return (jsxRuntime.jsxs(TableContainer__default["default"], Object.assign({}, tableContainerProps, { ref: (node) => {
2286
- if (node) {
2287
- tableContainerRef.current = node;
2288
- if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
2289
- //@ts-ignore
2290
- tableContainerProps.ref.current = node;
2291
- }
2292
- }
2293
- }, style: Object.assign({ maxHeight: isFullScreen
2294
- ? `calc(100vh - ${totalToolbarHeight}px)`
2295
- : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
2296
- ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
2297
- : undefined, maxWidth: '100%', overflow: 'auto' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [jsxRuntime.jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsxRuntime.jsx(MRT_EditRowModal, { open: true, table: table }))] })));
2298
- };
2299
-
2300
2110
  const MRT_LinearProgressBar = ({ isTopToolbar, table, }) => {
2301
2111
  const { getState, options: { muiLinearProgressProps }, } = table;
2302
2112
  const { isLoading, showProgressBars } = getState();
@@ -2312,65 +2122,205 @@ const MRT_LinearProgressBar = ({ isTopToolbar, table, }) => {
2312
2122
  }, unmountOnExit: true, children: jsxRuntime.jsx(LinearProgress__default["default"], Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
2313
2123
  };
2314
2124
 
2315
- const MRT_TablePagination = ({ position = 'bottom', table, }) => {
2316
- const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, localization, muiTablePaginationProps, rowCount, }, setPageIndex, setPageSize, } = table;
2317
- const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
2318
- const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
2319
- const showFirstLastPageButtons = totalRowCount / pageSize > 2;
2320
- const tablePaginationProps = parseFromValuesOrFunc(muiTablePaginationProps, {
2321
- table,
2322
- });
2323
- const handleChangeRowsPerPage = (event) => {
2324
- setPageSize(+event.target.value);
2325
- };
2326
- return (jsxRuntime.jsx(TablePagination__default["default"], Object.assign({ component: "div", count: totalRowCount, getItemAriaLabel: (type) => type === 'first'
2327
- ? localization.goToFirstPage
2328
- : type === 'last'
2329
- ? localization.goToLastPage
2330
- : type === 'next'
2331
- ? localization.goToNextPage
2332
- : localization.goToPreviousPage, labelDisplayedRows: ({ count, from, to }) => `${from}-${to} ${localization.of} ${count}`, labelRowsPerPage: localization.rowsPerPage, onPageChange: (_, newPage) => setPageIndex(newPage), onRowsPerPageChange: handleChangeRowsPerPage, page: Math.max(Math.min(pageIndex, Math.ceil(totalRowCount / pageSize) - 1), 0), rowsPerPage: pageSize, rowsPerPageOptions: [5, 10, 15, 20, 25, 30, 50, 100], showFirstButton: showFirstLastPageButtons, showLastButton: showFirstLastPageButtons }, tablePaginationProps, { SelectProps: Object.assign({ MenuProps: { MenuListProps: { disablePadding: true }, sx: { m: 0 } }, sx: { m: '0 1rem 0 1ch' } }, tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.SelectProps), sx: (theme) => (Object.assign({ '& . MuiTablePagination-select': {
2333
- m: '0 1px',
2334
- }, '& .MuiTablePagination-actions': {
2335
- m: '0 1px',
2336
- }, '& .MuiTablePagination-displayedRows': {
2337
- m: '0 1px',
2338
- }, '& .MuiTablePagination-selectLabel': {
2339
- m: '0 -1px',
2340
- }, '& .MuiTablePagination-toolbar': {
2341
- alignItems: 'center',
2342
- display: 'flex',
2343
- }, '&. MuiInputBase-root': {
2344
- m: '0 1px',
2345
- }, mt: position === 'top' &&
2346
- enableToolbarInternalActions &&
2347
- !showGlobalFilter
2348
- ? '3.5rem'
2349
- : undefined, position: 'relative', zIndex: 2 }, parseFromValuesOrFunc(tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx, theme))) })));
2350
- };
2351
-
2352
- const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
2353
- var _a, _b;
2354
- const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, rowCount, }, } = table;
2355
- const { grouping, showAlertBanner } = getState();
2356
- const alertProps = parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
2357
- table,
2358
- });
2359
- const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
2360
- table,
2361
- });
2362
- const selectMessage = getSelectedRowModel().rows.length > 0
2363
- ? (_b = (_a = localization.selectedCountOfRowCountRowsSelected) === null || _a === void 0 ? void 0 : _a.replace('{selectedCount}', getSelectedRowModel().rows.length.toString())) === null || _b === void 0 ? void 0 : _b.replace('{rowCount}', (rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length).toString())
2364
- : null;
2365
- const groupedByMessage = grouping.length > 0 ? (jsxRuntime.jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxRuntime.jsxs(react.Fragment, { children: [index > 0 ? localization.thenBy : '', jsxRuntime.jsx(Chip__default["default"], Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
2366
- return (jsxRuntime.jsx(Collapse__default["default"], { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0, children: jsxRuntime.jsxs(Alert__default["default"], Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, mb: stackAlertBanner
2367
- ? 0
2368
- : positionToolbarAlertBanner === 'bottom'
2369
- ? '-1rem'
2370
- : undefined, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, parseFromValuesOrFunc(alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx, theme))), children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsxRuntime.jsx(AlertTitle__default["default"], { children: alertProps.title }), jsxRuntime.jsxs(Box__default["default"], { sx: { p: '0.5rem 1rem' }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectMessage || groupedByMessage) && (jsxRuntime.jsx("br", {})), selectMessage, selectMessage && groupedByMessage && jsxRuntime.jsx("br", {}), groupedByMessage] })] })) }));
2371
- };
2372
-
2373
- const MRT_ToolbarDropZone = ({ table, }) => {
2125
+ /******************************************************************************
2126
+ Copyright (c) Microsoft Corporation.
2127
+
2128
+ Permission to use, copy, modify, and/or distribute this software for any
2129
+ purpose with or without fee is hereby granted.
2130
+
2131
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2132
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2133
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2134
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2135
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2136
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2137
+ PERFORMANCE OF THIS SOFTWARE.
2138
+ ***************************************************************************** */
2139
+ function __rest(s, e) {
2140
+ var t = {};
2141
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2142
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2143
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2144
+ }
2145
+ return t;
2146
+ }
2147
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2148
+ var e = new Error(message);
2149
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2150
+ };
2151
+
2152
+ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
2153
+ const MRT_TablePagination = ({ position = 'bottom', table, }) => {
2154
+ const { getPrePaginationRowModel, getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, localization, muiPaginationProps, paginationDisplayMode, rowCount, }, setPageIndex, setPageSize, } = table;
2155
+ const { pagination: { pageIndex = 0, pageSize = 10 }, showGlobalFilter, } = getState();
2156
+ const paginationProps = parseFromValuesOrFunc(muiPaginationProps, {
2157
+ table,
2158
+ });
2159
+ const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
2160
+ const numberOfPages = Math.ceil(totalRowCount / pageSize);
2161
+ const showFirstLastPageButtons = numberOfPages > 2;
2162
+ const firstRowIndex = pageIndex * pageSize;
2163
+ const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
2164
+ const _a = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { showRowsPerPage = true, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons } = _a, rest = __rest(_a, ["showRowsPerPage", "rowsPerPageOptions", "showFirstButton", "showLastButton"]);
2165
+ return (jsxRuntime.jsxs(Box__default["default"], { sx: {
2166
+ alignItems: 'center',
2167
+ display: 'flex',
2168
+ gap: '8px',
2169
+ justifyContent: 'space-between',
2170
+ justifySelf: 'flex-end',
2171
+ mt: position === 'top' &&
2172
+ enableToolbarInternalActions &&
2173
+ !showGlobalFilter
2174
+ ? '3rem'
2175
+ : undefined,
2176
+ position: 'relative',
2177
+ px: '4px',
2178
+ py: '12px',
2179
+ zIndex: 2,
2180
+ }, children: [showRowsPerPage && (jsxRuntime.jsxs(Box__default["default"], { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsxRuntime.jsx(InputLabel__default["default"], { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsxRuntime.jsx(Select__default["default"], { inputProps: { 'aria-label': localization.rowsPerPage }, id: "mrt-rows-per-page", label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { '&::before': { border: 'none' }, mb: 0 }, value: pageSize, variant: "standard", children: rowsPerPageOptions.map((value) => (jsxRuntime.jsx(MenuItem__default["default"], { sx: { m: 0 }, value: value, children: value }, value))) })] })), paginationDisplayMode === 'pages' ? (jsxRuntime.jsx(Pagination__default["default"], Object.assign({ count: numberOfPages, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsxRuntime.jsx(PaginationItem__default["default"], Object.assign({ slots: {
2181
+ first: FirstPageIcon,
2182
+ last: LastPageIcon,
2183
+ next: ChevronRightIcon,
2184
+ previous: ChevronLeftIcon,
2185
+ } }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { sx: { mb: 0, mx: '4px', minWidth: '10ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) })), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }), jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }), showLastButton && (jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }))] })] })) : null] }));
2186
+ };
2187
+
2188
+ const MRT_GlobalFilterTextField = ({ table, }) => {
2189
+ var _a;
2190
+ const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
2191
+ const { globalFilter, showGlobalFilter } = getState();
2192
+ const textFieldProps = parseFromValuesOrFunc(muiSearchTextFieldProps, {
2193
+ table,
2194
+ });
2195
+ const isMounted = react.useRef(false);
2196
+ const [anchorEl, setAnchorEl] = react.useState(null);
2197
+ const [searchValue, setSearchValue] = react.useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
2198
+ const handleChangeDebounced = react.useCallback(utils.debounce((event) => {
2199
+ var _a;
2200
+ setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
2201
+ }, manualFiltering ? 500 : 250), []);
2202
+ const handleChange = (event) => {
2203
+ setSearchValue(event.target.value);
2204
+ handleChangeDebounced(event);
2205
+ };
2206
+ const handleGlobalFilterMenuOpen = (event) => {
2207
+ setAnchorEl(event.currentTarget);
2208
+ };
2209
+ const handleClear = () => {
2210
+ setSearchValue('');
2211
+ setGlobalFilter(undefined);
2212
+ };
2213
+ react.useEffect(() => {
2214
+ if (isMounted.current) {
2215
+ if (globalFilter === undefined) {
2216
+ handleClear();
2217
+ }
2218
+ else {
2219
+ setSearchValue(globalFilter);
2220
+ }
2221
+ }
2222
+ isMounted.current = true;
2223
+ }, [globalFilter]);
2224
+ return (jsxRuntime.jsxs(Collapse__default["default"], { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsxRuntime.jsx(TextField__default["default"], Object.assign({ InputProps: {
2225
+ endAdornment: (jsxRuntime.jsx(InputAdornment__default["default"], { position: "end", children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: (_a = localization.clearSearch) !== null && _a !== void 0 ? _a : '', children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsxRuntime.jsx(CloseIcon, {}) }) }) }) })),
2226
+ startAdornment: enableGlobalFilterModes ? (jsxRuntime.jsx(InputAdornment__default["default"], { position: "start", children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.changeSearchMode, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsxRuntime.jsx(SearchIcon, {}) }) }) })) : (jsxRuntime.jsx(SearchIcon, { style: { marginRight: '4px' } })),
2227
+ }, onChange: handleChange, placeholder: localization.search, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
2228
+ searchInputRef.current = inputRef;
2229
+ if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
2230
+ textFieldProps.inputRef = inputRef;
2231
+ }
2232
+ } })), jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, onSelect: handleClear, setAnchorEl: setAnchorEl, table: table })] }));
2233
+ };
2234
+
2235
+ const MRT_SelectCheckbox = ({ row, selectAll, table, }) => {
2236
+ var _a;
2237
+ const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
2238
+ const { density, isLoading } = getState();
2239
+ const checkboxProps = !row
2240
+ ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
2241
+ : parseFromValuesOrFunc(muiSelectCheckboxProps, { row, table });
2242
+ const allRowsSelected = selectAll
2243
+ ? selectAllMode === 'page'
2244
+ ? table.getIsAllPageRowsSelected()
2245
+ : table.getIsAllRowsSelected()
2246
+ : undefined;
2247
+ const commonProps = Object.assign(Object.assign({ checked: selectAll ? allRowsSelected : row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading || (row && !row.getCanSelect()), inputProps: {
2248
+ 'aria-label': selectAll
2249
+ ? localization.toggleSelectAll
2250
+ : localization.toggleSelectRow,
2251
+ }, onChange: (event) => {
2252
+ event.stopPropagation();
2253
+ row
2254
+ ? row.getToggleSelectedHandler()(event)
2255
+ : selectAllMode === 'all'
2256
+ ? table.getToggleAllRowsSelectedHandler()(event)
2257
+ : table.getToggleAllPageRowsSelectedHandler()(event);
2258
+ if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
2259
+ if (row) {
2260
+ row.pin(!row.getIsPinned() && event.target.checked
2261
+ ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
2262
+ ? 'bottom'
2263
+ : 'top'
2264
+ : false);
2265
+ }
2266
+ else {
2267
+ table.setRowPinning({ bottom: [], top: [] });
2268
+ }
2269
+ }
2270
+ }, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
2271
+ var _a;
2272
+ e.stopPropagation();
2273
+ (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
2274
+ }, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.5rem', zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
2275
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
2276
+ ? localization.toggleSelectAll
2277
+ : localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsxRuntime.jsx(Radio__default["default"], Object.assign({}, commonProps))) : (jsxRuntime.jsx(Checkbox__default["default"], Object.assign({ indeterminate: selectAll
2278
+ ? table.getIsSomeRowsSelected() && !allRowsSelected
2279
+ : row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps))) }));
2280
+ };
2281
+
2282
+ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
2283
+ var _a, _b, _c;
2284
+ const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
2285
+ const { density, grouping, showAlertBanner } = getState();
2286
+ const alertProps = parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
2287
+ table,
2288
+ });
2289
+ const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
2290
+ table,
2291
+ });
2292
+ const selectedAlert = getSelectedRowModel().rows.length > 0
2293
+ ? (_b = (_a = localization.selectedCountOfRowCountRowsSelected) === null || _a === void 0 ? void 0 : _a.replace('{selectedCount}', getSelectedRowModel().rows.length.toString())) === null || _b === void 0 ? void 0 : _b.replace('{rowCount}', (rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length).toString())
2294
+ : null;
2295
+ const groupedAlert = grouping.length > 0 ? (jsxRuntime.jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxRuntime.jsxs(react.Fragment, { children: [index > 0 ? localization.thenBy : '', jsxRuntime.jsx(Chip__default["default"], Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
2296
+ return (jsxRuntime.jsx(Collapse__default["default"], { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsxRuntime.jsx(Alert__default["default"], Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
2297
+ var _a, _b;
2298
+ return (Object.assign({ '& .MuiAlert-message': {
2299
+ maxWidth: `calc(${(_b = (_a = tablePaperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 360}px - 1rem)`,
2300
+ width: '100%',
2301
+ }, borderRadius: 0, fontSize: '1rem', left: 0, mb: stackAlertBanner
2302
+ ? 0
2303
+ : positionToolbarAlertBanner === 'bottom'
2304
+ ? '-1rem'
2305
+ : undefined, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, parseFromValuesOrFunc(alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx, theme)));
2306
+ }, children: (_c = renderToolbarAlertBannerContent === null || renderToolbarAlertBannerContent === void 0 ? void 0 : renderToolbarAlertBannerContent({
2307
+ groupedAlert,
2308
+ selectedAlert,
2309
+ table,
2310
+ })) !== null && _c !== void 0 ? _c : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && jsxRuntime.jsx(AlertTitle__default["default"], { children: alertProps.title }), jsxRuntime.jsxs(Stack__default["default"], { sx: {
2311
+ p: positionToolbarAlertBanner !== 'head-overlay'
2312
+ ? '0.5rem 1rem'
2313
+ : density === 'spacious'
2314
+ ? '0.75rem 1.25rem'
2315
+ : density === 'comfortable'
2316
+ ? '0.5rem 0.75rem'
2317
+ : '0.25rem 0.5rem',
2318
+ }, children: [alertProps === null || alertProps === void 0 ? void 0 : alertProps.children, (alertProps === null || alertProps === void 0 ? void 0 : alertProps.children) && (selectedAlert || groupedAlert) && (jsxRuntime.jsx("br", {})), jsxRuntime.jsxs(Box__default["default"], { sx: { display: 'flex' }, children: [enableRowSelection &&
2319
+ enableSelectAll &&
2320
+ positionToolbarAlertBanner === 'head-overlay' && (jsxRuntime.jsx(MRT_SelectCheckbox, { selectAll: true, table: table })), ' ', selectedAlert] }), selectedAlert && groupedAlert && jsxRuntime.jsx("br", {}), groupedAlert] })] })) })) }));
2321
+ };
2322
+
2323
+ const MRT_ToolbarDropZone = ({ table, }) => {
2374
2324
  var _a, _b;
2375
2325
  const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
2376
2326
  const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = getState();
@@ -2401,33 +2351,6 @@ const MRT_ToolbarDropZone = ({ table, }) => {
2401
2351
  }), children: jsxRuntime.jsx(Typography__default["default"], { fontStyle: "italic", children: localization.dropToGroupBy.replace('{column}', (_b = (_a = draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.columnDef) === null || _a === void 0 ? void 0 : _a.header) !== null && _b !== void 0 ? _b : '') }) }) }));
2402
2352
  };
2403
2353
 
2404
- /******************************************************************************
2405
- Copyright (c) Microsoft Corporation.
2406
-
2407
- Permission to use, copy, modify, and/or distribute this software for any
2408
- purpose with or without fee is hereby granted.
2409
-
2410
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2411
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2412
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2413
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2414
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2415
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2416
- PERFORMANCE OF THIS SOFTWARE.
2417
- ***************************************************************************** */
2418
- function __rest(s, e) {
2419
- var t = {};
2420
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2421
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2422
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2423
- }
2424
- return t;
2425
- }
2426
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2427
- var e = new Error(message);
2428
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2429
- };
2430
-
2431
2354
  const MRT_ColumnPinningButtons = ({ column, table, }) => {
2432
2355
  const { options: { icons: { PushPinIcon }, localization, }, } = table;
2433
2356
  const handlePinColumn = (pinDirection) => {
@@ -2595,7 +2518,7 @@ const MRT_ToggleFullScreenButton = (_a) => {
2595
2518
  setTooltipOpened(false);
2596
2519
  setIsFullScreen(!isFullScreen);
2597
2520
  };
2598
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, open: tooltipOpened, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsxRuntime.jsx(FullscreenExitIcon, {}) : jsxRuntime.jsx(FullscreenIcon, {}) })) }));
2521
+ return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, open: tooltipOpened, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.toggleFullScreen, onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsxRuntime.jsx(FullscreenExitIcon, {}) : jsxRuntime.jsx(FullscreenIcon, {}) })) }));
2599
2522
  };
2600
2523
 
2601
2524
  const MRT_ToggleGlobalFilterButton = (_a) => {
@@ -2626,56 +2549,9 @@ const MRT_ToolbarInternalButtons = ({ table, }) => {
2626
2549
  columnFilterDisplayMode !== 'popover' && (jsxRuntime.jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsxRuntime.jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsxRuntime.jsx(MRT_ToggleDensePaddingButton, { table: table })), enableFullScreenToggle && (jsxRuntime.jsx(MRT_ToggleFullScreenButton, { table: table }))] })) }));
2627
2550
  };
2628
2551
 
2629
- const MRT_GlobalFilterTextField = ({ table, }) => {
2630
- var _a;
2631
- const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
2632
- const { globalFilter, showGlobalFilter } = getState();
2633
- const textFieldProps = parseFromValuesOrFunc(muiSearchTextFieldProps, {
2634
- table,
2635
- });
2636
- const isMounted = react.useRef(false);
2637
- const [anchorEl, setAnchorEl] = react.useState(null);
2638
- const [searchValue, setSearchValue] = react.useState(globalFilter !== null && globalFilter !== void 0 ? globalFilter : '');
2639
- const handleChangeDebounced = react.useCallback(utils.debounce((event) => {
2640
- var _a;
2641
- setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
2642
- }, manualFiltering ? 500 : 250), []);
2643
- const handleChange = (event) => {
2644
- setSearchValue(event.target.value);
2645
- handleChangeDebounced(event);
2646
- };
2647
- const handleGlobalFilterMenuOpen = (event) => {
2648
- setAnchorEl(event.currentTarget);
2649
- };
2650
- const handleClear = () => {
2651
- setSearchValue('');
2652
- setGlobalFilter(undefined);
2653
- };
2654
- react.useEffect(() => {
2655
- if (isMounted.current) {
2656
- if (globalFilter === undefined) {
2657
- handleClear();
2658
- }
2659
- else {
2660
- setSearchValue(globalFilter);
2661
- }
2662
- }
2663
- isMounted.current = true;
2664
- }, [globalFilter]);
2665
- return (jsxRuntime.jsxs(Collapse__default["default"], { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsxRuntime.jsx(TextField__default["default"], Object.assign({ InputProps: {
2666
- endAdornment: (jsxRuntime.jsx(InputAdornment__default["default"], { position: "end", children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: (_a = localization.clearSearch) !== null && _a !== void 0 ? _a : '', children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsxRuntime.jsx(CloseIcon, {}) }) }) }) })),
2667
- startAdornment: enableGlobalFilterModes ? (jsxRuntime.jsx(InputAdornment__default["default"], { position: "start", children: jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.changeSearchMode, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsxRuntime.jsx(SearchIcon, {}) }) }) })) : (jsxRuntime.jsx(SearchIcon, { style: { marginRight: '4px' } })),
2668
- }, onChange: handleChange, placeholder: localization.search, value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
2669
- searchInputRef.current = inputRef;
2670
- if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
2671
- textFieldProps.inputRef = inputRef;
2672
- }
2673
- } })), jsxRuntime.jsx(MRT_FilterOptionMenu, { anchorEl: anchorEl, onSelect: handleClear, setAnchorEl: setAnchorEl, table: table })] }));
2674
- };
2675
-
2676
2552
  const commonToolbarStyles = ({ theme }) => ({
2677
2553
  alignItems: 'flex-start',
2678
- backgroundColor: styles.lighten(theme.palette.background.default, 0.04),
2554
+ backgroundColor: styles.lighten(theme.palette.background.default, 0.05),
2679
2555
  backgroundImage: 'none',
2680
2556
  display: 'grid',
2681
2557
  flexWrap: 'wrap-reverse',
@@ -2748,6 +2624,214 @@ const MRT_BottomToolbar = ({ table, }) => {
2748
2624
  ['both', 'bottom'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsxRuntime.jsx(MRT_TablePagination, { position: "bottom", table: table })) })] })] })));
2749
2625
  };
2750
2626
 
2627
+ const MRT_TableHead = ({ table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, }) => {
2628
+ const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
2629
+ const { isFullScreen, showAlertBanner } = getState();
2630
+ const tableHeadProps = parseFromValuesOrFunc(muiTableHeadProps, { table });
2631
+ const stickyHeader = enableStickyHeader || isFullScreen;
2632
+ return (jsxRuntime.jsx(TableHead__default["default"], Object.assign({}, tableHeadProps, { ref: (ref) => {
2633
+ tableHeadRef.current = ref;
2634
+ if (tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.ref) {
2635
+ // @ts-ignore
2636
+ tableHeadProps.ref.current = ref;
2637
+ }
2638
+ }, sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, parseFromValuesOrFunc(tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx, theme))), children: positionToolbarAlertBanner === 'head-overlay' &&
2639
+ (showAlertBanner || getSelectedRowModel().rows.length > 0) ? (jsxRuntime.jsx("tr", { style: { display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, children: jsxRuntime.jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
2640
+ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : 'table-cell',
2641
+ padding: 0,
2642
+ }, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { headerGroup: headerGroup, table: table, virtualColumns: virtualColumns, virtualPaddingLeft: virtualPaddingLeft, virtualPaddingRight: virtualPaddingRight }, headerGroup.id)))) })));
2643
+ };
2644
+
2645
+ const MRT_Table = ({ table, }) => {
2646
+ var _a, _b, _c, _d;
2647
+ const { getFlatHeaders, getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, columns, enableColumnPinning, enableColumnResizing, enableColumnVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, refs: { tableContainerRef }, } = table;
2648
+ const { columnPinning, columnSizing, columnSizingInfo, columnVisibility, isFullScreen, } = getState();
2649
+ const tableProps = parseFromValuesOrFunc(muiTableProps, { table });
2650
+ const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, { table });
2651
+ const columnSizeVars = react.useMemo(() => {
2652
+ const headers = getFlatHeaders();
2653
+ const colSizes = {};
2654
+ for (let i = 0; i < headers.length; i++) {
2655
+ const header = headers[i];
2656
+ const colSize = header.getSize();
2657
+ colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
2658
+ colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
2659
+ }
2660
+ return colSizes;
2661
+ }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
2662
+ //get first 16 column widths and average them
2663
+ const averageColumnWidth = react.useMemo(() => {
2664
+ var _a, _b, _c, _d;
2665
+ if (!enableColumnVirtualization)
2666
+ return 0;
2667
+ const columnsWidths = (_d = (_c = (_b = (_a = table
2668
+ .getRowModel()
2669
+ .rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
2670
+ return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
2671
+ }, [table.getRowModel().rows, columnPinning, columnVisibility]);
2672
+ const [leftPinnedIndexes, rightPinnedIndexes] = react.useMemo(() => enableColumnVirtualization && enableColumnPinning
2673
+ ? [
2674
+ table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
2675
+ table
2676
+ .getRightLeafColumns()
2677
+ .map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1),
2678
+ ]
2679
+ : [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
2680
+ const columnVirtualizer = enableColumnVirtualization
2681
+ ? reactVirtual.useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: react.useCallback((range) => [
2682
+ ...new Set([
2683
+ ...leftPinnedIndexes,
2684
+ ...reactVirtual.defaultRangeExtractor(range),
2685
+ ...rightPinnedIndexes,
2686
+ ]),
2687
+ ], [leftPinnedIndexes, rightPinnedIndexes]) }, columnVirtualizerProps))
2688
+ : undefined;
2689
+ if (columnVirtualizerInstanceRef && columnVirtualizer) {
2690
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
2691
+ }
2692
+ const virtualColumns = columnVirtualizer
2693
+ ? columnVirtualizer.getVirtualItems()
2694
+ : undefined;
2695
+ let virtualPaddingLeft;
2696
+ let virtualPaddingRight;
2697
+ if (columnVirtualizer && (virtualColumns === null || virtualColumns === void 0 ? void 0 : virtualColumns.length)) {
2698
+ virtualPaddingLeft = (_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0;
2699
+ virtualPaddingRight =
2700
+ columnVirtualizer.getTotalSize() -
2701
+ ((_d = (_c = virtualColumns[virtualColumns.length - 1 - rightPinnedIndexes.length]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
2702
+ }
2703
+ const props = {
2704
+ table,
2705
+ virtualColumns,
2706
+ virtualPaddingLeft,
2707
+ virtualPaddingRight,
2708
+ };
2709
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(Table__default["default"], Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, tableLayout: layoutMode === 'semantic' && enableColumnResizing
2710
+ ? 'fixed'
2711
+ : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, props)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({ columnVirtualizer: columnVirtualizer }, props))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, props))] })) }));
2712
+ };
2713
+
2714
+ const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
2715
+ const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
2716
+ const { creatingRow, editingRow, isSaving } = getState();
2717
+ const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
2718
+ const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
2719
+ const handleCancel = () => {
2720
+ if (isCreating) {
2721
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
2722
+ setCreatingRow(null);
2723
+ }
2724
+ else if (isEditing) {
2725
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
2726
+ setEditingRow(null);
2727
+ }
2728
+ row._valuesCache = {}; //reset values cache
2729
+ };
2730
+ const handleSubmitRow = () => {
2731
+ var _a;
2732
+ //look for auto-filled input values
2733
+ (_a = Object.values(editInputRefs === null || editInputRefs === void 0 ? void 0 : editInputRefs.current)
2734
+ .filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _a === void 0 ? void 0 : _a.forEach((input) => {
2735
+ if (input.value !== undefined &&
2736
+ Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
2737
+ // @ts-ignore
2738
+ row._valuesCache[input.name] = input.value;
2739
+ }
2740
+ });
2741
+ if (isCreating)
2742
+ onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
2743
+ exitCreatingMode: () => setCreatingRow(null),
2744
+ row,
2745
+ table,
2746
+ values: row._valuesCache,
2747
+ });
2748
+ else if (isEditing) {
2749
+ onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
2750
+ exitEditingMode: () => setEditingRow(null),
2751
+ row,
2752
+ table,
2753
+ values: row === null || row === void 0 ? void 0 : row._valuesCache,
2754
+ });
2755
+ }
2756
+ };
2757
+ return (jsxRuntime.jsx(Box__default["default"], { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' }, children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.cancel, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }), jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, title: localization.save, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.save, color: "info", onClick: handleSubmitRow, children: isSaving ? jsxRuntime.jsx(CircularProgress__default["default"], { size: 18 }) : jsxRuntime.jsx(SaveIcon, {}) }) })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button__default["default"], { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxRuntime.jsxs(Button__default["default"], { onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsxRuntime.jsx(CircularProgress__default["default"], { color: "inherit", size: 18 }), localization.save] })] })) }));
2758
+ };
2759
+
2760
+ const MRT_EditRowModal = ({ open, table, }) => {
2761
+ var _a;
2762
+ const { getState, options: { localization, muiCreateRowModalProps, muiEditRowModalProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowModalContent, renderEditRowModalContent, }, setCreatingRow, setEditingRow, } = table;
2763
+ const { creatingRow, editingRow } = getState();
2764
+ const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
2765
+ const dialogProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowModalProps, { row, table })), (creatingRow &&
2766
+ parseFromValuesOrFunc(muiCreateRowModalProps, { row, table })));
2767
+ const internalEditComponents = row
2768
+ .getAllCells()
2769
+ .filter((cell) => cell.column.columnDef.columnDefType === 'data')
2770
+ .map((cell) => (jsxRuntime.jsx(MRT_EditCellTextField, { cell: cell, table: table }, cell.id)));
2771
+ return (jsxRuntime.jsx(Dialog__default["default"], Object.assign({ fullWidth: true, maxWidth: "xs", onClose: (event, reason) => {
2772
+ var _a;
2773
+ if (creatingRow) {
2774
+ onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
2775
+ setCreatingRow(null);
2776
+ }
2777
+ else {
2778
+ onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
2779
+ setEditingRow(null);
2780
+ }
2781
+ row._valuesCache = {}; //reset values cache
2782
+ (_a = dialogProps.onClose) === null || _a === void 0 ? void 0 : _a.call(dialogProps, event, reason);
2783
+ }, open: open }, dialogProps, { children: (_a = ((creatingRow &&
2784
+ (renderCreateRowModalContent === null || renderCreateRowModalContent === void 0 ? void 0 : renderCreateRowModalContent({
2785
+ internalEditComponents,
2786
+ row,
2787
+ table,
2788
+ }))) ||
2789
+ (renderEditRowModalContent === null || renderEditRowModalContent === void 0 ? void 0 : renderEditRowModalContent({
2790
+ internalEditComponents,
2791
+ row,
2792
+ table,
2793
+ })))) !== null && _a !== void 0 ? _a : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DialogTitle__default["default"], { sx: { textAlign: 'center' }, children: localization.edit }), jsxRuntime.jsx(DialogContent__default["default"], { children: jsxRuntime.jsx("form", { onSubmit: (e) => e.preventDefault(), children: jsxRuntime.jsx(Stack__default["default"], { sx: {
2794
+ gap: '24px',
2795
+ paddingTop: '16px',
2796
+ width: '100%',
2797
+ }, children: internalEditComponents }) }) }), jsxRuntime.jsx(DialogActions__default["default"], { sx: { p: '1.25rem' }, children: jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table, variant: "text" }) })] })) })));
2798
+ };
2799
+
2800
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react.useLayoutEffect : react.useEffect;
2801
+ const MRT_TableContainer = ({ table, }) => {
2802
+ const { getState, options: { createDisplayMode, editDisplayMode, enableStickyHeader, muiTableContainerProps, }, refs: { bottomToolbarRef, tableContainerRef, topToolbarRef }, } = table;
2803
+ const { creatingRow, editingRow, isFullScreen } = getState();
2804
+ const [totalToolbarHeight, setTotalToolbarHeight] = react.useState(0);
2805
+ const tableContainerProps = parseFromValuesOrFunc(muiTableContainerProps, {
2806
+ table,
2807
+ });
2808
+ useIsomorphicLayoutEffect(() => {
2809
+ var _a, _b, _c, _d;
2810
+ const topToolbarHeight = typeof document !== 'undefined'
2811
+ ? (_b = (_a = topToolbarRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0
2812
+ : 0;
2813
+ const bottomToolbarHeight = typeof document !== 'undefined'
2814
+ ? (_d = (_c = bottomToolbarRef === null || bottomToolbarRef === void 0 ? void 0 : bottomToolbarRef.current) === null || _c === void 0 ? void 0 : _c.offsetHeight) !== null && _d !== void 0 ? _d : 0
2815
+ : 0;
2816
+ setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
2817
+ });
2818
+ const createModalOpen = createDisplayMode === 'modal' && creatingRow;
2819
+ const editModalOpen = editDisplayMode === 'modal' && editingRow;
2820
+ return (jsxRuntime.jsxs(TableContainer__default["default"], Object.assign({}, tableContainerProps, { ref: (node) => {
2821
+ if (node) {
2822
+ tableContainerRef.current = node;
2823
+ if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
2824
+ //@ts-ignore
2825
+ tableContainerProps.ref.current = node;
2826
+ }
2827
+ }
2828
+ }, style: Object.assign({ maxHeight: isFullScreen
2829
+ ? `calc(100vh - ${totalToolbarHeight}px)`
2830
+ : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ maxHeight: enableStickyHeader
2831
+ ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
2832
+ : undefined, maxWidth: '100%', overflow: 'auto' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [jsxRuntime.jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsxRuntime.jsx(MRT_EditRowModal, { open: true, table: table }))] })));
2833
+ };
2834
+
2751
2835
  const MRT_TablePaper = ({ table, }) => {
2752
2836
  var _a, _b;
2753
2837
  const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
@@ -2899,53 +2983,6 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
2899
2983
  parseFromValuesOrFunc(enableEditing, row) ? (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, placement: "right", title: localization.edit, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles, children: jsxRuntime.jsx(EditIcon, {}) }) })) : renderRowActionMenuItems ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles, children: jsxRuntime.jsx(MoreHorizIcon, {}) }) }), jsxRuntime.jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
2900
2984
  };
2901
2985
 
2902
- const MRT_SelectCheckbox = ({ row, selectAll, table, }) => {
2903
- var _a;
2904
- const { getState, options: { enableMultiRowSelection, enableRowPinning, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, rowPinningDisplayMode, selectAllMode, }, } = table;
2905
- const { density, isLoading } = getState();
2906
- const checkboxProps = !row
2907
- ? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
2908
- : parseFromValuesOrFunc(muiSelectCheckboxProps, { row, table });
2909
- const allRowsSelected = selectAll
2910
- ? selectAllMode === 'page'
2911
- ? table.getIsAllPageRowsSelected()
2912
- : table.getIsAllRowsSelected()
2913
- : undefined;
2914
- const commonProps = Object.assign(Object.assign({ checked: selectAll ? allRowsSelected : row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading || (row && !row.getCanSelect()), inputProps: {
2915
- 'aria-label': selectAll
2916
- ? localization.toggleSelectAll
2917
- : localization.toggleSelectRow,
2918
- }, onChange: (event) => {
2919
- event.stopPropagation();
2920
- row
2921
- ? row.getToggleSelectedHandler()(event)
2922
- : selectAllMode === 'all'
2923
- ? table.getToggleAllRowsSelectedHandler()(event)
2924
- : table.getToggleAllPageRowsSelectedHandler()(event);
2925
- if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
2926
- if (row) {
2927
- row.pin(!row.getIsPinned() && event.target.checked
2928
- ? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
2929
- ? 'bottom'
2930
- : 'top'
2931
- : false);
2932
- }
2933
- else {
2934
- table.setRowPinning({ bottom: [], top: [] });
2935
- }
2936
- }
2937
- }, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
2938
- var _a;
2939
- e.stopPropagation();
2940
- (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
2941
- }, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.5rem', zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
2942
- return (jsxRuntime.jsx(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
2943
- ? localization.toggleSelectAll
2944
- : localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsxRuntime.jsx(Radio__default["default"], Object.assign({}, commonProps))) : (jsxRuntime.jsx(Checkbox__default["default"], Object.assign({ indeterminate: selectAll
2945
- ? table.getIsSomeRowsSelected() && !allRowsSelected
2946
- : row === null || row === void 0 ? void 0 : row.getIsSomeSelected() }, commonProps))) }));
2947
- };
2948
-
2949
2986
  const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOptions, }) => {
2950
2987
  var _a, _b;
2951
2988
  return react.useMemo(() => {
@@ -2994,8 +3031,9 @@ const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOption
2994
3031
  };
2995
3032
 
2996
3033
  const useMRT_Effects = (table) => {
2997
- const { getState, options: { enablePagination, rowCount }, } = table;
2998
- const { globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
3034
+ const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
3035
+ const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
3036
+ const rerender = react.useReducer(() => ({}), {})[1];
2999
3037
  const isMounted = react.useRef(false);
3000
3038
  const initialBodyHeight = react.useRef();
3001
3039
  const previousTop = react.useRef();
@@ -3051,6 +3089,13 @@ const useMRT_Effects = (table) => {
3051
3089
  table.setSorting(() => appliedSort.current || []);
3052
3090
  }
3053
3091
  }, [globalFilter]);
3092
+ react.useEffect(() => {
3093
+ if (enableRowPinning && getIsSomeRowsPinned()) {
3094
+ setTimeout(() => {
3095
+ rerender();
3096
+ }, 150);
3097
+ }
3098
+ }, [density]);
3054
3099
  };
3055
3100
 
3056
3101
  const useMRT_TableInstance = (tableOptions) => {
@@ -3319,6 +3364,8 @@ const MRT_Default_Icons = {
3319
3364
  ArrowDownwardIcon: ArrowDownwardIcon__default["default"],
3320
3365
  ArrowRightIcon: ArrowRightIcon__default["default"],
3321
3366
  CancelIcon: CancelIcon__default["default"],
3367
+ ChevronLeftIcon: ChevronLeftIcon__default["default"],
3368
+ ChevronRightIcon: ChevronRightIcon__default["default"],
3322
3369
  ClearAllIcon: ClearAllIcon__default["default"],
3323
3370
  CloseIcon: CloseIcon__default["default"],
3324
3371
  DensityLargeIcon: DensityLargeIcon__default["default"],
@@ -3331,9 +3378,11 @@ const MRT_Default_Icons = {
3331
3378
  FilterAltIcon: FilterAltIcon__default["default"],
3332
3379
  FilterListIcon: FilterListIcon__default["default"],
3333
3380
  FilterListOffIcon: FilterListOffIcon__default["default"],
3381
+ FirstPageIcon: FirstPageIcon__default["default"],
3334
3382
  FullscreenExitIcon: FullscreenExitIcon__default["default"],
3335
3383
  FullscreenIcon: FullscreenIcon__default["default"],
3336
3384
  KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDownIcon__default["default"],
3385
+ LastPageIcon: LastPageIcon__default["default"],
3337
3386
  MoreHorizIcon: MoreHorizIcon__default["default"],
3338
3387
  MoreVertIcon: MoreVertIcon__default["default"],
3339
3388
  PushPinIcon: PushPinIcon__default["default"],
@@ -3448,8 +3497,13 @@ const useMRT_TableOptions = (_a) => {
3448
3497
  const _sortingFns = react.useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
3449
3498
  const _defaultColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
3450
3499
  const _defaultDisplayColumn = react.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
3451
- if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
3452
- layoutMode = 'grid';
3500
+ if (layoutMode === 'semantic') {
3501
+ if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
3502
+ layoutMode = 'grid';
3503
+ }
3504
+ if (enableColumnResizing) {
3505
+ layoutMode = 'grid-no-grow';
3506
+ }
3453
3507
  }
3454
3508
  if (rest.enableRowVirtualization) {
3455
3509
  enableStickyHeader = true;