@itwin/presentation-hierarchies-react 2.0.0-alpha.3 → 2.0.0-alpha.31

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 (109) hide show
  1. package/CHANGELOG.md +559 -0
  2. package/README.md +24 -24
  3. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +85 -0
  4. package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
  5. package/lib/esm/presentation-hierarchies-react/{itwinui/TreeActionButton.css → Renderers.js} +2 -4
  6. package/lib/esm/presentation-hierarchies-react/Renderers.js.map +1 -0
  7. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts +14 -29
  8. package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  9. package/lib/esm/presentation-hierarchies-react/TreeNode.js +1 -7
  10. package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +1 -1
  11. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts +2 -0
  12. package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  13. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +1 -1
  14. package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  15. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +24 -0
  16. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
  17. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +39 -0
  18. package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
  19. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +3 -3
  20. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  21. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +1 -8
  22. package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  23. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +32 -70
  24. package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  25. package/lib/esm/presentation-hierarchies-react/UseTree.js +48 -49
  26. package/lib/esm/presentation-hierarchies-react/UseTree.js.map +1 -1
  27. package/lib/esm/presentation-hierarchies-react/Utils.d.ts +5 -0
  28. package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +1 -0
  29. package/lib/esm/presentation-hierarchies-react/Utils.js +23 -0
  30. package/lib/esm/presentation-hierarchies-react/Utils.js.map +1 -0
  31. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +2 -2
  32. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +1 -1
  33. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +31 -16
  34. package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  35. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +24 -6
  36. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +1 -1
  37. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +28 -32
  38. package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  39. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +6 -29
  40. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +1 -1
  41. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +31 -27
  42. package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  43. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +23 -9
  44. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  45. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +16 -29
  46. package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  47. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts +34 -0
  48. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.d.ts.map +1 -0
  49. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js +26 -0
  50. package/lib/esm/presentation-hierarchies-react/stratakit/FilterAction.js.map +1 -0
  51. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts +58 -0
  52. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
  53. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +74 -0
  54. package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
  55. package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.d.ts +47 -7
  56. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
  57. package/lib/esm/presentation-hierarchies-react/{itwinui → stratakit}/LocalizationContext.js +13 -5
  58. package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
  59. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts +33 -0
  60. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.d.ts.map +1 -0
  61. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js +39 -0
  62. package/lib/esm/presentation-hierarchies-react/stratakit/RenameAction.js.map +1 -0
  63. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +16 -0
  64. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
  65. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +42 -0
  66. package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
  67. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +43 -0
  68. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
  69. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +70 -0
  70. package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
  71. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +49 -0
  72. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
  73. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +116 -0
  74. package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
  75. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +40 -0
  76. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
  77. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +93 -0
  78. package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
  79. package/lib/esm/presentation-hierarchies-react.d.ts +13 -10
  80. package/lib/esm/presentation-hierarchies-react.d.ts.map +1 -1
  81. package/lib/esm/presentation-hierarchies-react.js +10 -9
  82. package/lib/esm/presentation-hierarchies-react.js.map +1 -1
  83. package/package.json +46 -38
  84. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts +0 -15
  85. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.d.ts.map +0 -1
  86. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js +0 -22
  87. package/lib/esm/presentation-hierarchies-react/UnifiedSelectionContext.js.map +0 -1
  88. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.d.ts.map +0 -1
  89. package/lib/esm/presentation-hierarchies-react/itwinui/LocalizationContext.js.map +0 -1
  90. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts +0 -21
  91. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.d.ts.map +0 -1
  92. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js +0 -29
  93. package/lib/esm/presentation-hierarchies-react/itwinui/TreeActionButton.js.map +0 -1
  94. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts +0 -12
  95. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.d.ts.map +0 -1
  96. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js +0 -72
  97. package/lib/esm/presentation-hierarchies-react/itwinui/TreeErrorRenderer.js.map +0 -1
  98. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts +0 -12
  99. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.d.ts.map +0 -1
  100. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js +0 -10
  101. package/lib/esm/presentation-hierarchies-react/itwinui/TreeLevelRenderer.js.map +0 -1
  102. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts +0 -45
  103. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.d.ts.map +0 -1
  104. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js +0 -71
  105. package/lib/esm/presentation-hierarchies-react/itwinui/TreeNodeRenderer.js.map +0 -1
  106. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts +0 -30
  107. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.d.ts.map +0 -1
  108. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js +0 -22
  109. package/lib/esm/presentation-hierarchies-react/itwinui/TreeRenderer.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TreeModel.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/TreeModel.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAwDhG,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,IAAoE;IAC3G,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;AAC3D,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,mBAAmB,CAAC,IAAoE;IACtG,OAAO,MAAM,IAAI,IAAI,IAAI,IAAI,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,SAAS,CAAC;IAClC,CAAC;IAXe,sBAAY,eAW3B,CAAA;AACH,CAAC,EA/HgB,SAAS,KAAT,SAAS,QA+HzB;AAED,SAAS,eAAe,CAAC,KAAgB,EAAE,MAA0B,EAAE,MAAkE;IACvI,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACvB,KAAK,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,SAAS,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,CAAC;IAClB,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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 { GenericInstanceFilter, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\n\n/** @internal */\nexport interface TreeModelRootNode {\n id: undefined;\n nodeData: undefined;\n hierarchyLimit?: number | \"unbounded\";\n instanceFilter?: GenericInstanceFilter;\n isLoading?: boolean;\n}\n\n/** @internal */\nexport interface TreeModelHierarchyNode {\n id: string;\n nodeData: HierarchyNode;\n label: string;\n children: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isSelected?: boolean;\n hierarchyLimit?: number | \"unbounded\";\n instanceFilter?: GenericInstanceFilter;\n}\n\n/** @internal */\nexport interface TreeModelGenericInfoNode {\n id: string;\n parentId: string | undefined;\n type: \"Unknown\";\n message: string;\n}\n\n/** @internal */\nexport interface TreeModelNoFilterMatchesInfoNode {\n id: string;\n parentId: string | undefined;\n type: \"NoFilterMatches\";\n}\n\n/** @internal */\nexport interface TreeModelResultSetTooLargeInfoNode {\n id: string;\n parentId: string | undefined;\n type: \"ResultSetTooLarge\";\n resultSetSizeLimit: number;\n}\n\n/** @internal */\nexport type TreeModelInfoNode = TreeModelGenericInfoNode | TreeModelResultSetTooLargeInfoNode | TreeModelNoFilterMatchesInfoNode;\n\n/** @internal */\nexport type TreeModelNode = TreeModelHierarchyNode | TreeModelInfoNode;\n\n/** @internal */\nexport function isTreeModelHierarchyNode(node: TreeModelHierarchyNode | TreeModelInfoNode | TreeModelRootNode): node is TreeModelHierarchyNode {\n return \"nodeData\" in node && node.nodeData !== undefined;\n}\n\n/** @internal */\nexport function isTreeModelInfoNode(node: TreeModelHierarchyNode | TreeModelInfoNode | TreeModelRootNode): node is TreeModelInfoNode {\n return \"type\" in node && node.type !== undefined;\n}\n\n/** @internal */\nexport interface TreeModel {\n parentChildMap: Map<string | undefined, string[]>;\n idToNode: Map<string, TreeModelNode>;\n rootNode: TreeModelRootNode;\n}\n\n/** @internal */\nexport namespace TreeModel {\n export function expandNode(model: TreeModel, nodeId: string, isExpanded: boolean): \"none\" | \"loadChildren\" | \"reloadChildren\" {\n const node = model.idToNode.get(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return \"none\";\n }\n\n node.isExpanded = isExpanded;\n if (!isExpanded || !node.children) {\n return \"none\";\n }\n\n const children = model.parentChildMap.get(node.id);\n if (!children) {\n node.isLoading = true;\n return \"loadChildren\";\n }\n\n if (children.length !== 1) {\n return \"none\";\n }\n\n const firstChild = TreeModel.getNode(model, children[0]);\n if (!firstChild || !isTreeModelInfoNode(firstChild) || firstChild.type !== \"Unknown\") {\n return \"none\";\n }\n\n // remove subtree if there is only one `Unknown` info node in order to attempt reloading children\n TreeModel.removeSubTree(model, nodeId);\n node.isLoading = true;\n return \"reloadChildren\";\n }\n\n /** @internal */\n export function addHierarchyPart(model: TreeModel, rootId: string | undefined, hierarchyPart: TreeModel): void {\n removeSubTree(model, rootId);\n\n for (const [parentId, children] of hierarchyPart.parentChildMap) {\n model.parentChildMap.set(parentId, children);\n }\n\n for (const [nodeId, node] of hierarchyPart.idToNode) {\n model.idToNode.set(nodeId, node);\n }\n\n const parentNode = rootId !== undefined ? model.idToNode.get(rootId) : model.rootNode;\n /* c8 ignore next 3*/\n if (!parentNode || isTreeModelInfoNode(parentNode)) {\n return;\n }\n parentNode.isLoading = false;\n }\n\n export function removeSubTree(model: TreeModel, parentId: string | undefined): void {\n const currentChildren = model.parentChildMap.get(parentId);\n if (!currentChildren) {\n return;\n }\n model.parentChildMap.delete(parentId);\n\n for (const childId of currentChildren) {\n const childNode = model.idToNode.get(childId);\n if (childNode && isTreeModelHierarchyNode(childNode)) {\n removeSubTree(model, childNode.id);\n }\n model.idToNode.delete(childId);\n }\n }\n\n export function setHierarchyLimit(model: TreeModel, nodeId: string | undefined, limit?: number | \"unbounded\"): boolean {\n return updateForReload(model, nodeId, (node) => {\n node.hierarchyLimit = limit;\n });\n }\n\n export function setInstanceFilter(model: TreeModel, nodeId: string | undefined, filter?: GenericInstanceFilter): boolean {\n return updateForReload(model, nodeId, (node) => {\n if (filter && isTreeModelHierarchyNode(node)) {\n node.isExpanded = true;\n }\n node.instanceFilter = filter;\n });\n }\n\n export function selectNodes(model: TreeModel, nodeIds: Array<string>, changeType: SelectionChangeType) {\n if (changeType === \"replace\") {\n for (const [nodeId, node] of model.idToNode) {\n if (!isTreeModelHierarchyNode(node)) {\n continue;\n }\n node.isSelected = !!nodeIds.find((id) => id === nodeId);\n }\n return;\n }\n for (const nodeId of nodeIds) {\n const modelNode = model.idToNode.get(nodeId);\n if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {\n return;\n }\n modelNode.isSelected = changeType === \"add\";\n }\n }\n\n export function isNodeSelected(model: TreeModel, nodeId: string): boolean {\n const currentNode = model.idToNode.get(nodeId);\n return !!currentNode && isTreeModelHierarchyNode(currentNode) && !!currentNode.isSelected;\n }\n\n export function getNode(model: TreeModel, nodeId: string | undefined): TreeModelNode | TreeModelRootNode | undefined {\n if (!nodeId) {\n return model.rootNode;\n }\n return model.idToNode.get(nodeId);\n }\n\n export function setIsLoading(model: TreeModel, nodeId: string | undefined, isLoading: boolean) {\n if (nodeId === undefined) {\n model.rootNode.isLoading = isLoading;\n return;\n }\n const modelNode = model.idToNode.get(nodeId);\n /* c8 ignore next 3*/\n if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {\n return;\n }\n modelNode.isLoading = isLoading;\n }\n}\n\nfunction updateForReload(model: TreeModel, nodeId: string | undefined, update: (node: TreeModelHierarchyNode | TreeModelRootNode) => void) {\n TreeModel.removeSubTree(model, nodeId);\n if (nodeId === undefined) {\n update(model.rootNode);\n model.rootNode.isLoading = true;\n return true;\n }\n\n const modelNode = model.idToNode.get(nodeId);\n if (!modelNode || !isTreeModelHierarchyNode(modelNode)) {\n return false;\n }\n\n update(modelNode);\n if (modelNode.isExpanded) {\n modelNode.isLoading = true;\n return true;\n }\n return false;\n}\n"]}
1
+ {"version":3,"file":"TreeModel.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/TreeModel.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AA8BhG,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,IAA4D;IACnG,OAAO,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;AAC3D,CAAC;AASD,gBAAgB;AAChB,MAAM,KAAW,SAAS,CA6HzB;AA7HD,WAAiB,SAAS;IACxB,SAAgB,UAAU,CAAC,KAAgB,EAAE,MAAc,EAAE,UAAmB;QAC9E,MAAM,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AC;IACf,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,CAAC;IAClB,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAgB,EAAE,QAA4B;IACpE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;IACT,CAAC;IACD,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;AACzB,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 { GenericInstanceFilter, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { ErrorInfo } from \"../TreeNode.js\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\n\n/** @internal */\nexport interface TreeModelRootNode {\n id: undefined;\n nodeData: undefined;\n hierarchyLimit?: number | \"unbounded\";\n instanceFilter?: GenericInstanceFilter;\n isLoading?: boolean;\n error?: ErrorInfo;\n}\n\n/** @internal */\nexport interface TreeModelHierarchyNode {\n id: string;\n nodeData: HierarchyNode;\n label: string;\n children: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isSelected?: boolean;\n hierarchyLimit?: number | \"unbounded\";\n instanceFilter?: GenericInstanceFilter;\n error?: ErrorInfo;\n}\n\n/** @internal */\nexport function isTreeModelHierarchyNode(node: TreeModelHierarchyNode | ErrorInfo | TreeModelRootNode): node is TreeModelHierarchyNode {\n return \"nodeData\" in node && node.nodeData !== undefined;\n}\n\n/** @internal */\nexport interface TreeModel {\n parentChildMap: Map<string | undefined, string[]>;\n idToNode: Map<string, TreeModelHierarchyNode>;\n rootNode: TreeModelRootNode;\n}\n\n/** @internal */\nexport namespace TreeModel {\n export function expandNode(model: TreeModel, nodeId: string, isExpanded: boolean): \"none\" | \"loadChildren\" | \"reloadChildren\" {\n const node = model.idToNode.get(nodeId);\n if (!node) {\n return \"none\";\n }\n\n node.isExpanded = isExpanded;\n if (!isExpanded) {\n return \"none\";\n }\n\n if (node.error?.type === \"Unknown\") {\n node.isLoading = true;\n // remove subtree if there `Unknown` error info in order to attempt reloading children\n TreeModel.removeSubTree(model, nodeId);\n return \"reloadChildren\";\n }\n\n if (!node.children) {\n return \"none\";\n }\n\n const children = model.parentChildMap.get(node.id);\n if (!children) {\n node.isLoading = true;\n return \"loadChildren\";\n }\n\n return \"none\";\n }\n\n /** @internal */\n export function addHierarchyPart(model: TreeModel, rootId: string | undefined, hierarchyPart: TreeModel): void {\n removeSubTree(model, rootId);\n model.rootNode.error = hierarchyPart.rootNode.error;\n\n for (const [parentId, children] of hierarchyPart.parentChildMap) {\n model.parentChildMap.set(parentId, children);\n }\n\n for (const [nodeId, node] of hierarchyPart.idToNode) {\n model.idToNode.set(nodeId, node);\n }\n\n const parentNode = rootId !== undefined ? model.idToNode.get(rootId) : model.rootNode;\n /* c8 ignore next 3*/\n if (!parentNode) {\n return;\n }\n parentNode.isLoading = false;\n }\n\n export function removeSubTree(model: TreeModel, parentId: string | undefined): void {\n clearNodeError(model, parentId);\n const currentChildren = model.parentChildMap.get(parentId);\n if (!currentChildren) {\n return;\n }\n model.parentChildMap.delete(parentId);\n\n for (const childId of currentChildren) {\n const childNode = model.idToNode.get(childId);\n if (childNode) {\n removeSubTree(model, childNode.id);\n }\n model.idToNode.delete(childId);\n }\n }\n\n export function setHierarchyLimit(model: TreeModel, nodeId: string | undefined, limit?: number | \"unbounded\"): boolean {\n return updateForReload(model, nodeId, (node) => {\n node.hierarchyLimit = limit;\n });\n }\n\n export function setInstanceFilter(model: TreeModel, nodeId: string | undefined, filter?: GenericInstanceFilter): boolean {\n return updateForReload(model, nodeId, (node) => {\n if (filter && node.id !== undefined) {\n node.isExpanded = true;\n }\n node.instanceFilter = filter;\n });\n }\n\n export function selectNodes(model: TreeModel, nodeIds: Array<string>, changeType: SelectionChangeType) {\n if (changeType === \"replace\") {\n for (const [nodeId, node] of model.idToNode) {\n node.isSelected = !!nodeIds.find((id) => id === nodeId);\n }\n return;\n }\n for (const nodeId of nodeIds) {\n const modelNode = model.idToNode.get(nodeId);\n if (!modelNode) {\n return;\n }\n modelNode.isSelected = changeType === \"add\";\n }\n }\n\n export function isNodeSelected(model: TreeModel, nodeId: string): boolean {\n const currentNode = model.idToNode.get(nodeId);\n return !!currentNode && !!currentNode.isSelected;\n }\n\n export function getNode(model: TreeModel, nodeId: string | undefined): TreeModelHierarchyNode | TreeModelRootNode | undefined {\n if (!nodeId) {\n return model.rootNode;\n }\n return model.idToNode.get(nodeId);\n }\n\n export function setIsLoading(model: TreeModel, nodeId: string | undefined, isLoading: boolean) {\n if (nodeId === undefined) {\n model.rootNode.isLoading = isLoading;\n return;\n }\n const modelNode = model.idToNode.get(nodeId);\n /* c8 ignore next 3*/\n if (!modelNode) {\n return;\n }\n modelNode.isLoading = isLoading;\n }\n}\n\nfunction updateForReload(model: TreeModel, nodeId: string | undefined, update: (node: TreeModelHierarchyNode | TreeModelRootNode) => void) {\n TreeModel.removeSubTree(model, nodeId);\n if (nodeId === undefined) {\n update(model.rootNode);\n model.rootNode.isLoading = true;\n return true;\n }\n\n const modelNode = model.idToNode.get(nodeId);\n if (!modelNode) {\n return false;\n }\n\n update(modelNode);\n if (modelNode.isExpanded) {\n modelNode.isLoading = true;\n return true;\n }\n return false;\n}\n\nfunction clearNodeError(model: TreeModel, parentId: string | undefined) {\n if (!parentId) {\n return (model.rootNode.error = undefined);\n }\n const node = model.idToNode.get(parentId);\n if (!node) {\n return;\n }\n node.error = undefined;\n}\n"]}
@@ -1,6 +1,7 @@
1
- import { SelectionStorage } from "@itwin/unified-selection";
1
+ import { GenericNodeKey, NonGroupingHierarchyNode } from "@itwin/presentation-hierarchies";
2
+ import { Selectable, SelectionStorage } from "@itwin/unified-selection";
2
3
  import { SelectionChangeType } from "../UseSelectionHandler.js";
3
- import { TreeModelNode, TreeModelRootNode } from "./TreeModel.js";
4
+ import { TreeModelHierarchyNode, TreeModelRootNode } from "./TreeModel.js";
4
5
  /** @internal */
5
6
  export interface TreeSelectionOptions {
6
7
  isNodeSelected: (nodeId: string) => boolean;
@@ -13,16 +14,29 @@ export interface UseUnifiedTreeSelectionProps {
13
14
  */
14
15
  sourceName: string;
15
16
  /**
16
- * Unified selection storage to use for listening, getting and changing active selection.
17
+ * An optional function that allows customizing the `Selectable` object that gets created for generic hierarchy nodes. When
18
+ * not supplied, the `Selectable` is created using the following signature:
19
+ * ```ts
20
+ * {
21
+ * identifier: treeModelNodeId,
22
+ * data: node,
23
+ * async *loadInstanceKeys() {},
24
+ * }
25
+ * ```
17
26
  *
18
- * When not specified, the deprecated unified selection React context is used to access the
19
- * selection storage (see `UnifiedSelectionProvider`). This prop will be made required in the
20
- * next major release, where the deprecated context will also be removed.
27
+ * @param node Hierarchy node to create a selectable for.
28
+ * @param treeModelNodeId ID of the hierarchy node in the internal tree model. This ID uniquely identifies the node in the whole hierarchy, as opposed to `GenericNodeKey.id` contained within the `node`, which may not be unique.
29
+ */
30
+ createSelectableForGenericNode?: (node: NonGroupingHierarchyNode & {
31
+ key: GenericNodeKey;
32
+ }, treeModelNodeId: string) => Selectable;
33
+ /**
34
+ * Unified selection storage to use for listening, getting and changing active selection.
21
35
  */
22
- selectionStorage?: SelectionStorage;
36
+ selectionStorage: SelectionStorage;
23
37
  }
24
38
  /** @internal */
25
- export declare function useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, }: UseUnifiedTreeSelectionProps & {
26
- getTreeModelNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined;
39
+ export declare function useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, createSelectableForGenericNode, }: UseUnifiedTreeSelectionProps & {
40
+ getTreeModelNode: (nodeId: string) => TreeModelHierarchyNode | TreeModelRootNode | undefined;
27
41
  }): TreeSelectionOptions;
28
42
  //# sourceMappingURL=UseUnifiedSelection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UseUnifiedSelection.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AASA,OAAO,EAA2B,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAErF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAoD,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpH,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChF;AAED,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE,4BAA4B,GAAG;IAAE,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,aAAa,GAAG,iBAAiB,GAAG,SAAS,CAAA;CAAE,GAAG,oBAAoB,CA6B/I"}
1
+ {"version":3,"file":"UseUnifiedSelection.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAmC,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE5H,OAAO,EAAE,UAAU,EAAe,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE3E,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,WAAW,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChF;AAED,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;OAaG;IACH,8BAA8B,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,GAAG;QAAE,GAAG,EAAE,cAAc,CAAA;KAAE,EAAE,eAAe,EAAE,MAAM,KAAK,UAAU,CAAC;IAEnI;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,gBAAgB;AAChB,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,8BAAsE,GACvE,EAAE,4BAA4B,GAAG;IAAE,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,sBAAsB,GAAG,iBAAiB,GAAG,SAAS,CAAA;CAAE,GAAG,oBAAoB,CAiBxJ"}
@@ -6,43 +6,36 @@ import { useEffect, useState } from "react";
6
6
  import { assert } from "@itwin/core-bentley";
7
7
  import { HierarchyNode } from "@itwin/presentation-hierarchies";
8
8
  import { Selectables } from "@itwin/unified-selection";
9
- import { useUnifiedSelectionStorage } from "../UnifiedSelectionContext.js";
10
- import { isTreeModelHierarchyNode } from "./TreeModel.js";
11
9
  /** @internal */
12
- export function useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, }) {
10
+ export function useUnifiedTreeSelection({ sourceName, selectionStorage, getTreeModelNode, createSelectableForGenericNode = defaultCreateSelectableForGenericNode, }) {
13
11
  const [options, setOptions] = useState(() => ({
14
12
  isNodeSelected: /* c8 ignore next */ () => false,
15
13
  selectNodes: /* c8 ignore next */ () => { },
16
14
  }));
17
- const deprecatedSelectionStorage = useUnifiedSelectionStorage();
18
- selectionStorage ??= deprecatedSelectionStorage;
19
15
  useEffect(() => {
20
- if (!selectionStorage) {
21
- // TODO: make selectionStorage prop required
22
- setOptions({
23
- isNodeSelected: () => false,
24
- selectNodes: () => { },
25
- });
26
- return;
27
- }
28
- setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));
16
+ setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));
29
17
  return selectionStorage.selectionChangeEvent.addListener((args) => {
30
18
  if (args.level > 0) {
31
19
  return;
32
20
  }
33
- setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));
21
+ setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));
34
22
  });
35
- }, [selectionStorage, getTreeModelNode, sourceName]);
23
+ }, [selectionStorage, createSelectableForGenericNode, getTreeModelNode, sourceName]);
36
24
  return options;
37
25
  }
38
- function createOptions(source, storage, getNode) {
26
+ const defaultCreateSelectableForGenericNode = (node, treeModelNodeId) => ({
27
+ identifier: treeModelNodeId,
28
+ data: node,
29
+ async *loadInstanceKeys() { },
30
+ });
31
+ function createOptions(source, storage, createSelectableForGenericNode, getNode) {
39
32
  return {
40
33
  isNodeSelected: (nodeId) => {
41
34
  const node = getNode(nodeId);
42
- if (!node || !isTreeModelHierarchyNode(node)) {
35
+ if (!node || node?.id === undefined) {
43
36
  return false;
44
37
  }
45
- return Object.entries(groupNodeSelectablesByIModelKey(node)).some(([imodelKey, nodeSelectables]) => {
38
+ return Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).some(([imodelKey, nodeSelectables]) => {
46
39
  const storageSelectables = storage.getSelection({ imodelKey, level: 0 });
47
40
  return Selectables.hasAny(storageSelectables, nodeSelectables);
48
41
  });
@@ -51,10 +44,10 @@ function createOptions(source, storage, getNode) {
51
44
  const imodelSelectables = {};
52
45
  for (const nodeId of nodeIds) {
53
46
  const node = getNode(nodeId);
54
- if (!node || !isTreeModelHierarchyNode(node)) {
47
+ if (!node || node?.id === undefined) {
55
48
  return;
56
49
  }
57
- Object.entries(groupNodeSelectablesByIModelKey(node)).forEach(([imodelKey, nodeSelectables]) => {
50
+ Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).forEach(([imodelKey, nodeSelectables]) => {
58
51
  let selectablesList = imodelSelectables[imodelKey];
59
52
  if (!selectablesList) {
60
53
  selectablesList = [];
@@ -80,7 +73,7 @@ function createOptions(source, storage, getNode) {
80
73
  },
81
74
  };
82
75
  }
83
- function groupNodeSelectablesByIModelKey(modelNode) {
76
+ function groupNodeSelectablesByIModelKey(modelNode, createSelectableForGenericNode) {
84
77
  const hierarchyNode = modelNode.nodeData;
85
78
  if (HierarchyNode.isInstancesNode(hierarchyNode)) {
86
79
  return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);
@@ -104,13 +97,7 @@ function groupNodeSelectablesByIModelKey(modelNode) {
104
97
  assert(HierarchyNode.isGeneric(hierarchyNode));
105
98
  return {
106
99
  // note: generic nodes aren't associated with an imodel
107
- [""]: [
108
- {
109
- identifier: modelNode.id,
110
- data: hierarchyNode,
111
- async *loadInstanceKeys() { },
112
- },
113
- ],
100
+ [""]: [createSelectableForGenericNode(hierarchyNode, modelNode.id)],
114
101
  };
115
102
  }
116
103
  function groupIModelInstanceKeys(instanceKeys) {
@@ -1 +1 @@
1
- {"version":3,"file":"UseUnifiedSelection.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"m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AC,uBAAuB,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CACtF,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;YACjD,GAAG,iBAAiB;YACpB,CAAC,SAAS,CAAC,EAAE;gBACX;oBACE,UAAU,EAAE,SAAS,CAAC,EAAE;oBACxB,IAAI,EAAE,aAAa;oBACnB,KAAK,CAAC,CAAC,gBAAgB;wBACrB,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;4BAC/B,MAAM,GAAG,CAAC;wBACZ,CAAC;oBACH,CAAC;iBACF;aACF;SACF,CAAC,EACF,EAA2C,CAC5C,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,uDAAuD;QACvD,CAAC,EAAE,CAAC,EAAE;YACJ;gBACE,UAAU,EAAE,SAAS,CAAC,EAAE;gBACxB,IAAI,EAAE,aAAa;gBACnB,KAAK,CAAC,CAAC,gBAAgB,KAAI,CAAC;aAC7B;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,YAA8C;IAC7E,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,iBAAiB,EAAE,GAAG,EAAE,EAAE;QACzB,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,eAAe,GAAG,EAAE,CAAC;YACrB,iBAAiB,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC;QACjD,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EACD,EAA4C,CAC7C,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 { useEffect, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { HierarchyNode, InstancesNodeKey } from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables, SelectionStorage } from \"@itwin/unified-selection\";\nimport { useUnifiedSelectionStorage } from \"../UnifiedSelectionContext.js\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\nimport { isTreeModelHierarchyNode, TreeModelHierarchyNode, TreeModelNode, TreeModelRootNode } from \"./TreeModel.js\";\n\n/** @internal */\nexport interface TreeSelectionOptions {\n isNodeSelected: (nodeId: string) => boolean;\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n}\n\n/** @public */\nexport interface UseUnifiedTreeSelectionProps {\n /**\n * Identifier to distinguish this source of changes to the unified selection from another ones in the application.\n */\n sourceName: string;\n\n /**\n * Unified selection storage to use for listening, getting and changing active selection.\n *\n * When not specified, the deprecated unified selection React context is used to access the\n * selection storage (see `UnifiedSelectionProvider`). This prop will be made required in the\n * next major release, where the deprecated context will also be removed.\n */\n selectionStorage?: SelectionStorage;\n}\n\n/** @internal */\nexport function useUnifiedTreeSelection({\n sourceName,\n selectionStorage,\n getTreeModelNode,\n}: UseUnifiedTreeSelectionProps & { getTreeModelNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined }): TreeSelectionOptions {\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: /* c8 ignore next */ () => false,\n selectNodes: /* c8 ignore next */ () => {},\n }));\n\n const deprecatedSelectionStorage = useUnifiedSelectionStorage();\n selectionStorage ??= deprecatedSelectionStorage;\n\n useEffect(() => {\n if (!selectionStorage) {\n // TODO: make selectionStorage prop required\n setOptions({\n isNodeSelected: () => false,\n selectNodes: () => {},\n });\n return;\n }\n\n setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));\n return selectionStorage.selectionChangeEvent.addListener((args) => {\n if (args.level > 0) {\n return;\n }\n setOptions(createOptions(sourceName, selectionStorage, getTreeModelNode));\n });\n }, [selectionStorage, getTreeModelNode, sourceName]);\n\n return options;\n}\n\nfunction createOptions(\n source: string,\n storage: SelectionStorage,\n getNode: (nodeId: string) => TreeModelNode | TreeModelRootNode | undefined,\n): TreeSelectionOptions {\n return {\n isNodeSelected: (nodeId: string) => {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return false;\n }\n return Object.entries(groupNodeSelectablesByIModelKey(node)).some(([imodelKey, nodeSelectables]) => {\n const storageSelectables = storage.getSelection({ imodelKey, level: 0 });\n return Selectables.hasAny(storageSelectables, nodeSelectables);\n });\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n const imodelSelectables: { [imodelKey: string]: Selectable[] } = {};\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || !isTreeModelHierarchyNode(node)) {\n return;\n }\n Object.entries(groupNodeSelectablesByIModelKey(node)).forEach(([imodelKey, nodeSelectables]) => {\n let selectablesList = imodelSelectables[imodelKey];\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n nodeSelectables.forEach((selectable) => selectablesList.push(selectable));\n });\n }\n Object.entries(imodelSelectables).forEach(([imodelKey, selectables]) => {\n const actionProps = { imodelKey, source, selectables, level: 0 };\n switch (changeType) {\n case \"add\":\n storage.addToSelection(actionProps);\n return;\n case \"remove\":\n storage.removeFromSelection(actionProps);\n return;\n case \"replace\":\n storage.replaceSelection(actionProps);\n return;\n }\n });\n },\n };\n}\n\nfunction groupNodeSelectablesByIModelKey(modelNode: TreeModelHierarchyNode): { [imodelKey: string]: Selectable[] } {\n const hierarchyNode = modelNode.nodeData;\n if (HierarchyNode.isInstancesNode(hierarchyNode)) {\n return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);\n }\n if (HierarchyNode.isGroupingNode(hierarchyNode)) {\n return Object.entries(groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys)).reduce(\n (imodelSelectables, [imodelKey, instanceKeys]) => ({\n ...imodelSelectables,\n [imodelKey]: [\n {\n identifier: modelNode.id,\n data: hierarchyNode,\n async *loadInstanceKeys() {\n for (const key of instanceKeys) {\n yield key;\n }\n },\n },\n ],\n }),\n {} as { [imodelKey: string]: Selectable[] },\n );\n }\n assert(HierarchyNode.isGeneric(hierarchyNode));\n return {\n // note: generic nodes aren't associated with an imodel\n [\"\"]: [\n {\n identifier: modelNode.id,\n data: hierarchyNode,\n async *loadInstanceKeys() {},\n },\n ],\n };\n}\n\nfunction groupIModelInstanceKeys(instanceKeys: InstancesNodeKey[\"instanceKeys\"]) {\n return instanceKeys.reduce(\n (imodelSelectables, key) => {\n const imodelKey = key.imodelKey ?? \"\";\n let selectablesList = imodelSelectables[imodelKey];\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n selectablesList.push(key);\n return imodelSelectables;\n },\n {} as { [imodelKey: string]: InstanceKey[] },\n );\n}\n"]}
1
+ {"version":3,"file":"UseUnifiedSelection.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAkB,aAAa,EAA8C,MAAM,iCAAiC,CAAC;AAE5H,OAAO,EAAc,WAAW,EAAoB,MAAM,0BAA0B,CAAC;AAuCrF,gBAAgB;AAChB,MAAM,UAAU,uBAAuB,CAAC,EACtC,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,8BAA8B,GAAG,qCAAqC,GAC0D;IAChI,MAAM,CAAC,OAAO,EAAE,UAAU,C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AAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,uDAAuD;QACvD,CAAC,EAAE,CAAC,EAAE,CAAC,8BAA8B,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,YAA8C;IAC7E,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,iBAAiB,EAAE,GAAG,EAAE,EAAE;QACzB,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,eAAe,GAAG,EAAE,CAAC;YACrB,iBAAiB,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC;QACjD,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EACD,EAA4C,CAC7C,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 { useEffect, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { GenericNodeKey, HierarchyNode, InstancesNodeKey, NonGroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { InstanceKey } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables, SelectionStorage } from \"@itwin/unified-selection\";\nimport { SelectionChangeType } from \"../UseSelectionHandler.js\";\nimport { TreeModelHierarchyNode, TreeModelRootNode } from \"./TreeModel.js\";\n\n/** @internal */\nexport interface TreeSelectionOptions {\n isNodeSelected: (nodeId: string) => boolean;\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => void;\n}\n\n/** @public */\nexport interface UseUnifiedTreeSelectionProps {\n /**\n * Identifier to distinguish this source of changes to the unified selection from another ones in the application.\n */\n sourceName: string;\n\n /**\n * An optional function that allows customizing the `Selectable` object that gets created for generic hierarchy nodes. When\n * not supplied, the `Selectable` is created using the following signature:\n * ```ts\n * {\n * identifier: treeModelNodeId,\n * data: node,\n * async *loadInstanceKeys() {},\n * }\n * ```\n *\n * @param node Hierarchy node to create a selectable for.\n * @param treeModelNodeId ID of the hierarchy node in the internal tree model. This ID uniquely identifies the node in the whole hierarchy, as opposed to `GenericNodeKey.id` contained within the `node`, which may not be unique.\n */\n createSelectableForGenericNode?: (node: NonGroupingHierarchyNode & { key: GenericNodeKey }, treeModelNodeId: string) => Selectable;\n\n /**\n * Unified selection storage to use for listening, getting and changing active selection.\n */\n selectionStorage: SelectionStorage;\n}\n\n/** @internal */\nexport function useUnifiedTreeSelection({\n sourceName,\n selectionStorage,\n getTreeModelNode,\n createSelectableForGenericNode = defaultCreateSelectableForGenericNode,\n}: UseUnifiedTreeSelectionProps & { getTreeModelNode: (nodeId: string) => TreeModelHierarchyNode | TreeModelRootNode | undefined }): TreeSelectionOptions {\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: /* c8 ignore next */ () => false,\n selectNodes: /* c8 ignore next */ () => {},\n }));\n\n useEffect(() => {\n setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));\n return selectionStorage.selectionChangeEvent.addListener((args) => {\n if (args.level > 0) {\n return;\n }\n setOptions(createOptions(sourceName, selectionStorage, createSelectableForGenericNode, getTreeModelNode));\n });\n }, [selectionStorage, createSelectableForGenericNode, getTreeModelNode, sourceName]);\n\n return options;\n}\n\nconst defaultCreateSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]> = (\n node,\n treeModelNodeId,\n): Selectable => ({\n identifier: treeModelNodeId,\n data: node,\n async *loadInstanceKeys() {},\n});\n\nfunction createOptions(\n source: string,\n storage: SelectionStorage,\n createSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]>,\n getNode: (nodeId: string) => TreeModelHierarchyNode | TreeModelRootNode | undefined,\n): TreeSelectionOptions {\n return {\n isNodeSelected: (nodeId: string) => {\n const node = getNode(nodeId);\n if (!node || node?.id === undefined) {\n return false;\n }\n return Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).some(([imodelKey, nodeSelectables]) => {\n const storageSelectables = storage.getSelection({ imodelKey, level: 0 });\n return Selectables.hasAny(storageSelectables, nodeSelectables);\n });\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n const imodelSelectables: { [imodelKey: string]: Selectable[] } = {};\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || node?.id === undefined) {\n return;\n }\n Object.entries(groupNodeSelectablesByIModelKey(node, createSelectableForGenericNode)).forEach(([imodelKey, nodeSelectables]) => {\n let selectablesList = imodelSelectables[imodelKey];\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n nodeSelectables.forEach((selectable) => selectablesList.push(selectable));\n });\n }\n Object.entries(imodelSelectables).forEach(([imodelKey, selectables]) => {\n const actionProps = { imodelKey, source, selectables, level: 0 };\n switch (changeType) {\n case \"add\":\n storage.addToSelection(actionProps);\n return;\n case \"remove\":\n storage.removeFromSelection(actionProps);\n return;\n case \"replace\":\n storage.replaceSelection(actionProps);\n return;\n }\n });\n },\n };\n}\n\nfunction groupNodeSelectablesByIModelKey(\n modelNode: TreeModelHierarchyNode,\n createSelectableForGenericNode: NonNullable<UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]>,\n): { [imodelKey: string]: Selectable[] } {\n const hierarchyNode = modelNode.nodeData;\n if (HierarchyNode.isInstancesNode(hierarchyNode)) {\n return groupIModelInstanceKeys(hierarchyNode.key.instanceKeys);\n }\n if (HierarchyNode.isGroupingNode(hierarchyNode)) {\n return Object.entries(groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys)).reduce(\n (imodelSelectables, [imodelKey, instanceKeys]) => ({\n ...imodelSelectables,\n [imodelKey]: [\n {\n identifier: modelNode.id,\n data: hierarchyNode,\n async *loadInstanceKeys() {\n for (const key of instanceKeys) {\n yield key;\n }\n },\n },\n ],\n }),\n {} as { [imodelKey: string]: Selectable[] },\n );\n }\n assert(HierarchyNode.isGeneric(hierarchyNode));\n return {\n // note: generic nodes aren't associated with an imodel\n [\"\"]: [createSelectableForGenericNode(hierarchyNode, modelNode.id)],\n };\n}\n\nfunction groupIModelInstanceKeys(instanceKeys: InstancesNodeKey[\"instanceKeys\"]) {\n return instanceKeys.reduce(\n (imodelSelectables, key) => {\n const imodelKey = key.imodelKey ?? \"\";\n let selectablesList = imodelSelectables[imodelKey];\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables[imodelKey] = selectablesList;\n }\n selectablesList.push(key);\n return imodelSelectables;\n },\n {} as { [imodelKey: string]: InstanceKey[] },\n );\n}\n"]}
@@ -0,0 +1,34 @@
1
+ import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
2
+ import { PresentationHierarchyNode } from "../TreeNode.js";
3
+ /** @alpha */
4
+ export type FilterActionProps = {
5
+ /** Action to perform when the filter button is clicked for this node. */
6
+ onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
7
+ /**
8
+ * Indicates that space for this action button should be reserved, even when the action is not available.
9
+ * For nodes that don't support filtering, `<FilterAction reserveSpace />` renders:
10
+ *
11
+ * - Blank space when the action is used as an inline action. It's recommended to set this prop to keep all action buttons of the same kind vertically aligned.
12
+ * - Disabled menu item when the action is used as a menu action.
13
+ */
14
+ reserveSpace?: true;
15
+ } & Pick<TreeRendererProps, "getHierarchyLevelDetails">;
16
+ /**
17
+ * React component that renders a filter action for a tree item.
18
+ * @alpha
19
+ */
20
+ export declare const FilterAction: import("react").NamedExoticComponent<{
21
+ /** Action to perform when the filter button is clicked for this node. */
22
+ onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
23
+ /**
24
+ * Indicates that space for this action button should be reserved, even when the action is not available.
25
+ * For nodes that don't support filtering, `<FilterAction reserveSpace />` renders:
26
+ *
27
+ * - Blank space when the action is used as an inline action. It's recommended to set this prop to keep all action buttons of the same kind vertically aligned.
28
+ * - Disabled menu item when the action is used as a menu action.
29
+ */
30
+ reserveSpace?: true;
31
+ } & Pick<TreeRendererProps, "getHierarchyLevelDetails"> & {
32
+ node: PresentationHierarchyNode;
33
+ }>;
34
+ //# sourceMappingURL=FilterAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterAction.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FilterAction.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAG3D,aAAa;AACb,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAClE;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC;CACrB,GAAG,IAAI,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,YAAY;IAhBvB,yEAAyE;eAC9D,CAAC,qBAAqB,EAAE,qBAAqB,KAAK,IAAI;IACjE;;;;;;OAMG;mBACY,IAAI;;UAYU,yBAAyB;EAsBtD,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } 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 { memo, useCallback } from "react";
7
+ import filterSvg from "@stratakit/icons/filter.svg";
8
+ import { Tree } from "@stratakit/structures";
9
+ import { useLocalizationContext } from "./LocalizationContext.js";
10
+ /**
11
+ * React component that renders a filter action for a tree item.
12
+ * @alpha
13
+ */
14
+ export const FilterAction = memo(function FilterAction({ node, onFilter, getHierarchyLevelDetails, reserveSpace, }) {
15
+ const { localizedStrings } = useLocalizationContext();
16
+ const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;
17
+ const handleClick = useCallback(() => {
18
+ const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);
19
+ hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);
20
+ }, [node, getHierarchyLevelDetails, onFilter]);
21
+ if (!onFilter || !node.isFilterable) {
22
+ return reserveSpace ? _jsx(Tree.ItemAction, { label: filterHierarchyLevel, icon: filterSvg, visible: false, disabled: true }) : undefined;
23
+ }
24
+ return (_jsx(Tree.ItemAction, { label: filterHierarchyLevel, onClick: handleClick, icon: filterSvg, visible: node.isFiltered ? true : undefined, dot: node.isFiltered ? filterHierarchyLevelActiveDescription : undefined }));
25
+ });
26
+ //# sourceMappingURL=FilterAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterAction.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FilterAction.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAgBlE;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,YAAY,CAAC,EACrD,IAAI,EACJ,QAAQ,EACR,wBAAwB,EACxB,YAAY,GAC4C;IACxD,MAAM,EAAE,gBAAgB,EAAE,GAAG,sBAAsB,EAAE,CAAC;IACtD,MAAM,EAAE,oBAAoB,EAAE,qCAAqC,EAAE,GAAG,gBAAgB,CAAC;IAEzF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClE,qBAAqB,IAAI,QAAQ,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAC7D,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE/C,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACpC,OAAO,YAAY,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,UAAU,IAAC,KAAK,EAAE,oBAAoB,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,SAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/H,CAAC;IAED,OAAO,CACL,KAAC,IAAI,CAAC,UAAU,IACd,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,WAAW,EACpB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC3C,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,SAAS,GACxE,CACH,CAAC;AACJ,CAAC,CAAC,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 { memo, useCallback } from \"react\";\nimport filterSvg from \"@stratakit/icons/filter.svg\";\nimport { Tree } from \"@stratakit/structures\";\nimport { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\nimport { useLocalizationContext } from \"./LocalizationContext.js\";\n\n/** @alpha */\nexport type FilterActionProps = {\n /** Action to perform when the filter button is clicked for this node. */\n onFilter?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n /**\n * Indicates that space for this action button should be reserved, even when the action is not available.\n * For nodes that don't support filtering, `<FilterAction reserveSpace />` renders:\n *\n * - Blank space when the action is used as an inline action. It's recommended to set this prop to keep all action buttons of the same kind vertically aligned.\n * - Disabled menu item when the action is used as a menu action.\n */\n reserveSpace?: true;\n} & Pick<TreeRendererProps, \"getHierarchyLevelDetails\">;\n\n/**\n * React component that renders a filter action for a tree item.\n * @alpha\n */\nexport const FilterAction = memo(function FilterAction({\n node,\n onFilter,\n getHierarchyLevelDetails,\n reserveSpace,\n}: FilterActionProps & { node: PresentationHierarchyNode }) {\n const { localizedStrings } = useLocalizationContext();\n const { filterHierarchyLevel, filterHierarchyLevelActiveDescription } = localizedStrings;\n\n const handleClick = useCallback(() => {\n const hierarchyLevelDetails = getHierarchyLevelDetails?.(node.id);\n hierarchyLevelDetails && onFilter?.(hierarchyLevelDetails);\n }, [node, getHierarchyLevelDetails, onFilter]);\n\n if (!onFilter || !node.isFilterable) {\n return reserveSpace ? <Tree.ItemAction label={filterHierarchyLevel} icon={filterSvg} visible={false} disabled /> : undefined;\n }\n\n return (\n <Tree.ItemAction\n label={filterHierarchyLevel}\n onClick={handleClick}\n icon={filterSvg}\n visible={node.isFiltered ? true : undefined}\n dot={node.isFiltered ? filterHierarchyLevelActiveDescription : undefined}\n />\n );\n});\n"]}
@@ -0,0 +1,58 @@
1
+ import { PresentationHierarchyNode } from "../TreeNode.js";
2
+ /**
3
+ * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.
4
+ *
5
+ * @alpha
6
+ * */
7
+ interface FlatPlaceholderItem {
8
+ id: string;
9
+ level: number;
10
+ placeholder: true;
11
+ }
12
+ /**
13
+ * An item containing `PresentationHierarchyNode` node with properties needed for a flat tree structure.
14
+ *
15
+ * @alpha
16
+ */
17
+ export interface FlatTreeNodeItem {
18
+ id: string;
19
+ level: number;
20
+ levelSize: number;
21
+ posInLevel: number;
22
+ node: PresentationHierarchyNode;
23
+ }
24
+ /**
25
+ * An item used to build an error message.
26
+ * Returned by `useErrorList`.
27
+ *
28
+ * @alpha
29
+ * */
30
+ export interface ErrorItem {
31
+ errorNode: PresentationHierarchyNode;
32
+ expandTo: (expandNode: (nodeId: string) => void) => void;
33
+ }
34
+ /**
35
+ * An Item describing single tree item position and its content inside tree.
36
+ * Returned by `useFlatTreeNodeList` hook.
37
+ *
38
+ * @alpha
39
+ */
40
+ export type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;
41
+ /** @alpha */
42
+ export declare function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem;
43
+ /**
44
+ * Used to get a list of `FlatTreeItem` objects for the given list of `PresentationHierarchyNode` objects that represent
45
+ * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
46
+ * virtualized list.
47
+ *
48
+ * @alpha
49
+ */
50
+ export declare function useFlatTreeItems(rootNodes: PresentationHierarchyNode[]): FlatTreeItem[];
51
+ /**
52
+ * Finds and returns all items containing errors in a given hierarchy in the form of `ErrorItem[]`.
53
+ *
54
+ * @alpha
55
+ */
56
+ export declare function useErrorList(rootNodes: PresentationHierarchyNode[]): ErrorItem[];
57
+ export {};
58
+ //# sourceMappingURL=FlatTreeNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlatTreeNode.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;;;KAIK;AACL,UAAU,mBAAmB;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,IAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,yBAAyB,CAAC;CACjC;AAED;;;;;KAKK;AACL,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,yBAAyB,CAAC;IACrC,QAAQ,EAAE,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAElE,aAAa;AACb,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,IAAI,mBAAmB,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,yBAAyB,EAAE,kBAEtE;AAoBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,yBAAyB,EAAE,GAAG,SAAS,EAAE,CAchF"}
@@ -0,0 +1,74 @@
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 { useMemo } from "react";
6
+ /** @alpha */
7
+ export function isPlaceholderItem(item) {
8
+ return "placeholder" in item;
9
+ }
10
+ /**
11
+ * Used to get a list of `FlatTreeItem` objects for the given list of `PresentationHierarchyNode` objects that represent
12
+ * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
13
+ * virtualized list.
14
+ *
15
+ * @alpha
16
+ */
17
+ export function useFlatTreeItems(rootNodes) {
18
+ return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);
19
+ }
20
+ function getFlatItems(nodes, level) {
21
+ const flatItems = [];
22
+ nodes.forEach((node, index) => {
23
+ flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });
24
+ if (!node.isExpanded || node.error) {
25
+ return;
26
+ }
27
+ if (node.children !== true) {
28
+ const childNodes = getFlatItems(node.children, level + 1);
29
+ flatItems.push(...childNodes);
30
+ return;
31
+ }
32
+ flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true });
33
+ });
34
+ return flatItems;
35
+ }
36
+ /**
37
+ * Finds and returns all items containing errors in a given hierarchy in the form of `ErrorItem[]`.
38
+ *
39
+ * @alpha
40
+ */
41
+ export function useErrorList(rootNodes) {
42
+ return useMemo(() => rootNodes.flatMap((rootNode) => {
43
+ if (!!rootNode.error) {
44
+ return [{ errorNode: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];
45
+ }
46
+ if (rootNode.children === true) {
47
+ return [];
48
+ }
49
+ return getErrorItems(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);
50
+ }), [rootNodes]);
51
+ }
52
+ function getErrorItems(parent, path) {
53
+ const errorList = [];
54
+ if (parent.children === true) {
55
+ return [];
56
+ }
57
+ const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];
58
+ parent.children.forEach((node) => {
59
+ if (!!node.error) {
60
+ errorList.push({ errorNode: node, expandTo: (expandNode) => expandTo(expandNode, path) });
61
+ return;
62
+ }
63
+ if (node.children !== true) {
64
+ const childErrorList = getErrorItems(node, pathToChild);
65
+ errorList.push(...childErrorList);
66
+ return;
67
+ }
68
+ });
69
+ return errorList;
70
+ }
71
+ function expandTo(expandNode, path) {
72
+ path.forEach((nodeId) => expandNode(nodeId));
73
+ }
74
+ //# sourceMappingURL=FlatTreeNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FlatTreeNode.js","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AA8ChC,aAAa;AACb,MAAM,UAAU,iBAAiB,CAAC,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,EAAE,CAAC;YAC3B,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACxD,SAAS,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YAClC,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,UAAoC,EAAE,IAAc;IACpE,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/C,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 { useMemo } from \"react\";\nimport { PresentationHierarchyNode } from \"../TreeNode.js\";\n\n/**\n * Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.\n *\n * @alpha\n * */\ninterface FlatPlaceholderItem {\n id: string;\n level: number;\n placeholder: true;\n}\n\n/**\n * An item containing `PresentationHierarchyNode` node with properties needed for a flat tree structure.\n *\n * @alpha\n */\nexport interface FlatTreeNodeItem {\n id: string;\n level: number;\n levelSize: number;\n posInLevel: number;\n node: PresentationHierarchyNode;\n}\n\n/**\n * An item used to build an error message.\n * Returned by `useErrorList`.\n *\n * @alpha\n * */\nexport interface ErrorItem {\n errorNode: PresentationHierarchyNode;\n expandTo: (expandNode: (nodeId: string) => void) => void;\n}\n\n/**\n * An Item describing single tree item position and its content inside tree.\n * Returned by `useFlatTreeNodeList` hook.\n *\n * @alpha\n */\nexport type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;\n\n/** @alpha */\nexport function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem {\n return \"placeholder\" in item;\n}\n\n/**\n * Used to get a list of `FlatTreeItem` objects for the given list of `PresentationHierarchyNode` objects that represent\n * a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a\n * virtualized list.\n *\n * @alpha\n */\nexport function useFlatTreeItems(rootNodes: PresentationHierarchyNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: PresentationHierarchyNode[], level: number) {\n const flatItems: FlatTreeItem[] = [];\n nodes.forEach((node, index) => {\n flatItems.push({ node, id: node.id, level, levelSize: nodes.length, posInLevel: index + 1 });\n if (!node.isExpanded || node.error) {\n return;\n }\n if (node.children !== true) {\n const childNodes = getFlatItems(node.children, level + 1);\n flatItems.push(...childNodes);\n return;\n }\n\n flatItems.push({ id: `${node.id}-children-placeholder`, level: level + 1, placeholder: true } satisfies FlatPlaceholderItem);\n });\n return flatItems;\n}\n\n/**\n * Finds and returns all items containing errors in a given hierarchy in the form of `ErrorItem[]`.\n *\n * @alpha\n */\nexport function useErrorList(rootNodes: PresentationHierarchyNode[]): ErrorItem[] {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (!!rootNode.error) {\n return [{ errorNode: rootNode, expandTo: (expandNode) => expandTo(expandNode, []) }];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorItems(rootNode, !rootNode.isExpanded ? [rootNode.id] : []);\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorItems(parent: PresentationHierarchyNode, path: string[]) {\n const errorList: ErrorItem[] = [];\n\n if (parent.children === true) {\n return [];\n }\n\n const pathToChild = [...path, ...(!parent.isExpanded ? [parent.id] : [])];\n parent.children.forEach((node) => {\n if (!!node.error) {\n errorList.push({ errorNode: node, expandTo: (expandNode) => expandTo(expandNode, path) });\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorItems(node, pathToChild);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction expandTo(expandNode: (nodeId: string) => void, path: string[]) {\n path.forEach((nodeId) => expandNode(nodeId));\n}\n"]}
@@ -14,6 +14,11 @@ export interface LocalizedStrings {
14
14
  * Default value: `Apply filter`.
15
15
  */
16
16
  filterHierarchyLevel: string;
17
+ /**
18
+ * Accesible description for applied hierarchy filter button.
19
+ * Default value: `Filter is applied`.
20
+ */
21
+ filterHierarchyLevelActiveDescription: string;
17
22
  /**
18
23
  * Title for clear hierarchy filter button.
19
24
  * Default value: `Clear active filter`.
@@ -21,27 +26,52 @@ export interface LocalizedStrings {
21
26
  clearHierarchyLevelFilter: string;
22
27
  /**
23
28
  * Message displayed when no nodes matching filter are found.
24
- * Default value: `No child nodes match current filter`.
29
+ * Default value: `No matches for current filter for {{node}}.`.
25
30
  */
26
31
  noFilteredChildren: string;
32
+ /**
33
+ * Label for change filter action.
34
+ * Default value: `Change filter`.
35
+ */
36
+ noFilteredChildrenChangeFilter: string;
37
+ /**
38
+ * Message displayed when hierarchy creation for a node failed.
39
+ * Default value: `Failed to create hierarchy for {{node}}.`.
40
+ */
41
+ failedToCreateHierarchy: string;
42
+ /**
43
+ * Message displayed when hierarchy creation for a node failed.
44
+ * Default value: `Failed to load tree.`.
45
+ */
46
+ failedToCreateRootHierarchy: string;
27
47
  /**
28
48
  * Message displayed when result limit exceeds hierarchy size limit.
29
- * Default value: `There are more items than allowed limit of {{limit}}.`.
49
+ * Default value: `The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.`.
30
50
  */
31
51
  resultLimitExceeded: string;
32
52
  /**
33
- * Message displayed when result limit exceeds hierarchy size limit and hierarchy filtering is enabled.
34
- * Default value: `Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.`.
53
+ * Message displayed when result limit exceeds hierarchy size limit.
54
+ * Default value: `The root item hierarchy contains {{limit}}+ items. Try increasing the limit.`.
55
+ */
56
+ rootResultLimitExceeded: string;
57
+ /**
58
+ * Label displayed on error dropdown.
59
+ * Default value: `issues found`.
35
60
  */
36
- resultLimitExceededWithFiltering: string;
61
+ issuesFound: string;
37
62
  /**
38
63
  * Message displayed when hierarchy size limit can be overridden.
39
- * Default value: `<link>Increase the hierarchy level size limit to {{limit}}.</link>`.
64
+ * Default value: `Increase limit to {{limit}}`.
40
65
  */
41
66
  increaseHierarchyLimit: string;
67
+ /**
68
+ * Message displayed when hierarchy size limit can be overridden.
69
+ * Default value: `Remove limit`.
70
+ */
71
+ increaseHierarchyLimitToUnlimited: string;
42
72
  /**
43
73
  * Message displayed when hierarchy size limit can be overridden and hierarchy filtering is enabled.
44
- * Default value: `Or, <link>increase the hierarchy level size limit to {{limit}}.</link>`.
74
+ * Default value: `Add Filter`.
45
75
  */
46
76
  increaseHierarchyLimitWithFiltering: string;
47
77
  /**
@@ -49,6 +79,16 @@ export interface LocalizedStrings {
49
79
  * Default value: `Retry`.
50
80
  */
51
81
  retry: string;
82
+ /**
83
+ * Label for rename action.
84
+ * Default value: `Rename`.
85
+ */
86
+ rename: string;
87
+ /**
88
+ * Label for more actions button.
89
+ * Default value: `More`.
90
+ */
91
+ more: string;
52
92
  }
53
93
  /** @internal */
54
94
  export interface LocalizationContext {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalizationContext.d.ts","sourceRoot":"","sources":["../../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAiB,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,qCAAqC,EAAE,MAAM,CAAC;IAC9C;;;OAGG;IACH,yBAAyB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,8BAA8B,EAAE,MAAM,CAAC;IACvC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;OAGG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,iCAAiC,EAAE,MAAM,CAAC;IAC1C;;;OAGG;IACH,mCAAmC,EAAE,MAAM,CAAC;IAC5C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAwBD;;;GAGG;AACH,UAAU,gCAAgC;IACxC,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,iBAAiB,CAAC,gCAAgC,CAAC,2CAQ9H;AAED,gBAAgB;AAChB,wBAAgB,sBAAsB,wBAErC"}
@@ -7,13 +7,21 @@ import { createContext, useContext, useEffect, useState } from "react";
7
7
  const defaultLocalizedStrings = {
8
8
  loading: "Loading...",
9
9
  filterHierarchyLevel: "Apply filter",
10
+ filterHierarchyLevelActiveDescription: "Filter is applied",
10
11
  clearHierarchyLevelFilter: "Clear active filter",
11
- noFilteredChildren: "No child nodes match current filter",
12
- resultLimitExceeded: "There are more items than allowed limit of {{limit}}.",
13
- resultLimitExceededWithFiltering: "Please provide <link>additional filtering</link> - there are more items than allowed limit of {{limit}}.",
14
- increaseHierarchyLimit: "<link>Increase the hierarchy level size limit to {{limit}}.</link>",
15
- increaseHierarchyLimitWithFiltering: "Or, <link>increase the hierarchy level size limit to {{limit}}.</link>",
12
+ noFilteredChildren: "No matches for current filter for {{node}}.",
13
+ noFilteredChildrenChangeFilter: "Change filter",
14
+ failedToCreateHierarchy: "Failed to create hierarchy for {{node}}.",
15
+ failedToCreateRootHierarchy: "Failed to load tree.",
16
+ resultLimitExceeded: "The hierarchy for {{node}} contains {{limit}}+ items. Try using filters or increase the limit.",
17
+ rootResultLimitExceeded: "The root item hierarchy contains {{limit}}+ items. Try increasing the limit.",
18
+ issuesFound: "issues found",
19
+ increaseHierarchyLimit: "Increase limit to {{limit}}",
20
+ increaseHierarchyLimitToUnlimited: "Remove limit",
21
+ increaseHierarchyLimitWithFiltering: "Add Filter",
16
22
  retry: "Retry",
23
+ rename: "Rename",
24
+ more: "More",
17
25
  };
18
26
  const localizationContext = createContext({ localizedStrings: defaultLocalizedStrings });
19
27
  /**