@mui/x-data-grid 5.13.1 → 5.14.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 +44 -1
- package/DataGrid/useDataGridComponent.js +1 -1
- package/colDef/gridActionsColDef.js +2 -0
- package/colDef/gridBooleanColDef.js +3 -1
- package/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/colDef/gridDateOperators.d.ts +1 -1
- package/colDef/gridStringColDef.d.ts +3 -0
- package/colDef/gridStringColDef.js +6 -0
- package/components/base/GridOverlays.js +4 -1
- package/components/cell/GridBooleanCell.d.ts +5 -2
- package/components/cell/GridBooleanCell.js +93 -2
- package/components/cell/GridEditDateCell.js +5 -1
- package/components/cell/index.d.ts +1 -0
- package/components/cell/index.js +1 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +7 -1
- package/components/containers/GridRootStyles.js +10 -0
- package/components/toolbar/GridToolbarExport.js +20 -10
- package/constants/gridClasses.d.ts +25 -1
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +8 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
- package/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/hooks/features/columns/useGridColumns.d.ts +1 -1
- package/hooks/features/columns/useGridColumns.js +13 -6
- package/hooks/features/export/utils.d.ts +1 -1
- package/hooks/features/export/utils.js +9 -2
- package/hooks/features/filter/gridFilterUtils.js +6 -0
- package/hooks/features/filter/useGridFilter.d.ts +1 -1
- package/hooks/features/filter/useGridFilter.js +11 -4
- package/hooks/features/pagination/useGridPage.js +4 -3
- package/hooks/features/pagination/useGridPageSize.js +4 -3
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/hooks/features/rows/gridRowsUtils.d.ts +1 -1
- package/hooks/features/selection/useGridSelection.js +24 -10
- package/hooks/features/sorting/gridSortingUtils.d.ts +1 -0
- package/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/hooks/features/sorting/useGridSorting.d.ts +1 -1
- package/hooks/features/sorting/useGridSorting.js +34 -6
- package/hooks/features/statePersistence/gridStatePersistenceInterface.d.ts +12 -1
- package/hooks/features/statePersistence/index.d.ts +1 -1
- package/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +3 -4
- package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
- package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
- package/hooks/utils/useGridNativeEventListener.js +1 -1
- package/index.js +1 -1
- package/internals/index.d.ts +2 -2
- package/internals/index.js +2 -2
- package/legacy/DataGrid/useDataGridComponent.js +1 -1
- package/legacy/colDef/gridActionsColDef.js +2 -0
- package/legacy/colDef/gridBooleanColDef.js +3 -1
- package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/legacy/colDef/gridStringColDef.js +6 -0
- package/legacy/components/base/GridOverlays.js +4 -1
- package/legacy/components/cell/GridBooleanCell.js +93 -2
- package/legacy/components/cell/GridEditDateCell.js +5 -1
- package/legacy/components/cell/index.js +1 -0
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +6 -1
- package/legacy/components/containers/GridRootStyles.js +3 -3
- package/legacy/components/toolbar/GridToolbarExport.js +20 -10
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/constants/localeTextConstants.js +8 -1
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/legacy/hooks/features/columns/useGridColumns.js +13 -8
- package/legacy/hooks/features/export/utils.js +9 -2
- package/legacy/hooks/features/filter/gridFilterUtils.js +6 -0
- package/legacy/hooks/features/filter/useGridFilter.js +11 -4
- package/legacy/hooks/features/pagination/useGridPage.js +4 -3
- package/legacy/hooks/features/pagination/useGridPageSize.js +4 -3
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/legacy/hooks/features/selection/useGridSelection.js +26 -12
- package/legacy/hooks/features/sorting/gridSortingUtils.js +11 -12
- package/legacy/hooks/features/sorting/useGridSorting.js +34 -6
- package/legacy/hooks/features/statePersistence/useGridStatePersistence.js +2 -1
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +3 -4
- package/legacy/hooks/utils/useGridNativeEventListener.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +2 -2
- package/legacy/locales/arSD.js +7 -0
- package/legacy/locales/bgBG.js +7 -0
- package/legacy/locales/csCZ.js +7 -0
- package/legacy/locales/daDK.js +7 -0
- package/legacy/locales/deDE.js +8 -1
- package/legacy/locales/elGR.js +7 -0
- package/legacy/locales/esES.js +7 -0
- package/legacy/locales/faIR.js +7 -0
- package/legacy/locales/fiFI.js +7 -0
- package/legacy/locales/frFR.js +8 -1
- package/legacy/locales/heIL.js +8 -1
- package/legacy/locales/huHU.js +7 -0
- package/legacy/locales/index.js +2 -1
- package/legacy/locales/itIT.js +7 -0
- package/legacy/locales/jaJP.js +8 -1
- package/legacy/locales/koKR.js +7 -0
- package/legacy/locales/nbNO.js +8 -1
- package/legacy/locales/nlNL.js +8 -1
- package/legacy/locales/plPL.js +7 -0
- package/legacy/locales/ptBR.js +8 -1
- package/legacy/locales/roRO.js +8 -1
- package/legacy/locales/ruRU.js +7 -0
- package/legacy/locales/skSK.js +8 -1
- package/legacy/locales/svSE.js +8 -1
- package/legacy/locales/trTR.js +7 -0
- package/legacy/locales/ukUA.js +7 -0
- package/legacy/locales/viVN.js +7 -0
- package/legacy/locales/zhCN.js +7 -0
- package/legacy/locales/zhTW.js +135 -0
- package/legacy/models/events/gridEvents.js +1 -0
- package/locales/arSD.js +7 -0
- package/locales/bgBG.js +7 -0
- package/locales/csCZ.js +7 -0
- package/locales/daDK.js +7 -0
- package/locales/deDE.js +8 -1
- package/locales/elGR.js +7 -0
- package/locales/esES.js +7 -0
- package/locales/faIR.js +7 -0
- package/locales/fiFI.js +7 -0
- package/locales/frFR.js +8 -1
- package/locales/heIL.js +8 -1
- package/locales/huHU.js +7 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +2 -1
- package/locales/itIT.js +7 -0
- package/locales/jaJP.js +8 -1
- package/locales/koKR.js +7 -0
- package/locales/nbNO.js +8 -1
- package/locales/nlNL.js +8 -1
- package/locales/plPL.js +7 -0
- package/locales/ptBR.js +8 -1
- package/locales/roRO.js +8 -1
- package/locales/ruRU.js +7 -0
- package/locales/skSK.js +8 -1
- package/locales/svSE.js +8 -1
- package/locales/trTR.js +7 -0
- package/locales/ukUA.js +7 -0
- package/locales/viVN.js +7 -0
- package/locales/zhCN.js +7 -0
- package/locales/zhTW.d.ts +2 -0
- package/locales/zhTW.js +123 -0
- package/models/api/gridColumnSpanning.d.ts +2 -0
- package/models/api/gridLocaleTextApi.d.ts +8 -2
- package/models/api/gridSelectionApi.d.ts +6 -0
- package/models/events/gridEvents.d.ts +1 -0
- package/models/events/gridEvents.js +1 -0
- package/models/gridRows.d.ts +10 -1
- package/models/params/gridCellParams.d.ts +4 -4
- package/modern/DataGrid/useDataGridComponent.js +1 -1
- package/modern/colDef/gridActionsColDef.js +2 -0
- package/modern/colDef/gridBooleanColDef.js +3 -1
- package/modern/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/modern/colDef/gridStringColDef.js +6 -0
- package/modern/components/base/GridOverlays.js +4 -1
- package/modern/components/cell/GridBooleanCell.js +93 -2
- package/modern/components/cell/GridEditDateCell.js +5 -1
- package/modern/components/cell/index.js +1 -0
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +7 -1
- package/modern/components/containers/GridRootStyles.js +10 -0
- package/modern/components/toolbar/GridToolbarExport.js +20 -10
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +8 -1
- package/modern/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/modern/hooks/features/columns/useGridColumns.js +10 -5
- package/modern/hooks/features/export/utils.js +5 -2
- package/modern/hooks/features/filter/gridFilterUtils.js +6 -0
- package/modern/hooks/features/filter/useGridFilter.js +8 -3
- package/modern/hooks/features/pagination/useGridPage.js +4 -3
- package/modern/hooks/features/pagination/useGridPageSize.js +4 -3
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +8 -4
- package/modern/hooks/features/selection/useGridSelection.js +22 -10
- package/modern/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/modern/hooks/features/sorting/useGridSorting.js +30 -6
- package/modern/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +3 -4
- package/modern/hooks/utils/useGridNativeEventListener.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -2
- package/modern/locales/arSD.js +7 -0
- package/modern/locales/bgBG.js +7 -0
- package/modern/locales/csCZ.js +7 -0
- package/modern/locales/daDK.js +7 -0
- package/modern/locales/deDE.js +8 -1
- package/modern/locales/elGR.js +7 -0
- package/modern/locales/esES.js +7 -0
- package/modern/locales/faIR.js +7 -0
- package/modern/locales/fiFI.js +7 -0
- package/modern/locales/frFR.js +8 -1
- package/modern/locales/heIL.js +8 -1
- package/modern/locales/huHU.js +7 -0
- package/modern/locales/index.js +2 -1
- package/modern/locales/itIT.js +7 -0
- package/modern/locales/jaJP.js +8 -1
- package/modern/locales/koKR.js +7 -0
- package/modern/locales/nbNO.js +8 -1
- package/modern/locales/nlNL.js +8 -1
- package/modern/locales/plPL.js +7 -0
- package/modern/locales/ptBR.js +8 -1
- package/modern/locales/roRO.js +8 -1
- package/modern/locales/ruRU.js +7 -0
- package/modern/locales/skSK.js +8 -1
- package/modern/locales/svSE.js +8 -1
- package/modern/locales/trTR.js +7 -0
- package/modern/locales/ukUA.js +7 -0
- package/modern/locales/viVN.js +7 -0
- package/modern/locales/zhCN.js +7 -0
- package/modern/locales/zhTW.js +123 -0
- package/modern/models/events/gridEvents.js +1 -0
- package/node/DataGrid/useDataGridComponent.js +1 -1
- package/node/colDef/gridActionsColDef.js +2 -0
- package/node/colDef/gridBooleanColDef.js +3 -1
- package/node/colDef/gridCheckboxSelectionColDef.js +2 -0
- package/node/colDef/gridStringColDef.js +5 -0
- package/node/components/base/GridOverlays.js +4 -1
- package/node/components/cell/GridBooleanCell.js +93 -2
- package/node/components/cell/GridEditDateCell.js +7 -1
- package/node/components/cell/index.js +13 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +7 -1
- package/node/components/containers/GridRootStyles.js +10 -0
- package/node/components/toolbar/GridToolbarExport.js +16 -10
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +8 -1
- package/node/hooks/features/columns/useGridColumnSpanning.js +9 -7
- package/node/hooks/features/columns/useGridColumns.js +13 -6
- package/node/hooks/features/export/utils.js +10 -2
- package/node/hooks/features/filter/gridFilterUtils.js +7 -0
- package/node/hooks/features/filter/useGridFilter.js +11 -4
- package/node/hooks/features/pagination/useGridPage.js +4 -3
- package/node/hooks/features/pagination/useGridPageSize.js +4 -3
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
- package/node/hooks/features/selection/useGridSelection.js +24 -10
- package/node/hooks/features/sorting/gridSortingUtils.js +10 -11
- package/node/hooks/features/sorting/useGridSorting.js +34 -6
- package/node/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +3 -4
- package/node/hooks/utils/useGridNativeEventListener.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +18 -0
- package/node/locales/arSD.js +7 -0
- package/node/locales/bgBG.js +7 -0
- package/node/locales/csCZ.js +7 -0
- package/node/locales/daDK.js +7 -0
- package/node/locales/deDE.js +8 -1
- package/node/locales/elGR.js +7 -0
- package/node/locales/esES.js +7 -0
- package/node/locales/faIR.js +7 -0
- package/node/locales/fiFI.js +7 -0
- package/node/locales/frFR.js +8 -1
- package/node/locales/heIL.js +8 -1
- package/node/locales/huHU.js +7 -0
- package/node/locales/index.js +13 -0
- package/node/locales/itIT.js +7 -0
- package/node/locales/jaJP.js +8 -1
- package/node/locales/koKR.js +7 -0
- package/node/locales/nbNO.js +8 -1
- package/node/locales/nlNL.js +8 -1
- package/node/locales/plPL.js +7 -0
- package/node/locales/ptBR.js +8 -1
- package/node/locales/roRO.js +8 -1
- package/node/locales/ruRU.js +7 -0
- package/node/locales/skSK.js +8 -1
- package/node/locales/svSE.js +8 -1
- package/node/locales/trTR.js +7 -0
- package/node/locales/ukUA.js +7 -0
- package/node/locales/viVN.js +7 -0
- package/node/locales/zhCN.js +7 -0
- package/node/locales/zhTW.js +133 -0
- package/node/models/events/gridEvents.js +1 -0
- package/package.json +1 -1
- package/utils/getGridLocalization.d.ts +1 -1
|
@@ -52,6 +52,7 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
|
|
|
52
52
|
field,
|
|
53
53
|
id,
|
|
54
54
|
value: isChecked,
|
|
55
|
+
rowNode,
|
|
55
56
|
hasFocus,
|
|
56
57
|
tabIndex
|
|
57
58
|
} = props,
|
|
@@ -100,7 +101,12 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
|
|
|
100
101
|
apiRef.current.publishEvent('cellNavigationKeyDown', props, event);
|
|
101
102
|
}
|
|
102
103
|
}, [apiRef, props]);
|
|
103
|
-
|
|
104
|
+
|
|
105
|
+
if (rowNode.position === 'footer') {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const isSelectable = apiRef.current.isRowSelectable(id);
|
|
104
110
|
const label = apiRef.current.getLocaleText(isChecked ? 'checkboxSelectionUnselectRow' : 'checkboxSelectionSelectRow');
|
|
105
111
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.components.BaseCheckbox, (0, _extends2.default)({
|
|
106
112
|
ref: handleRef,
|
|
@@ -18,6 +18,16 @@ const GridRootStyles = (0, _styles.styled)('div', {
|
|
|
18
18
|
slot: 'Root',
|
|
19
19
|
overridesResolver: (props, styles) => [{
|
|
20
20
|
[`&.${_gridClasses.gridClasses.autoHeight}`]: styles.autoHeight
|
|
21
|
+
}, {
|
|
22
|
+
[`&.${_gridClasses.gridClasses.aggregationColumnHeader}`]: styles.aggregationColumnHeader
|
|
23
|
+
}, {
|
|
24
|
+
[`&.${_gridClasses.gridClasses['aggregationColumnHeader--alignLeft']}`]: styles['aggregationColumnHeader--alignLeft']
|
|
25
|
+
}, {
|
|
26
|
+
[`&.${_gridClasses.gridClasses['aggregationColumnHeader--alignCenter']}`]: styles['aggregationColumnHeader--alignCenter']
|
|
27
|
+
}, {
|
|
28
|
+
[`&.${_gridClasses.gridClasses['aggregationColumnHeader--alignRight']}`]: styles['aggregationColumnHeader--alignRight']
|
|
29
|
+
}, {
|
|
30
|
+
[`&.${_gridClasses.gridClasses.aggregationColumnHeaderLabel}`]: styles.aggregationColumnHeaderLabel
|
|
21
31
|
}, {
|
|
22
32
|
[`& .${_gridClasses.gridClasses.editBooleanCell}`]: styles.editBooleanCell
|
|
23
33
|
}, {
|
|
@@ -23,7 +23,9 @@ var _GridToolbarExportContainer = require("./GridToolbarExportContainer");
|
|
|
23
23
|
|
|
24
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
25
|
|
|
26
|
-
const _excluded = ["
|
|
26
|
+
const _excluded = ["hideMenu", "options"],
|
|
27
|
+
_excluded2 = ["hideMenu", "options"],
|
|
28
|
+
_excluded3 = ["csvOptions", "printOptions", "excelOptions"];
|
|
27
29
|
|
|
28
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
31
|
|
|
@@ -34,14 +36,16 @@ const GridCsvExportMenuItem = props => {
|
|
|
34
36
|
const {
|
|
35
37
|
hideMenu,
|
|
36
38
|
options
|
|
37
|
-
} = props
|
|
38
|
-
|
|
39
|
+
} = props,
|
|
40
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
41
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuItem.default, (0, _extends2.default)({
|
|
39
42
|
onClick: () => {
|
|
40
43
|
apiRef.current.exportDataAsCsv(options);
|
|
41
44
|
hideMenu == null ? void 0 : hideMenu();
|
|
42
|
-
}
|
|
45
|
+
}
|
|
46
|
+
}, other, {
|
|
43
47
|
children: apiRef.current.getLocaleText('toolbarExportCSV')
|
|
44
|
-
});
|
|
48
|
+
}));
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
exports.GridCsvExportMenuItem = GridCsvExportMenuItem;
|
|
@@ -51,14 +55,16 @@ const GridPrintExportMenuItem = props => {
|
|
|
51
55
|
const {
|
|
52
56
|
hideMenu,
|
|
53
57
|
options
|
|
54
|
-
} = props
|
|
55
|
-
|
|
58
|
+
} = props,
|
|
59
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded2);
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuItem.default, (0, _extends2.default)({
|
|
56
61
|
onClick: () => {
|
|
57
62
|
apiRef.current.exportDataAsPrint(options);
|
|
58
63
|
hideMenu == null ? void 0 : hideMenu();
|
|
59
|
-
}
|
|
64
|
+
}
|
|
65
|
+
}, other, {
|
|
60
66
|
children: apiRef.current.getLocaleText('toolbarExportPrint')
|
|
61
|
-
});
|
|
67
|
+
}));
|
|
62
68
|
};
|
|
63
69
|
|
|
64
70
|
exports.GridPrintExportMenuItem = GridPrintExportMenuItem;
|
|
@@ -68,7 +74,7 @@ const GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExpo
|
|
|
68
74
|
printOptions = {},
|
|
69
75
|
excelOptions
|
|
70
76
|
} = props,
|
|
71
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(props,
|
|
77
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded3);
|
|
72
78
|
const apiRef = (0, _useGridApiContext.useGridApiContext)();
|
|
73
79
|
const preProcessedButtons = apiRef.current.unstable_applyPipeProcessors('exportMenu', [], {
|
|
74
80
|
excelOptions,
|
|
@@ -12,5 +12,5 @@ function getDataGridUtilityClass(slot) {
|
|
|
12
12
|
return (0, _material.generateUtilityClass)('MuiDataGrid', slot);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const gridClasses = (0, _material.generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
15
|
+
const gridClasses = (0, _material.generateUtilityClasses)('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'autoHeight', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--withRenderer', 'cell', 'cellContent', 'cellCheckbox', 'checkboxInput', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderDropZone', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeaders', 'columnHeadersInner', 'columnHeadersInner--scrollable', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsPanel', 'columnsPanelRow', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filterForm', 'filterFormDeleteIcon', 'filterFormLinkOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'iconButtonContainer', 'iconSeparator', 'main', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'row', 'row--editable', 'row--editing', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'pinnedColumns--left', 'pinnedColumns--right', 'pinnedColumnHeaders', 'pinnedColumnHeaders--left', 'pinnedColumnHeaders--right', 'withBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'groupingCriteriaCell', 'groupingCriteriaCellToggle']);
|
|
16
16
|
exports.gridClasses = gridClasses;
|
|
@@ -117,6 +117,13 @@ const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
117
117
|
// Used core components translation keys
|
|
118
118
|
MuiTablePagination: {},
|
|
119
119
|
// Row reordering text
|
|
120
|
-
rowReorderingHeaderName: 'Row reordering'
|
|
120
|
+
rowReorderingHeaderName: 'Row reordering',
|
|
121
|
+
// Aggregation
|
|
122
|
+
aggregationMenuItemHeader: 'Aggregation',
|
|
123
|
+
aggregationFunctionLabelSum: 'sum',
|
|
124
|
+
aggregationFunctionLabelAvg: 'avg',
|
|
125
|
+
aggregationFunctionLabelMin: 'min',
|
|
126
|
+
aggregationFunctionLabelMax: 'max',
|
|
127
|
+
aggregationFunctionLabelSize: 'size'
|
|
121
128
|
};
|
|
122
129
|
exports.GRID_DEFAULT_LOCALE_TEXT = GRID_DEFAULT_LOCALE_TEXT;
|
|
@@ -41,11 +41,11 @@ const useGridColumnSpanning = apiRef => {
|
|
|
41
41
|
columnIndex,
|
|
42
42
|
rowId,
|
|
43
43
|
minFirstColumnIndex,
|
|
44
|
-
maxLastColumnIndex
|
|
44
|
+
maxLastColumnIndex,
|
|
45
|
+
columns
|
|
45
46
|
} = params;
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const column = visibleColumns[columnIndex];
|
|
47
|
+
const columnsLength = columns.length;
|
|
48
|
+
const column = columns[columnIndex];
|
|
49
49
|
const colSpan = typeof column.colSpan === 'function' ? column.colSpan(apiRef.current.getCellParams(rowId, column.field)) : column.colSpan;
|
|
50
50
|
|
|
51
51
|
if (!colSpan || colSpan === 1) {
|
|
@@ -67,7 +67,7 @@ const useGridColumnSpanning = apiRef => {
|
|
|
67
67
|
const nextColumnIndex = columnIndex + j; // Cells should be spanned only within their column section (left-pinned, right-pinned and unpinned).
|
|
68
68
|
|
|
69
69
|
if (nextColumnIndex >= minFirstColumnIndex && nextColumnIndex < maxLastColumnIndex) {
|
|
70
|
-
const nextColumn =
|
|
70
|
+
const nextColumn = columns[nextColumnIndex];
|
|
71
71
|
width += nextColumn.computedWidth;
|
|
72
72
|
setCellColSpanInfo(rowId, columnIndex + j, {
|
|
73
73
|
spannedByColSpan: true,
|
|
@@ -93,14 +93,16 @@ const useGridColumnSpanning = apiRef => {
|
|
|
93
93
|
const calculateColSpan = React.useCallback(({
|
|
94
94
|
rowId,
|
|
95
95
|
minFirstColumn,
|
|
96
|
-
maxLastColumn
|
|
96
|
+
maxLastColumn,
|
|
97
|
+
columns
|
|
97
98
|
}) => {
|
|
98
99
|
for (let i = minFirstColumn; i < maxLastColumn; i += 1) {
|
|
99
100
|
const cellProps = calculateCellColSpan({
|
|
100
101
|
columnIndex: i,
|
|
101
102
|
rowId,
|
|
102
103
|
minFirstColumnIndex: minFirstColumn,
|
|
103
|
-
maxLastColumnIndex: maxLastColumn
|
|
104
|
+
maxLastColumnIndex: maxLastColumn,
|
|
105
|
+
columns
|
|
104
106
|
});
|
|
105
107
|
|
|
106
108
|
if (cellProps.colSpan > 1) {
|
|
@@ -63,7 +63,7 @@ const columnsStateInitializer = (state, props, apiRef) => {
|
|
|
63
63
|
exports.columnsStateInitializer = columnsStateInitializer;
|
|
64
64
|
|
|
65
65
|
function useGridColumns(apiRef, props) {
|
|
66
|
-
var _props$componentsProp2;
|
|
66
|
+
var _props$initialState5, _props$componentsProp2;
|
|
67
67
|
|
|
68
68
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridColumns');
|
|
69
69
|
const columnTypes = React.useMemo(() => (0, _gridColumnsUtils.computeColumnTypes)(props.columnTypes), [props.columnTypes]);
|
|
@@ -214,14 +214,21 @@ function useGridColumns(apiRef, props) {
|
|
|
214
214
|
* PRE-PROCESSING
|
|
215
215
|
*/
|
|
216
216
|
|
|
217
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
217
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
218
218
|
const columnsStateToExport = {};
|
|
219
219
|
|
|
220
220
|
if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
|
|
221
|
-
|
|
222
|
-
const hasHiddenColumns = Object.values(columnVisibilityModelToExport).some(value => value === false);
|
|
221
|
+
var _props$initialState$c2, _props$initialState4, _props$initialState4$;
|
|
223
222
|
|
|
224
|
-
|
|
223
|
+
const columnVisibilityModelToExport = (0, _gridColumnsSelector.gridColumnVisibilityModelSelector)(apiRef);
|
|
224
|
+
const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
225
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
226
|
+
props.columnVisibilityModel != null || // Always export if the model has been initialized
|
|
227
|
+
// TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
|
|
228
|
+
Object.keys((_props$initialState$c2 = (_props$initialState4 = props.initialState) == null ? void 0 : (_props$initialState4$ = _props$initialState4.columns) == null ? void 0 : _props$initialState4$.columnVisibilityModel) != null ? _props$initialState$c2 : {}).length > 0 || // Always export if the model is not empty
|
|
229
|
+
Object.keys(columnVisibilityModelToExport).length > 0;
|
|
230
|
+
|
|
231
|
+
if (shouldExportColumnVisibilityModel) {
|
|
225
232
|
columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
|
|
226
233
|
}
|
|
227
234
|
}
|
|
@@ -254,7 +261,7 @@ function useGridColumns(apiRef, props) {
|
|
|
254
261
|
return (0, _extends2.default)({}, prevState, {
|
|
255
262
|
columns: columnsStateToExport
|
|
256
263
|
});
|
|
257
|
-
}, [apiRef]);
|
|
264
|
+
}, [apiRef, props.columnVisibilityModel, (_props$initialState5 = props.initialState) == null ? void 0 : _props$initialState5.columns]);
|
|
258
265
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
259
266
|
var _context$stateToResto;
|
|
260
267
|
|
|
@@ -9,6 +9,8 @@ var _columns = require("../columns");
|
|
|
9
9
|
|
|
10
10
|
var _filter = require("../filter");
|
|
11
11
|
|
|
12
|
+
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
13
|
+
|
|
12
14
|
const getColumnsToExport = ({
|
|
13
15
|
apiRef,
|
|
14
16
|
options
|
|
@@ -29,13 +31,19 @@ const defaultGetRowsToExport = ({
|
|
|
29
31
|
apiRef
|
|
30
32
|
}) => {
|
|
31
33
|
const filteredSortedRowIds = (0, _filter.gridFilteredSortedRowIdsSelector)(apiRef);
|
|
34
|
+
const rowTree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
|
|
32
35
|
const selectedRows = apiRef.current.getSelectedRows();
|
|
36
|
+
const bodyRows = filteredSortedRowIds.filter(id => {
|
|
37
|
+
var _rowTree$id$position;
|
|
38
|
+
|
|
39
|
+
return ((_rowTree$id$position = rowTree[id].position) != null ? _rowTree$id$position : 'body') === 'body';
|
|
40
|
+
});
|
|
33
41
|
|
|
34
42
|
if (selectedRows.size > 0) {
|
|
35
|
-
return
|
|
43
|
+
return bodyRows.filter(id => selectedRows.has(id));
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
return
|
|
46
|
+
return bodyRows;
|
|
39
47
|
};
|
|
40
48
|
|
|
41
49
|
exports.defaultGetRowsToExport = defaultGetRowsToExport;
|
|
@@ -15,6 +15,8 @@ var _warning = require("../../../utils/warning");
|
|
|
15
15
|
|
|
16
16
|
var _columns = require("../columns");
|
|
17
17
|
|
|
18
|
+
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* Adds default values to the optional fields of a filter items.
|
|
20
22
|
* @param {GridFilterItem} item The raw filter item.
|
|
@@ -101,6 +103,7 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef) => {
|
|
|
101
103
|
items,
|
|
102
104
|
linkOperator = _models.GridLinkOperator.And
|
|
103
105
|
} = filterModel;
|
|
106
|
+
const tree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
|
|
104
107
|
|
|
105
108
|
const getFilterCallbackFromItem = filterItem => {
|
|
106
109
|
if (!filterItem.columnField || !filterItem.operatorValue) {
|
|
@@ -163,6 +166,10 @@ const buildAggregatedFilterItemsApplier = (filterModel, apiRef) => {
|
|
|
163
166
|
}
|
|
164
167
|
|
|
165
168
|
return (rowId, shouldApplyFilter) => {
|
|
169
|
+
if (tree[rowId].position === 'footer') {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
|
|
166
173
|
const filteredAppliers = shouldApplyFilter ? appliers.filter(applier => shouldApplyFilter(applier.item.columnField)) : appliers; // Return `false` as soon as we have a failing filter
|
|
167
174
|
|
|
168
175
|
if (linkOperator === _models.GridLinkOperator.And) {
|
|
@@ -67,7 +67,7 @@ const filterStateInitializer = (state, props, apiRef) => {
|
|
|
67
67
|
exports.filterStateInitializer = filterStateInitializer;
|
|
68
68
|
|
|
69
69
|
const useGridFilter = (apiRef, props) => {
|
|
70
|
-
var _props$componentsProp2;
|
|
70
|
+
var _props$initialState3, _props$initialState3$, _props$componentsProp2;
|
|
71
71
|
|
|
72
72
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridFilter');
|
|
73
73
|
apiRef.current.unstable_registerControlState({
|
|
@@ -243,10 +243,17 @@ const useGridFilter = (apiRef, props) => {
|
|
|
243
243
|
* PRE-PROCESSING
|
|
244
244
|
*/
|
|
245
245
|
|
|
246
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
246
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
247
|
+
var _props$initialState2, _props$initialState2$;
|
|
248
|
+
|
|
247
249
|
const filterModelToExport = (0, _gridFilterSelector.gridFilterModelSelector)(apiRef);
|
|
250
|
+
const shouldExportFilterModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
251
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
252
|
+
props.filterModel != null || // Always export if the model has been initialized
|
|
253
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.filter) == null ? void 0 : _props$initialState2$.filterModel) != null || // Export if the model is not equal to the default value
|
|
254
|
+
!(0, _utils.isDeepEqual)(filterModelToExport, (0, _gridFilterState.getDefaultGridFilterModel)());
|
|
248
255
|
|
|
249
|
-
if (
|
|
256
|
+
if (!shouldExportFilterModel) {
|
|
250
257
|
return prevState;
|
|
251
258
|
}
|
|
252
259
|
|
|
@@ -255,7 +262,7 @@ const useGridFilter = (apiRef, props) => {
|
|
|
255
262
|
filterModel: filterModelToExport
|
|
256
263
|
}
|
|
257
264
|
});
|
|
258
|
-
}, [apiRef]);
|
|
265
|
+
}, [apiRef, props.filterModel, (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.filter) == null ? void 0 : _props$initialState3$.filterModel]);
|
|
259
266
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
260
267
|
var _context$stateToResto;
|
|
261
268
|
|
|
@@ -85,13 +85,14 @@ const useGridPage = (apiRef, props) => {
|
|
|
85
85
|
* PRE-PROCESSING
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
88
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
89
89
|
var _props$initialState, _props$initialState$p;
|
|
90
90
|
|
|
91
91
|
const pageToExport = (0, _gridPaginationSelector.gridPageSelector)(apiRef);
|
|
92
|
-
const shouldExportPage = // Always export if the
|
|
92
|
+
const shouldExportPage = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
93
|
+
!context.exportOnlyDirtyModels || // Always export if the page is controlled
|
|
93
94
|
props.page != null || // Always export if the page has been initialized
|
|
94
|
-
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page
|
|
95
|
+
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page is not equal to the default value
|
|
95
96
|
pageToExport !== 0;
|
|
96
97
|
|
|
97
98
|
if (!shouldExportPage) {
|
|
@@ -70,13 +70,14 @@ const useGridPageSize = (apiRef, props) => {
|
|
|
70
70
|
* PRE-PROCESSING
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
73
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
74
74
|
var _props$initialState, _props$initialState$p;
|
|
75
75
|
|
|
76
76
|
const pageSizeToExport = (0, _gridPaginationSelector.gridPageSizeSelector)(apiRef);
|
|
77
|
-
const shouldExportPageSize = // Always export if the
|
|
77
|
+
const shouldExportPageSize = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
78
|
+
!context.exportOnlyDirtyModels || // Always export if the page size is controlled
|
|
78
79
|
props.pageSize != null || // Always export if the page size has been initialized
|
|
79
|
-
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size
|
|
80
|
+
((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size is not equal to the default value
|
|
80
81
|
pageSizeToExport !== defaultPageSize(props.autoPageSize);
|
|
81
82
|
|
|
82
83
|
if (!shouldExportPageSize) {
|
|
@@ -39,7 +39,9 @@ const preferencePanelStateInitializer = (state, props) => {
|
|
|
39
39
|
|
|
40
40
|
exports.preferencePanelStateInitializer = preferencePanelStateInitializer;
|
|
41
41
|
|
|
42
|
-
const useGridPreferencesPanel = apiRef => {
|
|
42
|
+
const useGridPreferencesPanel = (apiRef, props) => {
|
|
43
|
+
var _props$initialState3;
|
|
44
|
+
|
|
43
45
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridPreferencesPanel');
|
|
44
46
|
const hideTimeout = React.useRef();
|
|
45
47
|
const immediateTimeout = React.useRef();
|
|
@@ -96,17 +98,23 @@ const useGridPreferencesPanel = apiRef => {
|
|
|
96
98
|
* PRE-PROCESSING
|
|
97
99
|
*/
|
|
98
100
|
|
|
99
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
101
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
102
|
+
var _props$initialState2;
|
|
103
|
+
|
|
100
104
|
const preferencePanelToExport = (0, _gridPreferencePanelSelector.gridPreferencePanelStateSelector)(apiRef.current.state);
|
|
105
|
+
const shouldExportPreferencePanel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
106
|
+
!context.exportOnlyDirtyModels || // Always export if the panel was initialized
|
|
107
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.preferencePanel) != null || // Always export if the panel is opened
|
|
108
|
+
preferencePanelToExport.open;
|
|
101
109
|
|
|
102
|
-
if (!
|
|
110
|
+
if (!shouldExportPreferencePanel) {
|
|
103
111
|
return prevState;
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
return (0, _extends2.default)({}, prevState, {
|
|
107
115
|
preferencePanel: preferencePanelToExport
|
|
108
116
|
});
|
|
109
|
-
}, [apiRef]);
|
|
117
|
+
}, [apiRef, (_props$initialState3 = props.initialState) == null ? void 0 : _props$initialState3.preferencePanel]);
|
|
110
118
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
111
119
|
const preferencePanel = context.stateToRestore.preferencePanel;
|
|
112
120
|
|
|
@@ -91,9 +91,9 @@ const useGridSelection = (apiRef, props) => {
|
|
|
91
91
|
checkboxSelection,
|
|
92
92
|
disableMultipleSelection,
|
|
93
93
|
disableSelectionOnClick,
|
|
94
|
-
isRowSelectable,
|
|
95
94
|
pagination,
|
|
96
|
-
paginationMode
|
|
95
|
+
paginationMode,
|
|
96
|
+
isRowSelectable: propIsRowSelectable
|
|
97
97
|
} = props;
|
|
98
98
|
const canHaveMultipleSelection = !disableMultipleSelection || checkboxSelection;
|
|
99
99
|
const visibleRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
|
|
@@ -142,9 +142,22 @@ const useGridSelection = (apiRef, props) => {
|
|
|
142
142
|
}
|
|
143
143
|
}, [apiRef, logger]);
|
|
144
144
|
const isRowSelected = React.useCallback(id => (0, _gridSelectionSelector.gridSelectionStateSelector)(apiRef.current.state).includes(id), [apiRef]);
|
|
145
|
+
const isRowSelectable = React.useCallback(id => {
|
|
146
|
+
var _apiRef$current$getRo;
|
|
147
|
+
|
|
148
|
+
if (propIsRowSelectable && !propIsRowSelectable(apiRef.current.getRowParams(id))) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (((_apiRef$current$getRo = apiRef.current.getRowNode(id)) == null ? void 0 : _apiRef$current$getRo.position) === 'footer') {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return true;
|
|
157
|
+
}, [apiRef, propIsRowSelectable]);
|
|
145
158
|
const getSelectedRows = React.useCallback(() => (0, _gridSelectionSelector.selectedGridRowsSelector)(apiRef), [apiRef]);
|
|
146
159
|
const selectRow = React.useCallback((id, isSelected = true, resetSelection = false) => {
|
|
147
|
-
if (
|
|
160
|
+
if (!apiRef.current.isRowSelectable(id)) {
|
|
148
161
|
return;
|
|
149
162
|
}
|
|
150
163
|
|
|
@@ -168,10 +181,10 @@ const useGridSelection = (apiRef, props) => {
|
|
|
168
181
|
apiRef.current.setSelectionModel(newSelection);
|
|
169
182
|
}
|
|
170
183
|
}
|
|
171
|
-
}, [apiRef,
|
|
184
|
+
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
172
185
|
const selectRows = React.useCallback((ids, isSelected = true, resetSelection = false) => {
|
|
173
186
|
logger.debug(`Setting selection for several rows`);
|
|
174
|
-
const selectableIds =
|
|
187
|
+
const selectableIds = ids.filter(id => apiRef.current.isRowSelectable(id));
|
|
175
188
|
let newSelection;
|
|
176
189
|
|
|
177
190
|
if (resetSelection) {
|
|
@@ -194,7 +207,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
194
207
|
if (isSelectionValid) {
|
|
195
208
|
apiRef.current.setSelectionModel(newSelection);
|
|
196
209
|
}
|
|
197
|
-
}, [apiRef,
|
|
210
|
+
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
198
211
|
const selectRowRange = React.useCallback(({
|
|
199
212
|
startId,
|
|
200
213
|
endId
|
|
@@ -218,7 +231,8 @@ const useGridSelection = (apiRef, props) => {
|
|
|
218
231
|
selectRowRange,
|
|
219
232
|
setSelectionModel,
|
|
220
233
|
getSelectedRows,
|
|
221
|
-
isRowSelected
|
|
234
|
+
isRowSelected,
|
|
235
|
+
isRowSelectable
|
|
222
236
|
};
|
|
223
237
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, selectionApi, 'GridSelectionApi');
|
|
224
238
|
/**
|
|
@@ -399,13 +413,13 @@ const useGridSelection = (apiRef, props) => {
|
|
|
399
413
|
React.useEffect(() => {
|
|
400
414
|
if (isStateControlled) {
|
|
401
415
|
return;
|
|
402
|
-
} // isRowSelectable changed
|
|
416
|
+
} // props.isRowSelectable changed
|
|
403
417
|
|
|
404
418
|
|
|
405
419
|
const currentSelection = (0, _gridSelectionSelector.gridSelectionStateSelector)(apiRef.current.state);
|
|
406
420
|
|
|
407
421
|
if (isRowSelectable) {
|
|
408
|
-
const newSelection = currentSelection.filter(id => isRowSelectable(
|
|
422
|
+
const newSelection = currentSelection.filter(id => isRowSelectable(id));
|
|
409
423
|
|
|
410
424
|
if (newSelection.length < currentSelection.length) {
|
|
411
425
|
apiRef.current.setSelectionModel(newSelection);
|
|
@@ -432,7 +446,7 @@ const useGridSelection = (apiRef, props) => {
|
|
|
432
446
|
let isSelectable = true;
|
|
433
447
|
|
|
434
448
|
if (isRowSelectable) {
|
|
435
|
-
isSelectable = isRowSelectable(
|
|
449
|
+
isSelectable = isRowSelectable(id);
|
|
436
450
|
}
|
|
437
451
|
|
|
438
452
|
return isSelectable && currentPageRowsLookup[id]; // Check if the row is in the current page
|
|
@@ -63,25 +63,24 @@ const parseSortItem = (sortItem, apiRef) => {
|
|
|
63
63
|
comparator
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
|
+
|
|
66
67
|
/**
|
|
67
68
|
* Compare two rows according to a list of valid sort items.
|
|
68
69
|
* The `row1Params` and `row2Params` must have the same length as `parsedSortItems`,
|
|
69
70
|
* and each of their index must contain the `GridSortCellParams` of the sort item with the same index.
|
|
70
71
|
* @param {GridParsedSortItem[]} parsedSortItems All the sort items with which we want to compare the rows.
|
|
71
|
-
* @param {
|
|
72
|
-
* @param {
|
|
72
|
+
* @param {GridRowAggregatedSortingParams} row1 The node and params of the 1st row for each sort item.
|
|
73
|
+
* @param {GridRowAggregatedSortingParams} row2 The node and params of the 2nd row for each sort item.
|
|
73
74
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const compareRows = (parsedSortItems, row1Params, row2Params) => {
|
|
75
|
+
const compareRows = (parsedSortItems, row1, row2) => {
|
|
77
76
|
return parsedSortItems.reduce((res, item, index) => {
|
|
78
77
|
if (res !== 0) {
|
|
79
78
|
// return the results of the first comparator which distinguish the two rows
|
|
80
79
|
return res;
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
const sortCellParams1 =
|
|
84
|
-
const sortCellParams2 =
|
|
82
|
+
const sortCellParams1 = row1.params[index];
|
|
83
|
+
const sortCellParams2 = row2.params[index];
|
|
85
84
|
res = item.comparator(sortCellParams1.value, sortCellParams2.value, sortCellParams1, sortCellParams2);
|
|
86
85
|
return res;
|
|
87
86
|
}, 0);
|
|
@@ -101,10 +100,10 @@ const buildAggregatedSortingApplier = (sortModel, apiRef) => {
|
|
|
101
100
|
return null;
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
return rowList => rowList.map(
|
|
105
|
-
|
|
106
|
-
params: comparatorList.map(el => el.getSortCellParams(
|
|
107
|
-
})).sort((a, b) => compareRows(comparatorList, a
|
|
103
|
+
return rowList => rowList.map(node => ({
|
|
104
|
+
node,
|
|
105
|
+
params: comparatorList.map(el => el.getSortCellParams(node.id))
|
|
106
|
+
})).sort((a, b) => compareRows(comparatorList, a, b)).map(row => row.node.id);
|
|
108
107
|
};
|
|
109
108
|
|
|
110
109
|
exports.buildAggregatedSortingApplier = buildAggregatedSortingApplier;
|
|
@@ -59,6 +59,8 @@ const sortingStateInitializer = (state, props) => {
|
|
|
59
59
|
exports.sortingStateInitializer = sortingStateInitializer;
|
|
60
60
|
|
|
61
61
|
const useGridSorting = (apiRef, props) => {
|
|
62
|
+
var _props$initialState3, _props$initialState3$;
|
|
63
|
+
|
|
62
64
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridSorting');
|
|
63
65
|
apiRef.current.unstable_registerControlState({
|
|
64
66
|
stateId: 'sortModel',
|
|
@@ -182,10 +184,17 @@ const useGridSorting = (apiRef, props) => {
|
|
|
182
184
|
* PRE-PROCESSING
|
|
183
185
|
*/
|
|
184
186
|
|
|
185
|
-
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
187
|
+
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
188
|
+
var _props$initialState2, _props$initialState2$;
|
|
189
|
+
|
|
186
190
|
const sortModelToExport = (0, _gridSortingSelector.gridSortModelSelector)(apiRef);
|
|
191
|
+
const shouldExportSortModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
192
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
193
|
+
props.sortModel != null || // Always export if the model has been initialized
|
|
194
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.sorting) == null ? void 0 : _props$initialState2$.sortModel) != null || // Export if the model is not empty
|
|
195
|
+
sortModelToExport.length > 0;
|
|
187
196
|
|
|
188
|
-
if (
|
|
197
|
+
if (!shouldExportSortModel) {
|
|
189
198
|
return prevState;
|
|
190
199
|
}
|
|
191
200
|
|
|
@@ -194,7 +203,7 @@ const useGridSorting = (apiRef, props) => {
|
|
|
194
203
|
sortModel: sortModelToExport
|
|
195
204
|
}
|
|
196
205
|
});
|
|
197
|
-
}, [apiRef]);
|
|
206
|
+
}, [apiRef, props.sortModel, (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.sorting) == null ? void 0 : _props$initialState3$.sortModel]);
|
|
198
207
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
199
208
|
var _context$stateToResto;
|
|
200
209
|
|
|
@@ -210,12 +219,31 @@ const useGridSorting = (apiRef, props) => {
|
|
|
210
219
|
});
|
|
211
220
|
}, [apiRef, props.disableMultipleColumnsSorting]);
|
|
212
221
|
const flatSortingMethod = React.useCallback(params => {
|
|
222
|
+
const rowTree = (0, _rows.gridRowTreeSelector)(apiRef);
|
|
223
|
+
|
|
213
224
|
if (!params.sortRowList) {
|
|
214
|
-
|
|
225
|
+
const bodyRowIds = [];
|
|
226
|
+
const footerRowIds = [];
|
|
227
|
+
(0, _rows.gridRowIdsSelector)(apiRef).forEach(rowId => {
|
|
228
|
+
if (rowTree[rowId].position === 'footer') {
|
|
229
|
+
footerRowIds.push(rowId);
|
|
230
|
+
} else {
|
|
231
|
+
bodyRowIds.push(rowId);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return [...bodyRowIds, ...footerRowIds];
|
|
215
235
|
}
|
|
216
236
|
|
|
217
|
-
const
|
|
218
|
-
|
|
237
|
+
const bodyRows = [];
|
|
238
|
+
const footerRowIds = [];
|
|
239
|
+
Object.values(rowTree).forEach(rowNode => {
|
|
240
|
+
if (rowNode.position === 'footer') {
|
|
241
|
+
footerRowIds.push(rowNode.id);
|
|
242
|
+
} else {
|
|
243
|
+
bodyRows.push(rowNode);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return [...params.sortRowList(bodyRows), ...footerRowIds];
|
|
219
247
|
}, [apiRef]);
|
|
220
248
|
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'exportState', stateExportPreProcessing);
|
|
221
249
|
(0, _pipeProcessing.useGridRegisterPipeProcessor)(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
@@ -14,8 +14,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
|
|
16
16
|
const useGridStatePersistence = apiRef => {
|
|
17
|
-
const exportState = React.useCallback(() => {
|
|
18
|
-
const stateToExport = apiRef.current.unstable_applyPipeProcessors('exportState', {});
|
|
17
|
+
const exportState = React.useCallback((params = {}) => {
|
|
18
|
+
const stateToExport = apiRef.current.unstable_applyPipeProcessors('exportState', {}, params);
|
|
19
19
|
return stateToExport;
|
|
20
20
|
}, [apiRef]);
|
|
21
21
|
const restoreState = React.useCallback(stateToRestore => {
|
|
@@ -350,7 +350,8 @@ const useGridVirtualScroller = props => {
|
|
|
350
350
|
apiRef.current.unstable_calculateColSpan({
|
|
351
351
|
rowId: row.id,
|
|
352
352
|
minFirstColumn,
|
|
353
|
-
maxLastColumn
|
|
353
|
+
maxLastColumn,
|
|
354
|
+
columns: visibleColumns
|
|
354
355
|
});
|
|
355
356
|
}
|
|
356
357
|
|
|
@@ -384,10 +385,8 @@ const useGridVirtualScroller = props => {
|
|
|
384
385
|
|
|
385
386
|
if (selectedRowsLookup[id] == null) {
|
|
386
387
|
isSelected = false;
|
|
387
|
-
} else if (typeof rootProps.isRowSelectable === 'function') {
|
|
388
|
-
isSelected = rootProps.isRowSelectable(apiRef.current.getRowParams(id));
|
|
389
388
|
} else {
|
|
390
|
-
isSelected =
|
|
389
|
+
isSelected = apiRef.current.isRowSelectable(id);
|
|
391
390
|
}
|
|
392
391
|
|
|
393
392
|
rows.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.components.Row, (0, _extends2.default)({
|