@mui/x-data-grid 6.0.4 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/components/GridAutoSizer.js +3 -0
  3. package/components/GridPagination.d.ts +6 -6
  4. package/components/GridRow.js +3 -1
  5. package/components/cell/GridActionsCellItem.d.ts +2 -2
  6. package/components/cell/GridEditDateCell.js +37 -16
  7. package/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  8. package/components/panel/GridColumnsPanel.d.ts +8 -0
  9. package/components/panel/GridColumnsPanel.js +18 -6
  10. package/components/panel/GridPanel.d.ts +1 -1
  11. package/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  12. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  13. package/components/toolbar/GridToolbarColumnsButton.d.ts +1 -1
  14. package/components/toolbar/GridToolbarDensitySelector.d.ts +1 -1
  15. package/components/toolbar/GridToolbarExportContainer.d.ts +1 -1
  16. package/hooks/core/useGridApiInitialization.js +3 -3
  17. package/hooks/features/columns/gridColumnsSelector.d.ts +3 -3
  18. package/hooks/features/editing/useGridCellEditing.js +5 -1
  19. package/hooks/features/editing/useGridEditing.js +1 -3
  20. package/hooks/features/editing/useGridRowEditing.js +5 -1
  21. package/hooks/features/filter/gridFilterState.js +6 -1
  22. package/hooks/features/filter/useGridFilter.js +5 -0
  23. package/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  24. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +36 -16
  25. package/index.js +9 -1
  26. package/legacy/components/GridAutoSizer.js +3 -0
  27. package/legacy/components/GridRow.js +4 -1
  28. package/legacy/components/cell/GridEditBooleanCell.js +19 -21
  29. package/legacy/components/cell/GridEditDateCell.js +69 -39
  30. package/legacy/components/cell/GridEditInputCell.js +25 -27
  31. package/legacy/components/cell/GridEditSingleSelectCell.js +26 -28
  32. package/legacy/components/columnHeaders/ColumnHeaderMenuIcon.js +20 -16
  33. package/legacy/components/panel/GridColumnsPanel.js +19 -6
  34. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +37 -29
  35. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +34 -30
  36. package/legacy/hooks/core/useGridApiInitialization.js +3 -3
  37. package/legacy/hooks/features/columns/gridColumnsUtils.js +2 -2
  38. package/legacy/hooks/features/editing/useGridCellEditing.js +120 -120
  39. package/legacy/hooks/features/editing/useGridEditing.js +17 -21
  40. package/legacy/hooks/features/editing/useGridRowEditing.js +5 -1
  41. package/legacy/hooks/features/export/useGridPrintExport.js +45 -47
  42. package/legacy/hooks/features/filter/gridFilterState.js +6 -1
  43. package/legacy/hooks/features/filter/useGridFilter.js +5 -0
  44. package/legacy/hooks/features/rowSelection/useGridRowSelection.js +5 -24
  45. package/legacy/hooks/features/rows/gridRowsUtils.js +2 -2
  46. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +6 -6
  47. package/legacy/index.js +9 -1
  48. package/legacy/locales/coreLocales.js +0 -1
  49. package/legacy/locales/frFR.js +7 -9
  50. package/legacy/locales/huHU.js +15 -20
  51. package/legacy/locales/jaJP.js +1 -1
  52. package/legacy/locales/nlNL.js +3 -3
  53. package/legacy/locales/ptBR.js +7 -9
  54. package/legacy/locales/ruRU.js +1 -1
  55. package/legacy/locales/urPK.js +6 -6
  56. package/legacy/models/gridColumnGrouping.js +4 -0
  57. package/legacy/models/params/gridRowParams.js +8 -0
  58. package/legacy/utils/createSelector.js +14 -22
  59. package/legacy/utils/utils.js +1 -1
  60. package/locales/coreLocales.js +0 -1
  61. package/locales/frFR.js +7 -9
  62. package/locales/huHU.js +15 -20
  63. package/locales/jaJP.js +1 -1
  64. package/locales/nlNL.js +3 -3
  65. package/locales/ptBR.js +7 -9
  66. package/locales/ruRU.js +1 -1
  67. package/locales/urPK.js +6 -6
  68. package/models/api/gridCoreApi.d.ts +3 -1
  69. package/models/api/gridEditingApi.d.ts +4 -0
  70. package/models/gridColumnGrouping.js +4 -0
  71. package/models/params/gridRowParams.js +8 -0
  72. package/modern/components/GridAutoSizer.js +3 -0
  73. package/modern/components/GridRow.js +3 -1
  74. package/modern/components/cell/GridEditDateCell.js +37 -16
  75. package/modern/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  76. package/modern/components/panel/GridColumnsPanel.js +18 -6
  77. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  78. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +33 -29
  79. package/modern/hooks/core/useGridApiInitialization.js +3 -3
  80. package/modern/hooks/features/editing/useGridCellEditing.js +5 -1
  81. package/modern/hooks/features/editing/useGridEditing.js +1 -3
  82. package/modern/hooks/features/editing/useGridRowEditing.js +5 -1
  83. package/modern/hooks/features/filter/gridFilterState.js +6 -1
  84. package/modern/hooks/features/filter/useGridFilter.js +5 -0
  85. package/modern/hooks/features/rowSelection/useGridRowSelection.js +5 -26
  86. package/modern/index.js +9 -1
  87. package/modern/locales/coreLocales.js +0 -1
  88. package/modern/locales/frFR.js +7 -9
  89. package/modern/locales/huHU.js +15 -20
  90. package/modern/locales/jaJP.js +1 -1
  91. package/modern/locales/nlNL.js +3 -3
  92. package/modern/locales/ptBR.js +7 -9
  93. package/modern/locales/ruRU.js +1 -1
  94. package/modern/locales/urPK.js +6 -6
  95. package/modern/models/gridColumnGrouping.js +4 -0
  96. package/modern/models/params/gridRowParams.js +8 -0
  97. package/modern/utils/createSelector.js +12 -22
  98. package/modern/utils/utils.js +1 -1
  99. package/node/components/GridAutoSizer.js +3 -1
  100. package/node/components/GridRow.js +3 -1
  101. package/node/components/cell/GridCell.js +1 -0
  102. package/node/components/cell/GridEditDateCell.js +37 -16
  103. package/node/components/columnHeaders/ColumnHeaderMenuIcon.js +19 -15
  104. package/node/components/panel/GridColumnsPanel.js +18 -6
  105. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +36 -28
  106. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +32 -29
  107. package/node/hooks/core/useGridApiInitialization.js +3 -3
  108. package/node/hooks/features/editing/useGridCellEditing.js +5 -1
  109. package/node/hooks/features/editing/useGridEditing.js +1 -3
  110. package/node/hooks/features/editing/useGridRowEditing.js +5 -1
  111. package/node/hooks/features/filter/gridFilterState.js +5 -0
  112. package/node/hooks/features/filter/useGridFilter.js +5 -0
  113. package/node/hooks/features/rowSelection/useGridRowSelection.js +4 -25
  114. package/node/index.js +1 -1
  115. package/node/locales/frFR.js +7 -9
  116. package/node/locales/huHU.js +15 -20
  117. package/node/locales/jaJP.js +1 -1
  118. package/node/locales/nlNL.js +3 -3
  119. package/node/locales/ptBR.js +7 -9
  120. package/node/locales/ruRU.js +1 -1
  121. package/node/locales/urPK.js +6 -6
  122. package/node/models/gridColumnGrouping.js +4 -0
  123. package/node/models/params/gridEditCellParams.js +1 -0
  124. package/node/models/params/gridRowParams.js +9 -0
  125. package/node/utils/createSelector.js +12 -22
  126. package/node/utils/utils.js +1 -1
  127. package/package.json +1 -1
  128. package/utils/createSelector.d.ts +4 -4
  129. package/utils/createSelector.js +14 -22
  130. package/utils/utils.d.ts +1 -1
  131. package/utils/utils.js +1 -1
@@ -37,22 +37,26 @@ export const ColumnHeaderMenuIcon = /*#__PURE__*/React.memo(props => {
37
37
  }, [apiRef, colDef.field]);
38
38
  return /*#__PURE__*/_jsx("div", {
39
39
  className: classes.root,
40
- children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
41
- ref: iconButtonRef,
42
- tabIndex: -1,
43
- className: classes.button,
44
- "aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
40
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, _extends({
45
41
  title: apiRef.current.getLocaleText('columnMenuLabel'),
46
- size: "small",
47
- onClick: handleMenuIconClick,
48
- "aria-expanded": open ? 'true' : undefined,
49
- "aria-haspopup": "true",
50
- "aria-controls": columnMenuId,
51
- id: columnMenuButtonId
52
- }, rootProps.slotProps?.baseIconButton, {
53
- children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuIcon, {
54
- fontSize: "small"
55
- })
42
+ enterDelay: 1000
43
+ }, rootProps.slotProps?.baseTooltip, {
44
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
45
+ ref: iconButtonRef,
46
+ tabIndex: -1,
47
+ className: classes.button,
48
+ "aria-label": apiRef.current.getLocaleText('columnMenuLabel'),
49
+ size: "small",
50
+ onClick: handleMenuIconClick,
51
+ "aria-expanded": open ? 'true' : undefined,
52
+ "aria-haspopup": "true",
53
+ "aria-controls": columnMenuId,
54
+ id: columnMenuButtonId
55
+ }, rootProps.slotProps?.baseIconButton, {
56
+ children: /*#__PURE__*/_jsx(rootProps.slots.columnMenuIcon, {
57
+ fontSize: "small"
58
+ })
59
+ }))
56
60
  }))
57
61
  });
58
62
  });
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton"];
3
+ const _excluded = ["sort", "searchPredicate", "autoFocusSearchField", "disableHideAllButton", "disableShowAllButton", "getTogglableColumns"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
@@ -71,7 +71,8 @@ function GridColumnsPanel(props) {
71
71
  searchPredicate = defaultSearchPredicate,
72
72
  autoFocusSearchField = true,
73
73
  disableHideAllButton = false,
74
- disableShowAllButton = false
74
+ disableShowAllButton = false,
75
+ getTogglableColumns
75
76
  } = props,
76
77
  other = _objectWithoutPropertiesLoose(props, _excluded);
77
78
  const sortedColumns = React.useMemo(() => {
@@ -109,12 +110,15 @@ function GridColumnsPanel(props) {
109
110
  setSearchValue(event.target.value);
110
111
  }, []);
111
112
  const currentColumns = React.useMemo(() => {
113
+ const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
114
+ const togglableSortedColumns = togglableColumns ? sortedColumns.filter(({
115
+ field
116
+ }) => togglableColumns.includes(field)) : sortedColumns;
112
117
  if (!searchValue) {
113
- return sortedColumns;
118
+ return togglableSortedColumns;
114
119
  }
115
- const searchValueToCheck = searchValue.toLowerCase();
116
- return sortedColumns.filter(column => searchPredicate(column, searchValueToCheck));
117
- }, [sortedColumns, searchValue, searchPredicate]);
120
+ return togglableSortedColumns.filter(column => searchPredicate(column, searchValue.toLowerCase()));
121
+ }, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]);
118
122
  const firstSwitchRef = React.useRef(null);
119
123
  React.useEffect(() => {
120
124
  if (autoFocusSearchField) {
@@ -192,6 +196,14 @@ process.env.NODE_ENV !== "production" ? GridColumnsPanel.propTypes = {
192
196
  autoFocusSearchField: PropTypes.bool,
193
197
  disableHideAllButton: PropTypes.bool,
194
198
  disableShowAllButton: PropTypes.bool,
199
+ /**
200
+ * Returns the list of togglable columns.
201
+ * If used, only those columns will be displayed in the panel
202
+ * which are passed as the return value of the function.
203
+ * @param {GridColDef[]} columns The `ColDef` list of all columns.
204
+ * @returns {GridColDef['field'][]} The list of togglable columns' field names.
205
+ */
206
+ getTogglableColumns: PropTypes.func,
195
207
  searchPredicate: PropTypes.func,
196
208
  slotProps: PropTypes.object,
197
209
  sort: PropTypes.oneOf(['asc', 'desc'])
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["item", "applyValue", "apiRef", "focusElementRef"];
4
4
  import * as React from 'react';
5
+ import { unstable_useId as useId } from '@mui/utils';
5
6
  import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
6
7
  import { jsx as _jsx } from "react/jsx-runtime";
7
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -15,6 +16,8 @@ export function GridFilterInputBoolean(props) {
15
16
  others = _objectWithoutPropertiesLoose(props, _excluded);
16
17
  const [filterValueState, setFilterValueState] = React.useState(item.value || '');
17
18
  const rootProps = useGridRootProps();
19
+ const labelId = useId();
20
+ const selectId = useId();
18
21
  const baseSelectProps = rootProps.slotProps?.baseSelect || {};
19
22
  const isSelectNative = baseSelectProps.native ?? true;
20
23
  const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
@@ -28,34 +31,39 @@ export function GridFilterInputBoolean(props) {
28
31
  React.useEffect(() => {
29
32
  setFilterValueState(item.value || '');
30
33
  }, [item.value]);
31
- return /*#__PURE__*/_jsxs(rootProps.slots.baseTextField, _extends({
32
- // TODO: use baseSelect slot
33
- label: apiRef.current.getLocaleText('filterPanelInputLabel'),
34
- value: filterValueState,
35
- onChange: onFilterChange,
36
- select: true,
37
- variant: "standard",
38
- SelectProps: _extends({
34
+ const label = apiRef.current.getLocaleText('filterPanelInputLabel');
35
+ return /*#__PURE__*/_jsxs(React.Fragment, {
36
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, rootProps.slotProps?.baseInputLabel, {
37
+ id: labelId,
38
+ shrink: true,
39
+ variant: "standard",
40
+ children: label
41
+ })), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, _extends({
42
+ labelId: labelId,
43
+ id: selectId,
44
+ label: label,
45
+ value: filterValueState,
46
+ onChange: onFilterChange,
47
+ variant: "standard",
39
48
  native: isSelectNative,
40
- displayEmpty: true
41
- }, rootProps.slotProps?.baseSelect),
42
- InputLabelProps: {
43
- shrink: true
44
- },
45
- inputRef: focusElementRef
46
- }, others, rootProps.slotProps?.baseTextField, {
47
- children: [/*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
48
- native: isSelectNative,
49
- value: "",
50
- children: apiRef.current.getLocaleText('filterValueAny')
51
- })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
52
- native: isSelectNative,
53
- value: "true",
54
- children: apiRef.current.getLocaleText('filterValueTrue')
55
- })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
56
- native: isSelectNative,
57
- value: "false",
58
- children: apiRef.current.getLocaleText('filterValueFalse')
49
+ displayEmpty: true,
50
+ inputProps: {
51
+ ref: focusElementRef
52
+ }
53
+ }, others, baseSelectProps, {
54
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
55
+ native: isSelectNative,
56
+ value: "",
57
+ children: apiRef.current.getLocaleText('filterValueAny')
58
+ })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
59
+ native: isSelectNative,
60
+ value: "true",
61
+ children: apiRef.current.getLocaleText('filterValueTrue')
62
+ })), /*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
63
+ native: isSelectNative,
64
+ value: "false",
65
+ children: apiRef.current.getLocaleText('filterValueFalse')
66
+ }))]
59
67
  }))]
60
- }));
68
+ });
61
69
  }
@@ -8,6 +8,7 @@ import { useGridRootProps } from '../../../hooks/utils/useGridRootProps';
8
8
  import { getValueFromValueOptions, isSingleSelectColDef } from './filterPanelUtils';
9
9
  import { createElement as _createElement } from "react";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const renderSingleSelectOptions = ({
12
13
  column: {
13
14
  valueOptions,
@@ -45,10 +46,9 @@ function GridFilterInputSingleSelect(props) {
45
46
  others = _objectWithoutPropertiesLoose(props, _excluded);
46
47
  const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
47
48
  const id = useId();
49
+ const labelId = useId();
48
50
  const rootProps = useGridRootProps();
49
- const baseSelectProps = rootProps.slotProps?.baseSelect || {};
50
- const isSelectNative = baseSelectProps.native ?? true;
51
- const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
51
+ const isSelectNative = rootProps.slotProps?.baseSelect?.native ?? true;
52
52
  let resolvedColumn = null;
53
53
  if (item.field) {
54
54
  const column = apiRef.current.getColumn(item.field);
@@ -99,33 +99,37 @@ function GridFilterInputSingleSelect(props) {
99
99
  if (!isSingleSelectColDef(resolvedColumn)) {
100
100
  return null;
101
101
  }
102
- return /*#__PURE__*/_jsx(rootProps.slots.baseTextField, _extends({
103
- // TODO: use baseSelect slot
104
- id: id,
105
- label: apiRef.current.getLocaleText('filterPanelInputLabel'),
106
- placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
107
- value: filterValueState,
108
- onChange: onFilterChange,
109
- variant: "standard",
110
- type: type || 'text',
111
- InputLabelProps: {
112
- shrink: true
113
- },
114
- inputRef: focusElementRef,
115
- select: true,
116
- SelectProps: _extends({
102
+ const label = apiRef.current.getLocaleText('filterPanelInputLabel');
103
+ return /*#__PURE__*/_jsxs(React.Fragment, {
104
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, rootProps.slotProps?.baseInputLabel, {
105
+ id: labelId,
106
+ shrink: true,
107
+ variant: "standard",
108
+ children: label
109
+ })), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
110
+ id: id,
111
+ label: label,
112
+ labelId: labelId,
113
+ value: filterValueState,
114
+ onChange: onFilterChange,
115
+ variant: "standard",
116
+ type: type || 'text',
117
+ inputProps: {
118
+ ref: focusElementRef,
119
+ placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder')
120
+ },
117
121
  native: isSelectNative
118
- }, rootProps.slotProps?.baseSelect)
119
- }, others, rootProps.slotProps?.baseTextField, {
120
- children: renderSingleSelectOptions({
121
- column: resolvedColumn,
122
- OptionComponent: rootProps.slots.baseSelectOption,
123
- getOptionLabel,
124
- getOptionValue,
125
- isSelectNative,
126
- baseSelectOptionProps
127
- })
128
- }));
122
+ }, others, rootProps.slotProps?.baseSelect, {
123
+ children: renderSingleSelectOptions({
124
+ column: resolvedColumn,
125
+ OptionComponent: rootProps.slots.baseSelectOption,
126
+ getOptionLabel,
127
+ getOptionValue,
128
+ isSelectNative,
129
+ baseSelectOptionProps: rootProps.slotProps?.baseSelectOption
130
+ })
131
+ }))]
132
+ });
129
133
  }
130
134
  process.env.NODE_ENV !== "production" ? GridFilterInputSingleSelect.propTypes = {
131
135
  // ----------------------------- Warning --------------------------------
@@ -2,7 +2,6 @@ import * as React from 'react';
2
2
  import { useGridApiMethod } from '../utils/useGridApiMethod';
3
3
  import { GridSignature } from '../utils/useGridApiEventHandler';
4
4
  import { EventManager } from '../../utils/EventManager';
5
- import { unstable_resetCreateSelectorCache } from '../../utils/createSelector';
6
5
  const isSyntheticEvent = event => {
7
6
  return event.isPropagationStopped !== undefined;
8
7
  };
@@ -38,7 +37,9 @@ export function useGridApiInitialization(inputApiRef, props) {
38
37
  if (!publicApiRef.current) {
39
38
  publicApiRef.current = {
40
39
  state: {},
41
- instanceId: globalId
40
+ instanceId: {
41
+ id: globalId
42
+ }
42
43
  };
43
44
  globalId += 1;
44
45
  }
@@ -76,7 +77,6 @@ export function useGridApiInitialization(inputApiRef, props) {
76
77
  React.useEffect(() => {
77
78
  const api = privateApiRef.current;
78
79
  return () => {
79
- unstable_resetCreateSelectorCache(api.instanceId);
80
80
  api.publishEvent('unmount');
81
81
  };
82
82
  }, [privateApiRef]);
@@ -242,13 +242,17 @@ export const useGridCellEditing = (apiRef, props) => {
242
242
  initialValue
243
243
  } = params;
244
244
  let newValue = apiRef.current.getCellValue(id, field);
245
+ // eslint-disable-next-line @typescript-eslint/naming-convention
246
+ let unstable_updateValueOnRender = false;
245
247
  if (deleteValue || initialValue) {
246
248
  newValue = deleteValue ? '' : initialValue;
249
+ unstable_updateValueOnRender = true;
247
250
  }
248
251
  const newProps = {
249
252
  value: newValue,
250
253
  error: false,
251
- isProcessingProps: false
254
+ isProcessingProps: false,
255
+ unstable_updateValueOnRender
252
256
  };
253
257
  updateOrDeleteFieldState(id, field, newProps);
254
258
  apiRef.current.setCellFocus(id, field);
@@ -110,9 +110,7 @@ export const useGridEditing = (apiRef, props) => {
110
110
  }, [apiRef, props.editMode]);
111
111
  const getEditCellMeta = React.useCallback((id, field) => {
112
112
  const editingState = gridEditRowsStateSelector(apiRef.current.state);
113
- return {
114
- changeReason: editingState[id][field].changeReason
115
- };
113
+ return editingState[id][field];
116
114
  }, [apiRef]);
117
115
  const editingSharedApi = {
118
116
  isCellEditable,
@@ -310,13 +310,17 @@ export const useGridRowEditing = (apiRef, props) => {
310
310
  return acc;
311
311
  }
312
312
  let newValue = apiRef.current.getCellValue(id, field);
313
+ // eslint-disable-next-line @typescript-eslint/naming-convention
314
+ let unstable_updateValueOnRender = false;
313
315
  if (fieldToFocus === field && (deleteValue || initialValue)) {
314
316
  newValue = deleteValue ? '' : initialValue;
317
+ unstable_updateValueOnRender = true;
315
318
  }
316
319
  acc[field] = {
317
320
  value: newValue,
318
321
  error: false,
319
- isProcessingProps: false
322
+ isProcessingProps: false,
323
+ unstable_updateValueOnRender
320
324
  };
321
325
  return acc;
322
326
  }, {});
@@ -4,4 +4,9 @@ export const getDefaultGridFilterModel = () => ({
4
4
  logicOperator: GridLogicOperator.And,
5
5
  quickFilterValues: [],
6
6
  quickFilterLogicOperator: GridLogicOperator.And
7
- });
7
+ });
8
+
9
+ /**
10
+ * @param {GridRowId} rowId The id of the row we want to filter.
11
+ * @param {(filterItem: GridFilterItem) => boolean} shouldApplyItem An optional callback to allow the filtering engine to only apply some items.
12
+ */
@@ -111,6 +111,11 @@ export const useGridFilter = (apiRef, props) => {
111
111
  const filterModel = gridFilterModelSelector(apiRef);
112
112
  const filterItemsWithValue = filterModel.items.filter(item => {
113
113
  if (item.value !== undefined) {
114
+ // Some filters like `isAnyOf` support array as `item.value`.
115
+ // If array is empty, we want to remove it from the filter model.
116
+ if (Array.isArray(item.value) && item.value.length === 0) {
117
+ return false;
118
+ }
114
119
  return true;
115
120
  }
116
121
  const column = apiRef.current.getColumn(item.field);
@@ -11,7 +11,7 @@ import { gridExpandedSortedRowIdsSelector } from '../filter/gridFilterSelector';
11
11
  import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
12
12
  import { GridCellModes } from '../../../models/gridEditRowModel';
13
13
  import { isKeyboardEvent, isNavigationKey } from '../../../utils/keyboardUtils';
14
- import { getVisibleRows, useGridVisibleRows } from '../../utils/useGridVisibleRows';
14
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
15
15
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
16
16
  import { gridClasses } from '../../../constants/gridClasses';
17
17
  const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
@@ -58,8 +58,6 @@ export const useGridRowSelection = (apiRef, props) => {
58
58
  checkboxSelection,
59
59
  disableMultipleRowSelection,
60
60
  disableRowSelectionOnClick,
61
- pagination,
62
- paginationMode,
63
61
  isRowSelectable: propIsRowSelectable
64
62
  } = props;
65
63
  const canHaveMultipleSelection = !disableMultipleRowSelection || checkboxSelection;
@@ -375,32 +373,13 @@ export const useGridRowSelection = (apiRef, props) => {
375
373
  }
376
374
  }, [apiRef, isRowSelectable, isStateControlled, props.rowSelection]);
377
375
  React.useEffect(() => {
378
- if (!props.rowSelection) {
376
+ if (!props.rowSelection || isStateControlled) {
379
377
  return;
380
378
  }
381
379
  const currentSelection = gridRowSelectionStateSelector(apiRef.current.state);
382
380
  if (!canHaveMultipleSelection && currentSelection.length > 1) {
383
- const {
384
- rows: currentPageRows
385
- } = getVisibleRows(apiRef, {
386
- pagination,
387
- paginationMode
388
- });
389
- const currentPageRowsLookup = currentPageRows.reduce((acc, {
390
- id
391
- }) => {
392
- acc[id] = true;
393
- return acc;
394
- }, {});
395
- const firstSelectableRow = currentSelection.find(id => {
396
- let isSelectable = true;
397
- if (isRowSelectable) {
398
- isSelectable = isRowSelectable(id);
399
- }
400
- return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
401
- });
402
-
403
- apiRef.current.setRowSelectionModel(firstSelectableRow !== undefined ? [firstSelectableRow] : []);
381
+ // See https://github.com/mui/mui-x/issues/8455
382
+ apiRef.current.setRowSelectionModel([]);
404
383
  }
405
- }, [apiRef, canHaveMultipleSelection, checkboxSelection, disableMultipleRowSelection, isRowSelectable, pagination, paginationMode, props.rowSelection]);
384
+ }, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
406
385
  };
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.0.4
2
+ * @mui/x-data-grid v6.2.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -28,4 +28,12 @@ export { GridColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS } f
28
28
  * The full grid API.
29
29
  * @demos
30
30
  * - [API object](/x/react-data-grid/api-object/)
31
+ */
32
+
33
+ /**
34
+ * The state of `DataGrid`.
35
+ */
36
+
37
+ /**
38
+ * The initial state of `DataGrid`.
31
39
  */
@@ -3,7 +3,6 @@
3
3
  // This allows not to bump the minimal version of `@mui/material` in peerDependencies which results
4
4
  // in broader compatibility between the packages.
5
5
  // See https://github.com/mui/mui-x/pull/7646#issuecomment-1404605556 for additional context.
6
-
7
6
  export const beBYCore = {
8
7
  components: {
9
8
  MuiTablePagination: {
@@ -111,15 +111,13 @@ const frFRGrid = {
111
111
  expandDetailPanel: 'Afficher',
112
112
  collapseDetailPanel: 'Masquer',
113
113
  // Row reordering text
114
- rowReorderingHeaderName: 'Positionnement des lignes'
115
-
114
+ rowReorderingHeaderName: 'Positionnement des lignes',
116
115
  // Aggregation
117
- // aggregationMenuItemHeader: 'Aggregation',
118
- // aggregationFunctionLabelSum: 'sum',
119
- // aggregationFunctionLabelAvg: 'avg',
120
- // aggregationFunctionLabelMin: 'min',
121
- // aggregationFunctionLabelMax: 'max',
122
- // aggregationFunctionLabelSize: 'size',
116
+ aggregationMenuItemHeader: 'Agrégation',
117
+ aggregationFunctionLabelSum: 'Somme',
118
+ aggregationFunctionLabelAvg: 'Moyenne',
119
+ aggregationFunctionLabelMin: 'Minimum',
120
+ aggregationFunctionLabelMax: 'Maximum',
121
+ aggregationFunctionLabelSize: "Nombre d'éléments"
123
122
  };
124
-
125
123
  export const frFR = getGridLocalization(frFRGrid, frFRCore);
@@ -20,17 +20,15 @@ const huHUGrid = {
20
20
  toolbarFiltersTooltipShow: 'Szűrők megjelenítése',
21
21
  toolbarFiltersTooltipActive: count => `${count} aktív szűrő`,
22
22
  // Quick filter toolbar field
23
- // toolbarQuickFilterPlaceholder: 'Search…',
24
- // toolbarQuickFilterLabel: 'Search',
25
- // toolbarQuickFilterDeleteIconLabel: 'Clear',
26
-
23
+ toolbarQuickFilterPlaceholder: 'Keresés…',
24
+ toolbarQuickFilterLabel: 'Keresés',
25
+ toolbarQuickFilterDeleteIconLabel: 'Törlés',
27
26
  // Export selector toolbar button text
28
27
  toolbarExport: 'Exportálás',
29
28
  toolbarExportLabel: 'Exportálás',
30
29
  toolbarExportCSV: 'Mentés CSV fájlként',
31
30
  toolbarExportPrint: 'Nyomtatás',
32
- // toolbarExportExcel: 'Download as Excel',
33
-
31
+ toolbarExportExcel: 'Mentés Excel fájlként',
34
32
  // Columns panel text
35
33
  columnsPanelTextFieldLabel: 'Oszlop keresése',
36
34
  columnsPanelTextFieldPlaceholder: 'Oszlop neve',
@@ -39,7 +37,7 @@ const huHUGrid = {
39
37
  columnsPanelHideAllButton: 'Összes elrejtése',
40
38
  // Filter panel text
41
39
  filterPanelAddFilter: 'Szűrő hozzáadása',
42
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'Összes törlése',
43
41
  filterPanelDeleteIconLabel: 'Törlés',
44
42
  filterPanelLogicOperator: 'Logikai operátor',
45
43
  filterPanelOperator: 'Operátorok',
@@ -69,7 +67,7 @@ const huHUGrid = {
69
67
  // Column menu text
70
68
  columnMenuLabel: 'Menü',
71
69
  columnMenuShowColumns: 'Oszlopok megjelenítése',
72
- // columnMenuManageColumns: 'Manage columns',
70
+ columnMenuManageColumns: 'Oszlopok kezelése',
73
71
  columnMenuFilter: 'Szűrők',
74
72
  columnMenuHideColumn: 'Elrejtés',
75
73
  columnMenuUnsort: 'Sorrend visszaállítása',
@@ -109,20 +107,17 @@ const huHUGrid = {
109
107
  groupColumn: name => `Csoportosítás ${name} szerint`,
110
108
  unGroupColumn: name => `${name} szerinti csoportosítás törlése`,
111
109
  // Master/detail
112
- // detailPanelToggle: 'Detail panel toggle',
110
+ detailPanelToggle: 'Részletek panel váltása',
113
111
  expandDetailPanel: 'Kibontás',
114
- collapseDetailPanel: 'Összecsukás'
115
-
112
+ collapseDetailPanel: 'Összecsukás',
116
113
  // Row reordering text
117
- // rowReorderingHeaderName: 'Row reordering',
118
-
114
+ rowReorderingHeaderName: 'Sorok újrarendezése',
119
115
  // Aggregation
120
- // aggregationMenuItemHeader: 'Aggregation',
121
- // aggregationFunctionLabelSum: 'sum',
122
- // aggregationFunctionLabelAvg: 'avg',
123
- // aggregationFunctionLabelMin: 'min',
124
- // aggregationFunctionLabelMax: 'max',
125
- // aggregationFunctionLabelSize: 'size',
116
+ aggregationMenuItemHeader: 'Összesítés',
117
+ aggregationFunctionLabelSum: 'Összeg',
118
+ aggregationFunctionLabelAvg: 'Átlag',
119
+ aggregationFunctionLabelMin: 'Minimum',
120
+ aggregationFunctionLabelMax: 'Maximum',
121
+ aggregationFunctionLabelSize: 'Darabszám'
126
122
  };
127
-
128
123
  export const huHU = getGridLocalization(huHUGrid, huHUCore);
@@ -37,7 +37,7 @@ const jaJPGrid = {
37
37
  columnsPanelHideAllButton: 'すべて非表示',
38
38
  // Filter panel text
39
39
  filterPanelAddFilter: 'フィルター追加',
40
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'すべて削除',
41
41
  filterPanelDeleteIconLabel: '削除',
42
42
  filterPanelLogicOperator: '論理演算子',
43
43
  filterPanelOperator: '演算子',
@@ -37,7 +37,7 @@ const nlNLGrid = {
37
37
  columnsPanelHideAllButton: 'Alles verbergen',
38
38
  // Filter panel text
39
39
  filterPanelAddFilter: 'Filter toevoegen',
40
- // filterPanelRemoveAll: 'Remove all',
40
+ filterPanelRemoveAll: 'Alles verwijderen',
41
41
  filterPanelDeleteIconLabel: 'Verwijderen',
42
42
  filterPanelLogicOperator: 'Logische operator',
43
43
  filterPanelOperator: 'Operatoren',
@@ -67,7 +67,7 @@ const nlNLGrid = {
67
67
  // Column menu text
68
68
  columnMenuLabel: 'Menu',
69
69
  columnMenuShowColumns: 'Toon kolommen',
70
- // columnMenuManageColumns: 'Manage columns',
70
+ columnMenuManageColumns: 'Kolommen beheren',
71
71
  columnMenuFilter: 'Filteren',
72
72
  columnMenuHideColumn: 'Verbergen',
73
73
  columnMenuUnsort: 'Annuleer sortering',
@@ -107,7 +107,7 @@ const nlNLGrid = {
107
107
  groupColumn: name => `Groepeer op ${name}`,
108
108
  unGroupColumn: name => `Stop groeperen op ${name}`,
109
109
  // Master/detail
110
- // detailPanelToggle: 'Detail panel toggle',
110
+ detailPanelToggle: 'Detailmenu in- of uitklappen',
111
111
  expandDetailPanel: 'Uitklappen',
112
112
  collapseDetailPanel: 'Inklappen',
113
113
  // Row reordering text
@@ -111,15 +111,13 @@ const ptBRGrid = {
111
111
  expandDetailPanel: 'Expandir',
112
112
  collapseDetailPanel: 'Esconder',
113
113
  // Row reordering text
114
- rowReorderingHeaderName: 'Reorganizar linhas'
115
-
114
+ rowReorderingHeaderName: 'Reorganizar linhas',
116
115
  // Aggregation
117
- // aggregationMenuItemHeader: 'Aggregation',
118
- // aggregationFunctionLabelSum: 'sum',
119
- // aggregationFunctionLabelAvg: 'avg',
120
- // aggregationFunctionLabelMin: 'min',
121
- // aggregationFunctionLabelMax: 'max',
122
- // aggregationFunctionLabelSize: 'size',
116
+ aggregationMenuItemHeader: 'Agrupar',
117
+ aggregationFunctionLabelSum: 'soma',
118
+ aggregationFunctionLabelAvg: 'média',
119
+ aggregationFunctionLabelMin: 'mín',
120
+ aggregationFunctionLabelMax: 'máx',
121
+ aggregationFunctionLabelSize: 'tamanho'
123
122
  };
124
-
125
123
  export const ptBR = getGridLocalization(ptBRGrid, ptBRCore);
@@ -76,7 +76,7 @@ const ruRUGrid = {
76
76
  // Column menu text
77
77
  columnMenuLabel: 'Меню',
78
78
  columnMenuShowColumns: 'Показать столбцы',
79
- // columnMenuManageColumns: 'Manage columns',
79
+ columnMenuManageColumns: 'Управление колонками',
80
80
  columnMenuFilter: 'Фильтр',
81
81
  columnMenuHideColumn: 'Скрыть',
82
82
  columnMenuUnsort: 'Отменить сортировку',
@@ -113,11 +113,11 @@ const urPKGrid = {
113
113
  // Row reordering text
114
114
  rowReorderingHeaderName: 'قطاروں کی ترتیب تبدیل کریں',
115
115
  // Aggregation
116
- aggregationMenuItemHeader: 'Aggregation',
117
- aggregationFunctionLabelSum: 'sum',
118
- aggregationFunctionLabelAvg: 'avg',
119
- aggregationFunctionLabelMin: 'min',
120
- aggregationFunctionLabelMax: 'max',
121
- aggregationFunctionLabelSize: 'size'
116
+ aggregationMenuItemHeader: 'ایگریگیشن',
117
+ aggregationFunctionLabelSum: 'کل',
118
+ aggregationFunctionLabelAvg: 'اوسط',
119
+ aggregationFunctionLabelMin: 'کم از کم',
120
+ aggregationFunctionLabelMax: 'زیادہ سے زیادہ',
121
+ aggregationFunctionLabelSize: 'سائز'
122
122
  };
123
123
  export const urPK = getGridLocalization(urPKGrid, urPKCore);