@mui/x-data-grid 6.17.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 (69) hide show
  1. package/CHANGELOG.md +124 -5
  2. package/DataGrid/DataGrid.js +6 -0
  3. package/DataGrid/useDataGridProps.js +1 -0
  4. package/colDef/gridStringOperators.js +5 -1
  5. package/components/cell/GridActionsCell.js +19 -12
  6. package/components/cell/GridCell.js +4 -4
  7. package/components/containers/GridRootStyles.js +2 -1
  8. package/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
  9. package/hooks/core/useGridInitialization.d.ts +1 -1
  10. package/hooks/core/useGridInitialization.js +3 -0
  11. package/hooks/features/filter/gridFilterUtils.d.ts +9 -25
  12. package/hooks/features/filter/gridFilterUtils.js +61 -27
  13. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  14. package/hooks/features/filter/useGridFilter.js +4 -3
  15. package/index.js +1 -1
  16. package/internals/index.d.ts +1 -0
  17. package/internals/index.js +1 -0
  18. package/internals/utils/computeSlots.js +8 -1
  19. package/legacy/DataGrid/DataGrid.js +6 -0
  20. package/legacy/DataGrid/useDataGridProps.js +1 -0
  21. package/legacy/colDef/gridStringOperators.js +4 -0
  22. package/legacy/components/cell/GridActionsCell.js +21 -12
  23. package/legacy/components/cell/GridCell.js +6 -4
  24. package/legacy/components/containers/GridRootStyles.js +2 -1
  25. package/legacy/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
  26. package/legacy/hooks/core/useGridInitialization.js +3 -0
  27. package/legacy/hooks/features/filter/gridFilterUtils.js +47 -21
  28. package/legacy/hooks/features/filter/useGridFilter.js +4 -3
  29. package/legacy/index.js +1 -1
  30. package/legacy/internals/index.js +1 -0
  31. package/legacy/internals/utils/computeSlots.js +8 -1
  32. package/legacy/utils/getPublicApiRef.js +5 -0
  33. package/models/api/gridApiCommon.d.ts +3 -2
  34. package/models/api/gridApiCommunity.d.ts +2 -1
  35. package/models/api/gridCoreApi.d.ts +7 -1
  36. package/models/api/gridFilterApi.d.ts +6 -1
  37. package/models/api/gridLocaleTextApi.d.ts +3 -2
  38. package/models/props/DataGridProps.d.ts +6 -0
  39. package/modern/DataGrid/DataGrid.js +6 -0
  40. package/modern/DataGrid/useDataGridProps.js +1 -0
  41. package/modern/colDef/gridStringOperators.js +5 -1
  42. package/modern/components/cell/GridActionsCell.js +18 -12
  43. package/modern/components/cell/GridCell.js +3 -3
  44. package/modern/components/containers/GridRootStyles.js +2 -1
  45. package/modern/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
  46. package/modern/hooks/core/useGridInitialization.js +3 -0
  47. package/modern/hooks/features/filter/gridFilterUtils.js +61 -27
  48. package/modern/hooks/features/filter/useGridFilter.js +4 -3
  49. package/modern/index.js +1 -1
  50. package/modern/internals/index.js +1 -0
  51. package/modern/internals/utils/computeSlots.js +8 -1
  52. package/modern/utils/getPublicApiRef.js +5 -0
  53. package/node/DataGrid/DataGrid.js +6 -0
  54. package/node/DataGrid/useDataGridProps.js +1 -0
  55. package/node/colDef/gridStringOperators.js +5 -1
  56. package/node/components/cell/GridActionsCell.js +18 -12
  57. package/node/components/cell/GridCell.js +3 -3
  58. package/node/components/containers/GridRootStyles.js +2 -1
  59. package/node/components/menu/columnMenu/menuItems/GridColumnMenuSortItem.js +6 -2
  60. package/node/hooks/core/useGridInitialization.js +3 -0
  61. package/node/hooks/features/filter/gridFilterUtils.js +63 -30
  62. package/node/hooks/features/filter/useGridFilter.js +4 -3
  63. package/node/index.js +1 -1
  64. package/node/internals/index.js +12 -0
  65. package/node/internals/utils/computeSlots.js +8 -1
  66. package/node/utils/getPublicApiRef.js +11 -0
  67. package/package.json +2 -2
  68. package/utils/getPublicApiRef.d.ts +3 -0
  69. package/utils/getPublicApiRef.js +5 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,125 @@
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
+
64
+ ## 6.18.0
65
+
66
+ _Nov 3, 2023_
67
+
68
+ We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
69
+
70
+ - 🎁 The Charts package is now officially stable!
71
+ - 🥧 Pie charts are now animated.
72
+ - 📈 Line charts now support partial data, and can interpolate missing data.
73
+
74
+ <img width="380" alt="line charts with partial data" src="https://github.com/mui/mui-x/assets/45398769/385ecf77-19b2-4a03-8aef-5d547db1d9ad">
75
+
76
+ - ✨ Allow to ignore [diacritics](https://en.wikipedia.org/wiki/Diacritic) when filtering
77
+ - 📚 Documentation improvements
78
+
79
+ ### Data Grid
80
+
81
+ #### `@mui/x-data-grid@6.18.0`
82
+
83
+ - [DataGrid] Allow to ignore [diacritics](https://en.wikipedia.org/wiki/Diacritic) when filtering (#10569) @cherniavskii
84
+ - [DataGrid] Fix a typo in `gridFilterApi` (#10786) @vu-dao-93
85
+ - [DataGrid] Fix `undefined` row id (#10670) @romgrk
86
+ - [DataGrid] Make column autosizing work with dynamic row height (#10693) @cherniavskii
87
+ - [l10n] Allow to customize sorting label per column (#10839) @JerryWu1234
88
+
89
+ #### `@mui/x-data-grid-pro@6.18.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
90
+
91
+ Same changes as in `@mui/x-data-grid@6.18.0`.
92
+
93
+ #### `@mui/x-data-grid-premium@6.18.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
94
+
95
+ Same changes as in `@mui/x-data-grid-pro@6.18.0`.
96
+
97
+ ### Date Pickers
98
+
99
+ #### `@mui/x-date-pickers@6.18.0`
100
+
101
+ - [pickers] Add reference links to calendar components (#10644) @michelengelen
102
+
103
+ #### `@mui/x-date-pickers-pro@6.18.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
104
+
105
+ Same changes as in `@mui/x-date-pickers@6.18.0`.
106
+
107
+ ### Charts / `@mui/x-charts@6.18.0`
108
+
109
+ - [charts] Add animation on pie chart (#10782) @alexfauquette
110
+ - [charts] Add reference links to shared/misc chart components (#10660) @michelengelen
111
+ - [charts] Allows to connect nulls (#10803) @alexfauquette
112
+ - [charts] Fix axis highlight in dark mode (#10820) @LukasTy
113
+
114
+ ### Docs
115
+
116
+ - [docs] Add a data grid recipe for autosizing columns after fetching row-data (#10822) @michelengelen
117
+ - [docs] Add a data grid recipe showing how to remove cell outline on `focus` (#10843) @michelengelen
118
+ - [docs] Add demo about how to use charts margin (#10886) @alexfauquette
119
+ - [docs] Improve custom field input demos readability (#10559) @LukasTy
120
+
121
+ ### Core
122
+
123
+ - [core] Generate `slot` API descriptions based on `slots` or `components` (#10879) @LukasTy
124
+
6
125
  ## 6.17.0
7
126
 
8
127
  _Oct 27, 2023_
@@ -296,7 +415,7 @@ Same changes as in `@mui/x-date-pickers@6.16.1`, plus:
296
415
 
297
416
  - [core] Fix casing consistency with legal and marketing content @oliviertassinari
298
417
  - [core] Revert the link in the priority support ticket description (#10517) @michelengelen
299
- - [CHANGELOG] Polish image @oliviertassinari
418
+ - [changelog] Polish image @oliviertassinari
300
419
 
301
420
  ## 6.16.0
302
421
 
@@ -1088,7 +1207,7 @@ Same changes as in `@mui/x-date-pickers@6.10.1`.
1088
1207
  ### Core
1089
1208
 
1090
1209
  - [core] Add `validate` command (#9714) @romgrk
1091
- - [CHANGELOG] Update generator to new format @oliviertassinari
1210
+ - [changelog] Update generator to new format @oliviertassinari
1092
1211
 
1093
1212
  ## 6.10.0
1094
1213
 
@@ -1146,7 +1265,7 @@ Same changes as in `@mui/x-date-pickers@6.10.0`.
1146
1265
 
1147
1266
  - [core] Disambiguate eslint plugin name @oliviertassinari
1148
1267
  - [core] Update priority support issue template and prompt (#9574) @DanailH
1149
- - [CHANGELOG] Clarify each plan (#9446) @oliviertassinari
1268
+ - [changelog] Clarify each plan (#9446) @oliviertassinari
1150
1269
  - [license] Fix error terminology (#9614) @oliviertassinari
1151
1270
 
1152
1271
  ## 6.9.2
@@ -1295,8 +1414,8 @@ Same changes as in `@mui/x-date-pickers@6.9.1`.
1295
1414
  - [core] Fix priority support prompt action (#9472) @DanailH
1296
1415
  - [core] Update `uses` for priority support action (#9480) @DanailH
1297
1416
  - [core] Bumb update monorepo (#9476) @alexfauquette
1298
- - [CHANGELOG] Fix media quality (#9439) @oliviertassinari
1299
- - [CHANGELOG] Remove height img attribute @oliviertassinari
1417
+ - [changelog] Fix media quality (#9439) @oliviertassinari
1418
+ - [changelog] Remove height img attribute @oliviertassinari
1300
1419
  - [test] Skip flaky row pinning tests in JSDOM (#9511) @cherniavskii
1301
1420
 
1302
1421
  ## 6.9.0
@@ -278,6 +278,12 @@ DataGridRaw.propTypes = {
278
278
  * @default false
279
279
  */
280
280
  hideFooterSelectedRowCount: PropTypes.bool,
281
+ /**
282
+ * If `true`, the diacritics (accents) are ignored when filtering or quick filtering.
283
+ * E.g. when filter value is `cafe`, the rows with `café` will be visible.
284
+ * @default false
285
+ */
286
+ ignoreDiacritics: PropTypes.bool,
281
287
  /**
282
288
  * The initial state of the DataGrid.
283
289
  * The data in it will be set in the state on initialization but will not be controlled.
@@ -51,6 +51,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
51
51
  hideFooterPagination: false,
52
52
  hideFooterRowCount: false,
53
53
  hideFooterSelectedRowCount: false,
54
+ ignoreDiacritics: false,
54
55
  logger: console,
55
56
  logLevel: process.env.NODE_ENV === 'production' ? 'error' : 'warn',
56
57
  pagination: false,
@@ -2,13 +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
11
  return (_, row, column, apiRef) => {
11
- const columnValue = apiRef.current.getRowFormattedValue(row, column);
12
+ let columnValue = apiRef.current.getRowFormattedValue(row, column);
13
+ if (apiRef.current.ignoreDiacritics) {
14
+ columnValue = removeDiacritics(columnValue);
15
+ }
12
16
  return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
13
17
  };
14
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
  });
@@ -191,7 +191,8 @@ export const GridRootStyles = styled('div', {
191
191
  overflow: 'visible !important'
192
192
  },
193
193
  [`& .${gridClasses.cell} > *`]: {
194
- overflow: 'visible !important'
194
+ overflow: 'visible !important',
195
+ whiteSpace: 'nowrap'
195
196
  }
196
197
  },
197
198
  [`& .${gridClasses['virtualScrollerContent--overflowed']} .${gridClasses['row--lastVisible']} .${gridClasses.cell}`]: {
@@ -34,6 +34,10 @@ function GridColumnMenuSortItem(props) {
34
34
  if (!colDef || !colDef.sortable || !sortingOrder.some(item => !!item)) {
35
35
  return null;
36
36
  }
37
+ const getLabel = key => {
38
+ const label = apiRef.current.getLocaleText(key);
39
+ return typeof label === 'function' ? label(colDef) : label;
40
+ };
37
41
  return /*#__PURE__*/_jsxs(React.Fragment, {
38
42
  children: [sortingOrder.includes('asc') && sortDirection !== 'asc' ? /*#__PURE__*/_jsxs(MenuItem, {
39
43
  onClick: onSortMenuItemClick,
@@ -43,7 +47,7 @@ function GridColumnMenuSortItem(props) {
43
47
  fontSize: "small"
44
48
  })
45
49
  }), /*#__PURE__*/_jsx(ListItemText, {
46
- children: apiRef.current.getLocaleText('columnMenuSortAsc')
50
+ children: getLabel('columnMenuSortAsc')
47
51
  })]
48
52
  }) : null, sortingOrder.includes('desc') && sortDirection !== 'desc' ? /*#__PURE__*/_jsxs(MenuItem, {
49
53
  onClick: onSortMenuItemClick,
@@ -53,7 +57,7 @@ function GridColumnMenuSortItem(props) {
53
57
  fontSize: "small"
54
58
  })
55
59
  }), /*#__PURE__*/_jsx(ListItemText, {
56
- children: apiRef.current.getLocaleText('columnMenuSortDesc')
60
+ children: getLabel('columnMenuSortDesc')
57
61
  })]
58
62
  }) : null, sortingOrder.includes(null) && sortDirection != null ? /*#__PURE__*/_jsxs(MenuItem, {
59
63
  onClick: onSortMenuItemClick,
@@ -4,4 +4,4 @@ import { DataGridProcessedProps } from '../../models/props/DataGridProps';
4
4
  /**
5
5
  * Initialize the technical pieces of the DataGrid (logger, state, ...) that any DataGrid implementation needs
6
6
  */
7
- export declare const useGridInitialization: <PrivateApi extends GridPrivateApiCommon, Api extends GridApiCommon<any, any>>(inputApiRef: React.MutableRefObject<Api> | undefined, props: Pick<DataGridProcessedProps, 'signature' | 'logger' | 'logLevel' | 'localeText'>) => React.MutableRefObject<PrivateApi>;
7
+ export declare const useGridInitialization: <PrivateApi extends GridPrivateApiCommon, Api extends GridApiCommon<any, any>>(inputApiRef: React.MutableRefObject<Api> | undefined, props: DataGridProcessedProps) => React.MutableRefObject<PrivateApi>;
@@ -15,5 +15,8 @@ export const useGridInitialization = (inputApiRef, props) => {
15
15
  useGridPipeProcessing(privateApiRef);
16
16
  useGridStrategyProcessing(privateApiRef);
17
17
  useGridLocaleText(privateApiRef, props);
18
+ privateApiRef.current.register('private', {
19
+ rootProps: props
20
+ });
18
21
  return privateApiRef;
19
22
  };
@@ -1,38 +1,22 @@
1
1
  import * as React from 'react';
2
- import { GridFilterItem, GridFilterModel, GridRowIdGetter, GridValidRowModel } from '../../../models';
3
- import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
2
+ import { GridFilterItem, GridFilterModel } from '../../../models';
3
+ import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
4
4
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
5
5
  import { GridAggregatedFilterItemApplier, GridFilterItemResult, GridQuickFilterValueResult } from './gridFilterState';
6
- type GridFilterItemApplierNotAggregated = (row: GridValidRowModel, shouldApplyItem?: (field: string) => boolean) => GridFilterItemResult;
7
6
  /**
8
7
  * Adds default values to the optional fields of a filter items.
9
8
  * @param {GridFilterItem} item The raw filter item.
10
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
9
+ * @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
11
10
  * @return {GridFilterItem} The clean filter item with an uniq ID and an always-defined operator.
12
11
  * TODO: Make the typing reflect the different between GridFilterInputItem and GridFilterItem.
13
12
  */
14
- export declare const cleanFilterItem: (item: GridFilterItem, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItem;
15
- export declare const sanitizeFilterModel: (model: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterModel;
16
- export declare const mergeStateWithFilterModel: (filterModel: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridApiCommunity>) => (filteringState: GridStateCommunity['filter']) => GridStateCommunity['filter'];
17
- /**
18
- * Generates a method to easily check if a row is matching the current filter model.
19
- * @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
20
- * @param {GridFilterModel} filterModel The model with which we want to filter the rows.
21
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
22
- * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
23
- */
24
- export declare const buildAggregatedFilterItemsApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>, disableEval: boolean) => GridFilterItemApplierNotAggregated | null;
25
- /**
26
- * Generates a method to easily check if a row is matching the current quick filter.
27
- * @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
28
- * @param {any[]} filterModel The model with which we want to filter the rows.
29
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
30
- * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
31
- */
32
- export declare const buildAggregatedQuickFilterApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridFilterItemApplierNotAggregated | null;
33
- export declare const buildAggregatedFilterApplier: (getRowId: GridRowIdGetter | undefined, filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>, disableEval: boolean) => GridAggregatedFilterItemApplier;
13
+ export declare const cleanFilterItem: (item: GridFilterItem, apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => GridFilterItem;
14
+ export declare const sanitizeFilterModel: (model: GridFilterModel, disableMultipleColumnsFiltering: boolean, apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => GridFilterModel;
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;
17
+ export declare const buildAggregatedFilterApplier: (filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridPrivateApiCommunity>, disableEval: boolean) => GridAggregatedFilterItemApplier;
34
18
  type FilterCache = {
35
19
  cleanedFilterItems?: GridFilterItem[];
36
20
  };
37
- export declare const passFilterLogic: (allFilterItemResults: (null | GridFilterItemResult)[], allQuickFilterResults: (null | GridQuickFilterValueResult)[], filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridApiCommunity>, cache: FilterCache) => boolean;
21
+ export declare const passFilterLogic: (allFilterItemResults: (null | GridFilterItemResult)[], allQuickFilterResults: (null | GridQuickFilterValueResult)[], filterModel: GridFilterModel, apiRef: React.MutableRefObject<GridPrivateApiCommunity>, cache: FilterCache) => boolean;
38
22
  export {};
@@ -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
@@ -17,7 +18,7 @@ try {
17
18
  /**
18
19
  * Adds default values to the optional fields of a filter items.
19
20
  * @param {GridFilterItem} item The raw filter item.
20
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
21
+ * @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
21
22
  * @return {GridFilterItem} The clean filter item with an uniq ID and an always-defined operator.
22
23
  * TODO: Make the typing reflect the different between GridFilterInputItem and GridFilterItem.
23
24
  */
@@ -69,6 +70,12 @@ 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
  });
73
+ export const removeDiacritics = value => {
74
+ if (typeof value === 'string') {
75
+ return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
76
+ }
77
+ return value;
78
+ };
72
79
  const getFilterCallbackFromItem = (filterItem, apiRef) => {
73
80
  if (!filterItem.field || !filterItem.operator) {
74
81
  return null;
@@ -85,6 +92,12 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
85
92
  } else {
86
93
  parsedValue = filterItem.value;
87
94
  }
95
+ const {
96
+ ignoreDiacritics
97
+ } = apiRef.current.rootProps;
98
+ if (ignoreDiacritics) {
99
+ parsedValue = removeDiacritics(parsedValue);
100
+ }
88
101
  const newFilterItem = _extends({}, filterItem, {
89
102
  value: parsedValue
90
103
  });
@@ -98,6 +111,7 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
98
111
  }
99
112
  const hasUserFunctionLegacy = !isInternalFilter(filterOperator.getApplyFilterFn);
100
113
  const hasUserFunctionV7 = !isInternalFilter(filterOperator.getApplyFilterFnV7);
114
+ const publicApiRef = getPublicApiRef(apiRef);
101
115
  if (filterOperator.getApplyFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
102
116
  const applyFilterOnRow = filterOperator.getApplyFilterFnV7(newFilterItem, column);
103
117
  if (typeof applyFilterOnRow !== 'function') {
@@ -107,8 +121,11 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
107
121
  v7: true,
108
122
  item: newFilterItem,
109
123
  fn: row => {
110
- const value = apiRef.current.getRowValue(row, column);
111
- return applyFilterOnRow(value, row, column, apiRef);
124
+ let value = apiRef.current.getRowValue(row, column);
125
+ if (ignoreDiacritics) {
126
+ value = removeDiacritics(value);
127
+ }
128
+ return applyFilterOnRow(value, row, column, publicApiRef);
112
129
  }
113
130
  };
114
131
  }
@@ -121,7 +138,10 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
121
138
  item: newFilterItem,
122
139
  fn: rowId => {
123
140
  const params = apiRef.current.getCellParams(rowId, newFilterItem.field);
124
- GLOBAL_API_REF.current = apiRef;
141
+ GLOBAL_API_REF.current = publicApiRef;
142
+ if (ignoreDiacritics) {
143
+ params.value = removeDiacritics(params.value);
144
+ }
125
145
  const result = applyFilterOnRow(params);
126
146
  GLOBAL_API_REF.current = null;
127
147
  return result;
@@ -132,12 +152,11 @@ let filterItemsApplierId = 1;
132
152
 
133
153
  /**
134
154
  * Generates a method to easily check if a row is matching the current filter model.
135
- * @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
136
155
  * @param {GridFilterModel} filterModel The model with which we want to filter the rows.
137
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
156
+ * @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
138
157
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
139
158
  */
140
- export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef, disableEval) => {
159
+ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) => {
141
160
  const {
142
161
  items
143
162
  } = filterModel;
@@ -152,7 +171,7 @@ export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef,
152
171
  for (let i = 0; i < appliers.length; i += 1) {
153
172
  const applier = appliers[i];
154
173
  if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
155
- resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(getRowId ? getRowId(row) : row.id);
174
+ resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(apiRef.current.getRowId(row));
156
175
  }
157
176
  }
158
177
  return resultPerItemId;
@@ -168,14 +187,14 @@ export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef,
168
187
  ${appliers.map((applier, i) => `${JSON.stringify(String(applier.item.id))}:
169
188
  !shouldApply${i} ?
170
189
  false :
171
- ${applier.v7 ? `appliers[${i}].fn(row)` : `appliers[${i}].fn(${getRowId ? 'getRowId(row)' : 'row.id'})`},
190
+ ${applier.v7 ? `appliers[${i}].fn(row)` : `appliers[${i}].fn(getRowId(row))`},
172
191
  `).join('\n')}};
173
192
 
174
193
  return result$$;
175
194
  })`;
176
195
  const filterItemCore = evalCode(filterItemTemplate.replaceAll('$$', String(filterItemsApplierId)));
177
196
  const filterItem = (row, shouldApplyItem) => {
178
- return filterItemCore(getRowId, appliers, row, shouldApplyItem);
197
+ return filterItemCore(apiRef.current.getRowId, appliers, row, shouldApplyItem);
179
198
  };
180
199
  filterItemsApplierId += 1;
181
200
  return filterItem;
@@ -183,12 +202,11 @@ export const buildAggregatedFilterItemsApplier = (getRowId, filterModel, apiRef,
183
202
 
184
203
  /**
185
204
  * Generates a method to easily check if a row is matching the current quick filter.
186
- * @param {GridRowIdGetter | undefined} getRowId The getter for row's id.
187
205
  * @param {any[]} filterModel The model with which we want to filter the rows.
188
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
206
+ * @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
189
207
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
190
208
  */
191
- export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef) => {
209
+ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
192
210
  var _filterModel$quickFil, _filterModel$quickFil2, _filterModel$quickFil3;
193
211
  const quickFilterValues = (_filterModel$quickFil = (_filterModel$quickFil2 = filterModel.quickFilterValues) == null ? void 0 : _filterModel$quickFil2.filter(Boolean)) != null ? _filterModel$quickFil : [];
194
212
  if (quickFilterValues.length === 0) {
@@ -197,6 +215,10 @@ export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef)
197
215
  const quickFilterExcludeHiddenColumns = (_filterModel$quickFil3 = filterModel.quickFilterExcludeHiddenColumns) != null ? _filterModel$quickFil3 : false;
198
216
  const columnFields = quickFilterExcludeHiddenColumns ? gridVisibleColumnFieldsSelector(apiRef) : gridColumnFieldsSelector(apiRef);
199
217
  const appliersPerField = [];
218
+ const {
219
+ ignoreDiacritics
220
+ } = apiRef.current.rootProps;
221
+ const publicApiRef = getPublicApiRef(apiRef);
200
222
  columnFields.forEach(field => {
201
223
  const column = apiRef.current.getColumn(field);
202
224
  const getApplyQuickFilterFn = column == null ? void 0 : column.getApplyQuickFilterFn;
@@ -206,18 +228,24 @@ export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef)
206
228
  if (getApplyQuickFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
207
229
  appliersPerField.push({
208
230
  column,
209
- appliers: quickFilterValues.map(value => ({
210
- v7: true,
211
- fn: getApplyQuickFilterFnV7(value, column, apiRef)
212
- }))
231
+ appliers: quickFilterValues.map(quickFilterValue => {
232
+ const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
233
+ return {
234
+ v7: true,
235
+ fn: getApplyQuickFilterFnV7(value, column, publicApiRef)
236
+ };
237
+ })
213
238
  });
214
239
  } else if (getApplyQuickFilterFn) {
215
240
  appliersPerField.push({
216
241
  column,
217
- appliers: quickFilterValues.map(value => ({
218
- v7: false,
219
- fn: getApplyQuickFilterFn(value, column, apiRef)
220
- }))
242
+ appliers: quickFilterValues.map(quickFilterValue => {
243
+ const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
244
+ return {
245
+ v7: false,
246
+ fn: getApplyQuickFilterFn(value, column, publicApiRef)
247
+ };
248
+ })
221
249
  });
222
250
  }
223
251
  });
@@ -240,19 +268,25 @@ export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef)
240
268
  continue;
241
269
  }
242
270
  const applier = appliers[v];
243
- const value = apiRef.current.getRowValue(row, column);
271
+ let value = apiRef.current.getRowValue(row, column);
244
272
  if (applier.fn === null) {
245
273
  continue;
246
274
  }
247
275
  if (applier.v7) {
248
- const isMatching = applier.fn(value, row, column, apiRef);
276
+ if (ignoreDiacritics) {
277
+ value = removeDiacritics(value);
278
+ }
279
+ const isMatching = applier.fn(value, row, column, publicApiRef);
249
280
  if (isMatching) {
250
281
  result[filterValue] = true;
251
282
  continue outer;
252
283
  }
253
284
  } else {
254
285
  var _usedCellParams$field;
255
- const cellParams = (_usedCellParams$field = usedCellParams[field]) != null ? _usedCellParams$field : apiRef.current.getCellParams(getRowId ? getRowId(row) : row.id, field);
286
+ const cellParams = (_usedCellParams$field = usedCellParams[field]) != null ? _usedCellParams$field : apiRef.current.getCellParams(apiRef.current.getRowId(row), field);
287
+ if (ignoreDiacritics) {
288
+ cellParams.value = removeDiacritics(cellParams.value);
289
+ }
256
290
  usedCellParams[field] = cellParams;
257
291
  const isMatching = applier.fn(cellParams);
258
292
  if (isMatching) {
@@ -268,9 +302,9 @@ export const buildAggregatedQuickFilterApplier = (getRowId, filterModel, apiRef)
268
302
  return result;
269
303
  };
270
304
  };
271
- export const buildAggregatedFilterApplier = (getRowId, filterModel, apiRef, disableEval) => {
272
- const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(getRowId, filterModel, apiRef, disableEval);
273
- const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(getRowId, filterModel, apiRef);
305
+ export const buildAggregatedFilterApplier = (filterModel, apiRef, disableEval) => {
306
+ const isRowMatchingFilterItems = buildAggregatedFilterItemsApplier(filterModel, apiRef, disableEval);
307
+ const isRowMatchingQuickFilter = buildAggregatedQuickFilterApplier(filterModel, apiRef);
274
308
  return function isRowMatchingFilters(row, shouldApplyFilter, result) {
275
309
  var _isRowMatchingFilterI, _isRowMatchingQuickFi;
276
310
  result.passingFilterItems = (_isRowMatchingFilterI = isRowMatchingFilterItems == null ? void 0 : isRowMatchingFilterItems(row, shouldApplyFilter)) != null ? _isRowMatchingFilterI : null;
@@ -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;
@@ -61,7 +61,7 @@ export const useGridFilter = (apiRef, props) => {
61
61
  const updateFilteredRows = React.useCallback(() => {
62
62
  apiRef.current.setState(state => {
63
63
  const filterModel = gridFilterModelSelector(state, apiRef.current.instanceId);
64
- const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(props.getRowId, filterModel, apiRef, props.disableEval) : null;
64
+ const isRowMatchingFilters = props.filterMode === 'client' ? buildAggregatedFilterApplier(filterModel, apiRef, props.disableEval) : null;
65
65
  const filteringResult = apiRef.current.applyStrategyProcessor('filtering', {
66
66
  isRowMatchingFilters,
67
67
  filterModel: filterModel != null ? filterModel : getDefaultGridFilterModel()
@@ -75,7 +75,7 @@ export const useGridFilter = (apiRef, props) => {
75
75
  });
76
76
  });
77
77
  apiRef.current.publishEvent('filteredRowsSet');
78
- }, [apiRef, props.filterMode, props.getRowId, props.disableEval]);
78
+ }, [apiRef, props.filterMode, props.disableEval]);
79
79
  const addColumnMenuItem = React.useCallback((columnMenuItems, colDef) => {
80
80
  if (colDef == null || colDef.filterable === false || props.disableColumnFilter) {
81
81
  return columnMenuItems;
@@ -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.17.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