@mui/x-data-grid 6.0.4 → 6.2.0
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 +110 -0
- package/components/GridAutoSizer.js +3 -0
- package/components/GridPagination.d.ts +6 -6
- package/components/GridRow.js +3 -1
- package/components/cell/GridActionsCellItem.d.ts +2 -2
- package/components/cell/GridEditDateCell.js +37 -16
- package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/components/panel/GridColumnsPanel.d.ts +8 -0
- package/components/panel/GridColumnsPanel.js +18 -6
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
- package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
- package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
- package/hooks/core/useGridApiInitialization.js +3 -3
- package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
- package/hooks/features/editing/useGridCellEditing.js +5 -1
- package/hooks/features/editing/useGridEditing.js +1 -3
- package/hooks/features/editing/useGridRowEditing.js +5 -1
- package/hooks/features/filter/gridFilterState.js +6 -1
- package/hooks/features/filter/useGridFilter.js +5 -0
- package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +36 -16
- package/index.js +9 -1
- package/legacy/components/GridAutoSizer.js +3 -0
- package/legacy/components/GridRow.js +4 -1
- package/legacy/components/cell/GridEditBooleanCell.js +19 -21
- package/legacy/components/cell/GridEditDateCell.js +69 -39
- package/legacy/components/cell/GridEditInputCell.js +25 -27
- package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
- package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
- package/legacy/components/panel/GridColumnsPanel.js +19 -6
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
- package/legacy/hooks/core/useGridApiInitialization.js +3 -3
- package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
- package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
- package/legacy/hooks/features/editing/useGridEditing.js +17 -21
- package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
- package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
- package/legacy/hooks/features/filter/gridFilterState.js +6 -1
- package/legacy/hooks/features/filter/useGridFilter.js +5 -0
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
- package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +6 -6
- package/legacy/index.js +9 -1
- package/legacy/locales/coreLocales.js +0 -1
- package/legacy/locales/frFR.js +7 -9
- package/legacy/locales/huHU.js +15 -20
- package/legacy/locales/jaJP.js +1 -1
- package/legacy/locales/nlNL.js +3 -3
- package/legacy/locales/ptBR.js +7 -9
- package/legacy/locales/ruRU.js +1 -1
- package/legacy/locales/urPK.js +6 -6
- package/legacy/models/gridColumnGrouping.js +4 -0
- package/legacy/models/params/gridRowParams.js +8 -0
- package/legacy/utils/createSelector.js +14 -22
- package/legacy/utils/utils.js +1 -1
- package/locales/coreLocales.js +0 -1
- package/locales/frFR.js +7 -9
- package/locales/huHU.js +15 -20
- package/locales/jaJP.js +1 -1
- package/locales/nlNL.js +3 -3
- package/locales/ptBR.js +7 -9
- package/locales/ruRU.js +1 -1
- package/locales/urPK.js +6 -6
- package/models/api/gridCoreApi.d.ts +3 -1
- package/models/api/gridEditingApi.d.ts +4 -0
- package/models/gridColumnGrouping.js +4 -0
- package/models/params/gridRowParams.js +8 -0
- package/modern/components/GridAutoSizer.js +3 -0
- package/modern/components/GridRow.js +3 -1
- package/modern/components/cell/GridEditDateCell.js +37 -16
- package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/modern/components/panel/GridColumnsPanel.js +18 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
- package/modern/hooks/core/useGridApiInitialization.js +3 -3
- package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
- package/modern/hooks/features/editing/useGridEditing.js +1 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
- package/modern/hooks/features/filter/gridFilterState.js +6 -1
- package/modern/hooks/features/filter/useGridFilter.js +5 -0
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
- package/modern/index.js +9 -1
- package/modern/locales/coreLocales.js +0 -1
- package/modern/locales/frFR.js +7 -9
- package/modern/locales/huHU.js +15 -20
- package/modern/locales/jaJP.js +1 -1
- package/modern/locales/nlNL.js +3 -3
- package/modern/locales/ptBR.js +7 -9
- package/modern/locales/ruRU.js +1 -1
- package/modern/locales/urPK.js +6 -6
- package/modern/models/gridColumnGrouping.js +4 -0
- package/modern/models/params/gridRowParams.js +8 -0
- package/modern/utils/createSelector.js +12 -22
- package/modern/utils/utils.js +1 -1
- package/node/components/GridAutoSizer.js +3 -1
- package/node/components/GridRow.js +3 -1
- package/node/components/cell/GridCell.js +1 -0
- package/node/components/cell/GridEditDateCell.js +37 -16
- package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
- package/node/components/panel/GridColumnsPanel.js +18 -6
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
- package/node/hooks/core/useGridApiInitialization.js +3 -3
- package/node/hooks/features/editing/useGridCellEditing.js +5 -1
- package/node/hooks/features/editing/useGridEditing.js +1 -3
- package/node/hooks/features/editing/useGridRowEditing.js +5 -1
- package/node/hooks/features/filter/gridFilterState.js +5 -0
- package/node/hooks/features/filter/useGridFilter.js +5 -0
- package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
- package/node/index.js +1 -1
- package/node/locales/frFR.js +7 -9
- package/node/locales/huHU.js +15 -20
- package/node/locales/jaJP.js +1 -1
- package/node/locales/nlNL.js +3 -3
- package/node/locales/ptBR.js +7 -9
- package/node/locales/ruRU.js +1 -1
- package/node/locales/urPK.js +6 -6
- package/node/models/gridColumnGrouping.js +4 -0
- package/node/models/params/gridEditCellParams.js +1 -0
- package/node/models/params/gridRowParams.js +9 -0
- package/node/utils/createSelector.js +12 -22
- package/node/utils/utils.js +1 -1
- package/package.json +1 -1
- package/utils/createSelector.d.ts +4 -4
- package/utils/createSelector.js +14 -22
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +1 -1
|
@@ -32,5 +32,13 @@ var GridRowEditStopReasons = /*#__PURE__*/function (GridRowEditStopReasons) {
|
|
|
32
32
|
GridRowEditStopReasons["shiftTabKeyDown"] = "shiftTabKeyDown";
|
|
33
33
|
return GridRowEditStopReasons;
|
|
34
34
|
}(GridRowEditStopReasons || {});
|
|
35
|
+
/**
|
|
36
|
+
* Object passed as parameter in the row `getRowSpacing` callback prop.
|
|
37
|
+
* @demos
|
|
38
|
+
* - [Row spacing](/x/react-data-grid/row-height/#row-spacing)
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* The getRowSpacing return value.
|
|
42
|
+
*/
|
|
35
43
|
// https://github.com/mui/mui-x/pull/3738#discussion_r798504277
|
|
36
44
|
export { GridRowEditStartReasons, GridRowEditStopReasons };
|
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
import { createSelector as reselectCreateSelector } from 'reselect';
|
|
2
2
|
import { buildWarning } from './warning';
|
|
3
3
|
const cacheContainer = {
|
|
4
|
-
cache:
|
|
4
|
+
cache: new WeakMap()
|
|
5
5
|
};
|
|
6
6
|
const missingInstanceIdWarning = buildWarning(['MUI: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g `mySelector(state, apiRef.current.instanceId)`.']);
|
|
7
7
|
export const createSelector = (...args) => {
|
|
8
|
-
if (cacheContainer.cache === null) {
|
|
9
|
-
cacheContainer.cache = {};
|
|
10
|
-
}
|
|
11
8
|
const selector = (...selectorArgs) => {
|
|
12
9
|
const [stateOrApiRef, instanceId] = selectorArgs;
|
|
13
10
|
const isApiRef = !!stateOrApiRef.current;
|
|
14
|
-
const cacheKey = isApiRef ? stateOrApiRef.current.instanceId : instanceId ??
|
|
11
|
+
const cacheKey = isApiRef ? stateOrApiRef.current.instanceId : instanceId ?? {
|
|
12
|
+
id: 'default'
|
|
13
|
+
};
|
|
15
14
|
const state = isApiRef ? stateOrApiRef.current.state : stateOrApiRef;
|
|
16
15
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
-
if (cacheKey === 'default') {
|
|
16
|
+
if (cacheKey.id === 'default') {
|
|
18
17
|
missingInstanceIdWarning();
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
if (cacheContainer.cache === null) {
|
|
22
|
-
cacheContainer.cache = {};
|
|
23
|
-
}
|
|
24
20
|
const {
|
|
25
21
|
cache
|
|
26
22
|
} = cacheContainer;
|
|
27
|
-
if (cache
|
|
23
|
+
if (cache.get(cacheKey) && cache.get(cacheKey)?.get(args)) {
|
|
28
24
|
// We pass the cache key because the called selector might have as
|
|
29
25
|
// dependency another selector created with this `createSelector`.
|
|
30
|
-
return cache
|
|
26
|
+
return cache.get(cacheKey)?.get(args)(state, cacheKey);
|
|
31
27
|
}
|
|
32
28
|
const newSelector = reselectCreateSelector(...args);
|
|
33
|
-
if (!cache
|
|
34
|
-
cache
|
|
29
|
+
if (!cache.get(cacheKey)) {
|
|
30
|
+
cache.set(cacheKey, new Map());
|
|
35
31
|
}
|
|
36
|
-
cache
|
|
32
|
+
cache.get(cacheKey)?.set(args, newSelector);
|
|
37
33
|
return newSelector(state, cacheKey);
|
|
38
34
|
};
|
|
39
35
|
|
|
@@ -44,12 +40,6 @@ export const createSelector = (...args) => {
|
|
|
44
40
|
};
|
|
45
41
|
|
|
46
42
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
47
|
-
export const unstable_resetCreateSelectorCache =
|
|
48
|
-
|
|
49
|
-
if (cacheContainer.cache && cacheContainer.cache[cacheKey]) {
|
|
50
|
-
delete cacheContainer.cache[cacheKey];
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
cacheContainer.cache = null;
|
|
54
|
-
}
|
|
43
|
+
export const unstable_resetCreateSelectorCache = () => {
|
|
44
|
+
cacheContainer.cache = new WeakMap();
|
|
55
45
|
};
|
package/modern/utils/utils.js
CHANGED
|
@@ -12,7 +12,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
12
12
|
var _utils = require("@mui/utils");
|
|
13
13
|
var _createDetectElementResize = _interopRequireDefault(require("../lib/createDetectElementResize"));
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
const _excluded = ["children", "defaultHeight", "defaultWidth", "disableHeight", "disableWidth", "nonce", "onResize", "style"];
|
|
15
|
+
const _excluded = ["children", "defaultHeight", "defaultWidth", "disableHeight", "disableWidth", "nonce", "onResize", "style"]; // TODO replace with https://caniuse.com/resizeobserver.
|
|
16
|
+
// Credit to https://github.com/bvaughn/react-virtualized/blob/master/source/AutoSizer/AutoSizer.js
|
|
17
|
+
// for the sources.
|
|
16
18
|
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); }
|
|
17
19
|
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; }
|
|
18
20
|
const GridAutoSizer = /*#__PURE__*/React.forwardRef(function AutoSizer(props, ref) {
|
|
@@ -29,7 +29,7 @@ var _utils2 = require("../utils/utils");
|
|
|
29
29
|
var _gridEditingSelectors = require("../hooks/features/editing/gridEditingSelectors");
|
|
30
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
31
|
const _excluded = ["selected", "rowId", "row", "index", "style", "position", "rowHeight", "className", "visibleColumns", "renderedColumns", "containerWidth", "firstColumnToRender", "lastColumnToRender", "isLastVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave"],
|
|
32
|
-
_excluded2 = ["changeReason"];
|
|
32
|
+
_excluded2 = ["changeReason", "unstable_updateValueOnRender"];
|
|
33
33
|
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); }
|
|
34
34
|
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; }
|
|
35
35
|
const useUtilityClasses = ownerState => {
|
|
@@ -218,6 +218,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
218
218
|
}
|
|
219
219
|
if (editCellState != null && column.renderEditCell) {
|
|
220
220
|
const updatedRow = apiRef.current.getRowWithUpdatedValues(rowId, column.field);
|
|
221
|
+
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
221
223
|
const editCellStateRest = (0, _objectWithoutPropertiesLoose2.default)(editCellState, _excluded2);
|
|
222
224
|
const params = (0, _extends2.default)({}, cellParams, {
|
|
223
225
|
row: updatedRow
|
|
@@ -18,6 +18,7 @@ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
|
18
18
|
var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
const _excluded = ["align", "children", "colIndex", "colDef", "cellMode", "field", "formattedValue", "hasFocus", "height", "isEditable", "isSelected", "rowId", "tabIndex", "value", "width", "className", "showRightBorder", "extendRowFullWidth", "row", "colSpan", "disableDragEvents", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"];
|
|
21
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
21
22
|
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); }
|
|
22
23
|
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; }
|
|
23
24
|
// Based on https://stackoverflow.com/a/59518678
|
|
@@ -73,22 +73,25 @@ function GridEditDateCell(props) {
|
|
|
73
73
|
classes: rootProps.classes
|
|
74
74
|
};
|
|
75
75
|
const classes = useUtilityClasses(ownerState);
|
|
76
|
+
const hasUpdatedEditValueOnMount = React.useRef(false);
|
|
77
|
+
const parseValueToDate = React.useCallback(value => {
|
|
78
|
+
if (value === '') {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const [date, time] = value.split('T');
|
|
82
|
+
const [year, month, day] = date.split('-');
|
|
83
|
+
const parsedDate = new Date();
|
|
84
|
+
parsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
85
|
+
parsedDate.setHours(0, 0, 0, 0);
|
|
86
|
+
if (time) {
|
|
87
|
+
const [hours, minutes] = time.split(':');
|
|
88
|
+
parsedDate.setHours(Number(hours), Number(minutes), 0, 0);
|
|
89
|
+
}
|
|
90
|
+
return parsedDate;
|
|
91
|
+
}, []);
|
|
76
92
|
const handleChange = React.useCallback(async event => {
|
|
77
93
|
const newFormattedDate = event.target.value;
|
|
78
|
-
|
|
79
|
-
if (newFormattedDate === '') {
|
|
80
|
-
newParsedDate = null;
|
|
81
|
-
} else {
|
|
82
|
-
const [date, time] = newFormattedDate.split('T');
|
|
83
|
-
const [year, month, day] = date.split('-');
|
|
84
|
-
newParsedDate = new Date();
|
|
85
|
-
newParsedDate.setFullYear(Number(year), Number(month) - 1, Number(day));
|
|
86
|
-
newParsedDate.setHours(0, 0, 0, 0);
|
|
87
|
-
if (time) {
|
|
88
|
-
const [hours, minutes] = time.split(':');
|
|
89
|
-
newParsedDate.setHours(Number(hours), Number(minutes), 0, 0);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
94
|
+
const newParsedDate = parseValueToDate(newFormattedDate);
|
|
92
95
|
if (onValueChange) {
|
|
93
96
|
await onValueChange(event, newParsedDate);
|
|
94
97
|
}
|
|
@@ -101,7 +104,7 @@ function GridEditDateCell(props) {
|
|
|
101
104
|
field,
|
|
102
105
|
value: newParsedDate
|
|
103
106
|
}, event);
|
|
104
|
-
}, [apiRef, field, id, onValueChange]);
|
|
107
|
+
}, [apiRef, field, id, onValueChange, parseValueToDate]);
|
|
105
108
|
React.useEffect(() => {
|
|
106
109
|
setValueState(state => {
|
|
107
110
|
if (valueTransformed.parsed !== state.parsed && valueTransformed.parsed?.getTime() !== state.parsed?.getTime()) {
|
|
@@ -115,8 +118,26 @@ function GridEditDateCell(props) {
|
|
|
115
118
|
inputRef.current.focus();
|
|
116
119
|
}
|
|
117
120
|
}, [hasFocus]);
|
|
121
|
+
const meta = apiRef.current.unstable_getEditCellMeta(id, field);
|
|
122
|
+
const handleInputRef = el => {
|
|
123
|
+
inputRef.current = el;
|
|
124
|
+
if (meta.unstable_updateValueOnRender && !hasUpdatedEditValueOnMount.current) {
|
|
125
|
+
const inputValue = inputRef.current.value;
|
|
126
|
+
const parsedDate = parseValueToDate(inputValue);
|
|
127
|
+
setValueState({
|
|
128
|
+
parsed: parsedDate,
|
|
129
|
+
formatted: inputValue
|
|
130
|
+
});
|
|
131
|
+
apiRef.current.setEditCellValue({
|
|
132
|
+
id,
|
|
133
|
+
field,
|
|
134
|
+
value: parsedDate
|
|
135
|
+
});
|
|
136
|
+
hasUpdatedEditValueOnMount.current = true;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
118
139
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledInputBase, (0, _extends2.default)({
|
|
119
|
-
inputRef:
|
|
140
|
+
inputRef: handleInputRef,
|
|
120
141
|
fullWidth: true,
|
|
121
142
|
className: classes.root,
|
|
122
143
|
type: isDateTime ? 'datetime-local' : 'date',
|
|
@@ -46,22 +46,26 @@ const ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(props => {
|
|
|
46
46
|
}, [apiRef, colDef.field]);
|
|
47
47
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
48
48
|
className: classes.root,
|
|
49
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.
|
|
50
|
-
ref: iconButtonRef,
|
|
51
|
-
tabIndex: -1,
|
|
52
|
-
className: classes.button,
|
|
53
|
-
"aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
|
|
49
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, (0, _extends2.default)({
|
|
54
50
|
title: apiRef.current.getLocaleText('columnMenuLabel'),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
enterDelay: 1000
|
|
52
|
+
}, rootProps.slotProps?.baseTooltip, {
|
|
53
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
|
|
54
|
+
ref: iconButtonRef,
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
className: classes.button,
|
|
57
|
+
"aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
|
|
58
|
+
size: "small",
|
|
59
|
+
onClick: handleMenuIconClick,
|
|
60
|
+
"aria-expanded": open ? 'true' : undefined,
|
|
61
|
+
"aria-haspopup": "true",
|
|
62
|
+
"aria-controls": columnMenuId,
|
|
63
|
+
id: columnMenuButtonId
|
|
64
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
65
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.columnMenuIcon, {
|
|
66
|
+
fontSize: "small"
|
|
67
|
+
})
|
|
68
|
+
}))
|
|
65
69
|
}))
|
|
66
70
|
});
|
|
67
71
|
});
|
|
@@ -25,7 +25,7 @@ var _envConstants = require("../../constants/envConstants");
|
|
|
25
25
|
var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
|
|
26
26
|
var _gridClasses = require("../../constants/gridClasses");
|
|
27
27
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton"];
|
|
28
|
+
const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
|
|
29
29
|
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); }
|
|
30
30
|
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; }
|
|
31
31
|
const useUtilityClasses = ownerState => {
|
|
@@ -79,7 +79,8 @@ function GridColumnsPanel(props) {
|
|
|
79
79
|
searchPredicate = defaultSearchPredicate,
|
|
80
80
|
autoFocusSearchField = true,
|
|
81
81
|
disableHideAllButton = false,
|
|
82
|
-
disableShowAllButton = false
|
|
82
|
+
disableShowAllButton = false,
|
|
83
|
+
getTogglableColumns
|
|
83
84
|
} = props,
|
|
84
85
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
85
86
|
const sortedColumns = React.useMemo(() => {
|
|
@@ -117,12 +118,15 @@ function GridColumnsPanel(props) {
|
|
|
117
118
|
setSearchValue(event.target.value);
|
|
118
119
|
}, []);
|
|
119
120
|
const currentColumns = React.useMemo(() => {
|
|
121
|
+
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
|
|
122
|
+
const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
|
|
123
|
+
field
|
|
124
|
+
}) => togglableColumns.includes(field)) : sortedColumns;
|
|
120
125
|
if (!searchValue) {
|
|
121
|
-
return
|
|
126
|
+
return togglableSortedColumns;
|
|
122
127
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}, [sortedColumns, searchValue, searchPredicate]);
|
|
128
|
+
return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
|
|
129
|
+
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
|
|
126
130
|
const firstSwitchRef = React.useRef(null);
|
|
127
131
|
React.useEffect(() => {
|
|
128
132
|
if (autoFocusSearchField) {
|
|
@@ -200,6 +204,14 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
|
|
|
200
204
|
autoFocusSearchField: _propTypes.default.bool,
|
|
201
205
|
disableHideAllButton: _propTypes.default.bool,
|
|
202
206
|
disableShowAllButton: _propTypes.default.bool,
|
|
207
|
+
/**
|
|
208
|
+
* Returns the list of togglable columns.
|
|
209
|
+
* If used, only those columns will be displayed in the panel
|
|
210
|
+
* which are passed as the return value of the function.
|
|
211
|
+
* @param {GridColDef[]} columns The `ColDef` list of all columns.
|
|
212
|
+
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
213
|
+
*/
|
|
214
|
+
getTogglableColumns: _propTypes.default.func,
|
|
203
215
|
searchPredicate: _propTypes.default.func,
|
|
204
216
|
slotProps: _propTypes.default.object,
|
|
205
217
|
sort: _propTypes.default.oneOf(['asc', 'desc'])
|
|
@@ -8,6 +8,7 @@ exports.GridFilterInputBoolean = GridFilterInputBoolean;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _utils = require("@mui/utils");
|
|
11
12
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
const _excluded = ["item", "applyValue", "apiRef", "focusElementRef"];
|
|
@@ -23,6 +24,8 @@ function GridFilterInputBoolean(props) {
|
|
|
23
24
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
24
25
|
const [filterValueState, setFilterValueState] = React.useState(item.value || '');
|
|
25
26
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
27
|
+
const labelId = (0, _utils.unstable_useId)();
|
|
28
|
+
const selectId = (0, _utils.unstable_useId)();
|
|
26
29
|
const baseSelectProps = rootProps.slotProps?.baseSelect || {};
|
|
27
30
|
const isSelectNative = baseSelectProps.native ?? true;
|
|
28
31
|
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
@@ -36,34 +39,39 @@ function GridFilterInputBoolean(props) {
|
|
|
36
39
|
React.useEffect(() => {
|
|
37
40
|
setFilterValueState(item.value || '');
|
|
38
41
|
}, [item.value]);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
44
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputLabel, (0, _extends2.default)({}, rootProps.slotProps?.baseInputLabel, {
|
|
45
|
+
id: labelId,
|
|
46
|
+
shrink: true,
|
|
47
|
+
variant: "standard",
|
|
48
|
+
children: label
|
|
49
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsxs)(rootProps.slots.baseSelect, (0, _extends2.default)({
|
|
50
|
+
labelId: labelId,
|
|
51
|
+
id: selectId,
|
|
52
|
+
label: label,
|
|
53
|
+
value: filterValueState,
|
|
54
|
+
onChange: onFilterChange,
|
|
55
|
+
variant: "standard",
|
|
47
56
|
native: isSelectNative,
|
|
48
|
-
displayEmpty: true
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
57
|
+
displayEmpty: true,
|
|
58
|
+
inputProps: {
|
|
59
|
+
ref: focusElementRef
|
|
60
|
+
}
|
|
61
|
+
}, others, baseSelectProps, {
|
|
62
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
|
|
63
|
+
native: isSelectNative,
|
|
64
|
+
value: "",
|
|
65
|
+
children: apiRef.current.getLocaleText('filterValueAny')
|
|
66
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
|
|
67
|
+
native: isSelectNative,
|
|
68
|
+
value: "true",
|
|
69
|
+
children: apiRef.current.getLocaleText('filterValueTrue')
|
|
70
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelectOption, (0, _extends2.default)({}, baseSelectOptionProps, {
|
|
71
|
+
native: isSelectNative,
|
|
72
|
+
value: "false",
|
|
73
|
+
children: apiRef.current.getLocaleText('filterValueFalse')
|
|
74
|
+
}))]
|
|
67
75
|
}))]
|
|
68
|
-
})
|
|
76
|
+
});
|
|
69
77
|
}
|
|
@@ -53,10 +53,9 @@ function GridFilterInputSingleSelect(props) {
|
|
|
53
53
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
54
54
|
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
|
|
55
55
|
const id = (0, _utils.unstable_useId)();
|
|
56
|
+
const labelId = (0, _utils.unstable_useId)();
|
|
56
57
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
57
|
-
const
|
|
58
|
-
const isSelectNative = baseSelectProps.native ?? true;
|
|
59
|
-
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
58
|
+
const isSelectNative = rootProps.slotProps?.baseSelect?.native ?? true;
|
|
60
59
|
let resolvedColumn = null;
|
|
61
60
|
if (item.field) {
|
|
62
61
|
const column = apiRef.current.getColumn(item.field);
|
|
@@ -107,33 +106,37 @@ function GridFilterInputSingleSelect(props) {
|
|
|
107
106
|
if (!(0, _filterPanelUtils.isSingleSelectColDef)(resolvedColumn)) {
|
|
108
107
|
return null;
|
|
109
108
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
const label = apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
110
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
111
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputLabel, (0, _extends2.default)({}, rootProps.slotProps?.baseInputLabel, {
|
|
112
|
+
id: labelId,
|
|
113
|
+
shrink: true,
|
|
114
|
+
variant: "standard",
|
|
115
|
+
children: label
|
|
116
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelect, (0, _extends2.default)({
|
|
117
|
+
id: id,
|
|
118
|
+
label: label,
|
|
119
|
+
labelId: labelId,
|
|
120
|
+
value: filterValueState,
|
|
121
|
+
onChange: onFilterChange,
|
|
122
|
+
variant: "standard",
|
|
123
|
+
type: type || 'text',
|
|
124
|
+
inputProps: {
|
|
125
|
+
ref: focusElementRef,
|
|
126
|
+
placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder')
|
|
127
|
+
},
|
|
125
128
|
native: isSelectNative
|
|
126
|
-
}, rootProps.slotProps?.baseSelect
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
})
|
|
136
|
-
})
|
|
129
|
+
}, others, rootProps.slotProps?.baseSelect, {
|
|
130
|
+
children: renderSingleSelectOptions({
|
|
131
|
+
column: resolvedColumn,
|
|
132
|
+
OptionComponent: rootProps.slots.baseSelectOption,
|
|
133
|
+
getOptionLabel,
|
|
134
|
+
getOptionValue,
|
|
135
|
+
isSelectNative,
|
|
136
|
+
baseSelectOptionProps: rootProps.slotProps?.baseSelectOption
|
|
137
|
+
})
|
|
138
|
+
}))]
|
|
139
|
+
});
|
|
137
140
|
}
|
|
138
141
|
process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
|
|
139
142
|
// ----------------------------- Warning --------------------------------
|
|
@@ -8,7 +8,6 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _useGridApiMethod = require("../utils/useGridApiMethod");
|
|
9
9
|
var _useGridApiEventHandler = require("../utils/useGridApiEventHandler");
|
|
10
10
|
var _EventManager = require("../../utils/EventManager");
|
|
11
|
-
var _createSelector = require("../../utils/createSelector");
|
|
12
11
|
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); }
|
|
13
12
|
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; }
|
|
14
13
|
const isSyntheticEvent = event => {
|
|
@@ -46,7 +45,9 @@ function useGridApiInitialization(inputApiRef, props) {
|
|
|
46
45
|
if (!publicApiRef.current) {
|
|
47
46
|
publicApiRef.current = {
|
|
48
47
|
state: {},
|
|
49
|
-
instanceId:
|
|
48
|
+
instanceId: {
|
|
49
|
+
id: globalId
|
|
50
|
+
}
|
|
50
51
|
};
|
|
51
52
|
globalId += 1;
|
|
52
53
|
}
|
|
@@ -84,7 +85,6 @@ function useGridApiInitialization(inputApiRef, props) {
|
|
|
84
85
|
React.useEffect(() => {
|
|
85
86
|
const api = privateApiRef.current;
|
|
86
87
|
return () => {
|
|
87
|
-
(0, _createSelector.unstable_resetCreateSelectorCache)(api.instanceId);
|
|
88
88
|
api.publishEvent('unmount');
|
|
89
89
|
};
|
|
90
90
|
}, [privateApiRef]);
|
|
@@ -251,13 +251,17 @@ const useGridCellEditing = (apiRef, props) => {
|
|
|
251
251
|
initialValue
|
|
252
252
|
} = params;
|
|
253
253
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
255
|
+
let unstable_updateValueOnRender = false;
|
|
254
256
|
if (deleteValue || initialValue) {
|
|
255
257
|
newValue = deleteValue ? '' : initialValue;
|
|
258
|
+
unstable_updateValueOnRender = true;
|
|
256
259
|
}
|
|
257
260
|
const newProps = {
|
|
258
261
|
value: newValue,
|
|
259
262
|
error: false,
|
|
260
|
-
isProcessingProps: false
|
|
263
|
+
isProcessingProps: false,
|
|
264
|
+
unstable_updateValueOnRender
|
|
261
265
|
};
|
|
262
266
|
updateOrDeleteFieldState(id, field, newProps);
|
|
263
267
|
apiRef.current.setCellFocus(id, field);
|
|
@@ -120,9 +120,7 @@ const useGridEditing = (apiRef, props) => {
|
|
|
120
120
|
}, [apiRef, props.editMode]);
|
|
121
121
|
const getEditCellMeta = React.useCallback((id, field) => {
|
|
122
122
|
const editingState = (0, _gridEditingSelectors.gridEditRowsStateSelector)(apiRef.current.state);
|
|
123
|
-
return
|
|
124
|
-
changeReason: editingState[id][field].changeReason
|
|
125
|
-
};
|
|
123
|
+
return editingState[id][field];
|
|
126
124
|
}, [apiRef]);
|
|
127
125
|
const editingSharedApi = {
|
|
128
126
|
isCellEditable,
|
|
@@ -319,13 +319,17 @@ const useGridRowEditing = (apiRef, props) => {
|
|
|
319
319
|
return acc;
|
|
320
320
|
}
|
|
321
321
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
322
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
323
|
+
let unstable_updateValueOnRender = false;
|
|
322
324
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
323
325
|
newValue = deleteValue ? '' : initialValue;
|
|
326
|
+
unstable_updateValueOnRender = true;
|
|
324
327
|
}
|
|
325
328
|
acc[field] = {
|
|
326
329
|
value: newValue,
|
|
327
330
|
error: false,
|
|
328
|
-
isProcessingProps: false
|
|
331
|
+
isProcessingProps: false,
|
|
332
|
+
unstable_updateValueOnRender
|
|
329
333
|
};
|
|
330
334
|
return acc;
|
|
331
335
|
}, {});
|
|
@@ -11,4 +11,9 @@ const getDefaultGridFilterModel = () => ({
|
|
|
11
11
|
quickFilterValues: [],
|
|
12
12
|
quickFilterLogicOperator: _gridFilterItem.GridLogicOperator.And
|
|
13
13
|
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {GridRowId} rowId The id of the row we want to filter.
|
|
17
|
+
* @param {(filterItem: GridFilterItem) => boolean} shouldApplyItem An optional callback to allow the filtering engine to only apply some items.
|
|
18
|
+
*/
|
|
14
19
|
exports.getDefaultGridFilterModel = getDefaultGridFilterModel;
|
|
@@ -121,6 +121,11 @@ const useGridFilter = (apiRef, props) => {
|
|
|
121
121
|
const filterModel = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
|
|
122
122
|
const filterItemsWithValue = filterModel.items.filter(item => {
|
|
123
123
|
if (item.value !== undefined) {
|
|
124
|
+
// Some filters like `isAnyOf` support array as `item.value`.
|
|
125
|
+
// If array is empty, we want to remove it from the filter model.
|
|
126
|
+
if (Array.isArray(item.value) && item.value.length === 0) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
124
129
|
return true;
|
|
125
130
|
}
|
|
126
131
|
const column = apiRef.current.getColumn(item.field);
|
|
@@ -68,8 +68,6 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
68
68
|
checkboxSelection,
|
|
69
69
|
disableMultipleRowSelection,
|
|
70
70
|
disableRowSelectionOnClick,
|
|
71
|
-
pagination,
|
|
72
|
-
paginationMode,
|
|
73
71
|
isRowSelectable: propIsRowSelectable
|
|
74
72
|
} = props;
|
|
75
73
|
const canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
|
|
@@ -385,33 +383,14 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
385
383
|
}
|
|
386
384
|
}, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
|
|
387
385
|
React.useEffect(() => {
|
|
388
|
-
if (!props.rowSelection) {
|
|
386
|
+
if (!props.rowSelection || isStateControlled) {
|
|
389
387
|
return;
|
|
390
388
|
}
|
|
391
389
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
392
390
|
if (!canHaveMultipleSelection && currentSelection.length > 1) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
} = (0, _useGridVisibleRows.getVisibleRows)(apiRef, {
|
|
396
|
-
pagination,
|
|
397
|
-
paginationMode
|
|
398
|
-
});
|
|
399
|
-
const currentPageRowsLookup = currentPageRows.reduce((acc, {
|
|
400
|
-
id
|
|
401
|
-
}) => {
|
|
402
|
-
acc[id] = true;
|
|
403
|
-
return acc;
|
|
404
|
-
}, {});
|
|
405
|
-
const firstSelectableRow = currentSelection.find(id => {
|
|
406
|
-
let isSelectable = true;
|
|
407
|
-
if (isRowSelectable) {
|
|
408
|
-
isSelectable = isRowSelectable(id);
|
|
409
|
-
}
|
|
410
|
-
return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
|
|
391
|
+
// See https://github.com/mui/mui-x/issues/8455
|
|
392
|
+
apiRef.current.setRowSelectionModel([]);
|
|
414
393
|
}
|
|
415
|
-
}, [apiRef, canHaveMultipleSelection, checkboxSelection,
|
|
394
|
+
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
416
395
|
};
|
|
417
396
|
exports.useGridRowSelection = useGridRowSelection;
|