@mui/x-data-grid 5.17.2 → 5.17.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 +35 -1
- package/colDef/gridNumericOperators.d.ts +1 -1
- package/colDef/gridSingleSelectOperators.d.ts +1 -1
- package/colDef/gridStringOperators.d.ts +1 -1
- package/components/GridRow.js +5 -2
- package/components/cell/GridEditBooleanCell.js +1 -0
- package/components/cell/GridEditDateCell.js +1 -0
- package/components/cell/GridEditInputCell.js +21 -7
- package/components/cell/GridEditSingleSelectCell.js +1 -0
- package/hooks/features/editRows/useGridCellEditing.new.js +6 -3
- package/hooks/features/editRows/useGridEditing.new.js +9 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +6 -3
- package/hooks/utils/useGridInitializeState.d.ts +1 -1
- package/index.js +1 -1
- package/legacy/components/GridRow.js +6 -2
- package/legacy/components/cell/GridEditBooleanCell.js +1 -0
- package/legacy/components/cell/GridEditDateCell.js +1 -0
- package/legacy/components/cell/GridEditInputCell.js +23 -9
- package/legacy/components/cell/GridEditSingleSelectCell.js +1 -0
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +5 -4
- package/legacy/hooks/features/editRows/useGridEditing.new.js +9 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +6 -3
- package/legacy/index.js +1 -1
- package/models/api/gridEditingApi.d.ts +10 -0
- package/models/gridEditRowModel.d.ts +2 -0
- package/models/gridRows.d.ts +1 -1
- package/models/params/gridEditCellParams.d.ts +7 -3
- package/modern/components/GridRow.js +5 -2
- package/modern/components/cell/GridEditBooleanCell.js +1 -0
- package/modern/components/cell/GridEditDateCell.js +1 -0
- package/modern/components/cell/GridEditInputCell.js +18 -6
- package/modern/components/cell/GridEditSingleSelectCell.js +1 -0
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +6 -3
- package/modern/hooks/features/editRows/useGridEditing.new.js +9 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +6 -3
- package/modern/index.js +1 -1
- package/node/components/GridRow.js +4 -2
- package/node/components/cell/GridEditBooleanCell.js +1 -0
- package/node/components/cell/GridEditDateCell.js +1 -0
- package/node/components/cell/GridEditInputCell.js +21 -7
- package/node/components/cell/GridEditSingleSelectCell.js +1 -0
- package/node/hooks/features/editRows/useGridCellEditing.new.js +6 -3
- package/node/hooks/features/editRows/useGridEditing.new.js +10 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +6 -3
- package/node/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.17.3
|
|
7
|
+
|
|
8
|
+
_Sep 16, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 📝 Fix lost characters when typing into fields in the DataGrid (#5646) @m4theushw
|
|
13
|
+
- 🌏 New locale and improvements for pickers
|
|
14
|
+
- 🎁 Improve support to theme augmentation for pickers
|
|
15
|
+
|
|
16
|
+
### `@mui/x-data-grid@v5.17.3` / `@mui/x-data-grid-pro@v5.17.3` / `@mui/x-data-grid-premium@v5.17.3`
|
|
17
|
+
|
|
18
|
+
#### Changes
|
|
19
|
+
|
|
20
|
+
- [DataGrid] Only update input with value prop if debounce is off (#5646) @m4theushw
|
|
21
|
+
|
|
22
|
+
### `@mui/x-date-pickers@v5.0.2` / `@mui/x-date-pickers-pro@v5.0.2`
|
|
23
|
+
|
|
24
|
+
#### Changes
|
|
25
|
+
|
|
26
|
+
- [pickers] Add Icelandic (is-IS) locale (#6137) @elvatli
|
|
27
|
+
- [pickers] Fix `@mui/x-date-pickers` theme augmentation and style overriding (#6156) @LukasTy
|
|
28
|
+
- [pickers] Fix `@mui/x-date-pickers-pro` theme augmentation (#6096) @LukasTy
|
|
29
|
+
- [pickers] Improve German (de-DE) locale (#6138) @alexfauquette
|
|
30
|
+
|
|
31
|
+
### Docs
|
|
32
|
+
|
|
33
|
+
- [docs] Improve main demo to show new functionalities (#5292) @joserodolfofreitas
|
|
34
|
+
|
|
35
|
+
### Core
|
|
36
|
+
|
|
37
|
+
- [core] Update to typescript 4.8.3 (#6136) @flaviendelangle
|
|
38
|
+
- [core] Update RFC template (#6100) @bytasv
|
|
39
|
+
|
|
6
40
|
## 5.17.2
|
|
7
41
|
|
|
8
42
|
_Sep 9, 2022_
|
|
@@ -11,7 +45,7 @@ This release will the last regular release for our `v5` packages.
|
|
|
11
45
|
From now on, we'll be focusing on developing MUI X v6.
|
|
12
46
|
You can check the [roadmap](https://github.com/mui/mui-x/projects/1) for more details on what's coming next.
|
|
13
47
|
|
|
14
|
-
And if you'd like to help, please consider volunteering to give us a [user interview](https://
|
|
48
|
+
And if you'd like to help, please consider volunteering to give us a [user interview](https://forms.gle/vsBv6CLPz9h57xg8A).
|
|
15
49
|
We'd love to know more about your use cases, pain points and expectations for the future.
|
|
16
50
|
|
|
17
51
|
The `v5` packages will only get new versions to patch critical bug fixes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GridFilterOperator } from '../models/gridFilterOperator';
|
|
2
2
|
import { GridCellParams } from '../models';
|
|
3
|
-
export declare const getGridNumericQuickFilterFn: (value: any) => (({ value
|
|
3
|
+
export declare const getGridNumericQuickFilterFn: (value: any) => (({ value }: GridCellParams) => boolean) | null;
|
|
4
4
|
export declare const getGridNumericOperators: () => GridFilterOperator<any, number | string | null, any>[];
|
|
5
5
|
/**
|
|
6
6
|
* @deprecated Use `getGridNumericOperators` instead.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridFilterOperator } from '../models/gridFilterOperator';
|
|
2
2
|
import { GridCellParams, GridColDef } from '../models';
|
|
3
3
|
import { GridApiCommunity } from '../models/api/gridApiCommunity';
|
|
4
|
-
export declare const getGridSingleSelectQuickFilterFn: (value: any, column: GridColDef, apiRef: React.MutableRefObject<GridApiCommunity>) => (({ value
|
|
4
|
+
export declare const getGridSingleSelectQuickFilterFn: (value: any, column: GridColDef, apiRef: React.MutableRefObject<GridApiCommunity>) => (({ value }: GridCellParams) => boolean) | null;
|
|
5
5
|
export declare const getGridSingleSelectOperators: () => GridFilterOperator[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GridFilterOperator } from '../models/gridFilterOperator';
|
|
2
2
|
import { GridCellParams } from '../models';
|
|
3
|
-
export declare const getGridStringQuickFilterFn: (value: any) => (({ value
|
|
3
|
+
export declare const getGridStringQuickFilterFn: (value: any) => (({ value }: GridCellParams) => boolean) | null;
|
|
4
4
|
export declare const getGridStringOperators: (disableTrim?: boolean) => GridFilterOperator<any, number | string | null, any>[];
|
package/components/GridRow.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"]
|
|
3
|
+
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"],
|
|
4
|
+
_excluded2 = ["changeReason"];
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import PropTypes from 'prop-types';
|
|
6
7
|
import clsx from 'clsx';
|
|
@@ -231,9 +232,11 @@ function GridRow(props) {
|
|
|
231
232
|
updatedRow = apiRef.current.unstable_getRowWithUpdatedValues(rowId, column.field);
|
|
232
233
|
}
|
|
233
234
|
|
|
235
|
+
const editCellStateRest = _objectWithoutPropertiesLoose(editCellState, _excluded2);
|
|
236
|
+
|
|
234
237
|
const params = _extends({}, cellParams, {
|
|
235
238
|
row: updatedRow
|
|
236
|
-
},
|
|
239
|
+
}, editCellStateRest, {
|
|
237
240
|
api: apiRef.current
|
|
238
241
|
});
|
|
239
242
|
|
|
@@ -95,6 +95,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
95
95
|
* The mode of the cell.
|
|
96
96
|
*/
|
|
97
97
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
98
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
98
99
|
|
|
99
100
|
/**
|
|
100
101
|
* The column of the row that the current cell belongs to.
|
|
@@ -149,6 +149,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
149
149
|
* The mode of the cell.
|
|
150
150
|
*/
|
|
151
151
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
152
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
152
153
|
|
|
153
154
|
/**
|
|
154
155
|
* The column of the row that the current cell belongs to.
|
|
@@ -38,7 +38,7 @@ const GridEditInputCellRoot = styled(InputBase, {
|
|
|
38
38
|
}
|
|
39
39
|
}));
|
|
40
40
|
const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
41
|
-
var _rootProps$experiment;
|
|
41
|
+
var _rootProps$experiment, _rootProps$experiment3;
|
|
42
42
|
|
|
43
43
|
const rootProps = useGridRootProps();
|
|
44
44
|
|
|
@@ -62,23 +62,36 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
62
62
|
};
|
|
63
63
|
const classes = useUtilityClasses(ownerState);
|
|
64
64
|
const handleChange = React.useCallback(async event => {
|
|
65
|
+
var _rootProps$experiment2;
|
|
66
|
+
|
|
65
67
|
const newValue = event.target.value;
|
|
66
68
|
|
|
67
69
|
if (onValueChange) {
|
|
68
70
|
await onValueChange(event, newValue);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
const column = apiRef.current.getColumn(field);
|
|
74
|
+
let parsedValue = newValue;
|
|
75
|
+
|
|
76
|
+
if (column.valueParser && (_rootProps$experiment2 = rootProps.experimentalFeatures) != null && _rootProps$experiment2.newEditingApi) {
|
|
77
|
+
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setValueState(parsedValue);
|
|
72
81
|
apiRef.current.setEditCellValue({
|
|
73
82
|
id,
|
|
74
83
|
field,
|
|
75
|
-
value:
|
|
76
|
-
debounceMs
|
|
84
|
+
value: parsedValue,
|
|
85
|
+
debounceMs,
|
|
86
|
+
unstable_skipValueParser: true
|
|
77
87
|
}, event);
|
|
78
|
-
}, [apiRef, debounceMs, field, id, onValueChange]);
|
|
88
|
+
}, [apiRef, debounceMs, field, id, onValueChange, (_rootProps$experiment3 = rootProps.experimentalFeatures) == null ? void 0 : _rootProps$experiment3.newEditingApi]);
|
|
89
|
+
const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
|
|
79
90
|
React.useEffect(() => {
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
if (meta.changeReason !== 'debouncedSetEditCellValue') {
|
|
92
|
+
setValueState(value);
|
|
93
|
+
}
|
|
94
|
+
}, [meta.changeReason, value]);
|
|
82
95
|
useEnhancedEffect(() => {
|
|
83
96
|
if (hasFocus) {
|
|
84
97
|
inputRef.current.focus();
|
|
@@ -111,6 +124,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
111
124
|
* The mode of the cell.
|
|
112
125
|
*/
|
|
113
126
|
cellMode: PropTypes.oneOf(['edit', 'view']),
|
|
127
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
114
128
|
|
|
115
129
|
/**
|
|
116
130
|
* The column of the row that the current cell belongs to.
|
|
@@ -193,6 +193,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
193
193
|
* The mode of the cell.
|
|
194
194
|
*/
|
|
195
195
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
196
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
196
197
|
|
|
197
198
|
/**
|
|
198
199
|
* The column of the row that the current cell belongs to.
|
|
@@ -361,7 +361,9 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
361
361
|
const {
|
|
362
362
|
id,
|
|
363
363
|
field,
|
|
364
|
-
value
|
|
364
|
+
value,
|
|
365
|
+
debounceMs,
|
|
366
|
+
unstable_skipValueParser: skipValueParser
|
|
365
367
|
} = params;
|
|
366
368
|
throwIfNotEditable(id, field);
|
|
367
369
|
throwIfNotInMode(id, field, GridCellModes.Edit);
|
|
@@ -369,14 +371,15 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
369
371
|
const row = apiRef.current.getRow(id);
|
|
370
372
|
let parsedValue = value;
|
|
371
373
|
|
|
372
|
-
if (column.valueParser) {
|
|
374
|
+
if (column.valueParser && !skipValueParser) {
|
|
373
375
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
374
376
|
}
|
|
375
377
|
|
|
376
378
|
let editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
377
379
|
|
|
378
380
|
let newProps = _extends({}, editingState[id][field], {
|
|
379
|
-
value: parsedValue
|
|
381
|
+
value: parsedValue,
|
|
382
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
380
383
|
});
|
|
381
384
|
|
|
382
385
|
if (column.preProcessEditCellProps) {
|
|
@@ -4,6 +4,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
4
4
|
import { useGridCellEditing } from './useGridCellEditing.new';
|
|
5
5
|
import { GridCellModes, GridEditModes } from '../../../models/gridEditRowModel';
|
|
6
6
|
import { useGridRowEditing } from './useGridRowEditing.new';
|
|
7
|
+
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
7
8
|
export const editingStateInitializer = state => _extends({}, state, {
|
|
8
9
|
editRows: {}
|
|
9
10
|
});
|
|
@@ -116,11 +117,18 @@ export const useGridEditing = (apiRef, props) => {
|
|
|
116
117
|
const getRowWithUpdatedValues = React.useCallback((id, field) => {
|
|
117
118
|
return props.editMode === GridEditModes.Cell ? apiRef.current.unstable_getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.unstable_getRowWithUpdatedValuesFromRowEditing(id);
|
|
118
119
|
}, [apiRef, props.editMode]);
|
|
120
|
+
const getEditCellMeta = React.useCallback((id, field) => {
|
|
121
|
+
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
122
|
+
return {
|
|
123
|
+
changeReason: editingState[id][field].changeReason
|
|
124
|
+
};
|
|
125
|
+
}, [apiRef]);
|
|
119
126
|
const editingSharedApi = {
|
|
120
127
|
isCellEditable,
|
|
121
128
|
setEditCellValue,
|
|
122
129
|
unstable_runPendingEditCellValueMutation: runPendingEditCellValueMutation,
|
|
123
|
-
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues
|
|
130
|
+
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues,
|
|
131
|
+
unstable_getEditCellMeta: getEditCellMeta
|
|
124
132
|
};
|
|
125
133
|
useGridApiMethod(apiRef, editingSharedApi, 'EditingApi');
|
|
126
134
|
};
|
|
@@ -442,21 +442,24 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
442
442
|
const {
|
|
443
443
|
id,
|
|
444
444
|
field,
|
|
445
|
-
value
|
|
445
|
+
value,
|
|
446
|
+
debounceMs,
|
|
447
|
+
unstable_skipValueParser: skipValueParser
|
|
446
448
|
} = params;
|
|
447
449
|
throwIfNotEditable(id, field);
|
|
448
450
|
const column = apiRef.current.getColumn(field);
|
|
449
451
|
const row = apiRef.current.getRow(id);
|
|
450
452
|
let parsedValue = value;
|
|
451
453
|
|
|
452
|
-
if (column.valueParser) {
|
|
454
|
+
if (column.valueParser && !skipValueParser) {
|
|
453
455
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
454
456
|
}
|
|
455
457
|
|
|
456
458
|
let editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
457
459
|
|
|
458
460
|
let newProps = _extends({}, editingState[id][field], {
|
|
459
|
-
value: parsedValue
|
|
461
|
+
value: parsedValue,
|
|
462
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
460
463
|
});
|
|
461
464
|
|
|
462
465
|
if (!column.preProcessEditCellProps) {
|
|
@@ -6,5 +6,5 @@ declare type DeepPartial<T> = {
|
|
|
6
6
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
7
7
|
};
|
|
8
8
|
export declare type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, Api extends GridApiCommon = GridApiCommunity> = (state: DeepPartial<Api['state']>, props: P, apiRef: React.MutableRefObject<Api>) => DeepPartial<Api['state']>;
|
|
9
|
-
export declare const useGridInitializeState: <P
|
|
9
|
+
export declare const useGridInitializeState: <P extends Partial<DataGridProcessedProps<any>>, Api extends GridApiCommon = GridApiCommunity>(initializer: GridStateInitializer<P, Api>, apiRef: React.MutableRefObject<Api>, props: P) => void;
|
|
10
10
|
export {};
|
package/index.js
CHANGED
|
@@ -2,7 +2,8 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"]
|
|
5
|
+
var _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"],
|
|
6
|
+
_excluded2 = ["changeReason"];
|
|
6
7
|
import * as React from 'react';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
import clsx from 'clsx';
|
|
@@ -237,9 +238,12 @@ function GridRow(props) {
|
|
|
237
238
|
updatedRow = apiRef.current.unstable_getRowWithUpdatedValues(rowId, column.field);
|
|
238
239
|
}
|
|
239
240
|
|
|
241
|
+
var changeReason = editCellState.changeReason,
|
|
242
|
+
editCellStateRest = _objectWithoutProperties(editCellState, _excluded2);
|
|
243
|
+
|
|
240
244
|
var params = _extends({}, cellParams, {
|
|
241
245
|
row: updatedRow
|
|
242
|
-
},
|
|
246
|
+
}, editCellStateRest, {
|
|
243
247
|
api: apiRef.current
|
|
244
248
|
});
|
|
245
249
|
|
|
@@ -135,6 +135,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
135
135
|
* The mode of the cell.
|
|
136
136
|
*/
|
|
137
137
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
138
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
138
139
|
|
|
139
140
|
/**
|
|
140
141
|
* The column of the row that the current cell belongs to.
|
|
@@ -186,6 +186,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
186
186
|
* The mode of the cell.
|
|
187
187
|
*/
|
|
188
188
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
189
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
189
190
|
|
|
190
191
|
/**
|
|
191
192
|
* The column of the row that the current cell belongs to.
|
|
@@ -42,7 +42,7 @@ var GridEditInputCellRoot = styled(InputBase, {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
45
|
-
var _rootProps$experiment;
|
|
45
|
+
var _rootProps$experiment, _rootProps$experiment3;
|
|
46
46
|
|
|
47
47
|
var rootProps = useGridRootProps();
|
|
48
48
|
|
|
@@ -80,7 +80,9 @@ var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
80
80
|
var classes = useUtilityClasses(ownerState);
|
|
81
81
|
var handleChange = React.useCallback( /*#__PURE__*/function () {
|
|
82
82
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
|
|
83
|
-
var
|
|
83
|
+
var _rootProps$experiment2;
|
|
84
|
+
|
|
85
|
+
var newValue, column, parsedValue;
|
|
84
86
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
85
87
|
while (1) {
|
|
86
88
|
switch (_context.prev = _context.next) {
|
|
@@ -96,15 +98,23 @@ var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
96
98
|
return onValueChange(event, newValue);
|
|
97
99
|
|
|
98
100
|
case 4:
|
|
99
|
-
|
|
101
|
+
column = apiRef.current.getColumn(field);
|
|
102
|
+
parsedValue = newValue;
|
|
103
|
+
|
|
104
|
+
if (column.valueParser && (_rootProps$experiment2 = rootProps.experimentalFeatures) != null && _rootProps$experiment2.newEditingApi) {
|
|
105
|
+
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setValueState(parsedValue);
|
|
100
109
|
apiRef.current.setEditCellValue({
|
|
101
110
|
id: id,
|
|
102
111
|
field: field,
|
|
103
|
-
value:
|
|
104
|
-
debounceMs: debounceMs
|
|
112
|
+
value: parsedValue,
|
|
113
|
+
debounceMs: debounceMs,
|
|
114
|
+
unstable_skipValueParser: true
|
|
105
115
|
}, event);
|
|
106
116
|
|
|
107
|
-
case
|
|
117
|
+
case 9:
|
|
108
118
|
case "end":
|
|
109
119
|
return _context.stop();
|
|
110
120
|
}
|
|
@@ -115,10 +125,13 @@ var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
115
125
|
return function (_x) {
|
|
116
126
|
return _ref2.apply(this, arguments);
|
|
117
127
|
};
|
|
118
|
-
}(), [apiRef, debounceMs, field, id, onValueChange]);
|
|
128
|
+
}(), [apiRef, debounceMs, field, id, onValueChange, (_rootProps$experiment3 = rootProps.experimentalFeatures) == null ? void 0 : _rootProps$experiment3.newEditingApi]);
|
|
129
|
+
var meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
|
|
119
130
|
React.useEffect(function () {
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
if (meta.changeReason !== 'debouncedSetEditCellValue') {
|
|
132
|
+
setValueState(value);
|
|
133
|
+
}
|
|
134
|
+
}, [meta.changeReason, value]);
|
|
122
135
|
useEnhancedEffect(function () {
|
|
123
136
|
if (hasFocus) {
|
|
124
137
|
inputRef.current.focus();
|
|
@@ -151,6 +164,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
151
164
|
* The mode of the cell.
|
|
152
165
|
*/
|
|
153
166
|
cellMode: PropTypes.oneOf(['edit', 'view']),
|
|
167
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
154
168
|
|
|
155
169
|
/**
|
|
156
170
|
* The column of the row that the current cell belongs to.
|
|
@@ -250,6 +250,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
250
250
|
* The mode of the cell.
|
|
251
251
|
*/
|
|
252
252
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
253
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
256
|
* The column of the row that the current cell belongs to.
|
|
@@ -373,25 +373,26 @@ export var useGridCellEditing = function useGridCellEditing(apiRef, props) {
|
|
|
373
373
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
|
|
374
374
|
var _editingState$id, _editingState$id$fiel2;
|
|
375
375
|
|
|
376
|
-
var id, field, value, column, row, parsedValue, editingState, newProps, hasChanged;
|
|
376
|
+
var id, field, value, debounceMs, skipValueParser, column, row, parsedValue, editingState, newProps, hasChanged;
|
|
377
377
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
378
378
|
while (1) {
|
|
379
379
|
switch (_context2.prev = _context2.next) {
|
|
380
380
|
case 0:
|
|
381
|
-
id = params.id, field = params.field, value = params.value;
|
|
381
|
+
id = params.id, field = params.field, value = params.value, debounceMs = params.debounceMs, skipValueParser = params.unstable_skipValueParser;
|
|
382
382
|
throwIfNotEditable(id, field);
|
|
383
383
|
throwIfNotInMode(id, field, GridCellModes.Edit);
|
|
384
384
|
column = apiRef.current.getColumn(field);
|
|
385
385
|
row = apiRef.current.getRow(id);
|
|
386
386
|
parsedValue = value;
|
|
387
387
|
|
|
388
|
-
if (column.valueParser) {
|
|
388
|
+
if (column.valueParser && !skipValueParser) {
|
|
389
389
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
393
393
|
newProps = _extends({}, editingState[id][field], {
|
|
394
|
-
value: parsedValue
|
|
394
|
+
value: parsedValue,
|
|
395
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
395
396
|
});
|
|
396
397
|
|
|
397
398
|
if (!column.preProcessEditCellProps) {
|
|
@@ -7,6 +7,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
7
7
|
import { useGridCellEditing } from './useGridCellEditing.new';
|
|
8
8
|
import { GridCellModes, GridEditModes } from '../../../models/gridEditRowModel';
|
|
9
9
|
import { useGridRowEditing } from './useGridRowEditing.new';
|
|
10
|
+
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
10
11
|
export var editingStateInitializer = function editingStateInitializer(state) {
|
|
11
12
|
return _extends({}, state, {
|
|
12
13
|
editRows: {}
|
|
@@ -150,11 +151,18 @@ export var useGridEditing = function useGridEditing(apiRef, props) {
|
|
|
150
151
|
var getRowWithUpdatedValues = React.useCallback(function (id, field) {
|
|
151
152
|
return props.editMode === GridEditModes.Cell ? apiRef.current.unstable_getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.unstable_getRowWithUpdatedValuesFromRowEditing(id);
|
|
152
153
|
}, [apiRef, props.editMode]);
|
|
154
|
+
var getEditCellMeta = React.useCallback(function (id, field) {
|
|
155
|
+
var editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
156
|
+
return {
|
|
157
|
+
changeReason: editingState[id][field].changeReason
|
|
158
|
+
};
|
|
159
|
+
}, [apiRef]);
|
|
153
160
|
var editingSharedApi = {
|
|
154
161
|
isCellEditable: isCellEditable,
|
|
155
162
|
setEditCellValue: setEditCellValue,
|
|
156
163
|
unstable_runPendingEditCellValueMutation: runPendingEditCellValueMutation,
|
|
157
|
-
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues
|
|
164
|
+
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues,
|
|
165
|
+
unstable_getEditCellMeta: getEditCellMeta
|
|
158
166
|
};
|
|
159
167
|
useGridApiMethod(apiRef, editingSharedApi, 'EditingApi');
|
|
160
168
|
};
|
|
@@ -440,20 +440,23 @@ export var useGridRowEditing = function useGridRowEditing(apiRef, props) {
|
|
|
440
440
|
var setRowEditingEditCellValue = React.useCallback(function (params) {
|
|
441
441
|
var id = params.id,
|
|
442
442
|
field = params.field,
|
|
443
|
-
value = params.value
|
|
443
|
+
value = params.value,
|
|
444
|
+
debounceMs = params.debounceMs,
|
|
445
|
+
skipValueParser = params.unstable_skipValueParser;
|
|
444
446
|
throwIfNotEditable(id, field);
|
|
445
447
|
var column = apiRef.current.getColumn(field);
|
|
446
448
|
var row = apiRef.current.getRow(id);
|
|
447
449
|
var parsedValue = value;
|
|
448
450
|
|
|
449
|
-
if (column.valueParser) {
|
|
451
|
+
if (column.valueParser && !skipValueParser) {
|
|
450
452
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
451
453
|
}
|
|
452
454
|
|
|
453
455
|
var editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
454
456
|
|
|
455
457
|
var newProps = _extends({}, editingState[id][field], {
|
|
456
|
-
value: parsedValue
|
|
458
|
+
value: parsedValue,
|
|
459
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
457
460
|
});
|
|
458
461
|
|
|
459
462
|
if (!column.preProcessEditCellProps) {
|
package/legacy/index.js
CHANGED
|
@@ -16,6 +16,9 @@ export declare type GridRowModesModelProps = ({
|
|
|
16
16
|
mode: GridRowModes.Edit;
|
|
17
17
|
} & Omit<GridStartRowEditModeParams, 'id' | 'field'>);
|
|
18
18
|
export declare type GridRowModesModel = Record<GridRowId, GridRowModesModelProps>;
|
|
19
|
+
export interface GridEditCellMeta {
|
|
20
|
+
changeReason?: 'debouncedSetEditCellValue' | 'setEditCellValue';
|
|
21
|
+
}
|
|
19
22
|
export interface GridNewEditingSharedApi {
|
|
20
23
|
/**
|
|
21
24
|
* Controls if a cell is editable.
|
|
@@ -46,6 +49,13 @@ export interface GridNewEditingSharedApi {
|
|
|
46
49
|
* @ignore - do not document.
|
|
47
50
|
*/
|
|
48
51
|
unstable_getRowWithUpdatedValues: (id: GridRowId, field: string) => GridRowModel;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the meta information for the edit cell.
|
|
54
|
+
* @param {GridRowId} id The row id being edited.
|
|
55
|
+
* @param {string} field The field being edited.
|
|
56
|
+
* @ignore - do not document.
|
|
57
|
+
*/
|
|
58
|
+
unstable_getEditCellMeta: (id: GridRowId, field: string) => GridEditCellMeta;
|
|
49
59
|
}
|
|
50
60
|
/**
|
|
51
61
|
* The shared methods used by the cell and row editing API.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { GridEditCellMeta } from './api/gridEditingApi';
|
|
1
2
|
export interface GridEditCellProps<V = any> {
|
|
2
3
|
value?: V | undefined;
|
|
3
4
|
isValidating?: boolean;
|
|
4
5
|
isProcessingProps?: boolean;
|
|
6
|
+
changeReason?: GridEditCellMeta['changeReason'];
|
|
5
7
|
[prop: string]: any;
|
|
6
8
|
}
|
|
7
9
|
export declare type GridEditRowProps = {
|
package/models/gridRows.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { GridKeyValue } from './colDef/gridColDef';
|
|
|
2
2
|
export declare type GridValidRowModel = {
|
|
3
3
|
[key: string]: any;
|
|
4
4
|
};
|
|
5
|
-
export declare type GridRowsProp<R = GridValidRowModel> = Readonly<GridRowModel<R>[]>;
|
|
5
|
+
export declare type GridRowsProp<R extends GridValidRowModel = GridValidRowModel> = Readonly<GridRowModel<R>[]>;
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated prefer GridRowModel.
|
|
8
8
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridEditCellProps } from '../gridEditRowModel';
|
|
2
|
-
import { GridRowId } from '../gridRows';
|
|
2
|
+
import { GridRowId, GridValidRowModel } from '../gridRows';
|
|
3
3
|
import { GridCellParams } from './gridCellParams';
|
|
4
4
|
export interface GridEditCellPropsParams {
|
|
5
5
|
id: GridRowId;
|
|
@@ -26,6 +26,10 @@ export interface GridEditCellValueParams {
|
|
|
26
26
|
* The debounce time in milliseconds.
|
|
27
27
|
*/
|
|
28
28
|
debounceMs?: number;
|
|
29
|
+
/**
|
|
30
|
+
* TBD
|
|
31
|
+
*/
|
|
32
|
+
unstable_skipValueParser?: boolean;
|
|
29
33
|
}
|
|
30
34
|
export interface GridCommitCellChangeParams {
|
|
31
35
|
id: GridRowId;
|
|
@@ -45,7 +49,7 @@ declare enum GridCellEditStartReasons {
|
|
|
45
49
|
/**
|
|
46
50
|
* Params passed to the `cellEditStart` event.
|
|
47
51
|
*/
|
|
48
|
-
export interface GridCellEditStartParams<V = any, R =
|
|
52
|
+
export interface GridCellEditStartParams<V = any, R extends GridValidRowModel = GridValidRowModel, F = V> extends GridCellParams<V, R, F> {
|
|
49
53
|
/**
|
|
50
54
|
* The reason for this event to be triggered.
|
|
51
55
|
* Only applied if `props.experimentalFeatures.newEditingApi: true`.
|
|
@@ -62,7 +66,7 @@ declare enum GridCellEditStopReasons {
|
|
|
62
66
|
/**
|
|
63
67
|
* Params passed to the `cellEditStop event.
|
|
64
68
|
*/
|
|
65
|
-
export interface GridCellEditStopParams<V = any, R =
|
|
69
|
+
export interface GridCellEditStopParams<V = any, R extends GridValidRowModel = GridValidRowModel, F = V> extends GridCellParams<V, R, F> {
|
|
66
70
|
/**
|
|
67
71
|
* The reason for this event to be triggered.
|
|
68
72
|
* Only available if `props.experimentalFeatures.newEditingApi: true`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"]
|
|
3
|
+
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"],
|
|
4
|
+
_excluded2 = ["changeReason"];
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import PropTypes from 'prop-types';
|
|
6
7
|
import clsx from 'clsx';
|
|
@@ -223,9 +224,11 @@ function GridRow(props) {
|
|
|
223
224
|
updatedRow = apiRef.current.unstable_getRowWithUpdatedValues(rowId, column.field);
|
|
224
225
|
}
|
|
225
226
|
|
|
227
|
+
const editCellStateRest = _objectWithoutPropertiesLoose(editCellState, _excluded2);
|
|
228
|
+
|
|
226
229
|
const params = _extends({}, cellParams, {
|
|
227
230
|
row: updatedRow
|
|
228
|
-
},
|
|
231
|
+
}, editCellStateRest, {
|
|
229
232
|
api: apiRef.current
|
|
230
233
|
});
|
|
231
234
|
|
|
@@ -93,6 +93,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
93
93
|
* The mode of the cell.
|
|
94
94
|
*/
|
|
95
95
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
96
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
99
|
* The column of the row that the current cell belongs to.
|
|
@@ -147,6 +147,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
147
147
|
* The mode of the cell.
|
|
148
148
|
*/
|
|
149
149
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
150
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
150
151
|
|
|
151
152
|
/**
|
|
152
153
|
* The column of the row that the current cell belongs to.
|
|
@@ -66,17 +66,28 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
66
66
|
await onValueChange(event, newValue);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
const column = apiRef.current.getColumn(field);
|
|
70
|
+
let parsedValue = newValue;
|
|
71
|
+
|
|
72
|
+
if (column.valueParser && rootProps.experimentalFeatures?.newEditingApi) {
|
|
73
|
+
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setValueState(parsedValue);
|
|
70
77
|
apiRef.current.setEditCellValue({
|
|
71
78
|
id,
|
|
72
79
|
field,
|
|
73
|
-
value:
|
|
74
|
-
debounceMs
|
|
80
|
+
value: parsedValue,
|
|
81
|
+
debounceMs,
|
|
82
|
+
unstable_skipValueParser: true
|
|
75
83
|
}, event);
|
|
76
|
-
}, [apiRef, debounceMs, field, id, onValueChange]);
|
|
84
|
+
}, [apiRef, debounceMs, field, id, onValueChange, rootProps.experimentalFeatures?.newEditingApi]);
|
|
85
|
+
const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
|
|
77
86
|
React.useEffect(() => {
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
if (meta.changeReason !== 'debouncedSetEditCellValue') {
|
|
88
|
+
setValueState(value);
|
|
89
|
+
}
|
|
90
|
+
}, [meta.changeReason, value]);
|
|
80
91
|
useEnhancedEffect(() => {
|
|
81
92
|
if (hasFocus) {
|
|
82
93
|
inputRef.current.focus();
|
|
@@ -109,6 +120,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
109
120
|
* The mode of the cell.
|
|
110
121
|
*/
|
|
111
122
|
cellMode: PropTypes.oneOf(['edit', 'view']),
|
|
123
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
112
124
|
|
|
113
125
|
/**
|
|
114
126
|
* The column of the row that the current cell belongs to.
|
|
@@ -187,6 +187,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
187
187
|
* The mode of the cell.
|
|
188
188
|
*/
|
|
189
189
|
cellMode: PropTypes.oneOf(['edit', 'view']).isRequired,
|
|
190
|
+
changeReason: PropTypes.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
190
191
|
|
|
191
192
|
/**
|
|
192
193
|
* The column of the row that the current cell belongs to.
|
|
@@ -359,7 +359,9 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
359
359
|
const {
|
|
360
360
|
id,
|
|
361
361
|
field,
|
|
362
|
-
value
|
|
362
|
+
value,
|
|
363
|
+
debounceMs,
|
|
364
|
+
unstable_skipValueParser: skipValueParser
|
|
363
365
|
} = params;
|
|
364
366
|
throwIfNotEditable(id, field);
|
|
365
367
|
throwIfNotInMode(id, field, GridCellModes.Edit);
|
|
@@ -367,14 +369,15 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
367
369
|
const row = apiRef.current.getRow(id);
|
|
368
370
|
let parsedValue = value;
|
|
369
371
|
|
|
370
|
-
if (column.valueParser) {
|
|
372
|
+
if (column.valueParser && !skipValueParser) {
|
|
371
373
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
372
374
|
}
|
|
373
375
|
|
|
374
376
|
let editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
375
377
|
|
|
376
378
|
let newProps = _extends({}, editingState[id][field], {
|
|
377
|
-
value: parsedValue
|
|
379
|
+
value: parsedValue,
|
|
380
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
378
381
|
});
|
|
379
382
|
|
|
380
383
|
if (column.preProcessEditCellProps) {
|
|
@@ -4,6 +4,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
4
4
|
import { useGridCellEditing } from './useGridCellEditing.new';
|
|
5
5
|
import { GridCellModes, GridEditModes } from '../../../models/gridEditRowModel';
|
|
6
6
|
import { useGridRowEditing } from './useGridRowEditing.new';
|
|
7
|
+
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
7
8
|
export const editingStateInitializer = state => _extends({}, state, {
|
|
8
9
|
editRows: {}
|
|
9
10
|
});
|
|
@@ -116,11 +117,18 @@ export const useGridEditing = (apiRef, props) => {
|
|
|
116
117
|
const getRowWithUpdatedValues = React.useCallback((id, field) => {
|
|
117
118
|
return props.editMode === GridEditModes.Cell ? apiRef.current.unstable_getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.unstable_getRowWithUpdatedValuesFromRowEditing(id);
|
|
118
119
|
}, [apiRef, props.editMode]);
|
|
120
|
+
const getEditCellMeta = React.useCallback((id, field) => {
|
|
121
|
+
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
122
|
+
return {
|
|
123
|
+
changeReason: editingState[id][field].changeReason
|
|
124
|
+
};
|
|
125
|
+
}, [apiRef]);
|
|
119
126
|
const editingSharedApi = {
|
|
120
127
|
isCellEditable,
|
|
121
128
|
setEditCellValue,
|
|
122
129
|
unstable_runPendingEditCellValueMutation: runPendingEditCellValueMutation,
|
|
123
|
-
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues
|
|
130
|
+
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues,
|
|
131
|
+
unstable_getEditCellMeta: getEditCellMeta
|
|
124
132
|
};
|
|
125
133
|
useGridApiMethod(apiRef, editingSharedApi, 'EditingApi');
|
|
126
134
|
};
|
|
@@ -440,21 +440,24 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
440
440
|
const {
|
|
441
441
|
id,
|
|
442
442
|
field,
|
|
443
|
-
value
|
|
443
|
+
value,
|
|
444
|
+
debounceMs,
|
|
445
|
+
unstable_skipValueParser: skipValueParser
|
|
444
446
|
} = params;
|
|
445
447
|
throwIfNotEditable(id, field);
|
|
446
448
|
const column = apiRef.current.getColumn(field);
|
|
447
449
|
const row = apiRef.current.getRow(id);
|
|
448
450
|
let parsedValue = value;
|
|
449
451
|
|
|
450
|
-
if (column.valueParser) {
|
|
452
|
+
if (column.valueParser && !skipValueParser) {
|
|
451
453
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
452
454
|
}
|
|
453
455
|
|
|
454
456
|
let editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
455
457
|
|
|
456
458
|
let newProps = _extends({}, editingState[id][field], {
|
|
457
|
-
value: parsedValue
|
|
459
|
+
value: parsedValue,
|
|
460
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
458
461
|
});
|
|
459
462
|
|
|
460
463
|
if (!column.preProcessEditCellProps) {
|
package/modern/index.js
CHANGED
|
@@ -51,7 +51,8 @@ var _utils = require("../utils/utils");
|
|
|
51
51
|
|
|
52
52
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
53
53
|
|
|
54
|
-
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"]
|
|
54
|
+
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "cellFocus", "cellTabIndex", "editRowsState", "isLastVisible", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"],
|
|
55
|
+
_excluded2 = ["changeReason"];
|
|
55
56
|
|
|
56
57
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
57
58
|
|
|
@@ -264,9 +265,10 @@ function GridRow(props) {
|
|
|
264
265
|
updatedRow = apiRef.current.unstable_getRowWithUpdatedValues(rowId, column.field);
|
|
265
266
|
}
|
|
266
267
|
|
|
268
|
+
const editCellStateRest = (0, _objectWithoutPropertiesLoose2.default)(editCellState, _excluded2);
|
|
267
269
|
const params = (0, _extends2.default)({}, cellParams, {
|
|
268
270
|
row: updatedRow
|
|
269
|
-
},
|
|
271
|
+
}, editCellStateRest, {
|
|
270
272
|
api: apiRef.current
|
|
271
273
|
});
|
|
272
274
|
content = column.renderEditCell(params); // TODO move to GridCell
|
|
@@ -119,6 +119,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
|
|
|
119
119
|
* The mode of the cell.
|
|
120
120
|
*/
|
|
121
121
|
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
|
|
122
|
+
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
122
123
|
|
|
123
124
|
/**
|
|
124
125
|
* The column of the row that the current cell belongs to.
|
|
@@ -175,6 +175,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
|
|
|
175
175
|
* The mode of the cell.
|
|
176
176
|
*/
|
|
177
177
|
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
|
|
178
|
+
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
178
179
|
|
|
179
180
|
/**
|
|
180
181
|
* The column of the row that the current cell belongs to.
|
|
@@ -65,7 +65,7 @@ const GridEditInputCellRoot = (0, _styles.styled)(_InputBase.default, {
|
|
|
65
65
|
}
|
|
66
66
|
}));
|
|
67
67
|
const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
68
|
-
var _rootProps$experiment;
|
|
68
|
+
var _rootProps$experiment, _rootProps$experiment3;
|
|
69
69
|
|
|
70
70
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
71
71
|
const {
|
|
@@ -87,23 +87,36 @@ const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
87
87
|
};
|
|
88
88
|
const classes = useUtilityClasses(ownerState);
|
|
89
89
|
const handleChange = React.useCallback(async event => {
|
|
90
|
+
var _rootProps$experiment2;
|
|
91
|
+
|
|
90
92
|
const newValue = event.target.value;
|
|
91
93
|
|
|
92
94
|
if (onValueChange) {
|
|
93
95
|
await onValueChange(event, newValue);
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
const column = apiRef.current.getColumn(field);
|
|
99
|
+
let parsedValue = newValue;
|
|
100
|
+
|
|
101
|
+
if (column.valueParser && (_rootProps$experiment2 = rootProps.experimentalFeatures) != null && _rootProps$experiment2.newEditingApi) {
|
|
102
|
+
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setValueState(parsedValue);
|
|
97
106
|
apiRef.current.setEditCellValue({
|
|
98
107
|
id,
|
|
99
108
|
field,
|
|
100
|
-
value:
|
|
101
|
-
debounceMs
|
|
109
|
+
value: parsedValue,
|
|
110
|
+
debounceMs,
|
|
111
|
+
unstable_skipValueParser: true
|
|
102
112
|
}, event);
|
|
103
|
-
}, [apiRef, debounceMs, field, id, onValueChange]);
|
|
113
|
+
}, [apiRef, debounceMs, field, id, onValueChange, (_rootProps$experiment3 = rootProps.experimentalFeatures) == null ? void 0 : _rootProps$experiment3.newEditingApi]);
|
|
114
|
+
const meta = apiRef.current.unstable_getEditCellMeta ? apiRef.current.unstable_getEditCellMeta(id, field) : {};
|
|
104
115
|
React.useEffect(() => {
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
if (meta.changeReason !== 'debouncedSetEditCellValue') {
|
|
117
|
+
setValueState(value);
|
|
118
|
+
}
|
|
119
|
+
}, [meta.changeReason, value]);
|
|
107
120
|
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
108
121
|
if (hasFocus) {
|
|
109
122
|
inputRef.current.focus();
|
|
@@ -137,6 +150,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
137
150
|
* The mode of the cell.
|
|
138
151
|
*/
|
|
139
152
|
cellMode: _propTypes.default.oneOf(['edit', 'view']),
|
|
153
|
+
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
140
154
|
|
|
141
155
|
/**
|
|
142
156
|
* The column of the row that the current cell belongs to.
|
|
@@ -217,6 +217,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
217
217
|
* The mode of the cell.
|
|
218
218
|
*/
|
|
219
219
|
cellMode: _propTypes.default.oneOf(['edit', 'view']).isRequired,
|
|
220
|
+
changeReason: _propTypes.default.oneOf(['debouncedSetEditCellValue', 'setEditCellValue']),
|
|
220
221
|
|
|
221
222
|
/**
|
|
222
223
|
* The column of the row that the current cell belongs to.
|
|
@@ -382,7 +382,9 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
382
382
|
const {
|
|
383
383
|
id,
|
|
384
384
|
field,
|
|
385
|
-
value
|
|
385
|
+
value,
|
|
386
|
+
debounceMs,
|
|
387
|
+
unstable_skipValueParser: skipValueParser
|
|
386
388
|
} = params;
|
|
387
389
|
throwIfNotEditable(id, field);
|
|
388
390
|
throwIfNotInMode(id, field, _gridEditRowModel.GridCellModes.Edit);
|
|
@@ -390,13 +392,14 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
390
392
|
const row = apiRef.current.getRow(id);
|
|
391
393
|
let parsedValue = value;
|
|
392
394
|
|
|
393
|
-
if (column.valueParser) {
|
|
395
|
+
if (column.valueParser && !skipValueParser) {
|
|
394
396
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
395
397
|
}
|
|
396
398
|
|
|
397
399
|
let editingState = (0, _gridEditRowsSelector.gridEditRowsStateSelector)(apiRef.current.state);
|
|
398
400
|
let newProps = (0, _extends2.default)({}, editingState[id][field], {
|
|
399
|
-
value: parsedValue
|
|
401
|
+
value: parsedValue,
|
|
402
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
400
403
|
});
|
|
401
404
|
|
|
402
405
|
if (column.preProcessEditCellProps) {
|
|
@@ -19,6 +19,8 @@ var _gridEditRowModel = require("../../../models/gridEditRowModel");
|
|
|
19
19
|
|
|
20
20
|
var _useGridRowEditing = require("./useGridRowEditing.new");
|
|
21
21
|
|
|
22
|
+
var _gridEditRowsSelector = require("./gridEditRowsSelector");
|
|
23
|
+
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
25
|
|
|
24
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -138,11 +140,18 @@ const useGridEditing = (apiRef, props) => {
|
|
|
138
140
|
const getRowWithUpdatedValues = React.useCallback((id, field) => {
|
|
139
141
|
return props.editMode === _gridEditRowModel.GridEditModes.Cell ? apiRef.current.unstable_getRowWithUpdatedValuesFromCellEditing(id, field) : apiRef.current.unstable_getRowWithUpdatedValuesFromRowEditing(id);
|
|
140
142
|
}, [apiRef, props.editMode]);
|
|
143
|
+
const getEditCellMeta = React.useCallback((id, field) => {
|
|
144
|
+
const editingState = (0, _gridEditRowsSelector.gridEditRowsStateSelector)(apiRef.current.state);
|
|
145
|
+
return {
|
|
146
|
+
changeReason: editingState[id][field].changeReason
|
|
147
|
+
};
|
|
148
|
+
}, [apiRef]);
|
|
141
149
|
const editingSharedApi = {
|
|
142
150
|
isCellEditable,
|
|
143
151
|
setEditCellValue,
|
|
144
152
|
unstable_runPendingEditCellValueMutation: runPendingEditCellValueMutation,
|
|
145
|
-
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues
|
|
153
|
+
unstable_getRowWithUpdatedValues: getRowWithUpdatedValues,
|
|
154
|
+
unstable_getEditCellMeta: getEditCellMeta
|
|
146
155
|
};
|
|
147
156
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, editingSharedApi, 'EditingApi');
|
|
148
157
|
};
|
|
@@ -461,20 +461,23 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
461
461
|
const {
|
|
462
462
|
id,
|
|
463
463
|
field,
|
|
464
|
-
value
|
|
464
|
+
value,
|
|
465
|
+
debounceMs,
|
|
466
|
+
unstable_skipValueParser: skipValueParser
|
|
465
467
|
} = params;
|
|
466
468
|
throwIfNotEditable(id, field);
|
|
467
469
|
const column = apiRef.current.getColumn(field);
|
|
468
470
|
const row = apiRef.current.getRow(id);
|
|
469
471
|
let parsedValue = value;
|
|
470
472
|
|
|
471
|
-
if (column.valueParser) {
|
|
473
|
+
if (column.valueParser && !skipValueParser) {
|
|
472
474
|
parsedValue = column.valueParser(value, apiRef.current.getCellParams(id, field));
|
|
473
475
|
}
|
|
474
476
|
|
|
475
477
|
let editingState = (0, _gridEditRowsSelector.gridEditRowsStateSelector)(apiRef.current.state);
|
|
476
478
|
let newProps = (0, _extends2.default)({}, editingState[id][field], {
|
|
477
|
-
value: parsedValue
|
|
479
|
+
value: parsedValue,
|
|
480
|
+
changeReason: debounceMs ? 'debouncedSetEditCellValue' : 'setEditCellValue'
|
|
478
481
|
});
|
|
479
482
|
|
|
480
483
|
if (!column.preProcessEditCellProps) {
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "5.17.
|
|
3
|
+
"version": "5.17.3",
|
|
4
4
|
"description": "The community edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@babel/runtime": "^7.18.9",
|
|
39
|
-
"@mui/utils": "^5.
|
|
39
|
+
"@mui/utils": "^5.10.3",
|
|
40
40
|
"clsx": "^1.2.1",
|
|
41
41
|
"prop-types": "^15.8.1",
|
|
42
42
|
"reselect": "^4.1.6"
|