@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.
Files changed (154) hide show
  1. package/CHANGELOG.md +214 -13
  2. package/RichTreeView/RichTreeView.js +16 -15
  3. package/RichTreeView/RichTreeView.types.d.ts +3 -2
  4. package/SimpleTreeView/SimpleTreeView.js +10 -9
  5. package/SimpleTreeView/SimpleTreeView.types.d.ts +3 -2
  6. package/TreeItem/TreeItem.d.ts +1 -1
  7. package/TreeItem/TreeItem.types.d.ts +3 -1
  8. package/TreeItemProvider/TreeItemProvider.js +3 -3
  9. package/esm/RichTreeView/RichTreeView.js +16 -15
  10. package/esm/RichTreeView/RichTreeView.types.d.ts +3 -2
  11. package/esm/SimpleTreeView/SimpleTreeView.js +10 -9
  12. package/esm/SimpleTreeView/SimpleTreeView.types.d.ts +3 -2
  13. package/esm/TreeItem/TreeItem.d.ts +1 -1
  14. package/esm/TreeItem/TreeItem.types.d.ts +3 -1
  15. package/esm/TreeItemProvider/TreeItemProvider.js +3 -3
  16. package/esm/hooks/useTreeItemModel.js +3 -3
  17. package/esm/hooks/useTreeItemUtils/useTreeItemUtils.js +24 -25
  18. package/esm/index.js +1 -1
  19. package/esm/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +2 -2
  20. package/esm/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -3
  21. package/esm/internals/components/RichTreeViewItems.js +5 -5
  22. package/esm/internals/corePlugins/useTreeViewId/index.d.ts +2 -1
  23. package/esm/internals/corePlugins/useTreeViewId/index.js +2 -1
  24. package/esm/internals/corePlugins/useTreeViewId/useTreeViewId.js +10 -13
  25. package/esm/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.d.ts +8 -34
  26. package/esm/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.js +9 -9
  27. package/esm/internals/index.d.ts +6 -14
  28. package/esm/internals/index.js +6 -13
  29. package/esm/internals/models/plugin.d.ts +2 -3
  30. package/esm/internals/models/treeView.d.ts +4 -6
  31. package/esm/internals/plugins/useTreeViewExpansion/index.d.ts +2 -1
  32. package/esm/internals/plugins/useTreeViewExpansion/index.js +2 -1
  33. package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +26 -30
  34. package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.d.ts +24 -316
  35. package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.js +27 -38
  36. package/esm/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +7 -1
  37. package/esm/internals/plugins/useTreeViewFocus/index.d.ts +2 -1
  38. package/esm/internals/plugins/useTreeViewFocus/index.js +2 -1
  39. package/esm/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +17 -21
  40. package/esm/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.d.ts +20 -628
  41. package/esm/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.js +25 -37
  42. package/esm/internals/plugins/useTreeViewItems/index.d.ts +2 -1
  43. package/esm/internals/plugins/useTreeViewItems/index.js +2 -1
  44. package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.js +78 -99
  45. package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +52 -1142
  46. package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +58 -98
  47. package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.utils.d.ts +1 -1
  48. package/esm/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +1 -1
  49. package/esm/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +32 -42
  50. package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +22 -22
  51. package/esm/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +2 -0
  52. package/esm/internals/plugins/useTreeViewLabel/index.d.ts +2 -1
  53. package/esm/internals/plugins/useTreeViewLabel/index.js +2 -1
  54. package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.itemPlugin.js +4 -4
  55. package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +17 -25
  56. package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.d.ts +14 -100
  57. package/esm/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.js +24 -34
  58. package/esm/internals/plugins/useTreeViewLazyLoading/index.d.ts +2 -1
  59. package/esm/internals/plugins/useTreeViewLazyLoading/index.js +1 -1
  60. package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.d.ts +18 -245
  61. package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.js +15 -27
  62. package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +20 -6
  63. package/esm/internals/plugins/useTreeViewSelection/index.d.ts +2 -1
  64. package/esm/internals/plugins/useTreeViewSelection/index.js +2 -1
  65. package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.itemPlugin.js +25 -38
  66. package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +30 -34
  67. package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.d.ts +38 -517
  68. package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.js +46 -71
  69. package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +1 -0
  70. package/esm/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +10 -10
  71. package/esm/internals/useTreeView/useTreeView.d.ts +1 -1
  72. package/esm/internals/useTreeView/useTreeView.js +11 -18
  73. package/esm/internals/useTreeView/useTreeView.types.d.ts +1 -1
  74. package/esm/internals/useTreeView/useTreeViewBuildContext.d.ts +2 -3
  75. package/esm/internals/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +0 -2
  76. package/esm/internals/utils/tree.js +33 -33
  77. package/esm/useTreeItem/useTreeItem.js +14 -14
  78. package/esm/useTreeItem/useTreeItem.types.d.ts +2 -1
  79. package/hooks/useTreeItemModel.js +3 -3
  80. package/hooks/useTreeItemUtils/useTreeItemUtils.js +18 -19
  81. package/index.js +1 -1
  82. package/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +1 -1
  83. package/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -3
  84. package/internals/components/RichTreeViewItems.js +5 -5
  85. package/internals/corePlugins/useTreeViewId/index.d.ts +2 -1
  86. package/internals/corePlugins/useTreeViewId/index.js +8 -1
  87. package/internals/corePlugins/useTreeViewId/useTreeViewId.js +9 -12
  88. package/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.d.ts +8 -34
  89. package/internals/corePlugins/useTreeViewId/useTreeViewId.selectors.js +10 -10
  90. package/internals/index.d.ts +6 -14
  91. package/internals/index.js +12 -73
  92. package/internals/models/plugin.d.ts +2 -3
  93. package/internals/models/treeView.d.ts +4 -6
  94. package/internals/plugins/useTreeViewExpansion/index.d.ts +2 -1
  95. package/internals/plugins/useTreeViewExpansion/index.js +8 -1
  96. package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +24 -28
  97. package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.d.ts +24 -316
  98. package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.selectors.js +27 -38
  99. package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.types.d.ts +7 -1
  100. package/internals/plugins/useTreeViewFocus/index.d.ts +2 -1
  101. package/internals/plugins/useTreeViewFocus/index.js +8 -1
  102. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +14 -18
  103. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.d.ts +20 -628
  104. package/internals/plugins/useTreeViewFocus/useTreeViewFocus.selectors.js +23 -35
  105. package/internals/plugins/useTreeViewItems/index.d.ts +2 -1
  106. package/internals/plugins/useTreeViewItems/index.js +8 -1
  107. package/internals/plugins/useTreeViewItems/useTreeViewItems.js +77 -98
  108. package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.d.ts +52 -1142
  109. package/internals/plugins/useTreeViewItems/useTreeViewItems.selectors.js +59 -99
  110. package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.d.ts +1 -1
  111. package/internals/plugins/useTreeViewItems/useTreeViewItems.utils.js +1 -1
  112. package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +32 -42
  113. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +18 -18
  114. package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.types.d.ts +2 -0
  115. package/internals/plugins/useTreeViewLabel/index.d.ts +2 -1
  116. package/internals/plugins/useTreeViewLabel/index.js +8 -1
  117. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.itemPlugin.js +3 -3
  118. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +16 -24
  119. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.d.ts +14 -100
  120. package/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors.js +24 -34
  121. package/internals/plugins/useTreeViewLazyLoading/index.d.ts +2 -1
  122. package/internals/plugins/useTreeViewLazyLoading/index.js +8 -1
  123. package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.d.ts +18 -245
  124. package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.selectors.js +16 -28
  125. package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +20 -6
  126. package/internals/plugins/useTreeViewSelection/index.d.ts +2 -1
  127. package/internals/plugins/useTreeViewSelection/index.js +8 -1
  128. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.itemPlugin.js +23 -37
  129. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +29 -33
  130. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.d.ts +38 -517
  131. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.selectors.js +46 -71
  132. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.types.d.ts +1 -0
  133. package/internals/plugins/useTreeViewSelection/useTreeViewSelection.utils.js +8 -8
  134. package/internals/useTreeView/useTreeView.d.ts +1 -1
  135. package/internals/useTreeView/useTreeView.js +11 -18
  136. package/internals/useTreeView/useTreeView.types.d.ts +1 -1
  137. package/internals/useTreeView/useTreeViewBuildContext.d.ts +2 -3
  138. package/internals/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +0 -2
  139. package/internals/utils/tree.js +31 -31
  140. package/package.json +12 -13
  141. package/useTreeItem/useTreeItem.js +14 -14
  142. package/useTreeItem/useTreeItem.types.d.ts +2 -1
  143. package/esm/internals/hooks/useSelector.d.ts +0 -4
  144. package/esm/internals/hooks/useSelector.js +0 -8
  145. package/esm/internals/utils/TreeViewStore.d.ts +0 -12
  146. package/esm/internals/utils/TreeViewStore.js +0 -22
  147. package/esm/internals/utils/selectors.d.ts +0 -21
  148. package/esm/internals/utils/selectors.js +0 -51
  149. package/internals/hooks/useSelector.d.ts +0 -4
  150. package/internals/hooks/useSelector.js +0 -16
  151. package/internals/utils/TreeViewStore.d.ts +0 -12
  152. package/internals/utils/TreeViewStore.js +0 -29
  153. package/internals/utils/selectors.d.ts +0 -21
  154. package/internals/utils/selectors.js +0 -58
@@ -1,102 +1,16 @@
1
1
  import { UseTreeViewLabelSignature } from "./useTreeViewLabel.types.js";
2
- import { TreeViewRootSelector } from "../../utils/selectors.js";
3
- /**
4
- * Check if an item is editable.
5
- * @param {TreeViewState<[UseTreeViewItemsSignature]>} state The state of the tree view.
6
- * @param {TreeViewItemId} itemId The id of the item to check.
7
- * @returns {boolean} `true` if the item is editable, `false` otherwise.
8
- */
9
- export declare const selectorIsItemEditable: ((state: any, itemId: string) => boolean) & {
10
- clearCache: () => void;
11
- resultsCount: () => number;
12
- resetResultsCount: () => void;
13
- } & {
14
- resultFunc: (resultFuncArgs_0: {
15
- isItemEditable: ((item: any) => boolean) | boolean;
16
- editedItemId: string | null;
17
- } | undefined, resultFuncArgs_1: import("../../../index.js").TreeViewBaseItem<import("../../../index.js").TreeViewDefaultItemModelProperties>) => boolean;
18
- memoizedResultFunc: ((resultFuncArgs_0: {
19
- isItemEditable: ((item: any) => boolean) | boolean;
20
- editedItemId: string | null;
21
- } | undefined, resultFuncArgs_1: import("../../../index.js").TreeViewBaseItem<import("../../../index.js").TreeViewDefaultItemModelProperties>) => boolean) & {
22
- clearCache: () => void;
23
- resultsCount: () => number;
24
- resetResultsCount: () => void;
25
- };
26
- lastResult: () => boolean;
27
- dependencies: [TreeViewRootSelector<UseTreeViewLabelSignature, true>, (state: any, itemId: string) => import("../../../index.js").TreeViewBaseItem<import("../../../index.js").TreeViewDefaultItemModelProperties>];
28
- recomputations: () => number;
29
- resetRecomputations: () => void;
30
- dependencyRecomputations: () => number;
31
- resetDependencyRecomputations: () => void;
32
- } & {
33
- memoize: typeof import("reselect").weakMapMemoize;
34
- argsMemoize: typeof import("reselect").weakMapMemoize;
35
- };
36
- /**
37
- * Check if the given item is being edited.
38
- * @param {TreeViewState<[UseTreeViewLabelSignature]>} state The state of the tree view.
39
- * @param {TreeViewItemId} itemId The id of the item to check.
40
- * @returns {boolean} `true` if the item is being edited, `false` otherwise.
41
- */
42
- export declare const selectorIsItemBeingEdited: ((state: any, itemId: string | null) => boolean) & {
43
- clearCache: () => void;
44
- resultsCount: () => number;
45
- resetResultsCount: () => void;
46
- } & {
47
- resultFunc: (resultFuncArgs_0: {
48
- isItemEditable: ((item: any) => boolean) | boolean;
49
- editedItemId: string | null;
50
- } | undefined, resultFuncArgs_1: string | null) => boolean;
51
- memoizedResultFunc: ((resultFuncArgs_0: {
52
- isItemEditable: ((item: any) => boolean) | boolean;
53
- editedItemId: string | null;
54
- } | undefined, resultFuncArgs_1: string | null) => boolean) & {
55
- clearCache: () => void;
56
- resultsCount: () => number;
57
- resetResultsCount: () => void;
58
- };
59
- lastResult: () => boolean;
60
- dependencies: [TreeViewRootSelector<UseTreeViewLabelSignature, true>, (_: any, itemId: string | null) => string | null];
61
- recomputations: () => number;
62
- resetRecomputations: () => void;
63
- dependencyRecomputations: () => number;
64
- resetDependencyRecomputations: () => void;
65
- } & {
66
- memoize: typeof import("reselect").weakMapMemoize;
67
- argsMemoize: typeof import("reselect").weakMapMemoize;
68
- };
69
- /**
70
- * Check if an item is being edited.
71
- * @param {TreeViewState<[UseTreeViewLabelSignature]>} state The state of the tree view.
72
- * @returns {boolean} `true` if an item is being edited, `false` otherwise.
73
- */
74
- export declare const selectorIsAnyItemBeingEdited: ((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types.js").UseTreeViewIdState & Partial<import("./useTreeViewLabel.types.js").UseTreeViewLabelState> & {
75
- cacheKey: import("../../models/index.js").TreeViewStateCacheKey;
76
- }) => boolean) & {
77
- clearCache: () => void;
78
- resultsCount: () => number;
79
- resetResultsCount: () => void;
80
- } & {
81
- resultFunc: (resultFuncArgs_0: {
82
- isItemEditable: ((item: any) => boolean) | boolean;
83
- editedItemId: string | null;
84
- } | undefined) => boolean;
85
- memoizedResultFunc: ((resultFuncArgs_0: {
86
- isItemEditable: ((item: any) => boolean) | boolean;
87
- editedItemId: string | null;
88
- } | undefined) => boolean) & {
89
- clearCache: () => void;
90
- resultsCount: () => number;
91
- resetResultsCount: () => void;
92
- };
93
- lastResult: () => boolean;
94
- dependencies: [TreeViewRootSelector<UseTreeViewLabelSignature, true>];
95
- recomputations: () => number;
96
- resetRecomputations: () => void;
97
- dependencyRecomputations: () => number;
98
- resetDependencyRecomputations: () => void;
99
- } & {
100
- memoize: typeof import("reselect").weakMapMemoize;
101
- argsMemoize: typeof import("reselect").weakMapMemoize;
2
+ import { TreeViewState } from "../../models/index.js";
3
+ export declare const labelSelectors: {
4
+ /**
5
+ * Checks whether an item is editable.
6
+ */
7
+ isItemEditable: (args_0: import("../../corePlugins/useTreeViewId/useTreeViewId.types.js").UseTreeViewIdState & import("../useTreeViewItems/index.js").UseTreeViewItemsState<import("../../../index.js").TreeViewDefaultItemModelProperties> & Partial<{}>, _itemId: string) => boolean;
8
+ /**
9
+ * Checks whether an item is being edited.
10
+ */
11
+ isItemBeingEdited: (state: TreeViewState<[], [UseTreeViewLabelSignature]>, itemId: string | null) => boolean;
12
+ /**
13
+ * Checks whether any item is being edited.
14
+ */
15
+ isAnyItemBeingEdited: (state: TreeViewState<[], [UseTreeViewLabelSignature]>) => boolean;
102
16
  };
@@ -3,38 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorIsItemEditable = exports.selectorIsItemBeingEdited = exports.selectorIsAnyItemBeingEdited = void 0;
7
- var _selectors = require("../../utils/selectors");
6
+ exports.labelSelectors = void 0;
7
+ var _store = require("@mui/x-internals/store");
8
8
  var _useTreeViewItems = require("../useTreeViewItems/useTreeViewItems.selectors");
9
- const selectorTreeViewLabelState = state => state.label;
10
-
11
- /**
12
- * Check if an item is editable.
13
- * @param {TreeViewState<[UseTreeViewItemsSignature]>} state The state of the tree view.
14
- * @param {TreeViewItemId} itemId The id of the item to check.
15
- * @returns {boolean} `true` if the item is editable, `false` otherwise.
16
- */
17
- const selectorIsItemEditable = exports.selectorIsItemEditable = (0, _selectors.createSelector)([selectorTreeViewLabelState, (state, itemId) => (0, _useTreeViewItems.selectorItemModel)(state, itemId)], (labelState, itemModel) => {
18
- if (!itemModel || !labelState) {
19
- return false;
20
- }
21
- if (typeof labelState.isItemEditable === 'boolean') {
22
- return labelState.isItemEditable;
23
- }
24
- return labelState.isItemEditable(itemModel);
25
- });
26
-
27
- /**
28
- * Check if the given item is being edited.
29
- * @param {TreeViewState<[UseTreeViewLabelSignature]>} state The state of the tree view.
30
- * @param {TreeViewItemId} itemId The id of the item to check.
31
- * @returns {boolean} `true` if the item is being edited, `false` otherwise.
32
- */
33
- const selectorIsItemBeingEdited = exports.selectorIsItemBeingEdited = (0, _selectors.createSelector)([selectorTreeViewLabelState, (_, itemId) => itemId], (labelState, itemId) => itemId ? labelState?.editedItemId === itemId : false);
34
-
35
- /**
36
- * Check if an item is being edited.
37
- * @param {TreeViewState<[UseTreeViewLabelSignature]>} state The state of the tree view.
38
- * @returns {boolean} `true` if an item is being edited, `false` otherwise.
39
- */
40
- const selectorIsAnyItemBeingEdited = exports.selectorIsAnyItemBeingEdited = (0, _selectors.createSelector)(selectorTreeViewLabelState, labelState => !!labelState?.editedItemId);
9
+ const labelSelectors = exports.labelSelectors = {
10
+ /**
11
+ * Checks whether an item is editable.
12
+ */
13
+ isItemEditable: (0, _store.createSelector)(state => state.label?.isItemEditable, _useTreeViewItems.itemsSelectors.itemModel, (isItemEditable, itemModel, _itemId) => {
14
+ if (!itemModel || isItemEditable == null) {
15
+ return false;
16
+ }
17
+ if (typeof isItemEditable === 'boolean') {
18
+ return isItemEditable;
19
+ }
20
+ return isItemEditable(itemModel);
21
+ }),
22
+ /**
23
+ * Checks whether an item is being edited.
24
+ */
25
+ isItemBeingEdited: (0, _store.createSelector)((state, itemId) => itemId == null ? false : state.label?.editedItemId === itemId),
26
+ /**
27
+ * Checks whether any item is being edited.
28
+ */
29
+ isAnyItemBeingEdited: (0, _store.createSelector)(state => !!state.label?.editedItemId)
30
+ };
@@ -1 +1,2 @@
1
- export type { UseTreeViewLazyLoadingSignature, UseTreeViewLazyLoadingParameters } from "./useTreeViewLazyLoading.types.js";
1
+ export type { UseTreeViewLazyLoadingSignature, UseTreeViewLazyLoadingParameters, UseTreeViewLazyLoadingInstance } from "./useTreeViewLazyLoading.types.js";
2
+ export { lazyLoadingSelectors } from "./useTreeViewLazyLoading.selectors.js";
@@ -2,4 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ Object.defineProperty(exports, "lazyLoadingSelectors", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _useTreeViewLazyLoading.lazyLoadingSelectors;
10
+ }
11
+ });
12
+ var _useTreeViewLazyLoading = require("./useTreeViewLazyLoading.selectors");
@@ -1,247 +1,20 @@
1
- import { TreeViewRootSelector, TreeViewRootSelectorForOptionalPlugin } from "../../utils/selectors.js";
1
+ import { TreeViewItemId } from "../../../models/index.js";
2
2
  import { UseTreeViewLazyLoadingSignature } from "./useTreeViewLazyLoading.types.js";
3
- export declare const selectorDataSourceState: ((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types.js").UseTreeViewIdState & import("./useTreeViewLazyLoading.types.js").UseTreeViewLazyLoadingState & Partial<{}> & {
4
- cacheKey: import("../../models/index.js").TreeViewStateCacheKey;
5
- }) => {
6
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
7
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
8
- }) & {
9
- clearCache: () => void;
10
- resultsCount: () => number;
11
- resetResultsCount: () => void;
12
- } & {
13
- resultFunc: (resultFuncArgs_0: {
14
- enabled: boolean;
15
- dataSource: {
16
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
17
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
18
- };
19
- }) => {
20
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
21
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
22
- };
23
- memoizedResultFunc: ((resultFuncArgs_0: {
24
- enabled: boolean;
25
- dataSource: {
26
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
27
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
28
- };
29
- }) => {
30
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
31
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
32
- }) & {
33
- clearCache: () => void;
34
- resultsCount: () => number;
35
- resetResultsCount: () => void;
36
- };
37
- lastResult: () => {
38
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
39
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
40
- };
41
- dependencies: [TreeViewRootSelector<UseTreeViewLazyLoadingSignature>];
42
- recomputations: () => number;
43
- resetRecomputations: () => void;
44
- dependencyRecomputations: () => number;
45
- resetDependencyRecomputations: () => void;
46
- } & {
47
- memoize: typeof import("reselect").weakMapMemoize;
48
- argsMemoize: typeof import("reselect").weakMapMemoize;
49
- };
50
- /**
51
- * Check if lazy loading is enabled.
52
- * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
53
- * @returns {boolean} True if lazy loading is enabled, false if it isn't.
54
- */
55
- export declare const selectorIsLazyLoadingEnabled: ((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types.js").UseTreeViewIdState & Partial<import("./useTreeViewLazyLoading.types.js").UseTreeViewLazyLoadingState> & {
56
- cacheKey: import("../../models/index.js").TreeViewStateCacheKey;
57
- }) => boolean) & {
58
- clearCache: () => void;
59
- resultsCount: () => number;
60
- resetResultsCount: () => void;
61
- } & {
62
- resultFunc: (resultFuncArgs_0: {
63
- enabled: boolean;
64
- dataSource: {
65
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
66
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
67
- };
68
- } | undefined) => boolean;
69
- memoizedResultFunc: ((resultFuncArgs_0: {
70
- enabled: boolean;
71
- dataSource: {
72
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
73
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
74
- };
75
- } | undefined) => boolean) & {
76
- clearCache: () => void;
77
- resultsCount: () => number;
78
- resetResultsCount: () => void;
79
- };
80
- lastResult: () => boolean;
81
- dependencies: [TreeViewRootSelectorForOptionalPlugin<UseTreeViewLazyLoadingSignature>];
82
- recomputations: () => number;
83
- resetRecomputations: () => void;
84
- dependencyRecomputations: () => number;
85
- resetDependencyRecomputations: () => void;
86
- } & {
87
- memoize: typeof import("reselect").weakMapMemoize;
88
- argsMemoize: typeof import("reselect").weakMapMemoize;
89
- };
90
- /**
91
- * Get the loading state for a tree item.
92
- * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
93
- * @param {TreeViewItemId} itemId The id of the item to get the loading state of.
94
- * @returns {boolean} The loading state for the Tree Item.
95
- */
96
- export declare const selectorIsItemLoading: ((state: any, itemId: string) => boolean) & {
97
- clearCache: () => void;
98
- resultsCount: () => number;
99
- resetResultsCount: () => void;
100
- } & {
101
- resultFunc: (resultFuncArgs_0: {
102
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
103
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
104
- }, resultFuncArgs_1: string) => boolean;
105
- memoizedResultFunc: ((resultFuncArgs_0: {
106
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
107
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
108
- }, resultFuncArgs_1: string) => boolean) & {
109
- clearCache: () => void;
110
- resultsCount: () => number;
111
- resetResultsCount: () => void;
112
- };
113
- lastResult: () => boolean;
114
- dependencies: [((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types.js").UseTreeViewIdState & import("./useTreeViewLazyLoading.types.js").UseTreeViewLazyLoadingState & Partial<{}> & {
115
- cacheKey: import("../../models/index.js").TreeViewStateCacheKey;
116
- }) => {
117
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
118
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
119
- }) & {
120
- clearCache: () => void;
121
- resultsCount: () => number;
122
- resetResultsCount: () => void;
123
- } & {
124
- resultFunc: (resultFuncArgs_0: {
125
- enabled: boolean;
126
- dataSource: {
127
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
128
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
129
- };
130
- }) => {
131
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
132
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
133
- };
134
- memoizedResultFunc: ((resultFuncArgs_0: {
135
- enabled: boolean;
136
- dataSource: {
137
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
138
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
139
- };
140
- }) => {
141
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
142
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
143
- }) & {
144
- clearCache: () => void;
145
- resultsCount: () => number;
146
- resetResultsCount: () => void;
147
- };
148
- lastResult: () => {
149
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
150
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
151
- };
152
- dependencies: [TreeViewRootSelector<UseTreeViewLazyLoadingSignature>];
153
- recomputations: () => number;
154
- resetRecomputations: () => void;
155
- dependencyRecomputations: () => number;
156
- resetDependencyRecomputations: () => void;
157
- } & {
158
- memoize: typeof import("reselect").weakMapMemoize;
159
- argsMemoize: typeof import("reselect").weakMapMemoize;
160
- }, (_: any, itemId: string) => string];
161
- recomputations: () => number;
162
- resetRecomputations: () => void;
163
- dependencyRecomputations: () => number;
164
- resetDependencyRecomputations: () => void;
165
- } & {
166
- memoize: typeof import("reselect").weakMapMemoize;
167
- argsMemoize: typeof import("reselect").weakMapMemoize;
168
- };
169
- /**
170
- * Get the error for a tree item.
171
- * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
172
- * @param {TreeViewItemId} itemId The id of the item to get the error for.
173
- * @returns {boolean} The error for the Tree Item.
174
- */
175
- export declare const selectorGetTreeItemError: ((state: any, itemId: string) => Error | null) & {
176
- clearCache: () => void;
177
- resultsCount: () => number;
178
- resetResultsCount: () => void;
179
- } & {
180
- resultFunc: (resultFuncArgs_0: {
181
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
182
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
183
- }, resultFuncArgs_1: string) => Error | null;
184
- memoizedResultFunc: ((resultFuncArgs_0: {
185
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
186
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
187
- }, resultFuncArgs_1: string) => Error | null) & {
188
- clearCache: () => void;
189
- resultsCount: () => number;
190
- resetResultsCount: () => void;
191
- };
192
- lastResult: () => Error | null;
193
- dependencies: [((state: import("../../corePlugins/useTreeViewId/useTreeViewId.types.js").UseTreeViewIdState & import("./useTreeViewLazyLoading.types.js").UseTreeViewLazyLoadingState & Partial<{}> & {
194
- cacheKey: import("../../models/index.js").TreeViewStateCacheKey;
195
- }) => {
196
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
197
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
198
- }) & {
199
- clearCache: () => void;
200
- resultsCount: () => number;
201
- resetResultsCount: () => void;
202
- } & {
203
- resultFunc: (resultFuncArgs_0: {
204
- enabled: boolean;
205
- dataSource: {
206
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
207
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
208
- };
209
- }) => {
210
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
211
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
212
- };
213
- memoizedResultFunc: ((resultFuncArgs_0: {
214
- enabled: boolean;
215
- dataSource: {
216
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
217
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
218
- };
219
- }) => {
220
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
221
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
222
- }) & {
223
- clearCache: () => void;
224
- resultsCount: () => number;
225
- resetResultsCount: () => void;
226
- };
227
- lastResult: () => {
228
- loading: Record<import("../../../index.js").TreeViewItemId, boolean>;
229
- errors: Record<import("../../../index.js").TreeViewItemId, Error | null>;
230
- };
231
- dependencies: [TreeViewRootSelector<UseTreeViewLazyLoadingSignature>];
232
- recomputations: () => number;
233
- resetRecomputations: () => void;
234
- dependencyRecomputations: () => number;
235
- resetDependencyRecomputations: () => void;
236
- } & {
237
- memoize: typeof import("reselect").weakMapMemoize;
238
- argsMemoize: typeof import("reselect").weakMapMemoize;
239
- }, (_: any, itemId: string) => string];
240
- recomputations: () => number;
241
- resetRecomputations: () => void;
242
- dependencyRecomputations: () => number;
243
- resetDependencyRecomputations: () => void;
244
- } & {
245
- memoize: typeof import("reselect").weakMapMemoize;
246
- argsMemoize: typeof import("reselect").weakMapMemoize;
3
+ import { TreeViewState } from "../../models/index.js";
4
+ export declare const lazyLoadingSelectors: {
5
+ /**
6
+ * Gets the data source used to lazy load items.
7
+ */
8
+ dataSource: (state: TreeViewState<[], [UseTreeViewLazyLoadingSignature]>) => {
9
+ loading: Record<TreeViewItemId, boolean>;
10
+ errors: Record<TreeViewItemId, Error | null>;
11
+ } | undefined;
12
+ /**
13
+ * Checks whether an item is loading.
14
+ */
15
+ isItemLoading: (state: TreeViewState<[], [UseTreeViewLazyLoadingSignature]>, itemId: string) => boolean;
16
+ /**
17
+ * Checks whether an item has errors.
18
+ */
19
+ itemHasError: (state: TreeViewState<[], [UseTreeViewLazyLoadingSignature]>, itemId: string) => boolean;
247
20
  };
@@ -3,31 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorIsLazyLoadingEnabled = exports.selectorIsItemLoading = exports.selectorGetTreeItemError = exports.selectorDataSourceState = void 0;
7
- var _selectors = require("../../utils/selectors");
8
- const selectorLazyLoading = state => state.lazyLoading;
9
- const selectorLazyLoadingOptional = state => state.lazyLoading;
10
- const selectorDataSourceState = exports.selectorDataSourceState = (0, _selectors.createSelector)([selectorLazyLoading], lazyLoading => lazyLoading.dataSource);
11
-
12
- /**
13
- * Check if lazy loading is enabled.
14
- * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
15
- * @returns {boolean} True if lazy loading is enabled, false if it isn't.
16
- */
17
- const selectorIsLazyLoadingEnabled = exports.selectorIsLazyLoadingEnabled = (0, _selectors.createSelector)([selectorLazyLoadingOptional], lazyLoading => !!lazyLoading?.enabled);
18
-
19
- /**
20
- * Get the loading state for a tree item.
21
- * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
22
- * @param {TreeViewItemId} itemId The id of the item to get the loading state of.
23
- * @returns {boolean} The loading state for the Tree Item.
24
- */
25
- const selectorIsItemLoading = exports.selectorIsItemLoading = (0, _selectors.createSelector)([selectorDataSourceState, (_, itemId) => itemId], (dataSourceState, itemId) => dataSourceState.loading[itemId] || false);
26
-
27
- /**
28
- * Get the error for a tree item.
29
- * @param {TreeViewState<[UseTreeViewLazyLoadingSignature]>} state The state of the tree view.
30
- * @param {TreeViewItemId} itemId The id of the item to get the error for.
31
- * @returns {boolean} The error for the Tree Item.
32
- */
33
- const selectorGetTreeItemError = exports.selectorGetTreeItemError = (0, _selectors.createSelector)([selectorDataSourceState, (_, itemId) => itemId], (dataSourceState, itemId) => dataSourceState.errors[itemId] || null);
6
+ exports.lazyLoadingSelectors = void 0;
7
+ var _store = require("@mui/x-internals/store");
8
+ const lazyLoadingSelectors = exports.lazyLoadingSelectors = {
9
+ /**
10
+ * Gets the data source used to lazy load items.
11
+ */
12
+ dataSource: (0, _store.createSelector)(state => state.lazyLoading?.dataSource),
13
+ /**
14
+ * Checks whether an item is loading.
15
+ */
16
+ isItemLoading: (0, _store.createSelector)((state, itemId) => state.lazyLoading?.dataSource.loading[itemId] ?? false),
17
+ /**
18
+ * Checks whether an item has errors.
19
+ */
20
+ itemHasError: (0, _store.createSelector)((state, itemId) => !!state.lazyLoading?.dataSource.errors[itemId])
21
+ };
@@ -25,24 +25,38 @@ type DataSource<R extends {}> = {
25
25
  */
26
26
  getTreeItems: (parentId?: TreeViewItemId) => Promise<R[]>;
27
27
  };
28
- export interface UseTreeViewLazyLoadingPublicAPI {}
28
+ export interface UseTreeViewLazyLoadingPublicAPI {
29
+ /**
30
+ * Method used for updating an item's children.
31
+ * Only relevant for lazy-loaded tree views.
32
+ *
33
+ * @param {TreeViewItemId} itemId The The id of the item to update the children of.
34
+ * @returns {Promise<void>} The promise resolved when the items are fetched.
35
+ */
36
+ updateItemChildren: (itemId: TreeViewItemId) => Promise<void>;
37
+ }
29
38
  export interface UseTreeViewLazyLoadingInstance extends UseTreeViewLazyLoadingPublicAPI {
30
39
  /**
31
40
  * Method used for fetching multiple items concurrently.
32
41
  * Only relevant for lazy-loaded tree views.
33
42
  *
34
43
  * @param {TreeViewItemId[]} parentIds The ids of the items to fetch the children of.
35
- * @returns { Promise<void>} The children of the items.
44
+ * @returns {Promise<void>} The promise resolved when the items are fetched.
36
45
  */
37
46
  fetchItems: (parentIds?: TreeViewItemId[]) => Promise<void>;
38
47
  /**
39
- * Method used for fetching and item's children.
48
+ * Method used for fetching an item's children.
40
49
  * Only relevant for lazy-loaded tree views.
41
50
  *
42
- * @param {TreeViewItemId} itemId The The id of the item to fetch the children of.
43
- * @returns { Promise<void>} The children of the item.
51
+ * @param {object} parameters The parameters of the method.
52
+ * @param {TreeViewItemId} parameters.itemId The The id of the item to fetch the children of.
53
+ * @param {boolean} [parameters.forceRefresh] Whether to force a refresh of the children when the cache already contains some data.
54
+ * @returns {Promise<void>} The promise resolved when the items are fetched.
44
55
  */
45
- fetchItemChildren: (itemId: TreeViewItemId) => Promise<void>;
56
+ fetchItemChildren: (parameters: {
57
+ itemId: TreeViewItemId;
58
+ forceRefresh?: boolean;
59
+ }) => Promise<void>;
46
60
  /**
47
61
  * Set the loading state of an item.
48
62
  * @param {TreeViewItemId} itemId The id of the item to set the loading state of.
@@ -1,2 +1,3 @@
1
1
  export { useTreeViewSelection } from "./useTreeViewSelection.js";
2
- export type { UseTreeViewSelectionSignature, UseTreeViewSelectionParameters, UseTreeViewSelectionParametersWithDefaults } from "./useTreeViewSelection.types.js";
2
+ export type { UseTreeViewSelectionSignature, UseTreeViewSelectionParameters, UseTreeViewSelectionParametersWithDefaults } from "./useTreeViewSelection.types.js";
3
+ export { selectionSelectors } from "./useTreeViewSelection.selectors.js";
@@ -3,10 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "selectionSelectors", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _useTreeViewSelection2.selectionSelectors;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "useTreeViewSelection", {
7
13
  enumerable: true,
8
14
  get: function () {
9
15
  return _useTreeViewSelection.useTreeViewSelection;
10
16
  }
11
17
  });
12
- var _useTreeViewSelection = require("./useTreeViewSelection");
18
+ var _useTreeViewSelection = require("./useTreeViewSelection");
19
+ var _useTreeViewSelection2 = require("./useTreeViewSelection.selectors");