@mui/x-data-grid 7.0.0-beta.5 → 7.0.0-beta.7
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 +252 -50
- package/DataGrid/DataGrid.js +44 -0
- package/DataGrid/useDataGridComponent.js +3 -0
- package/DataGrid/useDataGridProps.js +3 -2
- package/components/GridColumnHeaders.d.ts +1 -2
- package/components/GridColumnHeaders.js +6 -17
- package/components/GridHeaders.js +1 -4
- package/components/GridPagination.js +2 -7
- package/components/GridPinnedRows.d.ts +1 -2
- package/components/GridRow.d.ts +1 -1
- package/components/GridRow.js +9 -26
- package/components/GridScrollArea.d.ts +10 -0
- package/components/GridScrollArea.js +150 -0
- package/components/cell/GridCell.d.ts +7 -2
- package/components/cell/GridCell.js +14 -10
- package/components/columnHeaders/GridBaseColumnHeaders.js +1 -0
- package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -0
- package/components/columnHeaders/GridColumnGroupHeader.js +18 -8
- package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -0
- package/components/columnHeaders/GridColumnHeaderItem.js +21 -6
- package/components/columnHeaders/GridGenericColumnHeaderItem.d.ts +1 -0
- package/components/columnHeaders/GridGenericColumnHeaderItem.js +6 -5
- package/components/containers/GridRootStyles.js +12 -22
- package/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/components/virtualization/GridVirtualScroller.js +11 -4
- package/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/constants/gridClasses.d.ts +6 -32
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -1
- package/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +23 -7
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +186 -99
- package/hooks/features/columnResize/columnResizeSelector.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/hooks/features/columnResize/columnResizeState.d.ts +3 -0
- package/hooks/features/columnResize/columnResizeState.js +1 -0
- package/hooks/features/columnResize/gridColumnResizeApi.d.ts +44 -0
- package/hooks/features/columnResize/gridColumnResizeApi.js +10 -0
- package/hooks/features/columnResize/index.d.ts +3 -0
- package/hooks/features/columnResize/index.js +3 -0
- package/hooks/features/columnResize/useGridColumnResize.d.ts +10 -0
- package/hooks/features/columnResize/useGridColumnResize.js +563 -0
- package/hooks/features/columns/gridColumnsUtils.js +4 -1
- package/hooks/features/dimensions/useGridDimensions.js +5 -5
- package/hooks/features/editing/useGridCellEditing.js +21 -2
- package/hooks/features/export/useGridPrintExport.js +8 -7
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +1 -0
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +6 -0
- package/hooks/features/headerFiltering/useGridHeaderFiltering.js +30 -7
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +1 -0
- package/hooks/features/pagination/gridPaginationInterfaces.d.ts +19 -2
- package/hooks/features/pagination/gridPaginationSelector.d.ts +5 -0
- package/hooks/features/pagination/gridPaginationSelector.js +8 -2
- package/hooks/features/pagination/useGridPagination.d.ts +1 -6
- package/hooks/features/pagination/useGridPagination.js +9 -157
- package/hooks/features/pagination/useGridPaginationModel.d.ts +11 -0
- package/hooks/features/pagination/useGridPaginationModel.js +170 -0
- package/hooks/features/pagination/useGridRowCount.d.ts +8 -0
- package/hooks/features/pagination/useGridRowCount.js +97 -0
- package/hooks/features/rows/useGridParamsApi.js +6 -10
- package/hooks/features/scroll/useGridScroll.js +1 -1
- package/hooks/features/sorting/useGridSorting.js +2 -2
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +4 -4
- package/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -2
- package/hooks/features/virtualization/useGridVirtualScroller.js +6 -0
- package/hooks/utils/useLazyRef.d.ts +1 -2
- package/hooks/utils/useLazyRef.js +1 -11
- package/hooks/utils/useOnMount.d.ts +1 -2
- package/hooks/utils/useOnMount.js +1 -7
- package/hooks/utils/useTimeout.d.ts +1 -11
- package/hooks/utils/useTimeout.js +1 -36
- package/index.js +1 -1
- package/internals/index.d.ts +2 -2
- package/internals/index.js +2 -2
- package/internals/utils/getPinnedCellOffset.d.ts +3 -0
- package/internals/utils/getPinnedCellOffset.js +17 -0
- package/joy/joySlots.js +13 -52
- package/locales/jaJP.js +3 -4
- package/material/index.js +0 -2
- package/models/api/gridApiCommon.d.ts +2 -1
- package/models/api/gridCoreApi.d.ts +1 -5
- package/models/api/gridInfiniteLoaderApi.d.ts +6 -0
- package/models/api/gridInfiniteLoaderApi.js +1 -0
- package/models/events/gridEventLookup.d.ts +6 -0
- package/models/gridHeaderFilteringModel.d.ts +1 -0
- package/models/gridSlotsComponent.d.ts +0 -5
- package/models/gridStateCommunity.d.ts +2 -0
- package/models/params/gridScrollParams.d.ts +5 -3
- package/models/props/DataGridProps.d.ts +35 -1
- package/modern/DataGrid/DataGrid.js +44 -0
- package/modern/DataGrid/useDataGridComponent.js +3 -0
- package/modern/DataGrid/useDataGridProps.js +3 -2
- package/modern/components/GridColumnHeaders.js +6 -17
- package/modern/components/GridHeaders.js +1 -4
- package/modern/components/GridPagination.js +2 -4
- package/modern/components/GridRow.js +9 -26
- package/modern/components/GridScrollArea.js +150 -0
- package/modern/components/cell/GridCell.js +14 -10
- package/modern/components/columnHeaders/GridBaseColumnHeaders.js +1 -0
- package/modern/components/columnHeaders/GridColumnGroupHeader.js +18 -8
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +21 -6
- package/modern/components/columnHeaders/GridGenericColumnHeaderItem.js +6 -5
- package/modern/components/containers/GridRootStyles.js +12 -22
- package/modern/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/modern/components/virtualization/GridVirtualScroller.js +11 -4
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +184 -97
- package/modern/hooks/features/columnResize/columnResizeSelector.js +3 -0
- package/modern/hooks/features/columnResize/columnResizeState.js +1 -0
- package/modern/hooks/features/columnResize/gridColumnResizeApi.js +10 -0
- package/modern/hooks/features/columnResize/index.js +3 -0
- package/modern/hooks/features/columnResize/useGridColumnResize.js +553 -0
- package/modern/hooks/features/columns/gridColumnsUtils.js +4 -1
- package/modern/hooks/features/dimensions/useGridDimensions.js +5 -5
- package/modern/hooks/features/editing/useGridCellEditing.js +21 -2
- package/modern/hooks/features/export/useGridPrintExport.js +8 -7
- package/modern/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +3 -0
- package/modern/hooks/features/headerFiltering/useGridHeaderFiltering.js +21 -2
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/pagination/gridPaginationSelector.js +8 -2
- package/modern/hooks/features/pagination/useGridPagination.js +8 -149
- package/modern/hooks/features/pagination/useGridPaginationModel.js +165 -0
- package/modern/hooks/features/pagination/useGridRowCount.js +94 -0
- package/modern/hooks/features/rows/useGridParamsApi.js +6 -10
- package/modern/hooks/features/scroll/useGridScroll.js +1 -1
- package/modern/hooks/features/sorting/useGridSorting.js +2 -2
- package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +5 -0
- package/modern/hooks/utils/useLazyRef.js +1 -11
- package/modern/hooks/utils/useOnMount.js +1 -7
- package/modern/hooks/utils/useTimeout.js +1 -36
- package/modern/index.js +1 -1
- package/modern/internals/index.js +2 -2
- package/modern/internals/utils/getPinnedCellOffset.js +17 -0
- package/modern/joy/joySlots.js +11 -50
- package/modern/locales/jaJP.js +3 -4
- package/modern/material/index.js +0 -2
- package/modern/models/api/gridInfiniteLoaderApi.js +1 -0
- package/modern/utils/cellBorderUtils.js +8 -0
- package/modern/utils/createSelector.js +12 -20
- package/modern/utils/domUtils.js +144 -0
- package/node/DataGrid/DataGrid.js +44 -0
- package/node/DataGrid/useDataGridComponent.js +3 -0
- package/node/DataGrid/useDataGridProps.js +3 -2
- package/node/components/GridColumnHeaders.js +6 -16
- package/node/components/GridHeaders.js +1 -4
- package/node/components/GridPagination.js +1 -3
- package/node/components/GridRow.js +8 -25
- package/node/components/GridScrollArea.js +158 -0
- package/node/components/cell/GridCell.js +15 -11
- package/node/components/columnHeaders/GridBaseColumnHeaders.js +1 -0
- package/node/components/columnHeaders/GridColumnGroupHeader.js +18 -8
- package/node/components/columnHeaders/GridColumnHeaderItem.js +21 -6
- package/node/components/columnHeaders/GridGenericColumnHeaderItem.js +6 -5
- package/node/components/containers/GridRootStyles.js +12 -22
- package/node/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/node/components/virtualization/GridVirtualScroller.js +11 -4
- package/node/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +190 -103
- package/node/hooks/features/columnResize/columnResizeSelector.js +10 -0
- package/node/hooks/features/columnResize/columnResizeState.js +5 -0
- package/node/hooks/features/columnResize/gridColumnResizeApi.js +16 -0
- package/node/hooks/features/columnResize/index.js +38 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +564 -0
- package/node/hooks/features/columns/gridColumnsUtils.js +4 -1
- package/node/hooks/features/dimensions/useGridDimensions.js +5 -5
- package/node/hooks/features/editing/useGridCellEditing.js +21 -2
- package/node/hooks/features/export/useGridPrintExport.js +8 -7
- package/node/hooks/features/headerFiltering/gridHeaderFilteringSelectors.js +4 -1
- package/node/hooks/features/headerFiltering/useGridHeaderFiltering.js +21 -2
- package/node/hooks/features/index.js +11 -0
- package/node/hooks/features/pagination/gridPaginationSelector.js +8 -2
- package/node/hooks/features/pagination/useGridPagination.js +9 -153
- package/node/hooks/features/pagination/useGridPaginationModel.js +176 -0
- package/node/hooks/features/pagination/useGridRowCount.js +103 -0
- package/node/hooks/features/rows/useGridParamsApi.js +6 -10
- package/node/hooks/features/scroll/useGridScroll.js +1 -1
- package/node/hooks/features/sorting/useGridSorting.js +2 -2
- package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +5 -0
- package/node/hooks/utils/useLazyRef.js +7 -13
- package/node/hooks/utils/useOnMount.js +8 -10
- package/node/hooks/utils/useTimeout.js +7 -37
- package/node/index.js +1 -1
- package/node/internals/index.js +15 -15
- package/node/internals/utils/getPinnedCellOffset.js +24 -0
- package/node/joy/joySlots.js +11 -50
- package/node/locales/jaJP.js +3 -4
- package/node/material/index.js +0 -2
- package/node/models/api/gridInfiniteLoaderApi.js +5 -0
- package/node/utils/cellBorderUtils.js +16 -0
- package/node/utils/createSelector.js +14 -23
- package/node/utils/domUtils.js +155 -0
- package/package.json +2 -2
- package/utils/cellBorderUtils.d.ts +3 -0
- package/utils/cellBorderUtils.js +8 -0
- package/utils/createSelector.d.ts +0 -1
- package/utils/createSelector.js +12 -22
- package/utils/domUtils.d.ts +14 -1
- package/utils/domUtils.js +147 -0
- package/components/columnHeaders/GridColumnHeadersInner.d.ts +0 -8
- package/components/columnHeaders/GridColumnHeadersInner.js +0 -58
- package/modern/components/columnHeaders/GridColumnHeadersInner.js +0 -58
- package/node/components/columnHeaders/GridColumnHeadersInner.js +0 -67
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
firstRowIndex: number;
|
|
3
|
-
lastRowIndex: number;
|
|
1
|
+
export interface GridColumnsRenderContext {
|
|
4
2
|
firstColumnIndex: number;
|
|
5
3
|
lastColumnIndex: number;
|
|
6
4
|
}
|
|
5
|
+
export interface GridRenderContext extends GridColumnsRenderContext {
|
|
6
|
+
firstRowIndex: number;
|
|
7
|
+
lastRowIndex: number;
|
|
8
|
+
}
|
|
7
9
|
export interface GridScrollParams {
|
|
8
10
|
left: number;
|
|
9
11
|
top: number;
|
|
@@ -24,6 +24,7 @@ import { GridColumnVisibilityModel } from '../../hooks/features/columns/gridColu
|
|
|
24
24
|
import { GridCellModesModel, GridRowModesModel } from '../api/gridEditingApi';
|
|
25
25
|
import { GridColumnGroupingModel } from '../gridColumnGrouping';
|
|
26
26
|
import { GridPaginationModel } from '../gridPaginationProps';
|
|
27
|
+
import type { GridAutosizeOptions } from '../../hooks/features/columnResize';
|
|
27
28
|
export interface GridExperimentalFeatures {
|
|
28
29
|
/**
|
|
29
30
|
* Emits a warning if the cell receives focus without also syncing the focus state.
|
|
@@ -46,7 +47,7 @@ export interface DataGridProcessedProps<R extends GridValidRowModel = any> exten
|
|
|
46
47
|
* The props of the `DataGrid` component after the pre-processing phase that the user should not be able to override.
|
|
47
48
|
* Those are usually used in feature-hook for which the pro-plan has more advanced features (eg: multi-sorting, multi-filtering, ...).
|
|
48
49
|
*/
|
|
49
|
-
export type DataGridForcedPropsKey = 'checkboxSelectionVisibleOnly' | 'disableMultipleColumnsFiltering' | 'disableMultipleColumnsSorting' | 'disableColumnReorder' | '
|
|
50
|
+
export type DataGridForcedPropsKey = 'checkboxSelectionVisibleOnly' | 'disableMultipleColumnsFiltering' | 'disableMultipleColumnsSorting' | 'disableColumnReorder' | 'keepColumnPositionIfDraggedOutside' | 'throttleRowsMs' | 'hideFooterRowCount' | 'pagination' | 'signature';
|
|
50
51
|
/**
|
|
51
52
|
* The `DataGrid` options with a default value that must be merged with the value given through props.
|
|
52
53
|
*/
|
|
@@ -342,6 +343,16 @@ export interface DataGridPropsWithDefaultValues {
|
|
|
342
343
|
* @default 166
|
|
343
344
|
*/
|
|
344
345
|
rowPositionsDebounceMs: number;
|
|
346
|
+
/**
|
|
347
|
+
* If `true`, columns are autosized after the datagrid is mounted.
|
|
348
|
+
* @default false
|
|
349
|
+
*/
|
|
350
|
+
autosizeOnMount: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* If `true`, column autosizing on header separator double-click is disabled.
|
|
353
|
+
* @default false
|
|
354
|
+
*/
|
|
355
|
+
disableAutosize: boolean;
|
|
345
356
|
}
|
|
346
357
|
/**
|
|
347
358
|
* The `DataGrid` props with no default value.
|
|
@@ -559,6 +570,11 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
559
570
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
560
571
|
*/
|
|
561
572
|
onPaginationModelChange?: (model: GridPaginationModel, details: GridCallbackDetails) => void;
|
|
573
|
+
/**
|
|
574
|
+
* Callback fired when the row count has changed.
|
|
575
|
+
* @param {number} count Updated row count.
|
|
576
|
+
*/
|
|
577
|
+
onRowCountChange?: (count: number) => void;
|
|
562
578
|
/**
|
|
563
579
|
* Callback fired when the preferences panel is closed.
|
|
564
580
|
* @param {GridPreferencePanelParams} params With all properties from [[GridPreferencePanelParams]].
|
|
@@ -714,4 +730,22 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
|
|
|
714
730
|
* @param {string} data The data copied to the clipboard.
|
|
715
731
|
*/
|
|
716
732
|
onClipboardCopy?: GridEventListener<'clipboardCopy'>;
|
|
733
|
+
/**
|
|
734
|
+
* The options for autosize when user-initiated.
|
|
735
|
+
*/
|
|
736
|
+
autosizeOptions?: GridAutosizeOptions;
|
|
737
|
+
/**
|
|
738
|
+
* Callback fired while a column is being resized.
|
|
739
|
+
* @param {GridColumnResizeParams} params With all properties from [[GridColumnResizeParams]].
|
|
740
|
+
* @param {MuiEvent<React.MouseEvent>} event The event object.
|
|
741
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
742
|
+
*/
|
|
743
|
+
onColumnResize?: GridEventListener<'columnResize'>;
|
|
744
|
+
/**
|
|
745
|
+
* Callback fired when the width of a column is changed.
|
|
746
|
+
* @param {GridColumnResizeParams} params With all properties from [[GridColumnResizeParams]].
|
|
747
|
+
* @param {MuiEvent<React.MouseEvent>} event The event object.
|
|
748
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
749
|
+
*/
|
|
750
|
+
onColumnWidthChange?: GridEventListener<'columnWidthChange'>;
|
|
717
751
|
}
|
|
@@ -67,6 +67,21 @@ DataGridRaw.propTypes = {
|
|
|
67
67
|
* @default false
|
|
68
68
|
*/
|
|
69
69
|
autoPageSize: PropTypes.bool,
|
|
70
|
+
/**
|
|
71
|
+
* If `true`, columns are autosized after the datagrid is mounted.
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
autosizeOnMount: PropTypes.bool,
|
|
75
|
+
/**
|
|
76
|
+
* The options for autosize when user-initiated.
|
|
77
|
+
*/
|
|
78
|
+
autosizeOptions: PropTypes.shape({
|
|
79
|
+
columns: PropTypes.arrayOf(PropTypes.string),
|
|
80
|
+
expand: PropTypes.bool,
|
|
81
|
+
includeHeaders: PropTypes.bool,
|
|
82
|
+
includeOutliers: PropTypes.bool,
|
|
83
|
+
outliersFactor: PropTypes.number
|
|
84
|
+
}),
|
|
70
85
|
/**
|
|
71
86
|
* Controls the modes of the cells.
|
|
72
87
|
*/
|
|
@@ -115,6 +130,11 @@ DataGridRaw.propTypes = {
|
|
|
115
130
|
* @default "standard"
|
|
116
131
|
*/
|
|
117
132
|
density: PropTypes.oneOf(['comfortable', 'compact', 'standard']),
|
|
133
|
+
/**
|
|
134
|
+
* If `true`, column autosizing on header separator double-click is disabled.
|
|
135
|
+
* @default false
|
|
136
|
+
*/
|
|
137
|
+
disableAutosize: PropTypes.bool,
|
|
118
138
|
/**
|
|
119
139
|
* If `true`, column filters are disabled.
|
|
120
140
|
* @default false
|
|
@@ -125,6 +145,11 @@ DataGridRaw.propTypes = {
|
|
|
125
145
|
* @default false
|
|
126
146
|
*/
|
|
127
147
|
disableColumnMenu: PropTypes.bool,
|
|
148
|
+
/**
|
|
149
|
+
* If `true`, resizing columns is disabled.
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
disableColumnResize: PropTypes.bool,
|
|
128
153
|
/**
|
|
129
154
|
* If `true`, hiding/showing columns is disabled.
|
|
130
155
|
* @default false
|
|
@@ -422,12 +447,26 @@ DataGridRaw.propTypes = {
|
|
|
422
447
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
423
448
|
*/
|
|
424
449
|
onColumnOrderChange: PropTypes.func,
|
|
450
|
+
/**
|
|
451
|
+
* Callback fired while a column is being resized.
|
|
452
|
+
* @param {GridColumnResizeParams} params With all properties from [[GridColumnResizeParams]].
|
|
453
|
+
* @param {MuiEvent<React.MouseEvent>} event The event object.
|
|
454
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
455
|
+
*/
|
|
456
|
+
onColumnResize: PropTypes.func,
|
|
425
457
|
/**
|
|
426
458
|
* Callback fired when the column visibility model changes.
|
|
427
459
|
* @param {GridColumnVisibilityModel} model The new model.
|
|
428
460
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
429
461
|
*/
|
|
430
462
|
onColumnVisibilityModelChange: PropTypes.func,
|
|
463
|
+
/**
|
|
464
|
+
* Callback fired when the width of a column is changed.
|
|
465
|
+
* @param {GridColumnResizeParams} params With all properties from [[GridColumnResizeParams]].
|
|
466
|
+
* @param {MuiEvent<React.MouseEvent>} event The event object.
|
|
467
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
468
|
+
*/
|
|
469
|
+
onColumnWidthChange: PropTypes.func,
|
|
431
470
|
/**
|
|
432
471
|
* Callback fired when the Filter model changes before the filters are applied.
|
|
433
472
|
* @param {GridFilterModel} model With all properties from [[GridFilterModel]].
|
|
@@ -488,6 +527,11 @@ DataGridRaw.propTypes = {
|
|
|
488
527
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
489
528
|
*/
|
|
490
529
|
onRowClick: PropTypes.func,
|
|
530
|
+
/**
|
|
531
|
+
* Callback fired when the row count has changed.
|
|
532
|
+
* @param {number} count Updated row count.
|
|
533
|
+
*/
|
|
534
|
+
onRowCountChange: PropTypes.func,
|
|
491
535
|
/**
|
|
492
536
|
* Callback fired when a double click event comes from a row container element.
|
|
493
537
|
* @param {GridRowParams} params With all properties from [[RowParams]].
|
|
@@ -26,6 +26,7 @@ import { useGridStatePersistence } from '../hooks/features/statePersistence/useG
|
|
|
26
26
|
import { useGridColumnSpanning } from '../hooks/features/columns/useGridColumnSpanning';
|
|
27
27
|
import { useGridColumnGrouping, columnGroupsStateInitializer } from '../hooks/features/columnGrouping/useGridColumnGrouping';
|
|
28
28
|
import { useGridVirtualization, virtualizationStateInitializer } from '../hooks/features/virtualization';
|
|
29
|
+
import { columnResizeStateInitializer, useGridColumnResize } from '../hooks/features/columnResize/useGridColumnResize';
|
|
29
30
|
export const useDataGridComponent = (inputApiRef, props) => {
|
|
30
31
|
const apiRef = useGridInitialization(inputApiRef, props);
|
|
31
32
|
|
|
@@ -48,6 +49,7 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
48
49
|
useGridInitializeState(preferencePanelStateInitializer, apiRef, props);
|
|
49
50
|
useGridInitializeState(filterStateInitializer, apiRef, props);
|
|
50
51
|
useGridInitializeState(densityStateInitializer, apiRef, props);
|
|
52
|
+
useGridInitializeState(columnResizeStateInitializer, apiRef, props);
|
|
51
53
|
useGridInitializeState(paginationStateInitializer, apiRef, props);
|
|
52
54
|
useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
|
|
53
55
|
useGridInitializeState(columnMenuStateInitializer, apiRef, props);
|
|
@@ -66,6 +68,7 @@ export const useDataGridComponent = (inputApiRef, props) => {
|
|
|
66
68
|
useGridFilter(apiRef, props);
|
|
67
69
|
useGridSorting(apiRef, props);
|
|
68
70
|
useGridDensity(apiRef, props);
|
|
71
|
+
useGridColumnResize(apiRef, props);
|
|
69
72
|
useGridPagination(apiRef, props);
|
|
70
73
|
useGridRowsMeta(apiRef, props);
|
|
71
74
|
useGridScroll(apiRef, props);
|
|
@@ -13,7 +13,6 @@ const DATA_GRID_FORCED_PROPS = {
|
|
|
13
13
|
pagination: true,
|
|
14
14
|
checkboxSelectionVisibleOnly: false,
|
|
15
15
|
disableColumnReorder: true,
|
|
16
|
-
disableColumnResize: true,
|
|
17
16
|
keepColumnPositionIfDraggedOutside: false,
|
|
18
17
|
signature: 'DataGrid'
|
|
19
18
|
};
|
|
@@ -70,7 +69,9 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
|
|
|
70
69
|
keepColumnPositionIfDraggedOutside: false,
|
|
71
70
|
ignoreValueFormatterDuringExport: false,
|
|
72
71
|
clipboardCopyCellDelimiter: '\t',
|
|
73
|
-
rowPositionsDebounceMs: 166
|
|
72
|
+
rowPositionsDebounceMs: 166,
|
|
73
|
+
autosizeOnMount: false,
|
|
74
|
+
disableAutosize: false
|
|
74
75
|
};
|
|
75
76
|
const defaultSlots = DATA_GRID_DEFAULT_SLOTS_COMPONENTS;
|
|
76
77
|
export const useDataGridProps = inProps => {
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["
|
|
3
|
+
const _excluded = ["className", "visibleColumns", "sortColumnLookup", "filterColumnLookup", "columnHeaderTabIndexState", "columnGroupHeaderTabIndexState", "columnHeaderFocus", "columnGroupHeaderFocus", "headerGroupingMaxDepth", "columnMenuState", "columnVisibility", "columnGroupsHeaderStructure", "hasOtherElementInTabSequence"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { refType } from '@mui/utils';
|
|
7
6
|
import { fastMemo } from '../utils/fastMemo';
|
|
8
7
|
import { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
9
8
|
import { GridBaseColumnHeaders } from './columnHeaders/GridBaseColumnHeaders';
|
|
10
|
-
import { GridColumnHeadersInner } from './columnHeaders/GridColumnHeadersInner';
|
|
11
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
10
|
const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeaders(props, ref) {
|
|
14
11
|
const {
|
|
15
|
-
innerRef,
|
|
16
12
|
visibleColumns,
|
|
17
13
|
sortColumnLookup,
|
|
18
14
|
filterColumnLookup,
|
|
@@ -28,12 +24,10 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
28
24
|
} = props,
|
|
29
25
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
30
26
|
const {
|
|
31
|
-
isDragging,
|
|
32
27
|
getInnerProps,
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
getColumnHeadersRow,
|
|
29
|
+
getColumnGroupHeadersRows
|
|
35
30
|
} = useGridColumnHeaders({
|
|
36
|
-
innerRef,
|
|
37
31
|
visibleColumns,
|
|
38
32
|
sortColumnLookup,
|
|
39
33
|
filterColumnLookup,
|
|
@@ -47,14 +41,10 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
47
41
|
columnGroupsHeaderStructure,
|
|
48
42
|
hasOtherElementInTabSequence
|
|
49
43
|
});
|
|
50
|
-
return /*#__PURE__*/
|
|
44
|
+
return /*#__PURE__*/_jsxs(GridBaseColumnHeaders, _extends({
|
|
51
45
|
ref: ref
|
|
52
|
-
}, other, {
|
|
53
|
-
children:
|
|
54
|
-
isDragging: isDragging
|
|
55
|
-
}, getInnerProps(), {
|
|
56
|
-
children: [getColumnGroupHeaders(), getColumnHeaders()]
|
|
57
|
-
}))
|
|
46
|
+
}, other, getInnerProps(), {
|
|
47
|
+
children: [getColumnGroupHeadersRows(), getColumnHeadersRow()]
|
|
58
48
|
}));
|
|
59
49
|
});
|
|
60
50
|
process.env.NODE_ENV !== "production" ? GridColumnHeaders.propTypes = {
|
|
@@ -88,7 +78,6 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaders.propTypes = {
|
|
|
88
78
|
filterColumnLookup: PropTypes.object.isRequired,
|
|
89
79
|
hasOtherElementInTabSequence: PropTypes.bool.isRequired,
|
|
90
80
|
headerGroupingMaxDepth: PropTypes.number.isRequired,
|
|
91
|
-
innerRef: refType,
|
|
92
81
|
sortColumnLookup: PropTypes.object.isRequired,
|
|
93
82
|
visibleColumns: PropTypes.arrayOf(PropTypes.object).isRequired
|
|
94
83
|
} : void 0;
|
|
@@ -26,15 +26,12 @@ function GridHeaders() {
|
|
|
26
26
|
const columnVisibility = useGridSelector(apiRef, gridColumnVisibilityModelSelector);
|
|
27
27
|
const columnGroupsHeaderStructure = useGridSelector(apiRef, gridColumnGroupsHeaderStructureSelector);
|
|
28
28
|
const hasOtherElementInTabSequence = !(columnGroupHeaderTabIndexState === null && columnHeaderTabIndexState === null && cellTabIndexState === null);
|
|
29
|
-
const columnHeadersRef = React.useRef(null);
|
|
30
29
|
const columnsContainerRef = React.useRef(null);
|
|
31
30
|
apiRef.current.register('private', {
|
|
32
|
-
|
|
33
|
-
columnHeadersElementRef: columnHeadersRef
|
|
31
|
+
columnHeadersContainerRef: columnsContainerRef
|
|
34
32
|
});
|
|
35
33
|
return /*#__PURE__*/_jsx(rootProps.slots.columnHeaders, {
|
|
36
34
|
ref: columnsContainerRef,
|
|
37
|
-
innerRef: columnHeadersRef,
|
|
38
35
|
visibleColumns: visibleColumns,
|
|
39
36
|
filterColumnLookup: filterColumnLookup,
|
|
40
37
|
sortColumnLookup: sortColumnLookup,
|
|
@@ -5,8 +5,7 @@ import { styled } from '@mui/material/styles';
|
|
|
5
5
|
import { useGridSelector } from '../hooks/utils/useGridSelector';
|
|
6
6
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
7
7
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
8
|
-
import {
|
|
9
|
-
import { gridPaginationModelSelector } from '../hooks/features/pagination/gridPaginationSelector';
|
|
8
|
+
import { gridPaginationModelSelector, gridPaginationRowCountSelector } from '../hooks/features/pagination/gridPaginationSelector';
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
10
|
const GridPaginationRoot = styled(TablePagination)(({
|
|
12
11
|
theme
|
|
@@ -31,8 +30,7 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
|
|
|
31
30
|
const apiRef = useGridApiContext();
|
|
32
31
|
const rootProps = useGridRootProps();
|
|
33
32
|
const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
|
|
34
|
-
const
|
|
35
|
-
const rowCount = React.useMemo(() => rootProps.rowCount ?? visibleTopLevelRowCount ?? 0, [rootProps.rowCount, visibleTopLevelRowCount]);
|
|
33
|
+
const rowCount = useGridSelector(apiRef, gridPaginationRowCountSelector);
|
|
36
34
|
const lastPage = React.useMemo(() => {
|
|
37
35
|
const calculatedValue = Math.ceil(rowCount / (paginationModel.pageSize || 1)) - 1;
|
|
38
36
|
return Math.max(0, calculatedValue);
|
|
@@ -21,8 +21,9 @@ import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSele
|
|
|
21
21
|
import { gridRowMaximumTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
|
|
22
22
|
import { gridColumnGroupsHeaderMaxDepthSelector } from '../hooks/features/columnGrouping/gridColumnGroupsSelector';
|
|
23
23
|
import { gridEditRowsStateSelector } from '../hooks/features/editing/gridEditingSelectors';
|
|
24
|
-
import { PinnedPosition } from './cell/GridCell';
|
|
24
|
+
import { PinnedPosition, gridPinnedColumnPositionLookup } from './cell/GridCell';
|
|
25
25
|
import { GridScrollbarFillerCell as ScrollbarFiller } from './GridScrollbarFillerCell';
|
|
26
|
+
import { getPinnedCellOffset } from '../internals/utils/getPinnedCellOffset';
|
|
26
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
28
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
29
|
const useUtilityClasses = ownerState => {
|
|
@@ -215,7 +216,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
215
216
|
const rowStyle = _extends({}, styleProp, {
|
|
216
217
|
maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
|
|
217
218
|
// max-height doesn't support "auto"
|
|
218
|
-
minHeight
|
|
219
|
+
minHeight,
|
|
220
|
+
'--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
|
|
219
221
|
});
|
|
220
222
|
if (sizes?.spacingTop) {
|
|
221
223
|
const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
|
|
@@ -250,21 +252,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
250
252
|
}
|
|
251
253
|
const width = cellColSpanInfo?.cellProps.width ?? column.computedWidth;
|
|
252
254
|
const colSpan = cellColSpanInfo?.cellProps.colSpan ?? 1;
|
|
253
|
-
|
|
254
|
-
// FIXME: Why is the switch check exhaustiveness not validated with typescript-eslint?
|
|
255
|
-
// eslint-disable-next-line default-case
|
|
256
|
-
switch (pinnedPosition) {
|
|
257
|
-
case PinnedPosition.LEFT:
|
|
258
|
-
pinnedOffset = columnPositions[indexRelativeToAllColumns];
|
|
259
|
-
break;
|
|
260
|
-
case PinnedPosition.RIGHT:
|
|
261
|
-
pinnedOffset = dimensions.columnsTotalWidth - columnPositions[indexRelativeToAllColumns] - column.computedWidth + scrollbarWidth;
|
|
262
|
-
break;
|
|
263
|
-
case PinnedPosition.NONE:
|
|
264
|
-
case PinnedPosition.VIRTUAL:
|
|
265
|
-
pinnedOffset = 0;
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
255
|
+
const pinnedOffset = getPinnedCellOffset(gridPinnedColumnPositionLookup[pinnedPosition], column.computedWidth, indexRelativeToAllColumns, columnPositions, dimensions);
|
|
268
256
|
if (rowNode?.type === 'skeletonRow') {
|
|
269
257
|
return /*#__PURE__*/_jsx(slots.skeletonCell, {
|
|
270
258
|
width: width,
|
|
@@ -287,20 +275,17 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
287
275
|
column: column,
|
|
288
276
|
width: width,
|
|
289
277
|
rowId: rowId,
|
|
290
|
-
height: rowHeight,
|
|
291
278
|
align: column.align || 'left',
|
|
292
279
|
colIndex: indexRelativeToAllColumns,
|
|
293
280
|
colSpan: colSpan,
|
|
294
281
|
disableDragEvents: disableDragEvents,
|
|
295
282
|
editCellState: editCellState,
|
|
296
|
-
isNotVisible: cellIsNotVisible
|
|
297
|
-
}, slotProps?.cell, {
|
|
283
|
+
isNotVisible: cellIsNotVisible,
|
|
298
284
|
pinnedOffset: pinnedOffset,
|
|
299
285
|
pinnedPosition: pinnedPosition,
|
|
300
286
|
sectionIndex: indexInSection,
|
|
301
|
-
sectionLength: sectionLength
|
|
302
|
-
|
|
303
|
-
}), column.field);
|
|
287
|
+
sectionLength: sectionLength
|
|
288
|
+
}, slotProps?.cell), column.field);
|
|
304
289
|
};
|
|
305
290
|
|
|
306
291
|
/* Start of rendering */
|
|
@@ -359,9 +344,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
359
344
|
width: emptyCellWidth
|
|
360
345
|
}), rightCells.length > 0 && /*#__PURE__*/_jsx("div", {
|
|
361
346
|
role: "presentation",
|
|
362
|
-
|
|
363
|
-
flex: '1'
|
|
364
|
-
}
|
|
347
|
+
className: gridClasses.filler
|
|
365
348
|
}), rightCells, scrollbarWidth !== 0 && /*#__PURE__*/_jsx(ScrollbarFiller, {
|
|
366
349
|
pinnedRight: pinnedColumns.right.length > 0
|
|
367
350
|
})]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
6
|
+
import { styled } from '@mui/system';
|
|
7
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
8
|
+
import { getDataGridUtilityClass, gridClasses } from '../constants';
|
|
9
|
+
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
10
|
+
import { useGridApiEventHandler } from '../hooks/utils/useGridApiEventHandler';
|
|
11
|
+
import { useGridSelector } from '../hooks/utils/useGridSelector';
|
|
12
|
+
import { gridDimensionsSelector } from '../hooks/features/dimensions/gridDimensionsSelectors';
|
|
13
|
+
import { gridDensityFactorSelector } from '../hooks/features/density/densitySelector';
|
|
14
|
+
import { gridColumnsTotalWidthSelector } from '../hooks/features/columns/gridColumnsSelector';
|
|
15
|
+
import { useTimeout } from '../hooks/utils/useTimeout';
|
|
16
|
+
import { getTotalHeaderHeight } from '../hooks/features/columns/gridColumnsUtils';
|
|
17
|
+
import { fastMemo } from '../utils/fastMemo';
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
const CLIFF = 1;
|
|
20
|
+
const SLOP = 1.5;
|
|
21
|
+
const useUtilityClasses = ownerState => {
|
|
22
|
+
const {
|
|
23
|
+
scrollDirection,
|
|
24
|
+
classes
|
|
25
|
+
} = ownerState;
|
|
26
|
+
const slots = {
|
|
27
|
+
root: ['scrollArea', `scrollArea--${scrollDirection}`]
|
|
28
|
+
};
|
|
29
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
30
|
+
};
|
|
31
|
+
const GridScrollAreaRawRoot = styled('div', {
|
|
32
|
+
name: 'MuiDataGrid',
|
|
33
|
+
slot: 'ScrollArea',
|
|
34
|
+
overridesResolver: (props, styles) => [{
|
|
35
|
+
[`&.${gridClasses['scrollArea--left']}`]: styles['scrollArea--left']
|
|
36
|
+
}, {
|
|
37
|
+
[`&.${gridClasses['scrollArea--right']}`]: styles['scrollArea--right']
|
|
38
|
+
}, styles.scrollArea]
|
|
39
|
+
})(() => ({
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
top: 0,
|
|
42
|
+
zIndex: 101,
|
|
43
|
+
width: 20,
|
|
44
|
+
bottom: 0,
|
|
45
|
+
[`&.${gridClasses['scrollArea--left']}`]: {
|
|
46
|
+
left: 0
|
|
47
|
+
},
|
|
48
|
+
[`&.${gridClasses['scrollArea--right']}`]: {
|
|
49
|
+
right: 0
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
function GridScrollAreaRaw(props) {
|
|
53
|
+
const {
|
|
54
|
+
scrollDirection
|
|
55
|
+
} = props;
|
|
56
|
+
const rootRef = React.useRef(null);
|
|
57
|
+
const apiRef = useGridApiContext();
|
|
58
|
+
const timeout = useTimeout();
|
|
59
|
+
const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
60
|
+
const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
61
|
+
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
62
|
+
const scrollPosition = React.useRef({
|
|
63
|
+
left: 0,
|
|
64
|
+
top: 0
|
|
65
|
+
});
|
|
66
|
+
const getCanScrollMore = () => {
|
|
67
|
+
if (scrollDirection === 'left') {
|
|
68
|
+
// Only render if the user has not reached yet the start of the list
|
|
69
|
+
return scrollPosition.current.left > 0;
|
|
70
|
+
}
|
|
71
|
+
if (scrollDirection === 'right') {
|
|
72
|
+
// Only render if the user has not reached yet the end of the list
|
|
73
|
+
const maxScrollLeft = columnsTotalWidth - dimensions.viewportInnerSize.width;
|
|
74
|
+
return scrollPosition.current.left < maxScrollLeft;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
const [dragging, setDragging] = React.useState(false);
|
|
79
|
+
const [canScrollMore, setCanScrollMore] = React.useState(getCanScrollMore);
|
|
80
|
+
const rootProps = useGridRootProps();
|
|
81
|
+
const ownerState = _extends({}, rootProps, {
|
|
82
|
+
scrollDirection
|
|
83
|
+
});
|
|
84
|
+
const classes = useUtilityClasses(ownerState);
|
|
85
|
+
const totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps.columnHeaderHeight);
|
|
86
|
+
const headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
|
|
87
|
+
const style = {
|
|
88
|
+
height: headerHeight,
|
|
89
|
+
top: totalHeaderHeight - headerHeight
|
|
90
|
+
};
|
|
91
|
+
if (scrollDirection === 'left') {
|
|
92
|
+
style.left = dimensions.leftPinnedWidth;
|
|
93
|
+
} else if (scrollDirection === 'right') {
|
|
94
|
+
style.right = dimensions.rightPinnedWidth + (dimensions.hasScrollX ? dimensions.scrollbarSize : 0);
|
|
95
|
+
}
|
|
96
|
+
const handleScrolling = newScrollPosition => {
|
|
97
|
+
scrollPosition.current = newScrollPosition;
|
|
98
|
+
setCanScrollMore(getCanScrollMore);
|
|
99
|
+
};
|
|
100
|
+
const handleDragOver = useEventCallback(event => {
|
|
101
|
+
let offset;
|
|
102
|
+
|
|
103
|
+
// Prevents showing the forbidden cursor
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
if (scrollDirection === 'left') {
|
|
106
|
+
offset = event.clientX - rootRef.current.getBoundingClientRect().right;
|
|
107
|
+
} else if (scrollDirection === 'right') {
|
|
108
|
+
offset = Math.max(1, event.clientX - rootRef.current.getBoundingClientRect().left);
|
|
109
|
+
} else {
|
|
110
|
+
throw new Error('MUI X: Wrong drag direction');
|
|
111
|
+
}
|
|
112
|
+
offset = (offset - CLIFF) * SLOP + CLIFF;
|
|
113
|
+
|
|
114
|
+
// Avoid freeze and inertia.
|
|
115
|
+
timeout.start(0, () => {
|
|
116
|
+
apiRef.current.scroll({
|
|
117
|
+
left: scrollPosition.current.left + offset,
|
|
118
|
+
top: scrollPosition.current.top
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
const handleColumnHeaderDragStart = useEventCallback(() => {
|
|
123
|
+
setDragging(true);
|
|
124
|
+
});
|
|
125
|
+
const handleColumnHeaderDragEnd = useEventCallback(() => {
|
|
126
|
+
setDragging(false);
|
|
127
|
+
});
|
|
128
|
+
useGridApiEventHandler(apiRef, 'scrollPositionChange', handleScrolling);
|
|
129
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragStart', handleColumnHeaderDragStart);
|
|
130
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleColumnHeaderDragEnd);
|
|
131
|
+
if (!dragging || !canScrollMore) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return /*#__PURE__*/_jsx(GridScrollAreaRawRoot, {
|
|
135
|
+
ref: rootRef,
|
|
136
|
+
className: clsx(classes.root),
|
|
137
|
+
ownerState: ownerState,
|
|
138
|
+
onDragOver: handleDragOver,
|
|
139
|
+
style: style
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
process.env.NODE_ENV !== "production" ? GridScrollAreaRaw.propTypes = {
|
|
143
|
+
// ----------------------------- Warning --------------------------------
|
|
144
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
145
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
146
|
+
// ----------------------------------------------------------------------
|
|
147
|
+
scrollDirection: PropTypes.oneOf(['left', 'right']).isRequired
|
|
148
|
+
} : void 0;
|
|
149
|
+
const GridScrollArea = fastMemo(GridScrollAreaRaw);
|
|
150
|
+
export { GridScrollArea };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "
|
|
3
|
+
const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "width", "className", "style", "gridHasScrollX", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "sectionIndex", "sectionLength", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
|
|
4
4
|
_excluded2 = ["changeReason", "unstable_updateValueOnRender"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -15,6 +15,8 @@ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
|
15
15
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
16
16
|
import { gridFocusCellSelector } from '../../hooks/features/focus/gridFocusStateSelector';
|
|
17
17
|
import { MissingRowIdError } from '../../hooks/features/rows/useGridParamsApi';
|
|
18
|
+
import { shouldCellShowLeftBorder, shouldCellShowRightBorder } from '../../utils/cellBorderUtils';
|
|
19
|
+
import { GridPinnedColumnPosition } from '../../hooks/features/columns/gridColumnsInterfaces';
|
|
18
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
21
|
export let PinnedPosition = /*#__PURE__*/function (PinnedPosition) {
|
|
20
22
|
PinnedPosition[PinnedPosition["NONE"] = 0] = "NONE";
|
|
@@ -23,6 +25,12 @@ export let PinnedPosition = /*#__PURE__*/function (PinnedPosition) {
|
|
|
23
25
|
PinnedPosition[PinnedPosition["VIRTUAL"] = 3] = "VIRTUAL";
|
|
24
26
|
return PinnedPosition;
|
|
25
27
|
}({});
|
|
28
|
+
export const gridPinnedColumnPositionLookup = {
|
|
29
|
+
[PinnedPosition.LEFT]: GridPinnedColumnPosition.LEFT,
|
|
30
|
+
[PinnedPosition.RIGHT]: GridPinnedColumnPosition.RIGHT,
|
|
31
|
+
[PinnedPosition.NONE]: undefined,
|
|
32
|
+
[PinnedPosition.VIRTUAL]: undefined
|
|
33
|
+
};
|
|
26
34
|
const EMPTY_CELL_PARAMS = {
|
|
27
35
|
id: -1,
|
|
28
36
|
field: '__unset__',
|
|
@@ -74,7 +82,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
74
82
|
editCellState,
|
|
75
83
|
align,
|
|
76
84
|
colIndex,
|
|
77
|
-
height,
|
|
78
85
|
width,
|
|
79
86
|
className,
|
|
80
87
|
style: styleProp,
|
|
@@ -154,9 +161,9 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
154
161
|
const focusElementRef = React.useRef(null);
|
|
155
162
|
// @ts-expect-error To access `cellSelection` flag as it's a `premium` feature
|
|
156
163
|
const isSelectionMode = rootProps.cellSelection ?? false;
|
|
157
|
-
const
|
|
158
|
-
const showLeftBorder =
|
|
159
|
-
const showRightBorder =
|
|
164
|
+
const position = gridPinnedColumnPositionLookup[pinnedPosition];
|
|
165
|
+
const showLeftBorder = shouldCellShowLeftBorder(position, sectionIndex);
|
|
166
|
+
const showRightBorder = shouldCellShowRightBorder(position, sectionIndex, sectionLength, rootProps.showCellVerticalBorder);
|
|
160
167
|
const ownerState = {
|
|
161
168
|
align,
|
|
162
169
|
showLeftBorder,
|
|
@@ -203,8 +210,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
203
210
|
};
|
|
204
211
|
}
|
|
205
212
|
const cellStyle = _extends({
|
|
206
|
-
'--width': `${width}px
|
|
207
|
-
'--height': typeof height === 'number' ? `${height}px` : height
|
|
213
|
+
'--width': `${width}px`
|
|
208
214
|
}, styleProp);
|
|
209
215
|
if (pinnedPosition === PinnedPosition.LEFT) {
|
|
210
216
|
cellStyle.left = pinnedOffset;
|
|
@@ -213,7 +219,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
213
219
|
cellStyle.right = pinnedOffset;
|
|
214
220
|
}
|
|
215
221
|
return cellStyle;
|
|
216
|
-
}, [width,
|
|
222
|
+
}, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
|
|
217
223
|
React.useEffect(() => {
|
|
218
224
|
if (!hasFocus || cellMode === GridCellModes.Edit) {
|
|
219
225
|
return;
|
|
@@ -323,8 +329,6 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
|
|
|
323
329
|
isValidating: PropTypes.bool,
|
|
324
330
|
value: PropTypes.any
|
|
325
331
|
}),
|
|
326
|
-
gridHasScrollX: PropTypes.bool.isRequired,
|
|
327
|
-
height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
|
|
328
332
|
isNotVisible: PropTypes.bool.isRequired,
|
|
329
333
|
onClick: PropTypes.func,
|
|
330
334
|
onDoubleClick: PropTypes.func,
|
|
@@ -23,6 +23,7 @@ const GridColumnHeadersRoot = styled('div', {
|
|
|
23
23
|
overridesResolver: (props, styles) => styles.columnHeaders
|
|
24
24
|
})({
|
|
25
25
|
display: 'flex',
|
|
26
|
+
flexDirection: 'column',
|
|
26
27
|
borderTopLeftRadius: 'var(--unstable_DataGrid-radius)',
|
|
27
28
|
borderTopRightRadius: 'var(--unstable_DataGrid-radius)'
|
|
28
29
|
});
|