@itwin/presentation-hierarchies-react 2.0.0-alpha.53 → 2.0.0-alpha.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/README.md +23 -61
- package/lib/presentation-hierarchies-react/Renderers.d.ts +92 -0
- package/lib/presentation-hierarchies-react/Renderers.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/TreeNode.d.ts +33 -29
- package/lib/presentation-hierarchies-react/TreeNode.d.ts.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/UseIModelTree.d.ts +28 -17
- package/lib/presentation-hierarchies-react/UseIModelTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js +184 -0
- package/lib/presentation-hierarchies-react/UseIModelTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts +30 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js +58 -0
- package/lib/presentation-hierarchies-react/UseNodeHighlighting.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts +25 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js +125 -0
- package/lib/presentation-hierarchies-react/UseSelectionHandler.js.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts +112 -0
- package/lib/presentation-hierarchies-react/UseTree.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/UseTree.js +294 -0
- package/lib/presentation-hierarchies-react/UseTree.js.map +1 -0
- package/lib/presentation-hierarchies-react/Utils.js +56 -0
- package/lib/presentation-hierarchies-react/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js +10 -0
- package/lib/presentation-hierarchies-react/internal/DisposePolyfill.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts +9 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js +12 -0
- package/lib/presentation-hierarchies-react/internal/LocalizedStrings.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js +295 -0
- package/lib/presentation-hierarchies-react/internal/TreeActions.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js +99 -0
- package/lib/presentation-hierarchies-react/internal/TreeLoader.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.d.ts +3 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js +120 -0
- package/lib/presentation-hierarchies-react/internal/TreeModel.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +37 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js +142 -0
- package/lib/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +1 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js +43 -0
- package/lib/presentation-hierarchies-react/internal/Utils.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +381 -0
- package/lib/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +1 -0
- package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/FlatTreeNode.d.ts +16 -15
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js +91 -0
- package/lib/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +24 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js +41 -0
- package/lib/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +27 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +186 -0
- package/lib/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts +49 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js +89 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +38 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +64 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +29 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +92 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +33 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +156 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +18 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +535 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +75 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +1 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js +418 -0
- package/lib/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +1 -0
- package/lib/presentation-hierarchies-react.d.ts +18 -0
- package/lib/presentation-hierarchies-react.js +16 -0
- package/lib/public/locales/en/PresentationHierarchies_1.0.json +26 -0
- package/package.json +27 -21
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts +0 -85
- package/lib/esm/presentation-hierarchies-react/Renderers.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Renderers.js +0 -6
- package/lib/esm/presentation-hierarchies-react/Renderers.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/TreeNode.js +0 -6
- package/lib/esm/presentation-hierarchies-react/TreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js +0 -62
- package/lib/esm/presentation-hierarchies-react/UseIModelTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts +0 -24
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js +0 -53
- package/lib/esm/presentation-hierarchies-react/UseNodeHighlighting.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts +0 -48
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js +0 -83
- package/lib/esm/presentation-hierarchies-react/UseSelectionHandler.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts +0 -94
- package/lib/esm/presentation-hierarchies-react/UseTree.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/UseTree.js +0 -241
- package/lib/esm/presentation-hierarchies-react/UseTree.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts +0 -8
- package/lib/esm/presentation-hierarchies-react/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/Utils.js +0 -39
- package/lib/esm/presentation-hierarchies-react/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts +0 -2
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js +0 -11
- package/lib/esm/presentation-hierarchies-react/internal/DisposePolyfill.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts +0 -53
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js +0 -322
- package/lib/esm/presentation-hierarchies-react/internal/TreeActions.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts +0 -62
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js +0 -90
- package/lib/esm/presentation-hierarchies-react/internal/TreeLoader.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts +0 -47
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js +0 -157
- package/lib/esm/presentation-hierarchies-react/internal/TreeModel.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts +0 -42
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js +0 -115
- package/lib/esm/presentation-hierarchies-react/internal/UseUnifiedSelection.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts +0 -23
- package/lib/esm/presentation-hierarchies-react/internal/Utils.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js +0 -58
- package/lib/esm/presentation-hierarchies-react/internal/Utils.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts +0 -27
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js +0 -74
- package/lib/esm/presentation-hierarchies-react/stratakit/ErrorItemRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js +0 -73
- package/lib/esm/presentation-hierarchies-react/stratakit/FlatTreeNode.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts +0 -138
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js +0 -47
- package/lib/esm/presentation-hierarchies-react/stratakit/LocalizationContext.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts +0 -16
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js +0 -42
- package/lib/esm/presentation-hierarchies-react/stratakit/RootErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts +0 -45
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js +0 -36
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js +0 -30
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeErrorRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts +0 -20
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js +0 -29
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeFilterAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts +0 -57
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js +0 -71
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenameAction.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts +0 -46
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js +0 -133
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeNodeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts +0 -75
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js +0 -193
- package/lib/esm/presentation-hierarchies-react/stratakit/TreeRenderer.js.map +0 -1
- package/lib/esm/presentation-hierarchies-react.d.ts +0 -17
- package/lib/esm/presentation-hierarchies-react.d.ts.map +0 -1
- package/lib/esm/presentation-hierarchies-react.js +0 -18
- package/lib/esm/presentation-hierarchies-react.js.map +0 -1
- /package/lib/{esm/presentation-hierarchies-react → presentation-hierarchies-react}/stratakit/TreeNodeRenderer.css +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorItemRenderer.js","names":["Anchor","Text","unstable_ErrorRegion","ErrorRegion","MAX_LIMIT_OVERRIDE","useTranslation","JSX","HierarchyLevelDetails","TreeRendererProps","TreeNode","useErrorNodes","ErrorItemRendererProps","Pick","errorNode","ReturnType","reloadTree","options","parentNodeId","scrollToNode","filterHierarchyLevel","hierarchyLevelDetails","ErrorItemRenderer","t0","$","_c","getHierarchyLevelDetails","translate","error","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 { TreeNode } from \"../TreeNode.js\";\nimport type { useErrorNodes } from \"./FlatTreeNode.js\";\n\n/** @alpha */\nexport interface ErrorItemRendererProps extends Pick<TreeRendererProps, \"getHierarchyLevelDetails\"> {\n /** A node containing an error. */\n errorNode: ReturnType<typeof useErrorNodes>[number];\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: (errorNode: TreeNode) => 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 errorNode,\n getHierarchyLevelDetails,\n filterHierarchyLevel,\n reloadTree,\n scrollToNode,\n}: ErrorItemRendererProps): JSX.Element {\n const translate = useTranslation();\n\n if (errorNode.error.type === \"ResultSetTooLarge\") {\n const limit = errorNode.error.resultSetSizeLimit;\n const onOverrideLimit = () => getHierarchyLevelDetails(errorNode.id)?.setSizeLimit(MAX_LIMIT_OVERRIDE);\n return (\n <ErrorItemContainer\n errorNode={errorNode}\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(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"increaseHierarchyLimitWithFiltering\"),\n condition: () => !!filterHierarchyLevel && !!errorNode.isFilterable,\n },\n ]}\n message={translate(\"resultLimitExceeded\").replace(\"{{limit}}\", limit.toString())}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"NoFilterMatches\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => {\n const hierarchyLevelDetails = getHierarchyLevelDetails(errorNode.id);\n hierarchyLevelDetails && filterHierarchyLevel?.(hierarchyLevelDetails);\n },\n label: translate(\"noFilteredChildrenChangeFilter\"),\n condition: () => true,\n },\n ]}\n message={translate(\"noFilteredChildren\")}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n if (errorNode.error.type === \"ChildrenLoad\") {\n return (\n <ErrorItemContainer\n errorNode={errorNode}\n actions={[\n {\n action: () => reloadTree({ parentNodeId: errorNode.id }),\n label: translate(\"retry\"),\n condition: () => true,\n },\n ]}\n message={translate(\"failedToCreateHierarchy\")}\n scrollToElement={() => scrollToNode(errorNode)}\n />\n );\n }\n\n return <ErrorItemContainer errorNode={errorNode} message={errorNode.error.message} scrollToElement={() => scrollToNode(errorNode)} />;\n}\n\ntype ErrorItemContainerProps = {\n errorNode: TreeNode;\n message: string;\n actions?: { action: () => void; label: string; condition: () => boolean }[];\n} & Pick<MessageWithLinkProps, \"scrollToElement\">;\n\nfunction ErrorItemContainer({ errorNode, message, actions, scrollToElement }: ErrorItemContainerProps) {\n return (\n <ErrorRegion.Item\n message={<MessageWithLink linkLabel={errorNode.label} scrollToElement={scrollToElement} message={message} />}\n messageId={errorNode.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":";;;;;;;;;;;;;;;;;AAoCA,SAAOqB,kBAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAA2B,MAAA,EAAAX,WAAAY,0BAAAN,sBAAAJ,YAAAG,iBAAAI;CAOhC,MAAAI,YAAkBrB,gBAAgB;AAElC,KAAIQ,UAASc,MAAMC,SAAU,qBAAmB;EAC9C,MAAAC,QAAchB,UAASc,MAAMG;EAAoB,IAAAC;AAAA,MAAAR,EAAA,OAAAV,UAAAmB,MAAAT,EAAA,OAAAE,0BAAA;AACzBM,cAAMN,yBAAyBZ,UAASmB,GAAkB,EAAAC,aAAC7B,mBAAmB;AAAAmB,KAAA,KAAAV,UAAAmB;AAAAT,KAAA,KAAAE;AAAAF,KAAA,KAAAQ;QAAAA,MAAAR,EAAA;EAAtG,MAAAW,kBAAwBH;EAA+E,IAAAI;AAAA,MAAAZ,EAAA,OAAAW,iBAAA;AAMvFC,cAAA;AACND,qBAAiB;;AAClBX,KAAA,KAAAW;AAAAX,KAAA,KAAAY;QAAAA,MAAAZ,EAAA;EAAA,IAAAa;AAAA,MAAAb,EAAA,OAAAG,WAAA;AACMU,QAAAV,UAAU,yBAAyB,CAAAW,QAAS,aAAajC,mBAAkBkC,UAAW,CAAC;AAAAf,KAAA,KAAAG;AAAAH,KAAA,KAAAa;QAAAA,MAAAb,EAAA;EAAA,IAAAgB;AAAA,MAAAhB,EAAA,OAAAM,OAAA;AACnFU,cAAMV,QAAQzB;AAAkBmB,KAAA,KAAAM;AAAAN,KAAA,KAAAgB;QAAAA,MAAAhB,EAAA;EAAA,IAAAiB;AAAA,MAAAjB,EAAA,OAAAY,MAAAZ,EAAA,QAAAa,MAAAb,EAAA,QAAAgB,IAAA;AA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,qBAAA;GAAY,OAAAT;;IACTkC,aAAY;IACb9B;IAGCC;;IACG;AAAAjB,IAAA,KAAA8C,aAAA;AAAA9C,IAAA,KAAAgB;AAAAhB,IAAA,KAAAiB;AAAAjB,IAAA,MAAAqB;OAAAA,MAAArB,EAAA;AAAA,QANNqB"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { TreeNode } from "../TreeNode.js";
|
|
2
|
+
|
|
3
|
+
//#region src/presentation-hierarchies-react/stratakit/FlatTreeNode.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Placeholder item that is added to hierarchy as a child for a parent item while its child items are loading.
|
|
4
6
|
*
|
|
5
7
|
* @alpha
|
|
6
8
|
*/
|
|
7
9
|
interface FlatPlaceholderItem {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
id: string;
|
|
11
|
+
level: number;
|
|
12
|
+
placeholder: true;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* An item containing `TreeNode` node with properties needed for a flat tree structure.
|
|
14
16
|
*
|
|
15
17
|
* @alpha
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
interface FlatTreeNodeItem {
|
|
20
|
+
id: string;
|
|
21
|
+
level: number;
|
|
22
|
+
levelSize: number;
|
|
23
|
+
posInLevel: number;
|
|
24
|
+
node: TreeNode;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* An Item describing single tree item position and its content inside tree.
|
|
@@ -27,9 +29,7 @@ export interface FlatTreeNodeItem {
|
|
|
27
29
|
*
|
|
28
30
|
* @alpha
|
|
29
31
|
*/
|
|
30
|
-
|
|
31
|
-
/** @alpha */
|
|
32
|
-
export declare function isPlaceholderItem(item: FlatTreeItem): item is FlatPlaceholderItem;
|
|
32
|
+
type FlatTreeItem = FlatTreeNodeItem | FlatPlaceholderItem;
|
|
33
33
|
/**
|
|
34
34
|
* Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
|
|
35
35
|
* a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
|
|
@@ -37,12 +37,13 @@ export declare function isPlaceholderItem(item: FlatTreeItem): item is FlatPlace
|
|
|
37
37
|
*
|
|
38
38
|
* @alpha
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
declare function useFlatTreeItems(rootNodes: TreeNode[]): FlatTreeItem[];
|
|
41
41
|
/**
|
|
42
42
|
* Finds and returns all nodes containing errors in a given hierarchy.
|
|
43
43
|
*
|
|
44
44
|
* @alpha
|
|
45
45
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
declare function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, "error">>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { FlatTreeItem, useErrorNodes, useFlatTreeItems };
|
|
48
49
|
//# sourceMappingURL=FlatTreeNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts"],"mappings":";;;;;AAO+C;;;UAOrC,mBAAA;EACR,EAAA;EACA,KAAA;EACA,WAAA;AAAA;;AAQF;;;;UAAiB,gBAAA;EACf,EAAA;EACA,KAAA;EACA,SAAA;EACA,UAAA;EACA,IAAA,EAAM,QAAA;AAAA;;AASR;;;;;KAAY,YAAA,GAAe,gBAAA,GAAmB,mBAAA;;;;;;;AAyC9C;iBA3BgB,gBAAA,CAAiB,SAAA,EAAW,QAAA,KAAU,YAAA;;;;;;iBA2BtC,aAAA,CAAc,SAAA,EAAW,QAAA,KAAa,KAAA,CAAM,QAAA,GAAW,IAAA,CAAK,QAAA,CAAS,QAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/presentation-hierarchies-react/stratakit/FlatTreeNode.ts
|
|
4
|
+
/** @alpha */
|
|
5
|
+
function isPlaceholderItem(item) {
|
|
6
|
+
return "placeholder" in item;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Used to get a list of `FlatTreeItem` objects for the given list of `TreeNode` objects that represent
|
|
10
|
+
* a hierarchical structure. The resulting items can be used to render the hierarchy in a flat manner, e.g. using a
|
|
11
|
+
* virtualized list.
|
|
12
|
+
*
|
|
13
|
+
* @alpha
|
|
14
|
+
*/
|
|
15
|
+
function useFlatTreeItems(rootNodes) {
|
|
16
|
+
const $ = c(2);
|
|
17
|
+
let t0;
|
|
18
|
+
if ($[0] !== rootNodes) {
|
|
19
|
+
t0 = getFlatItems(rootNodes, 1);
|
|
20
|
+
$[0] = rootNodes;
|
|
21
|
+
$[1] = t0;
|
|
22
|
+
} else t0 = $[1];
|
|
23
|
+
return t0;
|
|
24
|
+
}
|
|
25
|
+
function getFlatItems(nodes, level) {
|
|
26
|
+
const flatItems = [];
|
|
27
|
+
nodes.forEach((node, index) => {
|
|
28
|
+
flatItems.push({
|
|
29
|
+
node,
|
|
30
|
+
id: node.id,
|
|
31
|
+
level,
|
|
32
|
+
levelSize: nodes.length,
|
|
33
|
+
posInLevel: index + 1
|
|
34
|
+
});
|
|
35
|
+
if (!node.isExpanded || node.error) return;
|
|
36
|
+
if (node.children !== true) {
|
|
37
|
+
const childNodes = getFlatItems(node.children, level + 1);
|
|
38
|
+
flatItems.push(...childNodes);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
flatItems.push({
|
|
42
|
+
id: `${node.id}-children-placeholder`,
|
|
43
|
+
level: level + 1,
|
|
44
|
+
placeholder: true
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return flatItems;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Finds and returns all nodes containing errors in a given hierarchy.
|
|
51
|
+
*
|
|
52
|
+
* @alpha
|
|
53
|
+
*/
|
|
54
|
+
function useErrorNodes(rootNodes) {
|
|
55
|
+
const $ = c(2);
|
|
56
|
+
let t0;
|
|
57
|
+
if ($[0] !== rootNodes) {
|
|
58
|
+
t0 = rootNodes.flatMap(_temp);
|
|
59
|
+
$[0] = rootNodes;
|
|
60
|
+
$[1] = t0;
|
|
61
|
+
} else t0 = $[1];
|
|
62
|
+
return t0;
|
|
63
|
+
}
|
|
64
|
+
function _temp(rootNode) {
|
|
65
|
+
if (isErrorNode(rootNode)) return [rootNode];
|
|
66
|
+
if (rootNode.children === true) return [];
|
|
67
|
+
return getErrorNodes(rootNode);
|
|
68
|
+
}
|
|
69
|
+
function getErrorNodes(parent) {
|
|
70
|
+
const errorList = [];
|
|
71
|
+
if (parent.children === true) return [];
|
|
72
|
+
parent.children.forEach((node) => {
|
|
73
|
+
if (isErrorNode(node)) {
|
|
74
|
+
errorList.push(node);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (node.children !== true) {
|
|
78
|
+
const childErrorList = getErrorNodes(node);
|
|
79
|
+
errorList.push(...childErrorList);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return errorList;
|
|
84
|
+
}
|
|
85
|
+
function isErrorNode(node) {
|
|
86
|
+
return node.error !== void 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { isPlaceholderItem, useErrorNodes, useFlatTreeItems };
|
|
91
|
+
//# sourceMappingURL=FlatTreeNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlatTreeNode.js","names":["useMemo","TreeNode","FlatPlaceholderItem","id","level","placeholder","FlatTreeNodeItem","levelSize","posInLevel","node","FlatTreeItem","isPlaceholderItem","item","useFlatTreeItems","rootNodes","$","_c","t0","getFlatItems","nodes","flatItems","forEach","index","push","length","isExpanded","error","children","childNodes","useErrorNodes","flatMap","_temp","rootNode","isErrorNode","getErrorNodes","parent","errorList","ReturnType","childErrorList","Pick","Required","undefined"],"sources":["../../../src/presentation-hierarchies-react/stratakit/FlatTreeNode.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 { useMemo } from \"react\";\n\nimport type { TreeNode } 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 `TreeNode` 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: TreeNode;\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 `TreeNode` 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: TreeNode[]) {\n return useMemo(() => getFlatItems(rootNodes, 1), [rootNodes]);\n}\n\nfunction getFlatItems(nodes: TreeNode[], 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 nodes containing errors in a given hierarchy.\n *\n * @alpha\n */\nexport function useErrorNodes(rootNodes: TreeNode[]): Array<TreeNode & Pick<Required<TreeNode>, \"error\">> {\n return useMemo(\n () =>\n rootNodes.flatMap((rootNode) => {\n if (isErrorNode(rootNode)) {\n return [rootNode];\n }\n if (rootNode.children === true) {\n return [];\n }\n return getErrorNodes(rootNode);\n }),\n [rootNodes],\n );\n}\n\nfunction getErrorNodes(parent: TreeNode) {\n const errorList: ReturnType<typeof useErrorNodes> = [];\n\n if (parent.children === true) {\n return [];\n }\n\n parent.children.forEach((node) => {\n if (isErrorNode(node)) {\n errorList.push(node);\n return;\n }\n\n if (node.children !== true) {\n const childErrorList = getErrorNodes(node);\n errorList.push(...childErrorList);\n return;\n }\n });\n return errorList;\n}\n\nfunction isErrorNode(node: TreeNode): node is TreeNode & Pick<Required<TreeNode>, \"error\"> {\n return node.error !== undefined;\n}\n"],"mappings":";;;;AA0CA,SAAgBW,kBAAkBC,MAAiD;AACjF,QAAO,iBAAiBA;;;;;;;;;AAU1B,SAAOC,iBAAAC,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AACgBG,OAAAC,aAAaJ,WAAW,EAAE;AAAAC,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QAA1BE;;AAGvB,SAASC,aAAaC,OAAmBf,OAAe;CACtD,MAAMgB,YAA4B,EAAE;AACpCD,OAAME,SAASZ,MAAMa,UAAU;AAC7BF,YAAUG,KAAK;GAAEd;GAAMN,IAAIM,KAAKN;GAAIC;GAAOG,WAAWY,MAAMK;GAAQhB,YAAYc,QAAQ;GAAG,CAAC;AAC5F,MAAI,CAACb,KAAKgB,cAAchB,KAAKiB,MAC3B;AAEF,MAAIjB,KAAKkB,aAAa,MAAM;GAC1B,MAAMC,aAAaV,aAAaT,KAAKkB,UAAUvB,QAAQ,EAAE;AACzDgB,aAAUG,KAAK,GAAGK,WAAW;AAC7B;;AAGFR,YAAUG,KAAK;GAAEpB,IAAI,GAAGM,KAAKN,GAAE;GAAyBC,OAAOA,QAAQ;GAAGC,aAAa;GAAM,CAA+B;GAC5H;AACF,QAAOe;;;;;;;AAQT,SAAOS,cAAAf,WAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;AAAA,KAAAF,EAAA,OAAAD,WAAA;AAGDG,OAAAH,UAASgB,QAASC,MAQhB;AAAAhB,IAAA,KAAAD;AAAAC,IAAA,KAAAE;OAAAA,MAAAF,EAAA;AAAA,QARFE;;AAHC,SAAAc,MAAAC,UAAA;AAIC,KAAIC,YAAYD,SAAS,CAAA,QAChB,CAACA,SAAS;AAEnB,KAAIA,SAAQL,aAAc,KAAI,QACrB,EAAE;AACV,QACMO,cAAcF,SAAS;;AAMtC,SAASE,cAAcC,QAAkB;CACvC,MAAMC,YAA8C,EAAE;AAEtD,KAAID,OAAOR,aAAa,KACtB,QAAO,EAAE;AAGXQ,QAAOR,SAASN,SAASZ,SAAS;AAChC,MAAIwB,YAAYxB,KAAK,EAAE;AACrB2B,aAAUb,KAAKd,KAAK;AACpB;;AAGF,MAAIA,KAAKkB,aAAa,MAAM;GAC1B,MAAMW,iBAAiBJ,cAAczB,KAAK;AAC1C2B,aAAUb,KAAK,GAAGe,eAAe;AACjC;;GAEF;AACF,QAAOF;;AAGT,SAASH,YAAYxB,MAAsE;AACzF,QAAOA,KAAKiB,UAAUe"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JSX, PropsWithChildren } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/presentation-hierarchies-react/stratakit/LocalizationContext.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Properties for `LocalizationContextProvider`.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
interface LocalizationContextProviderProps {
|
|
9
|
+
/** Localization object compatible with `@itwin/core-common` */
|
|
10
|
+
localization: {
|
|
11
|
+
getLocalizedString: (key: string) => string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Context provider for localizing components.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
declare function LocalizationContextProvider({
|
|
19
|
+
localization,
|
|
20
|
+
children
|
|
21
|
+
}: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { LocalizationContextProvider };
|
|
24
|
+
//# sourceMappingURL=LocalizationContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx"],"mappings":";;;AAW0C;;;;AAAA,UAQhC,gCAAA;EAGN;EADF,YAAA;IACE,kBAAA,GAAqB,GAAA;EAAA;AAAA;;;;;iBAQT,2BAAA,CAAA;EAA8B,YAAA;EAAc;AAAA,GAAY,iBAAA,CAAkB,gCAAA,IAAoC,GAAA,CAAI,OAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LOCALIZATION_NAMESPACE } from "../internal/LocalizedStrings.js";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/presentation-hierarchies-react/stratakit/LocalizationContext.tsx
|
|
7
|
+
const localizationContext = createContext((key) => key);
|
|
8
|
+
/**
|
|
9
|
+
* Context provider for localizing components.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
function LocalizationContextProvider(t0) {
|
|
13
|
+
const $ = c(5);
|
|
14
|
+
const { localization, children } = t0;
|
|
15
|
+
let t1;
|
|
16
|
+
if ($[0] !== localization) {
|
|
17
|
+
t1 = (key) => localization.getLocalizedString(`${LOCALIZATION_NAMESPACE}:${key}`);
|
|
18
|
+
$[0] = localization;
|
|
19
|
+
$[1] = t1;
|
|
20
|
+
} else t1 = $[1];
|
|
21
|
+
const translate = t1;
|
|
22
|
+
let t2;
|
|
23
|
+
if ($[2] !== children || $[3] !== translate) {
|
|
24
|
+
t2 = /* @__PURE__ */ jsx(localizationContext.Provider, {
|
|
25
|
+
value: translate,
|
|
26
|
+
children
|
|
27
|
+
});
|
|
28
|
+
$[2] = children;
|
|
29
|
+
$[3] = translate;
|
|
30
|
+
$[4] = t2;
|
|
31
|
+
} else t2 = $[4];
|
|
32
|
+
return t2;
|
|
33
|
+
}
|
|
34
|
+
/** @internal */
|
|
35
|
+
function useTranslation() {
|
|
36
|
+
return useContext(localizationContext);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
export { LocalizationContextProvider, useTranslation };
|
|
41
|
+
//# sourceMappingURL=LocalizationContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationContext.js","names":["createContext","useContext","useMemo","LOCALIZATION_NAMESPACE","JSX","PropsWithChildren","LocalizationKey","TranslateFunc","key","localizationContext","LocalizationContextProviderProps","localization","getLocalizedString","LocalizationContextProvider","t0","$","_c","children","t1","translate","t2","useTranslation"],"sources":["../../../src/presentation-hierarchies-react/stratakit/LocalizationContext.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 { createContext, useContext, useMemo } from \"react\";\nimport { LOCALIZATION_NAMESPACE } from \"../internal/LocalizedStrings.js\";\n\nimport type { JSX, PropsWithChildren } from \"react\";\nimport type { LocalizationKey } from \"../internal/LocalizedStrings.js\";\n\ntype TranslateFunc = (key: LocalizationKey) => string;\n\nconst localizationContext = createContext<TranslateFunc>((key) => key);\n\n/**\n * Properties for `LocalizationContextProvider`.\n * @public\n */\ninterface LocalizationContextProviderProps {\n /** Localization object compatible with `@itwin/core-common` */\n localization: {\n getLocalizedString: (key: string) => string;\n };\n}\n\n/**\n * Context provider for localizing components.\n * @public\n */\nexport function LocalizationContextProvider({ localization, children }: PropsWithChildren<LocalizationContextProviderProps>): JSX.Element {\n const translate = useMemo<TranslateFunc>(() => {\n return (key: LocalizationKey) => localization.getLocalizedString(`${LOCALIZATION_NAMESPACE}:${key}`);\n }, [localization]);\n return <localizationContext.Provider value={translate}>{children}</localizationContext.Provider>;\n}\n\n/** @internal */\nexport function useTranslation() {\n return useContext(localizationContext);\n}\n"],"mappings":";;;;;;AAaA,MAAMS,sBAAsBT,eAA8BQ,QAAQA,IAAI;;;;;AAiBtE,SAAOK,4BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqC,MAAA,EAAAL,cAAAM,aAAAH;CAA+E,IAAAI;AAAA,KAAAH,EAAA,OAAAJ,cAAA;AAEhHO,QAAAV,QAA0BG,aAAYC,mBAAoB,GAAGT,uBAAsB,GAAIK,MAAM;AAAAO,IAAA,KAAAJ;AAAAI,IAAA,KAAAG;OAAAA,MAAAH,EAAA;CADtG,MAAAI,YACED;CACiB,IAAAE;AAAA,KAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,WAAA;AACZC,OAAA,oBAAA,oBAAA;GAAqCD,OAAAA;GAAYF;IAAwC;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAI;AAAAJ,IAAA,KAAAK;OAAAA,MAAAL,EAAA;AAAA,QAAzFK;;;AAIT,SAAOC,iBAAA;AAAA,QACEpB,WAAWQ,oBAAoB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ErrorInfo } from "../TreeNode.js";
|
|
2
|
+
import { RootErrorRendererProps } from "../Renderers.js";
|
|
3
|
+
import { JSX } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/presentation-hierarchies-react/stratakit/RootErrorRenderer.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
type StrataKitRootErrorRendererProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Root error to be displayed
|
|
12
|
+
*/
|
|
13
|
+
error: ErrorInfo;
|
|
14
|
+
} & RootErrorRendererProps;
|
|
15
|
+
/**
|
|
16
|
+
* A component that renders root node error state.
|
|
17
|
+
*
|
|
18
|
+
* @alpha
|
|
19
|
+
*/
|
|
20
|
+
declare function StrataKitRootErrorRenderer({
|
|
21
|
+
error,
|
|
22
|
+
getHierarchyLevelDetails,
|
|
23
|
+
reloadTree
|
|
24
|
+
}: StrataKitRootErrorRendererProps): JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { StrataKitRootErrorRenderer };
|
|
27
|
+
//# sourceMappingURL=RootErrorRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.d.ts","names":[],"sources":["../../../src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx"],"mappings":";;;;;;;AAiBA;KAAY,+BAAA;;;;EAIV,KAAA,EAAO,SAAA;AAAA,IACL,sBAAA;;;AAOJ;;;iBAAgB,0BAAA,CAAA;EAA6B,KAAA;EAAO,wBAAA;EAA0B;AAAA,GAAc,+BAAA,GAAkC,GAAA,CAAI,OAAA"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { useTranslation } from "./LocalizationContext.js";
|
|
2
|
+
import { c } from "react-compiler-runtime";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Button, Text } from "@stratakit/bricks";
|
|
5
|
+
import { Icon } from "@stratakit/foundations";
|
|
6
|
+
import errorSvg from "@stratakit/icons/status-error.svg";
|
|
7
|
+
|
|
8
|
+
//#region src/presentation-hierarchies-react/stratakit/RootErrorRenderer.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A component that renders root node error state.
|
|
11
|
+
*
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
function StrataKitRootErrorRenderer(t0) {
|
|
15
|
+
const $ = c(25);
|
|
16
|
+
const { error, getHierarchyLevelDetails, reloadTree } = t0;
|
|
17
|
+
const translate = useTranslation();
|
|
18
|
+
if (error.type === "ResultSetTooLarge") {
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] !== getHierarchyLevelDetails) {
|
|
21
|
+
t1 = () => getHierarchyLevelDetails(void 0)?.setSizeLimit("unbounded");
|
|
22
|
+
$[0] = getHierarchyLevelDetails;
|
|
23
|
+
$[1] = t1;
|
|
24
|
+
} else t1 = $[1];
|
|
25
|
+
const onOverrideLimit = t1;
|
|
26
|
+
let t2;
|
|
27
|
+
if ($[2] !== error.resultSetSizeLimit || $[3] !== translate) {
|
|
28
|
+
t2 = translate("rootResultLimitExceeded").replace("{{limit}}", error.resultSetSizeLimit.toString());
|
|
29
|
+
$[2] = error.resultSetSizeLimit;
|
|
30
|
+
$[3] = translate;
|
|
31
|
+
$[4] = t2;
|
|
32
|
+
} else t2 = $[4];
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[5] !== translate) {
|
|
35
|
+
t3 = translate("increaseHierarchyLimitToUnlimited");
|
|
36
|
+
$[5] = translate;
|
|
37
|
+
$[6] = t3;
|
|
38
|
+
} else t3 = $[6];
|
|
39
|
+
let t4;
|
|
40
|
+
if ($[7] !== onOverrideLimit || $[8] !== t3) {
|
|
41
|
+
t4 = [{
|
|
42
|
+
action: onOverrideLimit,
|
|
43
|
+
label: t3,
|
|
44
|
+
condition: _temp
|
|
45
|
+
}];
|
|
46
|
+
$[7] = onOverrideLimit;
|
|
47
|
+
$[8] = t3;
|
|
48
|
+
$[9] = t4;
|
|
49
|
+
} else t4 = $[9];
|
|
50
|
+
let t5;
|
|
51
|
+
if ($[10] !== t2 || $[11] !== t4) {
|
|
52
|
+
t5 = /* @__PURE__ */ jsx(RootErrorContainer, {
|
|
53
|
+
message: t2,
|
|
54
|
+
actions: t4
|
|
55
|
+
});
|
|
56
|
+
$[10] = t2;
|
|
57
|
+
$[11] = t4;
|
|
58
|
+
$[12] = t5;
|
|
59
|
+
} else t5 = $[12];
|
|
60
|
+
return t5;
|
|
61
|
+
}
|
|
62
|
+
let t1;
|
|
63
|
+
if ($[13] !== translate) {
|
|
64
|
+
t1 = translate("failedToCreateRootHierarchy");
|
|
65
|
+
$[13] = translate;
|
|
66
|
+
$[14] = t1;
|
|
67
|
+
} else t1 = $[14];
|
|
68
|
+
let t2;
|
|
69
|
+
if ($[15] !== reloadTree) {
|
|
70
|
+
t2 = () => reloadTree({
|
|
71
|
+
parentNodeId: void 0,
|
|
72
|
+
state: "reset"
|
|
73
|
+
});
|
|
74
|
+
$[15] = reloadTree;
|
|
75
|
+
$[16] = t2;
|
|
76
|
+
} else t2 = $[16];
|
|
77
|
+
let t3;
|
|
78
|
+
if ($[17] !== translate) {
|
|
79
|
+
t3 = translate("retry");
|
|
80
|
+
$[17] = translate;
|
|
81
|
+
$[18] = t3;
|
|
82
|
+
} else t3 = $[18];
|
|
83
|
+
let t4;
|
|
84
|
+
if ($[19] !== t2 || $[20] !== t3) {
|
|
85
|
+
t4 = [{
|
|
86
|
+
action: t2,
|
|
87
|
+
label: t3,
|
|
88
|
+
condition: _temp2
|
|
89
|
+
}];
|
|
90
|
+
$[19] = t2;
|
|
91
|
+
$[20] = t3;
|
|
92
|
+
$[21] = t4;
|
|
93
|
+
} else t4 = $[21];
|
|
94
|
+
let t5;
|
|
95
|
+
if ($[22] !== t1 || $[23] !== t4) {
|
|
96
|
+
t5 = /* @__PURE__ */ jsx(RootErrorContainer, {
|
|
97
|
+
message: t1,
|
|
98
|
+
actions: t4
|
|
99
|
+
});
|
|
100
|
+
$[22] = t1;
|
|
101
|
+
$[23] = t4;
|
|
102
|
+
$[24] = t5;
|
|
103
|
+
} else t5 = $[24];
|
|
104
|
+
return t5;
|
|
105
|
+
}
|
|
106
|
+
function _temp2() {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
function _temp() {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
function RootErrorContainer(t0) {
|
|
113
|
+
const $ = c(10);
|
|
114
|
+
const { actions, message } = t0;
|
|
115
|
+
let t1;
|
|
116
|
+
let t2;
|
|
117
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
118
|
+
t1 = {
|
|
119
|
+
height: "100%",
|
|
120
|
+
display: "flex",
|
|
121
|
+
flexDirection: "column",
|
|
122
|
+
justifyContent: "center",
|
|
123
|
+
alignItems: "center",
|
|
124
|
+
gap: "0.5rem"
|
|
125
|
+
};
|
|
126
|
+
t2 = /* @__PURE__ */ jsx(Icon, {
|
|
127
|
+
href: errorSvg,
|
|
128
|
+
size: "large"
|
|
129
|
+
});
|
|
130
|
+
$[0] = t1;
|
|
131
|
+
$[1] = t2;
|
|
132
|
+
} else {
|
|
133
|
+
t1 = $[0];
|
|
134
|
+
t2 = $[1];
|
|
135
|
+
}
|
|
136
|
+
let t3;
|
|
137
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
138
|
+
t3 = { textAlign: "center" };
|
|
139
|
+
$[2] = t3;
|
|
140
|
+
} else t3 = $[2];
|
|
141
|
+
let t4;
|
|
142
|
+
if ($[3] !== message) {
|
|
143
|
+
t4 = /* @__PURE__ */ jsx(Text, {
|
|
144
|
+
variant: "body-sm",
|
|
145
|
+
style: t3,
|
|
146
|
+
children: message
|
|
147
|
+
});
|
|
148
|
+
$[3] = message;
|
|
149
|
+
$[4] = t4;
|
|
150
|
+
} else t4 = $[4];
|
|
151
|
+
let t5;
|
|
152
|
+
if ($[5] !== actions) {
|
|
153
|
+
t5 = actions?.filter(_temp3).map(_temp4);
|
|
154
|
+
$[5] = actions;
|
|
155
|
+
$[6] = t5;
|
|
156
|
+
} else t5 = $[6];
|
|
157
|
+
let t6;
|
|
158
|
+
if ($[7] !== t4 || $[8] !== t5) {
|
|
159
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
160
|
+
style: t1,
|
|
161
|
+
children: [
|
|
162
|
+
t2,
|
|
163
|
+
t4,
|
|
164
|
+
t5
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
$[7] = t4;
|
|
168
|
+
$[8] = t5;
|
|
169
|
+
$[9] = t6;
|
|
170
|
+
} else t6 = $[9];
|
|
171
|
+
return t6;
|
|
172
|
+
}
|
|
173
|
+
function _temp4(action) {
|
|
174
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
175
|
+
onClick: () => action.action(),
|
|
176
|
+
children: action.label
|
|
177
|
+
}, action.label);
|
|
178
|
+
}
|
|
179
|
+
function _temp3(t0) {
|
|
180
|
+
const { condition } = t0;
|
|
181
|
+
return condition();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
//#endregion
|
|
185
|
+
export { StrataKitRootErrorRenderer };
|
|
186
|
+
//# sourceMappingURL=RootErrorRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootErrorRenderer.js","names":["Button","Text","Icon","errorSvg","useTranslation","JSX","RootErrorRendererProps","ErrorInfo","StrataKitRootErrorRendererProps","error","StrataKitRootErrorRenderer","t0","$","_c","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 errorSvg from \"@stratakit/icons/status-error.svg\";\nimport { useTranslation } from \"./LocalizationContext.js\";\n\nimport type { JSX } from \"react\";\nimport type { RootErrorRendererProps } from \"../Renderers.js\";\nimport type { ErrorInfo } from \"../TreeNode.js\";\n\n/**\n * @alpha\n */\nexport type StrataKitRootErrorRendererProps = {\n /**\n * Root error to be displayed\n */\n error: ErrorInfo;\n} & RootErrorRendererProps;\n\n/**\n * A component that renders root node error state.\n *\n * @alpha\n */\nexport function StrataKitRootErrorRenderer({ error, getHierarchyLevelDetails, reloadTree }: 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 {\n action: onOverrideLimit,\n label: translate(\"increaseHierarchyLimitToUnlimited\"),\n condition: () => true,\n },\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 style={{ height: \"100%\", display: \"flex\", flexDirection: \"column\", justifyContent: \"center\", alignItems: \"center\", gap: \"0.5rem\" }}>\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":";;;;;;;;;;;;;AA6BA,SAAOU,2BAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,GAAA;CAAoC,MAAA,EAAAJ,OAAAK,0BAAAC,eAAAJ;CACzC,MAAAK,YA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Ac;AAAA,KAAAd,EAAA,OAAA4B,OAAAC,IAAA,4BAAA,EAAA;AACJf,OAAA,EAAAsB,WAAa,UAAU;AAAApC,IAAA,KAAAc;OAAAA,MAAAd,EAAA;CAAA,IAAAe;AAAA,KAAAf,EAAA,OAAAyB,SAAA;AAAxDV,OAAA,oBAAC;GAAc,SAAA;GAAkB,OAAAD;aAC9BW;IACI;AAAAzB,IAAA,KAAAyB;AAAAzB,IAAA,KAAAe;OAAAA,MAAAf,EAAA;CAAA,IAAAoB;AAAA,KAAApB,EAAA,OAAA0B,SAAA;AACNN,OAAAM,SAAOW,OACGC,OACL,CAAAC,IAACC,OAMH;AAAAxC,IAAA,KAAA0B;AAAA1B,IAAA,KAAAoB;OAAAA,MAAApB,EAAA;CAAA,IAAAyC;AAAA,KAAAzC,EAAA,OAAAe,MAAAf,EAAA,OAAAoB,IAAA;AAbNqB,OAAA,qBAAA;GAAY,OAAAnC;;IACVI;IACAK;IAGCK;;IASG;AAAApB,IAAA,KAAAe;AAAAf,IAAA,KAAAoB;AAAApB,IAAA,KAAAyC;OAAAA,MAAAzC,EAAA;AAAA,QAdNyC;;AAFJ,SAAAD,OAAAxB,QAAA;AAAA,QAWY,oBAAC;EAAmC,eAAMA,OAAMA,QAAQ;YACrDA,OAAMC;IADID,OAAMC,MAEV;;AAbrB,SAAAqB,OAAAvC,IAAA;CAQkB,MAAA,EAAAmB,cAAAnB;AAAa,QAAKmB,WAAW"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ComponentProps, NamedExoticComponent } from "react";
|
|
2
|
+
import { Tree } from "@stratakit/structures";
|
|
3
|
+
|
|
4
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeAction.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Attributes used to decide how to render tree actions. They allow to differentiate action style based on the context
|
|
7
|
+
* where that action is used.
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
interface TreeActionBaseAttributes {
|
|
11
|
+
/**
|
|
12
|
+
* Specifies action variant supported by tree nodes:
|
|
13
|
+
*
|
|
14
|
+
* - "default" - standard action displayed in the dropdown menu accessible through the ellipsis button on the node.
|
|
15
|
+
* - "inline" - actions displayed directly on the tree node.
|
|
16
|
+
* - "context-menu" - actions displayed in the context menu opened by right-clicking the tree node.
|
|
17
|
+
*/
|
|
18
|
+
variant?: "default" | "inline" | "context-menu";
|
|
19
|
+
/**
|
|
20
|
+
* Indicates that the actions is not applicable for current tree node and should be hidden.
|
|
21
|
+
* When set to true, the action will not be rendered at all.
|
|
22
|
+
*/
|
|
23
|
+
hide?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** @alpha */
|
|
26
|
+
type TreeActionBaseProps = ComponentProps<typeof Tree.ItemAction> & TreeActionBaseAttributes;
|
|
27
|
+
/**
|
|
28
|
+
* Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.
|
|
29
|
+
* Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.
|
|
30
|
+
*
|
|
31
|
+
* When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:
|
|
32
|
+
*
|
|
33
|
+
* ```tsx
|
|
34
|
+
* interface MyCustomTreeActionProps extends TreeActionBaseAttributes {
|
|
35
|
+
* myProp: string
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {
|
|
39
|
+
* // custom button logic goes here
|
|
40
|
+
* return <TreeActionBase {...attributes} icon={...} onClick={...} />
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @alpha
|
|
45
|
+
*/
|
|
46
|
+
declare const TreeActionBase: NamedExoticComponent<TreeActionBaseProps>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { TreeActionBase, TreeActionBaseAttributes };
|
|
49
|
+
//# sourceMappingURL=TreeAction.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { c } from "react-compiler-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { DropdownMenu, Tree } from "@stratakit/structures";
|
|
5
|
+
|
|
6
|
+
//#region src/presentation-hierarchies-react/stratakit/TreeAction.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Base component used to render tree actions. It is designed to allow rendering same action in different contexts: inline, dropdown, context menu.
|
|
9
|
+
* Should be used together with `StrataKitTreeNodeRenderer` and returned from `getInlineActions`, `getMenuActions` and `getContextMenuActions` callbacks.
|
|
10
|
+
*
|
|
11
|
+
* When implementing custom action that returns this component, make sure to forward `TreeActionBaseAttributes` props to it. Example:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* interface MyCustomTreeActionProps extends TreeActionBaseAttributes {
|
|
15
|
+
* myProp: string
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* function MyCustomTreeAction({ myProp, ...attributes }: MyCustomTreeActionProps) {
|
|
19
|
+
* // custom button logic goes here
|
|
20
|
+
* return <TreeActionBase {...attributes} icon={...} onClick={...} />
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @alpha
|
|
25
|
+
*/
|
|
26
|
+
const TreeActionBase = memo(function TreeActionBase(t0) {
|
|
27
|
+
const $ = c(15);
|
|
28
|
+
let actionProps;
|
|
29
|
+
let dot;
|
|
30
|
+
let hide;
|
|
31
|
+
let t1;
|
|
32
|
+
let visible;
|
|
33
|
+
if ($[0] !== t0) {
|
|
34
|
+
({hide, variant: t1, dot, visible, ...actionProps} = t0);
|
|
35
|
+
$[0] = t0;
|
|
36
|
+
$[1] = actionProps;
|
|
37
|
+
$[2] = dot;
|
|
38
|
+
$[3] = hide;
|
|
39
|
+
$[4] = t1;
|
|
40
|
+
$[5] = visible;
|
|
41
|
+
} else {
|
|
42
|
+
actionProps = $[1];
|
|
43
|
+
dot = $[2];
|
|
44
|
+
hide = $[3];
|
|
45
|
+
t1 = $[4];
|
|
46
|
+
visible = $[5];
|
|
47
|
+
}
|
|
48
|
+
const variant = t1 === void 0 ? "default" : t1;
|
|
49
|
+
if (hide) {
|
|
50
|
+
let t2;
|
|
51
|
+
if ($[6] !== actionProps || $[7] !== variant) {
|
|
52
|
+
t2 = variant === "inline" ? /* @__PURE__ */ jsx(Tree.ItemAction, {
|
|
53
|
+
...actionProps,
|
|
54
|
+
visible: false
|
|
55
|
+
}) : void 0;
|
|
56
|
+
$[6] = actionProps;
|
|
57
|
+
$[7] = variant;
|
|
58
|
+
$[8] = t2;
|
|
59
|
+
} else t2 = $[8];
|
|
60
|
+
return t2;
|
|
61
|
+
}
|
|
62
|
+
if (variant === "context-menu") {
|
|
63
|
+
let t2;
|
|
64
|
+
if ($[9] !== actionProps) {
|
|
65
|
+
t2 = /* @__PURE__ */ jsx(DropdownMenu.Item, { ...actionProps });
|
|
66
|
+
$[9] = actionProps;
|
|
67
|
+
$[10] = t2;
|
|
68
|
+
} else t2 = $[10];
|
|
69
|
+
return t2;
|
|
70
|
+
}
|
|
71
|
+
const t2 = variant === "inline" ? visible : void 0;
|
|
72
|
+
let t3;
|
|
73
|
+
if ($[11] !== actionProps || $[12] !== dot || $[13] !== t2) {
|
|
74
|
+
t3 = /* @__PURE__ */ jsx(Tree.ItemAction, {
|
|
75
|
+
...actionProps,
|
|
76
|
+
dot,
|
|
77
|
+
visible: t2
|
|
78
|
+
});
|
|
79
|
+
$[11] = actionProps;
|
|
80
|
+
$[12] = dot;
|
|
81
|
+
$[13] = t2;
|
|
82
|
+
$[14] = t3;
|
|
83
|
+
} else t3 = $[14];
|
|
84
|
+
return t3;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
export { TreeActionBase };
|
|
89
|
+
//# sourceMappingURL=TreeAction.js.map
|