@mui/x-tree-view 8.10.2 → 8.11.1
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 +214 -13
- package/RichTreeView/RichTreeView.js +16 -15
- package/RichTreeView/RichTreeView.types.d.ts +3 -2
- package/SimpleTreeView/SimpleTreeView.js +10 -9
- package/SimpleTreeView/SimpleTreeView.types.d.ts +3 -2
- package/TreeItem/TreeItem.d.ts +1 -1
- package/TreeItem/TreeItem.types.d.ts +3 -1
- package/TreeItemProvider/TreeItemProvider.js +3 -3
- package/esm/RichTreeView/RichTreeView.js +16 -15
- package/esm/RichTreeView/RichTreeView.types.d.ts +3 -2
- package/esm/SimpleTreeView/SimpleTreeView.js +10 -9
- package/esm/SimpleTreeView/SimpleTreeView.types.d.ts +3 -2
- package/esm/TreeItem/TreeItem.d.ts +1 -1
- package/esm/TreeItem/TreeItem.types.d.ts +3 -1
- package/esm/TreeItemProvider/TreeItemProvider.js +3 -3
- package/esm/hooks/useTreeItemModel.js +3 -3
- package/esm/hooks/useTreeItemUtils/useTreeItemUtils.js +24 -25
- package/esm/index.js +1 -1
- package/esm/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +2 -2
- package/esm/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -3
- package/esm/internals/components/RichTreeViewItems.js +5 -5
- package/esm/internals/corePlugins/useTreeViewId/index.d.ts +2 -1
- package/esm/internals/corePlugins/useTreeViewId/index.js +2 -1
- package/esm/internals/corePlugins/useTreeViewId/useTreeViewId.js +10 -13
- package/esm/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.d.ts +8 -34
- package/esm/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.js +9 -9
- package/esm/internals/index.d.ts +6 -14
- package/esm/internals/index.js +6 -13
- package/esm/internals/models/plugin.d.ts +2 -3
- package/esm/internals/models/treeView.d.ts +4 -6
- package/esm/internals/plugins/useTreeViewExpansion/index.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewExpansion/index.js +2 -1
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +26 -30
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.d.ts +24 -316
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.js +27 -38
- package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +7 -1
- package/esm/internals/plugins/useTreeViewFocus/index.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewFocus/index.js +2 -1
- package/esm/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +17 -21
- package/esm/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.d.ts +20 -628
- package/esm/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.js +25 -37
- package/esm/internals/plugins/useTreeViewItems/index.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewItems/index.js +2 -1
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.js +78 -99
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +52 -1142
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +58 -98
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.utils.d.ts +1 -1
- package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +1 -1
- package/esm/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +32 -42
- package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +22 -22
- package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +2 -0
- package/esm/internals/plugins/useTreeViewLabel/index.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewLabel/index.js +2 -1
- package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.itemPlugin.js +4 -4
- package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +17 -25
- package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.d.ts +14 -100
- package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.js +24 -34
- package/esm/internals/plugins/useTreeViewLazyLoading/index.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewLazyLoading/index.js +1 -1
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.d.ts +18 -245
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.js +15 -27
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +20 -6
- package/esm/internals/plugins/useTreeViewSelection/index.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewSelection/index.js +2 -1
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.itemPlugin.js +25 -38
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +30 -34
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.d.ts +38 -517
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.js +46 -71
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +1 -0
- package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +10 -10
- package/esm/internals/useTreeView/useTreeView.d.ts +1 -1
- package/esm/internals/useTreeView/useTreeView.js +11 -18
- package/esm/internals/useTreeView/useTreeView.types.d.ts +1 -1
- package/esm/internals/useTreeView/useTreeViewBuildContext.d.ts +2 -3
- package/esm/internals/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +0 -2
- package/esm/internals/utils/tree.js +33 -33
- package/esm/useTreeItem/useTreeItem.js +14 -14
- package/esm/useTreeItem/useTreeItem.types.d.ts +2 -1
- package/hooks/useTreeItemModel.js +3 -3
- package/hooks/useTreeItemUtils/useTreeItemUtils.js +18 -19
- package/index.js +1 -1
- package/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +1 -1
- package/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -3
- package/internals/components/RichTreeViewItems.js +5 -5
- package/internals/corePlugins/useTreeViewId/index.d.ts +2 -1
- package/internals/corePlugins/useTreeViewId/index.js +8 -1
- package/internals/corePlugins/useTreeViewId/useTreeViewId.js +9 -12
- package/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.d.ts +8 -34
- package/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.js +10 -10
- package/internals/index.d.ts +6 -14
- package/internals/index.js +12 -73
- package/internals/models/plugin.d.ts +2 -3
- package/internals/models/treeView.d.ts +4 -6
- package/internals/plugins/useTreeViewExpansion/index.d.ts +2 -1
- package/internals/plugins/useTreeViewExpansion/index.js +8 -1
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +24 -28
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.d.ts +24 -316
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.js +27 -38
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +7 -1
- package/internals/plugins/useTreeViewFocus/index.d.ts +2 -1
- package/internals/plugins/useTreeViewFocus/index.js +8 -1
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +14 -18
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.d.ts +20 -628
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.js +23 -35
- package/internals/plugins/useTreeViewItems/index.d.ts +2 -1
- package/internals/plugins/useTreeViewItems/index.js +8 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.js +77 -98
- package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +52 -1142
- package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +59 -99
- package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.d.ts +1 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +1 -1
- package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +32 -42
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +18 -18
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +2 -0
- package/internals/plugins/useTreeViewLabel/index.d.ts +2 -1
- package/internals/plugins/useTreeViewLabel/index.js +8 -1
- package/internals/plugins/useTreeViewLabel/useTreeViewLabel.itemPlugin.js +3 -3
- package/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +16 -24
- package/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.d.ts +14 -100
- package/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.js +24 -34
- package/internals/plugins/useTreeViewLazyLoading/index.d.ts +2 -1
- package/internals/plugins/useTreeViewLazyLoading/index.js +8 -1
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.d.ts +18 -245
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.js +16 -28
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +20 -6
- package/internals/plugins/useTreeViewSelection/index.d.ts +2 -1
- package/internals/plugins/useTreeViewSelection/index.js +8 -1
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.itemPlugin.js +23 -37
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +29 -33
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.d.ts +38 -517
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.js +46 -71
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +1 -0
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +8 -8
- package/internals/useTreeView/useTreeView.d.ts +1 -1
- package/internals/useTreeView/useTreeView.js +11 -18
- package/internals/useTreeView/useTreeView.types.d.ts +1 -1
- package/internals/useTreeView/useTreeViewBuildContext.d.ts +2 -3
- package/internals/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +0 -2
- package/internals/utils/tree.js +31 -31
- package/package.json +12 -13
- package/useTreeItem/useTreeItem.js +14 -14
- package/useTreeItem/useTreeItem.types.d.ts +2 -1
- package/esm/internals/hooks/useSelector.d.ts +0 -4
- package/esm/internals/hooks/useSelector.js +0 -8
- package/esm/internals/utils/TreeViewStore.d.ts +0 -12
- package/esm/internals/utils/TreeViewStore.js +0 -22
- package/esm/internals/utils/selectors.d.ts +0 -21
- package/esm/internals/utils/selectors.js +0 -51
- package/internals/hooks/useSelector.d.ts +0 -4
- package/internals/hooks/useSelector.js +0 -16
- package/internals/utils/TreeViewStore.d.ts +0 -12
- package/internals/utils/TreeViewStore.js +0 -29
- package/internals/utils/selectors.d.ts +0 -21
- package/internals/utils/selectors.js +0 -58
|
@@ -1,81 +1,56 @@
|
|
|
1
|
-
import { createSelector } from
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* Get the selected items.
|
|
7
|
-
* @param {TreeViewState<[UseTreeViewSelectionSignature]>} state The state of the tree view.
|
|
8
|
-
* @returns {TreeViewSelectionValue<boolean>} The selected items.
|
|
9
|
-
*/
|
|
10
|
-
export const selectorSelectionModel = createSelector([selectorTreeViewSelectionState], selectionState => selectionState.selectedItems);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get the selected items as an array.
|
|
14
|
-
* @param {TreeViewState<[UseTreeViewSelectionSignature]>} state The state of the tree view.
|
|
15
|
-
* @returns {TreeViewItemId[]} The selected items as an array.
|
|
16
|
-
*/
|
|
17
|
-
export const selectorSelectionModelArray = createSelector([selectorSelectionModel], selectedItems => {
|
|
18
|
-
if (Array.isArray(selectedItems)) {
|
|
19
|
-
return selectedItems;
|
|
1
|
+
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
|
+
import { itemsSelectors } from "../useTreeViewItems/useTreeViewItems.selectors.js";
|
|
3
|
+
const selectedItemsSelector = createSelectorMemoized(state => state.selection.selectedItems, selectedItemsRaw => {
|
|
4
|
+
if (Array.isArray(selectedItemsRaw)) {
|
|
5
|
+
return selectedItemsRaw;
|
|
20
6
|
}
|
|
21
|
-
if (
|
|
22
|
-
return [
|
|
7
|
+
if (selectedItemsRaw != null) {
|
|
8
|
+
return [selectedItemsRaw];
|
|
23
9
|
}
|
|
24
10
|
return [];
|
|
25
11
|
});
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Get the selected items as a map.
|
|
29
|
-
* @param {TreeViewState<[UseTreeViewSelectionSignature]>} state The state of the tree view.
|
|
30
|
-
* @returns {Map<TreeViewItemId, true>} The selected items as a Map.
|
|
31
|
-
*/
|
|
32
|
-
const selectorSelectionModelMap = createSelector([selectorSelectionModelArray], selectedItems => {
|
|
12
|
+
const selectedItemsMapSelector = createSelectorMemoized(selectedItemsSelector, selectedItems => {
|
|
33
13
|
const selectedItemsMap = new Map();
|
|
34
14
|
selectedItems.forEach(id => {
|
|
35
15
|
selectedItemsMap.set(id, true);
|
|
36
16
|
});
|
|
37
17
|
return selectedItemsMap;
|
|
38
18
|
});
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* Get the selection propagation rules.
|
|
78
|
-
* @param {TreeViewState<[UseTreeViewSelectionSignature]>} state The state of the tree view.
|
|
79
|
-
* @returns {TreeViewSelectionPropagation} The selection propagation rules.
|
|
80
|
-
*/
|
|
81
|
-
export const selectorSelectionPropagationRules = createSelector([selectorTreeViewSelectionState], selectionState => selectionState.selectionPropagation);
|
|
19
|
+
export const selectionSelectors = {
|
|
20
|
+
/**
|
|
21
|
+
* Gets the selected items as provided to the component.
|
|
22
|
+
*/
|
|
23
|
+
selectedItemsRaw: createSelector(state => state.selection.selectedItems),
|
|
24
|
+
/**
|
|
25
|
+
* Gets the selected items as an array.
|
|
26
|
+
*/
|
|
27
|
+
selectedItems: selectedItemsSelector,
|
|
28
|
+
/**
|
|
29
|
+
* Gets the selected items as a Map.
|
|
30
|
+
*/
|
|
31
|
+
selectedItemsMap: selectedItemsMapSelector,
|
|
32
|
+
/**
|
|
33
|
+
* Checks whether selection is enabled.
|
|
34
|
+
*/
|
|
35
|
+
enabled: createSelector(state => state.selection.isEnabled),
|
|
36
|
+
/**
|
|
37
|
+
* Checks whether multi selection is enabled.
|
|
38
|
+
*/
|
|
39
|
+
isMultiSelectEnabled: createSelector(state => state.selection.isMultiSelectEnabled),
|
|
40
|
+
/**
|
|
41
|
+
* Checks whether checkbox selection is enabled.
|
|
42
|
+
*/
|
|
43
|
+
isCheckboxSelectionEnabled: createSelector(state => state.selection.isCheckboxSelectionEnabled),
|
|
44
|
+
/**
|
|
45
|
+
* Gets the selection propagation rules.
|
|
46
|
+
*/
|
|
47
|
+
propagationRules: createSelector(state => state.selection.selectionPropagation),
|
|
48
|
+
/**
|
|
49
|
+
* Checks whether an item is selected.
|
|
50
|
+
*/
|
|
51
|
+
isItemSelected: createSelector(selectedItemsMapSelector, (selectedItemsMap, itemId) => selectedItemsMap.has(itemId)),
|
|
52
|
+
/**
|
|
53
|
+
* Checks whether an item can be selected (if selection is enabled and if the item is not disabled).
|
|
54
|
+
*/
|
|
55
|
+
canItemBeSelected: createSelector(itemsSelectors.isItemDisabled, state => state.selection.isEnabled, (isItemDisabled, isSelectionEnabled, _itemId) => isSelectionEnabled && !isItemDisabled)
|
|
56
|
+
};
|
|
@@ -133,6 +133,7 @@ export type UseTreeViewSelectionSignature = TreeViewPluginSignature<{
|
|
|
133
133
|
export interface UseTreeItemCheckboxSlotPropsFromSelection {
|
|
134
134
|
visible?: boolean;
|
|
135
135
|
checked?: boolean;
|
|
136
|
+
indeterminate?: boolean;
|
|
136
137
|
disabled?: boolean;
|
|
137
138
|
tabIndex?: -1;
|
|
138
139
|
onChange?: TreeViewCancellableEventHandler<React.ChangeEvent<HTMLInputElement>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { selectionSelectors } from "./useTreeViewSelection.selectors.js";
|
|
2
|
+
import { itemsSelectors } from "../useTreeViewItems/useTreeViewItems.selectors.js";
|
|
3
3
|
export const getLookupFromArray = array => {
|
|
4
4
|
const lookup = {};
|
|
5
5
|
array.forEach(itemId => {
|
|
@@ -17,7 +17,7 @@ export const getAddedAndRemovedItems = ({
|
|
|
17
17
|
newModelMap.set(id, true);
|
|
18
18
|
});
|
|
19
19
|
return {
|
|
20
|
-
added: newModel.filter(itemId => !
|
|
20
|
+
added: newModel.filter(itemId => !selectionSelectors.isItemSelected(store.state, itemId)),
|
|
21
21
|
removed: oldModel.filter(itemId => !newModelMap.has(itemId))
|
|
22
22
|
};
|
|
23
23
|
};
|
|
@@ -54,7 +54,7 @@ export const propagateSelection = ({
|
|
|
54
54
|
shouldRegenerateModel = true;
|
|
55
55
|
newModelLookup[itemId] = true;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
itemsSelectors.itemOrderedChildrenIds(store.state, itemId).forEach(selectDescendants);
|
|
58
58
|
};
|
|
59
59
|
selectDescendants(addedItemId);
|
|
60
60
|
}
|
|
@@ -63,15 +63,15 @@ export const propagateSelection = ({
|
|
|
63
63
|
if (!newModelLookup[itemId]) {
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
|
-
const children =
|
|
66
|
+
const children = itemsSelectors.itemOrderedChildrenIds(store.state, itemId);
|
|
67
67
|
return children.every(checkAllDescendantsSelected);
|
|
68
68
|
};
|
|
69
69
|
const selectParents = itemId => {
|
|
70
|
-
const parentId =
|
|
70
|
+
const parentId = itemsSelectors.itemParentId(store.state, itemId);
|
|
71
71
|
if (parentId == null) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
const siblings =
|
|
74
|
+
const siblings = itemsSelectors.itemOrderedChildrenIds(store.state, parentId);
|
|
75
75
|
if (siblings.every(checkAllDescendantsSelected)) {
|
|
76
76
|
shouldRegenerateModel = true;
|
|
77
77
|
newModelLookup[parentId] = true;
|
|
@@ -83,13 +83,13 @@ export const propagateSelection = ({
|
|
|
83
83
|
});
|
|
84
84
|
changes.removed.forEach(removedItemId => {
|
|
85
85
|
if (selectionPropagation.parents) {
|
|
86
|
-
let parentId =
|
|
86
|
+
let parentId = itemsSelectors.itemParentId(store.state, removedItemId);
|
|
87
87
|
while (parentId != null) {
|
|
88
88
|
if (newModelLookup[parentId]) {
|
|
89
89
|
shouldRegenerateModel = true;
|
|
90
90
|
delete newModelLookup[parentId];
|
|
91
91
|
}
|
|
92
|
-
parentId =
|
|
92
|
+
parentId = itemsSelectors.itemParentId(store.state, parentId);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
if (selectionPropagation.descendants) {
|
|
@@ -98,7 +98,7 @@ export const propagateSelection = ({
|
|
|
98
98
|
shouldRegenerateModel = true;
|
|
99
99
|
delete newModelLookup[itemId];
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
itemsSelectors.itemOrderedChildrenIds(store.state, itemId).forEach(deSelectDescendants);
|
|
102
102
|
};
|
|
103
103
|
deSelectDescendants(removedItemId);
|
|
104
104
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TreeViewAnyPluginSignature } from "../models/index.js";
|
|
3
3
|
import { UseTreeViewBaseProps, UseTreeViewParameters, UseTreeViewReturnValue } from "./useTreeView.types.js";
|
|
4
|
-
export declare function useTreeViewApiInitialization<T>(inputApiRef: React.RefObject<T | undefined> | undefined): React.RefObject<T>;
|
|
4
|
+
export declare function useTreeViewApiInitialization<T>(inputApiRef: React.RefObject<Partial<T> | undefined> | undefined): React.RefObject<T>;
|
|
5
5
|
/**
|
|
6
6
|
* This is the main hook that sets the plugin system up for the tree-view.
|
|
7
7
|
*
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { useRefWithInit } from '@base-ui-components/utils/useRefWithInit';
|
|
4
|
+
import { Store } from '@mui/x-internals/store';
|
|
3
5
|
import useForkRef from '@mui/utils/useForkRef';
|
|
4
6
|
import { TREE_VIEW_CORE_PLUGINS } from "../corePlugins/index.js";
|
|
5
7
|
import { useExtractPluginParamsFromProps } from "./useExtractPluginParamsFromProps.js";
|
|
6
8
|
import { useTreeViewBuildContext } from "./useTreeViewBuildContext.js";
|
|
7
|
-
import { TreeViewStore } from "../utils/TreeViewStore.js";
|
|
8
9
|
function initializeInputApiRef(inputApiRef) {
|
|
9
10
|
if (inputApiRef.current == null) {
|
|
10
11
|
inputApiRef.current = {};
|
|
@@ -18,7 +19,6 @@ export function useTreeViewApiInitialization(inputApiRef) {
|
|
|
18
19
|
}
|
|
19
20
|
return fallbackPublicApiRef;
|
|
20
21
|
}
|
|
21
|
-
let globalId = 0;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* This is the main hook that sets the plugin system up for the tree-view.
|
|
@@ -43,31 +43,24 @@ export const useTreeView = ({
|
|
|
43
43
|
plugins,
|
|
44
44
|
props
|
|
45
45
|
});
|
|
46
|
-
const
|
|
47
|
-
const instance = instanceRef.current;
|
|
46
|
+
const instance = useRefWithInit(() => ({})).current;
|
|
48
47
|
const publicAPI = useTreeViewApiInitialization(apiRef);
|
|
49
48
|
const innerRootRef = React.useRef(null);
|
|
50
49
|
const handleRootRef = useForkRef(innerRootRef, rootRef);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const initialState = {
|
|
55
|
-
cacheKey: {
|
|
56
|
-
id: globalId
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
plugins.forEach(plugin => {
|
|
50
|
+
const store = useRefWithInit(() => {
|
|
51
|
+
const initialState = {};
|
|
52
|
+
for (const plugin of plugins) {
|
|
60
53
|
if (plugin.getInitialState) {
|
|
61
54
|
Object.assign(initialState, plugin.getInitialState(pluginParams));
|
|
62
55
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}
|
|
56
|
+
}
|
|
57
|
+
return new Store(initialState);
|
|
58
|
+
}).current;
|
|
66
59
|
const contextValue = useTreeViewBuildContext({
|
|
67
60
|
plugins,
|
|
68
61
|
instance,
|
|
69
62
|
publicAPI: publicAPI.current,
|
|
70
|
-
store
|
|
63
|
+
store,
|
|
71
64
|
rootRef: innerRootRef
|
|
72
65
|
});
|
|
73
66
|
const rootPropsGetters = [];
|
|
@@ -77,7 +70,7 @@ export const useTreeView = ({
|
|
|
77
70
|
params: pluginParams,
|
|
78
71
|
rootRef: innerRootRef,
|
|
79
72
|
plugins,
|
|
80
|
-
store
|
|
73
|
+
store
|
|
81
74
|
});
|
|
82
75
|
if (pluginResponse.getRootProps) {
|
|
83
76
|
rootPropsGetters.push(pluginResponse.getRootProps);
|
|
@@ -8,7 +8,7 @@ export interface UseTreeViewParameters<TSignatures extends readonly TreeViewAnyP
|
|
|
8
8
|
props: TProps;
|
|
9
9
|
}
|
|
10
10
|
export interface UseTreeViewBaseProps<TSignatures extends readonly TreeViewAnyPluginSignature[]> {
|
|
11
|
-
apiRef: React.RefObject<TreeViewPublicAPI<TSignatures
|
|
11
|
+
apiRef: React.RefObject<Partial<TreeViewPublicAPI<TSignatures>> | undefined> | undefined;
|
|
12
12
|
}
|
|
13
13
|
export interface UseTreeViewRootSlotProps extends Pick<React.HTMLAttributes<HTMLUListElement>, 'onFocus' | 'onBlur' | 'onKeyDown' | 'id' | 'aria-multiselectable' | 'role' | 'tabIndex'> {
|
|
14
14
|
ref: React.Ref<HTMLUListElement>;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TreeViewContextValue } from "../TreeViewProvider/index.js";
|
|
3
|
-
import { ConvertSignaturesIntoPlugins, TreeViewAnyPluginSignature, TreeViewInstance, TreeViewPublicAPI } from "../models/index.js";
|
|
3
|
+
import { ConvertSignaturesIntoPlugins, TreeViewAnyPluginSignature, TreeViewInstance, TreeViewPublicAPI, TreeViewStore } from "../models/index.js";
|
|
4
4
|
import { TreeViewCorePluginSignatures } from "../corePlugins/index.js";
|
|
5
|
-
import { TreeViewStore } from "../utils/TreeViewStore.js";
|
|
6
5
|
export declare const useTreeViewBuildContext: <TSignatures extends readonly TreeViewAnyPluginSignature[]>(parameters: UseTreeViewBuildContextParameters<TSignatures>) => TreeViewContextValue<TSignatures>;
|
|
7
6
|
interface UseTreeViewBuildContextParameters<TSignatures extends readonly TreeViewAnyPluginSignature[]> {
|
|
8
7
|
plugins: ConvertSignaturesIntoPlugins<readonly [...TreeViewCorePluginSignatures, ...TSignatures]>;
|
|
9
8
|
instance: TreeViewInstance<TSignatures>;
|
|
10
9
|
publicAPI: TreeViewPublicAPI<TSignatures>;
|
|
11
|
-
store: TreeViewStore<TSignatures>;
|
|
10
|
+
store: TreeViewStore<readonly [...TreeViewCorePluginSignatures, ...TSignatures]>;
|
|
12
11
|
rootRef: React.RefObject<HTMLUListElement | null>;
|
|
13
12
|
}
|
|
14
13
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { expansionSelectors } from "../plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.js";
|
|
2
|
+
import { itemsSelectors } from "../plugins/useTreeViewItems/useTreeViewItems.selectors.js";
|
|
3
3
|
const getLastNavigableItemInArray = (state, items) => {
|
|
4
4
|
// Equivalent to Array.prototype.findLastIndex
|
|
5
5
|
let itemIndex = items.length - 1;
|
|
6
|
-
while (itemIndex >= 0 && !
|
|
6
|
+
while (itemIndex >= 0 && !itemsSelectors.canItemBeFocused(state, items[itemIndex])) {
|
|
7
7
|
itemIndex -= 1;
|
|
8
8
|
}
|
|
9
9
|
if (itemIndex === -1) {
|
|
@@ -12,12 +12,12 @@ const getLastNavigableItemInArray = (state, items) => {
|
|
|
12
12
|
return items[itemIndex];
|
|
13
13
|
};
|
|
14
14
|
export const getPreviousNavigableItem = (state, itemId) => {
|
|
15
|
-
const itemMeta =
|
|
15
|
+
const itemMeta = itemsSelectors.itemMeta(state, itemId);
|
|
16
16
|
if (!itemMeta) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
const siblings =
|
|
20
|
-
const itemIndex =
|
|
19
|
+
const siblings = itemsSelectors.itemOrderedChildrenIds(state, itemMeta.parentId);
|
|
20
|
+
const itemIndex = itemsSelectors.itemIndex(state, itemId);
|
|
21
21
|
|
|
22
22
|
// TODO: What should we do if the parent is not navigable?
|
|
23
23
|
if (itemIndex === 0) {
|
|
@@ -26,7 +26,7 @@ export const getPreviousNavigableItem = (state, itemId) => {
|
|
|
26
26
|
|
|
27
27
|
// Finds the previous navigable sibling.
|
|
28
28
|
let previousNavigableSiblingIndex = itemIndex - 1;
|
|
29
|
-
while (!
|
|
29
|
+
while (!itemsSelectors.canItemBeFocused(state, siblings[previousNavigableSiblingIndex]) && previousNavigableSiblingIndex >= 0) {
|
|
30
30
|
previousNavigableSiblingIndex -= 1;
|
|
31
31
|
}
|
|
32
32
|
if (previousNavigableSiblingIndex === -1) {
|
|
@@ -41,45 +41,45 @@ export const getPreviousNavigableItem = (state, itemId) => {
|
|
|
41
41
|
|
|
42
42
|
// Finds the last navigable ancestor of the previous navigable sibling.
|
|
43
43
|
let currentItemId = siblings[previousNavigableSiblingIndex];
|
|
44
|
-
let lastNavigableChild = getLastNavigableItemInArray(state,
|
|
45
|
-
while (
|
|
44
|
+
let lastNavigableChild = getLastNavigableItemInArray(state, itemsSelectors.itemOrderedChildrenIds(state, currentItemId));
|
|
45
|
+
while (expansionSelectors.isItemExpanded(state, currentItemId) && lastNavigableChild != null) {
|
|
46
46
|
currentItemId = lastNavigableChild;
|
|
47
|
-
lastNavigableChild = getLastNavigableItemInArray(state,
|
|
47
|
+
lastNavigableChild = getLastNavigableItemInArray(state, itemsSelectors.itemOrderedChildrenIds(state, currentItemId));
|
|
48
48
|
}
|
|
49
49
|
return currentItemId;
|
|
50
50
|
};
|
|
51
51
|
export const getNextNavigableItem = (state, itemId) => {
|
|
52
52
|
// If the item is expanded and has some navigable children, return the first of them.
|
|
53
|
-
if (
|
|
54
|
-
const firstNavigableChild =
|
|
53
|
+
if (expansionSelectors.isItemExpanded(state, itemId)) {
|
|
54
|
+
const firstNavigableChild = itemsSelectors.itemOrderedChildrenIds(state, itemId).find(childId => itemsSelectors.canItemBeFocused(state, childId));
|
|
55
55
|
if (firstNavigableChild != null) {
|
|
56
56
|
return firstNavigableChild;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
let itemMeta =
|
|
59
|
+
let itemMeta = itemsSelectors.itemMeta(state, itemId);
|
|
60
60
|
while (itemMeta != null) {
|
|
61
61
|
// Try to find the first navigable sibling after the current item.
|
|
62
|
-
const siblings =
|
|
63
|
-
const currentItemIndex =
|
|
62
|
+
const siblings = itemsSelectors.itemOrderedChildrenIds(state, itemMeta.parentId);
|
|
63
|
+
const currentItemIndex = itemsSelectors.itemIndex(state, itemMeta.id);
|
|
64
64
|
if (currentItemIndex < siblings.length - 1) {
|
|
65
65
|
let nextItemIndex = currentItemIndex + 1;
|
|
66
|
-
while (!
|
|
66
|
+
while (!itemsSelectors.canItemBeFocused(state, siblings[nextItemIndex]) && nextItemIndex < siblings.length - 1) {
|
|
67
67
|
nextItemIndex += 1;
|
|
68
68
|
}
|
|
69
|
-
if (
|
|
69
|
+
if (itemsSelectors.canItemBeFocused(state, siblings[nextItemIndex])) {
|
|
70
70
|
return siblings[nextItemIndex];
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// If the sibling does not exist, go up a level to the parent and try again.
|
|
75
|
-
itemMeta =
|
|
75
|
+
itemMeta = itemsSelectors.itemMeta(state, itemMeta.parentId);
|
|
76
76
|
}
|
|
77
77
|
return null;
|
|
78
78
|
};
|
|
79
79
|
export const getLastNavigableItem = state => {
|
|
80
80
|
let itemId = null;
|
|
81
|
-
while (itemId == null ||
|
|
82
|
-
const children =
|
|
81
|
+
while (itemId == null || expansionSelectors.isItemExpanded(state, itemId)) {
|
|
82
|
+
const children = itemsSelectors.itemOrderedChildrenIds(state, itemId);
|
|
83
83
|
const lastNavigableChild = getLastNavigableItemInArray(state, children);
|
|
84
84
|
|
|
85
85
|
// The item has no navigable children.
|
|
@@ -90,7 +90,7 @@ export const getLastNavigableItem = state => {
|
|
|
90
90
|
}
|
|
91
91
|
return itemId;
|
|
92
92
|
};
|
|
93
|
-
export const getFirstNavigableItem = state =>
|
|
93
|
+
export const getFirstNavigableItem = state => itemsSelectors.itemOrderedChildrenIds(state, null).find(itemId => itemsSelectors.canItemBeFocused(state, itemId));
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* This is used to determine the start and end of a selection range so
|
|
@@ -110,8 +110,8 @@ export const findOrderInTremauxTree = (state, itemAId, itemBId) => {
|
|
|
110
110
|
if (itemAId === itemBId) {
|
|
111
111
|
return [itemAId, itemBId];
|
|
112
112
|
}
|
|
113
|
-
const itemMetaA =
|
|
114
|
-
const itemMetaB =
|
|
113
|
+
const itemMetaA = itemsSelectors.itemMeta(state, itemAId);
|
|
114
|
+
const itemMetaB = itemsSelectors.itemMeta(state, itemBId);
|
|
115
115
|
if (!itemMetaA || !itemMetaB) {
|
|
116
116
|
return [itemAId, itemBId];
|
|
117
117
|
}
|
|
@@ -132,7 +132,7 @@ export const findOrderInTremauxTree = (state, itemAId, itemBId) => {
|
|
|
132
132
|
aAncestorIsCommon = bFamily.indexOf(aAncestor) !== -1;
|
|
133
133
|
continueA = aAncestor !== null;
|
|
134
134
|
if (!aAncestorIsCommon && continueA) {
|
|
135
|
-
aAncestor =
|
|
135
|
+
aAncestor = itemsSelectors.itemParentId(state, aAncestor);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
if (continueB && !aAncestorIsCommon) {
|
|
@@ -140,12 +140,12 @@ export const findOrderInTremauxTree = (state, itemAId, itemBId) => {
|
|
|
140
140
|
bAncestorIsCommon = aFamily.indexOf(bAncestor) !== -1;
|
|
141
141
|
continueB = bAncestor !== null;
|
|
142
142
|
if (!bAncestorIsCommon && continueB) {
|
|
143
|
-
bAncestor =
|
|
143
|
+
bAncestor = itemsSelectors.itemParentId(state, bAncestor);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
const commonAncestor = aAncestorIsCommon ? aAncestor : bAncestor;
|
|
148
|
-
const ancestorFamily =
|
|
148
|
+
const ancestorFamily = itemsSelectors.itemOrderedChildrenIds(state, commonAncestor);
|
|
149
149
|
const aSide = aFamily[aFamily.indexOf(commonAncestor) - 1];
|
|
150
150
|
const bSide = bFamily[bFamily.indexOf(commonAncestor) - 1];
|
|
151
151
|
return ancestorFamily.indexOf(aSide) < ancestorFamily.indexOf(bSide) ? [itemAId, itemBId] : [itemBId, itemAId];
|
|
@@ -153,20 +153,20 @@ export const findOrderInTremauxTree = (state, itemAId, itemBId) => {
|
|
|
153
153
|
export const getNonDisabledItemsInRange = (state, itemAId, itemBId) => {
|
|
154
154
|
const getNextItem = itemId => {
|
|
155
155
|
// If the item is expanded and has some children, return the first of them.
|
|
156
|
-
if (
|
|
157
|
-
return
|
|
156
|
+
if (expansionSelectors.isItemExpandable(state, itemId) && expansionSelectors.isItemExpanded(state, itemId)) {
|
|
157
|
+
return itemsSelectors.itemOrderedChildrenIds(state, itemId)[0];
|
|
158
158
|
}
|
|
159
|
-
let itemMeta =
|
|
159
|
+
let itemMeta = itemsSelectors.itemMeta(state, itemId);
|
|
160
160
|
while (itemMeta != null) {
|
|
161
161
|
// Try to find the first navigable sibling after the current item.
|
|
162
|
-
const siblings =
|
|
163
|
-
const currentItemIndex =
|
|
162
|
+
const siblings = itemsSelectors.itemOrderedChildrenIds(state, itemMeta.parentId);
|
|
163
|
+
const currentItemIndex = itemsSelectors.itemIndex(state, itemMeta.id);
|
|
164
164
|
if (currentItemIndex < siblings.length - 1) {
|
|
165
165
|
return siblings[currentItemIndex + 1];
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// If the item is the last of its siblings, go up a level to the parent and try again.
|
|
169
|
-
itemMeta = itemMeta.parentId ?
|
|
169
|
+
itemMeta = itemMeta.parentId ? itemsSelectors.itemMeta(state, itemMeta.parentId) : null;
|
|
170
170
|
}
|
|
171
171
|
throw new Error('Invalid range');
|
|
172
172
|
};
|
|
@@ -175,7 +175,7 @@ export const getNonDisabledItemsInRange = (state, itemAId, itemBId) => {
|
|
|
175
175
|
let current = first;
|
|
176
176
|
while (current !== last) {
|
|
177
177
|
current = getNextItem(current);
|
|
178
|
-
if (!
|
|
178
|
+
if (!itemsSelectors.isItemDisabled(state, current)) {
|
|
179
179
|
items.push(current);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import { useStore } from '@mui/x-internals/store';
|
|
5
6
|
import extractEventHandlers from '@mui/utils/extractEventHandlers';
|
|
6
7
|
import useForkRef from '@mui/utils/useForkRef';
|
|
7
8
|
import { useTreeViewContext } from "../internals/TreeViewProvider/index.js";
|
|
8
9
|
import { useTreeItemUtils } from "../hooks/useTreeItemUtils/index.js";
|
|
9
10
|
import { TreeViewItemDepthContext } from "../internals/TreeViewItemDepthContext/index.js";
|
|
10
11
|
import { isTargetInDescendants } from "../internals/utils/tree.js";
|
|
11
|
-
import { useSelector } from "../internals/hooks/useSelector.js";
|
|
12
|
-
import { selectorIsItemTheDefaultFocusableItem } from "../internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.js";
|
|
13
12
|
import { generateTreeItemIdAttribute } from "../internals/corePlugins/useTreeViewId/useTreeViewId.utils.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
13
|
+
import { focusSelectors } from "../internals/plugins/useTreeViewFocus/index.js";
|
|
14
|
+
import { itemsSelectors } from "../internals/plugins/useTreeViewItems/index.js";
|
|
15
|
+
import { idSelectors } from "../internals/corePlugins/useTreeViewId/index.js";
|
|
16
|
+
import { expansionSelectors } from "../internals/plugins/useTreeViewExpansion/index.js";
|
|
17
|
+
import { selectionSelectors } from "../internals/plugins/useTreeViewSelection/index.js";
|
|
18
18
|
export const useTreeItem = parameters => {
|
|
19
19
|
const {
|
|
20
20
|
runItemPlugins,
|
|
@@ -23,7 +23,7 @@ export const useTreeItem = parameters => {
|
|
|
23
23
|
store
|
|
24
24
|
} = useTreeViewContext();
|
|
25
25
|
const depthContext = React.useContext(TreeViewItemDepthContext);
|
|
26
|
-
const depth =
|
|
26
|
+
const depth = useStore(store, (...params) => {
|
|
27
27
|
if (typeof depthContext === 'function') {
|
|
28
28
|
return depthContext(...params);
|
|
29
29
|
}
|
|
@@ -53,15 +53,15 @@ export const useTreeItem = parameters => {
|
|
|
53
53
|
const handleRootRef = useForkRef(rootRef, pluginRootRef, rootRefObject);
|
|
54
54
|
const handleContentRef = useForkRef(contentRef, contentRefObject);
|
|
55
55
|
const checkboxRef = React.useRef(null);
|
|
56
|
-
const treeId =
|
|
57
|
-
const isSelectionEnabledForItem =
|
|
58
|
-
const isCheckboxSelectionEnabled =
|
|
56
|
+
const treeId = useStore(store, idSelectors.treeId);
|
|
57
|
+
const isSelectionEnabledForItem = useStore(store, selectionSelectors.canItemBeSelected, itemId);
|
|
58
|
+
const isCheckboxSelectionEnabled = useStore(store, selectionSelectors.isCheckboxSelectionEnabled);
|
|
59
59
|
const idAttribute = generateTreeItemIdAttribute({
|
|
60
60
|
itemId,
|
|
61
61
|
treeId,
|
|
62
62
|
id
|
|
63
63
|
});
|
|
64
|
-
const shouldBeAccessibleWithTab =
|
|
64
|
+
const shouldBeAccessibleWithTab = useStore(store, focusSelectors.isItemTheDefaultFocusableItem, itemId);
|
|
65
65
|
const sharedPropsEnhancerParams = {
|
|
66
66
|
rootRefObject,
|
|
67
67
|
contentRefObject,
|
|
@@ -72,7 +72,7 @@ export const useTreeItem = parameters => {
|
|
|
72
72
|
if (event.defaultMuiPrevented) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
if (!status.focused &&
|
|
75
|
+
if (!status.focused && itemsSelectors.canItemBeFocused(store.state, itemId) && event.currentTarget === event.target) {
|
|
76
76
|
instance.focusItem(event, itemId);
|
|
77
77
|
}
|
|
78
78
|
};
|
|
@@ -114,7 +114,7 @@ export const useTreeItem = parameters => {
|
|
|
114
114
|
if (event.defaultMuiPrevented || checkboxRef.current?.contains(event.target)) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
|
-
if (
|
|
117
|
+
if (expansionSelectors.triggerSlot(store.state) === 'content') {
|
|
118
118
|
interactions.handleExpansion(event);
|
|
119
119
|
}
|
|
120
120
|
if (!isCheckboxSelectionEnabled) {
|
|
@@ -137,7 +137,7 @@ export const useTreeItem = parameters => {
|
|
|
137
137
|
if (event.defaultMuiPrevented) {
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
|
-
if (
|
|
140
|
+
if (expansionSelectors.triggerSlot(store.state) === 'iconContainer') {
|
|
141
141
|
interactions.handleExpansion(event);
|
|
142
142
|
}
|
|
143
143
|
};
|
|
@@ -7,6 +7,7 @@ import { UseTreeViewFocusSignature } from "../internals/plugins/useTreeViewFocus
|
|
|
7
7
|
import { UseTreeViewKeyboardNavigationSignature } from "../internals/plugins/useTreeViewKeyboardNavigation/index.js";
|
|
8
8
|
import { UseTreeViewLabelSignature } from "../internals/plugins/useTreeViewLabel/index.js";
|
|
9
9
|
import { UseTreeViewExpansionSignature } from "../internals/plugins/useTreeViewExpansion/index.js";
|
|
10
|
+
import { UseTreeViewLazyLoadingSignature } from "../internals/plugins/useTreeViewLazyLoading/index.js";
|
|
10
11
|
export interface UseTreeItemParameters {
|
|
11
12
|
/**
|
|
12
13
|
* The id attribute of the item. If not provided, it will be generated.
|
|
@@ -199,4 +200,4 @@ export type UseTreeItemMinimalPlugins = readonly [UseTreeViewSelectionSignature,
|
|
|
199
200
|
/**
|
|
200
201
|
* Plugins that `UseTreeItem` can use if they are present, but are not required.
|
|
201
202
|
*/
|
|
202
|
-
export type UseTreeItemOptionalPlugins = readonly [];
|
|
203
|
+
export type UseTreeItemOptionalPlugins = readonly [UseTreeViewLazyLoadingSignature];
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.useTreeItemModel = void 0;
|
|
8
|
+
var _store = require("@mui/x-internals/store");
|
|
8
9
|
var _TreeViewProvider = require("../internals/TreeViewProvider");
|
|
9
|
-
var
|
|
10
|
-
var _useTreeViewItems = require("../internals/plugins/useTreeViewItems/useTreeViewItems.selectors");
|
|
10
|
+
var _useTreeViewItems = require("../internals/plugins/useTreeViewItems");
|
|
11
11
|
const useTreeItemModel = itemId => {
|
|
12
12
|
const {
|
|
13
13
|
store
|
|
14
14
|
} = (0, _TreeViewProvider.useTreeViewContext)();
|
|
15
|
-
return (0,
|
|
15
|
+
return (0, _store.useStore)(store, _useTreeViewItems.itemsSelectors.itemModel, itemId);
|
|
16
16
|
};
|
|
17
17
|
exports.useTreeItemModel = useTreeItemModel;
|