@mui/x-data-grid 6.18.0 → 7.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +212 -5
  2. package/DataGrid/DataGrid.js +0 -10
  3. package/DataGrid/useDataGridProps.js +9 -14
  4. package/colDef/gridActionsColDef.js +1 -2
  5. package/colDef/gridBooleanColDef.js +0 -1
  6. package/colDef/gridBooleanOperators.js +3 -4
  7. package/colDef/gridCheckboxSelectionColDef.js +0 -1
  8. package/colDef/gridDateOperators.js +10 -11
  9. package/colDef/gridNumericColDef.js +1 -3
  10. package/colDef/gridNumericOperators.d.ts +2 -2
  11. package/colDef/gridNumericOperators.js +13 -14
  12. package/colDef/gridSingleSelectOperators.js +5 -6
  13. package/colDef/gridStringColDef.js +1 -3
  14. package/colDef/gridStringOperators.d.ts +2 -2
  15. package/colDef/gridStringOperators.js +17 -13
  16. package/components/cell/GridActionsCell.js +19 -12
  17. package/components/cell/GridCell.js +4 -4
  18. package/constants/defaultGridSlotsComponents.js +17 -17
  19. package/hooks/features/export/useGridPrintExport.js +7 -10
  20. package/hooks/features/filter/gridFilterUtils.d.ts +1 -0
  21. package/hooks/features/filter/gridFilterUtils.js +20 -71
  22. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  23. package/hooks/features/filter/useGridFilter.js +2 -1
  24. package/hooks/features/rows/useGridRows.js +4 -1
  25. package/index.js +1 -1
  26. package/internals/index.d.ts +1 -1
  27. package/internals/index.js +1 -1
  28. package/internals/utils/computeSlots.d.ts +4 -6
  29. package/internals/utils/computeSlots.js +10 -9
  30. package/internals/utils/index.d.ts +0 -1
  31. package/internals/utils/index.js +0 -1
  32. package/internals/utils/useProps.d.ts +1 -8
  33. package/internals/utils/useProps.js +5 -8
  34. package/joy/icons.d.ts +1 -2
  35. package/joy/joySlots.d.ts +1 -2
  36. package/legacy/DataGrid/DataGrid.js +0 -10
  37. package/legacy/DataGrid/useDataGridProps.js +10 -18
  38. package/legacy/colDef/gridActionsColDef.js +1 -2
  39. package/legacy/colDef/gridBooleanColDef.js +0 -1
  40. package/legacy/colDef/gridBooleanOperators.js +3 -4
  41. package/legacy/colDef/gridCheckboxSelectionColDef.js +0 -1
  42. package/legacy/colDef/gridDateOperators.js +10 -11
  43. package/legacy/colDef/gridNumericColDef.js +1 -3
  44. package/legacy/colDef/gridNumericOperators.js +13 -14
  45. package/legacy/colDef/gridSingleSelectOperators.js +5 -6
  46. package/legacy/colDef/gridStringColDef.js +1 -3
  47. package/legacy/colDef/gridStringOperators.js +17 -13
  48. package/legacy/components/cell/GridActionsCell.js +21 -12
  49. package/legacy/components/cell/GridCell.js +6 -4
  50. package/legacy/constants/defaultGridSlotsComponents.js +17 -17
  51. package/legacy/hooks/features/export/useGridPrintExport.js +7 -10
  52. package/legacy/hooks/features/filter/gridFilterUtils.js +20 -71
  53. package/legacy/hooks/features/filter/useGridFilter.js +2 -1
  54. package/legacy/hooks/features/rows/useGridRows.js +2 -1
  55. package/legacy/index.js +1 -1
  56. package/legacy/internals/index.js +1 -1
  57. package/legacy/internals/utils/computeSlots.js +10 -9
  58. package/legacy/internals/utils/index.js +0 -1
  59. package/legacy/internals/utils/useProps.js +5 -6
  60. package/legacy/locales/csCZ.js +2 -2
  61. package/legacy/material/index.js +48 -48
  62. package/legacy/utils/getPublicApiRef.js +5 -0
  63. package/locales/csCZ.js +2 -2
  64. package/material/index.js +48 -48
  65. package/models/api/gridFilterApi.d.ts +5 -0
  66. package/models/colDef/gridColDef.d.ts +4 -14
  67. package/models/colDef/index.d.ts +1 -1
  68. package/models/gridFilterOperator.d.ts +4 -16
  69. package/models/gridIconSlotsComponent.d.ts +35 -36
  70. package/models/gridSlotsComponent.d.ts +31 -34
  71. package/models/index.d.ts +1 -1
  72. package/models/props/DataGridProps.d.ts +3 -14
  73. package/modern/DataGrid/DataGrid.js +0 -10
  74. package/modern/DataGrid/useDataGridProps.js +7 -9
  75. package/modern/colDef/gridActionsColDef.js +1 -2
  76. package/modern/colDef/gridBooleanColDef.js +0 -1
  77. package/modern/colDef/gridBooleanOperators.js +3 -4
  78. package/modern/colDef/gridCheckboxSelectionColDef.js +0 -1
  79. package/modern/colDef/gridDateOperators.js +10 -11
  80. package/modern/colDef/gridNumericColDef.js +1 -3
  81. package/modern/colDef/gridNumericOperators.js +13 -14
  82. package/modern/colDef/gridSingleSelectOperators.js +5 -6
  83. package/modern/colDef/gridStringColDef.js +1 -3
  84. package/modern/colDef/gridStringOperators.js +17 -13
  85. package/modern/components/cell/GridActionsCell.js +18 -12
  86. package/modern/components/cell/GridCell.js +3 -3
  87. package/modern/constants/defaultGridSlotsComponents.js +17 -17
  88. package/modern/hooks/features/export/useGridPrintExport.js +6 -10
  89. package/modern/hooks/features/filter/gridFilterUtils.js +20 -70
  90. package/modern/hooks/features/filter/useGridFilter.js +2 -1
  91. package/modern/hooks/features/rows/useGridRows.js +1 -1
  92. package/modern/index.js +1 -1
  93. package/modern/internals/index.js +1 -1
  94. package/modern/internals/utils/computeSlots.js +10 -9
  95. package/modern/internals/utils/index.js +0 -1
  96. package/modern/internals/utils/useProps.js +5 -8
  97. package/modern/locales/csCZ.js +2 -2
  98. package/modern/material/index.js +48 -48
  99. package/modern/utils/getPublicApiRef.js +5 -0
  100. package/node/DataGrid/DataGrid.js +0 -10
  101. package/node/DataGrid/useDataGridProps.js +6 -8
  102. package/node/colDef/gridActionsColDef.js +1 -2
  103. package/node/colDef/gridBooleanColDef.js +0 -1
  104. package/node/colDef/gridBooleanOperators.js +3 -4
  105. package/node/colDef/gridCheckboxSelectionColDef.js +0 -1
  106. package/node/colDef/gridDateOperators.js +10 -11
  107. package/node/colDef/gridNumericColDef.js +1 -3
  108. package/node/colDef/gridNumericOperators.js +14 -14
  109. package/node/colDef/gridSingleSelectOperators.js +5 -6
  110. package/node/colDef/gridStringColDef.js +1 -3
  111. package/node/colDef/gridStringOperators.js +18 -13
  112. package/node/components/cell/GridActionsCell.js +18 -12
  113. package/node/components/cell/GridCell.js +3 -3
  114. package/node/constants/defaultGridSlotsComponents.js +17 -17
  115. package/node/hooks/features/export/useGridPrintExport.js +5 -9
  116. package/node/hooks/features/filter/gridFilterUtils.js +21 -70
  117. package/node/hooks/features/filter/useGridFilter.js +2 -1
  118. package/node/hooks/features/rows/useGridRows.js +1 -1
  119. package/node/index.js +1 -1
  120. package/node/internals/index.js +13 -13
  121. package/node/internals/utils/computeSlots.js +10 -8
  122. package/node/internals/utils/index.js +0 -11
  123. package/node/internals/utils/useProps.js +4 -8
  124. package/node/locales/csCZ.js +2 -2
  125. package/node/material/index.js +48 -48
  126. package/node/utils/getPublicApiRef.js +11 -0
  127. package/package.json +1 -1
  128. package/utils/getPublicApiRef.d.ts +3 -0
  129. package/utils/getPublicApiRef.js +5 -0
  130. package/colDef/utils.d.ts +0 -21
  131. package/colDef/utils.js +0 -51
  132. package/internals/utils/slotsMigration.d.ts +0 -4
  133. package/internals/utils/slotsMigration.js +0 -13
  134. package/legacy/colDef/utils.js +0 -51
  135. package/legacy/internals/utils/slotsMigration.js +0 -14
  136. package/modern/colDef/utils.js +0 -51
  137. package/modern/internals/utils/slotsMigration.js +0 -13
  138. package/node/colDef/utils.js +0 -63
  139. package/node/internals/utils/slotsMigration.js +0 -21
@@ -3,7 +3,6 @@ import { gridNumberComparator } from '../hooks/features/sorting/gridSortingUtils
3
3
  import { isNumber } from '../utils/utils';
4
4
  import { getGridNumericOperators, getGridNumericQuickFilterFn } from './gridNumericOperators';
5
5
  import { GRID_STRING_COL_DEF } from './gridStringColDef';
6
- import { convertQuickFilterV7ToLegacy } from './utils';
7
6
  export const GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
8
7
  type: 'number',
9
8
  align: 'right',
@@ -14,6 +13,5 @@ export const GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
14
13
  value
15
14
  }) => isNumber(value) ? value.toLocaleString() : value || '',
16
15
  filterOperators: getGridNumericOperators(),
17
- getApplyQuickFilterFn: convertQuickFilterV7ToLegacy(getGridNumericQuickFilterFn),
18
- getApplyQuickFilterFnV7: getGridNumericQuickFilterFn
16
+ getApplyQuickFilterFn: getGridNumericQuickFilterFn
19
17
  });
@@ -1,23 +1,22 @@
1
1
  import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilterInputValue';
2
2
  import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
3
- import { convertLegacyOperators, tagInternalFilter } from './utils';
4
3
  const parseNumericValue = value => {
5
4
  if (value == null) {
6
5
  return null;
7
6
  }
8
7
  return Number(value);
9
8
  };
10
- export const getGridNumericQuickFilterFn = tagInternalFilter(value => {
9
+ export const getGridNumericQuickFilterFn = value => {
11
10
  if (value == null || Number.isNaN(value) || value === '') {
12
11
  return null;
13
12
  }
14
13
  return columnValue => {
15
14
  return parseNumericValue(columnValue) === parseNumericValue(value);
16
15
  };
17
- });
18
- export const getGridNumericOperators = () => convertLegacyOperators([{
16
+ };
17
+ export const getGridNumericOperators = () => [{
19
18
  value: '=',
20
- getApplyFilterFnV7: filterItem => {
19
+ getApplyFilterFn: filterItem => {
21
20
  if (filterItem.value == null || Number.isNaN(filterItem.value)) {
22
21
  return null;
23
22
  }
@@ -31,7 +30,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
31
30
  }
32
31
  }, {
33
32
  value: '!=',
34
- getApplyFilterFnV7: filterItem => {
33
+ getApplyFilterFn: filterItem => {
35
34
  if (filterItem.value == null || Number.isNaN(filterItem.value)) {
36
35
  return null;
37
36
  }
@@ -45,7 +44,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
45
44
  }
46
45
  }, {
47
46
  value: '>',
48
- getApplyFilterFnV7: filterItem => {
47
+ getApplyFilterFn: filterItem => {
49
48
  if (filterItem.value == null || Number.isNaN(filterItem.value)) {
50
49
  return null;
51
50
  }
@@ -62,7 +61,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
62
61
  }
63
62
  }, {
64
63
  value: '>=',
65
- getApplyFilterFnV7: filterItem => {
64
+ getApplyFilterFn: filterItem => {
66
65
  if (filterItem.value == null || Number.isNaN(filterItem.value)) {
67
66
  return null;
68
67
  }
@@ -79,7 +78,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
79
78
  }
80
79
  }, {
81
80
  value: '<',
82
- getApplyFilterFnV7: filterItem => {
81
+ getApplyFilterFn: filterItem => {
83
82
  if (filterItem.value == null || Number.isNaN(filterItem.value)) {
84
83
  return null;
85
84
  }
@@ -96,7 +95,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
96
95
  }
97
96
  }, {
98
97
  value: '<=',
99
- getApplyFilterFnV7: filterItem => {
98
+ getApplyFilterFn: filterItem => {
100
99
  if (filterItem.value == null || Number.isNaN(filterItem.value)) {
101
100
  return null;
102
101
  }
@@ -113,7 +112,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
113
112
  }
114
113
  }, {
115
114
  value: 'isEmpty',
116
- getApplyFilterFnV7: () => {
115
+ getApplyFilterFn: () => {
117
116
  return value => {
118
117
  return value == null;
119
118
  };
@@ -121,7 +120,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
121
120
  requiresFilterValue: false
122
121
  }, {
123
122
  value: 'isNotEmpty',
124
- getApplyFilterFnV7: () => {
123
+ getApplyFilterFn: () => {
125
124
  return value => {
126
125
  return value != null;
127
126
  };
@@ -129,7 +128,7 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
129
128
  requiresFilterValue: false
130
129
  }, {
131
130
  value: 'isAnyOf',
132
- getApplyFilterFnV7: filterItem => {
131
+ getApplyFilterFn: filterItem => {
133
132
  if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
134
133
  return null;
135
134
  }
@@ -141,4 +140,4 @@ export const getGridNumericOperators = () => convertLegacyOperators([{
141
140
  InputComponentProps: {
142
141
  type: 'number'
143
142
  }
144
- }]);
143
+ }];
@@ -1,16 +1,15 @@
1
1
  import { GridFilterInputSingleSelect } from '../components/panel/filterPanel/GridFilterInputSingleSelect';
2
2
  import { GridFilterInputMultipleSingleSelect } from '../components/panel/filterPanel/GridFilterInputMultipleSingleSelect';
3
3
  import { isObject } from '../utils/utils';
4
- import { convertLegacyOperators } from './utils';
5
4
  const parseObjectValue = value => {
6
5
  if (value == null || !isObject(value)) {
7
6
  return value;
8
7
  }
9
8
  return value.value;
10
9
  };
11
- export const getGridSingleSelectOperators = () => convertLegacyOperators([{
10
+ export const getGridSingleSelectOperators = () => [{
12
11
  value: 'is',
13
- getApplyFilterFnV7: filterItem => {
12
+ getApplyFilterFn: filterItem => {
14
13
  if (filterItem.value == null || filterItem.value === '') {
15
14
  return null;
16
15
  }
@@ -19,7 +18,7 @@ export const getGridSingleSelectOperators = () => convertLegacyOperators([{
19
18
  InputComponent: GridFilterInputSingleSelect
20
19
  }, {
21
20
  value: 'not',
22
- getApplyFilterFnV7: filterItem => {
21
+ getApplyFilterFn: filterItem => {
23
22
  if (filterItem.value == null || filterItem.value === '') {
24
23
  return null;
25
24
  }
@@ -28,7 +27,7 @@ export const getGridSingleSelectOperators = () => convertLegacyOperators([{
28
27
  InputComponent: GridFilterInputSingleSelect
29
28
  }, {
30
29
  value: 'isAnyOf',
31
- getApplyFilterFnV7: filterItem => {
30
+ getApplyFilterFn: filterItem => {
32
31
  if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
33
32
  return null;
34
33
  }
@@ -36,4 +35,4 @@ export const getGridSingleSelectOperators = () => convertLegacyOperators([{
36
35
  return value => filterItemValues.includes(parseObjectValue(value));
37
36
  },
38
37
  InputComponent: GridFilterInputMultipleSingleSelect
39
- }]);
38
+ }];
@@ -1,7 +1,6 @@
1
1
  import { renderEditInputCell } from '../components/cell/GridEditInputCell';
2
2
  import { gridStringOrNumberComparator } from '../hooks/features/sorting/gridSortingUtils';
3
3
  import { getGridStringOperators, getGridStringQuickFilterFn } from './gridStringOperators';
4
- import { convertQuickFilterV7ToLegacy } from './utils';
5
4
 
6
5
  /**
7
6
  * TODO: Move pro and premium properties outside of this Community file
@@ -24,6 +23,5 @@ export const GRID_STRING_COL_DEF = {
24
23
  align: 'left',
25
24
  filterOperators: getGridStringOperators(),
26
25
  renderEditCell: renderEditInputCell,
27
- getApplyQuickFilterFn: convertQuickFilterV7ToLegacy(getGridStringQuickFilterFn),
28
- getApplyQuickFilterFnV7: getGridStringQuickFilterFn
26
+ getApplyQuickFilterFn: getGridStringQuickFilterFn
29
27
  };
@@ -1,19 +1,23 @@
1
1
  import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilterInputValue';
2
2
  import { escapeRegExp } from '../utils/utils';
3
3
  import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
4
- import { convertLegacyOperators, tagInternalFilter } from './utils';
5
- export const getGridStringQuickFilterFn = tagInternalFilter(value => {
4
+ import { removeDiacritics } from '../hooks/features/filter/gridFilterUtils';
5
+ export const getGridStringQuickFilterFn = value => {
6
6
  if (!value) {
7
7
  return null;
8
8
  }
9
9
  const filterRegex = new RegExp(escapeRegExp(value), 'i');
10
- return columnValue => {
10
+ return (_, row, column, apiRef) => {
11
+ let columnValue = apiRef.current.getRowFormattedValue(row, column);
12
+ if (apiRef.current.ignoreDiacritics) {
13
+ columnValue = removeDiacritics(columnValue);
14
+ }
11
15
  return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
12
16
  };
13
- });
14
- export const getGridStringOperators = (disableTrim = false) => convertLegacyOperators([{
17
+ };
18
+ export const getGridStringOperators = (disableTrim = false) => [{
15
19
  value: 'contains',
16
- getApplyFilterFnV7: filterItem => {
20
+ getApplyFilterFn: filterItem => {
17
21
  if (!filterItem.value) {
18
22
  return null;
19
23
  }
@@ -26,7 +30,7 @@ export const getGridStringOperators = (disableTrim = false) => convertLegacyOper
26
30
  InputComponent: GridFilterInputValue
27
31
  }, {
28
32
  value: 'equals',
29
- getApplyFilterFnV7: filterItem => {
33
+ getApplyFilterFn: filterItem => {
30
34
  if (!filterItem.value) {
31
35
  return null;
32
36
  }
@@ -42,7 +46,7 @@ export const getGridStringOperators = (disableTrim = false) => convertLegacyOper
42
46
  InputComponent: GridFilterInputValue
43
47
  }, {
44
48
  value: 'startsWith',
45
- getApplyFilterFnV7: filterItem => {
49
+ getApplyFilterFn: filterItem => {
46
50
  if (!filterItem.value) {
47
51
  return null;
48
52
  }
@@ -55,7 +59,7 @@ export const getGridStringOperators = (disableTrim = false) => convertLegacyOper
55
59
  InputComponent: GridFilterInputValue
56
60
  }, {
57
61
  value: 'endsWith',
58
- getApplyFilterFnV7: filterItem => {
62
+ getApplyFilterFn: filterItem => {
59
63
  if (!filterItem.value) {
60
64
  return null;
61
65
  }
@@ -68,7 +72,7 @@ export const getGridStringOperators = (disableTrim = false) => convertLegacyOper
68
72
  InputComponent: GridFilterInputValue
69
73
  }, {
70
74
  value: 'isEmpty',
71
- getApplyFilterFnV7: () => {
75
+ getApplyFilterFn: () => {
72
76
  return value => {
73
77
  return value === '' || value == null;
74
78
  };
@@ -76,7 +80,7 @@ export const getGridStringOperators = (disableTrim = false) => convertLegacyOper
76
80
  requiresFilterValue: false
77
81
  }, {
78
82
  value: 'isNotEmpty',
79
- getApplyFilterFnV7: () => {
83
+ getApplyFilterFn: () => {
80
84
  return value => {
81
85
  return value !== '' && value != null;
82
86
  };
@@ -84,7 +88,7 @@ export const getGridStringOperators = (disableTrim = false) => convertLegacyOper
84
88
  requiresFilterValue: false
85
89
  }, {
86
90
  value: 'isAnyOf',
87
- getApplyFilterFnV7: filterItem => {
91
+ getApplyFilterFn: filterItem => {
88
92
  if (!Array.isArray(filterItem.value) || filterItem.value.length === 0) {
89
93
  return null;
90
94
  }
@@ -98,4 +102,4 @@ export const getGridStringOperators = (disableTrim = false) => convertLegacyOper
98
102
  }) : false;
99
103
  },
100
104
  InputComponent: GridFilterInputMultipleValue
101
- }]);
105
+ }];
@@ -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
  });
@@ -9,21 +9,21 @@ import materialSlots from '../material';
9
9
  // TODO: camelCase these key. It's a private helper now.
10
10
  // Remove then need to call `uncapitalizeObjectKeys`.
11
11
  export const DATA_GRID_DEFAULT_SLOTS_COMPONENTS = _extends({}, materialSlots, {
12
- Cell: GridCellV7,
13
- SkeletonCell: GridSkeletonCell,
14
- ColumnHeaderFilterIconButton: GridColumnHeaderFilterIconButton,
15
- ColumnMenu: GridColumnMenu,
16
- ColumnHeaders: GridColumnHeaders,
17
- Footer: GridFooter,
18
- FooterRowCount: GridRowCount,
19
- Toolbar: null,
20
- PreferencesPanel: GridPreferencesPanel,
21
- LoadingOverlay: GridLoadingOverlay,
22
- NoResultsOverlay: GridNoResultsOverlay,
23
- NoRowsOverlay: GridNoRowsOverlay,
24
- Pagination: GridPagination,
25
- FilterPanel: GridFilterPanel,
26
- ColumnsPanel: GridColumnsPanel,
27
- Panel: GridPanel,
28
- Row: GridRow
12
+ cell: GridCellV7,
13
+ skeletonCell: GridSkeletonCell,
14
+ columnHeaderFilterIconButton: GridColumnHeaderFilterIconButton,
15
+ columnMenu: GridColumnMenu,
16
+ columnHeaders: GridColumnHeaders,
17
+ footer: GridFooter,
18
+ footerRowCount: GridRowCount,
19
+ toolbar: null,
20
+ preferencesPanel: GridPreferencesPanel,
21
+ loadingOverlay: GridLoadingOverlay,
22
+ noResultsOverlay: GridNoResultsOverlay,
23
+ noRowsOverlay: GridNoRowsOverlay,
24
+ pagination: GridPagination,
25
+ filterPanel: GridFilterPanel,
26
+ columnsPanel: GridColumnsPanel,
27
+ panel: GridPanel,
28
+ row: GridRow
29
29
  });
@@ -7,7 +7,7 @@ import { gridColumnDefinitionsSelector, gridColumnVisibilityModelSelector } from
7
7
  import { gridClasses } from '../../../constants/gridClasses';
8
8
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
9
9
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
10
- import { getColumnsToExport } from './utils';
10
+ import { defaultGetRowsToExport, getColumnsToExport } from './utils';
11
11
  import { mergeStateWithPaginationModel } from '../pagination/useGridPagination';
12
12
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
13
13
  import { GridPrintExportMenuItem } from '../../../components/toolbar/GridToolbarExport';
@@ -118,12 +118,10 @@ export const useGridPrintExport = (apiRef, props) => {
118
118
  // the footer is always being placed at the bottom of the page as if all rows are exported
119
119
  // so if getRowsToExport is being used to only export a subset of rows then we need to
120
120
  // adjust the footer position to be correctly placed at the bottom of the grid
121
- if (options?.getRowsToExport) {
122
- const gridFooterElement = gridClone.querySelector(`.${gridClasses.footerContainer}`);
123
- gridFooterElement.style.position = 'absolute';
124
- gridFooterElement.style.width = '100%';
125
- gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
126
- }
121
+ const gridFooterElement = gridClone.querySelector(`.${gridClasses.footerContainer}`);
122
+ gridFooterElement.style.position = 'absolute';
123
+ gridFooterElement.style.width = '100%';
124
+ gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
127
125
 
128
126
  // printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
129
127
  // prevents us to do it
@@ -226,9 +224,7 @@ export const useGridPrintExport = (apiRef, props) => {
226
224
  apiRef.current.forceUpdate();
227
225
  }
228
226
  await updateGridColumnsForPrint(options?.fields, options?.allColumns, options?.includeCheckboxes);
229
- if (options?.getRowsToExport) {
230
- updateGridRowsForPrint(options.getRowsToExport);
231
- }
227
+ updateGridRowsForPrint(options?.getRowsToExport ?? defaultGetRowsToExport);
232
228
  apiRef.current.unstable_setVirtualization(false);
233
229
  await raf(); // wait for the state changes to take action
234
230
  const printWindow = buildPrintWindow(options?.fileName);
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { GridLogicOperator } from '../../../models';
3
- import { GLOBAL_API_REF, isInternalFilter } from '../../../colDef/utils';
4
3
  import { getDefaultGridFilterModel } from './gridFilterState';
5
4
  import { buildWarning } from '../../../utils/warning';
5
+ import { getPublicApiRef } from '../../../utils/getPublicApiRef';
6
6
  import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from '../columns';
7
7
 
8
8
  // Fixes https://github.com/mui/mui-x/issues/10056
@@ -69,7 +69,7 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
69
69
  export const mergeStateWithFilterModel = (filterModel, disableMultipleColumnsFiltering, apiRef) => filteringState => _extends({}, filteringState, {
70
70
  filterModel: sanitizeFilterModel(filterModel, disableMultipleColumnsFiltering, apiRef)
71
71
  });
72
- const removeDiacritics = value => {
72
+ export const removeDiacritics = value => {
73
73
  if (typeof value === 'string') {
74
74
  return value.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
75
75
  }
@@ -107,41 +107,19 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
107
107
  if (!filterOperator) {
108
108
  throw new Error(`MUI: No filter operator found for column '${column.field}' and operator value '${newFilterItem.operator}'.`);
109
109
  }
110
- const hasUserFunctionLegacy = !isInternalFilter(filterOperator.getApplyFilterFn);
111
- const hasUserFunctionV7 = !isInternalFilter(filterOperator.getApplyFilterFnV7);
112
- if (filterOperator.getApplyFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
113
- const applyFilterOnRow = filterOperator.getApplyFilterFnV7(newFilterItem, column);
114
- if (typeof applyFilterOnRow !== 'function') {
115
- return null;
116
- }
117
- return {
118
- v7: true,
119
- item: newFilterItem,
120
- fn: row => {
121
- let value = apiRef.current.getRowValue(row, column);
122
- if (ignoreDiacritics) {
123
- value = removeDiacritics(value);
124
- }
125
- return applyFilterOnRow(value, row, column, apiRef);
126
- }
127
- };
128
- }
110
+ const publicApiRef = getPublicApiRef(apiRef);
129
111
  const applyFilterOnRow = filterOperator.getApplyFilterFn(newFilterItem, column);
130
112
  if (typeof applyFilterOnRow !== 'function') {
131
113
  return null;
132
114
  }
133
115
  return {
134
- v7: false,
135
116
  item: newFilterItem,
136
- fn: rowId => {
137
- const params = apiRef.current.getCellParams(rowId, newFilterItem.field);
138
- GLOBAL_API_REF.current = apiRef;
117
+ fn: row => {
118
+ let value = apiRef.current.getRowValue(row, column);
139
119
  if (ignoreDiacritics) {
140
- params.value = removeDiacritics(params.value);
120
+ value = removeDiacritics(value);
141
121
  }
142
- const result = applyFilterOnRow(params);
143
- GLOBAL_API_REF.current = null;
144
- return result;
122
+ return applyFilterOnRow(value, row, column, publicApiRef);
145
123
  }
146
124
  };
147
125
  };
@@ -168,7 +146,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
168
146
  for (let i = 0; i < appliers.length; i += 1) {
169
147
  const applier = appliers[i];
170
148
  if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
171
- resultPerItemId[applier.item.id] = applier.v7 ? applier.fn(row) : applier.fn(apiRef.current.getRowId(row));
149
+ resultPerItemId[applier.item.id] = applier.fn(row);
172
150
  }
173
151
  }
174
152
  return resultPerItemId;
@@ -184,7 +162,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
184
162
  ${appliers.map((applier, i) => `${JSON.stringify(String(applier.item.id))}:
185
163
  !shouldApply${i} ?
186
164
  false :
187
- ${applier.v7 ? `appliers[${i}].fn(row)` : `appliers[${i}].fn(getRowId(row))`},
165
+ appliers[${i}].fn(row),
188
166
  `).join('\n')}};
189
167
 
190
168
  return result$$;
@@ -214,31 +192,17 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
214
192
  const {
215
193
  ignoreDiacritics
216
194
  } = apiRef.current.rootProps;
195
+ const publicApiRef = getPublicApiRef(apiRef);
217
196
  columnFields.forEach(field => {
218
197
  const column = apiRef.current.getColumn(field);
219
198
  const getApplyQuickFilterFn = column?.getApplyQuickFilterFn;
220
- const getApplyQuickFilterFnV7 = column?.getApplyQuickFilterFnV7;
221
- const hasUserFunctionLegacy = !isInternalFilter(getApplyQuickFilterFn);
222
- const hasUserFunctionV7 = !isInternalFilter(getApplyQuickFilterFnV7);
223
- if (getApplyQuickFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
224
- appliersPerField.push({
225
- column,
226
- appliers: quickFilterValues.map(quickFilterValue => {
227
- const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
228
- return {
229
- v7: true,
230
- fn: getApplyQuickFilterFnV7(value, column, apiRef)
231
- };
232
- })
233
- });
234
- } else if (getApplyQuickFilterFn) {
199
+ if (getApplyQuickFilterFn) {
235
200
  appliersPerField.push({
236
201
  column,
237
202
  appliers: quickFilterValues.map(quickFilterValue => {
238
203
  const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
239
204
  return {
240
- v7: false,
241
- fn: getApplyQuickFilterFn(value, column, apiRef)
205
+ fn: getApplyQuickFilterFn(value, column, publicApiRef)
242
206
  };
243
207
  })
244
208
  });
@@ -246,7 +210,6 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
246
210
  });
247
211
  return function isRowMatchingQuickFilter(row, shouldApplyFilter) {
248
212
  const result = {};
249
- const usedCellParams = {};
250
213
 
251
214
  /* eslint-disable no-restricted-syntax, no-labels */
252
215
  outer: for (let v = 0; v < quickFilterValues.length; v += 1) {
@@ -263,30 +226,17 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
263
226
  continue;
264
227
  }
265
228
  const applier = appliers[v];
266
- let value = apiRef.current.getRowFormattedValue(row, column);
229
+ let value = apiRef.current.getRowValue(row, column);
267
230
  if (applier.fn === null) {
268
231
  continue;
269
232
  }
270
- if (applier.v7) {
271
- if (ignoreDiacritics) {
272
- value = removeDiacritics(value);
273
- }
274
- const isMatching = applier.fn(value, row, column, apiRef);
275
- if (isMatching) {
276
- result[filterValue] = true;
277
- continue outer;
278
- }
279
- } else {
280
- const cellParams = usedCellParams[field] ?? apiRef.current.getCellParams(apiRef.current.getRowId(row), field);
281
- if (ignoreDiacritics) {
282
- cellParams.value = removeDiacritics(cellParams.value);
283
- }
284
- usedCellParams[field] = cellParams;
285
- const isMatching = applier.fn(cellParams);
286
- if (isMatching) {
287
- result[filterValue] = true;
288
- continue outer;
289
- }
233
+ if (ignoreDiacritics) {
234
+ value = removeDiacritics(value);
235
+ }
236
+ const isMatching = applier.fn(value, row, column, publicApiRef);
237
+ if (isMatching) {
238
+ result[filterValue] = true;
239
+ continue outer;
290
240
  }
291
241
  }
292
242
  result[filterValue] = false;
@@ -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
 
@@ -283,7 +283,7 @@ export const useGridRows = (apiRef, props) => {
283
283
  });
284
284
 
285
285
  // Removes potential remaining skeleton rows from the dataRowIds.
286
- const dataRowIds = rootGroupChildren.filter(childId => tree[childId].type === 'leaf');
286
+ const dataRowIds = rootGroupChildren.filter(childId => tree[childId]?.type === 'leaf');
287
287
  apiRef.current.caches.rows.dataRowIdToModelLookup = dataRowIdToModelLookup;
288
288
  apiRef.current.caches.rows.dataRowIdToIdLookup = dataRowIdToIdLookup;
289
289
  apiRef.current.setState(state => _extends({}, state, {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v6.18.0
2
+ * @mui/x-data-grid v7.0.0-alpha.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -59,8 +59,8 @@ 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';
65
- export * from '../colDef/utils';
66
66
  export * from './utils';
@@ -1,17 +1,18 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { uncapitalizeObjectKeys } from './slotsMigration';
3
-
4
- // TODO v7: Remove `components` and usages of `UncapitalizeObjectKeys` type
5
- // after converting keys in Grid(Pro|Premium)SlotsComponent to camelCase.
6
- // https://github.com/mui/mui-x/issues/7940
7
2
  export function computeSlots({
8
3
  defaultSlots,
9
- slots,
10
- components
4
+ slots
11
5
  }) {
12
- const overrides = slots ?? (components ? uncapitalizeObjectKeys(components) : null);
6
+ const overrides = slots;
13
7
  if (!overrides || Object.keys(overrides).length === 0) {
14
8
  return defaultSlots;
15
9
  }
16
- return _extends({}, defaultSlots, overrides);
10
+ const result = _extends({}, defaultSlots);
11
+ Object.keys(overrides).forEach(key => {
12
+ const k = key;
13
+ if (overrides[k] !== undefined) {
14
+ result[k] = overrides[k];
15
+ }
16
+ });
17
+ return result;
17
18
  }
@@ -1,3 +1,2 @@
1
1
  export * from './computeSlots';
2
- export * from './slotsMigration';
3
2
  export * from './useProps';