@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/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
# Change Log - @itwin/tree-widget-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 19 Feb 2025 21:08:10 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 3.5.0
|
|
8
|
+
|
|
9
|
+
Wed, 19 Feb 2025 21:08:10 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- `CategoriesTree` component rendered `Categories` as a flat list, where each `Category` had zero or more child `SubCategories`. Some iTwin.js applications started to group `Categories` under `DefinitionContainers` and wanted to see them displayed in `CategoriesTree` component. Added `DefinitionContainers` to `CategoriesTree` component. This change doesn't affect applications that don't have `DefinitionContainers`. ([#1172](https://github.com/iTwin/viewer-components-react/pull/1172))
|
|
14
|
+
|
|
15
|
+
## 3.4.2
|
|
16
|
+
|
|
17
|
+
Fri, 14 Feb 2025 15:54:49 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Adjusted modeled element / sub-model visibility controls. Now, if visibility of modeled element is changed, visibility of sub-model is adjusted accordingly and vice versa. ([#1183](https://github.com/iTwin/viewer-components-react/pull/1183))
|
|
22
|
+
|
|
23
|
+
## 3.4.1
|
|
24
|
+
|
|
25
|
+
Thu, 06 Feb 2025 13:36:20 GMT
|
|
26
|
+
|
|
27
|
+
### Patches
|
|
28
|
+
|
|
29
|
+
- Removed horizontal scroll from trees. ([#1180](https://github.com/iTwin/viewer-components-react/pull/1180))
|
|
30
|
+
|
|
31
|
+
## 3.4.0
|
|
32
|
+
|
|
33
|
+
Tue, 04 Feb 2025 15:29:52 GMT
|
|
34
|
+
|
|
35
|
+
### Minor changes
|
|
36
|
+
|
|
37
|
+
- Expose `FocusedInstancesContextProvider` and `useFocusedInstancesContext` to allow using `ModelsTreeComponent.ToggleInstancesFocusButton` from outside of `ModelsTreeComponent` and accesing the context from other React components. ([#1175](https://github.com/iTwin/viewer-components-react/pull/1175))
|
|
38
|
+
- Add `filterButtonsVisibility` prop to `TreeRenderer`. The prop allows to control visibility of hierarchy level filtering buttons in the tree: `show-on-hover` (default) shows them on hover or focus, `hide` only shows them when a node is filtered. ([#1178](https://github.com/iTwin/viewer-components-react/pull/1178))
|
|
39
|
+
|
|
7
40
|
## 3.3.0
|
|
8
41
|
|
|
9
42
|
Mon, 27 Jan 2025 18:30:40 GMT
|
package/README.md
CHANGED
|
@@ -144,6 +144,7 @@ This package provides building blocks for custom models tree:
|
|
|
144
144
|
Example:
|
|
145
145
|
|
|
146
146
|
```tsx
|
|
147
|
+
import { useCallback } from "react";
|
|
147
148
|
import { TreeWithHeader, useModelsTree, useModelsTreeButtonProps, VisibilityTree, VisibilityTreeRenderer } from "@itwin/tree-widget-react";
|
|
148
149
|
import type { SelectionStorage } from "@itwin/unified-selection";
|
|
149
150
|
import type { IModelConnection, Viewport } from "@itwin/core-frontend";
|
|
@@ -291,11 +292,9 @@ function CustomCategoriesTreeRenderer(props: CustomCategoriesTreeRendererProps)
|
|
|
291
292
|
},
|
|
292
293
|
[getLabel],
|
|
293
294
|
);
|
|
294
|
-
|
|
295
295
|
const getSublabel = useCallback<Required<VisibilityTreeRendererProps>["getSublabel"]>(() => {
|
|
296
296
|
return <>Custom sub label</>;
|
|
297
297
|
}, []);
|
|
298
|
-
|
|
299
298
|
return <VisibilityTreeRenderer {...props} getLabel={getLabelCallback} getSublabel={getSublabel} />;
|
|
300
299
|
}
|
|
301
300
|
|
|
@@ -309,7 +308,6 @@ interface CustomCategoriesTreeProps {
|
|
|
309
308
|
function CustomCategoriesTreeComponent({ imodel, viewport, getSchemaContext, selectionStorage }: CustomCategoriesTreeProps) {
|
|
310
309
|
const { buttonProps } = useCategoriesTreeButtonProps({ viewport });
|
|
311
310
|
const { categoriesTreeProps, rendererProps } = useCategoriesTree({ activeView: viewport, filter: "" });
|
|
312
|
-
|
|
313
311
|
return (
|
|
314
312
|
<TreeWithHeader
|
|
315
313
|
buttons={[
|
|
@@ -7,7 +7,8 @@ import "./TreeWidgetUiItemsProvider.css";
|
|
|
7
7
|
import { useRef } from "react";
|
|
8
8
|
import { ErrorBoundary } from "react-error-boundary";
|
|
9
9
|
import { StagePanelLocation, StagePanelSection, useTransientState } from "@itwin/appui-react";
|
|
10
|
-
import
|
|
10
|
+
import hierarchyTreeSvg from "@itwin/itwinui-icons/hierarchy-tree.svg";
|
|
11
|
+
import { Icon } from "@itwin/itwinui-react/bricks";
|
|
11
12
|
import { TreeWidget } from "../TreeWidget.js";
|
|
12
13
|
import { ErrorState } from "./tree-header/ErrorState.js";
|
|
13
14
|
import { TreeWidgetComponentImpl } from "./TreeWidgetComponentImpl.js";
|
|
@@ -19,7 +20,7 @@ export function createTreeWidget(props) {
|
|
|
19
20
|
return {
|
|
20
21
|
id: "tree-widget-react:trees",
|
|
21
22
|
label: TreeWidget.translate("widget.label"),
|
|
22
|
-
icon: _jsx(
|
|
23
|
+
icon: _jsx(Icon, { href: hierarchyTreeSvg }),
|
|
23
24
|
layouts: {
|
|
24
25
|
standard: {
|
|
25
26
|
section: StagePanelSection.Start,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeWidgetUiItemsProvider.js","sourceRoot":"","sources":["../../../../src/tree-widget-react/components/TreeWidgetUiItemsProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"TreeWidgetUiItemsProvider.js","sourceRoot":"","sources":["../../../../src/tree-widget-react/components/TreeWidgetUiItemsProvider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,gBAAgB,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAwBvE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAsB;IACrD,OAAO;QACL,EAAE,EAAE,yBAAyB;QAC7B,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,cAAc,CAAC;QAC3C,IAAI,EAAE,KAAC,IAAI,IAAC,IAAI,EAAE,gBAAgB,GAAI;QACtC,OAAO,EAAE;YACP,QAAQ,EAAE;gBACR,OAAO,EAAE,iBAAiB,CAAC,KAAK;gBAChC,QAAQ,EAAE,kBAAkB,CAAC,KAAK;aACnC;SACF;QACD,OAAO,EAAE,KAAC,mBAAmB,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,GAAI;KAC7I,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAsB;IACxD,MAAM,GAAG,GAAG,2BAA2B,EAAE,CAAC;IAC1C,OAAO,CACL,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAC,aAAa,YACpC,KAAC,aAAa,IAAC,iBAAiB,EAAE,UAAU,YAC1C,KAAC,uBAAuB,OAAK,KAAK,GAAI,GACxB,GACZ,CACP,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B;IAClC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;IACnD,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC;AAQD,SAAS,cAAc;IACrB,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,MAAM,EAAsB,CAAC;IAE/C,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,OAAO,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,6BAA6B,CAAC,CAAC;IACnE,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,SAAS,CAAC,OAAO,GAAG,SAAS,EAAE,SAAS,CAAC;IAC3C,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;YACjC,IAAI,SAAS,IAAI,SAAS,CAAC,OAAO,EAAE;gBAClC,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACnC,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 \"./TreeWidgetUiItemsProvider.css\";\nimport { useRef } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\nimport { StagePanelLocation, StagePanelSection, useTransientState } from \"@itwin/appui-react\";\nimport hierarchyTreeSvg from \"@itwin/itwinui-icons/hierarchy-tree.svg\";\nimport { Icon } from \"@itwin/itwinui-react/bricks\";\nimport { TreeWidget } from \"../TreeWidget.js\";\nimport { ErrorState } from \"./tree-header/ErrorState.js\";\nimport { TreeWidgetComponentImpl } from \"./TreeWidgetComponentImpl.js\";\n\nimport type { Ref } from \"react\";\nimport type { Widget } from \"@itwin/appui-react\";\nimport type { TreeDefinition } from \"./TreeWidgetComponentImpl.js\";\n/**\n * Props for `createWidget`.\n * @public\n */\ninterface TreeWidgetProps {\n /**\n * Trees to show in the widget.\n * @see ModelsTreeComponent\n * @see CategoriesTreeComponent\n * @see ExternalSourcesTreeComponent\n * @see IModelContentTreeComponent\n */\n trees: TreeDefinition[];\n /** Callback that is invoked when performance of tracked feature is measured. */\n onPerformanceMeasured?: (feature: string, elapsedTime: number) => void;\n /** Callback that is invoked when a tracked feature is used. */\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * Creates a tree widget definition that should be returned from `UiItemsProvider.getWidgets()`.\n * @public\n */\nexport function createTreeWidget(props: TreeWidgetProps): Widget {\n return {\n id: \"tree-widget-react:trees\",\n label: TreeWidget.translate(\"widget.label\"),\n icon: <Icon href={hierarchyTreeSvg} />,\n layouts: {\n standard: {\n section: StagePanelSection.Start,\n location: StagePanelLocation.Right,\n },\n },\n content: <TreeWidgetComponent trees={props.trees} onPerformanceMeasured={props.onPerformanceMeasured} onFeatureUsed={props.onFeatureUsed} />,\n };\n}\n\n/**\n * Tree widget component which allows selecting which tree to render.\n * @public\n */\nexport function TreeWidgetComponent(props: TreeWidgetProps) {\n const ref = useTreeWidgetTransientState();\n return (\n <div ref={ref} className=\"tree-widget\">\n <ErrorBoundary FallbackComponent={ErrorState}>\n <TreeWidgetComponentImpl {...props} />\n </ErrorBoundary>\n </div>\n );\n}\n\nfunction useTreeWidgetTransientState() {\n const { ref, persist, restore } = useTreeStorage();\n useTransientState(persist, restore);\n return ref;\n}\n\ninterface UseTreeStorageResult {\n ref: Ref<HTMLDivElement>;\n persist: () => void;\n restore: () => void;\n}\n\nfunction useTreeStorage(): UseTreeStorageResult {\n const ref = useRef<HTMLDivElement>(null);\n const scrollTop = useRef<number | undefined>();\n\n const getContainer = () => {\n return ref.current?.querySelector(\"#tw-tree-renderer-container\");\n };\n\n const persist = () => {\n const container = getContainer();\n scrollTop.current = container?.scrollTop;\n };\n\n const restore = () => {\n setTimeout(() => {\n const container = getContainer();\n if (container && scrollTop.current) {\n container.scrollTop = scrollTop.current;\n }\n });\n };\n\n return { ref, persist, restore };\n}\n"]}
|
|
@@ -3,11 +3,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
import errorSvg from "@itwin/itwinui-icons/status-error.svg";
|
|
6
7
|
import { Button, Icon, Text } from "@itwin/itwinui-react/bricks";
|
|
7
8
|
import { TreeWidget } from "../../TreeWidget.js";
|
|
8
|
-
const errorIcon = new URL("@itwin/itwinui-icons/status-error.svg", import.meta.url).href;
|
|
9
9
|
/** @internal */
|
|
10
10
|
export function ErrorState({ resetErrorBoundary }) {
|
|
11
|
-
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: "100%", gap: "0.5rem" }, children: [_jsx(Icon, { href:
|
|
11
|
+
return (_jsxs("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: "100%", gap: "0.5rem" }, children: [_jsx(Icon, { href: errorSvg, size: "large" }), _jsx(Text, { children: TreeWidget.translate("errorState.description") }), _jsx(Button, { onClick: resetErrorBoundary, children: TreeWidget.translate("errorState.retryButtonLabel") })] }));
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=ErrorState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorState.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/tree-header/ErrorState.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,
|
|
1
|
+
{"version":3,"file":"ErrorState.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/tree-header/ErrorState.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,QAAQ,MAAM,uCAAuC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,gBAAgB;AAChB,MAAM,UAAU,UAAU,CAAC,EAAE,kBAAkB,EAAiB;IAC9D,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,aACrI,KAAC,IAAI,IAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,EACrC,KAAC,IAAI,cAAE,UAAU,CAAC,SAAS,CAAC,wBAAwB,CAAC,GAAQ,EAC7D,KAAC,MAAM,IAAC,OAAO,EAAE,kBAAkB,YAAG,UAAU,CAAC,SAAS,CAAC,6BAA6B,CAAC,GAAU,IAC/F,CACP,CAAC;AACJ,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 errorSvg from \"@itwin/itwinui-icons/status-error.svg\";\nimport { Button, Icon, Text } from \"@itwin/itwinui-react/bricks\";\nimport { TreeWidget } from \"../../TreeWidget.js\";\n\nimport type { FallbackProps } from \"react-error-boundary\";\n\n/** @internal */\nexport function ErrorState({ resetErrorBoundary }: FallbackProps) {\n return (\n <div style={{ display: \"flex\", flexDirection: \"column\", alignItems: \"center\", justifyContent: \"center\", height: \"100%\", gap: \"0.5rem\" }}>\n <Icon href={errorSvg} size=\"large\" />\n <Text>{TreeWidget.translate(\"errorState.description\")}</Text>\n <Button onClick={resetErrorBoundary}>{TreeWidget.translate(\"errorState.retryButtonLabel\")}</Button>\n </div>\n );\n}\n"]}
|
|
@@ -5,10 +5,10 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import "./SearchBox.css";
|
|
7
7
|
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import dismissSvg from "@itwin/itwinui-icons/dismiss.svg";
|
|
9
|
+
import searchSvg from "@itwin/itwinui-icons/search.svg";
|
|
8
10
|
import { IconButton, TextBox } from "@itwin/itwinui-react/bricks";
|
|
9
11
|
import { TreeWidget } from "../../TreeWidget.js";
|
|
10
|
-
const searchIcon = new URL("@itwin/itwinui-icons/search.svg", import.meta.url).href;
|
|
11
|
-
const dismissIcon = new URL("@itwin/itwinui-icons/dismiss.svg", import.meta.url).href;
|
|
12
12
|
export function DebouncedSearchBox({ isOpened, onSearch, setIsOpened, delay, className }) {
|
|
13
13
|
const [inputValue, setInputValue] = useState(undefined);
|
|
14
14
|
const onChangeRef = useRef(onSearch);
|
|
@@ -22,10 +22,10 @@ export function DebouncedSearchBox({ isOpened, onSearch, setIsOpened, delay, cla
|
|
|
22
22
|
clearTimeout(timeoutId);
|
|
23
23
|
};
|
|
24
24
|
}, [inputValue, delay]);
|
|
25
|
-
return !isOpened ? (_jsx(IconButton, { className: "tw-search-box-button", variant: "ghost", label: TreeWidget.translate("header.searchBox.searchForSomething"), icon:
|
|
25
|
+
return !isOpened ? (_jsx(IconButton, { className: "tw-search-box-button", variant: "ghost", label: TreeWidget.translate("header.searchBox.searchForSomething"), icon: searchSvg, onClick: () => {
|
|
26
26
|
setIsOpened(true);
|
|
27
27
|
setInputValue("");
|
|
28
|
-
} })) : (_jsxs(_Fragment, { children: [_jsx(TextBox.Root, { className: className, children: _jsx(TextBox.Input, { type: "text", onChange: (e) => setInputValue(e.currentTarget.value), placeholder: TreeWidget.translate("header.searchBox.search") }) }), _jsx(IconButton, { className: "tw-search-box-button", variant: "ghost", label: TreeWidget.translate("header.searchBox.close"), icon:
|
|
28
|
+
} })) : (_jsxs(_Fragment, { children: [_jsx(TextBox.Root, { className: className, children: _jsx(TextBox.Input, { type: "text", onChange: (e) => setInputValue(e.currentTarget.value), placeholder: TreeWidget.translate("header.searchBox.search") }) }), _jsx(IconButton, { className: "tw-search-box-button", variant: "ghost", label: TreeWidget.translate("header.searchBox.close"), icon: dismissSvg, onClick: () => {
|
|
29
29
|
setIsOpened(false);
|
|
30
30
|
setInputValue(undefined);
|
|
31
31
|
} })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchBox.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/tree-header/SearchBox.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"SearchBox.js","sourceRoot":"","sources":["../../../../../src/tree-widget-react/components/tree-header/SearchBox.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,SAAS,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAUjD,MAAM,UAAU,kBAAkB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAA2B;IAC/G,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC,CAAC;IAC5E,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,gHAAgH;IAChH,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC,EAAE,KAAK,CAAC,CAAC;QAEV,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CACjB,KAAC,UAAU,IACT,SAAS,EAAE,sBAAsB,EACjC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,qCAAqC,CAAC,EAClE,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,GAAG,EAAE;YACZ,WAAW,CAAC,IAAI,CAAC,CAAC;YAClB,aAAa,CAAC,EAAE,CAAC,CAAC;QACpB,CAAC,GACD,CACH,CAAC,CAAC,CAAC,CACF,8BACE,KAAC,OAAO,CAAC,IAAI,IAAC,SAAS,EAAE,SAAS,YAChC,KAAC,OAAO,CAAC,KAAK,IAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,yBAAyB,CAAC,GAAI,GACvI,EACf,KAAC,UAAU,IACT,SAAS,EAAE,sBAAsB,EACjC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,wBAAwB,CAAC,EACrD,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,GAAG,EAAE;oBACZ,WAAW,CAAC,KAAK,CAAC,CAAC;oBACnB,aAAa,CAAC,SAAS,CAAC,CAAC;gBAC3B,CAAC,GACD,IACD,CACJ,CAAC;AACJ,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 \"./SearchBox.css\";\nimport { useEffect, useRef, useState } from \"react\";\nimport dismissSvg from \"@itwin/itwinui-icons/dismiss.svg\";\nimport searchSvg from \"@itwin/itwinui-icons/search.svg\";\nimport { IconButton, TextBox } from \"@itwin/itwinui-react/bricks\";\nimport { TreeWidget } from \"../../TreeWidget.js\";\n\ninterface DebouncedSearchBoxProps {\n isOpened: boolean;\n setIsOpened: (value: boolean) => void;\n onSearch: (value?: string) => void;\n delay: number;\n className?: string;\n}\n\nexport function DebouncedSearchBox({ isOpened, onSearch, setIsOpened, delay, className }: DebouncedSearchBoxProps) {\n const [inputValue, setInputValue] = useState<string | undefined>(undefined);\n const onChangeRef = useRef(onSearch);\n // save latest `onChange` reference into `useRef` to avoid restarting timeout when `onChange` reference changes.\n onChangeRef.current = onSearch;\n\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n onChangeRef.current(inputValue);\n }, delay);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }, [inputValue, delay]);\n\n return !isOpened ? (\n <IconButton\n className={\"tw-search-box-button\"}\n variant={\"ghost\"}\n label={TreeWidget.translate(\"header.searchBox.searchForSomething\")}\n icon={searchSvg}\n onClick={() => {\n setIsOpened(true);\n setInputValue(\"\");\n }}\n />\n ) : (\n <>\n <TextBox.Root className={className}>\n <TextBox.Input type={\"text\"} onChange={(e) => setInputValue(e.currentTarget.value)} placeholder={TreeWidget.translate(\"header.searchBox.search\")} />\n </TextBox.Root>\n <IconButton\n className={\"tw-search-box-button\"}\n variant={\"ghost\"}\n label={TreeWidget.translate(\"header.searchBox.close\")}\n icon={dismissSvg}\n onClick={() => {\n setIsOpened(false);\n setInputValue(undefined);\n }}\n />\n </>\n );\n}\n"]}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
12
|
.tw-tree-toolbar {
|
|
13
|
-
padding: 0 var(--iui-size-s) var(--iui-size-xs)
|
|
13
|
+
padding: 0 var(--iui-size-s) var(--iui-size-xs) var(--iui-size-s);
|
|
14
14
|
display: flex;
|
|
15
15
|
align-items: center;
|
|
16
16
|
gap: var(--iui-size-2xs);
|
|
@@ -5,12 +5,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
import { useMemo, useState } from "react";
|
|
7
7
|
import { useAsyncValue } from "@itwin/components-react";
|
|
8
|
+
import visibilityHideSvg from "@itwin/itwinui-icons/visibility-hide.svg";
|
|
9
|
+
import visibilityShowSvg from "@itwin/itwinui-icons/visibility-show.svg";
|
|
10
|
+
import visibilityInvertSvg from "@itwin/itwinui-icons/visibilty-invert.svg";
|
|
8
11
|
import { IconButton } from "@itwin/itwinui-react/bricks";
|
|
9
12
|
import { TreeWidget } from "../../../TreeWidget.js";
|
|
10
13
|
import { hideAllCategories, invertAllCategories, loadCategoriesFromViewport, showAllCategories } from "../common/CategoriesVisibilityUtils.js";
|
|
11
|
-
const visibilityShowIcon = new URL("@itwin/itwinui-icons/visibility-show.svg", import.meta.url).href;
|
|
12
|
-
const visibilityHideIcon = new URL("@itwin/itwinui-icons/visibility-hide.svg", import.meta.url).href;
|
|
13
|
-
const visibilityInvertIcon = new URL("@itwin/itwinui-icons/visibilty-invert.svg", import.meta.url).href;
|
|
14
14
|
/**
|
|
15
15
|
* Custom hook that creates props required to render `CategoriesTreeComponent` header button.
|
|
16
16
|
*
|
|
@@ -45,21 +45,21 @@ export function ShowAllButton(props) {
|
|
|
45
45
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("categoriesTree.buttons.showAll.tooltip"), onClick: () => {
|
|
46
46
|
props.onFeatureUsed?.(`categories-tree-showall`);
|
|
47
47
|
void showAllCategories(props.categories.map((category) => category.categoryId), props.viewport);
|
|
48
|
-
}, icon:
|
|
48
|
+
}, icon: visibilityShowSvg }));
|
|
49
49
|
}
|
|
50
50
|
/** @public */
|
|
51
51
|
export function HideAllButton(props) {
|
|
52
52
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("categoriesTree.buttons.hideAll.tooltip"), onClick: () => {
|
|
53
53
|
props.onFeatureUsed?.(`categories-tree-hideall`);
|
|
54
54
|
void hideAllCategories(props.categories.map((category) => category.categoryId), props.viewport);
|
|
55
|
-
}, icon:
|
|
55
|
+
}, icon: visibilityHideSvg }));
|
|
56
56
|
}
|
|
57
57
|
/** @public */
|
|
58
58
|
export function InvertAllButton(props) {
|
|
59
59
|
return (_jsx(IconButton, { variant: "ghost", label: TreeWidget.translate("categoriesTree.buttons.invert.tooltip"), onClick: () => {
|
|
60
60
|
props.onFeatureUsed?.(`categories-tree-invert`);
|
|
61
61
|
void invertAllCategories(props.categories, props.viewport);
|
|
62
|
-
}, icon:
|
|
62
|
+
}, icon: visibilityInvertSvg }));
|
|
63
63
|
}
|
|
64
64
|
const EMPTY_CATEGORIES_ARRAY = [];
|
|
65
65
|
export function useCategories(viewport) {
|
package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CategoriesTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"CategoriesTreeButtons.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/categories-tree/CategoriesTreeButtons.tsx"],"names":[],"mappings":"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","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 { useMemo, useState } from \"react\";\nimport { useAsyncValue } from \"@itwin/components-react\";\nimport visibilityHideSvg from \"@itwin/itwinui-icons/visibility-hide.svg\";\nimport visibilityShowSvg from \"@itwin/itwinui-icons/visibility-show.svg\";\nimport visibilityInvertSvg from \"@itwin/itwinui-icons/visibilty-invert.svg\";\nimport { IconButton } from \"@itwin/itwinui-react/bricks\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { hideAllCategories, invertAllCategories, loadCategoriesFromViewport, showAllCategories } from \"../common/CategoriesVisibilityUtils.js\";\n\nimport type { CategoryInfo } from \"../common/CategoriesVisibilityUtils.js\";\nimport type { TreeToolbarButtonProps } from \"../../tree-header/SelectableTree.js\";\nimport type { Viewport } from \"@itwin/core-frontend\";\n\n/**\n * Props that get passed to `CategoriesTreeComponent` header button renderer.\n * @see CategoriesTreeComponentProps.headerButtons\n * @public\n */\nexport interface CategoriesTreeHeaderButtonProps extends TreeToolbarButtonProps {\n /** A list of categories available in the iModel */\n categories: CategoryInfo[];\n}\n\n/**\n * Custom hook that creates props required to render `CategoriesTreeComponent` header button.\n *\n * Example:\n * ```tsx\n * const { buttonProps, onCategoriesFiltered } = useCategoriesTreeButtonProps({ viewport });\n * <TreeWithHeader\n * buttons={[\n * <CategoriesTreeComponent.ShowAllButton {...buttonProps} />,\n * <CategoriesTreeComponent.HideAllButton {...buttonProps} />,\n * ]}\n * >\n * <CategoriesTree {...treeProps} onCategoriesFiltered={onCategoriesFiltered} />\n * </TreeWithHeader>\n * ```\n *\n * @public\n */\nexport function useCategoriesTreeButtonProps({ viewport }: { viewport: Viewport }): {\n buttonProps: Pick<CategoriesTreeHeaderButtonProps, \"categories\" | \"viewport\">;\n onCategoriesFiltered: (categories: CategoryInfo[] | undefined) => void;\n} {\n const [filteredCategories, setFilteredCategories] = useState<CategoryInfo[] | undefined>();\n const categories = useCategories(viewport);\n return {\n buttonProps: {\n viewport,\n categories: filteredCategories ?? categories,\n },\n onCategoriesFiltered: setFilteredCategories,\n };\n}\n\n/** @public */\nexport type CategoriesTreeHeaderButtonType = (props: CategoriesTreeHeaderButtonProps) => React.ReactElement | null;\n\n/** @public */\nexport function ShowAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"categoriesTree.buttons.showAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-showall`);\n void showAllCategories(\n props.categories.map((category) => category.categoryId),\n props.viewport,\n );\n }}\n icon={visibilityShowSvg}\n />\n );\n}\n\n/** @public */\nexport function HideAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"categoriesTree.buttons.hideAll.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-hideall`);\n void hideAllCategories(\n props.categories.map((category) => category.categoryId),\n props.viewport,\n );\n }}\n icon={visibilityHideSvg}\n />\n );\n}\n\n/** @public */\nexport function InvertAllButton(props: CategoriesTreeHeaderButtonProps) {\n return (\n <IconButton\n variant={\"ghost\"}\n label={TreeWidget.translate(\"categoriesTree.buttons.invert.tooltip\")}\n onClick={() => {\n props.onFeatureUsed?.(`categories-tree-invert`);\n void invertAllCategories(props.categories, props.viewport);\n }}\n icon={visibilityInvertSvg}\n />\n );\n}\n\nconst EMPTY_CATEGORIES_ARRAY: CategoryInfo[] = [];\n\nexport function useCategories(viewport: Viewport) {\n const categoriesPromise = useMemo(async () => loadCategoriesFromViewport(viewport), [viewport]);\n return useAsyncValue(categoriesPromise) ?? EMPTY_CATEGORIES_ARRAY;\n}\n"]}
|
package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import type { ECClassHierarchyInspector, ECSchemaProvider } from "@itwin/presentation-shared";
|
|
2
|
+
import type { CategoriesTreeIdsCache } from "./internal/CategoriesTreeIdsCache.js";
|
|
2
3
|
import type { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyFilteringPath, HierarchyLevelDefinition, LimitingECSqlQueryExecutor } from "@itwin/presentation-hierarchies";
|
|
3
4
|
interface CategoriesTreeDefinitionProps {
|
|
4
|
-
imodelAccess: ECSchemaProvider & ECClassHierarchyInspector;
|
|
5
|
+
imodelAccess: ECSchemaProvider & ECClassHierarchyInspector & LimitingECSqlQueryExecutor;
|
|
5
6
|
viewType: "2d" | "3d";
|
|
7
|
+
idsCache: CategoriesTreeIdsCache;
|
|
6
8
|
}
|
|
7
9
|
interface CategoriesTreeInstanceKeyPathsFromInstanceLabelProps {
|
|
8
10
|
imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;
|
|
9
11
|
label: string;
|
|
10
12
|
viewType: "2d" | "3d";
|
|
13
|
+
limit?: number | "unbounded";
|
|
14
|
+
idsCache: CategoriesTreeIdsCache;
|
|
11
15
|
}
|
|
12
16
|
export declare class CategoriesTreeDefinition implements HierarchyDefinition {
|
|
13
17
|
private _impl;
|
|
14
18
|
private _selectQueryFactory;
|
|
15
19
|
private _nodeLabelSelectClauseFactory;
|
|
20
|
+
private _idsCache;
|
|
21
|
+
private _viewType;
|
|
22
|
+
private _iModelAccess;
|
|
16
23
|
constructor(props: CategoriesTreeDefinitionProps);
|
|
24
|
+
private getHierarchyDefinition;
|
|
17
25
|
defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition>;
|
|
18
|
-
private
|
|
26
|
+
private createDefinitionContainersAndCategoriesQuery;
|
|
19
27
|
private createSubcategoryQuery;
|
|
20
28
|
static createInstanceKeyPaths(props: CategoriesTreeInstanceKeyPathsFromInstanceLabelProps): Promise<HierarchyFilteringPath[]>;
|
|
21
29
|
}
|