@mui/x-data-grid 5.16.0 → 5.17.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/CHANGELOG.md +138 -1
- package/components/GridRow.d.ts +2 -1
- package/components/GridRow.js +132 -83
- package/components/cell/GridBooleanCell.js +2 -1
- package/components/cell/GridCell.js +9 -1
- package/components/cell/GridEditBooleanCell.js +2 -1
- package/components/cell/GridEditDateCell.js +2 -1
- package/components/cell/GridEditInputCell.js +2 -1
- package/components/cell/GridEditSingleSelectCell.js +2 -1
- package/components/cell/GridSkeletonCell.d.ts +12 -0
- package/components/cell/GridSkeletonCell.js +60 -0
- package/components/cell/index.d.ts +1 -0
- package/components/cell/index.js +2 -1
- package/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/components/containers/GridRootStyles.js +2 -0
- package/components/panel/GridColumnsPanel.d.ts +6 -1
- package/components/panel/GridColumnsPanel.js +38 -6
- package/constants/defaultGridSlotsComponents.js +2 -1
- package/constants/gridClasses.d.ts +8 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +8 -2
- package/hooks/features/editRows/useGridRowEditing.new.js +8 -2
- package/hooks/features/filter/gridFilterUtils.d.ts +1 -1
- package/hooks/features/filter/gridFilterUtils.js +55 -54
- package/hooks/features/filter/useGridFilter.js +1 -1
- package/hooks/features/focus/useGridFocus.js +13 -3
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/hooks/features/rows/useGridParamsApi.js +1 -1
- package/hooks/features/rows/useGridRows.js +65 -8
- package/hooks/features/rows/useGridRowsMeta.js +36 -16
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/components/GridRow.js +135 -83
- package/legacy/components/cell/GridBooleanCell.js +2 -1
- package/legacy/components/cell/GridCell.js +11 -1
- package/legacy/components/cell/GridEditBooleanCell.js +2 -1
- package/legacy/components/cell/GridEditDateCell.js +2 -1
- package/legacy/components/cell/GridEditInputCell.js +2 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +2 -1
- package/legacy/components/cell/GridSkeletonCell.js +57 -0
- package/legacy/components/cell/index.js +2 -1
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/legacy/components/containers/GridRootStyles.js +3 -3
- package/legacy/components/panel/GridColumnsPanel.js +41 -6
- package/legacy/constants/defaultGridSlotsComponents.js +2 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +11 -5
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +8 -2
- package/legacy/hooks/features/filter/gridFilterUtils.js +61 -56
- package/legacy/hooks/features/filter/useGridFilter.js +1 -1
- package/legacy/hooks/features/focus/useGridFocus.js +13 -3
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/legacy/hooks/features/rows/useGridParamsApi.js +1 -1
- package/legacy/hooks/features/rows/useGridRows.js +73 -8
- package/legacy/hooks/features/rows/useGridRowsMeta.js +45 -18
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +31 -13
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/models/events/gridEvents.js +2 -0
- package/legacy/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/legacy/models/params/index.js +2 -1
- package/legacy/utils/utils.js +25 -0
- package/models/api/gridParamsApi.d.ts +1 -1
- package/models/api/gridRowApi.d.ts +6 -0
- package/models/api/gridRowsMetaApi.d.ts +6 -1
- package/models/events/gridEventLookup.d.ts +7 -1
- package/models/events/gridEvents.d.ts +3 -1
- package/models/events/gridEvents.js +2 -0
- package/models/gridSlotsComponent.d.ts +5 -0
- package/models/params/gridCellParams.d.ts +7 -2
- package/models/params/gridRenderedRowsIntervalChangeParams.d.ts +10 -0
- package/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/models/params/index.d.ts +1 -0
- package/models/params/index.js +2 -1
- package/modern/components/GridRow.js +129 -82
- package/modern/components/cell/GridBooleanCell.js +2 -1
- package/modern/components/cell/GridCell.js +9 -1
- package/modern/components/cell/GridEditBooleanCell.js +2 -1
- package/modern/components/cell/GridEditDateCell.js +2 -1
- package/modern/components/cell/GridEditInputCell.js +2 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
- package/modern/components/cell/GridSkeletonCell.js +60 -0
- package/modern/components/cell/index.js +2 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/modern/components/containers/GridRootStyles.js +2 -0
- package/modern/components/panel/GridColumnsPanel.js +38 -6
- package/modern/constants/defaultGridSlotsComponents.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +8 -2
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +8 -2
- package/modern/hooks/features/filter/gridFilterUtils.js +54 -53
- package/modern/hooks/features/filter/useGridFilter.js +1 -1
- package/modern/hooks/features/focus/useGridFocus.js +13 -3
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/modern/hooks/features/rows/useGridParamsApi.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +65 -8
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -16
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/models/events/gridEvents.js +2 -0
- package/modern/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
- package/modern/models/params/index.js +2 -1
- package/modern/utils/utils.js +23 -0
- package/node/components/GridRow.js +131 -75
- package/node/components/cell/GridBooleanCell.js +2 -1
- package/node/components/cell/GridCell.js +9 -1
- package/node/components/cell/GridEditBooleanCell.js +2 -1
- package/node/components/cell/GridEditDateCell.js +2 -1
- package/node/components/cell/GridEditInputCell.js +2 -1
- package/node/components/cell/GridEditSingleSelectCell.js +2 -1
- package/node/components/cell/GridSkeletonCell.js +81 -0
- package/node/components/cell/index.js +13 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
- package/node/components/containers/GridRootStyles.js +2 -0
- package/node/components/panel/GridColumnsPanel.js +36 -5
- package/node/constants/defaultGridSlotsComponents.js +1 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +9 -2
- package/node/hooks/features/editRows/useGridRowEditing.new.js +9 -2
- package/node/hooks/features/filter/gridFilterUtils.js +55 -55
- package/node/hooks/features/filter/useGridFilter.js +1 -1
- package/node/hooks/features/focus/useGridFocus.js +13 -3
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/node/hooks/features/rows/useGridParamsApi.js +1 -1
- package/node/hooks/features/rows/useGridRows.js +60 -7
- package/node/hooks/features/rows/useGridRowsMeta.js +35 -15
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
- package/node/index.js +1 -1
- package/node/internals/index.js +6 -0
- package/node/models/events/gridEvents.js +2 -0
- package/node/models/params/gridRenderedRowsIntervalChangeParams.js +5 -0
- package/node/models/params/index.js +13 -0
- package/node/utils/utils.js +27 -0
- package/package.json +1 -1
- package/utils/utils.d.ts +2 -0
- package/utils/utils.js +23 -0
|
@@ -190,7 +190,8 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
|
|
|
190
190
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired,
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
|
-
* The cell value
|
|
193
|
+
* The cell value.
|
|
194
|
+
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
194
195
|
*/
|
|
195
196
|
value: PropTypes.any
|
|
196
197
|
} : void 0;
|
|
@@ -7,12 +7,12 @@ export var GridRootStyles = styled('div', {
|
|
|
7
7
|
slot: 'Root',
|
|
8
8
|
overridesResolver: function overridesResolver(props, styles) {
|
|
9
9
|
return [_defineProperty({}, "&.".concat(gridClasses.autoHeight), styles.autoHeight), _defineProperty({}, "&.".concat(gridClasses.aggregationColumnHeader), styles.aggregationColumnHeader), _defineProperty({}, "&.".concat(gridClasses['aggregationColumnHeader--alignLeft']), styles['aggregationColumnHeader--alignLeft']), _defineProperty({}, "&.".concat(gridClasses['aggregationColumnHeader--alignCenter']), styles['aggregationColumnHeader--alignCenter']), _defineProperty({}, "&.".concat(gridClasses['aggregationColumnHeader--alignRight']), styles['aggregationColumnHeader--alignRight']), _defineProperty({}, "&.".concat(gridClasses.aggregationColumnHeaderLabel), styles.aggregationColumnHeaderLabel), _defineProperty({}, "& .".concat(gridClasses.editBooleanCell), styles.editBooleanCell), _defineProperty({}, "& .".concat(gridClasses['cell--editing']), styles['cell--editing']), _defineProperty({}, "& .".concat(gridClasses['cell--textCenter']), styles['cell--textCenter']), _defineProperty({}, "& .".concat(gridClasses['cell--textLeft']), styles['cell--textLeft']), _defineProperty({}, "& .".concat(gridClasses['cell--textRight']), styles['cell--textRight']), // TODO v6: Remove
|
|
10
|
-
_defineProperty({}, "& .".concat(gridClasses['cell--withRenderer']), styles['cell--withRenderer']), _defineProperty({}, "& .".concat(gridClasses.cell), styles.cell), _defineProperty({}, "& .".concat(gridClasses.cellContent), styles.cellContent), _defineProperty({}, "& .".concat(gridClasses.cellCheckbox), styles.cellCheckbox), _defineProperty({}, "& .".concat(gridClasses.checkboxInput), styles.checkboxInput), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignCenter']), styles['columnHeader--alignCenter']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignLeft']), styles['columnHeader--alignLeft']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignRight']), styles['columnHeader--alignRight']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--dragging']), styles['columnHeader--dragging']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--moving']), styles['columnHeader--moving']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--numeric']), styles['columnHeader--numeric']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--sortable']), styles['columnHeader--sortable']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--sorted']), styles['columnHeader--sorted']), _defineProperty({}, "& .".concat(gridClasses.columnHeader), styles.columnHeader), _defineProperty({}, "& .".concat(gridClasses.columnHeaderCheckbox), styles.columnHeaderCheckbox), _defineProperty({}, "& .".concat(gridClasses.columnHeaderDraggableContainer), styles.columnHeaderDraggableContainer), _defineProperty({}, "& .".concat(gridClasses.columnHeaderTitleContainer), styles.columnHeaderTitleContainer), _defineProperty({}, "& .".concat(gridClasses['columnSeparator--resizable']), styles['columnSeparator--resizable']), _defineProperty({}, "& .".concat(gridClasses['columnSeparator--resizing']), styles['columnSeparator--resizing']), _defineProperty({}, "& .".concat(gridClasses.columnSeparator), styles.columnSeparator), _defineProperty({}, "& .".concat(gridClasses.filterIcon), styles.filterIcon), _defineProperty({}, "& .".concat(gridClasses.iconSeparator), styles.iconSeparator), _defineProperty({}, "& .".concat(gridClasses.menuIcon), styles.menuIcon), _defineProperty({}, "& .".concat(gridClasses.menuIconButton), styles.menuIconButton), _defineProperty({}, "& .".concat(gridClasses.menuOpen), styles.menuOpen), _defineProperty({}, "& .".concat(gridClasses.menuList), styles.menuList), _defineProperty({}, "& .".concat(gridClasses['row--editable']), styles['row--editable']), _defineProperty({}, "& .".concat(gridClasses['row--editing']), styles['row--editing']), _defineProperty({}, "& .".concat(gridClasses['row--dragging']), styles['row--dragging']), _defineProperty({}, "& .".concat(gridClasses.row), styles.row), _defineProperty({}, "& .".concat(gridClasses.rowReorderCellPlaceholder), styles.rowReorderCellPlaceholder), _defineProperty({}, "& .".concat(gridClasses.rowReorderCell), styles.rowReorderCell), _defineProperty({}, "& .".concat(gridClasses['rowReorderCell--draggable']), styles['rowReorderCell--draggable']), _defineProperty({}, "& .".concat(gridClasses.sortIcon), styles.sortIcon), _defineProperty({}, "& .".concat(gridClasses.withBorder), styles.withBorder), _defineProperty({}, "& .".concat(gridClasses.treeDataGroupingCell), styles.treeDataGroupingCell), _defineProperty({}, "& .".concat(gridClasses.treeDataGroupingCellToggle), styles.treeDataGroupingCellToggle), _defineProperty({}, "& .".concat(gridClasses.detailPanelToggleCell), styles.detailPanelToggleCell), _defineProperty({}, "& .".concat(gridClasses['detailPanelToggleCell--expanded']), styles['detailPanelToggleCell--expanded']), styles.root];
|
|
10
|
+
_defineProperty({}, "& .".concat(gridClasses['cell--withRenderer']), styles['cell--withRenderer']), _defineProperty({}, "& .".concat(gridClasses.cell), styles.cell), _defineProperty({}, "& .".concat(gridClasses.cellContent), styles.cellContent), _defineProperty({}, "& .".concat(gridClasses.cellCheckbox), styles.cellCheckbox), _defineProperty({}, "& .".concat(gridClasses.cellSkeleton), styles.cellSkeleton), _defineProperty({}, "& .".concat(gridClasses.checkboxInput), styles.checkboxInput), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignCenter']), styles['columnHeader--alignCenter']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignLeft']), styles['columnHeader--alignLeft']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--alignRight']), styles['columnHeader--alignRight']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--dragging']), styles['columnHeader--dragging']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--moving']), styles['columnHeader--moving']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--numeric']), styles['columnHeader--numeric']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--sortable']), styles['columnHeader--sortable']), _defineProperty({}, "& .".concat(gridClasses['columnHeader--sorted']), styles['columnHeader--sorted']), _defineProperty({}, "& .".concat(gridClasses.columnHeader), styles.columnHeader), _defineProperty({}, "& .".concat(gridClasses.columnHeaderCheckbox), styles.columnHeaderCheckbox), _defineProperty({}, "& .".concat(gridClasses.columnHeaderDraggableContainer), styles.columnHeaderDraggableContainer), _defineProperty({}, "& .".concat(gridClasses.columnHeaderTitleContainer), styles.columnHeaderTitleContainer), _defineProperty({}, "& .".concat(gridClasses['columnSeparator--resizable']), styles['columnSeparator--resizable']), _defineProperty({}, "& .".concat(gridClasses['columnSeparator--resizing']), styles['columnSeparator--resizing']), _defineProperty({}, "& .".concat(gridClasses.columnSeparator), styles.columnSeparator), _defineProperty({}, "& .".concat(gridClasses.filterIcon), styles.filterIcon), _defineProperty({}, "& .".concat(gridClasses.iconSeparator), styles.iconSeparator), _defineProperty({}, "& .".concat(gridClasses.menuIcon), styles.menuIcon), _defineProperty({}, "& .".concat(gridClasses.menuIconButton), styles.menuIconButton), _defineProperty({}, "& .".concat(gridClasses.menuOpen), styles.menuOpen), _defineProperty({}, "& .".concat(gridClasses.menuList), styles.menuList), _defineProperty({}, "& .".concat(gridClasses['row--editable']), styles['row--editable']), _defineProperty({}, "& .".concat(gridClasses['row--editing']), styles['row--editing']), _defineProperty({}, "& .".concat(gridClasses['row--dragging']), styles['row--dragging']), _defineProperty({}, "& .".concat(gridClasses.row), styles.row), _defineProperty({}, "& .".concat(gridClasses.rowReorderCellPlaceholder), styles.rowReorderCellPlaceholder), _defineProperty({}, "& .".concat(gridClasses.rowReorderCell), styles.rowReorderCell), _defineProperty({}, "& .".concat(gridClasses['rowReorderCell--draggable']), styles['rowReorderCell--draggable']), _defineProperty({}, "& .".concat(gridClasses.sortIcon), styles.sortIcon), _defineProperty({}, "& .".concat(gridClasses.withBorder), styles.withBorder), _defineProperty({}, "& .".concat(gridClasses.treeDataGroupingCell), styles.treeDataGroupingCell), _defineProperty({}, "& .".concat(gridClasses.treeDataGroupingCellToggle), styles.treeDataGroupingCellToggle), _defineProperty({}, "& .".concat(gridClasses.detailPanelToggleCell), styles.detailPanelToggleCell), _defineProperty({}, "& .".concat(gridClasses['detailPanelToggleCell--expanded']), styles['detailPanelToggleCell--expanded']), styles.root];
|
|
11
11
|
}
|
|
12
|
-
})(function (
|
|
12
|
+
})(function (_ref52) {
|
|
13
13
|
var _$concat2, _$concat3, _extends2;
|
|
14
14
|
|
|
15
|
-
var theme =
|
|
15
|
+
var theme = _ref52.theme;
|
|
16
16
|
var borderColor = theme.palette.mode === 'light' ? lighten(alpha(theme.palette.divider, 1), 0.88) : darken(alpha(theme.palette.divider, 1), 0.68);
|
|
17
17
|
|
|
18
18
|
var gridStyle = _extends({
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
+
var _excluded = ["sort"];
|
|
4
7
|
import * as React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
5
9
|
import { unstable_composeClasses as composeClasses } from '@mui/material';
|
|
6
10
|
import IconButton from '@mui/material/IconButton';
|
|
7
11
|
import { switchClasses } from '@mui/material/Switch';
|
|
@@ -60,7 +64,9 @@ var GridColumnsPanelRowRoot = styled('div', {
|
|
|
60
64
|
var GridIconButtonRoot = styled(IconButton)({
|
|
61
65
|
justifyContent: 'flex-end'
|
|
62
66
|
});
|
|
63
|
-
|
|
67
|
+
var collator = new Intl.Collator();
|
|
68
|
+
|
|
69
|
+
function GridColumnsPanel(props) {
|
|
64
70
|
var _rootProps$components, _rootProps$components3, _rootProps$components4;
|
|
65
71
|
|
|
66
72
|
var apiRef = useGridApiContext();
|
|
@@ -79,6 +85,26 @@ export function GridColumnsPanel(props) {
|
|
|
79
85
|
};
|
|
80
86
|
var classes = useUtilityClasses(ownerState);
|
|
81
87
|
|
|
88
|
+
var sort = props.sort,
|
|
89
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
90
|
+
|
|
91
|
+
var sortedColumns = React.useMemo(function () {
|
|
92
|
+
switch (sort) {
|
|
93
|
+
case 'asc':
|
|
94
|
+
return _toConsumableArray(columns).sort(function (a, b) {
|
|
95
|
+
return collator.compare(a.headerName || a.field, b.headerName || b.field);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
case 'desc':
|
|
99
|
+
return _toConsumableArray(columns).sort(function (a, b) {
|
|
100
|
+
return -collator.compare(a.headerName || a.field, b.headerName || b.field);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
default:
|
|
104
|
+
return columns;
|
|
105
|
+
}
|
|
106
|
+
}, [columns, sort]);
|
|
107
|
+
|
|
82
108
|
var toggleColumn = function toggleColumn(event) {
|
|
83
109
|
var _ref3 = event.target,
|
|
84
110
|
field = _ref3.name;
|
|
@@ -115,18 +141,18 @@ export function GridColumnsPanel(props) {
|
|
|
115
141
|
}, []);
|
|
116
142
|
var currentColumns = React.useMemo(function () {
|
|
117
143
|
if (!searchValue) {
|
|
118
|
-
return
|
|
144
|
+
return sortedColumns;
|
|
119
145
|
}
|
|
120
146
|
|
|
121
147
|
var searchValueToCheck = searchValue.toLowerCase();
|
|
122
|
-
return
|
|
148
|
+
return sortedColumns.filter(function (column) {
|
|
123
149
|
return (column.headerName || column.field).toLowerCase().indexOf(searchValueToCheck) > -1;
|
|
124
150
|
});
|
|
125
|
-
}, [
|
|
151
|
+
}, [sortedColumns, searchValue]);
|
|
126
152
|
React.useEffect(function () {
|
|
127
153
|
searchInputRef.current.focus();
|
|
128
154
|
}, []);
|
|
129
|
-
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({},
|
|
155
|
+
return /*#__PURE__*/_jsxs(GridPanelWrapper, _extends({}, other, {
|
|
130
156
|
children: [/*#__PURE__*/_jsx(GridPanelHeader, {
|
|
131
157
|
children: /*#__PURE__*/_jsx(rootProps.components.BaseTextField, _extends({
|
|
132
158
|
label: apiRef.current.getLocaleText('columnsPanelTextFieldLabel'),
|
|
@@ -181,4 +207,13 @@ export function GridColumnsPanel(props) {
|
|
|
181
207
|
}))]
|
|
182
208
|
})]
|
|
183
209
|
}));
|
|
184
|
-
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
213
|
+
// ----------------------------- Warning --------------------------------
|
|
214
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
215
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
216
|
+
// ----------------------------------------------------------------------
|
|
217
|
+
sort: PropTypes.oneOf(['asc', 'desc'])
|
|
218
|
+
} : void 0;
|
|
219
|
+
export { GridColumnsPanel };
|
|
@@ -7,7 +7,7 @@ import MUISwitch from '@mui/material/Switch';
|
|
|
7
7
|
import MUIButton from '@mui/material/Button';
|
|
8
8
|
import MUITooltip from '@mui/material/Tooltip';
|
|
9
9
|
import MUIPopper from '@mui/material/Popper';
|
|
10
|
-
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton, GridSearchIcon } from '../components';
|
|
10
|
+
import { GridArrowDownwardIcon, GridArrowUpwardIcon, GridCell, GridSkeletonCell, GridCheckIcon, GridCloseIcon, GridColumnIcon, GridColumnMenu, GridColumnsPanel, GridFilterAltIcon, GridFilterListIcon, GridFilterPanel, GridFooter, GridHeader, GridLoadingOverlay, GridNoRowsOverlay, GridPagination, GridPanel, GridPreferencesPanel, GridRow, GridSaveAltIcon, GridSeparatorIcon, GridTableRowsIcon, GridTripleDotsVerticalIcon, GridViewHeadlineIcon, GridViewStreamIcon, GridMoreVertIcon, GridExpandMoreIcon, GridKeyboardArrowRight, GridAddIcon, GridRemoveIcon, GridDragIcon, GridColumnHeaderFilterIconButton, GridSearchIcon } from '../components';
|
|
11
11
|
import { GridColumnUnsortedIcon } from '../components/columnHeaders/GridColumnUnsortedIcon';
|
|
12
12
|
import { ErrorOverlay } from '../components/ErrorOverlay';
|
|
13
13
|
import { GridNoResultsOverlay } from '../components/GridNoResultsOverlay';
|
|
@@ -52,6 +52,7 @@ export var DATA_GRID_DEFAULT_SLOTS_COMPONENTS = _extends({}, DEFAULT_GRID_ICON_S
|
|
|
52
52
|
BaseTooltip: MUITooltip,
|
|
53
53
|
BasePopper: MUIPopper,
|
|
54
54
|
Cell: GridCell,
|
|
55
|
+
SkeletonCell: GridSkeletonCell,
|
|
55
56
|
ColumnHeaderFilterIconButton: GridColumnHeaderFilterIconButton,
|
|
56
57
|
ColumnMenu: GridColumnMenu,
|
|
57
58
|
ErrorOverlay: ErrorOverlay,
|
|
@@ -2,4 +2,4 @@ import { generateUtilityClasses, generateUtilityClass } from '@mui/material';
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export var gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnGroupHeader', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeader--showColumnBorder', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
5
|
+
export var gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'cellSkeleton', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnGroupHeader', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeader--showColumnBorder', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -15,6 +15,7 @@ import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
|
15
15
|
import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
16
16
|
import { buildWarning } from '../../../utils/warning';
|
|
17
17
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
18
|
+
import { deepClone } from '../../../utils/utils';
|
|
18
19
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from '../../../models/params/gridEditCellParams';
|
|
19
20
|
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
20
21
|
export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
@@ -315,16 +316,20 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
315
316
|
_editingState$id$fiel = editingState[id][field], error = _editingState$id$fiel.error, isProcessingProps = _editingState$id$fiel.isProcessingProps;
|
|
316
317
|
|
|
317
318
|
if (!(error || isProcessingProps)) {
|
|
318
|
-
_context.next =
|
|
319
|
+
_context.next = 13;
|
|
319
320
|
break;
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
// Attempt to change cell mode to "view" was not successful
|
|
323
324
|
// Update previous mode to allow another attempt
|
|
324
|
-
prevCellModesModel.current[id][field].mode = GridCellModes.Edit;
|
|
325
|
+
prevCellModesModel.current[id][field].mode = GridCellModes.Edit; // Revert the mode in the cellModesModel prop back to "edit"
|
|
326
|
+
|
|
327
|
+
updateFieldInCellModesModel(id, field, {
|
|
328
|
+
mode: GridCellModes.Edit
|
|
329
|
+
});
|
|
325
330
|
return _context.abrupt("return");
|
|
326
331
|
|
|
327
|
-
case
|
|
332
|
+
case 13:
|
|
328
333
|
rowUpdate = apiRef.current.unstable_getRowWithUpdatedValuesFromCellEditing(id, field);
|
|
329
334
|
|
|
330
335
|
if (processRowUpdate) {
|
|
@@ -352,7 +357,7 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
352
357
|
finishCellEditMode();
|
|
353
358
|
}
|
|
354
359
|
|
|
355
|
-
case
|
|
360
|
+
case 15:
|
|
356
361
|
case "end":
|
|
357
362
|
return _context.stop();
|
|
358
363
|
}
|
|
@@ -470,7 +475,8 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
470
475
|
var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopCellEditMode may change it later
|
|
471
476
|
|
|
472
477
|
var copyOfPrevCellModes = prevCellModesModel.current;
|
|
473
|
-
prevCellModesModel.current = cellModesModel;
|
|
478
|
+
prevCellModesModel.current = deepClone(cellModesModel); // Do a deep-clone because the attributes might be changed later
|
|
479
|
+
|
|
474
480
|
Object.entries(cellModesModel).forEach(function (_ref3) {
|
|
475
481
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
476
482
|
id = _ref4[0],
|
|
@@ -14,6 +14,7 @@ import { isPrintableKey } from '../../../utils/keyboardUtils';
|
|
|
14
14
|
import { gridColumnFieldsSelector } from '../columns/gridColumnsSelector';
|
|
15
15
|
import { buildWarning } from '../../../utils/warning';
|
|
16
16
|
import { gridRowsIdToIdLookupSelector } from '../rows/gridRowsSelector';
|
|
17
|
+
import { deepClone } from '../../../utils/utils';
|
|
17
18
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from '../../../models/params/gridRowParams';
|
|
18
19
|
var missingOnProcessRowUpdateErrorWarning = buildWarning(['MUI: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, e.g. `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see http://mui.com/components/data-grid/editing/#persistence.'], 'error');
|
|
19
20
|
export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
@@ -402,7 +403,11 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
402
403
|
});
|
|
403
404
|
|
|
404
405
|
if (hasSomeFieldWithError) {
|
|
405
|
-
prevRowModesModel.current[id].mode = GridRowModes.Edit;
|
|
406
|
+
prevRowModesModel.current[id].mode = GridRowModes.Edit; // Revert the mode in the rowModesModel prop back to "edit"
|
|
407
|
+
|
|
408
|
+
updateRowInRowModesModel(id, {
|
|
409
|
+
mode: GridRowModes.Edit
|
|
410
|
+
});
|
|
406
411
|
return;
|
|
407
412
|
}
|
|
408
413
|
|
|
@@ -593,7 +598,8 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
593
598
|
var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef); // Update the ref here because updateStateToStopRowEditMode may change it later
|
|
594
599
|
|
|
595
600
|
var copyOfPrevRowModesModel = prevRowModesModel.current;
|
|
596
|
-
prevRowModesModel.current = rowModesModel;
|
|
601
|
+
prevRowModesModel.current = deepClone(rowModesModel); // Do a deep-clone because the attributes might be changed later
|
|
602
|
+
|
|
597
603
|
Object.entries(rowModesModel).forEach(function (_ref5) {
|
|
598
604
|
var _copyOfPrevRowModesMo, _idToIdLookup$id;
|
|
599
605
|
|
|
@@ -79,76 +79,78 @@ export var mergeStateWithFilterModel = function mergeStateWithFilterModel(filter
|
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
|
-
/**
|
|
83
|
-
* Generates a method to easily check if a row is matching the current filter model.
|
|
84
|
-
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
85
|
-
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
86
|
-
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
87
|
-
*/
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
83
|
+
var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, apiRef) {
|
|
84
|
+
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
96
87
|
|
|
97
|
-
|
|
88
|
+
var column = apiRef.current.getColumn(filterItem.columnField);
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
if (!column) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
102
93
|
|
|
103
|
-
|
|
94
|
+
var parsedValue;
|
|
104
95
|
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
if (column.valueParser) {
|
|
97
|
+
var _filterItem$value;
|
|
107
98
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
99
|
+
var parser = column.valueParser;
|
|
100
|
+
parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(function (x) {
|
|
101
|
+
return parser(x);
|
|
102
|
+
}) : parser(filterItem.value);
|
|
103
|
+
} else {
|
|
104
|
+
parsedValue = filterItem.value;
|
|
105
|
+
}
|
|
115
106
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
var newFilterItem = _extends({}, filterItem, {
|
|
108
|
+
value: parsedValue
|
|
109
|
+
});
|
|
119
110
|
|
|
120
|
-
|
|
111
|
+
var filterOperators = column.filterOperators;
|
|
121
112
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
113
|
+
if (!(filterOperators != null && filterOperators.length)) {
|
|
114
|
+
throw new Error("MUI: No filter operators found for column '".concat(column.field, "'."));
|
|
115
|
+
}
|
|
125
116
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
var filterOperator = filterOperators.find(function (operator) {
|
|
118
|
+
return operator.value === newFilterItem.operatorValue;
|
|
119
|
+
});
|
|
129
120
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
if (!filterOperator) {
|
|
122
|
+
throw new Error("MUI: No filter operator found for column '".concat(column.field, "' and operator value '").concat(newFilterItem.operatorValue, "'."));
|
|
123
|
+
}
|
|
133
124
|
|
|
134
|
-
|
|
125
|
+
var applyFilterOnRow = filterOperator.getApplyFilterFn(newFilterItem, column);
|
|
135
126
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
127
|
+
if (typeof applyFilterOnRow !== 'function') {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
139
130
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
131
|
+
var fn = function fn(rowId) {
|
|
132
|
+
var cellParams = apiRef.current.getCellParams(rowId, newFilterItem.columnField);
|
|
133
|
+
return applyFilterOnRow(cellParams);
|
|
134
|
+
};
|
|
144
135
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
136
|
+
return {
|
|
137
|
+
fn: fn,
|
|
138
|
+
item: newFilterItem
|
|
149
139
|
};
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Generates a method to easily check if a row is matching the current filter model.
|
|
143
|
+
* @param {GridFilterModel} filterModel The model with which we want to filter the rows.
|
|
144
|
+
* @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
|
|
145
|
+
* @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
|
|
146
|
+
*/
|
|
147
|
+
|
|
150
148
|
|
|
151
|
-
|
|
149
|
+
export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterItemsApplier(filterModel, apiRef) {
|
|
150
|
+
var items = filterModel.items;
|
|
151
|
+
var appliers = items.map(function (item) {
|
|
152
|
+
return getFilterCallbackFromItem(item, apiRef);
|
|
153
|
+
}).filter(function (callback) {
|
|
152
154
|
return !!callback;
|
|
153
155
|
});
|
|
154
156
|
|
|
@@ -242,9 +244,12 @@ export var buildAggregatedFilterApplier = function buildAggregatedFilterApplier(
|
|
|
242
244
|
};
|
|
243
245
|
};
|
|
244
246
|
};
|
|
245
|
-
export var passFilterLogic = function passFilterLogic(allFilterItemResults, allQuickFilterResults, filterModel) {
|
|
247
|
+
export var passFilterLogic = function passFilterLogic(allFilterItemResults, allQuickFilterResults, filterModel, apiRef) {
|
|
246
248
|
var _filterModel$quickFil2, _filterModel$linkOper;
|
|
247
249
|
|
|
250
|
+
var cleanedFilterItems = filterModel.items.filter(function (item) {
|
|
251
|
+
return getFilterCallbackFromItem(item, apiRef) !== null;
|
|
252
|
+
});
|
|
248
253
|
var cleanedAllFilterItemResults = allFilterItemResults.filter(function (result) {
|
|
249
254
|
return result != null;
|
|
250
255
|
});
|
|
@@ -264,13 +269,13 @@ export var passFilterLogic = function passFilterLogic(allFilterItemResults, allQ
|
|
|
264
269
|
};
|
|
265
270
|
|
|
266
271
|
if (linkOperator === GridLinkOperator.And) {
|
|
267
|
-
var passesAllFilters =
|
|
272
|
+
var passesAllFilters = cleanedFilterItems.every(filterItemPredicate);
|
|
268
273
|
|
|
269
274
|
if (!passesAllFilters) {
|
|
270
275
|
return false;
|
|
271
276
|
}
|
|
272
277
|
} else {
|
|
273
|
-
var passesSomeFilters =
|
|
278
|
+
var passesSomeFilters = cleanedFilterItems.some(filterItemPredicate);
|
|
274
279
|
|
|
275
280
|
if (!passesSomeFilters) {
|
|
276
281
|
return false;
|
|
@@ -288,7 +288,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
|
|
|
288
288
|
passingFilterItems = _params$isRowMatching.passingFilterItems,
|
|
289
289
|
passingQuickFilterValues = _params$isRowMatching.passingQuickFilterValues;
|
|
290
290
|
|
|
291
|
-
isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel);
|
|
291
|
+
isRowPassing = passFilterLogic([passingFilterItems], [passingQuickFilterValues], params.filterModel, apiRef);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
filteredRowsLookup[rowId] = isRowPassing;
|
|
@@ -134,8 +134,18 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPage.rows.length - 1);
|
|
137
|
-
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
138
137
|
var rowToFocus = currentPage.rows[rowIndexToFocus];
|
|
138
|
+
var colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
139
|
+
|
|
140
|
+
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
141
|
+
if (direction === 'left' || direction === 'below') {
|
|
142
|
+
columnIndexToFocus = colSpanInfo.leftVisibleCellIndex;
|
|
143
|
+
} else if (direction === 'right') {
|
|
144
|
+
columnIndexToFocus = colSpanInfo.rightVisibleCellIndex;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
139
149
|
var columnToFocus = visibleColumns[columnIndexToFocus];
|
|
140
150
|
apiRef.current.setCellFocus(rowToFocus.id, columnToFocus.field);
|
|
141
151
|
}, [apiRef, props.pagination, props.paginationMode]);
|
|
@@ -172,7 +182,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
172
182
|
});
|
|
173
183
|
});
|
|
174
184
|
}, [logger, apiRef]);
|
|
175
|
-
var
|
|
185
|
+
var handleCellMouseDown = React.useCallback(function (params) {
|
|
176
186
|
lastClickedCell.current = params;
|
|
177
187
|
}, []);
|
|
178
188
|
var handleDocumentClick = React.useCallback(function (event) {
|
|
@@ -259,7 +269,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
259
269
|
}, [apiRef, handleDocumentClick]);
|
|
260
270
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
261
271
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
262
|
-
useGridApiEventHandler(apiRef, '
|
|
272
|
+
useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
263
273
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
264
274
|
useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
|
|
265
275
|
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
@@ -37,6 +37,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
37
37
|
* @param {number} colIndex Index of the column to focus
|
|
38
38
|
* @param {number} rowIndex index of the row to focus
|
|
39
39
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
40
|
+
* TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()
|
|
40
41
|
*/
|
|
41
42
|
|
|
42
43
|
var goToCell = React.useCallback(function (colIndex, rowId) {
|
|
@@ -98,6 +99,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
98
99
|
case 'ArrowDown':
|
|
99
100
|
case 'Enter':
|
|
100
101
|
{
|
|
102
|
+
// TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API
|
|
101
103
|
// "Enter" is only triggered by the row / cell editing feature
|
|
102
104
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
103
105
|
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
7
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
7
|
-
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowIdsSelector, gridRowGroupingNameSelector } from './gridRowsSelector';
|
|
8
|
+
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowIdsSelector, gridRowGroupingNameSelector, gridRowsIdToIdLookupSelector } from './gridRowsSelector';
|
|
8
9
|
import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
9
10
|
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
10
11
|
import { gridSortedRowIdsSelector } from '../sorting/gridSortingSelector';
|
|
@@ -109,14 +110,14 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
109
110
|
} // we remove duplicate updates. A server can batch updates, and send several updates for the same row in one fn call.
|
|
110
111
|
|
|
111
112
|
|
|
112
|
-
var
|
|
113
|
+
var uniqueUpdates = new Map();
|
|
113
114
|
updates.forEach(function (update) {
|
|
114
115
|
var id = getRowIdFromRowModel(update, props.getRowId, 'A row was provided without id when calling updateRows():');
|
|
115
116
|
|
|
116
|
-
if (
|
|
117
|
-
|
|
117
|
+
if (uniqueUpdates.has(id)) {
|
|
118
|
+
uniqueUpdates.set(id, _extends({}, uniqueUpdates.get(id), update));
|
|
118
119
|
} else {
|
|
119
|
-
|
|
120
|
+
uniqueUpdates.set(id, update);
|
|
120
121
|
}
|
|
121
122
|
});
|
|
122
123
|
var deletedRowIds = [];
|
|
@@ -128,7 +129,7 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
128
129
|
idToIdLookup: _extends({}, prevCache.idToIdLookup),
|
|
129
130
|
ids: _toConsumableArray(prevCache.ids)
|
|
130
131
|
};
|
|
131
|
-
|
|
132
|
+
uniqueUpdates.forEach(function (partialRow, id) {
|
|
132
133
|
// eslint-disable-next-line no-underscore-dangle
|
|
133
134
|
if (partialRow._action === 'delete') {
|
|
134
135
|
delete newCache.idRowsLookup[id];
|
|
@@ -264,8 +265,71 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
264
265
|
})
|
|
265
266
|
});
|
|
266
267
|
});
|
|
267
|
-
apiRef.current.
|
|
268
|
+
apiRef.current.publishEvent('rowsSet');
|
|
268
269
|
}, [apiRef, logger]);
|
|
270
|
+
var replaceRows = React.useCallback(function (firstRowToRender, newRows) {
|
|
271
|
+
if (props.signature === GridSignature.DataGrid && newRows.length > 1) {
|
|
272
|
+
throw new Error(["MUI: You can't replace rows using `apiRef.current.unstable_replaceRows` on the DataGrid.", 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (newRows.length === 0) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
var allRows = gridRowIdsSelector(apiRef);
|
|
280
|
+
|
|
281
|
+
var updatedRows = _toConsumableArray(allRows);
|
|
282
|
+
|
|
283
|
+
var idRowsLookup = gridRowsLookupSelector(apiRef);
|
|
284
|
+
var idToIdLookup = gridRowsIdToIdLookupSelector(apiRef);
|
|
285
|
+
var tree = gridRowTreeSelector(apiRef);
|
|
286
|
+
|
|
287
|
+
var updatedIdRowsLookup = _extends({}, idRowsLookup);
|
|
288
|
+
|
|
289
|
+
var updatedIdToIdLookup = _extends({}, idToIdLookup);
|
|
290
|
+
|
|
291
|
+
var updatedTree = _extends({}, tree);
|
|
292
|
+
|
|
293
|
+
var newRowEntries = newRows.map(function (newRowModel) {
|
|
294
|
+
var rowId = getRowIdFromRowModel(newRowModel, props.getRowId, 'A row was provided without id when calling replaceRows().');
|
|
295
|
+
return {
|
|
296
|
+
id: rowId,
|
|
297
|
+
model: newRowModel
|
|
298
|
+
};
|
|
299
|
+
});
|
|
300
|
+
newRowEntries.forEach(function (row, index) {
|
|
301
|
+
var _updatedRows$splice = updatedRows.splice(firstRowToRender + index, 1, row.id),
|
|
302
|
+
_updatedRows$splice2 = _slicedToArray(_updatedRows$splice, 1),
|
|
303
|
+
replacedRowId = _updatedRows$splice2[0];
|
|
304
|
+
|
|
305
|
+
delete updatedIdRowsLookup[replacedRowId];
|
|
306
|
+
delete updatedIdToIdLookup[replacedRowId];
|
|
307
|
+
delete updatedTree[replacedRowId];
|
|
308
|
+
});
|
|
309
|
+
newRowEntries.forEach(function (row) {
|
|
310
|
+
var rowTreeNodeConfig = {
|
|
311
|
+
id: row.id,
|
|
312
|
+
parent: null,
|
|
313
|
+
depth: 0,
|
|
314
|
+
groupingKey: null,
|
|
315
|
+
groupingField: null
|
|
316
|
+
};
|
|
317
|
+
updatedIdRowsLookup[row.id] = row.model;
|
|
318
|
+
updatedIdToIdLookup[row.id] = row.id;
|
|
319
|
+
updatedTree[row.id] = rowTreeNodeConfig;
|
|
320
|
+
});
|
|
321
|
+
apiRef.current.setState(function (state) {
|
|
322
|
+
return _extends({}, state, {
|
|
323
|
+
rows: _extends({}, state.rows, {
|
|
324
|
+
idRowsLookup: updatedIdRowsLookup,
|
|
325
|
+
idToIdLookup: updatedIdToIdLookup,
|
|
326
|
+
tree: updatedTree,
|
|
327
|
+
ids: updatedRows
|
|
328
|
+
})
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
apiRef.current.publishEvent('rowsSet');
|
|
332
|
+
}, [apiRef, props.signature, props.getRowId]);
|
|
269
333
|
var rowApi = {
|
|
270
334
|
getRow: getRow,
|
|
271
335
|
getRowModels: getRowModels,
|
|
@@ -277,7 +341,8 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
277
341
|
setRowChildrenExpansion: setRowChildrenExpansion,
|
|
278
342
|
getRowNode: getRowNode,
|
|
279
343
|
getRowIndexRelativeToVisibleRows: getRowIndexRelativeToVisibleRows,
|
|
280
|
-
getRowGroupChildren: getRowGroupChildren
|
|
344
|
+
getRowGroupChildren: getRowGroupChildren,
|
|
345
|
+
unstable_replaceRows: replaceRows
|
|
281
346
|
};
|
|
282
347
|
/**
|
|
283
348
|
* EVENTS
|