@mui/x-data-grid 7.0.0-alpha.5 → 7.0.0-alpha.7
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 +408 -6
- package/DataGrid/DataGrid.js +31 -21
- package/DataGrid/useDataGridProps.js +0 -1
- package/colDef/gridDateOperators.js +13 -6
- package/colDef/gridSingleSelectColDef.js +6 -15
- package/components/GridPagination.d.ts +2 -2
- 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/filter/gridFilterUtils.js +21 -24
- 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 +31 -21
- 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/filter/gridFilterUtils.js +20 -17
- 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/legacy/locales/csCZ.js +2 -2
- package/locales/csCZ.js +2 -2
- package/models/props/DataGridProps.d.ts +26 -26
- package/modern/DataGrid/DataGrid.js +31 -21
- 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/filter/gridFilterUtils.js +21 -24
- 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/modern/locales/csCZ.js +2 -2
- package/node/DataGrid/DataGrid.js +31 -21
- 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/filter/gridFilterUtils.js +21 -23
- 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/node/locales/csCZ.js +2 -2
- package/package.json +4 -4
|
@@ -15,26 +15,24 @@ var _styles = require("@mui/material/styles");
|
|
|
15
15
|
var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
|
|
16
16
|
var _filterPanelUtils = require("./filterPanelUtils");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "
|
|
18
|
+
const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "isFilterActive", "clearButton", "InputLabelProps"];
|
|
19
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
21
|
const renderSingleSelectOptions = ({
|
|
22
|
-
column
|
|
23
|
-
valueOptions,
|
|
24
|
-
field
|
|
25
|
-
},
|
|
22
|
+
column,
|
|
26
23
|
OptionComponent,
|
|
27
24
|
getOptionLabel,
|
|
28
25
|
getOptionValue,
|
|
29
26
|
isSelectNative,
|
|
30
27
|
baseSelectOptionProps
|
|
31
28
|
}) => {
|
|
32
|
-
const iterableColumnValues =
|
|
33
|
-
field
|
|
34
|
-
})] : ['', ...(valueOptions || [])];
|
|
29
|
+
const iterableColumnValues = ['', ...((0, _filterPanelUtils.getValueOptions)(column) || [])];
|
|
35
30
|
return iterableColumnValues.map(option => {
|
|
36
31
|
const value = getOptionValue(option);
|
|
37
|
-
|
|
32
|
+
let label = getOptionLabel(option);
|
|
33
|
+
if (label === '') {
|
|
34
|
+
label = ' '; // To force the height of the empty option
|
|
35
|
+
}
|
|
38
36
|
return /*#__PURE__*/(0, _react.createElement)(OptionComponent, (0, _extends2.default)({}, baseSelectOptionProps, {
|
|
39
37
|
native: isSelectNative,
|
|
40
38
|
key: value,
|
|
@@ -57,19 +55,17 @@ function GridFilterInputSingleSelect(props) {
|
|
|
57
55
|
type,
|
|
58
56
|
apiRef,
|
|
59
57
|
focusElementRef,
|
|
60
|
-
getOptionLabel: getOptionLabelProp,
|
|
61
|
-
getOptionValue: getOptionValueProp,
|
|
62
58
|
placeholder,
|
|
63
59
|
tabIndex,
|
|
64
60
|
label: labelProp,
|
|
65
61
|
clearButton
|
|
66
62
|
} = props,
|
|
67
63
|
others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
68
|
-
const
|
|
64
|
+
const filterValue = item.value ?? '';
|
|
69
65
|
const id = (0, _utils.unstable_useId)();
|
|
70
66
|
const labelId = (0, _utils.unstable_useId)();
|
|
71
67
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
72
|
-
const isSelectNative = rootProps.slotProps?.baseSelect?.native ??
|
|
68
|
+
const isSelectNative = rootProps.slotProps?.baseSelect?.native ?? false;
|
|
73
69
|
let resolvedColumn = null;
|
|
74
70
|
if (item.field) {
|
|
75
71
|
const column = apiRef.current.getColumn(item.field);
|
|
@@ -77,52 +73,27 @@ function GridFilterInputSingleSelect(props) {
|
|
|
77
73
|
resolvedColumn = column;
|
|
78
74
|
}
|
|
79
75
|
}
|
|
80
|
-
const getOptionValue =
|
|
81
|
-
const getOptionLabel =
|
|
76
|
+
const getOptionValue = resolvedColumn?.getOptionValue;
|
|
77
|
+
const getOptionLabel = resolvedColumn?.getOptionLabel;
|
|
82
78
|
const currentValueOptions = React.useMemo(() => {
|
|
83
|
-
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
return typeof resolvedColumn.valueOptions === 'function' ? resolvedColumn.valueOptions({
|
|
87
|
-
field: resolvedColumn.field
|
|
88
|
-
}) : resolvedColumn.valueOptions;
|
|
79
|
+
return (0, _filterPanelUtils.getValueOptions)(resolvedColumn);
|
|
89
80
|
}, [resolvedColumn]);
|
|
90
81
|
const onFilterChange = React.useCallback(event => {
|
|
91
82
|
let value = event.target.value;
|
|
92
83
|
|
|
93
84
|
// NativeSelect casts the value to a string.
|
|
94
85
|
value = (0, _filterPanelUtils.getValueFromValueOptions)(value, currentValueOptions, getOptionValue);
|
|
95
|
-
setFilterValueState(String(value));
|
|
96
86
|
applyValue((0, _extends2.default)({}, item, {
|
|
97
87
|
value
|
|
98
88
|
}));
|
|
99
89
|
}, [currentValueOptions, getOptionValue, applyValue, item]);
|
|
100
|
-
React.useEffect(() => {
|
|
101
|
-
let itemValue;
|
|
102
|
-
if (currentValueOptions !== undefined) {
|
|
103
|
-
// sanitize if valueOptions are provided
|
|
104
|
-
itemValue = (0, _filterPanelUtils.getValueFromValueOptions)(item.value, currentValueOptions, getOptionValue);
|
|
105
|
-
if (itemValue !== item.value) {
|
|
106
|
-
applyValue((0, _extends2.default)({}, item, {
|
|
107
|
-
value: itemValue
|
|
108
|
-
}));
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
itemValue = item.value;
|
|
113
|
-
}
|
|
114
|
-
itemValue = itemValue ?? '';
|
|
115
|
-
setFilterValueState(String(itemValue));
|
|
116
|
-
}, [item, currentValueOptions, applyValue, getOptionValue]);
|
|
117
|
-
if (!(0, _filterPanelUtils.isSingleSelectColDef)(resolvedColumn)) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
90
|
if (!(0, _filterPanelUtils.isSingleSelectColDef)(resolvedColumn)) {
|
|
121
91
|
return null;
|
|
122
92
|
}
|
|
123
93
|
const label = labelProp ?? apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
124
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(SingleSelectOperatorContainer, {
|
|
125
95
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(rootProps.slots.baseFormControl, {
|
|
96
|
+
fullWidth: true,
|
|
126
97
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputLabel, (0, _extends2.default)({}, rootProps.slotProps?.baseInputLabel, {
|
|
127
98
|
id: labelId,
|
|
128
99
|
htmlFor: id,
|
|
@@ -133,7 +104,7 @@ function GridFilterInputSingleSelect(props) {
|
|
|
133
104
|
id: id,
|
|
134
105
|
label: label,
|
|
135
106
|
labelId: labelId,
|
|
136
|
-
value:
|
|
107
|
+
value: filterValue,
|
|
137
108
|
onChange: onFilterChange,
|
|
138
109
|
variant: "standard",
|
|
139
110
|
type: type || 'text',
|
|
@@ -167,18 +138,6 @@ process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes =
|
|
|
167
138
|
applyValue: _propTypes.default.func.isRequired,
|
|
168
139
|
clearButton: _propTypes.default.node,
|
|
169
140
|
focusElementRef: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.func, _propTypes.default.object]),
|
|
170
|
-
/**
|
|
171
|
-
* Used to determine the label displayed for a given value option.
|
|
172
|
-
* @param {ValueOptions} value The current value option.
|
|
173
|
-
* @returns {string} The text to be displayed.
|
|
174
|
-
*/
|
|
175
|
-
getOptionLabel: _propTypes.default.func,
|
|
176
|
-
/**
|
|
177
|
-
* Used to determine the value used for a value option.
|
|
178
|
-
* @param {ValueOptions} value The current value option.
|
|
179
|
-
* @returns {string} The value to be used.
|
|
180
|
-
*/
|
|
181
|
-
getOptionValue: _propTypes.default.func,
|
|
182
141
|
/**
|
|
183
142
|
* It is `true` if the filter either has a value or an operator with no value
|
|
184
143
|
* required is selected (e.g. `isEmpty`)
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.getLabelFromValueOption = void 0;
|
|
7
7
|
exports.getValueFromValueOptions = getValueFromValueOptions;
|
|
8
|
+
exports.getValueOptions = getValueOptions;
|
|
8
9
|
exports.isSingleSelectColDef = isSingleSelectColDef;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
11
|
function isSingleSelectColDef(colDef) {
|
|
10
12
|
return colDef?.type === 'singleSelect';
|
|
11
13
|
}
|
|
14
|
+
function getValueOptions(column, additionalParams) {
|
|
15
|
+
if (!column) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return typeof column.valueOptions === 'function' ? column.valueOptions((0, _extends2.default)({
|
|
19
|
+
field: column.field
|
|
20
|
+
}, additionalParams)) : column.valueOptions;
|
|
21
|
+
}
|
|
12
22
|
function getValueFromValueOptions(value, valueOptions, getOptionValue) {
|
|
13
23
|
if (valueOptions === undefined) {
|
|
14
24
|
return undefined;
|
|
@@ -18,9 +28,4 @@ function getValueFromValueOptions(value, valueOptions, getOptionValue) {
|
|
|
18
28
|
return String(optionValue) === String(value);
|
|
19
29
|
});
|
|
20
30
|
return getOptionValue(result);
|
|
21
|
-
}
|
|
22
|
-
const getLabelFromValueOption = valueOption => {
|
|
23
|
-
const label = typeof valueOption === 'object' ? valueOption.label : valueOption;
|
|
24
|
-
return label != null ? String(label) : '';
|
|
25
|
-
};
|
|
26
|
-
exports.getLabelFromValueOption = getLabelFromValueOption;
|
|
31
|
+
}
|
|
@@ -11,14 +11,17 @@ var _gridFilterState = require("./gridFilterState");
|
|
|
11
11
|
var _warning = require("../../../utils/warning");
|
|
12
12
|
var _getPublicApiRef = require("../../../utils/getPublicApiRef");
|
|
13
13
|
var _columns = require("../columns");
|
|
14
|
-
// Fixes https://github.com/mui/mui-x/issues/10056
|
|
15
|
-
const globalScope = typeof window === 'undefined' ? globalThis : window;
|
|
16
|
-
const evalCode = globalScope[atob('ZXZhbA==')];
|
|
17
14
|
let hasEval;
|
|
18
|
-
|
|
19
|
-
hasEval
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
function getHasEval() {
|
|
16
|
+
if (hasEval !== undefined) {
|
|
17
|
+
return hasEval;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
hasEval = new Function('return true')();
|
|
21
|
+
} catch (_) {
|
|
22
|
+
hasEval = false;
|
|
23
|
+
}
|
|
24
|
+
return hasEval;
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* Adds default values to the optional fields of a filter items.
|
|
@@ -149,7 +152,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
|
|
|
149
152
|
if (appliers.length === 0) {
|
|
150
153
|
return null;
|
|
151
154
|
}
|
|
152
|
-
if (
|
|
155
|
+
if (disableEval || !getHasEval()) {
|
|
153
156
|
// This is the original logic, which is used if `eval()` is not supported (aka prevented by CSP).
|
|
154
157
|
return (row, shouldApplyFilter) => {
|
|
155
158
|
const resultPerItemId = {};
|
|
@@ -163,25 +166,20 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
|
|
|
163
166
|
};
|
|
164
167
|
}
|
|
165
168
|
|
|
166
|
-
// We generate a new function with `
|
|
169
|
+
// We generate a new function with `new Function()` to avoid expensive patterns for JS engines
|
|
167
170
|
// such as a dynamic object assignment, e.g. `{ [dynamicKey]: value }`.
|
|
168
|
-
const
|
|
169
|
-
|
|
171
|
+
const filterItemCore = new Function('appliers', 'row', 'shouldApplyFilter', `"use strict";
|
|
172
|
+
${appliers.map((applier, i) => `const shouldApply${i} = !shouldApplyFilter || shouldApplyFilter(${JSON.stringify(applier.item.field)});`).join('\n')}
|
|
170
173
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
false :
|
|
175
|
-
appliers[${i}].fn(row),
|
|
176
|
-
`).join('\n')}};
|
|
174
|
+
const result$$ = {
|
|
175
|
+
${appliers.map((applier, i) => ` ${JSON.stringify(String(applier.item.id))}: !shouldApply${i} ? false : appliers[${i}].fn(row),`).join('\n')}
|
|
176
|
+
};
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
})`;
|
|
180
|
-
const filterItemCore = evalCode(filterItemTemplate.replaceAll('$$', String(filterItemsApplierId)));
|
|
181
|
-
const filterItem = (row, shouldApplyItem) => {
|
|
182
|
-
return filterItemCore(apiRef.current.getRowId, appliers, row, shouldApplyItem);
|
|
183
|
-
};
|
|
178
|
+
return result$$;`.replaceAll('$$', String(filterItemsApplierId)));
|
|
184
179
|
filterItemsApplierId += 1;
|
|
180
|
+
|
|
181
|
+
// Assign to the arrow function a name to help debugging
|
|
182
|
+
const filterItem = (row, shouldApplyItem) => filterItemCore(appliers, row, shouldApplyItem);
|
|
185
183
|
return filterItem;
|
|
186
184
|
};
|
|
187
185
|
const shouldQuickFilterExcludeHiddenColumns = filterModel => {
|
|
@@ -22,6 +22,7 @@ var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
|
|
|
22
22
|
var _gridDetailPanelToggleField = require("../../../constants/gridDetailPanelToggleField");
|
|
23
23
|
var _gridClasses = require("../../../constants/gridClasses");
|
|
24
24
|
var _domUtils = require("../../../utils/domUtils");
|
|
25
|
+
var _utils = require("./utils");
|
|
25
26
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
27
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
28
|
const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
|
|
@@ -67,11 +68,10 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
67
68
|
});
|
|
68
69
|
const {
|
|
69
70
|
checkboxSelection,
|
|
70
|
-
disableMultipleRowSelection,
|
|
71
71
|
disableRowSelectionOnClick,
|
|
72
72
|
isRowSelectable: propIsRowSelectable
|
|
73
73
|
} = props;
|
|
74
|
-
const canHaveMultipleSelection =
|
|
74
|
+
const canHaveMultipleSelection = (0, _utils.isMultipleRowSelectionEnabled)(props);
|
|
75
75
|
const visibleRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
|
|
76
76
|
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
77
77
|
let endId = id;
|
|
@@ -101,7 +101,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
101
101
|
* API METHODS
|
|
102
102
|
*/
|
|
103
103
|
const setRowSelectionModel = React.useCallback(model => {
|
|
104
|
-
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid && !
|
|
104
|
+
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid && !canHaveMultipleSelection && Array.isArray(model) && model.length > 1) {
|
|
105
105
|
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'));
|
|
106
106
|
}
|
|
107
107
|
const currentModel = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
@@ -112,7 +112,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
112
112
|
}));
|
|
113
113
|
apiRef.current.forceUpdate();
|
|
114
114
|
}
|
|
115
|
-
}, [apiRef, logger, props.rowSelection, props.signature,
|
|
115
|
+
}, [apiRef, logger, props.rowSelection, props.signature, canHaveMultipleSelection]);
|
|
116
116
|
const isRowSelected = React.useCallback(id => (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state).includes(id), [apiRef]);
|
|
117
117
|
const isRowSelectable = React.useCallback(id => {
|
|
118
118
|
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
@@ -263,24 +263,24 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
263
263
|
if (rowNode.type === 'pinnedRow') {
|
|
264
264
|
return;
|
|
265
265
|
}
|
|
266
|
-
if (event.shiftKey &&
|
|
266
|
+
if (event.shiftKey && canHaveMultipleSelection) {
|
|
267
267
|
expandMouseRowRangeSelection(params.id);
|
|
268
268
|
} else {
|
|
269
269
|
handleSingleRowSelection(params.id, event);
|
|
270
270
|
}
|
|
271
|
-
}, [disableRowSelectionOnClick, canHaveMultipleSelection,
|
|
271
|
+
}, [disableRowSelectionOnClick, canHaveMultipleSelection, apiRef, expandMouseRowRangeSelection, handleSingleRowSelection]);
|
|
272
272
|
const preventSelectionOnShift = React.useCallback((params, event) => {
|
|
273
273
|
if (canHaveMultipleSelection && event.shiftKey) {
|
|
274
274
|
window.getSelection()?.removeAllRanges();
|
|
275
275
|
}
|
|
276
276
|
}, [canHaveMultipleSelection]);
|
|
277
277
|
const handleRowSelectionCheckboxChange = React.useCallback((params, event) => {
|
|
278
|
-
if (event.nativeEvent.shiftKey) {
|
|
278
|
+
if (canHaveMultipleSelection && event.nativeEvent.shiftKey) {
|
|
279
279
|
expandMouseRowRangeSelection(params.id);
|
|
280
280
|
} else {
|
|
281
|
-
apiRef.current.selectRow(params.id, params.value);
|
|
281
|
+
apiRef.current.selectRow(params.id, params.value, !canHaveMultipleSelection);
|
|
282
282
|
}
|
|
283
|
-
}, [apiRef, expandMouseRowRangeSelection]);
|
|
283
|
+
}, [apiRef, expandMouseRowRangeSelection, canHaveMultipleSelection]);
|
|
284
284
|
const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
|
|
285
285
|
const shouldLimitSelectionToCurrentPage = props.checkboxSelectionVisibleOnly && props.pagination;
|
|
286
286
|
const rowsToBeSelected = shouldLimitSelectionToCurrentPage ? (0, _pagination.gridPaginatedVisibleSortedGridRowIdsSelector)(apiRef) : (0, _gridFilterSelector.gridExpandedSortedRowIdsSelector)(apiRef);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMultipleRowSelectionEnabled = isMultipleRowSelectionEnabled;
|
|
7
|
+
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
8
|
+
function isMultipleRowSelectionEnabled(props) {
|
|
9
|
+
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid) {
|
|
10
|
+
// DataGrid Community has multiple row selection enabled only if checkbox selection is enabled.
|
|
11
|
+
return props.checkboxSelection && props.disableMultipleRowSelection !== true;
|
|
12
|
+
}
|
|
13
|
+
return !props.disableMultipleRowSelection;
|
|
14
|
+
}
|
|
@@ -10,6 +10,7 @@ var _useGridRootProps = require("./useGridRootProps");
|
|
|
10
10
|
var _gridColumnGroupsSelector = require("../features/columnGrouping/gridColumnGroupsSelector");
|
|
11
11
|
var _gridRowsSelector = require("../features/rows/gridRowsSelector");
|
|
12
12
|
var _useGridPrivateApiContext = require("./useGridPrivateApiContext");
|
|
13
|
+
var _utils = require("../features/rowSelection/utils");
|
|
13
14
|
const useGridAriaAttributes = () => {
|
|
14
15
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
15
16
|
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
@@ -25,7 +26,7 @@ const useGridAriaAttributes = () => {
|
|
|
25
26
|
role,
|
|
26
27
|
'aria-colcount': visibleColumns.length,
|
|
27
28
|
'aria-rowcount': headerGroupingMaxDepth + 1 + pinnedRowsCount + totalRowCount,
|
|
28
|
-
'aria-multiselectable':
|
|
29
|
+
'aria-multiselectable': (0, _utils.isMultipleRowSelectionEnabled)(rootProps)
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
32
|
exports.useGridAriaAttributes = useGridAriaAttributes;
|
package/node/index.js
CHANGED
package/node/locales/csCZ.js
CHANGED
|
@@ -165,8 +165,8 @@ const csCZGrid = {
|
|
|
165
165
|
treeDataCollapse: 'skrýt potomky',
|
|
166
166
|
// Grouping columns
|
|
167
167
|
groupingColumnHeaderName: 'Skupina',
|
|
168
|
-
groupColumn: name => `
|
|
169
|
-
unGroupColumn: name => `Přestat
|
|
168
|
+
groupColumn: name => `Seskupit podle ${name}`,
|
|
169
|
+
unGroupColumn: name => `Přestat seskupovat podle ${name}`,
|
|
170
170
|
// Master/detail
|
|
171
171
|
detailPanelToggle: 'Přepnout detail panelu',
|
|
172
172
|
expandDetailPanel: 'Rozbalit',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.7",
|
|
4
4
|
"description": "The community edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"directory": "packages/grid/x-data-grid"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@babel/runtime": "^7.23.
|
|
40
|
-
"@mui/system": "^5.
|
|
41
|
-
"@mui/utils": "^5.
|
|
39
|
+
"@babel/runtime": "^7.23.7",
|
|
40
|
+
"@mui/system": "^5.15.2",
|
|
41
|
+
"@mui/utils": "^5.15.2",
|
|
42
42
|
"clsx": "^2.0.0",
|
|
43
43
|
"prop-types": "^15.8.1",
|
|
44
44
|
"reselect": "^4.1.8"
|