@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,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridApiCommunity } from '../models/api/gridApiCommunity';
|
|
3
|
+
declare type GridContextProviderProps = {
|
|
4
|
+
apiRef: React.MutableRefObject<GridApiCommunity>;
|
|
5
|
+
props: {};
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare const GridContextProvider: ({ apiRef, props, children }: GridContextProviderProps) => JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
4
|
+
export declare const columnMenuStateInitializer: GridStateInitializer;
|
|
3
5
|
/**
|
|
4
6
|
* @requires useGridColumnResize (event)
|
|
5
7
|
* @requires useGridInfiniteLoader (event)
|
|
@@ -1,21 +1,20 @@
|
|
|
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 const columnMenuStateInitializer = state => _extends({}, state, {
|
|
7
|
+
columnMenu: {
|
|
8
|
+
open: false
|
|
9
|
+
}
|
|
10
|
+
});
|
|
8
11
|
/**
|
|
9
12
|
* @requires useGridColumnResize (event)
|
|
10
13
|
* @requires useGridInfiniteLoader (event)
|
|
11
14
|
*/
|
|
15
|
+
|
|
12
16
|
export const useGridColumnMenu = apiRef => {
|
|
13
17
|
const logger = useGridLogger(apiRef, 'useGridColumnMenu');
|
|
14
|
-
useGridStateInit(apiRef, state => _extends({}, state, {
|
|
15
|
-
columnMenu: {
|
|
16
|
-
open: false
|
|
17
|
-
}
|
|
18
|
-
}));
|
|
19
18
|
/**
|
|
20
19
|
* API METHODS
|
|
21
20
|
*/
|
|
@@ -63,38 +63,38 @@ export declare const gridFilterableColumnLookupSelector: import("../../../utils/
|
|
|
63
63
|
* @deprecated Use `gridColumnFieldsSelector` instead.
|
|
64
64
|
* @ignore - do not document.
|
|
65
65
|
*/
|
|
66
|
-
export declare const allGridColumnsFieldsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string[]
|
|
66
|
+
export declare const allGridColumnsFieldsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string[]> | ((...args: any[]) => any);
|
|
67
67
|
/**
|
|
68
68
|
* @category Columns
|
|
69
69
|
* @deprecated Use `gridColumnDefinitionsSelector` instead.
|
|
70
70
|
* @ignore - do not document.
|
|
71
71
|
*/
|
|
72
|
-
export declare const allGridColumnsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridStateColDef[]
|
|
72
|
+
export declare const allGridColumnsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridStateColDef[]> | ((...args: any[]) => any);
|
|
73
73
|
/**
|
|
74
74
|
* @category Visible Columns
|
|
75
75
|
* @deprecated Use `gridVisibleColumnDefinitionsSelector` instead.
|
|
76
76
|
* @ignore - do not document.
|
|
77
77
|
*/
|
|
78
|
-
export declare const visibleGridColumnsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridStateColDef[]
|
|
78
|
+
export declare const visibleGridColumnsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridStateColDef[]> | ((...args: any[]) => any);
|
|
79
79
|
/**
|
|
80
80
|
* @category Columns
|
|
81
81
|
* @deprecated Use `gridFilterableColumnDefinitionsSelector` instead.
|
|
82
82
|
* @ignore - do not document.
|
|
83
83
|
*/
|
|
84
|
-
export declare const filterableGridColumnsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridStateColDef[]
|
|
84
|
+
export declare const filterableGridColumnsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridStateColDef[]> | ((...args: any[]) => any);
|
|
85
85
|
/**
|
|
86
86
|
* @category Columns
|
|
87
87
|
* @deprecated Use `gridFilterableColumnLookupSelector` instead (not the same return format).
|
|
88
88
|
* @ignore - do not document.
|
|
89
89
|
*/
|
|
90
|
-
export declare const filterableGridColumnsIdsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string[]
|
|
90
|
+
export declare const filterableGridColumnsIdsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, string[]> | ((...args: any[]) => any);
|
|
91
91
|
/**
|
|
92
92
|
* Get the amount of visible columns.
|
|
93
93
|
* @category Visible Columns
|
|
94
|
-
* @deprecated Use the length of `gridVisibleColumnDefinitionsSelector` instead.
|
|
94
|
+
* @deprecated Use the length of the array returned by `gridVisibleColumnDefinitionsSelector` instead.
|
|
95
95
|
* @ignore - do not document.
|
|
96
96
|
*/
|
|
97
|
-
export declare const visibleGridColumnsLengthSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number
|
|
97
|
+
export declare const visibleGridColumnsLengthSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number> | ((...args: any[]) => any);
|
|
98
98
|
/**
|
|
99
99
|
* @category Visible Columns
|
|
100
100
|
* @deprecated Use `gridColumnsTotalWidthSelector` or `gridColumnPositionsSelector` instead.
|
|
@@ -103,4 +103,4 @@ export declare const visibleGridColumnsLengthSelector: import("../../../utils/cr
|
|
|
103
103
|
export declare const gridColumnsMetaSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, {
|
|
104
104
|
totalWidth: number;
|
|
105
105
|
positions: number[];
|
|
106
|
-
}
|
|
106
|
+
}> | ((...args: any[]) => any);
|
|
@@ -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 const gridColumnsSelector = state => state.columns;
|
|
10
11
|
/**
|
|
11
12
|
* Get the field of each column.
|
|
@@ -98,50 +99,50 @@ export const gridFilterableColumnLookupSelector = createSelector(gridColumnDefin
|
|
|
98
99
|
* @ignore - do not document.
|
|
99
100
|
*/
|
|
100
101
|
|
|
101
|
-
export const allGridColumnsFieldsSelector = gridColumnFieldsSelector;
|
|
102
|
+
export const allGridColumnsFieldsSelector = wrapWithWarningOnCall(gridColumnFieldsSelector, ['MUI: The method allGridColumnsFieldsSelector is deprecated and will be removed in the next major version.', 'Use gridColumnFieldsSelector instead']);
|
|
102
103
|
/**
|
|
103
104
|
* @category Columns
|
|
104
105
|
* @deprecated Use `gridColumnDefinitionsSelector` instead.
|
|
105
106
|
* @ignore - do not document.
|
|
106
107
|
*/
|
|
107
108
|
|
|
108
|
-
export const allGridColumnsSelector = gridColumnDefinitionsSelector;
|
|
109
|
+
export const allGridColumnsSelector = wrapWithWarningOnCall(gridColumnDefinitionsSelector, ['MUI: The method allGridColumnsSelector is deprecated and will be removed in the next major version.', 'Use gridColumnDefinitionsSelector instead']);
|
|
109
110
|
/**
|
|
110
111
|
* @category Visible Columns
|
|
111
112
|
* @deprecated Use `gridVisibleColumnDefinitionsSelector` instead.
|
|
112
113
|
* @ignore - do not document.
|
|
113
114
|
*/
|
|
114
115
|
|
|
115
|
-
export const visibleGridColumnsSelector = gridVisibleColumnDefinitionsSelector;
|
|
116
|
+
export const visibleGridColumnsSelector = wrapWithWarningOnCall(gridVisibleColumnDefinitionsSelector, ['MUI: The method visibleGridColumnsSelector is deprecated and will be removed in the next major version.', 'Use gridVisibleColumnDefinitionsSelector instead']);
|
|
116
117
|
/**
|
|
117
118
|
* @category Columns
|
|
118
119
|
* @deprecated Use `gridFilterableColumnDefinitionsSelector` instead.
|
|
119
120
|
* @ignore - do not document.
|
|
120
121
|
*/
|
|
121
122
|
|
|
122
|
-
export const filterableGridColumnsSelector = gridFilterableColumnDefinitionsSelector;
|
|
123
|
+
export const filterableGridColumnsSelector = wrapWithWarningOnCall(gridFilterableColumnDefinitionsSelector, ['MUI: The method filterableGridColumnsSelector is deprecated and will be removed in the next major version.', 'Use gridFilterableColumnDefinitionsSelector instead']);
|
|
123
124
|
/**
|
|
124
125
|
* @category Columns
|
|
125
126
|
* @deprecated Use `gridFilterableColumnLookupSelector` instead (not the same return format).
|
|
126
127
|
* @ignore - do not document.
|
|
127
128
|
*/
|
|
128
129
|
|
|
129
|
-
export const filterableGridColumnsIdsSelector = createSelector(gridFilterableColumnDefinitionsSelector, columns => columns.map(col => col.field));
|
|
130
|
+
export const filterableGridColumnsIdsSelector = wrapWithWarningOnCall(createSelector(gridFilterableColumnDefinitionsSelector, columns => columns.map(col => col.field)), ['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]);']);
|
|
130
131
|
/**
|
|
131
132
|
* Get the amount of visible columns.
|
|
132
133
|
* @category Visible Columns
|
|
133
|
-
* @deprecated Use the length of `gridVisibleColumnDefinitionsSelector` instead.
|
|
134
|
+
* @deprecated Use the length of the array returned by `gridVisibleColumnDefinitionsSelector` instead.
|
|
134
135
|
* @ignore - do not document.
|
|
135
136
|
*/
|
|
136
137
|
|
|
137
|
-
export const visibleGridColumnsLengthSelector = createSelector(gridVisibleColumnDefinitionsSelector, visibleColumns => visibleColumns.length);
|
|
138
|
+
export const visibleGridColumnsLengthSelector = wrapWithWarningOnCall(createSelector(gridVisibleColumnDefinitionsSelector, visibleColumns => visibleColumns.length), ['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.']);
|
|
138
139
|
/**
|
|
139
140
|
* @category Visible Columns
|
|
140
141
|
* @deprecated Use `gridColumnsTotalWidthSelector` or `gridColumnPositionsSelector` instead.
|
|
141
142
|
* @ignore - do not document.
|
|
142
143
|
*/
|
|
143
144
|
|
|
144
|
-
export const gridColumnsMetaSelector = createSelector(gridColumnPositionsSelector, gridColumnsTotalWidthSelector, (positions, totalWidth) => ({
|
|
145
|
+
export const gridColumnsMetaSelector = wrapWithWarningOnCall(createSelector(gridColumnPositionsSelector, gridColumnsTotalWidthSelector, (positions, totalWidth) => ({
|
|
145
146
|
totalWidth,
|
|
146
147
|
positions
|
|
147
|
-
}));
|
|
148
|
+
})), ['MUI: The method gridColumnsMetaSelector is deprecated and will be removed in the next major version.', 'Use gridColumnsTotalWidthSelector or gridColumnPositionsSelector instead']);
|
|
@@ -3,12 +3,14 @@ import { DEFAULT_GRID_COL_TYPE_KEY, getGridDefaultColumnTypes } from '../../../m
|
|
|
3
3
|
import { gridColumnsSelector, gridColumnVisibilityModelSelector } from './gridColumnsSelector';
|
|
4
4
|
import { clamp } from '../../../utils/utils';
|
|
5
5
|
export const computeColumnTypes = (customColumnTypes = {}) => {
|
|
6
|
-
const
|
|
6
|
+
const mergedColumnTypes = _extends({}, getGridDefaultColumnTypes());
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
Object.entries(customColumnTypes).forEach(([colType, colTypeDef]) => {
|
|
9
|
+
if (mergedColumnTypes[colType]) {
|
|
10
|
+
mergedColumnTypes[colType] = _extends({}, mergedColumnTypes[colType], colTypeDef);
|
|
11
|
+
} else {
|
|
12
|
+
mergedColumnTypes[colType] = _extends({}, mergedColumnTypes[colTypeDef.extendType || DEFAULT_GRID_COL_TYPE_KEY], colTypeDef);
|
|
13
|
+
}
|
|
12
14
|
});
|
|
13
15
|
return mergedColumnTypes;
|
|
14
16
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
4
5
|
export declare const COMPACT_DENSITY_FACTOR = 0.7;
|
|
5
6
|
export declare const COMFORTABLE_DENSITY_FACTOR = 1.3;
|
|
7
|
+
export declare const densityStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'density' | 'headerHeight' | 'rowHeight'>>;
|
|
6
8
|
export declare const useGridDensity: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'headerHeight' | 'rowHeight' | 'density'>) => void;
|
|
@@ -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 const COMPACT_DENSITY_FACTOR = 0.7;
|
|
@@ -37,11 +36,11 @@ const getUpdatedDensityState = (newDensity, newHeaderHeight, newRowHeight) => {
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
|
|
39
|
+
export const densityStateInitializer = (state, props) => _extends({}, state, {
|
|
40
|
+
density: getUpdatedDensityState(props.density, props.headerHeight, props.rowHeight)
|
|
41
|
+
});
|
|
40
42
|
export const useGridDensity = (apiRef, props) => {
|
|
41
43
|
const logger = useGridLogger(apiRef, 'useDensity');
|
|
42
|
-
useGridStateInit(apiRef, state => _extends({}, state, {
|
|
43
|
-
density: getUpdatedDensityState(props.density, props.headerHeight, props.rowHeight)
|
|
44
|
-
}));
|
|
45
44
|
const setDensity = React.useCallback((newDensity, newHeaderHeight = props.headerHeight, newRowHeight = props.rowHeight) => {
|
|
46
45
|
logger.debug(`Set grid density to ${newDensity}`);
|
|
47
46
|
apiRef.current.setState(state => {
|
|
@@ -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
|
const isTestEnvironment = process.env.NODE_ENV === 'test';
|
|
13
13
|
|
|
@@ -116,7 +116,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
116
116
|
return 0;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
const currentPage =
|
|
119
|
+
const currentPage = getVisibleRows(apiRef, {
|
|
120
120
|
pagination: props.pagination,
|
|
121
121
|
paginationMode: props.paginationMode
|
|
122
122
|
}); // TODO: Use a combination of scrollTop, dimensions.viewportInnerSize.height and rowsMeta.possitions
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
+
export declare const editingStateInitializer: GridStateInitializer;
|
|
4
6
|
/**
|
|
5
7
|
* @requires useGridFocus - can be after, async only
|
|
6
8
|
* @requires useGridParamsApi (method)
|
|
@@ -5,10 +5,12 @@ import { GridCellModes } from '../../../models/gridEditRowModel';
|
|
|
5
5
|
import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
|
|
6
6
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
7
7
|
import { useGridLogger } from '../../utils/useGridLogger';
|
|
8
|
-
import { useGridStateInit } from '../../utils/useGridStateInit';
|
|
9
8
|
import { gridEditRowsStateSelector } from './gridEditRowsSelector';
|
|
10
9
|
import { useCellEditing } from './useGridCellEditing';
|
|
11
10
|
import { useGridRowEditing } from './useGridRowEditing';
|
|
11
|
+
export const editingStateInitializer = state => _extends({}, state, {
|
|
12
|
+
editRows: {}
|
|
13
|
+
});
|
|
12
14
|
/**
|
|
13
15
|
* @requires useGridFocus - can be after, async only
|
|
14
16
|
* @requires useGridParamsApi (method)
|
|
@@ -21,9 +23,6 @@ export function useGridEditing(apiRef, props) {
|
|
|
21
23
|
const logger = useGridLogger(apiRef, 'useGridEditRows');
|
|
22
24
|
useCellEditing(apiRef, props);
|
|
23
25
|
useGridRowEditing(apiRef, props);
|
|
24
|
-
useGridStateInit(apiRef, state => _extends({}, state, {
|
|
25
|
-
editRows: {}
|
|
26
|
-
}));
|
|
27
26
|
const debounceMap = React.useRef({});
|
|
28
27
|
apiRef.current.unstable_updateControlState({
|
|
29
28
|
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
|
const serialiseCellValue = (value, delimiterCharacter) => {
|
|
4
5
|
if (typeof value === 'string') {
|
|
@@ -14,15 +15,14 @@ const serialiseCellValue = (value, delimiterCharacter) => {
|
|
|
14
15
|
return value;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
const 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.']);
|
|
18
19
|
|
|
19
20
|
const serialiseRow = (id, columns, getCellParams, delimiterCharacter) => columns.map(column => {
|
|
20
21
|
const cellParams = getCellParams(id, column.field);
|
|
21
22
|
|
|
22
23
|
if (process.env.NODE_ENV !== 'production') {
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
warnedOnce = true;
|
|
24
|
+
if (String(cellParams.formattedValue) === '[object Object]') {
|
|
25
|
+
objectFormattedValueWarning();
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -62,6 +62,7 @@ export declare const gridFilteredSortedRowIdsSelector: import("../../../utils/cr
|
|
|
62
62
|
* @category Filtering
|
|
63
63
|
* @deprecated Use `gridVisibleSortedRowIdsSelector` instead
|
|
64
64
|
* @ignore - do not document.
|
|
65
|
+
* TODO: Add deprecation warning once we have the new selectors without the "visible" keyword.
|
|
65
66
|
*/
|
|
66
67
|
export declare const gridVisibleRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, import("../../..").GridRowId[]>;
|
|
67
68
|
/**
|
|
@@ -63,6 +63,7 @@ export const gridFilteredSortedRowIdsSelector = createSelector(gridFilteredSorte
|
|
|
63
63
|
* @category Filtering
|
|
64
64
|
* @deprecated Use `gridVisibleSortedRowIdsSelector` instead
|
|
65
65
|
* @ignore - do not document.
|
|
66
|
+
* TODO: Add deprecation warning once we have the new selectors without the "visible" keyword.
|
|
66
67
|
*/
|
|
67
68
|
|
|
68
69
|
export const gridVisibleRowsSelector = gridVisibleSortedRowIdsSelector;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
+
export declare const focusStateInitializer: GridStateInitializer;
|
|
4
6
|
/**
|
|
5
7
|
* @requires useGridParamsApi (method)
|
|
6
8
|
* @requires useGridRows (method)
|
|
@@ -6,8 +6,17 @@ 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 const focusStateInitializer = state => _extends({}, state, {
|
|
11
|
+
focus: {
|
|
12
|
+
cell: null,
|
|
13
|
+
columnHeader: null
|
|
14
|
+
},
|
|
15
|
+
tabIndex: {
|
|
16
|
+
cell: null,
|
|
17
|
+
columnHeader: null
|
|
18
|
+
}
|
|
19
|
+
});
|
|
11
20
|
/**
|
|
12
21
|
* @requires useGridParamsApi (method)
|
|
13
22
|
* @requires useGridRows (method)
|
|
@@ -16,16 +25,6 @@ import { gridFocusCellSelector } from './gridFocusStateSelector';
|
|
|
16
25
|
|
|
17
26
|
export const useGridFocus = (apiRef, props) => {
|
|
18
27
|
const logger = useGridLogger(apiRef, 'useGridFocus');
|
|
19
|
-
useGridStateInit(apiRef, state => _extends({}, state, {
|
|
20
|
-
focus: {
|
|
21
|
-
cell: null,
|
|
22
|
-
columnHeader: null
|
|
23
|
-
},
|
|
24
|
-
tabIndex: {
|
|
25
|
-
cell: null,
|
|
26
|
-
columnHeader: null
|
|
27
|
-
}
|
|
28
|
-
}));
|
|
29
28
|
const lastClickedCell = React.useRef(null);
|
|
30
29
|
const setCellFocus = React.useCallback((id, field) => {
|
|
31
30
|
// 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 const useGridKeyboardNavigation = (apiRef, props) => {
|
|
23
23
|
const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
|
|
24
|
-
const currentPage =
|
|
24
|
+
const currentPage = useGridVisibleRows(apiRef, props);
|
|
25
25
|
const goToCell = React.useCallback((colIndex, rowIndex) => {
|
|
26
26
|
logger.debug(`Navigating to cell row ${rowIndex}, col ${colIndex}`);
|
|
27
27
|
apiRef.current.scrollToIndexes({
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
-
|
|
5
|
-
export declare const pageStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'initialState' | 'rowCount' | 'page'>>;
|
|
4
|
+
export declare const getPageCount: (rowCount: number, pageSize: number) => number;
|
|
6
5
|
/**
|
|
7
6
|
* @requires useGridPageSize (event)
|
|
8
7
|
*/
|
|
@@ -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
|
-
const getPageCount = (rowCount, pageSize) => {
|
|
9
|
+
export const getPageCount = (rowCount, pageSize) => {
|
|
11
10
|
if (pageSize > 0 && rowCount > 0) {
|
|
12
11
|
return Math.ceil(rowCount / pageSize);
|
|
13
12
|
}
|
|
@@ -32,23 +31,12 @@ const mergeStateWithPage = page => state => _extends({}, state, {
|
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
const 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');
|
|
35
|
-
export const pageStateInitializer = (state, props) => {
|
|
36
|
-
var _ref, _props$page, _props$initialState, _props$initialState$p, _props$rowCount, _props$rowCount2;
|
|
37
|
-
|
|
38
|
-
return _extends({}, state, {
|
|
39
|
-
pagination: _extends({}, state.pagination, {
|
|
40
|
-
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,
|
|
41
|
-
pageCount: getPageCount((_props$rowCount = props.rowCount) != null ? _props$rowCount : 0, state.pagination.pageSize),
|
|
42
|
-
rowCount: (_props$rowCount2 = props.rowCount) != null ? _props$rowCount2 : 0
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
34
|
/**
|
|
47
35
|
* @requires useGridPageSize (event)
|
|
48
36
|
*/
|
|
49
37
|
|
|
50
38
|
export const useGridPage = (apiRef, props) => {
|
|
51
|
-
var _props$
|
|
39
|
+
var _props$initialState2, _props$initialState2$;
|
|
52
40
|
|
|
53
41
|
const logger = useGridLogger(apiRef, 'useGridPage');
|
|
54
42
|
const visibleTopLevelRowCount = useGridSelector(apiRef, gridVisibleTopLevelRowCountSelector);
|
|
@@ -77,12 +65,12 @@ export const useGridPage = (apiRef, props) => {
|
|
|
77
65
|
*/
|
|
78
66
|
|
|
79
67
|
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
80
|
-
var _props$
|
|
68
|
+
var _props$initialState, _props$initialState$p;
|
|
81
69
|
|
|
82
70
|
const pageToExport = gridPageSelector(apiRef);
|
|
83
71
|
const shouldExportPage = // Always export if the page is controlled
|
|
84
72
|
props.page != null || // Always export if the page has been initialized
|
|
85
|
-
((_props$
|
|
73
|
+
((_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
|
|
86
74
|
pageToExport !== 0;
|
|
87
75
|
|
|
88
76
|
if (!shouldExportPage) {
|
|
@@ -94,7 +82,7 @@ export const useGridPage = (apiRef, props) => {
|
|
|
94
82
|
page: pageToExport
|
|
95
83
|
})
|
|
96
84
|
});
|
|
97
|
-
}, [apiRef, props.page, (_props$
|
|
85
|
+
}, [apiRef, props.page, (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.pagination) == null ? void 0 : _props$initialState2$.page]);
|
|
98
86
|
const stateRestorePreProcessing = React.useCallback((params, context) => {
|
|
99
87
|
var _context$stateToResto, _context$stateToResto2;
|
|
100
88
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
-
|
|
5
|
-
export declare const pageSizeStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'pageSize' | 'initialState' | 'autoPageSize'>>;
|
|
4
|
+
export declare const defaultPageSize: (autoPageSize: boolean) => 0 | 100;
|
|
6
5
|
/**
|
|
7
6
|
* @requires useGridDimensions (event) - can be after
|
|
8
7
|
*/
|
|
@@ -5,28 +5,7 @@ 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
|
-
const defaultPageSize = autoPageSize => autoPageSize ? 0 : 100;
|
|
10
|
-
|
|
11
|
-
export const pageSizeStateInitializer = (state, props) => {
|
|
12
|
-
var _props$initialState, _props$initialState$p;
|
|
13
|
-
|
|
14
|
-
let pageSize;
|
|
15
|
-
|
|
16
|
-
if (props.pageSize != null) {
|
|
17
|
-
pageSize = props.pageSize;
|
|
18
|
-
} else if (((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null) {
|
|
19
|
-
pageSize = props.initialState.pagination.pageSize;
|
|
20
|
-
} else {
|
|
21
|
-
pageSize = defaultPageSize(props.autoPageSize);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return _extends({}, state, {
|
|
25
|
-
pagination: {
|
|
26
|
-
pageSize
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
8
|
+
export const defaultPageSize = autoPageSize => autoPageSize ? 0 : 100;
|
|
30
9
|
|
|
31
10
|
const mergeStateWithPageSize = pageSize => state => _extends({}, state, {
|
|
32
11
|
pagination: _extends({}, state.pagination, {
|
|
@@ -39,7 +18,7 @@ const mergeStateWithPageSize = pageSize => state => _extends({}, state, {
|
|
|
39
18
|
|
|
40
19
|
|
|
41
20
|
export const useGridPageSize = (apiRef, props) => {
|
|
42
|
-
var _props$
|
|
21
|
+
var _props$initialState2, _props$initialState2$;
|
|
43
22
|
|
|
44
23
|
const logger = useGridLogger(apiRef, 'useGridPageSize');
|
|
45
24
|
const rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector);
|
|
@@ -72,12 +51,12 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
72
51
|
*/
|
|
73
52
|
|
|
74
53
|
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
75
|
-
var _props$
|
|
54
|
+
var _props$initialState, _props$initialState$p;
|
|
76
55
|
|
|
77
56
|
const pageSizeToExport = gridPageSizeSelector(apiRef);
|
|
78
57
|
const shouldExportPageSize = // Always export if the page size is controlled
|
|
79
58
|
props.pageSize != null || // Always export if the page size has been initialized
|
|
80
|
-
((_props$
|
|
59
|
+
((_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
|
|
81
60
|
pageSizeToExport !== defaultPageSize(props.autoPageSize);
|
|
82
61
|
|
|
83
62
|
if (!shouldExportPageSize) {
|
|
@@ -89,7 +68,7 @@ export const useGridPageSize = (apiRef, props) => {
|
|
|
89
68
|
pageSize: pageSizeToExport
|
|
90
69
|
})
|
|
91
70
|
});
|
|
92
|
-
}, [apiRef, props.pageSize, (_props$
|
|
71
|
+
}, [apiRef, props.pageSize, (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.pagination) == null ? void 0 : _props$initialState2$.pageSize, props.autoPageSize]);
|
|
93
72
|
/**
|
|
94
73
|
* TODO: Add error if `prop.autoHeight = true`
|
|
95
74
|
*/
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
+
export declare const paginationStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'page' | 'pageSize' | 'rowCount' | 'initialState' | 'autoPageSize'>>;
|
|
4
6
|
/**
|
|
5
7
|
* @requires useGridFilter (state)
|
|
6
8
|
* @requires useGridDimensions (event) - can be after
|
|
@@ -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 const paginationStateInitializer = (state, props) => {
|
|
5
|
+
var _props$initialState, _props$initialState$p, _ref, _props$page, _props$initialState2, _props$initialState2$, _props$rowCount, _props$rowCount2;
|
|
6
|
+
|
|
7
|
+
let 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,
|
|
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
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
+
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
5
|
+
export declare const preferencePanelStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'initialState'>>;
|
|
4
6
|
/**
|
|
5
7
|
* TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
|
|
6
8
|
*/
|
|
7
|
-
export declare const useGridPreferencesPanel: (apiRef: React.MutableRefObject<GridApiCommunity
|
|
9
|
+
export declare const useGridPreferencesPanel: (apiRef: React.MutableRefObject<GridApiCommunity>) => void;
|