@mui/x-data-grid 5.8.0 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +141 -63
- package/DataGrid/DataGrid.js +1 -1
- package/DataGrid/useDataGridComponent.js +3 -1
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/components/GridRow.d.ts +4 -0
- package/components/GridRow.js +49 -23
- package/components/base/GridOverlays.js +4 -3
- package/components/cell/GridActionsCell.d.ts +5 -1
- package/components/cell/GridActionsCell.js +170 -21
- package/components/cell/GridActionsCellItem.d.ts +66 -4
- package/components/cell/GridActionsCellItem.js +7 -5
- package/components/cell/GridCell.d.ts +1 -0
- package/components/cell/GridCell.js +28 -7
- package/components/cell/GridEditInputCell.js +1 -1
- package/components/cell/GridEditSingleSelectCell.js +22 -13
- package/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/components/columnHeaders/GridColumnHeaders.d.ts +0 -1
- package/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/components/columnSelection/GridCellCheckboxRenderer.d.ts +3 -3
- package/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/components/panel/GridPanel.js +1 -0
- package/components/panel/filterPanel/GridFilterForm.js +14 -10
- package/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -15
- package/components/panel/filterPanel/GridFilterInputValue.js +22 -15
- package/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/components/toolbar/GridToolbarFilterButton.d.ts +1 -1
- package/components/virtualization/GridVirtualScroller.js +2 -0
- package/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/constants/gridDetailPanelToggleField.d.ts +1 -0
- package/constants/gridDetailPanelToggleField.js +2 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +32 -15
- package/hooks/core/pipeProcessing/index.d.ts +1 -0
- package/hooks/core/pipeProcessing/index.js +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +8 -3
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +3 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +0 -3
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
- package/hooks/features/columns/gridColumnsInterfaces.d.ts +3 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +19 -1
- package/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/hooks/features/columns/useGridColumnSpanning.d.ts +7 -0
- package/hooks/features/columns/useGridColumnSpanning.js +109 -0
- package/hooks/features/columns/useGridColumns.js +24 -18
- package/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/hooks/features/editRows/useGridRowEditing.new.js +23 -15
- package/hooks/features/filter/useGridFilter.js +14 -9
- package/hooks/features/focus/useGridFocus.js +19 -9
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -0
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -7
- package/hooks/features/rows/gridRowsSelector.d.ts +1 -0
- package/hooks/features/rows/gridRowsSelector.js +1 -0
- package/hooks/features/rows/gridRowsState.d.ts +4 -0
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +5 -4
- package/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/hooks/features/scroll/useGridScroll.d.ts +2 -0
- package/hooks/features/scroll/useGridScroll.js +25 -3
- package/hooks/features/selection/useGridSelection.js +3 -2
- package/hooks/features/sorting/useGridSorting.js +10 -10
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +7 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +54 -27
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/legacy/DataGrid/DataGrid.js +1 -1
- package/legacy/DataGrid/useDataGridComponent.js +3 -1
- package/legacy/components/GridRow.js +47 -23
- package/legacy/components/base/GridOverlays.js +4 -3
- package/legacy/components/cell/GridActionsCell.js +188 -27
- package/legacy/components/cell/GridActionsCellItem.js +7 -5
- package/legacy/components/cell/GridCell.js +29 -7
- package/legacy/components/cell/GridEditInputCell.js +1 -1
- package/legacy/components/cell/GridEditSingleSelectCell.js +33 -24
- package/legacy/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/legacy/components/columnHeaders/GridColumnHeaders.js +2 -3
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +21 -3
- package/legacy/components/panel/GridPanel.js +1 -0
- package/legacy/components/panel/filterPanel/GridFilterForm.js +14 -10
- package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +13 -8
- package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +22 -17
- package/legacy/components/panel/filterPanel/GridFilterInputValue.js +22 -17
- package/legacy/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/legacy/components/virtualization/GridVirtualScroller.js +2 -0
- package/legacy/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/legacy/constants/gridDetailPanelToggleField.js +2 -0
- package/legacy/hooks/core/pipeProcessing/index.js +2 -1
- package/legacy/hooks/core/pipeProcessing/useGridPipeProcessing.js +60 -24
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/legacy/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +89 -10
- package/legacy/hooks/features/columns/gridColumnsUtils.js +79 -22
- package/legacy/hooks/features/columns/useGridColumnSpanning.js +107 -0
- package/legacy/hooks/features/columns/useGridColumns.js +24 -18
- package/legacy/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +14 -8
- package/legacy/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +32 -24
- package/legacy/hooks/features/filter/useGridFilter.js +14 -9
- package/legacy/hooks/features/focus/useGridFocus.js +19 -9
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +39 -6
- package/legacy/hooks/features/rows/gridRowsSelector.js +3 -0
- package/legacy/hooks/features/rows/useGridRows.js +5 -4
- package/legacy/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/legacy/hooks/features/scroll/useGridScroll.js +25 -3
- package/legacy/hooks/features/selection/useGridSelection.js +3 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +5 -7
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +65 -37
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -0
- package/legacy/locales/huHU.js +120 -0
- package/legacy/locales/index.js +1 -0
- package/legacy/models/api/gridColumnSpanning.js +1 -0
- package/legacy/models/events/gridEvents.js +2 -3
- package/legacy/models/gridColumnSpanning.js +1 -0
- package/locales/huHU.d.ts +2 -0
- package/locales/huHU.js +108 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/models/api/gridApiCommon.d.ts +2 -1
- package/models/api/gridColumnSpanning.d.ts +28 -0
- package/models/api/gridColumnSpanning.js +1 -0
- package/models/api/gridEditingApi.d.ts +49 -3
- package/models/colDef/gridColDef.d.ts +5 -0
- package/models/events/gridEventLookup.d.ts +3 -8
- package/models/events/gridEvents.d.ts +9 -14
- package/models/events/gridEvents.js +2 -3
- package/models/gridColumnSpanning.d.ts +12 -0
- package/models/gridColumnSpanning.js +1 -0
- package/models/gridEditRowModel.d.ts +1 -1
- package/models/params/gridCellParams.d.ts +12 -2
- package/models/params/gridRowParams.d.ts +5 -0
- package/models/props/DataGridProps.d.ts +1 -1
- package/modern/DataGrid/DataGrid.js +1 -1
- package/modern/DataGrid/useDataGridComponent.js +3 -1
- package/modern/components/GridRow.js +47 -21
- package/modern/components/base/GridOverlays.js +4 -3
- package/modern/components/cell/GridActionsCell.js +168 -21
- package/modern/components/cell/GridActionsCellItem.js +7 -5
- package/modern/components/cell/GridCell.js +28 -7
- package/modern/components/cell/GridEditInputCell.js +1 -1
- package/modern/components/cell/GridEditSingleSelectCell.js +20 -11
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/modern/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/modern/components/panel/GridPanel.js +1 -0
- package/modern/components/panel/filterPanel/GridFilterForm.js +10 -6
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +11 -6
- package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +20 -13
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +20 -13
- package/modern/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/modern/components/virtualization/GridVirtualScroller.js +2 -0
- package/modern/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/modern/constants/gridDetailPanelToggleField.js +2 -0
- package/modern/hooks/core/pipeProcessing/index.js +2 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +53 -19
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +27 -0
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -4
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +76 -10
- package/modern/hooks/features/columns/gridColumnsUtils.js +61 -8
- package/modern/hooks/features/columns/useGridColumnSpanning.js +107 -0
- package/modern/hooks/features/columns/useGridColumns.js +24 -18
- package/modern/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/modern/hooks/features/editRows/useGridEditing.new.js +7 -3
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +23 -15
- package/modern/hooks/features/filter/useGridFilter.js +14 -9
- package/modern/hooks/features/focus/useGridFocus.js +19 -9
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +37 -7
- package/modern/hooks/features/rows/gridRowsSelector.js +1 -0
- package/modern/hooks/features/rows/useGridRows.js +5 -4
- package/modern/hooks/features/rows/useGridRowsMeta.js +6 -13
- package/modern/hooks/features/scroll/useGridScroll.js +23 -3
- package/modern/hooks/features/selection/useGridSelection.js +3 -2
- package/modern/hooks/features/sorting/useGridSorting.js +10 -10
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +54 -23
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/locales/huHU.js +108 -0
- package/modern/locales/index.js +1 -0
- package/modern/models/api/gridColumnSpanning.js +1 -0
- package/modern/models/events/gridEvents.js +2 -3
- package/modern/models/gridColumnSpanning.js +1 -0
- package/node/DataGrid/DataGrid.js +1 -1
- package/node/DataGrid/useDataGridComponent.js +4 -1
- package/node/components/GridRow.js +50 -23
- package/node/components/base/GridOverlays.js +3 -2
- package/node/components/cell/GridActionsCell.js +172 -21
- package/node/components/cell/GridActionsCellItem.js +7 -4
- package/node/components/cell/GridCell.js +28 -7
- package/node/components/cell/GridEditInputCell.js +1 -1
- package/node/components/cell/GridEditSingleSelectCell.js +23 -13
- package/node/components/columnHeaders/GridColumnHeaderItem.js +4 -7
- package/node/components/columnHeaders/GridColumnHeaders.js +1 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +20 -3
- package/node/components/panel/GridPanel.js +1 -0
- package/node/components/panel/filterPanel/GridFilterForm.js +15 -10
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +14 -8
- package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +23 -15
- package/node/components/panel/filterPanel/GridFilterInputValue.js +23 -15
- package/node/components/toolbar/GridToolbarDensitySelector.js +1 -1
- package/node/components/virtualization/GridVirtualScroller.js +2 -0
- package/node/components/virtualization/GridVirtualScrollerContent.js +1 -3
- package/node/constants/gridDetailPanelToggleField.js +9 -0
- package/node/hooks/core/pipeProcessing/index.js +13 -0
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +51 -20
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +42 -0
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +0 -3
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +80 -10
- package/node/hooks/features/columns/gridColumnsUtils.js +65 -9
- package/node/hooks/features/columns/useGridColumnSpanning.js +130 -0
- package/node/hooks/features/columns/useGridColumns.js +23 -17
- package/node/hooks/features/dimensions/useGridDimensions.js +3 -3
- package/node/hooks/features/editRows/useGridCellEditing.new.js +18 -10
- package/node/hooks/features/editRows/useGridEditing.new.js +6 -2
- package/node/hooks/features/editRows/useGridRowEditing.new.js +21 -14
- package/node/hooks/features/filter/useGridFilter.js +14 -9
- package/node/hooks/features/focus/useGridFocus.js +19 -9
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +40 -7
- package/node/hooks/features/rows/gridRowsSelector.js +3 -1
- package/node/hooks/features/rows/useGridRows.js +5 -4
- package/node/hooks/features/rows/useGridRowsMeta.js +6 -14
- package/node/hooks/features/scroll/useGridScroll.js +26 -2
- package/node/hooks/features/selection/useGridSelection.js +4 -2
- package/node/hooks/features/sorting/useGridSorting.js +10 -10
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +59 -27
- package/node/index.js +1 -1
- package/node/internals/index.js +8 -0
- package/node/locales/huHU.js +118 -0
- package/node/locales/index.js +13 -0
- package/node/models/api/gridColumnSpanning.js +5 -0
- package/node/models/events/gridEvents.js +2 -3
- package/node/models/gridColumnSpanning.js +5 -0
- package/package.json +4 -4
- package/utils/domUtils.d.ts +2 -2
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { GridCellIndexCoordinates, GridScrollParams } from '../../../models';
|
|
2
|
+
import { GridCellIndexCoordinates, GridScrollParams, GridColDef } from '../../../models';
|
|
3
3
|
import { GridInitialStateCommunity } from '../../../models/gridStateCommunity';
|
|
4
|
-
import { GridColDef } from '../../../models/colDef/gridColDef';
|
|
5
4
|
import { GridRestoreStatePreProcessingContext, GridRestoreStatePreProcessingValue } from '../../features/statePersistence/gridStatePersistenceInterface';
|
|
6
5
|
import { GridHydrateColumnsValue } from '../../features/columns/gridColumnsInterfaces';
|
|
7
6
|
import { GridRowEntry } from '../../../models/gridRows';
|
|
8
7
|
import { GridPreferencePanelsValue } from '../../features/preferencesPanel';
|
|
9
8
|
export declare type GridPipeProcessorGroup = keyof GridPipeProcessingLookup;
|
|
10
9
|
export interface GridPipeProcessingLookup {
|
|
11
|
-
hydrateColumns: {
|
|
12
|
-
value: GridHydrateColumnsValue;
|
|
13
|
-
};
|
|
14
|
-
scrollToIndexes: {
|
|
15
|
-
value: Partial<GridScrollParams>;
|
|
16
|
-
context: Partial<GridCellIndexCoordinates>;
|
|
17
|
-
};
|
|
18
10
|
columnMenu: {
|
|
19
11
|
value: React.ReactNode[];
|
|
20
12
|
context: GridColDef;
|
|
@@ -22,6 +14,13 @@ export interface GridPipeProcessingLookup {
|
|
|
22
14
|
exportState: {
|
|
23
15
|
value: GridInitialStateCommunity;
|
|
24
16
|
};
|
|
17
|
+
hydrateColumns: {
|
|
18
|
+
value: GridHydrateColumnsValue;
|
|
19
|
+
};
|
|
20
|
+
preferencePanel: {
|
|
21
|
+
value: React.ReactNode;
|
|
22
|
+
context: GridPreferencePanelsValue;
|
|
23
|
+
};
|
|
25
24
|
restoreState: {
|
|
26
25
|
value: GridRestoreStatePreProcessingValue;
|
|
27
26
|
context: GridRestoreStatePreProcessingContext<GridInitialStateCommunity>;
|
|
@@ -30,9 +29,9 @@ export interface GridPipeProcessingLookup {
|
|
|
30
29
|
value: Record<string, number>;
|
|
31
30
|
context: GridRowEntry;
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
value:
|
|
35
|
-
context:
|
|
32
|
+
scrollToIndexes: {
|
|
33
|
+
value: Partial<GridScrollParams>;
|
|
34
|
+
context: Partial<GridCellIndexCoordinates>;
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
37
|
export declare type GridPipeProcessor<P extends GridPipeProcessorGroup> = (value: GridPipeProcessingLookup[P]['value'], context: GridPipeProcessingLookup[P] extends {
|
|
@@ -46,14 +45,14 @@ declare type GridPipeProcessorsApplierArgs<P extends GridPipeProcessorGroup, T e
|
|
|
46
45
|
declare type GridPipeProcessorsApplier = <P extends GridPipeProcessorGroup>(...params: GridPipeProcessorsApplierArgs<P, GridPipeProcessingLookup[P]>) => GridPipeProcessingLookup[P]['value'];
|
|
47
46
|
export interface GridPipeProcessingApi {
|
|
48
47
|
/**
|
|
49
|
-
* Register a
|
|
48
|
+
* Register a processor and run all the appliers of the group.
|
|
50
49
|
* @param {GridPipeProcessorGroup} group The group on which this processor should be applied.
|
|
51
|
-
* @param {
|
|
50
|
+
* @param {string} id An unique and static identifier of the processor.
|
|
52
51
|
* @param {GridPipeProcessor} processor The processor to register.
|
|
53
52
|
* @returns {() => void} A function to unregister the processor.
|
|
54
53
|
* @ignore - do not document.
|
|
55
54
|
*/
|
|
56
|
-
unstable_registerPipeProcessor: <G extends GridPipeProcessorGroup>(
|
|
55
|
+
unstable_registerPipeProcessor: <G extends GridPipeProcessorGroup>(group: GridPipeProcessorGroup, id: string, callback: GridPipeProcessor<G>) => () => void;
|
|
57
56
|
/**
|
|
58
57
|
* Run all the processors registered for the given group.
|
|
59
58
|
* @template T
|
|
@@ -64,5 +63,23 @@ export interface GridPipeProcessingApi {
|
|
|
64
63
|
* @ignore - do not document.
|
|
65
64
|
*/
|
|
66
65
|
unstable_applyPipeProcessors: GridPipeProcessorsApplier;
|
|
66
|
+
/**
|
|
67
|
+
* Register an applier.
|
|
68
|
+
* @param {GridPipeProcessorGroup} group The group of this applier
|
|
69
|
+
* @param {string} id An unique and static identifier of the applier.
|
|
70
|
+
* @param {() => void} applier The applier to register.
|
|
71
|
+
* @returns {() => void} A function to unregister the applier.
|
|
72
|
+
* @ignore - do not document.
|
|
73
|
+
*/
|
|
74
|
+
unstable_registerPipeApplier: (group: GridPipeProcessorGroup, id: string, applier: () => void) => () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Imperatively run all the appliers of a group.
|
|
77
|
+
* Most of the time, the applier should run because a processor is re-registered,
|
|
78
|
+
* but sometimes we want to re-apply the processing even if the processor deps have not changed.
|
|
79
|
+
* This may occur when the change requires a `isDeepEqual` check.
|
|
80
|
+
* @param {GridPipeProcessorGroup} group The group to apply.
|
|
81
|
+
* @ignore - do not document.
|
|
82
|
+
*/
|
|
83
|
+
unstable_requestPipeProcessorsApplication: (group: GridPipeProcessorGroup) => void;
|
|
67
84
|
}
|
|
68
85
|
export {};
|
|
@@ -13,7 +13,10 @@ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
|
13
13
|
* The plugin containing the custom logic must use:
|
|
14
14
|
*
|
|
15
15
|
* - `useGridRegisterPipeProcessor` to register their processor.
|
|
16
|
-
*
|
|
16
|
+
*
|
|
17
|
+
* - `apiRef.current.unstable_requestPipeProcessorsApplication` to imperatively re-apply a group.
|
|
18
|
+
* This method should be used in last resort.
|
|
19
|
+
* Most of the time, the application should be triggered by an update on the deps of the processor.
|
|
17
20
|
*
|
|
18
21
|
* =====================================================================================================================
|
|
19
22
|
*
|
|
@@ -21,7 +24,9 @@ import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
|
21
24
|
*
|
|
22
25
|
* - `apiRef.current.unstable_applyPipeProcessors` to run in chain all the processors of a given group.
|
|
23
26
|
*
|
|
24
|
-
* - `
|
|
25
|
-
*
|
|
27
|
+
* - `useGridRegisterPipeApplier` to re-apply the whole pipe when requested.
|
|
28
|
+
* The applier will be called when:
|
|
29
|
+
* * a processor is registered.
|
|
30
|
+
* * `apiRef.current.unstable_requestPipeProcessorsApplication` is called for the given group.
|
|
26
31
|
*/
|
|
27
32
|
export declare const useGridPipeProcessing: (apiRef: React.MutableRefObject<GridApiCommunity>) => void;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
import { useGridApiMethod } from '../../utils/useGridApiMethod';
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
/**
|
|
8
7
|
* Implement the Pipeline Pattern
|
|
9
8
|
*
|
|
@@ -17,7 +16,10 @@ import { GridEvents } from '../../../models/events';
|
|
|
17
16
|
* The plugin containing the custom logic must use:
|
|
18
17
|
*
|
|
19
18
|
* - `useGridRegisterPipeProcessor` to register their processor.
|
|
20
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* - `apiRef.current.unstable_requestPipeProcessorsApplication` to imperatively re-apply a group.
|
|
21
|
+
* This method should be used in last resort.
|
|
22
|
+
* Most of the time, the application should be triggered by an update on the deps of the processor.
|
|
21
23
|
*
|
|
22
24
|
* =====================================================================================================================
|
|
23
25
|
*
|
|
@@ -25,35 +27,65 @@ import { GridEvents } from '../../../models/events';
|
|
|
25
27
|
*
|
|
26
28
|
* - `apiRef.current.unstable_applyPipeProcessors` to run in chain all the processors of a given group.
|
|
27
29
|
*
|
|
28
|
-
* - `
|
|
29
|
-
*
|
|
30
|
+
* - `useGridRegisterPipeApplier` to re-apply the whole pipe when requested.
|
|
31
|
+
* The applier will be called when:
|
|
32
|
+
* * a processor is registered.
|
|
33
|
+
* * `apiRef.current.unstable_requestPipeProcessorsApplication` is called for the given group.
|
|
30
34
|
*/
|
|
31
|
-
|
|
32
35
|
export const useGridPipeProcessing = apiRef => {
|
|
33
36
|
const processorsCache = React.useRef({});
|
|
37
|
+
const runAppliers = React.useCallback(groupCache => {
|
|
38
|
+
if (!groupCache) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Object.values(groupCache.appliers).forEach(callback => {
|
|
43
|
+
callback();
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
34
46
|
const registerPipeProcessor = React.useCallback((group, id, processor) => {
|
|
35
47
|
if (!processorsCache.current[group]) {
|
|
36
|
-
processorsCache.current[group] = {
|
|
48
|
+
processorsCache.current[group] = {
|
|
49
|
+
processors: {},
|
|
50
|
+
appliers: {}
|
|
51
|
+
};
|
|
37
52
|
}
|
|
38
53
|
|
|
39
|
-
const
|
|
40
|
-
const oldProcessor =
|
|
54
|
+
const groupCache = processorsCache.current[group];
|
|
55
|
+
const oldProcessor = groupCache.processors[id];
|
|
41
56
|
|
|
42
57
|
if (oldProcessor !== processor) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
apiRef.current.publishEvent(GridEvents.pipeProcessorRegister, group);
|
|
58
|
+
groupCache.processors[id] = processor;
|
|
59
|
+
runAppliers(groupCache);
|
|
47
60
|
}
|
|
48
61
|
|
|
49
62
|
return () => {
|
|
50
|
-
const
|
|
51
|
-
otherProcessors = _objectWithoutPropertiesLoose(
|
|
63
|
+
const _processors = processorsCache.current[group].processors,
|
|
64
|
+
otherProcessors = _objectWithoutPropertiesLoose(_processors, [id].map(_toPropertyKey));
|
|
52
65
|
|
|
53
|
-
processorsCache.current[group] = otherProcessors;
|
|
54
|
-
apiRef.current.publishEvent(GridEvents.pipeProcessorUnregister, group);
|
|
66
|
+
processorsCache.current[group].processors = otherProcessors;
|
|
55
67
|
};
|
|
56
|
-
}, [
|
|
68
|
+
}, [runAppliers]);
|
|
69
|
+
const registerPipeApplier = React.useCallback((group, id, applier) => {
|
|
70
|
+
if (!processorsCache.current[group]) {
|
|
71
|
+
processorsCache.current[group] = {
|
|
72
|
+
processors: {},
|
|
73
|
+
appliers: {}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
processorsCache.current[group].appliers[id] = applier;
|
|
78
|
+
return () => {
|
|
79
|
+
const _appliers = processorsCache.current[group].appliers,
|
|
80
|
+
otherAppliers = _objectWithoutPropertiesLoose(_appliers, [id].map(_toPropertyKey));
|
|
81
|
+
|
|
82
|
+
processorsCache.current[group].appliers = otherAppliers;
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
const requestPipeProcessorsApplication = React.useCallback(group => {
|
|
86
|
+
const groupCache = processorsCache.current[group];
|
|
87
|
+
runAppliers(groupCache);
|
|
88
|
+
}, [runAppliers]);
|
|
57
89
|
const applyPipeProcessors = React.useCallback((...args) => {
|
|
58
90
|
const [group, value, context] = args;
|
|
59
91
|
|
|
@@ -61,13 +93,15 @@ export const useGridPipeProcessing = apiRef => {
|
|
|
61
93
|
return value;
|
|
62
94
|
}
|
|
63
95
|
|
|
64
|
-
const preProcessors = Object.values(processorsCache.current[group]);
|
|
96
|
+
const preProcessors = Object.values(processorsCache.current[group].processors);
|
|
65
97
|
return preProcessors.reduce((acc, preProcessor) => {
|
|
66
98
|
return preProcessor(acc, context);
|
|
67
99
|
}, value);
|
|
68
100
|
}, []);
|
|
69
101
|
const preProcessingApi = {
|
|
70
102
|
unstable_registerPipeProcessor: registerPipeProcessor,
|
|
103
|
+
unstable_registerPipeApplier: registerPipeApplier,
|
|
104
|
+
unstable_requestPipeProcessorsApplication: requestPipeProcessorsApplication,
|
|
71
105
|
unstable_applyPipeProcessors: applyPipeProcessors
|
|
72
106
|
};
|
|
73
107
|
useGridApiMethod(apiRef, preProcessingApi, 'GridPipeProcessingApi');
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridApiCommon } from '../../../models/api/gridApiCommon';
|
|
3
|
+
export declare const useGridRegisterPipeApplier: <Api extends GridApiCommon, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: () => void) => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useFirstRender } from '../../utils/useFirstRender';
|
|
3
|
+
export const useGridRegisterPipeApplier = (apiRef, group, callback) => {
|
|
4
|
+
const cleanup = React.useRef();
|
|
5
|
+
const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
|
|
6
|
+
const registerPreProcessor = React.useCallback(() => {
|
|
7
|
+
cleanup.current = apiRef.current.unstable_registerPipeApplier(group, id.current, callback);
|
|
8
|
+
}, [apiRef, callback, group]);
|
|
9
|
+
useFirstRender(() => {
|
|
10
|
+
registerPreProcessor();
|
|
11
|
+
});
|
|
12
|
+
const isFirstRender = React.useRef(true);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (isFirstRender.current) {
|
|
15
|
+
isFirstRender.current = false;
|
|
16
|
+
} else {
|
|
17
|
+
registerPreProcessor();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
if (cleanup.current) {
|
|
22
|
+
cleanup.current();
|
|
23
|
+
cleanup.current = null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}, [registerPreProcessor]);
|
|
27
|
+
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridApiCommon } from '../../../models/api/gridApiCommon';
|
|
3
3
|
import { GridPipeProcessor } from './gridPipeProcessingApi';
|
|
4
|
-
/**
|
|
5
|
-
* TODO: Rename `useGridRegisterPipeProcessor`
|
|
6
|
-
*/
|
|
7
4
|
export declare const useGridRegisterPipeProcessor: <Api extends GridApiCommon, G extends keyof import("./gridPipeProcessingApi").GridPipeProcessingLookup>(apiRef: React.MutableRefObject<Api>, group: G, callback: GridPipeProcessor<G>) => void;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useFirstRender } from '../../utils/useFirstRender';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TODO: Rename `useGridRegisterPipeProcessor`
|
|
6
|
-
*/
|
|
7
3
|
export const useGridRegisterPipeProcessor = (apiRef, group, callback) => {
|
|
8
4
|
const cleanup = React.useRef();
|
|
9
5
|
const id = React.useRef(`mui-${Math.round(Math.random() * 1e9)}`);
|
|
@@ -12,7 +12,6 @@ export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) =>
|
|
|
12
12
|
maxLastColumn?: number | undefined;
|
|
13
13
|
} | undefined, other?: {}) => JSX.Element[] | null;
|
|
14
14
|
isDragging: boolean;
|
|
15
|
-
updateInnerPosition: (nextRenderContext: GridRenderContext) => void;
|
|
16
15
|
getRootProps: (other?: {}) => {
|
|
17
16
|
style: {
|
|
18
17
|
minHeight: number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import * as ReactDOM from 'react-dom';
|
|
3
4
|
import { useForkRef } from '@mui/material/utils';
|
|
5
|
+
import { defaultMemoize } from 'reselect';
|
|
4
6
|
import { useGridApiContext } from '../../utils/useGridApiContext';
|
|
5
7
|
import { useGridSelector } from '../../utils/useGridSelector';
|
|
6
8
|
import { gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from '../columns/gridColumnsSelector';
|
|
@@ -13,7 +15,15 @@ import { useGridRootProps } from '../../utils/useGridRootProps';
|
|
|
13
15
|
import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
|
|
14
16
|
import { GridEvents } from '../../../models/events';
|
|
15
17
|
import { GridColumnHeaderItem } from '../../../components/columnHeaders/GridColumnHeaderItem';
|
|
18
|
+
import { getFirstColumnIndexToRender } from '../columns/gridColumnsUtils';
|
|
19
|
+
import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
|
|
20
|
+
import { getRenderableIndexes } from '../virtualization/useGridVirtualScroller';
|
|
16
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
|
|
23
|
+
function isUIEvent(event) {
|
|
24
|
+
return !!event.target;
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
export const useGridColumnHeaders = props => {
|
|
18
28
|
const {
|
|
19
29
|
innerRef: innerRefProp,
|
|
@@ -37,18 +47,43 @@ export const useGridColumnHeaders = props => {
|
|
|
37
47
|
const [renderContext, setRenderContext] = React.useState(null);
|
|
38
48
|
const prevRenderContext = React.useRef(renderContext);
|
|
39
49
|
const prevScrollLeft = React.useRef(0);
|
|
50
|
+
const currentPage = useGridVisibleRows(apiRef, rootProps);
|
|
40
51
|
React.useEffect(() => {
|
|
41
52
|
apiRef.current.columnHeadersContainerElementRef.current.scrollLeft = 0;
|
|
42
|
-
}, [apiRef]);
|
|
53
|
+
}, [apiRef]); // memoize `getFirstColumnIndexToRender`, since it's called on scroll
|
|
54
|
+
|
|
55
|
+
const getFirstColumnIndexToRenderRef = React.useRef(defaultMemoize(getFirstColumnIndexToRender, {
|
|
56
|
+
equalityCheck: (a, b) => ['firstColumnIndex', 'minColumnIndex', 'columnBuffer'].every(key => a[key] === b[key])
|
|
57
|
+
}));
|
|
43
58
|
const updateInnerPosition = React.useCallback(nextRenderContext => {
|
|
44
|
-
const
|
|
59
|
+
const [firstRowToRender, lastRowToRender] = getRenderableIndexes({
|
|
60
|
+
firstIndex: nextRenderContext.firstRowIndex,
|
|
61
|
+
lastIndex: nextRenderContext.lastRowIndex,
|
|
62
|
+
minFirstIndex: 0,
|
|
63
|
+
maxLastIndex: currentPage.rows.length,
|
|
64
|
+
buffer: rootProps.rowBuffer
|
|
65
|
+
});
|
|
66
|
+
const firstColumnToRender = getFirstColumnIndexToRenderRef.current({
|
|
67
|
+
firstColumnIndex: nextRenderContext.firstColumnIndex,
|
|
68
|
+
minColumnIndex,
|
|
69
|
+
columnBuffer: rootProps.columnBuffer,
|
|
70
|
+
firstRowToRender,
|
|
71
|
+
lastRowToRender,
|
|
72
|
+
apiRef,
|
|
73
|
+
visibleRows: currentPage.rows
|
|
74
|
+
});
|
|
45
75
|
const offset = firstColumnToRender > 0 ? prevScrollLeft.current - columnPositions[firstColumnToRender] : prevScrollLeft.current;
|
|
46
76
|
innerRef.current.style.transform = `translate3d(${-offset}px, 0px, 0px)`;
|
|
47
|
-
}, [columnPositions, minColumnIndex, rootProps.columnBuffer]);
|
|
77
|
+
}, [columnPositions, minColumnIndex, rootProps.columnBuffer, apiRef, currentPage.rows, rootProps.rowBuffer]);
|
|
78
|
+
React.useLayoutEffect(() => {
|
|
79
|
+
if (renderContext) {
|
|
80
|
+
updateInnerPosition(renderContext);
|
|
81
|
+
}
|
|
82
|
+
}, [renderContext, updateInnerPosition]);
|
|
48
83
|
const handleScroll = React.useCallback(({
|
|
49
84
|
left,
|
|
50
85
|
renderContext: nextRenderContext = null
|
|
51
|
-
}) => {
|
|
86
|
+
}, event) => {
|
|
52
87
|
var _prevRenderContext$cu, _prevRenderContext$cu2;
|
|
53
88
|
|
|
54
89
|
if (!innerRef.current) {
|
|
@@ -61,15 +96,32 @@ export const useGridColumnHeaders = props => {
|
|
|
61
96
|
return;
|
|
62
97
|
}
|
|
63
98
|
|
|
64
|
-
prevScrollLeft.current = left;
|
|
99
|
+
prevScrollLeft.current = left; // We can only update the position when we guarantee that the render context has been
|
|
100
|
+
// rendered. This is achieved using ReactDOM.flushSync or when the context doesn't change.
|
|
101
|
+
|
|
102
|
+
let canUpdateInnerPosition = false;
|
|
65
103
|
|
|
66
104
|
if (nextRenderContext !== prevRenderContext.current || !prevRenderContext.current) {
|
|
67
|
-
|
|
105
|
+
// ReactDOM.flushSync cannot be called on `scroll` events fired inside effects
|
|
106
|
+
if (isUIEvent(event)) {
|
|
107
|
+
// To prevent flickering, the inner position can only be updated after the new context has
|
|
108
|
+
// been rendered. ReactDOM.flushSync ensures that the state changes will happen before
|
|
109
|
+
// updating the position.
|
|
110
|
+
ReactDOM.flushSync(() => {
|
|
111
|
+
setRenderContext(nextRenderContext);
|
|
112
|
+
});
|
|
113
|
+
canUpdateInnerPosition = true;
|
|
114
|
+
} else {
|
|
115
|
+
setRenderContext(nextRenderContext);
|
|
116
|
+
}
|
|
117
|
+
|
|
68
118
|
prevRenderContext.current = nextRenderContext;
|
|
119
|
+
} else {
|
|
120
|
+
canUpdateInnerPosition = true;
|
|
69
121
|
} // Pass directly the render context to avoid waiting for the next render
|
|
70
122
|
|
|
71
123
|
|
|
72
|
-
if (nextRenderContext) {
|
|
124
|
+
if (nextRenderContext && canUpdateInnerPosition) {
|
|
73
125
|
updateInnerPosition(nextRenderContext);
|
|
74
126
|
}
|
|
75
127
|
}, [updateInnerPosition]);
|
|
@@ -95,7 +147,22 @@ export const useGridColumnHeaders = props => {
|
|
|
95
147
|
}
|
|
96
148
|
|
|
97
149
|
const columns = [];
|
|
98
|
-
const
|
|
150
|
+
const [firstRowToRender, lastRowToRender] = getRenderableIndexes({
|
|
151
|
+
firstIndex: nextRenderContext.firstRowIndex,
|
|
152
|
+
lastIndex: nextRenderContext.lastRowIndex,
|
|
153
|
+
minFirstIndex: 0,
|
|
154
|
+
maxLastIndex: currentPage.rows.length,
|
|
155
|
+
buffer: rootProps.rowBuffer
|
|
156
|
+
});
|
|
157
|
+
const firstColumnToRender = getFirstColumnIndexToRenderRef.current({
|
|
158
|
+
firstColumnIndex: nextRenderContext.firstColumnIndex,
|
|
159
|
+
minColumnIndex: minFirstColumn,
|
|
160
|
+
columnBuffer: rootProps.columnBuffer,
|
|
161
|
+
apiRef,
|
|
162
|
+
firstRowToRender,
|
|
163
|
+
lastRowToRender,
|
|
164
|
+
visibleRows: currentPage.rows
|
|
165
|
+
});
|
|
99
166
|
const lastColumnToRender = Math.min(nextRenderContext.lastColumnIndex + rootProps.columnBuffer, maxLastColumn);
|
|
100
167
|
const renderedColumns = visibleColumns.slice(firstColumnToRender, lastColumnToRender);
|
|
101
168
|
|
|
@@ -119,7 +186,7 @@ export const useGridColumnHeaders = props => {
|
|
|
119
186
|
extendRowFullWidth: !rootProps.disableExtendRowFullWidth,
|
|
120
187
|
hasFocus: hasFocus,
|
|
121
188
|
tabIndex: tabIndex
|
|
122
|
-
}, other),
|
|
189
|
+
}, other), column.field));
|
|
123
190
|
}
|
|
124
191
|
|
|
125
192
|
return columns;
|
|
@@ -134,7 +201,6 @@ export const useGridColumnHeaders = props => {
|
|
|
134
201
|
renderContext,
|
|
135
202
|
getColumns,
|
|
136
203
|
isDragging: !!dragCol,
|
|
137
|
-
updateInnerPosition,
|
|
138
204
|
getRootProps: (other = {}) => _extends({
|
|
139
205
|
style: rootStyle
|
|
140
206
|
}, other),
|
|
@@ -15,7 +15,9 @@ export interface GridColumnsState {
|
|
|
15
15
|
lookup: GridColumnLookup;
|
|
16
16
|
columnVisibilityModel: GridColumnVisibilityModel;
|
|
17
17
|
}
|
|
18
|
-
export declare type GridColumnDimensions =
|
|
18
|
+
export declare type GridColumnDimensions = {
|
|
19
|
+
[key in GridColumnDimensionProperties]?: number;
|
|
20
|
+
};
|
|
19
21
|
export interface GridColumnsInitialState {
|
|
20
22
|
columnVisibilityModel?: GridColumnVisibilityModel;
|
|
21
23
|
orderedFields?: string[];
|
|
@@ -4,6 +4,8 @@ import { GridColType, GridColumnTypesRecord } from '../../../models';
|
|
|
4
4
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
5
5
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
6
6
|
import { GridColDef } from '../../../models/colDef/gridColDef';
|
|
7
|
+
import { GridApiCommon } from '../../../models/api/gridApiCommon';
|
|
8
|
+
import { GridRowEntry } from '../../../models/gridRows';
|
|
7
9
|
export declare const COLUMNS_DIMENSION_PROPERTIES: readonly ["maxWidth", "minWidth", "width", "flex"];
|
|
8
10
|
export declare type GridColumnDimensionProperties = typeof COLUMNS_DIMENSION_PROPERTIES[number];
|
|
9
11
|
export declare const computeColumnTypes: (customColumnTypes?: GridColumnTypesRecord) => GridColumnTypesRecord;
|
|
@@ -17,7 +19,7 @@ export declare function computeFlexColumnsWidth({ initialFreeSpace, totalFlexUni
|
|
|
17
19
|
totalFlexUnits: number;
|
|
18
20
|
flexColumns: {
|
|
19
21
|
field: GridColDef['field'];
|
|
20
|
-
flex?: number;
|
|
22
|
+
flex?: number | null;
|
|
21
23
|
minWidth?: number;
|
|
22
24
|
maxWidth?: number;
|
|
23
25
|
}[];
|
|
@@ -52,3 +54,19 @@ export declare const createColumnsState: ({ apiRef, columnsToUpsert, initialStat
|
|
|
52
54
|
apiRef: React.MutableRefObject<GridApiCommunity>;
|
|
53
55
|
}) => GridColumnsState;
|
|
54
56
|
export declare const mergeColumnsState: (columnsState: GridColumnsState) => (state: GridStateCommunity) => GridStateCommunity;
|
|
57
|
+
export declare function getFirstNonSpannedColumnToRender({ firstColumnToRender, apiRef, firstRowToRender, lastRowToRender, visibleRows, }: {
|
|
58
|
+
firstColumnToRender: number;
|
|
59
|
+
apiRef: React.MutableRefObject<GridApiCommon>;
|
|
60
|
+
firstRowToRender: number;
|
|
61
|
+
lastRowToRender: number;
|
|
62
|
+
visibleRows: GridRowEntry[];
|
|
63
|
+
}): number;
|
|
64
|
+
export declare function getFirstColumnIndexToRender({ firstColumnIndex, minColumnIndex, columnBuffer, firstRowToRender, lastRowToRender, apiRef, visibleRows, }: {
|
|
65
|
+
firstColumnIndex: number;
|
|
66
|
+
minColumnIndex: number;
|
|
67
|
+
columnBuffer: number;
|
|
68
|
+
apiRef: React.MutableRefObject<GridApiCommon>;
|
|
69
|
+
firstRowToRender: number;
|
|
70
|
+
lastRowToRender: number;
|
|
71
|
+
visibleRows: GridRowEntry[];
|
|
72
|
+
}): number;
|
|
@@ -206,9 +206,15 @@ export const applyInitialState = (columnsState, initialState) => {
|
|
|
206
206
|
|
|
207
207
|
for (let i = 0; i < columnsWithUpdatedDimensions.length; i += 1) {
|
|
208
208
|
const field = columnsWithUpdatedDimensions[i];
|
|
209
|
-
|
|
209
|
+
|
|
210
|
+
const newColDef = _extends({}, newColumnLookup[field], {
|
|
210
211
|
hasBeenResized: true
|
|
211
212
|
});
|
|
213
|
+
|
|
214
|
+
Object.entries(dimensions[field]).forEach(([key, value]) => {
|
|
215
|
+
newColDef[key] = value === -1 ? Infinity : value;
|
|
216
|
+
});
|
|
217
|
+
newColumnLookup[field] = newColDef;
|
|
212
218
|
}
|
|
213
219
|
|
|
214
220
|
const newColumnsState = {
|
|
@@ -296,16 +302,20 @@ export const createColumnsState = ({
|
|
|
296
302
|
columnsStateWithoutColumnVisibilityModel.all.push(field);
|
|
297
303
|
}
|
|
298
304
|
|
|
299
|
-
let
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
305
|
+
let hasBeenResized = existingState.hasBeenResized;
|
|
306
|
+
COLUMNS_DIMENSION_PROPERTIES.forEach(key => {
|
|
307
|
+
if (newColumn[key] !== undefined) {
|
|
308
|
+
hasBeenResized = true;
|
|
304
309
|
|
|
310
|
+
if (newColumn[key] === -1) {
|
|
311
|
+
newColumn[key] = Infinity;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
305
315
|
columnsStateWithoutColumnVisibilityModel.lookup[field] = _extends({}, existingState, {
|
|
306
316
|
hide: newColumn.hide == null ? false : newColumn.hide
|
|
307
317
|
}, newColumn, {
|
|
308
|
-
hasBeenResized
|
|
318
|
+
hasBeenResized
|
|
309
319
|
});
|
|
310
320
|
});
|
|
311
321
|
|
|
@@ -394,4 +404,47 @@ export const createColumnsState = ({
|
|
|
394
404
|
};
|
|
395
405
|
export const mergeColumnsState = columnsState => state => _extends({}, state, {
|
|
396
406
|
columns: columnsState
|
|
397
|
-
});
|
|
407
|
+
});
|
|
408
|
+
export function getFirstNonSpannedColumnToRender({
|
|
409
|
+
firstColumnToRender,
|
|
410
|
+
apiRef,
|
|
411
|
+
firstRowToRender,
|
|
412
|
+
lastRowToRender,
|
|
413
|
+
visibleRows
|
|
414
|
+
}) {
|
|
415
|
+
let firstNonSpannedColumnToRender = firstColumnToRender;
|
|
416
|
+
|
|
417
|
+
for (let i = firstRowToRender; i < lastRowToRender; i += 1) {
|
|
418
|
+
const row = visibleRows[i];
|
|
419
|
+
|
|
420
|
+
if (row) {
|
|
421
|
+
const rowId = visibleRows[i].id;
|
|
422
|
+
const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, firstColumnToRender);
|
|
423
|
+
|
|
424
|
+
if (cellColSpanInfo && cellColSpanInfo.spannedByColSpan) {
|
|
425
|
+
firstNonSpannedColumnToRender = cellColSpanInfo.leftVisibleCellIndex;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
return firstNonSpannedColumnToRender;
|
|
431
|
+
}
|
|
432
|
+
export function getFirstColumnIndexToRender({
|
|
433
|
+
firstColumnIndex,
|
|
434
|
+
minColumnIndex,
|
|
435
|
+
columnBuffer,
|
|
436
|
+
firstRowToRender,
|
|
437
|
+
lastRowToRender,
|
|
438
|
+
apiRef,
|
|
439
|
+
visibleRows
|
|
440
|
+
}) {
|
|
441
|
+
const initialFirstColumnToRender = Math.max(firstColumnIndex - columnBuffer, minColumnIndex);
|
|
442
|
+
const firstColumnToRender = getFirstNonSpannedColumnToRender({
|
|
443
|
+
firstColumnToRender: initialFirstColumnToRender,
|
|
444
|
+
apiRef,
|
|
445
|
+
firstRowToRender,
|
|
446
|
+
lastRowToRender,
|
|
447
|
+
visibleRows
|
|
448
|
+
});
|
|
449
|
+
return firstColumnToRender;
|
|
450
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
|
+
/**
|
|
4
|
+
* @requires useGridColumns (method, event)
|
|
5
|
+
* @requires useGridParamsApi (method)
|
|
6
|
+
*/
|
|
7
|
+
export declare const useGridColumnSpanning: (apiRef: React.MutableRefObject<GridApiCommunity>) => void;
|