@mui/x-data-grid 7.22.1 → 7.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +139 -0
- package/colDef/gridBooleanOperators.js +4 -6
- package/components/GridDetailPanels.js +0 -1
- package/components/GridPinnedRows.js +0 -1
- package/components/GridRow.d.ts +2 -2
- package/components/GridRow.js +1 -1
- package/components/base/GridOverlays.js +5 -6
- package/components/cell/GridCell.d.ts +41 -3
- package/components/cell/GridCell.js +1 -9
- package/components/cell/GridEditInputCell.js +0 -67
- package/components/columnsManagement/GridColumnsManagement.d.ts +2 -0
- package/components/columnsManagement/GridColumnsManagement.js +53 -6
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -0
- package/components/panel/filterPanel/GridFilterInputBoolean.js +14 -5
- package/components/toolbar/GridToolbar.d.ts +2 -2
- package/components/toolbar/GridToolbar.js +12 -4
- package/components/toolbar/GridToolbarExport.d.ts +2 -2
- package/components/toolbar/GridToolbarExport.js +4 -3
- package/components/toolbar/index.d.ts +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/constants/gridClasses.d.ts +4 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +1 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/hooks/features/editing/useGridCellEditing.js +23 -4
- package/hooks/features/editing/useGridRowEditing.js +23 -2
- package/hooks/features/export/useGridCsvExport.js +1 -1
- package/hooks/features/export/useGridPrintExport.js +1 -1
- package/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +30 -16
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/rows/gridRowsUtils.js +1 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/hooks/utils/useGridSelector.d.ts +3 -2
- package/hooks/utils/useGridSelector.js +27 -2
- package/index.d.ts +0 -1
- package/index.js +1 -1
- package/locales/arSD.js +1 -0
- package/locales/beBY.js +1 -0
- package/locales/bgBG.js +2 -0
- package/locales/csCZ.js +2 -0
- package/locales/daDK.js +2 -0
- package/locales/deDE.js +2 -0
- package/locales/elGR.js +1 -0
- package/locales/esES.js +6 -4
- package/locales/faIR.js +2 -0
- package/locales/fiFI.js +2 -0
- package/locales/frFR.js +2 -0
- package/locales/heIL.js +2 -0
- package/locales/hrHR.js +2 -0
- package/locales/huHU.js +2 -0
- package/locales/isIS.js +1 -0
- package/locales/itIT.js +2 -0
- package/locales/jaJP.js +2 -0
- package/locales/koKR.js +1 -0
- package/locales/nbNO.js +2 -0
- package/locales/nlNL.js +2 -0
- package/locales/nnNO.js +2 -0
- package/locales/plPL.js +1 -0
- package/locales/ptBR.js +2 -0
- package/locales/ptPT.js +2 -0
- package/locales/roRO.js +1 -0
- package/locales/ruRU.js +2 -0
- package/locales/skSK.js +1 -0
- package/locales/svSE.js +6 -5
- package/locales/trTR.js +4 -2
- package/locales/ukUA.js +1 -0
- package/locales/urPK.js +1 -0
- package/locales/viVN.js +2 -0
- package/locales/zhCN.js +6 -4
- package/locales/zhHK.js +1 -0
- package/locales/zhTW.js +1 -0
- package/models/api/gridLocaleTextApi.d.ts +1 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/colDef/gridBooleanOperators.js +4 -6
- package/modern/components/GridDetailPanels.js +0 -1
- package/modern/components/GridPinnedRows.js +0 -1
- package/modern/components/GridRow.js +1 -1
- package/modern/components/base/GridOverlays.js +5 -6
- package/modern/components/cell/GridCell.js +1 -9
- package/modern/components/cell/GridEditInputCell.js +0 -67
- package/modern/components/columnsManagement/GridColumnsManagement.js +53 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +14 -5
- package/modern/components/toolbar/GridToolbar.js +12 -4
- package/modern/components/toolbar/GridToolbarExport.js +4 -3
- package/modern/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +1 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +23 -4
- package/modern/hooks/features/editing/useGridRowEditing.js +23 -2
- package/modern/hooks/features/export/useGridCsvExport.js +1 -1
- package/modern/hooks/features/export/useGridPrintExport.js +1 -1
- package/modern/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +30 -16
- package/modern/hooks/features/rows/gridRowsUtils.js +1 -5
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/modern/hooks/utils/useGridSelector.js +27 -2
- package/modern/index.js +1 -1
- package/modern/locales/arSD.js +1 -0
- package/modern/locales/beBY.js +1 -0
- package/modern/locales/bgBG.js +2 -0
- package/modern/locales/csCZ.js +2 -0
- package/modern/locales/daDK.js +2 -0
- package/modern/locales/deDE.js +2 -0
- package/modern/locales/elGR.js +1 -0
- package/modern/locales/esES.js +6 -4
- package/modern/locales/faIR.js +2 -0
- package/modern/locales/fiFI.js +2 -0
- package/modern/locales/frFR.js +2 -0
- package/modern/locales/heIL.js +2 -0
- package/modern/locales/hrHR.js +2 -0
- package/modern/locales/huHU.js +2 -0
- package/modern/locales/isIS.js +1 -0
- package/modern/locales/itIT.js +2 -0
- package/modern/locales/jaJP.js +2 -0
- package/modern/locales/koKR.js +1 -0
- package/modern/locales/nbNO.js +2 -0
- package/modern/locales/nlNL.js +2 -0
- package/modern/locales/nnNO.js +2 -0
- package/modern/locales/plPL.js +1 -0
- package/modern/locales/ptBR.js +2 -0
- package/modern/locales/ptPT.js +2 -0
- package/modern/locales/roRO.js +1 -0
- package/modern/locales/ruRU.js +2 -0
- package/modern/locales/skSK.js +1 -0
- package/modern/locales/svSE.js +6 -5
- package/modern/locales/trTR.js +4 -2
- package/modern/locales/ukUA.js +1 -0
- package/modern/locales/urPK.js +1 -0
- package/modern/locales/viVN.js +2 -0
- package/modern/locales/zhCN.js +6 -4
- package/modern/locales/zhHK.js +1 -0
- package/modern/locales/zhTW.js +1 -0
- package/modern/utils/createSelector.js +11 -1
- package/modern/utils/utils.js +1 -3
- package/node/colDef/gridBooleanOperators.js +3 -5
- package/node/components/GridDetailPanels.js +0 -1
- package/node/components/GridPinnedRows.js +0 -1
- package/node/components/GridRow.js +1 -1
- package/node/components/base/GridOverlays.js +5 -6
- package/node/components/cell/GridCell.js +1 -9
- package/node/components/cell/GridEditInputCell.js +0 -67
- package/node/components/columnsManagement/GridColumnsManagement.js +53 -6
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +16 -5
- package/node/components/toolbar/GridToolbar.js +12 -4
- package/node/components/toolbar/GridToolbarExport.js +4 -3
- package/node/components/virtualization/GridVirtualScrollbar.js +6 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +1 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/node/hooks/features/editing/useGridCellEditing.js +23 -4
- package/node/hooks/features/editing/useGridRowEditing.js +23 -2
- package/node/hooks/features/export/useGridCsvExport.js +2 -2
- package/node/hooks/features/export/useGridPrintExport.js +2 -2
- package/node/hooks/features/pagination/useGridPaginationModel.js +2 -2
- package/node/hooks/features/rowSelection/useGridRowSelection.js +29 -15
- package/node/hooks/features/rows/gridRowsUtils.js +2 -8
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/hooks/utils/useGridSelector.js +29 -3
- package/node/index.js +1 -1
- package/node/locales/arSD.js +1 -0
- package/node/locales/beBY.js +1 -0
- package/node/locales/bgBG.js +2 -0
- package/node/locales/csCZ.js +2 -0
- package/node/locales/daDK.js +2 -0
- package/node/locales/deDE.js +2 -0
- package/node/locales/elGR.js +1 -0
- package/node/locales/esES.js +6 -4
- package/node/locales/faIR.js +2 -0
- package/node/locales/fiFI.js +2 -0
- package/node/locales/frFR.js +2 -0
- package/node/locales/heIL.js +2 -0
- package/node/locales/hrHR.js +2 -0
- package/node/locales/huHU.js +2 -0
- package/node/locales/isIS.js +1 -0
- package/node/locales/itIT.js +2 -0
- package/node/locales/jaJP.js +2 -0
- package/node/locales/koKR.js +1 -0
- package/node/locales/nbNO.js +2 -0
- package/node/locales/nlNL.js +2 -0
- package/node/locales/nnNO.js +2 -0
- package/node/locales/plPL.js +1 -0
- package/node/locales/ptBR.js +2 -0
- package/node/locales/ptPT.js +2 -0
- package/node/locales/roRO.js +1 -0
- package/node/locales/ruRU.js +2 -0
- package/node/locales/skSK.js +1 -0
- package/node/locales/svSE.js +6 -5
- package/node/locales/trTR.js +4 -2
- package/node/locales/ukUA.js +1 -0
- package/node/locales/urPK.js +1 -0
- package/node/locales/viVN.js +2 -0
- package/node/locales/zhCN.js +6 -4
- package/node/locales/zhHK.js +1 -0
- package/node/locales/zhTW.js +1 -0
- package/node/utils/createSelector.js +11 -1
- package/node/utils/utils.js +1 -3
- package/package.json +1 -1
- package/utils/createSelector.d.ts +1 -1
- package/utils/createSelector.js +11 -1
- package/utils/utils.js +1 -3
|
@@ -5,6 +5,8 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
6
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
7
7
|
import { styled } from '@mui/material/styles';
|
|
8
|
+
import TextField from '@mui/material/TextField';
|
|
9
|
+
import { inputBaseClasses } from '@mui/material/InputBase';
|
|
8
10
|
import { gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector } from "../../hooks/features/columns/gridColumnsSelector.js";
|
|
9
11
|
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
10
12
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
@@ -20,6 +22,7 @@ const useUtilityClasses = ownerState => {
|
|
|
20
22
|
const slots = {
|
|
21
23
|
root: ['columnsManagement'],
|
|
22
24
|
header: ['columnsManagementHeader'],
|
|
25
|
+
searchInput: ['columnsManagementSearchInput'],
|
|
23
26
|
footer: ['columnsManagementFooter'],
|
|
24
27
|
row: ['columnsManagementRow']
|
|
25
28
|
};
|
|
@@ -42,7 +45,8 @@ function GridColumnsManagement(props) {
|
|
|
42
45
|
disableShowHideToggle = false,
|
|
43
46
|
disableResetButton = false,
|
|
44
47
|
toggleAllMode = 'all',
|
|
45
|
-
getTogglableColumns
|
|
48
|
+
getTogglableColumns,
|
|
49
|
+
searchInputProps
|
|
46
50
|
} = props;
|
|
47
51
|
const isResetDisabled = React.useMemo(() => checkColumnVisibilityModelsSame(columnVisibilityModel, initialColumnVisibilityModel), [columnVisibilityModel, initialColumnVisibilityModel]);
|
|
48
52
|
const sortedColumns = React.useMemo(() => {
|
|
@@ -109,28 +113,52 @@ function GridColumnsManagement(props) {
|
|
|
109
113
|
}
|
|
110
114
|
return false;
|
|
111
115
|
};
|
|
116
|
+
const handleSearchReset = React.useCallback(() => {
|
|
117
|
+
setSearchValue('');
|
|
118
|
+
searchInputRef.current.focus();
|
|
119
|
+
}, []);
|
|
112
120
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
113
121
|
children: [/*#__PURE__*/_jsx(GridColumnsManagementHeader, {
|
|
114
122
|
className: classes.header,
|
|
115
123
|
ownerState: rootProps,
|
|
116
|
-
children: /*#__PURE__*/_jsx(
|
|
124
|
+
children: /*#__PURE__*/_jsx(SearchInput, _extends({
|
|
125
|
+
as: rootProps.slots.baseTextField,
|
|
126
|
+
ownerState: rootProps,
|
|
117
127
|
placeholder: apiRef.current.getLocaleText('columnsManagementSearchTitle'),
|
|
118
128
|
inputRef: searchInputRef,
|
|
129
|
+
className: classes.searchInput,
|
|
119
130
|
value: searchValue,
|
|
120
131
|
onChange: handleSearchValueChange,
|
|
121
132
|
variant: "outlined",
|
|
122
133
|
size: "small",
|
|
134
|
+
type: "search",
|
|
123
135
|
InputProps: {
|
|
124
136
|
startAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseInputAdornment, {
|
|
125
137
|
position: "start",
|
|
126
138
|
children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterIcon, {})
|
|
127
139
|
}),
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
endAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
|
|
141
|
+
"aria-label": apiRef.current.getLocaleText('columnsManagementDeleteIconLabel'),
|
|
142
|
+
size: "small",
|
|
143
|
+
sx: [searchValue ? {
|
|
144
|
+
visibility: 'visible'
|
|
145
|
+
} : {
|
|
146
|
+
visibility: 'hidden'
|
|
147
|
+
}],
|
|
148
|
+
tabIndex: -1,
|
|
149
|
+
onClick: handleSearchReset
|
|
150
|
+
}, rootProps.slotProps?.baseIconButton, {
|
|
151
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.quickFilterClearIcon, {
|
|
152
|
+
fontSize: "small"
|
|
153
|
+
})
|
|
154
|
+
}))
|
|
155
|
+
},
|
|
156
|
+
inputProps: {
|
|
157
|
+
'aria-label': apiRef.current.getLocaleText('columnsManagementSearchTitle')
|
|
131
158
|
},
|
|
159
|
+
autoComplete: "off",
|
|
132
160
|
fullWidth: true
|
|
133
|
-
}, rootProps.slotProps?.baseTextField))
|
|
161
|
+
}, rootProps.slotProps?.baseTextField, searchInputProps))
|
|
134
162
|
}), /*#__PURE__*/_jsxs(GridColumnsManagementBody, {
|
|
135
163
|
className: classes.root,
|
|
136
164
|
ownerState: rootProps,
|
|
@@ -205,6 +233,7 @@ process.env.NODE_ENV !== "production" ? GridColumnsManagement.propTypes = {
|
|
|
205
233
|
* @returns {GridColDef['field'][]} The list of togglable columns' field names.
|
|
206
234
|
*/
|
|
207
235
|
getTogglableColumns: PropTypes.func,
|
|
236
|
+
searchInputProps: PropTypes.object,
|
|
208
237
|
searchPredicate: PropTypes.func,
|
|
209
238
|
sort: PropTypes.oneOf(['asc', 'desc']),
|
|
210
239
|
/**
|
|
@@ -239,6 +268,24 @@ const GridColumnsManagementHeader = styled('div', {
|
|
|
239
268
|
}) => ({
|
|
240
269
|
padding: theme.spacing(1.5, 3)
|
|
241
270
|
}));
|
|
271
|
+
const SearchInput = styled(TextField, {
|
|
272
|
+
name: 'MuiDataGrid',
|
|
273
|
+
slot: 'ColumnsManagementSearchInput',
|
|
274
|
+
overridesResolver: (props, styles) => styles.columnsManagementSearchInput
|
|
275
|
+
})(({
|
|
276
|
+
theme
|
|
277
|
+
}) => ({
|
|
278
|
+
[`& .${inputBaseClasses.root}`]: {
|
|
279
|
+
padding: theme.spacing(0, 1.5, 0, 1.5)
|
|
280
|
+
},
|
|
281
|
+
[`& .${inputBaseClasses.input}::-webkit-search-decoration,
|
|
282
|
+
& .${inputBaseClasses.input}::-webkit-search-cancel-button,
|
|
283
|
+
& .${inputBaseClasses.input}::-webkit-search-results-button,
|
|
284
|
+
& .${inputBaseClasses.input}::-webkit-search-results-decoration`]: {
|
|
285
|
+
/* clears the 'X' icon from Chrome */
|
|
286
|
+
display: 'none'
|
|
287
|
+
}
|
|
288
|
+
}));
|
|
242
289
|
const GridColumnsManagementFooter = styled('div', {
|
|
243
290
|
name: 'MuiDataGrid',
|
|
244
291
|
slot: 'ColumnsManagementFooter',
|
|
@@ -7,6 +7,15 @@ import { refType, unstable_useId as useId } from '@mui/utils';
|
|
|
7
7
|
import { styled } from '@mui/material/styles';
|
|
8
8
|
import { useGridRootProps } from "../../../hooks/utils/useGridRootProps.js";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
export const sanitizeFilterItemValue = value => {
|
|
11
|
+
if (String(value).toLowerCase() === 'true') {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (String(value).toLowerCase() === 'false') {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
};
|
|
10
19
|
const BooleanOperatorContainer = styled('div')({
|
|
11
20
|
display: 'flex',
|
|
12
21
|
alignItems: 'center',
|
|
@@ -27,7 +36,7 @@ function GridFilterInputBoolean(props) {
|
|
|
27
36
|
variant = 'standard'
|
|
28
37
|
} = props,
|
|
29
38
|
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
30
|
-
const [filterValueState, setFilterValueState] = React.useState(item.value
|
|
39
|
+
const [filterValueState, setFilterValueState] = React.useState(sanitizeFilterItemValue(item.value));
|
|
31
40
|
const rootProps = useGridRootProps();
|
|
32
41
|
const labelId = useId();
|
|
33
42
|
const selectId = useId();
|
|
@@ -35,14 +44,14 @@ function GridFilterInputBoolean(props) {
|
|
|
35
44
|
const isSelectNative = baseSelectProps.native ?? false;
|
|
36
45
|
const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
|
|
37
46
|
const onFilterChange = React.useCallback(event => {
|
|
38
|
-
const value = event.target.value;
|
|
47
|
+
const value = sanitizeFilterItemValue(event.target.value);
|
|
39
48
|
setFilterValueState(value);
|
|
40
49
|
applyValue(_extends({}, item, {
|
|
41
|
-
value
|
|
50
|
+
value
|
|
42
51
|
}));
|
|
43
52
|
}, [applyValue, item]);
|
|
44
53
|
React.useEffect(() => {
|
|
45
|
-
setFilterValueState(item.value
|
|
54
|
+
setFilterValueState(sanitizeFilterItemValue(item.value));
|
|
46
55
|
}, [item.value]);
|
|
47
56
|
const label = labelProp ?? apiRef.current.getLocaleText('filterPanelInputLabel');
|
|
48
57
|
return /*#__PURE__*/_jsxs(BooleanOperatorContainer, {
|
|
@@ -57,7 +66,7 @@ function GridFilterInputBoolean(props) {
|
|
|
57
66
|
labelId: labelId,
|
|
58
67
|
id: selectId,
|
|
59
68
|
label: label,
|
|
60
|
-
value: filterValueState,
|
|
69
|
+
value: filterValueState === undefined ? '' : String(filterValueState),
|
|
61
70
|
onChange: onFilterChange,
|
|
62
71
|
variant: variant,
|
|
63
72
|
notched: variant === 'outlined' ? true : undefined,
|
|
@@ -14,14 +14,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
const GridToolbar = /*#__PURE__*/React.forwardRef(function GridToolbar(props, ref) {
|
|
15
15
|
// TODO v7: think about where export option should be passed.
|
|
16
16
|
// from slotProps={{ toolbarExport: { ...exportOption } }} seems to be more appropriate
|
|
17
|
-
const
|
|
17
|
+
const _ref = props,
|
|
18
|
+
{
|
|
18
19
|
csvOptions,
|
|
19
20
|
printOptions,
|
|
20
21
|
excelOptions,
|
|
21
22
|
showQuickFilter = false,
|
|
22
23
|
quickFilterProps = {}
|
|
23
|
-
} =
|
|
24
|
-
other = _objectWithoutPropertiesLoose(
|
|
24
|
+
} = _ref,
|
|
25
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
26
|
const rootProps = useGridRootProps();
|
|
26
27
|
if (rootProps.disableColumnFilter && rootProps.disableColumnSelector && rootProps.disableDensitySelector && !showQuickFilter) {
|
|
27
28
|
return null;
|
|
@@ -32,7 +33,7 @@ const GridToolbar = /*#__PURE__*/React.forwardRef(function GridToolbar(props, re
|
|
|
32
33
|
children: [/*#__PURE__*/_jsx(GridToolbarColumnsButton, {}), /*#__PURE__*/_jsx(GridToolbarFilterButton, {}), /*#__PURE__*/_jsx(GridToolbarDensitySelector, {}), /*#__PURE__*/_jsx(GridToolbarExport, {
|
|
33
34
|
csvOptions: csvOptions,
|
|
34
35
|
printOptions: printOptions
|
|
35
|
-
//
|
|
36
|
+
// @ts-ignore
|
|
36
37
|
,
|
|
37
38
|
excelOptions: excelOptions
|
|
38
39
|
}), /*#__PURE__*/_jsx("div", {
|
|
@@ -47,6 +48,8 @@ process.env.NODE_ENV !== "production" ? GridToolbar.propTypes = {
|
|
|
47
48
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
48
49
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
49
50
|
// ----------------------------------------------------------------------
|
|
51
|
+
csvOptions: PropTypes.object,
|
|
52
|
+
printOptions: PropTypes.object,
|
|
50
53
|
/**
|
|
51
54
|
* Props passed to the quick filter component.
|
|
52
55
|
*/
|
|
@@ -56,6 +59,11 @@ process.env.NODE_ENV !== "production" ? GridToolbar.propTypes = {
|
|
|
56
59
|
* @default false
|
|
57
60
|
*/
|
|
58
61
|
showQuickFilter: PropTypes.bool,
|
|
62
|
+
/**
|
|
63
|
+
* The props used for each slot inside.
|
|
64
|
+
* @default {}
|
|
65
|
+
*/
|
|
66
|
+
slotProps: PropTypes.object,
|
|
59
67
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
60
68
|
} : void 0;
|
|
61
69
|
export { GridToolbar };
|
|
@@ -82,12 +82,13 @@ process.env.NODE_ENV !== "production" ? GridPrintExportMenuItem.propTypes = {
|
|
|
82
82
|
})
|
|
83
83
|
} : void 0;
|
|
84
84
|
const GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExport(props, ref) {
|
|
85
|
-
const
|
|
85
|
+
const _ref = props,
|
|
86
|
+
{
|
|
86
87
|
csvOptions = {},
|
|
87
88
|
printOptions = {},
|
|
88
89
|
excelOptions
|
|
89
|
-
} =
|
|
90
|
-
other = _objectWithoutPropertiesLoose(
|
|
90
|
+
} = _ref,
|
|
91
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded3);
|
|
91
92
|
const apiRef = useGridApiContext();
|
|
92
93
|
const preProcessedButtons = apiRef.current.unstable_applyPipeProcessors('exportMenu', [], {
|
|
93
94
|
excelOptions,
|
|
@@ -70,6 +70,9 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
70
70
|
const onScrollerScroll = useEventCallback(() => {
|
|
71
71
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
72
72
|
const scrollbar = scrollbarRef.current;
|
|
73
|
+
if (!scrollbar) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
73
76
|
if (scroller[propertyScroll] === lastPosition.current) {
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
@@ -85,6 +88,9 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
85
88
|
const onScrollbarScroll = useEventCallback(() => {
|
|
86
89
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
87
90
|
const scrollbar = scrollbarRef.current;
|
|
91
|
+
if (!scrollbar) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
88
94
|
if (isLocked.current) {
|
|
89
95
|
isLocked.current = false;
|
|
90
96
|
return;
|
|
@@ -2,4 +2,4 @@ import { unstable_generateUtilityClasses as generateUtilityClasses, unstable_gen
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--lastUnpinned', 'columnHeader--siblingFocused', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'groupingCriteriaCellLoadingContainer', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
5
|
+
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--lastUnpinned', 'columnHeader--siblingFocused', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementSearchInput', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'groupingCriteriaCellLoadingContainer', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -32,6 +32,7 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
32
32
|
columnsManagementNoColumns: 'No columns',
|
|
33
33
|
columnsManagementShowHideAllText: 'Show/Hide All',
|
|
34
34
|
columnsManagementReset: 'Reset',
|
|
35
|
+
columnsManagementDeleteIconLabel: 'Clear',
|
|
35
36
|
// Filter panel text
|
|
36
37
|
filterPanelAddFilter: 'Add filter',
|
|
37
38
|
filterPanelRemoveAll: 'Remove all',
|
|
@@ -291,7 +291,7 @@ export const useGridColumnHeaders = props => {
|
|
|
291
291
|
pinnedPosition: pinnedPosition,
|
|
292
292
|
style: style,
|
|
293
293
|
indexInSection: indexInSection,
|
|
294
|
-
sectionLength:
|
|
294
|
+
sectionLength: visibleColumnGroupHeader.length,
|
|
295
295
|
gridHasFiller: gridHasFiller
|
|
296
296
|
}, index);
|
|
297
297
|
});
|
|
@@ -241,26 +241,45 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
241
241
|
mode: GridCellModes.Edit
|
|
242
242
|
}, other));
|
|
243
243
|
}, [throwIfNotEditable, throwIfNotInMode, updateFieldInCellModesModel]);
|
|
244
|
-
const updateStateToStartCellEditMode = useEventCallback(params => {
|
|
244
|
+
const updateStateToStartCellEditMode = useEventCallback(async params => {
|
|
245
245
|
const {
|
|
246
246
|
id,
|
|
247
247
|
field,
|
|
248
248
|
deleteValue,
|
|
249
249
|
initialValue
|
|
250
250
|
} = params;
|
|
251
|
-
|
|
251
|
+
const value = apiRef.current.getCellValue(id, field);
|
|
252
|
+
let newValue = value;
|
|
252
253
|
if (deleteValue) {
|
|
253
254
|
newValue = getDefaultCellValue(apiRef.current.getColumn(field));
|
|
254
255
|
} else if (initialValue) {
|
|
255
256
|
newValue = initialValue;
|
|
256
257
|
}
|
|
257
|
-
const
|
|
258
|
+
const column = apiRef.current.getColumn(field);
|
|
259
|
+
const shouldProcessEditCellProps = !!column.preProcessEditCellProps && deleteValue;
|
|
260
|
+
let newProps = {
|
|
258
261
|
value: newValue,
|
|
259
262
|
error: false,
|
|
260
|
-
isProcessingProps:
|
|
263
|
+
isProcessingProps: shouldProcessEditCellProps
|
|
261
264
|
};
|
|
262
265
|
updateOrDeleteFieldState(id, field, newProps);
|
|
263
266
|
apiRef.current.setCellFocus(id, field);
|
|
267
|
+
if (shouldProcessEditCellProps) {
|
|
268
|
+
newProps = await Promise.resolve(column.preProcessEditCellProps({
|
|
269
|
+
id,
|
|
270
|
+
row: apiRef.current.getRow(id),
|
|
271
|
+
props: newProps,
|
|
272
|
+
hasChanged: newValue !== value
|
|
273
|
+
}));
|
|
274
|
+
// Check if still in edit mode before updating
|
|
275
|
+
if (apiRef.current.getCellMode(id, field) === GridCellModes.Edit) {
|
|
276
|
+
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
277
|
+
updateOrDeleteFieldState(id, field, _extends({}, newProps, {
|
|
278
|
+
value: editingState[id][field].value,
|
|
279
|
+
isProcessingProps: false
|
|
280
|
+
}));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
264
283
|
});
|
|
265
284
|
const stopCellEditMode = React.useCallback(params => {
|
|
266
285
|
const {
|
|
@@ -318,10 +318,11 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
318
318
|
if (!cellParams.isEditable) {
|
|
319
319
|
return acc;
|
|
320
320
|
}
|
|
321
|
+
const column = apiRef.current.getColumn(field);
|
|
321
322
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
322
323
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
323
324
|
if (deleteValue) {
|
|
324
|
-
newValue = getDefaultCellValue(
|
|
325
|
+
newValue = getDefaultCellValue(column);
|
|
325
326
|
} else if (initialValue) {
|
|
326
327
|
newValue = initialValue;
|
|
327
328
|
}
|
|
@@ -329,7 +330,7 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
329
330
|
acc[field] = {
|
|
330
331
|
value: newValue,
|
|
331
332
|
error: false,
|
|
332
|
-
isProcessingProps:
|
|
333
|
+
isProcessingProps: !!column.preProcessEditCellProps && deleteValue
|
|
333
334
|
};
|
|
334
335
|
return acc;
|
|
335
336
|
}, {});
|
|
@@ -337,6 +338,26 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
337
338
|
if (fieldToFocus) {
|
|
338
339
|
apiRef.current.setCellFocus(id, fieldToFocus);
|
|
339
340
|
}
|
|
341
|
+
columnFields.filter(field => !!apiRef.current.getColumn(field).preProcessEditCellProps && deleteValue).forEach(field => {
|
|
342
|
+
const column = apiRef.current.getColumn(field);
|
|
343
|
+
const value = apiRef.current.getCellValue(id, field);
|
|
344
|
+
const newValue = deleteValue ? getDefaultCellValue(column) : initialValue ?? value;
|
|
345
|
+
Promise.resolve(column.preProcessEditCellProps({
|
|
346
|
+
id,
|
|
347
|
+
row: apiRef.current.getRow(id),
|
|
348
|
+
props: newProps[field],
|
|
349
|
+
hasChanged: newValue !== value
|
|
350
|
+
})).then(processedProps => {
|
|
351
|
+
// Check if still in edit mode before updating
|
|
352
|
+
if (apiRef.current.getRowMode(id) === GridRowModes.Edit) {
|
|
353
|
+
const editingState = gridEditRowsStateSelector(apiRef.current.state);
|
|
354
|
+
updateOrDeleteFieldState(id, field, _extends({}, processedProps, {
|
|
355
|
+
value: editingState[id][field].value,
|
|
356
|
+
isProcessingProps: false
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
340
361
|
});
|
|
341
362
|
const stopRowEditMode = React.useCallback(params => {
|
|
342
363
|
const {
|
|
@@ -5,7 +5,7 @@ import { exportAs } from "../../../utils/exportAs.js";
|
|
|
5
5
|
import { buildCSV } from "./serializers/csvSerializer.js";
|
|
6
6
|
import { getColumnsToExport, defaultGetRowsToExport } from "./utils.js";
|
|
7
7
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
8
|
-
import { GridCsvExportMenuItem } from "../../../components/toolbar/
|
|
8
|
+
import { GridCsvExportMenuItem } from "../../../components/toolbar/index.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
/**
|
|
11
11
|
* @requires useGridColumns (state)
|
|
@@ -11,7 +11,7 @@ import { GRID_ID_AUTOGENERATED } from "../rows/gridRowsUtils.js";
|
|
|
11
11
|
import { defaultGetRowsToExport, getColumnsToExport } from "./utils.js";
|
|
12
12
|
import { getDerivedPaginationModel } from "../pagination/useGridPaginationModel.js";
|
|
13
13
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
14
|
-
import { GridPrintExportMenuItem } from "../../../components/toolbar/
|
|
14
|
+
import { GridPrintExportMenuItem } from "../../../components/toolbar/index.js";
|
|
15
15
|
import { getTotalHeaderHeight } from "../columns/gridColumnsUtils.js";
|
|
16
16
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../colDef/gridCheckboxSelectionColDef.js";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -75,7 +75,7 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
75
75
|
pagination: _extends({}, state.pagination, {
|
|
76
76
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, paginationModel)
|
|
77
77
|
})
|
|
78
|
-
}));
|
|
78
|
+
}), 'setPaginationModel');
|
|
79
79
|
}, [apiRef, logger, props.signature]);
|
|
80
80
|
const paginationModelApi = {
|
|
81
81
|
setPage,
|
|
@@ -113,7 +113,7 @@ export const useGridPaginationModel = (apiRef, props) => {
|
|
|
113
113
|
pagination: _extends({}, state.pagination, {
|
|
114
114
|
paginationModel: getDerivedPaginationModel(state.pagination, props.signature, paginationModel)
|
|
115
115
|
})
|
|
116
|
-
}));
|
|
116
|
+
}), 'stateRestorePreProcessing');
|
|
117
117
|
return params;
|
|
118
118
|
}, [apiRef, props.autoPageSize, props.signature]);
|
|
119
119
|
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
@@ -4,7 +4,7 @@ import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEve
|
|
|
4
4
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
5
5
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
6
6
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
7
|
-
import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
7
|
+
import { gridRowsLookupSelector, gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
8
8
|
import { gridRowSelectionStateSelector, selectedGridRowsSelector, selectedIdsLookupSelector } from "./gridRowSelectionSelector.js";
|
|
9
9
|
import { gridPaginatedVisibleSortedGridRowIdsSelector } from "../pagination/index.js";
|
|
10
10
|
import { gridFocusCellSelector } from "../focus/gridFocusStateSelector.js";
|
|
@@ -171,30 +171,33 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
171
171
|
let newSelection;
|
|
172
172
|
if (resetSelection) {
|
|
173
173
|
if (isSelected) {
|
|
174
|
-
newSelection = selectableIds;
|
|
174
|
+
newSelection = new Set(selectableIds);
|
|
175
175
|
if (applyAutoSelection) {
|
|
176
176
|
const addRow = rowId => {
|
|
177
|
-
newSelection.
|
|
177
|
+
newSelection.add(rowId);
|
|
178
178
|
};
|
|
179
179
|
selectableIds.forEach(id => {
|
|
180
180
|
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
} else {
|
|
184
|
-
newSelection =
|
|
184
|
+
newSelection = new Set();
|
|
185
|
+
}
|
|
186
|
+
const currentLookup = selectedIdsLookupSelector(apiRef);
|
|
187
|
+
if (newSelection.size === Object.keys(currentLookup).length && Array.from(newSelection).every(id => currentLookup[id] === id)) {
|
|
188
|
+
return;
|
|
185
189
|
}
|
|
186
190
|
} else {
|
|
187
|
-
|
|
188
|
-
const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
191
|
+
newSelection = new Set(Object.values(selectedIdsLookupSelector(apiRef)));
|
|
189
192
|
const addRow = rowId => {
|
|
190
|
-
|
|
193
|
+
newSelection.add(rowId);
|
|
191
194
|
};
|
|
192
195
|
const removeRow = rowId => {
|
|
193
|
-
delete
|
|
196
|
+
newSelection.delete(rowId);
|
|
194
197
|
};
|
|
195
198
|
selectableIds.forEach(id => {
|
|
196
199
|
if (isSelected) {
|
|
197
|
-
|
|
200
|
+
newSelection.add(id);
|
|
198
201
|
if (applyAutoSelection) {
|
|
199
202
|
findRowsToSelect(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
200
203
|
}
|
|
@@ -205,11 +208,10 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
});
|
|
208
|
-
newSelection = Object.values(selectionLookup);
|
|
209
211
|
}
|
|
210
|
-
const isSelectionValid = newSelection.
|
|
212
|
+
const isSelectionValid = newSelection.size < 2 || canHaveMultipleSelection;
|
|
211
213
|
if (isSelectionValid) {
|
|
212
|
-
apiRef.current.setRowSelectionModel(newSelection);
|
|
214
|
+
apiRef.current.setRowSelectionModel(Array.from(newSelection));
|
|
213
215
|
}
|
|
214
216
|
}, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents]);
|
|
215
217
|
const selectRowRange = React.useCallback(({
|
|
@@ -252,13 +254,20 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
252
254
|
return;
|
|
253
255
|
}
|
|
254
256
|
const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
|
|
257
|
+
const rowsLookup = gridRowsLookupSelector(apiRef);
|
|
255
258
|
const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
|
|
256
259
|
|
|
257
260
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
258
261
|
const selectionLookup = _extends({}, selectedIdsLookupSelector(apiRef));
|
|
262
|
+
const isNonExistent = id => {
|
|
263
|
+
if (props.filterMode === 'server') {
|
|
264
|
+
return !rowsLookup[id];
|
|
265
|
+
}
|
|
266
|
+
return filteredRowsLookup[id] !== true;
|
|
267
|
+
};
|
|
259
268
|
let hasChanged = false;
|
|
260
269
|
currentSelection.forEach(id => {
|
|
261
|
-
if (
|
|
270
|
+
if (isNonExistent(id)) {
|
|
262
271
|
if (props.keepNonExistentRowsSelected) {
|
|
263
272
|
return;
|
|
264
273
|
}
|
|
@@ -284,15 +293,20 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
284
293
|
}
|
|
285
294
|
}
|
|
286
295
|
});
|
|
287
|
-
|
|
296
|
+
|
|
297
|
+
// For nested data, on row tree updation (filtering, adding rows, etc.) when the selection is
|
|
298
|
+
// not empty, we need to re-run scanning of the tree to propagate the selection changes
|
|
299
|
+
// Example: A parent whose de-selected children are filtered out should now be selected
|
|
300
|
+
const shouldReapplyPropagation = isNestedData && props.rowSelectionPropagation?.parents && Object.keys(selectionLookup).length > 0;
|
|
301
|
+
if (hasChanged || shouldReapplyPropagation && !sortModelUpdated) {
|
|
288
302
|
const newSelection = Object.values(selectionLookup);
|
|
289
|
-
if (
|
|
303
|
+
if (shouldReapplyPropagation) {
|
|
290
304
|
apiRef.current.selectRows(newSelection, true, true);
|
|
291
305
|
} else {
|
|
292
306
|
apiRef.current.setRowSelectionModel(newSelection);
|
|
293
307
|
}
|
|
294
308
|
}
|
|
295
|
-
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, tree]);
|
|
309
|
+
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, props.filterMode, tree]);
|
|
296
310
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
297
311
|
const hasCtrlKey = event.metaKey || event.ctrlKey;
|
|
298
312
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { gridPinnedRowsSelector } from "./gridRowsSelector.js";
|
|
3
|
-
import { gridDimensionsSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
4
3
|
export const GRID_ROOT_GROUP_ID = `auto-generated-group-node-root`;
|
|
5
4
|
export const GRID_ID_AUTOGENERATED = Symbol('mui.id_autogenerated');
|
|
6
5
|
export const buildRootGroup = () => ({
|
|
@@ -285,10 +284,7 @@ export function calculatePinnedRowsHeight(apiRef) {
|
|
|
285
284
|
bottom: bottomPinnedRowsHeight
|
|
286
285
|
};
|
|
287
286
|
}
|
|
288
|
-
export
|
|
289
|
-
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
290
|
-
return `var(--DataGrid-overlayHeight, ${2 * dimensions.rowHeight}px)`;
|
|
291
|
-
}
|
|
287
|
+
export const minimalContentHeight = 'var(--DataGrid-overlayHeight, calc(var(--height) * 2))';
|
|
292
288
|
export function computeRowsUpdates(apiRef, updates, getRowId) {
|
|
293
289
|
const nonPinnedRowsUpdates = [];
|
|
294
290
|
updates.forEach(update => {
|
|
@@ -21,11 +21,11 @@ import { clamp, range } from "../../../utils/utils.js";
|
|
|
21
21
|
import { selectedIdsLookupSelector } from "../rowSelection/gridRowSelectionSelector.js";
|
|
22
22
|
import { gridRowsMetaSelector } from "../rows/gridRowsMetaSelector.js";
|
|
23
23
|
import { getFirstNonSpannedColumnToRender } from "../columns/gridColumnsUtils.js";
|
|
24
|
-
import { getMinimalContentHeight } from "../rows/gridRowsUtils.js";
|
|
25
24
|
import { gridRenderContextSelector, gridVirtualizationRowEnabledSelector, gridVirtualizationColumnEnabledSelector } from "./gridVirtualizationSelectors.js";
|
|
26
25
|
import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
|
|
27
26
|
import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
|
|
28
27
|
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
28
|
+
import { minimalContentHeight } from "../rows/gridRowsUtils.js";
|
|
29
29
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
30
|
const MINIMUM_COLUMN_WIDTH = 50;
|
|
31
31
|
var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
|
|
@@ -381,11 +381,11 @@ export const useGridVirtualScroller = () => {
|
|
|
381
381
|
flexBasis: contentHeight,
|
|
382
382
|
flexShrink: 0
|
|
383
383
|
};
|
|
384
|
-
if (
|
|
385
|
-
size.flexBasis =
|
|
384
|
+
if (size.flexBasis === 0) {
|
|
385
|
+
size.flexBasis = minimalContentHeight; // Give room to show the overlay when there no rows.
|
|
386
386
|
}
|
|
387
387
|
return size;
|
|
388
|
-
}, [
|
|
388
|
+
}, [columnsTotalWidth, contentHeight, needsHorizontalScrollbar]);
|
|
389
389
|
React.useEffect(() => {
|
|
390
390
|
apiRef.current.publishEvent('virtualScrollerContentSizeChange');
|
|
391
391
|
}, [apiRef, contentSize]);
|
|
@@ -23,10 +23,26 @@ function applySelectorV8(apiRef, selector, args, instanceId) {
|
|
|
23
23
|
}
|
|
24
24
|
const defaultCompare = Object.is;
|
|
25
25
|
export const objectShallowCompare = fastObjectShallowCompare;
|
|
26
|
+
const arrayShallowCompare = (a, b) => {
|
|
27
|
+
if (a === b) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
31
|
+
};
|
|
32
|
+
export const argsEqual = (prev, curr) => {
|
|
33
|
+
let fn = Object.is;
|
|
34
|
+
if (curr instanceof Array) {
|
|
35
|
+
fn = arrayShallowCompare;
|
|
36
|
+
} else if (curr instanceof Object) {
|
|
37
|
+
fn = objectShallowCompare;
|
|
38
|
+
}
|
|
39
|
+
return fn(prev, curr);
|
|
40
|
+
};
|
|
26
41
|
const createRefs = () => ({
|
|
27
42
|
state: null,
|
|
28
43
|
equals: null,
|
|
29
|
-
selector: null
|
|
44
|
+
selector: null,
|
|
45
|
+
args: null
|
|
30
46
|
});
|
|
31
47
|
|
|
32
48
|
// TODO v8: Remove this function
|
|
@@ -71,9 +87,18 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
|
|
|
71
87
|
refs.current.state = state;
|
|
72
88
|
refs.current.equals = equals;
|
|
73
89
|
refs.current.selector = selector;
|
|
90
|
+
const prevArgs = refs.current.args;
|
|
91
|
+
refs.current.args = args;
|
|
92
|
+
if (didInit && !argsEqual(prevArgs, args)) {
|
|
93
|
+
const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
94
|
+
if (!refs.current.equals(refs.current.state, newState)) {
|
|
95
|
+
refs.current.state = newState;
|
|
96
|
+
setState(newState);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
74
99
|
useOnMount(() => {
|
|
75
100
|
return apiRef.current.store.subscribe(() => {
|
|
76
|
-
const newState = applySelectorV8(apiRef, refs.current.selector, args, apiRef.current.instanceId);
|
|
101
|
+
const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
77
102
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
78
103
|
refs.current.state = newState;
|
|
79
104
|
setState(newState);
|