@itwin/presentation-hierarchies-react 2.0.0-alpha.62 → 2.0.0-alpha.64

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 (69) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +62 -37
  3. package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts +1 -2
  4. package/lib/presentation-hierarchies-react/FlatTreeNode.d.ts.map +1 -1
  5. package/lib/presentation-hierarchies-react/FlatTreeNode.js.map +1 -1
  6. package/lib/presentation-hierarchies-react/LocalizationContext.d.ts +1 -5
  7. package/lib/presentation-hierarchies-react/LocalizationContext.d.ts.map +1 -1
  8. package/lib/presentation-hierarchies-react/LocalizationContext.js.map +1 -1
  9. package/lib/presentation-hierarchies-react/Renderers.d.ts +0 -1
  10. package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -1
  11. package/lib/presentation-hierarchies-react/TreeNode.d.ts +1 -2
  12. package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -1
  13. package/lib/presentation-hierarchies-react/UseIModelTree.d.ts +0 -1
  14. package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -1
  15. package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -1
  16. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +1 -4
  17. package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -1
  18. package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -1
  19. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +1 -0
  20. package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -1
  21. package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -1
  22. package/lib/presentation-hierarchies-react/UseTree.d.ts +4 -11
  23. package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -1
  24. package/lib/presentation-hierarchies-react/UseTree.js +3 -2
  25. package/lib/presentation-hierarchies-react/UseTree.js.map +1 -1
  26. package/lib/presentation-hierarchies-react/Utils.js.map +1 -1
  27. package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -1
  28. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -1
  29. package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -1
  30. package/lib/presentation-hierarchies-react/internal/TreeActions.js +5 -0
  31. package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -1
  32. package/lib/presentation-hierarchies-react/internal/TreeLoader.js +3 -0
  33. package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -1
  34. package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +2 -0
  35. package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -1
  36. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +2 -1
  37. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -1
  38. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +1 -1
  39. package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -1
  40. package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -1
  41. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +1 -9
  42. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -1
  43. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +53 -46
  44. package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -1
  45. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +2 -7
  46. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -1
  47. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +5 -4
  48. package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -1
  49. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +6 -4
  50. package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -1
  51. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +37 -13
  52. package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -1
  53. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +1 -7
  54. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -1
  55. package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -1
  56. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +0 -1
  57. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -1
  58. package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -1
  59. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -1
  60. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -1
  61. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +3 -0
  62. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -1
  63. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +152 -140
  64. package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -1
  65. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +0 -1
  66. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -1
  67. package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -1
  68. package/lib/presentation-hierarchies-react-extract.d.ts +2 -1
  69. package/package.json +43 -35
@@ -1 +1 @@
1
- {"version":3,"file":"TreeModel.js","names":["GenericInstanceFilter","HierarchyNode","ErrorInfo","SelectionChangeType","TreeModelRootNode","id","nodeData","hierarchyLimit","instanceFilter","isLoading","error","TreeModelHierarchyNode","label","children","isExpanded","isSelected","TreeModel","parentChildMap","Map","idToNode","rootNode","expandNode","model","nodeId","node","get","type","removeSubTree","addHierarchyPart","rootId","hierarchyPart","parentId","set","parentNode","undefined","clearNodeError","currentChildren","delete","childId","childNode","setHierarchyLimit","limit","updateForReload","setInstanceFilter","filter","selectNodes","nodeIds","Array","changeType","find","modelNode","isNodeSelected","currentNode","getNode","setIsLoading","update"],"sources":["../../../src/presentation-hierarchies-react/internal/TreeModel.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport type { GenericInstanceFilter, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { ErrorInfo } from \"../TreeNode.js\";\nimport type { 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 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(\n model: TreeModel,\n nodeId: string,\n isExpanded: boolean,\n ): \"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 === \"ChildrenLoad\") {\n node.isLoading = true;\n // remove subtree if there `ChildrenLoad` 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 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(\n model: TreeModel,\n nodeId: string | undefined,\n limit?: number | \"unbounded\",\n ): boolean {\n return updateForReload(model, nodeId, (node) => {\n node.hierarchyLimit = limit;\n });\n }\n\n export function setInstanceFilter(\n model: TreeModel,\n nodeId: string | undefined,\n filter?: GenericInstanceFilter,\n ): 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(\n model: TreeModel,\n nodeId: string | undefined,\n ): 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 if (!modelNode) {\n return;\n }\n modelNode.isLoading = isLoading;\n }\n}\n\nfunction updateForReload(\n model: TreeModel,\n nodeId: string | undefined,\n update: (node: TreeModelHierarchyNode | TreeModelRootNode) => void,\n) {\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 const node = !parentId ? model.rootNode : model.idToNode.get(parentId);\n if (node) {\n node.error = undefined;\n }\n}\n"],"mappings":";AAyCO,IAAA;;CACE,SAASqB,WACdC,OACAC,QACAT,YAC4C;EAC5C,MAAMU,OAAOF,MAAMH,SAASM,IAAIF,OAAO;AACvC,MAAI,CAACC,KACH,QAAO;AAGTA,OAAKV,aAAaA;AAClB,MAAI,CAACA,WACH,QAAO;AAGT,MAAIU,KAAKd,OAAOgB,SAAS,gBAAgB;AACvCF,QAAKf,YAAY;AAEjBO,aAAUW,cAAcL,OAAOC,OAAO;AACtC,UAAO;;AAGT,MAAI,CAACC,KAAKX,SACR,QAAO;AAIT,MAAI,CADaS,MAAML,eAAeQ,IAAID,KAAKnB,GAAG,EACnC;AACbmB,QAAKf,YAAY;AACjB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"file":"TreeModel.js","names":["GenericInstanceFilter","HierarchyNode","ErrorInfo","SelectionChangeType","TreeModelRootNode","id","nodeData","hierarchyLimit","instanceFilter","isLoading","error","TreeModelHierarchyNode","label","children","isExpanded","isSelected","TreeModel","parentChildMap","Map","idToNode","rootNode","expandNode","model","nodeId","node","get","type","removeSubTree","addHierarchyPart","rootId","hierarchyPart","parentId","set","parentNode","undefined","clearNodeError","currentChildren","delete","childId","childNode","setHierarchyLimit","limit","updateForReload","setInstanceFilter","filter","selectNodes","nodeIds","Array","changeType","find","modelNode","isNodeSelected","currentNode","getNode","setIsLoading","update"],"sources":["../../../src/presentation-hierarchies-react/internal/TreeModel.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport type { GenericInstanceFilter, HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { ErrorInfo } from \"../TreeNode.js\";\nimport type { 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 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(\n model: TreeModel,\n nodeId: string,\n isExpanded: boolean,\n ): \"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 === \"ChildrenLoad\") {\n node.isLoading = true;\n // remove subtree if there `ChildrenLoad` 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 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(\n model: TreeModel,\n nodeId: string | undefined,\n limit?: number | \"unbounded\",\n ): boolean {\n return updateForReload(model, nodeId, (node) => {\n node.hierarchyLimit = limit;\n });\n }\n\n export function setInstanceFilter(\n model: TreeModel,\n nodeId: string | undefined,\n filter?: GenericInstanceFilter,\n ): 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(\n model: TreeModel,\n nodeId: string | undefined,\n ): 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 if (!modelNode) {\n return;\n }\n modelNode.isLoading = isLoading;\n }\n}\n\nfunction updateForReload(\n model: TreeModel,\n nodeId: string | undefined,\n update: (node: TreeModelHierarchyNode | TreeModelRootNode) => void,\n) {\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 const node = !parentId ? model.rootNode : model.idToNode.get(parentId);\n if (node) {\n node.error = undefined;\n }\n}\n"],"mappings":";AAyCO,IAAUgB;CAAV,SAAA,YAAA;CACE,SAASK,WACdC,OACAC,QACAT,YAC4C;EAC5C,MAAMU,OAAOF,MAAMH,SAASM,IAAIF,MAAM;EACtC,IAAI,CAACC,MACH,OAAO;EAGTA,KAAKV,aAAaA;EAClB,IAAI,CAACA,YACH,OAAO;EAGT,IAAIU,KAAK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MAAMH,SAASM,IAAIF,MAAM;CAC3C,IAAI,CAAC2B,WACH,OAAO;CAGTK,OAAOL,SAAS;CAChB,IAAIA,UAAUpC,YAAY;EACxBoC,UAAUzC,YAAY;EACtB,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS0B,eAAeb,OAAkBS,UAA8B;CACtE,MAAMP,OAAO,CAACO,WAAWT,MAAMF,WAAWE,MAAMH,SAASM,IAAIM,QAAQ;CACrE,IAAIP,MACFA,KAAKd,QAAQwB,KAAAA;AAEjB"}
@@ -1,6 +1,7 @@
1
+ import "../UseSelectionHandler.js";
2
+ import "./TreeModel.js";
1
3
  import { GenericNodeKey, NonGroupingHierarchyNode } from "@itwin/presentation-hierarchies";
2
4
  import { Selectable, SelectionStorage } from "@itwin/unified-selection";
3
-
4
5
  //#region src/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts
5
6
  /** @public */
6
7
  interface UseUnifiedTreeSelectionProps {
@@ -1 +1 @@
1
- {"version":3,"file":"UseUnifiedSelection.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"mappings":";;;;;UAuBiB,4BAAA;EAuBV;;;EAnBL,UAAA;EAAA;;;;;;;;;;;;;;EAgBA,8BAAA,IACE,IAAA,EAAM,wBAAA;IAA6B,GAAA,EAAK,cAAA;EAAA,GACxC,eAAA,aACG,UAAA;;;;EAKL,gBAAA,EAAkB,gBAAA;AAAA"}
1
+ {"version":3,"file":"UseUnifiedSelection.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"mappings":";;;;;;UAuBiB;;;;EAIf;;;;;;;;;;;;;;;EAgBA,kCACE,MAAM;IAA6B,KAAK;KACxC,4BACG;;;;EAKL,kBAAkB"}
@@ -121,7 +121,7 @@ function groupNodeSelectablesByIModelKey(modelNode, createSelectableForGenericNo
121
121
  return groupingNodeSelectables;
122
122
  }
123
123
  assert(HierarchyNode.isGeneric(hierarchyNode));
124
- return new Map([["", [createSelectableForGenericNode(hierarchyNode, modelNode.id)]]]);
124
+ return /* @__PURE__ */ new Map([["", [createSelectableForGenericNode(hierarchyNode, modelNode.id)]]]);
125
125
  }
126
126
  function groupIModelInstanceKeys(instanceKeys) {
127
127
  return instanceKeys.reduce((imodelSelectables, key) => {
@@ -1 +1 @@
1
- {"version":3,"file":"UseUnifiedSelection.js","names":["useEffect","useState","assert","HierarchyNode","Selectables","GenericNodeKey","InstancesNodeKey","NonGroupingHierarchyNode","InstanceKey","Selectable","SelectionStorage","SelectionChangeType","TreeModelHierarchyNode","TreeModelRootNode","TreeSelectionOptions","isNodeSelected","nodeId","selectNodes","nodeIds","Array","changeType","UseUnifiedTreeSelectionProps","sourceName","createSelectableForGenericNode","node","key","treeModelNodeId","selectionStorage","useUnifiedTreeSelection","t0","$","_c","getTreeModelNode","t1","undefined","defaultCreateSelectableForGenericNode","options","setOptions","_temp3","t2","t3","createOptions","selectionChangeEvent","addListener","args","level","_temp","_temp2","NonNullable","identifier","data","loadInstanceKeys","source","storage","getNode","id","imodelKey","nodeSelectables","groupNodeSelectablesByIModelKey","storageSelectables","getSelection","hasAny","imodelSelectables","Map","selectablesList","get","set","forEach","selectable","push","selectables","actionProps","addToSelection","removeFromSelection","replaceSelection","modelNode","hierarchyNode","nodeData","isInstancesNode","groupIModelInstanceKeys","instanceKeys","isGroupingNode","groupingNodeSelectables","groupedInstanceKeys","isGeneric","reduce"],"sources":["../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { Selectables } from \"@itwin/unified-selection\";\n\nimport type { GenericNodeKey, InstancesNodeKey, NonGroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { Selectable, SelectionStorage } from \"@itwin/unified-selection\";\nimport type { SelectionChangeType } from \"../UseSelectionHandler.js\";\nimport type { 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?: (\n node: NonGroupingHierarchyNode & { key: GenericNodeKey },\n treeModelNodeId: string,\n ) => 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 & {\n getTreeModelNode: (nodeId: string) => TreeModelHierarchyNode | TreeModelRootNode | undefined;\n}): TreeSelectionOptions {\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: () => false,\n selectNodes: () => {},\n }));\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\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<\n UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]\n> = (node, treeModelNodeId): Selectable => ({ identifier: treeModelNodeId, data: node, async *loadInstanceKeys() {} });\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 for (const [imodelKey, nodeSelectables] of groupNodeSelectablesByIModelKey(\n node,\n createSelectableForGenericNode,\n )) {\n const storageSelectables = storage.getSelection({ imodelKey, level: 0 });\n if (Selectables.hasAny(storageSelectables, nodeSelectables)) {\n return true;\n }\n }\n return false;\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n const imodelSelectables = new Map<string, Selectable[]>();\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || node.id === undefined) {\n return;\n }\n for (const [imodelKey, nodeSelectables] of groupNodeSelectablesByIModelKey(\n node,\n createSelectableForGenericNode,\n )) {\n let selectablesList = imodelSelectables.get(imodelKey);\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables.set(imodelKey, selectablesList);\n }\n nodeSelectables.forEach((selectable) => selectablesList.push(selectable));\n }\n }\n imodelSelectables.forEach((selectables, imodelKey) => {\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): Map<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 const groupingNodeSelectables = new Map<string, Selectable[]>();\n groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys).forEach((instanceKeys, imodelKey) => {\n groupingNodeSelectables.set(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 return groupingNodeSelectables;\n }\n assert(HierarchyNode.isGeneric(hierarchyNode));\n // note: generic nodes aren't associated with an imodel\n return new Map([[\"\", [createSelectableForGenericNode(hierarchyNode, modelNode.id)]]]);\n}\n\nfunction groupIModelInstanceKeys(instanceKeys: InstancesNodeKey[\"instanceKeys\"]) {\n return instanceKeys.reduce((imodelSelectables, key) => {\n const imodelKey = key.imodelKey ?? \"\";\n let selectablesList = imodelSelectables.get(imodelKey);\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables.set(imodelKey, selectablesList);\n }\n selectablesList.push(key);\n return imodelSelectables;\n }, new Map<string, InstanceKey[]>());\n}\n"],"mappings":";;;;;;;AAuDA,SAAO4B,wBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAiC,MAAA,EAAAT,YAAAK,kBAAAK,kBAAAT,gCAAAU,OAAAJ;CAItC,MAAAN,iCAAAU,OAAAC,KAAAA,IAAAC,wCAAAF;CAIA,MAAA,CAAAG,SAAAC,cAA8BpC,SAA+BqC,OAG1D;CAAC,IAAAC;CAAA,IAAAC;AAAA,KAAAV,EAAA,OAAAP,kCAAAO,EA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Ib,IAAI,CAAC,CAAC,IAAI,CAACxC,+BAA+BqD,eAAeD,UAAUpB,GAAG,CAAC,CAAC,CAAC,CAAC;;AAGvF,SAASwB,wBAAwBC,cAAgD;AAC/E,QAAOA,aAAaK,QAAQvB,mBAAmBrC,QAAQ;EACrD,MAAM+B,YAAY/B,IAAI+B,aAAa;EACnC,IAAIQ,kBAAkBF,kBAAkBG,IAAIT,UAAU;AACtD,MAAI,CAACQ,iBAAiB;AACpBA,qBAAkB,EAAE;AACpBF,qBAAkBI,IAAIV,WAAWQ,gBAAgB;;AAEnDA,kBAAgBK,KAAK5C,IAAI;AACzB,SAAOqC;oBACN,IAAIC,KAA4B,CAAC"}
1
+ {"version":3,"file":"UseUnifiedSelection.js","names":["useEffect","useState","assert","HierarchyNode","Selectables","GenericNodeKey","InstancesNodeKey","NonGroupingHierarchyNode","InstanceKey","Selectable","SelectionStorage","SelectionChangeType","TreeModelHierarchyNode","TreeModelRootNode","TreeSelectionOptions","isNodeSelected","nodeId","selectNodes","nodeIds","Array","changeType","UseUnifiedTreeSelectionProps","sourceName","createSelectableForGenericNode","node","key","treeModelNodeId","selectionStorage","useUnifiedTreeSelection","t0","$","_c","getTreeModelNode","t1","undefined","defaultCreateSelectableForGenericNode","options","setOptions","_temp3","t2","t3","createOptions","selectionChangeEvent","addListener","args","level","_temp","_temp2","NonNullable","identifier","data","loadInstanceKeys","source","storage","getNode","id","imodelKey","nodeSelectables","groupNodeSelectablesByIModelKey","storageSelectables","getSelection","hasAny","imodelSelectables","Map","selectablesList","get","set","forEach","selectable","push","selectables","actionProps","addToSelection","removeFromSelection","replaceSelection","modelNode","hierarchyNode","nodeData","isInstancesNode","groupIModelInstanceKeys","instanceKeys","isGroupingNode","groupingNodeSelectables","groupedInstanceKeys","isGeneric","reduce"],"sources":["../../../src/presentation-hierarchies-react/internal/UseUnifiedSelection.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { useEffect, useState } from \"react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { HierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport { Selectables } from \"@itwin/unified-selection\";\n\nimport type { GenericNodeKey, InstancesNodeKey, NonGroupingHierarchyNode } from \"@itwin/presentation-hierarchies\";\nimport type { InstanceKey } from \"@itwin/presentation-shared\";\nimport type { Selectable, SelectionStorage } from \"@itwin/unified-selection\";\nimport type { SelectionChangeType } from \"../UseSelectionHandler.js\";\nimport type { 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?: (\n node: NonGroupingHierarchyNode & { key: GenericNodeKey },\n treeModelNodeId: string,\n ) => 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 & {\n getTreeModelNode: (nodeId: string) => TreeModelHierarchyNode | TreeModelRootNode | undefined;\n}): TreeSelectionOptions {\n const [options, setOptions] = useState<TreeSelectionOptions>(() => ({\n isNodeSelected: () => false,\n selectNodes: () => {},\n }));\n\n useEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect\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<\n UseUnifiedTreeSelectionProps[\"createSelectableForGenericNode\"]\n> = (node, treeModelNodeId): Selectable => ({ identifier: treeModelNodeId, data: node, async *loadInstanceKeys() {} });\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 for (const [imodelKey, nodeSelectables] of groupNodeSelectablesByIModelKey(\n node,\n createSelectableForGenericNode,\n )) {\n const storageSelectables = storage.getSelection({ imodelKey, level: 0 });\n if (Selectables.hasAny(storageSelectables, nodeSelectables)) {\n return true;\n }\n }\n return false;\n },\n\n selectNodes: (nodeIds: Array<string>, changeType: SelectionChangeType) => {\n const imodelSelectables = new Map<string, Selectable[]>();\n for (const nodeId of nodeIds) {\n const node = getNode(nodeId);\n if (!node || node.id === undefined) {\n return;\n }\n for (const [imodelKey, nodeSelectables] of groupNodeSelectablesByIModelKey(\n node,\n createSelectableForGenericNode,\n )) {\n let selectablesList = imodelSelectables.get(imodelKey);\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables.set(imodelKey, selectablesList);\n }\n nodeSelectables.forEach((selectable) => selectablesList.push(selectable));\n }\n }\n imodelSelectables.forEach((selectables, imodelKey) => {\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): Map<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 const groupingNodeSelectables = new Map<string, Selectable[]>();\n groupIModelInstanceKeys(hierarchyNode.groupedInstanceKeys).forEach((instanceKeys, imodelKey) => {\n groupingNodeSelectables.set(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 return groupingNodeSelectables;\n }\n assert(HierarchyNode.isGeneric(hierarchyNode));\n // note: generic nodes aren't associated with an imodel\n return new Map([[\"\", [createSelectableForGenericNode(hierarchyNode, modelNode.id)]]]);\n}\n\nfunction groupIModelInstanceKeys(instanceKeys: InstancesNodeKey[\"instanceKeys\"]) {\n return instanceKeys.reduce((imodelSelectables, key) => {\n const imodelKey = key.imodelKey ?? \"\";\n let selectablesList = imodelSelectables.get(imodelKey);\n if (!selectablesList) {\n selectablesList = [];\n imodelSelectables.set(imodelKey, selectablesList);\n }\n selectablesList.push(key);\n return imodelSelectables;\n }, new Map<string, InstanceKey[]>());\n}\n"],"mappings":";;;;;;;AAuDA,SAAO4B,wBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAiC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EAC9DgB,wBAAwBH,cAAcO,mBAAmB,CAAC,CAAChB,SAASa,cAAcxB,cAAc;GAC9F0B,wBAAwBhB,IAAIV,WAAW,CACrC;IACEP,YAAY0B,UAAUpB;IACtBL,MAAM0B;IACN,OAAOzB,mBAAmB;KACxB,KAAK,MAAM1B,OAAOuD,cAChB,MAAMvD;IAEV;GACF,CAAC,CACF;EACH,CAAC;EACD,OAAOyD;CACT;CACAhF,OAAOC,cAAciF,UAAUR,aAAa,CAAC;CAE7C,uBAAO,IAAIb,IAAI,CAAC,CAAC,IAAI,CAACxC,+BAA+BqD,eAAeD,UAAUpB,EAAE,CAAC,CAAC,CAAC,CAAC;AACtF;AAEA,SAASwB,wBAAwBC,cAAgD;CAC/E,OAAOA,aAAaK,QAAQvB,mBAAmBrC,QAAQ;EACrD,MAAM+B,YAAY/B,IAAI+B,aAAa;EACnC,IAAIQ,kBAAkBF,kBAAkBG,IAAIT,SAAS;EACrD,IAAI,CAACQ,iBAAiB;GACpBA,kBAAkB,CAAA;GAClBF,kBAAkBI,IAAIV,WAAWQ,eAAe;EAClD;EACAA,gBAAgBK,KAAK5C,GAAG;EACxB,OAAOqC;CACT,mBAAG,IAAIC,IAA2B,CAAC;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","names":["HierarchyNodeKey","HierarchyNode","createNodeId","node","Pick","parentKeys","map","serializeNodeKey","key","join","convertObjectValuesToString","obj","Object","entries","value","String","sameNodes","lhs","rhs","compare","length","i","MAX_LIMIT_OVERRIDE","safeDispose","disposable","Symbol","dispose"],"sources":["../../../src/presentation-hierarchies-react/internal/Utils.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./DisposePolyfill.js\";\n\nimport { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport function createNodeId(node: Pick<HierarchyNode, \"key\" | \"parentKeys\">) {\n return [...node.parentKeys.map(serializeNodeKey), serializeNodeKey(node.key)].join(\";\");\n}\n\nfunction serializeNodeKey(key: HierarchyNodeKey): string {\n return convertObjectValuesToString(key);\n}\n\nfunction convertObjectValuesToString(obj: object): string {\n return Object.entries(obj)\n .map(([, value]) => {\n if (typeof value === \"object\") {\n return convertObjectValuesToString(value);\n }\n return String(value);\n })\n .join(\",\");\n}\n\n/** @internal */\nexport function sameNodes(lhs: HierarchyNode, rhs: HierarchyNode): boolean {\n if (HierarchyNodeKey.compare(lhs.key, rhs.key) !== 0) {\n return false;\n }\n\n if (lhs.parentKeys.length !== rhs.parentKeys.length) {\n return false;\n }\n\n for (let i = lhs.parentKeys.length - 1; i >= 0; --i) {\n if (HierarchyNodeKey.compare(lhs.parentKeys[i], rhs.parentKeys[i]) !== 0) {\n return false;\n }\n }\n return true;\n}\n\n/** @internal */\nexport const MAX_LIMIT_OVERRIDE = 10000;\n\n/**\n * A helper that disposes the given object, if it's disposable.\n *\n * The first option is to dispose using the deprecated `dispose` method if it exists on the object.\n * If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is\n * considered as non-disposable and nothing is done with it.\n *\n * @internal\n */\nexport function safeDispose(disposable: {} | { [Symbol.dispose]: () => void } | { dispose: () => void }) {\n if (\"dispose\" in disposable) {\n disposable.dispose();\n } else if (Symbol.dispose in disposable) {\n disposable[Symbol.dispose]();\n }\n}\n"],"mappings":";;;;AAYA,SAAgBE,aAAaC,MAAiD;AAC5E,QAAO,CAAC,GAAGA,KAAKE,WAAWC,IAAIC,iBAAiB,EAAEA,iBAAiBJ,KAAKK,IAAI,CAAC,CAACC,KAAK,IAAI;;AAGzF,SAASF,iBAAiBC,KAA+B;AACvD,QAAOE,4BAA4BF,IAAI;;AAGzC,SAASE,4BAA4BC,KAAqB;AACxD,QAAOC,OAAOC,QAAQF,IAAI,CACvBL,KAAK,GAAGQ,WAAW;AAClB,MAAI,OAAOA,UAAU,SACnB,QAAOJ,4BAA4BI,MAAM;AAE3C,SAAOC,OAAOD,MAAM;GACpB,CACDL,KAAK,IAAI;;;AAId,SAAgBO,UAAUC,KAAoBC,KAA6B;AACzE,KAAIlB,iBAAiBmB,QAAQF,IAAIT,KAAKU,IAAIV,IAAI,KAAK,EACjD,QAAO;AAGT,KAAIS,IAAIZ,WAAWe,WAAWF,IAAIb,WAAWe,OAC3C,QAAO;AAGT,MAAK,IAAIC,IAAIJ,IAAIZ,WAAWe,SAAS,GAAGC,KAAK,GAAG,EAAEA,EAChD,KAAIrB,iBAAiBmB,QAAQF,IAAIZ,WAAWgB,IAAIH,IAAIb,WAAWgB,GAAG,KAAK,EACrE,QAAO;AAGX,QAAO;;;AAIT,MAAaC,qBAAqB;;;;;;;;;;AAWlC,SAAgBC,YAAYC,YAA6E;AACvG,KAAI,aAAaA,WACfA,YAAWE,SAAS;UACXD,OAAOC,WAAWF,WAC3BA,YAAWC,OAAOC,UAAU"}
1
+ {"version":3,"file":"Utils.js","names":["HierarchyNodeKey","HierarchyNode","createNodeId","node","Pick","parentKeys","map","serializeNodeKey","key","join","convertObjectValuesToString","obj","Object","entries","value","String","sameNodes","lhs","rhs","compare","length","i","MAX_LIMIT_OVERRIDE","safeDispose","disposable","Symbol","dispose"],"sources":["../../../src/presentation-hierarchies-react/internal/Utils.ts"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./DisposePolyfill.js\";\n\nimport { HierarchyNodeKey } from \"@itwin/presentation-hierarchies\";\n\nimport type { HierarchyNode } from \"@itwin/presentation-hierarchies\";\n\n/** @internal */\nexport function createNodeId(node: Pick<HierarchyNode, \"key\" | \"parentKeys\">) {\n return [...node.parentKeys.map(serializeNodeKey), serializeNodeKey(node.key)].join(\";\");\n}\n\nfunction serializeNodeKey(key: HierarchyNodeKey): string {\n return convertObjectValuesToString(key);\n}\n\nfunction convertObjectValuesToString(obj: object): string {\n return Object.entries(obj)\n .map(([, value]) => {\n if (typeof value === \"object\") {\n return convertObjectValuesToString(value);\n }\n return String(value);\n })\n .join(\",\");\n}\n\n/** @internal */\nexport function sameNodes(lhs: HierarchyNode, rhs: HierarchyNode): boolean {\n if (HierarchyNodeKey.compare(lhs.key, rhs.key) !== 0) {\n return false;\n }\n\n if (lhs.parentKeys.length !== rhs.parentKeys.length) {\n return false;\n }\n\n for (let i = lhs.parentKeys.length - 1; i >= 0; --i) {\n if (HierarchyNodeKey.compare(lhs.parentKeys[i], rhs.parentKeys[i]) !== 0) {\n return false;\n }\n }\n return true;\n}\n\n/** @internal */\nexport const MAX_LIMIT_OVERRIDE = 10000;\n\n/**\n * A helper that disposes the given object, if it's disposable.\n *\n * The first option is to dispose using the deprecated `dispose` method if it exists on the object.\n * If not, we use the new `Symbol.dispose` method. If that doesn't exist either, the object is\n * considered as non-disposable and nothing is done with it.\n *\n * @internal\n */\nexport function safeDispose(disposable: {} | { [Symbol.dispose]: () => void } | { dispose: () => void }) {\n if (\"dispose\" in disposable) {\n disposable.dispose();\n } else if (Symbol.dispose in disposable) {\n disposable[Symbol.dispose]();\n }\n}\n"],"mappings":";;;;AAYA,SAAgBE,aAAaC,MAAiD;CAC5E,OAAO,CAAC,GAAGA,KAAKE,WAAWC,IAAIC,gBAAgB,GAAGA,iBAAiBJ,KAAKK,GAAG,CAAC,CAAC,CAACC,KAAK,GAAG;AACxF;AAEA,SAASF,iBAAiBC,KAA+B;CACvD,OAAOE,4BAA4BF,GAAG;AACxC;AAEA,SAASE,4BAA4BC,KAAqB;CACxD,OAAOC,OAAOC,QAAQF,GAAG,CAAC,CACvBL,KAAK,GAAGQ,WAAW;EAClB,IAAI,OAAOA,UAAU,UACnB,OAAOJ,4BAA4BI,KAAK;EAE1C,OAAOC,OAAOD,KAAK;CACrB,CAAC,CAAC,CACDL,KAAK,GAAG;AACb;;AAGA,SAAgBO,UAAUC,KAAoBC,KAA6B;CACzE,IAAIlB,iBAAiBmB,QAAQF,IAAIT,KAAKU,IAAIV,GAAG,MAAM,GACjD,OAAO;CAGT,IAAIS,IAAIZ,WAAWe,WAAWF,IAAIb,WAAWe,QAC3C,OAAO;CAGT,KAAK,IAAIC,IAAIJ,IAAIZ,WAAWe,SAAS,GAAGC,KAAK,GAAG,EAAEA,GAChD,IAAIrB,iBAAiBmB,QAAQF,IAAIZ,WAAWgB,IAAIH,IAAIb,WAAWgB,EAAE,MAAM,GACrE,OAAO;CAGX,OAAO;AACT;;AAGA,MAAaC,qBAAqB;;;;;;;;;;AAWlC,SAAgBC,YAAYC,YAA6E;CACvG,IAAI,aAAaA,YACfA,WAAWE,QAAQ;MACd,IAAID,OAAOC,WAAWF,YAC3BA,WAAWC,OAAOC,QAAQ,CAAC;AAE/B"}
@@ -1,7 +1,6 @@
1
1
  import { ErrorInfo, TreeNode } from "../TreeNode.js";
2
2
  import { HierarchyLevelDetails, TreeRendererProps } from "../Renderers.js";
3
3
  import { JSX } from "react";
4
-
5
4
  //#region src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts
6
5
  /** @alpha */
7
6
  interface ErrorItemRendererProps extends Pick<TreeRendererProps, "getHierarchyLevelDetails"> {
@@ -27,14 +26,7 @@ interface ErrorItemRendererProps extends Pick<TreeRendererProps, "getHierarchyLe
27
26
  *
28
27
  * @alpha
29
28
  */
30
- declare function ErrorItemRenderer({
31
- treeNode,
32
- error,
33
- getHierarchyLevelDetails,
34
- filterHierarchyLevel,
35
- reloadTree,
36
- scrollToNode
37
- }: ErrorItemRendererProps): JSX.Element;
29
+ declare function ErrorItemRenderer({ treeNode, error, getHierarchyLevelDetails, filterHierarchyLevel, reloadTree, scrollToNode }: ErrorItemRendererProps): JSX.Element;
38
30
  //#endregion
39
31
  export { ErrorItemRenderer, ErrorItemRendererProps };
40
32
  //# sourceMappingURL=ErrorItemRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorItemRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx"],"mappings":";;;;;;UAeiB,sBAAA,SAA+B,IAAA,CAAK,iBAAA;EAApC;EAEf,QAAA,EAAU,IAAA,CAAK,QAAA;;EAEf,KAAA,EAAO,SAAA;EAFQ;EAIf,UAAA,GAAa,OAAA;IAAW,YAAA;EAAA;EAEC;EAAzB,YAAA,GAAe,QAAA,EAAU,IAAA,CAAK,QAAA;EARgB;EAU9C,oBAAA,IAAwB,qBAAA,EAAuB,qBAAA;AAAA;;;;;;;;;;iBAYjC,iBAAA,CAAA;EACd,QAAA;EACA,KAAA;EACA,wBAAA;EACA,oBAAA;EACA,UAAA;EACA;AAAA,GACC,sBAAA,GAAyB,GAAA,CAAI,OAAA"}
1
+ {"version":3,"file":"ErrorItemRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx"],"mappings":";;;;;UAeiB,+BAA+B,KAAK;;EAEnD,UAAU,KAAK;;EAEf,OAAO;;EAEP,aAAa;IAAW;;;EAExB,eAAe,UAAU,KAAK;;EAE9B,wBAAwB,uBAAuB;;;;;;;;;;;iBAYjC,oBACd,UACA,OACA,0BACA,sBACA,YACA,gBACC,yBAAyB,IAAI"}
@@ -2,8 +2,8 @@ import { MAX_LIMIT_OVERRIDE } from "../internal/Utils.js";
2
2
  import { useTranslation } from "../LocalizationContext.js";
3
3
  import { c } from "react-compiler-runtime";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Link, Typography } from "@mui/material";
5
6
  import { unstable_ErrorRegion } from "@stratakit/structures";
6
- import { Anchor, Text } from "@stratakit/bricks";
7
7
  //#region src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx
8
8
  /**
9
9
  * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:
@@ -309,11 +309,12 @@ function ErrorItemContainer(t0) {
309
309
  }
310
310
  function _temp4(t0) {
311
311
  const { label, action } = t0;
312
- return /* @__PURE__ */ jsx(Text, {
313
- variant: "body-sm",
314
- children: /* @__PURE__ */ jsx(Anchor, {
312
+ return /* @__PURE__ */ jsx(Typography, {
313
+ variant: "caption",
314
+ render: /* @__PURE__ */ jsx("div", {}),
315
+ children: /* @__PURE__ */ jsx(Link, {
316
+ render: /* @__PURE__ */ jsx("button", { type: "button" }),
315
317
  onClick: action,
316
- render: /* @__PURE__ */ jsx("button", {}),
317
318
  children: label
318
319
  })
319
320
  }, label);
@@ -323,57 +324,63 @@ function _temp3(t0) {
323
324
  return condition();
324
325
  }
325
326
  function MessageWithLink(t0) {
326
- const $ = c(11);
327
+ const $ = c(13);
327
328
  const { linkLabel, scrollToElement, message } = t0;
329
+ let firstPart;
328
330
  let t1;
329
331
  if ($[0] !== message) {
330
- t1 = message.split("{{node}}", 2);
332
+ const splitMessage = message.split("{{node}}", 2);
333
+ firstPart = splitMessage[0].trimEnd();
334
+ t1 = splitMessage[1]?.trimStart();
331
335
  $[0] = message;
332
- $[1] = t1;
333
- } else t1 = $[1];
334
- const splitMessage = t1;
336
+ $[1] = firstPart;
337
+ $[2] = t1;
338
+ } else {
339
+ firstPart = $[1];
340
+ t1 = $[2];
341
+ }
342
+ const secondPart = t1;
335
343
  let t2;
336
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
337
- t2 = {
338
- display: "flex",
339
- whiteSpace: "pre",
340
- flexWrap: "wrap"
341
- };
342
- $[2] = t2;
343
- } else t2 = $[2];
344
- let t3;
345
344
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
346
- t3 = /* @__PURE__ */ jsx("button", {});
347
- $[3] = t3;
348
- } else t3 = $[3];
345
+ t2 = /* @__PURE__ */ jsx("button", { type: "button" });
346
+ $[3] = t2;
347
+ } else t2 = $[3];
348
+ let t3;
349
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
350
+ t3 = { verticalAlign: "baseline" };
351
+ $[4] = t3;
352
+ } else t3 = $[4];
349
353
  let t4;
350
- if ($[4] !== linkLabel || $[5] !== scrollToElement) {
351
- t4 = /* @__PURE__ */ jsx(Anchor, {
354
+ if ($[5] !== linkLabel || $[6] !== scrollToElement) {
355
+ t4 = /* @__PURE__ */ jsx(Link, {
356
+ render: t2,
352
357
  onClick: scrollToElement,
353
- render: t3,
358
+ variant: "caption",
359
+ style: t3,
354
360
  children: linkLabel
355
361
  });
356
- $[4] = linkLabel;
357
- $[5] = scrollToElement;
358
- $[6] = t4;
359
- } else t4 = $[6];
360
- const t5 = splitMessage[1] ? splitMessage[1] : null;
361
- let t6;
362
- if ($[7] !== splitMessage[0] || $[8] !== t4 || $[9] !== t5) {
363
- t6 = /* @__PURE__ */ jsxs("div", {
364
- style: t2,
365
- children: [
366
- splitMessage[0],
367
- t4,
368
- t5
369
- ]
370
- });
371
- $[7] = splitMessage[0];
372
- $[8] = t4;
373
- $[9] = t5;
374
- $[10] = t6;
375
- } else t6 = $[10];
376
- return t6;
362
+ $[5] = linkLabel;
363
+ $[6] = scrollToElement;
364
+ $[7] = t4;
365
+ } else t4 = $[7];
366
+ const t5 = secondPart ? " " : "";
367
+ const t6 = secondPart ? secondPart : null;
368
+ let t7;
369
+ if ($[8] !== firstPart || $[9] !== t4 || $[10] !== t5 || $[11] !== t6) {
370
+ t7 = /* @__PURE__ */ jsxs("div", { children: [
371
+ firstPart,
372
+ " ",
373
+ t4,
374
+ t5,
375
+ t6
376
+ ] });
377
+ $[8] = firstPart;
378
+ $[9] = t4;
379
+ $[10] = t5;
380
+ $[11] = t6;
381
+ $[12] = t7;
382
+ } else t7 = $[12];
383
+ return t7;
377
384
  }
378
385
  //#endregion
379
386
  export { ErrorItemRenderer };
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorItemRenderer.js","names":["Anchor","Text","unstable_ErrorRegion","ErrorRegion","MAX_LIMIT_OVERRIDE","useTranslation","JSX","HierarchyLevelDetails","TreeRendererProps","ErrorInfo","TreeNode","ErrorItemRendererProps","Pick","treeNode","Omit","error","reloadTree","options","parentNodeId","scrollToNode","filterHierarchyLevel","hierarchyLevelDetails","ErrorItemRenderer","t0","$","_c","getHierarchyLevelDetails","translate","type","limit","resultSetSizeLimit","t1","id","setSizeLimit","onOverrideLimit","t2","t3","replace","toString","t4","t5","action","label","condition","t6","t7","t8","isFilterable","t9","t10","t11","t12","t13","hierarchyLevelDetails_0","_temp","_temp2","message","ErrorItemContainerProps","actions","MessageWithLinkProps","ErrorItemContainer","scrollToElement","filter","_temp3","map","_temp4","linkLabel","MessageWithLink","split","splitMessage","Symbol","for","display","whiteSpace","flexWrap"],"sources":["../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Anchor, Text } from \"@stratakit/bricks\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport type { JSX } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { ErrorInfo, TreeNode } from \"../TreeNode.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n /** The tree node associated with the error. Used for displaying the node label in error messages and for scrolling to the node. */\n treeNode: Omit<TreeNode, \"errors\">;\n /** The error to render. */\n error: ErrorInfo;\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined }) => void;\n /** A callback to scroll to the node associated with the error. */\n scrollToNode: (treeNode: Omit<TreeNode, \"errors\">) => void;\n /** A callback to initiate filtering of the given hierarchy level. */\n filterHierarchyLevel?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\n/**\n * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:\n * - `ResultSetTooLarge` - renders `resultLimitExceeded` message with actions to increase limit or apply filtering\n * - `NoFilterMatches` - renders `noFilteredChildren` message with action to change filter\n * - `ChildrenLoad` - renders `failedToCreateHierarchy` message with action to retry loading\n * - `Unknown` - renders message set on error object.\n *\n * @alpha\n */\nexport function ErrorItemRenderer({\n treeNode,\n error,\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree,\n scrollToNode,\n}: ErrorItemRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (error.type === \"ResultSetTooLarge\") {\n const limit = error.resultSetSizeLimit;\n const onOverrideLimit = () => getHierarchyLevelDetails(treeNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE);\n return (\n <ErrorItemContainer\n treeNode={treeNode}\n actions={[\n {\n action: () => {\n onOverrideLimit();\n },\n label: translate(\"increaseHierarchyLimit\").replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString()),\n condition: () => limit < MAX_LIMIT_OVERRIDE,\n },\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(treeNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"increaseHierarchyLimitWithFiltering\"),\n condition: () => !!filterHierarchyLevel && !!treeNode.isFilterable,\n },\n ]}\n message={translate(\"resultLimitExceeded\").replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToNode(treeNode)}\n />\n );\n }\n if (error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n treeNode={treeNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(treeNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"noFilteredChildrenChangeFilter\"),\n condition: () => true,\n },\n ]}\n message={translate(\"noFilteredChildren\")}\n scrollToElement={() => scrollToNode(treeNode)}\n />\n );\n }\n if (error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n treeNode={treeNode}\n actions={[\n { action: () => reloadTree({ parentNodeId: treeNode.id }), label: translate(\"retry\"), condition: () => true },\n ]}\n message={translate(\"failedToCreateHierarchy\")}\n scrollToElement={() => scrollToNode(treeNode)}\n />\n );\n }\n return (\n <ErrorItemContainer treeNode={treeNode} message={error.message} scrollToElement={() => scrollToNode(treeNode)} />\n );\n}\n\ntype ErrorItemContainerProps = {\n treeNode: Omit<TreeNode, \"errors\">;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ treeNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={treeNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={treeNode.id}\n actions={actions\n ?.filter(({ condition }) => condition())\n .map(({ label, action }) => (\n <Text key={label} variant=\"body-sm\">\n <Anchor onClick={action} render={<button />}>\n {label}\n </Anchor>\n </Text>\n ))}\n />\n );\n}\n\ninterface MessageWithLinkProps {\n scrollToElement: () => void;\n message: string;\n linkLabel?: string;\n}\n\nfunction MessageWithLink({ linkLabel, scrollToElement, message }: MessageWithLinkProps) {\n const splitMessage = message.split(\"{{node}}\", 2);\n return (\n <div style={{ display: \"flex\", whiteSpace: \"pre\", flexWrap: \"wrap\" }}>\n {splitMessage[0]}\n <Anchor onClick={scrollToElement} render={<button />}>\n {linkLabel}\n </Anchor>\n {splitMessage[1] ? splitMessage[1] : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAOsB,kBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAA2B,MAAA,EAAAZ,UAAAE,OAAAW,0BAAAN,sBAAAJ,YAAAG,iBAAAI;CAQhC,MAAAI,YAAkBtB,gBAAgB;AAElC,KAAIU,MAAKa,SAAU,qBAAmB;EACpC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AP,EAAA,OAAAgC,SAAA;AAC/DzB,OAAAyB,QAAOY,MAAO,YAAY,EAAE;AAAA5C,IAAA,KAAAgC;AAAAhC,IAAA,KAAAO;OAAAA,MAAAP,EAAA;CAAjD,MAAA6C,eAAqBtC;CAA6B,IAAAI;AAAA,KAAAX,EAAA,OAAA8C,OAAAC,IAAA,4BAAA,EAAA;AAEpCpC,OAAA;GAAAqC,SAAW;GAAMC,YAAc;GAAKC,UAAY;GAAQ;AAAAlD,IAAA,KAAAW;OAAAA,MAAAX,EAAA;CAAA,IAAAY;AAAA,KAAAZ,EAAA,OAAA8C,OAAAC,IAAA,4BAAA,EAAA;AAExBnC,OAAA,oBAAA,UAAA,EAAU,CAAA;AAAAZ,IAAA,KAAAY;OAAAA,MAAAZ,EAAA;CAAA,IAAAe;AAAA,KAAAf,EAAA,OAAA0C,aAAA1C,EAAA,OAAAqC,iBAAA;AAApDtB,OAAA,oBAAC,QAAD;GAAiBsB,SAAAA;GAAyB,QAAAzB;aACvC8B;GACM,CAAA;AAAA1C,IAAA,KAAA0C;AAAA1C,IAAA,KAAAqC;AAAArC,IAAA,KAAAe;OAAAA,MAAAf,EAAA;CACR,MAAAgB,KAAA6B,aAAY,KAAMA,aAAY,KAA9B;CAAwC,IAAAzB;AAAA,KAAApB,EAAA,OAAA6C,aAAA,MAAA7C,EAAA,OAAAe,MAAAf,EAAA,OAAAgB,IAAA;AAL3CI,OAAA,qBAAA,OAAA;GAAY,OAAAT;aAAZ;IACGkC,aAAY;IACb9B;IAGCC;IACG;;AAAAhB,IAAA,KAAA6C,aAAA;AAAA7C,IAAA,KAAAe;AAAAf,IAAA,KAAAgB;AAAAhB,IAAA,MAAAoB;OAAAA,MAAApB,EAAA;AAAA,QANNoB"}
1
+ {"version":3,"file":"ErrorItemRenderer.js","names":["Link","Typography","unstable_ErrorRegion","ErrorRegion","MAX_LIMIT_OVERRIDE","useTranslation","JSX","HierarchyLevelDetails","TreeRendererProps","ErrorInfo","TreeNode","ErrorItemRendererProps","Pick","treeNode","Omit","error","reloadTree","options","parentNodeId","scrollToNode","filterHierarchyLevel","hierarchyLevelDetails","ErrorItemRenderer","t0","$","_c","getHierarchyLevelDetails","translate","type","limit","resultSetSizeLimit","t1","id","setSizeLimit","onOverrideLimit","t2","t3","replace","toString","t4","t5","action","label","condition","t6","t7","t8","isFilterable","t9","t10","t11","t12","t13","hierarchyLevelDetails_0","_temp","_temp2","message","ErrorItemContainerProps","actions","MessageWithLinkProps","ErrorItemContainer","scrollToElement","filter","_temp3","map","_temp4","linkLabel","MessageWithLink","firstPart","splitMessage","split","trimEnd","trimStart","secondPart","Symbol","for","verticalAlign"],"sources":["../../../src/presentation-hierarchies-react/stratakit/ErrorItemRenderer.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Link, Typography } from \"@mui/material\";\nimport { unstable_ErrorRegion as ErrorRegion } from \"@stratakit/structures\";\nimport { MAX_LIMIT_OVERRIDE } from \"../internal/Utils.js\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport type { JSX } from \"react\";\nimport type { HierarchyLevelDetails, TreeRendererProps } from \"../Renderers.js\";\nimport type { ErrorInfo, TreeNode } from \"../TreeNode.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n /** The tree node associated with the error. Used for displaying the node label in error messages and for scrolling to the node. */\n treeNode: Omit<TreeNode, \"errors\">;\n /** The error to render. */\n error: ErrorInfo;\n /** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */\n reloadTree: (options: { parentNodeId: string | undefined }) => void;\n /** A callback to scroll to the node associated with the error. */\n scrollToNode: (treeNode: Omit<TreeNode, \"errors\">) => void;\n /** A callback to initiate filtering of the given hierarchy level. */\n filterHierarchyLevel?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;\n}\n\n/**\n * Renders StrataKit `<ErrorRegion.Item />` for all supported error types:\n * - `ResultSetTooLarge` - renders `resultLimitExceeded` message with actions to increase limit or apply filtering\n * - `NoFilterMatches` - renders `noFilteredChildren` message with action to change filter\n * - `ChildrenLoad` - renders `failedToCreateHierarchy` message with action to retry loading\n * - `Unknown` - renders message set on error object.\n *\n * @alpha\n */\nexport function ErrorItemRenderer({\n treeNode,\n error,\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree,\n scrollToNode,\n}: ErrorItemRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (error.type === \"ResultSetTooLarge\") {\n const limit = error.resultSetSizeLimit;\n const onOverrideLimit = () => getHierarchyLevelDetails(treeNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE);\n return (\n <ErrorItemContainer\n treeNode={treeNode}\n actions={[\n {\n action: () => {\n onOverrideLimit();\n },\n label: translate(\"increaseHierarchyLimit\").replace(\"{{limit}}\", MAX_LIMIT_OVERRIDE.toString()),\n condition: () => limit < MAX_LIMIT_OVERRIDE,\n },\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(treeNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"increaseHierarchyLimitWithFiltering\"),\n condition: () => !!filterHierarchyLevel && !!treeNode.isFilterable,\n },\n ]}\n message={translate(\"resultLimitExceeded\").replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToNode(treeNode)}\n />\n );\n }\n if (error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n treeNode={treeNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(treeNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"noFilteredChildrenChangeFilter\"),\n condition: () => true,\n },\n ]}\n message={translate(\"noFilteredChildren\")}\n scrollToElement={() => scrollToNode(treeNode)}\n />\n );\n }\n if (error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n treeNode={treeNode}\n actions={[\n { action: () => reloadTree({ parentNodeId: treeNode.id }), label: translate(\"retry\"), condition: () => true },\n ]}\n message={translate(\"failedToCreateHierarchy\")}\n scrollToElement={() => scrollToNode(treeNode)}\n />\n );\n }\n return (\n <ErrorItemContainer treeNode={treeNode} message={error.message} scrollToElement={() => scrollToNode(treeNode)} />\n );\n}\n\ntype ErrorItemContainerProps = {\n treeNode: Omit<TreeNode, \"errors\">;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ treeNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={treeNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={treeNode.id}\n actions={actions\n ?.filter(({ condition }) => condition())\n .map(({ label, action }) => (\n <Typography key={label} variant=\"caption\" render={<div />}>\n <Link render={<button type=\"button\" />} onClick={action}>\n {label}\n </Link>\n </Typography>\n ))}\n />\n );\n}\n\ninterface MessageWithLinkProps {\n scrollToElement: () => void;\n message: string;\n linkLabel?: string;\n}\n\nfunction MessageWithLink({ linkLabel, scrollToElement, message }: MessageWithLinkProps) {\n const splitMessage = message.split(\"{{node}}\", 2);\n const firstPart = splitMessage[0].trimEnd();\n const secondPart = splitMessage[1]?.trimStart();\n return (\n <div>\n {firstPart}{\" \"}\n <Link\n render={<button type=\"button\" />}\n onClick={scrollToElement}\n variant=\"caption\"\n style={{ verticalAlign: \"baseline\" }}\n >\n {linkLabel}\n </Link>\n {secondPart ? \" \" : \"\"}\n {secondPart ? secondPart : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAOsB,kBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAA2B,MAAA,EAAAZ,UAAAE,OAAAW,0BAAAN,sBAAAJ,YAAAG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;EAAA1C,EAAA,KAAAqC;EAAArC,EAAA,KAAAe;CAAA,OAAAA,KAAAf,EAAA;CACN,MAAAgB,KAAAiC,aAAA,MAAA;CACA,MAAA7B,KAAA6B,aAAAA,aAAA;CAA8B,IAAA5B;CAAA,IAAArB,EAAA,OAAA4C,aAAA5C,EAAA,OAAAe,MAAAf,EAAA,QAAAgB,MAAAhB,EAAA,QAAAoB,IAAA;EAXjCC,KAAA,qBAAA,OAAA,EAAA,UAAA;GACGuB;GAAW;GACZ7B;GAQCC;GACAI;EACG,EAAA,CAAA;EAAApB,EAAA,KAAA4C;EAAA5C,EAAA,KAAAe;EAAAf,EAAA,MAAAgB;EAAAhB,EAAA,MAAAoB;EAAApB,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,OAZNqB;AAYM"}
@@ -1,6 +1,5 @@
1
1
  import { RootErrorRendererProps } from "../Renderers.js";
2
2
  import { JSX } from "react";
3
-
4
3
  //#region src/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts
5
4
  /**
6
5
  * @alpha
@@ -11,11 +10,7 @@ type StrataKitRootErrorRendererProps = RootErrorRendererProps;
11
10
  *
12
11
  * @alpha
13
12
  */
14
- declare function StrataKitRootErrorRenderer({
15
- error,
16
- getHierarchyLevelDetails,
17
- reloadTree
18
- }: StrataKitRootErrorRendererProps): JSX.Element;
13
+ declare function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }: StrataKitRootErrorRendererProps): JSX.Element;
19
14
  //#endregion
20
- export { StrataKitRootErrorRenderer };
15
+ export { StrataKitRootErrorRenderer, StrataKitRootErrorRendererProps };
21
16
  //# sourceMappingURL=RootErrorRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RootErrorRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"mappings":";;;;;;AAiBA;KAAY,+BAAA,GAAkC,sBAAA;;;;AAO9C;;iBAAgB,0BAAA,CAAA;EACd,KAAA;EACA,wBAAA;EACA;AAAA,GACC,+BAAA,GAAkC,GAAA,CAAI,OAAA"}
1
+ {"version":3,"file":"RootErrorRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"mappings":";;;;;;KAiBY,kCAAkC;;;;;;iBAO9B,6BACd,OACA,0BACA,cACC,kCAAkC,IAAI"}
@@ -1,8 +1,8 @@
1
1
  import { useTranslation } from "../LocalizationContext.js";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
- import { Button, Text } from "@stratakit/bricks";
5
- import { Icon } from "@stratakit/foundations";
4
+ import { Button, Typography } from "@mui/material";
5
+ import { Icon } from "@stratakit/mui";
6
6
  import errorSvg from "@stratakit/icons/status-error.svg";
7
7
  //#region src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx
8
8
  /**
@@ -139,8 +139,8 @@ function RootErrorContainer(t0) {
139
139
  } else t3 = $[2];
140
140
  let t4;
141
141
  if ($[3] !== message) {
142
- t4 = /* @__PURE__ */ jsx(Text, {
143
- variant: "body-sm",
142
+ t4 = /* @__PURE__ */ jsx(Typography, {
143
+ variant: "caption",
144
144
  style: t3,
145
145
  children: message
146
146
  });
@@ -172,6 +172,7 @@ function RootErrorContainer(t0) {
172
172
  function _temp4(action) {
173
173
  return /* @__PURE__ */ jsx(Button, {
174
174
  onClick: () => action.action(),
175
+ size: "small",
175
176
  children: action.label
176
177
  }, action.label);
177
178
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RootErrorRenderer.js","names":["Button","Text","Icon","useTranslation","errorSvg","JSX","RootErrorRendererProps","StrataKitRootErrorRendererProps","StrataKitRootErrorRenderer","t0","$","_c","error","getHierarchyLevelDetails","reloadTree","translate","type","t1","undefined","setSizeLimit","onOverrideLimit","t2","resultSetSizeLimit","replace","toString","t3","t4","action","label","condition","_temp","t5","parentNodeId","state","_temp2","RootErrorContainerProps","message","actions","RootErrorContainer","Symbol","for","height","display","flexDirection","justifyContent","alignItems","gap","textAlign","filter","_temp3","map","_temp4","t6"],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Button, Text } from \"@stratakit/bricks\";\nimport { Icon } from \"@stratakit/foundations\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport errorSvg from \"@stratakit/icons/status-error.svg\";\n\nimport type { JSX } from \"react\";\nimport type { RootErrorRendererProps } from \"../Renderers.js\";\n\n/**\n * @alpha\n */\nexport type StrataKitRootErrorRendererProps = RootErrorRendererProps;\n\n/**\n * A component that renders root node error state.\n *\n * @alpha\n */\nexport function StrataKitRootErrorRenderer({\n error,\n getHierarchyLevelDetails,\n reloadTree,\n}: StrataKitRootErrorRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (error.type === \"ResultSetTooLarge\") {\n const onOverrideLimit = () => getHierarchyLevelDetails(undefined)?.setSizeLimit(\"unbounded\");\n return (\n <RootErrorContainer\n message={translate(\"rootResultLimitExceeded\").replace(\"{{limit}}\", error.resultSetSizeLimit.toString())}\n actions={[\n { action: onOverrideLimit, label: translate(\"increaseHierarchyLimitToUnlimited\"), condition: () => true },\n ]}\n />\n );\n }\n\n return (\n <RootErrorContainer\n message={translate(\"failedToCreateRootHierarchy\")}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: undefined, state: \"reset\" }),\n label: translate(\"retry\"),\n condition: () => true,\n },\n ]}\n />\n );\n}\n\ninterface RootErrorContainerProps {\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n}\n\nfunction RootErrorContainer({ actions, message }: RootErrorContainerProps) {\n return (\n <div\n style={{\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: \"0.5rem\",\n }}\n >\n <Icon href={errorSvg} size=\"large\" />\n <Text variant={\"body-sm\"} style={{ textAlign: \"center\" }}>\n {message}\n </Text>\n {actions\n ?.filter(({ condition }) => condition())\n .map((action) => {\n return (\n <Button key={action.label} onClick={() => action.action()}>\n {action.label}\n </Button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,SAAOQ,2BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAoC,MAAA,EAAAC,OAAAC,0BAAAC,eAAAL;CAKzC,MAAAM,YAAkBZ,gBAAgB;AAElC,KAAIS,MAAKI,SAAU,qBAAmB;EAAA,IAAAC;AAAA,MAAAP,EAAA,OAAAG,0BAAA;AACZI,cAAMJ,yBAAyBK,KAAAA,EAAwB,EAAAC,aAAC,YAAY;AAAAT,KAAA,KAAAG;AAAAH,KAAA,KAAAO;QAAAA,MAAAP,EAAA;EAA5F,MAAAU,kBAAwBH;EAAqE,IAAAI;AAAA,MAAAX,EAAA,OAAAE,MAAAU,sBAAAZ,EAAA,OAAAK,WAAA;AAGhFM,QAAAN,UAAU,0BAA0B,CAAAQ,QAAS,aAAaX,MAAKU,mBAAmBE,UAAW,CAAC;AAAAd,KAAA,KAAAE,MAAAU;AAAAZ,KAAA,KAAAK;AAAAL,KAAA,KAAAW;QAAAA,MAAAX,EAAA;EAAA,IAAAe;AAAA,MAAAf,EAAA,OAAAK,WAAA;AAEnEU,QAAAV,UAAU,oCAAoC;AAAAL,KAAA,KAAAK;AAAAL,KAAA,KAAAe;QAAAA,MAAAf,EAAA;EAAA,IAAAgB;AAAA,MAAAhB,EAAA,OAAAU,mBAAAV,EAAA,OAAAe,IAAA;AADzEC,QAAA,CACP;IAAAC,QAAUP;IAAeQ,OAASH;IAA8CI,WAAaC;IAAY,CAC1G;AAAApB,KAAA,KAAAU;AAAAV,KAAA,KAAAe;AAAAf,KAAA,KAAAgB;QAAAA,MAAAhB,EAAA;EAAA,IAAAqB;AAAA,M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YACrDA,OAAMC;EACA,EAFID,OAAMC,MAEV;;AAtBrB,SAAAqB,OAAAxC,IAAA;CAiBkB,MAAA,EAAAoB,cAAApB;AAAa,QAAKoB,WAAW"}
1
+ {"version":3,"file":"RootErrorRenderer.js","names":["Button","Typography","Icon","useTranslation","errorSvg","JSX","RootErrorRendererProps","StrataKitRootErrorRendererProps","StrataKitRootErrorRenderer","t0","$","_c","error","getHierarchyLevelDetails","reloadTree","translate","type","t1","undefined","setSizeLimit","onOverrideLimit","t2","resultSetSizeLimit","replace","toString","t3","t4","action","label","condition","_temp","t5","parentNodeId","state","_temp2","RootErrorContainerProps","message","actions","RootErrorContainer","Symbol","for","height","display","flexDirection","justifyContent","alignItems","gap","textAlign","filter","_temp3","map","_temp4","t6"],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Button, Typography } from \"@mui/material\";\nimport { Icon } from \"@stratakit/mui\";\nimport { useTranslation } from \"../LocalizationContext.js\";\n\nimport errorSvg from \"@stratakit/icons/status-error.svg\";\n\nimport type { JSX } from \"react\";\nimport type { RootErrorRendererProps } from \"../Renderers.js\";\n\n/**\n * @alpha\n */\nexport type StrataKitRootErrorRendererProps = RootErrorRendererProps;\n\n/**\n * A component that renders root node error state.\n *\n * @alpha\n */\nexport function StrataKitRootErrorRenderer({\n error,\n getHierarchyLevelDetails,\n reloadTree,\n}: StrataKitRootErrorRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (error.type === \"ResultSetTooLarge\") {\n const onOverrideLimit = () => getHierarchyLevelDetails(undefined)?.setSizeLimit(\"unbounded\");\n return (\n <RootErrorContainer\n message={translate(\"rootResultLimitExceeded\").replace(\"{{limit}}\", error.resultSetSizeLimit.toString())}\n actions={[\n { action: onOverrideLimit, label: translate(\"increaseHierarchyLimitToUnlimited\"), condition: () => true },\n ]}\n />\n );\n }\n\n return (\n <RootErrorContainer\n message={translate(\"failedToCreateRootHierarchy\")}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: undefined, state: \"reset\" }),\n label: translate(\"retry\"),\n condition: () => true,\n },\n ]}\n />\n );\n}\n\ninterface RootErrorContainerProps {\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n}\n\nfunction RootErrorContainer({ actions, message }: RootErrorContainerProps) {\n return (\n <div\n style={{\n height: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n gap: \"0.5rem\",\n }}\n >\n <Icon href={errorSvg} size=\"large\" />\n <Typography variant=\"caption\" style={{ textAlign: \"center\" }}>\n {message}\n </Typography>\n {actions\n ?.filter(({ condition }) => condition())\n .map((action) => {\n return (\n <Button key={action.label} onClick={() => action.action()} size=\"small\">\n {action.label}\n </Button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAwBA,SAAOQ,2BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAoC,MAAA,EAAAC,OAAAC,0BAAAC,eAAAL;CAKzC,MAAAM,YAAkBZ,eAAe;CAEjC,IAAIS,MAAKI,SAAU,qBAAmB;EAAA,IAAAC;EAAA,IAAAP,EAAA,OAAAG,0BAAA;GACZI,WAAMJ,yBAAyBK,KAAAA,CAAuB,CAAC,EAAAC,aAAC,WAAW;GAACT,EAAA,KAAAG;GAAAH,EAAA,KAAAO;EAAA,OAAAA,KAAAP,EAAA;EAA5F,MAAAU,kBAAwBH;EAAqE,IAAAI;EAAA,IAAAX,EAAA,OAAAE,MAAAU,sBAAAZ,EAAA,OAAAK,WAAA;GAGhFM,KAAAN,UAAU,yBAAyB,CAAC,CAAAQ,QAAS,aAAaX,MAAKU,mBAAmBE,SAAU,CAAC;GAACd,EAAA,KAAAE,MAAAU;GAAAZ,EAAA,KAAAK;GAAAL,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AAA,KAAAhB,EAAA;CAAA,IAAAqB;CAAA,IAAArB,EAAA,OAAA2B,SAAA;EACZN,KAAAM,SAAOW,OACGC,MACN,CAAC,CAAAC,IAACC,MAMJ;EAACzC,EAAA,KAAA2B;EAAA3B,EAAA,KAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,IAAA0C;CAAA,IAAA1C,EAAA,OAAAgB,MAAAhB,EAAA,OAAAqB,IAAA;EAtBNqB,KAAA,qBAAA,OAAA;GACS,OAAAnC;GADT,UAAA;IAUEI;IACAK;IAGCK;GASG;;EAAArB,EAAA,KAAAgB;EAAAhB,EAAA,KAAAqB;EAAArB,EAAA,KAAA0C;CAAA,OAAAA,KAAA1C,EAAA;CAAA,OAvBN0C;AAuBM;AAzBV,SAAAD,OAAAxB,QAAA;CAAA,OAoBY,oBAAC,QAAD;EAAoC,eAAMA,OAAMA,OAAQ;EAAQ,MAAA;EAC7DA,UAAAA,OAAMC;CADF,GAAMD,OAAMC,KAAZ;AAEE;AAtBrB,SAAAqB,OAAAxC,IAAA;CAiBkB,MAAA,EAAAoB,cAAApB;CAAa,OAAKoB,UAAU;AAAC"}
@@ -1,6 +1,5 @@
1
- import { ComponentProps, NamedExoticComponent } from "react";
1
+ import { ComponentPropsWithoutRef, NamedExoticComponent } from "react";
2
2
  import { Tree } from "@stratakit/structures";
3
-
4
3
  //#region src/presentation-hierarchies-react/stratakit/TreeAction.d.ts
5
4
  /**
6
5
  * Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context
@@ -23,7 +22,10 @@ interface TreeActionBaseAttributes {
23
22
  hide?: boolean;
24
23
  }
25
24
  /** @alpha */
26
- type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeActionBaseAttributes;
25
+ type TreeActionBaseProps = Omit<ComponentPropsWithoutRef<typeof Tree.ItemAction>, "onClick"> & TreeActionBaseAttributes & {
26
+ /** Callback invoked when the action is clicked. */
27
+ onClick?: () => void;
28
+ };
27
29
  /**
28
30
  * Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.
29
31
  * Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.
@@ -45,5 +47,5 @@ type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeActionBa
45
47
  */
46
48
  declare const TreeActionBase: NamedExoticComponent<TreeActionBaseProps>;
47
49
  //#endregion
48
- export { TreeActionBase, TreeActionBaseAttributes };
50
+ export { TreeActionBase, TreeActionBaseAttributes, TreeActionBaseProps };
49
51
  //# sourceMappingURL=TreeAction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TreeAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"mappings":";;;;;;AAeA;;;UAAiB,wBAAA;EAaX;AAIN;;;;;;EATE,OAAA;EASiG;;;;EAJjG,IAAA;AAAA;;KAIU,mBAAA,GAAsB,cAAA,QAAsB,IAAA,CAAK,UAAA,IAAc,wBAAA;;;;;;;;;;;;;;;;;;;;cAqB9D,cAAA,EAAgB,oBAAA,CAAqB,mBAAA"}
1
+ {"version":3,"file":"TreeAction.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/TreeAction.tsx"],"mappings":";;;;;;;;UAiBiB;;;;;;;;EAQf;;;;;EAKA;;;KAIU,sBAAsB,KAAK,gCAAgC,KAAK,0BAC1E;;EAEE;;;;;;;;;;;;;;;;;;;;;cAsBS,gBAAgB,qBAAqB"}