@mui/x-data-grid 7.22.1 → 7.22.3
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 +139 -0
- package/colDef/gridBooleanOperators.js +4 -6
- package/components/GridDetailPanels.js +0 -1
- package/components/GridPinnedRows.js +0 -1
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +1 -1
- package/components/base/GridOverlays.js +5 -6
- package/components/cell/GridCell.d.ts +41 -3
- package/components/cell/GridCell.js +1 -9
- package/components/cell/GridEditInputCell.js +0 -67
- package/components/columnsManagement/GridColumnsManagement.d.ts +2 -0
- package/components/columnsManagement/GridColumnsManagement.js +53 -6
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.js +14 -5
- package/components/toolbar/GridToolbar.d.ts +2 -2
- package/components/toolbar/GridToolbar.js +12 -4
- package/components/toolbar/GridToolbarExport.d.ts +2 -2
- package/components/toolbar/GridToolbarExport.js +4 -3
- package/components/toolbar/index.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +1 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +23 -4
- package/hooks/features/editing/useGridRowEditing.js +23 -2
- package/hooks/features/export/useGridCsvExport.js +1 -1
- package/hooks/features/export/useGridPrintExport.js +1 -1
- package/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +30 -16
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +1 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/hooks/utils/useGridSelector.d.ts +3 -2
- package/hooks/utils/useGridSelector.js +27 -2
- package/index.d.ts +0 -1
- package/index.js +1 -1
- package/locales/arSD.js +1 -0
- package/locales/beBY.js +1 -0
- package/locales/bgBG.js +2 -0
- package/locales/csCZ.js +2 -0
- package/locales/daDK.js +2 -0
- package/locales/deDE.js +2 -0
- package/locales/elGR.js +1 -0
- package/locales/esES.js +6 -4
- package/locales/faIR.js +2 -0
- package/locales/fiFI.js +2 -0
- package/locales/frFR.js +2 -0
- package/locales/heIL.js +2 -0
- package/locales/hrHR.js +2 -0
- package/locales/huHU.js +2 -0
- package/locales/isIS.js +1 -0
- package/locales/itIT.js +2 -0
- package/locales/jaJP.js +2 -0
- package/locales/koKR.js +1 -0
- package/locales/nbNO.js +2 -0
- package/locales/nlNL.js +2 -0
- package/locales/nnNO.js +2 -0
- package/locales/plPL.js +1 -0
- package/locales/ptBR.js +2 -0
- package/locales/ptPT.js +2 -0
- package/locales/roRO.js +1 -0
- package/locales/ruRU.js +2 -0
- package/locales/skSK.js +1 -0
- package/locales/svSE.js +6 -5
- package/locales/trTR.js +4 -2
- package/locales/ukUA.js +1 -0
- package/locales/urPK.js +1 -0
- package/locales/viVN.js +2 -0
- package/locales/zhCN.js +6 -4
- package/locales/zhHK.js +1 -0
- package/locales/zhTW.js +1 -0
- package/models/api/gridLocaleTextApi.d.ts +1 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/colDef/gridBooleanOperators.js +4 -6
- package/modern/components/GridDetailPanels.js +0 -1
- package/modern/components/GridPinnedRows.js +0 -1
- package/modern/components/GridRow.js +1 -1
- package/modern/components/base/GridOverlays.js +5 -6
- package/modern/components/cell/GridCell.js +1 -9
- package/modern/components/cell/GridEditInputCell.js +0 -67
- package/modern/components/columnsManagement/GridColumnsManagement.js +53 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +14 -5
- package/modern/components/toolbar/GridToolbar.js +12 -4
- package/modern/components/toolbar/GridToolbarExport.js +4 -3
- package/modern/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +1 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +23 -4
- package/modern/hooks/features/editing/useGridRowEditing.js +23 -2
- package/modern/hooks/features/export/useGridCsvExport.js +1 -1
- package/modern/hooks/features/export/useGridPrintExport.js +1 -1
- package/modern/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +30 -16
- package/modern/hooks/features/rows/gridRowsUtils.js +1 -5
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/modern/hooks/utils/useGridSelector.js +27 -2
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +1 -0
- package/modern/locales/beBY.js +1 -0
- package/modern/locales/bgBG.js +2 -0
- package/modern/locales/csCZ.js +2 -0
- package/modern/locales/daDK.js +2 -0
- package/modern/locales/deDE.js +2 -0
- package/modern/locales/elGR.js +1 -0
- package/modern/locales/esES.js +6 -4
- package/modern/locales/faIR.js +2 -0
- package/modern/locales/fiFI.js +2 -0
- package/modern/locales/frFR.js +2 -0
- package/modern/locales/heIL.js +2 -0
- package/modern/locales/hrHR.js +2 -0
- package/modern/locales/huHU.js +2 -0
- package/modern/locales/isIS.js +1 -0
- package/modern/locales/itIT.js +2 -0
- package/modern/locales/jaJP.js +2 -0
- package/modern/locales/koKR.js +1 -0
- package/modern/locales/nbNO.js +2 -0
- package/modern/locales/nlNL.js +2 -0
- package/modern/locales/nnNO.js +2 -0
- package/modern/locales/plPL.js +1 -0
- package/modern/locales/ptBR.js +2 -0
- package/modern/locales/ptPT.js +2 -0
- package/modern/locales/roRO.js +1 -0
- package/modern/locales/ruRU.js +2 -0
- package/modern/locales/skSK.js +1 -0
- package/modern/locales/svSE.js +6 -5
- package/modern/locales/trTR.js +4 -2
- package/modern/locales/ukUA.js +1 -0
- package/modern/locales/urPK.js +1 -0
- package/modern/locales/viVN.js +2 -0
- package/modern/locales/zhCN.js +6 -4
- package/modern/locales/zhHK.js +1 -0
- package/modern/locales/zhTW.js +1 -0
- package/modern/utils/createSelector.js +11 -1
- package/modern/utils/utils.js +1 -3
- package/node/colDef/gridBooleanOperators.js +3 -5
- package/node/components/GridDetailPanels.js +0 -1
- package/node/components/GridPinnedRows.js +0 -1
- package/node/components/GridRow.js +1 -1
- package/node/components/base/GridOverlays.js +5 -6
- package/node/components/cell/GridCell.js +1 -9
- package/node/components/cell/GridEditInputCell.js +0 -67
- package/node/components/columnsManagement/GridColumnsManagement.js +53 -6
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +16 -5
- package/node/components/toolbar/GridToolbar.js +12 -4
- package/node/components/toolbar/GridToolbarExport.js +4 -3
- package/node/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +1 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/node/hooks/features/editing/useGridCellEditing.js +23 -4
- package/node/hooks/features/editing/useGridRowEditing.js +23 -2
- package/node/hooks/features/export/useGridCsvExport.js +2 -2
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/node/hooks/features/rowSelection/useGridRowSelection.js +29 -15
- package/node/hooks/features/rows/gridRowsUtils.js +2 -8
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/hooks/utils/useGridSelector.js +29 -3
- package/node/index.js +1 -1
- package/node/locales/arSD.js +1 -0
- package/node/locales/beBY.js +1 -0
- package/node/locales/bgBG.js +2 -0
- package/node/locales/csCZ.js +2 -0
- package/node/locales/daDK.js +2 -0
- package/node/locales/deDE.js +2 -0
- package/node/locales/elGR.js +1 -0
- package/node/locales/esES.js +6 -4
- package/node/locales/faIR.js +2 -0
- package/node/locales/fiFI.js +2 -0
- package/node/locales/frFR.js +2 -0
- package/node/locales/heIL.js +2 -0
- package/node/locales/hrHR.js +2 -0
- package/node/locales/huHU.js +2 -0
- package/node/locales/isIS.js +1 -0
- package/node/locales/itIT.js +2 -0
- package/node/locales/jaJP.js +2 -0
- package/node/locales/koKR.js +1 -0
- package/node/locales/nbNO.js +2 -0
- package/node/locales/nlNL.js +2 -0
- package/node/locales/nnNO.js +2 -0
- package/node/locales/plPL.js +1 -0
- package/node/locales/ptBR.js +2 -0
- package/node/locales/ptPT.js +2 -0
- package/node/locales/roRO.js +1 -0
- package/node/locales/ruRU.js +2 -0
- package/node/locales/skSK.js +1 -0
- package/node/locales/svSE.js +6 -5
- package/node/locales/trTR.js +4 -2
- package/node/locales/ukUA.js +1 -0
- package/node/locales/urPK.js +1 -0
- package/node/locales/viVN.js +2 -0
- package/node/locales/zhCN.js +6 -4
- package/node/locales/zhHK.js +1 -0
- package/node/locales/zhTW.js +1 -0
- package/node/utils/createSelector.js +11 -1
- package/node/utils/utils.js +1 -3
- package/package.json +1 -1
- package/utils/createSelector.d.ts +1 -1
- package/utils/createSelector.js +11 -1
- package/utils/utils.js +1 -3
|
@@ -9,7 +9,6 @@ exports.renderEditInputCell = exports.GridEditInputCell = void 0;
|
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
12
|
var _utils = require("@mui/utils");
|
|
14
13
|
var _styles = require("@mui/material/styles");
|
|
15
14
|
var _InputBase = _interopRequireDefault(require("@mui/material/InputBase"));
|
|
@@ -102,71 +101,5 @@ const GridEditInputCell = exports.GridEditInputCell = /*#__PURE__*/React.forward
|
|
|
102
101
|
}) : undefined
|
|
103
102
|
}, other));
|
|
104
103
|
});
|
|
105
|
-
process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
106
|
-
// ----------------------------- Warning --------------------------------
|
|
107
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
108
|
-
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
109
|
-
// ----------------------------------------------------------------------
|
|
110
|
-
/**
|
|
111
|
-
* GridApi that let you manipulate the grid.
|
|
112
|
-
*/
|
|
113
|
-
api: _propTypes.default.object.isRequired,
|
|
114
|
-
/**
|
|
115
|
-
* The mode of the cell.
|
|
116
|
-
*/
|
|
117
|
-
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
|
|
118
|
-
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
119
|
-
/**
|
|
120
|
-
* The column of the row that the current cell belongs to.
|
|
121
|
-
*/
|
|
122
|
-
colDef: _propTypes.default.object.isRequired,
|
|
123
|
-
debounceMs: _propTypes.default.number,
|
|
124
|
-
/**
|
|
125
|
-
* The column field of the cell that triggered the event.
|
|
126
|
-
*/
|
|
127
|
-
field: _propTypes.default.string.isRequired,
|
|
128
|
-
/**
|
|
129
|
-
* The cell value formatted with the column valueFormatter.
|
|
130
|
-
*/
|
|
131
|
-
formattedValue: _propTypes.default.any,
|
|
132
|
-
/**
|
|
133
|
-
* If true, the cell is the active element.
|
|
134
|
-
*/
|
|
135
|
-
hasFocus: _propTypes.default.bool.isRequired,
|
|
136
|
-
/**
|
|
137
|
-
* The grid row id.
|
|
138
|
-
*/
|
|
139
|
-
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
140
|
-
/**
|
|
141
|
-
* If true, the cell is editable.
|
|
142
|
-
*/
|
|
143
|
-
isEditable: _propTypes.default.bool,
|
|
144
|
-
isProcessingProps: _propTypes.default.bool,
|
|
145
|
-
isValidating: _propTypes.default.bool,
|
|
146
|
-
/**
|
|
147
|
-
* Callback called when the value is changed by the user.
|
|
148
|
-
* @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
|
|
149
|
-
* @param {Date | null} newValue The value that is going to be passed to `apiRef.current.setEditCellValue`.
|
|
150
|
-
* @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
|
|
151
|
-
*/
|
|
152
|
-
onValueChange: _propTypes.default.func,
|
|
153
|
-
/**
|
|
154
|
-
* The row model of the row that the current cell belongs to.
|
|
155
|
-
*/
|
|
156
|
-
row: _propTypes.default.any.isRequired,
|
|
157
|
-
/**
|
|
158
|
-
* The node of the row that the current cell belongs to.
|
|
159
|
-
*/
|
|
160
|
-
rowNode: _propTypes.default.object.isRequired,
|
|
161
|
-
/**
|
|
162
|
-
* the tabIndex value.
|
|
163
|
-
*/
|
|
164
|
-
tabIndex: _propTypes.default.oneOf([-1, 0]).isRequired,
|
|
165
|
-
/**
|
|
166
|
-
* The cell value.
|
|
167
|
-
* If the column has `valueGetter`, use `params.row` to directly access the fields.
|
|
168
|
-
*/
|
|
169
|
-
value: _propTypes.default.any
|
|
170
|
-
} : void 0;
|
|
171
104
|
const renderEditInputCell = params => /*#__PURE__*/(0, _jsxRuntime.jsx)(GridEditInputCell, (0, _extends2.default)({}, params));
|
|
172
105
|
exports.renderEditInputCell = renderEditInputCell;
|
|
@@ -12,6 +12,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
12
12
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
13
13
|
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
|
+
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
16
|
+
var _InputBase = require("@mui/material/InputBase");
|
|
15
17
|
var _gridColumnsSelector = require("../../hooks/features/columns/gridColumnsSelector");
|
|
16
18
|
var _useGridSelector = require("../../hooks/utils/useGridSelector");
|
|
17
19
|
var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
|
|
@@ -29,6 +31,7 @@ const useUtilityClasses = ownerState => {
|
|
|
29
31
|
const slots = {
|
|
30
32
|
root: ['columnsManagement'],
|
|
31
33
|
header: ['columnsManagementHeader'],
|
|
34
|
+
searchInput: ['columnsManagementSearchInput'],
|
|
32
35
|
footer: ['columnsManagementFooter'],
|
|
33
36
|
row: ['columnsManagementRow']
|
|
34
37
|
};
|
|
@@ -51,7 +54,8 @@ function GridColumnsManagement(props) {
|
|
|
51
54
|
disableShowHideToggle = false,
|
|
52
55
|
disableResetButton = false,
|
|
53
56
|
toggleAllMode = 'all',
|
|
54
|
-
getTogglableColumns
|
|
57
|
+
getTogglableColumns,
|
|
58
|
+
searchInputProps
|
|
55
59
|
} = props;
|
|
56
60
|
const isResetDisabled = React.useMemo(() => (0, _utils.checkColumnVisibilityModelsSame)(columnVisibilityModel, initialColumnVisibilityModel), [columnVisibilityModel, initialColumnVisibilityModel]);
|
|
57
61
|
const sortedColumns = React.useMemo(() => {
|
|
@@ -118,28 +122,52 @@ function GridColumnsManagement(props) {
|
|
|
118
122
|
}
|
|
119
123
|
return false;
|
|
120
124
|
};
|
|
125
|
+
const handleSearchReset = React.useCallback(() => {
|
|
126
|
+
setSearchValue('');
|
|
127
|
+
searchInputRef.current.focus();
|
|
128
|
+
}, []);
|
|
121
129
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
122
130
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnsManagementHeader, {
|
|
123
131
|
className: classes.header,
|
|
124
132
|
ownerState: rootProps,
|
|
125
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
133
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(SearchInput, (0, _extends2.default)({
|
|
134
|
+
as: rootProps.slots.baseTextField,
|
|
135
|
+
ownerState: rootProps,
|
|
126
136
|
placeholder: apiRef.current.getLocaleText('columnsManagementSearchTitle'),
|
|
127
137
|
inputRef: searchInputRef,
|
|
138
|
+
className: classes.searchInput,
|
|
128
139
|
value: searchValue,
|
|
129
140
|
onChange: handleSearchValueChange,
|
|
130
141
|
variant: "outlined",
|
|
131
142
|
size: "small",
|
|
143
|
+
type: "search",
|
|
132
144
|
InputProps: {
|
|
133
145
|
startAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputAdornment, {
|
|
134
146
|
position: "start",
|
|
135
147
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.quickFilterIcon, {})
|
|
136
148
|
}),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
149
|
+
endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
|
|
150
|
+
"aria-label": apiRef.current.getLocaleText('columnsManagementDeleteIconLabel'),
|
|
151
|
+
size: "small",
|
|
152
|
+
sx: [searchValue ? {
|
|
153
|
+
visibility: 'visible'
|
|
154
|
+
} : {
|
|
155
|
+
visibility: 'hidden'
|
|
156
|
+
}],
|
|
157
|
+
tabIndex: -1,
|
|
158
|
+
onClick: handleSearchReset
|
|
159
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
160
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.quickFilterClearIcon, {
|
|
161
|
+
fontSize: "small"
|
|
162
|
+
})
|
|
163
|
+
}))
|
|
164
|
+
},
|
|
165
|
+
inputProps: {
|
|
166
|
+
'aria-label': apiRef.current.getLocaleText('columnsManagementSearchTitle')
|
|
140
167
|
},
|
|
168
|
+
autoComplete: "off",
|
|
141
169
|
fullWidth: true
|
|
142
|
-
}, rootProps.slotProps?.baseTextField))
|
|
170
|
+
}, rootProps.slotProps?.baseTextField, searchInputProps))
|
|
143
171
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsManagementBody, {
|
|
144
172
|
className: classes.root,
|
|
145
173
|
ownerState: rootProps,
|
|
@@ -214,6 +242,7 @@ process.env.NODE_ENV !== "production" ? GridColumnsManagement.propTypes = {
|
|
|
214
242
|
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
215
243
|
*/
|
|
216
244
|
getTogglableColumns: _propTypes.default.func,
|
|
245
|
+
searchInputProps: _propTypes.default.object,
|
|
217
246
|
searchPredicate: _propTypes.default.func,
|
|
218
247
|
sort: _propTypes.default.oneOf(['asc', 'desc']),
|
|
219
248
|
/**
|
|
@@ -248,6 +277,24 @@ const GridColumnsManagementHeader = (0, _styles.styled)('div', {
|
|
|
248
277
|
}) => ({
|
|
249
278
|
padding: theme.spacing(1.5, 3)
|
|
250
279
|
}));
|
|
280
|
+
const SearchInput = (0, _styles.styled)(_TextField.default, {
|
|
281
|
+
name: 'MuiDataGrid',
|
|
282
|
+
slot: 'ColumnsManagementSearchInput',
|
|
283
|
+
overridesResolver: (props, styles) => styles.columnsManagementSearchInput
|
|
284
|
+
})(({
|
|
285
|
+
theme
|
|
286
|
+
}) => ({
|
|
287
|
+
[`& .${_InputBase.inputBaseClasses.root}`]: {
|
|
288
|
+
padding: theme.spacing(0, 1.5, 0, 1.5)
|
|
289
|
+
},
|
|
290
|
+
[`& .${_InputBase.inputBaseClasses.input}::-webkit-search-decoration,
|
|
291
|
+
& .${_InputBase.inputBaseClasses.input}::-webkit-search-cancel-button,
|
|
292
|
+
& .${_InputBase.inputBaseClasses.input}::-webkit-search-results-button,
|
|
293
|
+
& .${_InputBase.inputBaseClasses.input}::-webkit-search-results-decoration`]: {
|
|
294
|
+
/* clears the 'X' icon from Chrome */
|
|
295
|
+
display: 'none'
|
|
296
|
+
}
|
|
297
|
+
}));
|
|
251
298
|
const GridColumnsManagementFooter = (0, _styles.styled)('div', {
|
|
252
299
|
name: 'MuiDataGrid',
|
|
253
300
|
slot: 'ColumnsManagementFooter',
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.GridFilterInputBoolean = GridFilterInputBoolean;
|
|
9
|
+
exports.sanitizeFilterItemValue = void 0;
|
|
9
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -15,6 +16,16 @@ var _styles = require("@mui/material/styles");
|
|
|
15
16
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
16
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
18
|
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "variant", "InputLabelProps"];
|
|
19
|
+
const sanitizeFilterItemValue = value => {
|
|
20
|
+
if (String(value).toLowerCase() === 'true') {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (String(value).toLowerCase() === 'false') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
};
|
|
28
|
+
exports.sanitizeFilterItemValue = sanitizeFilterItemValue;
|
|
18
29
|
const BooleanOperatorContainer = (0, _styles.styled)('div')({
|
|
19
30
|
display: 'flex',
|
|
20
31
|
alignItems: 'center',
|
|
@@ -35,7 +46,7 @@ function GridFilterInputBoolean(props) {
|
|
|
35
46
|
variant = 'standard'
|
|
36
47
|
} = props,
|
|
37
48
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
38
|
-
const [filterValueState, setFilterValueState] = React.useState(item.value
|
|
49
|
+
const [filterValueState, setFilterValueState] = React.useState(sanitizeFilterItemValue(item.value));
|
|
39
50
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
40
51
|
const labelId = (0, _utils.unstable_useId)();
|
|
41
52
|
const selectId = (0, _utils.unstable_useId)();
|
|
@@ -43,14 +54,14 @@ function GridFilterInputBoolean(props) {
|
|
|
43
54
|
const isSelectNative = baseSelectProps.native ?? false;
|
|
44
55
|
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
45
56
|
const onFilterChange = React.useCallback(event => {
|
|
46
|
-
const value = event.target.value;
|
|
57
|
+
const value = sanitizeFilterItemValue(event.target.value);
|
|
47
58
|
setFilterValueState(value);
|
|
48
59
|
applyValue((0, _extends2.default)({}, item, {
|
|
49
|
-
value
|
|
60
|
+
value
|
|
50
61
|
}));
|
|
51
62
|
}, [applyValue, item]);
|
|
52
63
|
React.useEffect(() => {
|
|
53
|
-
setFilterValueState(item.value
|
|
64
|
+
setFilterValueState(sanitizeFilterItemValue(item.value));
|
|
54
65
|
}, [item.value]);
|
|
55
66
|
const label = labelProp ?? apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
56
67
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(BooleanOperatorContainer, {
|
|
@@ -65,7 +76,7 @@ function GridFilterInputBoolean(props) {
|
|
|
65
76
|
labelId: labelId,
|
|
66
77
|
id: selectId,
|
|
67
78
|
label: label,
|
|
68
|
-
value: filterValueState,
|
|
79
|
+
value: filterValueState === undefined ? '' : String(filterValueState),
|
|
69
80
|
onChange: onFilterChange,
|
|
70
81
|
variant: variant,
|
|
71
82
|
notched: variant === 'outlined' ? true : undefined,
|
|
@@ -22,14 +22,15 @@ const _excluded = ["className", "csvOptions", "printOptions", "excelOptions", "s
|
|
|
22
22
|
const GridToolbar = exports.GridToolbar = /*#__PURE__*/React.forwardRef(function GridToolbar(props, ref) {
|
|
23
23
|
// TODO v7: think about where export option should be passed.
|
|
24
24
|
// from slotProps={{ toolbarExport: { ...exportOption } }} seems to be more appropriate
|
|
25
|
-
const
|
|
25
|
+
const _ref = props,
|
|
26
|
+
{
|
|
26
27
|
csvOptions,
|
|
27
28
|
printOptions,
|
|
28
29
|
excelOptions,
|
|
29
30
|
showQuickFilter = false,
|
|
30
31
|
quickFilterProps = {}
|
|
31
|
-
} =
|
|
32
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(
|
|
32
|
+
} = _ref,
|
|
33
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
33
34
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
34
35
|
if (rootProps.disableColumnFilter && rootProps.disableColumnSelector && rootProps.disableDensitySelector && !showQuickFilter) {
|
|
35
36
|
return null;
|
|
@@ -40,7 +41,7 @@ const GridToolbar = exports.GridToolbar = /*#__PURE__*/React.forwardRef(function
|
|
|
40
41
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GridToolbarColumnsButton.GridToolbarColumnsButton, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridToolbarFilterButton.GridToolbarFilterButton, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridToolbarDensitySelector.GridToolbarDensitySelector, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridToolbarExport.GridToolbarExport, {
|
|
41
42
|
csvOptions: csvOptions,
|
|
42
43
|
printOptions: printOptions
|
|
43
|
-
//
|
|
44
|
+
// @ts-ignore
|
|
44
45
|
,
|
|
45
46
|
excelOptions: excelOptions
|
|
46
47
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -55,6 +56,8 @@ process.env.NODE_ENV !== "production" ? GridToolbar.propTypes = {
|
|
|
55
56
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
56
57
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
57
58
|
// ----------------------------------------------------------------------
|
|
59
|
+
csvOptions: _propTypes.default.object,
|
|
60
|
+
printOptions: _propTypes.default.object,
|
|
58
61
|
/**
|
|
59
62
|
* Props passed to the quick filter component.
|
|
60
63
|
*/
|
|
@@ -64,5 +67,10 @@ process.env.NODE_ENV !== "production" ? GridToolbar.propTypes = {
|
|
|
64
67
|
* @default false
|
|
65
68
|
*/
|
|
66
69
|
showQuickFilter: _propTypes.default.bool,
|
|
70
|
+
/**
|
|
71
|
+
* The props used for each slot inside.
|
|
72
|
+
* @default {}
|
|
73
|
+
*/
|
|
74
|
+
slotProps: _propTypes.default.object,
|
|
67
75
|
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
|
|
68
76
|
} : void 0;
|
|
@@ -92,12 +92,13 @@ process.env.NODE_ENV !== "production" ? GridPrintExportMenuItem.propTypes = {
|
|
|
92
92
|
})
|
|
93
93
|
} : void 0;
|
|
94
94
|
const GridToolbarExport = exports.GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExport(props, ref) {
|
|
95
|
-
const
|
|
95
|
+
const _ref = props,
|
|
96
|
+
{
|
|
96
97
|
csvOptions = {},
|
|
97
98
|
printOptions = {},
|
|
98
99
|
excelOptions
|
|
99
|
-
} =
|
|
100
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(
|
|
100
|
+
} = _ref,
|
|
101
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded3);
|
|
101
102
|
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
102
103
|
const preProcessedButtons = apiRef.current.unstable_applyPipeProcessors('exportMenu', [], {
|
|
103
104
|
excelOptions,
|
|
@@ -77,6 +77,9 @@ const GridVirtualScrollbar = exports.GridVirtualScrollbar = /*#__PURE__*/React.f
|
|
|
77
77
|
const onScrollerScroll = (0, _utils.unstable_useEventCallback)(() => {
|
|
78
78
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
79
79
|
const scrollbar = scrollbarRef.current;
|
|
80
|
+
if (!scrollbar) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
80
83
|
if (scroller[propertyScroll] === lastPosition.current) {
|
|
81
84
|
return;
|
|
82
85
|
}
|
|
@@ -92,6 +95,9 @@ const GridVirtualScrollbar = exports.GridVirtualScrollbar = /*#__PURE__*/React.f
|
|
|
92
95
|
const onScrollbarScroll = (0, _utils.unstable_useEventCallback)(() => {
|
|
93
96
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
94
97
|
const scrollbar = scrollbarRef.current;
|
|
98
|
+
if (!scrollbar) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
95
101
|
if (isLocked.current) {
|
|
96
102
|
isLocked.current = false;
|
|
97
103
|
return;
|
|
@@ -9,4 +9,4 @@ var _utils = require("@mui/utils");
|
|
|
9
9
|
function getDataGridUtilityClass(slot) {
|
|
10
10
|
return (0, _utils.unstable_generateUtilityClass)('MuiDataGrid', slot);
|
|
11
11
|
}
|
|
12
|
-
const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--lastUnpinned', 'columnHeader--siblingFocused', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'groupingCriteriaCellLoadingContainer', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
12
|
+
const gridClasses = exports.gridClasses = (0, _utils.unstable_generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--lastUnpinned', 'columnHeader--siblingFocused', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementSearchInput', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'groupingCriteriaCellLoadingContainer', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -38,6 +38,7 @@ const GRID_DEFAULT_LOCALE_TEXT = exports.GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
38
38
|
columnsManagementNoColumns: 'No columns',
|
|
39
39
|
columnsManagementShowHideAllText: 'Show/Hide All',
|
|
40
40
|
columnsManagementReset: 'Reset',
|
|
41
|
+
columnsManagementDeleteIconLabel: 'Clear',
|
|
41
42
|
// Filter panel text
|
|
42
43
|
filterPanelAddFilter: 'Add filter',
|
|
43
44
|
filterPanelRemoveAll: 'Remove all',
|
|
@@ -299,7 +299,7 @@ const useGridColumnHeaders = props => {
|
|
|
299
299
|
pinnedPosition: pinnedPosition,
|
|
300
300
|
style: style,
|
|
301
301
|
indexInSection: indexInSection,
|
|
302
|
-
sectionLength:
|
|
302
|
+
sectionLength: visibleColumnGroupHeader.length,
|
|
303
303
|
gridHasFiller: gridHasFiller
|
|
304
304
|
}, index);
|
|
305
305
|
});
|
|
@@ -249,26 +249,45 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
249
249
|
mode: _gridEditRowModel.GridCellModes.Edit
|
|
250
250
|
}, other));
|
|
251
251
|
}, [throwIfNotEditable, throwIfNotInMode, updateFieldInCellModesModel]);
|
|
252
|
-
const updateStateToStartCellEditMode = (0, _utils.unstable_useEventCallback)(params => {
|
|
252
|
+
const updateStateToStartCellEditMode = (0, _utils.unstable_useEventCallback)(async params => {
|
|
253
253
|
const {
|
|
254
254
|
id,
|
|
255
255
|
field,
|
|
256
256
|
deleteValue,
|
|
257
257
|
initialValue
|
|
258
258
|
} = params;
|
|
259
|
-
|
|
259
|
+
const value = apiRef.current.getCellValue(id, field);
|
|
260
|
+
let newValue = value;
|
|
260
261
|
if (deleteValue) {
|
|
261
262
|
newValue = (0, _utils3.getDefaultCellValue)(apiRef.current.getColumn(field));
|
|
262
263
|
} else if (initialValue) {
|
|
263
264
|
newValue = initialValue;
|
|
264
265
|
}
|
|
265
|
-
const
|
|
266
|
+
const column = apiRef.current.getColumn(field);
|
|
267
|
+
const shouldProcessEditCellProps = !!column.preProcessEditCellProps && deleteValue;
|
|
268
|
+
let newProps = {
|
|
266
269
|
value: newValue,
|
|
267
270
|
error: false,
|
|
268
|
-
isProcessingProps:
|
|
271
|
+
isProcessingProps: shouldProcessEditCellProps
|
|
269
272
|
};
|
|
270
273
|
updateOrDeleteFieldState(id, field, newProps);
|
|
271
274
|
apiRef.current.setCellFocus(id, field);
|
|
275
|
+
if (shouldProcessEditCellProps) {
|
|
276
|
+
newProps = await Promise.resolve(column.preProcessEditCellProps({
|
|
277
|
+
id,
|
|
278
|
+
row: apiRef.current.getRow(id),
|
|
279
|
+
props: newProps,
|
|
280
|
+
hasChanged: newValue !== value
|
|
281
|
+
}));
|
|
282
|
+
// Check if still in edit mode before updating
|
|
283
|
+
if (apiRef.current.getCellMode(id, field) === _gridEditRowModel.GridCellModes.Edit) {
|
|
284
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
285
|
+
updateOrDeleteFieldState(id, field, (0, _extends2.default)({}, newProps, {
|
|
286
|
+
value: editingState[id][field].value,
|
|
287
|
+
isProcessingProps: false
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
272
291
|
});
|
|
273
292
|
const stopCellEditMode = React.useCallback(params => {
|
|
274
293
|
const {
|
|
@@ -326,10 +326,11 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
326
326
|
if (!cellParams.isEditable) {
|
|
327
327
|
return acc;
|
|
328
328
|
}
|
|
329
|
+
const column = apiRef.current.getColumn(field);
|
|
329
330
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
330
331
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
331
332
|
if (deleteValue) {
|
|
332
|
-
newValue = (0, _utils3.getDefaultCellValue)(
|
|
333
|
+
newValue = (0, _utils3.getDefaultCellValue)(column);
|
|
333
334
|
} else if (initialValue) {
|
|
334
335
|
newValue = initialValue;
|
|
335
336
|
}
|
|
@@ -337,7 +338,7 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
337
338
|
acc[field] = {
|
|
338
339
|
value: newValue,
|
|
339
340
|
error: false,
|
|
340
|
-
isProcessingProps:
|
|
341
|
+
isProcessingProps: !!column.preProcessEditCellProps && deleteValue
|
|
341
342
|
};
|
|
342
343
|
return acc;
|
|
343
344
|
}, {});
|
|
@@ -345,6 +346,26 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
345
346
|
if (fieldToFocus) {
|
|
346
347
|
apiRef.current.setCellFocus(id, fieldToFocus);
|
|
347
348
|
}
|
|
349
|
+
columnFields.filter(field => !!apiRef.current.getColumn(field).preProcessEditCellProps && deleteValue).forEach(field => {
|
|
350
|
+
const column = apiRef.current.getColumn(field);
|
|
351
|
+
const value = apiRef.current.getCellValue(id, field);
|
|
352
|
+
const newValue = deleteValue ? (0, _utils3.getDefaultCellValue)(column) : initialValue ?? value;
|
|
353
|
+
Promise.resolve(column.preProcessEditCellProps({
|
|
354
|
+
id,
|
|
355
|
+
row: apiRef.current.getRow(id),
|
|
356
|
+
props: newProps[field],
|
|
357
|
+
hasChanged: newValue !== value
|
|
358
|
+
})).then(processedProps => {
|
|
359
|
+
// Check if still in edit mode before updating
|
|
360
|
+
if (apiRef.current.getRowMode(id) === _gridEditRowModel.GridRowModes.Edit) {
|
|
361
|
+
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
362
|
+
updateOrDeleteFieldState(id, field, (0, _extends2.default)({}, processedProps, {
|
|
363
|
+
value: editingState[id][field].value,
|
|
364
|
+
isProcessingProps: false
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
348
369
|
});
|
|
349
370
|
const stopRowEditMode = React.useCallback(params => {
|
|
350
371
|
const {
|
|
@@ -12,7 +12,7 @@ var _exportAs = require("../../../utils/exportAs");
|
|
|
12
12
|
var _csvSerializer = require("./serializers/csvSerializer");
|
|
13
13
|
var _utils = require("./utils");
|
|
14
14
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
15
|
-
var
|
|
15
|
+
var _toolbar = require("../../../components/toolbar");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
/**
|
|
18
18
|
* @requires useGridColumns (state)
|
|
@@ -71,7 +71,7 @@ const useGridCsvExport = (apiRef, props) => {
|
|
|
71
71
|
return initialValue;
|
|
72
72
|
}
|
|
73
73
|
return [...initialValue, {
|
|
74
|
-
component: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
74
|
+
component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_toolbar.GridCsvExportMenuItem, {
|
|
75
75
|
options: options.csvOptions
|
|
76
76
|
}),
|
|
77
77
|
componentName: 'csvExport'
|
|
@@ -19,7 +19,7 @@ var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
|
19
19
|
var _utils2 = require("./utils");
|
|
20
20
|
var _useGridPaginationModel = require("../pagination/useGridPaginationModel");
|
|
21
21
|
var _pipeProcessing = require("../../core/pipeProcessing");
|
|
22
|
-
var
|
|
22
|
+
var _toolbar = require("../../../components/toolbar");
|
|
23
23
|
var _gridColumnsUtils = require("../columns/gridColumnsUtils");
|
|
24
24
|
var _gridCheckboxSelectionColDef = require("../../../colDef/gridCheckboxSelectionColDef");
|
|
25
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -288,7 +288,7 @@ const useGridPrintExport = (apiRef, props) => {
|
|
|
288
288
|
return initialValue;
|
|
289
289
|
}
|
|
290
290
|
return [...initialValue, {
|
|
291
|
-
component: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
291
|
+
component: /*#__PURE__*/(0, _jsxRuntime.jsx)(_toolbar.GridPrintExportMenuItem, {
|
|
292
292
|
options: options.printOptions
|
|
293
293
|
}),
|
|
294
294
|
componentName: 'printExport'
|
|
@@ -84,7 +84,7 @@ const useGridPaginationModel = (apiRef, props) => {
|
|
|
84
84
|
pagination: (0, _extends2.default)({}, state.pagination, {
|
|
85
85
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, paginationModel)
|
|
86
86
|
})
|
|
87
|
-
}));
|
|
87
|
+
}), 'setPaginationModel');
|
|
88
88
|
}, [apiRef, logger, props.signature]);
|
|
89
89
|
const paginationModelApi = {
|
|
90
90
|
setPage,
|
|
@@ -122,7 +122,7 @@ const useGridPaginationModel = (apiRef, props) => {
|
|
|
122
122
|
pagination: (0, _extends2.default)({}, state.pagination, {
|
|
123
123
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, paginationModel)
|
|
124
124
|
})
|
|
125
|
-
}));
|
|
125
|
+
}), 'stateRestorePreProcessing');
|
|
126
126
|
return params;
|
|
127
127
|
}, [apiRef, props.autoPageSize, props.signature]);
|
|
128
128
|
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'exportState', stateExportPreProcessing);
|
|
@@ -180,30 +180,33 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
180
180
|
let newSelection;
|
|
181
181
|
if (resetSelection) {
|
|
182
182
|
if (isSelected) {
|
|
183
|
-
newSelection = selectableIds;
|
|
183
|
+
newSelection = new Set(selectableIds);
|
|
184
184
|
if (applyAutoSelection) {
|
|
185
185
|
const addRow = rowId => {
|
|
186
|
-
newSelection.
|
|
186
|
+
newSelection.add(rowId);
|
|
187
187
|
};
|
|
188
188
|
selectableIds.forEach(id => {
|
|
189
189
|
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
} else {
|
|
193
|
-
newSelection =
|
|
193
|
+
newSelection = new Set();
|
|
194
|
+
}
|
|
195
|
+
const currentLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef);
|
|
196
|
+
if (newSelection.size === Object.keys(currentLookup).length && Array.from(newSelection).every(id => currentLookup[id] === id)) {
|
|
197
|
+
return;
|
|
194
198
|
}
|
|
195
199
|
} else {
|
|
196
|
-
|
|
197
|
-
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
200
|
+
newSelection = new Set(Object.values((0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef)));
|
|
198
201
|
const addRow = rowId => {
|
|
199
|
-
|
|
202
|
+
newSelection.add(rowId);
|
|
200
203
|
};
|
|
201
204
|
const removeRow = rowId => {
|
|
202
|
-
delete
|
|
205
|
+
newSelection.delete(rowId);
|
|
203
206
|
};
|
|
204
207
|
selectableIds.forEach(id => {
|
|
205
208
|
if (isSelected) {
|
|
206
|
-
|
|
209
|
+
newSelection.add(id);
|
|
207
210
|
if (applyAutoSelection) {
|
|
208
211
|
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
209
212
|
}
|
|
@@ -214,11 +217,10 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
});
|
|
217
|
-
newSelection = Object.values(selectionLookup);
|
|
218
220
|
}
|
|
219
|
-
const isSelectionValid = newSelection.
|
|
221
|
+
const isSelectionValid = newSelection.size < 2 || canHaveMultipleSelection;
|
|
220
222
|
if (isSelectionValid) {
|
|
221
|
-
apiRef.current.setRowSelectionModel(newSelection);
|
|
223
|
+
apiRef.current.setRowSelectionModel(Array.from(newSelection));
|
|
222
224
|
}
|
|
223
225
|
}, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents]);
|
|
224
226
|
const selectRowRange = React.useCallback(({
|
|
@@ -261,13 +263,20 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
261
263
|
return;
|
|
262
264
|
}
|
|
263
265
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
266
|
+
const rowsLookup = (0, _gridRowsSelector.gridRowsLookupSelector)(apiRef);
|
|
264
267
|
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
265
268
|
|
|
266
269
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
267
270
|
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
271
|
+
const isNonExistent = id => {
|
|
272
|
+
if (props.filterMode === 'server') {
|
|
273
|
+
return !rowsLookup[id];
|
|
274
|
+
}
|
|
275
|
+
return filteredRowsLookup[id] !== true;
|
|
276
|
+
};
|
|
268
277
|
let hasChanged = false;
|
|
269
278
|
currentSelection.forEach(id => {
|
|
270
|
-
if (
|
|
279
|
+
if (isNonExistent(id)) {
|
|
271
280
|
if (props.keepNonExistentRowsSelected) {
|
|
272
281
|
return;
|
|
273
282
|
}
|
|
@@ -293,15 +302,20 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
293
302
|
}
|
|
294
303
|
}
|
|
295
304
|
});
|
|
296
|
-
|
|
305
|
+
|
|
306
|
+
// For nested data, on row tree updation (filtering, adding rows, etc.) when the selection is
|
|
307
|
+
// not empty, we need to re-run scanning of the tree to propagate the selection changes
|
|
308
|
+
// Example: A parent whose de-selected children are filtered out should now be selected
|
|
309
|
+
const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && Object.keys(selectionLookup).length > 0;
|
|
310
|
+
if (hasChanged || shouldReapplyPropagation && !sortModelUpdated) {
|
|
297
311
|
const newSelection = Object.values(selectionLookup);
|
|
298
|
-
if (
|
|
312
|
+
if (shouldReapplyPropagation) {
|
|
299
313
|
apiRef.current.selectRows(newSelection, true, true);
|
|
300
314
|
} else {
|
|
301
315
|
apiRef.current.setRowSelectionModel(newSelection);
|
|
302
316
|
}
|
|
303
317
|
}
|
|
304
|
-
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, tree]);
|
|
318
|
+
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, props.filterMode, tree]);
|
|
305
319
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
306
320
|
const hasCtrlKey = event.metaKey || event.ctrlKey;
|
|
307
321
|
|