material-react-table 0.40.2 → 0.40.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/MaterialReactTable.d.ts +14 -2
- package/dist/cjs/index.js +81 -54
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +1 -1
- package/dist/cjs/menus/MRT_RowActionMenu.d.ts +2 -2
- package/dist/esm/MaterialReactTable.d.ts +14 -2
- package/dist/esm/material-react-table.esm.js +81 -54
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +1 -1
- package/dist/esm/menus/MRT_RowActionMenu.d.ts +2 -2
- package/dist/index.d.ts +14 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +25 -3
- package/src/body/MRT_TableBody.tsx +9 -7
- package/src/buttons/MRT_CopyButton.tsx +4 -3
- package/src/buttons/MRT_EditActionButtons.tsx +4 -1
- package/src/buttons/MRT_ExpandButton.tsx +5 -3
- package/src/buttons/MRT_GrabHandleButton.tsx +4 -0
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +8 -3
- package/src/inputs/MRT_EditCellTextField.tsx +4 -2
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +63 -50
- package/src/menus/MRT_FilterOptionMenu.tsx +9 -3
- package/src/menus/MRT_RowActionMenu.tsx +2 -2
- package/src/table/MRT_TableRoot.tsx +4 -6
|
@@ -216,9 +216,16 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
216
216
|
table: MRT_TableInstance<TData>;
|
|
217
217
|
column: MRT_Column<TData>;
|
|
218
218
|
}) => TableCellProps);
|
|
219
|
-
|
|
219
|
+
renderColumnActionsMenuItems?: ({ closeMenu, column, table, }: {
|
|
220
|
+
closeMenu: () => void;
|
|
221
|
+
column: MRT_Column<TData>;
|
|
220
222
|
table: MRT_TableInstance<TData>;
|
|
223
|
+
}) => ReactNode[];
|
|
224
|
+
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
221
225
|
column: MRT_Column<TData>;
|
|
226
|
+
internalFilterOptions: MRT_InternalFilterOption[];
|
|
227
|
+
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
228
|
+
table: MRT_TableInstance<TData>;
|
|
222
229
|
}) => ReactNode[];
|
|
223
230
|
sortingFn?: MRT_SortingFn;
|
|
224
231
|
};
|
|
@@ -470,12 +477,17 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
470
477
|
renderBottomToolbarCustomActions?: ({ table, }: {
|
|
471
478
|
table: MRT_TableInstance<TData>;
|
|
472
479
|
}) => ReactNode;
|
|
480
|
+
renderColumnActionsMenuItems?: ({ column, closeMenu, table, }: {
|
|
481
|
+
column: MRT_Column<TData>;
|
|
482
|
+
closeMenu: () => void;
|
|
483
|
+
table: MRT_TableInstance<TData>;
|
|
484
|
+
}) => ReactNode[];
|
|
473
485
|
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
474
486
|
column: MRT_Column<TData>;
|
|
475
487
|
internalFilterOptions: MRT_InternalFilterOption[];
|
|
476
488
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
477
489
|
table: MRT_TableInstance<TData>;
|
|
478
|
-
}) => ReactNode;
|
|
490
|
+
}) => ReactNode[];
|
|
479
491
|
renderDetailPanel?: ({ row, table, }: {
|
|
480
492
|
row: MRT_Row<TData>;
|
|
481
493
|
table: MRT_TableInstance<TData>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -282,12 +282,15 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
|
282
282
|
const iconButtonProps = muiExpandButtonProps instanceof Function
|
|
283
283
|
? muiExpandButtonProps({ table, row })
|
|
284
284
|
: muiExpandButtonProps;
|
|
285
|
-
const handleToggleExpand = () => {
|
|
285
|
+
const handleToggleExpand = (event) => {
|
|
286
|
+
var _a;
|
|
287
|
+
event.stopPropagation();
|
|
286
288
|
row.toggleExpanded();
|
|
289
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
287
290
|
};
|
|
288
291
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.expand },
|
|
289
292
|
React__default["default"].createElement("span", null,
|
|
290
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expand, disabled: !row.getCanExpand() && !renderDetailPanel
|
|
293
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expand, disabled: !row.getCanExpand() && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
291
294
|
? iconButtonProps.sx(theme)
|
|
292
295
|
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
293
296
|
React__default["default"].createElement(ExpandMoreIcon, { style: {
|
|
@@ -387,7 +390,7 @@ const mrtFilterOptions = (localization) => [
|
|
|
387
390
|
},
|
|
388
391
|
];
|
|
389
392
|
const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table, }) => {
|
|
390
|
-
var _a, _b;
|
|
393
|
+
var _a, _b, _c, _d;
|
|
391
394
|
const { getState, options: { enabledGlobalFilterOptions, columnFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
|
|
392
395
|
const { globalFilterFn, density } = getState();
|
|
393
396
|
const { column } = header !== null && header !== void 0 ? header : {};
|
|
@@ -421,8 +424,13 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table,
|
|
|
421
424
|
const filterOption = !!header && columnDef ? columnDef._filterFn : globalFilterFn;
|
|
422
425
|
return (React__default["default"].createElement(material.Menu, { anchorEl: anchorEl, anchorOrigin: { vertical: 'center', horizontal: 'right' }, onClose: () => setAnchorEl(null), open: !!anchorEl, MenuListProps: {
|
|
423
426
|
dense: density === 'compact',
|
|
424
|
-
} }, (
|
|
425
|
-
? renderColumnFilterModeMenuItems === null ||
|
|
427
|
+
} }, (_d = (header && column && columnDef
|
|
428
|
+
? (_c = (_b = columnDef.renderColumnFilterModeMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, {
|
|
429
|
+
column: column,
|
|
430
|
+
internalFilterOptions,
|
|
431
|
+
onSelectFilterMode: handleSelectFilterMode,
|
|
432
|
+
table,
|
|
433
|
+
})) !== null && _c !== void 0 ? _c : renderColumnFilterModeMenuItems === null || renderColumnFilterModeMenuItems === void 0 ? void 0 : renderColumnFilterModeMenuItems({
|
|
426
434
|
column: column,
|
|
427
435
|
internalFilterOptions,
|
|
428
436
|
onSelectFilterMode: handleSelectFilterMode,
|
|
@@ -432,7 +440,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table,
|
|
|
432
440
|
internalFilterOptions,
|
|
433
441
|
onSelectFilterMode: handleSelectFilterMode,
|
|
434
442
|
table,
|
|
435
|
-
}))) !== null &&
|
|
443
|
+
}))) !== null && _d !== void 0 ? _d : internalFilterOptions.map(({ option, label, divider, symbol }, index) => (React__default["default"].createElement(material.MenuItem, { divider: divider, key: index, onClick: () => handleSelectFilterMode(option), selected: option === filterOption, sx: {
|
|
436
444
|
alignItems: 'center',
|
|
437
445
|
display: 'flex',
|
|
438
446
|
gap: '2ch',
|
|
@@ -466,7 +474,11 @@ const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
|
466
474
|
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
|
467
475
|
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
468
476
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: localization.move },
|
|
469
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, {
|
|
477
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { onClick: (e) => {
|
|
478
|
+
var _a;
|
|
479
|
+
e.stopPropagation();
|
|
480
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
481
|
+
}, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
|
|
470
482
|
backgroundColor: 'transparent',
|
|
471
483
|
opacity: 1,
|
|
472
484
|
}, '&:active': {
|
|
@@ -724,8 +736,8 @@ const commonListItemStyles = {
|
|
|
724
736
|
alignItems: 'center',
|
|
725
737
|
};
|
|
726
738
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
727
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
728
|
-
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { enableColumnFilterModes, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting,
|
|
739
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
740
|
+
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setShowFilters, } = table;
|
|
729
741
|
const { column } = header;
|
|
730
742
|
const { columnDef } = column;
|
|
731
743
|
const { columnSizing, columnVisibility, density } = getState();
|
|
@@ -790,25 +802,32 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
790
802
|
!!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
|
|
791
803
|
return (React__default["default"].createElement(material.Menu, { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
|
|
792
804
|
dense: density === 'compact',
|
|
793
|
-
} },
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
805
|
+
} }, (_d = (_c = (_b = columnDef.renderColumnActionsMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, {
|
|
806
|
+
closeMenu: () => setAnchorEl(null),
|
|
807
|
+
column,
|
|
808
|
+
table,
|
|
809
|
+
})) !== null && _c !== void 0 ? _c : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
|
|
810
|
+
closeMenu: () => setAnchorEl(null),
|
|
811
|
+
column,
|
|
812
|
+
table,
|
|
813
|
+
})) !== null && _d !== void 0 ? _d : (enableSorting &&
|
|
814
|
+
column.getCanSort() && [
|
|
815
|
+
React__default["default"].createElement(material.MenuItem, { disabled: !column.getIsSorted(), key: 0, onClick: handleClearSort, sx: commonMenuItemStyles },
|
|
816
|
+
React__default["default"].createElement(material.Box, { sx: commonListItemStyles },
|
|
817
|
+
React__default["default"].createElement(material.ListItemIcon, null,
|
|
818
|
+
React__default["default"].createElement(ClearAllIcon, null)),
|
|
819
|
+
localization.clearSort)),
|
|
820
|
+
React__default["default"].createElement(material.MenuItem, { disabled: column.getIsSorted() === 'asc', key: 1, onClick: handleSortAsc, sx: commonMenuItemStyles },
|
|
821
|
+
React__default["default"].createElement(material.Box, { sx: commonListItemStyles },
|
|
822
|
+
React__default["default"].createElement(material.ListItemIcon, null,
|
|
823
|
+
React__default["default"].createElement(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } })), (_e = localization.sortByColumnAsc) === null || _e === void 0 ? void 0 :
|
|
824
|
+
_e.replace('{column}', String(columnDef.header)))),
|
|
825
|
+
React__default["default"].createElement(material.MenuItem, { divider: enableColumnFilters || enableGrouping || enableHiding, key: 2, disabled: column.getIsSorted() === 'desc', onClick: handleSortDesc, sx: commonMenuItemStyles },
|
|
826
|
+
React__default["default"].createElement(material.Box, { sx: commonListItemStyles },
|
|
827
|
+
React__default["default"].createElement(material.ListItemIcon, null,
|
|
828
|
+
React__default["default"].createElement(SortIcon, null)), (_f = localization.sortByColumnDesc) === null || _f === void 0 ? void 0 :
|
|
829
|
+
_f.replace('{column}', String(columnDef.header)))),
|
|
830
|
+
]),
|
|
812
831
|
enableColumnFilters &&
|
|
813
832
|
column.getCanFilter() &&
|
|
814
833
|
[
|
|
@@ -820,8 +839,8 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
820
839
|
React__default["default"].createElement(material.MenuItem, { divider: enableGrouping || enableHiding, key: 1, onClick: handleFilterByColumn, sx: commonMenuItemStyles },
|
|
821
840
|
React__default["default"].createElement(material.Box, { sx: commonListItemStyles },
|
|
822
841
|
React__default["default"].createElement(material.ListItemIcon, null,
|
|
823
|
-
React__default["default"].createElement(FilterListIcon, null)), (
|
|
824
|
-
|
|
842
|
+
React__default["default"].createElement(FilterListIcon, null)), (_g = localization.filterByColumn) === null || _g === void 0 ? void 0 :
|
|
843
|
+
_g.replace('{column}', String(columnDef.header))),
|
|
825
844
|
showFilterModeSubMenu && (React__default["default"].createElement(material.IconButton, { onClick: handleOpenFilterModeMenu, onMouseEnter: handleOpenFilterModeMenu, size: "small", sx: { p: 0 } },
|
|
826
845
|
React__default["default"].createElement(ArrowRightIcon, null)))),
|
|
827
846
|
showFilterModeSubMenu && (React__default["default"].createElement(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, key: 2, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table })),
|
|
@@ -831,8 +850,8 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
831
850
|
React__default["default"].createElement(material.MenuItem, { divider: enablePinning, key: 0, onClick: handleGroupByColumn, sx: commonMenuItemStyles },
|
|
832
851
|
React__default["default"].createElement(material.Box, { sx: commonListItemStyles },
|
|
833
852
|
React__default["default"].createElement(material.ListItemIcon, null,
|
|
834
|
-
React__default["default"].createElement(DynamicFeedIcon, null)), (
|
|
835
|
-
|
|
853
|
+
React__default["default"].createElement(DynamicFeedIcon, null)), (_h = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _h === void 0 ? void 0 :
|
|
854
|
+
_h.replace('{column}', String(columnDef.header)))),
|
|
836
855
|
],
|
|
837
856
|
enablePinning &&
|
|
838
857
|
column.getCanPin() && [
|
|
@@ -864,14 +883,14 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
864
883
|
React__default["default"].createElement(material.MenuItem, { disabled: columnDef.enableHiding === false, key: 0, onClick: handleHideColumn, sx: commonMenuItemStyles },
|
|
865
884
|
React__default["default"].createElement(material.Box, { sx: commonListItemStyles },
|
|
866
885
|
React__default["default"].createElement(material.ListItemIcon, null,
|
|
867
|
-
React__default["default"].createElement(VisibilityOffIcon, null)), (
|
|
868
|
-
|
|
886
|
+
React__default["default"].createElement(VisibilityOffIcon, null)), (_j = localization.hideColumn) === null || _j === void 0 ? void 0 :
|
|
887
|
+
_j.replace('{column}', String(columnDef.header)))),
|
|
869
888
|
React__default["default"].createElement(material.MenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
|
|
870
889
|
.length, key: 1, onClick: handleShowAllColumns, sx: commonMenuItemStyles },
|
|
871
890
|
React__default["default"].createElement(material.Box, { sx: commonListItemStyles },
|
|
872
891
|
React__default["default"].createElement(material.ListItemIcon, null,
|
|
873
|
-
React__default["default"].createElement(ViewColumnIcon, null)), (
|
|
874
|
-
|
|
892
|
+
React__default["default"].createElement(ViewColumnIcon, null)), (_k = localization.showAllColumns) === null || _k === void 0 ? void 0 :
|
|
893
|
+
_k.replace('{column}', String(columnDef.header))),
|
|
875
894
|
React__default["default"].createElement(material.IconButton, { onClick: handleOpenShowHideColumnsMenu, onMouseEnter: handleOpenShowHideColumnsMenu, size: "small", sx: { p: 0 } },
|
|
876
895
|
React__default["default"].createElement(ArrowRightIcon, null))),
|
|
877
896
|
React__default["default"].createElement(MRT_ShowHideColumnsMenu, { anchorEl: showHideColumnsMenuAnchorEl, isSubMenu: true, key: 2, setAnchorEl: setShowHideColumnsMenuAnchorEl, table: table }),
|
|
@@ -917,7 +936,7 @@ const MRT_EditActionButtons = ({ row, table, variant = 'icon', }) => {
|
|
|
917
936
|
values: (_b = editingRow === null || editingRow === void 0 ? void 0 : editingRow._valuesCache) !== null && _b !== void 0 ? _b : Object.assign({}, row.original),
|
|
918
937
|
});
|
|
919
938
|
};
|
|
920
|
-
return (React__default["default"].createElement(material.Box, { sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
939
|
+
return (React__default["default"].createElement(material.Box, { onClick: (e) => e.stopPropagation(), sx: { display: 'flex', gap: '0.75rem' } }, variant === 'icon' ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
921
940
|
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.cancel },
|
|
922
941
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.cancel, onClick: handleCancel },
|
|
923
942
|
React__default["default"].createElement(CancelIcon, null))),
|
|
@@ -938,7 +957,7 @@ const commonIconButtonStyles = {
|
|
|
938
957
|
opacity: 1,
|
|
939
958
|
},
|
|
940
959
|
};
|
|
941
|
-
const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
|
|
960
|
+
const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
942
961
|
const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
943
962
|
const { editingRow } = getState();
|
|
944
963
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
@@ -947,7 +966,8 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
|
|
|
947
966
|
event.preventDefault();
|
|
948
967
|
setAnchorEl(event.currentTarget);
|
|
949
968
|
};
|
|
950
|
-
const handleStartEditMode = () => {
|
|
969
|
+
const handleStartEditMode = (event) => {
|
|
970
|
+
event.stopPropagation();
|
|
951
971
|
setEditingRow(Object.assign({}, row));
|
|
952
972
|
setAnchorEl(null);
|
|
953
973
|
};
|
|
@@ -979,7 +999,11 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
979
999
|
? selectAllMode === 'all'
|
|
980
1000
|
? table.getToggleAllRowsSelectedHandler()
|
|
981
1001
|
: table.getToggleAllPageRowsSelectedHandler()
|
|
982
|
-
: row.getToggleSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, {
|
|
1002
|
+
: row.getToggleSelectedHandler(), size: density === 'compact' ? 'small' : 'medium' }, checkboxProps, { onClick: (e) => {
|
|
1003
|
+
var _a;
|
|
1004
|
+
e.stopPropagation();
|
|
1005
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1006
|
+
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
|
|
983
1007
|
? checkboxProps.sx(theme)
|
|
984
1008
|
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) }))));
|
|
985
1009
|
};
|
|
@@ -1839,7 +1863,11 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1839
1863
|
textFieldProps.inputRef = inputRef;
|
|
1840
1864
|
}
|
|
1841
1865
|
}
|
|
1842
|
-
}, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id,
|
|
1866
|
+
}, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { onClick: (e) => {
|
|
1867
|
+
var _a;
|
|
1868
|
+
e.stopPropagation();
|
|
1869
|
+
(_a = textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.onClick) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
|
1870
|
+
}, onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown })));
|
|
1843
1871
|
};
|
|
1844
1872
|
|
|
1845
1873
|
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
@@ -1847,7 +1875,8 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
|
1847
1875
|
const { column, row } = cell;
|
|
1848
1876
|
const { columnDef } = column;
|
|
1849
1877
|
const [copied, setCopied] = React.useState(false);
|
|
1850
|
-
const handleCopy = (text) => {
|
|
1878
|
+
const handleCopy = (event, text) => {
|
|
1879
|
+
event.stopPropagation();
|
|
1851
1880
|
navigator.clipboard.writeText(text);
|
|
1852
1881
|
setCopied(true);
|
|
1853
1882
|
setTimeout(() => setCopied(false), 4000);
|
|
@@ -1863,7 +1892,7 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
|
1863
1892
|
: columnDef.muiTableBodyCellCopyButtonProps;
|
|
1864
1893
|
const buttonProps = Object.assign(Object.assign({}, mTableBodyCellCopyButtonProps), mcTableBodyCellCopyButtonProps);
|
|
1865
1894
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: copied ? localization.copiedToClipboard : localization.clickToCopy },
|
|
1866
|
-
React__default["default"].createElement(material.Button, Object.assign({ onClick: () => handleCopy(cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
|
|
1895
|
+
React__default["default"].createElement(material.Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
|
|
1867
1896
|
? buttonProps.sx(theme)
|
|
1868
1897
|
: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))) }), children)));
|
|
1869
1898
|
};
|
|
@@ -2113,7 +2142,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2113
2142
|
};
|
|
2114
2143
|
|
|
2115
2144
|
const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
2116
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization,
|
|
2145
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, } = table;
|
|
2117
2146
|
const { globalFilter, pagination, sorting } = getState();
|
|
2118
2147
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2119
2148
|
? muiTableBodyProps({ table })
|
|
@@ -2124,6 +2153,8 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2124
2153
|
const rows = React.useMemo(() => {
|
|
2125
2154
|
if (enableGlobalFilterRankedResults &&
|
|
2126
2155
|
globalFilter &&
|
|
2156
|
+
!manualFiltering &&
|
|
2157
|
+
!manualSorting &&
|
|
2127
2158
|
!Object.values(sorting).some(Boolean)) {
|
|
2128
2159
|
const rankedRows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
|
|
2129
2160
|
if (enablePagination) {
|
|
@@ -2144,11 +2175,9 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2144
2175
|
const virtualizer = enableRowVirtualization
|
|
2145
2176
|
? reactVirtual.useVirtual(Object.assign({ size: rows.length, parentRef: tableContainerRef, overscan: 15 }, vProps))
|
|
2146
2177
|
: {};
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
}
|
|
2151
|
-
}, [virtualizer]);
|
|
2178
|
+
if (virtualizerInstanceRef) {
|
|
2179
|
+
virtualizerInstanceRef.current = virtualizer;
|
|
2180
|
+
}
|
|
2152
2181
|
// const virtualizer: Virtualizer = enableRowVirtualization
|
|
2153
2182
|
// ? useVirtualizer({
|
|
2154
2183
|
// count: rows.length,
|
|
@@ -2455,11 +2484,9 @@ const MRT_TableRoot = (props) => {
|
|
|
2455
2484
|
tableContainerRef,
|
|
2456
2485
|
topToolbarRef,
|
|
2457
2486
|
}, setColumnFilterFns: (_w = props.onFilterFnsChange) !== null && _w !== void 0 ? _w : setColumnFilterFns, setDensity: (_x = props.onDensityChange) !== null && _x !== void 0 ? _x : setDensity, setDraggingColumn: (_y = props.onDraggingColumnChange) !== null && _y !== void 0 ? _y : setDraggingColumn, setDraggingRow: (_z = props.onDraggingRowChange) !== null && _z !== void 0 ? _z : setDraggingRow, setEditingCell: (_0 = props.onEditingCellChange) !== null && _0 !== void 0 ? _0 : setEditingCell, setEditingRow: (_1 = props.onEditingRowChange) !== null && _1 !== void 0 ? _1 : setEditingRow, setGlobalFilterFn: (_2 = props.onGlobalFilterFnChange) !== null && _2 !== void 0 ? _2 : setGlobalFilterFn, setHoveredColumn: (_3 = props.onHoveredColumnChange) !== null && _3 !== void 0 ? _3 : setHoveredColumn, setHoveredRow: (_4 = props.onHoveredRowChange) !== null && _4 !== void 0 ? _4 : setHoveredRow, setIsFullScreen: (_5 = props.onIsFullScreenChange) !== null && _5 !== void 0 ? _5 : setIsFullScreen, setShowAlertBanner: (_6 = props.onShowAlertBannerChange) !== null && _6 !== void 0 ? _6 : setShowAlertBanner, setShowFilters: (_7 = props.onShowFiltersChange) !== null && _7 !== void 0 ? _7 : setShowFilters, setShowGlobalFilter: (_8 = props.onShowGlobalFilterChange) !== null && _8 !== void 0 ? _8 : setShowGlobalFilter });
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
}
|
|
2462
|
-
}, [table]);
|
|
2487
|
+
if (props.tableInstanceRef) {
|
|
2488
|
+
props.tableInstanceRef.current = table;
|
|
2489
|
+
}
|
|
2463
2490
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2464
2491
|
React__default["default"].createElement(material.Dialog, { PaperComponent: material.Box, TransitionComponent: material.Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2465
2492
|
React__default["default"].createElement(MRT_TablePaper, { table: table })),
|