@itwin/presentation-hierarchies-react 2.0.0-alpha.53 → 2.0.0-alpha.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/README.md +23 -61
- package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts +33 -29
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -17
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js +184 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +58 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +25 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js +125 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.js +294 -0
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js +56 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js +295 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js +99 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js +120 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +37 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +142 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js +43 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +381 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.d.ts +16 -15
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js +91 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +24 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js +41 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +27 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +186 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +89 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +64 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +92 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +33 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +156 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +18 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +535 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +418 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react.d.ts +18 -0
- package/lib/presentation-hierarchies-react.js +16 -0
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +27 -21
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +0 -85
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
- package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +0 -24
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +0 -53
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -48
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -83
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -94
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -241
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.js +0 -39
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -322
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -90
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -47
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -157
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -42
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -115
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +0 -27
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +0 -74
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +0 -73
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +0 -138
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +0 -47
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +0 -16
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +0 -42
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +0 -45
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +0 -36
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +0 -20
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +0 -29
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +0 -57
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +0 -71
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +0 -46
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +0 -133
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +0 -75
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +0 -193
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +0 -17
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js +0 -18
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.css +0 -0
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { GenericInstanceFilter, HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
2
|
-
import { InstanceKey } from "@itwin/presentation-shared";
|
|
3
|
-
import { ErrorInfo, TreeNode } from "./TreeNode.js";
|
|
4
|
-
import { SelectionChangeType } from "./UseSelectionHandler.js";
|
|
5
|
-
/**
|
|
6
|
-
* Type definition used to render tree rendering UI component.
|
|
7
|
-
* @alpha
|
|
8
|
-
*/
|
|
9
|
-
export type TreeRendererProps = {
|
|
10
|
-
/**
|
|
11
|
-
* Array containing root tree nodes.
|
|
12
|
-
*/
|
|
13
|
-
rootNodes: TreeNode[];
|
|
14
|
-
/**
|
|
15
|
-
* A function that should be called to either expand or collapse the given node.
|
|
16
|
-
*/
|
|
17
|
-
expandNode: (nodeId: string, isExpanded: boolean) => void;
|
|
18
|
-
/**
|
|
19
|
-
* A function that should be called to select nodes in the tree.
|
|
20
|
-
* @param nodeIds Ids of the nodes that are selected.
|
|
21
|
-
* @param changeType Type of change that occurred for the selection.
|
|
22
|
-
*/
|
|
23
|
-
selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;
|
|
24
|
-
/** Determines whether a given node is selected. */
|
|
25
|
-
isNodeSelected: (nodeId: string) => boolean;
|
|
26
|
-
} & CommonRendererProps;
|
|
27
|
-
/**
|
|
28
|
-
* Type definition used to render root error handling UI component.
|
|
29
|
-
* @alpha
|
|
30
|
-
*/
|
|
31
|
-
export type RootErrorRendererProps = {
|
|
32
|
-
/** Object containing root error information */
|
|
33
|
-
error: ErrorInfo;
|
|
34
|
-
} & CommonRendererProps;
|
|
35
|
-
/**
|
|
36
|
-
* @alpha
|
|
37
|
-
*/
|
|
38
|
-
interface CommonRendererProps {
|
|
39
|
-
/**
|
|
40
|
-
* A function that should be called to reload the tree.
|
|
41
|
-
*/
|
|
42
|
-
reloadTree: (options?: ReloadTreeOptions) => void;
|
|
43
|
-
/** Returns hierarchy level details for a given node ID. */
|
|
44
|
-
getHierarchyLevelDetails: (nodeId: string | undefined) => HierarchyLevelDetails | undefined;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Options for doing either full or a sub tree reload.
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
interface ReloadTreeOptions {
|
|
51
|
-
/** Specifies parent node under which sub tree should be reloaded. */
|
|
52
|
-
parentNodeId: string | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* Specifies how current tree state should be handled:
|
|
55
|
-
* - `keep` - try to keep current tree state (expanded/collapsed nodes, instance filters, etc.).
|
|
56
|
-
* - `discard` - do not try to keep current tree state. Tree model will be update after nodes are reloaded.
|
|
57
|
-
* - `reset` - remove subtree from the model before reloading and reload nodes ignoring cache.
|
|
58
|
-
*
|
|
59
|
-
* Defaults to `"keep"`.
|
|
60
|
-
*/
|
|
61
|
-
state?: "keep" | "discard" | "reset";
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A data structure that contains information about a single hierarchy level.
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
|
-
export interface HierarchyLevelDetails {
|
|
68
|
-
/** The parent node whose hierarchy level's information is contained in this data structure */
|
|
69
|
-
hierarchyNode: HierarchyNode | undefined;
|
|
70
|
-
/** A function to get instance keys of the hierarchy level. */
|
|
71
|
-
getInstanceKeysIterator: (props?: {
|
|
72
|
-
instanceFilter?: GenericInstanceFilter;
|
|
73
|
-
hierarchyLevelSizeLimit?: number | "unbounded";
|
|
74
|
-
}) => AsyncIterableIterator<InstanceKey>;
|
|
75
|
-
/** Get the limit of how many nodes can be loaded in this hierarchy level. */
|
|
76
|
-
sizeLimit?: number | "unbounded";
|
|
77
|
-
/** Set the limit of how many nodes can be loaded in this hierarchy level. */
|
|
78
|
-
setSizeLimit: (value: undefined | number | "unbounded") => void;
|
|
79
|
-
/** Get the active instance filter applied to this hierarchy level. */
|
|
80
|
-
instanceFilter?: GenericInstanceFilter;
|
|
81
|
-
/** Set the instance filter to apply to this hierarchy level */
|
|
82
|
-
setInstanceFilter: (filter: GenericInstanceFilter | undefined) => void;
|
|
83
|
-
}
|
|
84
|
-
export {};
|
|
85
|
-
//# sourceMappingURL=Renderers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Renderers.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Renderers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,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;CAC7C,GAAG,mBAAmB,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,+CAA+C;IAC/C,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,mBAAmB,CAAC;AAExB;;GAEG;AACH,UAAU,mBAAmB;IAC3B;;OAEG;IACH,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClD,2DAA2D;IAC3D,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,qBAAqB,GAAG,SAAS,CAAC;CAC7F;AAED;;;GAGG;AACH,UAAU,iBAAiB;IACzB,qEAAqE;IACrE,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IAEzC,8DAA8D;IAC9D,uBAAuB,EAAE,CAAC,KAAK,CAAC,EAAE;QAChC,cAAc,CAAC,EAAE,qBAAqB,CAAC;QACvC,uBAAuB,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;KAChD,KAAK,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEzC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,6EAA6E;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,KAAK,IAAI,CAAC;IAEhE,sEAAsE;IACtE,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,+DAA+D;IAC/D,iBAAiB,EAAE,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,KAAK,IAAI,CAAC;CACxE"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
export {};
|
|
6
|
-
//# sourceMappingURL=Renderers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Renderers.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/Renderers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG","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 { GenericInstanceFilter, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { ErrorInfo, TreeNode } from \"./TreeNode.js\";\nimport { SelectionChangeType } from \"./UseSelectionHandler.js\";\n\n/**\n * Type definition used to render tree rendering UI component.\n * @alpha\n */\nexport type TreeRendererProps = {\n /**\n * Array containing root tree nodes.\n */\n rootNodes: TreeNode[];\n /**\n * A function that should be called to either expand or collapse the given node.\n */\n expandNode: (nodeId: string, isExpanded: boolean) => void;\n /**\n * A function that should be called to select nodes in the tree.\n * @param nodeIds Ids of the nodes that are selected.\n * @param changeType Type of change that occurred for the selection.\n */\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n /** Determines whether a given node is selected. */\n isNodeSelected: (nodeId: string) => boolean;\n} & CommonRendererProps;\n\n/**\n * Type definition used to render root error handling UI component.\n * @alpha\n */\nexport type RootErrorRendererProps = {\n /** Object containing root error information */\n error: ErrorInfo;\n} & CommonRendererProps;\n\n/**\n * @alpha\n */\ninterface CommonRendererProps {\n /**\n * A function that should be called to reload the tree.\n */\n reloadTree: (options?: ReloadTreeOptions) => void;\n /** Returns hierarchy level details for a given node ID. */\n getHierarchyLevelDetails: (nodeId: string | undefined) => HierarchyLevelDetails | undefined;\n}\n\n/**\n * Options for doing either full or a sub tree reload.\n * @public\n */\ninterface ReloadTreeOptions {\n /** Specifies parent node under which sub tree should be reloaded. */\n parentNodeId: string | undefined;\n\n /**\n * Specifies how current tree state should be handled:\n * - `keep` - try to keep current tree state (expanded/collapsed nodes, instance filters, etc.).\n * - `discard` - do not try to keep current tree state. Tree model will be update after nodes are reloaded.\n * - `reset` - remove subtree from the model before reloading and reload nodes ignoring cache.\n *\n * Defaults to `\"keep\"`.\n */\n state?: \"keep\" | \"discard\" | \"reset\";\n}\n\n/**\n * A data structure that contains information about a single hierarchy level.\n * @public\n */\nexport interface HierarchyLevelDetails {\n /** The parent node whose hierarchy level's information is contained in this data structure */\n hierarchyNode: HierarchyNode | undefined;\n\n /** A function to get instance keys of the hierarchy level. */\n getInstanceKeysIterator: (props?: {\n instanceFilter?: GenericInstanceFilter;\n hierarchyLevelSizeLimit?: number | \"unbounded\";\n }) => AsyncIterableIterator<InstanceKey>;\n\n /** Get the limit of how many nodes can be loaded in this hierarchy level. */\n sizeLimit?: number | \"unbounded\";\n /** Set the limit of how many nodes can be loaded in this hierarchy level. */\n setSizeLimit: (value: undefined | number | \"unbounded\") => void;\n\n /** Get the active instance filter applied to this hierarchy level. */\n instanceFilter?: GenericInstanceFilter;\n /** Set the instance filter to apply to this hierarchy level */\n setInstanceFilter: (filter: GenericInstanceFilter | undefined) => void;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNode.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,EAAE,aAAa,CAAC;IACxB,yDAAyD;IACzD,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,mBAAmB,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,0BAA0B,GAAG,wBAAwB,GAAG,qBAAqB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
export {};
|
|
6
|
-
//# sourceMappingURL=TreeNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNode.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/TreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG","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 node in a UI tree component, built with `useTree` hook.\n * @public\n */\nexport interface TreeNode {\n id: string;\n label: string;\n children: true | Array<TreeNode>;\n isExpanded: boolean;\n isLoading: boolean;\n isFilterable: boolean;\n isFiltered: boolean;\n /** UI-agnostic source of this node object. */\n nodeData: HierarchyNode;\n /** Contains error encountered from expanding the node */\n error?: ErrorInfo;\n}\n\n/**\n * A type of `ErrorInfo` that is returned,\n * when none of the child nodes match the filter.\n *\n * @public\n */\nexport interface NoFilterMatchesErrorInfo {\n id: string;\n type: \"NoFilterMatches\";\n}\n\n/**\n * A type of `ErrorInfo` that is returned, when the\n * number of child nodes exceeds the limit set on the tree nodes loader. The limit is also included\n * on this error as `resultSetSizeLimit` attribute.\n *\n * @public\n */\nexport interface ResultSetTooLargeErrorInfo {\n id: string;\n type: \"ResultSetTooLarge\";\n resultSetSizeLimit: number;\n}\n\n/**\n * A type of `ErrorInfo` that contains a user-friendly message to be displayed in the UI.\n * 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 ChildrenLoadErrorInfo {\n id: string;\n type: \"ChildrenLoad\";\n message: string;\n}\n\n/**\n * A type of `ErrorInfo` that can be used to show/handle generic errors,\n * that might not be directly caused by the tree components. (e.g. tree components\n * shows hierarchy of connections to external systems and an error is show in the\n * tree when some connections are unreachable).\n *\n * @public\n */\nexport interface GenericErrorInfo {\n id: string;\n type: \"Unknown\";\n message: string;\n additionalData?: unknown;\n}\n\n/**\n * A collection of types that defines an error state for `TreeNode` node in a UI tree component, built\n * with `useTree` hook.\n *\n * @public\n */\nexport type ErrorInfo = GenericErrorInfo | ResultSetTooLargeErrorInfo | NoFilterMatchesErrorInfo | ChildrenLoadErrorInfo;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseIModelTree.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC1H,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAW,YAAY,EAAE,aAAa,EAA2B,MAAM,cAAc,CAAC;AAE7F,cAAc;AACd,KAAK,4BAA4B,GAAG,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEhF,cAAc;AACd,KAAK,YAAY,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;AAEjE;;;GAGG;AACH,KAAK,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,sBAAsB,GAAG,gBAAgB,CAAC,GACrF,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,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE;QACvB,+FAA+F;QAC/F,YAAY,EAAE,YAAY,CAAC;QAC3B,2DAA2D;QAC3D,WAAW,EAAE,WAAW,CAAC;KAC1B,KAAK,OAAO,CAAC,mBAAmB,EAAE,GAAG,SAAS,CAAC,CAAC;CAClD,CAAC;AAEJ;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAMtE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kBAAkB,GAAG,4BAA4B,GAAG,aAAa,CAMrH"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { useCallback } from "react";
|
|
6
|
-
import { createIModelHierarchyProvider } from "@itwin/presentation-hierarchies";
|
|
7
|
-
import { useTree, useUnifiedSelectionTree } from "./UseTree.js";
|
|
8
|
-
/**
|
|
9
|
-
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
10
|
-
* iModel data.
|
|
11
|
-
*
|
|
12
|
-
* The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
|
|
13
|
-
* component-agnostic result which may be used to render the hierarchy using any UI framework.
|
|
14
|
-
*
|
|
15
|
-
* See `README.md` for an example
|
|
16
|
-
*
|
|
17
|
-
* @see `useTree`
|
|
18
|
-
* @see `useIModelUnifiedSelectionTree`
|
|
19
|
-
* @public
|
|
20
|
-
*/
|
|
21
|
-
export function useIModelTree(props) {
|
|
22
|
-
const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, localizedStrings, ...rest } = props;
|
|
23
|
-
return useTree({
|
|
24
|
-
...rest,
|
|
25
|
-
...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, localizedStrings }),
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* A React hook that creates state for a tree component whose displayed hierarchy is based on
|
|
30
|
-
* iModel data and that is integrated with unified selection through the given selection
|
|
31
|
-
* storage (previously the storage was provided through the, now deprecated, `UnifiedSelectionProvider`).
|
|
32
|
-
*
|
|
33
|
-
* The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
|
|
34
|
-
* component-agnostic result which may be used to render the hierarchy using any UI framework.
|
|
35
|
-
*
|
|
36
|
-
* See `README.md` for an example
|
|
37
|
-
*
|
|
38
|
-
* @see `useIModelTree`
|
|
39
|
-
* @see `useUnifiedSelectionTree`
|
|
40
|
-
* @see `UnifiedSelectionProvider`
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export function useIModelUnifiedSelectionTree(props) {
|
|
44
|
-
const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, localizedStrings, ...rest } = props;
|
|
45
|
-
return useUnifiedSelectionTree({
|
|
46
|
-
...rest,
|
|
47
|
-
...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, localizedStrings }),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function useIModelTreeProps(props) {
|
|
51
|
-
const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, localizedStrings } = props;
|
|
52
|
-
return {
|
|
53
|
-
getHierarchyProvider: useCallback(() => createIModelHierarchyProvider({
|
|
54
|
-
imodelAccess,
|
|
55
|
-
imodelChanged,
|
|
56
|
-
hierarchyDefinition: getHierarchyDefinition({ imodelAccess }),
|
|
57
|
-
localizedStrings,
|
|
58
|
-
}), [imodelAccess, imodelChanged, getHierarchyDefinition, localizedStrings]),
|
|
59
|
-
getSearchPaths: useCallback(async ({ abortSignal }) => getSearchPaths?.({ imodelAccess, abortSignal }), [imodelAccess, getSearchPaths]),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=UseIModelTree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseIModelTree.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseIModelTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAA4C,MAAM,iCAAiC,CAAC;AAG1H,OAAO,EAAE,OAAO,EAA+B,uBAAuB,EAAE,MAAM,cAAc,CAAC;AA0B7F;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACjH,OAAO,OAAO,CAAC;QACb,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;KACjH,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,6BAA6B,CAAC,KAAwD;IACpG,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACjH,OAAO,uBAAuB,CAAC;QAC7B,GAAG,IAAI;QACP,GAAG,kBAAkB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;KACjH,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAoI;IAEpI,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IACxG,OAAO;QACL,oBAAoB,EAAE,WAAW,CAC/B,GAAG,EAAE,CACH,6BAA6B,CAAC;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,cAAc,EAAE,WAAW,CACzB,KAAK,EAAE,EAAE,WAAW,EAAgC,EAAE,EAAE,CAAC,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,EACxG,CAAC,YAAY,EAAE,cAAc,CAAC,CAC/B;KACF,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, HierarchySearchPath } from \"@itwin/presentation-hierarchies\";\nimport { Props } from \"@itwin/presentation-shared\";\nimport { UseUnifiedTreeSelectionProps } from \"./internal/UseUnifiedSelection.js\";\nimport { useTree, UseTreeProps, UseTreeResult, useUnifiedSelectionTree } 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, \"localizedStrings\" | \"imodelAccess\" | \"imodelChanged\"> & {\n /** Provides the hierarchy definition for the tree. */\n getHierarchyDefinition: (props: { imodelAccess: IModelAccess }) => HierarchyDefinition;\n\n /** Provides paths to target nodes. */\n getSearchPaths?: (props: {\n /** Object that provides access to the iModel schema and can run queries against the iModel. */\n imodelAccess: IModelAccess;\n /** Signal indicating that that the request was canceled */\n abortSignal: AbortSignal;\n }) => Promise<HierarchySearchPath[] | 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, localizedStrings, ...rest } = props;\n return useTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, 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 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, localizedStrings, ...rest } = props;\n return useUnifiedSelectionTree({\n ...rest,\n ...useIModelTreeProps({ imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, localizedStrings }),\n });\n}\n\nfunction useIModelTreeProps(\n props: Pick<UseIModelTreeProps, \"imodelAccess\" | \"imodelChanged\" | \"getHierarchyDefinition\" | \"getSearchPaths\" | \"localizedStrings\">,\n): Pick<UseTreeProps, \"getHierarchyProvider\" | \"getSearchPaths\"> {\n const { imodelAccess, imodelChanged, getHierarchyDefinition, getSearchPaths, 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 getSearchPaths: useCallback(\n async ({ abortSignal }: { abortSignal: AbortSignal }) => getSearchPaths?.({ imodelAccess, abortSignal }),\n [imodelAccess, getSearchPaths],\n ),\n };\n}\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { TreeNode } from "./TreeNode.js";
|
|
2
|
-
/**
|
|
3
|
-
* Props for `useNodeHighlighting` hook.
|
|
4
|
-
* @alpha
|
|
5
|
-
*/
|
|
6
|
-
interface UseNodeHighlightingProps {
|
|
7
|
-
/** Text that should be highlighted */
|
|
8
|
-
highlightText?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Result of `useNodeHighlighting` hook.
|
|
12
|
-
* @alpha
|
|
13
|
-
*/
|
|
14
|
-
interface UseNodeHighlightingResult {
|
|
15
|
-
/** Function that creates highlighted node labels. */
|
|
16
|
-
getLabel: (node: TreeNode) => React.ReactElement;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* A react hook that helps create highlighted node labels based on provided highlight.
|
|
20
|
-
* @alpha
|
|
21
|
-
*/
|
|
22
|
-
export declare function useNodeHighlighting({ highlightText }: UseNodeHighlightingProps): UseNodeHighlightingResult;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=UseNodeHighlighting.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseNodeHighlighting.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;GAGG;AACH,UAAU,wBAAwB;IAChC,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,UAAU,yBAAyB;IACjC,qDAAqD;IACrD,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,KAAK,CAAC,YAAY,CAAC;CAClD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,aAAa,EAAE,EAAE,wBAAwB,GAAG,yBAAyB,CAgD1G"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
import { useCallback } from "react";
|
|
7
|
-
import { HierarchyNode } from "@itwin/presentation-hierarchies";
|
|
8
|
-
/**
|
|
9
|
-
* A react hook that helps create highlighted node labels based on provided highlight.
|
|
10
|
-
* @alpha
|
|
11
|
-
*/
|
|
12
|
-
export function useNodeHighlighting({ highlightText }) {
|
|
13
|
-
const getLabel = useCallback((node) => {
|
|
14
|
-
if (!highlightText || HierarchyNode.isGroupingNode(node.nodeData) || !node.nodeData.search?.isSearchTarget) {
|
|
15
|
-
return _jsx("span", { children: node.label });
|
|
16
|
-
}
|
|
17
|
-
const matchedIndexes = new Array();
|
|
18
|
-
const nodeLabel = node.label.toLocaleLowerCase();
|
|
19
|
-
const searchText = highlightText.toLocaleLowerCase();
|
|
20
|
-
let fromPosition = 0;
|
|
21
|
-
// Find all occurrences of the search text in the node label
|
|
22
|
-
while (true) {
|
|
23
|
-
const foundIndex = nodeLabel.indexOf(searchText, fromPosition);
|
|
24
|
-
if (foundIndex === -1) {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
matchedIndexes.push(foundIndex);
|
|
28
|
-
fromPosition = foundIndex + searchText.length;
|
|
29
|
-
}
|
|
30
|
-
if (matchedIndexes.length === 0) {
|
|
31
|
-
return _jsx("span", { children: node.label });
|
|
32
|
-
}
|
|
33
|
-
// Create the final label with highlighted parts
|
|
34
|
-
const finalLabel = new Array();
|
|
35
|
-
let lastAddedPosition = 0;
|
|
36
|
-
for (let i = 0; i < matchedIndexes.length; ++i) {
|
|
37
|
-
const matchedIndex = matchedIndexes[i];
|
|
38
|
-
if (matchedIndex > lastAddedPosition) {
|
|
39
|
-
finalLabel.push(_jsx("span", { children: node.label.substring(lastAddedPosition, matchedIndex) }, `normal-${i}`));
|
|
40
|
-
lastAddedPosition = matchedIndex;
|
|
41
|
-
}
|
|
42
|
-
const endingPlace = matchedIndex + highlightText.length;
|
|
43
|
-
finalLabel.push(_jsx("mark", { children: node.label.substring(lastAddedPosition, endingPlace) }, `marked-${i}`));
|
|
44
|
-
lastAddedPosition = endingPlace;
|
|
45
|
-
}
|
|
46
|
-
if (lastAddedPosition < node.label.length) {
|
|
47
|
-
finalLabel.push(_jsx("span", { children: node.label.substring(lastAddedPosition) }, `normal-${matchedIndexes.length + 1}`));
|
|
48
|
-
}
|
|
49
|
-
return _jsx(_Fragment, { children: finalLabel });
|
|
50
|
-
}, [highlightText]);
|
|
51
|
-
return { getLabel };
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=UseNodeHighlighting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseNodeHighlighting.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseNodeHighlighting.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAqBhE;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAE,aAAa,EAA4B;IAC7E,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,IAAc,EAAE,EAAE;QACjB,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;YAC3G,OAAO,yBAAO,IAAI,CAAC,KAAK,GAAQ,CAAC;QACnC,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,KAAK,EAAU,CAAC;QAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC;QACjD,MAAM,UAAU,GAAG,aAAa,CAAC,iBAAiB,EAAE,CAAC;QACrD,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,4DAA4D;QAC5D,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,UAAU,GAAG,SAA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S,CAAC,iBAAiB,CAAC,IAA/E,UAAU,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAkD,CAAC,CAAC;QACtH,CAAC;QAED,OAAO,4BAAG,UAAU,GAAI,CAAC;IAC3B,CAAC,EACD,CAAC,aAAa,CAAC,CAChB,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,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 { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { 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) => React.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<React.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(<span key={`normal-${matchedIndexes.length + 1}`}>{node.label.substring(lastAddedPosition)}</span>);\n }\n\n return <>{finalLabel}</>;\n },\n [highlightText],\n );\n\n return { getLabel };\n}\n"]}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { TreeRendererProps } from "./Renderers.js";
|
|
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
|
-
export 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
|
-
export type SelectionChangeType = "add" | "replace" | "remove";
|
|
21
|
-
/**
|
|
22
|
-
* Props for `useSelectionHandler` hook.
|
|
23
|
-
* @alpha
|
|
24
|
-
*/
|
|
25
|
-
type UseSelectionHandlerProps = Pick<TreeRendererProps, "selectNodes" | "rootNodes"> & {
|
|
26
|
-
/** Selection mode that the component is working in. */
|
|
27
|
-
selectionMode: SelectionMode;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Result of `useSelectionHandler` hook.
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
interface UseSelectionHandlerResult {
|
|
34
|
-
/** Updates nodes selection based on current node state and modifier keys used. */
|
|
35
|
-
handleNodeSelect: (props: {
|
|
36
|
-
nodeId: string;
|
|
37
|
-
isSelected: boolean;
|
|
38
|
-
shiftDown: boolean;
|
|
39
|
-
ctrlDown: boolean;
|
|
40
|
-
}) => void;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* A react hook that helps implement different selection modes in a tree component created using `useTree` hook.
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export declare function useSelectionHandler(props: UseSelectionHandlerProps): UseSelectionHandlerResult;
|
|
47
|
-
export {};
|
|
48
|
-
//# sourceMappingURL=UseSelectionHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseSelectionHandler.d.ts","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD;;;;;;;;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,iBAAiB,EAAE,aAAa,GAAG,WAAW,CAAC,GAAG;IACrF,uDAAuD;IACvD,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,UAAU,yBAAyB;IACjC,kFAAkF;IAClF,gBAAgB,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAC;CACnH;AAOD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,yBAAyB,CA8C9F"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { useCallback, useEffect, useRef } from "react";
|
|
6
|
-
/**
|
|
7
|
-
* A react hook that helps implement different selection modes in a tree component created using `useTree` hook.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export function useSelectionHandler(props) {
|
|
11
|
-
const { rootNodes, selectionMode, selectNodes } = props;
|
|
12
|
-
const previousSelectionRef = useRef(undefined);
|
|
13
|
-
const state = useRef({
|
|
14
|
-
flatNodeList: [],
|
|
15
|
-
nodeIdToIndexMap: new Map(),
|
|
16
|
-
});
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
state.current = computeFlatNodeList(rootNodes);
|
|
19
|
-
}, [rootNodes]);
|
|
20
|
-
const getNodeRange = (firstId, secondId) => {
|
|
21
|
-
const getIndex = (nodeId) => {
|
|
22
|
-
return nodeId ? state.current.nodeIdToIndexMap.get(nodeId) : 0;
|
|
23
|
-
};
|
|
24
|
-
const firstIndex = getIndex(firstId);
|
|
25
|
-
const secondIndex = getIndex(secondId);
|
|
26
|
-
if (firstIndex === undefined || secondIndex === undefined) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const startingIndex = Math.min(firstIndex, secondIndex);
|
|
30
|
-
const endIndex = Math.max(firstIndex, secondIndex);
|
|
31
|
-
return state.current.flatNodeList.slice(startingIndex, endIndex + 1);
|
|
32
|
-
};
|
|
33
|
-
const handleNodeSelect = useCallback(({ nodeId, isSelected, shiftDown, ctrlDown }) => {
|
|
34
|
-
const selection = getSelectionAction(selectionMode, isSelected, shiftDown, ctrlDown);
|
|
35
|
-
if (selection.type === "disabled") {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const nodes = selection.select === "range" ? getNodeRange(previousSelectionRef.current, nodeId) : [nodeId];
|
|
39
|
-
if (!nodes.length) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
selection.select !== "range" && (previousSelectionRef.current = nodeId);
|
|
43
|
-
selectNodes(nodes, selection.type);
|
|
44
|
-
}, [selectionMode, selectNodes]);
|
|
45
|
-
return { handleNodeSelect };
|
|
46
|
-
}
|
|
47
|
-
function getSelectionAction(selectionMode, isSelected, shiftDown, ctrlDown) {
|
|
48
|
-
switch (selectionMode) {
|
|
49
|
-
case "none":
|
|
50
|
-
return { select: "node", type: "disabled" };
|
|
51
|
-
case "single":
|
|
52
|
-
return { select: "node", type: isSelected ? "remove" : "replace" };
|
|
53
|
-
case "multiple":
|
|
54
|
-
return { select: "node", type: isSelected ? "remove" : "add" };
|
|
55
|
-
case "extended":
|
|
56
|
-
return getExtendedSelectionAction(isSelected, shiftDown, ctrlDown);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function getExtendedSelectionAction(isSelected, shiftDown, ctrlDown) {
|
|
60
|
-
if (shiftDown) {
|
|
61
|
-
return { select: "range", type: "replace" };
|
|
62
|
-
}
|
|
63
|
-
if (ctrlDown) {
|
|
64
|
-
return { select: "node", type: isSelected ? "remove" : "add" };
|
|
65
|
-
}
|
|
66
|
-
return { select: "node", type: "replace" };
|
|
67
|
-
}
|
|
68
|
-
function computeFlatNodeList(rootNodes) {
|
|
69
|
-
const flatNodeList = [];
|
|
70
|
-
const nodeIdToIndexMap = new Map();
|
|
71
|
-
const flattenNodeRecursively = (nodes) => {
|
|
72
|
-
nodes.forEach((node) => {
|
|
73
|
-
nodeIdToIndexMap.set(node.id, flatNodeList.length);
|
|
74
|
-
flatNodeList.push(node.id);
|
|
75
|
-
if (node.isExpanded && typeof node.children !== "boolean") {
|
|
76
|
-
flattenNodeRecursively(node.children);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
flattenNodeRecursively(rootNodes);
|
|
81
|
-
return { flatNodeList, nodeIdToIndexMap };
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=UseSelectionHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UseSelectionHandler.js","sourceRoot":"","sources":["../../../src/presentation-hierarchies-react/UseSelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAgDvD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IACjE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACxD,MAAM,oBAAoB,GAAG,MAAM,CAAqB,SAAS,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,MAAM,CAAgB;QAClC,YAAY,EAAE,EAAE;QAChB,gBAAgB,EAAE,IAAI,GAAG,EAAE;KAC5B,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,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;QAC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AC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,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 { TreeRendererProps } from \"./Renderers.js\";\nimport { TreeNode } from \"./TreeNode.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 * @alpha\n */\ntype UseSelectionHandlerProps = Pick<TreeRendererProps, \"selectNodes\" | \"rootNodes\"> & {\n /** Selection mode that the component is working in. */\n selectionMode: SelectionMode;\n};\n\n/**\n * Result of `useSelectionHandler` hook.\n * @internal\n */\ninterface UseSelectionHandlerResult {\n /** Updates nodes selection based on current node state and modifier keys used. */\n handleNodeSelect: (props: { nodeId: string; isSelected: boolean; shiftDown: boolean; ctrlDown: boolean }) => 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 * @internal\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 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 handleNodeSelect = useCallback<UseSelectionHandlerResult[\"handleNodeSelect\"]>(\n ({ nodeId, isSelected, shiftDown, ctrlDown }) => {\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 return { handleNodeSelect };\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 ? \"remove\" : \"replace\" };\n case \"multiple\":\n return { select: \"node\", type: isSelected ? \"remove\" : \"add\" };\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 ? \"remove\" : \"add\" };\n }\n return { select: \"node\", type: \"replace\" };\n}\n\nfunction computeFlatNodeList(rootNodes: Array<TreeNode>): FlatTreeState {\n const flatNodeList: Array<string> = [];\n const nodeIdToIndexMap: Map<string, number> = new Map();\n\n const flattenNodeRecursively = (nodes: Array<TreeNode>) => {\n nodes.forEach((node) => {\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,94 +0,0 @@
|
|
|
1
|
-
import { GenericInstanceFilter, HierarchyProvider, HierarchySearchPath } from "@itwin/presentation-hierarchies";
|
|
2
|
-
import { IPrimitiveValueFormatter } from "@itwin/presentation-shared";
|
|
3
|
-
import { UseUnifiedTreeSelectionProps } from "./internal/UseUnifiedSelection.js";
|
|
4
|
-
import { RootErrorRendererProps, TreeRendererProps } from "./Renderers.js";
|
|
5
|
-
import { TreeNode } from "./TreeNode.js";
|
|
6
|
-
/**
|
|
7
|
-
* A React hook that creates state for a tree component.
|
|
8
|
-
*
|
|
9
|
-
* The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
|
|
10
|
-
* component-agnostic result which may be used to render the hierarchy using any UI framework.
|
|
11
|
-
*
|
|
12
|
-
* See `README.md` for an example
|
|
13
|
-
*
|
|
14
|
-
* @see `useUnifiedSelectionTree`
|
|
15
|
-
* @see `useIModelTree`
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
export declare function useTree(props: UseTreeProps): UseTreeResult;
|
|
19
|
-
/**
|
|
20
|
-
* A React hook that creates state for a tree component, that is integrated with unified selection
|
|
21
|
-
* through the given selection storage (previously the storage was provided through the, now
|
|
22
|
-
* deprecated, `UnifiedSelectionProvider`).
|
|
23
|
-
*
|
|
24
|
-
* The hook uses `@itwin/presentation-hierarchies` package to load the hierarchy data and returns a
|
|
25
|
-
* component-agnostic result which may be used to render the hierarchy using any UI framework.
|
|
26
|
-
*
|
|
27
|
-
* See `README.md` for an example
|
|
28
|
-
*
|
|
29
|
-
* @see `useTree`
|
|
30
|
-
* @see `useIModelUnifiedSelectionTree`
|
|
31
|
-
* @see `UnifiedSelectionProvider`
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare function useUnifiedSelectionTree({ sourceName, selectionStorage, createSelectableForGenericNode, ...props }: UseTreeProps & UseUnifiedTreeSelectionProps): UseTreeResult;
|
|
35
|
-
/** @public */
|
|
36
|
-
export interface UseTreeProps {
|
|
37
|
-
/** Provides the hierarchy provider for the tree. */
|
|
38
|
-
getHierarchyProvider: () => HierarchyProvider;
|
|
39
|
-
/** Provides paths to search nodes. */
|
|
40
|
-
getSearchPaths?: ({ abortSignal }: {
|
|
41
|
-
abortSignal: AbortSignal;
|
|
42
|
-
}) => Promise<HierarchySearchPath[] | undefined>;
|
|
43
|
-
/**
|
|
44
|
-
* Callback that is called just after a certain action is finished.
|
|
45
|
-
* Can be used for performance tracking.
|
|
46
|
-
*/
|
|
47
|
-
onPerformanceMeasured?: (action: "initial-load" | "hierarchy-level-load" | "reload", duration: number) => void;
|
|
48
|
-
/** Action to perform when hierarchy level contains more items that the specified limit. */
|
|
49
|
-
onHierarchyLimitExceeded?: (props: {
|
|
50
|
-
parentId?: string;
|
|
51
|
-
filter?: GenericInstanceFilter;
|
|
52
|
-
limit?: number | "unbounded";
|
|
53
|
-
}) => void;
|
|
54
|
-
/** Action to perform when an error occurs while loading hierarchy. */
|
|
55
|
-
onHierarchyLoadError?: (props: {
|
|
56
|
-
parentId?: string;
|
|
57
|
-
type: "timeout" | "unknown";
|
|
58
|
-
error: unknown;
|
|
59
|
-
}) => void;
|
|
60
|
-
}
|
|
61
|
-
/** @public */
|
|
62
|
-
export type UseTreeResult = {
|
|
63
|
-
/**
|
|
64
|
-
* Specifies whether tree is reloading or not. It is set to `false` when initial tree load is in progress to check if
|
|
65
|
-
* or tree is reloading.
|
|
66
|
-
*/
|
|
67
|
-
isReloading: boolean;
|
|
68
|
-
/** Get a tree node by id */
|
|
69
|
-
getNode: (nodeId: string) => TreeNode | undefined;
|
|
70
|
-
/** Sets a formatter for the primitive values that are displayed in the hierarchy. */
|
|
71
|
-
setFormatter: (formatter: IPrimitiveValueFormatter | undefined) => void;
|
|
72
|
-
} & RendererProps;
|
|
73
|
-
/**.
|
|
74
|
-
* @alpha
|
|
75
|
-
*/
|
|
76
|
-
type RendererProps = {
|
|
77
|
-
/**
|
|
78
|
-
* An object containing information used to render root error handling UI.
|
|
79
|
-
* Use in combination with `RootErrorRenderer` or your custom implementation.
|
|
80
|
-
* Defined when root nodes fail to load.
|
|
81
|
-
*/
|
|
82
|
-
rootErrorRendererProps: RootErrorRendererProps;
|
|
83
|
-
} | {
|
|
84
|
-
/** Is undefined when rootNodes where successfully loaded or are in initial loading process */
|
|
85
|
-
rootErrorRendererProps: undefined;
|
|
86
|
-
/**
|
|
87
|
-
* An object containing information used to render tree.
|
|
88
|
-
* Use with `TreeRenderer` or your custom implementation.
|
|
89
|
-
* Is undefined on initial loading process.
|
|
90
|
-
*/
|
|
91
|
-
treeRendererProps?: TreeRendererProps;
|
|
92
|
-
};
|
|
93
|
-
export {};
|
|
94
|
-
//# sourceMappingURL=UseTree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