@mui/x-data-grid 7.24.0 → 7.25.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 +148 -0
- package/DataGrid/DataGrid.js +1 -7
- package/DataGrid/useDataGridComponent.d.ts +2 -1
- package/components/GridRow.d.ts +0 -1
- package/components/GridRow.js +25 -19
- package/components/cell/GridCell.d.ts +9 -6
- package/components/cell/GridCell.js +29 -52
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/components/containers/GridRootStyles.js +135 -37
- package/components/panel/GridPanel.js +2 -1
- package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
- package/components/toolbar/GridToolbarColumnsButton.js +8 -2
- package/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/components/toolbar/GridToolbarFilterButton.js +8 -2
- package/components/virtualization/GridMainContainer.d.ts +10 -0
- package/components/virtualization/GridMainContainer.js +10 -2
- package/components/virtualization/GridVirtualScrollbar.d.ts +4 -0
- package/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/components/virtualization/GridVirtualScroller.js +18 -5
- package/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/context/GridContextProvider.d.ts +2 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -2
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
- package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +2 -2
- package/hooks/core/useGridApiInitialization.d.ts +2 -2
- package/hooks/core/useGridInitialization.d.ts +2 -2
- package/hooks/core/useGridIsRtl.d.ts +2 -2
- package/hooks/core/useGridLocaleText.d.ts +2 -2
- package/hooks/core/useGridLoggerFactory.d.ts +2 -2
- package/hooks/core/useGridRefs.d.ts +2 -2
- package/hooks/core/useGridStateInitialization.d.ts +2 -2
- package/hooks/features/clipboard/useGridClipboard.d.ts +2 -2
- package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +2 -2
- package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -2
- package/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -2
- package/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/hooks/features/columns/gridColumnsUtils.d.ts +4 -4
- package/hooks/features/columns/useGridColumnSpanning.d.ts +2 -2
- package/hooks/features/columns/useGridColumns.d.ts +2 -2
- package/hooks/features/columns/useGridColumns.js +7 -3
- package/hooks/features/density/useGridDensity.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
- package/hooks/features/dimensions/useGridDimensions.js +7 -11
- package/hooks/features/editing/gridEditingSelectors.d.ts +6 -0
- package/hooks/features/editing/gridEditingSelectors.js +7 -1
- package/hooks/features/editing/index.d.ts +1 -1
- package/hooks/features/editing/index.js +1 -1
- package/hooks/features/editing/useGridCellEditing.d.ts +2 -2
- package/hooks/features/editing/useGridCellEditing.js +3 -3
- package/hooks/features/editing/useGridEditing.d.ts +2 -2
- package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
- package/hooks/features/editing/useGridRowEditing.js +5 -6
- package/hooks/features/events/useGridEvents.d.ts +2 -2
- package/hooks/features/export/serializers/csvSerializer.d.ts +2 -1
- package/hooks/features/export/useGridCsvExport.d.ts +2 -2
- package/hooks/features/export/useGridPrintExport.d.ts +2 -2
- package/hooks/features/export/utils.d.ts +2 -2
- package/hooks/features/filter/gridFilterUtils.d.ts +7 -7
- package/hooks/features/filter/gridFilterUtils.js +3 -3
- package/hooks/features/filter/useGridFilter.d.ts +2 -2
- package/hooks/features/focus/useGridFocus.d.ts +2 -2
- package/hooks/features/focus/useGridFocus.js +3 -2
- package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/hooks/features/keyboardNavigation/utils.d.ts +3 -4
- package/hooks/features/keyboardNavigation/utils.js +0 -5
- package/hooks/features/listView/useGridListView.d.ts +2 -2
- package/hooks/features/listView/useGridListView.js +2 -1
- package/hooks/features/pagination/useGridPagination.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationMeta.d.ts +2 -2
- package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
- package/hooks/features/pagination/useGridRowCount.d.ts +2 -2
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +1 -0
- package/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
- package/hooks/features/preferencesPanel/index.d.ts +1 -1
- package/hooks/features/preferencesPanel/index.js +1 -1
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +2 -2
- package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +2 -2
- package/hooks/features/rowSelection/useGridRowSelection.js +3 -3
- package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +2 -2
- package/hooks/features/rowSelection/utils.d.ts +3 -2
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +2 -2
- package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
- package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
- package/hooks/features/rows/useGridParamsApi.js +33 -14
- package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
- package/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/hooks/features/rows/useGridRows.d.ts +2 -2
- package/hooks/features/rows/useGridRows.js +7 -8
- package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
- package/hooks/features/rows/useGridRowsMeta.js +3 -2
- package/hooks/features/rows/useGridRowsPreProcessors.d.ts +2 -2
- package/hooks/features/scroll/useGridScroll.d.ts +2 -2
- package/hooks/features/sorting/gridSortingUtils.d.ts +3 -3
- package/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/hooks/features/sorting/useGridSorting.d.ts +2 -2
- package/hooks/features/statePersistence/useGridStatePersistence.d.ts +2 -2
- package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +9 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +32 -53
- package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
- package/hooks/utils/useGridApiContext.d.ts +2 -2
- package/hooks/utils/useGridApiEventHandler.d.ts +4 -4
- package/hooks/utils/useGridApiMethod.d.ts +2 -2
- package/hooks/utils/useGridApiRef.d.ts +2 -2
- package/hooks/utils/useGridApiRef.js +3 -1
- package/hooks/utils/useGridInitializeState.d.ts +3 -3
- package/hooks/utils/useGridLogger.d.ts +2 -2
- package/hooks/utils/useGridNativeEventListener.d.ts +2 -1
- package/hooks/utils/useGridPrivateApiContext.d.ts +2 -1
- package/hooks/utils/useGridSelector.d.ts +3 -3
- package/hooks/utils/useGridVisibleRows.d.ts +3 -3
- package/index.js +1 -1
- package/locales/faIR.js +5 -6
- package/models/api/gridApiCommon.d.ts +2 -2
- package/models/api/gridParamsApi.d.ts +29 -2
- package/models/api/index.d.ts +1 -1
- package/models/api/index.js +0 -1
- package/models/colDef/gridColDef.d.ts +9 -8
- package/models/gridExport.d.ts +2 -2
- package/models/gridFilterOperator.d.ts +2 -1
- package/models/props/DataGridProps.d.ts +2 -1
- package/modern/DataGrid/DataGrid.js +1 -7
- package/modern/components/GridRow.js +25 -19
- package/modern/components/cell/GridCell.js +29 -52
- package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
- package/modern/components/containers/GridRootStyles.js +135 -37
- package/modern/components/panel/GridPanel.js +2 -1
- package/modern/components/toolbar/GridToolbarColumnsButton.js +8 -2
- package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/modern/components/toolbar/GridToolbarFilterButton.js +8 -2
- package/modern/components/virtualization/GridMainContainer.js +10 -2
- package/modern/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/modern/components/virtualization/GridVirtualScroller.js +18 -5
- package/modern/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/modern/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/modern/hooks/features/columns/useGridColumns.js +7 -3
- package/modern/hooks/features/dimensions/useGridDimensions.js +7 -11
- package/modern/hooks/features/editing/gridEditingSelectors.js +7 -1
- package/modern/hooks/features/editing/index.js +1 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
- package/modern/hooks/features/editing/useGridRowEditing.js +5 -6
- package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
- package/modern/hooks/features/focus/useGridFocus.js +3 -2
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
- package/modern/hooks/features/keyboardNavigation/utils.js +0 -5
- package/modern/hooks/features/listView/useGridListView.js +2 -1
- package/modern/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
- package/modern/hooks/features/preferencesPanel/index.js +1 -1
- package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -3
- package/modern/hooks/features/rows/useGridParamsApi.js +33 -14
- package/modern/hooks/features/rows/useGridRowSpanning.js +94 -91
- package/modern/hooks/features/rows/useGridRows.js +7 -8
- package/modern/hooks/features/rows/useGridRowsMeta.js +3 -2
- package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +32 -53
- package/modern/hooks/utils/useGridApiRef.js +3 -1
- package/modern/index.js +1 -1
- package/modern/locales/faIR.js +5 -6
- package/modern/models/api/index.js +0 -1
- package/modern/utils/isJSDOM.js +1 -0
- package/modern/utils/roundToDecimalPlaces.js +3 -0
- package/modern/utils/utils.js +6 -1
- package/node/DataGrid/DataGrid.js +1 -7
- package/node/components/GridRow.js +22 -16
- package/node/components/cell/GridCell.js +27 -50
- package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
- package/node/components/containers/GridRootStyles.js +135 -37
- package/node/components/panel/GridPanel.js +2 -1
- package/node/components/toolbar/GridToolbarColumnsButton.js +8 -2
- package/node/components/toolbar/GridToolbarDensitySelector.js +2 -2
- package/node/components/toolbar/GridToolbarExportContainer.js +2 -2
- package/node/components/toolbar/GridToolbarFilterButton.js +8 -2
- package/node/components/virtualization/GridMainContainer.js +10 -2
- package/node/components/virtualization/GridVirtualScrollbar.js +5 -5
- package/node/components/virtualization/GridVirtualScroller.js +18 -5
- package/node/components/virtualization/GridVirtualScrollerContent.js +11 -2
- package/node/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
- package/node/hooks/features/columns/useGridColumns.js +7 -3
- package/node/hooks/features/dimensions/useGridDimensions.js +9 -13
- package/node/hooks/features/editing/gridEditingSelectors.js +8 -2
- package/node/hooks/features/editing/index.js +7 -11
- package/node/hooks/features/editing/useGridCellEditing.js +2 -2
- package/node/hooks/features/editing/useGridRowEditing.js +3 -4
- package/node/hooks/features/filter/gridFilterUtils.js +3 -3
- package/node/hooks/features/focus/useGridFocus.js +3 -2
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -15
- package/node/hooks/features/keyboardNavigation/utils.js +0 -6
- package/node/hooks/features/listView/useGridListView.js +2 -1
- package/node/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +9 -2
- package/node/hooks/features/preferencesPanel/index.js +11 -10
- package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/node/hooks/features/rows/useGridParamsApi.js +33 -14
- package/node/hooks/features/rows/useGridRowSpanning.js +92 -89
- package/node/hooks/features/rows/useGridRows.js +7 -8
- package/node/hooks/features/rows/useGridRowsMeta.js +5 -4
- package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
- package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +34 -55
- package/node/hooks/utils/useGridApiRef.js +3 -1
- package/node/index.js +1 -1
- package/node/locales/faIR.js +5 -6
- package/node/models/api/index.js +0 -11
- package/node/utils/isJSDOM.js +7 -0
- package/node/utils/roundToDecimalPlaces.js +9 -0
- package/node/utils/utils.js +8 -1
- package/package.json +2 -2
- package/utils/createSelector.d.ts +3 -3
- package/utils/getPublicApiRef.d.ts +2 -1
- package/utils/isJSDOM.d.ts +1 -0
- package/utils/isJSDOM.js +1 -0
- package/utils/roundToDecimalPlaces.d.ts +1 -0
- package/utils/roundToDecimalPlaces.js +3 -0
- package/utils/utils.d.ts +1 -0
- package/utils/utils.js +6 -1
|
@@ -6,7 +6,6 @@ import { gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector }
|
|
|
6
6
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
7
7
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
8
8
|
import { gridExpandedSortedRowEntriesSelector } from "../filter/gridFilterSelector.js";
|
|
9
|
-
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
10
9
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../colDef/gridCheckboxSelectionColDef.js";
|
|
11
10
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
12
11
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
@@ -16,8 +15,14 @@ import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridCo
|
|
|
16
15
|
import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from "../headerFiltering/gridHeaderFilteringSelectors.js";
|
|
17
16
|
import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
|
|
18
17
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
19
|
-
import {
|
|
18
|
+
import { getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
|
|
20
19
|
import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
20
|
+
import { createSelectorMemoized } from "../../../utils/createSelector.js";
|
|
21
|
+
import { gridVisibleRowsSelector } from "../pagination/index.js";
|
|
22
|
+
import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
|
|
23
|
+
const gridVisibleRowsWithPinnedRowsSelector = createSelectorMemoized(gridVisibleRowsSelector, gridPinnedRowsSelector, (visibleRows, pinnedRows) => {
|
|
24
|
+
return (pinnedRows.top || []).concat(visibleRows.rows, pinnedRows.bottom || []);
|
|
25
|
+
});
|
|
21
26
|
|
|
22
27
|
/**
|
|
23
28
|
* @requires useGridSorting (method) - can be after
|
|
@@ -30,10 +35,11 @@ import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
|
|
|
30
35
|
*/
|
|
31
36
|
export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
32
37
|
const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
|
|
33
|
-
const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
|
|
34
38
|
const isRtl = useRtl();
|
|
35
39
|
const listView = props.unstable_listView;
|
|
36
|
-
const
|
|
40
|
+
const getCurrentPageRows = React.useCallback(() => {
|
|
41
|
+
return gridVisibleRowsWithPinnedRowsSelector(apiRef);
|
|
42
|
+
}, [apiRef]);
|
|
37
43
|
const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
|
|
38
44
|
|
|
39
45
|
/**
|
|
@@ -92,8 +98,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
92
98
|
apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
|
|
93
99
|
}, [apiRef, logger]);
|
|
94
100
|
const getRowIdFromIndex = React.useCallback(rowIndex => {
|
|
95
|
-
return
|
|
96
|
-
}, [
|
|
101
|
+
return getCurrentPageRows()[rowIndex]?.id;
|
|
102
|
+
}, [getCurrentPageRows]);
|
|
97
103
|
const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
|
|
98
104
|
const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
|
|
99
105
|
const isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
|
|
@@ -102,6 +108,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
102
108
|
// There is one exception for the checkBoxHeader
|
|
103
109
|
return;
|
|
104
110
|
}
|
|
111
|
+
const currentPageRows = getCurrentPageRows();
|
|
105
112
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
106
113
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
107
114
|
const firstRowIndexInPage = currentPageRows.length > 0 ? 0 : null;
|
|
@@ -113,12 +120,10 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
113
120
|
switch (event.key) {
|
|
114
121
|
case 'ArrowDown':
|
|
115
122
|
{
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
121
|
-
}
|
|
123
|
+
if (headerFilteringEnabled) {
|
|
124
|
+
goToHeaderFilter(colIndexBefore, event);
|
|
125
|
+
} else if (firstRowIndexInPage !== null) {
|
|
126
|
+
goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
|
|
122
127
|
}
|
|
123
128
|
break;
|
|
124
129
|
}
|
|
@@ -192,13 +197,14 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
192
197
|
if (shouldPreventDefault) {
|
|
193
198
|
event.preventDefault();
|
|
194
199
|
}
|
|
195
|
-
}, [apiRef,
|
|
200
|
+
}, [apiRef, getCurrentPageRows, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, isRtl, goToHeader, goToGroupHeader]);
|
|
196
201
|
const handleHeaderFilterKeyDown = React.useCallback((params, event) => {
|
|
197
202
|
const isEditing = gridHeaderFilteringEditFieldSelector(apiRef) === params.field;
|
|
198
203
|
const isHeaderMenuOpen = gridHeaderFilteringMenuSelector(apiRef) === params.field;
|
|
199
204
|
if (isEditing || isHeaderMenuOpen || !isNavigationKey(event.key)) {
|
|
200
205
|
return;
|
|
201
206
|
}
|
|
207
|
+
const currentPageRows = getCurrentPageRows();
|
|
202
208
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
203
209
|
const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
|
|
204
210
|
const firstRowIndexInPage = 0;
|
|
@@ -278,7 +284,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
278
284
|
if (shouldPreventDefault) {
|
|
279
285
|
event.preventDefault();
|
|
280
286
|
}
|
|
281
|
-
}, [apiRef,
|
|
287
|
+
}, [apiRef, getCurrentPageRows, goToHeaderFilter, isRtl, goToHeader, goToCell, getRowIdFromIndex]);
|
|
282
288
|
const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
|
|
283
289
|
const focusedColumnGroup = gridFocusColumnGroupHeaderSelector(apiRef);
|
|
284
290
|
if (focusedColumnGroup === null) {
|
|
@@ -293,6 +299,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
293
299
|
depth,
|
|
294
300
|
maxDepth
|
|
295
301
|
} = params;
|
|
302
|
+
const currentPageRows = getCurrentPageRows();
|
|
296
303
|
const viewportPageSize = apiRef.current.getViewportPageSize();
|
|
297
304
|
const currentColIndex = apiRef.current.getColumnIndex(currentField);
|
|
298
305
|
const colIndexBefore = currentField ? apiRef.current.getColumnIndex(currentField) : 0;
|
|
@@ -364,7 +371,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
364
371
|
if (shouldPreventDefault) {
|
|
365
372
|
event.preventDefault();
|
|
366
373
|
}
|
|
367
|
-
}, [apiRef,
|
|
374
|
+
}, [apiRef, getCurrentPageRows, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
|
|
368
375
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
369
376
|
// Ignore portal
|
|
370
377
|
if (isEventTargetInPortal(event)) {
|
|
@@ -383,6 +390,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
383
390
|
if (!canUpdateFocus) {
|
|
384
391
|
return;
|
|
385
392
|
}
|
|
393
|
+
const currentPageRows = getCurrentPageRows();
|
|
386
394
|
if (currentPageRows.length === 0) {
|
|
387
395
|
return;
|
|
388
396
|
}
|
|
@@ -511,7 +519,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
511
519
|
if (shouldPreventDefault) {
|
|
512
520
|
event.preventDefault();
|
|
513
521
|
}
|
|
514
|
-
}, [apiRef,
|
|
522
|
+
}, [apiRef, getCurrentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
|
|
515
523
|
const checkIfCanStartEditing = React.useCallback((initialValue, {
|
|
516
524
|
event
|
|
517
525
|
}) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { GridColDef,
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridColDef, GridRowId } from '../../../models';
|
|
3
3
|
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
|
-
export declare function enrichPageRowsWithPinnedRows(apiRef: React.RefObject<GridApiCommunity>, rows: GridRowEntry[]): GridRowEntry<import("../../..").GridValidRowModel>[];
|
|
5
4
|
export declare const getLeftColumnIndex: ({ currentColIndex, firstColIndex, lastColIndex, isRtl, }: {
|
|
6
5
|
currentColIndex: number;
|
|
7
6
|
firstColIndex: number;
|
|
@@ -14,4 +13,4 @@ export declare const getRightColumnIndex: ({ currentColIndex, firstColIndex, las
|
|
|
14
13
|
lastColIndex: number;
|
|
15
14
|
isRtl: boolean;
|
|
16
15
|
}) => number | null;
|
|
17
|
-
export declare function findNonRowSpannedCell(apiRef:
|
|
16
|
+
export declare function findNonRowSpannedCell(apiRef: RefObject<GridApiCommunity>, rowId: GridRowId, field: GridColDef['field'], rowSpanScanDirection: 'up' | 'down'): GridRowId;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { gridFilteredSortedRowIdsSelector } from "../filter/gridFilterSelector.js";
|
|
2
2
|
import { gridRowSpanningHiddenCellsSelector } from "../rows/gridRowSpanningSelectors.js";
|
|
3
|
-
import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
|
|
4
|
-
export function enrichPageRowsWithPinnedRows(apiRef, rows) {
|
|
5
|
-
const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
6
|
-
return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
|
|
7
|
-
}
|
|
8
3
|
export const getLeftColumnIndex = ({
|
|
9
4
|
currentColIndex,
|
|
10
5
|
firstColIndex,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import type { GridListColDef } from '../../../models/colDef/gridColDef';
|
|
3
3
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
4
4
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
@@ -7,4 +7,4 @@ export type GridListViewState = (GridListColDef & {
|
|
|
7
7
|
computedWidth: number;
|
|
8
8
|
}) | undefined;
|
|
9
9
|
export declare const listViewStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'unstable_listColumn'>>;
|
|
10
|
-
export declare function useGridListView(apiRef:
|
|
10
|
+
export declare function useGridListView(apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listView' | 'unstable_listColumn'>): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
3
4
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
5
|
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
5
6
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
@@ -37,7 +38,7 @@ export function useGridListView(apiRef, props) {
|
|
|
37
38
|
/*
|
|
38
39
|
* EFFECTS
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
|
+
useEnhancedEffect(() => {
|
|
41
42
|
const listColumn = props.unstable_listColumn;
|
|
42
43
|
if (listColumn) {
|
|
43
44
|
apiRef.current.setState(state => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
@@ -7,4 +7,4 @@ export declare const paginationStateInitializer: GridStateInitializer<Pick<DataG
|
|
|
7
7
|
* @requires useGridFilter (state)
|
|
8
8
|
* @requires useGridDimensions (event) - can be after
|
|
9
9
|
*/
|
|
10
|
-
export declare const useGridPagination: (apiRef:
|
|
10
|
+
export declare const useGridPagination: (apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
-
export declare const useGridPaginationMeta: (apiRef:
|
|
4
|
+
export declare const useGridPaginationMeta: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationMeta" | "initialState" | "paginationMode" | "onPaginationMetaChange">) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridPaginationState } from './gridPaginationInterfaces';
|
|
@@ -8,4 +8,4 @@ export declare const getDerivedPaginationModel: (paginationState: GridPagination
|
|
|
8
8
|
* @requires useGridFilter (state)
|
|
9
9
|
* @requires useGridDimensions (event) - can be after
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridPaginationModel: (apiRef:
|
|
11
|
+
export declare const useGridPaginationModel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationModel" | "onPaginationModelChange" | "autoPageSize" | "initialState" | "paginationMode" | "pagination" | "signature" | "rowHeight">) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
|
-
export declare const useGridRowCount: (apiRef:
|
|
4
|
+
export declare const useGridRowCount: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rowCount" | "initialState" | "paginationMode" | "onRowCountChange">) => void;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
2
|
export declare const gridPreferencePanelStateSelector: (state: GridStateCommunity) => import("./gridPreferencePanelState").GridPreferencePanelState;
|
|
3
|
+
export declare const gridPreferencePanelSelectorWithLabel: import("../../../utils/createSelector").OutputSelectorV8<GridStateCommunity, string, boolean>;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { createSelectorV8 } from "../../../utils/createSelector.js";
|
|
2
|
+
export const gridPreferencePanelStateSelector = state => state.preferencePanel;
|
|
3
|
+
export const gridPreferencePanelSelectorWithLabel = createSelectorV8(gridPreferencePanelStateSelector, (panel, labelId) => {
|
|
4
|
+
if (panel.open && panel.labelId === labelId) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
@@ -6,4 +6,4 @@ export declare const preferencePanelStateInitializer: GridStateInitializer<Pick<
|
|
|
6
6
|
/**
|
|
7
7
|
* TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
|
|
8
8
|
*/
|
|
9
|
-
export declare const useGridPreferencesPanel: (apiRef:
|
|
9
|
+
export declare const useGridPreferencesPanel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState">) => void;
|
|
@@ -15,42 +15,29 @@ export const preferencePanelStateInitializer = (state, props) => _extends({}, st
|
|
|
15
15
|
*/
|
|
16
16
|
export const useGridPreferencesPanel = (apiRef, props) => {
|
|
17
17
|
const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
|
|
18
|
-
const hideTimeout = React.useRef(undefined);
|
|
19
|
-
const immediateTimeout = React.useRef(undefined);
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* API METHODS
|
|
23
21
|
*/
|
|
24
22
|
const hidePreferences = React.useCallback(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
apiRef.current.setState(state => {
|
|
24
|
+
if (!state.preferencePanel.open) {
|
|
25
|
+
return state;
|
|
26
|
+
}
|
|
27
|
+
logger.debug('Hiding Preferences Panel');
|
|
28
|
+
const preferencePanelState = gridPreferencePanelStateSelector(state);
|
|
28
29
|
apiRef.current.publishEvent('preferencePanelClose', {
|
|
29
30
|
openedPanelValue: preferencePanelState.openedPanelValue
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
apiRef.current.forceUpdate();
|
|
32
|
+
return _extends({}, state, {
|
|
33
|
+
preferencePanel: {
|
|
34
|
+
open: false
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
38
|
}, [apiRef, logger]);
|
|
39
|
-
|
|
40
|
-
// This is to prevent the preferences from closing when you open a select box or another panel,
|
|
41
|
-
// The issue is in MUI core V4 => Fixed in V5
|
|
42
|
-
const doNotHidePanel = React.useCallback(() => {
|
|
43
|
-
immediateTimeout.current = setTimeout(() => clearTimeout(hideTimeout.current), 0);
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
|
-
// This is a hack for the issue with Core V4, by delaying hiding the panel on the clickAwayListener,
|
|
47
|
-
// we can cancel the action if the trigger element still need the panel...
|
|
48
|
-
const hidePreferencesDelayed = React.useCallback(() => {
|
|
49
|
-
hideTimeout.current = setTimeout(hidePreferences, 100);
|
|
50
|
-
}, [hidePreferences]);
|
|
51
39
|
const showPreferences = React.useCallback((newValue, panelId, labelId) => {
|
|
52
40
|
logger.debug('Opening Preferences Panel');
|
|
53
|
-
doNotHidePanel();
|
|
54
41
|
apiRef.current.setState(state => _extends({}, state, {
|
|
55
42
|
preferencePanel: _extends({}, state.preferencePanel, {
|
|
56
43
|
open: true,
|
|
@@ -62,11 +49,10 @@ export const useGridPreferencesPanel = (apiRef, props) => {
|
|
|
62
49
|
apiRef.current.publishEvent('preferencePanelOpen', {
|
|
63
50
|
openedPanelValue: newValue
|
|
64
51
|
});
|
|
65
|
-
|
|
66
|
-
}, [logger, doNotHidePanel, apiRef]);
|
|
52
|
+
}, [logger, apiRef]);
|
|
67
53
|
useGridApiMethod(apiRef, {
|
|
68
54
|
showPreferences,
|
|
69
|
-
hidePreferences
|
|
55
|
+
hidePreferences
|
|
70
56
|
}, 'public');
|
|
71
57
|
|
|
72
58
|
/**
|
|
@@ -99,14 +85,4 @@ export const useGridPreferencesPanel = (apiRef, props) => {
|
|
|
99
85
|
}, [apiRef]);
|
|
100
86
|
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
101
87
|
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* EFFECTS
|
|
105
|
-
*/
|
|
106
|
-
React.useEffect(() => {
|
|
107
|
-
return () => {
|
|
108
|
-
clearTimeout(hideTimeout.current);
|
|
109
|
-
clearTimeout(immediateTimeout.current);
|
|
110
|
-
};
|
|
111
|
-
}, []);
|
|
112
88
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
4
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
@@ -9,4 +9,4 @@ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<Dat
|
|
|
9
9
|
* @requires useGridFocus (state) - can be after
|
|
10
10
|
* @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
|
|
11
11
|
*/
|
|
12
|
-
export declare const useGridRowSelection: (apiRef:
|
|
12
|
+
export declare const useGridRowSelection: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "filterMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "rowSelectionPropagation" | "signature">) => void;
|
|
@@ -12,7 +12,7 @@ import { gridExpandedSortedRowIdsSelector, gridFilteredRowsLookupSelector } from
|
|
|
12
12
|
import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
|
|
13
13
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
14
14
|
import { isKeyboardEvent, isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
15
|
-
import {
|
|
15
|
+
import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
16
16
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
17
17
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
18
18
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
@@ -64,7 +64,6 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
64
64
|
isRowSelectable: propIsRowSelectable
|
|
65
65
|
} = props;
|
|
66
66
|
const canHaveMultipleSelection = isMultipleRowSelectionEnabled(props);
|
|
67
|
-
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
68
67
|
const tree = useGridSelector(apiRef, gridRowTreeSelector);
|
|
69
68
|
const isNestedData = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector) > 1;
|
|
70
69
|
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
@@ -412,6 +411,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
412
411
|
end = previousRowIndex;
|
|
413
412
|
}
|
|
414
413
|
}
|
|
414
|
+
const visibleRows = getVisibleRows(apiRef);
|
|
415
415
|
const rowsBetweenStartAndEnd = visibleRows.rows.slice(start, end + 1).map(row => row.id);
|
|
416
416
|
apiRef.current.selectRows(rowsBetweenStartAndEnd, !isNextRowSelected);
|
|
417
417
|
return;
|
|
@@ -426,7 +426,7 @@ export const useGridRowSelection = (apiRef, props) => {
|
|
|
426
426
|
event.preventDefault();
|
|
427
427
|
selectRows(apiRef.current.getAllRowIds(), true);
|
|
428
428
|
}
|
|
429
|
-
}, [apiRef, handleSingleRowSelection, selectRows,
|
|
429
|
+
}, [apiRef, handleSingleRowSelection, selectRows, canHaveMultipleSelection]);
|
|
430
430
|
useGridApiEventHandler(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(() => removeOutdatedSelection(true)));
|
|
431
431
|
useGridApiEventHandler(apiRef, 'filteredRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
|
|
432
432
|
useGridApiEventHandler(apiRef, 'rowClick', runIfRowSelectionIsEnabled(handleRowClick));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
3
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
|
-
export declare const useGridRowSelectionPreProcessors: (apiRef:
|
|
4
|
+
export declare const useGridRowSelectionPreProcessors: (apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
1
2
|
import type { GridRowId, GridRowTreeConfig } from '../../../models/gridRows';
|
|
2
3
|
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
3
4
|
import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
@@ -8,5 +9,5 @@ export declare function getCheckboxPropsSelector(groupId: GridRowId, autoSelectP
|
|
|
8
9
|
isChecked: boolean;
|
|
9
10
|
}>;
|
|
10
11
|
export declare function isMultipleRowSelectionEnabled(props: Pick<DataGridProcessedProps, 'signature' | 'disableMultipleRowSelection' | 'checkboxSelection'>): boolean;
|
|
11
|
-
export declare const findRowsToSelect: (apiRef:
|
|
12
|
-
export declare const findRowsToDeselect: (apiRef:
|
|
12
|
+
export declare const findRowsToSelect: (apiRef: RefObject<GridPrivateApiCommunity>, tree: GridRowTreeConfig, selectedRow: GridRowId, autoSelectDescendants: boolean, autoSelectParents: boolean, addRow: (rowId: GridRowId) => void) => void;
|
|
13
|
+
export declare const findRowsToDeselect: (apiRef: RefObject<GridPrivateApiCommunity>, tree: GridRowTreeConfig, deselectedRow: GridRowId, autoSelectDescendants: boolean, autoSelectParents: boolean, removeRow: (rowId: GridRowId) => void) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import type { GridRenderContext } from '../../../models';
|
|
3
3
|
import type { GridValidRowModel } from '../../../models/gridRows';
|
|
4
4
|
import type { GridColDef } from '../../../models/colDef';
|
|
@@ -7,4 +7,4 @@ import type { RowRange } from './useGridRowSpanning';
|
|
|
7
7
|
export declare function getUnprocessedRange(testRange: RowRange, processedRange: RowRange): RowRange | null;
|
|
8
8
|
export declare function isRowContextInitialized(renderContext: GridRenderContext): boolean;
|
|
9
9
|
export declare function isRowRangeUpdated(range1: RowRange, range2: RowRange): boolean;
|
|
10
|
-
export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef:
|
|
10
|
+
export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: RefObject<GridApiCommunity>) => any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode } from '../../../models';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridApiCommunity, GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
@@ -20,7 +20,7 @@ export declare const getTopLevelRowCount: ({ tree, rowCountProp, }: {
|
|
|
20
20
|
rowCountProp: DataGridProcessedProps["rowCount"];
|
|
21
21
|
}) => number;
|
|
22
22
|
export declare const getRowsStateFromCache: ({ apiRef, rowCountProp, loadingProp, previousTree, previousTreeDepths, previousGroupsToFetch, }: Pick<GridRowTreeCreationParams, "previousTree" | "previousTreeDepths" | "previousGroupsToFetch"> & {
|
|
23
|
-
apiRef:
|
|
23
|
+
apiRef: RefObject<GridPrivateApiCommunity>;
|
|
24
24
|
rowCountProp: number | undefined;
|
|
25
25
|
loadingProp: boolean | undefined;
|
|
26
26
|
}) => GridRowsState;
|
|
@@ -33,12 +33,12 @@ export declare const updateCacheWithNewRows: ({ previousCache, getRowId, updates
|
|
|
33
33
|
updates: GridRowModelUpdate[];
|
|
34
34
|
groupKeys?: string[];
|
|
35
35
|
}) => GridRowsInternalCache;
|
|
36
|
-
export declare function calculatePinnedRowsHeight(apiRef:
|
|
36
|
+
export declare function calculatePinnedRowsHeight(apiRef: RefObject<GridApiCommunity>): {
|
|
37
37
|
top: number;
|
|
38
38
|
bottom: number;
|
|
39
39
|
};
|
|
40
40
|
export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
|
|
41
|
-
export declare function computeRowsUpdates(apiRef:
|
|
41
|
+
export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
|
|
42
42
|
export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
|
|
43
43
|
export declare const rowHeightWarning: string;
|
|
44
44
|
export declare const getRowHeightWarning: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
export declare class MissingRowIdError extends Error {
|
|
@@ -11,4 +11,4 @@ export declare class MissingRowIdError extends Error {
|
|
|
11
11
|
* TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
|
|
12
12
|
* TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
|
|
13
13
|
*/
|
|
14
|
-
export declare function useGridParamsApi(apiRef:
|
|
14
|
+
export declare function useGridParamsApi(apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps): void;
|
|
@@ -30,37 +30,52 @@ export function useGridParamsApi(apiRef, props) {
|
|
|
30
30
|
};
|
|
31
31
|
return params;
|
|
32
32
|
}, [apiRef]);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
const getCellParamsForRow = React.useCallback((id, field, row, {
|
|
34
|
+
cellMode,
|
|
35
|
+
colDef,
|
|
36
|
+
hasFocus,
|
|
37
|
+
rowNode,
|
|
38
|
+
tabIndex
|
|
39
|
+
}) => {
|
|
40
40
|
const rawValue = row[field];
|
|
41
41
|
const value = colDef?.valueGetter ? colDef.valueGetter(rawValue, row, colDef, apiRef) : rawValue;
|
|
42
|
-
const cellFocus = gridFocusCellSelector(apiRef);
|
|
43
|
-
const cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
44
42
|
const params = {
|
|
45
43
|
id,
|
|
46
44
|
field,
|
|
47
45
|
row,
|
|
48
46
|
rowNode,
|
|
49
47
|
colDef,
|
|
50
|
-
cellMode
|
|
51
|
-
hasFocus
|
|
52
|
-
tabIndex
|
|
48
|
+
cellMode,
|
|
49
|
+
hasFocus,
|
|
50
|
+
tabIndex,
|
|
53
51
|
value,
|
|
54
52
|
formattedValue: value,
|
|
55
53
|
isEditable: false,
|
|
56
|
-
api:
|
|
54
|
+
api: null
|
|
57
55
|
};
|
|
58
56
|
if (colDef && colDef.valueFormatter) {
|
|
59
57
|
params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
|
|
60
58
|
}
|
|
61
59
|
params.isEditable = colDef && apiRef.current.isCellEditable(params);
|
|
62
60
|
return params;
|
|
63
|
-
}, [apiRef
|
|
61
|
+
}, [apiRef]);
|
|
62
|
+
const getCellParams = React.useCallback((id, field) => {
|
|
63
|
+
const row = apiRef.current.getRow(id);
|
|
64
|
+
const rowNode = apiRef.current.getRowNode(id);
|
|
65
|
+
if (!row || !rowNode) {
|
|
66
|
+
throw new MissingRowIdError(`No row with id #${id} found`);
|
|
67
|
+
}
|
|
68
|
+
const cellFocus = gridFocusCellSelector(apiRef);
|
|
69
|
+
const cellTabIndex = gridTabIndexCellSelector(apiRef);
|
|
70
|
+
const cellMode = apiRef.current.getCellMode(id, field);
|
|
71
|
+
return apiRef.current.getCellParamsForRow(id, field, row, {
|
|
72
|
+
colDef: props.unstable_listView && props.unstable_listColumn?.field === field ? gridListColumnSelector(apiRef.current.state) : apiRef.current.getColumn(field),
|
|
73
|
+
rowNode,
|
|
74
|
+
hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
|
|
75
|
+
tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
|
|
76
|
+
cellMode
|
|
77
|
+
});
|
|
78
|
+
}, [apiRef, props.unstable_listView, props.unstable_listColumn?.field]);
|
|
64
79
|
const getCellValue = React.useCallback((id, field) => {
|
|
65
80
|
const colDef = apiRef.current.getColumn(field);
|
|
66
81
|
const row = apiRef.current.getRow(id);
|
|
@@ -119,5 +134,9 @@ export function useGridParamsApi(apiRef, props) {
|
|
|
119
134
|
getColumnHeaderParams,
|
|
120
135
|
getColumnHeaderElement
|
|
121
136
|
};
|
|
137
|
+
const paramsPrivateApi = {
|
|
138
|
+
getCellParamsForRow
|
|
139
|
+
};
|
|
122
140
|
useGridApiMethod(apiRef, paramsApi, 'public');
|
|
141
|
+
useGridApiMethod(apiRef, paramsPrivateApi, 'private');
|
|
123
142
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import type { GridColDef } from '../../../models/colDef';
|
|
3
3
|
import type { GridRowId } from '../../../models/gridRows';
|
|
4
4
|
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
@@ -24,4 +24,4 @@ export type RowRange = {
|
|
|
24
24
|
* @requires filterStateInitializer (method) - should be initialized before
|
|
25
25
|
*/
|
|
26
26
|
export declare const rowSpanningStateInitializer: GridStateInitializer;
|
|
27
|
-
export declare const useGridRowSpanning: (apiRef:
|
|
27
|
+
export declare const useGridRowSpanning: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "unstable_rowSpanning" | "pagination" | "paginationMode">) => void;
|