@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/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.d.ts
CHANGED
|
@@ -1,23 +1,84 @@
|
|
|
1
1
|
import { TreeViewState } from '@mui/x-tree-view/internals';
|
|
2
2
|
import { UseTreeViewItemsReorderingSignature } from "./useTreeViewItemsReordering.types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Get the
|
|
4
|
+
* Get the properties of the current reordering.
|
|
5
5
|
* @param {TreeViewState<[UseTreeViewItemsReorderingSignature]>} state The state of the tree view.
|
|
6
|
-
* @returns {TreeViewItemsReorderingState
|
|
6
|
+
* @returns {TreeViewItemsReorderingState['currentReorder']} The properties of the current reordering.
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const selectorCurrentItemReordering: ((state: import("@mui/x-tree-view/internals/corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & import("./useTreeViewItemsReordering.types").UseTreeViewItemsReorderingState & Partial<{}> & {
|
|
9
|
+
cacheKey: import("@mui/x-tree-view/internals/models").TreeViewStateCacheKey;
|
|
10
|
+
}) => {
|
|
9
11
|
draggedItemId: string;
|
|
10
12
|
targetItemId: string;
|
|
11
13
|
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
12
14
|
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
13
|
-
} | null
|
|
15
|
+
} | null) & {
|
|
16
|
+
clearCache: () => void;
|
|
17
|
+
resultsCount: () => number;
|
|
18
|
+
resetResultsCount: () => void;
|
|
19
|
+
} & {
|
|
20
|
+
resultFunc: (resultFuncArgs_0: {
|
|
21
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
22
|
+
currentReorder: {
|
|
23
|
+
draggedItemId: string;
|
|
24
|
+
targetItemId: string;
|
|
25
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
26
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
27
|
+
} | null;
|
|
28
|
+
}) => {
|
|
29
|
+
draggedItemId: string;
|
|
30
|
+
targetItemId: string;
|
|
31
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
32
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
33
|
+
} | null;
|
|
34
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
35
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
36
|
+
currentReorder: {
|
|
37
|
+
draggedItemId: string;
|
|
38
|
+
targetItemId: string;
|
|
39
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
40
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
41
|
+
} | null;
|
|
42
|
+
}) => {
|
|
43
|
+
draggedItemId: string;
|
|
44
|
+
targetItemId: string;
|
|
45
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
46
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
47
|
+
} | null) & {
|
|
48
|
+
clearCache: () => void;
|
|
49
|
+
resultsCount: () => number;
|
|
50
|
+
resetResultsCount: () => void;
|
|
51
|
+
};
|
|
52
|
+
lastResult: () => {
|
|
53
|
+
draggedItemId: string;
|
|
54
|
+
targetItemId: string;
|
|
55
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
56
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
57
|
+
} | null;
|
|
58
|
+
dependencies: [(state: TreeViewState<[UseTreeViewItemsReorderingSignature]>) => {
|
|
59
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
60
|
+
currentReorder: {
|
|
61
|
+
draggedItemId: string;
|
|
62
|
+
targetItemId: string;
|
|
63
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
64
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
65
|
+
} | null;
|
|
66
|
+
}];
|
|
67
|
+
recomputations: () => number;
|
|
68
|
+
resetRecomputations: () => void;
|
|
69
|
+
dependencyRecomputations: () => number;
|
|
70
|
+
resetDependencyRecomputations: () => void;
|
|
71
|
+
} & {
|
|
72
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
73
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
74
|
+
};
|
|
14
75
|
/**
|
|
15
76
|
* Get the properties of the dragged item.
|
|
16
77
|
* @param {TreeViewState<[UseTreeViewItemsSignature, UseTreeViewItemsReorderingSignature]>} state The state of the tree view.
|
|
17
78
|
* @param {string} itemId The id of the item.
|
|
18
79
|
* @returns {TreeViewItemDraggedItemProperties | null} The properties of the dragged item if the current item is being dragged, `null` otherwise.
|
|
19
80
|
*/
|
|
20
|
-
export declare const
|
|
81
|
+
export declare const selectorDraggedItemProperties: ((state: any, itemId: string) => {
|
|
21
82
|
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
22
83
|
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction;
|
|
23
84
|
targetDepth: number;
|
|
@@ -59,12 +120,73 @@ export declare const selectorItemsReorderingDraggedItemProperties: ((state: any,
|
|
|
59
120
|
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction;
|
|
60
121
|
targetDepth: number;
|
|
61
122
|
} | null;
|
|
62
|
-
dependencies: [(state:
|
|
123
|
+
dependencies: [((state: import("@mui/x-tree-view/internals/corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & import("./useTreeViewItemsReordering.types").UseTreeViewItemsReorderingState & Partial<{}> & {
|
|
124
|
+
cacheKey: import("@mui/x-tree-view/internals/models").TreeViewStateCacheKey;
|
|
125
|
+
}) => {
|
|
63
126
|
draggedItemId: string;
|
|
64
127
|
targetItemId: string;
|
|
65
128
|
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
66
129
|
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
67
|
-
} | null
|
|
130
|
+
} | null) & {
|
|
131
|
+
clearCache: () => void;
|
|
132
|
+
resultsCount: () => number;
|
|
133
|
+
resetResultsCount: () => void;
|
|
134
|
+
} & {
|
|
135
|
+
resultFunc: (resultFuncArgs_0: {
|
|
136
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
137
|
+
currentReorder: {
|
|
138
|
+
draggedItemId: string;
|
|
139
|
+
targetItemId: string;
|
|
140
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
141
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
142
|
+
} | null;
|
|
143
|
+
}) => {
|
|
144
|
+
draggedItemId: string;
|
|
145
|
+
targetItemId: string;
|
|
146
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
147
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
148
|
+
} | null;
|
|
149
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
150
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
151
|
+
currentReorder: {
|
|
152
|
+
draggedItemId: string;
|
|
153
|
+
targetItemId: string;
|
|
154
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
155
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
156
|
+
} | null;
|
|
157
|
+
}) => {
|
|
158
|
+
draggedItemId: string;
|
|
159
|
+
targetItemId: string;
|
|
160
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
161
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
162
|
+
} | null) & {
|
|
163
|
+
clearCache: () => void;
|
|
164
|
+
resultsCount: () => number;
|
|
165
|
+
resetResultsCount: () => void;
|
|
166
|
+
};
|
|
167
|
+
lastResult: () => {
|
|
168
|
+
draggedItemId: string;
|
|
169
|
+
targetItemId: string;
|
|
170
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
171
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
172
|
+
} | null;
|
|
173
|
+
dependencies: [(state: TreeViewState<[UseTreeViewItemsReorderingSignature]>) => {
|
|
174
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
175
|
+
currentReorder: {
|
|
176
|
+
draggedItemId: string;
|
|
177
|
+
targetItemId: string;
|
|
178
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
179
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
180
|
+
} | null;
|
|
181
|
+
}];
|
|
182
|
+
recomputations: () => number;
|
|
183
|
+
resetRecomputations: () => void;
|
|
184
|
+
dependencyRecomputations: () => number;
|
|
185
|
+
resetDependencyRecomputations: () => void;
|
|
186
|
+
} & {
|
|
187
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
188
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
189
|
+
}, ((state: import("@mui/x-tree-view/internals/corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & import("@mui/x-tree-view/internals").UseTreeViewItemsState<import("@mui/x-tree-view").TreeViewDefaultItemModelProperties> & Partial<{}> & {
|
|
68
190
|
cacheKey: import("@mui/x-tree-view/internals/models").TreeViewStateCacheKey;
|
|
69
191
|
}) => {
|
|
70
192
|
[itemId: string]: import("@mui/x-tree-view/internals").TreeViewItemMeta;
|
|
@@ -145,7 +267,7 @@ export declare const selectorItemsReorderingDraggedItemProperties: ((state: any,
|
|
|
145
267
|
* @param {string} itemId The id of the item.
|
|
146
268
|
* @returns {boolean} `true` if the current item is a valid target for the dragged item, `false` otherwise.
|
|
147
269
|
*/
|
|
148
|
-
export declare const
|
|
270
|
+
export declare const selectorIsItemValidReorderingTarget: ((state: any, itemId: string) => boolean | null) & {
|
|
149
271
|
clearCache: () => void;
|
|
150
272
|
resultsCount: () => number;
|
|
151
273
|
resetResultsCount: () => void;
|
|
@@ -167,12 +289,124 @@ export declare const selectorItemsReorderingIsValidTarget: ((state: any, itemId:
|
|
|
167
289
|
resetResultsCount: () => void;
|
|
168
290
|
};
|
|
169
291
|
lastResult: () => boolean | null;
|
|
170
|
-
dependencies: [(state:
|
|
292
|
+
dependencies: [((state: import("@mui/x-tree-view/internals/corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & import("./useTreeViewItemsReordering.types").UseTreeViewItemsReorderingState & Partial<{}> & {
|
|
293
|
+
cacheKey: import("@mui/x-tree-view/internals/models").TreeViewStateCacheKey;
|
|
294
|
+
}) => {
|
|
171
295
|
draggedItemId: string;
|
|
172
296
|
targetItemId: string;
|
|
173
297
|
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
174
298
|
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
175
|
-
} | null
|
|
299
|
+
} | null) & {
|
|
300
|
+
clearCache: () => void;
|
|
301
|
+
resultsCount: () => number;
|
|
302
|
+
resetResultsCount: () => void;
|
|
303
|
+
} & {
|
|
304
|
+
resultFunc: (resultFuncArgs_0: {
|
|
305
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
306
|
+
currentReorder: {
|
|
307
|
+
draggedItemId: string;
|
|
308
|
+
targetItemId: string;
|
|
309
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
310
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
311
|
+
} | null;
|
|
312
|
+
}) => {
|
|
313
|
+
draggedItemId: string;
|
|
314
|
+
targetItemId: string;
|
|
315
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
316
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
317
|
+
} | null;
|
|
318
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
319
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
320
|
+
currentReorder: {
|
|
321
|
+
draggedItemId: string;
|
|
322
|
+
targetItemId: string;
|
|
323
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
324
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
325
|
+
} | null;
|
|
326
|
+
}) => {
|
|
327
|
+
draggedItemId: string;
|
|
328
|
+
targetItemId: string;
|
|
329
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
330
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
331
|
+
} | null) & {
|
|
332
|
+
clearCache: () => void;
|
|
333
|
+
resultsCount: () => number;
|
|
334
|
+
resetResultsCount: () => void;
|
|
335
|
+
};
|
|
336
|
+
lastResult: () => {
|
|
337
|
+
draggedItemId: string;
|
|
338
|
+
targetItemId: string;
|
|
339
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
340
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
341
|
+
} | null;
|
|
342
|
+
dependencies: [(state: TreeViewState<[UseTreeViewItemsReorderingSignature]>) => {
|
|
343
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
344
|
+
currentReorder: {
|
|
345
|
+
draggedItemId: string;
|
|
346
|
+
targetItemId: string;
|
|
347
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
348
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
349
|
+
} | null;
|
|
350
|
+
}];
|
|
351
|
+
recomputations: () => number;
|
|
352
|
+
resetRecomputations: () => void;
|
|
353
|
+
dependencyRecomputations: () => number;
|
|
354
|
+
resetDependencyRecomputations: () => void;
|
|
355
|
+
} & {
|
|
356
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
357
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
358
|
+
}, (_: any, itemId: string) => string];
|
|
359
|
+
recomputations: () => number;
|
|
360
|
+
resetRecomputations: () => void;
|
|
361
|
+
dependencyRecomputations: () => number;
|
|
362
|
+
resetDependencyRecomputations: () => void;
|
|
363
|
+
} & {
|
|
364
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
365
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Check if the items can be reordered.
|
|
369
|
+
* @param {TreeViewState<[UseTreeViewItemsReorderingSignature]>} state The state of the tree view.
|
|
370
|
+
* @param {string} itemId The id of the item.
|
|
371
|
+
* @returns {boolean} `true` if the items can be reordered, `false` otherwise.
|
|
372
|
+
*/
|
|
373
|
+
export declare const selectorCanItemBeReordered: ((state: any, itemId: string) => boolean) & {
|
|
374
|
+
clearCache: () => void;
|
|
375
|
+
resultsCount: () => number;
|
|
376
|
+
resetResultsCount: () => void;
|
|
377
|
+
} & {
|
|
378
|
+
resultFunc: (resultFuncArgs_0: {
|
|
379
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
380
|
+
currentReorder: {
|
|
381
|
+
draggedItemId: string;
|
|
382
|
+
targetItemId: string;
|
|
383
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
384
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
385
|
+
} | null;
|
|
386
|
+
}, resultFuncArgs_1: string) => boolean;
|
|
387
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
388
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
389
|
+
currentReorder: {
|
|
390
|
+
draggedItemId: string;
|
|
391
|
+
targetItemId: string;
|
|
392
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
393
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
394
|
+
} | null;
|
|
395
|
+
}, resultFuncArgs_1: string) => boolean) & {
|
|
396
|
+
clearCache: () => void;
|
|
397
|
+
resultsCount: () => number;
|
|
398
|
+
resetResultsCount: () => void;
|
|
399
|
+
};
|
|
400
|
+
lastResult: () => boolean;
|
|
401
|
+
dependencies: [(state: TreeViewState<[UseTreeViewItemsReorderingSignature]>) => {
|
|
402
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
403
|
+
currentReorder: {
|
|
404
|
+
draggedItemId: string;
|
|
405
|
+
targetItemId: string;
|
|
406
|
+
newPosition: import("./useTreeViewItemsReordering.types").TreeViewItemReorderPosition | null;
|
|
407
|
+
action: import("@mui/x-tree-view").TreeViewItemsReorderingAction | null;
|
|
408
|
+
} | null;
|
|
409
|
+
}, (_: any, itemId: string) => string];
|
|
176
410
|
recomputations: () => number;
|
|
177
411
|
resetRecomputations: () => void;
|
|
178
412
|
dependencyRecomputations: () => number;
|
package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.selectors.js
CHANGED
|
@@ -2,9 +2,16 @@ import { createSelector, selectorItemMetaLookup } from '@mui/x-tree-view/interna
|
|
|
2
2
|
/**
|
|
3
3
|
* Get the items reordering state.
|
|
4
4
|
* @param {TreeViewState<[UseTreeViewItemsReorderingSignature]>} state The state of the tree view.
|
|
5
|
-
* @returns {TreeViewItemsReorderingState
|
|
5
|
+
* @returns {TreeViewItemsReorderingState} The items reordering state.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
const selectorItemsReordering = state => state.itemsReordering;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get the properties of the current reordering.
|
|
11
|
+
* @param {TreeViewState<[UseTreeViewItemsReorderingSignature]>} state The state of the tree view.
|
|
12
|
+
* @returns {TreeViewItemsReorderingState['currentReorder']} The properties of the current reordering.
|
|
13
|
+
*/
|
|
14
|
+
export const selectorCurrentItemReordering = createSelector([selectorItemsReordering], itemsReordering => itemsReordering.currentReorder);
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* Get the properties of the dragged item.
|
|
@@ -12,16 +19,16 @@ export const selectorItemsReordering = state => state.itemsReordering;
|
|
|
12
19
|
* @param {string} itemId The id of the item.
|
|
13
20
|
* @returns {TreeViewItemDraggedItemProperties | null} The properties of the dragged item if the current item is being dragged, `null` otherwise.
|
|
14
21
|
*/
|
|
15
|
-
export const
|
|
16
|
-
if (!
|
|
22
|
+
export const selectorDraggedItemProperties = createSelector([selectorCurrentItemReordering, selectorItemMetaLookup, (_, itemId) => itemId], (currentReorder, itemMetaLookup, itemId) => {
|
|
23
|
+
if (!currentReorder || currentReorder.targetItemId !== itemId || currentReorder.action == null) {
|
|
17
24
|
return null;
|
|
18
25
|
}
|
|
19
|
-
const targetDepth =
|
|
26
|
+
const targetDepth = currentReorder.newPosition?.parentId == null ? 0 :
|
|
20
27
|
// The depth is always defined because drag&drop is only usable with Rich Tree View components.
|
|
21
28
|
itemMetaLookup[itemId].depth + 1;
|
|
22
29
|
return {
|
|
23
|
-
newPosition:
|
|
24
|
-
action:
|
|
30
|
+
newPosition: currentReorder.newPosition,
|
|
31
|
+
action: currentReorder.action,
|
|
25
32
|
targetDepth
|
|
26
33
|
};
|
|
27
34
|
});
|
|
@@ -32,4 +39,12 @@ export const selectorItemsReorderingDraggedItemProperties = createSelector([sele
|
|
|
32
39
|
* @param {string} itemId The id of the item.
|
|
33
40
|
* @returns {boolean} `true` if the current item is a valid target for the dragged item, `false` otherwise.
|
|
34
41
|
*/
|
|
35
|
-
export const
|
|
42
|
+
export const selectorIsItemValidReorderingTarget = createSelector([selectorCurrentItemReordering, (_, itemId) => itemId], (currentReorder, itemId) => currentReorder && currentReorder.draggedItemId !== itemId);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if the items can be reordered.
|
|
46
|
+
* @param {TreeViewState<[UseTreeViewItemsReorderingSignature]>} state The state of the tree view.
|
|
47
|
+
* @param {string} itemId The id of the item.
|
|
48
|
+
* @returns {boolean} `true` if the items can be reordered, `false` otherwise.
|
|
49
|
+
*/
|
|
50
|
+
export const selectorCanItemBeReordered = createSelector([selectorItemsReordering, (_, itemId) => itemId], (itemsReordering, itemId) => itemsReordering.isItemReorderable(itemId));
|
package/esm/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.types.d.ts
CHANGED
|
@@ -93,16 +93,13 @@ export interface UseTreeViewItemsReorderingParameters {
|
|
|
93
93
|
export type UseTreeViewItemsReorderingDefaultizedParameters = DefaultizedProps<UseTreeViewItemsReorderingParameters, 'itemsReordering'>;
|
|
94
94
|
export interface UseTreeViewItemsReorderingState {
|
|
95
95
|
itemsReordering: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
itemsReordering: {
|
|
104
|
-
enabled: boolean;
|
|
105
|
-
isItemReorderable: ((itemId: string) => boolean) | undefined;
|
|
96
|
+
isItemReorderable: (itemId: string) => boolean;
|
|
97
|
+
currentReorder: {
|
|
98
|
+
draggedItemId: string;
|
|
99
|
+
targetItemId: string;
|
|
100
|
+
newPosition: TreeViewItemReorderPosition | null;
|
|
101
|
+
action: TreeViewItemsReorderingAction | null;
|
|
102
|
+
} | null;
|
|
106
103
|
};
|
|
107
104
|
}
|
|
108
105
|
export type UseTreeViewItemsReorderingSignature = TreeViewPluginSignature<{
|
|
@@ -110,7 +107,6 @@ export type UseTreeViewItemsReorderingSignature = TreeViewPluginSignature<{
|
|
|
110
107
|
defaultizedParams: UseTreeViewItemsReorderingDefaultizedParameters;
|
|
111
108
|
instance: UseTreeViewItemsReorderingInstance;
|
|
112
109
|
state: UseTreeViewItemsReorderingState;
|
|
113
|
-
contextValue: UseTreeViewItemsReorderingContextValue;
|
|
114
110
|
dependencies: [UseTreeViewItemsSignature];
|
|
115
111
|
}>;
|
|
116
112
|
export interface UseTreeItemRootSlotPropsFromItemsReordering {
|
|
@@ -128,5 +124,4 @@ declare module '@mui/x-tree-view/useTreeItem' {
|
|
|
128
124
|
interface UseTreeItemRootSlotOwnProps extends UseTreeItemRootSlotPropsFromItemsReordering {}
|
|
129
125
|
interface UseTreeItemContentSlotOwnProps extends UseTreeItemContentSlotPropsFromItemsReordering {}
|
|
130
126
|
interface UseTreeItemDragAndDropOverlaySlotOwnProps extends UseTreeItemDragAndDropOverlaySlotPropsFromItemsReordering {}
|
|
131
|
-
}
|
|
132
|
-
export {};
|
|
127
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
|
-
import { warnOnce } from '@mui/x-internals/warning';
|
|
5
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
5
|
import { selectorItemMeta, selectorIsItemSelected, useInstanceEventHandler, selectorDataSourceState, selectorGetTreeItemError } from '@mui/x-tree-view/internals';
|
|
7
6
|
import { DataSourceCacheDefault } from '@mui/x-tree-view/utils';
|
|
@@ -26,7 +25,7 @@ export const useTreeViewLazyLoading = ({
|
|
|
26
25
|
params,
|
|
27
26
|
store
|
|
28
27
|
}) => {
|
|
29
|
-
const isLazyLoadingEnabled = params.dataSource
|
|
28
|
+
const isLazyLoadingEnabled = !!params.dataSource;
|
|
30
29
|
const firstRenderRef = React.useRef(true);
|
|
31
30
|
const nestedDataManager = useLazyRef(() => new NestedDataManager(instance)).current;
|
|
32
31
|
const cacheRef = useLazyRef(() => getCache(params.dataSourceCache));
|
|
@@ -258,24 +257,6 @@ export const useTreeViewLazyLoading = ({
|
|
|
258
257
|
publicAPI: {}
|
|
259
258
|
};
|
|
260
259
|
};
|
|
261
|
-
useTreeViewLazyLoading.getDefaultizedParams = ({
|
|
262
|
-
params,
|
|
263
|
-
experimentalFeatures
|
|
264
|
-
}) => {
|
|
265
|
-
const canUseFeature = experimentalFeatures?.lazyLoading;
|
|
266
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
267
|
-
if (params.dataSource && !canUseFeature) {
|
|
268
|
-
warnOnce(['MUI X: The label editing feature requires the `lazyLoading` experimental feature to be enabled.', 'You can do it by passing `experimentalFeatures={{ lazyLoading: true}}` to the Rich Tree View Pro component.', 'Check the documentation for more details: https://mui.com/x/react-tree-view/rich-tree-view/lazy-loading/']);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
const defaultDataSource = params?.dataSource ?? {
|
|
272
|
-
getChildrenCount: () => 0,
|
|
273
|
-
getTreeItems: () => Promise.resolve([])
|
|
274
|
-
};
|
|
275
|
-
return _extends({}, params, {
|
|
276
|
-
dataSource: canUseFeature ? defaultDataSource : {}
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
260
|
useTreeViewLazyLoading.getInitialState = () => ({
|
|
280
261
|
lazyLoading: {
|
|
281
262
|
enabled: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ponyfillGlobal from '@mui/utils/ponyfillGlobal';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTc0MzExMjgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
package/index.js
CHANGED
package/internals/plugins/useTreeViewItemsReordering/useTreeViewItemsReordering.itemPlugin.js
CHANGED
|
@@ -15,15 +15,15 @@ const useTreeViewItemsReorderingItemPlugin = ({
|
|
|
15
15
|
}) => {
|
|
16
16
|
const {
|
|
17
17
|
instance,
|
|
18
|
-
store
|
|
19
|
-
itemsReordering
|
|
18
|
+
store
|
|
20
19
|
} = (0, _internals.useTreeViewContext)();
|
|
21
20
|
const {
|
|
22
21
|
itemId
|
|
23
22
|
} = props;
|
|
24
23
|
const validActionsRef = React.useRef(null);
|
|
25
|
-
const draggedItemProperties = (0, _internals.useSelector)(store, _useTreeViewItemsReordering.
|
|
26
|
-
const
|
|
24
|
+
const draggedItemProperties = (0, _internals.useSelector)(store, _useTreeViewItemsReordering.selectorDraggedItemProperties, itemId);
|
|
25
|
+
const canItemBeReordered = (0, _internals.useSelector)(store, _useTreeViewItemsReordering.selectorCanItemBeReordered);
|
|
26
|
+
const isValidTarget = (0, _internals.useSelector)(store, _useTreeViewItemsReordering.selectorIsItemValidReorderingTarget, itemId);
|
|
27
27
|
return {
|
|
28
28
|
propsEnhancers: {
|
|
29
29
|
root: ({
|
|
@@ -31,7 +31,7 @@ const useTreeViewItemsReorderingItemPlugin = ({
|
|
|
31
31
|
contentRefObject,
|
|
32
32
|
externalEventHandlers
|
|
33
33
|
}) => {
|
|
34
|
-
if (!
|
|
34
|
+
if (!canItemBeReordered) {
|
|
35
35
|
return {};
|
|
36
36
|
}
|
|
37
37
|
const handleDragStart = event => {
|