material-react-table 2.0.4 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +572 -533
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +571 -532
- package/dist/index.js.map +1 -1
- package/dist/types/MaterialReactTable.d.ts +7 -0
- package/dist/types/aggregationFns.d.ts +11 -0
- package/dist/types/body/MRT_TableBody.d.ts +13 -0
- package/dist/types/body/MRT_TableBodyCell.d.ts +15 -0
- package/dist/types/body/MRT_TableBodyCellValue.d.ts +8 -0
- package/dist/types/body/MRT_TableBodyRow.d.ts +18 -0
- package/dist/types/body/MRT_TableBodyRowGrabHandle.d.ts +10 -0
- package/dist/types/body/MRT_TableBodyRowPinButton.d.ts +8 -0
- package/dist/types/body/MRT_TableDetailPanel.d.ts +13 -0
- package/dist/types/body/index.d.ts +7 -0
- package/dist/types/buttons/MRT_ColumnPinningButtons.d.ts +8 -0
- package/dist/types/buttons/MRT_CopyButton.d.ts +8 -0
- package/dist/types/buttons/MRT_EditActionButtons.d.ts +9 -0
- package/dist/types/buttons/MRT_ExpandAllButton.d.ts +7 -0
- package/dist/types/buttons/MRT_ExpandButton.d.ts +8 -0
- package/dist/types/buttons/MRT_GrabHandleButton.d.ts +12 -0
- package/dist/types/buttons/MRT_RowPinButton.d.ts +10 -0
- package/dist/types/buttons/MRT_ShowHideColumnsButton.d.ts +7 -0
- package/dist/types/buttons/MRT_ToggleDensePaddingButton.d.ts +7 -0
- package/dist/types/buttons/MRT_ToggleFiltersButton.d.ts +7 -0
- package/dist/types/buttons/MRT_ToggleFullScreenButton.d.ts +7 -0
- package/dist/types/buttons/MRT_ToggleGlobalFilterButton.d.ts +7 -0
- package/dist/types/buttons/MRT_ToggleRowActionMenuButton.d.ts +9 -0
- package/dist/types/buttons/index.d.ts +13 -0
- package/dist/types/column.utils.d.ts +127 -0
- package/dist/types/filterFns.d.ts +69 -0
- package/dist/types/footer/MRT_TableFooter.d.ts +11 -0
- package/dist/types/footer/MRT_TableFooterCell.d.ts +8 -0
- package/dist/types/footer/MRT_TableFooterRow.d.ts +12 -0
- package/dist/types/footer/index.d.ts +3 -0
- package/dist/types/head/MRT_TableHead.d.ts +11 -0
- package/dist/types/head/MRT_TableHeadCell.d.ts +8 -0
- package/dist/types/head/MRT_TableHeadCellColumnActionsButton.d.ts +8 -0
- package/dist/types/head/MRT_TableHeadCellFilterContainer.d.ts +8 -0
- package/dist/types/head/MRT_TableHeadCellFilterLabel.d.ts +8 -0
- package/dist/types/head/MRT_TableHeadCellGrabHandle.d.ts +10 -0
- package/dist/types/head/MRT_TableHeadCellResizeHandle.d.ts +8 -0
- package/dist/types/head/MRT_TableHeadCellSortLabel.d.ts +8 -0
- package/dist/types/head/MRT_TableHeadRow.d.ts +12 -0
- package/dist/types/head/index.d.ts +9 -0
- package/dist/types/hooks/index.d.ts +4 -0
- package/dist/types/hooks/useMRT_DisplayColumns.d.ts +9 -0
- package/dist/types/hooks/useMRT_Effects.d.ts +2 -0
- package/dist/types/hooks/useMRT_TableInstance.d.ts +2 -0
- package/dist/types/hooks/useMRT_TableOptions.d.ts +22 -0
- package/dist/types/icons.d.ts +36 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/inputs/MRT_EditCellTextField.d.ts +8 -0
- package/dist/types/inputs/MRT_FilterCheckbox.d.ts +8 -0
- package/dist/types/inputs/MRT_FilterRangeFields.d.ts +8 -0
- package/dist/types/inputs/MRT_FilterRangeSlider.d.ts +8 -0
- package/dist/types/inputs/MRT_FilterTextField.d.ts +9 -0
- package/dist/types/inputs/MRT_GlobalFilterTextField.d.ts +7 -0
- package/dist/types/inputs/MRT_SelectCheckbox.d.ts +9 -0
- package/dist/types/inputs/index.d.ts +7 -0
- package/dist/types/locales/am.d.ts +2 -0
- package/dist/types/locales/ar.d.ts +2 -0
- package/dist/types/locales/az.d.ts +2 -0
- package/dist/types/locales/bg.d.ts +2 -0
- package/dist/types/locales/cs.d.ts +2 -0
- package/dist/types/locales/da.d.ts +2 -0
- package/dist/types/locales/de.d.ts +2 -0
- package/dist/types/locales/en.d.ts +2 -0
- package/dist/types/locales/es.d.ts +2 -0
- package/dist/types/locales/et.d.ts +2 -0
- package/dist/types/locales/fa.d.ts +2 -0
- package/dist/types/locales/fi.d.ts +2 -0
- package/dist/types/locales/fr.d.ts +2 -0
- package/dist/types/locales/he.d.ts +2 -0
- package/dist/types/locales/hu.d.ts +2 -0
- package/dist/types/locales/hy.d.ts +2 -0
- package/dist/types/locales/id.d.ts +2 -0
- package/dist/types/locales/it.d.ts +2 -0
- package/dist/types/locales/ja.d.ts +2 -0
- package/dist/types/locales/ko.d.ts +2 -0
- package/dist/types/locales/nl.d.ts +2 -0
- package/dist/types/locales/no.d.ts +2 -0
- package/dist/types/locales/np.d.ts +2 -0
- package/dist/types/locales/pl.d.ts +2 -0
- package/dist/types/locales/pt-BR.d.ts +2 -0
- package/dist/types/locales/pt.d.ts +2 -0
- package/dist/types/locales/ro.d.ts +2 -0
- package/dist/types/locales/ru.d.ts +2 -0
- package/dist/types/locales/sk.d.ts +2 -0
- package/dist/types/locales/sr-Cyrl-RS.d.ts +2 -0
- package/dist/types/locales/sr-Latn-RS.d.ts +2 -0
- package/dist/types/locales/sv.d.ts +2 -0
- package/dist/types/locales/tr.d.ts +2 -0
- package/dist/types/locales/uk.d.ts +2 -0
- package/dist/types/locales/vi.d.ts +2 -0
- package/dist/types/locales/zh-Hans.d.ts +2 -0
- package/dist/types/locales/zh-Hant.d.ts +2 -0
- package/dist/types/menus/MRT_ColumnActionMenu.d.ts +20 -0
- package/dist/types/menus/MRT_FilterOptionMenu.d.ts +13 -0
- package/dist/types/menus/MRT_RowActionMenu.d.ts +12 -0
- package/dist/types/menus/MRT_ShowHideColumnsMenu.d.ts +10 -0
- package/dist/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +12 -0
- package/dist/types/menus/index.d.ts +5 -0
- package/dist/types/modals/MRT_EditRowModal.d.ts +8 -0
- package/dist/types/modals/index.d.ts +1 -0
- package/dist/types/sortingFns.d.ts +12 -0
- package/dist/types/style.utils.d.ts +32 -0
- package/dist/types/table/MRT_Table.d.ts +7 -0
- package/dist/types/table/MRT_TableContainer.d.ts +7 -0
- package/dist/types/table/MRT_TableLoadingOverlay.d.ts +7 -0
- package/dist/types/table/MRT_TablePaper.d.ts +7 -0
- package/dist/types/table/index.d.ts +5 -0
- package/dist/types/toolbar/MRT_BottomToolbar.d.ts +7 -0
- package/dist/types/toolbar/MRT_LinearProgressBar.d.ts +8 -0
- package/dist/types/toolbar/MRT_TablePagination.d.ts +15 -0
- package/dist/types/toolbar/MRT_ToolbarAlertBanner.d.ts +8 -0
- package/dist/types/toolbar/MRT_ToolbarDropZone.d.ts +7 -0
- package/dist/types/toolbar/MRT_ToolbarInternalButtons.d.ts +7 -0
- package/dist/types/toolbar/MRT_TopToolbar.d.ts +6 -0
- package/dist/types/toolbar/index.d.ts +7 -0
- package/dist/types/types.d.ts +854 -0
- package/dist/types/useMaterialReactTable.d.ts +2 -0
- package/package.json +22 -22
- package/src/body/MRT_TableBody.tsx +18 -23
- package/src/body/MRT_TableBodyCell.tsx +17 -15
- package/src/body/MRT_TableBodyCellValue.tsx +10 -10
- package/src/body/MRT_TableBodyRow.tsx +13 -13
- package/src/buttons/MRT_RowPinButton.tsx +2 -2
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -2
- package/src/footer/MRT_TableFooterCell.tsx +2 -2
- package/src/head/MRT_TableHeadCell.tsx +21 -19
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +4 -3
- package/src/head/MRT_TableHeadCellSortLabel.tsx +15 -9
- package/src/hooks/useMRT_DisplayColumns.tsx +172 -125
- package/src/inputs/MRT_FilterCheckbox.tsx +2 -2
- package/src/inputs/MRT_FilterTextField.tsx +16 -16
- package/src/inputs/MRT_GlobalFilterTextField.tsx +10 -10
- package/src/inputs/MRT_SelectCheckbox.tsx +2 -2
- package/src/locales/he.ts +94 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -2
- package/src/style.utils.ts +2 -2
- package/src/toolbar/MRT_TablePagination.tsx +9 -4
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +6 -6
- package/src/types.ts +4 -2
package/dist/index.esm.js
CHANGED
@@ -11,7 +11,7 @@ import { lighten, darken, alpha, useTheme } from '@mui/material/styles';
|
|
11
11
|
import Skeleton from '@mui/material/Skeleton';
|
12
12
|
import TableCell from '@mui/material/TableCell';
|
13
13
|
import Box from '@mui/material/Box';
|
14
|
-
import { flexRender as flexRender$1, createRow as createRow$1, sortingFns,
|
14
|
+
import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, aggregationFns, filterFns } from '@tanstack/react-table';
|
15
15
|
import highlightWords from 'highlight-words';
|
16
16
|
import IconButton from '@mui/material/IconButton';
|
17
17
|
import Tooltip from '@mui/material/Tooltip';
|
@@ -428,7 +428,7 @@ const MRT_TableBodyCellValue = ({ cell, table, }) => {
|
|
428
428
|
allowedTypes.includes(typeof renderedCellValue) &&
|
429
429
|
((filterValue &&
|
430
430
|
allowedTypes.includes(typeof filterValue) &&
|
431
|
-
|
431
|
+
['autocomplete', 'text'].includes(columnDef.filterVariant)) ||
|
432
432
|
(globalFilter &&
|
433
433
|
allowedTypes.includes(typeof globalFilter) &&
|
434
434
|
column.getCanGlobalFilter()))) {
|
@@ -688,7 +688,8 @@ const MRT_TableBodyCell = (_a) => {
|
|
688
688
|
hoveredRow,
|
689
689
|
rowIndex,
|
690
690
|
]);
|
691
|
-
const isEditable =
|
691
|
+
const isEditable = !cell.getIsPlaceholder() &&
|
692
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
692
693
|
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false;
|
693
694
|
const isEditing = isEditable &&
|
694
695
|
!['custom', 'modal'].includes(editDisplayMode) &&
|
@@ -727,7 +728,8 @@ const MRT_TableBodyCell = (_a) => {
|
|
727
728
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
728
729
|
}
|
729
730
|
} }, tableCellProps, { onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
|
730
|
-
outline:
|
731
|
+
outline: (editDisplayMode === 'cell' && isEditable) ||
|
732
|
+
(editDisplayMode === 'table' && (isCreating || isEditing))
|
731
733
|
? `1px solid ${theme.palette.grey[500]}`
|
732
734
|
: undefined,
|
733
735
|
outlineOffset: '-1px',
|
@@ -987,19 +989,18 @@ const MRT_TableBody = (_a) => {
|
|
987
989
|
const virtualRows = rowVirtualizer
|
988
990
|
? rowVirtualizer.getVirtualItems()
|
989
991
|
: undefined;
|
992
|
+
const commonRowProps = {
|
993
|
+
columnVirtualizer,
|
994
|
+
numRows: rows.length,
|
995
|
+
table,
|
996
|
+
virtualColumns,
|
997
|
+
virtualPaddingLeft,
|
998
|
+
virtualPaddingRight,
|
999
|
+
};
|
990
1000
|
return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
991
1001
|
getIsSomeRowsPinned('top') && (jsx(TableBody, 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) => {
|
992
|
-
const props = {
|
993
|
-
|
994
|
-
measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
|
995
|
-
numRows: rows.length,
|
996
|
-
row,
|
997
|
-
rowIndex,
|
998
|
-
table,
|
999
|
-
virtualColumns,
|
1000
|
-
virtualPaddingLeft,
|
1001
|
-
virtualPaddingRight,
|
1002
|
-
};
|
1002
|
+
const props = Object.assign(Object.assign({}, commonRowProps), { row,
|
1003
|
+
rowIndex });
|
1003
1004
|
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1004
1005
|
}) }))), jsxs(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, height: rowVirtualizer
|
1005
1006
|
? `${rowVirtualizer.getTotalSize()}px`
|
@@ -1020,36 +1021,16 @@ const MRT_TableBody = (_a) => {
|
|
1020
1021
|
const row = rowVirtualizer
|
1021
1022
|
? rows[rowOrVirtualRow.index]
|
1022
1023
|
: rowOrVirtualRow;
|
1023
|
-
const props = {
|
1024
|
-
|
1025
|
-
measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement,
|
1026
|
-
numRows: rows.length,
|
1027
|
-
pinnedRowIds,
|
1028
|
-
row,
|
1029
|
-
rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex,
|
1030
|
-
table,
|
1031
|
-
virtualColumns,
|
1032
|
-
virtualPaddingLeft,
|
1033
|
-
virtualPaddingRight,
|
1034
|
-
virtualRow: rowVirtualizer
|
1024
|
+
const props = Object.assign(Object.assign({}, commonRowProps), { measureElement: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement, pinnedRowIds,
|
1025
|
+
row, rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex, virtualRow: rowVirtualizer
|
1035
1026
|
? rowOrVirtualRow
|
1036
|
-
: undefined
|
1037
|
-
};
|
1038
|
-
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1027
|
+
: undefined });
|
1028
|
+
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), `${row.id}${row.index}`)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), `${row.id}${row.index}`));
|
1039
1029
|
}) })))] })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
1040
1030
|
getIsSomeRowsPinned('bottom') && (jsx(TableBody, 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) => {
|
1041
|
-
const props = {
|
1042
|
-
|
1043
|
-
|
1044
|
-
numRows: rows.length,
|
1045
|
-
row,
|
1046
|
-
rowIndex,
|
1047
|
-
table,
|
1048
|
-
virtualColumns,
|
1049
|
-
virtualPaddingLeft,
|
1050
|
-
virtualPaddingRight,
|
1051
|
-
};
|
1052
|
-
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1031
|
+
const props = Object.assign(Object.assign({}, commonRowProps), { row,
|
1032
|
+
rowIndex });
|
1033
|
+
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), `${row.id}`)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
1053
1034
|
}) })))] }));
|
1054
1035
|
};
|
1055
1036
|
const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
|
@@ -1670,7 +1651,7 @@ const MRT_FilterTextField = (_a) => {
|
|
1670
1651
|
localization[`filter${((_l = currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.charAt(0)) === null || _l === void 0 ? void 0 : _l.toUpperCase()) +
|
1671
1652
|
(currentFilterOption === null || currentFilterOption === void 0 ? void 0 : currentFilterOption.slice(1))}`]) })) : null, inputProps: {
|
1672
1653
|
'aria-label': filterPlaceholder,
|
1673
|
-
autoComplete: 'new-password',
|
1654
|
+
autoComplete: 'new-password', // disable autocomplete and autofill
|
1674
1655
|
disabled: !!filterChipLabel,
|
1675
1656
|
sx: {
|
1676
1657
|
textOverflow: 'ellipsis',
|
@@ -1924,14 +1905,14 @@ const MRT_TableHeadCellResizeHandle = (_a) => {
|
|
1924
1905
|
},
|
1925
1906
|
cursor: 'col-resize',
|
1926
1907
|
mr: density === 'compact'
|
1927
|
-
? '-
|
1908
|
+
? '-8px'
|
1928
1909
|
: density === 'comfortable'
|
1929
|
-
? '-
|
1930
|
-
: '-
|
1910
|
+
? '-16px'
|
1911
|
+
: '-24px',
|
1931
1912
|
position: 'absolute',
|
1932
1913
|
px: '4px',
|
1933
1914
|
right: column.columnDef.columnDefType === 'display' ? '4px' : '0',
|
1934
|
-
}), children: jsx(Divider, { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: (theme) => (Object.assign({ borderRadius: '2px', borderWidth: '2px', height: '24px', touchAction: 'none', transition: column.getIsResizing()
|
1915
|
+
}), children: jsx(Divider, { className: "Mui-TableHeadCell-ResizeHandle-Divider", flexItem: true, orientation: "vertical", sx: (theme) => (Object.assign({ borderRadius: '2px', borderWidth: '2px', height: '24px', touchAction: 'none', transform: 'translateX(4px)', transition: column.getIsResizing()
|
1935
1916
|
? undefined
|
1936
1917
|
: 'all 150ms ease-in-out', userSelect: 'none', zIndex: 4 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) }) }));
|
1937
1918
|
};
|
@@ -1952,11 +1933,14 @@ const MRT_TableHeadCellSortLabel = (_a) => {
|
|
1952
1933
|
: column.getNextSortingOrder() === 'desc'
|
1953
1934
|
? localization.sortByColumnDesc.replace('{column}', columnDef.header)
|
1954
1935
|
: localization.sortByColumnAsc.replace('{column}', columnDef.header);
|
1936
|
+
const direction = isSorted
|
1937
|
+
? column.getIsSorted()
|
1938
|
+
: undefined;
|
1955
1939
|
return (jsx(Tooltip, { placement: "top", title: sortTooltip, children: jsx(Badge, { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular", children: jsx(TableSortLabel, Object.assign({ IconComponent: !isSorted
|
1956
|
-
? (props) => (jsx(SyncAltIcon, Object.assign({}, props, { style: {
|
1940
|
+
? (props) => (jsx(SyncAltIcon, Object.assign({}, props, { direction: direction, style: {
|
1957
1941
|
transform: 'rotate(-90deg) scaleX(0.9) translateX(-1px)',
|
1958
1942
|
} })))
|
1959
|
-
: ArrowDownwardIcon, active: true, "aria-label": sortTooltip, direction:
|
1943
|
+
: ArrowDownwardIcon, active: true, "aria-label": sortTooltip, direction: direction, onClick: (e) => {
|
1960
1944
|
var _a;
|
1961
1945
|
e.stopPropagation();
|
1962
1946
|
(_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
|
@@ -2105,7 +2089,9 @@ const MRT_TableHeadCell = (_a) => {
|
|
2105
2089
|
whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
|
2106
2090
|
? 'nowrap'
|
2107
2091
|
: 'normal',
|
2108
|
-
}, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
2092
|
+
}, title: columnDefType === 'data' ? columnDef.header : undefined, children: headerElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
2093
|
+
whiteSpace: 'nowrap',
|
2094
|
+
}, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
2109
2095
|
current: tableHeadCellRefs.current[column.id],
|
2110
2096
|
} })), showColumnActions && (jsx(MRT_TableHeadCellColumnActionsButton, { header: header, table: table }))] })), column.getCanResize() && (jsx(MRT_TableHeadCellResizeHandle, { header: header, table: table }))] })), columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }))] })));
|
2111
2097
|
};
|
@@ -2154,8 +2140,8 @@ const MRT_TablePagination = (_a) => {
|
|
2154
2140
|
const showFirstLastPageButtons = numberOfPages > 2;
|
2155
2141
|
const firstRowIndex = pageIndex * pageSize;
|
2156
2142
|
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
|
2157
|
-
const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
|
2158
|
-
return (jsxs(Box, { sx: {
|
2143
|
+
const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
|
2144
|
+
return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
|
2159
2145
|
alignItems: 'center',
|
2160
2146
|
display: 'flex',
|
2161
2147
|
flexWrap: 'wrap',
|
@@ -2171,17 +2157,17 @@ const MRT_TablePagination = (_a) => {
|
|
2171
2157
|
px: '8px',
|
2172
2158
|
py: '12px',
|
2173
2159
|
zIndex: 2,
|
2174
|
-
}, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ disableUnderline: true, id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
|
2160
|
+
}, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: "mrt-rows-per-page", sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ disableUnderline: true, disabled: disabled, id: "mrt-rows-per-page", inputProps: { 'aria-label': localization.rowsPerPage }, label: localization.rowsPerPage, onChange: (event) => setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
|
2175
2161
|
var _a;
|
2176
2162
|
const value = typeof option !== 'number' ? option.value : option;
|
2177
2163
|
const label = typeof option !== 'number' ? option.label : `${option}`;
|
2178
2164
|
return ((_a = SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.children) !== null && _a !== void 0 ? _a : ((SelectProps === null || SelectProps === void 0 ? void 0 : SelectProps.native) ? (jsx("option", { value: value, children: label }, value)) : (jsx(MenuItem, { sx: { m: 0 }, value: value, children: label }, value))));
|
2179
|
-
}) }))] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, Object.assign({ count: numberOfPages, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsx(PaginationItem, Object.assign({ slots: {
|
2165
|
+
}) }))] })), paginationDisplayMode === 'pages' ? (jsx(Pagination, Object.assign({ count: numberOfPages, disabled: disabled, onChange: (_e, newPageIndex) => setPageIndex(newPageIndex - 1), page: pageIndex + 1, renderItem: (item) => (jsx(PaginationItem, Object.assign({ slots: {
|
2180
2166
|
first: FirstPageIcon,
|
2181
2167
|
last: LastPageIcon,
|
2182
2168
|
next: ChevronRightIcon,
|
2183
2169
|
previous: ChevronLeftIcon,
|
2184
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, {}) })), jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, {}) }), jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, {}) }), showLastButton && (jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, {}) }))] })] })) : null] }));
|
2170
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, {}) })), jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: pageIndex <= 0 || disabled, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, {}) }), jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, {}) }), showLastButton && (jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: lastRowIndex >= totalRowCount || disabled, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, {}) }))] })] })) : null] }));
|
2185
2171
|
};
|
2186
2172
|
|
2187
2173
|
const MRT_GlobalFilterTextField = (_a) => {
|
@@ -2221,10 +2207,10 @@ const MRT_GlobalFilterTextField = (_a) => {
|
|
2221
2207
|
}
|
2222
2208
|
isMounted.current = true;
|
2223
2209
|
}, [globalFilter]);
|
2224
|
-
return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ InputProps: Object.assign(Object.assign({ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { title: (_b = localization.clearSearch) !== null && _b !== void 0 ? _b : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsx(CloseIcon, {}) }) }) }) })), startAdornment: enableGlobalFilterModes ? (jsx(InputAdornment, { position: "start", children: jsx(Tooltip, { title: localization.changeSearchMode, children: jsx(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(SearchIcon, {}) }) }) })) : (jsx(SearchIcon, { style: { marginRight: '4px' } })) }, textFieldProps.InputProps), { sx: (theme) => {
|
2210
|
+
return (jsxs(Collapse, { in: showGlobalFilter, mountOnEnter: true, orientation: "horizontal", unmountOnExit: true, children: [jsx(TextField, Object.assign({ inputProps: Object.assign({ autoComplete: 'new-password' }, textFieldProps.inputProps), onChange: handleChange, placeholder: localization.search, size: "small", value: searchValue !== null && searchValue !== void 0 ? searchValue : '', variant: "outlined" }, textFieldProps, { InputProps: Object.assign(Object.assign({ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(Tooltip, { title: (_b = localization.clearSearch) !== null && _b !== void 0 ? _b : '', children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.clearSearch, disabled: !(searchValue === null || searchValue === void 0 ? void 0 : searchValue.length), onClick: handleClear, size: "small", children: jsx(CloseIcon, {}) }) }) }) })), startAdornment: enableGlobalFilterModes ? (jsx(InputAdornment, { position: "start", children: jsx(Tooltip, { title: localization.changeSearchMode, children: jsx(IconButton, { "aria-label": localization.changeSearchMode, onClick: handleGlobalFilterMenuOpen, size: "small", sx: { height: '1.75rem', width: '1.75rem' }, children: jsx(SearchIcon, {}) }) }) })) : (jsx(SearchIcon, { style: { marginRight: '4px' } })) }, textFieldProps.InputProps), { sx: (theme) => {
|
2225
2211
|
var _a;
|
2226
2212
|
return (Object.assign({ mb: 0 }, parseFromValuesOrFunc((_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.sx, theme)));
|
2227
|
-
} }),
|
2213
|
+
} }), inputRef: (inputRef) => {
|
2228
2214
|
searchInputRef.current = inputRef;
|
2229
2215
|
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.inputRef) {
|
2230
2216
|
textFieldProps.inputRef = inputRef;
|
@@ -2997,487 +2983,231 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
2997
2983
|
['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) : renderRowActionMenuItems ? (jsxs(Fragment, { children: [jsx(Tooltip, { enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsx(MoreHorizIcon, {}) })) }), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, table: table })] })) : null }));
|
2998
2984
|
};
|
2999
2985
|
|
3000
|
-
const
|
3001
|
-
|
3002
|
-
const
|
3003
|
-
const
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
2986
|
+
const useMRT_DisplayColumns = (params) => {
|
2987
|
+
var _a, _b, _c, _d;
|
2988
|
+
const { columnOrder, creatingRow, grouping, tableOptions } = params;
|
2989
|
+
const order = (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder;
|
2990
|
+
return useMemo(() => [
|
2991
|
+
makeRowPinColumn,
|
2992
|
+
makeRowDragColumn,
|
2993
|
+
makeRowActionsColumn,
|
2994
|
+
makeRowExpandColumn,
|
2995
|
+
makeRowSelectColumn,
|
2996
|
+
makeRowNumbersColumn,
|
2997
|
+
makeSpacerColumn,
|
2998
|
+
]
|
2999
|
+
.map((makeCol) => makeCol(params, order))
|
3000
|
+
.filter(Boolean), [
|
3001
|
+
columnOrder,
|
3002
|
+
creatingRow,
|
3003
|
+
grouping,
|
3004
|
+
tableOptions.displayColumnDefOptions,
|
3005
|
+
tableOptions.editDisplayMode,
|
3006
|
+
tableOptions.enableColumnDragging,
|
3007
|
+
tableOptions.enableColumnFilterModes,
|
3008
|
+
tableOptions.enableColumnOrdering,
|
3009
|
+
tableOptions.enableEditing,
|
3010
|
+
tableOptions.enableExpandAll,
|
3011
|
+
tableOptions.enableExpanding,
|
3012
|
+
tableOptions.enableGrouping,
|
3013
|
+
tableOptions.enableRowActions,
|
3014
|
+
tableOptions.enableRowDragging,
|
3015
|
+
tableOptions.enableRowNumbers,
|
3016
|
+
tableOptions.enableRowOrdering,
|
3017
|
+
tableOptions.enableRowSelection,
|
3018
|
+
tableOptions.enableSelectAll,
|
3019
|
+
tableOptions.localization,
|
3020
|
+
tableOptions.positionActionsColumn,
|
3021
|
+
tableOptions.renderDetailPanel,
|
3022
|
+
tableOptions.renderRowActionMenuItems,
|
3023
|
+
tableOptions.renderRowActions,
|
3024
|
+
(_c = tableOptions.state) === null || _c === void 0 ? void 0 : _c.columnOrder,
|
3025
|
+
(_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.grouping,
|
3026
|
+
]);
|
3008
3027
|
};
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
.
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
.
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
.
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3042
|
-
|
3043
|
-
|
3044
|
-
|
3045
|
-
|
3046
|
-
|
3047
|
-
|
3048
|
-
|
3049
|
-
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3073
|
-
|
3074
|
-
|
3075
|
-
|
3076
|
-
equals,
|
3077
|
-
fuzzy,
|
3078
|
-
greaterThan,
|
3079
|
-
greaterThanOrEqualTo,
|
3080
|
-
lessThan,
|
3081
|
-
lessThanOrEqualTo,
|
3082
|
-
notEmpty,
|
3083
|
-
notEquals,
|
3084
|
-
startsWith });
|
3028
|
+
function defaultDisplayColumnProps({ defaultDisplayColumn, displayColumnDefOptions, localization, }, id, header, size = 60) {
|
3029
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
|
3030
|
+
}
|
3031
|
+
function makeRowPinColumn({ tableOptions }, order) {
|
3032
|
+
const id = 'mrt-row-pin';
|
3033
|
+
if (order.includes(id)) {
|
3034
|
+
return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'pin'));
|
3035
|
+
}
|
3036
|
+
return null;
|
3037
|
+
}
|
3038
|
+
function makeRowDragColumn({ tableOptions }, order) {
|
3039
|
+
const id = 'mrt-row-drag';
|
3040
|
+
if (order.includes(id)) {
|
3041
|
+
return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'move'));
|
3042
|
+
}
|
3043
|
+
return null;
|
3044
|
+
}
|
3045
|
+
function makeRowActionsColumn({ creatingRow, tableOptions }, order) {
|
3046
|
+
const id = 'mrt-row-actions';
|
3047
|
+
if (order.includes(id) ||
|
3048
|
+
(creatingRow && tableOptions.createDisplayMode === 'row')) {
|
3049
|
+
return Object.assign({ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })) }, defaultDisplayColumnProps(tableOptions, id, 'actions'));
|
3050
|
+
}
|
3051
|
+
return null;
|
3052
|
+
}
|
3053
|
+
function makeRowExpandColumn({ grouping, tableOptions }, order) {
|
3054
|
+
var _a, _b;
|
3055
|
+
const id = 'mrt-row-expand';
|
3056
|
+
if (order.includes(id) &&
|
3057
|
+
showExpandColumn(tableOptions, (_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.grouping) !== null && _b !== void 0 ? _b : grouping)) {
|
3058
|
+
return Object.assign({ Cell: ({ row, table }) => jsx(MRT_ExpandButton, { row: row, table: table }), Header: tableOptions.enableExpandAll
|
3059
|
+
? ({ table }) => jsx(MRT_ExpandAllButton, { table: table })
|
3060
|
+
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'expand'));
|
3061
|
+
}
|
3062
|
+
return null;
|
3063
|
+
}
|
3064
|
+
function makeRowSelectColumn({ tableOptions }, order) {
|
3065
|
+
const id = 'mrt-row-select';
|
3066
|
+
if (order.includes(id)) {
|
3067
|
+
return Object.assign({ Cell: ({ row, table }) => jsx(MRT_SelectCheckbox, { row: row, table: table }), Header: tableOptions.enableSelectAll && tableOptions.enableMultiRowSelection
|
3068
|
+
? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
3069
|
+
: undefined }, defaultDisplayColumnProps(tableOptions, id, 'select'));
|
3070
|
+
}
|
3071
|
+
return null;
|
3072
|
+
}
|
3073
|
+
function makeRowNumbersColumn({ tableOptions }, order) {
|
3074
|
+
const id = 'mrt-row-numbers';
|
3075
|
+
if (order.includes(id) || tableOptions.enableRowNumbers)
|
3076
|
+
return Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber }, defaultDisplayColumnProps(tableOptions, id, 'rowNumbers'));
|
3077
|
+
return null;
|
3078
|
+
}
|
3079
|
+
const blankColProps = {
|
3080
|
+
children: null,
|
3081
|
+
sx: {
|
3082
|
+
flex: '1 0 auto',
|
3083
|
+
minWidth: 0,
|
3084
|
+
p: 0,
|
3085
|
+
width: 0,
|
3086
|
+
},
|
3087
|
+
};
|
3088
|
+
function makeSpacerColumn({ tableOptions }, order) {
|
3089
|
+
const id = 'mrt-row-spacer';
|
3090
|
+
if (order.includes(id)) {
|
3091
|
+
return Object.assign(Object.assign({}, defaultDisplayColumnProps(tableOptions, id, undefined, 0)), { muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps });
|
3092
|
+
}
|
3093
|
+
return null;
|
3094
|
+
}
|
3085
3095
|
|
3086
|
-
const
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
|
3110
|
-
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3096
|
+
const useMRT_Effects = (table) => {
|
3097
|
+
const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
|
3098
|
+
const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
|
3099
|
+
const rerender = useReducer(() => ({}), {})[1];
|
3100
|
+
const isMounted = useRef(false);
|
3101
|
+
const initialBodyHeight = useRef();
|
3102
|
+
const previousTop = useRef();
|
3103
|
+
useEffect(() => {
|
3104
|
+
if (typeof window !== 'undefined') {
|
3105
|
+
initialBodyHeight.current = document.body.style.height;
|
3106
|
+
}
|
3107
|
+
}, []);
|
3108
|
+
useEffect(() => {
|
3109
|
+
if (isMounted && typeof window !== 'undefined') {
|
3110
|
+
if (isFullScreen) {
|
3111
|
+
previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
|
3112
|
+
document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
|
3113
|
+
}
|
3114
|
+
else {
|
3115
|
+
document.body.style.height = initialBodyHeight.current;
|
3116
|
+
if (!previousTop.current)
|
3117
|
+
return;
|
3118
|
+
//restore scroll position
|
3119
|
+
window.scrollTo({
|
3120
|
+
behavior: 'instant',
|
3121
|
+
top: -1 * previousTop.current,
|
3122
|
+
});
|
3123
|
+
}
|
3124
|
+
}
|
3125
|
+
isMounted.current = true;
|
3126
|
+
}, [isFullScreen]);
|
3127
|
+
//if page index is out of bounds, set it to the last page
|
3128
|
+
useEffect(() => {
|
3129
|
+
if (!enablePagination || isLoading || showSkeletons)
|
3130
|
+
return;
|
3131
|
+
const { pageIndex, pageSize } = pagination;
|
3132
|
+
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
|
3133
|
+
const firstVisibleRowIndex = pageIndex * pageSize;
|
3134
|
+
if (firstVisibleRowIndex > totalRowCount) {
|
3135
|
+
table.setPageIndex(Math.floor(totalRowCount / pageSize));
|
3136
|
+
}
|
3137
|
+
}, [rowCount, table.getPrePaginationRowModel().rows.length]);
|
3138
|
+
//turn off sort when global filter is looking for ranked results
|
3139
|
+
const appliedSort = useRef(sorting);
|
3140
|
+
useEffect(() => {
|
3141
|
+
if (sorting.length) {
|
3142
|
+
appliedSort.current = sorting;
|
3143
|
+
}
|
3144
|
+
}, [sorting]);
|
3145
|
+
useEffect(() => {
|
3146
|
+
if (!getCanRankRows(table))
|
3147
|
+
return;
|
3148
|
+
if (globalFilter) {
|
3149
|
+
table.setSorting([]);
|
3150
|
+
}
|
3151
|
+
else {
|
3152
|
+
table.setSorting(() => appliedSort.current || []);
|
3153
|
+
}
|
3154
|
+
}, [globalFilter]);
|
3155
|
+
useEffect(() => {
|
3156
|
+
if (enableRowPinning && getIsSomeRowsPinned()) {
|
3157
|
+
setTimeout(() => {
|
3158
|
+
rerender();
|
3159
|
+
}, 150);
|
3160
|
+
}
|
3161
|
+
}, [density]);
|
3120
3162
|
};
|
3121
3163
|
|
3122
|
-
const
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3126
|
-
|
3127
|
-
|
3128
|
-
|
3129
|
-
|
3130
|
-
|
3131
|
-
|
3132
|
-
|
3133
|
-
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
3140
|
-
|
3141
|
-
|
3142
|
-
|
3143
|
-
|
3144
|
-
|
3145
|
-
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
|
3150
|
-
|
3151
|
-
|
3152
|
-
|
3153
|
-
|
3154
|
-
|
3155
|
-
|
3156
|
-
|
3157
|
-
|
3158
|
-
|
3159
|
-
|
3160
|
-
|
3161
|
-
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3166
|
-
|
3167
|
-
goToNextPage: 'Go to next page',
|
3168
|
-
goToPreviousPage: 'Go to previous page',
|
3169
|
-
grab: 'Grab',
|
3170
|
-
groupByColumn: 'Group by {column}',
|
3171
|
-
groupedBy: 'Grouped by ',
|
3172
|
-
hideAll: 'Hide all',
|
3173
|
-
hideColumn: 'Hide {column} column',
|
3174
|
-
max: 'Max',
|
3175
|
-
min: 'Min',
|
3176
|
-
move: 'Move',
|
3177
|
-
noRecordsToDisplay: 'No records to display',
|
3178
|
-
noResultsFound: 'No results found',
|
3179
|
-
of: 'of',
|
3180
|
-
or: 'or',
|
3181
|
-
pin: 'Pin',
|
3182
|
-
pinToLeft: 'Pin to left',
|
3183
|
-
pinToRight: 'Pin to right',
|
3184
|
-
resetColumnSize: 'Reset column size',
|
3185
|
-
resetOrder: 'Reset order',
|
3186
|
-
rowActions: 'Row Actions',
|
3187
|
-
rowNumber: '#',
|
3188
|
-
rowNumbers: 'Row Numbers',
|
3189
|
-
rowsPerPage: 'Rows per page',
|
3190
|
-
save: 'Save',
|
3191
|
-
search: 'Search',
|
3192
|
-
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
3193
|
-
select: 'Select',
|
3194
|
-
showAll: 'Show all',
|
3195
|
-
showAllColumns: 'Show all columns',
|
3196
|
-
showHideColumns: 'Show/Hide columns',
|
3197
|
-
showHideFilters: 'Show/Hide filters',
|
3198
|
-
showHideSearch: 'Show/Hide search',
|
3199
|
-
sortByColumnAsc: 'Sort by {column} ascending',
|
3200
|
-
sortByColumnDesc: 'Sort by {column} descending',
|
3201
|
-
sortedByColumnAsc: 'Sorted by {column} ascending',
|
3202
|
-
sortedByColumnDesc: 'Sorted by {column} descending',
|
3203
|
-
thenBy: ', then by ',
|
3204
|
-
toggleDensity: 'Toggle density',
|
3205
|
-
toggleFullScreen: 'Toggle full screen',
|
3206
|
-
toggleSelectAll: 'Toggle select all',
|
3207
|
-
toggleSelectRow: 'Toggle select row',
|
3208
|
-
toggleVisibility: 'Toggle visibility',
|
3209
|
-
ungroupByColumn: 'Ungroup by {column}',
|
3210
|
-
unpin: 'Unpin',
|
3211
|
-
unpinAll: 'Unpin all',
|
3212
|
-
};
|
3213
|
-
|
3214
|
-
const MRT_DefaultColumn = {
|
3215
|
-
filterVariant: 'text',
|
3216
|
-
maxSize: 1000,
|
3217
|
-
minSize: 40,
|
3218
|
-
size: 180,
|
3219
|
-
};
|
3220
|
-
const MRT_DefaultDisplayColumn = {
|
3221
|
-
columnDefType: 'display',
|
3222
|
-
enableClickToCopy: false,
|
3223
|
-
enableColumnActions: false,
|
3224
|
-
enableColumnDragging: false,
|
3225
|
-
enableColumnFilter: false,
|
3226
|
-
enableColumnOrdering: false,
|
3227
|
-
enableEditing: false,
|
3228
|
-
enableGlobalFilter: false,
|
3229
|
-
enableGrouping: false,
|
3230
|
-
enableHiding: false,
|
3231
|
-
enableResizing: false,
|
3232
|
-
enableSorting: false,
|
3233
|
-
};
|
3234
|
-
const useMRT_TableOptions = (_a) => {
|
3235
|
-
var _b;
|
3236
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
3237
|
-
const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
3238
|
-
const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
3239
|
-
const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
|
3240
|
-
const _filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
|
3241
|
-
const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
|
3242
|
-
const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
|
3243
|
-
const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
|
3244
|
-
layoutMode =
|
3245
|
-
layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
|
3246
|
-
if (layoutMode === 'semantic' &&
|
3247
|
-
(rest.enableRowVirtualization || rest.enableColumnVirtualization)) {
|
3248
|
-
layoutMode = 'grid';
|
3249
|
-
}
|
3250
|
-
if (rest.enableRowVirtualization) {
|
3251
|
-
enableStickyHeader = true;
|
3252
|
-
}
|
3253
|
-
if (enablePagination === false && manualPagination === undefined) {
|
3254
|
-
manualPagination = true;
|
3255
|
-
}
|
3256
|
-
if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
|
3257
|
-
manualFiltering = true;
|
3258
|
-
manualGrouping = true;
|
3259
|
-
manualPagination = true;
|
3260
|
-
manualSorting = true;
|
3261
|
-
}
|
3262
|
-
return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
|
3263
|
-
columnFilterDisplayMode,
|
3264
|
-
columnResizeMode,
|
3265
|
-
createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
|
3266
|
-
enableBottomToolbar,
|
3267
|
-
enableColumnActions,
|
3268
|
-
enableColumnFilters,
|
3269
|
-
enableColumnOrdering,
|
3270
|
-
enableColumnPinning,
|
3271
|
-
enableColumnResizing,
|
3272
|
-
enableDensityToggle,
|
3273
|
-
enableExpandAll,
|
3274
|
-
enableExpanding,
|
3275
|
-
enableFilterMatchHighlighting,
|
3276
|
-
enableFilters,
|
3277
|
-
enableFullScreenToggle,
|
3278
|
-
enableGlobalFilter,
|
3279
|
-
enableGlobalFilterRankedResults,
|
3280
|
-
enableGrouping,
|
3281
|
-
enableHiding,
|
3282
|
-
enableMultiRowSelection,
|
3283
|
-
enableMultiSort,
|
3284
|
-
enablePagination,
|
3285
|
-
enableRowPinning,
|
3286
|
-
enableRowSelection,
|
3287
|
-
enableSelectAll,
|
3288
|
-
enableSorting,
|
3289
|
-
enableStickyHeader,
|
3290
|
-
enableTableFooter,
|
3291
|
-
enableTableHead,
|
3292
|
-
enableToolbarInternalActions,
|
3293
|
-
enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode, localization: _localization, manualFiltering,
|
3294
|
-
manualGrouping,
|
3295
|
-
manualPagination,
|
3296
|
-
manualSorting,
|
3297
|
-
paginationDisplayMode,
|
3298
|
-
positionActionsColumn,
|
3299
|
-
positionExpandColumn,
|
3300
|
-
positionGlobalFilter,
|
3301
|
-
positionPagination,
|
3302
|
-
positionToolbarAlertBanner,
|
3303
|
-
positionToolbarDropZone,
|
3304
|
-
rowNumberDisplayMode,
|
3305
|
-
rowPinningDisplayMode,
|
3306
|
-
selectAllMode, sortingFns: _sortingFns }, rest);
|
3307
|
-
};
|
3308
|
-
|
3309
|
-
const blankColProps = {
|
3310
|
-
children: null,
|
3311
|
-
sx: {
|
3312
|
-
flex: '1 0 auto',
|
3313
|
-
minWidth: 0,
|
3314
|
-
p: 0,
|
3315
|
-
width: 0,
|
3316
|
-
},
|
3317
|
-
};
|
3318
|
-
const useMRT_DisplayColumns = ({ columnOrder, creatingRow, grouping, tableOptions, }) => {
|
3319
|
-
var _a, _b;
|
3320
|
-
return useMemo(() => {
|
3321
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3322
|
-
return [
|
3323
|
-
((_b = (_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder) !== null && _b !== void 0 ? _b : columnOrder).includes('mrt-row-pin') && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), header: tableOptions.localization.pin, size: 60 }, (_c = tableOptions.displayColumnDefOptions) === null || _c === void 0 ? void 0 : _c['mrt-row-pin']), { columnDefType: 'display', id: 'mrt-row-pin' }),
|
3324
|
-
((_e = (_d = tableOptions.state) === null || _d === void 0 ? void 0 : _d.columnOrder) !== null && _e !== void 0 ? _e : columnOrder).includes('mrt-row-drag') && Object.assign(Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), header: tableOptions.localization.move, size: 60 }, (_f = tableOptions.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-drag']), { columnDefType: 'display', id: 'mrt-row-drag' }),
|
3325
|
-
(((_h = (_g = tableOptions.state) === null || _g === void 0 ? void 0 : _g.columnOrder) !== null && _h !== void 0 ? _h : columnOrder).includes('mrt-row-actions') ||
|
3326
|
-
(creatingRow && tableOptions.createDisplayMode === 'row')) && Object.assign(Object.assign({ Cell: ({ cell, row, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: tableOptions.localization.actions, size: 70 }, (_j = tableOptions.displayColumnDefOptions) === null || _j === void 0 ? void 0 : _j['mrt-row-actions']), { columnDefType: 'display', id: 'mrt-row-actions' }),
|
3327
|
-
((_l = (_k = tableOptions.state) === null || _k === void 0 ? void 0 : _k.columnOrder) !== null && _l !== void 0 ? _l : columnOrder).includes('mrt-row-expand') &&
|
3328
|
-
showExpandColumn(tableOptions, (_o = (_m = tableOptions.state) === null || _m === void 0 ? void 0 : _m.grouping) !== null && _o !== void 0 ? _o : grouping) && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_ExpandButton, { row: row, table: table })), Header: tableOptions.enableExpandAll
|
3329
|
-
? ({ table }) => jsx(MRT_ExpandAllButton, { table: table })
|
3330
|
-
: null, header: tableOptions.localization.expand, size: 60 }, (_p = tableOptions.displayColumnDefOptions) === null || _p === void 0 ? void 0 : _p['mrt-row-expand']), { columnDefType: 'display', id: 'mrt-row-expand' }),
|
3331
|
-
((_r = (_q = tableOptions.state) === null || _q === void 0 ? void 0 : _q.columnOrder) !== null && _r !== void 0 ? _r : columnOrder).includes('mrt-row-select') && Object.assign(Object.assign({ Cell: ({ row, table }) => (jsx(MRT_SelectCheckbox, { row: row, table: table })), Header: tableOptions.enableSelectAll &&
|
3332
|
-
tableOptions.enableMultiRowSelection
|
3333
|
-
? ({ table }) => jsx(MRT_SelectCheckbox, { selectAll: true, table: table })
|
3334
|
-
: null, header: tableOptions.localization.select, size: 60 }, (_s = tableOptions.displayColumnDefOptions) === null || _s === void 0 ? void 0 : _s['mrt-row-select']), { columnDefType: 'display', id: 'mrt-row-select' }),
|
3335
|
-
((_u = (_t = tableOptions.state) === null || _t === void 0 ? void 0 : _t.columnOrder) !== null && _u !== void 0 ? _u : columnOrder).includes('mrt-row-numbers') && Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => tableOptions.localization.rowNumber, header: tableOptions.localization.rowNumbers, size: 60 }, (_v = tableOptions.displayColumnDefOptions) === null || _v === void 0 ? void 0 : _v['mrt-row-numbers']), { columnDefType: 'display', id: 'mrt-row-numbers' }),
|
3336
|
-
((_x = (_w = tableOptions.state) === null || _w === void 0 ? void 0 : _w.columnOrder) !== null && _x !== void 0 ? _x : columnOrder).includes('mrt-row-spacer') && Object.assign(Object.assign(Object.assign({}, (_y = tableOptions.displayColumnDefOptions) === null || _y === void 0 ? void 0 : _y['mrt-row-spacer']), MRT_DefaultDisplayColumn), { columnDefType: 'display', header: '', id: 'mrt-row-spacer', muiTableBodyCellProps: blankColProps, muiTableFooterCellProps: blankColProps, muiTableHeadCellProps: blankColProps }),
|
3337
|
-
].filter(Boolean);
|
3338
|
-
}, [
|
3164
|
+
const useMRT_TableInstance = (tableOptions) => {
|
3165
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
3166
|
+
const bottomToolbarRef = useRef(null);
|
3167
|
+
const editInputRefs = useRef({});
|
3168
|
+
const filterInputRefs = useRef({});
|
3169
|
+
const searchInputRef = useRef(null);
|
3170
|
+
const tableContainerRef = useRef(null);
|
3171
|
+
const tableHeadCellRefs = useRef({});
|
3172
|
+
const tablePaperRef = useRef(null);
|
3173
|
+
const topToolbarRef = useRef(null);
|
3174
|
+
const tableHeadRef = useRef(null);
|
3175
|
+
const tableFooterRef = useRef(null);
|
3176
|
+
const initialState = useMemo(() => {
|
3177
|
+
var _a, _b, _c;
|
3178
|
+
const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
|
3179
|
+
initState.columnOrder =
|
3180
|
+
(_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
|
3181
|
+
initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
|
3182
|
+
return initState;
|
3183
|
+
}, []);
|
3184
|
+
const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
|
3185
|
+
const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
|
3186
|
+
var _a, _b, _c, _d;
|
3187
|
+
return ({
|
3188
|
+
[getColumnId(col)]: col.filterFn instanceof Function
|
3189
|
+
? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
|
3190
|
+
: (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
|
3191
|
+
});
|
3192
|
+
})));
|
3193
|
+
const [columnOrder, setColumnOrder] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
|
3194
|
+
const [density, setDensity] = useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
|
3195
|
+
const [draggingColumn, setDraggingColumn] = useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
|
3196
|
+
const [draggingRow, setDraggingRow] = useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
|
3197
|
+
const [editingCell, setEditingCell] = useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
|
3198
|
+
const [editingRow, setEditingRow] = useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
|
3199
|
+
const [globalFilterFn, setGlobalFilterFn] = useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
|
3200
|
+
const [grouping, setGrouping] = useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
|
3201
|
+
const [hoveredColumn, setHoveredColumn] = useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
|
3202
|
+
const [hoveredRow, setHoveredRow] = useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
|
3203
|
+
const [isFullScreen, setIsFullScreen] = useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
|
3204
|
+
const [showAlertBanner, setShowAlertBanner] = useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
|
3205
|
+
const [showColumnFilters, setShowColumnFilters] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
|
3206
|
+
const [showGlobalFilter, setShowGlobalFilter] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
|
3207
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
|
3208
|
+
const displayColumns = useMRT_DisplayColumns({
|
3339
3209
|
columnOrder,
|
3340
|
-
|
3341
|
-
tableOptions.displayColumnDefOptions,
|
3342
|
-
tableOptions.editDisplayMode,
|
3343
|
-
tableOptions.enableColumnDragging,
|
3344
|
-
tableOptions.enableColumnFilterModes,
|
3345
|
-
tableOptions.enableColumnOrdering,
|
3346
|
-
tableOptions.enableEditing,
|
3347
|
-
tableOptions.enableExpandAll,
|
3348
|
-
tableOptions.enableExpanding,
|
3349
|
-
tableOptions.enableGrouping,
|
3350
|
-
tableOptions.enableRowActions,
|
3351
|
-
tableOptions.enableRowDragging,
|
3352
|
-
tableOptions.enableRowNumbers,
|
3353
|
-
tableOptions.enableRowOrdering,
|
3354
|
-
tableOptions.enableRowSelection,
|
3355
|
-
tableOptions.enableSelectAll,
|
3356
|
-
tableOptions.localization,
|
3357
|
-
tableOptions.positionActionsColumn,
|
3358
|
-
tableOptions.renderDetailPanel,
|
3359
|
-
tableOptions.renderRowActionMenuItems,
|
3360
|
-
tableOptions.renderRowActions,
|
3361
|
-
(_a = tableOptions.state) === null || _a === void 0 ? void 0 : _a.columnOrder,
|
3362
|
-
(_b = tableOptions.state) === null || _b === void 0 ? void 0 : _b.grouping,
|
3363
|
-
]);
|
3364
|
-
};
|
3365
|
-
|
3366
|
-
const useMRT_Effects = (table) => {
|
3367
|
-
const { getIsSomeRowsPinned, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
|
3368
|
-
const { density, globalFilter, isFullScreen, isLoading, pagination, showSkeletons, sorting, } = getState();
|
3369
|
-
const rerender = useReducer(() => ({}), {})[1];
|
3370
|
-
const isMounted = useRef(false);
|
3371
|
-
const initialBodyHeight = useRef();
|
3372
|
-
const previousTop = useRef();
|
3373
|
-
useEffect(() => {
|
3374
|
-
if (typeof window !== 'undefined') {
|
3375
|
-
initialBodyHeight.current = document.body.style.height;
|
3376
|
-
}
|
3377
|
-
}, []);
|
3378
|
-
useEffect(() => {
|
3379
|
-
if (isMounted && typeof window !== 'undefined') {
|
3380
|
-
if (isFullScreen) {
|
3381
|
-
previousTop.current = document.body.getBoundingClientRect().top; //save scroll position
|
3382
|
-
document.body.style.height = '100vh'; //hide page scrollbars when table is in full screen mode
|
3383
|
-
}
|
3384
|
-
else {
|
3385
|
-
document.body.style.height = initialBodyHeight.current;
|
3386
|
-
if (!previousTop.current)
|
3387
|
-
return;
|
3388
|
-
//restore scroll position
|
3389
|
-
window.scrollTo({
|
3390
|
-
behavior: 'instant',
|
3391
|
-
top: -1 * previousTop.current,
|
3392
|
-
});
|
3393
|
-
}
|
3394
|
-
}
|
3395
|
-
isMounted.current = true;
|
3396
|
-
}, [isFullScreen]);
|
3397
|
-
//if page index is out of bounds, set it to the last page
|
3398
|
-
useEffect(() => {
|
3399
|
-
if (!enablePagination || isLoading || showSkeletons)
|
3400
|
-
return;
|
3401
|
-
const { pageIndex, pageSize } = pagination;
|
3402
|
-
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : table.getPrePaginationRowModel().rows.length;
|
3403
|
-
const firstVisibleRowIndex = pageIndex * pageSize;
|
3404
|
-
if (firstVisibleRowIndex > totalRowCount) {
|
3405
|
-
table.setPageIndex(Math.floor(totalRowCount / pageSize));
|
3406
|
-
}
|
3407
|
-
}, [rowCount, table.getPrePaginationRowModel().rows.length]);
|
3408
|
-
//turn off sort when global filter is looking for ranked results
|
3409
|
-
const appliedSort = useRef(sorting);
|
3410
|
-
useEffect(() => {
|
3411
|
-
if (sorting.length) {
|
3412
|
-
appliedSort.current = sorting;
|
3413
|
-
}
|
3414
|
-
}, [sorting]);
|
3415
|
-
useEffect(() => {
|
3416
|
-
if (!getCanRankRows(table))
|
3417
|
-
return;
|
3418
|
-
if (globalFilter) {
|
3419
|
-
table.setSorting([]);
|
3420
|
-
}
|
3421
|
-
else {
|
3422
|
-
table.setSorting(() => appliedSort.current || []);
|
3423
|
-
}
|
3424
|
-
}, [globalFilter]);
|
3425
|
-
useEffect(() => {
|
3426
|
-
if (enableRowPinning && getIsSomeRowsPinned()) {
|
3427
|
-
setTimeout(() => {
|
3428
|
-
rerender();
|
3429
|
-
}, 150);
|
3430
|
-
}
|
3431
|
-
}, [density]);
|
3432
|
-
};
|
3433
|
-
|
3434
|
-
const useMRT_TableInstance = (tableOptions) => {
|
3435
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
|
3436
|
-
const bottomToolbarRef = useRef(null);
|
3437
|
-
const editInputRefs = useRef({});
|
3438
|
-
const filterInputRefs = useRef({});
|
3439
|
-
const searchInputRef = useRef(null);
|
3440
|
-
const tableContainerRef = useRef(null);
|
3441
|
-
const tableHeadCellRefs = useRef({});
|
3442
|
-
const tablePaperRef = useRef(null);
|
3443
|
-
const topToolbarRef = useRef(null);
|
3444
|
-
const tableHeadRef = useRef(null);
|
3445
|
-
const tableFooterRef = useRef(null);
|
3446
|
-
const initialState = useMemo(() => {
|
3447
|
-
var _a, _b, _c;
|
3448
|
-
const initState = (_a = tableOptions.initialState) !== null && _a !== void 0 ? _a : {};
|
3449
|
-
initState.columnOrder =
|
3450
|
-
(_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(tableOptions);
|
3451
|
-
initState.globalFilterFn = (_c = tableOptions.globalFilterFn) !== null && _c !== void 0 ? _c : 'fuzzy';
|
3452
|
-
return initState;
|
3453
|
-
}, []);
|
3454
|
-
const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
|
3455
|
-
const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(tableOptions.columns).map((col) => {
|
3456
|
-
var _a, _b, _c, _d;
|
3457
|
-
return ({
|
3458
|
-
[getColumnId(col)]: col.filterFn instanceof Function
|
3459
|
-
? (_a = col.filterFn.name) !== null && _a !== void 0 ? _a : 'custom'
|
3460
|
-
: (_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col),
|
3461
|
-
});
|
3462
|
-
})));
|
3463
|
-
const [columnOrder, setColumnOrder] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
|
3464
|
-
const [density, setDensity] = useState((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'comfortable');
|
3465
|
-
const [draggingColumn, setDraggingColumn] = useState((_d = initialState.draggingColumn) !== null && _d !== void 0 ? _d : null);
|
3466
|
-
const [draggingRow, setDraggingRow] = useState((_e = initialState.draggingRow) !== null && _e !== void 0 ? _e : null);
|
3467
|
-
const [editingCell, setEditingCell] = useState((_f = initialState.editingCell) !== null && _f !== void 0 ? _f : null);
|
3468
|
-
const [editingRow, setEditingRow] = useState((_g = initialState.editingRow) !== null && _g !== void 0 ? _g : null);
|
3469
|
-
const [globalFilterFn, setGlobalFilterFn] = useState((_h = initialState.globalFilterFn) !== null && _h !== void 0 ? _h : 'fuzzy');
|
3470
|
-
const [grouping, setGrouping] = useState((_j = initialState.grouping) !== null && _j !== void 0 ? _j : []);
|
3471
|
-
const [hoveredColumn, setHoveredColumn] = useState((_k = initialState.hoveredColumn) !== null && _k !== void 0 ? _k : null);
|
3472
|
-
const [hoveredRow, setHoveredRow] = useState((_l = initialState.hoveredRow) !== null && _l !== void 0 ? _l : null);
|
3473
|
-
const [isFullScreen, setIsFullScreen] = useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _m !== void 0 ? _m : false);
|
3474
|
-
const [showAlertBanner, setShowAlertBanner] = useState((_p = (_o = tableOptions.initialState) === null || _o === void 0 ? void 0 : _o.showAlertBanner) !== null && _p !== void 0 ? _p : false);
|
3475
|
-
const [showColumnFilters, setShowColumnFilters] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _q !== void 0 ? _q : false);
|
3476
|
-
const [showGlobalFilter, setShowGlobalFilter] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _r !== void 0 ? _r : false);
|
3477
|
-
const [showToolbarDropZone, setShowToolbarDropZone] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _s !== void 0 ? _s : false);
|
3478
|
-
const displayColumns = useMRT_DisplayColumns({
|
3479
|
-
columnOrder,
|
3480
|
-
creatingRow,
|
3210
|
+
creatingRow,
|
3481
3211
|
grouping,
|
3482
3212
|
tableOptions,
|
3483
3213
|
});
|
@@ -3607,6 +3337,315 @@ const useMRT_TableInstance = (tableOptions) => {
|
|
3607
3337
|
return table;
|
3608
3338
|
};
|
3609
3339
|
|
3340
|
+
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
3341
|
+
|
3342
|
+
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
3343
|
+
const itemRank = rankItem(row.getValue(columnId), filterValue, {
|
3344
|
+
threshold: rankings.MATCHES,
|
3345
|
+
});
|
3346
|
+
addMeta(itemRank);
|
3347
|
+
return itemRank.passed;
|
3348
|
+
};
|
3349
|
+
fuzzy.autoRemove = (val) => !val;
|
3350
|
+
const contains = (row, id, filterValue) => row
|
3351
|
+
.getValue(id)
|
3352
|
+
.toString()
|
3353
|
+
.toLowerCase()
|
3354
|
+
.trim()
|
3355
|
+
.includes(filterValue.toString().toLowerCase().trim());
|
3356
|
+
contains.autoRemove = (val) => !val;
|
3357
|
+
const startsWith = (row, id, filterValue) => row
|
3358
|
+
.getValue(id)
|
3359
|
+
.toString()
|
3360
|
+
.toLowerCase()
|
3361
|
+
.trim()
|
3362
|
+
.startsWith(filterValue.toString().toLowerCase().trim());
|
3363
|
+
startsWith.autoRemove = (val) => !val;
|
3364
|
+
const endsWith = (row, id, filterValue) => row
|
3365
|
+
.getValue(id)
|
3366
|
+
.toString()
|
3367
|
+
.toLowerCase()
|
3368
|
+
.trim()
|
3369
|
+
.endsWith(filterValue.toString().toLowerCase().trim());
|
3370
|
+
endsWith.autoRemove = (val) => !val;
|
3371
|
+
const equals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() ===
|
3372
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3373
|
+
equals.autoRemove = (val) => !val;
|
3374
|
+
const notEquals = (row, id, filterValue) => row.getValue(id).toString().toLowerCase().trim() !==
|
3375
|
+
filterValue.toString().toLowerCase().trim();
|
3376
|
+
notEquals.autoRemove = (val) => !val;
|
3377
|
+
const greaterThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3378
|
+
? +row.getValue(id) > +filterValue
|
3379
|
+
: row.getValue(id).toString().toLowerCase().trim() >
|
3380
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3381
|
+
greaterThan.autoRemove = (val) => !val;
|
3382
|
+
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
3383
|
+
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
3384
|
+
const lessThan = (row, id, filterValue) => !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
3385
|
+
? +row.getValue(id) < +filterValue
|
3386
|
+
: row.getValue(id).toString().toLowerCase().trim() <
|
3387
|
+
(filterValue === null || filterValue === void 0 ? void 0 : filterValue.toString().toLowerCase().trim());
|
3388
|
+
lessThan.autoRemove = (val) => !val;
|
3389
|
+
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
3390
|
+
lessThanOrEqualTo.autoRemove = (val) => !val;
|
3391
|
+
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
3392
|
+
greaterThan(row, id, filterValues[0])) &&
|
3393
|
+
((!isNaN(+filterValues[0]) &&
|
3394
|
+
!isNaN(+filterValues[1]) &&
|
3395
|
+
+filterValues[0] > +filterValues[1]) ||
|
3396
|
+
['', undefined].includes(filterValues[1]) ||
|
3397
|
+
lessThan(row, id, filterValues[1]));
|
3398
|
+
between.autoRemove = (val) => !val;
|
3399
|
+
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
3400
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
3401
|
+
((!isNaN(+filterValues[0]) &&
|
3402
|
+
!isNaN(+filterValues[1]) &&
|
3403
|
+
+filterValues[0] > +filterValues[1]) ||
|
3404
|
+
['', undefined].includes(filterValues[1]) ||
|
3405
|
+
lessThanOrEqualTo(row, id, filterValues[1]));
|
3406
|
+
betweenInclusive.autoRemove = (val) => !val;
|
3407
|
+
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
3408
|
+
empty.autoRemove = (val) => !val;
|
3409
|
+
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
3410
|
+
notEmpty.autoRemove = (val) => !val;
|
3411
|
+
const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
3412
|
+
betweenInclusive,
|
3413
|
+
contains,
|
3414
|
+
empty,
|
3415
|
+
endsWith,
|
3416
|
+
equals,
|
3417
|
+
fuzzy,
|
3418
|
+
greaterThan,
|
3419
|
+
greaterThanOrEqualTo,
|
3420
|
+
lessThan,
|
3421
|
+
lessThanOrEqualTo,
|
3422
|
+
notEmpty,
|
3423
|
+
notEquals,
|
3424
|
+
startsWith });
|
3425
|
+
|
3426
|
+
const MRT_Default_Icons = {
|
3427
|
+
ArrowDownwardIcon,
|
3428
|
+
ArrowRightIcon,
|
3429
|
+
CancelIcon,
|
3430
|
+
ChevronLeftIcon,
|
3431
|
+
ChevronRightIcon,
|
3432
|
+
ClearAllIcon,
|
3433
|
+
CloseIcon,
|
3434
|
+
DensityLargeIcon,
|
3435
|
+
DensityMediumIcon,
|
3436
|
+
DensitySmallIcon,
|
3437
|
+
DragHandleIcon,
|
3438
|
+
DynamicFeedIcon,
|
3439
|
+
EditIcon,
|
3440
|
+
ExpandMoreIcon,
|
3441
|
+
FilterAltIcon,
|
3442
|
+
FilterListIcon,
|
3443
|
+
FilterListOffIcon,
|
3444
|
+
FirstPageIcon,
|
3445
|
+
FullscreenExitIcon,
|
3446
|
+
FullscreenIcon,
|
3447
|
+
KeyboardDoubleArrowDownIcon,
|
3448
|
+
LastPageIcon,
|
3449
|
+
MoreHorizIcon,
|
3450
|
+
MoreVertIcon,
|
3451
|
+
PushPinIcon,
|
3452
|
+
RestartAltIcon,
|
3453
|
+
SaveIcon,
|
3454
|
+
SearchIcon,
|
3455
|
+
SearchOffIcon,
|
3456
|
+
SortIcon,
|
3457
|
+
SyncAltIcon,
|
3458
|
+
ViewColumnIcon,
|
3459
|
+
VisibilityOffIcon,
|
3460
|
+
};
|
3461
|
+
|
3462
|
+
const MRT_Localization_EN = {
|
3463
|
+
actions: 'Actions',
|
3464
|
+
and: 'and',
|
3465
|
+
cancel: 'Cancel',
|
3466
|
+
changeFilterMode: 'Change filter mode',
|
3467
|
+
changeSearchMode: 'Change search mode',
|
3468
|
+
clearFilter: 'Clear filter',
|
3469
|
+
clearSearch: 'Clear search',
|
3470
|
+
clearSort: 'Clear sort',
|
3471
|
+
clickToCopy: 'Click to copy',
|
3472
|
+
collapse: 'Collapse',
|
3473
|
+
collapseAll: 'Collapse all',
|
3474
|
+
columnActions: 'Column Actions',
|
3475
|
+
copiedToClipboard: 'Copied to clipboard',
|
3476
|
+
dropToGroupBy: 'Drop to group by {column}',
|
3477
|
+
edit: 'Edit',
|
3478
|
+
expand: 'Expand',
|
3479
|
+
expandAll: 'Expand all',
|
3480
|
+
filterArrIncludes: 'Includes',
|
3481
|
+
filterArrIncludesAll: 'Includes all',
|
3482
|
+
filterArrIncludesSome: 'Includes',
|
3483
|
+
filterBetween: 'Between',
|
3484
|
+
filterBetweenInclusive: 'Between Inclusive',
|
3485
|
+
filterByColumn: 'Filter by {column}',
|
3486
|
+
filterContains: 'Contains',
|
3487
|
+
filterEmpty: 'Empty',
|
3488
|
+
filterEndsWith: 'Ends With',
|
3489
|
+
filterEquals: 'Equals',
|
3490
|
+
filterEqualsString: 'Equals',
|
3491
|
+
filterFuzzy: 'Fuzzy',
|
3492
|
+
filterGreaterThan: 'Greater Than',
|
3493
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
3494
|
+
filterInNumberRange: 'Between',
|
3495
|
+
filterIncludesString: 'Contains',
|
3496
|
+
filterIncludesStringSensitive: 'Contains',
|
3497
|
+
filterLessThan: 'Less Than',
|
3498
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
3499
|
+
filterMode: 'Filter Mode: {filterType}',
|
3500
|
+
filterNotEmpty: 'Not Empty',
|
3501
|
+
filterNotEquals: 'Not Equals',
|
3502
|
+
filterStartsWith: 'Starts With',
|
3503
|
+
filterWeakEquals: 'Equals',
|
3504
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
3505
|
+
goToFirstPage: 'Go to first page',
|
3506
|
+
goToLastPage: 'Go to last page',
|
3507
|
+
goToNextPage: 'Go to next page',
|
3508
|
+
goToPreviousPage: 'Go to previous page',
|
3509
|
+
grab: 'Grab',
|
3510
|
+
groupByColumn: 'Group by {column}',
|
3511
|
+
groupedBy: 'Grouped by ',
|
3512
|
+
hideAll: 'Hide all',
|
3513
|
+
hideColumn: 'Hide {column} column',
|
3514
|
+
max: 'Max',
|
3515
|
+
min: 'Min',
|
3516
|
+
move: 'Move',
|
3517
|
+
noRecordsToDisplay: 'No records to display',
|
3518
|
+
noResultsFound: 'No results found',
|
3519
|
+
of: 'of',
|
3520
|
+
or: 'or',
|
3521
|
+
pin: 'Pin',
|
3522
|
+
pinToLeft: 'Pin to left',
|
3523
|
+
pinToRight: 'Pin to right',
|
3524
|
+
resetColumnSize: 'Reset column size',
|
3525
|
+
resetOrder: 'Reset order',
|
3526
|
+
rowActions: 'Row Actions',
|
3527
|
+
rowNumber: '#',
|
3528
|
+
rowNumbers: 'Row Numbers',
|
3529
|
+
rowsPerPage: 'Rows per page',
|
3530
|
+
save: 'Save',
|
3531
|
+
search: 'Search',
|
3532
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
3533
|
+
select: 'Select',
|
3534
|
+
showAll: 'Show all',
|
3535
|
+
showAllColumns: 'Show all columns',
|
3536
|
+
showHideColumns: 'Show/Hide columns',
|
3537
|
+
showHideFilters: 'Show/Hide filters',
|
3538
|
+
showHideSearch: 'Show/Hide search',
|
3539
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
3540
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
3541
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
3542
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
3543
|
+
thenBy: ', then by ',
|
3544
|
+
toggleDensity: 'Toggle density',
|
3545
|
+
toggleFullScreen: 'Toggle full screen',
|
3546
|
+
toggleSelectAll: 'Toggle select all',
|
3547
|
+
toggleSelectRow: 'Toggle select row',
|
3548
|
+
toggleVisibility: 'Toggle visibility',
|
3549
|
+
ungroupByColumn: 'Ungroup by {column}',
|
3550
|
+
unpin: 'Unpin',
|
3551
|
+
unpinAll: 'Unpin all',
|
3552
|
+
};
|
3553
|
+
|
3554
|
+
const MRT_DefaultColumn = {
|
3555
|
+
filterVariant: 'text',
|
3556
|
+
maxSize: 1000,
|
3557
|
+
minSize: 40,
|
3558
|
+
size: 180,
|
3559
|
+
};
|
3560
|
+
const MRT_DefaultDisplayColumn = {
|
3561
|
+
columnDefType: 'display',
|
3562
|
+
enableClickToCopy: false,
|
3563
|
+
enableColumnActions: false,
|
3564
|
+
enableColumnDragging: false,
|
3565
|
+
enableColumnFilter: false,
|
3566
|
+
enableColumnOrdering: false,
|
3567
|
+
enableEditing: false,
|
3568
|
+
enableGlobalFilter: false,
|
3569
|
+
enableGrouping: false,
|
3570
|
+
enableHiding: false,
|
3571
|
+
enableResizing: false,
|
3572
|
+
enableSorting: false,
|
3573
|
+
};
|
3574
|
+
const useMRT_TableOptions = (_a) => {
|
3575
|
+
var _b;
|
3576
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "paginationDisplayMode", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
3577
|
+
const _icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
3578
|
+
const _localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
3579
|
+
const _aggregationFns = useMemo(() => (Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns)), []);
|
3580
|
+
const _filterFns = useMemo(() => (Object.assign(Object.assign({}, MRT_FilterFns), filterFns)), []);
|
3581
|
+
const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
|
3582
|
+
const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), [defaultColumn]);
|
3583
|
+
const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), [defaultDisplayColumn]);
|
3584
|
+
layoutMode =
|
3585
|
+
layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
|
3586
|
+
if (layoutMode === 'semantic' &&
|
3587
|
+
(rest.enableRowVirtualization || rest.enableColumnVirtualization)) {
|
3588
|
+
layoutMode = 'grid';
|
3589
|
+
}
|
3590
|
+
if (rest.enableRowVirtualization) {
|
3591
|
+
enableStickyHeader = true;
|
3592
|
+
}
|
3593
|
+
if (enablePagination === false && manualPagination === undefined) {
|
3594
|
+
manualPagination = true;
|
3595
|
+
}
|
3596
|
+
if (!((_b = rest.data) === null || _b === void 0 ? void 0 : _b.length)) {
|
3597
|
+
manualFiltering = true;
|
3598
|
+
manualGrouping = true;
|
3599
|
+
manualPagination = true;
|
3600
|
+
manualSorting = true;
|
3601
|
+
}
|
3602
|
+
return Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded,
|
3603
|
+
columnFilterDisplayMode,
|
3604
|
+
columnResizeMode,
|
3605
|
+
createDisplayMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editDisplayMode,
|
3606
|
+
enableBottomToolbar,
|
3607
|
+
enableColumnActions,
|
3608
|
+
enableColumnFilters,
|
3609
|
+
enableColumnOrdering,
|
3610
|
+
enableColumnPinning,
|
3611
|
+
enableColumnResizing,
|
3612
|
+
enableDensityToggle,
|
3613
|
+
enableExpandAll,
|
3614
|
+
enableExpanding,
|
3615
|
+
enableFilterMatchHighlighting,
|
3616
|
+
enableFilters,
|
3617
|
+
enableFullScreenToggle,
|
3618
|
+
enableGlobalFilter,
|
3619
|
+
enableGlobalFilterRankedResults,
|
3620
|
+
enableGrouping,
|
3621
|
+
enableHiding,
|
3622
|
+
enableMultiRowSelection,
|
3623
|
+
enableMultiSort,
|
3624
|
+
enablePagination,
|
3625
|
+
enableRowPinning,
|
3626
|
+
enableRowSelection,
|
3627
|
+
enableSelectAll,
|
3628
|
+
enableSorting,
|
3629
|
+
enableStickyHeader,
|
3630
|
+
enableTableFooter,
|
3631
|
+
enableTableHead,
|
3632
|
+
enableToolbarInternalActions,
|
3633
|
+
enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode, localization: _localization, manualFiltering,
|
3634
|
+
manualGrouping,
|
3635
|
+
manualPagination,
|
3636
|
+
manualSorting,
|
3637
|
+
paginationDisplayMode,
|
3638
|
+
positionActionsColumn,
|
3639
|
+
positionExpandColumn,
|
3640
|
+
positionGlobalFilter,
|
3641
|
+
positionPagination,
|
3642
|
+
positionToolbarAlertBanner,
|
3643
|
+
positionToolbarDropZone,
|
3644
|
+
rowNumberDisplayMode,
|
3645
|
+
rowPinningDisplayMode,
|
3646
|
+
selectAllMode, sortingFns: _sortingFns }, rest);
|
3647
|
+
};
|
3648
|
+
|
3610
3649
|
const useMaterialReactTable = (tableOptions) => useMRT_TableInstance(useMRT_TableOptions(tableOptions));
|
3611
3650
|
|
3612
3651
|
const isTableInstanceProp = (props) => props.table !== undefined;
|