@mui/x-data-grid 5.6.0 → 5.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/DataGrid/DataGrid.js +18 -3
- package/DataGrid/useDataGridComponent.js +19 -15
- package/DataGrid/useDataGridProps.js +3 -2
- package/colDef/gridNumericOperators.d.ts +1 -1
- package/colDef/gridNumericOperators.js +1 -1
- package/components/ErrorBoundary.d.ts +2 -2
- package/components/GridRow.js +29 -3
- package/components/base/GridErrorHandler.d.ts +8 -2
- package/components/base/GridErrorHandler.js +13 -2
- package/components/cell/GridBooleanCell.d.ts +2 -1
- package/components/cell/GridCell.js +4 -2
- package/components/cell/GridEditBooleanCell.d.ts +2 -1
- package/components/cell/GridEditDateCell.d.ts +2 -1
- package/components/cell/GridEditInputCell.d.ts +2 -1
- package/components/cell/GridEditSingleSelectCell.d.ts +2 -1
- package/components/cell/GridEditSingleSelectCell.js +2 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/components/containers/GridRootStyles.js +1 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -1
- package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
- package/components/panel/filterPanel/filterPanelUtils.d.ts +2 -2
- package/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/constants/gridClasses.d.ts +5 -1
- package/constants/gridClasses.js +1 -1
- package/context/GridContextProvider.d.ts +9 -6
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -0
- package/hooks/features/columnMenu/useGridColumnMenu.js +6 -7
- package/hooks/features/columns/gridColumnsSelector.d.ts +8 -8
- package/hooks/features/columns/gridColumnsSelector.js +11 -10
- package/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/hooks/features/density/useGridDensity.d.ts +2 -0
- package/hooks/features/density/useGridDensity.js +3 -4
- package/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/hooks/features/editRows/useGridEditing.d.ts +2 -0
- package/hooks/features/editRows/useGridEditing.js +3 -4
- package/hooks/features/export/serializers/csvSerializer.js +4 -4
- package/hooks/features/filter/gridFilterSelector.d.ts +1 -0
- package/hooks/features/filter/gridFilterSelector.js +1 -0
- package/hooks/features/focus/useGridFocus.d.ts +2 -0
- package/hooks/features/focus/useGridFocus.js +10 -11
- package/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/hooks/features/pagination/useGridPage.d.ts +1 -2
- package/hooks/features/pagination/useGridPage.js +5 -17
- package/hooks/features/pagination/useGridPageSize.d.ts +1 -2
- package/hooks/features/pagination/useGridPageSize.js +5 -26
- package/hooks/features/pagination/useGridPagination.d.ts +2 -0
- package/hooks/features/pagination/useGridPagination.js +25 -2
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +3 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +10 -11
- package/hooks/features/rows/useGridParamsApi.js +3 -10
- package/hooks/features/rows/useGridRows.js +14 -6
- package/hooks/features/rows/useGridRowsMeta.d.ts +3 -1
- package/hooks/features/rows/useGridRowsMeta.js +42 -24
- package/hooks/features/selection/gridSelectionSelector.d.ts +1 -1
- package/hooks/features/selection/useGridSelection.d.ts +2 -0
- package/hooks/features/selection/useGridSelection.js +28 -16
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -3
- package/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/hooks/utils/useGridApi.js +10 -1
- package/hooks/utils/useGridInitializeState.d.ts +2 -1
- package/hooks/utils/useGridSelector.js +4 -4
- package/hooks/utils/useGridState.js +10 -1
- package/hooks/utils/{useCurrentPageRows.d.ts → useGridVisibleRows.d.ts} +7 -6
- package/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
- package/index.js +1 -1
- package/internals/index.d.ts +9 -12
- package/internals/index.js +9 -12
- package/legacy/DataGrid/DataGrid.js +18 -3
- package/legacy/DataGrid/useDataGridComponent.js +19 -15
- package/legacy/DataGrid/useDataGridProps.js +8 -2
- package/legacy/colDef/gridNumericOperators.js +1 -1
- package/legacy/components/GridRow.js +30 -3
- package/legacy/components/base/GridErrorHandler.js +13 -2
- package/legacy/components/cell/GridCell.js +4 -2
- package/legacy/components/cell/GridEditSingleSelectCell.js +10 -9
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/legacy/components/containers/GridRootStyles.js +1 -1
- package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +29 -26
- package/legacy/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/legacy/constants/gridClasses.js +1 -1
- package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +8 -9
- package/legacy/hooks/features/columns/gridColumnsSelector.js +13 -12
- package/legacy/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/legacy/hooks/features/density/useGridDensity.js +5 -6
- package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/legacy/hooks/features/editRows/useGridEditing.js +5 -6
- package/legacy/hooks/features/export/serializers/csvSerializer.js +4 -4
- package/legacy/hooks/features/filter/gridFilterSelector.js +1 -0
- package/legacy/hooks/features/focus/useGridFocus.js +12 -13
- package/legacy/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/legacy/hooks/features/pagination/useGridPage.js +5 -17
- package/legacy/hooks/features/pagination/useGridPageSize.js +5 -26
- package/legacy/hooks/features/pagination/useGridPagination.js +25 -2
- package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +10 -11
- package/legacy/hooks/features/rows/useGridParamsApi.js +3 -10
- package/legacy/hooks/features/rows/useGridRows.js +17 -6
- package/legacy/hooks/features/rows/useGridRowsMeta.js +44 -26
- package/legacy/hooks/features/selection/useGridSelection.js +29 -19
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/legacy/hooks/utils/useGridApi.js +7 -0
- package/legacy/hooks/utils/useGridSelector.js +4 -4
- package/legacy/hooks/utils/useGridState.js +7 -0
- package/legacy/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +9 -12
- package/legacy/models/colDef/gridDefaultColumnTypes.js +4 -4
- package/legacy/utils/createSelector.js +4 -4
- package/legacy/utils/getGridLocalization.js +2 -2
- package/lib/lodash/_baseGetAllKeys.d.ts +1 -1
- package/lib/lodash/_baseIsEqual.d.ts +1 -1
- package/lib/lodash/_baseIsEqualDeep.d.ts +1 -1
- package/lib/lodash/_baseKeys.d.ts +1 -1
- package/lib/lodash/_cacheHas.d.ts +1 -1
- package/lib/lodash/_equalArrays.d.ts +1 -1
- package/lib/lodash/_equalByTag.d.ts +1 -1
- package/lib/lodash/_equalObjects.d.ts +1 -1
- package/lib/lodash/_getAllKeys.d.ts +1 -1
- package/lib/lodash/_getMapData.d.ts +1 -1
- package/lib/lodash/_getNative.d.ts +1 -1
- package/lib/lodash/_getValue.d.ts +1 -1
- package/lib/lodash/_hashSet.d.ts +1 -1
- package/lib/lodash/_listCacheSet.d.ts +1 -1
- package/lib/lodash/_mapCacheSet.d.ts +1 -1
- package/lib/lodash/_mapToArray.d.ts +1 -1
- package/lib/lodash/_setCacheAdd.d.ts +1 -1
- package/lib/lodash/_setToArray.d.ts +1 -1
- package/lib/lodash/_stackSet.d.ts +1 -1
- package/lib/lodash/keys.d.ts +1 -1
- package/models/api/gridRowApi.d.ts +6 -0
- package/models/api/gridRowsMetaApi.d.ts +7 -0
- package/models/api/gridSortApi.d.ts +1 -0
- package/models/colDef/gridColDef.d.ts +1 -2
- package/models/colDef/gridDefaultColumnTypes.js +2 -2
- package/models/gridRows.d.ts +8 -2
- package/models/params/gridRowParams.d.ts +29 -1
- package/models/props/DataGridProps.d.ts +20 -4
- package/modern/DataGrid/DataGrid.js +18 -3
- package/modern/DataGrid/useDataGridComponent.js +19 -15
- package/modern/DataGrid/useDataGridProps.js +3 -2
- package/modern/colDef/gridNumericOperators.js +1 -1
- package/modern/components/GridRow.js +29 -3
- package/modern/components/base/GridErrorHandler.js +13 -2
- package/modern/components/cell/GridCell.js +2 -2
- package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/modern/components/containers/GridRootStyles.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
- package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +6 -7
- package/modern/hooks/features/columns/gridColumnsSelector.js +11 -10
- package/modern/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/modern/hooks/features/density/useGridDensity.js +3 -4
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/modern/hooks/features/editRows/useGridEditing.js +3 -4
- package/modern/hooks/features/export/serializers/csvSerializer.js +4 -4
- package/modern/hooks/features/filter/gridFilterSelector.js +1 -0
- package/modern/hooks/features/focus/useGridFocus.js +10 -11
- package/modern/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/modern/hooks/features/pagination/useGridPage.js +1 -9
- package/modern/hooks/features/pagination/useGridPageSize.js +1 -20
- package/modern/hooks/features/pagination/useGridPagination.js +23 -2
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +6 -7
- package/modern/hooks/features/rows/useGridParamsApi.js +3 -10
- package/modern/hooks/features/rows/useGridRows.js +14 -6
- package/modern/hooks/features/rows/useGridRowsMeta.js +36 -24
- package/modern/hooks/features/selection/useGridSelection.js +24 -16
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/modern/hooks/utils/useGridApi.js +10 -1
- package/modern/hooks/utils/useGridSelector.js +4 -4
- package/modern/hooks/utils/useGridState.js +10 -1
- package/modern/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
- package/modern/index.js +1 -1
- package/modern/internals/index.js +9 -12
- package/modern/models/colDef/gridDefaultColumnTypes.js +2 -2
- package/modern/utils/createSelector.js +4 -4
- package/modern/utils/getGridLocalization.js +1 -1
- package/node/DataGrid/DataGrid.js +18 -3
- package/node/DataGrid/useDataGridComponent.js +11 -9
- package/node/DataGrid/useDataGridProps.js +3 -2
- package/node/colDef/gridNumericOperators.js +1 -1
- package/node/components/GridRow.js +28 -3
- package/node/components/base/GridErrorHandler.js +11 -1
- package/node/components/cell/GridCell.js +4 -2
- package/node/components/cell/GridEditSingleSelectCell.js +2 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +5 -3
- package/node/components/containers/GridRootStyles.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
- package/node/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +10 -8
- package/node/hooks/features/columns/gridColumnsSelector.js +11 -9
- package/node/hooks/features/columns/gridColumnsUtils.js +7 -5
- package/node/hooks/features/density/useGridDensity.js +7 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/node/hooks/features/editRows/useGridEditing.js +8 -5
- package/node/hooks/features/export/serializers/csvSerializer.js +5 -4
- package/node/hooks/features/filter/gridFilterSelector.js +1 -0
- package/node/hooks/features/focus/useGridFocus.js +15 -13
- package/node/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
- package/node/hooks/features/pagination/useGridPage.js +7 -20
- package/node/hooks/features/pagination/useGridPageSize.js +6 -26
- package/node/hooks/features/pagination/useGridPagination.js +31 -1
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +15 -13
- package/node/hooks/features/rows/useGridParamsApi.js +4 -10
- package/node/hooks/features/rows/useGridRows.js +15 -6
- package/node/hooks/features/rows/useGridRowsMeta.js +47 -26
- package/node/hooks/features/selection/useGridSelection.js +32 -18
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
- package/node/hooks/utils/useGridApi.js +11 -1
- package/node/hooks/utils/useGridSelector.js +6 -4
- package/node/hooks/utils/useGridState.js +11 -1
- package/node/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +11 -10
- package/node/index.js +1 -1
- package/node/internals/index.js +45 -21
- package/node/models/colDef/gridDefaultColumnTypes.js +2 -2
- package/node/utils/createSelector.js +5 -4
- package/node/utils/getGridLocalization.js +2 -2
- package/package.json +2 -2
- package/utils/createSelector.js +4 -4
- package/utils/getGridLocalization.d.ts +2 -1
- package/utils/getGridLocalization.js +2 -2
- package/utils/keyboardUtils.d.ts +1 -1
- package/utils/warning.d.ts +1 -1
- package/hooks/utils/useGridStateInit.d.ts +0 -7
- package/hooks/utils/useGridStateInit.js +0 -9
- package/legacy/hooks/utils/useGridStateInit.js +0 -9
- package/modern/hooks/utils/useGridStateInit.js +0 -9
- package/node/hooks/utils/useGridStateInit.js +0 -23
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { GridEvents } from '../../../models/events';
|
|
4
|
-
import { useGridStateInit } from '../../utils/useGridStateInit';
|
|
5
4
|
import { useGridLogger, useGridApiMethod, useGridApiEventHandler } from '../../utils';
|
|
6
5
|
import { gridColumnMenuSelector } from './columnMenuSelector';
|
|
7
|
-
|
|
6
|
+
export var columnMenuStateInitializer = function columnMenuStateInitializer(state) {
|
|
7
|
+
return _extends({}, state, {
|
|
8
|
+
columnMenu: {
|
|
9
|
+
open: false
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
8
13
|
/**
|
|
9
14
|
* @requires useGridColumnResize (event)
|
|
10
15
|
* @requires useGridInfiniteLoader (event)
|
|
11
16
|
*/
|
|
17
|
+
|
|
12
18
|
export var useGridColumnMenu = function useGridColumnMenu(apiRef) {
|
|
13
19
|
var logger = useGridLogger(apiRef, 'useGridColumnMenu');
|
|
14
|
-
useGridStateInit(apiRef, function (state) {
|
|
15
|
-
return _extends({}, state, {
|
|
16
|
-
columnMenu: {
|
|
17
|
-
open: false
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
20
|
/**
|
|
22
21
|
* API METHODS
|
|
23
22
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createSelector } from '../../../utils/createSelector';
|
|
2
|
-
|
|
2
|
+
import { wrapWithWarningOnCall } from '../../../utils/warning';
|
|
3
3
|
/**
|
|
4
4
|
* @category Columns
|
|
5
5
|
* @deprecated Use the selector returning exactly the value you are looking for.
|
|
6
6
|
* @ignore - do not document.
|
|
7
7
|
* TODO v6: Rename `gridColumnsStateSelector`
|
|
8
8
|
*/
|
|
9
|
+
|
|
9
10
|
export var gridColumnsSelector = function gridColumnsSelector(state) {
|
|
10
11
|
return state.columns;
|
|
11
12
|
};
|
|
@@ -124,58 +125,58 @@ export var gridFilterableColumnLookupSelector = createSelector(gridColumnDefinit
|
|
|
124
125
|
* @ignore - do not document.
|
|
125
126
|
*/
|
|
126
127
|
|
|
127
|
-
export var allGridColumnsFieldsSelector = gridColumnFieldsSelector;
|
|
128
|
+
export var allGridColumnsFieldsSelector = wrapWithWarningOnCall(gridColumnFieldsSelector, ['MUI: The method allGridColumnsFieldsSelector is deprecated and will be removed in the next major version.', 'Use gridColumnFieldsSelector instead']);
|
|
128
129
|
/**
|
|
129
130
|
* @category Columns
|
|
130
131
|
* @deprecated Use `gridColumnDefinitionsSelector` instead.
|
|
131
132
|
* @ignore - do not document.
|
|
132
133
|
*/
|
|
133
134
|
|
|
134
|
-
export var allGridColumnsSelector = gridColumnDefinitionsSelector;
|
|
135
|
+
export var allGridColumnsSelector = wrapWithWarningOnCall(gridColumnDefinitionsSelector, ['MUI: The method allGridColumnsSelector is deprecated and will be removed in the next major version.', 'Use gridColumnDefinitionsSelector instead']);
|
|
135
136
|
/**
|
|
136
137
|
* @category Visible Columns
|
|
137
138
|
* @deprecated Use `gridVisibleColumnDefinitionsSelector` instead.
|
|
138
139
|
* @ignore - do not document.
|
|
139
140
|
*/
|
|
140
141
|
|
|
141
|
-
export var visibleGridColumnsSelector = gridVisibleColumnDefinitionsSelector;
|
|
142
|
+
export var visibleGridColumnsSelector = wrapWithWarningOnCall(gridVisibleColumnDefinitionsSelector, ['MUI: The method visibleGridColumnsSelector is deprecated and will be removed in the next major version.', 'Use gridVisibleColumnDefinitionsSelector instead']);
|
|
142
143
|
/**
|
|
143
144
|
* @category Columns
|
|
144
145
|
* @deprecated Use `gridFilterableColumnDefinitionsSelector` instead.
|
|
145
146
|
* @ignore - do not document.
|
|
146
147
|
*/
|
|
147
148
|
|
|
148
|
-
export var filterableGridColumnsSelector = gridFilterableColumnDefinitionsSelector;
|
|
149
|
+
export var filterableGridColumnsSelector = wrapWithWarningOnCall(gridFilterableColumnDefinitionsSelector, ['MUI: The method filterableGridColumnsSelector is deprecated and will be removed in the next major version.', 'Use gridFilterableColumnDefinitionsSelector instead']);
|
|
149
150
|
/**
|
|
150
151
|
* @category Columns
|
|
151
152
|
* @deprecated Use `gridFilterableColumnLookupSelector` instead (not the same return format).
|
|
152
153
|
* @ignore - do not document.
|
|
153
154
|
*/
|
|
154
155
|
|
|
155
|
-
export var filterableGridColumnsIdsSelector = createSelector(gridFilterableColumnDefinitionsSelector, function (columns) {
|
|
156
|
+
export var filterableGridColumnsIdsSelector = wrapWithWarningOnCall(createSelector(gridFilterableColumnDefinitionsSelector, function (columns) {
|
|
156
157
|
return columns.map(function (col) {
|
|
157
158
|
return col.field;
|
|
158
159
|
});
|
|
159
|
-
});
|
|
160
|
+
}), ['MUI: The method filterableGridColumnsIdsSelector is deprecated and will be removed in the next major version.', 'Use gridFilterableColumnDefinitionsSelector instead.', 'The return format is now a lookup, if you want to get the same output as before, use the following code:', '', 'const lookup = gridFilterableColumnLookupSelector(apiRef);', 'const fields = gridColumnFieldsSelector(apiRef).filter(field => lookup[field]);']);
|
|
160
161
|
/**
|
|
161
162
|
* Get the amount of visible columns.
|
|
162
163
|
* @category Visible Columns
|
|
163
|
-
* @deprecated Use the length of `gridVisibleColumnDefinitionsSelector` instead.
|
|
164
|
+
* @deprecated Use the length of the array returned by `gridVisibleColumnDefinitionsSelector` instead.
|
|
164
165
|
* @ignore - do not document.
|
|
165
166
|
*/
|
|
166
167
|
|
|
167
|
-
export var visibleGridColumnsLengthSelector = createSelector(gridVisibleColumnDefinitionsSelector, function (visibleColumns) {
|
|
168
|
+
export var visibleGridColumnsLengthSelector = wrapWithWarningOnCall(createSelector(gridVisibleColumnDefinitionsSelector, function (visibleColumns) {
|
|
168
169
|
return visibleColumns.length;
|
|
169
|
-
});
|
|
170
|
+
}), ['MUI: The method visibleGridColumnsLengthSelector is deprecated and will be removed in the next major version.', 'Use the length of the array returned by gridVisibleColumnDefinitionsSelector instead.']);
|
|
170
171
|
/**
|
|
171
172
|
* @category Visible Columns
|
|
172
173
|
* @deprecated Use `gridColumnsTotalWidthSelector` or `gridColumnPositionsSelector` instead.
|
|
173
174
|
* @ignore - do not document.
|
|
174
175
|
*/
|
|
175
176
|
|
|
176
|
-
export var gridColumnsMetaSelector = createSelector(gridColumnPositionsSelector, gridColumnsTotalWidthSelector, function (positions, totalWidth) {
|
|
177
|
+
export var gridColumnsMetaSelector = wrapWithWarningOnCall(createSelector(gridColumnPositionsSelector, gridColumnsTotalWidthSelector, function (positions, totalWidth) {
|
|
177
178
|
return {
|
|
178
179
|
totalWidth: totalWidth,
|
|
179
180
|
positions: positions
|
|
180
181
|
};
|
|
181
|
-
});
|
|
182
|
+
}), ['MUI: The method gridColumnsMetaSelector is deprecated and will be removed in the next major version.', 'Use gridColumnsTotalWidthSelector or gridColumnPositionsSelector instead']);
|
|
@@ -7,16 +7,18 @@ import { clamp } from '../../../utils/utils';
|
|
|
7
7
|
export var computeColumnTypes = function computeColumnTypes() {
|
|
8
8
|
var customColumnTypes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var mergedColumnTypes = _extends({}, getGridDefaultColumnTypes());
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
Object.entries(allColumnTypes).forEach(function (_ref) {
|
|
12
|
+
Object.entries(customColumnTypes).forEach(function (_ref) {
|
|
14
13
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
15
14
|
colType = _ref2[0],
|
|
16
15
|
colTypeDef = _ref2[1];
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (mergedColumnTypes[colType]) {
|
|
18
|
+
mergedColumnTypes[colType] = _extends({}, mergedColumnTypes[colType], colTypeDef);
|
|
19
|
+
} else {
|
|
20
|
+
mergedColumnTypes[colType] = _extends({}, mergedColumnTypes[colTypeDef.extendType || DEFAULT_GRID_COL_TYPE_KEY], colTypeDef);
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
23
|
return mergedColumnTypes;
|
|
22
24
|
};
|
|
@@ -3,7 +3,6 @@ import * as React from 'react';
|
|
|
3
3
|
import { GridDensityTypes } from '../../../models/gridDensity';
|
|
4
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
5
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
|
-
import { useGridStateInit } from '../../utils/useGridStateInit';
|
|
7
6
|
import { gridDensitySelector } from './densitySelector';
|
|
8
7
|
import { isDeepEqual } from '../../../utils/utils';
|
|
9
8
|
export var COMPACT_DENSITY_FACTOR = 0.7;
|
|
@@ -37,13 +36,13 @@ var getUpdatedDensityState = function getUpdatedDensityState(newDensity, newHead
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
|
|
39
|
+
export var densityStateInitializer = function densityStateInitializer(state, props) {
|
|
40
|
+
return _extends({}, state, {
|
|
41
|
+
density: getUpdatedDensityState(props.density, props.headerHeight, props.rowHeight)
|
|
42
|
+
});
|
|
43
|
+
};
|
|
40
44
|
export var useGridDensity = function useGridDensity(apiRef, props) {
|
|
41
45
|
var logger = useGridLogger(apiRef, 'useDensity');
|
|
42
|
-
useGridStateInit(apiRef, function (state) {
|
|
43
|
-
return _extends({}, state, {
|
|
44
|
-
density: getUpdatedDensityState(props.density, props.headerHeight, props.rowHeight)
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
46
|
var setDensity = React.useCallback(function (newDensity) {
|
|
48
47
|
var newHeaderHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : props.headerHeight;
|
|
49
48
|
var newRowHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : props.rowHeight;
|
|
@@ -7,7 +7,7 @@ import { useGridLogger } from '../../utils/useGridLogger';
|
|
|
7
7
|
import { gridColumnsTotalWidthSelector } from '../columns';
|
|
8
8
|
import { gridDensityHeaderHeightSelector, gridDensityRowHeightSelector } from '../density';
|
|
9
9
|
import { useGridSelector } from '../../utils';
|
|
10
|
-
import {
|
|
10
|
+
import { getVisibleRows } from '../../utils/useGridVisibleRows';
|
|
11
11
|
import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
|
|
12
12
|
var isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
13
13
|
|
|
@@ -118,7 +118,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
118
118
|
return 0;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
var currentPage =
|
|
121
|
+
var currentPage = getVisibleRows(apiRef, {
|
|
122
122
|
pagination: props.pagination,
|
|
123
123
|
paginationMode: props.paginationMode
|
|
124
124
|
}); // TODO: Use a combination of scrollTop, dimensions.viewportInnerSize.height and rowsMeta.possitions
|
|
@@ -6,10 +6,14 @@ import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
|
6
6
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
7
7
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
8
8
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
9
|
-
import { useGridStateInit } from '../../utils/useGridStateInit';
|
|
10
9
|
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
11
10
|
import { useCellEditing } from './useGridCellEditing';
|
|
12
11
|
import { useGridRowEditing } from './useGridRowEditing';
|
|
12
|
+
export var editingStateInitializer = function editingStateInitializer(state) {
|
|
13
|
+
return _extends({}, state, {
|
|
14
|
+
editRows: {}
|
|
15
|
+
});
|
|
16
|
+
};
|
|
13
17
|
/**
|
|
14
18
|
* @requires useGridFocus - can be after, async only
|
|
15
19
|
* @requires useGridParamsApi (method)
|
|
@@ -22,11 +26,6 @@ export function useGridEditing(apiRef, props) {
|
|
|
22
26
|
var logger = useGridLogger(apiRef, 'useGridEditRows');
|
|
23
27
|
useCellEditing(apiRef, props);
|
|
24
28
|
useGridRowEditing(apiRef, props);
|
|
25
|
-
useGridStateInit(apiRef, function (state) {
|
|
26
|
-
return _extends({}, state, {
|
|
27
|
-
editRows: {}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
29
|
var debounceMap = React.useRef({});
|
|
31
30
|
apiRef.current.unstable_updateControlState({
|
|
32
31
|
stateId: 'editRows',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
|
|
2
|
+
import { buildWarning } from '../../../../utils/warning';
|
|
2
3
|
|
|
3
4
|
var serialiseCellValue = function serialiseCellValue(value, delimiterCharacter) {
|
|
4
5
|
if (typeof value === 'string') {
|
|
@@ -16,16 +17,15 @@ var serialiseCellValue = function serialiseCellValue(value, delimiterCharacter)
|
|
|
16
17
|
return value;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
var
|
|
20
|
+
var objectFormattedValueWarning = buildWarning(['MUI: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
|
|
20
21
|
|
|
21
22
|
var serialiseRow = function serialiseRow(id, columns, getCellParams, delimiterCharacter) {
|
|
22
23
|
return columns.map(function (column) {
|
|
23
24
|
var cellParams = getCellParams(id, column.field);
|
|
24
25
|
|
|
25
26
|
if (process.env.NODE_ENV !== 'production') {
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
warnedOnce = true;
|
|
27
|
+
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
28
|
+
objectFormattedValueWarning();
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -89,6 +89,7 @@ export var gridFilteredSortedRowIdsSelector = createSelector(gridFilteredSortedR
|
|
|
89
89
|
* @category Filtering
|
|
90
90
|
* @deprecated Use `gridVisibleSortedRowIdsSelector` instead
|
|
91
91
|
* @ignore - do not document.
|
|
92
|
+
* TODO: Add deprecation warning once we have the new selectors without the "visible" keyword.
|
|
92
93
|
*/
|
|
93
94
|
|
|
94
95
|
export var gridVisibleRowsSelector = gridVisibleSortedRowIdsSelector;
|
|
@@ -6,8 +6,19 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
6
6
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
7
7
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
8
8
|
import { isNavigationKey } from '../../../utils/keyboardUtils';
|
|
9
|
-
import { useGridStateInit } from '../../utils/useGridStateInit';
|
|
10
9
|
import { gridFocusCellSelector } from './gridFocusStateSelector';
|
|
10
|
+
export var focusStateInitializer = function focusStateInitializer(state) {
|
|
11
|
+
return _extends({}, state, {
|
|
12
|
+
focus: {
|
|
13
|
+
cell: null,
|
|
14
|
+
columnHeader: null
|
|
15
|
+
},
|
|
16
|
+
tabIndex: {
|
|
17
|
+
cell: null,
|
|
18
|
+
columnHeader: null
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
11
22
|
/**
|
|
12
23
|
* @requires useGridParamsApi (method)
|
|
13
24
|
* @requires useGridRows (method)
|
|
@@ -16,18 +27,6 @@ import { gridFocusCellSelector } from './gridFocusStateSelector';
|
|
|
16
27
|
|
|
17
28
|
export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
18
29
|
var logger = useGridLogger(apiRef, 'useGridFocus');
|
|
19
|
-
useGridStateInit(apiRef, function (state) {
|
|
20
|
-
return _extends({}, state, {
|
|
21
|
-
focus: {
|
|
22
|
-
cell: null,
|
|
23
|
-
columnHeader: null
|
|
24
|
-
},
|
|
25
|
-
tabIndex: {
|
|
26
|
-
cell: null,
|
|
27
|
-
columnHeader: null
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
30
|
var lastClickedCell = React.useRef(null);
|
|
32
31
|
var setCellFocus = React.useCallback(function (id, field) {
|
|
33
32
|
// The row might have been deleted
|
|
@@ -4,7 +4,7 @@ import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSele
|
|
|
4
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
5
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
6
6
|
import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
|
|
7
|
-
import {
|
|
7
|
+
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
8
8
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../colDef/gridCheckboxSelectionColDef';
|
|
9
9
|
import { gridClasses } from '../../../constants/gridClasses';
|
|
10
10
|
/**
|
|
@@ -21,7 +21,7 @@ import { gridClasses } from '../../../constants/gridClasses';
|
|
|
21
21
|
|
|
22
22
|
export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef, props) {
|
|
23
23
|
var logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
|
|
24
|
-
var currentPage =
|
|
24
|
+
var currentPage = useGridVisibleRows(apiRef, props);
|
|
25
25
|
var goToCell = React.useCallback(function (colIndex, rowIndex) {
|
|
26
26
|
logger.debug("Navigating to cell row ".concat(rowIndex, ", col ").concat(colIndex));
|
|
27
27
|
apiRef.current.scrollToIndexes({
|
|
@@ -6,8 +6,7 @@ import { gridVisibleTopLevelRowCountSelector } from '../filter';
|
|
|
6
6
|
import { gridPageSelector } from './gridPaginationSelector';
|
|
7
7
|
import { useGridRegisterPreProcessor } from '../../core/preProcessing';
|
|
8
8
|
import { buildWarning } from '../../../utils/warning';
|
|
9
|
-
|
|
10
|
-
var getPageCount = function getPageCount(rowCount, pageSize) {
|
|
9
|
+
export var getPageCount = function getPageCount(rowCount, pageSize) {
|
|
11
10
|
if (pageSize > 0 && rowCount > 0) {
|
|
12
11
|
return Math.ceil(rowCount / pageSize);
|
|
13
12
|
}
|
|
@@ -36,23 +35,12 @@ var mergeStateWithPage = function mergeStateWithPage(page) {
|
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
var noRowCountInServerMode = buildWarning(["MUI: the 'rowCount' prop is undefined while using paginationMode='server'", 'For more detail, see http://mui.com/components/data-grid/pagination/#basic-implementation'], 'error');
|
|
39
|
-
export var pageStateInitializer = function pageStateInitializer(state, props) {
|
|
40
|
-
var _ref, _props$page, _props$initialState, _props$initialState$p, _props$rowCount, _props$rowCount2;
|
|
41
|
-
|
|
42
|
-
return _extends({}, state, {
|
|
43
|
-
pagination: _extends({}, state.pagination, {
|
|
44
|
-
page: (_ref = (_props$page = props.page) != null ? _props$page : (_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null ? _ref : 0,
|
|
45
|
-
pageCount: getPageCount((_props$rowCount = props.rowCount) != null ? _props$rowCount : 0, state.pagination.pageSize),
|
|
46
|
-
rowCount: (_props$rowCount2 = props.rowCount) != null ? _props$rowCount2 : 0
|
|
47
|
-
})
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
38
|
/**
|
|
51
39
|
* @requires useGridPageSize (event)
|
|
52
40
|
*/
|
|
53
41
|
|
|
54
42
|
export var useGridPage = function useGridPage(apiRef, props) {
|
|
55
|
-
var _props$
|
|
43
|
+
var _props$initialState2, _props$initialState2$;
|
|
56
44
|
|
|
57
45
|
var logger = useGridLogger(apiRef, 'useGridPage');
|
|
58
46
|
var visibleTopLevelRowCount = useGridSelector(apiRef, gridVisibleTopLevelRowCountSelector);
|
|
@@ -81,12 +69,12 @@ export var useGridPage = function useGridPage(apiRef, props) {
|
|
|
81
69
|
*/
|
|
82
70
|
|
|
83
71
|
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
84
|
-
var _props$
|
|
72
|
+
var _props$initialState, _props$initialState$p;
|
|
85
73
|
|
|
86
74
|
var pageToExport = gridPageSelector(apiRef);
|
|
87
75
|
var shouldExportPage = // Always export if the page is controlled
|
|
88
76
|
props.page != null || // Always export if the page has been initialized
|
|
89
|
-
((_props$
|
|
77
|
+
((_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 value is not equal to the default value
|
|
90
78
|
pageToExport !== 0;
|
|
91
79
|
|
|
92
80
|
if (!shouldExportPage) {
|
|
@@ -98,7 +86,7 @@ export var useGridPage = function useGridPage(apiRef, props) {
|
|
|
98
86
|
page: pageToExport
|
|
99
87
|
})
|
|
100
88
|
});
|
|
101
|
-
}, [apiRef, props.page, (_props$
|
|
89
|
+
}, [apiRef, props.page, (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.pagination) == null ? void 0 : _props$initialState2$.page]);
|
|
102
90
|
var stateRestorePreProcessing = React.useCallback(function (params, context) {
|
|
103
91
|
var _context$stateToResto, _context$stateToResto2;
|
|
104
92
|
|
|
@@ -5,31 +5,10 @@ import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelecto
|
|
|
5
5
|
import { gridPageSizeSelector } from './gridPaginationSelector';
|
|
6
6
|
import { gridDensityRowHeightSelector } from '../density';
|
|
7
7
|
import { useGridRegisterPreProcessor } from '../../core/preProcessing';
|
|
8
|
-
|
|
9
|
-
var defaultPageSize = function defaultPageSize(autoPageSize) {
|
|
8
|
+
export var defaultPageSize = function defaultPageSize(autoPageSize) {
|
|
10
9
|
return autoPageSize ? 0 : 100;
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
export var pageSizeStateInitializer = function pageSizeStateInitializer(state, props) {
|
|
14
|
-
var _props$initialState, _props$initialState$p;
|
|
15
|
-
|
|
16
|
-
var pageSize;
|
|
17
|
-
|
|
18
|
-
if (props.pageSize != null) {
|
|
19
|
-
pageSize = props.pageSize;
|
|
20
|
-
} else if (((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null) {
|
|
21
|
-
pageSize = props.initialState.pagination.pageSize;
|
|
22
|
-
} else {
|
|
23
|
-
pageSize = defaultPageSize(props.autoPageSize);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return _extends({}, state, {
|
|
27
|
-
pagination: {
|
|
28
|
-
pageSize: pageSize
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
12
|
var mergeStateWithPageSize = function mergeStateWithPageSize(pageSize) {
|
|
34
13
|
return function (state) {
|
|
35
14
|
return _extends({}, state, {
|
|
@@ -45,7 +24,7 @@ var mergeStateWithPageSize = function mergeStateWithPageSize(pageSize) {
|
|
|
45
24
|
|
|
46
25
|
|
|
47
26
|
export var useGridPageSize = function useGridPageSize(apiRef, props) {
|
|
48
|
-
var _props$
|
|
27
|
+
var _props$initialState2, _props$initialState2$;
|
|
49
28
|
|
|
50
29
|
var logger = useGridLogger(apiRef, 'useGridPageSize');
|
|
51
30
|
var rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector);
|
|
@@ -78,12 +57,12 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
|
|
|
78
57
|
*/
|
|
79
58
|
|
|
80
59
|
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
81
|
-
var _props$
|
|
60
|
+
var _props$initialState, _props$initialState$p;
|
|
82
61
|
|
|
83
62
|
var pageSizeToExport = gridPageSizeSelector(apiRef);
|
|
84
63
|
var shouldExportPageSize = // Always export if the page size is controlled
|
|
85
64
|
props.pageSize != null || // Always export if the page size has been initialized
|
|
86
|
-
((_props$
|
|
65
|
+
((_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 value is not equal to the default value
|
|
87
66
|
pageSizeToExport !== defaultPageSize(props.autoPageSize);
|
|
88
67
|
|
|
89
68
|
if (!shouldExportPageSize) {
|
|
@@ -95,7 +74,7 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
|
|
|
95
74
|
pageSize: pageSizeToExport
|
|
96
75
|
})
|
|
97
76
|
});
|
|
98
|
-
}, [apiRef, props.pageSize, (_props$
|
|
77
|
+
}, [apiRef, props.pageSize, (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.pagination) == null ? void 0 : _props$initialState2$.pageSize, props.autoPageSize]);
|
|
99
78
|
/**
|
|
100
79
|
* TODO: Add error if `prop.autoHeight = true`
|
|
101
80
|
*/
|
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { useGridPageSize, defaultPageSize } from './useGridPageSize';
|
|
3
|
+
import { useGridPage, getPageCount } from './useGridPage';
|
|
4
|
+
export var paginationStateInitializer = function paginationStateInitializer(state, props) {
|
|
5
|
+
var _props$initialState, _props$initialState$p, _ref, _props$page, _props$initialState2, _props$initialState2$, _props$rowCount, _props$rowCount2;
|
|
6
|
+
|
|
7
|
+
var pageSize;
|
|
8
|
+
|
|
9
|
+
if (props.pageSize != null) {
|
|
10
|
+
pageSize = props.pageSize;
|
|
11
|
+
} else if (((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null) {
|
|
12
|
+
pageSize = props.initialState.pagination.pageSize;
|
|
13
|
+
} else {
|
|
14
|
+
pageSize = defaultPageSize(props.autoPageSize);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return _extends({}, state, {
|
|
18
|
+
pagination: {
|
|
19
|
+
pageSize: pageSize,
|
|
20
|
+
page: (_ref = (_props$page = props.page) != null ? _props$page : (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.pagination) == null ? void 0 : _props$initialState2$.page) != null ? _ref : 0,
|
|
21
|
+
pageCount: getPageCount((_props$rowCount = props.rowCount) != null ? _props$rowCount : 0, pageSize),
|
|
22
|
+
rowCount: (_props$rowCount2 = props.rowCount) != null ? _props$rowCount2 : 0
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
3
26
|
/**
|
|
4
27
|
* @requires useGridFilter (state)
|
|
5
28
|
* @requires useGridDimensions (event) - can be after
|
|
@@ -2,24 +2,23 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
4
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
5
|
-
import { useGridStateInit } from '../../utils/useGridStateInit';
|
|
6
5
|
import { useGridRegisterPreProcessor } from '../../core/preProcessing';
|
|
7
6
|
import { gridPreferencePanelStateSelector } from './gridPreferencePanelSelector';
|
|
7
|
+
export var preferencePanelStateInitializer = function preferencePanelStateInitializer(state, props) {
|
|
8
|
+
var _props$initialState$p, _props$initialState;
|
|
9
|
+
|
|
10
|
+
return _extends({}, state, {
|
|
11
|
+
preferencePanel: (_props$initialState$p = (_props$initialState = props.initialState) == null ? void 0 : _props$initialState.preferencePanel) != null ? _props$initialState$p : {
|
|
12
|
+
open: false
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
};
|
|
8
16
|
/**
|
|
9
17
|
* TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
|
|
10
18
|
*/
|
|
11
19
|
|
|
12
|
-
export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef
|
|
20
|
+
export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
|
|
13
21
|
var logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
14
|
-
useGridStateInit(apiRef, function (state) {
|
|
15
|
-
var _props$initialState$p, _props$initialState;
|
|
16
|
-
|
|
17
|
-
return _extends({}, state, {
|
|
18
|
-
preferencePanel: (_props$initialState$p = (_props$initialState = props.initialState) == null ? void 0 : _props$initialState.preferencePanel) != null ? _props$initialState$p : {
|
|
19
|
-
open: false
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
22
|
var hideTimeout = React.useRef();
|
|
24
23
|
var immediateTimeout = React.useRef();
|
|
25
24
|
/**
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from '../../../utils/domUtils';
|
|
3
3
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
4
4
|
import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
|
|
5
|
+
import { buildWarning } from '../../../utils/warning';
|
|
5
6
|
var warnedOnceMissingColumn = false;
|
|
6
7
|
|
|
7
8
|
function warnMissingColumn(field) {
|
|
@@ -9,12 +10,7 @@ function warnMissingColumn(field) {
|
|
|
9
10
|
warnedOnceMissingColumn = true;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
function warnGetValue() {
|
|
15
|
-
console.warn(["MUI: You are calling getValue. This method is deprecated and will be removed in the next major version.", "Instead, you can access the data from `params.row}`."].join('\n'));
|
|
16
|
-
warnedOnceGetValue = true;
|
|
17
|
-
}
|
|
13
|
+
var getCellValueWarning = buildWarning(["MUI: You are calling getValue. This method is deprecated and will be removed in the next major version.", 'Instead, you can access the data from `params.row`.']);
|
|
18
14
|
/**
|
|
19
15
|
* @requires useGridColumns (method)
|
|
20
16
|
* @requires useGridRows (method)
|
|
@@ -24,7 +20,6 @@ function warnGetValue() {
|
|
|
24
20
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
25
21
|
*/
|
|
26
22
|
|
|
27
|
-
|
|
28
23
|
export function useGridParamsApi(apiRef) {
|
|
29
24
|
var getColumnHeaderParams = React.useCallback(function (field) {
|
|
30
25
|
return {
|
|
@@ -40,9 +35,7 @@ export function useGridParamsApi(apiRef) {
|
|
|
40
35
|
var _apiRef$current;
|
|
41
36
|
|
|
42
37
|
if (process.env.NODE_ENV !== 'production') {
|
|
43
|
-
|
|
44
|
-
warnGetValue();
|
|
45
|
-
}
|
|
38
|
+
getCellValueWarning();
|
|
46
39
|
}
|
|
47
40
|
|
|
48
41
|
return (_apiRef$current = apiRef.current).getCellValue.apply(_apiRef$current, arguments);
|
|
@@ -8,6 +8,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
|
8
8
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
9
9
|
import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowIdsSelector } from './gridRowsSelector';
|
|
10
10
|
import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
11
|
+
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
11
12
|
|
|
12
13
|
function getGridRowId(rowModel, getRowId, detailErrorMessage) {
|
|
13
14
|
var id = getRowId ? getRowId(rowModel) : rowModel.id;
|
|
@@ -49,14 +50,12 @@ var getRowsStateFromCache = function getRowsStateFromCache(rowsCache, previousTr
|
|
|
49
50
|
var groupingResponse = apiRef.current.unstable_groupRows(_extends({}, value, {
|
|
50
51
|
previousTree: previousTree
|
|
51
52
|
}));
|
|
52
|
-
var dataTopLevelRowCount = Object.values(groupingResponse.tree).filter(function (node) {
|
|
53
|
+
var dataTopLevelRowCount = groupingResponse.treeDepth === 1 ? groupingResponse.ids.length : Object.values(groupingResponse.tree).filter(function (node) {
|
|
53
54
|
return node.parent == null;
|
|
54
55
|
}).length;
|
|
55
|
-
var totalRowCount = rowCount > groupingResponse.ids.length ? rowCount : groupingResponse.ids.length;
|
|
56
|
-
var totalTopLevelRowCount = rowCount > dataTopLevelRowCount ? rowCount : dataTopLevelRowCount;
|
|
57
56
|
return _extends({}, groupingResponse, {
|
|
58
|
-
totalRowCount:
|
|
59
|
-
totalTopLevelRowCount:
|
|
57
|
+
totalRowCount: Math.max(rowCount, groupingResponse.ids.length),
|
|
58
|
+
totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
|
|
60
59
|
});
|
|
61
60
|
};
|
|
62
61
|
|
|
@@ -95,11 +94,22 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
95
94
|
var logger = useGridLogger(apiRef, 'useGridRows');
|
|
96
95
|
var rowsCache = React.useRef(apiRef.current.state.rowsCache); // To avoid listing rowsCache as useEffect dep
|
|
97
96
|
|
|
97
|
+
var currentPage = useGridVisibleRows(apiRef, props);
|
|
98
98
|
var getRow = React.useCallback(function (id) {
|
|
99
99
|
var _gridRowsLookupSelect;
|
|
100
100
|
|
|
101
101
|
return (_gridRowsLookupSelect = gridRowsLookupSelector(apiRef)[id]) != null ? _gridRowsLookupSelect : null;
|
|
102
102
|
}, [apiRef]);
|
|
103
|
+
var lookup = React.useMemo(function () {
|
|
104
|
+
return currentPage.rows.reduce(function (acc, _ref2, index) {
|
|
105
|
+
var id = _ref2.id;
|
|
106
|
+
acc[id] = index;
|
|
107
|
+
return acc;
|
|
108
|
+
}, {});
|
|
109
|
+
}, [currentPage.rows]);
|
|
110
|
+
var getRowIndexRelativeToVisibleRows = React.useCallback(function (id) {
|
|
111
|
+
return lookup[id];
|
|
112
|
+
}, [lookup]);
|
|
103
113
|
var throttledRowsChange = React.useCallback(function (newState, throttle) {
|
|
104
114
|
var run = function run() {
|
|
105
115
|
rowsCache.current.timeout = null;
|
|
@@ -293,7 +303,8 @@ export var useGridRows = function useGridRows(apiRef, props) {
|
|
|
293
303
|
setRows: setRows,
|
|
294
304
|
updateRows: updateRows,
|
|
295
305
|
setRowChildrenExpansion: setRowChildrenExpansion,
|
|
296
|
-
getRowNode: getRowNode
|
|
306
|
+
getRowNode: getRowNode,
|
|
307
|
+
getRowIndexRelativeToVisibleRows: getRowIndexRelativeToVisibleRows
|
|
297
308
|
};
|
|
298
309
|
useGridApiMethod(apiRef, rowApi, 'GridRowApi');
|
|
299
310
|
};
|