@mui/x-data-grid 5.17.0 → 5.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/components/cell/GridCell.js +9 -1
- package/hooks/features/focus/useGridFocus.js +13 -3
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/components/cell/GridCell.js +11 -1
- package/legacy/hooks/features/focus/useGridFocus.js +13 -3
- package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/modern/components/cell/GridCell.js +9 -1
- package/modern/hooks/features/focus/useGridFocus.js +13 -3
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/node/components/cell/GridCell.js +9 -1
- package/node/hooks/features/focus/useGridFocus.js +13 -3
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 5.17.1
|
|
7
|
+
|
|
8
|
+
_Sep 5, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🐞 Bugfixes
|
|
13
|
+
|
|
14
|
+
### `@mui/x-data-grid@v5.17.1` / `@mui/x-data-grid-pro@v5.17.1` / `@mui/x-data-grid-premium@v5.17.1`
|
|
15
|
+
|
|
16
|
+
#### Changes
|
|
17
|
+
|
|
18
|
+
- [DataGrid] Fix cells being focused on mouseUp (#5980) @cherniavskii
|
|
19
|
+
- [DataGrid] Fix focused cell if column is spanned and new editing API is used (#5962) @m4theushw
|
|
20
|
+
- [DataGridPro] Fix import in lazy-loading causing a bundling error (#6031) @flaviendelangle
|
|
21
|
+
|
|
6
22
|
## 5.17.0
|
|
7
23
|
|
|
8
24
|
_Sep 2, 2022_
|
|
@@ -98,6 +98,14 @@ function GridCell(props) {
|
|
|
98
98
|
onMouseUp(event);
|
|
99
99
|
}
|
|
100
100
|
}, [apiRef, field, onMouseUp, rowId]);
|
|
101
|
+
const publishMouseDown = React.useCallback(eventName => event => {
|
|
102
|
+
const params = apiRef.current.getCellParams(rowId, field || '');
|
|
103
|
+
apiRef.current.publishEvent(eventName, params, event);
|
|
104
|
+
|
|
105
|
+
if (onMouseDown) {
|
|
106
|
+
onMouseDown(event);
|
|
107
|
+
}
|
|
108
|
+
}, [apiRef, field, onMouseDown, rowId]);
|
|
101
109
|
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
102
110
|
// Ignore portal
|
|
103
111
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -202,7 +210,7 @@ function GridCell(props) {
|
|
|
202
210
|
tabIndex: (cellMode === 'view' || !isEditable) && !managesOwnFocus ? tabIndex : -1,
|
|
203
211
|
onClick: publish('cellClick', onClick),
|
|
204
212
|
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
205
|
-
onMouseDown:
|
|
213
|
+
onMouseDown: publishMouseDown('cellMouseDown'),
|
|
206
214
|
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
207
215
|
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
208
216
|
}, draggableEventHandlers, other, {
|
|
@@ -131,8 +131,18 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPage.rows.length - 1);
|
|
134
|
-
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
135
134
|
const rowToFocus = currentPage.rows[rowIndexToFocus];
|
|
135
|
+
const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
136
|
+
|
|
137
|
+
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
138
|
+
if (direction === 'left' || direction === 'below') {
|
|
139
|
+
columnIndexToFocus = colSpanInfo.leftVisibleCellIndex;
|
|
140
|
+
} else if (direction === 'right') {
|
|
141
|
+
columnIndexToFocus = colSpanInfo.rightVisibleCellIndex;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
136
146
|
const columnToFocus = visibleColumns[columnIndexToFocus];
|
|
137
147
|
apiRef.current.setCellFocus(rowToFocus.id, columnToFocus.field);
|
|
138
148
|
}, [apiRef, props.pagination, props.paginationMode]);
|
|
@@ -168,7 +178,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
168
178
|
}
|
|
169
179
|
}));
|
|
170
180
|
}, [logger, apiRef]);
|
|
171
|
-
const
|
|
181
|
+
const handleCellMouseDown = React.useCallback(params => {
|
|
172
182
|
lastClickedCell.current = params;
|
|
173
183
|
}, []);
|
|
174
184
|
const handleDocumentClick = React.useCallback(event => {
|
|
@@ -251,7 +261,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
251
261
|
}, [apiRef, handleDocumentClick]);
|
|
252
262
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
253
263
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
254
|
-
useGridApiEventHandler(apiRef, '
|
|
264
|
+
useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
255
265
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
256
266
|
useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
|
|
257
267
|
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
@@ -34,6 +34,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
34
34
|
* @param {number} colIndex Index of the column to focus
|
|
35
35
|
* @param {number} rowIndex index of the row to focus
|
|
36
36
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
37
|
+
* TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()
|
|
37
38
|
*/
|
|
38
39
|
|
|
39
40
|
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
|
|
@@ -90,6 +91,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
90
91
|
case 'ArrowDown':
|
|
91
92
|
case 'Enter':
|
|
92
93
|
{
|
|
94
|
+
// TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API
|
|
93
95
|
// "Enter" is only triggered by the row / cell editing feature
|
|
94
96
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
95
97
|
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
|
45
45
|
export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
|
|
46
46
|
export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
47
47
|
export type { GridRestoreStatePreProcessingContext } from '../hooks/features/statePersistence/gridStatePersistenceInterface';
|
|
48
|
-
export { useGridVirtualScroller } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
48
|
+
export { useGridVirtualScroller, getRenderableIndexes, } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
49
49
|
export { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
50
50
|
export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
51
51
|
export type { GridStateInitializer } from '../hooks/utils/useGridInitializeState';
|
package/internals/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
|
38
38
|
export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
39
39
|
export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
|
|
40
40
|
export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
41
|
-
export { useGridVirtualScroller } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
41
|
+
export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
42
42
|
export { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
43
43
|
export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
44
44
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
@@ -99,6 +99,16 @@ function GridCell(props) {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
}, [apiRef, field, onMouseUp, rowId]);
|
|
102
|
+
var publishMouseDown = React.useCallback(function (eventName) {
|
|
103
|
+
return function (event) {
|
|
104
|
+
var params = apiRef.current.getCellParams(rowId, field || '');
|
|
105
|
+
apiRef.current.publishEvent(eventName, params, event);
|
|
106
|
+
|
|
107
|
+
if (onMouseDown) {
|
|
108
|
+
onMouseDown(event);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, [apiRef, field, onMouseDown, rowId]);
|
|
102
112
|
var publish = React.useCallback(function (eventName, propHandler) {
|
|
103
113
|
return function (event) {
|
|
104
114
|
// Ignore portal
|
|
@@ -205,7 +215,7 @@ function GridCell(props) {
|
|
|
205
215
|
tabIndex: (cellMode === 'view' || !isEditable) && !managesOwnFocus ? tabIndex : -1,
|
|
206
216
|
onClick: publish('cellClick', onClick),
|
|
207
217
|
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
208
|
-
onMouseDown:
|
|
218
|
+
onMouseDown: publishMouseDown('cellMouseDown'),
|
|
209
219
|
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
210
220
|
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
211
221
|
}, draggableEventHandlers, other, {
|
|
@@ -134,8 +134,18 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPage.rows.length - 1);
|
|
137
|
-
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
138
137
|
var rowToFocus = currentPage.rows[rowIndexToFocus];
|
|
138
|
+
var colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
139
|
+
|
|
140
|
+
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
141
|
+
if (direction === 'left' || direction === 'below') {
|
|
142
|
+
columnIndexToFocus = colSpanInfo.leftVisibleCellIndex;
|
|
143
|
+
} else if (direction === 'right') {
|
|
144
|
+
columnIndexToFocus = colSpanInfo.rightVisibleCellIndex;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
139
149
|
var columnToFocus = visibleColumns[columnIndexToFocus];
|
|
140
150
|
apiRef.current.setCellFocus(rowToFocus.id, columnToFocus.field);
|
|
141
151
|
}, [apiRef, props.pagination, props.paginationMode]);
|
|
@@ -172,7 +182,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
172
182
|
});
|
|
173
183
|
});
|
|
174
184
|
}, [logger, apiRef]);
|
|
175
|
-
var
|
|
185
|
+
var handleCellMouseDown = React.useCallback(function (params) {
|
|
176
186
|
lastClickedCell.current = params;
|
|
177
187
|
}, []);
|
|
178
188
|
var handleDocumentClick = React.useCallback(function (event) {
|
|
@@ -259,7 +269,7 @@ export var useGridFocus = function useGridFocus(apiRef, props) {
|
|
|
259
269
|
}, [apiRef, handleDocumentClick]);
|
|
260
270
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
261
271
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
262
|
-
useGridApiEventHandler(apiRef, '
|
|
272
|
+
useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
263
273
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
264
274
|
useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
|
|
265
275
|
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
@@ -37,6 +37,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
37
37
|
* @param {number} colIndex Index of the column to focus
|
|
38
38
|
* @param {number} rowIndex index of the row to focus
|
|
39
39
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
40
|
+
* TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()
|
|
40
41
|
*/
|
|
41
42
|
|
|
42
43
|
var goToCell = React.useCallback(function (colIndex, rowId) {
|
|
@@ -98,6 +99,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
|
|
|
98
99
|
case 'ArrowDown':
|
|
99
100
|
case 'Enter':
|
|
100
101
|
{
|
|
102
|
+
// TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API
|
|
101
103
|
// "Enter" is only triggered by the row / cell editing feature
|
|
102
104
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
103
105
|
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
package/legacy/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
|
38
38
|
export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
39
39
|
export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
|
|
40
40
|
export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
41
|
-
export { useGridVirtualScroller } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
41
|
+
export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
42
42
|
export { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
43
43
|
export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
44
44
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
@@ -96,6 +96,14 @@ function GridCell(props) {
|
|
|
96
96
|
onMouseUp(event);
|
|
97
97
|
}
|
|
98
98
|
}, [apiRef, field, onMouseUp, rowId]);
|
|
99
|
+
const publishMouseDown = React.useCallback(eventName => event => {
|
|
100
|
+
const params = apiRef.current.getCellParams(rowId, field || '');
|
|
101
|
+
apiRef.current.publishEvent(eventName, params, event);
|
|
102
|
+
|
|
103
|
+
if (onMouseDown) {
|
|
104
|
+
onMouseDown(event);
|
|
105
|
+
}
|
|
106
|
+
}, [apiRef, field, onMouseDown, rowId]);
|
|
99
107
|
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
100
108
|
// Ignore portal
|
|
101
109
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -200,7 +208,7 @@ function GridCell(props) {
|
|
|
200
208
|
tabIndex: (cellMode === 'view' || !isEditable) && !managesOwnFocus ? tabIndex : -1,
|
|
201
209
|
onClick: publish('cellClick', onClick),
|
|
202
210
|
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
203
|
-
onMouseDown:
|
|
211
|
+
onMouseDown: publishMouseDown('cellMouseDown'),
|
|
204
212
|
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
205
213
|
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
206
214
|
}, draggableEventHandlers, other, {
|
|
@@ -131,8 +131,18 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
rowIndexToFocus = clamp(rowIndexToFocus, 0, currentPage.rows.length - 1);
|
|
134
|
-
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
135
134
|
const rowToFocus = currentPage.rows[rowIndexToFocus];
|
|
135
|
+
const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
136
|
+
|
|
137
|
+
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
138
|
+
if (direction === 'left' || direction === 'below') {
|
|
139
|
+
columnIndexToFocus = colSpanInfo.leftVisibleCellIndex;
|
|
140
|
+
} else if (direction === 'right') {
|
|
141
|
+
columnIndexToFocus = colSpanInfo.rightVisibleCellIndex;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
columnIndexToFocus = clamp(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
136
146
|
const columnToFocus = visibleColumns[columnIndexToFocus];
|
|
137
147
|
apiRef.current.setCellFocus(rowToFocus.id, columnToFocus.field);
|
|
138
148
|
}, [apiRef, props.pagination, props.paginationMode]);
|
|
@@ -168,7 +178,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
168
178
|
}
|
|
169
179
|
}));
|
|
170
180
|
}, [logger, apiRef]);
|
|
171
|
-
const
|
|
181
|
+
const handleCellMouseDown = React.useCallback(params => {
|
|
172
182
|
lastClickedCell.current = params;
|
|
173
183
|
}, []);
|
|
174
184
|
const handleDocumentClick = React.useCallback(event => {
|
|
@@ -251,7 +261,7 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
251
261
|
}, [apiRef, handleDocumentClick]);
|
|
252
262
|
useGridApiEventHandler(apiRef, 'columnHeaderBlur', handleBlur);
|
|
253
263
|
useGridApiEventHandler(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
254
|
-
useGridApiEventHandler(apiRef, '
|
|
264
|
+
useGridApiEventHandler(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
255
265
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
256
266
|
useGridApiEventHandler(apiRef, 'cellModeChange', handleCellModeChange);
|
|
257
267
|
useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
@@ -34,6 +34,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
34
34
|
* @param {number} colIndex Index of the column to focus
|
|
35
35
|
* @param {number} rowIndex index of the row to focus
|
|
36
36
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
37
|
+
* TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()
|
|
37
38
|
*/
|
|
38
39
|
|
|
39
40
|
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
|
|
@@ -90,6 +91,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
90
91
|
case 'ArrowDown':
|
|
91
92
|
case 'Enter':
|
|
92
93
|
{
|
|
94
|
+
// TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API
|
|
93
95
|
// "Enter" is only triggered by the row / cell editing feature
|
|
94
96
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
95
97
|
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
package/modern/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
|
38
38
|
export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
39
39
|
export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
|
|
40
40
|
export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
41
|
-
export { useGridVirtualScroller } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
41
|
+
export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
|
|
42
42
|
export { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
|
|
43
43
|
export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
|
|
44
44
|
export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
|
|
@@ -122,6 +122,14 @@ function GridCell(props) {
|
|
|
122
122
|
onMouseUp(event);
|
|
123
123
|
}
|
|
124
124
|
}, [apiRef, field, onMouseUp, rowId]);
|
|
125
|
+
const publishMouseDown = React.useCallback(eventName => event => {
|
|
126
|
+
const params = apiRef.current.getCellParams(rowId, field || '');
|
|
127
|
+
apiRef.current.publishEvent(eventName, params, event);
|
|
128
|
+
|
|
129
|
+
if (onMouseDown) {
|
|
130
|
+
onMouseDown(event);
|
|
131
|
+
}
|
|
132
|
+
}, [apiRef, field, onMouseDown, rowId]);
|
|
125
133
|
const publish = React.useCallback((eventName, propHandler) => event => {
|
|
126
134
|
// Ignore portal
|
|
127
135
|
if (!event.currentTarget.contains(event.target)) {
|
|
@@ -226,7 +234,7 @@ function GridCell(props) {
|
|
|
226
234
|
tabIndex: (cellMode === 'view' || !isEditable) && !managesOwnFocus ? tabIndex : -1,
|
|
227
235
|
onClick: publish('cellClick', onClick),
|
|
228
236
|
onDoubleClick: publish('cellDoubleClick', onDoubleClick),
|
|
229
|
-
onMouseDown:
|
|
237
|
+
onMouseDown: publishMouseDown('cellMouseDown'),
|
|
230
238
|
onMouseUp: publishMouseUp('cellMouseUp'),
|
|
231
239
|
onKeyDown: publish('cellKeyDown', onKeyDown)
|
|
232
240
|
}, draggableEventHandlers, other, {
|
|
@@ -158,8 +158,18 @@ const useGridFocus = (apiRef, props) => {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
rowIndexToFocus = (0, _utils2.clamp)(rowIndexToFocus, 0, currentPage.rows.length - 1);
|
|
161
|
-
columnIndexToFocus = (0, _utils2.clamp)(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
162
161
|
const rowToFocus = currentPage.rows[rowIndexToFocus];
|
|
162
|
+
const colSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowToFocus.id, columnIndexToFocus);
|
|
163
|
+
|
|
164
|
+
if (colSpanInfo && colSpanInfo.spannedByColSpan) {
|
|
165
|
+
if (direction === 'left' || direction === 'below') {
|
|
166
|
+
columnIndexToFocus = colSpanInfo.leftVisibleCellIndex;
|
|
167
|
+
} else if (direction === 'right') {
|
|
168
|
+
columnIndexToFocus = colSpanInfo.rightVisibleCellIndex;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
columnIndexToFocus = (0, _utils2.clamp)(columnIndexToFocus, 0, visibleColumns.length - 1);
|
|
163
173
|
const columnToFocus = visibleColumns[columnIndexToFocus];
|
|
164
174
|
apiRef.current.setCellFocus(rowToFocus.id, columnToFocus.field);
|
|
165
175
|
}, [apiRef, props.pagination, props.paginationMode]);
|
|
@@ -195,7 +205,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
195
205
|
}
|
|
196
206
|
}));
|
|
197
207
|
}, [logger, apiRef]);
|
|
198
|
-
const
|
|
208
|
+
const handleCellMouseDown = React.useCallback(params => {
|
|
199
209
|
lastClickedCell.current = params;
|
|
200
210
|
}, []);
|
|
201
211
|
const handleDocumentClick = React.useCallback(event => {
|
|
@@ -278,7 +288,7 @@ const useGridFocus = (apiRef, props) => {
|
|
|
278
288
|
}, [apiRef, handleDocumentClick]);
|
|
279
289
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderBlur', handleBlur);
|
|
280
290
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellDoubleClick', handleCellDoubleClick);
|
|
281
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, '
|
|
291
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellMouseDown', handleCellMouseDown);
|
|
282
292
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
283
293
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellModeChange', handleCellModeChange);
|
|
284
294
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
|
|
@@ -56,6 +56,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
56
56
|
* @param {number} colIndex Index of the column to focus
|
|
57
57
|
* @param {number} rowIndex index of the row to focus
|
|
58
58
|
* @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
|
|
59
|
+
* TODO replace with apiRef.current.unstable_moveFocusToRelativeCell()
|
|
59
60
|
*/
|
|
60
61
|
|
|
61
62
|
const goToCell = React.useCallback((colIndex, rowId, closestColumnToUse = 'left') => {
|
|
@@ -112,6 +113,7 @@ const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
112
113
|
case 'ArrowDown':
|
|
113
114
|
case 'Enter':
|
|
114
115
|
{
|
|
116
|
+
// TODO v6: Remove Enter case because `cellNavigationKeyDown` is not fired by the new editing API
|
|
115
117
|
// "Enter" is only triggered by the row / cell editing feature
|
|
116
118
|
if (rowIndexBefore < lastRowIndexInPage) {
|
|
117
119
|
goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
|
package/node/index.js
CHANGED
package/node/internals/index.js
CHANGED
|
@@ -135,6 +135,12 @@ Object.defineProperty(exports, "getColumnsToExport", {
|
|
|
135
135
|
return _utils.getColumnsToExport;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
+
Object.defineProperty(exports, "getRenderableIndexes", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return _useGridVirtualScroller.getRenderableIndexes;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
138
144
|
Object.defineProperty(exports, "getRowIdFromRowModel", {
|
|
139
145
|
enumerable: true,
|
|
140
146
|
get: function () {
|