@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.
- package/CHANGELOG.md +212 -5
- package/DataGrid/DataGrid.js +0 -10
- package/DataGrid/useDataGridProps.js +9 -14
- package/colDef/gridActionsColDef.js +1 -2
- package/colDef/gridBooleanColDef.js +0 -1
- package/colDef/gridBooleanOperators.js +3 -4
- package/colDef/gridCheckboxSelectionColDef.js +0 -1
- package/colDef/gridDateOperators.js +10 -11
- package/colDef/gridNumericColDef.js +1 -3
- package/colDef/gridNumericOperators.d.ts +2 -2
- package/colDef/gridNumericOperators.js +13 -14
- package/colDef/gridSingleSelectOperators.js +5 -6
- package/colDef/gridStringColDef.js +1 -3
- package/colDef/gridStringOperators.d.ts +2 -2
- package/colDef/gridStringOperators.js +17 -13
- package/components/cell/GridActionsCell.js +19 -12
- package/components/cell/GridCell.js +4 -4
- package/constants/defaultGridSlotsComponents.js +17 -17
- package/hooks/features/export/useGridPrintExport.js +7 -10
- package/hooks/features/filter/gridFilterUtils.d.ts +1 -0
- package/hooks/features/filter/gridFilterUtils.js +20 -71
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +2 -1
- package/hooks/features/rows/useGridRows.js +4 -1
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/internals/utils/computeSlots.d.ts +4 -6
- package/internals/utils/computeSlots.js +10 -9
- package/internals/utils/index.d.ts +0 -1
- package/internals/utils/index.js +0 -1
- package/internals/utils/useProps.d.ts +1 -8
- package/internals/utils/useProps.js +5 -8
- package/joy/icons.d.ts +1 -2
- package/joy/joySlots.d.ts +1 -2
- package/legacy/DataGrid/DataGrid.js +0 -10
- package/legacy/DataGrid/useDataGridProps.js +10 -18
- package/legacy/colDef/gridActionsColDef.js +1 -2
- package/legacy/colDef/gridBooleanColDef.js +0 -1
- package/legacy/colDef/gridBooleanOperators.js +3 -4
- package/legacy/colDef/gridCheckboxSelectionColDef.js +0 -1
- package/legacy/colDef/gridDateOperators.js +10 -11
- package/legacy/colDef/gridNumericColDef.js +1 -3
- package/legacy/colDef/gridNumericOperators.js +13 -14
- package/legacy/colDef/gridSingleSelectOperators.js +5 -6
- package/legacy/colDef/gridStringColDef.js +1 -3
- package/legacy/colDef/gridStringOperators.js +17 -13
- package/legacy/components/cell/GridActionsCell.js +21 -12
- package/legacy/components/cell/GridCell.js +6 -4
- package/legacy/constants/defaultGridSlotsComponents.js +17 -17
- package/legacy/hooks/features/export/useGridPrintExport.js +7 -10
- package/legacy/hooks/features/filter/gridFilterUtils.js +20 -71
- package/legacy/hooks/features/filter/useGridFilter.js +2 -1
- package/legacy/hooks/features/rows/useGridRows.js +2 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/internals/utils/computeSlots.js +10 -9
- package/legacy/internals/utils/index.js +0 -1
- package/legacy/internals/utils/useProps.js +5 -6
- package/legacy/locales/csCZ.js +2 -2
- package/legacy/material/index.js +48 -48
- package/legacy/utils/getPublicApiRef.js +5 -0
- package/locales/csCZ.js +2 -2
- package/material/index.js +48 -48
- package/models/api/gridFilterApi.d.ts +5 -0
- package/models/colDef/gridColDef.d.ts +4 -14
- package/models/colDef/index.d.ts +1 -1
- package/models/gridFilterOperator.d.ts +4 -16
- package/models/gridIconSlotsComponent.d.ts +35 -36
- package/models/gridSlotsComponent.d.ts +31 -34
- package/models/index.d.ts +1 -1
- package/models/props/DataGridProps.d.ts +3 -14
- package/modern/DataGrid/DataGrid.js +0 -10
- package/modern/DataGrid/useDataGridProps.js +7 -9
- package/modern/colDef/gridActionsColDef.js +1 -2
- package/modern/colDef/gridBooleanColDef.js +0 -1
- package/modern/colDef/gridBooleanOperators.js +3 -4
- package/modern/colDef/gridCheckboxSelectionColDef.js +0 -1
- package/modern/colDef/gridDateOperators.js +10 -11
- package/modern/colDef/gridNumericColDef.js +1 -3
- package/modern/colDef/gridNumericOperators.js +13 -14
- package/modern/colDef/gridSingleSelectOperators.js +5 -6
- package/modern/colDef/gridStringColDef.js +1 -3
- package/modern/colDef/gridStringOperators.js +17 -13
- package/modern/components/cell/GridActionsCell.js +18 -12
- package/modern/components/cell/GridCell.js +3 -3
- package/modern/constants/defaultGridSlotsComponents.js +17 -17
- package/modern/hooks/features/export/useGridPrintExport.js +6 -10
- package/modern/hooks/features/filter/gridFilterUtils.js +20 -70
- package/modern/hooks/features/filter/useGridFilter.js +2 -1
- package/modern/hooks/features/rows/useGridRows.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/internals/utils/computeSlots.js +10 -9
- package/modern/internals/utils/index.js +0 -1
- package/modern/internals/utils/useProps.js +5 -8
- package/modern/locales/csCZ.js +2 -2
- package/modern/material/index.js +48 -48
- package/modern/utils/getPublicApiRef.js +5 -0
- package/node/DataGrid/DataGrid.js +0 -10
- package/node/DataGrid/useDataGridProps.js +6 -8
- package/node/colDef/gridActionsColDef.js +1 -2
- package/node/colDef/gridBooleanColDef.js +0 -1
- package/node/colDef/gridBooleanOperators.js +3 -4
- package/node/colDef/gridCheckboxSelectionColDef.js +0 -1
- package/node/colDef/gridDateOperators.js +10 -11
- package/node/colDef/gridNumericColDef.js +1 -3
- package/node/colDef/gridNumericOperators.js +14 -14
- package/node/colDef/gridSingleSelectOperators.js +5 -6
- package/node/colDef/gridStringColDef.js +1 -3
- package/node/colDef/gridStringOperators.js +18 -13
- package/node/components/cell/GridActionsCell.js +18 -12
- package/node/components/cell/GridCell.js +3 -3
- package/node/constants/defaultGridSlotsComponents.js +17 -17
- package/node/hooks/features/export/useGridPrintExport.js +5 -9
- package/node/hooks/features/filter/gridFilterUtils.js +21 -70
- package/node/hooks/features/filter/useGridFilter.js +2 -1
- package/node/hooks/features/rows/useGridRows.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +13 -13
- package/node/internals/utils/computeSlots.js +10 -8
- package/node/internals/utils/index.js +0 -11
- package/node/internals/utils/useProps.js +4 -8
- package/node/locales/csCZ.js +2 -2
- package/node/material/index.js +48 -48
- package/node/utils/getPublicApiRef.js +11 -0
- package/package.json +1 -1
- package/utils/getPublicApiRef.d.ts +3 -0
- package/utils/getPublicApiRef.js +5 -0
- package/colDef/utils.d.ts +0 -21
- package/colDef/utils.js +0 -51
- package/internals/utils/slotsMigration.d.ts +0 -4
- package/internals/utils/slotsMigration.js +0 -13
- package/legacy/colDef/utils.js +0 -51
- package/legacy/internals/utils/slotsMigration.js +0 -14
- package/modern/colDef/utils.js +0 -51
- package/modern/internals/utils/slotsMigration.js +0 -13
- package/node/colDef/utils.js +0 -63
- package/node/internals/utils/slotsMigration.js +0 -21
|
@@ -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 {
|
|
5
|
-
export const getGridStringQuickFilterFn =
|
|
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
|
|
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) =>
|
|
17
|
+
};
|
|
18
|
+
export const getGridStringOperators = (disableTrim = false) => [{
|
|
15
19
|
value: 'contains',
|
|
16
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}];
|
|
@@ -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
|
-
|
|
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
|
-
|
|
110
|
-
newIndex -= 1;
|
|
111
|
-
} else {
|
|
112
|
-
newIndex += 1;
|
|
113
|
-
}
|
|
124
|
+
newIndex = getNewIndex(focusedButtonIndex, 'right');
|
|
114
125
|
} else if (event.key === 'ArrowLeft') {
|
|
115
|
-
|
|
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
|
|
445
|
-
const tabIndex = (cellMode === 'view' || !isEditable) && !
|
|
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) &&
|
|
583
|
+
if ( /*#__PURE__*/React.isValidElement(children) && canManageOwnFocus) {
|
|
584
584
|
children = /*#__PURE__*/React.cloneElement(children, {
|
|
585
585
|
focusElementRef
|
|
586
586
|
});
|
|
@@ -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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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';
|
|
@@ -121,12 +121,10 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
121
121
|
// the footer is always being placed at the bottom of the page as if all rows are exported
|
|
122
122
|
// so if getRowsToExport is being used to only export a subset of rows then we need to
|
|
123
123
|
// adjust the footer position to be correctly placed at the bottom of the grid
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
|
|
129
|
-
}
|
|
124
|
+
const gridFooterElement = gridClone.querySelector(`.${gridClasses.footerContainer}`);
|
|
125
|
+
gridFooterElement.style.position = 'absolute';
|
|
126
|
+
gridFooterElement.style.width = '100%';
|
|
127
|
+
gridFooterElement.style.top = `${computedTotalHeight - gridFooterElementHeight}px`;
|
|
130
128
|
|
|
131
129
|
// printDoc.body.appendChild(gridClone); should be enough but a clone isolation bug in Safari
|
|
132
130
|
// prevents us to do it
|
|
@@ -210,6 +208,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
210
208
|
previousRows.current = [];
|
|
211
209
|
}, [apiRef]);
|
|
212
210
|
const exportDataAsPrint = React.useCallback(async options => {
|
|
211
|
+
var _options$getRowsToExp;
|
|
213
212
|
logger.debug(`Export data as Print`);
|
|
214
213
|
if (!apiRef.current.rootElementRef.current) {
|
|
215
214
|
throw new Error('MUI: No grid root element available.');
|
|
@@ -230,9 +229,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
230
229
|
apiRef.current.forceUpdate();
|
|
231
230
|
}
|
|
232
231
|
await updateGridColumnsForPrint(options == null ? void 0 : options.fields, options == null ? void 0 : options.allColumns, options == null ? void 0 : options.includeCheckboxes);
|
|
233
|
-
|
|
234
|
-
updateGridRowsForPrint(options.getRowsToExport);
|
|
235
|
-
}
|
|
232
|
+
updateGridRowsForPrint((_options$getRowsToExp = options == null ? void 0 : options.getRowsToExport) != null ? _options$getRowsToExp : defaultGetRowsToExport);
|
|
236
233
|
apiRef.current.unstable_setVirtualization(false);
|
|
237
234
|
await raf(); // wait for the state changes to take action
|
|
238
235
|
const printWindow = buildPrintWindow(options == null ? void 0 : options.fileName);
|
|
@@ -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[];
|
|
@@ -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
|
}
|
|
@@ -108,41 +108,19 @@ const getFilterCallbackFromItem = (filterItem, apiRef) => {
|
|
|
108
108
|
if (!filterOperator) {
|
|
109
109
|
throw new Error(`MUI: No filter operator found for column '${column.field}' and operator value '${newFilterItem.operator}'.`);
|
|
110
110
|
}
|
|
111
|
-
const
|
|
112
|
-
const hasUserFunctionV7 = !isInternalFilter(filterOperator.getApplyFilterFnV7);
|
|
113
|
-
if (filterOperator.getApplyFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
|
|
114
|
-
const applyFilterOnRow = filterOperator.getApplyFilterFnV7(newFilterItem, column);
|
|
115
|
-
if (typeof applyFilterOnRow !== 'function') {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
v7: true,
|
|
120
|
-
item: newFilterItem,
|
|
121
|
-
fn: row => {
|
|
122
|
-
let value = apiRef.current.getRowValue(row, column);
|
|
123
|
-
if (ignoreDiacritics) {
|
|
124
|
-
value = removeDiacritics(value);
|
|
125
|
-
}
|
|
126
|
-
return applyFilterOnRow(value, row, column, apiRef);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
111
|
+
const publicApiRef = getPublicApiRef(apiRef);
|
|
130
112
|
const applyFilterOnRow = filterOperator.getApplyFilterFn(newFilterItem, column);
|
|
131
113
|
if (typeof applyFilterOnRow !== 'function') {
|
|
132
114
|
return null;
|
|
133
115
|
}
|
|
134
116
|
return {
|
|
135
|
-
v7: false,
|
|
136
117
|
item: newFilterItem,
|
|
137
|
-
fn:
|
|
138
|
-
|
|
139
|
-
GLOBAL_API_REF.current = apiRef;
|
|
118
|
+
fn: row => {
|
|
119
|
+
let value = apiRef.current.getRowValue(row, column);
|
|
140
120
|
if (ignoreDiacritics) {
|
|
141
|
-
|
|
121
|
+
value = removeDiacritics(value);
|
|
142
122
|
}
|
|
143
|
-
|
|
144
|
-
GLOBAL_API_REF.current = null;
|
|
145
|
-
return result;
|
|
123
|
+
return applyFilterOnRow(value, row, column, publicApiRef);
|
|
146
124
|
}
|
|
147
125
|
};
|
|
148
126
|
};
|
|
@@ -169,7 +147,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
|
|
|
169
147
|
for (let i = 0; i < appliers.length; i += 1) {
|
|
170
148
|
const applier = appliers[i];
|
|
171
149
|
if (!shouldApplyFilter || shouldApplyFilter(applier.item.field)) {
|
|
172
|
-
resultPerItemId[applier.item.id] = applier.
|
|
150
|
+
resultPerItemId[applier.item.id] = applier.fn(row);
|
|
173
151
|
}
|
|
174
152
|
}
|
|
175
153
|
return resultPerItemId;
|
|
@@ -185,7 +163,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) =>
|
|
|
185
163
|
${appliers.map((applier, i) => `${JSON.stringify(String(applier.item.id))}:
|
|
186
164
|
!shouldApply${i} ?
|
|
187
165
|
false :
|
|
188
|
-
|
|
166
|
+
appliers[${i}].fn(row),
|
|
189
167
|
`).join('\n')}};
|
|
190
168
|
|
|
191
169
|
return result$$;
|
|
@@ -216,31 +194,17 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
|
216
194
|
const {
|
|
217
195
|
ignoreDiacritics
|
|
218
196
|
} = apiRef.current.rootProps;
|
|
197
|
+
const publicApiRef = getPublicApiRef(apiRef);
|
|
219
198
|
columnFields.forEach(field => {
|
|
220
199
|
const column = apiRef.current.getColumn(field);
|
|
221
200
|
const getApplyQuickFilterFn = column == null ? void 0 : column.getApplyQuickFilterFn;
|
|
222
|
-
|
|
223
|
-
const hasUserFunctionLegacy = !isInternalFilter(getApplyQuickFilterFn);
|
|
224
|
-
const hasUserFunctionV7 = !isInternalFilter(getApplyQuickFilterFnV7);
|
|
225
|
-
if (getApplyQuickFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
|
|
226
|
-
appliersPerField.push({
|
|
227
|
-
column,
|
|
228
|
-
appliers: quickFilterValues.map(quickFilterValue => {
|
|
229
|
-
const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
|
|
230
|
-
return {
|
|
231
|
-
v7: true,
|
|
232
|
-
fn: getApplyQuickFilterFnV7(value, column, apiRef)
|
|
233
|
-
};
|
|
234
|
-
})
|
|
235
|
-
});
|
|
236
|
-
} else if (getApplyQuickFilterFn) {
|
|
201
|
+
if (getApplyQuickFilterFn) {
|
|
237
202
|
appliersPerField.push({
|
|
238
203
|
column,
|
|
239
204
|
appliers: quickFilterValues.map(quickFilterValue => {
|
|
240
205
|
const value = ignoreDiacritics ? removeDiacritics(quickFilterValue) : quickFilterValue;
|
|
241
206
|
return {
|
|
242
|
-
|
|
243
|
-
fn: getApplyQuickFilterFn(value, column, apiRef)
|
|
207
|
+
fn: getApplyQuickFilterFn(value, column, publicApiRef)
|
|
244
208
|
};
|
|
245
209
|
})
|
|
246
210
|
});
|
|
@@ -248,7 +212,6 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
|
248
212
|
});
|
|
249
213
|
return function isRowMatchingQuickFilter(row, shouldApplyFilter) {
|
|
250
214
|
const result = {};
|
|
251
|
-
const usedCellParams = {};
|
|
252
215
|
|
|
253
216
|
/* eslint-disable no-restricted-syntax, no-labels */
|
|
254
217
|
outer: for (let v = 0; v < quickFilterValues.length; v += 1) {
|
|
@@ -265,31 +228,17 @@ const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
|
|
|
265
228
|
continue;
|
|
266
229
|
}
|
|
267
230
|
const applier = appliers[v];
|
|
268
|
-
let value = apiRef.current.
|
|
231
|
+
let value = apiRef.current.getRowValue(row, column);
|
|
269
232
|
if (applier.fn === null) {
|
|
270
233
|
continue;
|
|
271
234
|
}
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
continue outer;
|
|
280
|
-
}
|
|
281
|
-
} else {
|
|
282
|
-
var _usedCellParams$field;
|
|
283
|
-
const cellParams = (_usedCellParams$field = usedCellParams[field]) != null ? _usedCellParams$field : apiRef.current.getCellParams(apiRef.current.getRowId(row), field);
|
|
284
|
-
if (ignoreDiacritics) {
|
|
285
|
-
cellParams.value = removeDiacritics(cellParams.value);
|
|
286
|
-
}
|
|
287
|
-
usedCellParams[field] = cellParams;
|
|
288
|
-
const isMatching = applier.fn(cellParams);
|
|
289
|
-
if (isMatching) {
|
|
290
|
-
result[filterValue] = true;
|
|
291
|
-
continue outer;
|
|
292
|
-
}
|
|
235
|
+
if (ignoreDiacritics) {
|
|
236
|
+
value = removeDiacritics(value);
|
|
237
|
+
}
|
|
238
|
+
const isMatching = applier.fn(value, row, column, publicApiRef);
|
|
239
|
+
if (isMatching) {
|
|
240
|
+
result[filterValue] = true;
|
|
241
|
+
continue outer;
|
|
293
242
|
}
|
|
294
243
|
}
|
|
295
244
|
result[filterValue] = false;
|
|
@@ -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
|
|
|
@@ -289,7 +289,10 @@ export const useGridRows = (apiRef, props) => {
|
|
|
289
289
|
});
|
|
290
290
|
|
|
291
291
|
// Removes potential remaining skeleton rows from the dataRowIds.
|
|
292
|
-
const dataRowIds = rootGroupChildren.filter(childId =>
|
|
292
|
+
const dataRowIds = rootGroupChildren.filter(childId => {
|
|
293
|
+
var _tree$childId;
|
|
294
|
+
return ((_tree$childId = tree[childId]) == null ? void 0 : _tree$childId.type) === 'leaf';
|
|
295
|
+
});
|
|
293
296
|
apiRef.current.caches.rows.dataRowIdToModelLookup = dataRowIdToModelLookup;
|
|
294
297
|
apiRef.current.caches.rows.dataRowIdToIdLookup = dataRowIdToIdLookup;
|
|
295
298
|
apiRef.current.setState(state => _extends({}, state, {
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -72,11 +72,11 @@ 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';
|
|
78
79
|
export type { GridApiCommunity } from '../models/api/gridApiCommunity';
|
|
79
80
|
export type { GridApiCaches } from '../models/gridApiCaches';
|
|
80
81
|
export { serializeCellValue } from '../hooks/features/export/serializers/csvSerializer';
|
|
81
|
-
export * from '../colDef/utils';
|
|
82
82
|
export * from './utils';
|
package/internals/index.js
CHANGED
|
@@ -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,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
components?: Partial<SlotComponents>;
|
|
6
|
-
}): UncapitalizeObjectKeys<SlotComponents>;
|
|
1
|
+
export declare function computeSlots<SlotComponents extends object>({ defaultSlots, slots, }: {
|
|
2
|
+
defaultSlots: SlotComponents;
|
|
3
|
+
slots?: Partial<SlotComponents>;
|
|
4
|
+
}): SlotComponents;
|
|
@@ -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
|
|
6
|
+
const overrides = slots;
|
|
13
7
|
if (!overrides || Object.keys(overrides).length === 0) {
|
|
14
8
|
return defaultSlots;
|
|
15
9
|
}
|
|
16
|
-
|
|
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
|
}
|
package/internals/utils/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { GridSlotsComponent } from '../../models';
|
|
3
|
-
interface WithComponents {
|
|
4
|
-
components?: Partial<GridSlotsComponent>;
|
|
5
|
-
componentsProps?: GridSlotsComponentsProps;
|
|
6
|
-
}
|
|
7
|
-
export declare function useProps<T extends WithComponents>(allProps: T): readonly [Partial<GridSlotsComponent> | undefined, GridSlotsComponentsProps | undefined, Omit<T, "components" | "componentsProps">];
|
|
8
|
-
export {};
|
|
1
|
+
export declare function useProps<T extends Record<string, any>>(allProps: T): T;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import _objectDestructuringEmpty from "@babel/runtime/helpers/esm/objectDestructuringEmpty";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
|
|
4
5
|
/** Gathers props for the root element into a single `.forwardedProps` field */
|
|
5
6
|
function groupForwardedProps(props) {
|
|
6
7
|
var _props$forwardedProps;
|
|
@@ -23,11 +24,7 @@ function groupForwardedProps(props) {
|
|
|
23
24
|
}
|
|
24
25
|
export function useProps(allProps) {
|
|
25
26
|
return React.useMemo(() => {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
componentsProps
|
|
29
|
-
} = allProps,
|
|
30
|
-
themedProps = _objectWithoutPropertiesLoose(allProps, _excluded);
|
|
31
|
-
return [components, componentsProps, groupForwardedProps(themedProps)];
|
|
27
|
+
const themedProps = _extends({}, (_objectDestructuringEmpty(allProps), allProps));
|
|
28
|
+
return groupForwardedProps(themedProps);
|
|
32
29
|
}, [allProps]);
|
|
33
30
|
}
|
package/joy/icons.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GridIconSlotsComponent } from '../models/gridIconSlotsComponent';
|
|
2
|
-
import { UncapitalizeObjectKeys } from '../internals/utils';
|
|
3
2
|
export declare const GridArrowUpwardIcon: import("@mui/types").OverridableComponent<import("@mui/joy/SvgIcon").SvgIconTypeMap<{}, "svg">>;
|
|
4
3
|
export declare const GridArrowDownwardIcon: import("@mui/types").OverridableComponent<import("@mui/joy/SvgIcon").SvgIconTypeMap<{}, "svg">>;
|
|
5
4
|
export declare const GridKeyboardArrowLeft: import("@mui/types").OverridableComponent<import("@mui/joy/SvgIcon").SvgIconTypeMap<{}, "svg">>;
|
|
@@ -29,5 +28,5 @@ export declare const GridViewColumnIcon: import("@mui/types").OverridableCompone
|
|
|
29
28
|
export declare const GridClearIcon: import("@mui/types").OverridableComponent<import("@mui/joy/SvgIcon").SvgIconTypeMap<{}, "svg">>;
|
|
30
29
|
export declare const GridDeleteIcon: import("@mui/types").OverridableComponent<import("@mui/joy/SvgIcon").SvgIconTypeMap<{}, "svg">>;
|
|
31
30
|
export declare const GridDeleteForeverIcon: import("@mui/types").OverridableComponent<import("@mui/joy/SvgIcon").SvgIconTypeMap<{}, "svg">>;
|
|
32
|
-
declare const joyIconSlots:
|
|
31
|
+
declare const joyIconSlots: GridIconSlotsComponent;
|
|
33
32
|
export default joyIconSlots;
|
package/joy/joySlots.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { UncapitalizeObjectKeys } from '../internals/utils';
|
|
2
1
|
import type { GridSlotsComponent } from '../models';
|
|
3
|
-
declare const joySlots:
|
|
2
|
+
declare const joySlots: Partial<GridSlotsComponent>;
|
|
4
3
|
export default joySlots;
|
|
@@ -127,16 +127,6 @@ DataGridRaw.propTypes = {
|
|
|
127
127
|
* If defined, the grid will ignore the `hide` property in [[GridColDef]].
|
|
128
128
|
*/
|
|
129
129
|
columnVisibilityModel: PropTypes.object,
|
|
130
|
-
/**
|
|
131
|
-
* Overridable components.
|
|
132
|
-
* @deprecated Use `slots` instead.
|
|
133
|
-
*/
|
|
134
|
-
components: PropTypes.object,
|
|
135
|
-
/**
|
|
136
|
-
* Overridable components props dynamically passed to the component at rendering.
|
|
137
|
-
* @deprecated Use the `slotProps` prop instead.
|
|
138
|
-
*/
|
|
139
|
-
componentsProps: PropTypes.object,
|
|
140
130
|
/**
|
|
141
131
|
* Set the density of the grid.
|
|
142
132
|
* @default "standard"
|