@mui/x-tree-view-pro 8.0.0-beta.0 → 8.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +171 -0
- package/RichTreeViewPro/RichTreeViewPro.js +19 -7
- package/RichTreeViewPro/richTreeViewProClasses.d.ts +2 -4
- package/RichTreeViewPro/richTreeViewProClasses.js +1 -1
- package/esm/RichTreeViewPro/RichTreeViewPro.js +19 -7
- package/esm/RichTreeViewPro/richTreeViewProClasses.d.ts +2 -4
- package/esm/RichTreeViewPro/richTreeViewProClasses.js +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.itemPlugin.js +6 -6
- package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.js +51 -38
- package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.d.ts +244 -10
- package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.js +23 -8
- package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.types.d.ts +8 -13
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.js +1 -20
- package/esm/internals/utils/releaseInfo.js +1 -1
- package/index.js +1 -1
- package/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.itemPlugin.js +5 -5
- package/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.js +50 -37
- package/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.d.ts +244 -10
- package/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.js +23 -9
- package/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.types.d.ts +8 -13
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.js +1 -20
- package/internals/utils/releaseInfo.js +1 -1
- package/modern/RichTreeViewPro/RichTreeViewPro.js +19 -7
- package/modern/RichTreeViewPro/richTreeViewProClasses.d.ts +2 -4
- package/modern/RichTreeViewPro/richTreeViewProClasses.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.itemPlugin.js +6 -6
- package/modern/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.js +51 -38
- package/modern/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.d.ts +244 -10
- package/modern/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.js +23 -8
- package/modern/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.types.d.ts +8 -13
- package/modern/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.js +1 -20
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/package.json +4 -4
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,177 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.0.0-beta.2
|
|
9
|
+
|
|
10
|
+
_Mar 27, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🔍 Update the Data Grid quick filter to be collapsed when not in use
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
|
|
17
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
18
|
+
@lhilgert9.
|
|
19
|
+
Following are all team members who have contributed to this release:
|
|
20
|
+
@alexfauquette, @arminmeh, @flaviendelangle, @hasdfa, @JCQuintas, @KenanYusuf, @LukasTy, @MBilalShafi, @michelengelen, @mnajdova, @romgrk.
|
|
21
|
+
|
|
22
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
23
|
+
|
|
24
|
+
### Data Grid
|
|
25
|
+
|
|
26
|
+
#### `@mui/x-data-grid@8.0.0-beta.2`
|
|
27
|
+
|
|
28
|
+
- [DataGrid] Fix error caused by trying to render rows that are not in the state anymore (#17057) @arminmeh
|
|
29
|
+
- [DataGrid] Refactor: remove more material (#16922) @romgrk
|
|
30
|
+
- [DataGrid] Update Quick Filter component to be expandable (#16862) @KenanYusuf
|
|
31
|
+
- [DataGrid] Fix crash when used with `@mui/styled-engine-sc` (#17154) @KenanYusuf
|
|
32
|
+
|
|
33
|
+
#### `@mui/x-data-grid-pro@8.0.0-beta.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
34
|
+
|
|
35
|
+
Same changes as in `@mui/x-data-grid@8.0.0-beta.2`, plus:
|
|
36
|
+
|
|
37
|
+
- [DataGridPro] Data source: Allow expanding groups with unknown children (#17144) @MBilalShafi
|
|
38
|
+
|
|
39
|
+
#### `@mui/x-data-grid-premium@8.0.0-beta.2` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
40
|
+
|
|
41
|
+
Same changes as in `@mui/x-data-grid-pro@8.0.0-beta.2`.
|
|
42
|
+
|
|
43
|
+
### Date and Time Pickers
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-date-pickers@8.0.0-beta.2`
|
|
46
|
+
|
|
47
|
+
- [fields] Extract the props of each field slot into a standalone hook for easier re-use (#17114) @flaviendelangle
|
|
48
|
+
- [pickers] Fix visual regression in Date Range Calendar's day (#17148) @flaviendelangle
|
|
49
|
+
- [pickers] Remove all code duplication to apply default values to validation props (#17038) @flaviendelangle
|
|
50
|
+
|
|
51
|
+
#### `@mui/x-date-pickers-pro@8.0.0-beta.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
52
|
+
|
|
53
|
+
Same changes as in `@mui/x-date-pickers@8.0.0-beta.2`.
|
|
54
|
+
|
|
55
|
+
### Charts
|
|
56
|
+
|
|
57
|
+
#### `@mui/x-charts@8.0.0-beta.2`
|
|
58
|
+
|
|
59
|
+
- [charts] Memoize axes and series with default (#17156) @alexfauquette
|
|
60
|
+
- [charts] Add pie benchmark (#17115) @JCQuintas
|
|
61
|
+
- [charts] Fix CSS vars support for dark theme (#17106) @alexfauquette
|
|
62
|
+
- [charts] Fix radar hover (#17134) @alexfauquette
|
|
63
|
+
- [charts] Move axis interaction to selectors (#17039) @alexfauquette
|
|
64
|
+
- [charts] Fix Pie benchmark (#17125) @JCQuintas
|
|
65
|
+
|
|
66
|
+
#### `@mui/x-charts-pro@8.0.0-beta.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
67
|
+
|
|
68
|
+
Same changes as in `@mui/x-charts@8.0.0-beta.2`.
|
|
69
|
+
|
|
70
|
+
### Tree View
|
|
71
|
+
|
|
72
|
+
#### `@mui/x-tree-view@8.0.0-beta.2`
|
|
73
|
+
|
|
74
|
+
Internal changes.
|
|
75
|
+
|
|
76
|
+
#### `@mui/x-tree-view-pro@8.0.0-beta.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
77
|
+
|
|
78
|
+
Same changes as in `@mui/x-tree-view@8.0.0-beta.2`.
|
|
79
|
+
|
|
80
|
+
### `@mui/x-codemod@8.0.0-beta.1`
|
|
81
|
+
|
|
82
|
+
- [codemod] Add Data Grid codemods (#17121, #17124) @MBilalShafi
|
|
83
|
+
|
|
84
|
+
### Docs
|
|
85
|
+
|
|
86
|
+
- [docs] Fix example import for `ExportExcel` component (#17110) @KenanYusuf
|
|
87
|
+
|
|
88
|
+
### Core
|
|
89
|
+
|
|
90
|
+
- [code-infra] Remove `@mui/styles` dependency & patches (#17071) @mnajdova
|
|
91
|
+
- [code-infra] Add more tests to slow screenshot tests (#17075) @JCQuintas
|
|
92
|
+
- [code-infra] Fix pickers codecov (#17120) @JCQuintas
|
|
93
|
+
- [code-infra] Move `isDeepEqual` to @mui/x-internals (#17129) @JCQuintas
|
|
94
|
+
- [code-infra] Remove `test_regressions` step from React 18 pipeline (#17108) @LukasTy
|
|
95
|
+
- [code-infra] Update some data-grid tests for vitest (#17078, #17104, #17146) @JCQuintas
|
|
96
|
+
- [code-infra] Update some date-pickers tests for vitest (#17083) @JCQuintas
|
|
97
|
+
- [infra] Update `issue-status-label-handler.yml` @michelengelen
|
|
98
|
+
- [infra] Added reusable issue status label handler workflow (#17145) @michelengelen
|
|
99
|
+
- [infra] Switch to reusable 'stale issues/PRs' workflow (#17107) @michelengelen
|
|
100
|
+
- [telemetry] Improve request body size, update dependencies, and optimize SSR handling (#17008) @hasdfa
|
|
101
|
+
|
|
102
|
+
## 8.0.0-beta.1
|
|
103
|
+
|
|
104
|
+
_Mar 21, 2025_
|
|
105
|
+
|
|
106
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
107
|
+
|
|
108
|
+
- 🐞 Bugfixes
|
|
109
|
+
|
|
110
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
111
|
+
@jyash97.
|
|
112
|
+
Following are all team members who have contributed to this release:
|
|
113
|
+
@alexfauquette, @arminmeh, @flaviendelangle, @JCQuintas, @KenanYusuf.
|
|
114
|
+
|
|
115
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
116
|
+
|
|
117
|
+
### Data Grid
|
|
118
|
+
|
|
119
|
+
#### `@mui/x-data-grid@8.0.0-beta.1`
|
|
120
|
+
|
|
121
|
+
- [DataGrid] Fix error caused by `forwardRef` to `ClickAwayListener` (#17049) @arminmeh
|
|
122
|
+
- [DataGrid] Fix error while editing rows with custom id (#17048) @arminmeh
|
|
123
|
+
|
|
124
|
+
#### `@mui/x-data-grid-pro@8.0.0-beta.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
125
|
+
|
|
126
|
+
Same changes as in `@mui/x-data-grid@8.0.0-beta.1`, plus:
|
|
127
|
+
|
|
128
|
+
- [DataGridPro] Fix header select checkbox state with `checkboxSelectionVisibleOnly` and `paginationMode="server"` (#17026) @arminmeh
|
|
129
|
+
|
|
130
|
+
#### `@mui/x-data-grid-premium@8.0.0-beta.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
131
|
+
|
|
132
|
+
Same changes as in `@mui/x-data-grid-pro@8.0.0-beta.1`, plus:
|
|
133
|
+
|
|
134
|
+
- [DataGridPremium] Update column state correctly when grouping mode is updated with one grouping column (#17069) @arminmeh
|
|
135
|
+
|
|
136
|
+
### Date and Time Pickers
|
|
137
|
+
|
|
138
|
+
#### `@mui/x-date-pickers@8.0.0-beta.1`
|
|
139
|
+
|
|
140
|
+
- [fields] Clean the `useField` hook (part 1) (#16944) @flaviendelangle
|
|
141
|
+
- [fields] Improve the check for year in `doesSectionFormatHaveLeadingZeros` (#17051) @flaviendelangle
|
|
142
|
+
- [pickers] Deprecate the `disableOpenPicker` prop (#17040) @flaviendelangle
|
|
143
|
+
- [pickers] Simplify the `cleanLeadingZeros` method (#17063) @flaviendelangle
|
|
144
|
+
- [pickers] Use the new `ownerState` in `PickersDay` and `DateRangePickerDay` (#17035) @flaviendelangle
|
|
145
|
+
|
|
146
|
+
#### `@mui/x-date-pickers-pro@8.0.0-beta.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
147
|
+
|
|
148
|
+
Same changes as in `@mui/x-date-pickers@8.0.0-beta.1`, plus:
|
|
149
|
+
|
|
150
|
+
- [DateRangePicker] Use desktop media query constant on range pickers (#17052) @flaviendelangle
|
|
151
|
+
|
|
152
|
+
### Charts
|
|
153
|
+
|
|
154
|
+
#### `@mui/x-charts@8.0.0-beta.1`
|
|
155
|
+
|
|
156
|
+
- [charts] Fix horizontal bar with multiple axes (#17059) @alexfauquette
|
|
157
|
+
|
|
158
|
+
#### `@mui/x-charts-pro@8.0.0-beta.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
159
|
+
|
|
160
|
+
Same changes as in `@mui/x-charts@8.0.0-beta.1`, plus:
|
|
161
|
+
|
|
162
|
+
- [charts-pro] Allow disabling Heatmap tooltip (#17060) @JCQuintas
|
|
163
|
+
|
|
164
|
+
### Tree View
|
|
165
|
+
|
|
166
|
+
#### `@mui/x-tree-view@8.0.0-beta.1`
|
|
167
|
+
|
|
168
|
+
Internal changes.
|
|
169
|
+
|
|
170
|
+
#### `@mui/x-tree-view-pro@8.0.0-beta.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
171
|
+
|
|
172
|
+
Same changes as in `@mui/x-tree-view@8.0.0-beta.1`.
|
|
173
|
+
|
|
174
|
+
### Docs
|
|
175
|
+
|
|
176
|
+
- [docs] Fix 404 (#17033) @alexfauquette
|
|
177
|
+
- [docs] Fix Data Grid advanced list view demo (#17064) @KenanYusuf
|
|
178
|
+
|
|
8
179
|
## 8.0.0-beta.0
|
|
9
180
|
|
|
10
181
|
<img width="100%" alt="MUI X v8 Beta is live" src="https://github.com/user-attachments/assets/61ec4dd8-c946-456b-8b45-d51de8772f5d">
|
|
@@ -25,10 +25,21 @@ const useUtilityClasses = ownerState => {
|
|
|
25
25
|
const {
|
|
26
26
|
classes
|
|
27
27
|
} = ownerState;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return React.useMemo(() => {
|
|
29
|
+
const slots = {
|
|
30
|
+
root: ['root'],
|
|
31
|
+
item: ['item'],
|
|
32
|
+
itemContent: ['itemContent'],
|
|
33
|
+
itemGroupTransition: ['itemGroupTransition'],
|
|
34
|
+
itemIconContainer: ['itemIconContainer'],
|
|
35
|
+
itemLabel: ['itemLabel'],
|
|
36
|
+
itemLabelInput: ['itemLabelInput'],
|
|
37
|
+
itemCheckbox: ['itemCheckbox'],
|
|
38
|
+
itemDragAndDropOverlay: ['itemDragAndDropOverlay'],
|
|
39
|
+
itemErrorIcon: ['itemErrorIcon']
|
|
40
|
+
};
|
|
41
|
+
return (0, _composeClasses.default)(slots, _richTreeViewProClasses.getRichTreeViewProUtilityClass, classes);
|
|
42
|
+
}, [classes]);
|
|
32
43
|
};
|
|
33
44
|
const RichTreeViewProRoot = exports.RichTreeViewProRoot = (0, _zeroStyled.styled)('ul', {
|
|
34
45
|
name: 'MuiRichTreeViewPro',
|
|
@@ -86,7 +97,8 @@ const RichTreeViewPro = exports.RichTreeViewPro = /*#__PURE__*/React.forwardRef(
|
|
|
86
97
|
ownerState: props
|
|
87
98
|
});
|
|
88
99
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.TreeViewProvider, {
|
|
89
|
-
|
|
100
|
+
contextValue: contextValue,
|
|
101
|
+
classes: classes,
|
|
90
102
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Root, (0, _extends2.default)({}, rootProps, {
|
|
91
103
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_internals.RichTreeViewItems, {
|
|
92
104
|
slots: slots,
|
|
@@ -140,8 +152,8 @@ process.env.NODE_ENV !== "production" ? RichTreeViewPro.propTypes = {
|
|
|
140
152
|
classes: _propTypes.default.object,
|
|
141
153
|
className: _propTypes.default.string,
|
|
142
154
|
dataSource: _propTypes.default.shape({
|
|
143
|
-
getChildrenCount: _propTypes.default.func,
|
|
144
|
-
getTreeItems: _propTypes.default.func
|
|
155
|
+
getChildrenCount: _propTypes.default.func.isRequired,
|
|
156
|
+
getTreeItems: _propTypes.default.func.isRequired
|
|
145
157
|
}),
|
|
146
158
|
dataSourceCache: _propTypes.default.shape({
|
|
147
159
|
clear: _propTypes.default.func.isRequired,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
root: string;
|
|
4
|
-
}
|
|
1
|
+
import { TreeViewClasses } from '@mui/x-tree-view/internals';
|
|
2
|
+
export interface RichTreeViewProClasses extends TreeViewClasses {}
|
|
5
3
|
export type RichTreeViewProClassKey = keyof RichTreeViewProClasses;
|
|
6
4
|
export declare function getRichTreeViewProUtilityClass(slot: string): string;
|
|
7
5
|
export declare const richTreeViewProClasses: RichTreeViewProClasses;
|
|
@@ -11,4 +11,4 @@ var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generat
|
|
|
11
11
|
function getRichTreeViewProUtilityClass(slot) {
|
|
12
12
|
return (0, _generateUtilityClass.default)('MuiRichTreeViewPro', slot);
|
|
13
13
|
}
|
|
14
|
-
const richTreeViewProClasses = exports.richTreeViewProClasses = (0, _generateUtilityClasses.default)('MuiRichTreeViewPro', ['root']);
|
|
14
|
+
const richTreeViewProClasses = exports.richTreeViewProClasses = (0, _generateUtilityClasses.default)('MuiRichTreeViewPro', ['root', 'item', 'itemContent', 'itemGroupTransition', 'itemIconContainer', 'itemLabel', 'itemCheckbox', 'itemLabelInput', 'itemDragAndDropOverlay', 'itemErrorIcon', 'itemLoadingIcon']);
|
|
@@ -18,10 +18,21 @@ const useUtilityClasses = ownerState => {
|
|
|
18
18
|
const {
|
|
19
19
|
classes
|
|
20
20
|
} = ownerState;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return React.useMemo(() => {
|
|
22
|
+
const slots = {
|
|
23
|
+
root: ['root'],
|
|
24
|
+
item: ['item'],
|
|
25
|
+
itemContent: ['itemContent'],
|
|
26
|
+
itemGroupTransition: ['itemGroupTransition'],
|
|
27
|
+
itemIconContainer: ['itemIconContainer'],
|
|
28
|
+
itemLabel: ['itemLabel'],
|
|
29
|
+
itemLabelInput: ['itemLabelInput'],
|
|
30
|
+
itemCheckbox: ['itemCheckbox'],
|
|
31
|
+
itemDragAndDropOverlay: ['itemDragAndDropOverlay'],
|
|
32
|
+
itemErrorIcon: ['itemErrorIcon']
|
|
33
|
+
};
|
|
34
|
+
return composeClasses(slots, getRichTreeViewProUtilityClass, classes);
|
|
35
|
+
}, [classes]);
|
|
25
36
|
};
|
|
26
37
|
export const RichTreeViewProRoot = styled('ul', {
|
|
27
38
|
name: 'MuiRichTreeViewPro',
|
|
@@ -79,7 +90,8 @@ const RichTreeViewPro = /*#__PURE__*/React.forwardRef(function RichTreeViewPro(i
|
|
|
79
90
|
ownerState: props
|
|
80
91
|
});
|
|
81
92
|
return /*#__PURE__*/_jsx(TreeViewProvider, {
|
|
82
|
-
|
|
93
|
+
contextValue: contextValue,
|
|
94
|
+
classes: classes,
|
|
83
95
|
children: /*#__PURE__*/_jsxs(Root, _extends({}, rootProps, {
|
|
84
96
|
children: [/*#__PURE__*/_jsx(RichTreeViewItems, {
|
|
85
97
|
slots: slots,
|
|
@@ -133,8 +145,8 @@ process.env.NODE_ENV !== "production" ? RichTreeViewPro.propTypes = {
|
|
|
133
145
|
classes: PropTypes.object,
|
|
134
146
|
className: PropTypes.string,
|
|
135
147
|
dataSource: PropTypes.shape({
|
|
136
|
-
getChildrenCount: PropTypes.func,
|
|
137
|
-
getTreeItems: PropTypes.func
|
|
148
|
+
getChildrenCount: PropTypes.func.isRequired,
|
|
149
|
+
getTreeItems: PropTypes.func.isRequired
|
|
138
150
|
}),
|
|
139
151
|
dataSourceCache: PropTypes.shape({
|
|
140
152
|
clear: PropTypes.func.isRequired,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
root: string;
|
|
4
|
-
}
|
|
1
|
+
import { TreeViewClasses } from '@mui/x-tree-view/internals';
|
|
2
|
+
export interface RichTreeViewProClasses extends TreeViewClasses {}
|
|
5
3
|
export type RichTreeViewProClassKey = keyof RichTreeViewProClasses;
|
|
6
4
|
export declare function getRichTreeViewProUtilityClass(slot: string): string;
|
|
7
5
|
export declare const richTreeViewProClasses: RichTreeViewProClasses;
|
|
@@ -3,4 +3,4 @@ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
|
3
3
|
export function getRichTreeViewProUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiRichTreeViewPro', slot);
|
|
5
5
|
}
|
|
6
|
-
export const richTreeViewProClasses = generateUtilityClasses('MuiRichTreeViewPro', ['root']);
|
|
6
|
+
export const richTreeViewProClasses = generateUtilityClasses('MuiRichTreeViewPro', ['root', 'item', 'itemContent', 'itemGroupTransition', 'itemIconContainer', 'itemLabel', 'itemCheckbox', 'itemLabelInput', 'itemDragAndDropOverlay', 'itemErrorIcon', 'itemLoadingIcon']);
|
package/esm/index.js
CHANGED
package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.itemPlugin.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useTreeViewContext, isTargetInDescendants, useSelector } from '@mui/x-tree-view/internals';
|
|
3
|
-
import {
|
|
3
|
+
import { selectorCanItemBeReordered, selectorDraggedItemProperties, selectorIsItemValidReorderingTarget } from "./useTreeViewItemsReordering.selectors.js";
|
|
4
4
|
export const isAndroid = () => navigator.userAgent.toLowerCase().includes('android');
|
|
5
5
|
export const useTreeViewItemsReorderingItemPlugin = ({
|
|
6
6
|
props
|
|
7
7
|
}) => {
|
|
8
8
|
const {
|
|
9
9
|
instance,
|
|
10
|
-
store
|
|
11
|
-
itemsReordering
|
|
10
|
+
store
|
|
12
11
|
} = useTreeViewContext();
|
|
13
12
|
const {
|
|
14
13
|
itemId
|
|
15
14
|
} = props;
|
|
16
15
|
const validActionsRef = React.useRef(null);
|
|
17
|
-
const draggedItemProperties = useSelector(store,
|
|
18
|
-
const
|
|
16
|
+
const draggedItemProperties = useSelector(store, selectorDraggedItemProperties, itemId);
|
|
17
|
+
const canItemBeReordered = useSelector(store, selectorCanItemBeReordered);
|
|
18
|
+
const isValidTarget = useSelector(store, selectorIsItemValidReorderingTarget, itemId);
|
|
19
19
|
return {
|
|
20
20
|
propsEnhancers: {
|
|
21
21
|
root: ({
|
|
@@ -23,7 +23,7 @@ export const useTreeViewItemsReorderingItemPlugin = ({
|
|
|
23
23
|
contentRefObject,
|
|
24
24
|
externalEventHandlers
|
|
25
25
|
}) => {
|
|
26
|
-
if (!
|
|
26
|
+
if (!canItemBeReordered) {
|
|
27
27
|
return {};
|
|
28
28
|
}
|
|
29
29
|
const handleDragStart = event => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
3
4
|
import { selectorItemIndex, selectorItemMeta, selectorItemOrderedChildrenIds } from '@mui/x-tree-view/internals';
|
|
4
5
|
import { chooseActionToApply, isAncestor, moveItemInTree } from "./useTreeViewItemsReordering.utils.js";
|
|
5
6
|
import { useTreeViewItemsReorderingItemPlugin } from "./useTreeViewItemsReordering.itemPlugin.js";
|
|
6
|
-
import {
|
|
7
|
+
import { selectorCurrentItemReordering } from "./useTreeViewItemsReordering.selectors.js";
|
|
7
8
|
export const useTreeViewItemsReordering = ({
|
|
8
9
|
params,
|
|
9
10
|
store
|
|
@@ -19,18 +20,19 @@ export const useTreeViewItemsReordering = ({
|
|
|
19
20
|
return true;
|
|
20
21
|
}, [params.itemsReordering, params.isItemReorderable]);
|
|
21
22
|
const getDroppingTargetValidActions = React.useCallback(itemId => {
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
23
|
+
const currentReorder = selectorCurrentItemReordering(store.value);
|
|
24
|
+
if (!currentReorder) {
|
|
24
25
|
throw new Error('There is no ongoing reordering.');
|
|
25
26
|
}
|
|
26
|
-
if (itemId ===
|
|
27
|
+
if (itemId === currentReorder.draggedItemId) {
|
|
27
28
|
return {};
|
|
28
29
|
}
|
|
29
30
|
const canMoveItemToNewPosition = params.canMoveItemToNewPosition;
|
|
30
31
|
const targetItemMeta = selectorItemMeta(store.value, itemId);
|
|
31
32
|
const targetItemIndex = selectorItemIndex(store.value, targetItemMeta.id);
|
|
32
|
-
const draggedItemMeta = selectorItemMeta(store.value,
|
|
33
|
+
const draggedItemMeta = selectorItemMeta(store.value, currentReorder.draggedItemId);
|
|
33
34
|
const draggedItemIndex = selectorItemIndex(store.value, draggedItemMeta.id);
|
|
35
|
+
const isTargetLastSibling = targetItemIndex === selectorItemOrderedChildrenIds(store.value, targetItemMeta.parentId).length - 1;
|
|
34
36
|
const oldPosition = {
|
|
35
37
|
parentId: draggedItemMeta.parentId,
|
|
36
38
|
index: draggedItemIndex
|
|
@@ -42,7 +44,7 @@ export const useTreeViewItemsReordering = ({
|
|
|
42
44
|
isValid = false;
|
|
43
45
|
} else if (canMoveItemToNewPosition) {
|
|
44
46
|
isValid = canMoveItemToNewPosition({
|
|
45
|
-
itemId:
|
|
47
|
+
itemId: currentReorder.draggedItemId,
|
|
46
48
|
oldPosition,
|
|
47
49
|
newPosition: positionAfterAction
|
|
48
50
|
});
|
|
@@ -60,10 +62,10 @@ export const useTreeViewItemsReordering = ({
|
|
|
60
62
|
parentId: targetItemMeta.parentId,
|
|
61
63
|
index: targetItemMeta.parentId === draggedItemMeta.parentId && targetItemIndex > draggedItemIndex ? targetItemIndex - 1 : targetItemIndex
|
|
62
64
|
},
|
|
63
|
-
'reorder-below': targetItemMeta.expandable
|
|
65
|
+
'reorder-below': !targetItemMeta.expandable || isTargetLastSibling ? {
|
|
64
66
|
parentId: targetItemMeta.parentId,
|
|
65
67
|
index: targetItemMeta.parentId === draggedItemMeta.parentId && targetItemIndex > draggedItemIndex ? targetItemIndex : targetItemIndex + 1
|
|
66
|
-
},
|
|
68
|
+
} : null,
|
|
67
69
|
'move-to-parent': targetItemMeta.parentId == null ? null : {
|
|
68
70
|
parentId: targetItemMeta.parentId,
|
|
69
71
|
index: selectorItemOrderedChildrenIds(store.value, targetItemMeta.parentId).length
|
|
@@ -80,33 +82,39 @@ export const useTreeViewItemsReordering = ({
|
|
|
80
82
|
}, [store, params.canMoveItemToNewPosition]);
|
|
81
83
|
const startDraggingItem = React.useCallback(itemId => {
|
|
82
84
|
store.update(prevState => _extends({}, prevState, {
|
|
83
|
-
itemsReordering: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
itemsReordering: _extends({}, prevState.itemsReordering, {
|
|
86
|
+
currentReorder: {
|
|
87
|
+
targetItemId: itemId,
|
|
88
|
+
draggedItemId: itemId,
|
|
89
|
+
action: null,
|
|
90
|
+
newPosition: null
|
|
91
|
+
}
|
|
92
|
+
})
|
|
89
93
|
}));
|
|
90
94
|
}, [store]);
|
|
91
95
|
const stopDraggingItem = React.useCallback(itemId => {
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
96
|
+
const currentReorder = selectorCurrentItemReordering(store.value);
|
|
97
|
+
if (currentReorder == null || currentReorder.draggedItemId !== itemId) {
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
|
-
if (
|
|
100
|
+
if (currentReorder.draggedItemId === currentReorder.targetItemId || currentReorder.action == null || currentReorder.newPosition == null) {
|
|
97
101
|
store.update(prevState => _extends({}, prevState, {
|
|
98
|
-
itemsReordering:
|
|
102
|
+
itemsReordering: _extends({}, prevState.itemsReordering, {
|
|
103
|
+
currentReorder: null
|
|
104
|
+
})
|
|
99
105
|
}));
|
|
100
106
|
return;
|
|
101
107
|
}
|
|
102
|
-
const draggedItemMeta = selectorItemMeta(store.value,
|
|
108
|
+
const draggedItemMeta = selectorItemMeta(store.value, currentReorder.draggedItemId);
|
|
103
109
|
const oldPosition = {
|
|
104
110
|
parentId: draggedItemMeta.parentId,
|
|
105
111
|
index: selectorItemIndex(store.value, draggedItemMeta.id)
|
|
106
112
|
};
|
|
107
|
-
const newPosition =
|
|
113
|
+
const newPosition = currentReorder.newPosition;
|
|
108
114
|
store.update(prevState => _extends({}, prevState, {
|
|
109
|
-
itemsReordering:
|
|
115
|
+
itemsReordering: _extends({}, prevState.itemsReordering, {
|
|
116
|
+
currentReorder: null
|
|
117
|
+
}),
|
|
110
118
|
items: moveItemInTree({
|
|
111
119
|
itemToMoveId: itemId,
|
|
112
120
|
newPosition,
|
|
@@ -130,8 +138,8 @@ export const useTreeViewItemsReordering = ({
|
|
|
130
138
|
contentElement
|
|
131
139
|
}) => {
|
|
132
140
|
store.update(prevState => {
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
141
|
+
const prevItemReorder = prevState.itemsReordering.currentReorder;
|
|
142
|
+
if (prevItemReorder == null || isAncestor(store, itemId, prevItemReorder.draggedItemId)) {
|
|
135
143
|
return prevState;
|
|
136
144
|
}
|
|
137
145
|
const action = chooseActionToApply({
|
|
@@ -144,24 +152,27 @@ export const useTreeViewItemsReordering = ({
|
|
|
144
152
|
contentElement
|
|
145
153
|
});
|
|
146
154
|
const newPosition = action == null ? null : validActions[action];
|
|
147
|
-
if (
|
|
155
|
+
if (prevItemReorder.targetItemId === itemId && prevItemReorder.action === action && prevItemReorder.newPosition?.parentId === newPosition?.parentId && prevItemReorder.newPosition?.index === newPosition?.index) {
|
|
148
156
|
return prevState;
|
|
149
157
|
}
|
|
150
158
|
return _extends({}, prevState, {
|
|
151
|
-
itemsReordering: _extends({},
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
itemsReordering: _extends({}, prevState.itemsReordering, {
|
|
160
|
+
currentReorder: _extends({}, prevItemReorder, {
|
|
161
|
+
targetItemId: itemId,
|
|
162
|
+
newPosition,
|
|
163
|
+
action
|
|
164
|
+
})
|
|
155
165
|
})
|
|
156
166
|
});
|
|
157
167
|
});
|
|
158
168
|
}, [store, params.itemChildrenIndentation]);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
useEnhancedEffect(() => {
|
|
170
|
+
store.update(prevState => _extends({}, prevState, {
|
|
171
|
+
itemsReordering: _extends({}, prevState.itemsReordering, {
|
|
172
|
+
isItemReorderable: params.itemsReordering ? params.isItemReorderable ?? (() => true) : () => false
|
|
173
|
+
})
|
|
174
|
+
}));
|
|
175
|
+
}, [store, params.itemsReordering, params.isItemReorderable]);
|
|
165
176
|
return {
|
|
166
177
|
instance: {
|
|
167
178
|
canItemBeDragged,
|
|
@@ -169,8 +180,7 @@ export const useTreeViewItemsReordering = ({
|
|
|
169
180
|
startDraggingItem,
|
|
170
181
|
stopDraggingItem,
|
|
171
182
|
setDragTargetItem
|
|
172
|
-
}
|
|
173
|
-
contextValue: pluginContextValue
|
|
183
|
+
}
|
|
174
184
|
};
|
|
175
185
|
};
|
|
176
186
|
useTreeViewItemsReordering.itemPlugin = useTreeViewItemsReorderingItemPlugin;
|
|
@@ -179,8 +189,11 @@ useTreeViewItemsReordering.getDefaultizedParams = ({
|
|
|
179
189
|
}) => _extends({}, params, {
|
|
180
190
|
itemsReordering: params.itemsReordering ?? false
|
|
181
191
|
});
|
|
182
|
-
useTreeViewItemsReordering.getInitialState =
|
|
183
|
-
itemsReordering:
|
|
192
|
+
useTreeViewItemsReordering.getInitialState = params => ({
|
|
193
|
+
itemsReordering: {
|
|
194
|
+
currentReorder: null,
|
|
195
|
+
isItemReorderable: params.itemsReordering ? params.isItemReorderable ?? (() => true) : () => false
|
|
196
|
+
}
|
|
184
197
|
});
|
|
185
198
|
useTreeViewItemsReordering.params = {
|
|
186
199
|
itemsReordering: true,
|