@itwin/presentation-hierarchies-react 1.0.1 → 1.1.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 (102) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +5 -3
  3. package/lib/cjs/package.json +1 -0
  4. package/lib/cjs/presentation-hierarchies-react/TreeNode.d.ts +7 -7
  5. package/lib/cjs/presentation-hierarchies-react/TreeNode.js +1 -1
  6. package/lib/cjs/presentation-hierarchies-react/TreeNode.js.map +1 -1
  7. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +1 -1
  8. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js +1 -1
  9. package/lib/cjs/presentation-hierarchies-react/UnifiedSelectionContext.js.map +1 -1
  10. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts +7 -7
  11. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  12. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js +5 -5
  13. package/lib/cjs/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  14. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.d.ts +7 -7
  15. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  16. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js +3 -3
  17. package/lib/cjs/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  18. package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts +9 -9
  19. package/lib/cjs/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  20. package/lib/cjs/presentation-hierarchies-react/UseTree.js +11 -11
  21. package/lib/cjs/presentation-hierarchies-react/UseTree.js.map +1 -1
  22. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts +2 -2
  23. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  24. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js +30 -29
  25. package/lib/cjs/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  26. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts +1 -1
  27. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  28. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js +4 -4
  29. package/lib/cjs/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  30. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.d.ts +1 -1
  31. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
  32. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.js +5 -4
  33. package/lib/cjs/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  34. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +3 -3
  35. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  36. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js +19 -21
  37. package/lib/cjs/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  38. package/lib/cjs/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +3 -3
  39. package/lib/cjs/presentation-hierarchies-react/itwinui/LocalizationContext.js +1 -1
  40. package/lib/cjs/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +1 -1
  41. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +9 -9
  42. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
  43. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +15 -15
  44. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
  45. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +13 -13
  46. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
  47. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js +8 -8
  48. package/lib/cjs/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
  49. package/lib/cjs/presentation-hierarchies-react.d.ts +8 -8
  50. package/lib/cjs/presentation-hierarchies-react.d.ts.map +1 -1
  51. package/lib/cjs/presentation-hierarchies-react.js +19 -19
  52. package/lib/cjs/presentation-hierarchies-react.js.map +1 -1
  53. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +7 -7
  54. package/lib/esm/presentation-hierarchies-react/TreeNode.js +1 -1
  55. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
  56. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +1 -1
  57. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +1 -1
  58. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +1 -1
  59. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +7 -7
  60. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  61. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +3 -3
  62. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  63. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +7 -7
  64. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  65. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +2 -2
  66. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  67. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +9 -9
  68. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  69. package/lib/esm/presentation-hierarchies-react/UseTree.js +6 -6
  70. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  71. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +2 -2
  72. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  73. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +10 -9
  74. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  75. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +1 -1
  76. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  77. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +3 -3
  78. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  79. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +1 -1
  80. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
  81. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +5 -4
  82. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  83. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +3 -3
  84. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  85. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +16 -18
  86. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  87. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +3 -3
  88. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js +1 -1
  89. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +1 -1
  90. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +9 -9
  91. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +1 -1
  92. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +8 -8
  93. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +1 -1
  94. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +12 -12
  95. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +1 -1
  96. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +5 -5
  97. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +1 -1
  98. package/lib/esm/presentation-hierarchies-react.d.ts +8 -8
  99. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  100. package/lib/esm/presentation-hierarchies-react.js +8 -8
  101. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  102. package/package.json +27 -19
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @itwin/presentation-hierarchies-react
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#740](https://github.com/iTwin/presentation/pull/740): Define `type` and `exports` attributes in `package.json`.
8
+
9
+ The change moves this package a step closer towards dropping CommonJS support - it's now transpiled from ESM to CommonJS instead of the opposite.
10
+
11
+ In addition, the `exports` attribute has been added to `package.json` to prohibit access to APIs that are not intended to be used by external consumers.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#758](https://github.com/iTwin/presentation/pull/758): Promote `@beta` APIs to `@public`.
16
+ - [#756](https://github.com/iTwin/presentation/pull/756): Added missing `ref` property to `TreeNodeRendererProps` type.
17
+ - Updated dependencies:
18
+ - @itwin/presentation-shared@1.1.0
19
+ - @itwin/unified-selection@1.1.0
20
+ - @itwin/presentation-hierarchies@1.2.0
21
+
3
22
  ## 1.0.1
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -65,6 +65,7 @@ The hook takes 2 required properties:
65
65
  import { IModelConnection } from "@itwin/core-frontend";
66
66
  import { SchemaContext } from "@itwin/ecschema-metadata";
67
67
  import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common";
68
+ import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
68
69
  import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
69
70
  import { createLimitingECSqlQueryExecutor, createNodesQueryClauseFactory, HierarchyDefinition } from "@itwin/presentation-hierarchies";
70
71
 
@@ -209,22 +210,23 @@ The component is based on `TreeNode` component from iTwinUI library and supports
209
210
 
210
211
  ## Full example
211
212
 
212
- <!-- [[include: [Presentation.HierarchiesReact.iModelAccess.Imports, Presentation.HierarchiesReact.SelectionStorage.Imports, Presentation.HierarchiesReact.CustomTreeExample.Imports, Presentation.HierarchiesReact.iModelAccess, Presentation.HierarchiesReact.SelectionStorage, Presentation.HierarchiesReact.CustomTreeExample], tsx]] -->
213
+ <!-- [[include: [Presentation.HierarchiesReact.iModelAccess.Imports, Presentation.HierarchiesReact.CustomTreeExample.Imports, Presentation.HierarchiesReact.SelectionStorage.Imports, Presentation.HierarchiesReact.iModelAccess, Presentation.HierarchiesReact.SelectionStorage, Presentation.HierarchiesReact.CustomTreeExample], tsx]] -->
213
214
  <!-- BEGIN EXTRACTION -->
214
215
 
215
216
  ```tsx
216
217
  import { IModelConnection } from "@itwin/core-frontend";
217
218
  import { SchemaContext } from "@itwin/ecschema-metadata";
218
219
  import { ECSchemaRpcLocater } from "@itwin/ecschema-rpcinterface-common";
220
+ import { createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
219
221
  import { createECSchemaProvider, createECSqlQueryExecutor } from "@itwin/presentation-core-interop";
220
222
  import { createLimitingECSqlQueryExecutor, createNodesQueryClauseFactory, HierarchyDefinition } from "@itwin/presentation-hierarchies";
221
223
 
224
+ import { createBisInstanceLabelSelectClauseFactory } from "@itwin/presentation-shared";
225
+
222
226
  import { TreeRenderer, UnifiedSelectionProvider, useIModelUnifiedSelectionTree } from "@itwin/presentation-hierarchies-react";
223
227
  import { createStorage } from "@itwin/unified-selection";
224
228
  import { useEffect, useState } from "react";
225
229
 
226
- import { createBisInstanceLabelSelectClauseFactory, createCachingECClassHierarchyInspector } from "@itwin/presentation-shared";
227
-
228
230
  // Not really part of the package, but we need SchemaContext to create the tree state. It's
229
231
  // recommended to cache the schema context and reuse it across different application's components to
230
232
  // avoid loading and storing same schemas multiple times.
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -1,7 +1,7 @@
1
1
  import { HierarchyNode } from "@itwin/presentation-hierarchies";
2
2
  /**
3
3
  * A type that defines an actual expandable node in a UI tree component, built with `useTree` hook.
4
- * @beta
4
+ * @public
5
5
  */
6
6
  export interface PresentationHierarchyNode {
7
7
  id: string;
@@ -22,7 +22,7 @@ export interface PresentationHierarchyNode {
22
22
  * A type of `PresentationInfoNode` that is returned as the single child of a filtered parent node,
23
23
  * when none of the child nodes match the filter.
24
24
  *
25
- * @beta
25
+ * @public
26
26
  */
27
27
  export interface PresentationNoFilterMatchesInfoNode {
28
28
  id: string;
@@ -34,7 +34,7 @@ export interface PresentationNoFilterMatchesInfoNode {
34
34
  * number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included
35
35
  * on this node as `resultSetSizeLimit` attribute.
36
36
  *
37
- * @beta
37
+ * @public
38
38
  */
39
39
  export interface PresentationResultSetTooLargeInfoNode {
40
40
  id: string;
@@ -47,7 +47,7 @@ export interface PresentationResultSetTooLargeInfoNode {
47
47
  * Generally, this is the only child of a parent node, created in cases like an error loading children. The
48
48
  * renderer may offer users to re-load the children or the whole component in such cases.
49
49
  *
50
- * @beta
50
+ * @public
51
51
  */
52
52
  export interface PresentationGenericInfoNode {
53
53
  id: string;
@@ -59,17 +59,17 @@ export interface PresentationGenericInfoNode {
59
59
  * A type that defines a non-expandable, non-selectable informational node in a UI tree component, built
60
60
  * with `useTree` hook.
61
61
  *
62
- * @beta
62
+ * @public
63
63
  */
64
64
  export type PresentationInfoNode = PresentationGenericInfoNode | PresentationResultSetTooLargeInfoNode | PresentationNoFilterMatchesInfoNode;
65
65
  /**
66
66
  * A type that defines a node in a UI tree component, built with `useTree` hook.
67
- * @beta
67
+ * @public
68
68
  */
69
69
  export type PresentationTreeNode = PresentationHierarchyNode | PresentationInfoNode;
70
70
  /**
71
71
  * An utility function to check if a node is a `PresentationHierarchyNode`.
72
- * @beta
72
+ * @public
73
73
  */
74
74
  export declare function isPresentationHierarchyNode(node: PresentationTreeNode): node is PresentationHierarchyNode;
75
75
  //# sourceMappingURL=TreeNode.d.ts.map
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.isPresentationHierarchyNode = isPresentationHierarchyNode;
8
8
  /**
9
9
  * An utility function to check if a node is a `PresentationHierarchyNode`.
10
- * @beta
10
+ * @public
11
11
  */
12
12
  function isPresentationHierarchyNode(node) {
13
13
  return "children" in node;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNode.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAgFhG,kEAEC;AAND;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,IAA0B;IACpE,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,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 { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/**\n * A type that defines an actual expandable node in a UI tree component, built with `useTree` hook.\n * @beta\n */\nexport interface PresentationHierarchyNode {\n id: string;\n label: string;\n children: true | Array<PresentationTreeNode>;\n isExpanded: boolean;\n isLoading: boolean;\n isFilterable: boolean;\n isFiltered: boolean;\n /** UI-agnostic source of this node object. */\n nodeData: HierarchyNode;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a filtered parent node,\n * when none of the child nodes match the filter.\n *\n * @beta\n */\nexport interface PresentationNoFilterMatchesInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"NoFilterMatches\";\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a parent node, when the\n * number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included\n * on this node as `resultSetSizeLimit` attribute.\n *\n * @beta\n */\nexport interface PresentationResultSetTooLargeInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"ResultSetTooLarge\";\n resultSetSizeLimit: number;\n}\n\n/**\n * A type of `PresentationInfoNode` that contains a user-friendly message to be displayed in the UI.\n * Generally, this is the only child of a parent node, created in cases like an error loading children. The\n * renderer may offer users to re-load the children or the whole component in such cases.\n *\n * @beta\n */\nexport interface PresentationGenericInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"Unknown\";\n message: string;\n}\n\n/**\n * A type that defines a non-expandable, non-selectable informational node in a UI tree component, built\n * with `useTree` hook.\n *\n * @beta\n */\nexport type PresentationInfoNode = PresentationGenericInfoNode | PresentationResultSetTooLargeInfoNode | PresentationNoFilterMatchesInfoNode;\n\n/**\n * A type that defines a node in a UI tree component, built with `useTree` hook.\n * @beta\n */\nexport type PresentationTreeNode = PresentationHierarchyNode | PresentationInfoNode;\n\n/**\n * An utility function to check if a node is a `PresentationHierarchyNode`.\n * @beta\n */\nexport function isPresentationHierarchyNode(node: PresentationTreeNode): node is PresentationHierarchyNode {\n return \"children\" in node;\n}\n"]}
1
+ {"version":3,"file":"TreeNode.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAgFhG,kEAEC;AAND;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,IAA0B;IACpE,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,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 { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/**\n * A type that defines an actual expandable node in a UI tree component, built with `useTree` hook.\n * @public\n */\nexport interface PresentationHierarchyNode {\n id: string;\n label: string;\n children: true | Array<PresentationTreeNode>;\n isExpanded: boolean;\n isLoading: boolean;\n isFilterable: boolean;\n isFiltered: boolean;\n /** UI-agnostic source of this node object. */\n nodeData: HierarchyNode;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a filtered parent node,\n * when none of the child nodes match the filter.\n *\n * @public\n */\nexport interface PresentationNoFilterMatchesInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"NoFilterMatches\";\n}\n\n/**\n * A type of `PresentationInfoNode` that is returned as the single child of a parent node, when the\n * number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included\n * on this node as `resultSetSizeLimit` attribute.\n *\n * @public\n */\nexport interface PresentationResultSetTooLargeInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"ResultSetTooLarge\";\n resultSetSizeLimit: number;\n}\n\n/**\n * A type of `PresentationInfoNode` that contains a user-friendly message to be displayed in the UI.\n * Generally, this is the only child of a parent node, created in cases like an error loading children. The\n * renderer may offer users to re-load the children or the whole component in such cases.\n *\n * @public\n */\nexport interface PresentationGenericInfoNode {\n id: string;\n parentNodeId: string | undefined;\n type: \"Unknown\";\n message: string;\n}\n\n/**\n * A type that defines a non-expandable, non-selectable informational node in a UI tree component, built\n * with `useTree` hook.\n *\n * @public\n */\nexport type PresentationInfoNode = PresentationGenericInfoNode | PresentationResultSetTooLargeInfoNode | PresentationNoFilterMatchesInfoNode;\n\n/**\n * A type that defines a node in a UI tree component, built with `useTree` hook.\n * @public\n */\nexport type PresentationTreeNode = PresentationHierarchyNode | PresentationInfoNode;\n\n/**\n * An utility function to check if a node is a `PresentationHierarchyNode`.\n * @public\n */\nexport function isPresentationHierarchyNode(node: PresentationTreeNode): node is PresentationHierarchyNode {\n return \"children\" in node;\n}\n"]}
@@ -6,7 +6,7 @@ import { SelectionStorage } from "@itwin/unified-selection";
6
6
  *
7
7
  * See `README.md` for a usage example.
8
8
  *
9
- * @beta
9
+ * @public
10
10
  */
11
11
  export declare function UnifiedSelectionProvider({ storage, children }: PropsWithChildren<{
12
12
  storage: SelectionStorage;
@@ -15,7 +15,7 @@ const unifiedSelectionContext = (0, react_1.createContext)(undefined);
15
15
  *
16
16
  * See `README.md` for a usage example.
17
17
  *
18
- * @beta
18
+ * @public
19
19
  */
20
20
  function UnifiedSelectionProvider({ storage, children }) {
21
21
  return (0, jsx_runtime_1.jsx)(unifiedSelectionContext.Provider, { value: storage, children: children });
@@ -1 +1 @@
1
- {"version":3,"file":"UnifiedSelectionContext.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UnifiedSelectionContext.tsx"],"names":[],"mappings":";;AAkBA,4DAEC;AAGD,gEAEC;;AAzBD;;;gGAGgG;AAEhG,iCAAqE;AAGrE,MAAM,uBAAuB,GAAG,IAAA,qBAAa,EAA+B,SAAS,CAAC,CAAC;AAEvF;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAoD;IAC9G,OAAO,uBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YAAG,QAAQ,GAAoC,CAAC;AACzG,CAAC;AAED,gBAAgB;AAChB,SAAgB,0BAA0B;IACxC,OAAO,IAAA,kBAAU,EAAC,uBAAuB,CAAC,CAAC;AAC7C,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 { createContext, PropsWithChildren, useContext } from \"react\";\nimport { SelectionStorage } from \"@itwin/unified-selection\";\n\nconst unifiedSelectionContext = createContext<SelectionStorage | undefined>(undefined);\n\n/**\n * A React context provider that makes given selection storage available to all child components. This\n * is a requirement for `useUnifiedSelectionTree` to work with unified selection.\n *\n * See `README.md` for a usage example.\n *\n * @beta\n */\nexport function UnifiedSelectionProvider({ storage, children }: PropsWithChildren<{ storage: SelectionStorage }>) {\n return <unifiedSelectionContext.Provider value={storage}>{children}</unifiedSelectionContext.Provider>;\n}\n\n/** @internal */\nexport function useUnifiedSelectionContext() {\n return useContext(unifiedSelectionContext);\n}\n"]}
1
+ {"version":3,"file":"UnifiedSelectionContext.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UnifiedSelectionContext.tsx"],"names":[],"mappings":";;AAkBA,4DAEC;AAGD,gEAEC;;AAzBD;;;gGAGgG;AAEhG,iCAAqE;AAGrE,MAAM,uBAAuB,GAAG,IAAA,qBAAa,EAA+B,SAAS,CAAC,CAAC;AAEvF;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAoD;IAC9G,OAAO,uBAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YAAG,QAAQ,GAAoC,CAAC;AACzG,CAAC;AAED,gBAAgB;AAChB,SAAgB,0BAA0B;IACxC,OAAO,IAAA,kBAAU,EAAC,uBAAuB,CAAC,CAAC;AAC7C,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 { createContext, PropsWithChildren, useContext } from \"react\";\nimport { SelectionStorage } from \"@itwin/unified-selection\";\n\nconst unifiedSelectionContext = createContext<SelectionStorage | undefined>(undefined);\n\n/**\n * A React context provider that makes given selection storage available to all child components. This\n * is a requirement for `useUnifiedSelectionTree` to work with unified selection.\n *\n * See `README.md` for a usage example.\n *\n * @public\n */\nexport function UnifiedSelectionProvider({ storage, children }: PropsWithChildren<{ storage: SelectionStorage }>) {\n return <unifiedSelectionContext.Provider value={storage}>{children}</unifiedSelectionContext.Provider>;\n}\n\n/** @internal */\nexport function useUnifiedSelectionContext() {\n return useContext(unifiedSelectionContext);\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  import { createIModelHierarchyProvider, HierarchyDefinition, HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
2
- import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection";
3
- import { UseTreeProps, UseTreeResult } from "./UseTree";
4
- /** @beta */
2
+ import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js";
3
+ import { UseTreeProps, UseTreeResult } from "./UseTree.js";
4
+ /** @public */
5
5
  type IModelHierarchyProviderProps = Parameters<typeof createIModelHierarchyProvider>[0];
6
- /** @beta */
6
+ /** @public */
7
7
  type IModelAccess = IModelHierarchyProviderProps["imodelAccess"];
8
8
  /**
9
9
  * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.
10
- * @beta
10
+ * @public
11
11
  */
12
12
  type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getFilteredPaths"> & Pick<IModelHierarchyProviderProps, "localizedStrings" | "imodelAccess" | "imodelChanged"> & {
13
13
  /** Provides the hierarchy definition for the tree. */
@@ -31,7 +31,7 @@ type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getFilter
31
31
  *
32
32
  * @see `useTree`
33
33
  * @see `useIModelUnifiedSelectionTree`
34
- * @beta
34
+ * @public
35
35
  */
36
36
  export declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
37
37
  /**
@@ -46,7 +46,7 @@ export declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
46
46
  * @see `useIModelTree`
47
47
  * @see `useUnifiedSelectionTree`
48
48
  * @see `UnifiedSelectionProvider`
49
- * @beta
49
+ * @public
50
50
  */
51
51
  export declare function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
52
52
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"UseIModelTree.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC7H,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAg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UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC;AAExF,cAAc;AACd,KAAK,YAAY,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;AAEjE;;;GAGG;AACH,KAAK,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,sBAAsB,GAAG,kBAAkB,CAAC,GACvF,IAAI,CAAC,4BAA4B,EAAE,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC,GAAG;IAC1F,sDAAsD;IACtD,sBAAsB,EAAE,CAAC,KAAK,EAAE;QAAE,YAAY,EAAE,YAAY,CAAA;KAAE,KAAK,mBAAmB,CAAC;IAEvF,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE;QACzB,+FAA+F;QAC/F,YAAY,EAAE,YAAY,CAAC;KAC5B,KAAK,OAAO,CAAC,sBAAsB,EAAE,GAAG,SAAS,CAAC,CAAC;CACrD,CAAC;AAEJ;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAMtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kBAAkB,GAAG,4BAA4B,GAAG,aAAa,CAMrH"}
@@ -8,7 +8,7 @@ exports.useIModelTree = useIModelTree;
8
8
  exports.useIModelUnifiedSelectionTree = useIModelUnifiedSelectionTree;
9
9
  const react_1 = require("react");
10
10
  const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
11
- const UseTree_1 = require("./UseTree");
11
+ const UseTree_js_1 = require("./UseTree.js");
12
12
  /**
13
13
  * A React hook that creates state for a tree component whose displayed hierarchy is based on
14
14
  * iModel data.
@@ -20,11 +20,11 @@ const UseTree_1 = require("./UseTree");
20
20
  *
21
21
  * @see `useTree`
22
22
  * @see `useIModelUnifiedSelectionTree`
23
- * @beta
23
+ * @public
24
24
  */
25
25
  function useIModelTree(props) {
26
26
  const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;
27
- return (0, UseTree_1.useTree)({
27
+ return (0, UseTree_js_1.useTree)({
28
28
  ...rest,
29
29
  ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),
30
30
  });
@@ -41,11 +41,11 @@ function useIModelTree(props) {
41
41
  * @see `useIModelTree`
42
42
  * @see `useUnifiedSelectionTree`
43
43
  * @see `UnifiedSelectionProvider`
44
- * @beta
44
+ * @public
45
45
  */
46
46
  function useIModelUnifiedSelectionTree(props) {
47
47
  const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;
48
- return (0, UseTree_1.useUnifiedSelectionTree)({
48
+ return (0, UseTree_js_1.useUnifiedSelectionTree)({
49
49
  ...rest,
50
50
  ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),
51
51
  });
@@ -1 +1 @@
1
- {"version":3,"file":"UseIModelTree.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA0ChG,sCAMC;AAgBD,sEAMC;AApED,iCAAoC;AACpC,8EAA6H;AAE7H,uCAA0F;AAwB1F;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAC,KAAyB;IACrD,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACnH,OAAO,IAAA,iBAAO,EAAC;QACb,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;KACnH,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,6BAA6B,CAAC,KAAwD;IACpG,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACnH,OAAO,IAAA,iCAAuB,EAAC;QAC7B,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;KACnH,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAsI;IAEtI,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC1G,OAAO;QACL,oBAAoB,EAAE,IAAA,mBAAW,EAC/B,GAAG,EAAE,CACH,IAAA,wDAA6B,EAAC;YAC5B,YAAY;YACZ,aAAa;YACb,mBAAmB,EAAE,sBAAsB,CAAC,EAAE,YAAY,EAAE,CAAC;YAC7D,gBAAgB;SACjB,CAAC,EACJ,CAAC,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,CAAC,CACxE;QACD,gBAAgB,EAAE,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KAClH,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 { useCallback } from \"react\";\nimport { createIModelHierarchyProvider, HierarchyDefinition, HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection\";\nimport { useTree, UseTreeProps, UseTreeResult, useUnifiedSelectionTree } from \"./UseTree\";\n\n/** @beta */\ntype IModelHierarchyProviderProps = Parameters<typeof createIModelHierarchyProvider>[0];\n\n/** @beta */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @beta\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> &\n Pick<IModelHierarchyProviderProps, \"localizedStrings\" | \"imodelAccess\" | \"imodelChanged\"> & {\n /** Provides the hierarchy definition for the tree. */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /** Provides paths to filtered nodes. */\n getFilteredPaths?: (props: {\n /** Object that provides access to the iModel schema and can run queries against the iModel. */\n imodelAccess: IModelAccess;\n }) => Promise<HierarchyFilteringPath[] | undefined>;\n };\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useTree`\n * @see `useIModelUnifiedSelectionTree`\n * @beta\n */\nexport function useIModelTree(props: UseIModelTreeProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data and that is integrated with unified selection through context provided by `UnifiedSelectionProvider`.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useIModelTree`\n * @see `useUnifiedSelectionTree`\n * @see `UnifiedSelectionProvider`\n * @beta\n */\nexport function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"localizedStrings\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings } = props;\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings,\n }),\n [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings],\n ),\n getFilteredPaths: useCallback(async () => getFilteredPaths?.({ imodelAccess }), [imodelAccess, getFilteredPaths]),\n };\n}\n"]}
1
+ {"version":3,"file":"UseIModelTree.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA0ChG,sCAMC;AAgBD,sEAMC;AApED,iCAAoC;AACpC,8EAA6H;AAE7H,6CAA6F;AAwB7F;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa,CAAC,KAAyB;IACrD,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACnH,OAAO,IAAA,oBAAO,EAAC;QACb,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;KACnH,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,6BAA6B,CAAC,KAAwD;IACpG,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACnH,OAAO,IAAA,oCAAuB,EAAC;QAC7B,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC;KACnH,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAsI;IAEtI,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAC1G,OAAO;QACL,oBAAoB,EAAE,IAAA,mBAAW,EAC/B,GAAG,EAAE,CACH,IAAA,wDAA6B,EAAC;YAC5B,YAAY;YACZ,aAAa;YACb,mBAAmB,EAAE,sBAAsB,CAAC,EAAE,YAAY,EAAE,CAAC;YAC7D,gBAAgB;SACjB,CAAC,EACJ,CAAC,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,CAAC,CACxE;QACD,gBAAgB,EAAE,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KAClH,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 { useCallback } from \"react\";\nimport { createIModelHierarchyProvider, HierarchyDefinition, HierarchyFilteringPath } from \"@itwin/presentation-hierarchies\";\nimport { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport { useTree, UseTreeProps, UseTreeResult, useUnifiedSelectionTree } from \"./UseTree.js\";\n\n/** @public */\ntype IModelHierarchyProviderProps = Parameters<typeof createIModelHierarchyProvider>[0];\n\n/** @public */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @public\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> &\n Pick<IModelHierarchyProviderProps, \"localizedStrings\" | \"imodelAccess\" | \"imodelChanged\"> & {\n /** Provides the hierarchy definition for the tree. */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /** Provides paths to filtered nodes. */\n getFilteredPaths?: (props: {\n /** Object that provides access to the iModel schema and can run queries against the iModel. */\n imodelAccess: IModelAccess;\n }) => Promise<HierarchyFilteringPath[] | undefined>;\n };\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useTree`\n * @see `useIModelUnifiedSelectionTree`\n * @public\n */\nexport function useIModelTree(props: UseIModelTreeProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\n/**\n * A React hook that creates state for a tree component whose displayed hierarchy is based on\n * iModel data and that is integrated with unified selection through context provided by `UnifiedSelectionProvider`.\n *\n * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a\n * component-agnostic result which may be used to render the hierarchy using any UI framework.\n *\n * See `README.md` for an example\n *\n * @see `useIModelTree`\n * @see `useUnifiedSelectionTree`\n * @see `UnifiedSelectionProvider`\n * @public\n */\nexport function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getFilteredPaths\" | \"localizedStrings\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getFilteredPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getFilteredPaths, localizedStrings } = props;\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings,\n }),\n [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings],\n ),\n getFilteredPaths: useCallback(async () => getFilteredPaths?.({ imodelAccess }), [imodelAccess, getFilteredPaths]),\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { PresentationHierarchyNode } from "./TreeNode";
2
- import { useTree } from "./UseTree";
1
+ import { PresentationHierarchyNode } from "./TreeNode.js";
2
+ import { useTree } from "./UseTree.js";
3
3
  /**
4
4
  * A union of different supported selection modes in a tree component:
5
5
  * - `none` - no selection is allowed,
@@ -7,7 +7,7 @@ import { useTree } from "./UseTree";
7
7
  * - `extended` - multiple nodes can be selected using shift and ctrl keys,
8
8
  * - `multiple` - multiple nodes can be selected without using shift or ctrl keys.
9
9
  *
10
- * @beta
10
+ * @public
11
11
  */
12
12
  export type SelectionMode = "none" | "single" | "extended" | "multiple";
13
13
  /**
@@ -16,12 +16,12 @@ export type SelectionMode = "none" | "single" | "extended" | "multiple";
16
16
  * - `replace` - a selected node was replaced with a different one,
17
17
  * - `remove` - a node was removed from the selection.
18
18
  *
19
- * @beta
19
+ * @public
20
20
  */
21
21
  export type SelectionChangeType = "add" | "replace" | "remove";
22
22
  /**
23
23
  * Props for `useSelectionHandler` hook.
24
- * @beta
24
+ * @public
25
25
  */
26
26
  type UseSelectionHandlerProps = Pick<ReturnType<typeof useTree>, "rootNodes" | "selectNodes"> & {
27
27
  /** Selection mode that the component is working in. */
@@ -29,7 +29,7 @@ type UseSelectionHandlerProps = Pick<ReturnType<typeof useTree>, "rootNodes" | "
29
29
  };
30
30
  /**
31
31
  * Result of `useSelectionHandler` hook.
32
- * @beta
32
+ * @public
33
33
  */
34
34
  interface UseSelectionHandlerResult {
35
35
  /** Should be called by node renderer when a node component is clicked. */
@@ -39,7 +39,7 @@ interface UseSelectionHandlerResult {
39
39
  }
40
40
  /**
41
41
  * A react hook that helps implement different selection modes in a tree component created using `useTree` hook.
42
- * @beta
42
+ * @public
43
43
  */
44
44
  export declare function useSelectionHandler(props: UseSelectionHandlerProps): UseSelectionHandlerResult;
45
45
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"UseSelectionHandler.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+B,yBAAyB,EAAwB,MAAM,YAAY,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/D;;;GAGG;AACH,KAAK,wBAAwB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG;IAC9F,uDAAuD;IACvD,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,UAAU,yBAAyB;IACjC,0EAA0E;IAC1E,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E,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACxH;AAOD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,yBAAyB,CAiE9F"}
@@ -6,10 +6,10 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.useSelectionHandler = useSelectionHandler;
8
8
  const react_1 = require("react");
9
- const TreeNode_1 = require("./TreeNode");
9
+ const TreeNode_js_1 = require("./TreeNode.js");
10
10
  /**
11
11
  * A react hook that helps implement different selection modes in a tree component created using `useTree` hook.
12
- * @beta
12
+ * @public
13
13
  */
14
14
  function useSelectionHandler(props) {
15
15
  const { rootNodes, selectionMode, selectNodes } = props;
@@ -85,7 +85,7 @@ function computeFlatNodeList(rootNodes) {
85
85
  const nodeIdToIndexMap = new Map();
86
86
  const flattenNodeRecursively = (nodes) => {
87
87
  nodes.forEach((node) => {
88
- if (!(0, TreeNode_1.isPresentationHierarchyNode)(node)) {
88
+ if (!(0, TreeNode_js_1.isPresentationHierarchyNode)(node)) {
89
89
  return;
90
90
  }
91
91
  nodeIdToIndexMap.set(node.id, flatNodeList.length);
@@ -1 +1 @@
1
- {"version":3,"file":"UseSelectionHandler.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAwDhG,kDAiEC;AAvHD,iCAAuD;AACvD,yCAA0G;AAiD1G;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACxD,MAAM,oBAAoB,GAAG,IAAA,cAAM,EAAqB,SAAS,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,IAAA,cAAM,EAAgB;QAClC,YAAY,EAAE,EAAE;QAChB,gBAAgB,EAAE,IAAI,GAAG,EAAE;KA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ACrB,IAAI,CAAC,IAAA,sCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;gBACvC,OAAO;YACT,CAAC;YACD,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC1D,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC5C,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 { useCallback, useEffect, useRef } from \"react\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode, PresentationTreeNode } from \"./TreeNode\";\nimport { useTree } from \"./UseTree\";\n\n/**\n * A union of different supported selection modes in a tree component:\n * - `none` - no selection is allowed,\n * - `single` - only one node can be selected at a time,\n * - `extended` - multiple nodes can be selected using shift and ctrl keys,\n * - `multiple` - multiple nodes can be selected without using shift or ctrl keys.\n *\n * @beta\n */\nexport type SelectionMode = \"none\" | \"single\" | \"extended\" | \"multiple\";\n\n/**\n * Type of selection change.\n * - `add` - a node was added to the selection,\n * - `replace` - a selected node was replaced with a different one,\n * - `remove` - a node was removed from the selection.\n *\n * @beta\n */\nexport type SelectionChangeType = \"add\" | \"replace\" | \"remove\";\n\n/**\n * Props for `useSelectionHandler` hook.\n * @beta\n */\ntype UseSelectionHandlerProps = Pick<ReturnType<typeof useTree>, \"rootNodes\" | \"selectNodes\"> & {\n /** Selection mode that the component is working in. */\n selectionMode: SelectionMode;\n};\n\n/**\n * Result of `useSelectionHandler` hook.\n * @beta\n */\ninterface UseSelectionHandlerResult {\n /** Should be called by node renderer when a node component is clicked. */\n onNodeClick: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Should be called by node renderer when a keyboard event happens on a node. */\n onNodeKeyDown: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\ninterface FlatTreeState {\n flatNodeList: Array<string>;\n nodeIdToIndexMap: Map<string, number>;\n}\n\n/**\n * A react hook that helps implement different selection modes in a tree component created using `useTree` hook.\n * @beta\n */\nexport function useSelectionHandler(props: UseSelectionHandlerProps): UseSelectionHandlerResult {\n const { rootNodes, selectionMode, selectNodes } = props;\n const previousSelectionRef = useRef<string | undefined>(undefined);\n const state = useRef<FlatTreeState>({\n flatNodeList: [],\n nodeIdToIndexMap: new Map(),\n });\n\n useEffect(() => {\n if (!rootNodes) {\n return;\n }\n state.current = computeFlatNodeList(rootNodes);\n }, [rootNodes]);\n\n const getNodeRange = (firstId?: string, secondId?: string) => {\n const getIndex = (nodeId?: string) => {\n return nodeId ? state.current.nodeIdToIndexMap.get(nodeId) : 0;\n };\n const firstIndex = getIndex(firstId);\n const secondIndex = getIndex(secondId);\n if (firstIndex === undefined || secondIndex === undefined) {\n return [];\n }\n\n const startingIndex = Math.min(firstIndex, secondIndex);\n const endIndex = Math.max(firstIndex, secondIndex);\n return state.current.flatNodeList.slice(startingIndex, endIndex + 1);\n };\n\n const onNodeSelect = useCallback(\n (nodeId: string, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean) => {\n const selection = getSelectionAction(selectionMode, isSelected, shiftDown, ctrlDown);\n if (selection.type === \"disabled\") {\n return;\n }\n\n const nodes = selection.select === \"range\" ? getNodeRange(previousSelectionRef.current, nodeId) : [nodeId];\n if (!nodes.length) {\n return;\n }\n\n selection.select !== \"range\" && (previousSelectionRef.current = nodeId);\n selectNodes(nodes, selection.type);\n },\n [selectionMode, selectNodes],\n );\n\n const onNodeClick = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n },\n [onNodeSelect],\n );\n\n const onNodeKeyDown = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key === \" \" || event.key === \"Spacebar\" || event.key === \"Enter\") {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n }\n },\n [onNodeSelect],\n );\n\n return { onNodeClick, onNodeKeyDown };\n}\n\ninterface SelectionAction {\n select: \"node\" | \"range\";\n type: SelectionChangeType | \"disabled\";\n}\n\nfunction getSelectionAction(selectionMode: SelectionMode, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n switch (selectionMode) {\n case \"none\":\n return { select: \"node\", type: \"disabled\" };\n case \"single\":\n return { select: \"node\", type: isSelected ? \"replace\" : \"remove\" };\n case \"multiple\":\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n case \"extended\":\n return getExtendedSelectionAction(isSelected, shiftDown, ctrlDown);\n }\n}\n\nfunction getExtendedSelectionAction(isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n if (shiftDown) {\n return { select: \"range\", type: \"replace\" };\n }\n if (ctrlDown) {\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n }\n return { select: \"node\", type: isSelected ? \"replace\" : \"disabled\" };\n}\n\nfunction computeFlatNodeList(rootNodes: Array<PresentationTreeNode>): FlatTreeState {\n const flatNodeList: Array<string> = [];\n const nodeIdToIndexMap: Map<string, number> = new Map();\n\n const flattenNodeRecursively = (nodes: Array<PresentationTreeNode>) => {\n nodes.forEach((node) => {\n if (!isPresentationHierarchyNode(node)) {\n return;\n }\n nodeIdToIndexMap.set(node.id, flatNodeList.length);\n flatNodeList.push(node.id);\n if (node.isExpanded && typeof node.children !== \"boolean\") {\n flattenNodeRecursively(node.children);\n }\n });\n };\n\n flattenNodeRecursively(rootNodes);\n return { flatNodeList, nodeIdToIndexMap };\n}\n"]}
1
+ {"version":3,"file":"UseSelectionHandler.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAwDhG,kDAiEC;AAvHD,iCAAuD;AACvD,+CAA6G;AAiD7G;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACxD,MAAM,oBAAoB,GAAG,IAAA,cAAM,EAAqB,SAAS,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,IAAA,cAAM,EAAgB;QAClC,YAAY,EAAE,EAAE;QAChB,gBAAgB,EAAE,IAAI,GAAG,EAAE;KAC5B,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QACD,KAAK,CAAC,OAAO,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACjD,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,QAAiB,EAAE,EAAE;QAC3D,MAAM,QAAQ,GAAG,CAAC,MAAe,EAAE,EAAE;YACnC,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;QACF,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrC,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,UAAU,KAAK,SAA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CAAC;QACd,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC9C,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAsC;IACjE,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,EAAE,CAAC;IAExD,MAAM,sBAAsB,GAAG,CAAC,KAAkC,EAAE,EAAE;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,IAAA,yCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;gBACvC,OAAO;YACT,CAAC;YACD,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;YACnD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC1D,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC5C,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 { useCallback, useEffect, useRef } from \"react\";\nimport { isPresentationHierarchyNode, PresentationHierarchyNode, PresentationTreeNode } from \"./TreeNode.js\";\nimport { useTree } from \"./UseTree.js\";\n\n/**\n * A union of different supported selection modes in a tree component:\n * - `none` - no selection is allowed,\n * - `single` - only one node can be selected at a time,\n * - `extended` - multiple nodes can be selected using shift and ctrl keys,\n * - `multiple` - multiple nodes can be selected without using shift or ctrl keys.\n *\n * @public\n */\nexport type SelectionMode = \"none\" | \"single\" | \"extended\" | \"multiple\";\n\n/**\n * Type of selection change.\n * - `add` - a node was added to the selection,\n * - `replace` - a selected node was replaced with a different one,\n * - `remove` - a node was removed from the selection.\n *\n * @public\n */\nexport type SelectionChangeType = \"add\" | \"replace\" | \"remove\";\n\n/**\n * Props for `useSelectionHandler` hook.\n * @public\n */\ntype UseSelectionHandlerProps = Pick<ReturnType<typeof useTree>, \"rootNodes\" | \"selectNodes\"> & {\n /** Selection mode that the component is working in. */\n selectionMode: SelectionMode;\n};\n\n/**\n * Result of `useSelectionHandler` hook.\n * @public\n */\ninterface UseSelectionHandlerResult {\n /** Should be called by node renderer when a node component is clicked. */\n onNodeClick: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Should be called by node renderer when a keyboard event happens on a node. */\n onNodeKeyDown: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\ninterface FlatTreeState {\n flatNodeList: Array<string>;\n nodeIdToIndexMap: Map<string, number>;\n}\n\n/**\n * A react hook that helps implement different selection modes in a tree component created using `useTree` hook.\n * @public\n */\nexport function useSelectionHandler(props: UseSelectionHandlerProps): UseSelectionHandlerResult {\n const { rootNodes, selectionMode, selectNodes } = props;\n const previousSelectionRef = useRef<string | undefined>(undefined);\n const state = useRef<FlatTreeState>({\n flatNodeList: [],\n nodeIdToIndexMap: new Map(),\n });\n\n useEffect(() => {\n if (!rootNodes) {\n return;\n }\n state.current = computeFlatNodeList(rootNodes);\n }, [rootNodes]);\n\n const getNodeRange = (firstId?: string, secondId?: string) => {\n const getIndex = (nodeId?: string) => {\n return nodeId ? state.current.nodeIdToIndexMap.get(nodeId) : 0;\n };\n const firstIndex = getIndex(firstId);\n const secondIndex = getIndex(secondId);\n if (firstIndex === undefined || secondIndex === undefined) {\n return [];\n }\n\n const startingIndex = Math.min(firstIndex, secondIndex);\n const endIndex = Math.max(firstIndex, secondIndex);\n return state.current.flatNodeList.slice(startingIndex, endIndex + 1);\n };\n\n const onNodeSelect = useCallback(\n (nodeId: string, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean) => {\n const selection = getSelectionAction(selectionMode, isSelected, shiftDown, ctrlDown);\n if (selection.type === \"disabled\") {\n return;\n }\n\n const nodes = selection.select === \"range\" ? getNodeRange(previousSelectionRef.current, nodeId) : [nodeId];\n if (!nodes.length) {\n return;\n }\n\n selection.select !== \"range\" && (previousSelectionRef.current = nodeId);\n selectNodes(nodes, selection.type);\n },\n [selectionMode, selectNodes],\n );\n\n const onNodeClick = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n },\n [onNodeSelect],\n );\n\n const onNodeKeyDown = useCallback(\n (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key === \" \" || event.key === \"Spacebar\" || event.key === \"Enter\") {\n return onNodeSelect(node.id, isSelected, event.shiftKey, event.ctrlKey);\n }\n },\n [onNodeSelect],\n );\n\n return { onNodeClick, onNodeKeyDown };\n}\n\ninterface SelectionAction {\n select: \"node\" | \"range\";\n type: SelectionChangeType | \"disabled\";\n}\n\nfunction getSelectionAction(selectionMode: SelectionMode, isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n switch (selectionMode) {\n case \"none\":\n return { select: \"node\", type: \"disabled\" };\n case \"single\":\n return { select: \"node\", type: isSelected ? \"replace\" : \"remove\" };\n case \"multiple\":\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n case \"extended\":\n return getExtendedSelectionAction(isSelected, shiftDown, ctrlDown);\n }\n}\n\nfunction getExtendedSelectionAction(isSelected: boolean, shiftDown: boolean, ctrlDown: boolean): SelectionAction {\n if (shiftDown) {\n return { select: \"range\", type: \"replace\" };\n }\n if (ctrlDown) {\n return { select: \"node\", type: isSelected ? \"add\" : \"remove\" };\n }\n return { select: \"node\", type: isSelected ? \"replace\" : \"disabled\" };\n}\n\nfunction computeFlatNodeList(rootNodes: Array<PresentationTreeNode>): FlatTreeState {\n const flatNodeList: Array<string> = [];\n const nodeIdToIndexMap: Map<string, number> = new Map();\n\n const flattenNodeRecursively = (nodes: Array<PresentationTreeNode>) => {\n nodes.forEach((node) => {\n if (!isPresentationHierarchyNode(node)) {\n return;\n }\n nodeIdToIndexMap.set(node.id, flatNodeList.length);\n flatNodeList.push(node.id);\n if (node.isExpanded && typeof node.children !== \"boolean\") {\n flattenNodeRecursively(node.children);\n }\n });\n };\n\n flattenNodeRecursively(rootNodes);\n return { flatNodeList, nodeIdToIndexMap };\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { GenericInstanceFilter, HierarchyFilteringPath, HierarchyNode, HierarchyProvider } from "@itwin/presentation-hierarchies";
2
2
  import { InstanceKey, IPrimitiveValueFormatter } from "@itwin/presentation-shared";
3
- import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection";
4
- import { PresentationTreeNode } from "./TreeNode";
5
- import { SelectionChangeType } from "./UseSelectionHandler";
3
+ import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js";
4
+ import { PresentationTreeNode } from "./TreeNode.js";
5
+ import { SelectionChangeType } from "./UseSelectionHandler.js";
6
6
  /**
7
7
  * A data structure that contains information about a single hierarchy level.
8
- * @beta
8
+ * @public
9
9
  */
10
10
  export interface HierarchyLevelDetails {
11
11
  /** The parent node whose hierarchy level's information is contained in this data structure */
@@ -34,7 +34,7 @@ export interface HierarchyLevelDetails {
34
34
  *
35
35
  * @see `useUnifiedSelectionTree`
36
36
  * @see `useIModelTree`
37
- * @beta
37
+ * @public
38
38
  */
39
39
  export declare function useTree(props: UseTreeProps): UseTreeResult;
40
40
  /**
@@ -49,10 +49,10 @@ export declare function useTree(props: UseTreeProps): UseTreeResult;
49
49
  * @see `useTree`
50
50
  * @see `useIModelUnifiedSelectionTree`
51
51
  * @see `UnifiedSelectionProvider`
52
- * @beta
52
+ * @public
53
53
  */
54
54
  export declare function useUnifiedSelectionTree({ sourceName, ...props }: UseTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
55
- /** @beta */
55
+ /** @public */
56
56
  export interface UseTreeProps {
57
57
  /** Provides the hierarchy provider for the tree. */
58
58
  getHierarchyProvider: () => HierarchyProvider;
@@ -77,7 +77,7 @@ export interface UseTreeProps {
77
77
  }
78
78
  /**
79
79
  * Options for doing either full or a sub tree reload.
80
- * @beta
80
+ * @public
81
81
  */
82
82
  interface ReloadTreeOptions {
83
83
  /** Specifies parent node under which sub tree should be reloaded. */
@@ -92,7 +92,7 @@ interface ReloadTreeOptions {
92
92
  */
93
93
  state?: "keep" | "discard" | "reset";
94
94
  }
95
- /** @beta */
95
+ /** @public */
96
96
  export interface UseTreeResult {
97
97
  /**
98
98
  * Array containing root tree nodes. It is `undefined` on initial render until any nodes are loaded.
@@ -1 +1 @@
1
- {"version":3,"file":"UseTree.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseTree.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAClI,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGnF,OAAO,EAA2B,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACvG,O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,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D;;;;OAIG;IACH,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/E,mDAAmD;IACnD,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,2DAA2D;IAC3D,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,qBAAqB,GAAG,SAAS,CAAC;IAC5F,qFAAqF;IACrF,YAAY,EAAE,CAAC,SAAS,EAAE,wBAAwB,GAAG,SAAS,KAAK,IAAI,CAAC;CACzE"}
@@ -9,9 +9,9 @@ exports.useUnifiedSelectionTree = useUnifiedSelectionTree;
9
9
  const react_1 = require("react");
10
10
  const core_bentley_1 = require("@itwin/core-bentley");
11
11
  const presentation_hierarchies_1 = require("@itwin/presentation-hierarchies");
12
- const TreeActions_1 = require("./internal/TreeActions");
13
- const TreeModel_1 = require("./internal/TreeModel");
14
- const UseUnifiedSelection_1 = require("./internal/UseUnifiedSelection");
12
+ const TreeActions_js_1 = require("./internal/TreeActions.js");
13
+ const TreeModel_js_1 = require("./internal/TreeModel.js");
14
+ const UseUnifiedSelection_js_1 = require("./internal/UseUnifiedSelection.js");
15
15
  /**
16
16
  * A React hook that creates state for a tree component.
17
17
  *
@@ -22,7 +22,7 @@ const UseUnifiedSelection_1 = require("./internal/UseUnifiedSelection");
22
22
  *
23
23
  * @see `useUnifiedSelectionTree`
24
24
  * @see `useIModelTree`
25
- * @beta
25
+ * @public
26
26
  */
27
27
  function useTree(props) {
28
28
  const { getNode: _, ...rest } = useTreeInternal(props);
@@ -40,11 +40,11 @@ function useTree(props) {
40
40
  * @see `useTree`
41
41
  * @see `useIModelUnifiedSelectionTree`
42
42
  * @see `UnifiedSelectionProvider`
43
- * @beta
43
+ * @public
44
44
  */
45
45
  function useUnifiedSelectionTree({ sourceName, ...props }) {
46
46
  const { getNode, ...rest } = useTreeInternal(props);
47
- return { ...rest, ...(0, UseUnifiedSelection_1.useUnifiedTreeSelection)({ sourceName, getNode }) };
47
+ return { ...rest, ...(0, UseUnifiedSelection_js_1.useUnifiedTreeSelection)({ sourceName, getNode }) };
48
48
  }
49
49
  function useTreeInternal({ getHierarchyProvider, getFilteredPaths, onPerformanceMeasured, onHierarchyLimitExceeded, onHierarchyLoadError, }) {
50
50
  const [state, setState] = (0, react_1.useState)({
@@ -54,7 +54,7 @@ function useTreeInternal({ getHierarchyProvider, getFilteredPaths, onPerformance
54
54
  const onPerformanceMeasuredRef = useLatest(onPerformanceMeasured);
55
55
  const onHierarchyLimitExceededRef = useLatest(onHierarchyLimitExceeded);
56
56
  const onHierarchyLoadErrorRef = useLatest(onHierarchyLoadError);
57
- const [actions] = (0, react_1.useState)(() => new TreeActions_1.TreeActions((model) => {
57
+ const [actions] = (0, react_1.useState)(() => new TreeActions_js_1.TreeActions((model) => {
58
58
  const rootNodes = model.parentChildMap.get(undefined) !== undefined ? generateTreeStructure(undefined, model) : undefined;
59
59
  setState({
60
60
  model,
@@ -120,10 +120,10 @@ function useTreeInternal({ getHierarchyProvider, getFilteredPaths, onPerformance
120
120
  const selectNodes = (0, react_1.useCallback)((nodeIds, changeType) => {
121
121
  actions.selectNodes(nodeIds, changeType);
122
122
  }, [actions]);
123
- const isNodeSelected = (0, react_1.useCallback)((nodeId) => TreeModel_1.TreeModel.isNodeSelected(state.model, nodeId), [state]);
123
+ const isNodeSelected = (0, react_1.useCallback)((nodeId) => TreeModel_js_1.TreeModel.isNodeSelected(state.model, nodeId), [state]);
124
124
  const setFormatter = (0, react_1.useCallback)((formatter) => {
125
125
  currentFormatter.current = formatter;
126
- // istanbul ignore if
126
+ /* c8 ignore next 3 */
127
127
  if (!hierarchyProvider) {
128
128
  return;
129
129
  }
@@ -132,7 +132,7 @@ function useTreeInternal({ getHierarchyProvider, getFilteredPaths, onPerformance
132
132
  }, [hierarchyProvider, actions]);
133
133
  const getHierarchyLevelDetails = (0, react_1.useCallback)((nodeId) => {
134
134
  const node = actions.getNode(nodeId);
135
- if (!hierarchyProvider || !node || (0, TreeModel_1.isTreeModelInfoNode)(node)) {
135
+ if (!hierarchyProvider || !node || (0, TreeModel_js_1.isTreeModelInfoNode)(node)) {
136
136
  return undefined;
137
137
  }
138
138
  const hierarchyNode = node.nodeData;
@@ -173,7 +173,7 @@ function generateTreeStructure(parentNodeId, model) {
173
173
  .map((childId) => model.idToNode.get(childId))
174
174
  .filter((node) => !!node)
175
175
  .map((node) => {
176
- if ((0, TreeModel_1.isTreeModelHierarchyNode)(node)) {
176
+ if ((0, TreeModel_js_1.isTreeModelHierarchyNode)(node)) {
177
177
  const children = generateTreeStructure(node.id, model);
178
178
  return {
179
179
  ...toPresentationHierarchyNodeBase(node),