@mui/x-data-grid 6.18.0 → 6.18.1

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 (43) hide show
  1. package/CHANGELOG.md +63 -5
  2. package/colDef/gridStringOperators.js +6 -1
  3. package/components/cell/GridActionsCell.js +19 -12
  4. package/components/cell/GridCell.js +4 -4
  5. package/hooks/features/filter/gridFilterUtils.d.ts +1 -0
  6. package/hooks/features/filter/gridFilterUtils.js +10 -7
  7. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  8. package/hooks/features/filter/useGridFilter.js +2 -1
  9. package/index.js +1 -1
  10. package/internals/index.d.ts +1 -0
  11. package/internals/index.js +1 -0
  12. package/internals/utils/computeSlots.js +8 -1
  13. package/legacy/colDef/gridStringOperators.js +6 -1
  14. package/legacy/components/cell/GridActionsCell.js +21 -12
  15. package/legacy/components/cell/GridCell.js +6 -4
  16. package/legacy/hooks/features/filter/gridFilterUtils.js +10 -7
  17. package/legacy/hooks/features/filter/useGridFilter.js +2 -1
  18. package/legacy/index.js +1 -1
  19. package/legacy/internals/index.js +1 -0
  20. package/legacy/internals/utils/computeSlots.js +8 -1
  21. package/legacy/utils/getPublicApiRef.js +5 -0
  22. package/models/api/gridFilterApi.d.ts +5 -0
  23. package/modern/colDef/gridStringOperators.js +6 -1
  24. package/modern/components/cell/GridActionsCell.js +18 -12
  25. package/modern/components/cell/GridCell.js +3 -3
  26. package/modern/hooks/features/filter/gridFilterUtils.js +10 -7
  27. package/modern/hooks/features/filter/useGridFilter.js +2 -1
  28. package/modern/index.js +1 -1
  29. package/modern/internals/index.js +1 -0
  30. package/modern/internals/utils/computeSlots.js +8 -1
  31. package/modern/utils/getPublicApiRef.js +5 -0
  32. package/node/colDef/gridStringOperators.js +6 -1
  33. package/node/components/cell/GridActionsCell.js +18 -12
  34. package/node/components/cell/GridCell.js +3 -3
  35. package/node/hooks/features/filter/gridFilterUtils.js +11 -7
  36. package/node/hooks/features/filter/useGridFilter.js +2 -1
  37. package/node/index.js +1 -1
  38. package/node/internals/index.js +12 -0
  39. package/node/internals/utils/computeSlots.js +8 -1
  40. package/node/utils/getPublicApiRef.js +11 -0
  41. package/package.json +1 -1
  42. package/utils/getPublicApiRef.d.ts +3 -0
  43. package/utils/getPublicApiRef.js +5 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,64 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.18.1
7
+
8
+ _Nov 9, 2023_
9
+
10
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - ✨ Fix aggregation label not showing when `renderHeader` is used (#10961) @cherniavskii
13
+ - 📘 Server side data source [early documentation](https://mui.com/x/react-data-grid/server-side-data/) published
14
+ - 📈 `<ChartsReferenceLine />` component is now available
15
+ - 🐞 Bugfixes
16
+ - 📚 Documentation improvements
17
+
18
+ ### Data Grid
19
+
20
+ #### `@mui/x-data-grid@6.18.1`
21
+
22
+ - [DataGrid] Fix cell value type in quick filtering v7 (#10884) @cherniavskii
23
+ - [DataGrid] Fix keyboard navigation for actions cell with disabled buttons (#10947) @michelengelen
24
+ - [DataGrid] Fix `undefined` slot values (#10934) @romgrk
25
+
26
+ #### `@mui/x-data-grid-pro@6.18.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
27
+
28
+ Same changes as in `@mui/x-data-grid@6.18.1`, plus:
29
+
30
+ - [DataGridPro] Add data source interface and basic documentation (#10543) @MBilalShafi
31
+
32
+ #### `@mui/x-data-grid-premium@6.18.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
33
+
34
+ Same changes as in `@mui/x-data-grid-pro@6.18.1`, plus:
35
+
36
+ - [DataGridPremium] Render aggregation label when `renderHeader` is used (#10961) @cherniavskii
37
+
38
+ ### Date Pickers
39
+
40
+ #### `@mui/x-date-pickers@6.18.1`
41
+
42
+ - [fields] Fix multi input date time field section selection (#10915) @noraleonte
43
+ - [pickers] Always use up-to-date `defaultView` (#10889) @LukasTy
44
+
45
+ #### `@mui/x-date-pickers-pro@6.18.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
46
+
47
+ Same changes as in `@mui/x-date-pickers@6.18.1`.
48
+
49
+ ### Charts / `@mui/x-charts@6.18.1`
50
+
51
+ - [charts] Add `<ChartsReferenceLine />` component (#10597) @wascou
52
+ - [charts] Improve properties JSDoc (#10931) @alexfauquette
53
+
54
+ ### Docs
55
+
56
+ - [docs] Fix charts docs as stable (#10888) @alexfauquette
57
+ - [docs] Document how to hide the legend (#10954) @alexfauquette
58
+
59
+ ### Core
60
+
61
+ - [core] Adds new alpha version to version select on the docs (#10944) @michelengelen
62
+ - [core] Fix GitHub title tag consistency @oliviertassinari
63
+
6
64
  ## 6.18.0
7
65
 
8
66
  _Nov 3, 2023_
@@ -357,7 +415,7 @@ Same changes as in `@mui/x-date-pickers@6.16.1`, plus:
357
415
 
358
416
  - [core] Fix casing consistency with legal and marketing content @oliviertassinari
359
417
  - [core] Revert the link in the priority support ticket description (#10517) @michelengelen
360
- - [CHANGELOG] Polish image @oliviertassinari
418
+ - [changelog] Polish image @oliviertassinari
361
419
 
362
420
  ## 6.16.0
363
421
 
@@ -1149,7 +1207,7 @@ Same changes as in `@mui/x-date-pickers@6.10.1`.
1149
1207
  ### Core
1150
1208
 
1151
1209
  - [core] Add `validate` command (#9714) @romgrk
1152
- - [CHANGELOG] Update generator to new format @oliviertassinari
1210
+ - [changelog] Update generator to new format @oliviertassinari
1153
1211
 
1154
1212
  ## 6.10.0
1155
1213
 
@@ -1207,7 +1265,7 @@ Same changes as in `@mui/x-date-pickers@6.10.0`.
1207
1265
 
1208
1266
  - [core] Disambiguate eslint plugin name @oliviertassinari
1209
1267
  - [core] Update priority support issue template and prompt (#9574) @DanailH
1210
- - [CHANGELOG] Clarify each plan (#9446) @oliviertassinari
1268
+ - [changelog] Clarify each plan (#9446) @oliviertassinari
1211
1269
  - [license] Fix error terminology (#9614) @oliviertassinari
1212
1270
 
1213
1271
  ## 6.9.2
@@ -1356,8 +1414,8 @@ Same changes as in `@mui/x-date-pickers@6.9.1`.
1356
1414
  - [core] Fix priority support prompt action (#9472) @DanailH
1357
1415
  - [core] Update `uses` for priority support action (#9480) @DanailH
1358
1416
  - [core] Bumb update monorepo (#9476) @alexfauquette
1359
- - [CHANGELOG] Fix media quality (#9439) @oliviertassinari
1360
- - [CHANGELOG] Remove height img attribute @oliviertassinari
1417
+ - [changelog] Fix media quality (#9439) @oliviertassinari
1418
+ - [changelog] Remove height img attribute @oliviertassinari
1361
1419
  - [test] Skip flaky row pinning tests in JSDOM (#9511) @cherniavskii
1362
1420
 
1363
1421
  ## 6.9.0
@@ -2,12 +2,17 @@ import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilter
2
2
  import { escapeRegExp } from '../utils/utils';
3
3
  import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
4
4
  import { convertLegacyOperators, tagInternalFilter } from './utils';
5
+ import { removeDiacritics } from '../hooks/features/filter/gridFilterUtils';
5
6
  export const getGridStringQuickFilterFn = tagInternalFilter(value => {
6
7
  if (!value) {
7
8
  return null;
8
9
  }
9
10
  const filterRegex = new RegExp(escapeRegExp(value), 'i');
10
- return columnValue => {
11
+ return (_, row, column, apiRef) => {
12
+ let columnValue = apiRef.current.getRowFormattedValue(row, column);
13
+ if (apiRef.current.ignoreDiacritics) {
14
+ columnValue = removeDiacritics(columnValue);
15
+ }
11
16
  return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
12
17
  };
13
18
  });
@@ -73,10 +73,12 @@ function GridActionsCell(props) {
73
73
  focus() {
74
74
  // If ignoreCallToFocus is true, then one of the buttons was clicked and the focus is already set
75
75
  if (!ignoreCallToFocus.current) {
76
- setFocusedButtonIndex(0);
76
+ // find the first focusable button and pass the index to the state
77
+ const focusableButtonIndex = options.findIndex(o => !o.props.disabled);
78
+ setFocusedButtonIndex(focusableButtonIndex);
77
79
  }
78
80
  }
79
- }), []);
81
+ }), [options]);
80
82
  React.useEffect(() => {
81
83
  if (focusedButtonIndex >= numberOfButtons) {
82
84
  setFocusedButtonIndex(numberOfButtons - 1);
@@ -104,19 +106,24 @@ function GridActionsCell(props) {
104
106
  if (numberOfButtons <= 1) {
105
107
  return;
106
108
  }
109
+ const getNewIndex = (index, direction) => {
110
+ var _options;
111
+ if (index < 0 || index > options.length) {
112
+ return index;
113
+ }
114
+
115
+ // for rtl mode we need to reverse the direction
116
+ const rtlMod = theme.direction === 'rtl' ? -1 : 1;
117
+ const indexMod = (direction === 'left' ? -1 : 1) * rtlMod;
118
+
119
+ // if the button that should receive focus is disabled go one more step
120
+ return (_options = options[index + indexMod]) != null && _options.props.disabled ? getNewIndex(index + indexMod, direction) : index + indexMod;
121
+ };
107
122
  let newIndex = focusedButtonIndex;
108
123
  if (event.key === 'ArrowRight') {
109
- if (theme.direction === 'rtl') {
110
- newIndex -= 1;
111
- } else {
112
- newIndex += 1;
113
- }
124
+ newIndex = getNewIndex(focusedButtonIndex, 'right');
114
125
  } else if (event.key === 'ArrowLeft') {
115
- if (theme.direction === 'rtl') {
116
- newIndex += 1;
117
- } else {
118
- newIndex -= 1;
119
- }
126
+ newIndex = getNewIndex(focusedButtonIndex, 'left');
120
127
  }
121
128
  if (newIndex < 0 || newIndex >= numberOfButtons) {
122
129
  return; // We're already in the first or last item = do nothing and let the grid listen the event
@@ -386,7 +386,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
386
386
  } : void 0;
387
387
  export { MemoizedCellWrapper as GridCellWrapper, GridCell };
388
388
  const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
389
- var _rootProps$unstable_c, _rootProps$experiment3, _rootProps$experiment4;
389
+ var _getActions, _ref, _rootProps$unstable_c, _rootProps$experiment3, _rootProps$experiment4;
390
390
  const {
391
391
  column,
392
392
  rowId,
@@ -441,8 +441,8 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
441
441
  value,
442
442
  formattedValue
443
443
  } = cellParamsWithAPI;
444
- const managesOwnFocus = column.type === 'actions';
445
- const tabIndex = (cellMode === 'view' || !isEditable) && !managesOwnFocus ? cellParamsWithAPI.tabIndex : -1;
444
+ const canManageOwnFocus = column.type === 'actions' && ((_getActions = (_ref = column).getActions) == null ? void 0 : _getActions.call(_ref, apiRef.current.getRowParams(rowId)).some(action => !action.props.disabled));
445
+ const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
446
446
  const {
447
447
  classes: rootClasses,
448
448
  getCellClassName
@@ -580,7 +580,7 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
580
580
  children: valueString
581
581
  });
582
582
  }
583
- if ( /*#__PURE__*/React.isValidElement(children) && managesOwnFocus) {
583
+ if ( /*#__PURE__*/React.isValidElement(children) && canManageOwnFocus) {
584
584
  children = /*#__PURE__*/React.cloneElement(children, {
585
585
  focusElementRef
586
586
  });
@@ -13,6 +13,7 @@ import { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterV
13
13
  export declare const cleanFilterItem: (item: GridFilterItem, apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => GridFilterItem;
14
14
  export declare const sanitizeFilterModel: (model: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => GridFilterModel;
15
15
  export declare const mergeStateWithFilterModel: (filterModel: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => (filteringState: GridStateCommunity['filter']) => GridStateCommunity['filter'];
16
+ export declare const removeDiacritics: (value: unknown) => unknown;
16
17
  export declare const buildAggregatedFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridPrivateApiCommunity>, disableEval: boolean) => GridAggregatedFilterItemApplier;
17
18
  type FilterCache = {
18
19
  cleanedFilterItems?: GridFilterItem[];
@@ -3,6 +3,7 @@ import { GridLogicOperator } from '../../../models';
3
3
  import { GLOBAL_API_REF, isInternalFilter } from '../../../colDef/utils';
4
4
  import { getDefaultGridFilterModel } from './gridFilterState';
5
5
  import { buildWarning } from '../../../utils/warning';
6
+ import { getPublicApiRef } from '../../../utils/getPublicApiRef';
6
7
  import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from '../columns';
7
8
 
8
9
  // Fixes https://github.com/mui/mui-x/issues/10056
@@ -69,7 +70,7 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
69
70
  export const mergeStateWithFilterModel = (filterModel, disableMultipleColumnsFiltering, apiRef) => filteringState => _extends({}, filteringState, {
70
71
  filterModel: sanitizeFilterModel(filterModel, disableMultipleColumnsFiltering, apiRef)
71
72
  });
72
- const removeDiacritics = value => {
73
+ export const removeDiacritics = value => {
73
74
  if (typeof value === 'string') {
74
75
  return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
75
76
  }
@@ -110,6 +111,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
110
111
  }
111
112
  const hasUserFunctionLegacy = !isInternalFilter(filterOperator.getApplyFilterFn);
112
113
  const hasUserFunctionV7 = !isInternalFilter(filterOperator.getApplyFilterFnV7);
114
+ const publicApiRef = getPublicApiRef(apiRef);
113
115
  if (filterOperator.getApplyFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
114
116
  const applyFilterOnRow = filterOperator.getApplyFilterFnV7(newFilterItem, column);
115
117
  if (typeof applyFilterOnRow !== 'function') {
@@ -123,7 +125,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
123
125
  if (ignoreDiacritics) {
124
126
  value = removeDiacritics(value);
125
127
  }
126
- return applyFilterOnRow(value, row, column, apiRef);
128
+ return applyFilterOnRow(value, row, column, publicApiRef);
127
129
  }
128
130
  };
129
131
  }
@@ -136,7 +138,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
136
138
  item: newFilterItem,
137
139
  fn: rowId => {
138
140
  const params = apiRef.current.getCellParams(rowId, newFilterItem.field);
139
- GLOBAL_API_REF.current = apiRef;
141
+ GLOBAL_API_REF.current = publicApiRef;
140
142
  if (ignoreDiacritics) {
141
143
  params.value = removeDiacritics(params.value);
142
144
  }
@@ -216,6 +218,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
216
218
  const {
217
219
  ignoreDiacritics
218
220
  } = apiRef.current.rootProps;
221
+ const publicApiRef = getPublicApiRef(apiRef);
219
222
  columnFields.forEach(field => {
220
223
  const column = apiRef.current.getColumn(field);
221
224
  const getApplyQuickFilterFn = column == null ? void 0 : column.getApplyQuickFilterFn;
@@ -229,7 +232,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
229
232
  const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
230
233
  return {
231
234
  v7: true,
232
- fn: getApplyQuickFilterFnV7(value, column, apiRef)
235
+ fn: getApplyQuickFilterFnV7(value, column, publicApiRef)
233
236
  };
234
237
  })
235
238
  });
@@ -240,7 +243,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
240
243
  const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
241
244
  return {
242
245
  v7: false,
243
- fn: getApplyQuickFilterFn(value, column, apiRef)
246
+ fn: getApplyQuickFilterFn(value, column, publicApiRef)
244
247
  };
245
248
  })
246
249
  });
@@ -265,7 +268,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
265
268
  continue;
266
269
  }
267
270
  const applier = appliers[v];
268
- let value = apiRef.current.getRowFormattedValue(row, column);
271
+ let value = apiRef.current.getRowValue(row, column);
269
272
  if (applier.fn === null) {
270
273
  continue;
271
274
  }
@@ -273,7 +276,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
273
276
  if (ignoreDiacritics) {
274
277
  value = removeDiacritics(value);
275
278
  }
276
- const isMatching = applier.fn(value, row, column, apiRef);
279
+ const isMatching = applier.fn(value, row, column, publicApiRef);
277
280
  if (isMatching) {
278
281
  result[filterValue] = true;
279
282
  continue outer;
@@ -8,4 +8,4 @@ export declare const filterStateInitializer: GridStateInitializer<Pick<DataGridP
8
8
  * @requires useGridParamsApi (method)
9
9
  * @requires useGridRows (event)
10
10
  */
11
- export declare const useGridFilter: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'rows' | 'initialState' | 'filterModel' | 'getRowId' | 'onFilterModelChange' | 'filterMode' | 'disableMultipleColumnsFiltering' | 'slots' | 'slotProps' | 'disableColumnFilter' | 'disableEval'>) => void;
11
+ export declare const useGridFilter: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'rows' | 'initialState' | 'filterModel' | 'getRowId' | 'onFilterModelChange' | 'filterMode' | 'disableMultipleColumnsFiltering' | 'slots' | 'slotProps' | 'disableColumnFilter' | 'disableEval' | 'ignoreDiacritics'>) => void;
@@ -215,7 +215,8 @@ export const useGridFilter = (apiRef, props) => {
215
215
  setFilterModel,
216
216
  showFilterPanel,
217
217
  hideFilterPanel,
218
- setQuickFilterValues
218
+ setQuickFilterValues,
219
+ ignoreDiacritics: props.ignoreDiacritics
219
220
  };
220
221
  useGridApiMethod(apiRef, filterApi, 'public');
221
222
 
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.18.0
2
+ * @mui/x-data-grid v6.18.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -72,6 +72,7 @@ export { isNavigationKey } from '../utils/keyboardUtils';
72
72
  export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
73
73
  export { buildWarning } from '../utils/warning';
74
74
  export { exportAs } from '../utils/exportAs';
75
+ export * from '../utils/getPublicApiRef';
75
76
  export type { GridPrivateOnlyApiCommon } from '../models/api/gridApiCommon';
76
77
  export { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
77
78
  export * from '../hooks/utils/useOnMount';
@@ -59,6 +59,7 @@ export { isNavigationKey } from '../utils/keyboardUtils';
59
59
  export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
60
60
  export { buildWarning } from '../utils/warning';
61
61
  export { exportAs } from '../utils/exportAs';
62
+ export * from '../utils/getPublicApiRef';
62
63
  export { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
63
64
  export * from '../hooks/utils/useOnMount';
64
65
  export { serializeCellValue } from '../hooks/features/export/serializers/csvSerializer';
@@ -13,5 +13,12 @@ export function computeSlots({
13
13
  if (!overrides || Object.keys(overrides).length === 0) {
14
14
  return defaultSlots;
15
15
  }
16
- return _extends({}, defaultSlots, overrides);
16
+ const result = _extends({}, defaultSlots);
17
+ Object.keys(overrides).forEach(key => {
18
+ const k = key;
19
+ if (overrides[k] !== undefined) {
20
+ result[k] = overrides[k];
21
+ }
22
+ });
23
+ return result;
17
24
  }
@@ -2,12 +2,17 @@ import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilter
2
2
  import { escapeRegExp } from '../utils/utils';
3
3
  import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
4
4
  import { convertLegacyOperators, tagInternalFilter } from './utils';
5
+ import { removeDiacritics } from '../hooks/features/filter/gridFilterUtils';
5
6
  export var getGridStringQuickFilterFn = tagInternalFilter(function (value) {
6
7
  if (!value) {
7
8
  return null;
8
9
  }
9
10
  var filterRegex = new RegExp(escapeRegExp(value), 'i');
10
- return function (columnValue) {
11
+ return function (_, row, column, apiRef) {
12
+ var columnValue = apiRef.current.getRowFormattedValue(row, column);
13
+ if (apiRef.current.ignoreDiacritics) {
14
+ columnValue = removeDiacritics(columnValue);
15
+ }
11
16
  return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
12
17
  };
13
18
  });
@@ -97,11 +97,15 @@ function GridActionsCell(props) {
97
97
  focus: function focus() {
98
98
  // If ignoreCallToFocus is true, then one of the buttons was clicked and the focus is already set
99
99
  if (!ignoreCallToFocus.current) {
100
- setFocusedButtonIndex(0);
100
+ // find the first focusable button and pass the index to the state
101
+ var focusableButtonIndex = options.findIndex(function (o) {
102
+ return !o.props.disabled;
103
+ });
104
+ setFocusedButtonIndex(focusableButtonIndex);
101
105
  }
102
106
  }
103
107
  };
104
- }, []);
108
+ }, [options]);
105
109
  React.useEffect(function () {
106
110
  if (focusedButtonIndex >= numberOfButtons) {
107
111
  setFocusedButtonIndex(numberOfButtons - 1);
@@ -133,19 +137,24 @@ function GridActionsCell(props) {
133
137
  if (numberOfButtons <= 1) {
134
138
  return;
135
139
  }
140
+ var getNewIndex = function getNewIndex(index, direction) {
141
+ var _options;
142
+ if (index < 0 || index > options.length) {
143
+ return index;
144
+ }
145
+
146
+ // for rtl mode we need to reverse the direction
147
+ var rtlMod = theme.direction === 'rtl' ? -1 : 1;
148
+ var indexMod = (direction === 'left' ? -1 : 1) * rtlMod;
149
+
150
+ // if the button that should receive focus is disabled go one more step
151
+ return (_options = options[index + indexMod]) != null && _options.props.disabled ? getNewIndex(index + indexMod, direction) : index + indexMod;
152
+ };
136
153
  var newIndex = focusedButtonIndex;
137
154
  if (event.key === 'ArrowRight') {
138
- if (theme.direction === 'rtl') {
139
- newIndex -= 1;
140
- } else {
141
- newIndex += 1;
142
- }
155
+ newIndex = getNewIndex(focusedButtonIndex, 'right');
143
156
  } else if (event.key === 'ArrowLeft') {
144
- if (theme.direction === 'rtl') {
145
- newIndex += 1;
146
- } else {
147
- newIndex -= 1;
148
- }
157
+ newIndex = getNewIndex(focusedButtonIndex, 'left');
149
158
  }
150
159
  if (newIndex < 0 || newIndex >= numberOfButtons) {
151
160
  return; // We're already in the first or last item = do nothing and let the grid listen the event
@@ -387,7 +387,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
387
387
  } : void 0;
388
388
  export { MemoizedCellWrapper as GridCellWrapper, GridCell };
389
389
  var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
390
- var _rootProps$unstable_c, _rootProps$experiment3, _rootProps$experiment4;
390
+ var _getActions, _ref, _rootProps$unstable_c, _rootProps$experiment3, _rootProps$experiment4;
391
391
  var column = props.column,
392
392
  rowId = props.rowId,
393
393
  editCellState = props.editCellState,
@@ -443,8 +443,10 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
443
443
  isEditable = cellParamsWithAPI.isEditable,
444
444
  value = cellParamsWithAPI.value,
445
445
  formattedValue = cellParamsWithAPI.formattedValue;
446
- var managesOwnFocus = column.type === 'actions';
447
- var tabIndex = (cellMode === 'view' || !isEditable) && !managesOwnFocus ? cellParamsWithAPI.tabIndex : -1;
446
+ var canManageOwnFocus = column.type === 'actions' && ((_getActions = (_ref = column).getActions) == null ? void 0 : _getActions.call(_ref, apiRef.current.getRowParams(rowId)).some(function (action) {
447
+ return !action.props.disabled;
448
+ }));
449
+ var tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
448
450
  var rootClasses = rootProps.classes,
449
451
  getCellClassName = rootProps.getCellClassName;
450
452
  var classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
@@ -588,7 +590,7 @@ var GridCellV7 = /*#__PURE__*/React.forwardRef(function (props, ref) {
588
590
  children: valueString
589
591
  });
590
592
  }
591
- if ( /*#__PURE__*/React.isValidElement(children) && managesOwnFocus) {
593
+ if ( /*#__PURE__*/React.isValidElement(children) && canManageOwnFocus) {
592
594
  children = /*#__PURE__*/React.cloneElement(children, {
593
595
  focusElementRef: focusElementRef
594
596
  });
@@ -3,6 +3,7 @@ import { GridLogicOperator } from '../../../models';
3
3
  import { GLOBAL_API_REF, isInternalFilter } from '../../../colDef/utils';
4
4
  import { getDefaultGridFilterModel } from './gridFilterState';
5
5
  import { buildWarning } from '../../../utils/warning';
6
+ import { getPublicApiRef } from '../../../utils/getPublicApiRef';
6
7
  import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from '../columns';
7
8
 
8
9
  // Fixes https://github.com/mui/mui-x/issues/10056
@@ -79,7 +80,7 @@ export var mergeStateWithFilterModel = function mergeStateWithFilterModel(filter
79
80
  });
80
81
  };
81
82
  };
82
- var removeDiacritics = function removeDiacritics(value) {
83
+ export var removeDiacritics = function removeDiacritics(value) {
83
84
  if (typeof value === 'string') {
84
85
  return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
85
86
  }
@@ -122,6 +123,7 @@ var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, a
122
123
  }
123
124
  var hasUserFunctionLegacy = !isInternalFilter(filterOperator.getApplyFilterFn);
124
125
  var hasUserFunctionV7 = !isInternalFilter(filterOperator.getApplyFilterFnV7);
126
+ var publicApiRef = getPublicApiRef(apiRef);
125
127
  if (filterOperator.getApplyFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
126
128
  var _applyFilterOnRow = filterOperator.getApplyFilterFnV7(newFilterItem, column);
127
129
  if (typeof _applyFilterOnRow !== 'function') {
@@ -135,7 +137,7 @@ var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, a
135
137
  if (ignoreDiacritics) {
136
138
  value = removeDiacritics(value);
137
139
  }
138
- return _applyFilterOnRow(value, row, column, apiRef);
140
+ return _applyFilterOnRow(value, row, column, publicApiRef);
139
141
  }
140
142
  };
141
143
  }
@@ -148,7 +150,7 @@ var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem, a
148
150
  item: newFilterItem,
149
151
  fn: function fn(rowId) {
150
152
  var params = apiRef.current.getCellParams(rowId, newFilterItem.field);
151
- GLOBAL_API_REF.current = apiRef;
153
+ GLOBAL_API_REF.current = publicApiRef;
152
154
  if (ignoreDiacritics) {
153
155
  params.value = removeDiacritics(params.value);
154
156
  }
@@ -221,6 +223,7 @@ var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterAppli
221
223
  var columnFields = quickFilterExcludeHiddenColumns ? gridVisibleColumnFieldsSelector(apiRef) : gridColumnFieldsSelector(apiRef);
222
224
  var appliersPerField = [];
223
225
  var ignoreDiacritics = apiRef.current.rootProps.ignoreDiacritics;
226
+ var publicApiRef = getPublicApiRef(apiRef);
224
227
  columnFields.forEach(function (field) {
225
228
  var column = apiRef.current.getColumn(field);
226
229
  var getApplyQuickFilterFn = column == null ? void 0 : column.getApplyQuickFilterFn;
@@ -234,7 +237,7 @@ var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterAppli
234
237
  var value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
235
238
  return {
236
239
  v7: true,
237
- fn: getApplyQuickFilterFnV7(value, column, apiRef)
240
+ fn: getApplyQuickFilterFnV7(value, column, publicApiRef)
238
241
  };
239
242
  })
240
243
  });
@@ -245,7 +248,7 @@ var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterAppli
245
248
  var value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
246
249
  return {
247
250
  v7: false,
248
- fn: getApplyQuickFilterFn(value, column, apiRef)
251
+ fn: getApplyQuickFilterFn(value, column, publicApiRef)
249
252
  };
250
253
  })
251
254
  });
@@ -267,7 +270,7 @@ var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterAppli
267
270
  continue;
268
271
  }
269
272
  var applier = appliers[v];
270
- var value = apiRef.current.getRowFormattedValue(row, column);
273
+ var value = apiRef.current.getRowValue(row, column);
271
274
  if (applier.fn === null) {
272
275
  continue;
273
276
  }
@@ -275,7 +278,7 @@ var buildAggregatedQuickFilterApplier = function buildAggregatedQuickFilterAppli
275
278
  if (ignoreDiacritics) {
276
279
  value = removeDiacritics(value);
277
280
  }
278
- var isMatching = applier.fn(value, row, column, apiRef);
281
+ var isMatching = applier.fn(value, row, column, publicApiRef);
279
282
  if (isMatching) {
280
283
  result[filterValue] = true;
281
284
  continue outer;
@@ -226,7 +226,8 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
226
226
  setFilterModel: setFilterModel,
227
227
  showFilterPanel: showFilterPanel,
228
228
  hideFilterPanel: hideFilterPanel,
229
- setQuickFilterValues: setQuickFilterValues
229
+ setQuickFilterValues: setQuickFilterValues,
230
+ ignoreDiacritics: props.ignoreDiacritics
230
231
  };
231
232
  useGridApiMethod(apiRef, filterApi, 'public');
232
233
 
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.18.0
2
+ * @mui/x-data-grid v6.18.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -59,6 +59,7 @@ export { isNavigationKey } from '../utils/keyboardUtils';
59
59
  export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
60
60
  export { buildWarning } from '../utils/warning';
61
61
  export { exportAs } from '../utils/exportAs';
62
+ export * from '../utils/getPublicApiRef';
62
63
  export { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
63
64
  export * from '../hooks/utils/useOnMount';
64
65
  export { serializeCellValue } from '../hooks/features/export/serializers/csvSerializer';
@@ -12,5 +12,12 @@ export function computeSlots(_ref) {
12
12
  if (!overrides || Object.keys(overrides).length === 0) {
13
13
  return defaultSlots;
14
14
  }
15
- return _extends({}, defaultSlots, overrides);
15
+ var result = _extends({}, defaultSlots);
16
+ Object.keys(overrides).forEach(function (key) {
17
+ var k = key;
18
+ if (overrides[k] !== undefined) {
19
+ result[k] = overrides[k];
20
+ }
21
+ });
22
+ return result;
16
23
  }
@@ -0,0 +1,5 @@
1
+ export function getPublicApiRef(apiRef) {
2
+ return {
3
+ current: apiRef.current.getPublicApi()
4
+ };
5
+ }
@@ -1,6 +1,7 @@
1
1
  import { GridFilterModel } from '../gridFilterModel';
2
2
  import { GridFilterItem, GridLogicOperator } from '../gridFilterItem';
3
3
  import { GridControlledStateReasonLookup } from '../events';
4
+ import { DataGridProcessedProps } from '../props/DataGridProps';
4
5
  /**
5
6
  * The filter API interface that is available in the grid [[apiRef]].
6
7
  */
@@ -52,4 +53,8 @@ export interface GridFilterApi {
52
53
  * @param {any[]} values The list of element to quick filter
53
54
  */
54
55
  setQuickFilterValues: (values: any[]) => void;
56
+ /**
57
+ * Returns the value of the `ignoreDiacritics` prop.
58
+ */
59
+ ignoreDiacritics: DataGridProcessedProps['ignoreDiacritics'];
55
60
  }
@@ -2,12 +2,17 @@ import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilter
2
2
  import { escapeRegExp } from '../utils/utils';
3
3
  import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
4
4
  import { convertLegacyOperators, tagInternalFilter } from './utils';
5
+ import { removeDiacritics } from '../hooks/features/filter/gridFilterUtils';
5
6
  export const getGridStringQuickFilterFn = tagInternalFilter(value => {
6
7
  if (!value) {
7
8
  return null;
8
9
  }
9
10
  const filterRegex = new RegExp(escapeRegExp(value), 'i');
10
- return columnValue => {
11
+ return (_, row, column, apiRef) => {
12
+ let columnValue = apiRef.current.getRowFormattedValue(row, column);
13
+ if (apiRef.current.ignoreDiacritics) {
14
+ columnValue = removeDiacritics(columnValue);
15
+ }
11
16
  return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
12
17
  };
13
18
  });
@@ -72,10 +72,12 @@ function GridActionsCell(props) {
72
72
  focus() {
73
73
  // If ignoreCallToFocus is true, then one of the buttons was clicked and the focus is already set
74
74
  if (!ignoreCallToFocus.current) {
75
- setFocusedButtonIndex(0);
75
+ // find the first focusable button and pass the index to the state
76
+ const focusableButtonIndex = options.findIndex(o => !o.props.disabled);
77
+ setFocusedButtonIndex(focusableButtonIndex);
76
78
  }
77
79
  }
78
- }), []);
80
+ }), [options]);
79
81
  React.useEffect(() => {
80
82
  if (focusedButtonIndex >= numberOfButtons) {
81
83
  setFocusedButtonIndex(numberOfButtons - 1);
@@ -103,19 +105,23 @@ function GridActionsCell(props) {
103
105
  if (numberOfButtons <= 1) {
104
106
  return;
105
107
  }
108
+ const getNewIndex = (index, direction) => {
109
+ if (index < 0 || index > options.length) {
110
+ return index;
111
+ }
112
+
113
+ // for rtl mode we need to reverse the direction
114
+ const rtlMod = theme.direction === 'rtl' ? -1 : 1;
115
+ const indexMod = (direction === 'left' ? -1 : 1) * rtlMod;
116
+
117
+ // if the button that should receive focus is disabled go one more step
118
+ return options[index + indexMod]?.props.disabled ? getNewIndex(index + indexMod, direction) : index + indexMod;
119
+ };
106
120
  let newIndex = focusedButtonIndex;
107
121
  if (event.key === 'ArrowRight') {
108
- if (theme.direction === 'rtl') {
109
- newIndex -= 1;
110
- } else {
111
- newIndex += 1;
112
- }
122
+ newIndex = getNewIndex(focusedButtonIndex, 'right');
113
123
  } else if (event.key === 'ArrowLeft') {
114
- if (theme.direction === 'rtl') {
115
- newIndex += 1;
116
- } else {
117
- newIndex -= 1;
118
- }
124
+ newIndex = getNewIndex(focusedButtonIndex, 'left');
119
125
  }
120
126
  if (newIndex < 0 || newIndex >= numberOfButtons) {
121
127
  return; // We're already in the first or last item = do nothing and let the grid listen the event
@@ -439,8 +439,8 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
439
439
  value,
440
440
  formattedValue
441
441
  } = cellParamsWithAPI;
442
- const managesOwnFocus = column.type === 'actions';
443
- const tabIndex = (cellMode === 'view' || !isEditable) && !managesOwnFocus ? cellParamsWithAPI.tabIndex : -1;
442
+ const canManageOwnFocus = column.type === 'actions' && column.getActions?.(apiRef.current.getRowParams(rowId)).some(action => !action.props.disabled);
443
+ const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
444
444
  const {
445
445
  classes: rootClasses,
446
446
  getCellClassName
@@ -578,7 +578,7 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
578
578
  children: valueString
579
579
  });
580
580
  }
581
- if ( /*#__PURE__*/React.isValidElement(children) && managesOwnFocus) {
581
+ if ( /*#__PURE__*/React.isValidElement(children) && canManageOwnFocus) {
582
582
  children = /*#__PURE__*/React.cloneElement(children, {
583
583
  focusElementRef
584
584
  });
@@ -3,6 +3,7 @@ import { GridLogicOperator } from '../../../models';
3
3
  import { GLOBAL_API_REF, isInternalFilter } from '../../../colDef/utils';
4
4
  import { getDefaultGridFilterModel } from './gridFilterState';
5
5
  import { buildWarning } from '../../../utils/warning';
6
+ import { getPublicApiRef } from '../../../utils/getPublicApiRef';
6
7
  import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from '../columns';
7
8
 
8
9
  // Fixes https://github.com/mui/mui-x/issues/10056
@@ -69,7 +70,7 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
69
70
  export const mergeStateWithFilterModel = (filterModel, disableMultipleColumnsFiltering, apiRef) => filteringState => _extends({}, filteringState, {
70
71
  filterModel: sanitizeFilterModel(filterModel, disableMultipleColumnsFiltering, apiRef)
71
72
  });
72
- const removeDiacritics = value => {
73
+ export const removeDiacritics = value => {
73
74
  if (typeof value === 'string') {
74
75
  return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
75
76
  }
@@ -109,6 +110,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
109
110
  }
110
111
  const hasUserFunctionLegacy = !isInternalFilter(filterOperator.getApplyFilterFn);
111
112
  const hasUserFunctionV7 = !isInternalFilter(filterOperator.getApplyFilterFnV7);
113
+ const publicApiRef = getPublicApiRef(apiRef);
112
114
  if (filterOperator.getApplyFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
113
115
  const applyFilterOnRow = filterOperator.getApplyFilterFnV7(newFilterItem, column);
114
116
  if (typeof applyFilterOnRow !== 'function') {
@@ -122,7 +124,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
122
124
  if (ignoreDiacritics) {
123
125
  value = removeDiacritics(value);
124
126
  }
125
- return applyFilterOnRow(value, row, column, apiRef);
127
+ return applyFilterOnRow(value, row, column, publicApiRef);
126
128
  }
127
129
  };
128
130
  }
@@ -135,7 +137,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
135
137
  item: newFilterItem,
136
138
  fn: rowId => {
137
139
  const params = apiRef.current.getCellParams(rowId, newFilterItem.field);
138
- GLOBAL_API_REF.current = apiRef;
140
+ GLOBAL_API_REF.current = publicApiRef;
139
141
  if (ignoreDiacritics) {
140
142
  params.value = removeDiacritics(params.value);
141
143
  }
@@ -214,6 +216,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
214
216
  const {
215
217
  ignoreDiacritics
216
218
  } = apiRef.current.rootProps;
219
+ const publicApiRef = getPublicApiRef(apiRef);
217
220
  columnFields.forEach(field => {
218
221
  const column = apiRef.current.getColumn(field);
219
222
  const getApplyQuickFilterFn = column?.getApplyQuickFilterFn;
@@ -227,7 +230,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
227
230
  const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
228
231
  return {
229
232
  v7: true,
230
- fn: getApplyQuickFilterFnV7(value, column, apiRef)
233
+ fn: getApplyQuickFilterFnV7(value, column, publicApiRef)
231
234
  };
232
235
  })
233
236
  });
@@ -238,7 +241,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
238
241
  const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
239
242
  return {
240
243
  v7: false,
241
- fn: getApplyQuickFilterFn(value, column, apiRef)
244
+ fn: getApplyQuickFilterFn(value, column, publicApiRef)
242
245
  };
243
246
  })
244
247
  });
@@ -263,7 +266,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
263
266
  continue;
264
267
  }
265
268
  const applier = appliers[v];
266
- let value = apiRef.current.getRowFormattedValue(row, column);
269
+ let value = apiRef.current.getRowValue(row, column);
267
270
  if (applier.fn === null) {
268
271
  continue;
269
272
  }
@@ -271,7 +274,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
271
274
  if (ignoreDiacritics) {
272
275
  value = removeDiacritics(value);
273
276
  }
274
- const isMatching = applier.fn(value, row, column, apiRef);
277
+ const isMatching = applier.fn(value, row, column, publicApiRef);
275
278
  if (isMatching) {
276
279
  result[filterValue] = true;
277
280
  continue outer;
@@ -212,7 +212,8 @@ export const useGridFilter = (apiRef, props) => {
212
212
  setFilterModel,
213
213
  showFilterPanel,
214
214
  hideFilterPanel,
215
- setQuickFilterValues
215
+ setQuickFilterValues,
216
+ ignoreDiacritics: props.ignoreDiacritics
216
217
  };
217
218
  useGridApiMethod(apiRef, filterApi, 'public');
218
219
 
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.18.0
2
+ * @mui/x-data-grid v6.18.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -59,6 +59,7 @@ export { isNavigationKey } from '../utils/keyboardUtils';
59
59
  export { clamp, isDeepEqual, isNumber, isFunction, isObject } from '../utils/utils';
60
60
  export { buildWarning } from '../utils/warning';
61
61
  export { exportAs } from '../utils/exportAs';
62
+ export * from '../utils/getPublicApiRef';
62
63
  export { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
63
64
  export * from '../hooks/utils/useOnMount';
64
65
  export { serializeCellValue } from '../hooks/features/export/serializers/csvSerializer';
@@ -13,5 +13,12 @@ export function computeSlots({
13
13
  if (!overrides || Object.keys(overrides).length === 0) {
14
14
  return defaultSlots;
15
15
  }
16
- return _extends({}, defaultSlots, overrides);
16
+ const result = _extends({}, defaultSlots);
17
+ Object.keys(overrides).forEach(key => {
18
+ const k = key;
19
+ if (overrides[k] !== undefined) {
20
+ result[k] = overrides[k];
21
+ }
22
+ });
23
+ return result;
17
24
  }
@@ -0,0 +1,5 @@
1
+ export function getPublicApiRef(apiRef) {
2
+ return {
3
+ current: apiRef.current.getPublicApi()
4
+ };
5
+ }
@@ -8,12 +8,17 @@ var _GridFilterInputValue = require("../components/panel/filterPanel/GridFilterI
8
8
  var _utils = require("../utils/utils");
9
9
  var _GridFilterInputMultipleValue = require("../components/panel/filterPanel/GridFilterInputMultipleValue");
10
10
  var _utils2 = require("./utils");
11
+ var _gridFilterUtils = require("../hooks/features/filter/gridFilterUtils");
11
12
  const getGridStringQuickFilterFn = exports.getGridStringQuickFilterFn = (0, _utils2.tagInternalFilter)(value => {
12
13
  if (!value) {
13
14
  return null;
14
15
  }
15
16
  const filterRegex = new RegExp((0, _utils.escapeRegExp)(value), 'i');
16
- return columnValue => {
17
+ return (_, row, column, apiRef) => {
18
+ let columnValue = apiRef.current.getRowFormattedValue(row, column);
19
+ if (apiRef.current.ignoreDiacritics) {
20
+ columnValue = (0, _gridFilterUtils.removeDiacritics)(columnValue);
21
+ }
17
22
  return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
18
23
  };
19
24
  });
@@ -81,10 +81,12 @@ function GridActionsCell(props) {
81
81
  focus() {
82
82
  // If ignoreCallToFocus is true, then one of the buttons was clicked and the focus is already set
83
83
  if (!ignoreCallToFocus.current) {
84
- setFocusedButtonIndex(0);
84
+ // find the first focusable button and pass the index to the state
85
+ const focusableButtonIndex = options.findIndex(o => !o.props.disabled);
86
+ setFocusedButtonIndex(focusableButtonIndex);
85
87
  }
86
88
  }
87
- }), []);
89
+ }), [options]);
88
90
  React.useEffect(() => {
89
91
  if (focusedButtonIndex >= numberOfButtons) {
90
92
  setFocusedButtonIndex(numberOfButtons - 1);
@@ -112,19 +114,23 @@ function GridActionsCell(props) {
112
114
  if (numberOfButtons <= 1) {
113
115
  return;
114
116
  }
117
+ const getNewIndex = (index, direction) => {
118
+ if (index < 0 || index > options.length) {
119
+ return index;
120
+ }
121
+
122
+ // for rtl mode we need to reverse the direction
123
+ const rtlMod = theme.direction === 'rtl' ? -1 : 1;
124
+ const indexMod = (direction === 'left' ? -1 : 1) * rtlMod;
125
+
126
+ // if the button that should receive focus is disabled go one more step
127
+ return options[index + indexMod]?.props.disabled ? getNewIndex(index + indexMod, direction) : index + indexMod;
128
+ };
115
129
  let newIndex = focusedButtonIndex;
116
130
  if (event.key === 'ArrowRight') {
117
- if (theme.direction === 'rtl') {
118
- newIndex -= 1;
119
- } else {
120
- newIndex += 1;
121
- }
131
+ newIndex = getNewIndex(focusedButtonIndex, 'right');
122
132
  } else if (event.key === 'ArrowLeft') {
123
- if (theme.direction === 'rtl') {
124
- newIndex += 1;
125
- } else {
126
- newIndex -= 1;
127
- }
133
+ newIndex = getNewIndex(focusedButtonIndex, 'left');
128
134
  }
129
135
  if (newIndex < 0 || newIndex >= numberOfButtons) {
130
136
  return; // We're already in the first or last item = do nothing and let the grid listen the event
@@ -447,8 +447,8 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
447
447
  value,
448
448
  formattedValue
449
449
  } = cellParamsWithAPI;
450
- const managesOwnFocus = column.type === 'actions';
451
- const tabIndex = (cellMode === 'view' || !isEditable) && !managesOwnFocus ? cellParamsWithAPI.tabIndex : -1;
450
+ const canManageOwnFocus = column.type === 'actions' && column.getActions?.(apiRef.current.getRowParams(rowId)).some(action => !action.props.disabled);
451
+ const tabIndex = (cellMode === 'view' || !isEditable) && !canManageOwnFocus ? cellParamsWithAPI.tabIndex : -1;
452
452
  const {
453
453
  classes: rootClasses,
454
454
  getCellClassName
@@ -586,7 +586,7 @@ const GridCellV7 = /*#__PURE__*/React.forwardRef((props, ref) => {
586
586
  children: valueString
587
587
  });
588
588
  }
589
- if ( /*#__PURE__*/React.isValidElement(children) && managesOwnFocus) {
589
+ if ( /*#__PURE__*/React.isValidElement(children) && canManageOwnFocus) {
590
590
  children = /*#__PURE__*/React.cloneElement(children, {
591
591
  focusElementRef
592
592
  });
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.sanitizeFilterModel = exports.passFilterLogic = exports.mergeStateWithFilterModel = exports.cleanFilterItem = exports.buildAggregatedFilterApplier = void 0;
7
+ exports.sanitizeFilterModel = exports.removeDiacritics = exports.passFilterLogic = exports.mergeStateWithFilterModel = exports.cleanFilterItem = exports.buildAggregatedFilterApplier = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _models = require("../../../models");
10
10
  var _utils = require("../../../colDef/utils");
11
11
  var _gridFilterState = require("./gridFilterState");
12
12
  var _warning = require("../../../utils/warning");
13
+ var _getPublicApiRef = require("../../../utils/getPublicApiRef");
13
14
  var _columns = require("../columns");
14
15
  // Fixes https://github.com/mui/mui-x/issues/10056
15
16
  const globalScope = typeof window === 'undefined' ? globalThis : window;
@@ -84,6 +85,7 @@ const removeDiacritics = value => {
84
85
  }
85
86
  return value;
86
87
  };
88
+ exports.removeDiacritics = removeDiacritics;
87
89
  const getFilterCallbackFromItem = (filterItem, apiRef) => {
88
90
  if (!filterItem.field || !filterItem.operator) {
89
91
  return null;
@@ -118,6 +120,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
118
120
  }
119
121
  const hasUserFunctionLegacy = !(0, _utils.isInternalFilter)(filterOperator.getApplyFilterFn);
120
122
  const hasUserFunctionV7 = !(0, _utils.isInternalFilter)(filterOperator.getApplyFilterFnV7);
123
+ const publicApiRef = (0, _getPublicApiRef.getPublicApiRef)(apiRef);
121
124
  if (filterOperator.getApplyFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
122
125
  const applyFilterOnRow = filterOperator.getApplyFilterFnV7(newFilterItem, column);
123
126
  if (typeof applyFilterOnRow !== 'function') {
@@ -131,7 +134,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
131
134
  if (ignoreDiacritics) {
132
135
  value = removeDiacritics(value);
133
136
  }
134
- return applyFilterOnRow(value, row, column, apiRef);
137
+ return applyFilterOnRow(value, row, column, publicApiRef);
135
138
  }
136
139
  };
137
140
  }
@@ -144,7 +147,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
144
147
  item: newFilterItem,
145
148
  fn: rowId => {
146
149
  const params = apiRef.current.getCellParams(rowId, newFilterItem.field);
147
- _utils.GLOBAL_API_REF.current = apiRef;
150
+ _utils.GLOBAL_API_REF.current = publicApiRef;
148
151
  if (ignoreDiacritics) {
149
152
  params.value = removeDiacritics(params.value);
150
153
  }
@@ -223,6 +226,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
223
226
  const {
224
227
  ignoreDiacritics
225
228
  } = apiRef.current.rootProps;
229
+ const publicApiRef = (0, _getPublicApiRef.getPublicApiRef)(apiRef);
226
230
  columnFields.forEach(field => {
227
231
  const column = apiRef.current.getColumn(field);
228
232
  const getApplyQuickFilterFn = column?.getApplyQuickFilterFn;
@@ -236,7 +240,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
236
240
  const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
237
241
  return {
238
242
  v7: true,
239
- fn: getApplyQuickFilterFnV7(value, column, apiRef)
243
+ fn: getApplyQuickFilterFnV7(value, column, publicApiRef)
240
244
  };
241
245
  })
242
246
  });
@@ -247,7 +251,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
247
251
  const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
248
252
  return {
249
253
  v7: false,
250
- fn: getApplyQuickFilterFn(value, column, apiRef)
254
+ fn: getApplyQuickFilterFn(value, column, publicApiRef)
251
255
  };
252
256
  })
253
257
  });
@@ -272,7 +276,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
272
276
  continue;
273
277
  }
274
278
  const applier = appliers[v];
275
- let value = apiRef.current.getRowFormattedValue(row, column);
279
+ let value = apiRef.current.getRowValue(row, column);
276
280
  if (applier.fn === null) {
277
281
  continue;
278
282
  }
@@ -280,7 +284,7 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
280
284
  if (ignoreDiacritics) {
281
285
  value = removeDiacritics(value);
282
286
  }
283
- const isMatching = applier.fn(value, row, column, apiRef);
287
+ const isMatching = applier.fn(value, row, column, publicApiRef);
284
288
  if (isMatching) {
285
289
  result[filterValue] = true;
286
290
  continue outer;
@@ -222,7 +222,8 @@ const useGridFilter = (apiRef, props) => {
222
222
  setFilterModel,
223
223
  showFilterPanel,
224
224
  hideFilterPanel,
225
- setQuickFilterValues
225
+ setQuickFilterValues,
226
+ ignoreDiacritics: props.ignoreDiacritics
226
227
  };
227
228
  (0, _useGridApiMethod.useGridApiMethod)(apiRef, filterApi, 'public');
228
229
 
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.18.0
2
+ * @mui/x-data-grid v6.18.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -716,6 +716,18 @@ var _keyboardUtils = require("../utils/keyboardUtils");
716
716
  var _utils2 = require("../utils/utils");
717
717
  var _warning = require("../utils/warning");
718
718
  var _exportAs = require("../utils/exportAs");
719
+ var _getPublicApiRef = require("../utils/getPublicApiRef");
720
+ Object.keys(_getPublicApiRef).forEach(function (key) {
721
+ if (key === "default" || key === "__esModule") return;
722
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
723
+ if (key in exports && exports[key] === _getPublicApiRef[key]) return;
724
+ Object.defineProperty(exports, key, {
725
+ enumerable: true,
726
+ get: function () {
727
+ return _getPublicApiRef[key];
728
+ }
729
+ });
730
+ });
719
731
  var _useGridPrivateApiContext = require("../hooks/utils/useGridPrivateApiContext");
720
732
  var _useOnMount = require("../hooks/utils/useOnMount");
721
733
  Object.keys(_useOnMount).forEach(function (key) {
@@ -19,5 +19,12 @@ function computeSlots({
19
19
  if (!overrides || Object.keys(overrides).length === 0) {
20
20
  return defaultSlots;
21
21
  }
22
- return (0, _extends2.default)({}, defaultSlots, overrides);
22
+ const result = (0, _extends2.default)({}, defaultSlots);
23
+ Object.keys(overrides).forEach(key => {
24
+ const k = key;
25
+ if (overrides[k] !== undefined) {
26
+ result[k] = overrides[k];
27
+ }
28
+ });
29
+ return result;
23
30
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPublicApiRef = getPublicApiRef;
7
+ function getPublicApiRef(apiRef) {
8
+ return {
9
+ current: apiRef.current.getPublicApi()
10
+ };
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "6.18.0",
3
+ "version": "6.18.1",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { GridPrivateApiCommunity } from '../models/api/gridApiCommunity';
3
+ export declare function getPublicApiRef<PrivateApi extends GridPrivateApiCommunity>(apiRef: React.MutableRefObject<PrivateApi>): import("react").MutableRefObject<ReturnType<PrivateApi["getPublicApi"]>>;
@@ -0,0 +1,5 @@
1
+ export function getPublicApiRef(apiRef) {
2
+ return {
3
+ current: apiRef.current.getPublicApi()
4
+ };
5
+ }