@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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,102 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.0.0-beta.7
|
|
7
|
+
|
|
8
|
+
_Mar 14, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🦥 The Lazy loading feature is now stable and the `lazyLoading` feature flag was removed from the `experimentalFeatures` prop.
|
|
13
|
+
- 🌍 Improve Japanese (ja-JP) locale for the Data Grid
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
### Data Grid
|
|
18
|
+
|
|
19
|
+
#### Breaking changes
|
|
20
|
+
|
|
21
|
+
- The `columnHeader--showColumnBorder` class was replaced by `columnHeader--withLeftBorder` and `columnHeader--withRightBorder`.
|
|
22
|
+
- The `columnHeadersInner`, `columnHeadersInner--scrollable`, and `columnHeaderDropZone` classes were removed since the inner wrapper was removed in our effort to simplify the DOM structure and improve accessibility.
|
|
23
|
+
- The `pinnedColumnHeaders`, `pinnedColumnHeaders--left`, and `pinnedColumnHeaders--right` classes were removed along with the element they were applied to.
|
|
24
|
+
The pinned column headers now use `position: 'sticky'` and are rendered in the same row element as the regular column headers.
|
|
25
|
+
|
|
26
|
+
#### `@mui/x-data-grid@7.0.0-beta.7`
|
|
27
|
+
|
|
28
|
+
- [DataGrid] Fix focus visible style on scrollbar (#12402) @oliviertassinari
|
|
29
|
+
- [DataGrid] Fix the issue where pressing the Delete key resets various cell values to an empty string. (#12216) @sooster910
|
|
30
|
+
- [DataGrid] Make `rowCount` part of the state (#12381) @MBilalShafi
|
|
31
|
+
- [DataGrid] Make column resizing and autosizing available in Community plan (#12420) @cherniavskii
|
|
32
|
+
- [DataGrid] Remove `baseSwitch` slot (#12439) @romgrk
|
|
33
|
+
- [l10n] Improve Japanese (ja-JP) locale (#12398) @makoto14
|
|
34
|
+
|
|
35
|
+
#### `@mui/x-data-grid-pro@7.0.0-beta.7` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
36
|
+
|
|
37
|
+
Same changes as in `@mui/x-data-grid@7.0.0-beta.7`, plus:
|
|
38
|
+
|
|
39
|
+
- [DataGridPro] Add `inputRef` to the props passed to `colDef.renderHeaderFilter` (#12328) @vovarudomanenko
|
|
40
|
+
- [DataGridPro] Fix filler rendered for no reason when there are pinned columns (#12440) @cherniavskii
|
|
41
|
+
- [DataGridPro] Make lazy loading feature stable (#12421) @cherniavskii
|
|
42
|
+
- [DataGridPro] Render pinned and non-pinned column headers in one row (#12376) @cherniavskii
|
|
43
|
+
|
|
44
|
+
#### `@mui/x-data-grid-premium@7.0.0-beta.7` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
45
|
+
|
|
46
|
+
Same changes as in `@mui/x-data-grid-pro@7.0.0-beta.7`, plus:
|
|
47
|
+
|
|
48
|
+
- [DataGridPremium] Fix auto-scroll not working when selecting cell range (#12267) @cherniavskii
|
|
49
|
+
|
|
50
|
+
### Date and Time Pickers
|
|
51
|
+
|
|
52
|
+
#### `@mui/x-date-pickers@7.0.0-beta.7`
|
|
53
|
+
|
|
54
|
+
- [fields] Fix `tabIndex` on accessible field DOM structure (#12311) @flaviendelangle
|
|
55
|
+
- [fields] Fix items alignment on multi input range fields (#12312) @flaviendelangle
|
|
56
|
+
- [pickers] Improve the customization of the range picker calendar header (#11988) @flaviendelangle
|
|
57
|
+
- [pickers] Keep the existing time when looking for closest enabled date (#12377) @LukasTy
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-date-pickers-pro@7.0.0-beta.7` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
60
|
+
|
|
61
|
+
Same changes as in `@mui/x-date-pickers@7.0.0-beta.7`.
|
|
62
|
+
|
|
63
|
+
### Charts
|
|
64
|
+
|
|
65
|
+
#### `@mui/x-charts@7.0.0-beta.7`
|
|
66
|
+
|
|
67
|
+
- [charts] Fix axis highlight when axis is reversed (#12407) @alexfauquette
|
|
68
|
+
|
|
69
|
+
### Tree View
|
|
70
|
+
|
|
71
|
+
#### Breaking changes
|
|
72
|
+
|
|
73
|
+
The `onNodeFocus` callback has been renamed to `onItemFocus` for consistency:
|
|
74
|
+
|
|
75
|
+
```diff
|
|
76
|
+
<SimpleTreeView
|
|
77
|
+
- onNodeFocus={onNodeFocus}
|
|
78
|
+
+ onItemFocus={onItemFocus}
|
|
79
|
+
/>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### `@mui/x-tree-view@7.0.0-beta.7`
|
|
83
|
+
|
|
84
|
+
- [TreeView] Clean the usage of the term "item" and "node" in API introduced during v7 (#12368) @noraleonte
|
|
85
|
+
- [TreeView] Introduce a new `TreeItem2` component and a new `useTreeItem2` hook (#11721) @flaviendelangle
|
|
86
|
+
- [TreeView] Rename `onNodeFocus` to `onItemFocus` (#12419) @noraleonte
|
|
87
|
+
|
|
88
|
+
### Docs
|
|
89
|
+
|
|
90
|
+
- [docs] Add `legacy` bundle drop mention in migration pages (#12424) @LukasTy
|
|
91
|
+
- [docs] Add missing luxon `Info` import (#12427) @LukasTy
|
|
92
|
+
- [docs] Improve slots definitions for charts (#12408) @alexfauquette
|
|
93
|
+
- [docs] Polish What's new in MUI X blog titles (#12309) @oliviertassinari
|
|
94
|
+
- [docs] Replace `rel="noreferrer"` by `rel="noopener"` @oliviertassinari
|
|
95
|
+
- [docs] Update `date-fns` `weekStarsOn` overriding example (#12416) @LukasTy
|
|
96
|
+
|
|
97
|
+
### Core
|
|
98
|
+
|
|
99
|
+
- [core] Fix CI (#12414) @flaviendelangle
|
|
100
|
+
- [core] Fix PR deploy link for Tree View doc pages (#12411) @flaviendelangle
|
|
101
|
+
|
|
6
102
|
## 7.0.0-beta.6
|
|
7
103
|
|
|
8
104
|
_Mar 8, 2024_
|
|
@@ -1731,7 +1827,7 @@ Same changes as in `@mui/x-data-grid-pro@7.0.0-alpha.3`, plus:
|
|
|
1731
1827
|
The Firefox browser currently does not support this behavior because the [getWeekInfo](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getWeekInfo) API is not yet implemented.
|
|
1732
1828
|
|
|
1733
1829
|
```ts
|
|
1734
|
-
import { Settings } from 'luxon';
|
|
1830
|
+
import { Settings, Info } from 'luxon';
|
|
1735
1831
|
|
|
1736
1832
|
Settings.defaultWeekSettings = {
|
|
1737
1833
|
firstDay: 1,
|
|
@@ -2521,6 +2617,26 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
|
|
|
2521
2617
|
- [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
|
|
2522
2618
|
- [license] Correctly throw errors (#10924) @oliviertassinari
|
|
2523
2619
|
|
|
2620
|
+
## 6.19.7
|
|
2621
|
+
|
|
2622
|
+
_Mar 14, 2024_
|
|
2623
|
+
|
|
2624
|
+
We'd like to offer a big thanks to @LukasTy who made this release possible.
|
|
2625
|
+
|
|
2626
|
+
### Date Pickers
|
|
2627
|
+
|
|
2628
|
+
#### `@mui/x-date-pickers@6.19.7`
|
|
2629
|
+
|
|
2630
|
+
- [pickers] Keep the existing time when looking for closest enabled date (#12410) @LukasTy
|
|
2631
|
+
|
|
2632
|
+
#### `@mui/x-date-pickers-pro@6.19.7` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
2633
|
+
|
|
2634
|
+
Same changes as in `@mui/x-date-pickers@6.19.7`.
|
|
2635
|
+
|
|
2636
|
+
### Docs
|
|
2637
|
+
|
|
2638
|
+
- [docs] Add Pickers custom start of week section (#12425) @LukasTy
|
|
2639
|
+
|
|
2524
2640
|
## 6.19.6
|
|
2525
2641
|
|
|
2526
2642
|
_Mar 1, 2024_
|
package/DataGrid/DataGrid.js
CHANGED
|
@@ -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,8 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { UseGridColumnHeadersProps } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
3
|
-
export interface GridColumnHeadersProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
3
|
+
export interface GridColumnHeadersProps extends React.HTMLAttributes<HTMLDivElement>, UseGridColumnHeadersProps {
|
|
4
4
|
ref?: React.Ref<HTMLDivElement>;
|
|
5
|
-
innerRef?: React.Ref<HTMLDivElement>;
|
|
6
5
|
}
|
|
7
6
|
declare const MemoizedGridColumnHeaders: React.ForwardRefExoticComponent<Omit<GridColumnHeadersProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
8
7
|
export { MemoizedGridColumnHeaders as GridColumnHeaders };
|
|
@@ -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,11 +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(() => {
|
|
36
|
-
var _ref, _rootProps$rowCount;
|
|
37
|
-
return (_ref = (_rootProps$rowCount = rootProps.rowCount) != null ? _rootProps$rowCount : visibleTopLevelRowCount) != null ? _ref : 0;
|
|
38
|
-
}, [rootProps.rowCount, visibleTopLevelRowCount]);
|
|
33
|
+
const rowCount = useGridSelector(apiRef, gridPaginationRowCountSelector);
|
|
39
34
|
const lastPage = React.useMemo(() => {
|
|
40
35
|
const calculatedValue = Math.ceil(rowCount / (paginationModel.pageSize || 1)) - 1;
|
|
41
36
|
return Math.max(0, calculatedValue);
|
package/components/GridRow.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridRowId, GridRowModel } from '../models/gridRows';
|
|
3
|
-
import
|
|
3
|
+
import { GridPinnedColumns } from '../hooks/features/columns';
|
|
4
4
|
import type { GridStateColDef } from '../models/colDef/gridColDef';
|
|
5
5
|
import type { GridRenderContext } from '../models/params/gridScrollParams';
|
|
6
6
|
import type { GridDimensions } from '../hooks/features/dimensions';
|
package/components/GridRow.js
CHANGED
|
@@ -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 => {
|
|
@@ -254,21 +255,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
254
255
|
}
|
|
255
256
|
const width = (_cellColSpanInfo$cell = cellColSpanInfo == null ? void 0 : cellColSpanInfo.cellProps.width) != null ? _cellColSpanInfo$cell : column.computedWidth;
|
|
256
257
|
const colSpan = (_cellColSpanInfo$cell2 = cellColSpanInfo == null ? void 0 : cellColSpanInfo.cellProps.colSpan) != null ? _cellColSpanInfo$cell2 : 1;
|
|
257
|
-
|
|
258
|
-
// FIXME: Why is the switch check exhaustiveness not validated with typescript-eslint?
|
|
259
|
-
// eslint-disable-next-line default-case
|
|
260
|
-
switch (pinnedPosition) {
|
|
261
|
-
case PinnedPosition.LEFT:
|
|
262
|
-
pinnedOffset = columnPositions[indexRelativeToAllColumns];
|
|
263
|
-
break;
|
|
264
|
-
case PinnedPosition.RIGHT:
|
|
265
|
-
pinnedOffset = dimensions.columnsTotalWidth - columnPositions[indexRelativeToAllColumns] - column.computedWidth + scrollbarWidth;
|
|
266
|
-
break;
|
|
267
|
-
case PinnedPosition.NONE:
|
|
268
|
-
case PinnedPosition.VIRTUAL:
|
|
269
|
-
pinnedOffset = 0;
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
258
|
+
const pinnedOffset = getPinnedCellOffset(gridPinnedColumnPositionLookup[pinnedPosition], column.computedWidth, indexRelativeToAllColumns, columnPositions, dimensions);
|
|
272
259
|
if ((rowNode == null ? void 0 : rowNode.type) === 'skeletonRow') {
|
|
273
260
|
var _column$align;
|
|
274
261
|
return /*#__PURE__*/_jsx(slots.skeletonCell, {
|
|
@@ -361,9 +348,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
|
|
|
361
348
|
width: emptyCellWidth
|
|
362
349
|
}), rightCells.length > 0 && /*#__PURE__*/_jsx("div", {
|
|
363
350
|
role: "presentation",
|
|
364
|
-
|
|
365
|
-
flex: '1'
|
|
366
|
-
}
|
|
351
|
+
className: gridClasses.filler
|
|
367
352
|
}), rightCells, scrollbarWidth !== 0 && /*#__PURE__*/_jsx(ScrollbarFiller, {
|
|
368
353
|
pinnedRight: pinnedColumns.right.length > 0
|
|
369
354
|
})]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface ScrollAreaProps {
|
|
3
|
+
scrollDirection: 'left' | 'right';
|
|
4
|
+
}
|
|
5
|
+
declare function GridScrollAreaRaw(props: ScrollAreaProps): React.JSX.Element | null;
|
|
6
|
+
declare namespace GridScrollAreaRaw {
|
|
7
|
+
var propTypes: any;
|
|
8
|
+
}
|
|
9
|
+
declare const GridScrollArea: typeof GridScrollAreaRaw;
|
|
10
|
+
export { GridScrollArea };
|
|
@@ -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,12 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { GridRowId, GridEditCellProps } from '../../models';
|
|
3
3
|
import { GridColDef, GridAlignment } from '../../models/colDef/gridColDef';
|
|
4
|
+
import { GridPinnedColumnPosition } from '../../hooks/features/columns/gridColumnsInterfaces';
|
|
4
5
|
export declare enum PinnedPosition {
|
|
5
6
|
NONE = 0,
|
|
6
7
|
LEFT = 1,
|
|
7
8
|
RIGHT = 2,
|
|
8
9
|
VIRTUAL = 3
|
|
9
10
|
}
|
|
11
|
+
export declare const gridPinnedColumnPositionLookup: {
|
|
12
|
+
1: GridPinnedColumnPosition;
|
|
13
|
+
2: GridPinnedColumnPosition;
|
|
14
|
+
0: undefined;
|
|
15
|
+
3: undefined;
|
|
16
|
+
};
|
|
10
17
|
export type GridCellProps = {
|
|
11
18
|
align: GridAlignment;
|
|
12
19
|
className?: string;
|
|
@@ -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__',
|
|
@@ -154,9 +162,9 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
154
162
|
const focusElementRef = React.useRef(null);
|
|
155
163
|
// @ts-expect-error To access `cellSelection` flag as it's a `premium` feature
|
|
156
164
|
const isSelectionMode = (_rootProps$cellSelect = rootProps.cellSelection) != null ? _rootProps$cellSelect : false;
|
|
157
|
-
const
|
|
158
|
-
const showLeftBorder =
|
|
159
|
-
const showRightBorder =
|
|
165
|
+
const position = gridPinnedColumnPositionLookup[pinnedPosition];
|
|
166
|
+
const showLeftBorder = shouldCellShowLeftBorder(position, sectionIndex);
|
|
167
|
+
const showRightBorder = shouldCellShowRightBorder(position, sectionIndex, sectionLength, rootProps.showCellVerticalBorder);
|
|
160
168
|
const ownerState = {
|
|
161
169
|
align,
|
|
162
170
|
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
|
});
|