@mui/x-tree-view 8.0.0-alpha.13 → 8.0.0-alpha.14
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 +131 -0
- package/RichTreeView/RichTreeView.js +24 -5
- package/SimpleTreeView/SimpleTreeView.js +8 -6
- package/TreeItem/TreeItem.d.ts +2 -0
- package/TreeItem/TreeItem.js +46 -5
- package/TreeItem/TreeItem.types.d.ts +14 -0
- package/TreeItemIcon/TreeItemIcon.js +2 -0
- package/esm/RichTreeView/RichTreeView.js +24 -5
- package/esm/SimpleTreeView/SimpleTreeView.js +8 -6
- package/esm/TreeItem/TreeItem.d.ts +2 -0
- package/esm/TreeItem/TreeItem.js +45 -4
- package/esm/TreeItem/TreeItem.types.d.ts +14 -0
- package/esm/TreeItemIcon/TreeItemIcon.js +2 -0
- package/esm/hooks/useTreeItemUtils/useTreeItemUtils.d.ts +3 -2
- package/esm/hooks/useTreeItemUtils/useTreeItemUtils.js +21 -9
- package/esm/hooks/useTreeViewApiRef.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +6 -1
- package/esm/internals/index.js +4 -1
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +35 -12
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.d.ts +4 -0
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +40 -16
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.js +157 -16
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +172 -0
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +13 -0
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +49 -0
- package/esm/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +2 -2
- package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +16 -7
- package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewLazyLoading/index.d.ts +1 -0
- package/esm/internals/plugins/useTreeViewLazyLoading/index.js +1 -0
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.d.ts +249 -0
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.js +27 -0
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +83 -0
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.js +1 -0
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +4 -4
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +12 -12
- package/esm/internals/utils/selectors.d.ts +7 -0
- package/esm/internals/utils/selectors.js +9 -0
- package/esm/useTreeItem/useTreeItem.d.ts +1 -1
- package/esm/useTreeItem/useTreeItem.js +13 -0
- package/esm/useTreeItem/useTreeItem.types.d.ts +21 -0
- package/esm/utils/cache.d.ts +38 -0
- package/esm/utils/cache.js +31 -0
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +1 -0
- package/hooks/useTreeItemUtils/useTreeItemUtils.d.ts +3 -2
- package/hooks/useTreeItemUtils/useTreeItemUtils.js +22 -10
- package/hooks/useTreeViewApiRef.d.ts +1 -1
- package/index.js +1 -1
- package/internals/index.d.ts +6 -1
- package/internals/index.js +33 -0
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +35 -12
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.d.ts +4 -0
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +40 -16
- package/internals/plugins/useTreeViewItems/useTreeViewItems.js +157 -16
- package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +172 -0
- package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +14 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +49 -0
- package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +1 -1
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +16 -7
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +2 -1
- package/internals/plugins/useTreeViewLazyLoading/index.d.ts +1 -0
- package/internals/plugins/useTreeViewLazyLoading/index.js +5 -0
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.d.ts +249 -0
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.js +33 -0
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +83 -0
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.js +5 -0
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +4 -4
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +12 -12
- package/internals/utils/selectors.d.ts +7 -0
- package/internals/utils/selectors.js +9 -0
- package/modern/RichTreeView/RichTreeView.js +24 -5
- package/modern/SimpleTreeView/SimpleTreeView.js +8 -6
- package/modern/TreeItem/TreeItem.d.ts +2 -0
- package/modern/TreeItem/TreeItem.js +45 -4
- package/modern/TreeItem/TreeItem.types.d.ts +14 -0
- package/modern/TreeItemIcon/TreeItemIcon.js +2 -0
- package/modern/hooks/useTreeItemUtils/useTreeItemUtils.d.ts +3 -2
- package/modern/hooks/useTreeItemUtils/useTreeItemUtils.js +21 -9
- package/modern/hooks/useTreeViewApiRef.d.ts +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/index.d.ts +6 -1
- package/modern/internals/index.js +4 -1
- package/modern/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +35 -12
- package/modern/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.d.ts +4 -0
- package/modern/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +40 -16
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.js +157 -16
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +172 -0
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +13 -0
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +49 -0
- package/modern/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +2 -2
- package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +16 -7
- package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +2 -1
- package/modern/internals/plugins/useTreeViewLazyLoading/index.d.ts +1 -0
- package/modern/internals/plugins/useTreeViewLazyLoading/index.js +1 -0
- package/modern/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.d.ts +249 -0
- package/modern/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.js +27 -0
- package/modern/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +83 -0
- package/modern/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.js +1 -0
- package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +4 -4
- package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +12 -12
- package/modern/internals/utils/selectors.d.ts +7 -0
- package/modern/internals/utils/selectors.js +9 -0
- package/modern/useTreeItem/useTreeItem.d.ts +1 -1
- package/modern/useTreeItem/useTreeItem.js +13 -0
- package/modern/useTreeItem/useTreeItem.types.d.ts +21 -0
- package/modern/utils/cache.d.ts +38 -0
- package/modern/utils/cache.js +31 -0
- package/modern/utils/index.d.ts +1 -0
- package/modern/utils/index.js +1 -0
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/useTreeItem/useTreeItem.d.ts +1 -1
- package/useTreeItem/useTreeItem.js +13 -0
- package/useTreeItem/useTreeItem.types.d.ts +21 -0
- package/utils/cache.d.ts +38 -0
- package/utils/cache.js +38 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +16 -0
package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js
CHANGED
|
@@ -64,7 +64,7 @@ export const useTreeViewKeyboardNavigation = ({
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
// ARIA specification: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/#keyboardinteraction
|
|
67
|
-
const handleItemKeyDown = (event, itemId) => {
|
|
67
|
+
const handleItemKeyDown = async (event, itemId) => {
|
|
68
68
|
if (event.defaultMuiPrevented) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
@@ -83,7 +83,7 @@ export const useTreeViewKeyboardNavigation = ({
|
|
|
83
83
|
if (params.multiSelect && event.shiftKey) {
|
|
84
84
|
instance.expandSelectionRange(event, itemId);
|
|
85
85
|
} else {
|
|
86
|
-
instance.
|
|
86
|
+
instance.setItemSelection({
|
|
87
87
|
event,
|
|
88
88
|
itemId,
|
|
89
89
|
keepExistingSelection: params.multiSelect,
|
|
@@ -103,18 +103,21 @@ export const useTreeViewKeyboardNavigation = ({
|
|
|
103
103
|
}) && !selectorIsItemBeingEdited(store.value, itemId)) {
|
|
104
104
|
instance.setEditedItemId(itemId);
|
|
105
105
|
} else if (canToggleItemExpansion(itemId)) {
|
|
106
|
-
instance.
|
|
106
|
+
instance.setItemExpansion({
|
|
107
|
+
event,
|
|
108
|
+
itemId
|
|
109
|
+
});
|
|
107
110
|
event.preventDefault();
|
|
108
111
|
} else if (canToggleItemSelection(itemId)) {
|
|
109
112
|
if (params.multiSelect) {
|
|
110
113
|
event.preventDefault();
|
|
111
|
-
instance.
|
|
114
|
+
instance.setItemSelection({
|
|
112
115
|
event,
|
|
113
116
|
itemId,
|
|
114
117
|
keepExistingSelection: true
|
|
115
118
|
});
|
|
116
119
|
} else if (!selectorIsItemSelected(store.value, itemId)) {
|
|
117
|
-
instance.
|
|
120
|
+
instance.setItemSelection({
|
|
118
121
|
event,
|
|
119
122
|
itemId
|
|
120
123
|
});
|
|
@@ -172,7 +175,10 @@ export const useTreeViewKeyboardNavigation = ({
|
|
|
172
175
|
event.preventDefault();
|
|
173
176
|
}
|
|
174
177
|
} else if (canToggleItemExpansion(itemId)) {
|
|
175
|
-
instance.
|
|
178
|
+
instance.setItemExpansion({
|
|
179
|
+
event,
|
|
180
|
+
itemId
|
|
181
|
+
});
|
|
176
182
|
event.preventDefault();
|
|
177
183
|
}
|
|
178
184
|
break;
|
|
@@ -186,7 +192,10 @@ export const useTreeViewKeyboardNavigation = ({
|
|
|
186
192
|
return;
|
|
187
193
|
}
|
|
188
194
|
if (canToggleItemExpansion(itemId) && selectorIsItemExpanded(store.value, itemId)) {
|
|
189
|
-
instance.
|
|
195
|
+
instance.setItemExpansion({
|
|
196
|
+
event,
|
|
197
|
+
itemId
|
|
198
|
+
});
|
|
190
199
|
event.preventDefault();
|
|
191
200
|
} else {
|
|
192
201
|
const parent = selectorItemParentId(store.value, itemId);
|
package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { UseTreeViewFocusSignature } from "../useTreeViewFocus/index.js";
|
|
|
6
6
|
import { UseTreeViewExpansionSignature } from "../useTreeViewExpansion/index.js";
|
|
7
7
|
import { TreeViewItemId, TreeViewCancellableEvent } from "../../../models/index.js";
|
|
8
8
|
import { UseTreeViewLabelSignature } from "../useTreeViewLabel/index.js";
|
|
9
|
+
import { UseTreeViewLazyLoadingSignature } from "../useTreeViewLazyLoading/index.js";
|
|
9
10
|
export interface UseTreeViewKeyboardNavigationInstance {
|
|
10
11
|
/**
|
|
11
12
|
* Updates the `firstCharMap` to add/remove the first character of some item's labels.
|
|
@@ -25,7 +26,7 @@ export interface UseTreeViewKeyboardNavigationInstance {
|
|
|
25
26
|
export type UseTreeViewKeyboardNavigationSignature = TreeViewPluginSignature<{
|
|
26
27
|
instance: UseTreeViewKeyboardNavigationInstance;
|
|
27
28
|
dependencies: [UseTreeViewItemsSignature, UseTreeViewSelectionSignature, UseTreeViewFocusSignature, UseTreeViewExpansionSignature];
|
|
28
|
-
optionalDependencies: [UseTreeViewLabelSignature];
|
|
29
|
+
optionalDependencies: [UseTreeViewLabelSignature, UseTreeViewLazyLoadingSignature];
|
|
29
30
|
}>;
|
|
30
31
|
export type TreeViewFirstCharMap = {
|
|
31
32
|
[itemId: string]: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { UseTreeViewLazyLoadingSignature, UseTreeViewLazyLoadingParameters } from './useTreeViewLazyLoading.types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { TreeViewAnyPluginSignature, TreeViewState } from "../../models/index.js";
|
|
2
|
+
import { TreeViewRootSelector, TreeViewRootSelectorForOptionalPlugin } from "../../utils/selectors.js";
|
|
3
|
+
import { UseTreeViewLazyLoadingSignature } from "./useTreeViewLazyLoading.types.js";
|
|
4
|
+
export type Temp<TSignature extends TreeViewAnyPluginSignature> = <TSignatures extends [], TOptionalSignatures extends [TSignature]>(state: TreeViewState<TSignatures, TOptionalSignatures>) => TSignature['state'][keyof TSignature['state']];
|
|
5
|
+
export declare const selectorDataSourceState: ((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & import("./useTreeViewLazyLoading.types").UseTreeViewLazyLoadingState & Partial<{}> & {
|
|
6
|
+
cacheKey: import("../../models").TreeViewStateCacheKey;
|
|
7
|
+
}) => {
|
|
8
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
9
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
10
|
+
}) & {
|
|
11
|
+
clearCache: () => void;
|
|
12
|
+
resultsCount: () => number;
|
|
13
|
+
resetResultsCount: () => void;
|
|
14
|
+
} & {
|
|
15
|
+
resultFunc: (resultFuncArgs_0: {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
dataSource: {
|
|
18
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
19
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
20
|
+
};
|
|
21
|
+
}) => {
|
|
22
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
23
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
24
|
+
};
|
|
25
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
dataSource: {
|
|
28
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
29
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
30
|
+
};
|
|
31
|
+
}) => {
|
|
32
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
33
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
34
|
+
}) & {
|
|
35
|
+
clearCache: () => void;
|
|
36
|
+
resultsCount: () => number;
|
|
37
|
+
resetResultsCount: () => void;
|
|
38
|
+
};
|
|
39
|
+
lastResult: () => {
|
|
40
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
41
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
42
|
+
};
|
|
43
|
+
dependencies: [TreeViewRootSelector<UseTreeViewLazyLoadingSignature>];
|
|
44
|
+
recomputations: () => number;
|
|
45
|
+
resetRecomputations: () => void;
|
|
46
|
+
dependencyRecomputations: () => number;
|
|
47
|
+
resetDependencyRecomputations: () => void;
|
|
48
|
+
} & {
|
|
49
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
50
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Check if lazy loading is enabled.
|
|
54
|
+
* @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
|
|
55
|
+
* @returns {boolean} True if lazy loading is enabled, false if it isn't.
|
|
56
|
+
*/
|
|
57
|
+
export declare const selectorIsLazyLoadingEnabled: ((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & Partial<import("./useTreeViewLazyLoading.types").UseTreeViewLazyLoadingState> & {
|
|
58
|
+
cacheKey: import("../../models").TreeViewStateCacheKey;
|
|
59
|
+
}) => boolean) & {
|
|
60
|
+
clearCache: () => void;
|
|
61
|
+
resultsCount: () => number;
|
|
62
|
+
resetResultsCount: () => void;
|
|
63
|
+
} & {
|
|
64
|
+
resultFunc: (resultFuncArgs_0: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
dataSource: {
|
|
67
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
68
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
69
|
+
};
|
|
70
|
+
} | undefined) => boolean;
|
|
71
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
dataSource: {
|
|
74
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
75
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
76
|
+
};
|
|
77
|
+
} | undefined) => boolean) & {
|
|
78
|
+
clearCache: () => void;
|
|
79
|
+
resultsCount: () => number;
|
|
80
|
+
resetResultsCount: () => void;
|
|
81
|
+
};
|
|
82
|
+
lastResult: () => boolean;
|
|
83
|
+
dependencies: [TreeViewRootSelectorForOptionalPlugin<UseTreeViewLazyLoadingSignature>];
|
|
84
|
+
recomputations: () => number;
|
|
85
|
+
resetRecomputations: () => void;
|
|
86
|
+
dependencyRecomputations: () => number;
|
|
87
|
+
resetDependencyRecomputations: () => void;
|
|
88
|
+
} & {
|
|
89
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
90
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Get the loading state for a tree item.
|
|
94
|
+
* @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
|
|
95
|
+
* @param {TreeViewItemId} itemId The id of the item to get the loading state of.
|
|
96
|
+
* @returns {boolean} The loading state for the Tree Item.
|
|
97
|
+
*/
|
|
98
|
+
export declare const selectorIsItemLoading: ((state: any, itemId: string) => boolean) & {
|
|
99
|
+
clearCache: () => void;
|
|
100
|
+
resultsCount: () => number;
|
|
101
|
+
resetResultsCount: () => void;
|
|
102
|
+
} & {
|
|
103
|
+
resultFunc: (resultFuncArgs_0: {
|
|
104
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
105
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
106
|
+
}, resultFuncArgs_1: string) => boolean;
|
|
107
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
108
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
109
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
110
|
+
}, resultFuncArgs_1: string) => boolean) & {
|
|
111
|
+
clearCache: () => void;
|
|
112
|
+
resultsCount: () => number;
|
|
113
|
+
resetResultsCount: () => void;
|
|
114
|
+
};
|
|
115
|
+
lastResult: () => boolean;
|
|
116
|
+
dependencies: [((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & import("./useTreeViewLazyLoading.types").UseTreeViewLazyLoadingState & Partial<{}> & {
|
|
117
|
+
cacheKey: import("../../models").TreeViewStateCacheKey;
|
|
118
|
+
}) => {
|
|
119
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
120
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
121
|
+
}) & {
|
|
122
|
+
clearCache: () => void;
|
|
123
|
+
resultsCount: () => number;
|
|
124
|
+
resetResultsCount: () => void;
|
|
125
|
+
} & {
|
|
126
|
+
resultFunc: (resultFuncArgs_0: {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
dataSource: {
|
|
129
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
130
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
131
|
+
};
|
|
132
|
+
}) => {
|
|
133
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
134
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
135
|
+
};
|
|
136
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
137
|
+
enabled: boolean;
|
|
138
|
+
dataSource: {
|
|
139
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
140
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
141
|
+
};
|
|
142
|
+
}) => {
|
|
143
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
144
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
145
|
+
}) & {
|
|
146
|
+
clearCache: () => void;
|
|
147
|
+
resultsCount: () => number;
|
|
148
|
+
resetResultsCount: () => void;
|
|
149
|
+
};
|
|
150
|
+
lastResult: () => {
|
|
151
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
152
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
153
|
+
};
|
|
154
|
+
dependencies: [TreeViewRootSelector<UseTreeViewLazyLoadingSignature>];
|
|
155
|
+
recomputations: () => number;
|
|
156
|
+
resetRecomputations: () => void;
|
|
157
|
+
dependencyRecomputations: () => number;
|
|
158
|
+
resetDependencyRecomputations: () => void;
|
|
159
|
+
} & {
|
|
160
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
161
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
162
|
+
}, (_: any, itemId: string) => string];
|
|
163
|
+
recomputations: () => number;
|
|
164
|
+
resetRecomputations: () => void;
|
|
165
|
+
dependencyRecomputations: () => number;
|
|
166
|
+
resetDependencyRecomputations: () => void;
|
|
167
|
+
} & {
|
|
168
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
169
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Get the error for a tree item.
|
|
173
|
+
* @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
|
|
174
|
+
* @param {TreeViewItemId} itemId The id of the item to get the error for.
|
|
175
|
+
* @returns {boolean} The error for the Tree Item.
|
|
176
|
+
*/
|
|
177
|
+
export declare const selectorGetTreeItemError: ((state: any, itemId: string) => Error | null) & {
|
|
178
|
+
clearCache: () => void;
|
|
179
|
+
resultsCount: () => number;
|
|
180
|
+
resetResultsCount: () => void;
|
|
181
|
+
} & {
|
|
182
|
+
resultFunc: (resultFuncArgs_0: {
|
|
183
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
184
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
185
|
+
}, resultFuncArgs_1: string) => Error | null;
|
|
186
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
187
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
188
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
189
|
+
}, resultFuncArgs_1: string) => Error | null) & {
|
|
190
|
+
clearCache: () => void;
|
|
191
|
+
resultsCount: () => number;
|
|
192
|
+
resetResultsCount: () => void;
|
|
193
|
+
};
|
|
194
|
+
lastResult: () => Error | null;
|
|
195
|
+
dependencies: [((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types").UseTreeViewIdState & import("./useTreeViewLazyLoading.types").UseTreeViewLazyLoadingState & Partial<{}> & {
|
|
196
|
+
cacheKey: import("../../models").TreeViewStateCacheKey;
|
|
197
|
+
}) => {
|
|
198
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
199
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
200
|
+
}) & {
|
|
201
|
+
clearCache: () => void;
|
|
202
|
+
resultsCount: () => number;
|
|
203
|
+
resetResultsCount: () => void;
|
|
204
|
+
} & {
|
|
205
|
+
resultFunc: (resultFuncArgs_0: {
|
|
206
|
+
enabled: boolean;
|
|
207
|
+
dataSource: {
|
|
208
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
209
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
210
|
+
};
|
|
211
|
+
}) => {
|
|
212
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
213
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
214
|
+
};
|
|
215
|
+
memoizedResultFunc: ((resultFuncArgs_0: {
|
|
216
|
+
enabled: boolean;
|
|
217
|
+
dataSource: {
|
|
218
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
219
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
220
|
+
};
|
|
221
|
+
}) => {
|
|
222
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
223
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
224
|
+
}) & {
|
|
225
|
+
clearCache: () => void;
|
|
226
|
+
resultsCount: () => number;
|
|
227
|
+
resetResultsCount: () => void;
|
|
228
|
+
};
|
|
229
|
+
lastResult: () => {
|
|
230
|
+
loading: Record<import("../../..").TreeViewItemId, boolean>;
|
|
231
|
+
errors: Record<import("../../..").TreeViewItemId, Error | null>;
|
|
232
|
+
};
|
|
233
|
+
dependencies: [TreeViewRootSelector<UseTreeViewLazyLoadingSignature>];
|
|
234
|
+
recomputations: () => number;
|
|
235
|
+
resetRecomputations: () => void;
|
|
236
|
+
dependencyRecomputations: () => number;
|
|
237
|
+
resetDependencyRecomputations: () => void;
|
|
238
|
+
} & {
|
|
239
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
240
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
241
|
+
}, (_: any, itemId: string) => string];
|
|
242
|
+
recomputations: () => number;
|
|
243
|
+
resetRecomputations: () => void;
|
|
244
|
+
dependencyRecomputations: () => number;
|
|
245
|
+
resetDependencyRecomputations: () => void;
|
|
246
|
+
} & {
|
|
247
|
+
argsMemoize: typeof import("reselect").weakMapMemoize;
|
|
248
|
+
memoize: typeof import("reselect").weakMapMemoize;
|
|
249
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
const selectorLazyLoading = state => state.lazyLoading;
|
|
3
|
+
const selectorLazyLoadingOptional = state => state.lazyLoading;
|
|
4
|
+
export const selectorDataSourceState = createSelector([selectorLazyLoading], lazyLoading => lazyLoading.dataSource);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Check if lazy loading is enabled.
|
|
8
|
+
* @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
|
|
9
|
+
* @returns {boolean} True if lazy loading is enabled, false if it isn't.
|
|
10
|
+
*/
|
|
11
|
+
export const selectorIsLazyLoadingEnabled = createSelector([selectorLazyLoadingOptional], lazyLoading => !!lazyLoading?.enabled);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the loading state for a tree item.
|
|
15
|
+
* @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
|
|
16
|
+
* @param {TreeViewItemId} itemId The id of the item to get the loading state of.
|
|
17
|
+
* @returns {boolean} The loading state for the Tree Item.
|
|
18
|
+
*/
|
|
19
|
+
export const selectorIsItemLoading = createSelector([selectorDataSourceState, (_, itemId) => itemId], (dataSourceState, itemId) => dataSourceState.loading[itemId] || false);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get the error for a tree item.
|
|
23
|
+
* @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
|
|
24
|
+
* @param {TreeViewItemId} itemId The id of the item to get the error for.
|
|
25
|
+
* @returns {boolean} The error for the Tree Item.
|
|
26
|
+
*/
|
|
27
|
+
export const selectorGetTreeItemError = createSelector([selectorDataSourceState, (_, itemId) => itemId], (dataSourceState, itemId) => dataSourceState.errors[itemId] || null);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DefaultizedProps } from '@mui/x-internals/types';
|
|
2
|
+
import { TreeViewPluginSignature } from "../../models/index.js";
|
|
3
|
+
import { DataSourceCache } from "../../../utils/index.js";
|
|
4
|
+
import { TreeViewItemId } from "../../../models/index.js";
|
|
5
|
+
import { UseTreeViewItemsSignature } from "../useTreeViewItems/index.js";
|
|
6
|
+
import { UseTreeViewExpansionSignature } from "../useTreeViewExpansion/index.js";
|
|
7
|
+
import { UseTreeViewSelectionSignature } from "../useTreeViewSelection/index.js";
|
|
8
|
+
type DataSource<R extends {}> = {
|
|
9
|
+
/**
|
|
10
|
+
* Used to determine the number of children the item has.
|
|
11
|
+
* Only relevant for lazy-loaded trees.
|
|
12
|
+
*
|
|
13
|
+
* @template R
|
|
14
|
+
* @param {R} item The item to check.
|
|
15
|
+
* @returns {number} The number of children.
|
|
16
|
+
* @default (item) => number
|
|
17
|
+
*/
|
|
18
|
+
getChildrenCount?: (item: R) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Method used for fetching the items.
|
|
21
|
+
* Only relevant for lazy-loaded tree views.
|
|
22
|
+
*
|
|
23
|
+
* @template R
|
|
24
|
+
* @param {TreeViewItemId} parentId The id of the item the children belong to.
|
|
25
|
+
* @returns { Promise<R[]>} The children of the item.
|
|
26
|
+
*/
|
|
27
|
+
getTreeItems?: (parentId?: TreeViewItemId) => Promise<R[]>;
|
|
28
|
+
};
|
|
29
|
+
export interface UseTreeViewLazyLoadingPublicAPI {}
|
|
30
|
+
export interface UseTreeViewLazyLoadingInstance extends UseTreeViewLazyLoadingPublicAPI {
|
|
31
|
+
/**
|
|
32
|
+
* Method used for fetching multiple items concurrently.
|
|
33
|
+
* Only relevant for lazy-loaded tree views.
|
|
34
|
+
*
|
|
35
|
+
* @param {TreeViewItemId[]} parentIds The ids of the items to fetch the children of.
|
|
36
|
+
* @returns { Promise<void>} The children of the items.
|
|
37
|
+
*/
|
|
38
|
+
fetchItems: (parentIds?: TreeViewItemId[]) => Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Method used for fetching and item's children.
|
|
41
|
+
* Only relevant for lazy-loaded tree views.
|
|
42
|
+
*
|
|
43
|
+
* @param {TreeViewItemId} itemId The The id of the item to fetch the children of.
|
|
44
|
+
* @returns { Promise<void>} The children of the item.
|
|
45
|
+
*/
|
|
46
|
+
fetchItemChildren: (itemId: TreeViewItemId) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Set the loading state of an item.
|
|
49
|
+
* @param {TreeViewItemId} itemId The id of the item to set the loading state of.
|
|
50
|
+
* @param {boolean} isLoading True if the item is loading.
|
|
51
|
+
*/
|
|
52
|
+
setDataSourceLoading: (itemId: TreeViewItemId, isLoading: boolean) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Set the error state of an item.
|
|
55
|
+
* @param {TreeViewItemId} itemId The id of the item to set the error state of.
|
|
56
|
+
* @param {Error | null} error The error caught on the item.
|
|
57
|
+
*/
|
|
58
|
+
setDataSourceError: (itemId: TreeViewItemId, error: Error | null) => void;
|
|
59
|
+
}
|
|
60
|
+
export interface UseTreeViewLazyLoadingParameters<R extends {}> {
|
|
61
|
+
dataSource?: DataSource<R>;
|
|
62
|
+
dataSourceCache?: DataSourceCache;
|
|
63
|
+
}
|
|
64
|
+
export type UseTreeViewLazyLoadingDefaultizedParameters<R extends {}> = DefaultizedProps<UseTreeViewLazyLoadingParameters<R>, 'dataSource'>;
|
|
65
|
+
export interface UseTreeViewLazyLoadingState {
|
|
66
|
+
lazyLoading: {
|
|
67
|
+
enabled: boolean;
|
|
68
|
+
dataSource: {
|
|
69
|
+
loading: Record<TreeViewItemId, boolean>;
|
|
70
|
+
errors: Record<TreeViewItemId, Error | null>;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export type UseTreeViewLazyLoadingSignature = TreeViewPluginSignature<{
|
|
75
|
+
params: UseTreeViewLazyLoadingParameters<any>;
|
|
76
|
+
defaultizedParams: UseTreeViewLazyLoadingDefaultizedParameters<any>;
|
|
77
|
+
publicAPI: UseTreeViewLazyLoadingPublicAPI;
|
|
78
|
+
instance: UseTreeViewLazyLoadingInstance;
|
|
79
|
+
state: UseTreeViewLazyLoadingState;
|
|
80
|
+
experimentalFeatures: 'lazyLoading';
|
|
81
|
+
dependencies: [UseTreeViewItemsSignature, UseTreeViewExpansionSignature, UseTreeViewSelectionSignature];
|
|
82
|
+
}>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -61,9 +61,9 @@ export const useTreeViewSelection = ({
|
|
|
61
61
|
}
|
|
62
62
|
models.selectedItems.setControlledValue(cleanModel);
|
|
63
63
|
};
|
|
64
|
-
const
|
|
65
|
-
event,
|
|
64
|
+
const setItemSelection = ({
|
|
66
65
|
itemId,
|
|
66
|
+
event = null,
|
|
67
67
|
keepExistingSelection = false,
|
|
68
68
|
shouldBeSelected
|
|
69
69
|
}) => {
|
|
@@ -177,10 +177,10 @@ export const useTreeViewSelection = ({
|
|
|
177
177
|
'aria-multiselectable': params.multiSelect
|
|
178
178
|
}),
|
|
179
179
|
publicAPI: {
|
|
180
|
-
|
|
180
|
+
setItemSelection
|
|
181
181
|
},
|
|
182
182
|
instance: {
|
|
183
|
-
|
|
183
|
+
setItemSelection,
|
|
184
184
|
selectAllNavigableItems,
|
|
185
185
|
expandSelectionRange,
|
|
186
186
|
selectRangeFromStartToItem,
|
|
@@ -7,17 +7,17 @@ import { TreeViewSelectionPropagation, TreeViewCancellableEventHandler } from ".
|
|
|
7
7
|
export interface UseTreeViewSelectionPublicAPI {
|
|
8
8
|
/**
|
|
9
9
|
* Select or deselect an item.
|
|
10
|
-
* @param {object}
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {boolean}
|
|
14
|
-
* @param {boolean | undefined}
|
|
10
|
+
* @param {object} parameters The parameters of the method.
|
|
11
|
+
* @param {string} parameters.itemId The id of the item to select or deselect.
|
|
12
|
+
* @param {React.SyntheticEvent} parameters.event The DOM event that triggered the change.
|
|
13
|
+
* @param {boolean} parameters.keepExistingSelection If `true`, the other already selected items will remain selected, otherwise, they will be deselected. This parameter is only relevant when `multiSelect` is `true`
|
|
14
|
+
* @param {boolean | undefined} parameters.shouldBeSelected If `true` the item will be selected. If `false` the item will be deselected. If not defined, the item's selection status will be toggled.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
event: React.SyntheticEvent;
|
|
16
|
+
setItemSelection: (parameters: {
|
|
18
17
|
itemId: string;
|
|
19
|
-
|
|
18
|
+
event?: React.SyntheticEvent;
|
|
20
19
|
shouldBeSelected?: boolean;
|
|
20
|
+
keepExistingSelection?: boolean;
|
|
21
21
|
}) => void;
|
|
22
22
|
}
|
|
23
23
|
export interface UseTreeViewSelectionInstance extends UseTreeViewSelectionPublicAPI {
|
|
@@ -99,18 +99,18 @@ export interface UseTreeViewSelectionParameters<Multiple extends boolean | undef
|
|
|
99
99
|
selectionPropagation?: TreeViewSelectionPropagation;
|
|
100
100
|
/**
|
|
101
101
|
* Callback fired when Tree Items are selected/deselected.
|
|
102
|
-
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
102
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change. Can be null when the change is caused by the `publicAPI.setItemSelection()` method.
|
|
103
103
|
* @param {string[] | string} itemIds The ids of the selected items.
|
|
104
104
|
* When `multiSelect` is `true`, this is an array of strings; when false (default) a string.
|
|
105
105
|
*/
|
|
106
|
-
onSelectedItemsChange?: (event: React.SyntheticEvent, itemIds: TreeViewSelectionValue<Multiple>) => void;
|
|
106
|
+
onSelectedItemsChange?: (event: React.SyntheticEvent | null, itemIds: TreeViewSelectionValue<Multiple>) => void;
|
|
107
107
|
/**
|
|
108
108
|
* Callback fired when a Tree Item is selected or deselected.
|
|
109
|
-
* @param {React.SyntheticEvent} event The DOM event that triggered the change.
|
|
109
|
+
* @param {React.SyntheticEvent} event The DOM event that triggered the change. Can be null when the change is caused by the `publicAPI.setItemSelection()` method.
|
|
110
110
|
* @param {array} itemId The itemId of the modified item.
|
|
111
111
|
* @param {array} isSelected `true` if the item has just been selected, `false` if it has just been deselected.
|
|
112
112
|
*/
|
|
113
|
-
onItemSelectionToggle?: (event: React.SyntheticEvent, itemId: string, isSelected: boolean) => void;
|
|
113
|
+
onItemSelectionToggle?: (event: React.SyntheticEvent | null, itemId: string, isSelected: boolean) => void;
|
|
114
114
|
}
|
|
115
115
|
export type UseTreeViewSelectionDefaultizedParameters<Multiple extends boolean> = DefaultizedProps<UseTreeViewSelectionParameters<Multiple>, 'disableSelection' | 'defaultSelectedItems' | 'multiSelect' | 'checkboxSelection' | 'selectionPropagation'>;
|
|
116
116
|
export interface UseTreeViewSelectionState {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { CreateSelectorFunction } from 'reselect';
|
|
2
2
|
import { TreeViewAnyPluginSignature, TreeViewState } from "../models/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Type of a selector that take the whole tree view state as input and returns a value based on a required plugin.
|
|
5
|
+
*/
|
|
3
6
|
export type TreeViewRootSelector<TSignature extends TreeViewAnyPluginSignature> = <TSignatures extends [TSignature]>(state: TreeViewState<TSignatures>) => TSignature['state'][keyof TSignature['state']];
|
|
7
|
+
/**
|
|
8
|
+
* Type of a selector that take the whole tree view state as input and returns a value based on an optional plugin.
|
|
9
|
+
*/
|
|
10
|
+
export type TreeViewRootSelectorForOptionalPlugin<TSignature extends TreeViewAnyPluginSignature> = <TSignatures extends [], TOptionalSignatures extends [TSignature]>(state: TreeViewState<TSignatures, TOptionalSignatures>) => TSignature['state'][keyof TSignature['state']] | undefined;
|
|
4
11
|
export type TreeViewSelector<TState, TArgs, TResult> = (state: TState, args: TArgs) => TResult;
|
|
5
12
|
/**
|
|
6
13
|
* Method wrapping reselect's createSelector to provide caching for tree view instances.
|
|
@@ -7,6 +7,15 @@ const reselectCreateSelector = createSelectorCreator({
|
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
const cache = new WeakMap();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Type of a selector that take the whole tree view state as input and returns a value based on a required plugin.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Type of a selector that take the whole tree view state as input and returns a value based on an optional plugin.
|
|
17
|
+
*/
|
|
18
|
+
|
|
10
19
|
/**
|
|
11
20
|
* Method wrapping reselect's createSelector to provide caching for tree view instances.
|
|
12
21
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { UseTreeItemParameters, UseTreeItemReturnValue, UseTreeItemMinimalPlugins, UseTreeItemOptionalPlugins } from "./useTreeItem.types.js";
|
|
2
|
-
export declare const useTreeItem: <TSignatures extends UseTreeItemMinimalPlugins = UseTreeItemMinimalPlugins, TOptionalSignatures extends UseTreeItemOptionalPlugins =
|
|
2
|
+
export declare const useTreeItem: <TSignatures extends UseTreeItemMinimalPlugins = UseTreeItemMinimalPlugins, TOptionalSignatures extends UseTreeItemOptionalPlugins = UseTreeItemOptionalPlugins>(parameters: UseTreeItemParameters) => UseTreeItemReturnValue<TSignatures, TOptionalSignatures>;
|
|
@@ -235,6 +235,17 @@ export const useTreeItem = parameters => {
|
|
|
235
235
|
onClick: createIconContainerHandleClick(externalEventHandlers)
|
|
236
236
|
});
|
|
237
237
|
};
|
|
238
|
+
const getErrorContainerProps = (externalProps = {}) => {
|
|
239
|
+
const externalEventHandlers = extractEventHandlers(externalProps);
|
|
240
|
+
return _extends({}, externalEventHandlers, externalProps);
|
|
241
|
+
};
|
|
242
|
+
const getLoadingContainerProps = (externalProps = {}) => {
|
|
243
|
+
const externalEventHandlers = extractEventHandlers(externalProps);
|
|
244
|
+
return _extends({
|
|
245
|
+
size: '12px',
|
|
246
|
+
thickness: 6
|
|
247
|
+
}, externalEventHandlers, externalProps);
|
|
248
|
+
};
|
|
238
249
|
const getGroupTransitionProps = (externalProps = {}) => {
|
|
239
250
|
const externalEventHandlers = extractEventHandlers(externalProps);
|
|
240
251
|
const response = _extends({}, externalEventHandlers, {
|
|
@@ -263,6 +274,8 @@ export const useTreeItem = parameters => {
|
|
|
263
274
|
getLabelProps,
|
|
264
275
|
getLabelInputProps,
|
|
265
276
|
getDragAndDropOverlayProps,
|
|
277
|
+
getErrorContainerProps,
|
|
278
|
+
getLoadingContainerProps,
|
|
266
279
|
rootRef: handleRootRef,
|
|
267
280
|
status,
|
|
268
281
|
publicAPI
|
|
@@ -78,6 +78,11 @@ export interface UseTreeItemCheckboxSlotOwnProps {
|
|
|
78
78
|
ref: React.RefObject<HTMLButtonElement | null>;
|
|
79
79
|
}
|
|
80
80
|
export type UseTreeItemCheckboxSlotProps<ExternalProps = {}> = ExternalProps & UseTreeItemCheckboxSlotOwnProps;
|
|
81
|
+
export type UseTreeItemErrorContainerSlotProps<ExternalProps = {}> = ExternalProps & {};
|
|
82
|
+
export type UseTreeItemLoadingContainerSlotProps<ExternalProps = {}> = ExternalProps & {
|
|
83
|
+
size: string;
|
|
84
|
+
thickness: number;
|
|
85
|
+
};
|
|
81
86
|
export interface UseTreeItemGroupTransitionSlotOwnProps {
|
|
82
87
|
unmountOnExit: boolean;
|
|
83
88
|
in: boolean;
|
|
@@ -96,6 +101,8 @@ export interface UseTreeItemStatus {
|
|
|
96
101
|
disabled: boolean;
|
|
97
102
|
editing: boolean;
|
|
98
103
|
editable: boolean;
|
|
104
|
+
loading: boolean;
|
|
105
|
+
error: boolean;
|
|
99
106
|
}
|
|
100
107
|
export interface UseTreeItemReturnValue<TSignatures extends UseTreeItemMinimalPlugins, TOptionalSignatures extends UseTreeItemOptionalPlugins> {
|
|
101
108
|
/**
|
|
@@ -152,6 +159,20 @@ export interface UseTreeItemReturnValue<TSignatures extends UseTreeItemMinimalPl
|
|
|
152
159
|
* @returns {UseTreeItemDragAndDropOverlaySlotProps<ExternalProps>} Props that should be spread on the DragAndDropOverlay slot.
|
|
153
160
|
*/
|
|
154
161
|
getDragAndDropOverlayProps: <ExternalProps extends Record<string, any> = {}>(externalProps?: ExternalProps) => UseTreeItemDragAndDropOverlaySlotProps<ExternalProps>;
|
|
162
|
+
/**
|
|
163
|
+
* Resolver for the ErrorIcon slot's props.
|
|
164
|
+
* Warning: This slot is only useful when using the `<RichTreeView />` component when lazy loading is enabled.
|
|
165
|
+
* @param {ExternalProps} externalProps Additional props for the ErrorIcon slot.
|
|
166
|
+
* @returns {UseTreeItemErrorContainerSlotProps<ExternalProps>} Props that should be spread on the ErrorIcon slot.
|
|
167
|
+
*/
|
|
168
|
+
getErrorContainerProps: <ExternalProps extends Record<string, any> = {}>(externalProps?: ExternalProps) => UseTreeItemErrorContainerSlotProps<ExternalProps>;
|
|
169
|
+
/**
|
|
170
|
+
* Resolver for the LoadingIcon slot's props.
|
|
171
|
+
* Warning: This slot is only useful when using the `<RichTreeView />` component when lazy loading is enabled.
|
|
172
|
+
* @param {ExternalProps} externalProps Additional props for the LoadingIcon slot.
|
|
173
|
+
* @returns {UseTreeItemLoadingContainerSlotProps<ExternalProps>} Props that should be spread on the LoadingIcon slot.
|
|
174
|
+
*/
|
|
175
|
+
getLoadingContainerProps: <ExternalProps extends Record<string, any> = {}>(externalProps?: ExternalProps) => UseTreeItemLoadingContainerSlotProps<ExternalProps>;
|
|
155
176
|
/**
|
|
156
177
|
* A ref to the component's root DOM element.
|
|
157
178
|
*/
|