@mui/x-data-grid 5.15.0 → 5.15.1
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 +42 -1
- package/components/cell/GridEditInputCell.d.ts +2 -5
- package/components/cell/GridEditInputCell.js +13 -14
- package/components/cell/GridEditSingleSelectCell.d.ts +4 -0
- package/components/cell/GridEditSingleSelectCell.js +11 -4
- package/components/toolbar/GridToolbarDensitySelector.js +13 -4
- package/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/constants/envConstants.d.ts +1 -1
- package/constants/envConstants.js +2 -11
- package/hooks/features/editRows/useGridCellEditing.new.js +5 -6
- package/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/hooks/features/editRows/useGridRowEditing.new.js +5 -6
- package/index.js +1 -1
- package/legacy/components/cell/GridEditInputCell.js +13 -14
- package/legacy/components/cell/GridEditSingleSelectCell.js +11 -3
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +14 -5
- package/legacy/components/toolbar/GridToolbarExportContainer.js +15 -2
- package/legacy/constants/envConstants.js +2 -11
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +5 -6
- package/legacy/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +5 -6
- package/legacy/index.js +1 -1
- package/legacy/locales/deDE.js +8 -8
- package/legacy/locales/itIT.js +15 -15
- package/legacy/locales/koKR.js +34 -30
- package/legacy/utils/keyboardUtils.js +8 -5
- package/locales/deDE.js +8 -8
- package/locales/itIT.js +15 -15
- package/locales/koKR.js +30 -30
- package/modern/components/cell/GridEditInputCell.js +13 -14
- package/modern/components/cell/GridEditSingleSelectCell.js +11 -4
- package/modern/components/toolbar/GridToolbarDensitySelector.js +11 -4
- package/modern/components/toolbar/GridToolbarExportContainer.js +11 -2
- package/modern/constants/envConstants.js +2 -11
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +5 -6
- package/modern/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +5 -6
- package/modern/index.js +1 -1
- package/modern/locales/deDE.js +8 -8
- package/modern/locales/itIT.js +15 -15
- package/modern/locales/koKR.js +30 -30
- package/modern/utils/keyboardUtils.js +7 -2
- package/node/components/cell/GridEditInputCell.js +15 -16
- package/node/components/cell/GridEditSingleSelectCell.js +10 -4
- package/node/components/toolbar/GridToolbarDensitySelector.js +13 -4
- package/node/components/toolbar/GridToolbarExportContainer.js +13 -2
- package/node/constants/envConstants.js +2 -13
- package/node/hooks/features/editRows/useGridCellEditing.new.js +5 -6
- package/node/hooks/features/editRows/useGridCellEditing.old.js +2 -2
- package/node/hooks/features/editRows/useGridRowEditing.new.js +5 -6
- package/node/index.js +1 -1
- package/node/locales/deDE.js +8 -8
- package/node/locales/itIT.js +15 -15
- package/node/locales/koKR.js +30 -30
- package/node/utils/keyboardUtils.js +10 -4
- package/package.json +1 -1
- package/utils/keyboardUtils.d.ts +2 -2
- package/utils/keyboardUtils.js +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
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.15.1
|
|
7
|
+
|
|
8
|
+
_Aug 4, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 📚 New [page presenting the `apiRef`](https://mui.com/x/react-data-grid/api-object/) (#5273) @flaviendelangle
|
|
13
|
+
- ✨ Better keyboard support for start editing cells (#5511) @oliviertassinari
|
|
14
|
+
- 🌍 Improvements to different locales
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
|
|
17
|
+
### `@mui/x-data-grid@v5.15.1` / `@mui/x-data-grid-pro@v5.15.1` / `@mui/x-data-grid-premium@v5.15.1`
|
|
18
|
+
|
|
19
|
+
#### Changes
|
|
20
|
+
|
|
21
|
+
- [DataGrid] Improve start edit UX (#5511) @oliviertassinari
|
|
22
|
+
- [DataGrid] Add `initialOpen` prop to `GridEditSingleSelectCell` to allow overriding initial open state (#5645) @shapaaa
|
|
23
|
+
- [DataGrid] Forward `ref` to root element in `GridEditInputCell` (#5631) @Zenoo
|
|
24
|
+
- [DataGrid] Toggle open state when clicking on buttons in the `GridToolbar` (#5503) @cherniavskii
|
|
25
|
+
- [DataGrid] Improve German (de-DE) locale (#5586) @sebastianfrey
|
|
26
|
+
- [DataGrid] Improve Korean (ko-KR) locale (#5668) @Einere
|
|
27
|
+
- [DataGrid] Complete Italian (it-IT) locale (#5487) @mamodev
|
|
28
|
+
|
|
29
|
+
### `@mui/x-date-pickers@v5.0.0-beta.4` / `@mui/x-date-picker-pro@5.0.0-beta.4`
|
|
30
|
+
|
|
31
|
+
#### Changes
|
|
32
|
+
|
|
33
|
+
- [DatePicker] Customize day formatter in the calendar (#5373) @alexfauquette
|
|
34
|
+
|
|
35
|
+
### Docs
|
|
36
|
+
|
|
37
|
+
- [docs] New location for the legal content (#5595) @oliviertassinari
|
|
38
|
+
- [docs] Update description of `maxDateTime` prop (#5639) @jurecuhalev
|
|
39
|
+
- [docs] Add missing `date-fns` dependency when opening Codesandbox demo (#5692) @cherniavskii
|
|
40
|
+
|
|
41
|
+
### Core
|
|
42
|
+
|
|
43
|
+
- [core] Drop usage of `GRID_EXPERIMENTAL_ENABLED` env variable (#5669) @ar7casper
|
|
44
|
+
- [core] Isolate asset loading under /x/ (#5594) @oliviertassinari
|
|
45
|
+
- [core] Upgrade node to v14 (#4999) @cherniavskii
|
|
46
|
+
|
|
6
47
|
## 5.15.0
|
|
7
48
|
|
|
8
49
|
_Jul 29, 2022_
|
|
@@ -13,7 +54,7 @@ We'd like to offer a big thanks to the 6 contributors who made this release poss
|
|
|
13
54
|
|
|
14
55
|
Premium users can now aggregate data in the grid.
|
|
15
56
|
Extract information like sum, average, count, and others with a couple of clicks.
|
|
16
|
-
|
|
57
|
+
|
|
17
58
|
https://user-images.githubusercontent.com/45398769/181581503-77cc412e-9d9e-4de1-8bc3-c3bccc54cdaa.mp4
|
|
18
59
|
|
|
19
60
|
To enable this feature, add `experimentalFeatures={{ aggregation: true }}`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InputBaseProps } from '@mui/material/InputBase';
|
|
3
3
|
import { GridRenderEditCellParams } from '../../models/params/gridCellParams';
|
|
4
|
-
export interface GridEditInputCellProps extends GridRenderEditCellParams, Omit<InputBaseProps, 'id' | 'value' | 'tabIndex'> {
|
|
4
|
+
export interface GridEditInputCellProps extends GridRenderEditCellParams, Omit<InputBaseProps, 'id' | 'value' | 'tabIndex' | 'ref'> {
|
|
5
5
|
debounceMs?: number;
|
|
6
6
|
/**
|
|
7
7
|
* Callback called when the value is changed by the user.
|
|
@@ -11,9 +11,6 @@ export interface GridEditInputCellProps extends GridRenderEditCellParams, Omit<I
|
|
|
11
11
|
*/
|
|
12
12
|
onValueChange?: (event: React.ChangeEvent<HTMLInputElement>, newValue: string) => Promise<void> | void;
|
|
13
13
|
}
|
|
14
|
-
declare
|
|
15
|
-
declare namespace GridEditInputCell {
|
|
16
|
-
var propTypes: any;
|
|
17
|
-
}
|
|
14
|
+
declare const GridEditInputCell: React.ForwardRefExoticComponent<Pick<GridEditInputCellProps, keyof GridEditInputCellProps> & React.RefAttributes<HTMLInputElement>>;
|
|
18
15
|
export { GridEditInputCell };
|
|
19
16
|
export declare const renderEditInputCell: (params: GridEditInputCellProps) => JSX.Element;
|
|
@@ -37,8 +37,7 @@ const GridEditInputCellRoot = styled(InputBase, {
|
|
|
37
37
|
height: '100%'
|
|
38
38
|
}
|
|
39
39
|
}));
|
|
40
|
-
|
|
41
|
-
function GridEditInputCell(props) {
|
|
40
|
+
const GridEditInputCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
42
41
|
var _rootProps$experiment;
|
|
43
42
|
|
|
44
43
|
const rootProps = useGridRootProps();
|
|
@@ -86,6 +85,7 @@ function GridEditInputCell(props) {
|
|
|
86
85
|
}
|
|
87
86
|
}, [hasFocus]);
|
|
88
87
|
return /*#__PURE__*/_jsx(GridEditInputCellRoot, _extends({
|
|
88
|
+
ref: ref,
|
|
89
89
|
inputRef: inputRef,
|
|
90
90
|
className: classes.root,
|
|
91
91
|
fullWidth: true,
|
|
@@ -94,8 +94,7 @@ function GridEditInputCell(props) {
|
|
|
94
94
|
onChange: handleChange,
|
|
95
95
|
endAdornment: isProcessingProps ? /*#__PURE__*/_jsx(GridLoadIcon, {}) : undefined
|
|
96
96
|
}, other));
|
|
97
|
-
}
|
|
98
|
-
|
|
97
|
+
});
|
|
99
98
|
process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
100
99
|
// ----------------------------- Warning --------------------------------
|
|
101
100
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -106,23 +105,23 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
106
105
|
* GridApi that let you manipulate the grid.
|
|
107
106
|
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
|
|
108
107
|
*/
|
|
109
|
-
api: PropTypes.any
|
|
108
|
+
api: PropTypes.any,
|
|
110
109
|
|
|
111
110
|
/**
|
|
112
111
|
* The mode of the cell.
|
|
113
112
|
*/
|
|
114
|
-
cellMode: PropTypes.oneOf(['edit', 'view'])
|
|
113
|
+
cellMode: PropTypes.oneOf(['edit', 'view']),
|
|
115
114
|
|
|
116
115
|
/**
|
|
117
116
|
* The column of the row that the current cell belongs to.
|
|
118
117
|
*/
|
|
119
|
-
colDef: PropTypes.object
|
|
118
|
+
colDef: PropTypes.object,
|
|
120
119
|
debounceMs: PropTypes.number,
|
|
121
120
|
|
|
122
121
|
/**
|
|
123
122
|
* The column field of the cell that triggered the event.
|
|
124
123
|
*/
|
|
125
|
-
field: PropTypes.string
|
|
124
|
+
field: PropTypes.string,
|
|
126
125
|
|
|
127
126
|
/**
|
|
128
127
|
* The cell value formatted with the column valueFormatter.
|
|
@@ -136,17 +135,17 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
136
135
|
* @returns {any} The cell value.
|
|
137
136
|
* @deprecated Use `params.row` to directly access the fields you want instead.
|
|
138
137
|
*/
|
|
139
|
-
getValue: PropTypes.func
|
|
138
|
+
getValue: PropTypes.func,
|
|
140
139
|
|
|
141
140
|
/**
|
|
142
141
|
* If true, the cell is the active element.
|
|
143
142
|
*/
|
|
144
|
-
hasFocus: PropTypes.bool
|
|
143
|
+
hasFocus: PropTypes.bool,
|
|
145
144
|
|
|
146
145
|
/**
|
|
147
146
|
* The grid row id.
|
|
148
147
|
*/
|
|
149
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
148
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
150
149
|
|
|
151
150
|
/**
|
|
152
151
|
* If true, the cell is editable.
|
|
@@ -166,17 +165,17 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
166
165
|
/**
|
|
167
166
|
* The row model of the row that the current cell belongs to.
|
|
168
167
|
*/
|
|
169
|
-
row: PropTypes.object
|
|
168
|
+
row: PropTypes.object,
|
|
170
169
|
|
|
171
170
|
/**
|
|
172
171
|
* The node of the row that the current cell belongs to.
|
|
173
172
|
*/
|
|
174
|
-
rowNode: PropTypes.object
|
|
173
|
+
rowNode: PropTypes.object,
|
|
175
174
|
|
|
176
175
|
/**
|
|
177
176
|
* the tabIndex value.
|
|
178
177
|
*/
|
|
179
|
-
tabIndex: PropTypes.oneOf([-1, 0])
|
|
178
|
+
tabIndex: PropTypes.oneOf([-1, 0]),
|
|
180
179
|
|
|
181
180
|
/**
|
|
182
181
|
* The cell value, but if the column has valueGetter, use getValue.
|
|
@@ -9,6 +9,10 @@ export interface GridEditSingleSelectCellProps extends GridRenderEditCellParams,
|
|
|
9
9
|
* @returns {Promise<void> | void} A promise to be awaited before calling `apiRef.current.setEditCellValue`
|
|
10
10
|
*/
|
|
11
11
|
onValueChange?: (event: SelectChangeEvent<any>, newValue: any) => Promise<void> | void;
|
|
12
|
+
/**
|
|
13
|
+
* If true, the select opens by default.
|
|
14
|
+
*/
|
|
15
|
+
initialOpen?: boolean;
|
|
12
16
|
}
|
|
13
17
|
declare function GridEditSingleSelectCell(props: GridEditSingleSelectCellProps): JSX.Element;
|
|
14
18
|
declare namespace GridEditSingleSelectCell {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "getValue", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange"];
|
|
3
|
+
const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "getValue", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
|
|
@@ -26,6 +26,8 @@ const renderSingleSelectOptions = (option, OptionComponent) => {
|
|
|
26
26
|
function GridEditSingleSelectCell(props) {
|
|
27
27
|
var _rootProps$components, _baseSelectProps$nati, _rootProps$components2;
|
|
28
28
|
|
|
29
|
+
const rootProps = useGridRootProps();
|
|
30
|
+
|
|
29
31
|
const {
|
|
30
32
|
id,
|
|
31
33
|
value,
|
|
@@ -35,15 +37,15 @@ function GridEditSingleSelectCell(props) {
|
|
|
35
37
|
colDef,
|
|
36
38
|
hasFocus,
|
|
37
39
|
error,
|
|
38
|
-
onValueChange
|
|
40
|
+
onValueChange,
|
|
41
|
+
initialOpen = rootProps.editMode === GridEditModes.Cell
|
|
39
42
|
} = props,
|
|
40
43
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
41
44
|
|
|
42
45
|
const apiRef = useGridApiContext();
|
|
43
46
|
const ref = React.useRef();
|
|
44
47
|
const inputRef = React.useRef();
|
|
45
|
-
const
|
|
46
|
-
const [open, setOpen] = React.useState(rootProps.editMode === 'cell');
|
|
48
|
+
const [open, setOpen] = React.useState(initialOpen);
|
|
47
49
|
const baseSelectProps = ((_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.baseSelect) || {};
|
|
48
50
|
const isSelectNative = (_baseSelectProps$nati = baseSelectProps.native) != null ? _baseSelectProps$nati : false;
|
|
49
51
|
let valueOptionsFormatted;
|
|
@@ -218,6 +220,11 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
218
220
|
*/
|
|
219
221
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
220
222
|
|
|
223
|
+
/**
|
|
224
|
+
* If true, the select opens by default.
|
|
225
|
+
*/
|
|
226
|
+
initialOpen: PropTypes.bool,
|
|
227
|
+
|
|
221
228
|
/**
|
|
222
229
|
* If true, the cell is editable.
|
|
223
230
|
*/
|
|
@@ -59,11 +59,20 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
59
59
|
}, [densityValue, rootProps]);
|
|
60
60
|
|
|
61
61
|
const handleDensitySelectorOpen = event => {
|
|
62
|
-
setOpen(
|
|
62
|
+
setOpen(prevOpen => !prevOpen);
|
|
63
63
|
onClick == null ? void 0 : onClick(event);
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
const
|
|
66
|
+
const handleDensitySelectorClickAway = event => {
|
|
67
|
+
var _buttonRef$current;
|
|
68
|
+
|
|
69
|
+
if (buttonRef.current === event.target || // if user clicked on the icon
|
|
70
|
+
(_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setOpen(false);
|
|
75
|
+
};
|
|
67
76
|
|
|
68
77
|
const handleDensityUpdate = newDensity => {
|
|
69
78
|
apiRef.current.setDensity(newDensity);
|
|
@@ -76,7 +85,7 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
if (isHideMenuKey(event.key)) {
|
|
79
|
-
|
|
88
|
+
setOpen(false);
|
|
80
89
|
}
|
|
81
90
|
}; // Disable the button if the corresponding is disabled
|
|
82
91
|
|
|
@@ -109,7 +118,7 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
|
|
|
109
118
|
})), /*#__PURE__*/_jsx(GridMenu, {
|
|
110
119
|
open: open,
|
|
111
120
|
target: buttonRef.current,
|
|
112
|
-
onClickAway:
|
|
121
|
+
onClickAway: handleDensitySelectorClickAway,
|
|
113
122
|
position: "bottom-start",
|
|
114
123
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
115
124
|
id: densityMenuId,
|
|
@@ -29,7 +29,7 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
|
|
|
29
29
|
const handleRef = useForkRef(ref, buttonRef);
|
|
30
30
|
|
|
31
31
|
const handleMenuOpen = event => {
|
|
32
|
-
setOpen(
|
|
32
|
+
setOpen(prevOpen => !prevOpen);
|
|
33
33
|
onClick == null ? void 0 : onClick(event);
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -45,6 +45,17 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
const handleMenuClickAway = event => {
|
|
49
|
+
var _buttonRef$current;
|
|
50
|
+
|
|
51
|
+
if (buttonRef.current === event.target || // if user clicked on the icon
|
|
52
|
+
(_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setOpen(false);
|
|
57
|
+
};
|
|
58
|
+
|
|
48
59
|
if (children == null) {
|
|
49
60
|
return null;
|
|
50
61
|
}
|
|
@@ -66,7 +77,7 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
|
|
|
66
77
|
})), /*#__PURE__*/_jsx(GridMenu, {
|
|
67
78
|
open: open,
|
|
68
79
|
target: buttonRef.current,
|
|
69
|
-
onClickAway:
|
|
80
|
+
onClickAway: handleMenuClickAway,
|
|
70
81
|
position: "bottom-start",
|
|
71
82
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
72
83
|
id: menuId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const GRID_EXPERIMENTAL_ENABLED
|
|
1
|
+
export declare const GRID_EXPERIMENTAL_ENABLED = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// A guide to feature toggling (deprecated)
|
|
2
2
|
//
|
|
3
3
|
// The feature toggle is:
|
|
4
4
|
// - independent from the NODE_ENV
|
|
@@ -15,13 +15,4 @@ import { localStorageAvailable } from '../utils/utils'; // A guide to feature to
|
|
|
15
15
|
//
|
|
16
16
|
// Developers (users) are discouraged to enable the experimental feature by setting the GRID_EXPERIMENTAL_ENABLED env.
|
|
17
17
|
// Instead, prefer exposing experimental APIs, for instance, a prop or a new `unstable_` module.
|
|
18
|
-
|
|
19
|
-
let experimentalEnabled = false;
|
|
20
|
-
|
|
21
|
-
if (typeof process !== 'undefined' && process.env.GRID_EXPERIMENTAL_ENABLED !== undefined && localStorageAvailable() && window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED')) {
|
|
22
|
-
experimentalEnabled = window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED') === 'true';
|
|
23
|
-
} else if (typeof process !== 'undefined') {
|
|
24
|
-
experimentalEnabled = process.env.GRID_EXPERIMENTAL_ENABLED === 'true';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const GRID_EXPERIMENTAL_ENABLED = experimentalEnabled;
|
|
18
|
+
export const GRID_EXPERIMENTAL_ENABLED = false;
|
|
@@ -97,15 +97,14 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
97
97
|
} else if (params.isEditable) {
|
|
98
98
|
let reason;
|
|
99
99
|
|
|
100
|
-
if (isPrintableKey(event
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
100
|
+
if (isPrintableKey(event)) {
|
|
101
|
+
reason = GridCellEditStartReasons.printableKeyDown;
|
|
102
|
+
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
105
103
|
reason = GridCellEditStartReasons.printableKeyDown;
|
|
106
104
|
} else if (event.key === 'Enter') {
|
|
107
105
|
reason = GridCellEditStartReasons.enterKeyDown;
|
|
108
|
-
} else if (event.key === 'Delete') {
|
|
106
|
+
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
107
|
+
// Delete on Windows, Backspace on macOS
|
|
109
108
|
reason = GridCellEditStartReasons.deleteKeyDown;
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -199,7 +199,7 @@ export const useCellEditing = (apiRef, props) => {
|
|
|
199
199
|
const isEditMode = cellMode === GridCellModes.Edit;
|
|
200
200
|
const isModifierKeyPressed = event.ctrlKey || event.metaKey || event.altKey;
|
|
201
201
|
|
|
202
|
-
if (!isEditMode && isCellEnterEditModeKeys(event
|
|
202
|
+
if (!isEditMode && isCellEnterEditModeKeys(event) && !isModifierKeyPressed && !(event.key === ' ' && event.shiftKey)) {
|
|
203
203
|
apiRef.current.publishEvent('cellEditStart', params, event);
|
|
204
204
|
}
|
|
205
205
|
|
|
@@ -269,7 +269,7 @@ export const useCellEditing = (apiRef, props) => {
|
|
|
269
269
|
|
|
270
270
|
apiRef.current.setCellMode(params.id, params.field, GridCellModes.Edit);
|
|
271
271
|
|
|
272
|
-
if (isKeyboardEvent(event) && isPrintableKey(event
|
|
272
|
+
if (isKeyboardEvent(event) && isPrintableKey(event)) {
|
|
273
273
|
apiRef.current.unstable_setEditCellProps({
|
|
274
274
|
id: params.id,
|
|
275
275
|
field: params.field,
|
|
@@ -153,15 +153,14 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
153
153
|
} else if (params.isEditable) {
|
|
154
154
|
let reason;
|
|
155
155
|
|
|
156
|
-
if (isPrintableKey(event
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
156
|
+
if (isPrintableKey(event)) {
|
|
157
|
+
reason = GridRowEditStartReasons.printableKeyDown;
|
|
158
|
+
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v') {
|
|
161
159
|
reason = GridRowEditStartReasons.printableKeyDown;
|
|
162
160
|
} else if (event.key === 'Enter') {
|
|
163
161
|
reason = GridRowEditStartReasons.enterKeyDown;
|
|
164
|
-
} else if (event.key === 'Delete') {
|
|
162
|
+
} else if (event.key === 'Delete' || event.key === 'Backspace') {
|
|
163
|
+
// Delete on Windows, Backspace on macOS
|
|
165
164
|
reason = GridRowEditStartReasons.deleteKeyDown;
|
|
166
165
|
}
|
|
167
166
|
|
package/index.js
CHANGED
|
@@ -41,8 +41,7 @@ var GridEditInputCellRoot = styled(InputBase, {
|
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
-
|
|
45
|
-
function GridEditInputCell(props) {
|
|
44
|
+
var GridEditInputCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
46
45
|
var _rootProps$experiment;
|
|
47
46
|
|
|
48
47
|
var rootProps = useGridRootProps();
|
|
@@ -126,6 +125,7 @@ function GridEditInputCell(props) {
|
|
|
126
125
|
}
|
|
127
126
|
}, [hasFocus]);
|
|
128
127
|
return /*#__PURE__*/_jsx(GridEditInputCellRoot, _extends({
|
|
128
|
+
ref: ref,
|
|
129
129
|
inputRef: inputRef,
|
|
130
130
|
className: classes.root,
|
|
131
131
|
fullWidth: true,
|
|
@@ -134,8 +134,7 @@ function GridEditInputCell(props) {
|
|
|
134
134
|
onChange: handleChange,
|
|
135
135
|
endAdornment: isProcessingProps ? /*#__PURE__*/_jsx(GridLoadIcon, {}) : undefined
|
|
136
136
|
}, other));
|
|
137
|
-
}
|
|
138
|
-
|
|
137
|
+
});
|
|
139
138
|
process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
140
139
|
// ----------------------------- Warning --------------------------------
|
|
141
140
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -146,23 +145,23 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
146
145
|
* GridApi that let you manipulate the grid.
|
|
147
146
|
* @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
|
|
148
147
|
*/
|
|
149
|
-
api: PropTypes.any
|
|
148
|
+
api: PropTypes.any,
|
|
150
149
|
|
|
151
150
|
/**
|
|
152
151
|
* The mode of the cell.
|
|
153
152
|
*/
|
|
154
|
-
cellMode: PropTypes.oneOf(['edit', 'view'])
|
|
153
|
+
cellMode: PropTypes.oneOf(['edit', 'view']),
|
|
155
154
|
|
|
156
155
|
/**
|
|
157
156
|
* The column of the row that the current cell belongs to.
|
|
158
157
|
*/
|
|
159
|
-
colDef: PropTypes.object
|
|
158
|
+
colDef: PropTypes.object,
|
|
160
159
|
debounceMs: PropTypes.number,
|
|
161
160
|
|
|
162
161
|
/**
|
|
163
162
|
* The column field of the cell that triggered the event.
|
|
164
163
|
*/
|
|
165
|
-
field: PropTypes.string
|
|
164
|
+
field: PropTypes.string,
|
|
166
165
|
|
|
167
166
|
/**
|
|
168
167
|
* The cell value formatted with the column valueFormatter.
|
|
@@ -176,17 +175,17 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
176
175
|
* @returns {any} The cell value.
|
|
177
176
|
* @deprecated Use `params.row` to directly access the fields you want instead.
|
|
178
177
|
*/
|
|
179
|
-
getValue: PropTypes.func
|
|
178
|
+
getValue: PropTypes.func,
|
|
180
179
|
|
|
181
180
|
/**
|
|
182
181
|
* If true, the cell is the active element.
|
|
183
182
|
*/
|
|
184
|
-
hasFocus: PropTypes.bool
|
|
183
|
+
hasFocus: PropTypes.bool,
|
|
185
184
|
|
|
186
185
|
/**
|
|
187
186
|
* The grid row id.
|
|
188
187
|
*/
|
|
189
|
-
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
188
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
190
189
|
|
|
191
190
|
/**
|
|
192
191
|
* If true, the cell is editable.
|
|
@@ -206,17 +205,17 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
|
|
|
206
205
|
/**
|
|
207
206
|
* The row model of the row that the current cell belongs to.
|
|
208
207
|
*/
|
|
209
|
-
row: PropTypes.object
|
|
208
|
+
row: PropTypes.object,
|
|
210
209
|
|
|
211
210
|
/**
|
|
212
211
|
* The node of the row that the current cell belongs to.
|
|
213
212
|
*/
|
|
214
|
-
rowNode: PropTypes.object
|
|
213
|
+
rowNode: PropTypes.object,
|
|
215
214
|
|
|
216
215
|
/**
|
|
217
216
|
* the tabIndex value.
|
|
218
217
|
*/
|
|
219
|
-
tabIndex: PropTypes.oneOf([-1, 0])
|
|
218
|
+
tabIndex: PropTypes.oneOf([-1, 0]),
|
|
220
219
|
|
|
221
220
|
/**
|
|
222
221
|
* The cell value, but if the column has valueGetter, use getValue.
|
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
6
|
-
var _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "getValue", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange"];
|
|
6
|
+
var _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowNode", "colDef", "cellMode", "isEditable", "tabIndex", "className", "getValue", "hasFocus", "isValidating", "isProcessingProps", "error", "onValueChange", "initialOpen"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
@@ -30,6 +30,8 @@ var renderSingleSelectOptions = function renderSingleSelectOptions(option, Optio
|
|
|
30
30
|
function GridEditSingleSelectCell(props) {
|
|
31
31
|
var _rootProps$components, _baseSelectProps$nati, _rootProps$components2;
|
|
32
32
|
|
|
33
|
+
var rootProps = useGridRootProps();
|
|
34
|
+
|
|
33
35
|
var id = props.id,
|
|
34
36
|
value = props.value,
|
|
35
37
|
formattedValue = props.formattedValue,
|
|
@@ -48,14 +50,15 @@ function GridEditSingleSelectCell(props) {
|
|
|
48
50
|
isProcessingProps = props.isProcessingProps,
|
|
49
51
|
error = props.error,
|
|
50
52
|
onValueChange = props.onValueChange,
|
|
53
|
+
_props$initialOpen = props.initialOpen,
|
|
54
|
+
initialOpen = _props$initialOpen === void 0 ? rootProps.editMode === GridEditModes.Cell : _props$initialOpen,
|
|
51
55
|
other = _objectWithoutProperties(props, _excluded);
|
|
52
56
|
|
|
53
57
|
var apiRef = useGridApiContext();
|
|
54
58
|
var ref = React.useRef();
|
|
55
59
|
var inputRef = React.useRef();
|
|
56
|
-
var rootProps = useGridRootProps();
|
|
57
60
|
|
|
58
|
-
var _React$useState = React.useState(
|
|
61
|
+
var _React$useState = React.useState(initialOpen),
|
|
59
62
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
60
63
|
open = _React$useState2[0],
|
|
61
64
|
setOpen = _React$useState2[1];
|
|
@@ -274,6 +277,11 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
|
|
|
274
277
|
*/
|
|
275
278
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
276
279
|
|
|
280
|
+
/**
|
|
281
|
+
* If true, the select opens by default.
|
|
282
|
+
*/
|
|
283
|
+
initialOpen: PropTypes.bool,
|
|
284
|
+
|
|
277
285
|
/**
|
|
278
286
|
* If true, the cell is editable.
|
|
279
287
|
*/
|
|
@@ -63,12 +63,21 @@ export var GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function G
|
|
|
63
63
|
}, [densityValue, rootProps]);
|
|
64
64
|
|
|
65
65
|
var handleDensitySelectorOpen = function handleDensitySelectorOpen(event) {
|
|
66
|
-
setOpen(
|
|
66
|
+
setOpen(function (prevOpen) {
|
|
67
|
+
return !prevOpen;
|
|
68
|
+
});
|
|
67
69
|
onClick == null ? void 0 : onClick(event);
|
|
68
70
|
};
|
|
69
71
|
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
+
var handleDensitySelectorClickAway = function handleDensitySelectorClickAway(event) {
|
|
73
|
+
var _buttonRef$current;
|
|
74
|
+
|
|
75
|
+
if (buttonRef.current === event.target || // if user clicked on the icon
|
|
76
|
+
(_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setOpen(false);
|
|
72
81
|
};
|
|
73
82
|
|
|
74
83
|
var handleDensityUpdate = function handleDensityUpdate(newDensity) {
|
|
@@ -82,7 +91,7 @@ export var GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function G
|
|
|
82
91
|
}
|
|
83
92
|
|
|
84
93
|
if (isHideMenuKey(event.key)) {
|
|
85
|
-
|
|
94
|
+
setOpen(false);
|
|
86
95
|
}
|
|
87
96
|
}; // Disable the button if the corresponding is disabled
|
|
88
97
|
|
|
@@ -119,7 +128,7 @@ export var GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function G
|
|
|
119
128
|
})), /*#__PURE__*/_jsx(GridMenu, {
|
|
120
129
|
open: open,
|
|
121
130
|
target: buttonRef.current,
|
|
122
|
-
onClickAway:
|
|
131
|
+
onClickAway: handleDensitySelectorClickAway,
|
|
123
132
|
position: "bottom-start",
|
|
124
133
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
125
134
|
id: densityMenuId,
|
|
@@ -33,7 +33,9 @@ export var GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function G
|
|
|
33
33
|
var handleRef = useForkRef(ref, buttonRef);
|
|
34
34
|
|
|
35
35
|
var handleMenuOpen = function handleMenuOpen(event) {
|
|
36
|
-
setOpen(
|
|
36
|
+
setOpen(function (prevOpen) {
|
|
37
|
+
return !prevOpen;
|
|
38
|
+
});
|
|
37
39
|
onClick == null ? void 0 : onClick(event);
|
|
38
40
|
};
|
|
39
41
|
|
|
@@ -51,6 +53,17 @@ export var GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function G
|
|
|
51
53
|
}
|
|
52
54
|
};
|
|
53
55
|
|
|
56
|
+
var handleMenuClickAway = function handleMenuClickAway(event) {
|
|
57
|
+
var _buttonRef$current;
|
|
58
|
+
|
|
59
|
+
if (buttonRef.current === event.target || // if user clicked on the icon
|
|
60
|
+
(_buttonRef$current = buttonRef.current) != null && _buttonRef$current.contains(event.target)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setOpen(false);
|
|
65
|
+
};
|
|
66
|
+
|
|
54
67
|
if (children == null) {
|
|
55
68
|
return null;
|
|
56
69
|
}
|
|
@@ -72,7 +85,7 @@ export var GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function G
|
|
|
72
85
|
})), /*#__PURE__*/_jsx(GridMenu, {
|
|
73
86
|
open: open,
|
|
74
87
|
target: buttonRef.current,
|
|
75
|
-
onClickAway:
|
|
88
|
+
onClickAway: handleMenuClickAway,
|
|
76
89
|
position: "bottom-start",
|
|
77
90
|
children: /*#__PURE__*/_jsx(MenuList, {
|
|
78
91
|
id: menuId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// A guide to feature toggling (deprecated)
|
|
2
2
|
//
|
|
3
3
|
// The feature toggle is:
|
|
4
4
|
// - independent from the NODE_ENV
|
|
@@ -15,13 +15,4 @@ import { localStorageAvailable } from '../utils/utils'; // A guide to feature to
|
|
|
15
15
|
//
|
|
16
16
|
// Developers (users) are discouraged to enable the experimental feature by setting the GRID_EXPERIMENTAL_ENABLED env.
|
|
17
17
|
// Instead, prefer exposing experimental APIs, for instance, a prop or a new `unstable_` module.
|
|
18
|
-
|
|
19
|
-
var experimentalEnabled = false;
|
|
20
|
-
|
|
21
|
-
if (typeof process !== 'undefined' && process.env.GRID_EXPERIMENTAL_ENABLED !== undefined && localStorageAvailable() && window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED')) {
|
|
22
|
-
experimentalEnabled = window.localStorage.getItem('GRID_EXPERIMENTAL_ENABLED') === 'true';
|
|
23
|
-
} else if (typeof process !== 'undefined') {
|
|
24
|
-
experimentalEnabled = process.env.GRID_EXPERIMENTAL_ENABLED === 'true';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export var GRID_EXPERIMENTAL_ENABLED = experimentalEnabled;
|
|
18
|
+
export var GRID_EXPERIMENTAL_ENABLED = false;
|