@mui/x-data-grid-premium 6.9.1 → 6.9.2
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 +62 -0
- package/DataGridPremium/DataGridPremium.js +4 -1
- package/README.md +1 -1
- package/hooks/features/cellSelection/useGridCellSelection.js +128 -11
- package/index.js +1 -1
- package/legacy/DataGridPremium/DataGridPremium.js +4 -1
- package/legacy/hooks/features/cellSelection/useGridCellSelection.js +122 -11
- package/legacy/index.js +1 -1
- package/legacy/utils/releaseInfo.js +1 -1
- package/modern/DataGridPremium/DataGridPremium.js +4 -1
- package/modern/hooks/features/cellSelection/useGridCellSelection.js +121 -8
- package/modern/index.js +1 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPremium/DataGridPremium.js +4 -1
- package/node/hooks/features/cellSelection/useGridCellSelection.js +120 -7
- package/node/index.js +1 -1
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +3 -3
- package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,68 @@
|
|
|
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
|
+
## 6.9.2
|
|
7
|
+
|
|
8
|
+
_Jul 6, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🚀 Auto-scroll when making range selection (#8661) @m4theushw
|
|
13
|
+
|
|
14
|
+
- 📚 New page: Components lifecycle (#8372) @flaviendelangle
|
|
15
|
+
|
|
16
|
+
Clarify pickers events and value updates in a [single docs page](https://mui.com/x/react-date-pickers/lifecycle/).
|
|
17
|
+
|
|
18
|
+
- 🥧 Add pie chart component
|
|
19
|
+
|
|
20
|
+
They are fresh from the code editor. You can visit [pie charts docs](https://mui.com/x/react-charts/pie/) or their [demo page](https://mui.com/x/react-charts/pie-demo/).
|
|
21
|
+
|
|
22
|
+
<img width="380" alt="pie-charts" src="https://github.com/mui/mui-x/assets/13808724/fe908c45-803c-4316-b913-dbd2f9f0551e">
|
|
23
|
+
|
|
24
|
+
- 🐞 Bugfixes
|
|
25
|
+
|
|
26
|
+
- 📚 Documentation improvements
|
|
27
|
+
|
|
28
|
+
### `@mui/x-data-grid@v6.9.2` / `@mui/x-data-grid-pro@v6.9.2` / `@mui/x-data-grid-premium@v6.9.2`
|
|
29
|
+
|
|
30
|
+
#### Changes
|
|
31
|
+
|
|
32
|
+
- [DataGrid] Fix `RangeError` when using flex columns (#9554) @cherniavskii
|
|
33
|
+
- [DataGrid] Fix React 17 editing bug (#9530) @romgrk
|
|
34
|
+
- [DataGrid] Use `getRowId` in filtering (#9564) @romgrk
|
|
35
|
+
- [DataGrid] Correctly reflect `TablePagination`'s `rowsPerPageOptions` shape to `pageSizeOptions` (#9438) @burakkgunduzz
|
|
36
|
+
- [DataGridPremium] Auto-scroll when making range selection (#8661) @m4theushw
|
|
37
|
+
- [l10n] Improve Spanish (es-ES) locale (#9500) @fufex
|
|
38
|
+
|
|
39
|
+
### `@mui/x-date-pickers@v6.9.2` / `@mui/x-date-pickers-pro@v6.9.2`
|
|
40
|
+
|
|
41
|
+
#### Changes
|
|
42
|
+
|
|
43
|
+
- [pickers] Forward digital clock classes (#9555) @YoonjiJang
|
|
44
|
+
- [pickers] Rename `internal` folder to `internals` on `@mui/x-date-picker-pro` (#9571) @flaviendelangle
|
|
45
|
+
|
|
46
|
+
### `@mui/x-charts@6.0.0-alpha.2`
|
|
47
|
+
|
|
48
|
+
#### Changes
|
|
49
|
+
|
|
50
|
+
- [charts] Add pie chart component (#9395) @alexfauquette
|
|
51
|
+
|
|
52
|
+
### Docs
|
|
53
|
+
|
|
54
|
+
- [docs] Add pickers playground (#9164) @LukasTy
|
|
55
|
+
- [docs] Fix API links for pickers (#9573) @alexfauquette
|
|
56
|
+
- [docs] Fix demos with `ToggleButtonGroup` (#9548) @flaviendelangle
|
|
57
|
+
- [docs] Fix typos in pagination documentation page (#9332) @RatherBeLunar
|
|
58
|
+
- [docs] Hide ads on paid content @oliviertassinari
|
|
59
|
+
- [docs] Move the charts in the sidebar (#9437) @flaviendelangle
|
|
60
|
+
- [docs] New page: Components lifecycle (#8372) @flaviendelangle
|
|
61
|
+
- [docs] Remove outdated header tag @oliviertassinari
|
|
62
|
+
|
|
63
|
+
### Core
|
|
64
|
+
|
|
65
|
+
- [core] Fix typo in priority support @oliviertassinari
|
|
66
|
+
- [core] Remove mention of Crowdin @oliviertassinari
|
|
67
|
+
|
|
6
68
|
## 6.9.1
|
|
7
69
|
|
|
8
70
|
_Jun 30, 2023_
|
|
@@ -740,7 +740,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
740
740
|
* Select the pageSize dynamically using the component UI.
|
|
741
741
|
* @default [25, 50, 100]
|
|
742
742
|
*/
|
|
743
|
-
pageSizeOptions: PropTypes.arrayOf(PropTypes.number
|
|
743
|
+
pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
744
|
+
label: PropTypes.string.isRequired,
|
|
745
|
+
value: PropTypes.number.isRequired
|
|
746
|
+
})]).isRequired),
|
|
744
747
|
/**
|
|
745
748
|
* If `true`, pagination is enabled.
|
|
746
749
|
* @default false
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useEventCallback } from '@mui/material/utils';
|
|
3
|
+
import { ownerDocument, useEventCallback } from '@mui/material/utils';
|
|
4
4
|
import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
|
|
5
5
|
import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector } from '@mui/x-data-grid-pro';
|
|
6
6
|
import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
|
|
@@ -13,10 +13,15 @@ export const cellSelectionStateInitializer = (state, props) => {
|
|
|
13
13
|
function isKeyboardEvent(event) {
|
|
14
14
|
return !!event.key;
|
|
15
15
|
}
|
|
16
|
+
const AUTO_SCROLL_SENSITIVITY = 50; // The distance from the edge to start scrolling
|
|
17
|
+
const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the sensitivity area
|
|
18
|
+
|
|
16
19
|
export const useGridCellSelection = (apiRef, props) => {
|
|
17
20
|
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
18
21
|
const cellWithVirtualFocus = React.useRef();
|
|
19
22
|
const lastMouseDownCell = React.useRef();
|
|
23
|
+
const mousePosition = React.useRef(null);
|
|
24
|
+
const autoScrollRAF = React.useRef();
|
|
20
25
|
const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
21
26
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
|
|
22
27
|
const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
@@ -113,8 +118,16 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
113
118
|
}
|
|
114
119
|
return params.rowNode.type !== 'pinnedRow';
|
|
115
120
|
}, [apiRef]);
|
|
116
|
-
const
|
|
121
|
+
const handleMouseUp = useEventCallback(() => {
|
|
117
122
|
var _apiRef$current$rootE, _apiRef$current$rootE2;
|
|
123
|
+
lastMouseDownCell.current = null;
|
|
124
|
+
(_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE2 = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE2.classList.remove(gridClasses['root--disableUserSelection']);
|
|
125
|
+
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
127
|
+
stopAutoScroll();
|
|
128
|
+
});
|
|
129
|
+
const handleCellMouseDown = React.useCallback((params, event) => {
|
|
130
|
+
var _apiRef$current$rootE3, _apiRef$current$rootE4, _apiRef$current$rootE5;
|
|
118
131
|
// Skip if the click comes from the right-button or, only on macOS, Ctrl is pressed
|
|
119
132
|
// Fix for https://github.com/mui/mui-x/pull/6567#issuecomment-1329155578
|
|
120
133
|
const isMacOs = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
@@ -129,20 +142,86 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
129
142
|
id: params.id,
|
|
130
143
|
field: params.field
|
|
131
144
|
};
|
|
132
|
-
(_apiRef$current$
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
145
|
+
(_apiRef$current$rootE3 = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE4 = _apiRef$current$rootE3.current) == null ? void 0 : _apiRef$current$rootE4.classList.add(gridClasses['root--disableUserSelection']);
|
|
146
|
+
const document = ownerDocument((_apiRef$current$rootE5 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE5.current);
|
|
147
|
+
document.addEventListener('mouseup', handleMouseUp, {
|
|
148
|
+
once: true
|
|
149
|
+
});
|
|
150
|
+
}, [apiRef, handleMouseUp, hasClickedValidCellForRangeSelection]);
|
|
151
|
+
const stopAutoScroll = React.useCallback(() => {
|
|
152
|
+
if (autoScrollRAF.current) {
|
|
153
|
+
cancelAnimationFrame(autoScrollRAF.current);
|
|
154
|
+
autoScrollRAF.current = null;
|
|
155
|
+
}
|
|
156
|
+
}, []);
|
|
139
157
|
const handleCellFocusIn = React.useCallback(params => {
|
|
140
158
|
cellWithVirtualFocus.current = {
|
|
141
159
|
id: params.id,
|
|
142
160
|
field: params.field
|
|
143
161
|
};
|
|
144
162
|
}, []);
|
|
163
|
+
const startAutoScroll = React.useCallback(() => {
|
|
164
|
+
var _apiRef$current$virtu, _apiRef$current$virtu2, _apiRef$current$virtu3;
|
|
165
|
+
if (autoScrollRAF.current) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!((_apiRef$current$virtu = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu.current)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const virtualScrollerRect = (_apiRef$current$virtu2 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu3 = _apiRef$current$virtu2.current) == null ? void 0 : _apiRef$current$virtu3.getBoundingClientRect();
|
|
172
|
+
if (!virtualScrollerRect) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
function autoScroll() {
|
|
176
|
+
var _apiRef$current$virtu4;
|
|
177
|
+
if (!mousePosition.current || !((_apiRef$current$virtu4 = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu4.current)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const {
|
|
181
|
+
x: mouseX,
|
|
182
|
+
y: mouseY
|
|
183
|
+
} = mousePosition.current;
|
|
184
|
+
const {
|
|
185
|
+
height,
|
|
186
|
+
width
|
|
187
|
+
} = virtualScrollerRect;
|
|
188
|
+
let deltaX = 0;
|
|
189
|
+
let deltaY = 0;
|
|
190
|
+
let factor = 0;
|
|
191
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
192
|
+
if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
|
|
193
|
+
// When scrolling up, the multiplier increases going closer to the top edge
|
|
194
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
|
|
195
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
196
|
+
} else if (mouseY >= height - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
|
|
197
|
+
// When scrolling down, the multiplier increases going closer to the bottom edge
|
|
198
|
+
factor = (mouseY - (height - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
199
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
200
|
+
} else if (mouseX <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
|
|
201
|
+
// When scrolling left, the multiplier increases going closer to the left edge
|
|
202
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseX) / -AUTO_SCROLL_SENSITIVITY;
|
|
203
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
204
|
+
} else if (mouseX >= width - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
|
|
205
|
+
// When scrolling right, the multiplier increases going closer to the right edge
|
|
206
|
+
factor = (mouseX - (width - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
207
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
208
|
+
}
|
|
209
|
+
if (deltaX !== 0 || deltaY !== 0) {
|
|
210
|
+
const {
|
|
211
|
+
scrollLeft,
|
|
212
|
+
scrollTop
|
|
213
|
+
} = apiRef.current.virtualScrollerRef.current;
|
|
214
|
+
apiRef.current.scroll({
|
|
215
|
+
top: scrollTop + deltaY * factor,
|
|
216
|
+
left: scrollLeft + deltaX * factor
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
autoScrollRAF.current = requestAnimationFrame(autoScroll);
|
|
220
|
+
}
|
|
221
|
+
autoScroll();
|
|
222
|
+
}, [apiRef]);
|
|
145
223
|
const handleCellMouseOver = React.useCallback((params, event) => {
|
|
224
|
+
var _apiRef$current$virtu5, _apiRef$current$virtu6;
|
|
146
225
|
if (!lastMouseDownCell.current) {
|
|
147
226
|
return;
|
|
148
227
|
}
|
|
@@ -154,7 +233,33 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
154
233
|
id,
|
|
155
234
|
field
|
|
156
235
|
}, event.ctrlKey || event.metaKey);
|
|
157
|
-
|
|
236
|
+
const virtualScrollerRect = (_apiRef$current$virtu5 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu6 = _apiRef$current$virtu5.current) == null ? void 0 : _apiRef$current$virtu6.getBoundingClientRect();
|
|
237
|
+
if (!virtualScrollerRect) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const {
|
|
241
|
+
height,
|
|
242
|
+
width,
|
|
243
|
+
x,
|
|
244
|
+
y
|
|
245
|
+
} = virtualScrollerRect;
|
|
246
|
+
const mouseX = event.clientX - x;
|
|
247
|
+
const mouseY = event.clientY - y;
|
|
248
|
+
mousePosition.current = {
|
|
249
|
+
x: mouseX,
|
|
250
|
+
y: mouseY
|
|
251
|
+
};
|
|
252
|
+
const hasEnteredVerticalSensitivityArea = mouseY <= AUTO_SCROLL_SENSITIVITY || mouseY >= height - AUTO_SCROLL_SENSITIVITY;
|
|
253
|
+
const hasEnteredHorizontalSensitivityArea = mouseX <= AUTO_SCROLL_SENSITIVITY || mouseX >= width - AUTO_SCROLL_SENSITIVITY;
|
|
254
|
+
const hasEnteredSensitivityArea = hasEnteredVerticalSensitivityArea || hasEnteredHorizontalSensitivityArea;
|
|
255
|
+
if (hasEnteredSensitivityArea) {
|
|
256
|
+
// Mouse has entered the sensitity area for the first time
|
|
257
|
+
startAutoScroll();
|
|
258
|
+
} else {
|
|
259
|
+
// Mouse has left the sensitivity area while auto scroll is on
|
|
260
|
+
stopAutoScroll();
|
|
261
|
+
}
|
|
262
|
+
}, [apiRef, startAutoScroll, stopAutoScroll]);
|
|
158
263
|
const handleCellClick = useEventCallback((params, event) => {
|
|
159
264
|
const {
|
|
160
265
|
id,
|
|
@@ -225,6 +330,10 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
225
330
|
id: visibleRows.rows[endRowIndex].id,
|
|
226
331
|
field: visibleColumns[endColumnIndex].field
|
|
227
332
|
};
|
|
333
|
+
apiRef.current.scrollToIndexes({
|
|
334
|
+
rowIndex: endRowIndex,
|
|
335
|
+
colIndex: endColumnIndex
|
|
336
|
+
});
|
|
228
337
|
const {
|
|
229
338
|
id,
|
|
230
339
|
field
|
|
@@ -238,13 +347,21 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
238
347
|
useGridApiEventHandler(apiRef, 'cellFocusIn', runIfCellSelectionIsEnabled(handleCellFocusIn));
|
|
239
348
|
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfCellSelectionIsEnabled(handleCellKeyDown));
|
|
240
349
|
useGridApiEventHandler(apiRef, 'cellMouseDown', runIfCellSelectionIsEnabled(handleCellMouseDown));
|
|
241
|
-
useGridApiEventHandler(apiRef, 'cellMouseUp', runIfCellSelectionIsEnabled(handleCellMouseUp));
|
|
242
350
|
useGridApiEventHandler(apiRef, 'cellMouseOver', runIfCellSelectionIsEnabled(handleCellMouseOver));
|
|
243
351
|
React.useEffect(() => {
|
|
244
352
|
if (props.unstable_cellSelectionModel) {
|
|
245
353
|
apiRef.current.unstable_setCellSelectionModel(props.unstable_cellSelectionModel);
|
|
246
354
|
}
|
|
247
355
|
}, [apiRef, props.unstable_cellSelectionModel]);
|
|
356
|
+
React.useEffect(() => {
|
|
357
|
+
var _apiRef$current$rootE6;
|
|
358
|
+
const rootRef = (_apiRef$current$rootE6 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE6.current;
|
|
359
|
+
return () => {
|
|
360
|
+
stopAutoScroll();
|
|
361
|
+
const document = ownerDocument(rootRef);
|
|
362
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
363
|
+
};
|
|
364
|
+
}, [apiRef, handleMouseUp, stopAutoScroll]);
|
|
248
365
|
const checkIfCellIsSelected = React.useCallback((isSelected, {
|
|
249
366
|
id,
|
|
250
367
|
field
|
package/index.js
CHANGED
|
@@ -740,7 +740,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
740
740
|
* Select the pageSize dynamically using the component UI.
|
|
741
741
|
* @default [25, 50, 100]
|
|
742
742
|
*/
|
|
743
|
-
pageSizeOptions: PropTypes.arrayOf(PropTypes.number
|
|
743
|
+
pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
744
|
+
label: PropTypes.string.isRequired,
|
|
745
|
+
value: PropTypes.number.isRequired
|
|
746
|
+
})]).isRequired),
|
|
744
747
|
/**
|
|
745
748
|
* If `true`, pagination is enabled.
|
|
746
749
|
* @default false
|
|
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
4
4
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
5
5
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import { useEventCallback } from '@mui/material/utils';
|
|
7
|
+
import { ownerDocument, useEventCallback } from '@mui/material/utils';
|
|
8
8
|
import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
|
|
9
9
|
import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector } from '@mui/x-data-grid-pro';
|
|
10
10
|
import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
|
|
@@ -17,10 +17,15 @@ export var cellSelectionStateInitializer = function cellSelectionStateInitialize
|
|
|
17
17
|
function isKeyboardEvent(event) {
|
|
18
18
|
return !!event.key;
|
|
19
19
|
}
|
|
20
|
+
var AUTO_SCROLL_SENSITIVITY = 50; // The distance from the edge to start scrolling
|
|
21
|
+
var AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the sensitivity area
|
|
22
|
+
|
|
20
23
|
export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
|
|
21
24
|
var visibleRows = useGridVisibleRows(apiRef, props);
|
|
22
25
|
var cellWithVirtualFocus = React.useRef();
|
|
23
26
|
var lastMouseDownCell = React.useRef();
|
|
27
|
+
var mousePosition = React.useRef(null);
|
|
28
|
+
var autoScrollRAF = React.useRef();
|
|
24
29
|
var ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
25
30
|
var ignoreValueFormatter = (_typeof(ignoreValueFormatterProp) === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
|
|
26
31
|
var clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
@@ -130,8 +135,16 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
|
|
|
130
135
|
}
|
|
131
136
|
return params.rowNode.type !== 'pinnedRow';
|
|
132
137
|
}, [apiRef]);
|
|
133
|
-
var
|
|
138
|
+
var handleMouseUp = useEventCallback(function () {
|
|
134
139
|
var _apiRef$current$rootE, _apiRef$current$rootE2;
|
|
140
|
+
lastMouseDownCell.current = null;
|
|
141
|
+
(_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE2 = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE2.classList.remove(gridClasses['root--disableUserSelection']);
|
|
142
|
+
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
144
|
+
stopAutoScroll();
|
|
145
|
+
});
|
|
146
|
+
var handleCellMouseDown = React.useCallback(function (params, event) {
|
|
147
|
+
var _apiRef$current$rootE3, _apiRef$current$rootE4, _apiRef$current$rootE5;
|
|
135
148
|
// Skip if the click comes from the right-button or, only on macOS, Ctrl is pressed
|
|
136
149
|
// Fix for https://github.com/mui/mui-x/pull/6567#issuecomment-1329155578
|
|
137
150
|
var isMacOs = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
@@ -146,20 +159,82 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
|
|
|
146
159
|
id: params.id,
|
|
147
160
|
field: params.field
|
|
148
161
|
};
|
|
149
|
-
(_apiRef$current$
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
(_apiRef$current$rootE3 = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE4 = _apiRef$current$rootE3.current) == null ? void 0 : _apiRef$current$rootE4.classList.add(gridClasses['root--disableUserSelection']);
|
|
163
|
+
var document = ownerDocument((_apiRef$current$rootE5 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE5.current);
|
|
164
|
+
document.addEventListener('mouseup', handleMouseUp, {
|
|
165
|
+
once: true
|
|
166
|
+
});
|
|
167
|
+
}, [apiRef, handleMouseUp, hasClickedValidCellForRangeSelection]);
|
|
168
|
+
var stopAutoScroll = React.useCallback(function () {
|
|
169
|
+
if (autoScrollRAF.current) {
|
|
170
|
+
cancelAnimationFrame(autoScrollRAF.current);
|
|
171
|
+
autoScrollRAF.current = null;
|
|
172
|
+
}
|
|
173
|
+
}, []);
|
|
156
174
|
var handleCellFocusIn = React.useCallback(function (params) {
|
|
157
175
|
cellWithVirtualFocus.current = {
|
|
158
176
|
id: params.id,
|
|
159
177
|
field: params.field
|
|
160
178
|
};
|
|
161
179
|
}, []);
|
|
180
|
+
var startAutoScroll = React.useCallback(function () {
|
|
181
|
+
var _apiRef$current$virtu, _apiRef$current$virtu2, _apiRef$current$virtu3;
|
|
182
|
+
if (autoScrollRAF.current) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (!((_apiRef$current$virtu = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu.current)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
var virtualScrollerRect = (_apiRef$current$virtu2 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu3 = _apiRef$current$virtu2.current) == null ? void 0 : _apiRef$current$virtu3.getBoundingClientRect();
|
|
189
|
+
if (!virtualScrollerRect) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
function autoScroll() {
|
|
193
|
+
var _apiRef$current$virtu4;
|
|
194
|
+
if (!mousePosition.current || !((_apiRef$current$virtu4 = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu4.current)) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
var _mousePosition$curren = mousePosition.current,
|
|
198
|
+
mouseX = _mousePosition$curren.x,
|
|
199
|
+
mouseY = _mousePosition$curren.y;
|
|
200
|
+
var height = virtualScrollerRect.height,
|
|
201
|
+
width = virtualScrollerRect.width;
|
|
202
|
+
var deltaX = 0;
|
|
203
|
+
var deltaY = 0;
|
|
204
|
+
var factor = 0;
|
|
205
|
+
var dimensions = apiRef.current.getRootDimensions();
|
|
206
|
+
if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
|
|
207
|
+
// When scrolling up, the multiplier increases going closer to the top edge
|
|
208
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
|
|
209
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
210
|
+
} else if (mouseY >= height - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
|
|
211
|
+
// When scrolling down, the multiplier increases going closer to the bottom edge
|
|
212
|
+
factor = (mouseY - (height - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
213
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
214
|
+
} else if (mouseX <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
|
|
215
|
+
// When scrolling left, the multiplier increases going closer to the left edge
|
|
216
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseX) / -AUTO_SCROLL_SENSITIVITY;
|
|
217
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
218
|
+
} else if (mouseX >= width - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
|
|
219
|
+
// When scrolling right, the multiplier increases going closer to the right edge
|
|
220
|
+
factor = (mouseX - (width - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
221
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
222
|
+
}
|
|
223
|
+
if (deltaX !== 0 || deltaY !== 0) {
|
|
224
|
+
var _apiRef$current$virtu5 = apiRef.current.virtualScrollerRef.current,
|
|
225
|
+
scrollLeft = _apiRef$current$virtu5.scrollLeft,
|
|
226
|
+
scrollTop = _apiRef$current$virtu5.scrollTop;
|
|
227
|
+
apiRef.current.scroll({
|
|
228
|
+
top: scrollTop + deltaY * factor,
|
|
229
|
+
left: scrollLeft + deltaX * factor
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
autoScrollRAF.current = requestAnimationFrame(autoScroll);
|
|
233
|
+
}
|
|
234
|
+
autoScroll();
|
|
235
|
+
}, [apiRef]);
|
|
162
236
|
var handleCellMouseOver = React.useCallback(function (params, event) {
|
|
237
|
+
var _apiRef$current$virtu6, _apiRef$current$virtu7;
|
|
163
238
|
if (!lastMouseDownCell.current) {
|
|
164
239
|
return;
|
|
165
240
|
}
|
|
@@ -169,7 +244,31 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
|
|
|
169
244
|
id: id,
|
|
170
245
|
field: field
|
|
171
246
|
}, event.ctrlKey || event.metaKey);
|
|
172
|
-
|
|
247
|
+
var virtualScrollerRect = (_apiRef$current$virtu6 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu7 = _apiRef$current$virtu6.current) == null ? void 0 : _apiRef$current$virtu7.getBoundingClientRect();
|
|
248
|
+
if (!virtualScrollerRect) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
var height = virtualScrollerRect.height,
|
|
252
|
+
width = virtualScrollerRect.width,
|
|
253
|
+
x = virtualScrollerRect.x,
|
|
254
|
+
y = virtualScrollerRect.y;
|
|
255
|
+
var mouseX = event.clientX - x;
|
|
256
|
+
var mouseY = event.clientY - y;
|
|
257
|
+
mousePosition.current = {
|
|
258
|
+
x: mouseX,
|
|
259
|
+
y: mouseY
|
|
260
|
+
};
|
|
261
|
+
var hasEnteredVerticalSensitivityArea = mouseY <= AUTO_SCROLL_SENSITIVITY || mouseY >= height - AUTO_SCROLL_SENSITIVITY;
|
|
262
|
+
var hasEnteredHorizontalSensitivityArea = mouseX <= AUTO_SCROLL_SENSITIVITY || mouseX >= width - AUTO_SCROLL_SENSITIVITY;
|
|
263
|
+
var hasEnteredSensitivityArea = hasEnteredVerticalSensitivityArea || hasEnteredHorizontalSensitivityArea;
|
|
264
|
+
if (hasEnteredSensitivityArea) {
|
|
265
|
+
// Mouse has entered the sensitity area for the first time
|
|
266
|
+
startAutoScroll();
|
|
267
|
+
} else {
|
|
268
|
+
// Mouse has left the sensitivity area while auto scroll is on
|
|
269
|
+
stopAutoScroll();
|
|
270
|
+
}
|
|
271
|
+
}, [apiRef, startAutoScroll, stopAutoScroll]);
|
|
173
272
|
var handleCellClick = useEventCallback(function (params, event) {
|
|
174
273
|
var id = params.id,
|
|
175
274
|
field = params.field;
|
|
@@ -228,6 +327,10 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
|
|
|
228
327
|
id: visibleRows.rows[endRowIndex].id,
|
|
229
328
|
field: visibleColumns[endColumnIndex].field
|
|
230
329
|
};
|
|
330
|
+
apiRef.current.scrollToIndexes({
|
|
331
|
+
rowIndex: endRowIndex,
|
|
332
|
+
colIndex: endColumnIndex
|
|
333
|
+
});
|
|
231
334
|
var id = params.id,
|
|
232
335
|
field = params.field;
|
|
233
336
|
apiRef.current.unstable_selectCellRange({
|
|
@@ -239,13 +342,21 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
|
|
|
239
342
|
useGridApiEventHandler(apiRef, 'cellFocusIn', runIfCellSelectionIsEnabled(handleCellFocusIn));
|
|
240
343
|
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfCellSelectionIsEnabled(handleCellKeyDown));
|
|
241
344
|
useGridApiEventHandler(apiRef, 'cellMouseDown', runIfCellSelectionIsEnabled(handleCellMouseDown));
|
|
242
|
-
useGridApiEventHandler(apiRef, 'cellMouseUp', runIfCellSelectionIsEnabled(handleCellMouseUp));
|
|
243
345
|
useGridApiEventHandler(apiRef, 'cellMouseOver', runIfCellSelectionIsEnabled(handleCellMouseOver));
|
|
244
346
|
React.useEffect(function () {
|
|
245
347
|
if (props.unstable_cellSelectionModel) {
|
|
246
348
|
apiRef.current.unstable_setCellSelectionModel(props.unstable_cellSelectionModel);
|
|
247
349
|
}
|
|
248
350
|
}, [apiRef, props.unstable_cellSelectionModel]);
|
|
351
|
+
React.useEffect(function () {
|
|
352
|
+
var _apiRef$current$rootE6;
|
|
353
|
+
var rootRef = (_apiRef$current$rootE6 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE6.current;
|
|
354
|
+
return function () {
|
|
355
|
+
stopAutoScroll();
|
|
356
|
+
var document = ownerDocument(rootRef);
|
|
357
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
358
|
+
};
|
|
359
|
+
}, [apiRef, handleMouseUp, stopAutoScroll]);
|
|
249
360
|
var checkIfCellIsSelected = React.useCallback(function (isSelected, _ref5) {
|
|
250
361
|
var id = _ref5.id,
|
|
251
362
|
field = _ref5.field;
|
package/legacy/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export var getReleaseInfo = function getReleaseInfo() {
|
|
3
|
-
var releaseInfo = "
|
|
3
|
+
var releaseInfo = "MTY4ODU5MDgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -740,7 +740,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
740
740
|
* Select the pageSize dynamically using the component UI.
|
|
741
741
|
* @default [25, 50, 100]
|
|
742
742
|
*/
|
|
743
|
-
pageSizeOptions: PropTypes.arrayOf(PropTypes.number
|
|
743
|
+
pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
744
|
+
label: PropTypes.string.isRequired,
|
|
745
|
+
value: PropTypes.number.isRequired
|
|
746
|
+
})]).isRequired),
|
|
744
747
|
/**
|
|
745
748
|
* If `true`, pagination is enabled.
|
|
746
749
|
* @default false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { useEventCallback } from '@mui/material/utils';
|
|
3
|
+
import { ownerDocument, useEventCallback } from '@mui/material/utils';
|
|
4
4
|
import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
|
|
5
5
|
import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector } from '@mui/x-data-grid-pro';
|
|
6
6
|
import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
|
|
@@ -10,10 +10,15 @@ export const cellSelectionStateInitializer = (state, props) => _extends({}, stat
|
|
|
10
10
|
function isKeyboardEvent(event) {
|
|
11
11
|
return !!event.key;
|
|
12
12
|
}
|
|
13
|
+
const AUTO_SCROLL_SENSITIVITY = 50; // The distance from the edge to start scrolling
|
|
14
|
+
const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the sensitivity area
|
|
15
|
+
|
|
13
16
|
export const useGridCellSelection = (apiRef, props) => {
|
|
14
17
|
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
15
18
|
const cellWithVirtualFocus = React.useRef();
|
|
16
19
|
const lastMouseDownCell = React.useRef();
|
|
20
|
+
const mousePosition = React.useRef(null);
|
|
21
|
+
const autoScrollRAF = React.useRef();
|
|
17
22
|
const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
18
23
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
|
|
19
24
|
const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
@@ -110,6 +115,13 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
110
115
|
}
|
|
111
116
|
return params.rowNode.type !== 'pinnedRow';
|
|
112
117
|
}, [apiRef]);
|
|
118
|
+
const handleMouseUp = useEventCallback(() => {
|
|
119
|
+
lastMouseDownCell.current = null;
|
|
120
|
+
apiRef.current.rootElementRef?.current?.classList.remove(gridClasses['root--disableUserSelection']);
|
|
121
|
+
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
123
|
+
stopAutoScroll();
|
|
124
|
+
});
|
|
113
125
|
const handleCellMouseDown = React.useCallback((params, event) => {
|
|
114
126
|
// Skip if the click comes from the right-button or, only on macOS, Ctrl is pressed
|
|
115
127
|
// Fix for https://github.com/mui/mui-x/pull/6567#issuecomment-1329155578
|
|
@@ -126,17 +138,81 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
126
138
|
field: params.field
|
|
127
139
|
};
|
|
128
140
|
apiRef.current.rootElementRef?.current?.classList.add(gridClasses['root--disableUserSelection']);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, [apiRef]);
|
|
141
|
+
const document = ownerDocument(apiRef.current.rootElementRef?.current);
|
|
142
|
+
document.addEventListener('mouseup', handleMouseUp, {
|
|
143
|
+
once: true
|
|
144
|
+
});
|
|
145
|
+
}, [apiRef, handleMouseUp, hasClickedValidCellForRangeSelection]);
|
|
146
|
+
const stopAutoScroll = React.useCallback(() => {
|
|
147
|
+
if (autoScrollRAF.current) {
|
|
148
|
+
cancelAnimationFrame(autoScrollRAF.current);
|
|
149
|
+
autoScrollRAF.current = null;
|
|
150
|
+
}
|
|
151
|
+
}, []);
|
|
134
152
|
const handleCellFocusIn = React.useCallback(params => {
|
|
135
153
|
cellWithVirtualFocus.current = {
|
|
136
154
|
id: params.id,
|
|
137
155
|
field: params.field
|
|
138
156
|
};
|
|
139
157
|
}, []);
|
|
158
|
+
const startAutoScroll = React.useCallback(() => {
|
|
159
|
+
if (autoScrollRAF.current) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (!apiRef.current.virtualScrollerRef?.current) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const virtualScrollerRect = apiRef.current.virtualScrollerRef?.current?.getBoundingClientRect();
|
|
166
|
+
if (!virtualScrollerRect) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
function autoScroll() {
|
|
170
|
+
if (!mousePosition.current || !apiRef.current.virtualScrollerRef?.current) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const {
|
|
174
|
+
x: mouseX,
|
|
175
|
+
y: mouseY
|
|
176
|
+
} = mousePosition.current;
|
|
177
|
+
const {
|
|
178
|
+
height,
|
|
179
|
+
width
|
|
180
|
+
} = virtualScrollerRect;
|
|
181
|
+
let deltaX = 0;
|
|
182
|
+
let deltaY = 0;
|
|
183
|
+
let factor = 0;
|
|
184
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
185
|
+
if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollY) {
|
|
186
|
+
// When scrolling up, the multiplier increases going closer to the top edge
|
|
187
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
|
|
188
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
189
|
+
} else if (mouseY >= height - AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollY) {
|
|
190
|
+
// When scrolling down, the multiplier increases going closer to the bottom edge
|
|
191
|
+
factor = (mouseY - (height - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
192
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
193
|
+
} else if (mouseX <= AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollX) {
|
|
194
|
+
// When scrolling left, the multiplier increases going closer to the left edge
|
|
195
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseX) / -AUTO_SCROLL_SENSITIVITY;
|
|
196
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
197
|
+
} else if (mouseX >= width - AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollX) {
|
|
198
|
+
// When scrolling right, the multiplier increases going closer to the right edge
|
|
199
|
+
factor = (mouseX - (width - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
200
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
201
|
+
}
|
|
202
|
+
if (deltaX !== 0 || deltaY !== 0) {
|
|
203
|
+
const {
|
|
204
|
+
scrollLeft,
|
|
205
|
+
scrollTop
|
|
206
|
+
} = apiRef.current.virtualScrollerRef.current;
|
|
207
|
+
apiRef.current.scroll({
|
|
208
|
+
top: scrollTop + deltaY * factor,
|
|
209
|
+
left: scrollLeft + deltaX * factor
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
autoScrollRAF.current = requestAnimationFrame(autoScroll);
|
|
213
|
+
}
|
|
214
|
+
autoScroll();
|
|
215
|
+
}, [apiRef]);
|
|
140
216
|
const handleCellMouseOver = React.useCallback((params, event) => {
|
|
141
217
|
if (!lastMouseDownCell.current) {
|
|
142
218
|
return;
|
|
@@ -149,7 +225,33 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
149
225
|
id,
|
|
150
226
|
field
|
|
151
227
|
}, event.ctrlKey || event.metaKey);
|
|
152
|
-
|
|
228
|
+
const virtualScrollerRect = apiRef.current.virtualScrollerRef?.current?.getBoundingClientRect();
|
|
229
|
+
if (!virtualScrollerRect) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const {
|
|
233
|
+
height,
|
|
234
|
+
width,
|
|
235
|
+
x,
|
|
236
|
+
y
|
|
237
|
+
} = virtualScrollerRect;
|
|
238
|
+
const mouseX = event.clientX - x;
|
|
239
|
+
const mouseY = event.clientY - y;
|
|
240
|
+
mousePosition.current = {
|
|
241
|
+
x: mouseX,
|
|
242
|
+
y: mouseY
|
|
243
|
+
};
|
|
244
|
+
const hasEnteredVerticalSensitivityArea = mouseY <= AUTO_SCROLL_SENSITIVITY || mouseY >= height - AUTO_SCROLL_SENSITIVITY;
|
|
245
|
+
const hasEnteredHorizontalSensitivityArea = mouseX <= AUTO_SCROLL_SENSITIVITY || mouseX >= width - AUTO_SCROLL_SENSITIVITY;
|
|
246
|
+
const hasEnteredSensitivityArea = hasEnteredVerticalSensitivityArea || hasEnteredHorizontalSensitivityArea;
|
|
247
|
+
if (hasEnteredSensitivityArea) {
|
|
248
|
+
// Mouse has entered the sensitity area for the first time
|
|
249
|
+
startAutoScroll();
|
|
250
|
+
} else {
|
|
251
|
+
// Mouse has left the sensitivity area while auto scroll is on
|
|
252
|
+
stopAutoScroll();
|
|
253
|
+
}
|
|
254
|
+
}, [apiRef, startAutoScroll, stopAutoScroll]);
|
|
153
255
|
const handleCellClick = useEventCallback((params, event) => {
|
|
154
256
|
const {
|
|
155
257
|
id,
|
|
@@ -220,6 +322,10 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
220
322
|
id: visibleRows.rows[endRowIndex].id,
|
|
221
323
|
field: visibleColumns[endColumnIndex].field
|
|
222
324
|
};
|
|
325
|
+
apiRef.current.scrollToIndexes({
|
|
326
|
+
rowIndex: endRowIndex,
|
|
327
|
+
colIndex: endColumnIndex
|
|
328
|
+
});
|
|
223
329
|
const {
|
|
224
330
|
id,
|
|
225
331
|
field
|
|
@@ -233,13 +339,20 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
233
339
|
useGridApiEventHandler(apiRef, 'cellFocusIn', runIfCellSelectionIsEnabled(handleCellFocusIn));
|
|
234
340
|
useGridApiEventHandler(apiRef, 'cellKeyDown', runIfCellSelectionIsEnabled(handleCellKeyDown));
|
|
235
341
|
useGridApiEventHandler(apiRef, 'cellMouseDown', runIfCellSelectionIsEnabled(handleCellMouseDown));
|
|
236
|
-
useGridApiEventHandler(apiRef, 'cellMouseUp', runIfCellSelectionIsEnabled(handleCellMouseUp));
|
|
237
342
|
useGridApiEventHandler(apiRef, 'cellMouseOver', runIfCellSelectionIsEnabled(handleCellMouseOver));
|
|
238
343
|
React.useEffect(() => {
|
|
239
344
|
if (props.unstable_cellSelectionModel) {
|
|
240
345
|
apiRef.current.unstable_setCellSelectionModel(props.unstable_cellSelectionModel);
|
|
241
346
|
}
|
|
242
347
|
}, [apiRef, props.unstable_cellSelectionModel]);
|
|
348
|
+
React.useEffect(() => {
|
|
349
|
+
const rootRef = apiRef.current.rootElementRef?.current;
|
|
350
|
+
return () => {
|
|
351
|
+
stopAutoScroll();
|
|
352
|
+
const document = ownerDocument(rootRef);
|
|
353
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
354
|
+
};
|
|
355
|
+
}, [apiRef, handleMouseUp, stopAutoScroll]);
|
|
243
356
|
const checkIfCellIsSelected = React.useCallback((isSelected, {
|
|
244
357
|
id,
|
|
245
358
|
field
|
package/modern/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY4ODU5MDgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -749,7 +749,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
749
749
|
* Select the pageSize dynamically using the component UI.
|
|
750
750
|
* @default [25, 50, 100]
|
|
751
751
|
*/
|
|
752
|
-
pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.number
|
|
752
|
+
pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
|
|
753
|
+
label: _propTypes.default.string.isRequired,
|
|
754
|
+
value: _propTypes.default.number.isRequired
|
|
755
|
+
})]).isRequired),
|
|
753
756
|
/**
|
|
754
757
|
* If `true`, pagination is enabled.
|
|
755
758
|
* @default false
|
|
@@ -20,10 +20,15 @@ exports.cellSelectionStateInitializer = cellSelectionStateInitializer;
|
|
|
20
20
|
function isKeyboardEvent(event) {
|
|
21
21
|
return !!event.key;
|
|
22
22
|
}
|
|
23
|
+
const AUTO_SCROLL_SENSITIVITY = 50; // The distance from the edge to start scrolling
|
|
24
|
+
const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the sensitivity area
|
|
25
|
+
|
|
23
26
|
const useGridCellSelection = (apiRef, props) => {
|
|
24
27
|
const visibleRows = (0, _internals.useGridVisibleRows)(apiRef, props);
|
|
25
28
|
const cellWithVirtualFocus = React.useRef();
|
|
26
29
|
const lastMouseDownCell = React.useRef();
|
|
30
|
+
const mousePosition = React.useRef(null);
|
|
31
|
+
const autoScrollRAF = React.useRef();
|
|
27
32
|
const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
|
|
28
33
|
const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
|
|
29
34
|
const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
|
|
@@ -120,6 +125,13 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
120
125
|
}
|
|
121
126
|
return params.rowNode.type !== 'pinnedRow';
|
|
122
127
|
}, [apiRef]);
|
|
128
|
+
const handleMouseUp = (0, _utils.useEventCallback)(() => {
|
|
129
|
+
lastMouseDownCell.current = null;
|
|
130
|
+
apiRef.current.rootElementRef?.current?.classList.remove(_xDataGridPro.gridClasses['root--disableUserSelection']);
|
|
131
|
+
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
133
|
+
stopAutoScroll();
|
|
134
|
+
});
|
|
123
135
|
const handleCellMouseDown = React.useCallback((params, event) => {
|
|
124
136
|
// Skip if the click comes from the right-button or, only on macOS, Ctrl is pressed
|
|
125
137
|
// Fix for https://github.com/mui/mui-x/pull/6567#issuecomment-1329155578
|
|
@@ -136,17 +148,81 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
136
148
|
field: params.field
|
|
137
149
|
};
|
|
138
150
|
apiRef.current.rootElementRef?.current?.classList.add(_xDataGridPro.gridClasses['root--disableUserSelection']);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}, [apiRef]);
|
|
151
|
+
const document = (0, _utils.ownerDocument)(apiRef.current.rootElementRef?.current);
|
|
152
|
+
document.addEventListener('mouseup', handleMouseUp, {
|
|
153
|
+
once: true
|
|
154
|
+
});
|
|
155
|
+
}, [apiRef, handleMouseUp, hasClickedValidCellForRangeSelection]);
|
|
156
|
+
const stopAutoScroll = React.useCallback(() => {
|
|
157
|
+
if (autoScrollRAF.current) {
|
|
158
|
+
cancelAnimationFrame(autoScrollRAF.current);
|
|
159
|
+
autoScrollRAF.current = null;
|
|
160
|
+
}
|
|
161
|
+
}, []);
|
|
144
162
|
const handleCellFocusIn = React.useCallback(params => {
|
|
145
163
|
cellWithVirtualFocus.current = {
|
|
146
164
|
id: params.id,
|
|
147
165
|
field: params.field
|
|
148
166
|
};
|
|
149
167
|
}, []);
|
|
168
|
+
const startAutoScroll = React.useCallback(() => {
|
|
169
|
+
if (autoScrollRAF.current) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!apiRef.current.virtualScrollerRef?.current) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const virtualScrollerRect = apiRef.current.virtualScrollerRef?.current?.getBoundingClientRect();
|
|
176
|
+
if (!virtualScrollerRect) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
function autoScroll() {
|
|
180
|
+
if (!mousePosition.current || !apiRef.current.virtualScrollerRef?.current) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const {
|
|
184
|
+
x: mouseX,
|
|
185
|
+
y: mouseY
|
|
186
|
+
} = mousePosition.current;
|
|
187
|
+
const {
|
|
188
|
+
height,
|
|
189
|
+
width
|
|
190
|
+
} = virtualScrollerRect;
|
|
191
|
+
let deltaX = 0;
|
|
192
|
+
let deltaY = 0;
|
|
193
|
+
let factor = 0;
|
|
194
|
+
const dimensions = apiRef.current.getRootDimensions();
|
|
195
|
+
if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollY) {
|
|
196
|
+
// When scrolling up, the multiplier increases going closer to the top edge
|
|
197
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
|
|
198
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
199
|
+
} else if (mouseY >= height - AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollY) {
|
|
200
|
+
// When scrolling down, the multiplier increases going closer to the bottom edge
|
|
201
|
+
factor = (mouseY - (height - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
202
|
+
deltaY = AUTO_SCROLL_SPEED;
|
|
203
|
+
} else if (mouseX <= AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollX) {
|
|
204
|
+
// When scrolling left, the multiplier increases going closer to the left edge
|
|
205
|
+
factor = (AUTO_SCROLL_SENSITIVITY - mouseX) / -AUTO_SCROLL_SENSITIVITY;
|
|
206
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
207
|
+
} else if (mouseX >= width - AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollX) {
|
|
208
|
+
// When scrolling right, the multiplier increases going closer to the right edge
|
|
209
|
+
factor = (mouseX - (width - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
|
|
210
|
+
deltaX = AUTO_SCROLL_SPEED;
|
|
211
|
+
}
|
|
212
|
+
if (deltaX !== 0 || deltaY !== 0) {
|
|
213
|
+
const {
|
|
214
|
+
scrollLeft,
|
|
215
|
+
scrollTop
|
|
216
|
+
} = apiRef.current.virtualScrollerRef.current;
|
|
217
|
+
apiRef.current.scroll({
|
|
218
|
+
top: scrollTop + deltaY * factor,
|
|
219
|
+
left: scrollLeft + deltaX * factor
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
autoScrollRAF.current = requestAnimationFrame(autoScroll);
|
|
223
|
+
}
|
|
224
|
+
autoScroll();
|
|
225
|
+
}, [apiRef]);
|
|
150
226
|
const handleCellMouseOver = React.useCallback((params, event) => {
|
|
151
227
|
if (!lastMouseDownCell.current) {
|
|
152
228
|
return;
|
|
@@ -159,7 +235,33 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
159
235
|
id,
|
|
160
236
|
field
|
|
161
237
|
}, event.ctrlKey || event.metaKey);
|
|
162
|
-
|
|
238
|
+
const virtualScrollerRect = apiRef.current.virtualScrollerRef?.current?.getBoundingClientRect();
|
|
239
|
+
if (!virtualScrollerRect) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const {
|
|
243
|
+
height,
|
|
244
|
+
width,
|
|
245
|
+
x,
|
|
246
|
+
y
|
|
247
|
+
} = virtualScrollerRect;
|
|
248
|
+
const mouseX = event.clientX - x;
|
|
249
|
+
const mouseY = event.clientY - y;
|
|
250
|
+
mousePosition.current = {
|
|
251
|
+
x: mouseX,
|
|
252
|
+
y: mouseY
|
|
253
|
+
};
|
|
254
|
+
const hasEnteredVerticalSensitivityArea = mouseY <= AUTO_SCROLL_SENSITIVITY || mouseY >= height - AUTO_SCROLL_SENSITIVITY;
|
|
255
|
+
const hasEnteredHorizontalSensitivityArea = mouseX <= AUTO_SCROLL_SENSITIVITY || mouseX >= width - AUTO_SCROLL_SENSITIVITY;
|
|
256
|
+
const hasEnteredSensitivityArea = hasEnteredVerticalSensitivityArea || hasEnteredHorizontalSensitivityArea;
|
|
257
|
+
if (hasEnteredSensitivityArea) {
|
|
258
|
+
// Mouse has entered the sensitity area for the first time
|
|
259
|
+
startAutoScroll();
|
|
260
|
+
} else {
|
|
261
|
+
// Mouse has left the sensitivity area while auto scroll is on
|
|
262
|
+
stopAutoScroll();
|
|
263
|
+
}
|
|
264
|
+
}, [apiRef, startAutoScroll, stopAutoScroll]);
|
|
163
265
|
const handleCellClick = (0, _utils.useEventCallback)((params, event) => {
|
|
164
266
|
const {
|
|
165
267
|
id,
|
|
@@ -230,6 +332,10 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
230
332
|
id: visibleRows.rows[endRowIndex].id,
|
|
231
333
|
field: visibleColumns[endColumnIndex].field
|
|
232
334
|
};
|
|
335
|
+
apiRef.current.scrollToIndexes({
|
|
336
|
+
rowIndex: endRowIndex,
|
|
337
|
+
colIndex: endColumnIndex
|
|
338
|
+
});
|
|
233
339
|
const {
|
|
234
340
|
id,
|
|
235
341
|
field
|
|
@@ -243,13 +349,20 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
243
349
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'cellFocusIn', runIfCellSelectionIsEnabled(handleCellFocusIn));
|
|
244
350
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'cellKeyDown', runIfCellSelectionIsEnabled(handleCellKeyDown));
|
|
245
351
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'cellMouseDown', runIfCellSelectionIsEnabled(handleCellMouseDown));
|
|
246
|
-
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'cellMouseUp', runIfCellSelectionIsEnabled(handleCellMouseUp));
|
|
247
352
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'cellMouseOver', runIfCellSelectionIsEnabled(handleCellMouseOver));
|
|
248
353
|
React.useEffect(() => {
|
|
249
354
|
if (props.unstable_cellSelectionModel) {
|
|
250
355
|
apiRef.current.unstable_setCellSelectionModel(props.unstable_cellSelectionModel);
|
|
251
356
|
}
|
|
252
357
|
}, [apiRef, props.unstable_cellSelectionModel]);
|
|
358
|
+
React.useEffect(() => {
|
|
359
|
+
const rootRef = apiRef.current.rootElementRef?.current;
|
|
360
|
+
return () => {
|
|
361
|
+
stopAutoScroll();
|
|
362
|
+
const document = (0, _utils.ownerDocument)(rootRef);
|
|
363
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
364
|
+
};
|
|
365
|
+
}, [apiRef, handleMouseUp, stopAutoScroll]);
|
|
253
366
|
const checkIfCellIsSelected = React.useCallback((isSelected, {
|
|
254
367
|
id,
|
|
255
368
|
field
|
package/node/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReleaseInfo = void 0;
|
|
7
7
|
var _utils = require("@mui/utils");
|
|
8
8
|
const getReleaseInfo = () => {
|
|
9
|
-
const releaseInfo = "
|
|
9
|
+
const releaseInfo = "MTY4ODU5MDgwMDAwMA==";
|
|
10
10
|
if (process.env.NODE_ENV !== 'production') {
|
|
11
11
|
// A simple hack to set the value in the test environment (has no build step).
|
|
12
12
|
// eslint-disable-next-line no-useless-concat
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-premium",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.2",
|
|
4
4
|
"description": "The Premium plan edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.22.5",
|
|
35
35
|
"@mui/utils": "^5.13.6",
|
|
36
|
-
"@mui/x-data-grid": "6.9.
|
|
37
|
-
"@mui/x-data-grid-pro": "6.9.
|
|
36
|
+
"@mui/x-data-grid": "6.9.2",
|
|
37
|
+
"@mui/x-data-grid-pro": "6.9.2",
|
|
38
38
|
"@mui/x-license-pro": "6.9.0",
|
|
39
39
|
"@types/format-util": "^1.0.2",
|
|
40
40
|
"clsx": "^1.2.1",
|
package/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY4ODU5MDgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|