@mui/x-data-grid 7.16.0 → 7.18.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 +184 -4
- package/DataGrid/DataGrid.js +11 -1
- package/DataGrid/useDataGridComponent.js +3 -0
- package/DataGrid/useDataGridProps.js +2 -1
- package/colDef/gridStringOperators.js +49 -33
- package/components/GridRow.js +1 -0
- package/components/cell/GridCell.js +30 -5
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +2 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +9 -2
- package/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
- package/components/containers/GridRootStyles.js +3 -7
- package/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/constants/gridClasses.d.ts +10 -0
- package/constants/gridClasses.js +1 -1
- package/constants/localeTextConstants.js +4 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +0 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
- package/hooks/features/columnResize/useGridColumnResize.js +6 -6
- package/hooks/features/dimensions/gridDimensionsApi.d.ts +4 -0
- package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +4 -1
- package/hooks/features/editing/useGridCellEditing.js +3 -19
- package/hooks/features/editing/useGridRowEditing.js +7 -2
- package/hooks/features/editing/utils.d.ts +2 -0
- package/hooks/features/editing/utils.js +15 -0
- package/hooks/features/export/serializers/csvSerializer.js +1 -1
- package/hooks/features/export/useGridPrintExport.js +2 -1
- package/hooks/features/filter/gridFilterUtils.js +1 -1
- package/hooks/features/focus/useGridFocus.js +2 -1
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
- package/hooks/features/keyboardNavigation/utils.d.ts +17 -0
- package/hooks/features/keyboardNavigation/utils.js +58 -0
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +4 -0
- package/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
- package/hooks/features/rows/gridRowSpanningUtils.d.ts +10 -0
- package/hooks/features/rows/gridRowSpanningUtils.js +42 -0
- package/hooks/features/rows/useGridRowSpanning.d.ts +27 -0
- package/hooks/features/rows/useGridRowSpanning.js +257 -0
- package/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
- package/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/hooks/utils/useGridApiEventHandler.js +0 -1
- package/hooks/utils/useGridSelector.js +1 -1
- package/index.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/utils/index.d.ts +0 -1
- package/internals/utils/index.js +1 -2
- package/internals/utils/propValidation.js +1 -1
- package/locales/arSD.js +4 -0
- package/locales/beBY.js +4 -0
- package/locales/bgBG.js +4 -0
- package/locales/csCZ.js +4 -0
- package/locales/daDK.js +4 -0
- package/locales/deDE.js +4 -0
- package/locales/elGR.js +4 -0
- package/locales/esES.js +4 -0
- package/locales/faIR.js +4 -0
- package/locales/fiFI.js +4 -0
- package/locales/frFR.js +4 -0
- package/locales/heIL.js +4 -0
- package/locales/hrHR.js +4 -0
- package/locales/huHU.js +11 -8
- package/locales/isIS.js +4 -0
- package/locales/itIT.js +4 -0
- package/locales/jaJP.js +4 -0
- package/locales/koKR.js +4 -0
- package/locales/nbNO.js +4 -0
- package/locales/nlNL.js +4 -0
- package/locales/nnNO.js +4 -0
- package/locales/plPL.js +4 -0
- package/locales/ptBR.js +4 -0
- package/locales/ptPT.js +4 -0
- package/locales/roRO.js +4 -0
- package/locales/ruRU.js +4 -0
- package/locales/skSK.js +4 -0
- package/locales/svSE.js +4 -0
- package/locales/trTR.js +4 -0
- package/locales/ukUA.js +4 -0
- package/locales/urPK.js +4 -0
- package/locales/viVN.js +4 -0
- package/locales/zhCN.js +4 -0
- package/locales/zhHK.js +4 -0
- package/locales/zhTW.js +4 -0
- package/models/api/gridLocaleTextApi.d.ts +4 -0
- package/models/colDef/gridColDef.d.ts +4 -0
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/props/DataGridProps.d.ts +10 -0
- package/modern/DataGrid/DataGrid.js +11 -1
- package/modern/DataGrid/useDataGridComponent.js +3 -0
- package/modern/DataGrid/useDataGridProps.js +2 -1
- package/modern/colDef/gridStringOperators.js +49 -33
- package/modern/components/GridRow.js +1 -0
- package/modern/components/cell/GridCell.js +30 -5
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +9 -2
- package/modern/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
- package/modern/components/containers/GridRootStyles.js +3 -7
- package/modern/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/constants/localeTextConstants.js +4 -0
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
- package/modern/hooks/features/columnResize/useGridColumnResize.js +6 -6
- package/modern/hooks/features/dimensions/useGridDimensions.js +4 -1
- package/modern/hooks/features/editing/useGridCellEditing.js +3 -19
- package/modern/hooks/features/editing/useGridRowEditing.js +7 -2
- package/modern/hooks/features/editing/utils.js +15 -0
- package/modern/hooks/features/export/serializers/csvSerializer.js +1 -1
- package/modern/hooks/features/export/useGridPrintExport.js +2 -1
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/focus/useGridFocus.js +2 -1
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +10 -46
- package/modern/hooks/features/keyboardNavigation/utils.js +58 -0
- package/modern/hooks/features/rows/gridRowSpanningSelectors.js +5 -0
- package/modern/hooks/features/rows/gridRowSpanningUtils.js +42 -0
- package/modern/hooks/features/rows/useGridRowSpanning.js +257 -0
- package/modern/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/modern/hooks/utils/useGridApiEventHandler.js +0 -1
- package/modern/hooks/utils/useGridSelector.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/utils/index.js +1 -2
- package/modern/internals/utils/propValidation.js +1 -1
- package/modern/locales/arSD.js +4 -0
- package/modern/locales/beBY.js +4 -0
- package/modern/locales/bgBG.js +4 -0
- package/modern/locales/csCZ.js +4 -0
- package/modern/locales/daDK.js +4 -0
- package/modern/locales/deDE.js +4 -0
- package/modern/locales/elGR.js +4 -0
- package/modern/locales/esES.js +4 -0
- package/modern/locales/faIR.js +4 -0
- package/modern/locales/fiFI.js +4 -0
- package/modern/locales/frFR.js +4 -0
- package/modern/locales/heIL.js +4 -0
- package/modern/locales/hrHR.js +4 -0
- package/modern/locales/huHU.js +11 -8
- package/modern/locales/isIS.js +4 -0
- package/modern/locales/itIT.js +4 -0
- package/modern/locales/jaJP.js +4 -0
- package/modern/locales/koKR.js +4 -0
- package/modern/locales/nbNO.js +4 -0
- package/modern/locales/nlNL.js +4 -0
- package/modern/locales/nnNO.js +4 -0
- package/modern/locales/plPL.js +4 -0
- package/modern/locales/ptBR.js +4 -0
- package/modern/locales/ptPT.js +4 -0
- package/modern/locales/roRO.js +4 -0
- package/modern/locales/ruRU.js +4 -0
- package/modern/locales/skSK.js +4 -0
- package/modern/locales/svSE.js +4 -0
- package/modern/locales/trTR.js +4 -0
- package/modern/locales/ukUA.js +4 -0
- package/modern/locales/urPK.js +4 -0
- package/modern/locales/viVN.js +4 -0
- package/modern/locales/zhCN.js +4 -0
- package/modern/locales/zhHK.js +4 -0
- package/modern/locales/zhTW.js +4 -0
- package/modern/utils/createSelector.js +1 -1
- package/modern/utils/domUtils.js +12 -12
- package/node/DataGrid/DataGrid.js +11 -1
- package/node/DataGrid/useDataGridComponent.js +3 -0
- package/node/DataGrid/useDataGridProps.js +2 -1
- package/node/colDef/gridStringOperators.js +49 -33
- package/node/components/GridRow.js +1 -0
- package/node/components/cell/GridCell.js +30 -5
- package/node/components/columnHeaders/GridColumnHeaderItem.js +9 -2
- package/node/components/columnHeaders/GridColumnHeaderTitle.js +3 -1
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +1 -2
- package/node/components/containers/GridRootStyles.js +3 -7
- package/node/components/panel/filterPanel/GridFilterForm.js +1 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/constants/localeTextConstants.js +4 -0
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +17 -12
- package/node/hooks/features/columnResize/useGridColumnResize.js +6 -6
- package/node/hooks/features/dimensions/useGridDimensions.js +4 -1
- package/node/hooks/features/editing/useGridCellEditing.js +3 -19
- package/node/hooks/features/editing/useGridRowEditing.js +7 -2
- package/node/hooks/features/editing/utils.js +22 -0
- package/node/hooks/features/export/serializers/csvSerializer.js +1 -1
- package/node/hooks/features/export/useGridPrintExport.js +2 -1
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/focus/useGridFocus.js +2 -1
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +16 -53
- package/node/hooks/features/keyboardNavigation/utils.js +68 -0
- package/node/hooks/features/rows/gridRowSpanningSelectors.js +11 -0
- package/node/hooks/features/rows/gridRowSpanningUtils.js +52 -0
- package/node/hooks/features/rows/useGridRowSpanning.js +267 -0
- package/node/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -7
- package/node/hooks/utils/useGridApiEventHandler.js +0 -1
- package/node/hooks/utils/useGridSelector.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +15 -0
- package/node/internals/utils/index.js +0 -11
- package/node/internals/utils/propValidation.js +1 -1
- package/node/locales/arSD.js +4 -0
- package/node/locales/beBY.js +4 -0
- package/node/locales/bgBG.js +4 -0
- package/node/locales/csCZ.js +4 -0
- package/node/locales/daDK.js +4 -0
- package/node/locales/deDE.js +4 -0
- package/node/locales/elGR.js +4 -0
- package/node/locales/esES.js +4 -0
- package/node/locales/faIR.js +4 -0
- package/node/locales/fiFI.js +4 -0
- package/node/locales/frFR.js +4 -0
- package/node/locales/heIL.js +4 -0
- package/node/locales/hrHR.js +4 -0
- package/node/locales/huHU.js +11 -8
- package/node/locales/isIS.js +4 -0
- package/node/locales/itIT.js +4 -0
- package/node/locales/jaJP.js +4 -0
- package/node/locales/koKR.js +4 -0
- package/node/locales/nbNO.js +4 -0
- package/node/locales/nlNL.js +4 -0
- package/node/locales/nnNO.js +4 -0
- package/node/locales/plPL.js +4 -0
- package/node/locales/ptBR.js +4 -0
- package/node/locales/ptPT.js +4 -0
- package/node/locales/roRO.js +4 -0
- package/node/locales/ruRU.js +4 -0
- package/node/locales/skSK.js +4 -0
- package/node/locales/svSE.js +4 -0
- package/node/locales/trTR.js +4 -0
- package/node/locales/ukUA.js +4 -0
- package/node/locales/urPK.js +4 -0
- package/node/locales/viVN.js +4 -0
- package/node/locales/zhCN.js +4 -0
- package/node/locales/zhHK.js +4 -0
- package/node/locales/zhTW.js +4 -0
- package/node/utils/createSelector.js +1 -1
- package/node/utils/domUtils.js +12 -12
- package/package.json +3 -3
- package/utils/createSelector.js +1 -1
- package/utils/domUtils.d.ts +4 -4
- package/utils/domUtils.js +12 -12
- package/internals/utils/warning.d.ts +0 -2
- package/internals/utils/warning.js +0 -21
- package/modern/internals/utils/warning.js +0 -21
- package/node/internals/utils/warning.js +0 -28
|
@@ -45,7 +45,9 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
45
45
|
filterPanelInputPlaceholder: 'Filter value',
|
|
46
46
|
// Filter operators text
|
|
47
47
|
filterOperatorContains: 'contains',
|
|
48
|
+
filterOperatorDoesNotContain: 'does not contain',
|
|
48
49
|
filterOperatorEquals: 'equals',
|
|
50
|
+
filterOperatorDoesNotEqual: 'does not equal',
|
|
49
51
|
filterOperatorStartsWith: 'starts with',
|
|
50
52
|
filterOperatorEndsWith: 'ends with',
|
|
51
53
|
filterOperatorIs: 'is',
|
|
@@ -65,7 +67,9 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
|
|
|
65
67
|
'filterOperator<=': '<=',
|
|
66
68
|
// Header filter operators text
|
|
67
69
|
headerFilterOperatorContains: 'Contains',
|
|
70
|
+
headerFilterOperatorDoesNotContain: 'Does not contain',
|
|
68
71
|
headerFilterOperatorEquals: 'Equals',
|
|
72
|
+
headerFilterOperatorDoesNotEqual: 'Does not equal',
|
|
69
73
|
headerFilterOperatorStartsWith: 'Starts with',
|
|
70
74
|
headerFilterOperatorEndsWith: 'Ends with',
|
|
71
75
|
headerFilterOperatorIs: 'Is',
|
|
@@ -25,7 +25,6 @@ export interface UseGridColumnHeadersProps {
|
|
|
25
25
|
export interface GetHeadersParams {
|
|
26
26
|
position?: GridPinnedColumnPosition;
|
|
27
27
|
renderContext?: GridColumnsRenderContext;
|
|
28
|
-
minFirstColumn?: number;
|
|
29
28
|
maxLastColumn?: number;
|
|
30
29
|
}
|
|
31
30
|
type OwnerState = DataGridProcessedProps;
|
|
@@ -53,7 +53,7 @@ export const useGridColumnHeaders = props => {
|
|
|
53
53
|
const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
|
|
54
54
|
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
|
|
55
55
|
const columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
|
|
56
|
-
const offsetLeft = computeOffsetLeft(columnPositions, renderContext,
|
|
56
|
+
const offsetLeft = computeOffsetLeft(columnPositions, renderContext, pinnedColumns.left.length);
|
|
57
57
|
const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;
|
|
58
58
|
React.useEffect(() => {
|
|
59
59
|
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
@@ -83,7 +83,6 @@ export const useGridColumnHeaders = props => {
|
|
|
83
83
|
const getColumnsToRender = params => {
|
|
84
84
|
const {
|
|
85
85
|
renderContext: currentContext = renderContext,
|
|
86
|
-
// TODO: `minFirstColumn` is not used anymore, could be refactored out.
|
|
87
86
|
maxLastColumn = visibleColumns.length
|
|
88
87
|
} = params || {};
|
|
89
88
|
const firstColumnToRender = currentContext.firstColumnIndex;
|
|
@@ -123,16 +122,22 @@ export const useGridColumnHeaders = props => {
|
|
|
123
122
|
computedWidth
|
|
124
123
|
}) => {
|
|
125
124
|
let style;
|
|
126
|
-
|
|
125
|
+
const isLeftPinned = pinnedPosition === GridPinnedColumnPosition.LEFT;
|
|
126
|
+
const isRightPinned = pinnedPosition === GridPinnedColumnPosition.RIGHT;
|
|
127
|
+
if (isLeftPinned || isRightPinned) {
|
|
127
128
|
const pinnedOffset = getPinnedCellOffset(pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions);
|
|
129
|
+
let side = isLeftPinned ? 'left' : 'right';
|
|
130
|
+
if (isRtl) {
|
|
131
|
+
side = isLeftPinned ? 'right' : 'left';
|
|
132
|
+
}
|
|
128
133
|
if (pinnedPosition === 'left') {
|
|
129
134
|
style = {
|
|
130
|
-
|
|
135
|
+
[side]: pinnedOffset
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
if (pinnedPosition === 'right') {
|
|
134
139
|
style = {
|
|
135
|
-
|
|
140
|
+
[side]: pinnedOffset
|
|
136
141
|
};
|
|
137
142
|
}
|
|
138
143
|
}
|
|
@@ -157,6 +162,9 @@ export const useGridColumnHeaders = props => {
|
|
|
157
162
|
columnIndex,
|
|
158
163
|
computedWidth: colDef.computedWidth
|
|
159
164
|
});
|
|
165
|
+
const siblingWithBorderingSeparator = pinnedPosition === GridPinnedColumnPosition.RIGHT ? renderedColumns[i - 1] : renderedColumns[i + 1];
|
|
166
|
+
const isSiblingFocused = siblingWithBorderingSeparator ? columnHeaderFocus !== null && columnHeaderFocus.field === siblingWithBorderingSeparator.field : false;
|
|
167
|
+
const isLastUnpinned = columnIndex + 1 === columnPositions.length - pinnedColumns.right.length;
|
|
160
168
|
columns.push(/*#__PURE__*/_jsx(GridColumnHeaderItem, _extends({}, sortColumnLookup[colDef.field], {
|
|
161
169
|
columnMenuOpen: open,
|
|
162
170
|
filterItemsCounter: filterColumnLookup[colDef.field] && filterColumnLookup[colDef.field].length,
|
|
@@ -172,7 +180,9 @@ export const useGridColumnHeaders = props => {
|
|
|
172
180
|
style: style,
|
|
173
181
|
indexInSection: i,
|
|
174
182
|
sectionLength: renderedColumns.length,
|
|
175
|
-
gridHasFiller: gridHasFiller
|
|
183
|
+
gridHasFiller: gridHasFiller,
|
|
184
|
+
isLastUnpinned: isLastUnpinned,
|
|
185
|
+
isSiblingFocused: isSiblingFocused
|
|
176
186
|
}, other), colDef.field));
|
|
177
187
|
}
|
|
178
188
|
return getFillers(params, columns, 0);
|
|
@@ -186,18 +196,15 @@ export const useGridColumnHeaders = props => {
|
|
|
186
196
|
children: [leftRenderContext && getColumnHeaders({
|
|
187
197
|
position: GridPinnedColumnPosition.LEFT,
|
|
188
198
|
renderContext: leftRenderContext,
|
|
189
|
-
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
190
199
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
191
200
|
}, {
|
|
192
201
|
disableReorder: true
|
|
193
202
|
}), getColumnHeaders({
|
|
194
203
|
renderContext,
|
|
195
|
-
minFirstColumn: pinnedColumns.left.length,
|
|
196
204
|
maxLastColumn: visibleColumns.length - pinnedColumns.right.length
|
|
197
205
|
}), rightRenderContext && getColumnHeaders({
|
|
198
206
|
position: GridPinnedColumnPosition.RIGHT,
|
|
199
207
|
renderContext: rightRenderContext,
|
|
200
|
-
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
201
208
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
202
209
|
}, {
|
|
203
210
|
disableReorder: true,
|
|
@@ -277,7 +284,7 @@ export const useGridColumnHeaders = props => {
|
|
|
277
284
|
depth: depth,
|
|
278
285
|
isLastColumn: headerInfo.colIndex === visibleColumns.length - headerInfo.fields.length,
|
|
279
286
|
maxDepth: headerGroupingMaxDepth,
|
|
280
|
-
height: dimensions.
|
|
287
|
+
height: dimensions.groupHeaderHeight,
|
|
281
288
|
hasFocus: hasFocus,
|
|
282
289
|
tabIndex: tabIndex,
|
|
283
290
|
pinnedPosition: pinnedPosition,
|
|
@@ -304,7 +311,6 @@ export const useGridColumnHeaders = props => {
|
|
|
304
311
|
params: {
|
|
305
312
|
position: GridPinnedColumnPosition.LEFT,
|
|
306
313
|
renderContext: leftRenderContext,
|
|
307
|
-
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
308
314
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
309
315
|
}
|
|
310
316
|
}), getColumnGroupHeaders({
|
|
@@ -317,7 +323,6 @@ export const useGridColumnHeaders = props => {
|
|
|
317
323
|
params: {
|
|
318
324
|
position: GridPinnedColumnPosition.RIGHT,
|
|
319
325
|
renderContext: rightRenderContext,
|
|
320
|
-
minFirstColumn: rightRenderContext.firstColumnIndex,
|
|
321
326
|
maxLastColumn: rightRenderContext.lastColumnIndex
|
|
322
327
|
}
|
|
323
328
|
})]
|
|
@@ -302,13 +302,13 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
302
302
|
}
|
|
303
303
|
refs.groupHeaderElements = findGroupHeaderElementsFromField(apiRef.current.columnHeadersContainerRef?.current, colDef.field);
|
|
304
304
|
refs.cellElements = findGridCellElementsFromCol(refs.columnHeaderElement, apiRef.current);
|
|
305
|
-
refs.fillerLeft = findGridElement(apiRef.current, 'filler--pinnedLeft');
|
|
306
|
-
refs.fillerRight = findGridElement(apiRef.current, 'filler--pinnedRight');
|
|
305
|
+
refs.fillerLeft = findGridElement(apiRef.current, isRtl ? 'filler--pinnedRight' : 'filler--pinnedLeft');
|
|
306
|
+
refs.fillerRight = findGridElement(apiRef.current, isRtl ? 'filler--pinnedLeft' : 'filler--pinnedRight');
|
|
307
307
|
const pinnedPosition = apiRef.current.unstable_applyPipeProcessors('isColumnPinned', false, refs.colDef.field);
|
|
308
|
-
refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement);
|
|
309
|
-
refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement);
|
|
310
|
-
refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement);
|
|
311
|
-
refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement);
|
|
308
|
+
refs.leftPinnedCellsAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
309
|
+
refs.rightPinnedCellsBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
310
|
+
refs.leftPinnedHeadersAfter = pinnedPosition !== GridPinnedColumnPosition.LEFT ? [] : findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
311
|
+
refs.rightPinnedHeadersBefore = pinnedPosition !== GridPinnedColumnPosition.RIGHT ? [] : findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);
|
|
312
312
|
resizeDirection.current = getResizeDirection(separator, isRtl);
|
|
313
313
|
initialOffsetToSeparator.current = computeOffsetToSeparator(xStart, refs.columnHeaderElement.getBoundingClientRect(), resizeDirection.current);
|
|
314
314
|
};
|
|
@@ -3,7 +3,7 @@ import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
|
3
3
|
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
4
4
|
import { GridDimensions } from './gridDimensionsApi';
|
|
5
5
|
import { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
6
|
-
type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'headerFilterHeight'>;
|
|
6
|
+
type RootProps = Pick<DataGridProcessedProps, 'onResize' | 'scrollbarSize' | 'pagination' | 'paginationMode' | 'autoHeight' | 'getRowHeight' | 'rowHeight' | 'resizeThrottleMs' | 'columnHeaderHeight' | 'columnGroupHeaderHeight' | 'headerFilterHeight'>;
|
|
7
7
|
export type GridDimensionsState = GridDimensions;
|
|
8
8
|
export declare const dimensionsStateInitializer: GridStateInitializer<RootProps>;
|
|
9
9
|
export declare function useGridDimensions(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: RootProps): void;
|
|
@@ -29,6 +29,7 @@ const EMPTY_DIMENSIONS = {
|
|
|
29
29
|
hasScrollY: false,
|
|
30
30
|
scrollbarSize: 0,
|
|
31
31
|
headerHeight: 0,
|
|
32
|
+
groupHeaderHeight: 0,
|
|
32
33
|
headerFilterHeight: 0,
|
|
33
34
|
rowWidth: 0,
|
|
34
35
|
rowHeight: 0,
|
|
@@ -55,6 +56,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
55
56
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
56
57
|
const rowHeight = Math.floor(props.rowHeight * densityFactor);
|
|
57
58
|
const headerHeight = Math.floor(props.columnHeaderHeight * densityFactor);
|
|
59
|
+
const groupHeaderHeight = Math.floor((props.columnGroupHeaderHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
58
60
|
const headerFilterHeight = Math.floor((props.headerFilterHeight ?? props.columnHeaderHeight) * densityFactor);
|
|
59
61
|
const columnsTotalWidth = roundToDecimalPlaces(gridColumnsTotalWidthSelector(apiRef), 6);
|
|
60
62
|
const headersTotalHeight = getTotalHeaderHeight(apiRef, props);
|
|
@@ -175,6 +177,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
175
177
|
hasScrollY,
|
|
176
178
|
scrollbarSize,
|
|
177
179
|
headerHeight,
|
|
180
|
+
groupHeaderHeight,
|
|
178
181
|
headerFilterHeight,
|
|
179
182
|
rowWidth,
|
|
180
183
|
rowHeight,
|
|
@@ -191,7 +194,7 @@ export function useGridDimensions(apiRef, props) {
|
|
|
191
194
|
apiRef.current.publishEvent('viewportInnerSizeChange', newDimensions.viewportInnerSize);
|
|
192
195
|
}
|
|
193
196
|
apiRef.current.updateRenderContext?.();
|
|
194
|
-
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
197
|
+
}, [apiRef, setDimensions, props.scrollbarSize, props.autoHeight, rowsMeta.currentPageTotalHeight, rowHeight, headerHeight, groupHeaderHeight, headerFilterHeight, columnsTotalWidth, headersTotalHeight, leftPinnedWidth, rightPinnedWidth]);
|
|
195
198
|
const apiPublic = {
|
|
196
199
|
resize,
|
|
197
200
|
getRootDimensions
|
|
@@ -5,15 +5,16 @@ const _excluded = ["id", "field"],
|
|
|
5
5
|
_excluded2 = ["id", "field"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
8
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
8
9
|
import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
10
|
import { GridEditModes, GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
10
11
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
11
12
|
import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
|
|
12
13
|
import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
|
|
13
|
-
import { warnOnce } from "../../../internals/utils/warning.js";
|
|
14
14
|
import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
|
|
15
15
|
import { deepClone } from "../../../utils/utils.js";
|
|
16
16
|
import { GridCellEditStartReasons, GridCellEditStopReasons } from "../../../models/params/gridEditCellParams.js";
|
|
17
|
+
import { getDefaultCellValue } from "./utils.js";
|
|
17
18
|
export const useGridCellEditing = (apiRef, props) => {
|
|
18
19
|
const [cellModesModel, setCellModesModel] = React.useState({});
|
|
19
20
|
const cellModesModelRef = React.useRef(cellModesModel);
|
|
@@ -249,24 +250,7 @@ export const useGridCellEditing = (apiRef, props) => {
|
|
|
249
250
|
} = params;
|
|
250
251
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
251
252
|
if (deleteValue) {
|
|
252
|
-
|
|
253
|
-
switch (fieldType) {
|
|
254
|
-
case 'boolean':
|
|
255
|
-
newValue = false;
|
|
256
|
-
break;
|
|
257
|
-
case 'date':
|
|
258
|
-
case 'dateTime':
|
|
259
|
-
case 'number':
|
|
260
|
-
newValue = undefined;
|
|
261
|
-
break;
|
|
262
|
-
case 'singleSelect':
|
|
263
|
-
newValue = null;
|
|
264
|
-
break;
|
|
265
|
-
case 'string':
|
|
266
|
-
default:
|
|
267
|
-
newValue = '';
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
253
|
+
newValue = getDefaultCellValue(apiRef.current.getColumn(field));
|
|
270
254
|
} else if (initialValue) {
|
|
271
255
|
newValue = initialValue;
|
|
272
256
|
}
|
|
@@ -5,17 +5,18 @@ const _excluded = ["id"],
|
|
|
5
5
|
_excluded2 = ["id"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { unstable_useEventCallback as useEventCallback, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
8
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
8
9
|
import { useGridApiEventHandler, useGridApiOptionHandler } from "../../utils/useGridApiEventHandler.js";
|
|
9
10
|
import { GridEditModes, GridRowModes } from "../../../models/gridEditRowModel.js";
|
|
10
11
|
import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
|
|
11
12
|
import { gridEditRowsStateSelector } from "./gridEditingSelectors.js";
|
|
12
13
|
import { isPrintableKey, isPasteShortcut } from "../../../utils/keyboardUtils.js";
|
|
13
14
|
import { gridColumnFieldsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
|
|
14
|
-
import { warnOnce } from "../../../internals/utils/warning.js";
|
|
15
15
|
import { gridRowsDataRowIdToIdLookupSelector } from "../rows/gridRowsSelector.js";
|
|
16
16
|
import { deepClone } from "../../../utils/utils.js";
|
|
17
17
|
import { GridRowEditStopReasons, GridRowEditStartReasons } from "../../../models/params/gridRowParams.js";
|
|
18
18
|
import { GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
|
|
19
|
+
import { getDefaultCellValue } from "./utils.js";
|
|
19
20
|
export const useGridRowEditing = (apiRef, props) => {
|
|
20
21
|
const [rowModesModel, setRowModesModel] = React.useState({});
|
|
21
22
|
const rowModesModelRef = React.useRef(rowModesModel);
|
|
@@ -319,7 +320,11 @@ export const useGridRowEditing = (apiRef, props) => {
|
|
|
319
320
|
}
|
|
320
321
|
let newValue = apiRef.current.getCellValue(id, field);
|
|
321
322
|
if (fieldToFocus === field && (deleteValue || initialValue)) {
|
|
322
|
-
|
|
323
|
+
if (deleteValue) {
|
|
324
|
+
newValue = getDefaultCellValue(apiRef.current.getColumn(field));
|
|
325
|
+
} else if (initialValue) {
|
|
326
|
+
newValue = initialValue;
|
|
327
|
+
}
|
|
323
328
|
}
|
|
324
329
|
acc[field] = {
|
|
325
330
|
value: newValue,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getDefaultCellValue = colDef => {
|
|
2
|
+
switch (colDef.type) {
|
|
3
|
+
case 'boolean':
|
|
4
|
+
return false;
|
|
5
|
+
case 'date':
|
|
6
|
+
case 'dateTime':
|
|
7
|
+
case 'number':
|
|
8
|
+
return undefined;
|
|
9
|
+
case 'singleSelect':
|
|
10
|
+
return null;
|
|
11
|
+
case 'string':
|
|
12
|
+
default:
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
1
2
|
import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../../colDef/index.js";
|
|
2
|
-
import { warnOnce } from "../../../../internals/utils/warning.js";
|
|
3
3
|
function sanitizeCellValue(value, csvOptions) {
|
|
4
4
|
if (value === null || value === undefined) {
|
|
5
5
|
return '';
|
|
@@ -38,6 +38,7 @@ function buildPrintWindow(title) {
|
|
|
38
38
|
* @requires useGridParamsApi (method)
|
|
39
39
|
*/
|
|
40
40
|
export const useGridPrintExport = (apiRef, props) => {
|
|
41
|
+
const hasRootReference = apiRef.current.rootElementRef.current !== null;
|
|
41
42
|
const logger = useGridLogger(apiRef, 'useGridPrintExport');
|
|
42
43
|
const doc = React.useRef(null);
|
|
43
44
|
const previousGridState = React.useRef(null);
|
|
@@ -46,7 +47,7 @@ export const useGridPrintExport = (apiRef, props) => {
|
|
|
46
47
|
const previousVirtualizationState = React.useRef();
|
|
47
48
|
React.useEffect(() => {
|
|
48
49
|
doc.current = ownerDocument(apiRef.current.rootElementRef.current);
|
|
49
|
-
}, [apiRef]);
|
|
50
|
+
}, [apiRef, hasRootReference]);
|
|
50
51
|
|
|
51
52
|
// Returns a promise because updateColumns triggers state update and
|
|
52
53
|
// the new state needs to be in place before the grid can be sized correctly
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
2
3
|
import { GridLogicOperator } from "../../../models/index.js";
|
|
3
4
|
import { getDefaultGridFilterModel } from "./gridFilterState.js";
|
|
4
|
-
import { warnOnce } from "../../../internals/utils/warning.js";
|
|
5
5
|
import { getPublicApiRef } from "../../../utils/getPublicApiRef.js";
|
|
6
6
|
import { gridColumnFieldsSelector, gridColumnLookupSelector, gridVisibleColumnFieldsSelector } from "../columns/index.js";
|
|
7
7
|
let hasEval;
|
|
@@ -34,6 +34,7 @@ export const focusStateInitializer = state => _extends({}, state, {
|
|
|
34
34
|
export const useGridFocus = (apiRef, props) => {
|
|
35
35
|
const logger = useGridLogger(apiRef, 'useGridFocus');
|
|
36
36
|
const lastClickedCell = React.useRef(null);
|
|
37
|
+
const hasRootReference = apiRef.current.rootElementRef.current !== null;
|
|
37
38
|
const publishCellFocusOut = React.useCallback((cell, event) => {
|
|
38
39
|
if (cell) {
|
|
39
40
|
// The row might have been deleted
|
|
@@ -380,7 +381,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
380
381
|
return () => {
|
|
381
382
|
doc.removeEventListener('mouseup', handleDocumentClick);
|
|
382
383
|
};
|
|
383
|
-
}, [apiRef, handleDocumentClick]);
|
|
384
|
+
}, [apiRef, hasRootReference, handleDocumentClick]);
|
|
384
385
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
385
386
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
386
387
|
useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
3
|
-
import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
|
|
3
|
+
import { gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
|
|
4
4
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
5
5
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
6
6
|
import { gridExpandedSortedRowEntriesSelector } from "../filter/gridFilterSelector.js";
|
|
@@ -10,50 +10,12 @@ import { gridClasses } from "../../../constants/gridClasses.js";
|
|
|
10
10
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
11
11
|
import { isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
12
12
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants/gridDetailPanelToggleField.js";
|
|
13
|
-
import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
|
|
14
13
|
import { gridFocusColumnGroupHeaderSelector } from "../focus/index.js";
|
|
15
14
|
import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridColumnGroupsSelector.js";
|
|
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
|
-
|
|
20
|
-
const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
|
|
21
|
-
return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
|
|
22
|
-
}
|
|
23
|
-
const getLeftColumnIndex = ({
|
|
24
|
-
currentColIndex,
|
|
25
|
-
firstColIndex,
|
|
26
|
-
lastColIndex,
|
|
27
|
-
isRtl
|
|
28
|
-
}) => {
|
|
29
|
-
if (isRtl) {
|
|
30
|
-
if (currentColIndex < lastColIndex) {
|
|
31
|
-
return currentColIndex + 1;
|
|
32
|
-
}
|
|
33
|
-
} else if (!isRtl) {
|
|
34
|
-
if (currentColIndex > firstColIndex) {
|
|
35
|
-
return currentColIndex - 1;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
};
|
|
40
|
-
const getRightColumnIndex = ({
|
|
41
|
-
currentColIndex,
|
|
42
|
-
firstColIndex,
|
|
43
|
-
lastColIndex,
|
|
44
|
-
isRtl
|
|
45
|
-
}) => {
|
|
46
|
-
if (isRtl) {
|
|
47
|
-
if (currentColIndex > firstColIndex) {
|
|
48
|
-
return currentColIndex - 1;
|
|
49
|
-
}
|
|
50
|
-
} else if (!isRtl) {
|
|
51
|
-
if (currentColIndex < lastColIndex) {
|
|
52
|
-
return currentColIndex + 1;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
};
|
|
18
|
+
import { enrichPageRowsWithPinnedRows, getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
|
|
57
19
|
|
|
58
20
|
/**
|
|
59
21
|
* @requires useGridSorting (method) - can be after
|
|
@@ -73,11 +35,12 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
73
35
|
|
|
74
36
|
/**
|
|
75
37
|
* @param {number} colIndex Index of the column to focus
|
|
76
|
-
* @param {
|
|
38
|
+
* @param {GridRowId} rowId index of the row to focus
|
|
77
39
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
40
|
+
* @param {string} rowSpanScanDirection Which direction to search to find the next cell not hidden by `rowSpan`.
|
|
78
41
|
* TODO replace with apiRef.current.moveFocusToRelativeCell()
|
|
79
42
|
*/
|
|
80
|
-
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
|
|
43
|
+
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left', rowSpanScanDirection = 'up') => {
|
|
81
44
|
const visibleSortedRows = gridExpandedSortedRowEntriesSelector(apiRef);
|
|
82
45
|
const nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
83
46
|
if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {
|
|
@@ -87,16 +50,17 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
87
50
|
colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
|
|
88
51
|
}
|
|
89
52
|
}
|
|
53
|
+
const field = gridVisibleColumnFieldsSelector(apiRef)[colIndex];
|
|
54
|
+
const nonRowSpannedRowId = findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection);
|
|
90
55
|
// `scrollToIndexes` requires a rowIndex relative to all visible rows.
|
|
91
56
|
// Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
|
|
92
|
-
const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id ===
|
|
57
|
+
const rowIndexRelativeToAllRows = visibleSortedRows.findIndex(row => row.id === nonRowSpannedRowId);
|
|
93
58
|
logger.debug(`Navigating to cell row ${rowIndexRelativeToAllRows}, col ${colIndex}`);
|
|
94
59
|
apiRef.current.scrollToIndexes({
|
|
95
60
|
colIndex,
|
|
96
61
|
rowIndex: rowIndexRelativeToAllRows
|
|
97
62
|
});
|
|
98
|
-
|
|
99
|
-
apiRef.current.setCellFocus(rowId, field);
|
|
63
|
+
apiRef.current.setCellFocus(nonRowSpannedRowId, field);
|
|
100
64
|
}, [apiRef, logger]);
|
|
101
65
|
const goToHeader = React.useCallback((colIndex, event) => {
|
|
102
66
|
logger.debug(`Navigating to header col ${colIndex}`);
|
|
@@ -432,7 +396,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
432
396
|
{
|
|
433
397
|
// "Enter" is only triggered by the row / cell editing feature
|
|
434
398
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
435
|
-
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
|
399
|
+
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1), isRtl ? 'right' : 'left', 'down');
|
|
436
400
|
}
|
|
437
401
|
break;
|
|
438
402
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { GridColDef, GridRowEntry, GridRowId } from '../../../models';
|
|
3
|
+
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
4
|
+
export declare function enrichPageRowsWithPinnedRows(apiRef: React.MutableRefObject<GridApiCommunity>, rows: GridRowEntry[]): GridRowEntry<import("../../../models").GridValidRowModel>[];
|
|
5
|
+
export declare const getLeftColumnIndex: ({ currentColIndex, firstColIndex, lastColIndex, isRtl, }: {
|
|
6
|
+
currentColIndex: number;
|
|
7
|
+
firstColIndex: number;
|
|
8
|
+
lastColIndex: number;
|
|
9
|
+
isRtl: boolean;
|
|
10
|
+
}) => number | null;
|
|
11
|
+
export declare const getRightColumnIndex: ({ currentColIndex, firstColIndex, lastColIndex, isRtl, }: {
|
|
12
|
+
currentColIndex: number;
|
|
13
|
+
firstColIndex: number;
|
|
14
|
+
lastColIndex: number;
|
|
15
|
+
isRtl: boolean;
|
|
16
|
+
}) => number | null;
|
|
17
|
+
export declare function findNonRowSpannedCell(apiRef: React.MutableRefObject<GridApiCommunity>, rowId: GridRowId, field: GridColDef['field'], rowSpanScanDirection: 'up' | 'down'): GridRowId;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { gridFilteredSortedRowIdsSelector } from "../filter/gridFilterSelector.js";
|
|
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
|
+
export const getLeftColumnIndex = ({
|
|
9
|
+
currentColIndex,
|
|
10
|
+
firstColIndex,
|
|
11
|
+
lastColIndex,
|
|
12
|
+
isRtl
|
|
13
|
+
}) => {
|
|
14
|
+
if (isRtl) {
|
|
15
|
+
if (currentColIndex < lastColIndex) {
|
|
16
|
+
return currentColIndex + 1;
|
|
17
|
+
}
|
|
18
|
+
} else if (!isRtl) {
|
|
19
|
+
if (currentColIndex > firstColIndex) {
|
|
20
|
+
return currentColIndex - 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
export const getRightColumnIndex = ({
|
|
26
|
+
currentColIndex,
|
|
27
|
+
firstColIndex,
|
|
28
|
+
lastColIndex,
|
|
29
|
+
isRtl
|
|
30
|
+
}) => {
|
|
31
|
+
if (isRtl) {
|
|
32
|
+
if (currentColIndex > firstColIndex) {
|
|
33
|
+
return currentColIndex - 1;
|
|
34
|
+
}
|
|
35
|
+
} else if (!isRtl) {
|
|
36
|
+
if (currentColIndex < lastColIndex) {
|
|
37
|
+
return currentColIndex + 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
export function findNonRowSpannedCell(apiRef, rowId, field, rowSpanScanDirection) {
|
|
43
|
+
const rowSpanHiddenCells = gridRowSpanningHiddenCellsSelector(apiRef);
|
|
44
|
+
if (!rowSpanHiddenCells[rowId]?.[field]) {
|
|
45
|
+
return rowId;
|
|
46
|
+
}
|
|
47
|
+
const filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
|
|
48
|
+
// find closest non row spanned cell in the given `rowSpanScanDirection`
|
|
49
|
+
let nextRowIndex = filteredSortedRowIds.indexOf(rowId) + (rowSpanScanDirection === 'down' ? 1 : -1);
|
|
50
|
+
while (nextRowIndex >= 0 && nextRowIndex < filteredSortedRowIds.length) {
|
|
51
|
+
const nextRowId = filteredSortedRowIds[nextRowIndex];
|
|
52
|
+
if (!rowSpanHiddenCells[nextRowId]?.[field]) {
|
|
53
|
+
return nextRowId;
|
|
54
|
+
}
|
|
55
|
+
nextRowIndex += rowSpanScanDirection === 'down' ? 1 : -1;
|
|
56
|
+
}
|
|
57
|
+
return rowId;
|
|
58
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GridStateCommunity } from '../../../models/gridStateCommunity';
|
|
2
|
+
export declare const gridRowSpanningHiddenCellsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<import("../../..").GridRowId, Record<string, boolean>>>;
|
|
3
|
+
export declare const gridRowSpanningSpannedCellsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<import("../../..").GridRowId, Record<string, number>>>;
|
|
4
|
+
export declare const gridRowSpanningHiddenCellsOriginMapSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<number, Record<string, number>>>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createSelector } from "../../../utils/createSelector.js";
|
|
2
|
+
const gridRowSpanningStateSelector = state => state.rowSpanning;
|
|
3
|
+
export const gridRowSpanningHiddenCellsSelector = createSelector(gridRowSpanningStateSelector, rowSpanning => rowSpanning.hiddenCells);
|
|
4
|
+
export const gridRowSpanningSpannedCellsSelector = createSelector(gridRowSpanningStateSelector, rowSpanning => rowSpanning.spannedCells);
|
|
5
|
+
export const gridRowSpanningHiddenCellsOriginMapSelector = createSelector(gridRowSpanningStateSelector, rowSpanning => rowSpanning.hiddenCellOriginMap);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GridRenderContext } from '../../../models';
|
|
3
|
+
import type { GridValidRowModel } from '../../../models/gridRows';
|
|
4
|
+
import type { GridColDef } from '../../../models/colDef';
|
|
5
|
+
import type { GridApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
6
|
+
import type { RowRange } from './useGridRowSpanning';
|
|
7
|
+
export declare function getUnprocessedRange(testRange: RowRange, processedRange: RowRange): RowRange | null;
|
|
8
|
+
export declare function isRowContextInitialized(renderContext: GridRenderContext): boolean;
|
|
9
|
+
export declare function isRowRangeUpdated(range1: RowRange, range2: RowRange): boolean;
|
|
10
|
+
export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: React.MutableRefObject<GridApiCommunity>) => any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function getUnprocessedRange(testRange, processedRange) {
|
|
2
|
+
if (testRange.firstRowIndex >= processedRange.firstRowIndex && testRange.lastRowIndex <= processedRange.lastRowIndex) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
// Overflowing at the end
|
|
6
|
+
// Example: testRange={ firstRowIndex: 10, lastRowIndex: 20 }, processedRange={ firstRowIndex: 0, lastRowIndex: 15 }
|
|
7
|
+
// Unprocessed Range={ firstRowIndex: 16, lastRowIndex: 20 }
|
|
8
|
+
if (testRange.firstRowIndex >= processedRange.firstRowIndex && testRange.lastRowIndex > processedRange.lastRowIndex) {
|
|
9
|
+
return {
|
|
10
|
+
firstRowIndex: processedRange.lastRowIndex,
|
|
11
|
+
lastRowIndex: testRange.lastRowIndex
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
// Overflowing at the beginning
|
|
15
|
+
// Example: testRange={ firstRowIndex: 0, lastRowIndex: 20 }, processedRange={ firstRowIndex: 16, lastRowIndex: 30 }
|
|
16
|
+
// Unprocessed Range={ firstRowIndex: 0, lastRowIndex: 15 }
|
|
17
|
+
if (testRange.firstRowIndex < processedRange.firstRowIndex && testRange.lastRowIndex <= processedRange.lastRowIndex) {
|
|
18
|
+
return {
|
|
19
|
+
firstRowIndex: testRange.firstRowIndex,
|
|
20
|
+
lastRowIndex: processedRange.firstRowIndex - 1
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// TODO: Should return two ranges handle overflowing at both ends ?
|
|
24
|
+
return testRange;
|
|
25
|
+
}
|
|
26
|
+
export function isRowContextInitialized(renderContext) {
|
|
27
|
+
return renderContext.firstRowIndex !== 0 || renderContext.lastRowIndex !== 0;
|
|
28
|
+
}
|
|
29
|
+
export function isRowRangeUpdated(range1, range2) {
|
|
30
|
+
return range1.firstRowIndex !== range2.firstRowIndex || range1.lastRowIndex !== range2.lastRowIndex;
|
|
31
|
+
}
|
|
32
|
+
export const getCellValue = (row, colDef, apiRef) => {
|
|
33
|
+
if (!row) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
let cellValue = row[colDef.field];
|
|
37
|
+
const valueGetter = colDef.rowSpanValueGetter ?? colDef.valueGetter;
|
|
38
|
+
if (valueGetter) {
|
|
39
|
+
cellValue = valueGetter(cellValue, row, colDef, apiRef);
|
|
40
|
+
}
|
|
41
|
+
return cellValue;
|
|
42
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { GridColDef } from '../../../models/colDef';
|
|
3
|
+
import type { GridRowId } from '../../../models/gridRows';
|
|
4
|
+
import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
|
|
5
|
+
import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
|
|
6
|
+
import type { GridStateInitializer } from '../../utils/useGridInitializeState';
|
|
7
|
+
export interface GridRowSpanningState {
|
|
8
|
+
spannedCells: Record<GridRowId, Record<GridColDef['field'], number>>;
|
|
9
|
+
hiddenCells: Record<GridRowId, Record<GridColDef['field'], boolean>>;
|
|
10
|
+
/**
|
|
11
|
+
* For each hidden cell, it contains the row index corresponding to the cell that is
|
|
12
|
+
* the origin of the hidden cell. i.e. the cell which is spanned.
|
|
13
|
+
* Used by the virtualization to properly keep the spanned cells in view.
|
|
14
|
+
*/
|
|
15
|
+
hiddenCellOriginMap: Record<number, Record<GridColDef['field'], number>>;
|
|
16
|
+
}
|
|
17
|
+
export type RowRange = {
|
|
18
|
+
firstRowIndex: number;
|
|
19
|
+
lastRowIndex: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* @requires columnsStateInitializer (method) - should be initialized before
|
|
23
|
+
* @requires rowsStateInitializer (method) - should be initialized before
|
|
24
|
+
* @requires filterStateInitializer (method) - should be initialized before
|
|
25
|
+
*/
|
|
26
|
+
export declare const rowSpanningStateInitializer: GridStateInitializer;
|
|
27
|
+
export declare const useGridRowSpanning: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "unstable_rowSpanning" | "pagination" | "paginationMode">) => void;
|