material-react-table 0.34.1 → 0.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/MaterialReactTable.d.ts +36 -31
- package/dist/cjs/index.js +118 -611
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/menus/MRT_ShowHideColumnsMenuItems.d.ts +3 -3
- package/dist/esm/MaterialReactTable.d.ts +36 -31
- package/dist/esm/material-react-table.esm.js +117 -610
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_ShowHideColumnsMenuItems.d.ts +3 -3
- package/dist/index.d.ts +36 -31
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +35 -27
- package/src/body/MRT_TableBodyCell.tsx +17 -18
- package/src/body/MRT_TableBodyRow.tsx +7 -10
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -5
- package/src/buttons/MRT_EditActionButtons.tsx +11 -7
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +4 -4
- package/src/head/MRT_TableHeadCell.tsx +11 -16
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +11 -12
- package/src/inputs/MRT_EditCellTextField.tsx +13 -13
- package/src/inputs/MRT_GlobalFilterTextField.tsx +1 -6
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +5 -4
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +11 -11
- package/src/table/MRT_TableRoot.tsx +57 -63
- package/src/toolbar/MRT_ToolbarDropZone.tsx +6 -10
|
@@ -3,6 +3,7 @@ import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel,
|
|
|
3
3
|
import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
|
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
5
5
|
import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, alpha, useMediaQuery, Toolbar, lighten, ListItemText, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog } from '@mui/material';
|
|
6
|
+
import { useVirtual } from 'react-virtual';
|
|
6
7
|
|
|
7
8
|
/******************************************************************************
|
|
8
9
|
Copyright (c) Microsoft Corporation.
|
|
@@ -559,7 +560,7 @@ const getDefaultColumnFilterFn = (columnDef) => {
|
|
|
559
560
|
return 'fuzzy';
|
|
560
561
|
};
|
|
561
562
|
|
|
562
|
-
const MRT_ShowHideColumnsMenuItems = ({ allColumns,
|
|
563
|
+
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
563
564
|
var _a;
|
|
564
565
|
const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
|
|
565
566
|
const { columnOrder } = getState();
|
|
@@ -587,14 +588,14 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCur
|
|
|
587
588
|
};
|
|
588
589
|
const handleDragEnd = (_e) => {
|
|
589
590
|
setIsDragging(false);
|
|
590
|
-
|
|
591
|
-
if (
|
|
592
|
-
setColumnOrder(reorderColumn(column,
|
|
591
|
+
setHoveredColumn(null);
|
|
592
|
+
if (hoveredColumn) {
|
|
593
|
+
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
|
593
594
|
}
|
|
594
595
|
};
|
|
595
596
|
const handleDragEnter = (_e) => {
|
|
596
597
|
if (!isDragging) {
|
|
597
|
-
|
|
598
|
+
setHoveredColumn(column);
|
|
598
599
|
}
|
|
599
600
|
};
|
|
600
601
|
return (React.createElement(React.Fragment, null,
|
|
@@ -605,7 +606,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCur
|
|
|
605
606
|
opacity: isDragging ? 0.5 : 1,
|
|
606
607
|
outline: isDragging
|
|
607
608
|
? `1px dashed ${theme.palette.divider}`
|
|
608
|
-
: (
|
|
609
|
+
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
609
610
|
? `2px dashed ${theme.palette.primary.main}`
|
|
610
611
|
: 'none',
|
|
611
612
|
pl: `${(column.depth + 0.5) * 2}rem`,
|
|
@@ -635,7 +636,7 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, currentHoveredColumn, setCur
|
|
|
635
636
|
React.createElement(Switch, null)), disabled: (isSubMenu && switchChecked) ||
|
|
636
637
|
!column.getCanHide() ||
|
|
637
638
|
column.getIsGrouped(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (React.createElement(Typography, { sx: { alignSelf: 'center' } }, columnDef.header)))), (_a = column.columns) === null || _a === void 0 ? void 0 :
|
|
638
|
-
_a.map((c, i) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c,
|
|
639
|
+
_a.map((c, i) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isSubMenu: isSubMenu, key: `${i}-${c.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
|
|
639
640
|
};
|
|
640
641
|
|
|
641
642
|
const MRT_ShowHideColumnsMenu = ({ anchorEl, isSubMenu, setAnchorEl, table, }) => {
|
|
@@ -665,7 +666,7 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, isSubMenu, setAnchorEl, table, }) =
|
|
|
665
666
|
getLeftLeafColumns(),
|
|
666
667
|
getRightLeafColumns(),
|
|
667
668
|
]);
|
|
668
|
-
const [
|
|
669
|
+
const [hoveredColumn, setHoveredColumn] = useState(null);
|
|
669
670
|
return (React.createElement(Menu, { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
|
|
670
671
|
dense: density === 'compact',
|
|
671
672
|
} },
|
|
@@ -680,7 +681,7 @@ const MRT_ShowHideColumnsMenu = ({ anchorEl, isSubMenu, setAnchorEl, table, }) =
|
|
|
680
681
|
!isSubMenu && enablePinning && (React.createElement(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true) }, localization.unpinAll)),
|
|
681
682
|
React.createElement(Button, { disabled: getIsAllColumnsVisible(), onClick: () => toggleAllColumnsVisible(true) }, localization.showAll)),
|
|
682
683
|
React.createElement(Divider, null),
|
|
683
|
-
allColumns.map((column, index) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column,
|
|
684
|
+
allColumns.map((column, index) => (React.createElement(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isSubMenu: isSubMenu, key: `${index}-${column.id}`, setHoveredColumn: setHoveredColumn, table: table })))));
|
|
684
685
|
};
|
|
685
686
|
|
|
686
687
|
const commonMenuItemStyles = {
|
|
@@ -873,16 +874,20 @@ const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) =
|
|
|
873
874
|
};
|
|
874
875
|
|
|
875
876
|
const MRT_EditActionButtons = ({ row, table }) => {
|
|
876
|
-
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization,
|
|
877
|
-
const {
|
|
877
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onEditingRowSave, }, setEditingRow, } = table;
|
|
878
|
+
const { editingRow } = getState();
|
|
878
879
|
const handleCancel = () => {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
setCurrentEditingRow(null);
|
|
880
|
+
row._valuesCache = Object.assign({}, row.original);
|
|
881
|
+
setEditingRow(null);
|
|
882
882
|
};
|
|
883
883
|
const handleSave = () => {
|
|
884
|
-
|
|
885
|
-
|
|
884
|
+
var _a;
|
|
885
|
+
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
886
|
+
row: editingRow !== null && editingRow !== void 0 ? editingRow : row,
|
|
887
|
+
table,
|
|
888
|
+
values: (_a = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _a !== void 0 ? _a : Object.assign({}, row.original),
|
|
889
|
+
});
|
|
890
|
+
setEditingRow(null);
|
|
886
891
|
};
|
|
887
892
|
return (React.createElement(Box, { sx: { display: 'flex', gap: '0.75rem' } },
|
|
888
893
|
React.createElement(Tooltip, { arrow: true, title: localization.cancel },
|
|
@@ -904,8 +909,8 @@ const commonIconButtonStyles = {
|
|
|
904
909
|
},
|
|
905
910
|
};
|
|
906
911
|
const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
907
|
-
const { getState, options: { enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, },
|
|
908
|
-
const {
|
|
912
|
+
const { getState, options: { enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
913
|
+
const { editingRow } = getState();
|
|
909
914
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
910
915
|
const handleOpenRowActionMenu = (event) => {
|
|
911
916
|
event.stopPropagation();
|
|
@@ -913,10 +918,10 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
|
913
918
|
setAnchorEl(event.currentTarget);
|
|
914
919
|
};
|
|
915
920
|
const handleStartEditMode = () => {
|
|
916
|
-
|
|
921
|
+
setEditingRow(Object.assign({}, row));
|
|
917
922
|
setAnchorEl(null);
|
|
918
923
|
};
|
|
919
|
-
return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ row, table }))) : row.id === (
|
|
924
|
+
return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) ? (React.createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React.createElement(Tooltip, { placement: "right", arrow: true, title: localization.edit },
|
|
920
925
|
React.createElement(IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
921
926
|
React.createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React.createElement(React.Fragment, null,
|
|
922
927
|
React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
|
|
@@ -1146,15 +1151,15 @@ const MRT_ToolbarInternalButtons = ({ table }) => {
|
|
|
1146
1151
|
|
|
1147
1152
|
const MRT_ToolbarDropZone = ({ table }) => {
|
|
1148
1153
|
var _a, _b;
|
|
1149
|
-
const { getState, options: { enableGrouping, localization },
|
|
1150
|
-
const {
|
|
1154
|
+
const { getState, options: { enableGrouping, localization }, setHoveredColumn, } = table;
|
|
1155
|
+
const { draggingColumn, hoveredColumn } = getState();
|
|
1151
1156
|
const handleDragEnter = (_event) => {
|
|
1152
|
-
|
|
1157
|
+
setHoveredColumn({ id: 'drop-zone' });
|
|
1153
1158
|
};
|
|
1154
|
-
return (React.createElement(Fade, { unmountOnExit: true, mountOnEnter: true, in: !!enableGrouping && !!
|
|
1159
|
+
return (React.createElement(Fade, { unmountOnExit: true, mountOnEnter: true, in: !!enableGrouping && !!draggingColumn },
|
|
1155
1160
|
React.createElement(Box, { sx: (theme) => ({
|
|
1156
1161
|
alignItems: 'center',
|
|
1157
|
-
backgroundColor: alpha(theme.palette.info.main, (
|
|
1162
|
+
backgroundColor: alpha(theme.palette.info.main, (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone' ? 0.2 : 0.1),
|
|
1158
1163
|
border: `dashed ${theme.palette.info.main} 2px`,
|
|
1159
1164
|
display: 'flex',
|
|
1160
1165
|
justifyContent: 'center',
|
|
@@ -1163,7 +1168,7 @@ const MRT_ToolbarDropZone = ({ table }) => {
|
|
|
1163
1168
|
width: 'calc(100% - 4px)',
|
|
1164
1169
|
zIndex: 2,
|
|
1165
1170
|
}), onDragEnter: handleDragEnter },
|
|
1166
|
-
React.createElement(Typography, null, localization.dropToGroupBy.replace('{column}', (_b = (_a =
|
|
1171
|
+
React.createElement(Typography, null, 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 : '')))));
|
|
1167
1172
|
};
|
|
1168
1173
|
|
|
1169
1174
|
const commonToolbarStyles = ({ theme }) => ({
|
|
@@ -1493,9 +1498,9 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1493
1498
|
};
|
|
1494
1499
|
|
|
1495
1500
|
const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
1496
|
-
const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps, onColumnDrop, }, setColumnOrder,
|
|
1501
|
+
const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps, onColumnDrop, }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
|
1497
1502
|
const { columnDef } = column;
|
|
1498
|
-
const {
|
|
1503
|
+
const { hoveredColumn, draggingColumn, columnOrder } = getState();
|
|
1499
1504
|
const mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function
|
|
1500
1505
|
? muiTableHeadCellDragHandleProps({ column, table })
|
|
1501
1506
|
: muiTableHeadCellDragHandleProps;
|
|
@@ -1504,25 +1509,25 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
|
1504
1509
|
: columnDef.muiTableHeadCellDragHandleProps;
|
|
1505
1510
|
const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
|
|
1506
1511
|
const handleDragStart = (e) => {
|
|
1507
|
-
|
|
1512
|
+
setDraggingColumn(column);
|
|
1508
1513
|
e.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
|
1509
1514
|
};
|
|
1510
1515
|
const handleDragEnd = (event) => {
|
|
1511
1516
|
onColumnDrop === null || onColumnDrop === void 0 ? void 0 : onColumnDrop({
|
|
1512
1517
|
event,
|
|
1513
1518
|
draggedColumn: column,
|
|
1514
|
-
targetColumn:
|
|
1519
|
+
targetColumn: hoveredColumn,
|
|
1515
1520
|
});
|
|
1516
|
-
if ((
|
|
1521
|
+
if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1517
1522
|
column.toggleGrouping();
|
|
1518
1523
|
}
|
|
1519
1524
|
else if (enableColumnOrdering &&
|
|
1520
|
-
|
|
1521
|
-
(
|
|
1522
|
-
setColumnOrder(reorderColumn(column,
|
|
1525
|
+
hoveredColumn &&
|
|
1526
|
+
(hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
|
|
1527
|
+
setColumnOrder(reorderColumn(column, hoveredColumn, columnOrder));
|
|
1523
1528
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
1529
|
+
setDraggingColumn(null);
|
|
1530
|
+
setHoveredColumn(null);
|
|
1526
1531
|
};
|
|
1527
1532
|
return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1528
1533
|
};
|
|
@@ -1580,8 +1585,8 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
|
1580
1585
|
const MRT_TableHeadCell = ({ header, table }) => {
|
|
1581
1586
|
var _a, _b, _c, _d;
|
|
1582
1587
|
const theme = useTheme();
|
|
1583
|
-
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnResizing, enableGrouping, enableMultiSort, muiTableHeadCellProps, },
|
|
1584
|
-
const { density,
|
|
1588
|
+
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnResizing, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
|
|
1589
|
+
const { density, draggingColumn, hoveredColumn, showColumnFilters } = getState();
|
|
1585
1590
|
const { column } = header;
|
|
1586
1591
|
const { columnDef } = column;
|
|
1587
1592
|
const { columnDefType } = columnDef;
|
|
@@ -1603,16 +1608,16 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1603
1608
|
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
1604
1609
|
};
|
|
1605
1610
|
const handleDragEnter = (_e) => {
|
|
1606
|
-
if (enableGrouping && (
|
|
1607
|
-
|
|
1611
|
+
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1612
|
+
setHoveredColumn(null);
|
|
1608
1613
|
}
|
|
1609
|
-
if (enableColumnOrdering &&
|
|
1610
|
-
|
|
1614
|
+
if (enableColumnOrdering && draggingColumn) {
|
|
1615
|
+
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
1611
1616
|
}
|
|
1612
1617
|
};
|
|
1613
|
-
const draggingBorder = (
|
|
1618
|
+
const draggingBorder = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1614
1619
|
? `1px dashed ${theme.palette.text.secondary}`
|
|
1615
|
-
: (
|
|
1620
|
+
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
1616
1621
|
? `2px dashed ${theme.palette.primary.main}`
|
|
1617
1622
|
: undefined;
|
|
1618
1623
|
const draggingBorders = draggingBorder
|
|
@@ -1640,8 +1645,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1640
1645
|
? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
1641
1646
|
: undefined, fontWeight: 'bold', left: column.getIsPinned() === 'left'
|
|
1642
1647
|
? `${column.getStart('left')}px`
|
|
1643
|
-
: undefined, overflow: 'visible', opacity: (
|
|
1644
|
-
(currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === column.id
|
|
1648
|
+
: undefined, overflow: 'visible', opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
1645
1649
|
? 0.5
|
|
1646
1650
|
: 1, p: density === 'compact'
|
|
1647
1651
|
? '0.5rem'
|
|
@@ -1663,7 +1667,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1663
1667
|
? '0.25'
|
|
1664
1668
|
: density === 'comfortable'
|
|
1665
1669
|
? '.75rem'
|
|
1666
|
-
: '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (
|
|
1670
|
+
: '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1667
1671
|
? 3
|
|
1668
1672
|
: column.getIsPinned() && columnDefType !== 'group'
|
|
1669
1673
|
? 2
|
|
@@ -1727,521 +1731,30 @@ const MRT_TableHead = ({ table }) => {
|
|
|
1727
1731
|
return (React.createElement(TableHead, Object.assign({}, tableHeadProps), getHeaderGroups().map((headerGroup) => (React.createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
|
|
1728
1732
|
};
|
|
1729
1733
|
|
|
1730
|
-
function _extends() {
|
|
1731
|
-
_extends = Object.assign || function (target) {
|
|
1732
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
1733
|
-
var source = arguments[i];
|
|
1734
|
-
|
|
1735
|
-
for (var key in source) {
|
|
1736
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1737
|
-
target[key] = source[key];
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
return target;
|
|
1743
|
-
};
|
|
1744
|
-
|
|
1745
|
-
return _extends.apply(this, arguments);
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
1749
|
-
if (source == null) return {};
|
|
1750
|
-
var target = {};
|
|
1751
|
-
var sourceKeys = Object.keys(source);
|
|
1752
|
-
var key, i;
|
|
1753
|
-
|
|
1754
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
1755
|
-
key = sourceKeys[i];
|
|
1756
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
1757
|
-
target[key] = source[key];
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
return target;
|
|
1761
|
-
}
|
|
1762
|
-
|
|
1763
|
-
var props = ['bottom', 'height', 'left', 'right', 'top', 'width'];
|
|
1764
|
-
|
|
1765
|
-
var rectChanged = function rectChanged(a, b) {
|
|
1766
|
-
if (a === void 0) {
|
|
1767
|
-
a = {};
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
if (b === void 0) {
|
|
1771
|
-
b = {};
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
return props.some(function (prop) {
|
|
1775
|
-
return a[prop] !== b[prop];
|
|
1776
|
-
});
|
|
1777
|
-
};
|
|
1778
|
-
|
|
1779
|
-
var observedNodes = /*#__PURE__*/new Map();
|
|
1780
|
-
var rafId;
|
|
1781
|
-
|
|
1782
|
-
var run = function run() {
|
|
1783
|
-
var changedStates = [];
|
|
1784
|
-
observedNodes.forEach(function (state, node) {
|
|
1785
|
-
var newRect = node.getBoundingClientRect();
|
|
1786
|
-
|
|
1787
|
-
if (rectChanged(newRect, state.rect)) {
|
|
1788
|
-
state.rect = newRect;
|
|
1789
|
-
changedStates.push(state);
|
|
1790
|
-
}
|
|
1791
|
-
});
|
|
1792
|
-
changedStates.forEach(function (state) {
|
|
1793
|
-
state.callbacks.forEach(function (cb) {
|
|
1794
|
-
return cb(state.rect);
|
|
1795
|
-
});
|
|
1796
|
-
});
|
|
1797
|
-
rafId = window.requestAnimationFrame(run);
|
|
1798
|
-
};
|
|
1799
|
-
|
|
1800
|
-
function observeRect(node, cb) {
|
|
1801
|
-
return {
|
|
1802
|
-
observe: function observe() {
|
|
1803
|
-
var wasEmpty = observedNodes.size === 0;
|
|
1804
|
-
|
|
1805
|
-
if (observedNodes.has(node)) {
|
|
1806
|
-
observedNodes.get(node).callbacks.push(cb);
|
|
1807
|
-
} else {
|
|
1808
|
-
observedNodes.set(node, {
|
|
1809
|
-
rect: undefined,
|
|
1810
|
-
hasRectChanged: false,
|
|
1811
|
-
callbacks: [cb]
|
|
1812
|
-
});
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
if (wasEmpty) run();
|
|
1816
|
-
},
|
|
1817
|
-
unobserve: function unobserve() {
|
|
1818
|
-
var state = observedNodes.get(node);
|
|
1819
|
-
|
|
1820
|
-
if (state) {
|
|
1821
|
-
// Remove the callback
|
|
1822
|
-
var index = state.callbacks.indexOf(cb);
|
|
1823
|
-
if (index >= 0) state.callbacks.splice(index, 1); // Remove the node reference
|
|
1824
|
-
|
|
1825
|
-
if (!state.callbacks.length) observedNodes["delete"](node); // Stop the loop
|
|
1826
|
-
|
|
1827
|
-
if (!observedNodes.size) cancelAnimationFrame(rafId);
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
};
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
var useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
1834
|
-
|
|
1835
|
-
function useRect(nodeRef, initialRect) {
|
|
1836
|
-
if (initialRect === void 0) {
|
|
1837
|
-
initialRect = {
|
|
1838
|
-
width: 0,
|
|
1839
|
-
height: 0
|
|
1840
|
-
};
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
var _React$useState = React.useState(nodeRef.current),
|
|
1844
|
-
element = _React$useState[0],
|
|
1845
|
-
setElement = _React$useState[1];
|
|
1846
|
-
|
|
1847
|
-
var _React$useReducer = React.useReducer(rectReducer, initialRect),
|
|
1848
|
-
rect = _React$useReducer[0],
|
|
1849
|
-
dispatch = _React$useReducer[1];
|
|
1850
|
-
|
|
1851
|
-
var initialRectSet = React.useRef(false);
|
|
1852
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
1853
|
-
if (nodeRef.current !== element) {
|
|
1854
|
-
setElement(nodeRef.current);
|
|
1855
|
-
}
|
|
1856
|
-
});
|
|
1857
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
1858
|
-
if (element && !initialRectSet.current) {
|
|
1859
|
-
initialRectSet.current = true;
|
|
1860
|
-
|
|
1861
|
-
var _rect = element.getBoundingClientRect();
|
|
1862
|
-
|
|
1863
|
-
dispatch({
|
|
1864
|
-
rect: _rect
|
|
1865
|
-
});
|
|
1866
|
-
}
|
|
1867
|
-
}, [element]);
|
|
1868
|
-
React.useEffect(function () {
|
|
1869
|
-
if (!element) {
|
|
1870
|
-
return;
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
var observer = observeRect(element, function (rect) {
|
|
1874
|
-
dispatch({
|
|
1875
|
-
rect: rect
|
|
1876
|
-
});
|
|
1877
|
-
});
|
|
1878
|
-
observer.observe();
|
|
1879
|
-
return function () {
|
|
1880
|
-
observer.unobserve();
|
|
1881
|
-
};
|
|
1882
|
-
}, [element]);
|
|
1883
|
-
return rect;
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
|
-
function rectReducer(state, action) {
|
|
1887
|
-
var rect = action.rect;
|
|
1888
|
-
|
|
1889
|
-
if (state.height !== rect.height || state.width !== rect.width) {
|
|
1890
|
-
return rect;
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
return state;
|
|
1894
|
-
}
|
|
1895
|
-
|
|
1896
|
-
var defaultEstimateSize = function defaultEstimateSize() {
|
|
1897
|
-
return 50;
|
|
1898
|
-
};
|
|
1899
|
-
|
|
1900
|
-
var defaultKeyExtractor = function defaultKeyExtractor(index) {
|
|
1901
|
-
return index;
|
|
1902
|
-
};
|
|
1903
|
-
|
|
1904
|
-
var defaultMeasureSize = function defaultMeasureSize(el, horizontal) {
|
|
1905
|
-
var key = horizontal ? 'offsetWidth' : 'offsetHeight';
|
|
1906
|
-
return el[key];
|
|
1907
|
-
};
|
|
1908
|
-
|
|
1909
|
-
var defaultRangeExtractor = function defaultRangeExtractor(range) {
|
|
1910
|
-
var start = Math.max(range.start - range.overscan, 0);
|
|
1911
|
-
var end = Math.min(range.end + range.overscan, range.size - 1);
|
|
1912
|
-
var arr = [];
|
|
1913
|
-
|
|
1914
|
-
for (var i = start; i <= end; i++) {
|
|
1915
|
-
arr.push(i);
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
return arr;
|
|
1919
|
-
};
|
|
1920
|
-
function useVirtual(_ref) {
|
|
1921
|
-
var _measurements;
|
|
1922
|
-
|
|
1923
|
-
var _ref$size = _ref.size,
|
|
1924
|
-
size = _ref$size === void 0 ? 0 : _ref$size,
|
|
1925
|
-
_ref$estimateSize = _ref.estimateSize,
|
|
1926
|
-
estimateSize = _ref$estimateSize === void 0 ? defaultEstimateSize : _ref$estimateSize,
|
|
1927
|
-
_ref$overscan = _ref.overscan,
|
|
1928
|
-
overscan = _ref$overscan === void 0 ? 1 : _ref$overscan,
|
|
1929
|
-
_ref$paddingStart = _ref.paddingStart,
|
|
1930
|
-
paddingStart = _ref$paddingStart === void 0 ? 0 : _ref$paddingStart,
|
|
1931
|
-
_ref$paddingEnd = _ref.paddingEnd,
|
|
1932
|
-
paddingEnd = _ref$paddingEnd === void 0 ? 0 : _ref$paddingEnd,
|
|
1933
|
-
parentRef = _ref.parentRef,
|
|
1934
|
-
horizontal = _ref.horizontal,
|
|
1935
|
-
scrollToFn = _ref.scrollToFn,
|
|
1936
|
-
useObserver = _ref.useObserver,
|
|
1937
|
-
initialRect = _ref.initialRect,
|
|
1938
|
-
onScrollElement = _ref.onScrollElement,
|
|
1939
|
-
scrollOffsetFn = _ref.scrollOffsetFn,
|
|
1940
|
-
_ref$keyExtractor = _ref.keyExtractor,
|
|
1941
|
-
keyExtractor = _ref$keyExtractor === void 0 ? defaultKeyExtractor : _ref$keyExtractor,
|
|
1942
|
-
_ref$measureSize = _ref.measureSize,
|
|
1943
|
-
measureSize = _ref$measureSize === void 0 ? defaultMeasureSize : _ref$measureSize,
|
|
1944
|
-
_ref$rangeExtractor = _ref.rangeExtractor,
|
|
1945
|
-
rangeExtractor = _ref$rangeExtractor === void 0 ? defaultRangeExtractor : _ref$rangeExtractor;
|
|
1946
|
-
var sizeKey = horizontal ? 'width' : 'height';
|
|
1947
|
-
var scrollKey = horizontal ? 'scrollLeft' : 'scrollTop';
|
|
1948
|
-
var latestRef = React.useRef({
|
|
1949
|
-
scrollOffset: 0,
|
|
1950
|
-
measurements: []
|
|
1951
|
-
});
|
|
1952
|
-
|
|
1953
|
-
var _React$useState = React.useState(0),
|
|
1954
|
-
scrollOffset = _React$useState[0],
|
|
1955
|
-
setScrollOffset = _React$useState[1];
|
|
1956
|
-
|
|
1957
|
-
latestRef.current.scrollOffset = scrollOffset;
|
|
1958
|
-
var useMeasureParent = useObserver || useRect;
|
|
1959
|
-
|
|
1960
|
-
var _useMeasureParent = useMeasureParent(parentRef, initialRect),
|
|
1961
|
-
outerSize = _useMeasureParent[sizeKey];
|
|
1962
|
-
|
|
1963
|
-
latestRef.current.outerSize = outerSize;
|
|
1964
|
-
var defaultScrollToFn = React.useCallback(function (offset) {
|
|
1965
|
-
if (parentRef.current) {
|
|
1966
|
-
parentRef.current[scrollKey] = offset;
|
|
1967
|
-
}
|
|
1968
|
-
}, [parentRef, scrollKey]);
|
|
1969
|
-
var resolvedScrollToFn = scrollToFn || defaultScrollToFn;
|
|
1970
|
-
scrollToFn = React.useCallback(function (offset) {
|
|
1971
|
-
resolvedScrollToFn(offset, defaultScrollToFn);
|
|
1972
|
-
}, [defaultScrollToFn, resolvedScrollToFn]);
|
|
1973
|
-
|
|
1974
|
-
var _React$useState2 = React.useState({}),
|
|
1975
|
-
measuredCache = _React$useState2[0],
|
|
1976
|
-
setMeasuredCache = _React$useState2[1];
|
|
1977
|
-
|
|
1978
|
-
var measure = React.useCallback(function () {
|
|
1979
|
-
return setMeasuredCache({});
|
|
1980
|
-
}, []);
|
|
1981
|
-
var pendingMeasuredCacheIndexesRef = React.useRef([]);
|
|
1982
|
-
var measurements = React.useMemo(function () {
|
|
1983
|
-
var min = pendingMeasuredCacheIndexesRef.current.length > 0 ? Math.min.apply(Math, pendingMeasuredCacheIndexesRef.current) : 0;
|
|
1984
|
-
pendingMeasuredCacheIndexesRef.current = [];
|
|
1985
|
-
var measurements = latestRef.current.measurements.slice(0, min);
|
|
1986
|
-
|
|
1987
|
-
for (var i = min; i < size; i++) {
|
|
1988
|
-
var key = keyExtractor(i);
|
|
1989
|
-
var measuredSize = measuredCache[key];
|
|
1990
|
-
|
|
1991
|
-
var _start = measurements[i - 1] ? measurements[i - 1].end : paddingStart;
|
|
1992
|
-
|
|
1993
|
-
var _size = typeof measuredSize === 'number' ? measuredSize : estimateSize(i);
|
|
1994
|
-
|
|
1995
|
-
var _end = _start + _size;
|
|
1996
|
-
|
|
1997
|
-
measurements[i] = {
|
|
1998
|
-
index: i,
|
|
1999
|
-
start: _start,
|
|
2000
|
-
size: _size,
|
|
2001
|
-
end: _end,
|
|
2002
|
-
key: key
|
|
2003
|
-
};
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
return measurements;
|
|
2007
|
-
}, [estimateSize, measuredCache, paddingStart, size, keyExtractor]);
|
|
2008
|
-
var totalSize = (((_measurements = measurements[size - 1]) == null ? void 0 : _measurements.end) || paddingStart) + paddingEnd;
|
|
2009
|
-
latestRef.current.measurements = measurements;
|
|
2010
|
-
latestRef.current.totalSize = totalSize;
|
|
2011
|
-
var element = onScrollElement ? onScrollElement.current : parentRef.current;
|
|
2012
|
-
var scrollOffsetFnRef = React.useRef(scrollOffsetFn);
|
|
2013
|
-
scrollOffsetFnRef.current = scrollOffsetFn;
|
|
2014
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
2015
|
-
if (!element) {
|
|
2016
|
-
setScrollOffset(0);
|
|
2017
|
-
return;
|
|
2018
|
-
}
|
|
2019
|
-
|
|
2020
|
-
var onScroll = function onScroll(event) {
|
|
2021
|
-
var offset = scrollOffsetFnRef.current ? scrollOffsetFnRef.current(event) : element[scrollKey];
|
|
2022
|
-
setScrollOffset(offset);
|
|
2023
|
-
};
|
|
2024
|
-
|
|
2025
|
-
onScroll();
|
|
2026
|
-
element.addEventListener('scroll', onScroll, {
|
|
2027
|
-
capture: false,
|
|
2028
|
-
passive: true
|
|
2029
|
-
});
|
|
2030
|
-
return function () {
|
|
2031
|
-
element.removeEventListener('scroll', onScroll);
|
|
2032
|
-
};
|
|
2033
|
-
}, [element, scrollKey]);
|
|
2034
|
-
|
|
2035
|
-
var _calculateRange = calculateRange(latestRef.current),
|
|
2036
|
-
start = _calculateRange.start,
|
|
2037
|
-
end = _calculateRange.end;
|
|
2038
|
-
|
|
2039
|
-
var indexes = React.useMemo(function () {
|
|
2040
|
-
return rangeExtractor({
|
|
2041
|
-
start: start,
|
|
2042
|
-
end: end,
|
|
2043
|
-
overscan: overscan,
|
|
2044
|
-
size: measurements.length
|
|
2045
|
-
});
|
|
2046
|
-
}, [start, end, overscan, measurements.length, rangeExtractor]);
|
|
2047
|
-
var measureSizeRef = React.useRef(measureSize);
|
|
2048
|
-
measureSizeRef.current = measureSize;
|
|
2049
|
-
var virtualItems = React.useMemo(function () {
|
|
2050
|
-
var virtualItems = [];
|
|
2051
|
-
|
|
2052
|
-
var _loop = function _loop(k, len) {
|
|
2053
|
-
var i = indexes[k];
|
|
2054
|
-
var measurement = measurements[i];
|
|
2055
|
-
|
|
2056
|
-
var item = _extends(_extends({}, measurement), {}, {
|
|
2057
|
-
measureRef: function measureRef(el) {
|
|
2058
|
-
if (el) {
|
|
2059
|
-
var measuredSize = measureSizeRef.current(el, horizontal);
|
|
2060
|
-
|
|
2061
|
-
if (measuredSize !== item.size) {
|
|
2062
|
-
var _scrollOffset = latestRef.current.scrollOffset;
|
|
2063
|
-
|
|
2064
|
-
if (item.start < _scrollOffset) {
|
|
2065
|
-
defaultScrollToFn(_scrollOffset + (measuredSize - item.size));
|
|
2066
|
-
}
|
|
2067
|
-
|
|
2068
|
-
pendingMeasuredCacheIndexesRef.current.push(i);
|
|
2069
|
-
setMeasuredCache(function (old) {
|
|
2070
|
-
var _extends2;
|
|
2071
|
-
|
|
2072
|
-
return _extends(_extends({}, old), {}, (_extends2 = {}, _extends2[item.key] = measuredSize, _extends2));
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
});
|
|
2078
|
-
|
|
2079
|
-
virtualItems.push(item);
|
|
2080
|
-
};
|
|
2081
|
-
|
|
2082
|
-
for (var k = 0, len = indexes.length; k < len; k++) {
|
|
2083
|
-
_loop(k);
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
return virtualItems;
|
|
2087
|
-
}, [indexes, defaultScrollToFn, horizontal, measurements]);
|
|
2088
|
-
var mountedRef = React.useRef(false);
|
|
2089
|
-
useIsomorphicLayoutEffect$1(function () {
|
|
2090
|
-
if (mountedRef.current) {
|
|
2091
|
-
setMeasuredCache({});
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
mountedRef.current = true;
|
|
2095
|
-
}, [estimateSize]);
|
|
2096
|
-
var scrollToOffset = React.useCallback(function (toOffset, _temp) {
|
|
2097
|
-
var _ref2 = _temp === void 0 ? {} : _temp,
|
|
2098
|
-
_ref2$align = _ref2.align,
|
|
2099
|
-
align = _ref2$align === void 0 ? 'start' : _ref2$align;
|
|
2100
|
-
|
|
2101
|
-
var _latestRef$current = latestRef.current,
|
|
2102
|
-
scrollOffset = _latestRef$current.scrollOffset,
|
|
2103
|
-
outerSize = _latestRef$current.outerSize;
|
|
2104
|
-
|
|
2105
|
-
if (align === 'auto') {
|
|
2106
|
-
if (toOffset <= scrollOffset) {
|
|
2107
|
-
align = 'start';
|
|
2108
|
-
} else if (toOffset >= scrollOffset + outerSize) {
|
|
2109
|
-
align = 'end';
|
|
2110
|
-
} else {
|
|
2111
|
-
align = 'start';
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
if (align === 'start') {
|
|
2116
|
-
scrollToFn(toOffset);
|
|
2117
|
-
} else if (align === 'end') {
|
|
2118
|
-
scrollToFn(toOffset - outerSize);
|
|
2119
|
-
} else if (align === 'center') {
|
|
2120
|
-
scrollToFn(toOffset - outerSize / 2);
|
|
2121
|
-
}
|
|
2122
|
-
}, [scrollToFn]);
|
|
2123
|
-
var tryScrollToIndex = React.useCallback(function (index, _temp2) {
|
|
2124
|
-
var _ref3 = _temp2 === void 0 ? {} : _temp2,
|
|
2125
|
-
_ref3$align = _ref3.align,
|
|
2126
|
-
align = _ref3$align === void 0 ? 'auto' : _ref3$align,
|
|
2127
|
-
rest = _objectWithoutPropertiesLoose(_ref3, ["align"]);
|
|
2128
|
-
|
|
2129
|
-
var _latestRef$current2 = latestRef.current,
|
|
2130
|
-
measurements = _latestRef$current2.measurements,
|
|
2131
|
-
scrollOffset = _latestRef$current2.scrollOffset,
|
|
2132
|
-
outerSize = _latestRef$current2.outerSize;
|
|
2133
|
-
var measurement = measurements[Math.max(0, Math.min(index, size - 1))];
|
|
2134
|
-
|
|
2135
|
-
if (!measurement) {
|
|
2136
|
-
return;
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
if (align === 'auto') {
|
|
2140
|
-
if (measurement.end >= scrollOffset + outerSize) {
|
|
2141
|
-
align = 'end';
|
|
2142
|
-
} else if (measurement.start <= scrollOffset) {
|
|
2143
|
-
align = 'start';
|
|
2144
|
-
} else {
|
|
2145
|
-
return;
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
|
|
2149
|
-
var toOffset = align === 'center' ? measurement.start + measurement.size / 2 : align === 'end' ? measurement.end : measurement.start;
|
|
2150
|
-
scrollToOffset(toOffset, _extends({
|
|
2151
|
-
align: align
|
|
2152
|
-
}, rest));
|
|
2153
|
-
}, [scrollToOffset, size]);
|
|
2154
|
-
var scrollToIndex = React.useCallback(function () {
|
|
2155
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2156
|
-
args[_key] = arguments[_key];
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
// We do a double request here because of
|
|
2160
|
-
// dynamic sizes which can cause offset shift
|
|
2161
|
-
// and end up in the wrong spot. Unfortunately,
|
|
2162
|
-
// we can't know about those dynamic sizes until
|
|
2163
|
-
// we try and render them. So double down!
|
|
2164
|
-
tryScrollToIndex.apply(void 0, args);
|
|
2165
|
-
requestAnimationFrame(function () {
|
|
2166
|
-
tryScrollToIndex.apply(void 0, args);
|
|
2167
|
-
});
|
|
2168
|
-
}, [tryScrollToIndex]);
|
|
2169
|
-
return {
|
|
2170
|
-
virtualItems: virtualItems,
|
|
2171
|
-
totalSize: totalSize,
|
|
2172
|
-
scrollToOffset: scrollToOffset,
|
|
2173
|
-
scrollToIndex: scrollToIndex,
|
|
2174
|
-
measure: measure
|
|
2175
|
-
};
|
|
2176
|
-
}
|
|
2177
|
-
|
|
2178
|
-
var findNearestBinarySearch = function findNearestBinarySearch(low, high, getCurrentValue, value) {
|
|
2179
|
-
while (low <= high) {
|
|
2180
|
-
var middle = (low + high) / 2 | 0;
|
|
2181
|
-
var currentValue = getCurrentValue(middle);
|
|
2182
|
-
|
|
2183
|
-
if (currentValue < value) {
|
|
2184
|
-
low = middle + 1;
|
|
2185
|
-
} else if (currentValue > value) {
|
|
2186
|
-
high = middle - 1;
|
|
2187
|
-
} else {
|
|
2188
|
-
return middle;
|
|
2189
|
-
}
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
|
-
if (low > 0) {
|
|
2193
|
-
return low - 1;
|
|
2194
|
-
} else {
|
|
2195
|
-
return 0;
|
|
2196
|
-
}
|
|
2197
|
-
};
|
|
2198
|
-
|
|
2199
|
-
function calculateRange(_ref4) {
|
|
2200
|
-
var measurements = _ref4.measurements,
|
|
2201
|
-
outerSize = _ref4.outerSize,
|
|
2202
|
-
scrollOffset = _ref4.scrollOffset;
|
|
2203
|
-
var size = measurements.length - 1;
|
|
2204
|
-
|
|
2205
|
-
var getOffset = function getOffset(index) {
|
|
2206
|
-
return measurements[index].start;
|
|
2207
|
-
};
|
|
2208
|
-
|
|
2209
|
-
var start = findNearestBinarySearch(0, size, getOffset, scrollOffset);
|
|
2210
|
-
var end = start;
|
|
2211
|
-
|
|
2212
|
-
while (end < size && measurements[end].end < scrollOffset + outerSize) {
|
|
2213
|
-
end++;
|
|
2214
|
-
}
|
|
2215
|
-
|
|
2216
|
-
return {
|
|
2217
|
-
start: start,
|
|
2218
|
-
end: end
|
|
2219
|
-
};
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
1734
|
const MRT_EditCellTextField = ({ cell, table }) => {
|
|
2223
1735
|
var _a;
|
|
2224
|
-
const { getState, options: { tableId,
|
|
1736
|
+
const { getState, options: { tableId, muiTableBodyCellEditTextFieldProps, onCellEditBlur, onCellEditChange, }, setEditingCell, setEditingRow, } = table;
|
|
2225
1737
|
const { column, row } = cell;
|
|
2226
1738
|
const { columnDef } = column;
|
|
2227
|
-
const
|
|
1739
|
+
const { editingRow } = getState();
|
|
1740
|
+
const [value, setValue] = useState(() => cell.getValue());
|
|
2228
1741
|
const handleChange = (event) => {
|
|
2229
1742
|
var _a;
|
|
2230
1743
|
setValue(event.target.value);
|
|
2231
|
-
(_a = columnDef.onCellEditChange) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table });
|
|
2232
|
-
onCellEditChange === null || onCellEditChange === void 0 ? void 0 : onCellEditChange({ event, cell, table });
|
|
1744
|
+
(_a = columnDef.onCellEditChange) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table, value });
|
|
1745
|
+
onCellEditChange === null || onCellEditChange === void 0 ? void 0 : onCellEditChange({ event, cell, table, value });
|
|
2233
1746
|
};
|
|
2234
1747
|
const handleBlur = (event) => {
|
|
2235
1748
|
var _a;
|
|
2236
|
-
if (
|
|
1749
|
+
if (editingRow) {
|
|
2237
1750
|
if (!row._valuesCache)
|
|
2238
1751
|
row._valuesCache = {};
|
|
2239
1752
|
row._valuesCache[column.id] = value;
|
|
2240
|
-
|
|
1753
|
+
setEditingRow(Object.assign({}, editingRow));
|
|
2241
1754
|
}
|
|
2242
|
-
|
|
2243
|
-
(_a = columnDef.onCellEditBlur) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table });
|
|
2244
|
-
onCellEditBlur === null || onCellEditBlur === void 0 ? void 0 : onCellEditBlur({ event, cell, table });
|
|
1755
|
+
setEditingCell(null);
|
|
1756
|
+
(_a = columnDef.onCellEditBlur) === null || _a === void 0 ? void 0 : _a.call(columnDef, { event, cell, table, value });
|
|
1757
|
+
onCellEditBlur === null || onCellEditBlur === void 0 ? void 0 : onCellEditBlur({ event, cell, table, value });
|
|
2245
1758
|
};
|
|
2246
1759
|
const mTableBodyCellEditTextFieldProps = muiTableBodyCellEditTextFieldProps instanceof Function
|
|
2247
1760
|
? muiTableBodyCellEditTextFieldProps({ cell, table })
|
|
@@ -2253,10 +1766,10 @@ const MRT_EditCellTextField = ({ cell, table }) => {
|
|
|
2253
1766
|
})
|
|
2254
1767
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
2255
1768
|
const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
|
|
2256
|
-
if (
|
|
1769
|
+
if (columnDef.Edit) {
|
|
2257
1770
|
return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, table }));
|
|
2258
1771
|
}
|
|
2259
|
-
return (React.createElement(TextField, Object.assign({ id: `mrt-${tableId}-edit-cell-text-field-${cell.id}`, margin: "
|
|
1772
|
+
return (React.createElement(TextField, Object.assign({ id: `mrt-${tableId}-edit-cell-text-field-${cell.id}`, margin: "none", onBlur: handleBlur, onChange: handleChange, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps)));
|
|
2260
1773
|
};
|
|
2261
1774
|
|
|
2262
1775
|
const MRT_CopyButton = ({ cell, children, table }) => {
|
|
@@ -2292,16 +1805,16 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
2292
1805
|
: muiTableBodyRowDragHandleProps;
|
|
2293
1806
|
const handleDragStart = (e) => {
|
|
2294
1807
|
e.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
2295
|
-
table.
|
|
1808
|
+
table.setDraggingRow(cell.row);
|
|
2296
1809
|
};
|
|
2297
1810
|
const handleDragEnd = (event) => {
|
|
2298
1811
|
onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
|
|
2299
1812
|
event,
|
|
2300
|
-
draggedRow: table.getState().
|
|
2301
|
-
targetRow: table.getState().
|
|
1813
|
+
draggedRow: table.getState().draggingRow,
|
|
1814
|
+
targetRow: table.getState().hoveredRow,
|
|
2302
1815
|
});
|
|
2303
|
-
table.
|
|
2304
|
-
table.
|
|
1816
|
+
table.setDraggingRow(null);
|
|
1817
|
+
table.setHoveredRow(null);
|
|
2305
1818
|
};
|
|
2306
1819
|
return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
2307
1820
|
};
|
|
@@ -2309,8 +1822,8 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
2309
1822
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
2310
1823
|
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
2311
1824
|
const theme = useTheme();
|
|
2312
|
-
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, tableId, },
|
|
2313
|
-
const {
|
|
1825
|
+
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, tableId, }, setEditingCell, setHoveredColumn, } = table;
|
|
1826
|
+
const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
|
|
2314
1827
|
const { column, row } = cell;
|
|
2315
1828
|
const { columnDef } = column;
|
|
2316
1829
|
const { columnDefType } = columnDef;
|
|
@@ -2325,8 +1838,8 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2325
1838
|
columnDef.enableEditing !== false;
|
|
2326
1839
|
const isEditing = isEditable &&
|
|
2327
1840
|
(editingMode === 'table' ||
|
|
2328
|
-
(
|
|
2329
|
-
(
|
|
1841
|
+
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
|
|
1842
|
+
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id);
|
|
2330
1843
|
const [skeletonWidth, setSkeletonWidth] = useState(0);
|
|
2331
1844
|
useEffect(() => setSkeletonWidth(isLoading || showSkeletons
|
|
2332
1845
|
? columnDefType === 'display'
|
|
@@ -2338,7 +1851,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2338
1851
|
if ((enableEditing || columnDef.enableEditing) &&
|
|
2339
1852
|
columnDef.enableEditing !== false &&
|
|
2340
1853
|
editingMode === 'cell') {
|
|
2341
|
-
|
|
1854
|
+
setEditingCell(cell);
|
|
2342
1855
|
setTimeout(() => {
|
|
2343
1856
|
const textField = document.getElementById(`mrt-${tableId}-edit-cell-text-field-${cell.id}`);
|
|
2344
1857
|
if (textField) {
|
|
@@ -2359,16 +1872,16 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2359
1872
|
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
2360
1873
|
};
|
|
2361
1874
|
const handleDragEnter = (_e) => {
|
|
2362
|
-
if (enableGrouping && (
|
|
2363
|
-
|
|
1875
|
+
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1876
|
+
setHoveredColumn(null);
|
|
2364
1877
|
}
|
|
2365
|
-
if (enableColumnOrdering &&
|
|
2366
|
-
|
|
1878
|
+
if (enableColumnOrdering && draggingColumn) {
|
|
1879
|
+
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
2367
1880
|
}
|
|
2368
1881
|
};
|
|
2369
|
-
const draggingBorder = (
|
|
1882
|
+
const draggingBorder = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
2370
1883
|
? `1px dashed ${theme.palette.text.secondary}`
|
|
2371
|
-
: (
|
|
1884
|
+
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
2372
1885
|
? `2px dashed ${theme.palette.primary.main}`
|
|
2373
1886
|
: undefined;
|
|
2374
1887
|
const draggingBorders = draggingBorder
|
|
@@ -2394,8 +1907,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2394
1907
|
? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
2395
1908
|
: undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
|
|
2396
1909
|
? `${column.getStart('left')}px`
|
|
2397
|
-
: undefined, opacity: (
|
|
2398
|
-
(currentHoveredColumn === null || currentHoveredColumn === void 0 ? void 0 : currentHoveredColumn.id) === column.id
|
|
1910
|
+
: undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
2399
1911
|
? 0.5
|
|
2400
1912
|
: 1, overflow: 'hidden', p: density === 'compact'
|
|
2401
1913
|
? columnDefType === 'display'
|
|
@@ -2414,7 +1926,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2414
1926
|
: density === 'comfortable'
|
|
2415
1927
|
? 0.75
|
|
2416
1928
|
: 1.25)}rem`
|
|
2417
|
-
: undefined, position: column.getIsPinned() ? 'sticky' : 'relative', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, transition: 'all 0.2s ease-in-out', whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (
|
|
1929
|
+
: undefined, position: column.getIsPinned() ? 'sticky' : 'relative', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, transition: 'all 0.2s ease-in-out', whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
2418
1930
|
? 2
|
|
2419
1931
|
: column.getIsPinned()
|
|
2420
1932
|
? 1
|
|
@@ -2460,20 +1972,20 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2460
1972
|
const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
2461
1973
|
var _a, _b;
|
|
2462
1974
|
const theme = useTheme();
|
|
2463
|
-
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel },
|
|
2464
|
-
const {
|
|
1975
|
+
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel }, setHoveredRow, } = table;
|
|
1976
|
+
const { draggingRow, hoveredRow } = getState();
|
|
2465
1977
|
const tableRowProps = muiTableBodyRowProps instanceof Function
|
|
2466
1978
|
? muiTableBodyRowProps({ row, table })
|
|
2467
1979
|
: muiTableBodyRowProps;
|
|
2468
1980
|
const handleDragEnter = (_e) => {
|
|
2469
|
-
if (enableRowOrdering &&
|
|
2470
|
-
|
|
1981
|
+
if (enableRowOrdering && draggingRow) {
|
|
1982
|
+
setHoveredRow(row);
|
|
2471
1983
|
}
|
|
2472
1984
|
};
|
|
2473
1985
|
const rowRef = useRef(null);
|
|
2474
|
-
const draggingBorder = (
|
|
1986
|
+
const draggingBorder = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id
|
|
2475
1987
|
? `1px dashed ${theme.palette.text.secondary}`
|
|
2476
|
-
: (
|
|
1988
|
+
: (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
|
|
2477
1989
|
? `2px dashed ${theme.palette.primary.main}`
|
|
2478
1990
|
: undefined;
|
|
2479
1991
|
const draggingBorders = draggingBorder
|
|
@@ -2482,10 +1994,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
|
2482
1994
|
}
|
|
2483
1995
|
: undefined;
|
|
2484
1996
|
return (React.createElement(React.Fragment, null,
|
|
2485
|
-
React.createElement(TableRow, Object.assign({ onDragEnter: handleDragEnter, hover: true, selected: row.getIsSelected(), ref: rowRef }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (
|
|
2486
|
-
(currentHoveredRow === null || currentHoveredRow === void 0 ? void 0 : currentHoveredRow.id) === row.id
|
|
2487
|
-
? 0.5
|
|
2488
|
-
: 1, transition: 'all 0.2s ease-in-out', '&:hover td': {
|
|
1997
|
+
React.createElement(TableRow, Object.assign({ onDragEnter: handleDragEnter, hover: true, selected: row.getIsSelected(), ref: rowRef }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all 0.2s ease-in-out', '&:hover td': {
|
|
2489
1998
|
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
|
|
2490
1999
|
? theme.palette.mode === 'dark'
|
|
2491
2000
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
|
@@ -2692,7 +2201,7 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2692
2201
|
};
|
|
2693
2202
|
|
|
2694
2203
|
const MRT_TableRoot = (props) => {
|
|
2695
|
-
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;
|
|
2204
|
+
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;
|
|
2696
2205
|
const [tableId, setIdPrefix] = useState(props.tableId);
|
|
2697
2206
|
useEffect(() => { var _a; return setIdPrefix((_a = props.tableId) !== null && _a !== void 0 ? _a : Math.random().toString(36).substring(2, 9)); }, [props.tableId]);
|
|
2698
2207
|
const initialState = useMemo(() => {
|
|
@@ -2700,20 +2209,12 @@ const MRT_TableRoot = (props) => {
|
|
|
2700
2209
|
const initState = (_a = props.initialState) !== null && _a !== void 0 ? _a : {};
|
|
2701
2210
|
initState.columnOrder =
|
|
2702
2211
|
(_b = initState.columnOrder) !== null && _b !== void 0 ? _b : getDefaultColumnOrderIds(props);
|
|
2212
|
+
initState.globalFilterFn =
|
|
2213
|
+
props.globalFilterFn instanceof String
|
|
2214
|
+
? props.globalFilterFn
|
|
2215
|
+
: 'fuzzy';
|
|
2703
2216
|
return initState;
|
|
2704
2217
|
}, []);
|
|
2705
|
-
const [columnOrder, setColumnOrder] = useState((_a = initialState.columnOrder) !== null && _a !== void 0 ? _a : []);
|
|
2706
|
-
const [currentDraggingColumn, setCurrentDraggingColumn] = useState((_b = initialState.currentDraggingColumn) !== null && _b !== void 0 ? _b : null);
|
|
2707
|
-
const [currentDraggingRow, setCurrentDraggingRow] = useState((_c = initialState.currentDraggingRow) !== null && _c !== void 0 ? _c : null);
|
|
2708
|
-
const [currentEditingCell, setCurrentEditingCell] = useState((_d = initialState.currentEditingCell) !== null && _d !== void 0 ? _d : null);
|
|
2709
|
-
const [currentEditingRow, setCurrentEditingRow] = useState((_e = initialState.currentEditingRow) !== null && _e !== void 0 ? _e : null);
|
|
2710
|
-
const [currentHoveredColumn, setCurrentHoveredColumn] = useState((_f = initialState.currentHoveredColumn) !== null && _f !== void 0 ? _f : null);
|
|
2711
|
-
const [currentHoveredRow, setCurrentHoveredRow] = useState((_g = initialState.currentHoveredRow) !== null && _g !== void 0 ? _g : null);
|
|
2712
|
-
const [density, setDensity] = useState((_h = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _h !== void 0 ? _h : 'comfortable');
|
|
2713
|
-
const [isFullScreen, setIsFullScreen] = useState((_j = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _j !== void 0 ? _j : false);
|
|
2714
|
-
const [showAlertBanner, setShowAlertBanner] = useState((_l = (_k = props.initialState) === null || _k === void 0 ? void 0 : _k.showAlertBanner) !== null && _l !== void 0 ? _l : false);
|
|
2715
|
-
const [showColumnFilters, setShowFilters] = useState((_m = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _m !== void 0 ? _m : false);
|
|
2716
|
-
const [showGlobalFilter, setShowGlobalFilter] = useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _o !== void 0 ? _o : false);
|
|
2717
2218
|
const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(props.columns).map((col) => {
|
|
2718
2219
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2719
2220
|
return ({
|
|
@@ -2722,9 +2223,19 @@ const MRT_TableRoot = (props) => {
|
|
|
2722
2223
|
: (_m = (_f = col.filterFn) !== null && _f !== void 0 ? _f : (_g = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _g === void 0 ? void 0 : _g[(_l = (_j = (_h = col.id) === null || _h === void 0 ? void 0 : _h.toString()) !== null && _j !== void 0 ? _j : (_k = col.accessorKey) === null || _k === void 0 ? void 0 : _k.toString()) !== null && _l !== void 0 ? _l : '']) !== null && _m !== void 0 ? _m : getDefaultColumnFilterFn(col),
|
|
2723
2224
|
});
|
|
2724
2225
|
})));
|
|
2725
|
-
const [
|
|
2726
|
-
|
|
2727
|
-
|
|
2226
|
+
const [columnOrder, setColumnOrder] = useState((_a = initialState.columnOrder) !== null && _a !== void 0 ? _a : []);
|
|
2227
|
+
const [density, setDensity] = useState((_b = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _b !== void 0 ? _b : 'comfortable');
|
|
2228
|
+
const [draggingColumn, setDraggingColumn] = useState((_c = initialState.draggingColumn) !== null && _c !== void 0 ? _c : null);
|
|
2229
|
+
const [draggingRow, setDraggingRow] = useState((_d = initialState.draggingRow) !== null && _d !== void 0 ? _d : null);
|
|
2230
|
+
const [editingCell, setEditingCell] = useState((_e = initialState.editingCell) !== null && _e !== void 0 ? _e : null);
|
|
2231
|
+
const [editingRow, setEditingRow] = useState((_f = initialState.editingRow) !== null && _f !== void 0 ? _f : null);
|
|
2232
|
+
const [globalFilterFn, setGlobalFilterFn] = useState((_g = initialState.globalFilterFn) !== null && _g !== void 0 ? _g : 'fuzzy');
|
|
2233
|
+
const [hoveredColumn, setHoveredColumn] = useState((_h = initialState.hoveredColumn) !== null && _h !== void 0 ? _h : null);
|
|
2234
|
+
const [hoveredRow, setHoveredRow] = useState((_j = initialState.hoveredRow) !== null && _j !== void 0 ? _j : null);
|
|
2235
|
+
const [isFullScreen, setIsFullScreen] = useState((_k = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _k !== void 0 ? _k : false);
|
|
2236
|
+
const [showAlertBanner, setShowAlertBanner] = useState((_m = (_l = props.initialState) === null || _l === void 0 ? void 0 : _l.showAlertBanner) !== null && _m !== void 0 ? _m : false);
|
|
2237
|
+
const [showColumnFilters, setShowFilters] = useState((_o = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _o !== void 0 ? _o : false);
|
|
2238
|
+
const [showGlobalFilter, setShowGlobalFilter] = useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _p !== void 0 ? _p : false);
|
|
2728
2239
|
const displayColumns = useMemo(() => {
|
|
2729
2240
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2730
2241
|
return [
|
|
@@ -2751,8 +2262,6 @@ const MRT_TableRoot = (props) => {
|
|
|
2751
2262
|
props.enableRowSelection,
|
|
2752
2263
|
props.enableSelectAll,
|
|
2753
2264
|
props.localization,
|
|
2754
|
-
props.muiTableBodyCellProps,
|
|
2755
|
-
props.muiTableHeadCellProps,
|
|
2756
2265
|
props.positionActionsColumn,
|
|
2757
2266
|
]);
|
|
2758
2267
|
const columnDefs = useMemo(() => prepareColumns([...displayColumns, ...props.columns], columnFilterFns, props.filterFns, props.sortingFns), [columnFilterFns, displayColumns, props.columns]);
|
|
@@ -2771,26 +2280,24 @@ const MRT_TableRoot = (props) => {
|
|
|
2771
2280
|
});
|
|
2772
2281
|
})))
|
|
2773
2282
|
: props.data;
|
|
2774
|
-
}, [props.data, (
|
|
2283
|
+
}, [props.data, (_q = props.state) === null || _q === void 0 ? void 0 : _q.isLoading, (_r = props.state) === null || _r === void 0 ? void 0 : _r.showSkeletons]);
|
|
2775
2284
|
//@ts-ignore
|
|
2776
2285
|
const table = Object.assign(Object.assign({}, useReactTable(Object.assign(Object.assign({ getCoreRowModel: getCoreRowModel(), getExpandedRowModel: getExpandedRowModel(), getFacetedRowModel: getFacetedRowModel(), getFilteredRowModel: getFilteredRowModel(), getGroupedRowModel: getGroupedRowModel(), getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), onColumnOrderChange: setColumnOrder, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
|
2777
2286
|
//@ts-ignore
|
|
2778
|
-
columns: columnDefs, data, globalFilterFn:
|
|
2779
|
-
|
|
2780
|
-
(_r = props.filterFns[globalFilterFn]) !== null && _r !== void 0 ? _r : props.filterFns.fuzzy, initialState, state: Object.assign({ columnOrder,
|
|
2781
|
-
currentDraggingColumn,
|
|
2782
|
-
currentDraggingRow,
|
|
2783
|
-
currentEditingCell,
|
|
2784
|
-
currentEditingRow,
|
|
2785
|
-
columnFilterFns,
|
|
2786
|
-
globalFilterFn,
|
|
2787
|
-
currentHoveredColumn,
|
|
2788
|
-
currentHoveredRow,
|
|
2287
|
+
columns: columnDefs, data, globalFilterFn: (_t = (_s = props.filterFns) === null || _s === void 0 ? void 0 : _s[globalFilterFn]) !== null && _t !== void 0 ? _t : (_u = props.filterFns) === null || _u === void 0 ? void 0 : _u.fuzzy, initialState, state: Object.assign({ columnFilterFns,
|
|
2288
|
+
columnOrder,
|
|
2789
2289
|
density,
|
|
2290
|
+
draggingColumn,
|
|
2291
|
+
draggingRow,
|
|
2292
|
+
editingCell,
|
|
2293
|
+
editingRow,
|
|
2294
|
+
globalFilterFn,
|
|
2295
|
+
hoveredColumn,
|
|
2296
|
+
hoveredRow,
|
|
2790
2297
|
isFullScreen,
|
|
2791
2298
|
showAlertBanner,
|
|
2792
2299
|
showColumnFilters,
|
|
2793
|
-
showGlobalFilter }, props.state), tableId }))), {
|
|
2300
|
+
showGlobalFilter }, props.state), tableId }))), { setColumnFilterFns: (_v = props.onFilterFnsChange) !== null && _v !== void 0 ? _v : setColumnFilterFns, setDensity: (_w = props.onDensityChange) !== null && _w !== void 0 ? _w : setDensity, setDraggingColumn: (_x = props.onDraggingColumnChange) !== null && _x !== void 0 ? _x : setDraggingColumn, setDraggingRow: (_y = props.onDraggingRowChange) !== null && _y !== void 0 ? _y : setDraggingRow, setEditingCell: (_z = props.onEditingCellChange) !== null && _z !== void 0 ? _z : setEditingCell, setEditingRow: (_0 = props.onEditingRowChange) !== null && _0 !== void 0 ? _0 : setEditingRow, setGlobalFilterFn: (_1 = props.onGlobalFilterFnChange) !== null && _1 !== void 0 ? _1 : setGlobalFilterFn, setHoveredColumn: (_2 = props.onHoveredColumnChange) !== null && _2 !== void 0 ? _2 : setHoveredColumn, setHoveredRow: (_3 = props.onHoveredRowChange) !== null && _3 !== void 0 ? _3 : setHoveredRow, setIsFullScreen: (_4 = props.onIsFullScreenChange) !== null && _4 !== void 0 ? _4 : setIsFullScreen, setShowAlertBanner: (_5 = props.onShowAlertBannerChange) !== null && _5 !== void 0 ? _5 : setShowAlertBanner, setShowFilters: (_6 = props.onShowFiltersChange) !== null && _6 !== void 0 ? _6 : setShowFilters, setShowGlobalFilter: (_7 = props.onShowGlobalFilterChange) !== null && _7 !== void 0 ? _7 : setShowGlobalFilter });
|
|
2794
2301
|
return (React.createElement(React.Fragment, null,
|
|
2795
2302
|
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2796
2303
|
React.createElement(MRT_TablePaper, { table: table })),
|