material-react-table 0.23.5 → 0.25.0
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/MaterialReactTable.d.ts +61 -28
- package/dist/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/body/MRT_TableBodyRowGrabHandle.d.ts +9 -0
- package/dist/buttons/MRT_GrabHandleButton.d.ts +4 -2
- package/dist/head/MRT_TableHeadCellGrabHandle.d.ts +9 -0
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +334 -221
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +335 -222
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/utils.d.ts +3 -3
- package/package.json +3 -3
- package/src/MaterialReactTable.tsx +95 -35
- package/src/body/MRT_TableBodyCell.tsx +20 -4
- package/src/body/MRT_TableBodyRow.tsx +37 -3
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +48 -0
- package/src/buttons/MRT_GrabHandleButton.tsx +12 -8
- package/src/head/MRT_TableHeadCell.tsx +40 -57
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +77 -0
- package/src/inputs/MRT_FilterTextField.tsx +4 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +13 -18
- package/src/localization.ts +2 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +17 -16
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -3
- package/src/table/MRT_TableRoot.tsx +61 -25
- package/src/utils.ts +11 -9
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useMemo, useState, useCallback, Fragment, useLayoutEffect, useEffect } from 'react';
|
1
|
+
import React, { useMemo, useState, useCallback, Fragment, useRef, useLayoutEffect, useEffect } from 'react';
|
2
2
|
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';
|
3
3
|
import { filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
4
4
|
import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, TablePagination, Chip, Alert, AlertTitle, LinearProgress, useMediaQuery, Toolbar, lighten, alpha, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog } from '@mui/material';
|
@@ -73,6 +73,7 @@ var MRT_DefaultLocalization_EN = {
|
|
73
73
|
hideColumn: 'Hide {column} column',
|
74
74
|
max: 'Max',
|
75
75
|
min: 'Min',
|
76
|
+
move: 'Move',
|
76
77
|
pinToLeft: 'Pin to left',
|
77
78
|
pinToRight: 'Pin to right',
|
78
79
|
resetColumnSize: 'Reset column size',
|
@@ -414,8 +415,9 @@ var MRT_ColumnPinningButtons = function MRT_ColumnPinningButtons(_ref) {
|
|
414
415
|
};
|
415
416
|
|
416
417
|
var MRT_GrabHandleButton = function MRT_GrabHandleButton(_ref) {
|
417
|
-
var
|
418
|
-
|
418
|
+
var iconButtonProps = _ref.iconButtonProps,
|
419
|
+
onDragEnd = _ref.onDragEnd,
|
420
|
+
onDragStart = _ref.onDragStart,
|
419
421
|
table = _ref.table;
|
420
422
|
var _table$options = table.options,
|
421
423
|
DragHandleIcon = _table$options.icons.DragHandleIcon,
|
@@ -425,14 +427,15 @@ var MRT_GrabHandleButton = function MRT_GrabHandleButton(_ref) {
|
|
425
427
|
enterDelay: 1000,
|
426
428
|
enterNextDelay: 1000,
|
427
429
|
placement: "top",
|
428
|
-
title: localization.
|
429
|
-
}, React.createElement(IconButton, {
|
430
|
+
title: localization.move
|
431
|
+
}, React.createElement(IconButton, Object.assign({
|
430
432
|
disableRipple: true,
|
431
433
|
draggable: "true",
|
432
|
-
onDragStart:
|
433
|
-
onDragEnd:
|
434
|
-
size: "small"
|
435
|
-
|
434
|
+
onDragStart: onDragStart,
|
435
|
+
onDragEnd: onDragEnd,
|
436
|
+
size: "small"
|
437
|
+
}, iconButtonProps, {
|
438
|
+
sx: _extends({
|
436
439
|
cursor: 'grab',
|
437
440
|
m: 0,
|
438
441
|
opacity: 0.5,
|
@@ -445,8 +448,8 @@ var MRT_GrabHandleButton = function MRT_GrabHandleButton(_ref) {
|
|
445
448
|
'&:active': {
|
446
449
|
cursor: 'grabbing'
|
447
450
|
}
|
448
|
-
}
|
449
|
-
}, React.createElement(DragHandleIcon, null)));
|
451
|
+
}, iconButtonProps == null ? void 0 : iconButtonProps.sx)
|
452
|
+
}), React.createElement(DragHandleIcon, null)));
|
450
453
|
};
|
451
454
|
|
452
455
|
var fuzzy = function fuzzy(row, columnId, filterValue, addMeta) {
|
@@ -642,16 +645,16 @@ var prepareColumns = function prepareColumns(columnDefs, currentFilterFns) {
|
|
642
645
|
return columnDef;
|
643
646
|
});
|
644
647
|
};
|
645
|
-
var reorderColumn = function reorderColumn(
|
646
|
-
if (
|
647
|
-
|
648
|
+
var reorderColumn = function reorderColumn(draggedColumn, targetColumn, columnOrder) {
|
649
|
+
if (draggedColumn.getCanPin()) {
|
650
|
+
draggedColumn.pin(targetColumn.getIsPinned());
|
648
651
|
}
|
649
652
|
|
650
|
-
columnOrder.splice(columnOrder.indexOf(
|
653
|
+
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
651
654
|
return [].concat(columnOrder);
|
652
655
|
};
|
653
656
|
var getLeadingDisplayColumnIds = function getLeadingDisplayColumnIds(props) {
|
654
|
-
return [(props.positionActionsColumn === 'first' && props.enableRowActions || props.enableEditing && props.editingMode === 'row') && 'mrt-row-actions', (props.enableExpanding || props.enableGrouping || props.renderDetailPanel) && 'mrt-expand', props.enableRowSelection && 'mrt-select', props.enableRowNumbers && 'mrt-row-numbers'].filter(Boolean);
|
657
|
+
return [(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag', (props.positionActionsColumn === 'first' && props.enableRowActions || props.enableEditing && props.editingMode === 'row') && 'mrt-row-actions', (props.enableExpanding || props.enableGrouping || props.renderDetailPanel) && 'mrt-row-expand', props.enableRowSelection && 'mrt-row-select', props.enableRowNumbers && 'mrt-row-numbers'].filter(Boolean);
|
655
658
|
};
|
656
659
|
var getTrailingDisplayColumnIds = function getTrailingDisplayColumnIds(props) {
|
657
660
|
return [(props.positionActionsColumn === 'last' && props.enableRowActions || props.enableEditing && props.editingMode === 'row') && 'mrt-row-actions'];
|
@@ -727,7 +730,7 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
727
730
|
};
|
728
731
|
|
729
732
|
return React.createElement(React.Fragment, null, React.createElement(MenuItem, {
|
730
|
-
disableRipple:
|
733
|
+
disableRipple: true,
|
731
734
|
ref: menuItemRef,
|
732
735
|
onDragEnter: handleDragEnter,
|
733
736
|
sx: function sx(theme) {
|
@@ -750,8 +753,8 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
750
753
|
}, !isSubMenu && columnDefType !== 'group' && enableColumnOrdering && !allColumns.some(function (col) {
|
751
754
|
return col.columnDef.columnDefType === 'group';
|
752
755
|
}) && (columnDef.enableColumnOrdering !== false ? React.createElement(MRT_GrabHandleButton, {
|
753
|
-
|
754
|
-
|
756
|
+
onDragEnd: handleDragEnd,
|
757
|
+
onDragStart: handleDragStart,
|
755
758
|
table: table
|
756
759
|
}) : React.createElement(Box, {
|
757
760
|
sx: {
|
@@ -993,7 +996,7 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
993
996
|
var handleGroupByColumn = function handleGroupByColumn() {
|
994
997
|
column.toggleGrouping();
|
995
998
|
setColumnOrder(function (old) {
|
996
|
-
return ['mrt-expand'].concat(old);
|
999
|
+
return ['mrt-row-expand'].concat(old);
|
997
1000
|
});
|
998
1001
|
setAnchorEl(null);
|
999
1002
|
};
|
@@ -1138,8 +1141,8 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
1138
1141
|
sx: commonMenuItemStyles$1
|
1139
1142
|
}, React.createElement(Box, {
|
1140
1143
|
sx: commonListItemStyles
|
1141
|
-
}, React.createElement(ListItemIcon, null, React.createElement(PushPinIcon, null)), localization.unpin))], enableColumnResizing && [React.createElement(MenuItem, {
|
1142
|
-
disabled: !
|
1144
|
+
}, React.createElement(ListItemIcon, null, React.createElement(PushPinIcon, null)), localization.unpin))], enableColumnResizing && column.getCanResize() && [React.createElement(MenuItem, {
|
1145
|
+
disabled: !columnSizing[column.id],
|
1143
1146
|
key: 0,
|
1144
1147
|
onClick: handleResetColumnSize,
|
1145
1148
|
sx: commonMenuItemStyles$1
|
@@ -1355,19 +1358,7 @@ var MRT_SelectCheckbox = function MRT_SelectCheckbox(_ref) {
|
|
1355
1358
|
var _getState = getState(),
|
1356
1359
|
density = _getState.density;
|
1357
1360
|
|
1358
|
-
var
|
1359
|
-
if (selectAll) {
|
1360
|
-
if (selectAllMode === 'all') {
|
1361
|
-
table.getToggleAllRowsSelectedHandler()(event);
|
1362
|
-
} else if (selectAllMode === 'page') {
|
1363
|
-
table.getToggleAllPageRowsSelectedHandler()(event);
|
1364
|
-
}
|
1365
|
-
} else if (row) {
|
1366
|
-
row == null ? void 0 : row.getToggleSelectedHandler()(event);
|
1367
|
-
}
|
1368
|
-
};
|
1369
|
-
|
1370
|
-
var checkboxProps = selectAll ? muiSelectAllCheckboxProps instanceof Function ? muiSelectAllCheckboxProps({
|
1361
|
+
var checkboxProps = !row ? muiSelectAllCheckboxProps instanceof Function ? muiSelectAllCheckboxProps({
|
1371
1362
|
table: table
|
1372
1363
|
}) : muiSelectAllCheckboxProps : muiSelectCheckboxProps instanceof Function ? muiSelectCheckboxProps({
|
1373
1364
|
row: row,
|
@@ -1384,12 +1375,13 @@ var MRT_SelectCheckbox = function MRT_SelectCheckbox(_ref) {
|
|
1384
1375
|
inputProps: {
|
1385
1376
|
'aria-label': selectAll ? localization.toggleSelectAll : localization.toggleSelectRow
|
1386
1377
|
},
|
1387
|
-
onChange:
|
1378
|
+
onChange: !row ? selectAllMode === 'all' ? table.getToggleAllRowsSelectedHandler() : table.getToggleAllPageRowsSelectedHandler() : row.getToggleSelectedHandler(),
|
1388
1379
|
size: density === 'compact' ? 'small' : 'medium'
|
1389
1380
|
}, checkboxProps, {
|
1390
1381
|
sx: _extends({
|
1391
|
-
height: density === 'compact' ? '1.
|
1392
|
-
width: density === 'compact' ? '1.
|
1382
|
+
height: density === 'compact' ? '1.5rem' : '2rem',
|
1383
|
+
width: density === 'compact' ? '1.5rem' : '2rem',
|
1384
|
+
m: '-1re.m'
|
1393
1385
|
}, checkboxProps == null ? void 0 : checkboxProps.sx)
|
1394
1386
|
})));
|
1395
1387
|
};
|
@@ -1986,6 +1978,66 @@ var MRT_ToolbarBottom = function MRT_ToolbarBottom(_ref) {
|
|
1986
1978
|
}))));
|
1987
1979
|
};
|
1988
1980
|
|
1981
|
+
var MRT_TableHeadCellColumnActionsButton = function MRT_TableHeadCellColumnActionsButton(_ref) {
|
1982
|
+
var header = _ref.header,
|
1983
|
+
table = _ref.table;
|
1984
|
+
var _table$options = table.options,
|
1985
|
+
MoreVertIcon = _table$options.icons.MoreVertIcon,
|
1986
|
+
localization = _table$options.localization,
|
1987
|
+
muiTableHeadCellColumnActionsButtonProps = _table$options.muiTableHeadCellColumnActionsButtonProps;
|
1988
|
+
var column = header.column;
|
1989
|
+
var columnDef = column.columnDef;
|
1990
|
+
|
1991
|
+
var _useState = useState(null),
|
1992
|
+
anchorEl = _useState[0],
|
1993
|
+
setAnchorEl = _useState[1];
|
1994
|
+
|
1995
|
+
var handleClick = function handleClick(event) {
|
1996
|
+
event.stopPropagation();
|
1997
|
+
event.preventDefault();
|
1998
|
+
setAnchorEl(event.currentTarget);
|
1999
|
+
};
|
2000
|
+
|
2001
|
+
var mTableHeadCellColumnActionsButtonProps = muiTableHeadCellColumnActionsButtonProps instanceof Function ? muiTableHeadCellColumnActionsButtonProps({
|
2002
|
+
column: column,
|
2003
|
+
table: table
|
2004
|
+
}) : muiTableHeadCellColumnActionsButtonProps;
|
2005
|
+
var mcTableHeadCellColumnActionsButtonProps = columnDef.muiTableHeadCellColumnActionsButtonProps instanceof Function ? columnDef.muiTableHeadCellColumnActionsButtonProps({
|
2006
|
+
column: column,
|
2007
|
+
table: table
|
2008
|
+
}) : columnDef.muiTableHeadCellColumnActionsButtonProps;
|
2009
|
+
|
2010
|
+
var iconButtonProps = _extends({}, mTableHeadCellColumnActionsButtonProps, mcTableHeadCellColumnActionsButtonProps);
|
2011
|
+
|
2012
|
+
return React.createElement(React.Fragment, null, React.createElement(Tooltip, {
|
2013
|
+
arrow: true,
|
2014
|
+
enterDelay: 1000,
|
2015
|
+
enterNextDelay: 1000,
|
2016
|
+
placement: "top",
|
2017
|
+
title: localization.columnActions
|
2018
|
+
}, React.createElement(IconButton, Object.assign({
|
2019
|
+
"aria-label": localization.columnActions,
|
2020
|
+
onClick: handleClick,
|
2021
|
+
size: "small"
|
2022
|
+
}, iconButtonProps, {
|
2023
|
+
sx: _extends({
|
2024
|
+
height: '2rem',
|
2025
|
+
mt: '-0.2rem',
|
2026
|
+
opacity: 0.5,
|
2027
|
+
transition: 'opacity 0.2s',
|
2028
|
+
width: '2rem',
|
2029
|
+
'&:hover': {
|
2030
|
+
opacity: 1
|
2031
|
+
}
|
2032
|
+
}, iconButtonProps.sx)
|
2033
|
+
}), React.createElement(MoreVertIcon, null))), React.createElement(MRT_ColumnActionMenu, {
|
2034
|
+
anchorEl: anchorEl,
|
2035
|
+
header: header,
|
2036
|
+
setAnchorEl: setAnchorEl,
|
2037
|
+
table: table
|
2038
|
+
}));
|
2039
|
+
};
|
2040
|
+
|
1989
2041
|
var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
1990
2042
|
var _localization$filterB, _columnDef$enabledCol, _localization$clearFi, _columnDef$filterSele;
|
1991
2043
|
|
@@ -2033,16 +2085,16 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
2033
2085
|
setFilterValue = _useState2[1];
|
2034
2086
|
|
2035
2087
|
var handleChangeDebounced = useCallback(debounce(function (event) {
|
2088
|
+
var value = textFieldProps.type === 'date' ? new Date(event.target.value) : event.target.value;
|
2089
|
+
|
2036
2090
|
if (inputIndex !== undefined) {
|
2037
2091
|
column.setFilterValue(function (old) {
|
2038
2092
|
var newFilterValues = old != null ? old : ['', ''];
|
2039
|
-
newFilterValues[inputIndex] =
|
2093
|
+
newFilterValues[inputIndex] = value;
|
2040
2094
|
return newFilterValues;
|
2041
2095
|
});
|
2042
2096
|
} else {
|
2043
|
-
|
2044
|
-
|
2045
|
-
column.setFilterValue((_event$target$value = event.target.value) != null ? _event$target$value : undefined);
|
2097
|
+
column.setFilterValue(value != null ? value : undefined);
|
2046
2098
|
}
|
2047
2099
|
}, 200), []);
|
2048
2100
|
|
@@ -2284,6 +2336,64 @@ var MRT_TableHeadCellFilterLabel = function MRT_TableHeadCellFilterLabel(_ref) {
|
|
2284
2336
|
}, React.createElement(FilterAltIcon, null)))));
|
2285
2337
|
};
|
2286
2338
|
|
2339
|
+
var MRT_TableHeadCellGrabHandle = function MRT_TableHeadCellGrabHandle(_ref) {
|
2340
|
+
var column = _ref.column,
|
2341
|
+
table = _ref.table,
|
2342
|
+
tableHeadCellRef = _ref.tableHeadCellRef;
|
2343
|
+
var getState = table.getState,
|
2344
|
+
_table$options = table.options,
|
2345
|
+
enableColumnOrdering = _table$options.enableColumnOrdering,
|
2346
|
+
muiTableHeadCellDragHandleProps = _table$options.muiTableHeadCellDragHandleProps,
|
2347
|
+
onColumnDrop = _table$options.onColumnDrop,
|
2348
|
+
setColumnOrder = table.setColumnOrder,
|
2349
|
+
setCurrentDraggingColumn = table.setCurrentDraggingColumn,
|
2350
|
+
setCurrentHoveredColumn = table.setCurrentHoveredColumn;
|
2351
|
+
var columnDef = column.columnDef;
|
2352
|
+
|
2353
|
+
var _getState = getState(),
|
2354
|
+
currentHoveredColumn = _getState.currentHoveredColumn,
|
2355
|
+
currentDraggingColumn = _getState.currentDraggingColumn,
|
2356
|
+
columnOrder = _getState.columnOrder;
|
2357
|
+
|
2358
|
+
var mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function ? muiTableHeadCellDragHandleProps({
|
2359
|
+
column: column,
|
2360
|
+
table: table
|
2361
|
+
}) : muiTableHeadCellDragHandleProps;
|
2362
|
+
var mcIconButtonProps = columnDef.muiTableHeadCellDragHandleProps instanceof Function ? columnDef.muiTableHeadCellDragHandleProps({
|
2363
|
+
column: column,
|
2364
|
+
table: table
|
2365
|
+
}) : columnDef.muiTableHeadCellDragHandleProps;
|
2366
|
+
|
2367
|
+
var iconButtonProps = _extends({}, mIconButtonProps, mcIconButtonProps);
|
2368
|
+
|
2369
|
+
var handleDragStart = function handleDragStart(e) {
|
2370
|
+
setCurrentDraggingColumn(column);
|
2371
|
+
e.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
2372
|
+
};
|
2373
|
+
|
2374
|
+
var handleDragEnd = function handleDragEnd(event) {
|
2375
|
+
onColumnDrop == null ? void 0 : onColumnDrop({
|
2376
|
+
event: event,
|
2377
|
+
draggedColumn: column,
|
2378
|
+
targetColumn: currentHoveredColumn
|
2379
|
+
});
|
2380
|
+
|
2381
|
+
if (enableColumnOrdering && currentHoveredColumn && (currentHoveredColumn == null ? void 0 : currentHoveredColumn.id) !== (currentDraggingColumn == null ? void 0 : currentDraggingColumn.id)) {
|
2382
|
+
setColumnOrder(reorderColumn(column, currentHoveredColumn, columnOrder));
|
2383
|
+
}
|
2384
|
+
|
2385
|
+
setCurrentDraggingColumn(null);
|
2386
|
+
setCurrentHoveredColumn(null);
|
2387
|
+
};
|
2388
|
+
|
2389
|
+
return React.createElement(MRT_GrabHandleButton, {
|
2390
|
+
iconButtonProps: iconButtonProps,
|
2391
|
+
onDragStart: handleDragStart,
|
2392
|
+
onDragEnd: handleDragEnd,
|
2393
|
+
table: table
|
2394
|
+
});
|
2395
|
+
};
|
2396
|
+
|
2287
2397
|
var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref) {
|
2288
2398
|
var _getState$columnSizin;
|
2289
2399
|
|
@@ -2355,66 +2465,6 @@ var MRT_TableHeadCellSortLabel = function MRT_TableHeadCellSortLabel(_ref) {
|
|
2355
2465
|
}));
|
2356
2466
|
};
|
2357
2467
|
|
2358
|
-
var MRT_TableHeadCellColumnActionsButton = function MRT_TableHeadCellColumnActionsButton(_ref) {
|
2359
|
-
var header = _ref.header,
|
2360
|
-
table = _ref.table;
|
2361
|
-
var _table$options = table.options,
|
2362
|
-
MoreVertIcon = _table$options.icons.MoreVertIcon,
|
2363
|
-
localization = _table$options.localization,
|
2364
|
-
muiTableHeadCellColumnActionsButtonProps = _table$options.muiTableHeadCellColumnActionsButtonProps;
|
2365
|
-
var column = header.column;
|
2366
|
-
var columnDef = column.columnDef;
|
2367
|
-
|
2368
|
-
var _useState = useState(null),
|
2369
|
-
anchorEl = _useState[0],
|
2370
|
-
setAnchorEl = _useState[1];
|
2371
|
-
|
2372
|
-
var handleClick = function handleClick(event) {
|
2373
|
-
event.stopPropagation();
|
2374
|
-
event.preventDefault();
|
2375
|
-
setAnchorEl(event.currentTarget);
|
2376
|
-
};
|
2377
|
-
|
2378
|
-
var mTableHeadCellColumnActionsButtonProps = muiTableHeadCellColumnActionsButtonProps instanceof Function ? muiTableHeadCellColumnActionsButtonProps({
|
2379
|
-
column: column,
|
2380
|
-
table: table
|
2381
|
-
}) : muiTableHeadCellColumnActionsButtonProps;
|
2382
|
-
var mcTableHeadCellColumnActionsButtonProps = columnDef.muiTableHeadCellColumnActionsButtonProps instanceof Function ? columnDef.muiTableHeadCellColumnActionsButtonProps({
|
2383
|
-
column: column,
|
2384
|
-
table: table
|
2385
|
-
}) : columnDef.muiTableHeadCellColumnActionsButtonProps;
|
2386
|
-
|
2387
|
-
var iconButtonProps = _extends({}, mTableHeadCellColumnActionsButtonProps, mcTableHeadCellColumnActionsButtonProps);
|
2388
|
-
|
2389
|
-
return React.createElement(React.Fragment, null, React.createElement(Tooltip, {
|
2390
|
-
arrow: true,
|
2391
|
-
enterDelay: 1000,
|
2392
|
-
enterNextDelay: 1000,
|
2393
|
-
placement: "top",
|
2394
|
-
title: localization.columnActions
|
2395
|
-
}, React.createElement(IconButton, Object.assign({
|
2396
|
-
"aria-label": localization.columnActions,
|
2397
|
-
onClick: handleClick,
|
2398
|
-
size: "small"
|
2399
|
-
}, iconButtonProps, {
|
2400
|
-
sx: _extends({
|
2401
|
-
height: '2rem',
|
2402
|
-
mt: '-0.2rem',
|
2403
|
-
opacity: 0.5,
|
2404
|
-
transition: 'opacity 0.2s',
|
2405
|
-
width: '2rem',
|
2406
|
-
'&:hover': {
|
2407
|
-
opacity: 1
|
2408
|
-
}
|
2409
|
-
}, iconButtonProps.sx)
|
2410
|
-
}), React.createElement(MoreVertIcon, null))), React.createElement(MRT_ColumnActionMenu, {
|
2411
|
-
anchorEl: anchorEl,
|
2412
|
-
header: header,
|
2413
|
-
setAnchorEl: setAnchorEl,
|
2414
|
-
table: table
|
2415
|
-
}));
|
2416
|
-
};
|
2417
|
-
|
2418
2468
|
var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
2419
2469
|
var _ref2, _columnDef$header$len, _columnDef$header;
|
2420
2470
|
|
@@ -2424,17 +2474,15 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
2424
2474
|
var getState = table.getState,
|
2425
2475
|
_table$options = table.options,
|
2426
2476
|
enableColumnActions = _table$options.enableColumnActions,
|
2477
|
+
enableColumnDragging = _table$options.enableColumnDragging,
|
2427
2478
|
enableColumnOrdering = _table$options.enableColumnOrdering,
|
2428
2479
|
enableColumnResizing = _table$options.enableColumnResizing,
|
2429
2480
|
enableGrouping = _table$options.enableGrouping,
|
2430
2481
|
enableMultiSort = _table$options.enableMultiSort,
|
2431
2482
|
muiTableHeadCellProps = _table$options.muiTableHeadCellProps,
|
2432
|
-
setColumnOrder = table.setColumnOrder,
|
2433
|
-
setCurrentDraggingColumn = table.setCurrentDraggingColumn,
|
2434
2483
|
setCurrentHoveredColumn = table.setCurrentHoveredColumn;
|
2435
2484
|
|
2436
2485
|
var _getState = getState(),
|
2437
|
-
columnOrder = _getState.columnOrder,
|
2438
2486
|
density = _getState.density,
|
2439
2487
|
currentDraggingColumn = _getState.currentDraggingColumn,
|
2440
2488
|
currentHoveredColumn = _getState.currentHoveredColumn;
|
@@ -2453,11 +2501,6 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
2453
2501
|
|
2454
2502
|
var tableCellProps = _extends({}, mTableHeadCellProps, mcTableHeadCellProps);
|
2455
2503
|
|
2456
|
-
var headerElement = (_ref2 = (columnDef == null ? void 0 : columnDef.Header) instanceof Function ? columnDef == null ? void 0 : columnDef.Header == null ? void 0 : columnDef.Header({
|
2457
|
-
header: header,
|
2458
|
-
table: table
|
2459
|
-
}) : columnDef == null ? void 0 : columnDef.Header) != null ? _ref2 : columnDef.header;
|
2460
|
-
|
2461
2504
|
var getIsLastLeftPinnedColumn = function getIsLastLeftPinnedColumn() {
|
2462
2505
|
return column.getIsPinned() === 'left' && table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex();
|
2463
2506
|
};
|
@@ -2470,25 +2513,9 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
2470
2513
|
return (table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150;
|
2471
2514
|
};
|
2472
2515
|
|
2473
|
-
var tableHeadCellRef = React.useRef(null);
|
2474
|
-
|
2475
|
-
var handleDragStart = function handleDragStart(e) {
|
2476
|
-
setCurrentDraggingColumn(column);
|
2477
|
-
e.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
2478
|
-
};
|
2479
|
-
|
2480
|
-
var handleDragEnd = function handleDragEnd(_e) {
|
2481
|
-
setCurrentDraggingColumn(null);
|
2482
|
-
setCurrentHoveredColumn(null);
|
2483
|
-
|
2484
|
-
if (currentHoveredColumn && (currentHoveredColumn == null ? void 0 : currentHoveredColumn.id) !== (currentDraggingColumn == null ? void 0 : currentDraggingColumn.id)) {
|
2485
|
-
setColumnOrder(reorderColumn(column, currentHoveredColumn, columnOrder));
|
2486
|
-
}
|
2487
|
-
};
|
2488
|
-
|
2489
2516
|
var handleDragEnter = function handleDragEnter(_e) {
|
2490
|
-
if (currentDraggingColumn) {
|
2491
|
-
setCurrentHoveredColumn(
|
2517
|
+
if (enableColumnOrdering && currentDraggingColumn) {
|
2518
|
+
setCurrentHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
2492
2519
|
}
|
2493
2520
|
};
|
2494
2521
|
|
@@ -2498,6 +2525,11 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
2498
2525
|
borderRight: draggingBorder,
|
2499
2526
|
borderTop: draggingBorder
|
2500
2527
|
} : undefined;
|
2528
|
+
var headerElement = (_ref2 = (columnDef == null ? void 0 : columnDef.Header) instanceof Function ? columnDef == null ? void 0 : columnDef.Header == null ? void 0 : columnDef.Header({
|
2529
|
+
header: header,
|
2530
|
+
table: table
|
2531
|
+
}) : columnDef == null ? void 0 : columnDef.Header) != null ? _ref2 : columnDef.header;
|
2532
|
+
var tableHeadCellRef = React.useRef(null);
|
2501
2533
|
return React.createElement(TableCell, Object.assign({
|
2502
2534
|
align: columnDefType === 'group' ? 'center' : 'left',
|
2503
2535
|
colSpan: header.colSpan,
|
@@ -2522,7 +2554,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
2522
2554
|
right: column.getIsPinned() === 'right' ? getTotalRight() + "px" : undefined,
|
2523
2555
|
transition: "all " + (enableColumnResizing ? 0 : '0.2s') + " ease-in-out",
|
2524
2556
|
userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined,
|
2525
|
-
verticalAlign: '
|
2557
|
+
verticalAlign: 'top',
|
2526
2558
|
zIndex: column.getIsResizing() || (currentDraggingColumn == null ? void 0 : currentDraggingColumn.id) === column.id ? 3 : column.getIsPinned() && columnDefType !== 'group' ? 2 : 1
|
2527
2559
|
}, tableCellProps == null ? void 0 : tableCellProps.sx, draggingBorders, {
|
2528
2560
|
maxWidth: "min(" + column.getSize() + "px, fit-content)",
|
@@ -2530,7 +2562,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
2530
2562
|
width: header.getSize()
|
2531
2563
|
});
|
2532
2564
|
}
|
2533
|
-
}), header.isPlaceholder ? null :
|
2565
|
+
}), header.isPlaceholder ? null : React.createElement(Box, {
|
2534
2566
|
sx: {
|
2535
2567
|
alignItems: 'flex-start',
|
2536
2568
|
display: 'flex',
|
@@ -2547,27 +2579,27 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
2547
2579
|
flexWrap: 'nowrap',
|
2548
2580
|
whiteSpace: ((_columnDef$header$len = (_columnDef$header = columnDef.header) == null ? void 0 : _columnDef$header.length) != null ? _columnDef$header$len : 0) < 24 ? 'nowrap' : 'normal'
|
2549
2581
|
}
|
2550
|
-
}, headerElement,
|
2582
|
+
}, headerElement, column.getCanSort() && React.createElement(MRT_TableHeadCellSortLabel, {
|
2551
2583
|
header: header,
|
2552
2584
|
table: table
|
2553
|
-
}),
|
2585
|
+
}), column.getCanFilter() && React.createElement(MRT_TableHeadCellFilterLabel, {
|
2554
2586
|
header: header,
|
2555
2587
|
table: table
|
2556
|
-
})), React.createElement(Box, {
|
2588
|
+
})), columnDefType !== 'group' && React.createElement(Box, {
|
2557
2589
|
sx: {
|
2558
2590
|
whiteSpace: 'nowrap'
|
2559
2591
|
}
|
2560
|
-
},
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
}), (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false &&
|
2592
|
+
}, (enableColumnDragging && columnDef.enableColumnDragging !== false || enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React.createElement(MRT_TableHeadCellGrabHandle, {
|
2593
|
+
column: column,
|
2594
|
+
table: table,
|
2595
|
+
tableHeadCellRef: tableHeadCellRef
|
2596
|
+
}), (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false && React.createElement(MRT_TableHeadCellColumnActionsButton, {
|
2565
2597
|
header: header,
|
2566
2598
|
table: table
|
2567
2599
|
})), column.getCanResize() && React.createElement(MRT_TableHeadCellResizeHandle, {
|
2568
2600
|
header: header,
|
2569
2601
|
table: table
|
2570
|
-
})),
|
2602
|
+
})), column.getCanFilter() && React.createElement(MRT_TableHeadCellFilterContainer, {
|
2571
2603
|
header: header,
|
2572
2604
|
table: table
|
2573
2605
|
}));
|
@@ -2762,18 +2794,55 @@ var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
2762
2794
|
}), children));
|
2763
2795
|
};
|
2764
2796
|
|
2797
|
+
var MRT_TableBodyRowGrabHandle = function MRT_TableBodyRowGrabHandle(_ref) {
|
2798
|
+
var cell = _ref.cell,
|
2799
|
+
rowRef = _ref.rowRef,
|
2800
|
+
table = _ref.table;
|
2801
|
+
var _table$options = table.options,
|
2802
|
+
muiTableBodyRowDragHandleProps = _table$options.muiTableBodyRowDragHandleProps,
|
2803
|
+
onRowDrop = _table$options.onRowDrop;
|
2804
|
+
var iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function ? muiTableBodyRowDragHandleProps({
|
2805
|
+
row: cell.row,
|
2806
|
+
table: table
|
2807
|
+
}) : muiTableBodyRowDragHandleProps;
|
2808
|
+
|
2809
|
+
var handleDragStart = function handleDragStart(e) {
|
2810
|
+
e.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
2811
|
+
table.setCurrentDraggingRow(cell.row);
|
2812
|
+
};
|
2813
|
+
|
2814
|
+
var handleDragEnd = function handleDragEnd(event) {
|
2815
|
+
onRowDrop == null ? void 0 : onRowDrop({
|
2816
|
+
event: event,
|
2817
|
+
draggedRow: table.getState().currentDraggingRow,
|
2818
|
+
targetRow: table.getState().currentHoveredRow
|
2819
|
+
});
|
2820
|
+
table.setCurrentDraggingRow(null);
|
2821
|
+
table.setCurrentHoveredRow(null);
|
2822
|
+
};
|
2823
|
+
|
2824
|
+
return React.createElement(MRT_GrabHandleButton, {
|
2825
|
+
iconButtonProps: iconButtonProps,
|
2826
|
+
onDragStart: handleDragStart,
|
2827
|
+
onDragEnd: handleDragEnd,
|
2828
|
+
table: table
|
2829
|
+
});
|
2830
|
+
};
|
2831
|
+
|
2765
2832
|
var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
2766
2833
|
var _columnDef$Cell, _row$subRows, _columnDef$Cell2, _row$subRows$length, _row$subRows2;
|
2767
2834
|
|
2768
2835
|
var cell = _ref.cell,
|
2769
2836
|
enableHover = _ref.enableHover,
|
2770
2837
|
rowIndex = _ref.rowIndex,
|
2838
|
+
rowRef = _ref.rowRef,
|
2771
2839
|
table = _ref.table;
|
2772
2840
|
var theme = useTheme();
|
2773
2841
|
var getState = table.getState,
|
2774
2842
|
_table$options = table.options,
|
2775
2843
|
editingMode = _table$options.editingMode,
|
2776
2844
|
enableClickToCopy = _table$options.enableClickToCopy,
|
2845
|
+
enableColumnOrdering = _table$options.enableColumnOrdering,
|
2777
2846
|
enableEditing = _table$options.enableEditing,
|
2778
2847
|
enableRowNumbers = _table$options.enableRowNumbers,
|
2779
2848
|
muiTableBodyCellProps = _table$options.muiTableBodyCellProps,
|
@@ -2840,15 +2909,16 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
2840
2909
|
};
|
2841
2910
|
|
2842
2911
|
var handleDragEnter = function handleDragEnter(_e) {
|
2843
|
-
if (currentDraggingColumn) {
|
2844
|
-
setCurrentHoveredColumn(
|
2912
|
+
if (enableColumnOrdering && currentDraggingColumn) {
|
2913
|
+
setCurrentHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
2845
2914
|
}
|
2846
2915
|
};
|
2847
2916
|
|
2848
2917
|
var draggingBorder = (currentDraggingColumn == null ? void 0 : currentDraggingColumn.id) === column.id ? "1px dashed " + theme.palette.divider : (currentHoveredColumn == null ? void 0 : currentHoveredColumn.id) === column.id ? "2px dashed " + theme.palette.primary.main : undefined;
|
2849
2918
|
var draggingBorders = draggingBorder ? {
|
2850
2919
|
borderLeft: draggingBorder,
|
2851
|
-
borderRight: draggingBorder
|
2920
|
+
borderRight: draggingBorder,
|
2921
|
+
borderBottom: row.index === table.getRowModel().rows.length - 1 ? draggingBorder : undefined
|
2852
2922
|
} : undefined;
|
2853
2923
|
return React.createElement(TableCell, Object.assign({
|
2854
2924
|
onDoubleClick: handleDoubleClick,
|
@@ -2865,7 +2935,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
2865
2935
|
opacity: (currentDraggingColumn == null ? void 0 : currentDraggingColumn.id) === column.id || (currentHoveredColumn == null ? void 0 : currentHoveredColumn.id) === column.id ? 0.5 : 1,
|
2866
2936
|
overflow: 'hidden',
|
2867
2937
|
p: density === 'compact' ? columnDefType === 'display' ? '0 0.5rem' : '0.5rem' : density === 'comfortable' ? columnDefType === 'display' ? '0.5rem 0.75rem' : '1rem' : columnDefType === 'display' ? '1rem 1.25rem' : '1.5rem',
|
2868
|
-
pl: column.id === 'mrt-expand' ? row.depth + (density === 'compact' ? 0.5 : density === 'comfortable' ? 0.75 : 1.25) + "rem" : undefined,
|
2938
|
+
pl: column.id === 'mrt-row-expand' ? row.depth + (density === 'compact' ? 0.5 : density === 'comfortable' ? 0.75 : 1.25) + "rem" : undefined,
|
2869
2939
|
position: column.getIsPinned() ? 'sticky' : 'relative',
|
2870
2940
|
right: column.getIsPinned() === 'right' ? getTotalRight() + "px" : undefined,
|
2871
2941
|
textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined,
|
@@ -2885,7 +2955,11 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
2885
2955
|
animation: "wave",
|
2886
2956
|
height: 20,
|
2887
2957
|
width: skeletonWidth
|
2888
|
-
}, muiTableBodyCellSkeletonProps)) : enableRowNumbers && rowNumberMode === 'static' && column.id === 'mrt-row-numbers' ? rowIndex + 1 :
|
2958
|
+
}, muiTableBodyCellSkeletonProps)) : enableRowNumbers && rowNumberMode === 'static' && column.id === 'mrt-row-numbers' ? rowIndex + 1 : column.id === 'mrt-row-drag' ? React.createElement(MRT_TableBodyRowGrabHandle, {
|
2959
|
+
cell: cell,
|
2960
|
+
rowRef: rowRef,
|
2961
|
+
table: table
|
2962
|
+
}) : columnDefType === 'display' ? columnDef.Cell == null ? void 0 : columnDef.Cell({
|
2889
2963
|
cell: cell,
|
2890
2964
|
table: table
|
2891
2965
|
}) : isEditing ? React.createElement(MRT_EditCellTextField, {
|
@@ -2943,26 +3017,50 @@ var MRT_TableBodyRow = function MRT_TableBodyRow(_ref) {
|
|
2943
3017
|
var row = _ref.row,
|
2944
3018
|
rowIndex = _ref.rowIndex,
|
2945
3019
|
table = _ref.table;
|
3020
|
+
var theme = useTheme();
|
2946
3021
|
var getIsSomeColumnsPinned = table.getIsSomeColumnsPinned,
|
3022
|
+
getState = table.getState,
|
2947
3023
|
_table$options = table.options,
|
3024
|
+
enableRowOrdering = _table$options.enableRowOrdering,
|
2948
3025
|
muiTableBodyRowProps = _table$options.muiTableBodyRowProps,
|
2949
|
-
renderDetailPanel = _table$options.renderDetailPanel
|
3026
|
+
renderDetailPanel = _table$options.renderDetailPanel,
|
3027
|
+
setCurrentHoveredRow = table.setCurrentHoveredRow;
|
3028
|
+
|
3029
|
+
var _getState = getState(),
|
3030
|
+
currentDraggingRow = _getState.currentDraggingRow,
|
3031
|
+
currentHoveredRow = _getState.currentHoveredRow;
|
3032
|
+
|
2950
3033
|
var tableRowProps = muiTableBodyRowProps instanceof Function ? muiTableBodyRowProps({
|
2951
3034
|
row: row,
|
2952
3035
|
table: table
|
2953
3036
|
}) : muiTableBodyRowProps;
|
3037
|
+
|
3038
|
+
var handleDragEnter = function handleDragEnter(_e) {
|
3039
|
+
if (enableRowOrdering && currentDraggingRow) {
|
3040
|
+
setCurrentHoveredRow(row);
|
3041
|
+
}
|
3042
|
+
};
|
3043
|
+
|
3044
|
+
var rowRef = useRef(null);
|
3045
|
+
var draggingBorder = (currentDraggingRow == null ? void 0 : currentDraggingRow.id) === row.id ? "1px dashed " + theme.palette.divider : (currentHoveredRow == null ? void 0 : currentHoveredRow.id) === row.id ? "2px dashed " + theme.palette.primary.main : undefined;
|
3046
|
+
var draggingBorders = draggingBorder ? {
|
3047
|
+
border: draggingBorder
|
3048
|
+
} : undefined;
|
2954
3049
|
return React.createElement(React.Fragment, null, React.createElement(TableRow, Object.assign({
|
3050
|
+
onDragEnter: handleDragEnter,
|
2955
3051
|
hover: true,
|
2956
|
-
selected: row.getIsSelected()
|
3052
|
+
selected: row.getIsSelected(),
|
3053
|
+
ref: rowRef
|
2957
3054
|
}, tableRowProps, {
|
2958
3055
|
sx: function sx(theme) {
|
2959
3056
|
return _extends({
|
2960
3057
|
backgroundColor: lighten(theme.palette.background["default"], 0.06),
|
3058
|
+
opacity: (currentDraggingRow == null ? void 0 : currentDraggingRow.id) === row.id || (currentHoveredRow == null ? void 0 : currentHoveredRow.id) === row.id ? 0.5 : 1,
|
2961
3059
|
transition: 'all 0.2s ease-in-out',
|
2962
3060
|
'&:hover td': {
|
2963
3061
|
backgroundColor: (tableRowProps == null ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned() ? theme.palette.mode === 'dark' ? "" + lighten(theme.palette.background["default"], 0.12) : "" + darken(theme.palette.background["default"], 0.05) : undefined
|
2964
3062
|
}
|
2965
|
-
}, tableRowProps == null ? void 0 : tableRowProps.sx);
|
3063
|
+
}, tableRowProps == null ? void 0 : tableRowProps.sx, draggingBorders);
|
2966
3064
|
}
|
2967
3065
|
}), row == null ? void 0 : (_row$getVisibleCells = row.getVisibleCells()) == null ? void 0 : _row$getVisibleCells.map == null ? void 0 : _row$getVisibleCells.map(function (cell) {
|
2968
3066
|
return React.createElement(MRT_TableBodyCell, {
|
@@ -2970,6 +3068,7 @@ var MRT_TableBodyRow = function MRT_TableBodyRow(_ref) {
|
|
2970
3068
|
key: cell.id,
|
2971
3069
|
enableHover: (tableRowProps == null ? void 0 : tableRowProps.hover) !== false,
|
2972
3070
|
rowIndex: rowIndex,
|
3071
|
+
rowRef: rowRef,
|
2973
3072
|
table: table
|
2974
3073
|
});
|
2975
3074
|
})), renderDetailPanel && !row.getIsGrouped() && React.createElement(MRT_TableDetailPanel, {
|
@@ -3269,8 +3368,23 @@ var MRT_TablePaper = function MRT_TablePaper(_ref) {
|
|
3269
3368
|
}));
|
3270
3369
|
};
|
3271
3370
|
|
3371
|
+
var defaultDisplayColumnDefOptions = {
|
3372
|
+
columnDefType: 'display',
|
3373
|
+
enableClickToCopy: false,
|
3374
|
+
enableColumnActions: false,
|
3375
|
+
enableColumnDragging: false,
|
3376
|
+
enableColumnFilter: false,
|
3377
|
+
enableColumnOrdering: false,
|
3378
|
+
enableEditing: false,
|
3379
|
+
enableGlobalFilter: false,
|
3380
|
+
enableGrouping: false,
|
3381
|
+
enableHiding: false,
|
3382
|
+
enablePinning: false,
|
3383
|
+
enableResizing: false,
|
3384
|
+
enableSorting: false
|
3385
|
+
};
|
3272
3386
|
var MRT_TableRoot = function MRT_TableRoot(props) {
|
3273
|
-
var _initialState$columnO, _initialState$current, _initialState$current2, _initialState$density, _initialState$isFullS, _props$initialState$s, _props$initialState2, _initialState$showCol, _initialState$showGlo, _props$state3, _props$state4, _MRT_FilterFns$curren, _props$onCurrentDragg, _props$onCurrentEditi, _props$onCurrentEditi2, _props$onCurrentFilte, _props$onCurrentGloba, _props$onCurrentHover, _props$onDensityChang, _props$onIsFullScreen, _props$onShowAlertBan, _props$onShowFiltersC, _props$onShowGlobalFi;
|
3387
|
+
var _initialState$columnO, _initialState$current, _initialState$current2, _initialState$current3, _initialState$current4, _initialState$current5, _initialState$current6, _initialState$density, _initialState$isFullS, _props$initialState$s, _props$initialState2, _initialState$showCol, _initialState$showGlo, _props$state3, _props$state4, _MRT_FilterFns$curren, _props$onCurrentDragg, _props$onCurrentDragg2, _props$onCurrentEditi, _props$onCurrentEditi2, _props$onCurrentFilte, _props$onCurrentGloba, _props$onCurrentHover, _props$onCurrentHover2, _props$onDensityChang, _props$onIsFullScreen, _props$onShowAlertBan, _props$onShowFiltersC, _props$onShowGlobalFi;
|
3274
3388
|
|
3275
3389
|
var _useState = useState(props.tableId),
|
3276
3390
|
tableId = _useState[0],
|
@@ -3293,60 +3407,73 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
3293
3407
|
columnOrder = _useState2[0],
|
3294
3408
|
setColumnOrder = _useState2[1];
|
3295
3409
|
|
3296
|
-
var _useState3 = useState((_initialState$current = initialState
|
3297
|
-
|
3298
|
-
|
3410
|
+
var _useState3 = useState((_initialState$current = initialState.currentDraggingColumn) != null ? _initialState$current : null),
|
3411
|
+
currentDraggingColumn = _useState3[0],
|
3412
|
+
setCurrentDraggingColumn = _useState3[1];
|
3299
3413
|
|
3300
|
-
var _useState4 = useState((_initialState$current2 = initialState
|
3301
|
-
|
3302
|
-
|
3414
|
+
var _useState4 = useState((_initialState$current2 = initialState.currentDraggingRow) != null ? _initialState$current2 : null),
|
3415
|
+
currentDraggingRow = _useState4[0],
|
3416
|
+
setCurrentDraggingRow = _useState4[1];
|
3303
3417
|
|
3304
|
-
var _useState5 = useState(null),
|
3305
|
-
|
3306
|
-
|
3418
|
+
var _useState5 = useState((_initialState$current3 = initialState.currentEditingCell) != null ? _initialState$current3 : null),
|
3419
|
+
currentEditingCell = _useState5[0],
|
3420
|
+
setCurrentEditingCell = _useState5[1];
|
3307
3421
|
|
3308
|
-
var _useState6 = useState(null),
|
3309
|
-
|
3310
|
-
|
3422
|
+
var _useState6 = useState((_initialState$current4 = initialState.currentEditingRow) != null ? _initialState$current4 : null),
|
3423
|
+
currentEditingRow = _useState6[0],
|
3424
|
+
setCurrentEditingRow = _useState6[1];
|
3311
3425
|
|
3312
|
-
var _useState7 = useState((_initialState$
|
3313
|
-
|
3314
|
-
|
3426
|
+
var _useState7 = useState((_initialState$current5 = initialState.currentHoveredColumn) != null ? _initialState$current5 : null),
|
3427
|
+
currentHoveredColumn = _useState7[0],
|
3428
|
+
setCurrentHoveredColumn = _useState7[1];
|
3315
3429
|
|
3316
|
-
var _useState8 = useState((_initialState$
|
3317
|
-
|
3318
|
-
|
3430
|
+
var _useState8 = useState((_initialState$current6 = initialState.currentHoveredRow) != null ? _initialState$current6 : null),
|
3431
|
+
currentHoveredRow = _useState8[0],
|
3432
|
+
setCurrentHoveredRow = _useState8[1];
|
3319
3433
|
|
3320
|
-
var _useState9 = useState((
|
3321
|
-
|
3322
|
-
|
3434
|
+
var _useState9 = useState((_initialState$density = initialState == null ? void 0 : initialState.density) != null ? _initialState$density : 'comfortable'),
|
3435
|
+
density = _useState9[0],
|
3436
|
+
setDensity = _useState9[1];
|
3323
3437
|
|
3324
|
-
var _useState10 = useState((_initialState$
|
3325
|
-
|
3326
|
-
|
3438
|
+
var _useState10 = useState((_initialState$isFullS = initialState == null ? void 0 : initialState.isFullScreen) != null ? _initialState$isFullS : false),
|
3439
|
+
isFullScreen = _useState10[0],
|
3440
|
+
setIsFullScreen = _useState10[1];
|
3327
3441
|
|
3328
|
-
var _useState11 = useState((
|
3329
|
-
|
3330
|
-
|
3442
|
+
var _useState11 = useState((_props$initialState$s = (_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.showAlertBanner) != null ? _props$initialState$s : false),
|
3443
|
+
showAlertBanner = _useState11[0],
|
3444
|
+
setShowAlertBanner = _useState11[1];
|
3331
3445
|
|
3332
|
-
var _useState12 = useState(
|
3446
|
+
var _useState12 = useState((_initialState$showCol = initialState == null ? void 0 : initialState.showColumnFilters) != null ? _initialState$showCol : false),
|
3447
|
+
showColumnFilters = _useState12[0],
|
3448
|
+
setShowFilters = _useState12[1];
|
3449
|
+
|
3450
|
+
var _useState13 = useState((_initialState$showGlo = initialState == null ? void 0 : initialState.showGlobalFilter) != null ? _initialState$showGlo : false),
|
3451
|
+
showGlobalFilter = _useState13[0],
|
3452
|
+
setShowGlobalFilter = _useState13[1];
|
3453
|
+
|
3454
|
+
var _useState14 = useState(function () {
|
3333
3455
|
return Object.assign.apply(Object, [{}].concat(getAllLeafColumnDefs(props.columns).map(function (col) {
|
3334
|
-
var _ref, _col$id$toString, _col$id, _col$accessorKey, _col$filterFn$name, _ref2, _col$filterFn, _initialState$
|
3456
|
+
var _ref, _col$id$toString, _col$id, _col$accessorKey, _col$filterFn$name, _ref2, _col$filterFn, _initialState$current7, _ref3, _col$id$toString2, _col$id2, _col$accessorKey2, _col$filterSelectOpti, _ref4;
|
3335
3457
|
|
3336
|
-
return _ref4 = {}, _ref4[(_ref = (_col$id$toString = (_col$id = col.id) == null ? void 0 : _col$id.toString()) != null ? _col$id$toString : (_col$accessorKey = col.accessorKey) == null ? void 0 : _col$accessorKey.toString()) != null ? _ref : ''] = col.filterFn instanceof Function ? (_col$filterFn$name = col.filterFn.name) != null ? _col$filterFn$name : 'custom' : (_ref2 = (_col$filterFn = col.filterFn) != null ? _col$filterFn : initialState == null ? void 0 : (_initialState$
|
3458
|
+
return _ref4 = {}, _ref4[(_ref = (_col$id$toString = (_col$id = col.id) == null ? void 0 : _col$id.toString()) != null ? _col$id$toString : (_col$accessorKey = col.accessorKey) == null ? void 0 : _col$accessorKey.toString()) != null ? _ref : ''] = col.filterFn instanceof Function ? (_col$filterFn$name = col.filterFn.name) != null ? _col$filterFn$name : 'custom' : (_ref2 = (_col$filterFn = col.filterFn) != null ? _col$filterFn : initialState == null ? void 0 : (_initialState$current7 = initialState.currentFilterFns) == null ? void 0 : _initialState$current7[(_ref3 = (_col$id$toString2 = (_col$id2 = col.id) == null ? void 0 : _col$id2.toString()) != null ? _col$id$toString2 : (_col$accessorKey2 = col.accessorKey) == null ? void 0 : _col$accessorKey2.toString()) != null ? _ref3 : '']) != null ? _ref2 : !!((_col$filterSelectOpti = col.filterSelectOptions) != null && _col$filterSelectOpti.length) ? 'equals' : 'fuzzy', _ref4;
|
3337
3459
|
})));
|
3338
3460
|
}),
|
3339
|
-
currentFilterFns =
|
3340
|
-
setCurrentFilterFns =
|
3461
|
+
currentFilterFns = _useState14[0],
|
3462
|
+
setCurrentFilterFns = _useState14[1];
|
3341
3463
|
|
3342
|
-
var
|
3343
|
-
currentGlobalFilterFn =
|
3344
|
-
setCurrentGlobalFilterFn =
|
3464
|
+
var _useState15 = useState(props.globalFilterFn instanceof String ? props.globalFilterFn : 'fuzzy'),
|
3465
|
+
currentGlobalFilterFn = _useState15[0],
|
3466
|
+
setCurrentGlobalFilterFn = _useState15[1];
|
3345
3467
|
|
3346
3468
|
var displayColumns = useMemo(function () {
|
3347
|
-
var _props$localization, _props$localization2, _props$localization3, _props$
|
3469
|
+
var _props$localization, _props$displayColumnD, _props$localization2, _props$displayColumnD2, _props$localization3, _props$displayColumnD3, _props$localization4, _props$displayColumnD4, _props$localization6, _props$displayColumnD5;
|
3348
3470
|
|
3349
|
-
return [columnOrder.includes('mrt-row-
|
3471
|
+
return [columnOrder.includes('mrt-row-drag') && _extends({
|
3472
|
+
header: (_props$localization = props.localization) == null ? void 0 : _props$localization.move,
|
3473
|
+
size: 60
|
3474
|
+
}, defaultDisplayColumnDefOptions, (_props$displayColumnD = props.displayColumnDefOptions) == null ? void 0 : _props$displayColumnD['mrt-row-drag'], {
|
3475
|
+
id: 'mrt-row-drag'
|
3476
|
+
}), columnOrder.includes('mrt-row-actions') && _extends({
|
3350
3477
|
Cell: function Cell(_ref5) {
|
3351
3478
|
var cell = _ref5.cell;
|
3352
3479
|
return React.createElement(MRT_ToggleRowActionMenuButton, {
|
@@ -3354,13 +3481,11 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
3354
3481
|
table: table
|
3355
3482
|
});
|
3356
3483
|
},
|
3357
|
-
|
3358
|
-
header: (_props$localization = props.localization) == null ? void 0 : _props$localization.actions,
|
3359
|
-
id: 'mrt-row-actions',
|
3360
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
3361
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
3484
|
+
header: (_props$localization2 = props.localization) == null ? void 0 : _props$localization2.actions,
|
3362
3485
|
size: 70
|
3363
|
-
},
|
3486
|
+
}, defaultDisplayColumnDefOptions, (_props$displayColumnD2 = props.displayColumnDefOptions) == null ? void 0 : _props$displayColumnD2['mrt-row-actions'], {
|
3487
|
+
id: 'mrt-row-actions'
|
3488
|
+
}), columnOrder.includes('mrt-row-expand') && _extends({
|
3364
3489
|
Cell: function Cell(_ref6) {
|
3365
3490
|
var cell = _ref6.cell;
|
3366
3491
|
return React.createElement(MRT_ExpandButton, {
|
@@ -3373,13 +3498,11 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
3373
3498
|
table: table
|
3374
3499
|
}) : null;
|
3375
3500
|
},
|
3376
|
-
|
3377
|
-
header: (_props$localization2 = props.localization) == null ? void 0 : _props$localization2.expand,
|
3378
|
-
id: 'mrt-expand',
|
3379
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
3380
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
3501
|
+
header: (_props$localization3 = props.localization) == null ? void 0 : _props$localization3.expand,
|
3381
3502
|
size: 60
|
3382
|
-
},
|
3503
|
+
}, defaultDisplayColumnDefOptions, (_props$displayColumnD3 = props.displayColumnDefOptions) == null ? void 0 : _props$displayColumnD3['mrt-row-expand'], {
|
3504
|
+
id: 'mrt-row-expand'
|
3505
|
+
}), columnOrder.includes('mrt-row-select') && _extends({
|
3383
3506
|
Cell: function Cell(_ref7) {
|
3384
3507
|
var cell = _ref7.cell;
|
3385
3508
|
return React.createElement(MRT_SelectCheckbox, {
|
@@ -3393,30 +3516,26 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
3393
3516
|
table: table
|
3394
3517
|
}) : null;
|
3395
3518
|
},
|
3396
|
-
|
3397
|
-
header: (_props$localization3 = props.localization) == null ? void 0 : _props$localization3.select,
|
3398
|
-
id: 'mrt-select',
|
3399
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
3400
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
3519
|
+
header: (_props$localization4 = props.localization) == null ? void 0 : _props$localization4.select,
|
3401
3520
|
size: 60
|
3402
|
-
},
|
3521
|
+
}, defaultDisplayColumnDefOptions, (_props$displayColumnD4 = props.displayColumnDefOptions) == null ? void 0 : _props$displayColumnD4['mrt-row-select'], {
|
3522
|
+
id: 'mrt-row-select'
|
3523
|
+
}), columnOrder.includes('mrt-row-numbers') && _extends({
|
3403
3524
|
Cell: function Cell(_ref8) {
|
3404
3525
|
var cell = _ref8.cell;
|
3405
3526
|
return cell.row.index + 1;
|
3406
3527
|
},
|
3407
3528
|
Header: function Header() {
|
3408
|
-
var _props$
|
3529
|
+
var _props$localization5;
|
3409
3530
|
|
3410
|
-
return (_props$
|
3531
|
+
return (_props$localization5 = props.localization) == null ? void 0 : _props$localization5.rowNumber;
|
3411
3532
|
},
|
3412
|
-
|
3413
|
-
header: (_props$localization5 = props.localization) == null ? void 0 : _props$localization5.rowNumbers,
|
3414
|
-
id: 'mrt-row-numbers',
|
3415
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
3416
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
3533
|
+
header: (_props$localization6 = props.localization) == null ? void 0 : _props$localization6.rowNumbers,
|
3417
3534
|
size: 60
|
3418
|
-
}
|
3419
|
-
|
3535
|
+
}, defaultDisplayColumnDefOptions, (_props$displayColumnD5 = props.displayColumnDefOptions) == null ? void 0 : _props$displayColumnD5['mrt-row-numbers'], {
|
3536
|
+
id: 'mrt-row-numbers'
|
3537
|
+
})].filter(Boolean);
|
3538
|
+
}, [columnOrder, props.displayColumnDefOptions, props.editingMode, props.enableColumnDragging, props.enableColumnOrdering, props.enableEditing, props.enableExpandAll, props.enableExpanding, props.enableGrouping, props.enableRowActions, props.enableRowDragging, props.enableRowNumbers, props.enableRowOrdering, props.enableRowSelection, props.enableSelectAll, props.localization, props.muiTableBodyCellProps, props.muiTableHeadCellProps, props.positionActionsColumn]);
|
3420
3539
|
var columnDefs = useMemo(function () {
|
3421
3540
|
return prepareColumns([].concat(displayColumns, props.columns), currentFilterFns);
|
3422
3541
|
}, [currentFilterFns, displayColumns, props.columns]);
|
@@ -3454,11 +3573,13 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
3454
3573
|
state: _extends({
|
3455
3574
|
columnOrder: columnOrder,
|
3456
3575
|
currentDraggingColumn: currentDraggingColumn,
|
3576
|
+
currentDraggingRow: currentDraggingRow,
|
3457
3577
|
currentEditingCell: currentEditingCell,
|
3458
3578
|
currentEditingRow: currentEditingRow,
|
3459
3579
|
currentFilterFns: currentFilterFns,
|
3460
3580
|
currentGlobalFilterFn: currentGlobalFilterFn,
|
3461
3581
|
currentHoveredColumn: currentHoveredColumn,
|
3582
|
+
currentHoveredRow: currentHoveredRow,
|
3462
3583
|
density: density,
|
3463
3584
|
isFullScreen: isFullScreen,
|
3464
3585
|
showAlertBanner: showAlertBanner,
|
@@ -3468,11 +3589,13 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
3468
3589
|
tableId: tableId
|
3469
3590
|
})), {
|
3470
3591
|
setCurrentDraggingColumn: (_props$onCurrentDragg = props.onCurrentDraggingColumnChange) != null ? _props$onCurrentDragg : setCurrentDraggingColumn,
|
3592
|
+
setCurrentDraggingRow: (_props$onCurrentDragg2 = props.onCurrentDraggingRowChange) != null ? _props$onCurrentDragg2 : setCurrentDraggingRow,
|
3471
3593
|
setCurrentEditingCell: (_props$onCurrentEditi = props.onCurrentEditingCellChange) != null ? _props$onCurrentEditi : setCurrentEditingCell,
|
3472
3594
|
setCurrentEditingRow: (_props$onCurrentEditi2 = props.onCurrentEditingRowChange) != null ? _props$onCurrentEditi2 : setCurrentEditingRow,
|
3473
3595
|
setCurrentFilterFns: (_props$onCurrentFilte = props.onCurrentFilterFnsChange) != null ? _props$onCurrentFilte : setCurrentFilterFns,
|
3474
3596
|
setCurrentGlobalFilterFn: (_props$onCurrentGloba = props.onCurrentGlobalFilterFnChange) != null ? _props$onCurrentGloba : setCurrentGlobalFilterFn,
|
3475
3597
|
setCurrentHoveredColumn: (_props$onCurrentHover = props.onCurrentHoveredColumnChange) != null ? _props$onCurrentHover : setCurrentHoveredColumn,
|
3598
|
+
setCurrentHoveredRow: (_props$onCurrentHover2 = props.onCurrentHoveredRowChange) != null ? _props$onCurrentHover2 : setCurrentHoveredRow,
|
3476
3599
|
setDensity: (_props$onDensityChang = props.onDensityChange) != null ? _props$onDensityChang : setDensity,
|
3477
3600
|
setIsFullScreen: (_props$onIsFullScreen = props.onIsFullScreenChange) != null ? _props$onIsFullScreen : setIsFullScreen,
|
3478
3601
|
setShowAlertBanner: (_props$onShowAlertBan = props.onShowAlertBannerChange) != null ? _props$onShowAlertBan : setShowAlertBanner,
|
@@ -3499,16 +3622,6 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
3499
3622
|
};
|
3500
3623
|
|
3501
3624
|
var _excluded$5 = ["autoResetExpanded", "columnResizeMode", "defaultColumn", "editingMode", "enableColumnActions", "enableColumnFilterChangeMode", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterChangeMode", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarBottom", "enableToolbarInternalActions", "enableToolbarTop", "icons", "localization", "positionActionsColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "rowNumberMode", "selectAllMode"];
|
3502
|
-
/**
|
3503
|
-
* `columns` and `data` props are the only required props, but there are over 150 other optional props.
|
3504
|
-
*
|
3505
|
-
* See more info on creating columns and data on the official docs site:
|
3506
|
-
* @link https://www.material-react-table.com/docs/usage
|
3507
|
-
*
|
3508
|
-
* See the full props list on the official docs site:
|
3509
|
-
* @link https://www.material-react-table.com/docs/api/props
|
3510
|
-
*/
|
3511
|
-
|
3512
3625
|
var MaterialReactTable = (function (_ref) {
|
3513
3626
|
var _ref$autoResetExpande = _ref.autoResetExpanded,
|
3514
3627
|
autoResetExpanded = _ref$autoResetExpande === void 0 ? false : _ref$autoResetExpande,
|