@mui/x-data-grid 7.0.0-alpha.5 → 7.0.0-alpha.6
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 +226 -6
- package/DataGrid/DataGrid.js +25 -19
- package/DataGrid/useDataGridProps.js +0 -1
- package/colDef/gridDateOperators.js +13 -6
- package/colDef/gridSingleSelectColDef.js +6 -15
- package/components/cell/GridEditSingleSelectCell.d.ts +1 -2
- package/components/cell/GridEditSingleSelectCell.js +9 -29
- package/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/components/panel/filterPanel/GridFilterInputDate.js +25 -8
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -2
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -48
- package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -2
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -57
- package/components/panel/filterPanel/filterPanelUtils.d.ts +3 -2
- package/components/panel/filterPanel/filterPanelUtils.js +10 -5
- package/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/hooks/features/rowSelection/utils.d.ts +2 -0
- package/hooks/features/rowSelection/utils.js +8 -0
- package/hooks/utils/useGridAriaAttributes.js +2 -1
- package/index.js +1 -1
- package/legacy/DataGrid/DataGrid.js +25 -19
- package/legacy/DataGrid/useDataGridProps.js +0 -1
- package/legacy/colDef/gridDateOperators.js +13 -13
- package/legacy/colDef/gridSingleSelectColDef.js +6 -15
- package/legacy/components/cell/GridEditSingleSelectCell.js +8 -28
- package/legacy/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/legacy/components/panel/filterPanel/GridFilterForm.js +51 -19
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/legacy/components/panel/filterPanel/GridFilterInputDate.js +27 -8
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -53
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -59
- package/legacy/components/panel/filterPanel/filterPanelUtils.js +10 -6
- package/legacy/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/legacy/hooks/features/rowSelection/utils.js +8 -0
- package/legacy/hooks/utils/useGridAriaAttributes.js +2 -1
- package/legacy/index.js +1 -1
- package/models/props/DataGridProps.d.ts +26 -25
- package/modern/DataGrid/DataGrid.js +25 -19
- package/modern/DataGrid/useDataGridProps.js +0 -1
- package/modern/colDef/gridDateOperators.js +13 -6
- package/modern/colDef/gridSingleSelectColDef.js +6 -15
- package/modern/components/cell/GridEditSingleSelectCell.js +9 -29
- package/modern/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/modern/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputDate.js +24 -6
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +7 -47
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +15 -56
- package/modern/components/panel/filterPanel/filterPanelUtils.js +10 -5
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/modern/hooks/features/rowSelection/utils.js +8 -0
- package/modern/hooks/utils/useGridAriaAttributes.js +2 -1
- package/modern/index.js +1 -1
- package/node/DataGrid/DataGrid.js +25 -19
- package/node/DataGrid/useDataGridProps.js +0 -1
- package/node/colDef/gridDateOperators.js +13 -6
- package/node/colDef/gridSingleSelectColDef.js +5 -14
- package/node/components/cell/GridEditSingleSelectCell.js +8 -28
- package/node/components/columnSelection/GridHeaderCheckbox.js +3 -1
- package/node/components/panel/filterPanel/GridFilterForm.js +44 -9
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputDate.js +24 -6
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +6 -46
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +14 -55
- package/node/components/panel/filterPanel/filterPanelUtils.js +12 -7
- package/node/hooks/features/rowSelection/useGridRowSelection.js +9 -9
- package/node/hooks/features/rowSelection/utils.js +14 -0
- package/node/hooks/utils/useGridAriaAttributes.js +2 -1
- package/node/index.js +1 -1
- package/package.json +3 -3
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
4
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
6
|
-
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "
|
|
5
|
+
var _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "isFilterActive", "clearButton", "InputLabelProps"];
|
|
7
6
|
import * as React from 'react';
|
|
8
7
|
import PropTypes from 'prop-types';
|
|
9
8
|
import { unstable_useId as useId } from '@mui/utils';
|
|
10
9
|
import { styled } from '@mui/material/styles';
|
|
11
10
|
import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
|
|
12
|
-
import { getValueFromValueOptions, isSingleSelectColDef } from './filterPanelUtils';
|
|
11
|
+
import { getValueFromValueOptions, getValueOptions, isSingleSelectColDef } from './filterPanelUtils';
|
|
13
12
|
import { createElement as _createElement } from "react";
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
15
|
var renderSingleSelectOptions = function renderSingleSelectOptions(_ref) {
|
|
17
|
-
var
|
|
18
|
-
valueOptions = _ref$column.valueOptions,
|
|
19
|
-
field = _ref$column.field,
|
|
16
|
+
var column = _ref.column,
|
|
20
17
|
OptionComponent = _ref.OptionComponent,
|
|
21
18
|
getOptionLabel = _ref.getOptionLabel,
|
|
22
19
|
getOptionValue = _ref.getOptionValue,
|
|
23
20
|
isSelectNative = _ref.isSelectNative,
|
|
24
21
|
baseSelectOptionProps = _ref.baseSelectOptionProps;
|
|
25
|
-
var iterableColumnValues =
|
|
26
|
-
field: field
|
|
27
|
-
}))) : [''].concat(_toConsumableArray(valueOptions || []));
|
|
22
|
+
var iterableColumnValues = [''].concat(_toConsumableArray(getValueOptions(column) || []));
|
|
28
23
|
return iterableColumnValues.map(function (option) {
|
|
29
24
|
var value = getOptionValue(option);
|
|
30
25
|
var label = getOptionLabel(option);
|
|
26
|
+
if (label === '') {
|
|
27
|
+
label = ' '; // To force the height of the empty option
|
|
28
|
+
}
|
|
31
29
|
return /*#__PURE__*/_createElement(OptionComponent, _extends({}, baseSelectOptionProps, {
|
|
32
30
|
native: isSelectNative,
|
|
33
31
|
key: value,
|
|
@@ -49,8 +47,6 @@ function GridFilterInputSingleSelect(props) {
|
|
|
49
47
|
type = props.type,
|
|
50
48
|
apiRef = props.apiRef,
|
|
51
49
|
focusElementRef = props.focusElementRef,
|
|
52
|
-
getOptionLabelProp = props.getOptionLabel,
|
|
53
|
-
getOptionValueProp = props.getOptionValue,
|
|
54
50
|
placeholder = props.placeholder,
|
|
55
51
|
tabIndex = props.tabIndex,
|
|
56
52
|
labelProp = props.label,
|
|
@@ -58,14 +54,11 @@ function GridFilterInputSingleSelect(props) {
|
|
|
58
54
|
clearButton = props.clearButton,
|
|
59
55
|
InputLabelProps = props.InputLabelProps,
|
|
60
56
|
others = _objectWithoutProperties(props, _excluded);
|
|
61
|
-
var
|
|
62
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
63
|
-
filterValueState = _React$useState2[0],
|
|
64
|
-
setFilterValueState = _React$useState2[1];
|
|
57
|
+
var filterValue = (_item$value = item.value) != null ? _item$value : '';
|
|
65
58
|
var id = useId();
|
|
66
59
|
var labelId = useId();
|
|
67
60
|
var rootProps = useGridRootProps();
|
|
68
|
-
var isSelectNative = (_rootProps$slotProps$ = (_rootProps$slotProps = rootProps.slotProps) == null || (_rootProps$slotProps = _rootProps$slotProps.baseSelect) == null ? void 0 : _rootProps$slotProps.native) != null ? _rootProps$slotProps$ :
|
|
61
|
+
var isSelectNative = (_rootProps$slotProps$ = (_rootProps$slotProps = rootProps.slotProps) == null || (_rootProps$slotProps = _rootProps$slotProps.baseSelect) == null ? void 0 : _rootProps$slotProps.native) != null ? _rootProps$slotProps$ : false;
|
|
69
62
|
var resolvedColumn = null;
|
|
70
63
|
if (item.field) {
|
|
71
64
|
var column = apiRef.current.getColumn(item.field);
|
|
@@ -73,53 +66,27 @@ function GridFilterInputSingleSelect(props) {
|
|
|
73
66
|
resolvedColumn = column;
|
|
74
67
|
}
|
|
75
68
|
}
|
|
76
|
-
var getOptionValue =
|
|
77
|
-
var getOptionLabel =
|
|
69
|
+
var getOptionValue = (_resolvedColumn = resolvedColumn) == null ? void 0 : _resolvedColumn.getOptionValue;
|
|
70
|
+
var getOptionLabel = (_resolvedColumn2 = resolvedColumn) == null ? void 0 : _resolvedColumn2.getOptionLabel;
|
|
78
71
|
var currentValueOptions = React.useMemo(function () {
|
|
79
|
-
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
return typeof resolvedColumn.valueOptions === 'function' ? resolvedColumn.valueOptions({
|
|
83
|
-
field: resolvedColumn.field
|
|
84
|
-
}) : resolvedColumn.valueOptions;
|
|
72
|
+
return getValueOptions(resolvedColumn);
|
|
85
73
|
}, [resolvedColumn]);
|
|
86
74
|
var onFilterChange = React.useCallback(function (event) {
|
|
87
75
|
var value = event.target.value;
|
|
88
76
|
|
|
89
77
|
// NativeSelect casts the value to a string.
|
|
90
78
|
value = getValueFromValueOptions(value, currentValueOptions, getOptionValue);
|
|
91
|
-
setFilterValueState(String(value));
|
|
92
79
|
applyValue(_extends({}, item, {
|
|
93
80
|
value: value
|
|
94
81
|
}));
|
|
95
82
|
}, [currentValueOptions, getOptionValue, applyValue, item]);
|
|
96
|
-
React.useEffect(function () {
|
|
97
|
-
var _itemValue;
|
|
98
|
-
var itemValue;
|
|
99
|
-
if (currentValueOptions !== undefined) {
|
|
100
|
-
// sanitize if valueOptions are provided
|
|
101
|
-
itemValue = getValueFromValueOptions(item.value, currentValueOptions, getOptionValue);
|
|
102
|
-
if (itemValue !== item.value) {
|
|
103
|
-
applyValue(_extends({}, item, {
|
|
104
|
-
value: itemValue
|
|
105
|
-
}));
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
itemValue = item.value;
|
|
110
|
-
}
|
|
111
|
-
itemValue = (_itemValue = itemValue) != null ? _itemValue : '';
|
|
112
|
-
setFilterValueState(String(itemValue));
|
|
113
|
-
}, [item, currentValueOptions, applyValue, getOptionValue]);
|
|
114
|
-
if (!isSingleSelectColDef(resolvedColumn)) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
83
|
if (!isSingleSelectColDef(resolvedColumn)) {
|
|
118
84
|
return null;
|
|
119
85
|
}
|
|
120
86
|
var label = labelProp != null ? labelProp : apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
121
87
|
return /*#__PURE__*/_jsxs(SingleSelectOperatorContainer, {
|
|
122
88
|
children: [/*#__PURE__*/_jsxs(rootProps.slots.baseFormControl, {
|
|
89
|
+
fullWidth: true,
|
|
123
90
|
children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, (_rootProps$slotProps2 = rootProps.slotProps) == null ? void 0 : _rootProps$slotProps2.baseInputLabel, {
|
|
124
91
|
id: labelId,
|
|
125
92
|
htmlFor: id,
|
|
@@ -130,7 +97,7 @@ function GridFilterInputSingleSelect(props) {
|
|
|
130
97
|
id: id,
|
|
131
98
|
label: label,
|
|
132
99
|
labelId: labelId,
|
|
133
|
-
value:
|
|
100
|
+
value: filterValue,
|
|
134
101
|
onChange: onFilterChange,
|
|
135
102
|
variant: "standard",
|
|
136
103
|
type: type || 'text',
|
|
@@ -164,18 +131,6 @@ process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes =
|
|
|
164
131
|
applyValue: PropTypes.func.isRequired,
|
|
165
132
|
clearButton: PropTypes.node,
|
|
166
133
|
focusElementRef: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.func, PropTypes.object]),
|
|
167
|
-
/**
|
|
168
|
-
* Used to determine the label displayed for a given value option.
|
|
169
|
-
* @param {ValueOptions} value The current value option.
|
|
170
|
-
* @returns {string} The text to be displayed.
|
|
171
|
-
*/
|
|
172
|
-
getOptionLabel: PropTypes.func,
|
|
173
|
-
/**
|
|
174
|
-
* Used to determine the value used for a value option.
|
|
175
|
-
* @param {ValueOptions} value The current value option.
|
|
176
|
-
* @returns {string} The value to be used.
|
|
177
|
-
*/
|
|
178
|
-
getOptionValue: PropTypes.func,
|
|
179
134
|
/**
|
|
180
135
|
* It is `true` if the filter either has a value or an operator with no value
|
|
181
136
|
* required is selected (e.g. `isEmpty`)
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
export function isSingleSelectColDef(colDef) {
|
|
3
3
|
return (colDef == null ? void 0 : colDef.type) === 'singleSelect';
|
|
4
4
|
}
|
|
5
|
+
export function getValueOptions(column, additionalParams) {
|
|
6
|
+
if (!column) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return typeof column.valueOptions === 'function' ? column.valueOptions(_extends({
|
|
10
|
+
field: column.field
|
|
11
|
+
}, additionalParams)) : column.valueOptions;
|
|
12
|
+
}
|
|
5
13
|
export function getValueFromValueOptions(value, valueOptions, getOptionValue) {
|
|
6
14
|
if (valueOptions === undefined) {
|
|
7
15
|
return undefined;
|
|
@@ -11,8 +19,4 @@ export function getValueFromValueOptions(value, valueOptions, getOptionValue) {
|
|
|
11
19
|
return String(optionValue) === String(value);
|
|
12
20
|
});
|
|
13
21
|
return getOptionValue(result);
|
|
14
|
-
}
|
|
15
|
-
export var getLabelFromValueOption = function getLabelFromValueOption(valueOption) {
|
|
16
|
-
var label = _typeof(valueOption) === 'object' ? valueOption.label : valueOption;
|
|
17
|
-
return label != null ? String(label) : '';
|
|
18
|
-
};
|
|
22
|
+
}
|
|
@@ -16,6 +16,7 @@ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
|
16
16
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
|
|
17
17
|
import { gridClasses } from '../../../constants/gridClasses';
|
|
18
18
|
import { isEventTargetInPortal } from '../../../utils/domUtils';
|
|
19
|
+
import { isMultipleRowSelectionEnabled } from './utils';
|
|
19
20
|
var getSelectionModelPropValue = function getSelectionModelPropValue(selectionModelProp, prevSelectionModel) {
|
|
20
21
|
if (selectionModelProp == null) {
|
|
21
22
|
return selectionModelProp;
|
|
@@ -62,10 +63,9 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
|
62
63
|
changeEvent: 'rowSelectionChange'
|
|
63
64
|
});
|
|
64
65
|
var checkboxSelection = props.checkboxSelection,
|
|
65
|
-
disableMultipleRowSelection = props.disableMultipleRowSelection,
|
|
66
66
|
disableRowSelectionOnClick = props.disableRowSelectionOnClick,
|
|
67
67
|
propIsRowSelectable = props.isRowSelectable;
|
|
68
|
-
var canHaveMultipleSelection =
|
|
68
|
+
var canHaveMultipleSelection = isMultipleRowSelectionEnabled(props);
|
|
69
69
|
var visibleRows = useGridVisibleRows(apiRef, props);
|
|
70
70
|
var expandMouseRowRangeSelection = React.useCallback(function (id) {
|
|
71
71
|
var _lastRowToggled$curre;
|
|
@@ -100,7 +100,7 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
|
100
100
|
* API METHODS
|
|
101
101
|
*/
|
|
102
102
|
var setRowSelectionModel = React.useCallback(function (model) {
|
|
103
|
-
if (props.signature === GridSignature.DataGrid && !
|
|
103
|
+
if (props.signature === GridSignature.DataGrid && !canHaveMultipleSelection && Array.isArray(model) && model.length > 1) {
|
|
104
104
|
throw new Error(['MUI: `rowSelectionModel` can only contain 1 item in DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock multiple selection.'].join('\n'));
|
|
105
105
|
}
|
|
106
106
|
var currentModel = gridRowSelectionStateSelector(apiRef.current.state);
|
|
@@ -113,7 +113,7 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
|
113
113
|
});
|
|
114
114
|
apiRef.current.forceUpdate();
|
|
115
115
|
}
|
|
116
|
-
}, [apiRef, logger, props.rowSelection, props.signature,
|
|
116
|
+
}, [apiRef, logger, props.rowSelection, props.signature, canHaveMultipleSelection]);
|
|
117
117
|
var isRowSelected = React.useCallback(function (id) {
|
|
118
118
|
return gridRowSelectionStateSelector(apiRef.current.state).includes(id);
|
|
119
119
|
}, [apiRef]);
|
|
@@ -281,12 +281,12 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
|
281
281
|
if (rowNode.type === 'pinnedRow') {
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
if (event.shiftKey &&
|
|
284
|
+
if (event.shiftKey && canHaveMultipleSelection) {
|
|
285
285
|
expandMouseRowRangeSelection(params.id);
|
|
286
286
|
} else {
|
|
287
287
|
handleSingleRowSelection(params.id, event);
|
|
288
288
|
}
|
|
289
|
-
}, [disableRowSelectionOnClick, canHaveMultipleSelection,
|
|
289
|
+
}, [disableRowSelectionOnClick, canHaveMultipleSelection, apiRef, expandMouseRowRangeSelection, handleSingleRowSelection]);
|
|
290
290
|
var preventSelectionOnShift = React.useCallback(function (params, event) {
|
|
291
291
|
if (canHaveMultipleSelection && event.shiftKey) {
|
|
292
292
|
var _window$getSelection;
|
|
@@ -294,12 +294,12 @@ export var useGridRowSelection = function useGridRowSelection(apiRef, props) {
|
|
|
294
294
|
}
|
|
295
295
|
}, [canHaveMultipleSelection]);
|
|
296
296
|
var handleRowSelectionCheckboxChange = React.useCallback(function (params, event) {
|
|
297
|
-
if (event.nativeEvent.shiftKey) {
|
|
297
|
+
if (canHaveMultipleSelection && event.nativeEvent.shiftKey) {
|
|
298
298
|
expandMouseRowRangeSelection(params.id);
|
|
299
299
|
} else {
|
|
300
|
-
apiRef.current.selectRow(params.id, params.value);
|
|
300
|
+
apiRef.current.selectRow(params.id, params.value, !canHaveMultipleSelection);
|
|
301
301
|
}
|
|
302
|
-
}, [apiRef, expandMouseRowRangeSelection]);
|
|
302
|
+
}, [apiRef, expandMouseRowRangeSelection, canHaveMultipleSelection]);
|
|
303
303
|
var handleHeaderSelectionCheckboxChange = React.useCallback(function (params) {
|
|
304
304
|
var shouldLimitSelectionToCurrentPage = props.checkboxSelectionVisibleOnly && props.pagination;
|
|
305
305
|
var rowsToBeSelected = shouldLimitSelectionToCurrentPage ? gridPaginatedVisibleSortedGridRowIdsSelector(apiRef) : gridExpandedSortedRowIdsSelector(apiRef);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GridSignature } from '../../utils/useGridApiEventHandler';
|
|
2
|
+
export function isMultipleRowSelectionEnabled(props) {
|
|
3
|
+
if (props.signature === GridSignature.DataGrid) {
|
|
4
|
+
// DataGrid Community has multiple row selection enabled only if checkbox selection is enabled.
|
|
5
|
+
return props.checkboxSelection && props.disableMultipleRowSelection !== true;
|
|
6
|
+
}
|
|
7
|
+
return !props.disableMultipleRowSelection;
|
|
8
|
+
}
|
|
@@ -4,6 +4,7 @@ import { useGridRootProps } from './useGridRootProps';
|
|
|
4
4
|
import { gridColumnGroupsHeaderMaxDepthSelector } from '../features/columnGrouping/gridColumnGroupsSelector';
|
|
5
5
|
import { gridPinnedRowsCountSelector, gridRowCountSelector } from '../features/rows/gridRowsSelector';
|
|
6
6
|
import { useGridPrivateApiContext } from './useGridPrivateApiContext';
|
|
7
|
+
import { isMultipleRowSelectionEnabled } from '../features/rowSelection/utils';
|
|
7
8
|
export var useGridAriaAttributes = function useGridAriaAttributes() {
|
|
8
9
|
var _rootProps$experiment;
|
|
9
10
|
var apiRef = useGridPrivateApiContext();
|
|
@@ -20,6 +21,6 @@ export var useGridAriaAttributes = function useGridAriaAttributes() {
|
|
|
20
21
|
role: role,
|
|
21
22
|
'aria-colcount': visibleColumns.length,
|
|
22
23
|
'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
|
|
23
|
-
'aria-multiselectable':
|
|
24
|
+
'aria-multiselectable': isMultipleRowSelectionEnabled(rootProps)
|
|
24
25
|
};
|
|
25
26
|
};
|
package/legacy/index.js
CHANGED
|
@@ -56,7 +56,7 @@ export interface DataGridProcessedProps<R extends GridValidRowModel = any> exten
|
|
|
56
56
|
* The props of the `DataGrid` component after the pre-processing phase that the user should not be able to override.
|
|
57
57
|
* Those are usually used in feature-hook for which the pro-plan has more advanced features (eg: multi-sorting, multi-filtering, ...).
|
|
58
58
|
*/
|
|
59
|
-
export type DataGridForcedPropsKey = 'checkboxSelectionVisibleOnly' | 'disableMultipleColumnsFiltering' | 'disableMultipleColumnsSorting' | '
|
|
59
|
+
export type DataGridForcedPropsKey = 'checkboxSelectionVisibleOnly' | 'disableMultipleColumnsFiltering' | 'disableMultipleColumnsSorting' | 'disableColumnReorder' | 'disableColumnResize' | 'keepColumnPositionIfDraggedOutside' | 'throttleRowsMs' | 'hideFooterRowCount' | 'pagination' | 'signature';
|
|
60
60
|
/**
|
|
61
61
|
* The `DataGrid` options with a default value that must be merged with the value given through props.
|
|
62
62
|
*/
|
|
@@ -73,7 +73,7 @@ export interface DataGridPropsWithComplexDefaultValueBeforeProcessing {
|
|
|
73
73
|
*/
|
|
74
74
|
slots?: Partial<GridSlotsComponent>;
|
|
75
75
|
/**
|
|
76
|
-
* Set the locale text of the
|
|
76
|
+
* Set the locale text of the Data Grid.
|
|
77
77
|
* You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
|
|
78
78
|
*/
|
|
79
79
|
localeText?: Partial<GridLocaleText>;
|
|
@@ -86,7 +86,7 @@ export interface DataGridPropsWithComplexDefaultValueBeforeProcessing {
|
|
|
86
86
|
*/
|
|
87
87
|
export interface DataGridPropsWithDefaultValues {
|
|
88
88
|
/**
|
|
89
|
-
* If `true`, the
|
|
89
|
+
* If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
|
|
90
90
|
* @default false
|
|
91
91
|
*/
|
|
92
92
|
autoHeight: boolean;
|
|
@@ -96,7 +96,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
96
96
|
*/
|
|
97
97
|
autoPageSize: boolean;
|
|
98
98
|
/**
|
|
99
|
-
* If `true`, the
|
|
99
|
+
* If `true`, the Data Grid will display an extra column with checkboxes for selecting rows.
|
|
100
100
|
* @default false
|
|
101
101
|
*/
|
|
102
102
|
checkboxSelection: boolean;
|
|
@@ -132,7 +132,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
132
132
|
*/
|
|
133
133
|
columnThreshold: number;
|
|
134
134
|
/**
|
|
135
|
-
* Set the density of the
|
|
135
|
+
* Set the density of the Data Grid.
|
|
136
136
|
* @default "standard"
|
|
137
137
|
*/
|
|
138
138
|
density: GridDensity;
|
|
@@ -168,8 +168,9 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
168
168
|
*/
|
|
169
169
|
disableMultipleColumnsFiltering: boolean;
|
|
170
170
|
/**
|
|
171
|
-
* If `true`, multiple selection using the Ctrl or
|
|
172
|
-
*
|
|
171
|
+
* If `true`, multiple selection using the Ctrl/CMD or Shift key is disabled.
|
|
172
|
+
* The MIT DataGrid will ignore this prop, unless `checkboxSelection` is enabled.
|
|
173
|
+
* @default false (`!props.checkboxSelection` for MIT Data Grid)
|
|
173
174
|
*/
|
|
174
175
|
disableMultipleRowSelection: boolean;
|
|
175
176
|
/**
|
|
@@ -204,7 +205,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
204
205
|
*/
|
|
205
206
|
filterDebounceMs: number;
|
|
206
207
|
/**
|
|
207
|
-
* Sets the height in pixel of the column headers in the
|
|
208
|
+
* Sets the height in pixel of the column headers in the Data Grid.
|
|
208
209
|
* @default 56
|
|
209
210
|
*/
|
|
210
211
|
columnHeaderHeight: number;
|
|
@@ -265,7 +266,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
265
266
|
*/
|
|
266
267
|
paginationMode: GridFeatureMode;
|
|
267
268
|
/**
|
|
268
|
-
* Sets the height in pixel of a row in the
|
|
269
|
+
* Sets the height in pixel of a row in the Data Grid.
|
|
269
270
|
* @default 52
|
|
270
271
|
*/
|
|
271
272
|
rowHeight: number;
|
|
@@ -305,7 +306,7 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
305
306
|
*/
|
|
306
307
|
sortingMode: GridFeatureMode;
|
|
307
308
|
/**
|
|
308
|
-
* If positive, the Grid will throttle updates coming from `apiRef.current.updateRows` and `apiRef.current.setRows`.
|
|
309
|
+
* If positive, the Data Grid will throttle updates coming from `apiRef.current.updateRows` and `apiRef.current.setRows`.
|
|
309
310
|
* It can be useful if you have a high update rate but do not want to do heavy work like filtering / sorting or rendering on each individual update.
|
|
310
311
|
* @default 0
|
|
311
312
|
*/
|
|
@@ -321,13 +322,13 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
321
322
|
*/
|
|
322
323
|
disableColumnResize: boolean;
|
|
323
324
|
/**
|
|
324
|
-
* If `true`, moving the mouse pointer outside the
|
|
325
|
+
* If `true`, moving the mouse pointer outside the Data Grid before releasing the mouse button
|
|
325
326
|
* in a column re-order action will not cause the column to jump back to its original position.
|
|
326
327
|
* @default false
|
|
327
328
|
*/
|
|
328
329
|
keepColumnPositionIfDraggedOutside: boolean;
|
|
329
330
|
/**
|
|
330
|
-
* If `true`, the
|
|
331
|
+
* If `true`, the Data Grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
331
332
|
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
332
333
|
* @default false
|
|
333
334
|
*/
|
|
@@ -353,17 +354,17 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
353
354
|
*/
|
|
354
355
|
export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends CommonProps {
|
|
355
356
|
/**
|
|
356
|
-
* The ref object that allows
|
|
357
|
+
* The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
|
|
357
358
|
*/
|
|
358
359
|
apiRef?: React.MutableRefObject<GridApiCommunity>;
|
|
359
360
|
/**
|
|
360
|
-
* Forwarded props for the
|
|
361
|
+
* Forwarded props for the Data Grid root element.
|
|
361
362
|
* @ignore - do not document.
|
|
362
363
|
*/
|
|
363
364
|
forwardedProps?: Record<string, unknown>;
|
|
364
365
|
/**
|
|
365
366
|
* Signal to the underlying logic what version of the public component API
|
|
366
|
-
* of the
|
|
367
|
+
* of the Data Grid is exposed [[GridSignature]].
|
|
367
368
|
* @ignore - do not document.
|
|
368
369
|
*/
|
|
369
370
|
signature?: string;
|
|
@@ -377,7 +378,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
377
378
|
*/
|
|
378
379
|
rowCount?: number;
|
|
379
380
|
/**
|
|
380
|
-
* Override the height/width of the
|
|
381
|
+
* Override the height/width of the Data Grid inner scrollbar.
|
|
381
382
|
*/
|
|
382
383
|
scrollbarSize?: number;
|
|
383
384
|
/**
|
|
@@ -546,14 +547,14 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
546
547
|
*/
|
|
547
548
|
onRowDoubleClick?: GridEventListener<'rowDoubleClick'>;
|
|
548
549
|
/**
|
|
549
|
-
* Callback fired when the
|
|
550
|
+
* Callback fired when the Data Grid is resized.
|
|
550
551
|
* @param {ElementSize} containerSize With all properties from [[ElementSize]].
|
|
551
552
|
* @param {MuiEvent<{}>} event The event object.
|
|
552
553
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
553
554
|
*/
|
|
554
555
|
onResize?: GridEventListener<'debouncedResize'>;
|
|
555
556
|
/**
|
|
556
|
-
* Callback fired when the state of the
|
|
557
|
+
* Callback fired when the state of the Data Grid is updated.
|
|
557
558
|
* @param {GridState} state The new state.
|
|
558
559
|
* @param {MuiEvent<{}>} event The event object.
|
|
559
560
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -619,7 +620,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
619
620
|
*/
|
|
620
621
|
onRowModesModelChange?: (rowModesModel: GridRowModesModel, details: GridCallbackDetails) => void;
|
|
621
622
|
/**
|
|
622
|
-
* Set the filter model of the
|
|
623
|
+
* Set the filter model of the Data Grid.
|
|
623
624
|
*/
|
|
624
625
|
filterModel?: GridFilterModel;
|
|
625
626
|
/**
|
|
@@ -629,7 +630,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
629
630
|
*/
|
|
630
631
|
onFilterModelChange?: (model: GridFilterModel, details: GridCallbackDetails<'filter'>) => void;
|
|
631
632
|
/**
|
|
632
|
-
* Sets the row selection model of the
|
|
633
|
+
* Sets the row selection model of the Data Grid.
|
|
633
634
|
*/
|
|
634
635
|
rowSelectionModel?: GridInputRowSelectionModel;
|
|
635
636
|
/**
|
|
@@ -639,8 +640,8 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
639
640
|
*/
|
|
640
641
|
onRowSelectionModelChange?: (rowSelectionModel: GridRowSelectionModel, details: GridCallbackDetails) => void;
|
|
641
642
|
/**
|
|
642
|
-
* Set the column visibility model of the
|
|
643
|
-
* If defined, the
|
|
643
|
+
* Set the column visibility model of the Data Grid.
|
|
644
|
+
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
644
645
|
*/
|
|
645
646
|
columnVisibilityModel?: GridColumnVisibilityModel;
|
|
646
647
|
/**
|
|
@@ -650,7 +651,7 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
650
651
|
*/
|
|
651
652
|
onColumnVisibilityModelChange?: (model: GridColumnVisibilityModel, details: GridCallbackDetails) => void;
|
|
652
653
|
/**
|
|
653
|
-
* Set the sort model of the
|
|
654
|
+
* Set the sort model of the Data Grid.
|
|
654
655
|
*/
|
|
655
656
|
sortModel?: GridSortModel;
|
|
656
657
|
/**
|
|
@@ -660,11 +661,11 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
660
661
|
*/
|
|
661
662
|
onSortModelChange?: (model: GridSortModel, details: GridCallbackDetails) => void;
|
|
662
663
|
/**
|
|
663
|
-
* The label of the
|
|
664
|
+
* The label of the Data Grid.
|
|
664
665
|
*/
|
|
665
666
|
'aria-label'?: string;
|
|
666
667
|
/**
|
|
667
|
-
* The id of the element containing a label for the
|
|
668
|
+
* The id of the element containing a label for the Data Grid.
|
|
668
669
|
*/
|
|
669
670
|
'aria-labelledby'?: string;
|
|
670
671
|
/**
|
|
@@ -41,21 +41,21 @@ DataGridRaw.propTypes = {
|
|
|
41
41
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
42
42
|
// ----------------------------------------------------------------------
|
|
43
43
|
/**
|
|
44
|
-
* The ref object that allows
|
|
44
|
+
* The ref object that allows Data Grid manipulation. Can be instantiated with `useGridApiRef()`.
|
|
45
45
|
*/
|
|
46
46
|
apiRef: PropTypes.shape({
|
|
47
47
|
current: PropTypes.object.isRequired
|
|
48
48
|
}),
|
|
49
49
|
/**
|
|
50
|
-
* The label of the
|
|
50
|
+
* The label of the Data Grid.
|
|
51
51
|
*/
|
|
52
52
|
'aria-label': PropTypes.string,
|
|
53
53
|
/**
|
|
54
|
-
* The id of the element containing a label for the
|
|
54
|
+
* The id of the element containing a label for the Data Grid.
|
|
55
55
|
*/
|
|
56
56
|
'aria-labelledby': PropTypes.string,
|
|
57
57
|
/**
|
|
58
|
-
* If `true`, the
|
|
58
|
+
* If `true`, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
61
|
autoHeight: PropTypes.bool,
|
|
@@ -69,7 +69,7 @@ DataGridRaw.propTypes = {
|
|
|
69
69
|
*/
|
|
70
70
|
cellModesModel: PropTypes.object,
|
|
71
71
|
/**
|
|
72
|
-
* If `true`, the
|
|
72
|
+
* If `true`, the Data Grid will display an extra column with checkboxes for selecting rows.
|
|
73
73
|
* @default false
|
|
74
74
|
*/
|
|
75
75
|
checkboxSelection: PropTypes.bool,
|
|
@@ -89,7 +89,7 @@ DataGridRaw.propTypes = {
|
|
|
89
89
|
columnBuffer: PropTypes.number,
|
|
90
90
|
columnGroupingModel: PropTypes.arrayOf(PropTypes.object),
|
|
91
91
|
/**
|
|
92
|
-
* Sets the height in pixel of the column headers in the
|
|
92
|
+
* Sets the height in pixel of the column headers in the Data Grid.
|
|
93
93
|
* @default 56
|
|
94
94
|
*/
|
|
95
95
|
columnHeaderHeight: PropTypes.number,
|
|
@@ -109,12 +109,12 @@ DataGridRaw.propTypes = {
|
|
|
109
109
|
*/
|
|
110
110
|
columnThreshold: PropTypes.number,
|
|
111
111
|
/**
|
|
112
|
-
* Set the column visibility model of the
|
|
113
|
-
* If defined, the
|
|
112
|
+
* Set the column visibility model of the Data Grid.
|
|
113
|
+
* If defined, the Data Grid will ignore the `hide` property in [[GridColDef]].
|
|
114
114
|
*/
|
|
115
115
|
columnVisibilityModel: PropTypes.object,
|
|
116
116
|
/**
|
|
117
|
-
* Set the density of the
|
|
117
|
+
* Set the density of the Data Grid.
|
|
118
118
|
* @default "standard"
|
|
119
119
|
*/
|
|
120
120
|
density: PropTypes.oneOf(['comfortable', 'compact', 'standard']),
|
|
@@ -144,6 +144,12 @@ DataGridRaw.propTypes = {
|
|
|
144
144
|
* @ignore - do not document
|
|
145
145
|
*/
|
|
146
146
|
disableEval: PropTypes.bool,
|
|
147
|
+
/**
|
|
148
|
+
* If `true`, multiple selection using the Ctrl/CMD or Shift key is disabled.
|
|
149
|
+
* The MIT DataGrid will ignore this prop, unless `checkboxSelection` is enabled.
|
|
150
|
+
* @default false (`!props.checkboxSelection` for MIT Data Grid)
|
|
151
|
+
*/
|
|
152
|
+
disableMultipleRowSelection: PropTypes.bool,
|
|
147
153
|
/**
|
|
148
154
|
* If `true`, the selection on click on a row or cell is disabled.
|
|
149
155
|
* @default false
|
|
@@ -180,7 +186,7 @@ DataGridRaw.propTypes = {
|
|
|
180
186
|
*/
|
|
181
187
|
filterMode: PropTypes.oneOf(['client', 'server']),
|
|
182
188
|
/**
|
|
183
|
-
* Set the filter model of the
|
|
189
|
+
* Set the filter model of the Data Grid.
|
|
184
190
|
*/
|
|
185
191
|
filterModel: PropTypes.shape({
|
|
186
192
|
items: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -195,7 +201,7 @@ DataGridRaw.propTypes = {
|
|
|
195
201
|
quickFilterValues: PropTypes.array
|
|
196
202
|
}),
|
|
197
203
|
/**
|
|
198
|
-
* Forwarded props for the
|
|
204
|
+
* Forwarded props for the Data Grid root element.
|
|
199
205
|
* @ignore - do not document.
|
|
200
206
|
*/
|
|
201
207
|
forwardedProps: PropTypes.object,
|
|
@@ -263,7 +269,7 @@ DataGridRaw.propTypes = {
|
|
|
263
269
|
*/
|
|
264
270
|
ignoreDiacritics: PropTypes.bool,
|
|
265
271
|
/**
|
|
266
|
-
* If `true`, the
|
|
272
|
+
* If `true`, the Data Grid will not use `valueFormatter` when exporting to CSV or copying to clipboard.
|
|
267
273
|
* If an object is provided, you can choose to ignore the `valueFormatter` for CSV export or clipboard export.
|
|
268
274
|
* @default false
|
|
269
275
|
*/
|
|
@@ -301,7 +307,7 @@ DataGridRaw.propTypes = {
|
|
|
301
307
|
*/
|
|
302
308
|
loading: PropTypes.bool,
|
|
303
309
|
/**
|
|
304
|
-
* Set the locale text of the
|
|
310
|
+
* Set the locale text of the Data Grid.
|
|
305
311
|
* You can find all the translation keys supported in [the source](https://github.com/mui/mui-x/blob/HEAD/packages/grid/x-data-grid/src/constants/localeTextConstants.ts) in the GitHub repository.
|
|
306
312
|
*/
|
|
307
313
|
localeText: PropTypes.object,
|
|
@@ -469,7 +475,7 @@ DataGridRaw.propTypes = {
|
|
|
469
475
|
*/
|
|
470
476
|
onProcessRowUpdateError: PropTypes.func,
|
|
471
477
|
/**
|
|
472
|
-
* Callback fired when the
|
|
478
|
+
* Callback fired when the Data Grid is resized.
|
|
473
479
|
* @param {ElementSize} containerSize With all properties from [[ElementSize]].
|
|
474
480
|
* @param {MuiEvent<{}>} event The event object.
|
|
475
481
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -527,7 +533,7 @@ DataGridRaw.propTypes = {
|
|
|
527
533
|
*/
|
|
528
534
|
onSortModelChange: PropTypes.func,
|
|
529
535
|
/**
|
|
530
|
-
* Callback fired when the state of the
|
|
536
|
+
* Callback fired when the state of the Data Grid is updated.
|
|
531
537
|
* @param {GridState} state The new state.
|
|
532
538
|
* @param {MuiEvent<{}>} event The event object.
|
|
533
539
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
@@ -581,7 +587,7 @@ DataGridRaw.propTypes = {
|
|
|
581
587
|
*/
|
|
582
588
|
rowCount: PropTypes.number,
|
|
583
589
|
/**
|
|
584
|
-
* Sets the height in pixel of a row in the
|
|
590
|
+
* Sets the height in pixel of a row in the Data Grid.
|
|
585
591
|
* @default 52
|
|
586
592
|
*/
|
|
587
593
|
rowHeight: PropTypes.number,
|
|
@@ -606,7 +612,7 @@ DataGridRaw.propTypes = {
|
|
|
606
612
|
*/
|
|
607
613
|
rowSelection: PropTypes.bool,
|
|
608
614
|
/**
|
|
609
|
-
* Sets the row selection model of the
|
|
615
|
+
* Sets the row selection model of the Data Grid.
|
|
610
616
|
*/
|
|
611
617
|
rowSelectionModel: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired), PropTypes.number, PropTypes.string]),
|
|
612
618
|
/**
|
|
@@ -620,7 +626,7 @@ DataGridRaw.propTypes = {
|
|
|
620
626
|
*/
|
|
621
627
|
rowThreshold: PropTypes.number,
|
|
622
628
|
/**
|
|
623
|
-
* Override the height/width of the
|
|
629
|
+
* Override the height/width of the Data Grid inner scrollbar.
|
|
624
630
|
*/
|
|
625
631
|
scrollbarSize: PropTypes.number,
|
|
626
632
|
/**
|
|
@@ -654,7 +660,7 @@ DataGridRaw.propTypes = {
|
|
|
654
660
|
*/
|
|
655
661
|
sortingOrder: PropTypes.arrayOf(PropTypes.oneOf(['asc', 'desc'])),
|
|
656
662
|
/**
|
|
657
|
-
* Set the sort model of the
|
|
663
|
+
* Set the sort model of the Data Grid.
|
|
658
664
|
*/
|
|
659
665
|
sortModel: PropTypes.arrayOf(PropTypes.shape({
|
|
660
666
|
field: PropTypes.string.isRequired,
|
|
@@ -8,7 +8,6 @@ import { computeSlots, useProps } from '../internals/utils';
|
|
|
8
8
|
const DATA_GRID_FORCED_PROPS = {
|
|
9
9
|
disableMultipleColumnsFiltering: true,
|
|
10
10
|
disableMultipleColumnsSorting: true,
|
|
11
|
-
disableMultipleRowSelection: true,
|
|
12
11
|
throttleRowsMs: undefined,
|
|
13
12
|
hideFooterRowCount: false,
|
|
14
13
|
pagination: true,
|