@itwin/presentation-hierarchies-react 2.0.0-alpha.6 → 2.0.0-alpha.60

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 (163) hide show
  1. package/CHANGELOG.md +1137 -11
  2. package/README.md +93 -160
  3. package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts +49 -0
  4. package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts.map +1 -0
  5. package/lib/presentation-hierarchies-react/FlatTreeNode.js +93 -0
  6. package/lib/presentation-hierarchies-react/FlatTreeNode.js.map +1 -0
  7. package/lib/presentation-hierarchies-react/LocalizationContext.d.ts +24 -0
  8. package/lib/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -0
  9. package/lib/presentation-hierarchies-react/LocalizationContext.js +40 -0
  10. package/lib/presentation-hierarchies-react/LocalizationContext.js.map +1 -0
  11. package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
  12. package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
  13. package/lib/presentation-hierarchies-react/TreeNode.d.ts +80 -0
  14. package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
  15. package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -15
  16. package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
  17. package/lib/presentation-hierarchies-react/UseIModelTree.js +183 -0
  18. package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
  19. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
  20. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
  21. package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +57 -0
  22. package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
  23. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +23 -0
  24. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
  25. package/lib/presentation-hierarchies-react/UseSelectionHandler.js +124 -0
  26. package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
  27. package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
  28. package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
  29. package/lib/presentation-hierarchies-react/UseTree.js +297 -0
  30. package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
  31. package/lib/presentation-hierarchies-react/Utils.js +56 -0
  32. package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
  33. package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
  34. package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
  35. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
  36. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
  37. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
  38. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
  39. package/lib/presentation-hierarchies-react/internal/TreeActions.js +294 -0
  40. package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
  41. package/lib/presentation-hierarchies-react/internal/TreeLoader.js +98 -0
  42. package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
  43. package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +1 -0
  44. package/lib/presentation-hierarchies-react/internal/TreeModel.js +120 -0
  45. package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
  46. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +35 -0
  47. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
  48. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +141 -0
  49. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
  50. package/lib/presentation-hierarchies-react/internal/Utils.js +42 -0
  51. package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
  52. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +38 -0
  53. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
  54. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +380 -0
  55. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
  56. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +27 -0
  57. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
  58. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +185 -0
  59. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
  60. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
  61. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
  62. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +88 -0
  63. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
  64. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
  65. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
  66. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +63 -0
  67. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
  68. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
  69. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
  70. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +91 -0
  71. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
  72. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +31 -0
  73. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
  74. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +155 -0
  75. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
  76. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.css +25 -0
  77. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +14 -0
  78. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
  79. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +534 -0
  80. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
  81. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
  82. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
  83. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +417 -0
  84. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
  85. package/lib/presentation-hierarchies-react-extract.d.ts +17 -0
  86. package/lib/presentation-hierarchies-react-extract.js +16 -0
  87. package/lib/presentation-hierarchies-react-stratakit.d.ts +8 -0
  88. package/lib/presentation-hierarchies-react-stratakit.js +8 -0
  89. package/lib/presentation-hierarchies-react.d.ts +11 -0
  90. package/lib/presentation-hierarchies-react.js +8 -0
  91. package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
  92. package/package.json +78 -56
  93. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +0 -75
  94. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
  95. package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -12
  96. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
  97. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
  98. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
  99. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
  100. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
  101. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
  102. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
  103. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
  104. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -46
  105. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
  106. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -98
  107. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
  108. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -132
  109. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
  110. package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -242
  111. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
  112. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
  113. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
  114. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
  115. package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
  116. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
  117. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
  118. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -307
  119. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
  120. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -44
  121. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
  122. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -94
  123. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
  124. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -70
  125. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
  126. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -153
  127. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
  128. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -28
  129. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
  130. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -128
  131. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
  132. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
  133. package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
  134. package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
  135. package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
  136. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts +0 -21
  137. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.d.ts.map +0 -1
  138. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js +0 -30
  139. package/lib/esm/presentation-hierarchies-react/itwinui/FlatTreeNode.js.map +0 -1
  140. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts +0 -73
  141. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
  142. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js +0 -34
  143. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
  144. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -25
  145. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
  146. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -40
  147. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
  148. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -23
  149. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
  150. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
  151. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
  152. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -40
  153. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
  154. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -80
  155. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
  156. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
  157. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
  158. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -48
  159. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
  160. package/lib/esm/presentation-hierarchies-react.d.ts +0 -13
  161. package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
  162. package/lib/esm/presentation-hierarchies-react.js +0 -16
  163. package/lib/esm/presentation-hierarchies-react.js.map +0 -1
@@ -0,0 +1,92 @@
1
+ import { ErrorInfo, TreeNode } from "./TreeNode.js";
2
+ import { SelectionChangeType } from "./UseSelectionHandler.js";
3
+ import { GenericInstanceFilter, HierarchyNode } from "@itwin/presentation-hierarchies";
4
+ import { InstanceKey } from "@itwin/presentation-shared";
5
+
6
+ //#region src/presentation-hierarchies-react/Renderers.d.ts
7
+ /**
8
+ * Type definition used to render tree rendering UI component.
9
+ * @alpha
10
+ */
11
+ type TreeRendererProps = {
12
+ /**
13
+ * Array containing root tree nodes.
14
+ */
15
+ rootNodes: TreeNode[];
16
+ /**
17
+ * A function that should be called to either expand or collapse the given node.
18
+ */
19
+ expandNode: (nodeId: string, isExpanded: boolean) => void;
20
+ /**
21
+ * A function that should be called to select nodes in the tree.
22
+ * @param nodeIds Ids of the nodes that are selected.
23
+ * @param changeType Type of change that occurred for the selection.
24
+ */
25
+ selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;
26
+ /**
27
+ * Determines whether a given node is selected.
28
+ */
29
+ isNodeSelected: (nodeId: string) => boolean;
30
+ } & CommonRendererProps;
31
+ /**
32
+ * Type definition used to render root error handling UI component.
33
+ * @alpha
34
+ */
35
+ type RootErrorRendererProps = {
36
+ /**
37
+ * Object containing root error information
38
+ */
39
+ error: ErrorInfo;
40
+ } & CommonRendererProps;
41
+ /**
42
+ * @alpha
43
+ */
44
+ interface CommonRendererProps {
45
+ /**
46
+ * A function that should be called to reload the tree.
47
+ */
48
+ reloadTree: (options?: ReloadTreeOptions) => void;
49
+ /** Returns hierarchy level details for a given node ID. */
50
+ getHierarchyLevelDetails: (nodeId: string | undefined) => HierarchyLevelDetails | undefined;
51
+ }
52
+ /**
53
+ * Options for doing either full or a sub tree reload.
54
+ * @public
55
+ */
56
+ interface ReloadTreeOptions {
57
+ /** Specifies parent node under which sub tree should be reloaded. */
58
+ parentNodeId: string | undefined;
59
+ /**
60
+ * Specifies how current tree state should be handled:
61
+ * - `keep` - try to keep current tree state (expanded/collapsed nodes, instance filters, etc.).
62
+ * - `discard` - do not try to keep current tree state. Tree model will be update after nodes are reloaded.
63
+ * - `reset` - remove subtree from the model before reloading and reload nodes ignoring cache.
64
+ *
65
+ * Defaults to `"keep"`.
66
+ */
67
+ state?: "keep" | "discard" | "reset";
68
+ }
69
+ /**
70
+ * A data structure that contains information about a single hierarchy level.
71
+ * @public
72
+ */
73
+ interface HierarchyLevelDetails {
74
+ /** The parent node whose hierarchy level's information is contained in this data structure */
75
+ hierarchyNode: HierarchyNode | undefined;
76
+ /** A function to get instance keys of the hierarchy level. */
77
+ getInstanceKeysIterator: (props?: {
78
+ instanceFilter?: GenericInstanceFilter;
79
+ hierarchyLevelSizeLimit?: number | "unbounded";
80
+ }) => AsyncIterableIterator<InstanceKey>;
81
+ /** Get the limit of how many nodes can be loaded in this hierarchy level. */
82
+ sizeLimit?: number | "unbounded";
83
+ /** Set the limit of how many nodes can be loaded in this hierarchy level. */
84
+ setSizeLimit: (value: undefined | number | "unbounded") => void;
85
+ /** Get the active instance filter applied to this hierarchy level. */
86
+ instanceFilter?: GenericInstanceFilter;
87
+ /** Set the instance filter to apply to this hierarchy level */
88
+ setInstanceFilter: (filter: GenericInstanceFilter | undefined) => void;
89
+ }
90
+ //#endregion
91
+ export { HierarchyLevelDetails, RootErrorRendererProps, TreeRendererProps };
92
+ //# sourceMappingURL=Renderers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Renderers.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/Renderers.ts"],"mappings":";;;;;;;;AAcA;;KAAY,iBAAA;EAIC;;;EAAX,SAAA,EAAW,QAAA;EAeU;;;EAXrB,UAAA,GAAa,MAAA,UAAgB,UAAA;EAA7B;;;;;EAMA,WAAA,GAAc,OAAA,EAAS,KAAA,UAAe,UAAA,EAAY,mBAAA;EAAA;;;EAIlD,cAAA,GAAiB,MAAA;AAAA,IACf,mBAAA;;;AAMJ;;KAAY,sBAAA;EAKW;;;EADrB,KAAA,EAAO,SAAA;AAAA,IACL,mBAAA;;AAAoB;;UAKd,mBAAA;EAMuE;;;EAF/E,UAAA,GAAa,OAAA,GAAU,iBAAA;EAEvB;EAAA,wBAAA,GAA2B,MAAA,yBAA+B,qBAAA;AAAA;;;AAAqB;;UAOvE,iBAAA;EAER;EAAA,YAAA;EAiBe;;;;;;;;EAPf,KAAA;AAAA;;;;;UAOe,qBAAA;EAMI;EAJnB,aAAA,EAAe,aAAA;EAGW;EAA1B,uBAAA,GAA0B,KAAA;IACxB,cAAA,GAAiB,qBAAA;IACjB,uBAAA;EAAA,MACI,qBAAA,CAAsB,WAAA;EAKb;EAFf,SAAA;EAKiB;EAHjB,YAAA,GAAe,KAAA;EAKa;EAF5B,cAAA,GAAiB,qBAAA;EAE4C;EAA7D,iBAAA,GAAoB,MAAA,EAAQ,qBAAA;AAAA"}
@@ -0,0 +1,80 @@
1
+ import { HierarchyNode } from "@itwin/presentation-hierarchies";
2
+
3
+ //#region src/presentation-hierarchies-react/TreeNode.d.ts
4
+ /**
5
+ * A type that defines an node in a UI tree component, built with `useTree` hook.
6
+ * @public
7
+ */
8
+ interface TreeNode {
9
+ id: string;
10
+ label: string;
11
+ children: true | Array<TreeNode>;
12
+ isExpanded: boolean;
13
+ isLoading: boolean;
14
+ isFilterable: boolean;
15
+ isFiltered: boolean;
16
+ /** UI-agnostic source of this node object. */
17
+ nodeData: HierarchyNode;
18
+ /** Contains error encountered from expanding the node */
19
+ error?: ErrorInfo;
20
+ }
21
+ /**
22
+ * A type of `ErrorInfo` that is returned,
23
+ * when none of the child nodes match the filter.
24
+ *
25
+ * @public
26
+ */
27
+ interface NoFilterMatchesErrorInfo {
28
+ id: string;
29
+ type: "NoFilterMatches";
30
+ }
31
+ /**
32
+ * A type of `ErrorInfo` that is returned, when the
33
+ * number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included
34
+ * on this error as `resultSetSizeLimit` attribute.
35
+ *
36
+ * @public
37
+ */
38
+ interface ResultSetTooLargeErrorInfo {
39
+ id: string;
40
+ type: "ResultSetTooLarge";
41
+ resultSetSizeLimit: number;
42
+ }
43
+ /**
44
+ * A type of `ErrorInfo` that contains a user-friendly message to be displayed in the UI.
45
+ * Created in cases like an error loading children. The
46
+ * renderer may offer users to re-load the children or the whole component in such cases.
47
+ *
48
+ * @public
49
+ */
50
+ interface ChildrenLoadErrorInfo {
51
+ id: string;
52
+ type: "ChildrenLoad";
53
+ message: string;
54
+ }
55
+ /**
56
+ * A type of `ErrorInfo` that can be used to show/handle generic errors,
57
+ * that might not be directly caused by the tree components. (e.g. tree components
58
+ * shows hierarchy of connections to external systems and an error is show in the
59
+ * tree when some connections are unreachable).
60
+ *
61
+ * @public
62
+ */
63
+ interface GenericErrorInfo {
64
+ id: string;
65
+ type: "Unknown";
66
+ message: string;
67
+ /** Allows node expansion even when this error is present. */
68
+ isNodeExpandable?: boolean;
69
+ additionalData?: unknown;
70
+ }
71
+ /**
72
+ * A collection of types that defines an error state for `TreeNode` node in a UI tree component, built
73
+ * with `useTree` hook.
74
+ *
75
+ * @public
76
+ */
77
+ type ErrorInfo = GenericErrorInfo | ResultSetTooLargeErrorInfo | NoFilterMatchesErrorInfo | ChildrenLoadErrorInfo;
78
+ //#endregion
79
+ export { ErrorInfo, GenericErrorInfo, ResultSetTooLargeErrorInfo, TreeNode };
80
+ //# sourceMappingURL=TreeNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TreeNode.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/TreeNode.ts"],"mappings":";;;;;AAWA;;UAAiB,QAAA;EACf,EAAA;EACA,KAAA;EACA,QAAA,SAAiB,KAAA,CAAM,QAAA;EACvB,UAAA;EACA,SAAA;EACA,YAAA;EACA,UAAA;EALA;EAOA,QAAA,EAAU,aAAA;EANO;EAQjB,KAAA,GAAQ,SAAA;AAAA;;;;;;;UASO,wBAAA;EACf,EAAA;EACA,IAAA;AAAA;;;;;AAUF;;;UAAiB,0BAAA;EACf,EAAA;EACA,IAAA;EACA,kBAAA;AAAA;;AAUF;;;;;;UAAiB,qBAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;AAAA;;;;;;;;;UAWe,gBAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EAaE;EAXF,gBAAA;EACA,cAAA;AAAA;;;;;;;KASU,SAAA,GACR,gBAAA,GACA,0BAAA,GACA,wBAAA,GACA,qBAAA"}
@@ -1,7 +1,9 @@
1
- import { createIModelHierarchyProvider, HierarchyDefinition, HierarchyFilteringPath } from "@itwin/presentation-hierarchies";
2
- import { Props } from "@itwin/presentation-shared";
3
1
  import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js";
4
2
  import { UseTreeProps, UseTreeResult } from "./UseTree.js";
3
+ import { HierarchyDefinition, HierarchySearchTree, createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
4
+ import { Props } from "@itwin/presentation-shared";
5
+
6
+ //#region src/presentation-hierarchies-react/UseIModelTree.d.ts
5
7
  /** @public */
6
8
  type IModelHierarchyProviderProps = Props<typeof createIModelHierarchyProvider>;
7
9
  /** @public */
@@ -10,16 +12,26 @@ type IModelAccess = IModelHierarchyProviderProps["imodelAccess"];
10
12
  * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.
11
13
  * @public
12
14
  */
13
- type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getFilteredPaths"> & Pick<IModelHierarchyProviderProps, "localizedStrings" | "imodelAccess" | "imodelChanged"> & {
14
- /** Provides the hierarchy definition for the tree. */
15
- getHierarchyDefinition: (props: {
16
- imodelAccess: IModelAccess;
17
- }) => HierarchyDefinition;
18
- /** Provides paths to filtered nodes. */
19
- getFilteredPaths?: (props: {
20
- /** Object that provides access to the iModel schema and can run queries against the iModel. */
21
- imodelAccess: IModelAccess;
22
- }) => Promise<HierarchyFilteringPath[] | undefined>;
15
+ type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getSearchPaths"> & Pick<IModelHierarchyProviderProps, "imodelAccess" | "imodelChanged"> & {
16
+ /**
17
+ * Provides the hierarchy definition for the tree.
18
+ */
19
+ getHierarchyDefinition: (props: {
20
+ imodelAccess: IModelAccess;
21
+ }) => HierarchyDefinition;
22
+ /**
23
+ * Provides paths to target nodes.
24
+ */
25
+ getSearchPaths?: (props: {
26
+ /**
27
+ * Object that provides access to the iModel schema and can run queries against the iModel.
28
+ */
29
+ imodelAccess: IModelAccess;
30
+ /**
31
+ * Signal indicating that that the request was canceled
32
+ */
33
+ abortSignal: AbortSignal;
34
+ }) => Promise<HierarchySearchTree[] | undefined>;
23
35
  };
24
36
  /**
25
37
  * A React hook that creates state for a tree component whose displayed hierarchy is based on
@@ -34,7 +46,7 @@ type UseIModelTreeProps = Omit<UseTreeProps, "getHierarchyProvider" | "getFilter
34
46
  * @see `useIModelUnifiedSelectionTree`
35
47
  * @public
36
48
  */
37
- export declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
49
+ declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
38
50
  /**
39
51
  * A React hook that creates state for a tree component whose displayed hierarchy is based on
40
52
  * iModel data and that is integrated with unified selection through the given selection
@@ -50,6 +62,7 @@ export declare function useIModelTree(props: UseIModelTreeProps): UseTreeResult;
50
62
  * @see `UnifiedSelectionProvider`
51
63
  * @public
52
64
  */
53
- export declare function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
54
- export {};
65
+ declare function useIModelUnifiedSelectionTree(props: UseIModelTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
66
+ //#endregion
67
+ export { useIModelTree, useIModelUnifiedSelectionTree };
55
68
  //# sourceMappingURL=UseIModelTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseIModelTree.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseIModelTree.ts"],"mappings":";;;;;;;KAgBK,4BAAA,GAA+B,KAAA,QAAa,6BAAA;;KAG5C,YAAA,GAAe,4BAAA;;;AAH0D;;KASzE,kBAAA,GAAqB,IAAA,CAAK,YAAA,+CAC7B,IAAA,CAAK,4BAAA;EAPa;;AAA4B;EAW5C,sBAAA,GAAyB,KAAA;IAAS,YAAA,EAAc,YAAA;EAAA,MAAmB,mBAAA;EAL7C;;;EAUtB,cAAA,IAAkB,KAAA;IALiD;;;IASjE,YAAA,EAAc,YAAA;IAKV;;;IADJ,WAAA,EAAa,WAAA;EAAA,MACT,OAAA,CAAQ,mBAAA;AAAA;;;;;;;;;;;;;;iBAgBF,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAqB,aAAA;;;AAA1D;;;;;;;;;AAuBA;;;;iBAAgB,6BAAA,CAA8B,KAAA,EAAO,kBAAA,GAAqB,4BAAA,GAA+B,aAAA"}
@@ -0,0 +1,183 @@
1
+ import { useTree, useUnifiedSelectionTree } from "./UseTree.js";
2
+ import { useTranslation } from "./LocalizationContext.js";
3
+ import { c } from "react-compiler-runtime";
4
+ import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
5
+ //#region src/presentation-hierarchies-react/UseIModelTree.ts
6
+ /**
7
+ * A React hook that creates state for a tree component whose displayed hierarchy is based on
8
+ * iModel data.
9
+ *
10
+ * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
11
+ * component-agnostic result which may be used to render the hierarchy using any UI framework.
12
+ *
13
+ * See `README.md` for an example
14
+ *
15
+ * @see `useTree`
16
+ * @see `useIModelUnifiedSelectionTree`
17
+ * @public
18
+ */
19
+ function useIModelTree(props) {
20
+ const $ = c(14);
21
+ let getHierarchyDefinition;
22
+ let getSearchPaths;
23
+ let imodelAccess;
24
+ let imodelChanged;
25
+ let rest;
26
+ if ($[0] !== props) {
27
+ ({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest} = props);
28
+ $[0] = props;
29
+ $[1] = getHierarchyDefinition;
30
+ $[2] = getSearchPaths;
31
+ $[3] = imodelAccess;
32
+ $[4] = imodelChanged;
33
+ $[5] = rest;
34
+ } else {
35
+ getHierarchyDefinition = $[1];
36
+ getSearchPaths = $[2];
37
+ imodelAccess = $[3];
38
+ imodelChanged = $[4];
39
+ rest = $[5];
40
+ }
41
+ let t0;
42
+ if ($[6] !== getHierarchyDefinition || $[7] !== getSearchPaths || $[8] !== imodelAccess || $[9] !== imodelChanged) {
43
+ t0 = {
44
+ imodelAccess,
45
+ imodelChanged,
46
+ getHierarchyDefinition,
47
+ getSearchPaths
48
+ };
49
+ $[6] = getHierarchyDefinition;
50
+ $[7] = getSearchPaths;
51
+ $[8] = imodelAccess;
52
+ $[9] = imodelChanged;
53
+ $[10] = t0;
54
+ } else t0 = $[10];
55
+ const t1 = useIModelTreeProps(t0);
56
+ let t2;
57
+ if ($[11] !== rest || $[12] !== t1) {
58
+ t2 = {
59
+ ...rest,
60
+ ...t1
61
+ };
62
+ $[11] = rest;
63
+ $[12] = t1;
64
+ $[13] = t2;
65
+ } else t2 = $[13];
66
+ return useTree(t2);
67
+ }
68
+ /**
69
+ * A React hook that creates state for a tree component whose displayed hierarchy is based on
70
+ * iModel data and that is integrated with unified selection through the given selection
71
+ * storage (previously the storage was provided through the, now deprecated, `UnifiedSelectionProvider`).
72
+ *
73
+ * The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
74
+ * component-agnostic result which may be used to render the hierarchy using any UI framework.
75
+ *
76
+ * See `README.md` for an example
77
+ *
78
+ * @see `useIModelTree`
79
+ * @see `useUnifiedSelectionTree`
80
+ * @see `UnifiedSelectionProvider`
81
+ * @public
82
+ */
83
+ function useIModelUnifiedSelectionTree(props) {
84
+ const $ = c(14);
85
+ let getHierarchyDefinition;
86
+ let getSearchPaths;
87
+ let imodelAccess;
88
+ let imodelChanged;
89
+ let rest;
90
+ if ($[0] !== props) {
91
+ ({imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, ...rest} = props);
92
+ $[0] = props;
93
+ $[1] = getHierarchyDefinition;
94
+ $[2] = getSearchPaths;
95
+ $[3] = imodelAccess;
96
+ $[4] = imodelChanged;
97
+ $[5] = rest;
98
+ } else {
99
+ getHierarchyDefinition = $[1];
100
+ getSearchPaths = $[2];
101
+ imodelAccess = $[3];
102
+ imodelChanged = $[4];
103
+ rest = $[5];
104
+ }
105
+ let t0;
106
+ if ($[6] !== getHierarchyDefinition || $[7] !== getSearchPaths || $[8] !== imodelAccess || $[9] !== imodelChanged) {
107
+ t0 = {
108
+ imodelAccess,
109
+ imodelChanged,
110
+ getHierarchyDefinition,
111
+ getSearchPaths
112
+ };
113
+ $[6] = getHierarchyDefinition;
114
+ $[7] = getSearchPaths;
115
+ $[8] = imodelAccess;
116
+ $[9] = imodelChanged;
117
+ $[10] = t0;
118
+ } else t0 = $[10];
119
+ const t1 = useIModelTreeProps(t0);
120
+ let t2;
121
+ if ($[11] !== rest || $[12] !== t1) {
122
+ t2 = {
123
+ ...rest,
124
+ ...t1
125
+ };
126
+ $[11] = rest;
127
+ $[12] = t1;
128
+ $[13] = t2;
129
+ } else t2 = $[13];
130
+ return useUnifiedSelectionTree(t2);
131
+ }
132
+ function useIModelTreeProps(props) {
133
+ const $ = c(11);
134
+ const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths } = props;
135
+ const translate = useTranslation();
136
+ let t0;
137
+ if ($[0] !== getHierarchyDefinition || $[1] !== imodelAccess || $[2] !== imodelChanged || $[3] !== translate) {
138
+ t0 = () => createIModelHierarchyProvider({
139
+ imodelAccess,
140
+ imodelChanged,
141
+ hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),
142
+ localizedStrings: {
143
+ other: translate("other"),
144
+ unspecified: translate("unspecified")
145
+ }
146
+ });
147
+ $[0] = getHierarchyDefinition;
148
+ $[1] = imodelAccess;
149
+ $[2] = imodelChanged;
150
+ $[3] = translate;
151
+ $[4] = t0;
152
+ } else t0 = $[4];
153
+ const t1 = t0;
154
+ let t2;
155
+ if ($[5] !== getSearchPaths || $[6] !== imodelAccess) {
156
+ t2 = async (t3) => {
157
+ const { abortSignal } = t3;
158
+ return getSearchPaths?.({
159
+ imodelAccess,
160
+ abortSignal
161
+ });
162
+ };
163
+ $[5] = getSearchPaths;
164
+ $[6] = imodelAccess;
165
+ $[7] = t2;
166
+ } else t2 = $[7];
167
+ const t3 = t2;
168
+ let t4;
169
+ if ($[8] !== t1 || $[9] !== t3) {
170
+ t4 = {
171
+ getHierarchyProvider: t1,
172
+ getSearchPaths: t3
173
+ };
174
+ $[8] = t1;
175
+ $[9] = t3;
176
+ $[10] = t4;
177
+ } else t4 = $[10];
178
+ return t4;
179
+ }
180
+ //#endregion
181
+ export { useIModelTree, useIModelUnifiedSelectionTree };
182
+
183
+ //# sourceMappingURL=UseIModelTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseIModelTree.js","names":["useCallback","createIModelHierarchyProvider","useTranslation","useTree","useUnifiedSelectionTree","HierarchyDefinition","HierarchySearchTree","Props","UseUnifiedTreeSelectionProps","UseTreeProps","UseTreeResult","IModelHierarchyProviderProps","IModelAccess","UseIModelTreeProps","Omit","Pick","getHierarchyDefinition","props","imodelAccess","getSearchPaths","abortSignal","AbortSignal","Promise","useIModelTree","$","_c","imodelChanged","rest","t0","t1","useIModelTreeProps","t2","useIModelUnifiedSelectionTree","translate","hierarchyDefinition","localizedStrings","other","unspecified","t3","t4","getHierarchyProvider"],"sources":["../../src/presentation-hierarchies-react/UseIModelTree.ts"],"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 } from \"@itwin/presentation-hierarchies\";\nimport { useTranslation } from \"./LocalizationContext.js\";\nimport { useTree, useUnifiedSelectionTree } from \"./UseTree.js\";\n\nimport type { HierarchyDefinition, HierarchySearchTree } from \"@itwin/presentation-hierarchies\";\nimport type { Props } from \"@itwin/presentation-shared\";\nimport type { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport type { UseTreeProps, UseTreeResult } from \"./UseTree.js\";\n\n/** @public */\ntype IModelHierarchyProviderProps = Props<typeof createIModelHierarchyProvider>;\n\n/** @public */\ntype IModelAccess = IModelHierarchyProviderProps[\"imodelAccess\"];\n\n/**\n * Props for `useIModelTree` and `useIModelUnifiedSelectionTree` hooks.\n * @public\n */\ntype UseIModelTreeProps = Omit<UseTreeProps, \"getHierarchyProvider\" | \"getSearchPaths\"> &\n Pick<IModelHierarchyProviderProps, \"imodelAccess\" | \"imodelChanged\"> & {\n /**\n * Provides the hierarchy definition for the tree.\n */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /**\n * Provides paths to target nodes.\n */\n getSearchPaths?: (props: {\n /**\n * Object that provides access to the iModel schema and can run queries against the iModel.\n */\n imodelAccess: IModelAccess;\n /**\n * Signal indicating that that the request was canceled\n */\n abortSignal: AbortSignal;\n }) => Promise<HierarchySearchTree[] | 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, getSearchPaths, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths }),\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 the given selection\n * storage (previously the storage was provided through the, now deprecated, `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, getSearchPaths, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getSearchPaths\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getSearchPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths } = props;\n const translate = useTranslation();\n return {\n getHierarchyProvider: useCallback(\n () =>\n createIModelHierarchyProvider({\n imodelAccess,\n imodelChanged,\n hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),\n localizedStrings: { other: translate(\"other\"), unspecified: translate(\"unspecified\") },\n }),\n [imodelAccess, imodelChanged, translate, getHierarchyDefinition],\n ),\n getSearchPaths: useCallback(\n async ({ abortSignal }: { abortSignal: AbortSignal }) => getSearchPaths?.({ imodelAccess, abortSignal }),\n [imodelAccess, getSearchPaths],\n ),\n };\n}\n"],"mappings":"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"}
@@ -0,0 +1,30 @@
1
+ import { TreeNode } from "./TreeNode.js";
2
+ import { ReactElement } from "react";
3
+
4
+ //#region src/presentation-hierarchies-react/UseNodeHighlighting.d.ts
5
+ /**
6
+ * Props for `useNodeHighlighting` hook.
7
+ * @alpha
8
+ */
9
+ interface UseNodeHighlightingProps {
10
+ /** Text that should be highlighted */
11
+ highlightText?: string;
12
+ }
13
+ /**
14
+ * Result of `useNodeHighlighting` hook.
15
+ * @alpha
16
+ */
17
+ interface UseNodeHighlightingResult {
18
+ /** Function that creates highlighted node labels. */
19
+ getLabel: (node: TreeNode) => ReactElement;
20
+ }
21
+ /**
22
+ * A react hook that helps create highlighted node labels based on provided highlight.
23
+ * @alpha
24
+ */
25
+ declare function useNodeHighlighting({
26
+ highlightText
27
+ }: UseNodeHighlightingProps): UseNodeHighlightingResult;
28
+ //#endregion
29
+ export { useNodeHighlighting };
30
+ //# sourceMappingURL=UseNodeHighlighting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseNodeHighlighting.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"mappings":";;;;;;AAS8C;;UAMpC,wBAAA;EAER;EAAA,aAAA;AAAA;;;;;UAOQ,yBAAA;EAEG;EAAX,QAAA,GAAW,IAAA,EAAM,QAAA,KAAa,YAAA;AAAA;;AAOhC;;;iBAAgB,mBAAA,CAAA;EAAsB;AAAA,GAAiB,wBAAA,GAA2B,yBAAA"}
@@ -0,0 +1,57 @@
1
+ import { c } from "react-compiler-runtime";
2
+ import { HierarchyNode } from "@itwin/presentation-hierarchies";
3
+ import { Fragment, jsx } from "react/jsx-runtime";
4
+ //#region src/presentation-hierarchies-react/UseNodeHighlighting.tsx
5
+ /**
6
+ * A react hook that helps create highlighted node labels based on provided highlight.
7
+ * @alpha
8
+ */
9
+ function useNodeHighlighting(t0) {
10
+ const $ = c(4);
11
+ const { highlightText } = t0;
12
+ let t1;
13
+ if ($[0] !== highlightText) {
14
+ t1 = (node) => {
15
+ if (!highlightText || HierarchyNode.isGroupingNode(node.nodeData) || !node.nodeData.search?.isSearchTarget) return /* @__PURE__ */ jsx("span", { children: node.label });
16
+ const matchedIndexes = new Array();
17
+ const nodeLabel = node.label.toLocaleLowerCase();
18
+ const searchText = highlightText.toLocaleLowerCase();
19
+ let fromPosition = 0;
20
+ while (true) {
21
+ const foundIndex = nodeLabel.indexOf(searchText, fromPosition);
22
+ if (foundIndex === -1) break;
23
+ matchedIndexes.push(foundIndex);
24
+ fromPosition = foundIndex + searchText.length;
25
+ }
26
+ if (matchedIndexes.length === 0) return /* @__PURE__ */ jsx("span", { children: node.label });
27
+ const finalLabel = new Array();
28
+ let lastAddedPosition = 0;
29
+ for (let i = 0; i < matchedIndexes.length; ++i) {
30
+ const matchedIndex = matchedIndexes[i];
31
+ if (matchedIndex > lastAddedPosition) {
32
+ finalLabel.push(/* @__PURE__ */ jsx("span", { children: node.label.substring(lastAddedPosition, matchedIndex) }, `normal-${i}`));
33
+ lastAddedPosition = matchedIndex;
34
+ }
35
+ const endingPlace = matchedIndex + highlightText.length;
36
+ finalLabel.push(/* @__PURE__ */ jsx("mark", { children: node.label.substring(lastAddedPosition, endingPlace) }, `marked-${i}`));
37
+ lastAddedPosition = endingPlace;
38
+ }
39
+ if (lastAddedPosition < node.label.length) finalLabel.push(/* @__PURE__ */ jsx("span", { children: node.label.substring(lastAddedPosition) }, `normal-${matchedIndexes.length + 1}`));
40
+ return /* @__PURE__ */ jsx(Fragment, { children: finalLabel });
41
+ };
42
+ $[0] = highlightText;
43
+ $[1] = t1;
44
+ } else t1 = $[1];
45
+ const getLabel = t1;
46
+ let t2;
47
+ if ($[2] !== getLabel) {
48
+ t2 = { getLabel };
49
+ $[2] = getLabel;
50
+ $[3] = t2;
51
+ } else t2 = $[3];
52
+ return t2;
53
+ }
54
+ //#endregion
55
+ export { useNodeHighlighting };
56
+
57
+ //# sourceMappingURL=UseNodeHighlighting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseNodeHighlighting.js","names":["useCallback","HierarchyNode","JSX","ReactElement","TreeNode","UseNodeHighlightingProps","highlightText","UseNodeHighlightingResult","getLabel","node","useNodeHighlighting","t0","$","_c","t1","isGroupingNode","nodeData","search","isSearchTarget","label","matchedIndexes","Array","nodeLabel","toLocaleLowerCase","searchText","fromPosition","foundIndex","indexOf","push","length","finalLabel","lastAddedPosition","i","matchedIndex","substring","endingPlace","t2"],"sources":["../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"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 { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\nimport type { JSX, ReactElement } from \"react\";\nimport type { TreeNode } from \"./TreeNode.js\";\n\n/**\n * Props for `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingProps {\n /** Text that should be highlighted */\n highlightText?: string;\n}\n\n/**\n * Result of `useNodeHighlighting` hook.\n * @alpha\n */\ninterface UseNodeHighlightingResult {\n /** Function that creates highlighted node labels. */\n getLabel: (node: TreeNode) => ReactElement;\n}\n\n/**\n * A react hook that helps create highlighted node labels based on provided highlight.\n * @alpha\n */\nexport function useNodeHighlighting({ highlightText }: UseNodeHighlightingProps): UseNodeHighlightingResult {\n const getLabel = useCallback(\n (node: TreeNode) => {\n if (!highlightText || HierarchyNode.isGroupingNode(node.nodeData) || !node.nodeData.search?.isSearchTarget) {\n return <span>{node.label}</span>;\n }\n\n const matchedIndexes = new Array<number>();\n const nodeLabel = node.label.toLocaleLowerCase();\n const searchText = highlightText.toLocaleLowerCase();\n let fromPosition = 0;\n // Find all occurrences of the search text in the node label\n while (true) {\n const foundIndex = nodeLabel.indexOf(searchText, fromPosition);\n if (foundIndex === -1) {\n break;\n }\n matchedIndexes.push(foundIndex);\n fromPosition = foundIndex + searchText.length;\n }\n\n if (matchedIndexes.length === 0) {\n return <span>{node.label}</span>;\n }\n\n // Create the final label with highlighted parts\n const finalLabel = new Array<JSX.Element>();\n let lastAddedPosition = 0;\n for (let i = 0; i < matchedIndexes.length; ++i) {\n const matchedIndex = matchedIndexes[i];\n if (matchedIndex > lastAddedPosition) {\n finalLabel.push(<span key={`normal-${i}`}>{node.label.substring(lastAddedPosition, matchedIndex)}</span>);\n lastAddedPosition = matchedIndex;\n }\n const endingPlace = matchedIndex + highlightText.length;\n finalLabel.push(<mark key={`marked-${i}`}>{node.label.substring(lastAddedPosition, endingPlace)}</mark>);\n lastAddedPosition = endingPlace;\n }\n if (lastAddedPosition < node.label.length) {\n finalLabel.push(\n <span key={`normal-${matchedIndexes.length + 1}`}>{node.label.substring(lastAddedPosition)}</span>,\n );\n }\n\n return <>{finalLabel}</>;\n },\n [highlightText],\n );\n\n return { getLabel };\n}\n"],"mappings":";;;;;;;;AAiCA,SAAOU,oBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA6B,MAAA,EAAAP,kBAAAK;CAA2C,IAAAG;AAAA,KAAAF,EAAA,OAAAN,eAAA;AAE3EQ,QAAAL,SAAA;AACE,OAAI,CAACH,iBAAiBL,cAAac,eAAgBN,KAAIO,SAAmD,IAAtG,CAAkEP,KAAIO,SAASC,QAAuBC,eAAA,QACjG,oBAAA,QAAA,EAAA,UAAOT,KAAIU,OAAc,CAAA;GAGlC,MAAAC,iBAAuB,IAAIC,OAAe;GAC1C,MAAAC,YAAkBb,KAAIU,MAAMI,mBAAoB;GAChD,MAAAC,aAAmBlB,cAAaiB,mBAAoB;GACpD,IAAAE,eAAmB;AAEnB,UAAO,MAAI;IACT,MAAAC,aAAmBJ,UAASK,QAASH,YAAYC,aAAa;AAC9D,QAAIC,eAAe,GACjB;AAEFN,mBAAcQ,KAAMF,WAAW;AAC/BD,mBAAeC,aAAaF,WAAUK;;AAGxC,OAAIT,eAAcS,WAAY,EAAC,QACtB,oBAAA,QAAA,EAAA,UAAOpB,KAAIU,OAAc,CAAA;GAIlC,MAAAW,aAAmB,IAAIT,OAAoB;GAC3C,IAAAU,oBAAwB;AACxB,QAAA,IAAAC,IAAa,GAAGA,IAAIZ,eAAcS,QAAS,EAAEG,GAAC;IAC5C,MAAAC,eAAqBb,eAAeY;AACpC,QAAIC,eAAeF,mBAAiB;AAClCD,gBAAUF,KAAM,oBAAA,QAAA,EAAA,UAA2BnB,KAAIU,MAAMe,UAAWH,mBAAmBE,aAAY,EAAS,EAA7E,UAAUD,IAAmE,CAAC;AACzGD,yBAAoBE;;IAEtB,MAAAE,cAAoBF,eAAe3B,cAAauB;AAChDC,eAAUF,KAAM,oBAAA,QAAA,EAAA,UAA2BnB,KAAIU,MAAMe,UAAWH,mBAAmBI,YAAW,EAAS,EAA5E,UAAUH,IAAkE,CAAC;AACxGD,wBAAoBI;;AAEtB,OAAIJ,oBAAoBtB,KAAIU,MAAMU,OAChCC,YAAUF,KACR,oBAAA,QAAA,EAAA,UAAmDnB,KAAIU,MAAMe,UAAWH,kBAAiB,EAC3F,EADa,UAAUX,eAAcS,SAAU,IAC/C,CAAC;AACF,UAEM,oBAAA,UAAA,EAAA,UAAGC,YAAc,CAAA;;AACzBlB,IAAA,KAAAN;AAAAM,IAAA,KAAAE;OAAAA,MAAAF,EAAA;CA5CH,MAAAJ,WAAiBM;CA8Cf,IAAAsB;AAAA,KAAAxB,EAAA,OAAAJ,UAAA;AAEK4B,OAAA,EAAA5B,UAAY;AAAAI,IAAA,KAAAJ;AAAAI,IAAA,KAAAwB;OAAAA,MAAAxB,EAAA;AAAA,QAAZwB"}
@@ -0,0 +1,23 @@
1
+ //#region src/presentation-hierarchies-react/UseSelectionHandler.d.ts
2
+ /**
3
+ * A union of different supported selection modes in a tree component:
4
+ * - `none` - no selection is allowed,
5
+ * - `single` - only one node can be selected at a time,
6
+ * - `extended` - multiple nodes can be selected using shift and ctrl keys,
7
+ * - `multiple` - multiple nodes can be selected without using shift or ctrl keys.
8
+ *
9
+ * @public
10
+ */
11
+ type SelectionMode = "none" | "single" | "extended" | "multiple";
12
+ /**
13
+ * Type of selection change.
14
+ * - `add` - a node was added to the selection,
15
+ * - `replace` - a selected node was replaced with a different one,
16
+ * - `remove` - a node was removed from the selection.
17
+ *
18
+ * @public
19
+ */
20
+ type SelectionChangeType = "add" | "replace" | "remove";
21
+ //#endregion
22
+ export { SelectionChangeType, SelectionMode };
23
+ //# sourceMappingURL=UseSelectionHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseSelectionHandler.d.ts","names":[],"sources":["../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"mappings":";;;AAmBA;;;;;AAUA;;KAVY,aAAA;;;;;;;;;KAUA,mBAAA"}