@mui/x-data-grid 7.25.0 → 7.26.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 +71 -0
- package/DataGrid/useDataGridComponent.js +2 -2
- package/components/GridRow.js +8 -2
- package/components/GridScrollArea.d.ts +5 -2
- package/components/GridScrollArea.js +32 -25
- package/components/GridSkeletonLoadingOverlay.js +2 -1
- package/components/containers/GridRoot.js +11 -9
- package/components/containers/GridRootStyles.js +3 -3
- package/components/virtualization/GridMainContainer.d.ts +2 -2
- package/components/virtualization/GridMainContainer.js +1 -1
- package/components/virtualization/GridVirtualScroller.js +21 -14
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
- package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/hooks/core/useGridStateInitialization.js +3 -2
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/hooks/features/columns/gridColumnsSelector.d.ts +0 -5
- package/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/hooks/features/dimensions/gridDimensionsSelectors.d.ts +16 -0
- package/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/hooks/features/dimensions/index.d.ts +1 -1
- package/hooks/features/dimensions/index.js +1 -2
- package/hooks/features/dimensions/useGridDimensions.js +97 -70
- package/hooks/features/editing/gridEditingSelectors.d.ts +5 -1
- package/hooks/features/editing/gridEditingSelectors.js +6 -1
- package/hooks/features/editing/useGridRowEditing.js +4 -4
- package/hooks/features/filter/gridFilterState.d.ts +5 -0
- package/hooks/features/filter/gridFilterState.js +5 -0
- package/hooks/features/filter/useGridFilter.js +6 -13
- package/hooks/features/pagination/useGridPagination.js +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/hooks/features/rowSelection/utils.js +1 -1
- package/hooks/features/rows/gridRowsMetaState.d.ts +8 -0
- package/hooks/features/rows/gridRowsUtils.d.ts +0 -4
- package/hooks/features/rows/gridRowsUtils.js +0 -16
- package/hooks/features/rows/useGridRowsMeta.js +33 -17
- package/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +6 -0
- package/hooks/features/virtualization/useGridVirtualScroller.js +43 -27
- package/hooks/utils/useGridSelector.d.ts +8 -1
- package/hooks/utils/useGridSelector.js +42 -8
- package/hooks/utils/useIsSSR.d.ts +1 -0
- package/hooks/utils/useIsSSR.js +5 -0
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +2 -1
- package/models/api/gridStateApi.d.ts +1 -0
- package/models/events/gridEventLookup.d.ts +6 -0
- package/modern/DataGrid/useDataGridComponent.js +2 -2
- package/modern/components/GridRow.js +8 -2
- package/modern/components/GridScrollArea.js +32 -25
- package/modern/components/GridSkeletonLoadingOverlay.js +2 -1
- package/modern/components/containers/GridRoot.js +11 -9
- package/modern/components/containers/GridRootStyles.js +3 -3
- package/modern/components/virtualization/GridMainContainer.js +1 -1
- package/modern/components/virtualization/GridVirtualScroller.js +21 -14
- package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/modern/hooks/core/useGridStateInitialization.js +3 -2
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/modern/hooks/features/columns/gridColumnsSelector.js +0 -12
- package/modern/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
- package/modern/hooks/features/dimensions/index.js +1 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +97 -70
- package/modern/hooks/features/editing/gridEditingSelectors.js +6 -1
- package/modern/hooks/features/editing/useGridRowEditing.js +4 -4
- package/modern/hooks/features/filter/gridFilterState.js +5 -0
- package/modern/hooks/features/filter/useGridFilter.js +6 -13
- package/modern/hooks/features/pagination/useGridPagination.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/modern/hooks/features/rowSelection/utils.js +1 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +0 -16
- package/modern/hooks/features/rows/useGridRowsMeta.js +33 -17
- package/modern/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +43 -27
- package/modern/hooks/utils/useGridSelector.js +42 -8
- package/modern/hooks/utils/useIsSSR.js +5 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -1
- package/node/DataGrid/useDataGridComponent.js +2 -2
- package/node/components/GridRow.js +7 -2
- package/node/components/GridScrollArea.js +31 -24
- package/node/components/GridSkeletonLoadingOverlay.js +2 -1
- package/node/components/containers/GridRoot.js +10 -8
- package/node/components/containers/GridRootStyles.js +3 -3
- package/node/components/virtualization/GridMainContainer.js +1 -1
- package/node/components/virtualization/GridVirtualScroller.js +21 -14
- package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
- package/node/hooks/core/useGridStateInitialization.js +3 -2
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
- package/node/hooks/features/columns/gridColumnsSelector.js +1 -13
- package/node/hooks/features/dimensions/gridDimensionsSelectors.js +38 -2
- package/node/hooks/features/dimensions/index.js +13 -11
- package/node/hooks/features/dimensions/useGridDimensions.js +94 -67
- package/node/hooks/features/editing/gridEditingSelectors.js +5 -1
- package/node/hooks/features/editing/useGridRowEditing.js +4 -4
- package/node/hooks/features/filter/gridFilterState.js +6 -1
- package/node/hooks/features/filter/useGridFilter.js +5 -12
- package/node/hooks/features/pagination/useGridPagination.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/node/hooks/features/rowSelection/utils.js +1 -1
- package/node/hooks/features/rows/gridRowsUtils.js +0 -17
- package/node/hooks/features/rows/useGridRowsMeta.js +31 -15
- package/node/hooks/features/sorting/gridSortingSelector.js +10 -9
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +42 -26
- package/node/hooks/utils/useGridSelector.js +42 -8
- package/node/hooks/utils/useIsSSR.js +12 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +20 -7
- package/package.json +3 -2
|
@@ -24,15 +24,16 @@ export const gridSortedRowEntriesSelector = createSelectorMemoized(gridSortedRow
|
|
|
24
24
|
id,
|
|
25
25
|
model
|
|
26
26
|
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
} else {
|
|
28
|
+
const rowNode = rowTree[id];
|
|
29
|
+
if (rowNode && isAutogeneratedRowNode(rowNode)) {
|
|
30
|
+
acc.push({
|
|
31
|
+
id,
|
|
32
|
+
model: {
|
|
33
|
+
[GRID_ID_AUTOGENERATED]: id
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
36
37
|
}
|
|
37
38
|
return acc;
|
|
38
39
|
}, []));
|
|
@@ -47,6 +47,12 @@ export declare const useGridVirtualScroller: () => {
|
|
|
47
47
|
left: number;
|
|
48
48
|
}>;
|
|
49
49
|
};
|
|
50
|
+
getScrollAreaProps: () => {
|
|
51
|
+
scrollPosition: React.RefObject<{
|
|
52
|
+
top: number;
|
|
53
|
+
left: number;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
50
56
|
};
|
|
51
57
|
export declare function areRenderContextsEqual(context1: GridRenderContext, context2: GridRenderContext): boolean;
|
|
52
58
|
export declare function computeOffsetLeft(columnPositions: number[], renderContext: GridColumnsRenderContext, pinnedLeftLength: number): number;
|
|
@@ -6,15 +6,15 @@ import useLazyRef from '@mui/utils/useLazyRef';
|
|
|
6
6
|
import useTimeout from '@mui/utils/useTimeout';
|
|
7
7
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
8
|
import reactMajor from '@mui/x-internals/reactMajor';
|
|
9
|
+
import { gridDimensionsSelector, gridColumnsTotalWidthSelector, gridContentHeightSelector, gridHasFillerSelector, gridRowHeightSelector, gridVerticalScrollbarWidthSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
9
10
|
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
10
11
|
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
11
12
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
12
13
|
import { useRunOnce } from "../../utils/useRunOnce.js";
|
|
13
14
|
import { gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridHasColSpanSelector } from "../columns/gridColumnsSelector.js";
|
|
14
|
-
import { gridDimensionsSelector } from "../dimensions/gridDimensionsSelectors.js";
|
|
15
15
|
import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
|
|
16
16
|
import { useGridVisibleRows, getVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
17
|
-
import {
|
|
17
|
+
import { useGridApiOptionHandler } from "../../utils/index.js";
|
|
18
18
|
import * as platform from "../../../utils/platform.js";
|
|
19
19
|
import { clamp, range } from "../../../utils/utils.js";
|
|
20
20
|
import { selectedIdsLookupSelector } from "../rowSelection/gridRowSelectionSelector.js";
|
|
@@ -57,8 +57,6 @@ export const useGridVirtualScroller = () => {
|
|
|
57
57
|
const visibleColumns = useGridSelector(apiRef, () => listView ? [gridListColumnSelector(apiRef.current.state)] : gridVisibleColumnDefinitionsSelector(apiRef));
|
|
58
58
|
const enabledForRows = useGridSelector(apiRef, gridVirtualizationRowEnabledSelector) && !isJSDOM;
|
|
59
59
|
const enabledForColumns = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector) && !isJSDOM;
|
|
60
|
-
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
61
|
-
const outerSize = dimensions.viewportOuterSize;
|
|
62
60
|
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
63
61
|
const pinnedColumnDefinitions = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
|
|
64
62
|
const pinnedColumns = listView ? EMPTY_PINNED_COLUMN_FIELDS : pinnedColumnDefinitions;
|
|
@@ -71,10 +69,14 @@ export const useGridVirtualScroller = () => {
|
|
|
71
69
|
const scrollerRef = apiRef.current.virtualScrollerRef;
|
|
72
70
|
const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
73
71
|
const scrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
74
|
-
const contentHeight = dimensions.contentSize.height;
|
|
75
|
-
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
76
72
|
const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
|
|
77
73
|
const isRenderContextReady = React.useRef(false);
|
|
74
|
+
const rowHeight = useGridSelector(apiRef, gridRowHeightSelector);
|
|
75
|
+
const contentHeight = useGridSelector(apiRef, gridContentHeightSelector);
|
|
76
|
+
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
77
|
+
const needsHorizontalScrollbar = useGridSelector(apiRef, needsHorizontalScrollbarSelector);
|
|
78
|
+
const verticalScrollbarWidth = useGridSelector(apiRef, gridVerticalScrollbarWidthSelector);
|
|
79
|
+
const gridHasFiller = useGridSelector(apiRef, gridHasFillerSelector);
|
|
78
80
|
const previousSize = React.useRef(null);
|
|
79
81
|
const mainRefCallback = React.useCallback(node => {
|
|
80
82
|
mainRef.current = node;
|
|
@@ -141,7 +143,7 @@ export const useGridVirtualScroller = () => {
|
|
|
141
143
|
const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
|
|
142
144
|
const scrollTimeout = useTimeout();
|
|
143
145
|
const frozenContext = React.useRef(undefined);
|
|
144
|
-
const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx,
|
|
146
|
+
const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
|
|
145
147
|
const updateRenderContext = React.useCallback(nextRenderContext => {
|
|
146
148
|
if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
|
|
147
149
|
return;
|
|
@@ -156,19 +158,21 @@ export const useGridVirtualScroller = () => {
|
|
|
156
158
|
});
|
|
157
159
|
|
|
158
160
|
// The lazy-loading hook is listening to `renderedRowsIntervalChange`,
|
|
159
|
-
// but only does something if
|
|
160
|
-
//
|
|
161
|
-
|
|
161
|
+
// but only does something if we already have a render context, because
|
|
162
|
+
// otherwise we would call an update directly on mount
|
|
163
|
+
const isReady = gridDimensionsSelector(apiRef.current.state).isReady;
|
|
164
|
+
if (isReady && didRowsIntervalChange) {
|
|
162
165
|
previousRowContext.current = nextRenderContext;
|
|
163
166
|
apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
|
|
164
167
|
}
|
|
165
168
|
previousContextScrollPosition.current = scrollPosition.current;
|
|
166
|
-
}, [apiRef
|
|
169
|
+
}, [apiRef]);
|
|
167
170
|
const triggerUpdateRenderContext = useEventCallback(() => {
|
|
168
171
|
const scroller = scrollerRef.current;
|
|
169
172
|
if (!scroller) {
|
|
170
173
|
return undefined;
|
|
171
174
|
}
|
|
175
|
+
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
172
176
|
const maxScrollTop = Math.ceil(dimensions.minimumSize.height - dimensions.viewportOuterSize.height);
|
|
173
177
|
const maxScrollLeft = Math.ceil(dimensions.minimumSize.width - dimensions.viewportInnerSize.width);
|
|
174
178
|
|
|
@@ -188,7 +192,7 @@ export const useGridVirtualScroller = () => {
|
|
|
188
192
|
const columnScroll = Math.abs(scrollPosition.current.left - previousContextScrollPosition.current.left);
|
|
189
193
|
|
|
190
194
|
// PERF: use the computed minimum column width instead of a static one
|
|
191
|
-
const didCrossThreshold = rowScroll >=
|
|
195
|
+
const didCrossThreshold = rowScroll >= rowHeight || columnScroll >= MINIMUM_COLUMN_WIDTH;
|
|
192
196
|
const didChangeDirection = scrollCache.direction !== direction;
|
|
193
197
|
const shouldUpdate = didCrossThreshold || didChangeDirection;
|
|
194
198
|
if (!shouldUpdate) {
|
|
@@ -210,7 +214,7 @@ export const useGridVirtualScroller = () => {
|
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
216
|
scrollCache.direction = direction;
|
|
213
|
-
scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx,
|
|
217
|
+
scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
|
|
214
218
|
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
215
219
|
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
216
220
|
|
|
@@ -222,6 +226,10 @@ export const useGridVirtualScroller = () => {
|
|
|
222
226
|
return nextRenderContext;
|
|
223
227
|
});
|
|
224
228
|
const forceUpdateRenderContext = () => {
|
|
229
|
+
// skip update if dimensions are not ready and virtualization is enabled
|
|
230
|
+
if (!gridDimensionsSelector(apiRef.current.state).isReady && (enabledForRows || enabledForColumns)) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
225
233
|
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
226
234
|
const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
227
235
|
// Reset the frozen context when the render context changes, see the illustration in https://github.com/mui/mui-x/pull/12353
|
|
@@ -250,7 +258,12 @@ export const useGridVirtualScroller = () => {
|
|
|
250
258
|
if (!params.rows && !currentPage.range) {
|
|
251
259
|
return [];
|
|
252
260
|
}
|
|
253
|
-
|
|
261
|
+
let baseRenderContext = renderContext;
|
|
262
|
+
if (params.renderContext) {
|
|
263
|
+
baseRenderContext = params.renderContext;
|
|
264
|
+
baseRenderContext.firstColumnIndex = renderContext.firstColumnIndex;
|
|
265
|
+
baseRenderContext.lastColumnIndex = renderContext.lastColumnIndex;
|
|
266
|
+
}
|
|
254
267
|
const isLastSection = !hasBottomPinnedRows && params.position === undefined || hasBottomPinnedRows && params.position === 'bottom';
|
|
255
268
|
const isPinnedSection = params.position !== undefined;
|
|
256
269
|
let rowIndexOffset;
|
|
@@ -344,7 +357,7 @@ export const useGridVirtualScroller = () => {
|
|
|
344
357
|
}
|
|
345
358
|
}
|
|
346
359
|
let currentRenderContext = baseRenderContext;
|
|
347
|
-
if (
|
|
360
|
+
if (frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
|
|
348
361
|
currentRenderContext = frozenContext.current;
|
|
349
362
|
}
|
|
350
363
|
const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
|
|
@@ -359,7 +372,7 @@ export const useGridVirtualScroller = () => {
|
|
|
359
372
|
index: rowIndex,
|
|
360
373
|
selected: isSelected,
|
|
361
374
|
offsetLeft: offsetLeft,
|
|
362
|
-
columnsTotalWidth:
|
|
375
|
+
columnsTotalWidth: columnsTotalWidth,
|
|
363
376
|
rowHeight: baseRowHeight,
|
|
364
377
|
pinnedColumns: pinnedColumns,
|
|
365
378
|
visibleColumns: visibleColumns,
|
|
@@ -370,8 +383,8 @@ export const useGridVirtualScroller = () => {
|
|
|
370
383
|
isLastVisible: isLastVisible,
|
|
371
384
|
isNotVisible: isVirtualFocusRow,
|
|
372
385
|
showBottomBorder: showBottomBorder,
|
|
373
|
-
scrollbarWidth:
|
|
374
|
-
gridHasFiller:
|
|
386
|
+
scrollbarWidth: verticalScrollbarWidth,
|
|
387
|
+
gridHasFiller: gridHasFiller
|
|
375
388
|
}, rowProps), id));
|
|
376
389
|
if (isVirtualFocusRow) {
|
|
377
390
|
return;
|
|
@@ -388,7 +401,6 @@ export const useGridVirtualScroller = () => {
|
|
|
388
401
|
});
|
|
389
402
|
return rows;
|
|
390
403
|
};
|
|
391
|
-
const needsHorizontalScrollbar = outerSize.width && columnsTotalWidth > outerSize.width;
|
|
392
404
|
const scrollerStyle = React.useMemo(() => ({
|
|
393
405
|
overflowX: !needsHorizontalScrollbar || listView ? 'hidden' : undefined,
|
|
394
406
|
overflowY: rootProps.autoHeight ? 'hidden' : undefined
|
|
@@ -424,14 +436,11 @@ export const useGridVirtualScroller = () => {
|
|
|
424
436
|
scrollerRef.current.scrollLeft = 0;
|
|
425
437
|
}
|
|
426
438
|
}, [listView, scrollerRef]);
|
|
427
|
-
useRunOnce(
|
|
428
|
-
const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
|
|
429
|
-
const initialRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
|
|
430
|
-
updateRenderContext(initialRenderContext);
|
|
439
|
+
useRunOnce(renderContext !== EMPTY_RENDER_CONTEXT, () => {
|
|
431
440
|
apiRef.current.publishEvent('scrollPositionChange', {
|
|
432
441
|
top: scrollPosition.current.top,
|
|
433
442
|
left: scrollPosition.current.left,
|
|
434
|
-
renderContext
|
|
443
|
+
renderContext
|
|
435
444
|
});
|
|
436
445
|
isRenderContextReady.current = true;
|
|
437
446
|
if (rootProps.initialState?.scroll && scrollerRef.current) {
|
|
@@ -484,9 +493,9 @@ export const useGridVirtualScroller = () => {
|
|
|
484
493
|
apiRef.current.register('private', {
|
|
485
494
|
updateRenderContext: forceUpdateRenderContext
|
|
486
495
|
});
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
496
|
+
useGridApiOptionHandler(apiRef, 'sortedRowsSet', forceUpdateRenderContext);
|
|
497
|
+
useGridApiOptionHandler(apiRef, 'paginationModelChange', forceUpdateRenderContext);
|
|
498
|
+
useGridApiOptionHandler(apiRef, 'columnsChange', forceUpdateRenderContext);
|
|
490
499
|
return {
|
|
491
500
|
renderContext,
|
|
492
501
|
setPanels,
|
|
@@ -522,9 +531,16 @@ export const useGridVirtualScroller = () => {
|
|
|
522
531
|
ref: scrollbarHorizontalRef,
|
|
523
532
|
role: 'presentation',
|
|
524
533
|
scrollPosition
|
|
534
|
+
}),
|
|
535
|
+
getScrollAreaProps: () => ({
|
|
536
|
+
scrollPosition
|
|
525
537
|
})
|
|
526
538
|
};
|
|
527
539
|
};
|
|
540
|
+
// dimension selectors
|
|
541
|
+
function needsHorizontalScrollbarSelector(state) {
|
|
542
|
+
return state.dimensions.viewportOuterSize.width > 0 && state.dimensions.columnsTotalWidth > state.dimensions.viewportOuterSize.width;
|
|
543
|
+
}
|
|
528
544
|
function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
|
|
529
545
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
530
546
|
const currentPage = getVisibleRows(apiRef, rootProps);
|
|
@@ -5,6 +5,13 @@ import type { OutputSelector, OutputSelectorV8 } from '../../utils/createSelecto
|
|
|
5
5
|
type Selector<Api extends GridApiCommon, Args, T> = ((state: Api['state']) => T) | OutputSelectorV8<Api['state'], Args, T>;
|
|
6
6
|
export declare const objectShallowCompare: typeof fastObjectShallowCompare;
|
|
7
7
|
export declare const argsEqual: (prev: any, curr: any) => boolean;
|
|
8
|
+
type Refs<T> = {
|
|
9
|
+
state: T;
|
|
10
|
+
equals: <U = T>(a: U, b: U) => boolean;
|
|
11
|
+
selector: Selector<any, any, T>;
|
|
12
|
+
args: any;
|
|
13
|
+
subscription: undefined | (() => void);
|
|
14
|
+
};
|
|
8
15
|
export declare const useGridSelector: <Api extends GridApiCommon, T>(apiRef: RefObject<Api>, selector: ((state: Api["state"]) => T) | OutputSelector<Api["state"], T>, equals?: (a: T, b: T) => boolean) => T;
|
|
9
|
-
export declare const useGridSelectorV8: <Api extends GridApiCommon, Args, T>(apiRef: RefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: <
|
|
16
|
+
export declare const useGridSelectorV8: <Api extends GridApiCommon, Args, T>(apiRef: RefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: Refs<T>["equals"]) => T;
|
|
10
17
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
|
|
3
3
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
4
5
|
import { useLazyRef } from "./useLazyRef.js";
|
|
5
|
-
import { useOnMount } from "./useOnMount.js";
|
|
6
6
|
function isOutputSelector(selector) {
|
|
7
7
|
return selector.acceptsApiRef;
|
|
8
8
|
}
|
|
@@ -42,8 +42,10 @@ const createRefs = () => ({
|
|
|
42
42
|
state: null,
|
|
43
43
|
equals: null,
|
|
44
44
|
selector: null,
|
|
45
|
-
args:
|
|
45
|
+
args: undefined
|
|
46
46
|
});
|
|
47
|
+
const EMPTY = [];
|
|
48
|
+
const emptyGetSnapshot = () => null;
|
|
47
49
|
|
|
48
50
|
// TODO v8: Remove this function
|
|
49
51
|
export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
|
|
@@ -60,15 +62,31 @@ export const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
|
|
|
60
62
|
refs.current.state = state;
|
|
61
63
|
refs.current.equals = equals;
|
|
62
64
|
refs.current.selector = selector;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
const subscribe = React.useCallback(() => {
|
|
66
|
+
if (refs.current.subscription) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
refs.current.subscription = apiRef.current.store.subscribe(() => {
|
|
65
70
|
const newState = applySelector(apiRef, refs.current.selector);
|
|
66
71
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
67
72
|
refs.current.state = newState;
|
|
68
73
|
setState(newState);
|
|
69
74
|
}
|
|
70
75
|
});
|
|
71
|
-
|
|
76
|
+
return null;
|
|
77
|
+
},
|
|
78
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
79
|
+
EMPTY);
|
|
80
|
+
const unsubscribe = React.useCallback(() => {
|
|
81
|
+
return () => {
|
|
82
|
+
if (refs.current.subscription) {
|
|
83
|
+
refs.current.subscription();
|
|
84
|
+
refs.current.subscription = undefined;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
+
}, EMPTY);
|
|
89
|
+
useSyncExternalStore(unsubscribe, subscribe, emptyGetSnapshot);
|
|
72
90
|
return state;
|
|
73
91
|
};
|
|
74
92
|
|
|
@@ -96,14 +114,30 @@ export const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = d
|
|
|
96
114
|
setState(newState);
|
|
97
115
|
}
|
|
98
116
|
}
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
const subscribe = React.useCallback(() => {
|
|
118
|
+
if (refs.current.subscription) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
refs.current.subscription = apiRef.current.store.subscribe(() => {
|
|
101
122
|
const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
|
|
102
123
|
if (!refs.current.equals(refs.current.state, newState)) {
|
|
103
124
|
refs.current.state = newState;
|
|
104
125
|
setState(newState);
|
|
105
126
|
}
|
|
106
127
|
});
|
|
107
|
-
|
|
128
|
+
return null;
|
|
129
|
+
},
|
|
130
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
131
|
+
EMPTY);
|
|
132
|
+
const unsubscribe = React.useCallback(() => {
|
|
133
|
+
return () => {
|
|
134
|
+
if (refs.current.subscription) {
|
|
135
|
+
refs.current.subscription();
|
|
136
|
+
refs.current.subscription = undefined;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
140
|
+
}, EMPTY);
|
|
141
|
+
useSyncExternalStore(unsubscribe, subscribe, emptyGetSnapshot);
|
|
108
142
|
return state;
|
|
109
143
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsSSR: () => boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
2
|
+
const emptySubscribe = () => () => {};
|
|
3
|
+
const clientSnapshot = () => false;
|
|
4
|
+
const serverSnapshot = () => true;
|
|
5
|
+
export const useIsSSR = () => useSyncExternalStore(emptySubscribe, clientSnapshot, serverSnapshot);
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { useGridDensity, densityStateInitializer } from '../hooks/features/densi
|
|
|
30
30
|
export { useGridCsvExport } from '../hooks/features/export/useGridCsvExport';
|
|
31
31
|
export { useGridPrintExport } from '../hooks/features/export/useGridPrintExport';
|
|
32
32
|
export { useGridFilter, filterStateInitializer } from '../hooks/features/filter/useGridFilter';
|
|
33
|
+
export { defaultGridFilterLookup } from '../hooks/features/filter/gridFilterState';
|
|
33
34
|
export { passFilterLogic } from '../hooks/features/filter/gridFilterUtils';
|
|
34
35
|
export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, } from '../hooks/features/filter/gridFilterSelector';
|
|
35
36
|
export { isSingleSelectColDef } from '../components/panel/filterPanel/filterPanelUtils';
|
|
@@ -52,7 +53,6 @@ export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
|
|
|
52
53
|
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED } from '../hooks/features/rows/gridRowsUtils';
|
|
53
54
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, } from '../hooks/features/rows/gridRowsSelector';
|
|
54
55
|
export { headerFilteringStateInitializer, useGridHeaderFiltering, } from '../hooks/features/headerFiltering/useGridHeaderFiltering';
|
|
55
|
-
export { calculatePinnedRowsHeight } from '../hooks/features/rows/gridRowsUtils';
|
|
56
56
|
export { useGridRowSelection, rowSelectionStateInitializer, } from '../hooks/features/rowSelection/useGridRowSelection';
|
|
57
57
|
export { useGridRowSelectionPreProcessors } from '../hooks/features/rowSelection/useGridRowSelectionPreProcessors';
|
|
58
58
|
export { useGridSorting, sortingStateInitializer } from '../hooks/features/sorting/useGridSorting';
|
|
@@ -61,6 +61,7 @@ export { gridSortedRowIndexLookupSelector } from '../hooks/features/sorting/grid
|
|
|
61
61
|
export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
|
|
62
62
|
export { useGridEvents } from '../hooks/features/events/useGridEvents';
|
|
63
63
|
export { dimensionsStateInitializer, useGridDimensions, } from '../hooks/features/dimensions/useGridDimensions';
|
|
64
|
+
export * from '../hooks/features/dimensions/gridDimensionsSelectors';
|
|
64
65
|
export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
|
|
65
66
|
export type { GridRestoreStatePreProcessingContext } from '../hooks/features/statePersistence/gridStatePersistenceInterface';
|
|
66
67
|
export { useGridVirtualScroller, EMPTY_DETAIL_PANELS, } from '../hooks/features/virtualization/useGridVirtualScroller';
|
package/internals/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { useGridDensity, densityStateInitializer } from "../hooks/features/densi
|
|
|
22
22
|
export { useGridCsvExport } from "../hooks/features/export/useGridCsvExport.js";
|
|
23
23
|
export { useGridPrintExport } from "../hooks/features/export/useGridPrintExport.js";
|
|
24
24
|
export { useGridFilter, filterStateInitializer } from "../hooks/features/filter/useGridFilter.js";
|
|
25
|
+
export { defaultGridFilterLookup } from "../hooks/features/filter/gridFilterState.js";
|
|
25
26
|
export { passFilterLogic } from "../hooks/features/filter/gridFilterUtils.js";
|
|
26
27
|
export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector } from "../hooks/features/filter/gridFilterSelector.js";
|
|
27
28
|
export { isSingleSelectColDef } from "../components/panel/filterPanel/filterPanelUtils.js";
|
|
@@ -42,7 +43,6 @@ export { useGridParamsApi } from "../hooks/features/rows/useGridParamsApi.js";
|
|
|
42
43
|
export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED } from "../hooks/features/rows/gridRowsUtils.js";
|
|
43
44
|
export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector } from "../hooks/features/rows/gridRowsSelector.js";
|
|
44
45
|
export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
|
|
45
|
-
export { calculatePinnedRowsHeight } from "../hooks/features/rows/gridRowsUtils.js";
|
|
46
46
|
export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
|
|
47
47
|
export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
|
|
48
48
|
export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
|
|
@@ -50,6 +50,7 @@ export { gridSortedRowIndexLookupSelector } from "../hooks/features/sorting/grid
|
|
|
50
50
|
export { useGridScroll } from "../hooks/features/scroll/useGridScroll.js";
|
|
51
51
|
export { useGridEvents } from "../hooks/features/events/useGridEvents.js";
|
|
52
52
|
export { dimensionsStateInitializer, useGridDimensions } from "../hooks/features/dimensions/useGridDimensions.js";
|
|
53
|
+
export * from "../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
53
54
|
export { useGridStatePersistence } from "../hooks/features/statePersistence/useGridStatePersistence.js";
|
|
54
55
|
export { useGridVirtualScroller, EMPTY_DETAIL_PANELS } from "../hooks/features/virtualization/useGridVirtualScroller.js";
|
|
55
56
|
export * from "../hooks/features/virtualization/index.js";
|
|
@@ -401,6 +401,12 @@ export interface GridControlledStateReasonLookup {
|
|
|
401
401
|
pagination: 'setPaginationModel' | 'stateRestorePreProcessing';
|
|
402
402
|
}
|
|
403
403
|
export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEventLookup, GridHeaderFilterEventLookup, GridColumnGroupHeaderEventLookup, GridCellEventLookup, GridControlledStateEventLookup {
|
|
404
|
+
/**
|
|
405
|
+
* Fired when rootElementRef.current becomes available.
|
|
406
|
+
*/
|
|
407
|
+
rootMount: {
|
|
408
|
+
params: HTMLElement;
|
|
409
|
+
};
|
|
404
410
|
/**
|
|
405
411
|
* Fired when the grid is unmounted.
|
|
406
412
|
*/
|
|
@@ -41,7 +41,6 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
41
41
|
/**
|
|
42
42
|
* Register all state initializers here.
|
|
43
43
|
*/
|
|
44
|
-
useGridInitializeState(dimensionsStateInitializer, apiRef, props);
|
|
45
44
|
useGridInitializeState(rowSelectionStateInitializer, apiRef, props);
|
|
46
45
|
useGridInitializeState(columnsStateInitializer, apiRef, props);
|
|
47
46
|
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
@@ -54,10 +53,11 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
54
53
|
useGridInitializeState(rowSpanningStateInitializer, apiRef, props);
|
|
55
54
|
useGridInitializeState(densityStateInitializer, apiRef, props);
|
|
56
55
|
useGridInitializeState(columnResizeStateInitializer, apiRef, props);
|
|
57
|
-
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
58
56
|
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
59
57
|
useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
|
|
60
58
|
useGridInitializeState(virtualizationStateInitializer, apiRef, props);
|
|
59
|
+
useGridInitializeState(dimensionsStateInitializer, apiRef, props);
|
|
60
|
+
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
61
61
|
useGridInitializeState(listViewStateInitializer, apiRef, props);
|
|
62
62
|
useGridKeyboardNavigation(apiRef, props);
|
|
63
63
|
useGridRowSelection(apiRef, props);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
5
|
const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "pinnedColumns", "offsetLeft", "columnsTotalWidth", "firstColumnIndex", "lastColumnIndex", "focusedColumnIndex", "isFirstVisible", "isLastVisible", "isNotVisible", "showBottomBorder", "scrollbarWidth", "gridHasFiller", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
|
|
@@ -78,7 +80,10 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
|
|
|
78
80
|
const isRowReorderingEnabled = useGridSelectorV8(apiRef, isRowReorderingEnabledSelector, rowReordering);
|
|
79
81
|
const handleRef = useForkRef(ref, refProp);
|
|
80
82
|
const rowNode = apiRef.current.getRowNode(rowId);
|
|
81
|
-
const editing = useGridSelectorV8(apiRef, gridRowIsEditingSelector,
|
|
83
|
+
const editing = useGridSelectorV8(apiRef, gridRowIsEditingSelector, {
|
|
84
|
+
rowId,
|
|
85
|
+
editMode: rootProps.editMode
|
|
86
|
+
});
|
|
82
87
|
const editable = rootProps.editMode === GridEditModes.Row;
|
|
83
88
|
const hasFocusCell = focusedColumnIndex !== undefined;
|
|
84
89
|
const hasVirtualFocusCellLeft = hasFocusCell && focusedColumnIndex >= pinnedColumns.left.length && focusedColumnIndex < firstColumnIndex;
|
|
@@ -296,7 +301,8 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
|
|
|
296
301
|
role: "presentation",
|
|
297
302
|
className: clsx(gridClasses.cell, gridClasses.cellEmpty)
|
|
298
303
|
}), rightCells, scrollbarWidth !== 0 && /*#__PURE__*/_jsx(ScrollbarFiller, {
|
|
299
|
-
pinnedRight: pinnedColumns.right.length > 0
|
|
304
|
+
pinnedRight: pinnedColumns.right.length > 0,
|
|
305
|
+
borderTop: !isFirstVisible
|
|
300
306
|
})]
|
|
301
307
|
}));
|
|
302
308
|
});
|
|
@@ -8,12 +8,12 @@ import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
|
|
|
8
8
|
import { getDataGridUtilityClass, gridClasses } from "../constants/index.js";
|
|
9
9
|
import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
|
|
10
10
|
import { useGridApiEventHandler } from "../hooks/utils/useGridApiEventHandler.js";
|
|
11
|
-
import { useGridSelector } from "../hooks/utils/useGridSelector.js";
|
|
12
|
-
import { gridDimensionsSelector } from "../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
11
|
+
import { useGridSelector, useGridSelectorV8 } from "../hooks/utils/useGridSelector.js";
|
|
12
|
+
import { gridDimensionsSelector, gridColumnsTotalWidthSelector } from "../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
13
13
|
import { gridDensityFactorSelector } from "../hooks/features/density/densitySelector.js";
|
|
14
|
-
import { gridColumnsTotalWidthSelector } from "../hooks/features/columns/gridColumnsSelector.js";
|
|
15
14
|
import { useTimeout } from "../hooks/utils/useTimeout.js";
|
|
16
15
|
import { getTotalHeaderHeight } from "../hooks/features/columns/gridColumnsUtils.js";
|
|
16
|
+
import { createSelectorV8 } from "../utils/createSelector.js";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
const CLIFF = 1;
|
|
19
19
|
const SLOP = 1.5;
|
|
@@ -48,21 +48,38 @@ const GridScrollAreaRawRoot = styled('div', {
|
|
|
48
48
|
right: 0
|
|
49
49
|
}
|
|
50
50
|
}));
|
|
51
|
-
|
|
51
|
+
const offsetSelector = createSelectorV8(gridDimensionsSelector, (dimensions, direction) => {
|
|
52
|
+
if (direction === 'left') {
|
|
53
|
+
return dimensions.leftPinnedWidth;
|
|
54
|
+
}
|
|
55
|
+
if (direction === 'right') {
|
|
56
|
+
return dimensions.rightPinnedWidth + (dimensions.hasScrollX ? dimensions.scrollbarSize : 0);
|
|
57
|
+
}
|
|
58
|
+
return 0;
|
|
59
|
+
});
|
|
60
|
+
function GridScrollAreaWrapper(props) {
|
|
61
|
+
const apiRef = useGridApiContext();
|
|
62
|
+
const [dragging, setDragging] = React.useState(false);
|
|
63
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragStart', () => setDragging(true));
|
|
64
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', () => setDragging(false));
|
|
65
|
+
if (!dragging) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/_jsx(GridScrollAreaContent, _extends({}, props));
|
|
69
|
+
}
|
|
70
|
+
function GridScrollAreaContent(props) {
|
|
52
71
|
const {
|
|
53
|
-
scrollDirection
|
|
72
|
+
scrollDirection,
|
|
73
|
+
scrollPosition
|
|
54
74
|
} = props;
|
|
55
75
|
const rootRef = React.useRef(null);
|
|
56
76
|
const apiRef = useGridApiContext();
|
|
57
77
|
const timeout = useTimeout();
|
|
58
78
|
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
59
79
|
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
60
|
-
const
|
|
61
|
-
const scrollPosition = React.useRef({
|
|
62
|
-
left: 0,
|
|
63
|
-
top: 0
|
|
64
|
-
});
|
|
80
|
+
const sideOffset = useGridSelectorV8(apiRef, offsetSelector, scrollDirection);
|
|
65
81
|
const getCanScrollMore = () => {
|
|
82
|
+
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
66
83
|
if (scrollDirection === 'left') {
|
|
67
84
|
// Only render if the user has not reached yet the start of the list
|
|
68
85
|
return scrollPosition.current.left > 0;
|
|
@@ -74,7 +91,6 @@ function GridScrollAreaRaw(props) {
|
|
|
74
91
|
}
|
|
75
92
|
return false;
|
|
76
93
|
};
|
|
77
|
-
const [dragging, setDragging] = React.useState(false);
|
|
78
94
|
const [canScrollMore, setCanScrollMore] = React.useState(getCanScrollMore);
|
|
79
95
|
const rootProps = useGridRootProps();
|
|
80
96
|
const ownerState = _extends({}, rootProps, {
|
|
@@ -88,12 +104,11 @@ function GridScrollAreaRaw(props) {
|
|
|
88
104
|
top: totalHeaderHeight - headerHeight
|
|
89
105
|
};
|
|
90
106
|
if (scrollDirection === 'left') {
|
|
91
|
-
style.left =
|
|
107
|
+
style.left = sideOffset;
|
|
92
108
|
} else if (scrollDirection === 'right') {
|
|
93
|
-
style.right =
|
|
109
|
+
style.right = sideOffset;
|
|
94
110
|
}
|
|
95
|
-
const handleScrolling =
|
|
96
|
-
scrollPosition.current = newScrollPosition;
|
|
111
|
+
const handleScrolling = () => {
|
|
97
112
|
setCanScrollMore(getCanScrollMore);
|
|
98
113
|
};
|
|
99
114
|
const handleDragOver = useEventCallback(event => {
|
|
@@ -118,16 +133,8 @@ function GridScrollAreaRaw(props) {
|
|
|
118
133
|
});
|
|
119
134
|
});
|
|
120
135
|
});
|
|
121
|
-
const handleColumnHeaderDragStart = useEventCallback(() => {
|
|
122
|
-
setDragging(true);
|
|
123
|
-
});
|
|
124
|
-
const handleColumnHeaderDragEnd = useEventCallback(() => {
|
|
125
|
-
setDragging(false);
|
|
126
|
-
});
|
|
127
136
|
useGridApiEventHandler(apiRef, 'scrollPositionChange', handleScrolling);
|
|
128
|
-
|
|
129
|
-
useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleColumnHeaderDragEnd);
|
|
130
|
-
if (!dragging || !canScrollMore) {
|
|
137
|
+
if (!canScrollMore) {
|
|
131
138
|
return null;
|
|
132
139
|
}
|
|
133
140
|
return /*#__PURE__*/_jsx(GridScrollAreaRawRoot, {
|
|
@@ -138,4 +145,4 @@ function GridScrollAreaRaw(props) {
|
|
|
138
145
|
style: style
|
|
139
146
|
});
|
|
140
147
|
}
|
|
141
|
-
export const GridScrollArea = fastMemo(
|
|
148
|
+
export const GridScrollArea = fastMemo(GridScrollAreaWrapper);
|
|
@@ -8,8 +8,9 @@ import { useRtl } from '@mui/system/RtlProvider';
|
|
|
8
8
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
9
9
|
import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
|
|
10
10
|
import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
|
|
11
|
-
import { gridColumnPositionsSelector,
|
|
11
|
+
import { gridColumnPositionsSelector, gridDimensionsSelector, gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, useGridApiEventHandler, useGridSelector } from "../hooks/index.js";
|
|
12
12
|
import { PinnedColumnPosition } from "../internals/constants.js";
|
|
13
|
+
import { gridColumnsTotalWidthSelector } from "../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
13
14
|
import { getDataGridUtilityClass, gridClasses } from "../constants/gridClasses.js";
|
|
14
15
|
import { getPinnedCellOffset } from "../internals/utils/getPinnedCellOffset.js";
|
|
15
16
|
import { shouldCellShowLeftBorder, shouldCellShowRightBorder } from "../utils/cellBorderUtils.js";
|