@itwin/tree-widget-react 4.0.0-alpha.2 → 4.0.0-alpha.4
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 +34 -1
- package/README.md +1 -3
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js +3 -2
- package/lib/esm/tree-widget-react/components/TreeWidgetUiItemsProvider.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js +2 -2
- package/lib/esm/tree-widget-react/components/tree-header/ErrorState.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js +4 -4
- package/lib/esm/tree-widget-react/components/tree-header/SearchBox.js.map +1 -1
- package/lib/esm/tree-widget-react/components/tree-header/SelectableTree.css +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js +6 -6
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +10 -2
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +246 -129
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +69 -20
- package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.d.ts +54 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js +280 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeIdsCache.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.d.ts +26 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js +23 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesTreeNode.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/{CategoriesVisibilityHandler.d.ts → internal/CategoriesVisibilityHandler.d.ts} +18 -9
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js +214 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/CategoriesVisibilityHandler.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/ClassNameDefinitions.d.ts +7 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/ClassNameDefinitions.js +11 -0
- package/lib/esm/tree-widget-react/components/trees/categories-tree/internal/ClassNameDefinitions.js.map +1 -0
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +0 -4
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.d.ts +28 -4
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js +73 -2
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContext.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.d.ts +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js +3 -4
- package/lib/esm/tree-widget-react/components/trees/common/components/Tree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.css +2 -1
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js +6 -6
- package/lib/esm/tree-widget-react/components/trees/common/components/TreeNodeVisibilityButton.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js +9 -9
- package/lib/esm/tree-widget-react/components/trees/external-sources-tree/ExternalSourcesTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js +15 -15
- package/lib/esm/tree-widget-react/components/trees/imodel-content-tree/IModelContentTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/index.d.ts +1 -0
- package/lib/esm/tree-widget-react/components/trees/index.js +1 -0
- package/lib/esm/tree-widget-react/components/trees/index.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js +12 -12
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeButtons.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +6 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js +7 -3
- package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +11 -11
- package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/AlwaysAndNeverDrawnElementInfo.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.d.ts +5 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js +45 -0
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeIdsCache.js.map +1 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.d.ts +2 -1
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js +128 -38
- package/lib/esm/tree-widget-react/components/trees/models-tree/internal/ModelsTreeVisibilityHandler.js.map +1 -1
- package/lib/public/locales/en/TreeWidget.json +15 -4
- package/package.json +8 -11
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js +0 -87
- package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesVisibilityHandler.js.map +0 -1
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.d.ts +0 -7
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js +0 -66
- package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js.map +0 -1
package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { HierarchyNode } from "@itwin/presentation-hierarchies-react";
|
|
8
|
-
import { Selectable, Selectables } from "@itwin/unified-selection";
|
|
9
|
-
import { focusedInstancesContext } from "./FocusedInstancesContext.js";
|
|
10
|
-
export function FocusedInstancesContextProvider({ selectionStorage, imodelKey, children, }) {
|
|
11
|
-
const [state, setState] = useState({
|
|
12
|
-
enabled: false,
|
|
13
|
-
toggle: () => {
|
|
14
|
-
setState((prev) => ({ ...prev, enabled: !prev.enabled }));
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
const enabled = state.enabled;
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!enabled) {
|
|
20
|
-
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const onSelectionChanged = () => {
|
|
24
|
-
const selection = selectionStorage.getSelection({ imodelKey, level: 0 });
|
|
25
|
-
if (Selectables.isEmpty(selection)) {
|
|
26
|
-
setState((prev) => ({ ...prev, loadFocusedItems: undefined }));
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const selected = [];
|
|
30
|
-
Selectables.forEach(selection, (selectable) => {
|
|
31
|
-
if (Selectable.isInstanceKey(selectable)) {
|
|
32
|
-
selected.push(selectable);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {
|
|
36
|
-
selected.push(selectable.data);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
selected.push(selectable.loadInstanceKeys);
|
|
40
|
-
});
|
|
41
|
-
const loadFocusedItems = async function* () {
|
|
42
|
-
for (const item of selected) {
|
|
43
|
-
if (typeof item === "function") {
|
|
44
|
-
yield* item();
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
yield item;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
setState((prev) => ({ ...prev, loadFocusedItems }));
|
|
52
|
-
};
|
|
53
|
-
onSelectionChanged();
|
|
54
|
-
return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {
|
|
55
|
-
if (changeImodelKey !== imodelKey || level !== 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
onSelectionChanged();
|
|
59
|
-
});
|
|
60
|
-
}, [enabled, imodelKey, selectionStorage]);
|
|
61
|
-
return _jsx(focusedInstancesContext.Provider, { value: state, children: children });
|
|
62
|
-
}
|
|
63
|
-
function isHierarchyNode(data) {
|
|
64
|
-
return !!data && typeof data === "object" && "key" in data;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=FocusedInstancesContextProvider.js.map
|
package/lib/esm/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FocusedInstancesContextProvider.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/FocusedInstancesContextProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAA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AI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies-react\";\nimport { Selectable, Selectables } from \"@itwin/unified-selection\";\nimport { focusedInstancesContext } from \"./FocusedInstancesContext.js\";\n\nimport type { SelectionStorage } from \"@itwin/presentation-hierarchies-react\";\nimport type { PropsWithChildren } from \"react\";\nimport type { InstanceKey } from \"@itwin/presentation-common\";\nimport type { FocusedInstancesContext } from \"./FocusedInstancesContext.js\";\nimport type { GroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nexport function FocusedInstancesContextProvider({\n selectionStorage,\n imodelKey,\n children,\n}: PropsWithChildren<{ selectionStorage: SelectionStorage; imodelKey: string }>) {\n const [state, setState] = useState<FocusedInstancesContext>({\n enabled: false,\n toggle: () => {\n setState((prev) => ({ ...prev, enabled: !prev.enabled }));\n },\n });\n const enabled = state.enabled;\n\n useEffect(() => {\n if (!enabled) {\n setState((prev) => ({ ...prev, loadFocusedItems: undefined }));\n return;\n }\n\n const onSelectionChanged = () => {\n const selection = selectionStorage.getSelection({ imodelKey, level: 0 });\n if (Selectables.isEmpty(selection)) {\n setState((prev) => ({ ...prev, loadFocusedItems: undefined }));\n return;\n }\n\n const selected: Array<InstanceKey | GroupingHierarchyNode | (() => AsyncIterableIterator<InstanceKey>)> = [];\n Selectables.forEach(selection, (selectable) => {\n if (Selectable.isInstanceKey(selectable)) {\n selected.push(selectable);\n return;\n }\n\n if (isHierarchyNode(selectable.data) && HierarchyNode.isGroupingNode(selectable.data)) {\n selected.push(selectable.data);\n return;\n }\n\n selected.push(selectable.loadInstanceKeys);\n });\n\n const loadFocusedItems: () => AsyncIterableIterator<InstanceKey | GroupingHierarchyNode> = async function* () {\n for (const item of selected) {\n if (typeof item === \"function\") {\n yield* item();\n } else {\n yield item;\n }\n }\n };\n\n setState((prev) => ({ ...prev, loadFocusedItems }));\n };\n\n onSelectionChanged();\n return selectionStorage.selectionChangeEvent.addListener(({ imodelKey: changeImodelKey, level }) => {\n if (changeImodelKey !== imodelKey || level !== 0) {\n return;\n }\n onSelectionChanged();\n });\n }, [enabled, imodelKey, selectionStorage]);\n\n return <focusedInstancesContext.Provider value={state}>{children}</focusedInstancesContext.Provider>;\n}\n\nfunction isHierarchyNode(data: unknown): data is HierarchyNode {\n return !!data && typeof data === \"object\" && \"key\" in data;\n}\n"]}
|