@mui/x-data-grid 7.0.0-beta.6 → 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 +117 -1
- 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/GridRow.d.ts +1 -1
- package/components/GridRow.js +4 -19
- package/components/GridScrollArea.d.ts +10 -0
- package/components/GridScrollArea.js +150 -0
- package/components/cell/GridCell.d.ts +7 -0
- package/components/cell/GridCell.js +11 -3
- 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 -20
- package/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/components/virtualization/GridVirtualScroller.js +6 -1
- 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/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 +4 -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/scroll/useGridScroll.js +1 -1
- 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/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 +1 -1
- package/internals/index.js +1 -1
- 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 +3 -3
- package/models/api/gridCoreApi.d.ts +1 -5
- 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 +4 -19
- package/modern/components/GridScrollArea.js +150 -0
- package/modern/components/cell/GridCell.js +11 -3
- 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 -20
- package/modern/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/modern/components/virtualization/GridVirtualScroller.js +6 -1
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/modern/constants/gridClasses.js +1 -1
- 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 +4 -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/scroll/useGridScroll.js +1 -1
- package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- 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 +1 -1
- 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/utils/cellBorderUtils.js +8 -0
- 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 +3 -18
- package/node/components/GridScrollArea.js +158 -0
- package/node/components/cell/GridCell.js +12 -4
- 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 -20
- package/node/components/virtualization/GridVirtualScrollbar.js +4 -0
- package/node/components/virtualization/GridVirtualScroller.js +6 -1
- package/node/components/virtualization/GridVirtualScrollerFiller.js +2 -1
- package/node/constants/gridClasses.js +1 -1
- 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 +4 -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/scroll/useGridScroll.js +1 -1
- package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -2
- 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 -8
- 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/utils/cellBorderUtils.js +16 -0
- package/node/utils/domUtils.js +155 -0
- package/package.json +1 -1
- package/utils/cellBorderUtils.d.ts +3 -0
- package/utils/cellBorderUtils.js +8 -0
- 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
|
@@ -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 => {
|
|
@@ -251,21 +252,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
251
252
|
}
|
|
252
253
|
const width = cellColSpanInfo?.cellProps.width ?? column.computedWidth;
|
|
253
254
|
const colSpan = cellColSpanInfo?.cellProps.colSpan ?? 1;
|
|
254
|
-
|
|
255
|
-
// FIXME: Why is the switch check exhaustiveness not validated with typescript-eslint?
|
|
256
|
-
// eslint-disable-next-line default-case
|
|
257
|
-
switch (pinnedPosition) {
|
|
258
|
-
case PinnedPosition.LEFT:
|
|
259
|
-
pinnedOffset = columnPositions[indexRelativeToAllColumns];
|
|
260
|
-
break;
|
|
261
|
-
case PinnedPosition.RIGHT:
|
|
262
|
-
pinnedOffset = dimensions.columnsTotalWidth - columnPositions[indexRelativeToAllColumns] - column.computedWidth + scrollbarWidth;
|
|
263
|
-
break;
|
|
264
|
-
case PinnedPosition.NONE:
|
|
265
|
-
case PinnedPosition.VIRTUAL:
|
|
266
|
-
pinnedOffset = 0;
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
255
|
+
const pinnedOffset = getPinnedCellOffset(gridPinnedColumnPositionLookup[pinnedPosition], column.computedWidth, indexRelativeToAllColumns, columnPositions, dimensions);
|
|
269
256
|
if (rowNode?.type === 'skeletonRow') {
|
|
270
257
|
return /*#__PURE__*/_jsx(slots.skeletonCell, {
|
|
271
258
|
width: width,
|
|
@@ -357,9 +344,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
357
344
|
width: emptyCellWidth
|
|
358
345
|
}), rightCells.length > 0 && /*#__PURE__*/_jsx("div", {
|
|
359
346
|
role: "presentation",
|
|
360
|
-
|
|
361
|
-
flex: '1'
|
|
362
|
-
}
|
|
347
|
+
className: gridClasses.filler
|
|
363
348
|
}), rightCells, scrollbarWidth !== 0 && /*#__PURE__*/_jsx(ScrollbarFiller, {
|
|
364
349
|
pinnedRight: pinnedColumns.right.length > 0
|
|
365
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 };
|
|
@@ -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__',
|
|
@@ -153,9 +161,9 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
153
161
|
const focusElementRef = React.useRef(null);
|
|
154
162
|
// @ts-expect-error To access `cellSelection` flag as it's a `premium` feature
|
|
155
163
|
const isSelectionMode = rootProps.cellSelection ?? false;
|
|
156
|
-
const
|
|
157
|
-
const showLeftBorder =
|
|
158
|
-
const showRightBorder =
|
|
164
|
+
const position = gridPinnedColumnPositionLookup[pinnedPosition];
|
|
165
|
+
const showLeftBorder = shouldCellShowLeftBorder(position, sectionIndex);
|
|
166
|
+
const showRightBorder = shouldCellShowRightBorder(position, sectionIndex, sectionLength, rootProps.showCellVerticalBorder);
|
|
159
167
|
const ownerState = {
|
|
160
168
|
align,
|
|
161
169
|
showLeftBorder,
|
|
@@ -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
|
});
|
|
@@ -8,17 +8,20 @@ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
|
|
|
8
8
|
import { useGridSelector } from '../../hooks/utils/useGridSelector';
|
|
9
9
|
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
10
10
|
import { isEventTargetInPortal } from '../../utils/domUtils';
|
|
11
|
+
import { shouldCellShowLeftBorder, shouldCellShowRightBorder } from '../../utils/cellBorderUtils';
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
const useUtilityClasses = ownerState => {
|
|
13
14
|
const {
|
|
14
15
|
classes,
|
|
15
16
|
headerAlign,
|
|
16
17
|
isDragging,
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
showLeftBorder,
|
|
19
|
+
showRightBorder,
|
|
20
|
+
groupId,
|
|
21
|
+
pinnedPosition
|
|
19
22
|
} = ownerState;
|
|
20
23
|
const slots = {
|
|
21
|
-
root: ['columnHeader', headerAlign === 'left' && 'columnHeader--alignLeft', headerAlign === 'center' && 'columnHeader--alignCenter', headerAlign === 'right' && 'columnHeader--alignRight', isDragging && 'columnHeader--moving',
|
|
24
|
+
root: ['columnHeader', headerAlign === 'left' && 'columnHeader--alignLeft', headerAlign === 'center' && 'columnHeader--alignCenter', headerAlign === 'right' && 'columnHeader--alignRight', isDragging && 'columnHeader--moving', showRightBorder && 'columnHeader--withRightBorder', showLeftBorder && 'columnHeader--withLeftBorder', 'withBorderColor', groupId === null ? 'columnHeader--emptyGroup' : 'columnHeader--filledGroup', pinnedPosition === 'left' && 'columnHeader--pinnedLeft', pinnedPosition === 'right' && 'columnHeader--pinnedRight'],
|
|
22
25
|
draggableContainer: ['columnHeaderDraggableContainer'],
|
|
23
26
|
titleContainer: ['columnHeaderTitleContainer', 'withBorderColor'],
|
|
24
27
|
titleContainerContent: ['columnHeaderTitleContainerContent']
|
|
@@ -36,7 +39,11 @@ function GridColumnGroupHeader(props) {
|
|
|
36
39
|
colIndex,
|
|
37
40
|
hasFocus,
|
|
38
41
|
tabIndex,
|
|
39
|
-
isLastColumn
|
|
42
|
+
isLastColumn,
|
|
43
|
+
pinnedPosition,
|
|
44
|
+
style,
|
|
45
|
+
indexInSection,
|
|
46
|
+
sectionLength
|
|
40
47
|
} = props;
|
|
41
48
|
const rootProps = useGridRootProps();
|
|
42
49
|
const headerCellRef = React.useRef(null);
|
|
@@ -63,10 +70,12 @@ function GridColumnGroupHeader(props) {
|
|
|
63
70
|
if (groupId && render) {
|
|
64
71
|
headerComponent = render(renderParams);
|
|
65
72
|
}
|
|
66
|
-
const
|
|
73
|
+
const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
|
|
74
|
+
const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder);
|
|
67
75
|
const ownerState = _extends({}, props, {
|
|
68
76
|
classes: rootProps.classes,
|
|
69
|
-
|
|
77
|
+
showLeftBorder,
|
|
78
|
+
showRightBorder,
|
|
70
79
|
headerAlign,
|
|
71
80
|
depth,
|
|
72
81
|
isDragging: false
|
|
@@ -117,12 +126,13 @@ function GridColumnGroupHeader(props) {
|
|
|
117
126
|
width: width,
|
|
118
127
|
columnMenuIconButton: null,
|
|
119
128
|
columnTitleIconButtons: null,
|
|
120
|
-
resizable:
|
|
129
|
+
resizable: true,
|
|
121
130
|
label: label,
|
|
122
131
|
"aria-colspan": fields.length
|
|
123
132
|
// The fields are wrapped between |-...-| to avoid confusion between fields "id" and "id2" when using selector data-fields~=
|
|
124
133
|
,
|
|
125
|
-
"data-fields": `|-${fields.join('-|-')}
|
|
134
|
+
"data-fields": `|-${fields.join('-|-')}-|`,
|
|
135
|
+
style: style
|
|
126
136
|
}, mouseEventsHandlers));
|
|
127
137
|
}
|
|
128
138
|
export { GridColumnGroupHeader };
|
|
@@ -11,6 +11,7 @@ import { getDataGridUtilityClass } from '../../constants/gridClasses';
|
|
|
11
11
|
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
|
|
12
12
|
import { GridGenericColumnHeaderItem } from './GridGenericColumnHeaderItem';
|
|
13
13
|
import { isEventTargetInPortal } from '../../utils/domUtils';
|
|
14
|
+
import { shouldCellShowLeftBorder, shouldCellShowRightBorder } from '../../utils/cellBorderUtils';
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
const useUtilityClasses = ownerState => {
|
|
@@ -20,14 +21,16 @@ const useUtilityClasses = ownerState => {
|
|
|
20
21
|
isDragging,
|
|
21
22
|
sortDirection,
|
|
22
23
|
showRightBorder,
|
|
23
|
-
|
|
24
|
+
showLeftBorder,
|
|
25
|
+
filterItemsCounter,
|
|
26
|
+
pinnedPosition
|
|
24
27
|
} = ownerState;
|
|
25
28
|
const isColumnSorted = sortDirection != null;
|
|
26
29
|
const isColumnFiltered = filterItemsCounter != null && filterItemsCounter > 0;
|
|
27
30
|
// todo refactor to a prop on col isNumeric or ?? ie: coltype===price wont work
|
|
28
31
|
const isColumnNumeric = colDef.type === 'number';
|
|
29
32
|
const slots = {
|
|
30
|
-
root: ['columnHeader', colDef.headerAlign === 'left' && 'columnHeader--alignLeft', colDef.headerAlign === 'center' && 'columnHeader--alignCenter', colDef.headerAlign === 'right' && 'columnHeader--alignRight', colDef.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnFiltered && 'columnHeader--filtered', isColumnNumeric && 'columnHeader--numeric', 'withBorderColor', showRightBorder && 'columnHeader--withRightBorder'],
|
|
33
|
+
root: ['columnHeader', colDef.headerAlign === 'left' && 'columnHeader--alignLeft', colDef.headerAlign === 'center' && 'columnHeader--alignCenter', colDef.headerAlign === 'right' && 'columnHeader--alignRight', colDef.sortable && 'columnHeader--sortable', isDragging && 'columnHeader--moving', isColumnSorted && 'columnHeader--sorted', isColumnFiltered && 'columnHeader--filtered', isColumnNumeric && 'columnHeader--numeric', 'withBorderColor', showRightBorder && 'columnHeader--withRightBorder', showLeftBorder && 'columnHeader--withLeftBorder', pinnedPosition === 'left' && 'columnHeader--pinnedLeft', pinnedPosition === 'right' && 'columnHeader--pinnedRight'],
|
|
31
34
|
draggableContainer: ['columnHeaderDraggableContainer'],
|
|
32
35
|
titleContainer: ['columnHeaderTitleContainer'],
|
|
33
36
|
titleContainerContent: ['columnHeaderTitleContainerContent']
|
|
@@ -47,7 +50,11 @@ function GridColumnHeaderItem(props) {
|
|
|
47
50
|
hasFocus,
|
|
48
51
|
tabIndex,
|
|
49
52
|
disableReorder,
|
|
50
|
-
separatorSide
|
|
53
|
+
separatorSide,
|
|
54
|
+
style,
|
|
55
|
+
pinnedPosition,
|
|
56
|
+
indexInSection,
|
|
57
|
+
sectionLength
|
|
51
58
|
} = props;
|
|
52
59
|
const apiRef = useGridPrivateApiContext();
|
|
53
60
|
const rootProps = useGridRootProps();
|
|
@@ -61,9 +68,12 @@ function GridColumnHeaderItem(props) {
|
|
|
61
68
|
if (colDef.renderHeader) {
|
|
62
69
|
headerComponent = colDef.renderHeader(apiRef.current.getColumnHeaderParams(colDef.field));
|
|
63
70
|
}
|
|
71
|
+
const showLeftBorder = shouldCellShowLeftBorder(pinnedPosition, indexInSection);
|
|
72
|
+
const showRightBorder = shouldCellShowRightBorder(pinnedPosition, indexInSection, sectionLength, rootProps.showCellVerticalBorder);
|
|
64
73
|
const ownerState = _extends({}, props, {
|
|
65
74
|
classes: rootProps.classes,
|
|
66
|
-
showRightBorder
|
|
75
|
+
showRightBorder,
|
|
76
|
+
showLeftBorder
|
|
67
77
|
});
|
|
68
78
|
const classes = useUtilityClasses(ownerState);
|
|
69
79
|
const publish = React.useCallback(eventName => event => {
|
|
@@ -143,7 +153,7 @@ function GridColumnHeaderItem(props) {
|
|
|
143
153
|
const focusableElement = headerCellRef.current.querySelector('[tabindex="0"]');
|
|
144
154
|
const elementToFocus = focusableElement || headerCellRef.current;
|
|
145
155
|
elementToFocus?.focus();
|
|
146
|
-
apiRef.current.
|
|
156
|
+
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
147
157
|
}
|
|
148
158
|
}, [apiRef, hasFocus]);
|
|
149
159
|
const headerClassName = typeof colDef.headerClassName === 'function' ? colDef.headerClassName({
|
|
@@ -175,7 +185,8 @@ function GridColumnHeaderItem(props) {
|
|
|
175
185
|
"data-field": colDef.field,
|
|
176
186
|
columnMenu: columnMenu,
|
|
177
187
|
draggableContainerProps: draggableEventHandlers,
|
|
178
|
-
columnHeaderSeparatorProps: columnHeaderSeparatorProps
|
|
188
|
+
columnHeaderSeparatorProps: columnHeaderSeparatorProps,
|
|
189
|
+
style: style
|
|
179
190
|
}, mouseEventsHandlers));
|
|
180
191
|
}
|
|
181
192
|
process.env.NODE_ENV !== "production" ? GridColumnHeaderItem.propTypes = {
|
|
@@ -190,11 +201,15 @@ process.env.NODE_ENV !== "production" ? GridColumnHeaderItem.propTypes = {
|
|
|
190
201
|
filterItemsCounter: PropTypes.number,
|
|
191
202
|
hasFocus: PropTypes.bool,
|
|
192
203
|
headerHeight: PropTypes.number.isRequired,
|
|
204
|
+
indexInSection: PropTypes.number.isRequired,
|
|
193
205
|
isDragging: PropTypes.bool.isRequired,
|
|
194
206
|
isResizing: PropTypes.bool.isRequired,
|
|
207
|
+
pinnedPosition: PropTypes.oneOf(['left', 'right']),
|
|
208
|
+
sectionLength: PropTypes.number.isRequired,
|
|
195
209
|
separatorSide: PropTypes.oneOf(['left', 'right']),
|
|
196
210
|
sortDirection: PropTypes.oneOf(['asc', 'desc']),
|
|
197
211
|
sortIndex: PropTypes.number,
|
|
212
|
+
style: PropTypes.object,
|
|
198
213
|
tabIndex: PropTypes.oneOf([-1, 0]).isRequired
|
|
199
214
|
} : void 0;
|
|
200
215
|
const Memoized = fastMemo(GridColumnHeaderItem);
|