@itwin/tree-widget-react 3.10.3 → 3.12.0

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 (49) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +1 -0
  3. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +18 -12
  4. package/lib/cjs/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  5. package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +2 -2
  6. package/lib/cjs/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  7. package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +10 -1
  8. package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +28 -21
  9. package/lib/cjs/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  10. package/lib/cjs/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -1
  11. package/lib/cjs/tree-widget-react/components/trees/common/Utils.d.ts +4 -0
  12. package/lib/cjs/tree-widget-react/components/trees/common/Utils.js +50 -0
  13. package/lib/cjs/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  14. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
  15. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -1
  16. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  17. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  18. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  19. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +8 -9
  20. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +32 -27
  21. package/lib/cjs/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  22. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +20 -2
  23. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js +95 -37
  24. package/lib/cjs/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  25. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.d.ts +1 -0
  26. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js +19 -13
  27. package/lib/esm/tree-widget-react/components/trees/categories-tree/CategoriesTreeDefinition.js.map +1 -1
  28. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js +2 -2
  29. package/lib/esm/tree-widget-react/components/trees/categories-tree/UseCategoriesTree.js.map +1 -1
  30. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.d.ts +10 -1
  31. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js +28 -21
  32. package/lib/esm/tree-widget-react/components/trees/common/CategoriesVisibilityUtils.js.map +1 -1
  33. package/lib/esm/tree-widget-react/components/trees/common/UseIModelAccess.js.map +1 -1
  34. package/lib/esm/tree-widget-react/components/trees/common/Utils.d.ts +4 -0
  35. package/lib/esm/tree-widget-react/components/trees/common/Utils.js +49 -0
  36. package/lib/esm/tree-widget-react/components/trees/common/Utils.js.map +1 -1
  37. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.d.ts +1 -1
  38. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js +2 -1
  39. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTree.js.map +1 -1
  40. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.d.ts +1 -1
  41. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.js.map +1 -1
  42. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.d.ts +8 -9
  43. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js +33 -28
  44. package/lib/esm/tree-widget-react/components/trees/models-tree/ModelsTreeDefinition.js.map +1 -1
  45. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.d.ts +20 -2
  46. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js +96 -38
  47. package/lib/esm/tree-widget-react/components/trees/models-tree/UseModelsTree.js.map +1 -1
  48. package/lib/public/locales/en/TreeWidget.json +3 -0
  49. package/package.json +3 -3
@@ -8,7 +8,9 @@ exports.createIdsSelector = createIdsSelector;
8
8
  exports.parseIdsSelectorResult = parseIdsSelectorResult;
9
9
  exports.pushToMap = pushToMap;
10
10
  exports.useLatest = useLatest;
11
+ exports.joinHierarchyFilteringPaths = joinHierarchyFilteringPaths;
11
12
  const react_1 = require("react");
13
+ const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
12
14
  /** @internal */
13
15
  function createIdsSelector(ids) {
14
16
  // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,
@@ -47,4 +49,52 @@ function useLatest(value) {
47
49
  }, [value]);
48
50
  return ref;
49
51
  }
52
+ /** @internal */
53
+ function joinHierarchyFilteringPaths(subTreePaths, filteringPaths) {
54
+ const normalizedFilteringPaths = filteringPaths.map((filteringPath) => presentation_hierarchies_1.HierarchyFilteringPath.normalize(filteringPath));
55
+ const result = new Array();
56
+ const filteringPathsToIncludeIndexes = new Set();
57
+ subTreePaths.forEach((subTreePath) => {
58
+ let options;
59
+ let addSubTreePathToResult = false;
60
+ for (let i = 0; i < normalizedFilteringPaths.length; ++i) {
61
+ const normalizedFilteringPath = normalizedFilteringPaths[i];
62
+ if (normalizedFilteringPath.path.length === 0) {
63
+ continue;
64
+ }
65
+ for (let j = 0; j < subTreePath.length; ++j) {
66
+ const identifier = subTreePath[j];
67
+ if (normalizedFilteringPath.path.length <= j || !presentation_hierarchies_1.HierarchyNodeIdentifier.equal(normalizedFilteringPath.path[j], identifier)) {
68
+ break;
69
+ }
70
+ // filtering paths that are shorter or equal than subTree paths length don't need to be added to the result
71
+ if (normalizedFilteringPath.path.length === j + 1) {
72
+ addSubTreePathToResult = true;
73
+ // If filtering path has autoExpand set to true, it means that we should expand only to the targeted filtered node
74
+ // This is done by setting depthInPath
75
+ options =
76
+ normalizedFilteringPath.options?.autoExpand !== true
77
+ ? presentation_hierarchies_1.HierarchyFilteringPath.mergeOptions(options, normalizedFilteringPath.options)
78
+ : { autoExpand: { depthInPath: normalizedFilteringPath.path.length - 1 } };
79
+ break;
80
+ }
81
+ // filtering paths that are longer than subTree paths need to be added to the result
82
+ if (subTreePath.length === j + 1) {
83
+ addSubTreePathToResult = true;
84
+ filteringPathsToIncludeIndexes.add(i);
85
+ }
86
+ }
87
+ }
88
+ if (addSubTreePathToResult) {
89
+ result.push({
90
+ path: subTreePath,
91
+ options,
92
+ });
93
+ }
94
+ });
95
+ for (const index of filteringPathsToIncludeIndexes) {
96
+ result.push(normalizedFilteringPaths[index]);
97
+ }
98
+ return result;
99
+ }
50
100
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAUhG,8CAYC;AAGD,wDAKC;AAGD,8BAOC;AAGD,8BAMC;AA/CD,iCAA0C;AAO1C,gBAAgB;AAChB,SAAgB,iBAAiB,CAAC,GAAc;IAC9C,sHAAsH;IACtH,oCAAoC;IACpC,MAAM,MAAM,GAAG,IAAI,KAAK,EAAgB,CAAC;IACzC,KAAK,IAAI,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,IAAI,GAAG,EAAE,CAAC;QACnF,IAAI,aAAa,GAAuB,eAAe,GAAG,GAAG,CAAC;QAC9D,IAAI,aAAa,GAAG,GAAG,CAAC,M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ACnC,MAAM,GAAG,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAC1B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC;AACb,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, useRef } from \"react\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n"]}
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/common/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAYhG,8CAYC;AAGD,wDAKC;AAGD,8BAOC;AAGD,8BAMC;AAGD,kEAqDC;AAzGD,iCAA0C;AAC1C,8EAAkG;AAQlG,gBAAgB;AAChB,SAAgB,iBAAiB,CAAC,GAAc;IAC9C,sHAAsH;IACtH,oCAAoC;IACpC,MAAM,MAAM,GAAG,IAAI,KAAK,EAAgB,CAAC;IACzC,KAAK,IAAI,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,IAAI,GAAG,EAAE,CAAC;QACnF,IAAI,aAAa,GAAuB,eAAe,GAAG,GAAG,CAAC;QAC9D,IAAI,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;YAC/B,aAAa,GAAG,SAAS,CAAC;QAC5B,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,cAAc,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,cAAc,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACzH,CAAC;AAED,gBAAgB;AAChB,SAAgB,sBAAsB,CAAC,cAAmB;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAA8B,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG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H,CAAC;QAED,IAAI,sBAAsB,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,WAAW;gBACjB,OAAO;aACR,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,KAAK,IAAI,8BAA8B,EAAE,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,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, useRef } from \"react\";\nimport { HierarchyFilteringPath, HierarchyNodeIdentifier } from \"@itwin/presentation-hierarchies\";\n\nimport type { Id64Array, Id64String } from \"@itwin/core-bentley\";\nimport type { HierarchyFilteringPathOptions, HierarchyNodeIdentifiersPath } from \"@itwin/presentation-hierarchies\";\n\n/** @beta */\nexport type FunctionProps<THook extends (props: any) => any> = Parameters<THook>[0];\n\n/** @internal */\nexport function createIdsSelector(ids: Id64Array): string {\n // Note: `json_array` function only accepts up to 127 arguments and we may have more `ids` than that. As a workaround,\n // we're creating an array of arrays\n const slices = new Array<Id64String[]>();\n for (let sliceStartIndex = 0; sliceStartIndex < ids.length; sliceStartIndex += 127) {\n let sliceEndIndex: number | undefined = sliceStartIndex + 127;\n if (sliceEndIndex > ids.length) {\n sliceEndIndex = undefined;\n }\n slices.push(ids.slice(sliceStartIndex, sliceEndIndex));\n }\n return `json_array(${slices.map((sliceIds) => `json_array(${sliceIds.map((id) => `'${id}'`).join(\",\")})`).join(\",\")})`;\n}\n\n/** @internal */\nexport function parseIdsSelectorResult(selectorResult: any): Id64Array {\n if (!Array.isArray(selectorResult)) {\n return [];\n }\n return selectorResult.reduce((arr, ids: Id64String | Id64String[]) => [...arr, ...(Array.isArray(ids) ? ids : [ids])], new Array<Id64String>());\n}\n\n/** @internal */\nexport function pushToMap<TKey, TValue>(targetMap: Map<TKey, Set<TValue>>, key: TKey, value: TValue) {\n let set = targetMap.get(key);\n if (!set) {\n set = new Set();\n targetMap.set(key, set);\n }\n set.add(value);\n}\n\n/** @internal */\nexport function useLatest<T>(value: T) {\n const ref = useRef(value);\n useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\n/** @internal */\nexport function joinHierarchyFilteringPaths(subTreePaths: HierarchyNodeIdentifiersPath[], filteringPaths: HierarchyFilteringPath[]): HierarchyFilteringPath[] {\n const normalizedFilteringPaths = filteringPaths.map((filteringPath) => HierarchyFilteringPath.normalize(filteringPath));\n\n const result = new Array<HierarchyFilteringPath>();\n const filteringPathsToIncludeIndexes = new Set<number>();\n\n subTreePaths.forEach((subTreePath) => {\n let options: HierarchyFilteringPathOptions | undefined;\n let addSubTreePathToResult = false;\n\n for (let i = 0; i < normalizedFilteringPaths.length; ++i) {\n const normalizedFilteringPath = normalizedFilteringPaths[i];\n if (normalizedFilteringPath.path.length === 0) {\n continue;\n }\n\n for (let j = 0; j < subTreePath.length; ++j) {\n const identifier = subTreePath[j];\n if (normalizedFilteringPath.path.length <= j || !HierarchyNodeIdentifier.equal(normalizedFilteringPath.path[j], identifier)) {\n break;\n }\n\n // filtering paths that are shorter or equal than subTree paths length don't need to be added to the result\n if (normalizedFilteringPath.path.length === j + 1) {\n addSubTreePathToResult = true;\n // If filtering path has autoExpand set to true, it means that we should expand only to the targeted filtered node\n // This is done by setting depthInPath\n options =\n normalizedFilteringPath.options?.autoExpand !== true\n ? HierarchyFilteringPath.mergeOptions(options, normalizedFilteringPath.options)\n : { autoExpand: { depthInPath: normalizedFilteringPath.path.length - 1 } };\n break;\n }\n\n // filtering paths that are longer than subTree paths need to be added to the result\n if (subTreePath.length === j + 1) {\n addSubTreePathToResult = true;\n filteringPathsToIncludeIndexes.add(i);\n }\n }\n }\n\n if (addSubTreePathToResult) {\n result.push({\n path: subTreePath,\n options,\n });\n }\n });\n for (const index of filteringPathsToIncludeIndexes) {\n result.push(normalizedFilteringPaths[index]);\n }\n return result;\n}\n"]}
@@ -7,5 +7,5 @@ export type ModelsTreeProps = Pick<VisibilityTreeProps, "imodel" | "getSchemaCon
7
7
  };
8
8
  };
9
9
  /** @beta */
10
- export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, }: ModelsTreeProps): JSX.Element;
10
+ export declare function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, getSubTreePaths, }: ModelsTreeProps): JSX.Element;
11
11
  //# sourceMappingURL=ModelsTree.d.ts.map
@@ -10,7 +10,7 @@ const VisibilityTree_js_1 = require("../common/components/VisibilityTree.js");
10
10
  const VisibilityTreeRenderer_js_1 = require("../common/components/VisibilityTreeRenderer.js");
11
11
  const UseModelsTree_js_1 = require("./UseModelsTree.js");
12
12
  /** @beta */
13
- function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, }) {
13
+ function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, filter, density, hierarchyLevelConfig, hierarchyConfig, selectionMode, selectionPredicate, visibilityHandlerOverrides, getFilteredPaths, onModelsFiltered, getSubTreePaths, }) {
14
14
  const { modelsTreeProps, rendererProps } = (0, UseModelsTree_js_1.useModelsTree)({
15
15
  activeView,
16
16
  filter,
@@ -19,6 +19,7 @@ function ModelsTree({ imodel, getSchemaContext, selectionStorage, activeView, fi
19
19
  getFilteredPaths,
20
20
  onModelsFiltered,
21
21
  selectionPredicate,
22
+ getSubTreePaths,
22
23
  });
23
24
  return ((0, jsx_runtime_1.jsx)(VisibilityTree_js_1.VisibilityTree, { ...modelsTreeProps, imodel: imodel, selectionStorage: selectionStorage, getSchemaContext: getSchemaContext, hierarchyLevelSizeLimit: hierarchyLevelConfig?.sizeLimit, density: density, selectionMode: selectionMode, treeRenderer: (treeProps) => (0, jsx_runtime_1.jsx)(VisibilityTreeRenderer_js_1.VisibilityTreeRenderer, { ...treeProps, ...rendererProps }) }));
24
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;AAqBA,gCAqCC;;AA1DD;;;gGAGgG;AAEhG,8EAAwE;AACxE,8FAAwF;AACxF,yDAAmD;AAanD,YAAY;AACZ,SAAgB,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,GACA;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAA,gCAAa,EAAC;QACvD,UAAU;QACV,MAAM;QACN,eAAe;QACf,0BAA0B;QAC1B,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;KACnB,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,kCAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,uBAAC,kDAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,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 { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type { UseModelsTreeProps } from \"./UseModelsTree.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\n\n/** @beta */\nexport type ModelsTreeProps = Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> &\n UseModelsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n selectionPredicate,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate,\n });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"ModelsTree.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTree.tsx"],"names":[],"mappings":";;AAqBA,gCAuCC;;AA5DD;;;gGAGgG;AAEhG,8EAAwE;AACxE,8FAAwF;AACxF,yDAAmD;AAanD,YAAY;AACZ,SAAgB,UAAU,CAAC,EACzB,MAAM,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GACC;IAChB,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,GAAG,IAAA,gCAAa,EAAC;QACvD,UAAU;QACV,MAAM;QACN,eAAe;QACf,0BAA0B;QAC1B,gBAAgB;QAChB,gBAAgB;QAChB,kBAAkB;QAClB,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO,CACL,uBAAC,kCAAc,OACT,eAAe,EACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,oBAAoB,EAAE,SAAS,EACxD,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,uBAAC,kDAAsB,OAAK,SAAS,KAAM,aAAa,GAAI,GACzF,CACH,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 { VisibilityTree } from \"../common/components/VisibilityTree.js\";\nimport { VisibilityTreeRenderer } from \"../common/components/VisibilityTreeRenderer.js\";\nimport { useModelsTree } from \"./UseModelsTree.js\";\n\nimport type { UseModelsTreeProps } from \"./UseModelsTree.js\";\nimport type { VisibilityTreeProps } from \"../common/components/VisibilityTree.js\";\n\n/** @beta */\nexport type ModelsTreeProps = Pick<VisibilityTreeProps, \"imodel\" | \"getSchemaContext\" | \"selectionStorage\" | \"density\" | \"selectionMode\"> &\n UseModelsTreeProps & {\n hierarchyLevelConfig?: {\n sizeLimit?: number;\n };\n };\n\n/** @beta */\nexport function ModelsTree({\n imodel,\n getSchemaContext,\n selectionStorage,\n activeView,\n filter,\n density,\n hierarchyLevelConfig,\n hierarchyConfig,\n selectionMode,\n selectionPredicate,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n getSubTreePaths,\n}: ModelsTreeProps) {\n const { modelsTreeProps, rendererProps } = useModelsTree({\n activeView,\n filter,\n hierarchyConfig,\n visibilityHandlerOverrides,\n getFilteredPaths,\n onModelsFiltered,\n selectionPredicate,\n getSubTreePaths,\n });\n\n return (\n <VisibilityTree\n {...modelsTreeProps}\n imodel={imodel}\n selectionStorage={selectionStorage}\n getSchemaContext={getSchemaContext}\n hierarchyLevelSizeLimit={hierarchyLevelConfig?.sizeLimit}\n density={density}\n selectionMode={selectionMode}\n treeRenderer={(treeProps) => <VisibilityTreeRenderer {...treeProps} {...rendererProps} />}\n />\n );\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { ModelsTreeProps } from "./ModelsTree.js";
2
2
  import type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from "./ModelsTreeButtons.js";
3
3
  /** @public */
4
- interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getFilteredPaths"> {
4
+ interface ModelsTreeComponentProps extends Pick<ModelsTreeProps, "getSchemaContext" | "selectionStorage" | "density" | "hierarchyLevelConfig" | "selectionMode" | "selectionPredicate" | "hierarchyConfig" | "visibilityHandlerOverrides" | "getFilteredPaths" | "getSubTreePaths"> {
5
5
  /**
6
6
  * Renderers of header buttons. Defaults to:
7
7
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;;;;AAAA;;;gGAGgG;AAEhG,iCAA4C;AAC5C,oDAA+D;AAC/D,0DAAoD;AAC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,EAAE,aAAa,EAAE,aAAa,IAA3E,4BAA4B,CAAmD;SAChH,CAAC;IAEN,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,oBAAoB,EAAE,CAAC;YACzB,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAExC,OAAO,CACL,uBAAC,iDAAwB,IAAC,mBAAmB,EAAE,2BAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,uBAAC,kCAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB;aACjE,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,uBAAC,0BAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACxG,GACQ,CAC5B,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 { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveViewport } from \"../common/UseActiveViewport.js\";\nimport { useFiltering } from \"../common/UseFiltering.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"density\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} onModelsFiltered={onModelsFiltered} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"ModelsTreeComponent.js","sourceRoot":"","sources":["../../../../../../src/tree-widget-react/components/trees/models-tree/ModelsTreeComponent.tsx"],"names":[],"mappings":";;;;;AAAA;;;gGAGgG;AAEhG,iCAA4C;AAC5C,oDAA+D;AAC/D,0DAAoD;AACpD,2EAAqE;AACrE,qFAAmH;AACnH,yEAAmE;AACnE,+DAAyD;AACzD,6EAA4E;AAC5E,mDAA6C;AAC7C,iEAQgC;AAwChC;;;;;GAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IACrE,MAAM,MAAM,GAAG,IAAA,uCAAyB,GAAE,CAAC;IAC3C,MAAM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OAAO,CACL,uBAAC,iDAAwB,IAAC,mBAAmB,EAAE,2BAAmB,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,qBAAqB,EAAE,qBAAqB,YAC/I,uBAAC,kCAAc,IACb,cAAc,EAAE;gBACd,aAAa,EAAE,WAAW;gBAC1B,aAAa,EAAE,WAAW;gBAC1B,UAAU,EAAE,oBAAoB,IAAI,CAAC,CAAC,SAAS,CAAC,gBAAgB;aACjE,EACD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,YAEhB,uBAAC,0BAAU,OAAK,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,GACxG,GACQ,CAC5B,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 { Fragment, useEffect } from \"react\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { TreeWidget } from \"../../../TreeWidget.js\";\nimport { TreeWithHeader } from \"../../tree-header/TreeWithHeader.js\";\nimport { FocusedInstancesContextProvider, useFocusedInstancesContext } from \"../common/FocusedInstancesContext.js\";\nimport { useActiveViewport } from \"../common/UseActiveViewport.js\";\nimport { useFiltering } from \"../common/UseFiltering.js\";\nimport { TelemetryContextProvider } from \"../common/UseTelemetryContext.js\";\nimport { ModelsTree } from \"./ModelsTree.js\";\nimport {\n HideAllButton,\n InvertButton,\n ShowAllButton,\n ToggleInstancesFocusButton,\n useModelsTreeButtonProps,\n View2DButton,\n View3DButton,\n} from \"./ModelsTreeButtons.js\";\n\nimport type { ModelsTreeProps } from \"./ModelsTree.js\";\nimport type { ReactNode } from \"react\";\nimport type { IModelConnection, ScreenViewport } from \"@itwin/core-frontend\";\nimport type { ModelsTreeHeaderButtonProps, ModelsTreeHeaderButtonType } from \"./ModelsTreeButtons.js\";\n\n/** @public */\ninterface ModelsTreeComponentProps\n extends Pick<\n ModelsTreeProps,\n | \"getSchemaContext\"\n | \"selectionStorage\"\n | \"density\"\n | \"hierarchyLevelConfig\"\n | \"selectionMode\"\n | \"selectionPredicate\"\n | \"hierarchyConfig\"\n | \"visibilityHandlerOverrides\"\n | \"getFilteredPaths\"\n | \"getSubTreePaths\"\n > {\n /**\n * Renderers of header buttons. Defaults to:\n * ```ts\n * [\n * ModelsTreeComponent.ShowAllButton,\n * ModelsTreeComponent.HideAllButton,\n * ModelsTreeComponent.InvertButton,\n * ModelsTreeComponent.View2DButton,\n * ModelsTreeComponent.View3DButton,\n * ModelsTreeComponent.ToggleInstancesFocusButton,\n * ]\n * ```\n */\n headerButtons?: Array<(props: ModelsTreeHeaderButtonProps) => React.ReactNode>;\n onPerformanceMeasured?: (featureId: string, duration: number) => void;\n onFeatureUsed?: (feature: string) => void;\n}\n\n/**\n * A component that renders `ModelsTree` and a header with filtering capabilities\n * and header buttons.\n *\n * @public\n */\nexport const ModelsTreeComponent = (props: ModelsTreeComponentProps) => {\n const iModel = useActiveIModelConnection();\n const viewport = useActiveViewport();\n\n if (!iModel || !viewport) {\n return null;\n }\n\n return (\n <FocusedInstancesContextProvider selectionStorage={props.selectionStorage} imodelKey={iModel.key}>\n <ModelsTreeComponentImpl {...props} iModel={iModel} viewport={viewport} />\n </FocusedInstancesContextProvider>\n );\n};\n\n/**\n * Renders a \"Show all\" button that enables display of all models.\n * @public\n */\nModelsTreeComponent.ShowAllButton = ShowAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"Hide all\" button that disables display of all models.\n * @public\n */\nModelsTreeComponent.HideAllButton = HideAllButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Invert all\" button that inverts display of all models.\n * @public\n */\nModelsTreeComponent.InvertButton = InvertButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 2D\" button that enables display of all plan projection models and disables all others.\n * @public\n */\nModelsTreeComponent.View2DButton = View2DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders a \"View 3D\" button that enables display of all non-plan projection models and disables all plan projection ones.\n * @public\n */\nModelsTreeComponent.View3DButton = View3DButton as ModelsTreeHeaderButtonType;\n\n/**\n * Renders an \"Instance focus\" toggle button that enables/disables instances focusing mode.\n *\n * Requires instances focus context to be provided using `FocusedInstancesContextProvider`. The context\n * is provided automatically, when using `ModelsTreeComponent`, but needs to be provided by consumers\n * when rendering `ToggleInstancesFocusButton` outside of `ModelsTreeComponent`.\n *\n * @public\n */\nModelsTreeComponent.ToggleInstancesFocusButton = ToggleInstancesFocusButton as ModelsTreeHeaderButtonType;\n\n/**\n * Id of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.id = \"models-tree-v2\";\n\n/**\n * Label of the component. May be used when a creating a `TreeDefinition` for `SelectableTree`.\n * @public\n */\nModelsTreeComponent.getLabel = () => TreeWidget.translate(\"modelsTree.label\");\n\nfunction ModelsTreeComponentImpl({\n iModel,\n viewport,\n headerButtons,\n onFeatureUsed,\n onPerformanceMeasured,\n ...treeProps\n}: ModelsTreeComponentProps & { iModel: IModelConnection; viewport: ScreenViewport }) {\n const { buttonProps, onModelsFiltered } = useModelsTreeButtonProps({ imodel: iModel, viewport });\n const { filter, applyFilter, clearFilter } = useFiltering();\n const { enabled: instanceFocusEnabled } = useFocusedInstancesContext();\n const density = treeProps.density;\n\n const buttons: ReactNode = headerButtons\n ? headerButtons.map((btn, index) => <Fragment key={index}>{btn({ ...buttonProps, onFeatureUsed })}</Fragment>)\n : [\n <ShowAllButton {...buttonProps} key=\"show-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <HideAllButton {...buttonProps} key=\"hide-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <InvertButton {...buttonProps} key=\"invert-all-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View2DButton {...buttonProps} key=\"view-2d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <View3DButton {...buttonProps} key=\"view-3d-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n <ToggleInstancesFocusButton key=\"toggle-instances-focus-btn\" density={density} onFeatureUsed={onFeatureUsed} />,\n ];\n\n useEffect(() => {\n if (instanceFocusEnabled) {\n clearFilter();\n }\n }, [instanceFocusEnabled, clearFilter]);\n\n return (\n <TelemetryContextProvider componentIdentifier={ModelsTreeComponent.id} onFeatureUsed={onFeatureUsed} onPerformanceMeasured={onPerformanceMeasured}>\n <TreeWithHeader\n filteringProps={{\n onFilterStart: applyFilter,\n onFilterClear: clearFilter,\n isDisabled: instanceFocusEnabled || !!treeProps.getFilteredPaths,\n }}\n buttons={buttons}\n density={density}\n >\n <ModelsTree {...treeProps} imodel={iModel} activeView={viewport} filter={filter} onModelsFiltered={onModelsFiltered} />\n </TreeWithHeader>\n </TelemetryContextProvider>\n );\n}\n"]}
@@ -42,20 +42,19 @@ export interface ElementsGroupInfo {
42
42
  };
43
43
  groupingNode: ClassGroupingHierarchyNode;
44
44
  }
45
- interface ModelsTreeInstanceKeyPathsFromTargetItemsProps {
45
+ interface ModelsTreeInstanceKeyPathsBaseProps {
46
46
  imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;
47
47
  idsCache: ModelsTreeIdsCache;
48
- targetItems: Array<InstanceKey | ElementsGroupInfo>;
49
48
  hierarchyConfig: ModelsTreeHierarchyConfiguration;
50
49
  limit?: number | "unbounded";
50
+ abortSignal?: AbortSignal;
51
51
  }
52
- interface ModelsTreeInstanceKeyPathsFromInstanceLabelProps {
53
- imodelAccess: ECClassHierarchyInspector & LimitingECSqlQueryExecutor;
54
- idsCache: ModelsTreeIdsCache;
52
+ type ModelsTreeInstanceKeyPathsFromTargetItemsProps = {
53
+ targetItems: Array<InstanceKey | ElementsGroupInfo>;
54
+ } & ModelsTreeInstanceKeyPathsBaseProps;
55
+ type ModelsTreeInstanceKeyPathsFromInstanceLabelProps = {
55
56
  label: string;
56
- hierarchyConfig: ModelsTreeHierarchyConfiguration;
57
- limit?: number | "unbounded";
58
- }
57
+ } & ModelsTreeInstanceKeyPathsBaseProps;
59
58
  export type ModelsTreeInstanceKeyPathsProps = ModelsTreeInstanceKeyPathsFromTargetItemsProps | ModelsTreeInstanceKeyPathsFromInstanceLabelProps;
60
59
  export declare namespace ModelsTreeInstanceKeyPathsProps {
61
60
  function isLabelProps(props: ModelsTreeInstanceKeyPathsProps): props is ModelsTreeInstanceKeyPathsFromInstanceLabelProps;
@@ -76,7 +75,7 @@ export declare class ModelsTreeDefinition implements HierarchyDefinition {
76
75
  private createGeometricModel3dChildrenQuery;
77
76
  private createSpatialCategoryChildrenQuery;
78
77
  private createGeometricElement3dChildrenQuery;
79
- static createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps): Promise<import("@itwin/presentation-hierarchies").HierarchyFilteringPath[]>;
78
+ static createInstanceKeyPaths(props: ModelsTreeInstanceKeyPathsProps): Promise<never[] | import("@itwin/presentation-hierarchies").HierarchyFilteringPath[]>;
80
79
  private supportsFiltering;
81
80
  private isSupported;
82
81
  }
@@ -404,11 +404,13 @@ class ModelsTreeDefinition {
404
404
  ];
405
405
  }
406
406
  static async createInstanceKeyPaths(props) {
407
- if (ModelsTreeInstanceKeyPathsProps.isLabelProps(props)) {
408
- const labelsFactory = (0, presentation_shared_1.createBisInstanceLabelSelectClauseFactory)({ classHierarchyInspector: props.imodelAccess });
409
- return createInstanceKeyPathsFromInstanceLabel({ ...props, labelsFactory });
410
- }
411
- return createInstanceKeyPathsFromTargetItems(props);
407
+ return (0, rxjs_1.lastValueFrom)((0, rxjs_1.defer)(() => {
408
+ if (ModelsTreeInstanceKeyPathsProps.isLabelProps(props)) {
409
+ const labelsFactory = (0, presentation_shared_1.createBisInstanceLabelSelectClauseFactory)({ classHierarchyInspector: props.imodelAccess });
410
+ return createInstanceKeyPathsFromInstanceLabelObs({ ...props, labelsFactory });
411
+ }
412
+ return createInstanceKeyPathsFromTargetItemsObs(props);
413
+ }).pipe(props.abortSignal ? (0, rxjs_1.takeUntil)((0, rxjs_1.fromEvent)(props.abortSignal, "abort")) : rxjs_1.identity, (0, rxjs_1.defaultIfEmpty)([])));
412
414
  }
413
415
  supportsFiltering() {
414
416
  return this._hierarchyConfig.hierarchyLevelFiltering === "enable";
@@ -539,11 +541,11 @@ function parseQueryRow(row, groupInfos, separator, elementClassName) {
539
541
  groupingNode: row[2] === -1 ? undefined : groupInfos[row[2]].groupingNode,
540
542
  };
541
543
  }
542
- async function createInstanceKeyPathsFromTargetItems({ targetItems, imodelAccess, hierarchyConfig, idsCache, limit, }) {
544
+ function createInstanceKeyPathsFromTargetItemsObs({ targetItems, imodelAccess, hierarchyConfig, idsCache, limit, }) {
543
545
  if (limit !== "unbounded" && targetItems.length > (limit ?? MAX_FILTERING_INSTANCE_KEY_COUNT)) {
544
546
  throw new TreeErrors_js_1.FilterLimitExceededError(limit ?? MAX_FILTERING_INSTANCE_KEY_COUNT);
545
547
  }
546
- return (0, rxjs_1.lastValueFrom)((0, rxjs_1.from)(targetItems).pipe((0, Utils_js_2.releaseMainThreadOnItemsCount)(2000), (0, rxjs_1.mergeMap)(async (key) => {
548
+ return (0, rxjs_1.from)(targetItems).pipe((0, Utils_js_2.releaseMainThreadOnItemsCount)(2000), (0, rxjs_1.mergeMap)(async (key) => {
547
549
  if ("parent" in key) {
548
550
  return { key, type: 0 };
549
551
  }
@@ -580,17 +582,18 @@ async function createInstanceKeyPathsFromTargetItems({ targetItems, imodelAccess
580
582
  }), (0, rxjs_1.switchMap)(async (ids) => {
581
583
  const elementsLength = ids.elements.length;
582
584
  return (0, Rxjs_js_1.collect)((0, rxjs_1.merge)((0, rxjs_1.from)(ids.subjects).pipe((0, rxjs_1.mergeMap)((id) => (0, rxjs_1.from)(idsCache.createSubjectInstanceKeysPath(id)))), (0, rxjs_1.from)(ids.models).pipe((0, rxjs_1.mergeMap)((id) => (0, rxjs_1.from)(idsCache.createModelInstanceKeyPaths(id)).pipe((0, rxjs_1.mergeAll)()))), (0, rxjs_1.from)(ids.categories).pipe((0, rxjs_1.mergeMap)((id) => (0, rxjs_1.from)(idsCache.createCategoryInstanceKeyPaths(id)).pipe((0, rxjs_1.mergeAll)()))), (0, rxjs_1.from)(ids.elements).pipe((0, rxjs_1.bufferCount)(Math.ceil(elementsLength / Math.ceil(elementsLength / 5000))), (0, Utils_js_2.releaseMainThreadOnItemsCount)(1), (0, rxjs_1.mergeMap)((block) => createGeometricElementInstanceKeyPaths(imodelAccess, idsCache, hierarchyConfig, block), 10))));
583
- })));
585
+ }));
584
586
  }
585
- async function createInstanceKeyPathsFromInstanceLabel(props) {
586
- const elementLabelSelectClause = await props.labelsFactory.createSelectClause({
587
- classAlias: "e",
588
- className: "BisCore.Element",
589
- // eslint-disable-next-line @typescript-eslint/unbound-method
590
- selectorsConcatenator: presentation_shared_1.ECSql.createConcatenatedValueStringSelector,
591
- });
592
- const targetsReader = props.imodelAccess.createQueryReader({
593
- ecsql: `
587
+ function createInstanceKeyPathsFromInstanceLabelObs(props) {
588
+ const { labelsFactory, hierarchyConfig, label, imodelAccess, limit } = props;
589
+ return (0, rxjs_1.defer)(async () => {
590
+ const elementLabelSelectClause = await labelsFactory.createSelectClause({
591
+ classAlias: "e",
592
+ className: "BisCore.Element",
593
+ // eslint-disable-next-line @typescript-eslint/unbound-method
594
+ selectorsConcatenator: presentation_shared_1.ECSql.createConcatenatedValueStringSelector,
595
+ });
596
+ const ecsql = `
594
597
  SELECT *
595
598
  FROM (
596
599
  SELECT
@@ -598,7 +601,7 @@ async function createInstanceKeyPathsFromInstanceLabel(props) {
598
601
  e.ECInstanceId,
599
602
  ${elementLabelSelectClause} Label
600
603
  FROM BisCore.Element e
601
- WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${props.hierarchyConfig.elementClassSpecification})
604
+ WHERE e.ECClassId IS (BisCore.Subject, BisCore.SpatialCategory, ${hierarchyConfig.elementClassSpecification})
602
605
 
603
606
  UNION ALL
604
607
 
@@ -609,19 +612,21 @@ async function createInstanceKeyPathsFromInstanceLabel(props) {
609
612
  FROM BisCore.GeometricModel3d m
610
613
  JOIN BisCore.Element e ON e.ECInstanceId = m.ModeledElement.Id
611
614
  WHERE NOT m.IsPrivate
612
- ${props.hierarchyConfig.showEmptyModels ? "" : `AND EXISTS (SELECT 1 FROM ${props.hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}
615
+ ${hierarchyConfig.showEmptyModels ? "" : `AND EXISTS (SELECT 1 FROM ${hierarchyConfig.elementClassSpecification} WHERE Model.Id = m.ECInstanceId)`}
613
616
  AND json_extract(e.JsonProperties, '$.PhysicalPartition.Model.Content') IS NULL
614
617
  AND json_extract(e.JsonProperties, '$.GraphicalPartition3d.Model.Content') IS NULL
615
618
  )
616
619
  WHERE Label LIKE '%' || ? || '%' ESCAPE '\\'
617
620
  LIMIT ${MAX_FILTERING_INSTANCE_KEY_COUNT + 1}
618
- `,
619
- bindings: [{ type: "string", value: props.label.replace(/[%_\\]/g, "\\$&") }],
620
- }, { rowFormat: "Indexes", restartToken: "tree-widget/models-tree/filter-by-label-query", limit: props.limit });
621
- const targetKeys = new Array();
622
- for await (const row of targetsReader) {
623
- targetKeys.push({ className: row[0], id: row[1] });
624
- }
625
- return createInstanceKeyPathsFromTargetItems({ ...props, targetItems: targetKeys });
621
+ `;
622
+ const bindings = [{ type: "string", value: label.replace(/[%_\\]/g, "\\$&") }];
623
+ return { ecsql, bindings };
624
+ }).pipe((0, rxjs_1.mergeMap)((queryProps) => {
625
+ return imodelAccess.createQueryReader(queryProps, {
626
+ rowFormat: "Indexes",
627
+ restartToken: "tree-widget/models-tree/filter-by-label-query",
628
+ limit,
629
+ });
630
+ }), (0, rxjs_1.map)((row) => ({ className: row[0], id: row[1] })), (0, rxjs_1.toArray)(), (0, rxjs_1.mergeMap)((targetKeys) => createInstanceKeyPathsFromTargetItemsObs({ ...props, targetItems: targetKeys })));
626
631
  }
627
632
  //# sourceMappingURL=ModelsTreeDefinition.js.map