@likec4/diagram 1.19.1 → 1.20.0
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/dist/LikeC4Diagram.css.d.ts +0 -1
- package/dist/LikeC4Diagram.css.js +1 -5
- package/dist/LikeC4Diagram.d.ts +1 -4
- package/dist/LikeC4Diagram.js +102 -147
- package/dist/LikeC4Diagram.props.d.ts +10 -16
- package/dist/LikeC4Search.js +7 -15
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/base/Background.d.ts +7 -0
- package/dist/{xyflow/XYFlowBackground.js → base/Background.js} +5 -6
- package/dist/base/BaseXYFlow.d.ts +14 -0
- package/dist/base/BaseXYFlow.js +146 -0
- package/dist/base/example/RelationshipsBrowser.d.ts +6 -0
- package/dist/base/example/_types.d.ts +20 -0
- package/dist/base/example/custom.d.ts +71 -0
- package/dist/base/example/useViewToNodesEdges.d.ts +6 -0
- package/dist/base/index.d.ts +2 -0
- package/dist/base/primitives/NodeHandles.d.ts +4 -0
- package/dist/base/primitives/NodeHandles.js +14 -0
- package/dist/base/primitives/compound/CompoundActionButton.css.d.ts +3 -0
- package/dist/base/primitives/compound/CompoundActionButton.css.js +9 -0
- package/dist/base/primitives/compound/CompoundActionButton.d.ts +7 -0
- package/dist/base/primitives/compound/CompoundActionButton.js +48 -0
- package/dist/base/primitives/compound/CompoundDetailsButton.css.d.ts +3 -0
- package/dist/base/primitives/compound/CompoundDetailsButton.css.js +9 -0
- package/dist/base/primitives/compound/CompoundDetailsButton.d.ts +7 -0
- package/dist/base/primitives/compound/CompoundDetailsButton.js +50 -0
- package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +9 -0
- package/dist/base/primitives/compound/CompoundNodeContainer.css.js +17 -0
- package/dist/base/primitives/compound/CompoundNodeContainer.d.ts +26 -0
- package/dist/base/primitives/compound/CompoundNodeContainer.js +86 -0
- package/dist/base/primitives/compound/CompoundTitle.css.d.ts +2 -0
- package/dist/base/primitives/compound/CompoundTitle.css.js +7 -0
- package/dist/base/primitives/compound/CompoundTitle.d.ts +6 -0
- package/dist/base/primitives/compound/CompoundTitle.js +20 -0
- package/dist/base/primitives/customEdge.d.ts +41 -0
- package/dist/base/primitives/customEdge.js +13 -0
- package/dist/base/primitives/customNode.d.ts +7 -0
- package/dist/base/primitives/customNode.js +10 -0
- package/dist/base/primitives/edge/EdgeActionButton.d.ts +7 -0
- package/dist/base/primitives/edge/EdgeActionButton.js +24 -0
- package/dist/base/primitives/edge/EdgeContainer.d.ts +10 -0
- package/dist/base/primitives/edge/EdgeContainer.js +35 -0
- package/dist/{xyflow/edges/edges.css.d.ts → base/primitives/edge/EdgeLabel.css.d.ts} +5 -9
- package/dist/base/primitives/edge/EdgeLabel.css.js +25 -0
- package/dist/base/primitives/edge/EdgeLabel.d.ts +51 -0
- package/dist/base/primitives/edge/EdgeLabel.js +90 -0
- package/dist/{xyflow → base/primitives/edge}/EdgeMarkers.d.ts +2 -0
- package/dist/{xyflow → base/primitives/edge}/EdgeMarkers.js +29 -1
- package/dist/base/primitives/edge/EdgePath.d.ts +44 -0
- package/dist/base/primitives/edge/EdgePath.js +77 -0
- package/dist/base/primitives/edge/edge.css.d.ts +6 -0
- package/dist/base/primitives/edge/edge.css.js +14 -0
- package/dist/base/primitives/element/ElementActionButtons.css.d.ts +3 -0
- package/dist/base/primitives/element/ElementActionButtons.css.js +9 -0
- package/dist/base/primitives/element/ElementActionButtons.d.ts +13 -0
- package/dist/base/primitives/element/ElementActionButtons.js +62 -0
- package/dist/base/primitives/element/ElementDetailsButton.css.d.ts +3 -0
- package/dist/base/primitives/element/ElementDetailsButton.css.js +9 -0
- package/dist/base/primitives/element/ElementDetailsButton.d.ts +7 -0
- package/dist/base/primitives/element/ElementDetailsButton.js +54 -0
- package/dist/base/primitives/element/ElementNodeContainer.css.d.ts +3 -0
- package/dist/base/primitives/element/ElementNodeContainer.css.js +7 -0
- package/dist/base/primitives/element/ElementNodeContainer.d.ts +26 -0
- package/dist/base/primitives/element/ElementNodeContainer.js +60 -0
- package/dist/base/primitives/element/ElementShape.css.d.ts +6 -0
- package/dist/base/primitives/element/ElementShape.css.js +14 -0
- package/dist/base/primitives/element/ElementShape.d.ts +28 -0
- package/dist/{xyflow/nodes/element/ElementShapeSvg.js → base/primitives/element/ElementShape.js} +23 -7
- package/dist/base/primitives/element/ElementTitle.css.d.ts +8 -0
- package/dist/base/primitives/element/ElementTitle.css.js +19 -0
- package/dist/base/primitives/element/ElementTitle.d.ts +10 -0
- package/dist/base/primitives/element/ElementTitle.js +66 -0
- package/dist/base/primitives/index.d.ts +17 -0
- package/dist/base/types.d.ts +90 -0
- package/dist/base/types.js +54 -0
- package/dist/base/updateEdges.d.ts +3 -0
- package/dist/base/updateEdges.js +31 -0
- package/dist/base/updateNodes.d.ts +3 -0
- package/dist/base/updateNodes.js +36 -0
- package/dist/base/xyflowMachine.d.ts +212 -0
- package/dist/context/DiagramEventHandlers.d.ts +10 -0
- package/dist/context/DiagramEventHandlers.js +49 -0
- package/dist/context/DiagramFeatures.d.ts +31 -0
- package/dist/context/DiagramFeatures.js +140 -0
- package/dist/{ui → context}/FramerMotionConfig.js +2 -4
- package/dist/context/IconRenderer.d.ts +11 -0
- package/dist/{xyflow/nodes/shared/ElementIcon.js → context/IconRenderer.js} +14 -14
- package/dist/context/RootContainer.d.ts +9 -0
- package/dist/context/RootContainer.js +20 -0
- package/dist/context/index.d.ts +7 -0
- package/dist/globals.css.js +0 -87
- package/dist/hooks/index.d.ts +7 -5
- package/dist/hooks/useCurrentViewId.d.ts +2 -0
- package/dist/hooks/useCurrentViewId.js +8 -0
- package/dist/hooks/useDiagram.d.ts +10725 -0
- package/dist/hooks/useDiagram.js +119 -0
- package/dist/hooks/useDiagramActor.d.ts +5 -0
- package/dist/hooks/useDiagramActor.js +21 -0
- package/dist/hooks/useDiagramContext.d.ts +3 -0
- package/dist/hooks/useDiagramContext.js +10 -0
- package/dist/hooks/useMantinePortalProps.js +2 -2
- package/dist/hooks/useXYFlow.d.ts +195 -37
- package/dist/hooks/useXYFlow.js +4 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -6
- package/dist/likec4diagram/DiagramActor.d.ts +7 -0
- package/dist/likec4diagram/DiagramActor.js +71 -0
- package/dist/likec4diagram/DiagramUI.d.ts +2 -0
- package/dist/likec4diagram/DiagramUI.js +22 -0
- package/dist/likec4diagram/XYFlow.d.ts +6 -0
- package/dist/likec4diagram/XYFlow.js +122 -0
- package/dist/likec4diagram/custom/edges/NotePopover.css.d.ts +2 -0
- package/dist/likec4diagram/custom/edges/NotePopover.css.js +7 -0
- package/dist/likec4diagram/custom/edges/NotePopover.d.ts +4 -0
- package/dist/likec4diagram/custom/edges/NotePopover.js +101 -0
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +55 -0
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +307 -0
- package/dist/{xyflow → likec4diagram/custom}/edges/RelationshipsDropdownMenu.css.js +4 -4
- package/dist/{xyflow → likec4diagram/custom}/edges/RelationshipsDropdownMenu.d.ts +5 -5
- package/dist/{xyflow → likec4diagram/custom}/edges/RelationshipsDropdownMenu.js +51 -53
- package/dist/likec4diagram/custom/edges/edges.css.d.ts +2 -0
- package/dist/likec4diagram/custom/edges/edges.css.js +7 -0
- package/dist/likec4diagram/custom/edges/utils.d.ts +22 -0
- package/dist/likec4diagram/custom/edges/utils.js +25 -0
- package/dist/likec4diagram/custom/index.d.ts +57 -0
- package/dist/likec4diagram/custom/index.js +7 -0
- package/dist/likec4diagram/custom/nodes/CompoundActions.d.ts +5 -0
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +25 -0
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +7 -0
- package/dist/likec4diagram/custom/nodes/ElementActions.js +69 -0
- package/dist/likec4diagram/custom/nodes/nodeTypes.d.ts +10 -0
- package/dist/likec4diagram/custom/nodes/nodeTypes.js +94 -0
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +21 -0
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +159 -0
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.d.ts +7 -0
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +128 -0
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.d.ts +7 -0
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +149 -0
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.d.ts +8 -0
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.js +66 -0
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +40 -0
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +131 -0
- package/dist/likec4diagram/custom/nodes/toolbar/styles.css.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/toolbar/styles.css.js +5 -0
- package/dist/likec4diagram/state/actorContext.d.ts +50849 -0
- package/dist/likec4diagram/state/actorContext.js +12 -0
- package/dist/{state → likec4diagram/state}/aligners.d.ts +4 -1
- package/dist/{state → likec4diagram/state}/aligners.js +31 -5
- package/dist/likec4diagram/state/assign.d.ts +18 -0
- package/dist/likec4diagram/state/assign.js +343 -0
- package/dist/likec4diagram/state/hotkeyActor.d.ts +5 -0
- package/dist/likec4diagram/state/hotkeyActor.js +18 -0
- package/dist/likec4diagram/state/inspector.d.ts +5 -0
- package/dist/likec4diagram/state/machine.d.ts +10751 -0
- package/dist/likec4diagram/state/machine.js +783 -0
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +113 -0
- package/dist/likec4diagram/state/syncManualLayoutActor.js +178 -0
- package/dist/likec4diagram/state/utils.d.ts +8 -0
- package/dist/likec4diagram/state/utils.js +48 -0
- package/dist/likec4diagram/types.d.ts +74 -0
- package/dist/{ui/top-left → likec4diagram/ui/controls}/ChangeAutoLayoutButton.js +11 -10
- package/dist/likec4diagram/ui/controls/Controls.d.ts +2 -0
- package/dist/likec4diagram/ui/controls/Controls.js +102 -0
- package/dist/likec4diagram/ui/controls/LayoutDriftNotification.d.ts +2 -0
- package/dist/likec4diagram/ui/controls/LayoutDriftNotification.js +43 -0
- package/dist/{ui/top-left → likec4diagram/ui/controls}/ManualLayoutToolsButton.js +11 -11
- package/dist/likec4diagram/ui/controls/NavigationButtons.d.ts +1 -0
- package/dist/likec4diagram/ui/controls/NavigationButtons.js +92 -0
- package/dist/{ui/top-left → likec4diagram/ui/controls}/_shared.js +2 -1
- package/dist/{ui/top-left → likec4diagram/ui/controls}/styles.css.d.ts +1 -1
- package/dist/likec4diagram/ui/controls/styles.css.js +17 -0
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.css.js +11 -0
- package/dist/likec4diagram/ui/diagram-title/DiagramTitlePanel.d.ts +1 -0
- package/dist/{ui → likec4diagram/ui/diagram-title}/DiagramTitlePanel.js +3 -3
- package/dist/likec4diagram/ui/diagram-title/Link.d.ts +4 -0
- package/dist/likec4diagram/ui/index.d.ts +2 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +13 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.d.ts +2 -0
- package/dist/{ui → likec4diagram/ui}/notation/NotationPanel.js +23 -31
- package/dist/{ui → likec4diagram/ui/walkthrough}/DynamicViewWalkthrough.css.js +4 -4
- package/dist/{ui → likec4diagram/ui/walkthrough}/DynamicViewWalkthrough.js +19 -44
- package/dist/{xyflow → likec4diagram}/useLayoutConstraints.d.ts +11 -6
- package/dist/{xyflow → likec4diagram}/useLayoutConstraints.js +17 -12
- package/dist/likec4diagram/useViewToNodesEdges.d.ts +11 -0
- package/dist/likec4diagram/useViewToNodesEdges.js +245 -0
- package/dist/likec4model/index.d.ts +1 -1
- package/dist/likec4model/useLikeC4Model.d.ts +1 -11
- package/dist/likec4model/useLikeC4Model.js +1 -39
- package/dist/overlays/Overlays.js +61 -105
- package/dist/overlays/element-details/ElementDetailsCard.js +111 -116
- package/dist/overlays/element-details/TabPanelDeployments.js +4 -7
- package/dist/overlays/element-details/TabPanelRelationships.css.js +0 -2
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelRelationships.js +35 -64
- package/dist/overlays/element-details/TabPanelStructure.d.ts +2 -2
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/overlay/Overlay.css.d.ts +2 -0
- package/dist/overlays/overlay/Overlay.css.js +93 -0
- package/dist/overlays/overlay/Overlay.d.ts +8 -0
- package/dist/overlays/overlay/Overlay.js +86 -0
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +5 -0
- package/dist/overlays/relationship-details/RelationshipDetails.js +189 -0
- package/dist/overlays/{edge-details → relationship-details}/SelectEdge.css.d.ts +1 -0
- package/dist/overlays/relationship-details/SelectEdge.css.js +17 -0
- package/dist/overlays/{edge-details → relationship-details}/SelectEdge.d.ts +1 -1
- package/dist/overlays/{edge-details → relationship-details}/SelectEdge.js +8 -8
- package/dist/overlays/relationship-details/_types.d.ts +36 -0
- package/dist/overlays/relationship-details/actor.d.ts +41 -0
- package/dist/overlays/relationship-details/actor.js +113 -0
- package/dist/overlays/relationship-details/custom/ElementActions.d.ts +5 -0
- package/dist/overlays/relationship-details/custom/ElementActions.js +33 -0
- package/dist/overlays/relationship-details/custom/edgeTypes.d.ts +49 -0
- package/dist/overlays/relationship-details/custom/edgeTypes.js +51 -0
- package/dist/overlays/relationship-details/custom/index.d.ts +2 -0
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +39 -0
- package/dist/overlays/relationship-details/custom/nodeTypes.js +89 -0
- package/dist/overlays/relationship-details/custom/styles.css.d.ts +1 -0
- package/dist/overlays/relationship-details/hooks.d.ts +59 -0
- package/dist/overlays/relationship-details/hooks.js +46 -0
- package/dist/overlays/{edge-details/use-layouted-edge-details.d.ts → relationship-details/useLayoutedDetails.d.ts} +4 -6
- package/dist/overlays/{edge-details/use-layouted-edge-details.js → relationship-details/useLayoutedDetails.js} +68 -64
- package/dist/overlays/relationships-browser/-useRelationshipsView.d.ts +39 -0
- package/dist/overlays/relationships-browser/-useRelationshipsView.js +488 -0
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +5 -0
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +209 -0
- package/dist/overlays/{relationships-of → relationships-browser}/SelectElement.css.d.ts +1 -0
- package/dist/overlays/relationships-browser/SelectElement.css.js +9 -0
- package/dist/overlays/relationships-browser/SelectElement.d.ts +7 -0
- package/dist/overlays/{relationships-of → relationships-browser}/SelectElement.js +11 -7
- package/dist/overlays/relationships-browser/_types.d.ts +40 -0
- package/dist/overlays/relationships-browser/actor.d.ts +66 -0
- package/dist/overlays/relationships-browser/actor.js +159 -0
- package/dist/overlays/relationships-browser/custom/ElementActions.d.ts +5 -0
- package/dist/overlays/relationships-browser/custom/ElementActions.js +43 -0
- package/dist/overlays/relationships-browser/custom/EmptyNode.d.ts +5 -0
- package/dist/overlays/{relationships-of/xyflow → relationships-browser/custom}/EmptyNode.js +1 -3
- package/dist/overlays/relationships-browser/custom/edgeTypes.d.ts +46 -0
- package/dist/overlays/relationships-browser/custom/edgeTypes.js +51 -0
- package/dist/overlays/relationships-browser/custom/index.d.ts +2 -0
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +45 -0
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +93 -0
- package/dist/overlays/relationships-browser/custom/styles.css.d.ts +1 -0
- package/dist/overlays/relationships-browser/custom/styles.css.js +5 -0
- package/dist/overlays/relationships-browser/hooks.d.ts +62 -0
- package/dist/overlays/relationships-browser/hooks.js +46 -0
- package/dist/overlays/relationships-browser/useViewToNodesEdges.d.ts +10 -0
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +160 -0
- package/dist/style.css +1 -1
- package/dist/theme-vars.css.js +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/{xyflow/utils.d.ts → utils/xyflow.d.ts} +4 -4
- package/dist/{xyflow/utils.js → utils/xyflow.js} +14 -20
- package/package.json +24 -21
- package/src/LikeC4Diagram.css.ts +21 -15
- package/src/LikeC4Diagram.props.ts +14 -21
- package/src/LikeC4Diagram.tsx +105 -150
- package/src/LikeC4Search.tsx +21 -28
- package/src/StaticLikeC4Diagram.tsx +0 -1
- package/src/{xyflow/XYFlowBackground.tsx → base/Background.tsx} +8 -8
- package/src/base/BaseXYFlow.tsx +200 -0
- package/src/{xyflow → base}/const.ts +1 -1
- package/src/base/example/RelationshipsBrowser.tsx +62 -0
- package/src/base/example/_types.ts +71 -0
- package/src/base/example/custom.tsx +58 -0
- package/src/base/example/useViewToNodesEdges.ts +193 -0
- package/src/base/index.ts +10 -0
- package/src/base/primitives/NodeHandles.tsx +18 -0
- package/src/base/primitives/compound/CompoundActionButton.css.ts +55 -0
- package/src/base/primitives/compound/CompoundActionButton.tsx +52 -0
- package/src/base/primitives/compound/CompoundDetailsButton.css.ts +56 -0
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +54 -0
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +161 -0
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +95 -0
- package/src/base/primitives/compound/CompoundTitle.css.ts +43 -0
- package/src/base/primitives/compound/CompoundTitle.tsx +29 -0
- package/src/base/primitives/customEdge.ts +32 -0
- package/src/base/primitives/customNode.ts +21 -0
- package/src/base/primitives/edge/EdgeActionButton.tsx +27 -0
- package/src/base/primitives/edge/EdgeContainer.tsx +48 -0
- package/src/base/primitives/edge/EdgeLabel.css.ts +196 -0
- package/src/base/primitives/edge/EdgeLabel.tsx +136 -0
- package/src/{xyflow → base/primitives/edge}/EdgeMarkers.tsx +29 -1
- package/src/base/primitives/edge/EdgePath.tsx +89 -0
- package/src/base/primitives/edge/edge.css.ts +122 -0
- package/src/base/primitives/element/ElementActionButtons.css.ts +48 -0
- package/src/base/primitives/element/ElementActionButtons.tsx +73 -0
- package/src/base/primitives/element/ElementDetailsButton.css.ts +54 -0
- package/src/base/primitives/element/ElementDetailsButton.tsx +59 -0
- package/src/base/primitives/element/ElementNodeContainer.css.ts +47 -0
- package/src/base/primitives/element/ElementNodeContainer.tsx +72 -0
- package/src/base/primitives/element/ElementShape.css.ts +134 -0
- package/src/{xyflow/nodes/element/ElementShapeSvg.tsx → base/primitives/element/ElementShape.tsx} +64 -19
- package/src/base/primitives/element/ElementTitle.css.ts +156 -0
- package/src/base/primitives/element/ElementTitle.tsx +76 -0
- package/src/base/primitives/index.ts +17 -0
- package/src/base/types.ts +169 -0
- package/src/base/updateEdges.ts +40 -0
- package/src/base/updateNodes.ts +46 -0
- package/src/base/xyflowMachine.ts +75 -0
- package/src/context/DiagramEventHandlers.tsx +53 -0
- package/src/context/DiagramFeatures.tsx +162 -0
- package/src/{ui → context}/FramerMotionConfig.tsx +2 -6
- package/src/context/IconRenderer.tsx +45 -0
- package/src/context/RootContainer.tsx +31 -0
- package/src/context/index.ts +14 -0
- package/src/globals.css.ts +32 -32
- package/src/hooks/index.ts +7 -5
- package/src/hooks/useCurrentViewId.ts +8 -0
- package/src/hooks/useDiagram.ts +129 -0
- package/src/hooks/useDiagramActor.ts +25 -0
- package/src/hooks/useDiagramContext.ts +11 -0
- package/src/hooks/useMantinePortalProps.ts +2 -2
- package/src/hooks/useXYFlow.ts +12 -38
- package/src/index.ts +3 -7
- package/src/likec4diagram/DiagramActor.tsx +79 -0
- package/src/likec4diagram/DiagramUI.tsx +28 -0
- package/src/likec4diagram/XYFlow.tsx +137 -0
- package/src/likec4diagram/custom/edges/NotePopover.css.ts +27 -0
- package/src/likec4diagram/custom/edges/NotePopover.tsx +96 -0
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +355 -0
- package/src/{xyflow → likec4diagram/custom}/edges/RelationshipsDropdownMenu.css.ts +7 -7
- package/src/{xyflow → likec4diagram/custom}/edges/RelationshipsDropdownMenu.tsx +91 -70
- package/src/likec4diagram/custom/edges/edges.css.ts +39 -0
- package/src/likec4diagram/custom/edges/utils.ts +126 -0
- package/src/likec4diagram/custom/index.tsx +8 -0
- package/src/likec4diagram/custom/nodes/CompoundActions.tsx +27 -0
- package/src/likec4diagram/custom/nodes/ElementActions.tsx +74 -0
- package/src/likec4diagram/custom/nodes/nodeTypes.tsx +107 -0
- package/src/likec4diagram/custom/nodes/toolbar/ColorButton.tsx +175 -0
- package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +122 -0
- package/src/likec4diagram/custom/nodes/toolbar/ElementToolbar.tsx +140 -0
- package/src/likec4diagram/custom/nodes/toolbar/Toolbar.tsx +77 -0
- package/src/likec4diagram/custom/nodes/toolbar/_shared.tsx +143 -0
- package/src/likec4diagram/custom/nodes/toolbar/styles.css.ts +9 -0
- package/src/likec4diagram/state/actorContext.ts +8 -0
- package/src/{state → likec4diagram/state}/aligners.ts +67 -40
- package/src/likec4diagram/state/assign.ts +384 -0
- package/src/likec4diagram/state/hotkeyActor.ts +20 -0
- package/src/likec4diagram/state/inspector.ts +23 -0
- package/src/likec4diagram/state/machine.ts +946 -0
- package/src/likec4diagram/state/syncManualLayoutActor.ts +219 -0
- package/src/likec4diagram/state/utils.ts +52 -0
- package/src/likec4diagram/types.ts +144 -0
- package/src/{ui/top-left → likec4diagram/ui/controls}/ChangeAutoLayoutButton.tsx +32 -28
- package/src/likec4diagram/ui/controls/Controls.tsx +107 -0
- package/src/likec4diagram/ui/controls/LayoutDriftNotification.tsx +46 -0
- package/src/{ui/top-left → likec4diagram/ui/controls}/ManualLayoutToolsButton.tsx +16 -16
- package/src/likec4diagram/ui/controls/NavigationButtons.tsx +83 -0
- package/src/{ui/top-left → likec4diagram/ui/controls}/_shared.ts +4 -3
- package/src/{ui/top-left → likec4diagram/ui/controls}/styles.css.ts +17 -17
- package/src/{ui → likec4diagram/ui/diagram-title}/DiagramTitlePanel.css.ts +11 -11
- package/src/{ui → likec4diagram/ui/diagram-title}/DiagramTitlePanel.tsx +6 -5
- package/src/likec4diagram/ui/diagram-title/Link.tsx +40 -0
- package/src/likec4diagram/ui/index.ts +2 -0
- package/src/{ui → likec4diagram/ui}/notation/NotationPanel.css.ts +18 -18
- package/src/{ui → likec4diagram/ui}/notation/NotationPanel.tsx +44 -44
- package/src/{ui → likec4diagram/ui/walkthrough}/DynamicViewWalkthrough.css.ts +16 -16
- package/src/{ui → likec4diagram/ui/walkthrough}/DynamicViewWalkthrough.tsx +29 -49
- package/src/{xyflow → likec4diagram}/useLayoutConstraints.ts +54 -43
- package/src/likec4diagram/useViewToNodesEdges.ts +297 -0
- package/src/likec4model/index.ts +0 -6
- package/src/likec4model/useLikeC4Model.ts +1 -43
- package/src/overlays/Overlays.tsx +201 -147
- package/src/overlays/element-details/ElementDetailsCard.css.ts +58 -58
- package/src/overlays/element-details/ElementDetailsCard.tsx +143 -128
- package/src/overlays/element-details/TabPanelDeployments.css.ts +14 -14
- package/src/overlays/element-details/TabPanelDeployments.tsx +22 -22
- package/src/overlays/element-details/TabPanelRelationships.css.ts +19 -19
- package/src/overlays/element-details/TabPanelRelationships.tsx +45 -28
- package/src/overlays/element-details/TabPanelStructure.css.ts +7 -7
- package/src/overlays/element-details/TabPanelStructure.tsx +11 -11
- package/src/overlays/overlay/Overlay.css.ts +73 -0
- package/src/overlays/overlay/Overlay.tsx +99 -0
- package/src/overlays/relationship-details/RelationshipDetails.tsx +234 -0
- package/src/overlays/{edge-details → relationship-details}/SelectEdge.css.ts +20 -13
- package/src/overlays/{edge-details → relationship-details}/SelectEdge.tsx +14 -14
- package/src/overlays/relationship-details/_types.ts +73 -0
- package/src/overlays/relationship-details/actor.ts +162 -0
- package/src/overlays/relationship-details/custom/ElementActions.tsx +45 -0
- package/src/overlays/relationship-details/custom/edgeTypes.tsx +49 -0
- package/src/overlays/relationship-details/custom/index.tsx +2 -0
- package/src/overlays/relationship-details/custom/nodeTypes.tsx +108 -0
- package/src/overlays/relationship-details/custom/styles.css.ts +13 -0
- package/src/overlays/relationship-details/hooks.ts +48 -0
- package/src/overlays/{edge-details/use-layouted-edge-details.ts → relationship-details/useLayoutedDetails.ts} +128 -114
- package/src/overlays/relationships-browser/-useRelationshipsView.ts +642 -0
- package/src/overlays/relationships-browser/RelationshipsBrowser.tsx +247 -0
- package/src/overlays/{relationships-of → relationships-browser}/SelectElement.css.ts +12 -5
- package/src/overlays/{relationships-of → relationships-browser}/SelectElement.tsx +19 -17
- package/src/overlays/relationships-browser/_types.ts +89 -0
- package/src/overlays/relationships-browser/actor.ts +224 -0
- package/src/overlays/relationships-browser/custom/ElementActions.tsx +44 -0
- package/src/overlays/relationships-browser/custom/EmptyNode.tsx +18 -0
- package/src/overlays/relationships-browser/custom/edgeTypes.tsx +49 -0
- package/src/overlays/relationships-browser/custom/index.tsx +2 -0
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +109 -0
- package/src/overlays/relationships-browser/custom/styles.css.ts +13 -0
- package/src/overlays/relationships-browser/hooks.ts +48 -0
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +209 -0
- package/src/utils/index.ts +15 -0
- package/src/{xyflow/utils.ts → utils/xyflow.ts} +22 -8
- package/dist/_virtual/_commonjsHelpers.js +0 -6
- package/dist/controls/Text.d.ts +0 -2
- package/dist/controls/Text.js +0 -7
- package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +0 -1
- package/dist/controls/action-button-bar/ActionButtonBar.css.js +0 -5
- package/dist/controls/action-button-bar/ActionButtonBar.d.ts +0 -9
- package/dist/controls/action-button-bar/ActionButtonBar.js +0 -100
- package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +0 -10
- package/dist/controls/action-button-bar/useActionButtonBarCtx.js +0 -9
- package/dist/controls/action-buttons/ActionButton.css.d.ts +0 -1
- package/dist/controls/action-buttons/ActionButton.css.js +0 -5
- package/dist/controls/action-buttons/ActionButton.d.ts +0 -9
- package/dist/controls/action-buttons/ActionButton.js +0 -66
- package/dist/controls/action-buttons/ActionButtons.d.ts +0 -12
- package/dist/controls/action-buttons/ActionButtons.js +0 -99
- package/dist/hooks/useDiagramState.d.ts +0 -6
- package/dist/hooks/useDiagramState.js +0 -27
- package/dist/overlays/OverlayContext.d.ts +0 -10
- package/dist/overlays/OverlayContext.js +0 -9
- package/dist/overlays/Overlays.css.d.ts +0 -3
- package/dist/overlays/Overlays.css.js +0 -7
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +0 -5
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +0 -185
- package/dist/overlays/edge-details/SelectEdge.css.js +0 -17
- package/dist/overlays/edge-details/_types.d.ts +0 -14
- package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +0 -5
- package/dist/overlays/edge-details/xyflow/CompoundNode.js +0 -76
- package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +0 -5
- package/dist/overlays/edge-details/xyflow/ElementNode.js +0 -159
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +0 -3
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +0 -84
- package/dist/overlays/edge-details/xyflow/styles.css.d.ts +0 -9
- package/dist/overlays/edge-details/xyflow/styles.css.js +0 -21
- package/dist/overlays/index.d.ts +0 -1
- package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +0 -5
- package/dist/overlays/relationships-of/RelationshipsOverlay.js +0 -193
- package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +0 -19
- package/dist/overlays/relationships-of/RelationshipsXYFlow.js +0 -290
- package/dist/overlays/relationships-of/SelectElement.css.js +0 -7
- package/dist/overlays/relationships-of/SelectElement.d.ts +0 -7
- package/dist/overlays/relationships-of/_types.d.ts +0 -28
- package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +0 -22
- package/dist/overlays/relationships-of/use-layouted-relationships.js +0 -496
- package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +0 -6
- package/dist/overlays/relationships-of/xyflow/CompoundNode.js +0 -120
- package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +0 -6
- package/dist/overlays/relationships-of/xyflow/ElementNode.js +0 -194
- package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +0 -5
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +0 -3
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +0 -123
- package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +0 -14
- package/dist/overlays/relationships-of/xyflow/styles.css.js +0 -24
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +0 -4
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +0 -12
- package/dist/overlays/shared/xyflow/_types.d.ts +0 -77
- package/dist/state/DiagramContext.d.ts +0 -1609
- package/dist/state/DiagramContext.js +0 -101
- package/dist/state/diagram-to-xyflow.d.ts +0 -11
- package/dist/state/diagram-to-xyflow.js +0 -113
- package/dist/state/diagramStore.d.ts +0 -1705
- package/dist/state/diagramStore.js +0 -808
- package/dist/state/diagramStore.layout.d.ts +0 -4
- package/dist/state/diagramStore.layout.js +0 -56
- package/dist/ui/DiagramTitlePanel.css.js +0 -11
- package/dist/ui/DiagramTitlePanel.d.ts +0 -1
- package/dist/ui/notation/NotationPanel.css.js +0 -16
- package/dist/ui/notation/NotationPanel.d.ts +0 -1
- package/dist/ui/top-left/TopLeftPanel.d.ts +0 -4
- package/dist/ui/top-left/TopLeftPanel.js +0 -211
- package/dist/ui/top-left/styles.css.js +0 -17
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +0 -4
- package/dist/xyflow/FitviewOnDiagramChange.js +0 -72
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +0 -1
- package/dist/xyflow/SelectEdgesOnNodeFocus.js +0 -96
- package/dist/xyflow/XYFlow.d.ts +0 -8
- package/dist/xyflow/XYFlow.js +0 -145
- package/dist/xyflow/XYFlowBackground.d.ts +0 -10
- package/dist/xyflow/XYFlowInner.d.ts +0 -8
- package/dist/xyflow/XYFlowInner.js +0 -41
- package/dist/xyflow/edges/EdgeLabel.d.ts +0 -7
- package/dist/xyflow/edges/EdgeLabel.js +0 -160
- package/dist/xyflow/edges/RelationshipEdge.d.ts +0 -6
- package/dist/xyflow/edges/RelationshipEdge.js +0 -443
- package/dist/xyflow/edges/edges.css.js +0 -37
- package/dist/xyflow/edges/utils.d.ts +0 -16
- package/dist/xyflow/edges/utils.js +0 -24
- package/dist/xyflow/nodes/AnimateVariants.d.ts +0 -1313
- package/dist/xyflow/nodes/AnimateVariants.js +0 -123
- package/dist/xyflow/nodes/Node.css.d.ts +0 -3
- package/dist/xyflow/nodes/Node.css.js +0 -9
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +0 -14
- package/dist/xyflow/nodes/compound/CompoundNode.css.js +0 -27
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +0 -6
- package/dist/xyflow/nodes/compound/CompoundNode.js +0 -216
- package/dist/xyflow/nodes/compound/index.d.ts +0 -1
- package/dist/xyflow/nodes/element/ElementLink.css.d.ts +0 -3
- package/dist/xyflow/nodes/element/ElementLink.d.ts +0 -6
- package/dist/xyflow/nodes/element/ElementNode.d.ts +0 -6
- package/dist/xyflow/nodes/element/ElementNode.js +0 -190
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +0 -17
- package/dist/xyflow/nodes/element/element.css.d.ts +0 -18
- package/dist/xyflow/nodes/element/element.css.js +0 -31
- package/dist/xyflow/nodes/element/index.d.ts +0 -1
- package/dist/xyflow/nodes/shared/ElementIcon.d.ts +0 -8
- package/dist/xyflow/nodes/shared/Toolbar.d.ts +0 -9
- package/dist/xyflow/nodes/shared/Toolbar.js +0 -436
- package/dist/xyflow/types.d.ts +0 -36
- package/dist/xyflow/useXYFlowEvents.d.ts +0 -160
- package/dist/xyflow/useXYFlowEvents.js +0 -275
- package/src/controls/Text.ts +0 -5
- package/src/controls/action-button-bar/ActionButtonBar.css.ts +0 -13
- package/src/controls/action-button-bar/ActionButtonBar.tsx +0 -138
- package/src/controls/action-button-bar/useActionButtonBarCtx.ts +0 -13
- package/src/controls/action-buttons/ActionButton.css.ts +0 -29
- package/src/controls/action-buttons/ActionButton.tsx +0 -66
- package/src/controls/action-buttons/ActionButtons.tsx +0 -138
- package/src/hooks/useDiagramState.ts +0 -36
- package/src/overlays/OverlayContext.tsx +0 -11
- package/src/overlays/Overlays.css.ts +0 -136
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +0 -255
- package/src/overlays/edge-details/_types.ts +0 -18
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +0 -72
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +0 -152
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +0 -85
- package/src/overlays/edge-details/xyflow/styles.css.ts +0 -144
- package/src/overlays/index.tsx +0 -1
- package/src/overlays/relationships-of/RelationshipsOverlay.tsx +0 -185
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +0 -378
- package/src/overlays/relationships-of/_types.ts +0 -40
- package/src/overlays/relationships-of/use-layouted-relationships.ts +0 -699
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +0 -124
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +0 -194
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +0 -19
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +0 -127
- package/src/overlays/relationships-of/xyflow/styles.css.ts +0 -214
- package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +0 -60
- package/src/overlays/shared/xyflow/_types.ts +0 -87
- package/src/state/DiagramContext.tsx +0 -107
- package/src/state/diagram-to-xyflow.ts +0 -150
- package/src/state/diagramStore.layout.ts +0 -66
- package/src/state/diagramStore.ts +0 -1099
- package/src/ui/top-left/TopLeftPanel.tsx +0 -220
- package/src/xyflow/FitviewOnDiagramChange.tsx +0 -83
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +0 -106
- package/src/xyflow/XYFlow.tsx +0 -179
- package/src/xyflow/XYFlowInner.tsx +0 -48
- package/src/xyflow/edges/EdgeLabel.tsx +0 -193
- package/src/xyflow/edges/RelationshipEdge.tsx +0 -547
- package/src/xyflow/edges/edges.css.ts +0 -288
- package/src/xyflow/edges/utils.ts +0 -153
- package/src/xyflow/nodes/AnimateVariants.ts +0 -143
- package/src/xyflow/nodes/Node.css.ts +0 -44
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +0 -258
- package/src/xyflow/nodes/compound/CompoundNode.tsx +0 -226
- package/src/xyflow/nodes/compound/index.ts +0 -1
- package/src/xyflow/nodes/element/ElementLink.css.ts +0 -67
- package/src/xyflow/nodes/element/ElementLink.tsx +0 -97
- package/src/xyflow/nodes/element/ElementNode.tsx +0 -208
- package/src/xyflow/nodes/element/element.css.ts +0 -369
- package/src/xyflow/nodes/element/index.ts +0 -1
- package/src/xyflow/nodes/shared/ElementIcon.tsx +0 -43
- package/src/xyflow/nodes/shared/Toolbar.tsx +0 -496
- package/src/xyflow/types.ts +0 -57
- package/src/xyflow/useXYFlowEvents.ts +0 -315
- /package/dist/{xyflow → base}/const.d.ts +0 -0
- /package/dist/{xyflow → base}/const.js +0 -0
- /package/dist/{ui → context}/EnsureMantine.d.ts +0 -0
- /package/dist/{ui → context}/EnsureMantine.js +0 -0
- /package/dist/{ui → context}/FramerMotionConfig.d.ts +0 -0
- /package/dist/{xyflow → likec4diagram/custom}/edges/RelationshipsDropdownMenu.css.d.ts +0 -0
- /package/dist/{ui/top-left → likec4diagram/ui/controls}/ChangeAutoLayoutButton.d.ts +0 -0
- /package/dist/{ui/top-left → likec4diagram/ui/controls}/ManualLayoutToolsButton.d.ts +0 -0
- /package/dist/{ui/top-left → likec4diagram/ui/controls}/_shared.d.ts +0 -0
- /package/dist/{ui → likec4diagram/ui/diagram-title}/DiagramTitlePanel.css.d.ts +0 -0
- /package/dist/{ui → likec4diagram/ui/diagram-title}/Link.js +0 -0
- /package/dist/{ui → likec4diagram/ui}/notation/NotationPanel.css.d.ts +0 -0
- /package/dist/{ui → likec4diagram/ui}/notation/index.d.ts +0 -0
- /package/dist/{ui → likec4diagram/ui/walkthrough}/DynamicViewWalkthrough.css.d.ts +0 -0
- /package/dist/{ui → likec4diagram/ui/walkthrough}/DynamicViewWalkthrough.d.ts +0 -0
- /package/src/{ui → context}/EnsureMantine.tsx +0 -0
- /package/src/{ui → likec4diagram/ui}/notation/index.ts +0 -0
|
@@ -1,1099 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComputedNode,
|
|
3
|
-
DiagramNode,
|
|
4
|
-
DiagramView,
|
|
5
|
-
EdgeId,
|
|
6
|
-
ElementNotation,
|
|
7
|
-
Fqn,
|
|
8
|
-
NodeId,
|
|
9
|
-
ViewChange,
|
|
10
|
-
ViewId,
|
|
11
|
-
XYPoint
|
|
12
|
-
} from '@likec4/core'
|
|
13
|
-
import {
|
|
14
|
-
getBBoxCenter,
|
|
15
|
-
getParallelStepsPrefix,
|
|
16
|
-
invariant,
|
|
17
|
-
isStepEdgeId,
|
|
18
|
-
nonexhaustive,
|
|
19
|
-
nonNullable,
|
|
20
|
-
type StepEdgeId
|
|
21
|
-
} from '@likec4/core'
|
|
22
|
-
import {
|
|
23
|
-
applyEdgeChanges,
|
|
24
|
-
applyNodeChanges,
|
|
25
|
-
getViewportForBounds,
|
|
26
|
-
type OnEdgesChange,
|
|
27
|
-
type OnNodesChange
|
|
28
|
-
} from '@xyflow/react'
|
|
29
|
-
import { boxToRect, getBoundsOfRects, getNodeDimensions } from '@xyflow/system'
|
|
30
|
-
import { DEV } from 'esm-env'
|
|
31
|
-
import { deepEqual as eq, shallowEqual } from 'fast-equals'
|
|
32
|
-
import type { MouseEvent as ReactMouseEvent } from 'react'
|
|
33
|
-
import { entries, first, hasAtLeast, isNullish, map, prop, reduce } from 'remeda'
|
|
34
|
-
import type { ConditionalKeys, Except, RequiredKeysOf, RequireExactlyOne, Simplify } from 'type-fest'
|
|
35
|
-
import { devtools, subscribeWithSelector } from 'zustand/middleware'
|
|
36
|
-
import { shallow } from 'zustand/shallow'
|
|
37
|
-
import { createWithEqualityFn } from 'zustand/traditional'
|
|
38
|
-
import type { XYStoreApi } from '../hooks/useXYFlow'
|
|
39
|
-
import type {
|
|
40
|
-
DiagramNodeWithNavigate,
|
|
41
|
-
ElementIconRenderer,
|
|
42
|
-
LikeC4DiagramEventHandlers,
|
|
43
|
-
WhereOperator
|
|
44
|
-
} from '../LikeC4Diagram.props'
|
|
45
|
-
import { type Vector, vector, VectorImpl } from '../utils/vector'
|
|
46
|
-
import { MinZoom } from '../xyflow/const'
|
|
47
|
-
import type { DiagramFlowTypes } from '../xyflow/types'
|
|
48
|
-
import { bezierControlPoints, isInside, isSamePoint, toDomPrecision } from '../xyflow/utils'
|
|
49
|
-
import { diagramViewToXYFlowData } from './diagram-to-xyflow'
|
|
50
|
-
import { align, type AlignmentMode } from './diagramStore.layout'
|
|
51
|
-
|
|
52
|
-
type RequiredOrNull<T> = {
|
|
53
|
-
[P in keyof T]-?: NonNullable<T[P]> | null
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type DiagramInitialState = {
|
|
57
|
-
view: DiagramView
|
|
58
|
-
readonly: boolean
|
|
59
|
-
// If LikeC4Model provided
|
|
60
|
-
hasLikeC4Model: boolean
|
|
61
|
-
controls: boolean
|
|
62
|
-
showNavigationButtons: boolean
|
|
63
|
-
showNotations: boolean
|
|
64
|
-
fitViewEnabled: boolean
|
|
65
|
-
fitViewPadding: number
|
|
66
|
-
zoomable: boolean
|
|
67
|
-
pannable: boolean
|
|
68
|
-
nodesDraggable: boolean
|
|
69
|
-
nodesSelectable: boolean
|
|
70
|
-
experimentalEdgeEditing: boolean
|
|
71
|
-
enableFocusMode: boolean
|
|
72
|
-
enableElementDetails: boolean
|
|
73
|
-
enableRelationshipBrowser: boolean
|
|
74
|
-
enableRelationshipDetails: boolean
|
|
75
|
-
enableSearch: boolean
|
|
76
|
-
renderIcon: ElementIconRenderer | null
|
|
77
|
-
whereFilter: WhereOperator<string, string> | null
|
|
78
|
-
// If Dynamic View
|
|
79
|
-
enableDynamicViewWalkthrough: boolean
|
|
80
|
-
|
|
81
|
-
xyflow: DiagramFlowTypes.XYFlowInstance
|
|
82
|
-
xystore: XYStoreApi
|
|
83
|
-
|
|
84
|
-
// Diagram Container, for Mantine Portal
|
|
85
|
-
getContainer: () => HTMLDivElement | null
|
|
86
|
-
} & RequiredOrNull<LikeC4DiagramEventHandlers>
|
|
87
|
-
|
|
88
|
-
type NodeKind = ComputedNode['kind']
|
|
89
|
-
|
|
90
|
-
const StringSet = Set<string>
|
|
91
|
-
|
|
92
|
-
export type DiagramState = Simplify<
|
|
93
|
-
DiagramInitialState & {
|
|
94
|
-
readonly storeDevId: string
|
|
95
|
-
|
|
96
|
-
// Internal state
|
|
97
|
-
xynodes: DiagramFlowTypes.Node[]
|
|
98
|
-
xyedges: DiagramFlowTypes.Edge[]
|
|
99
|
-
viewSyncDebounceTimeout: number | null
|
|
100
|
-
viewportChanged: boolean
|
|
101
|
-
|
|
102
|
-
initialized: boolean
|
|
103
|
-
|
|
104
|
-
activeOverlay:
|
|
105
|
-
| null
|
|
106
|
-
| RequireExactlyOne<{
|
|
107
|
-
elementDetails: Fqn
|
|
108
|
-
relationshipsOf: Fqn
|
|
109
|
-
edgeDetails: EdgeId
|
|
110
|
-
}>
|
|
111
|
-
|
|
112
|
-
// readonly=false and onChange is not null
|
|
113
|
-
isEditable: () => boolean
|
|
114
|
-
|
|
115
|
-
// If Dynamic View
|
|
116
|
-
isDynamicView: boolean
|
|
117
|
-
activeWalkthrough: null | {
|
|
118
|
-
stepId: StepEdgeId
|
|
119
|
-
hasPrevious: boolean
|
|
120
|
-
hasNext: boolean
|
|
121
|
-
parallelPrefix: string | null
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// This is XYFlow id's
|
|
125
|
-
lastClickedNodeId: string | null
|
|
126
|
-
lastClickedEdgeId: string | null
|
|
127
|
-
focusedNodeId: string | null
|
|
128
|
-
hoveredEdgeId: string | null
|
|
129
|
-
|
|
130
|
-
// id's of nodes / edges that
|
|
131
|
-
dimmed: ReadonlySet<string>
|
|
132
|
-
|
|
133
|
-
lastOnNavigate: null | {
|
|
134
|
-
fromView: ViewId
|
|
135
|
-
toView: ViewId
|
|
136
|
-
fromNode: NodeId | null
|
|
137
|
-
}
|
|
138
|
-
navigationHistory: Array<{
|
|
139
|
-
viewId: ViewId
|
|
140
|
-
nodeId: NodeId | null
|
|
141
|
-
}>
|
|
142
|
-
navigationHistoryIndex: number
|
|
143
|
-
|
|
144
|
-
// Actions
|
|
145
|
-
updateView: (view: DiagramView) => void
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* A function to set the focus on a specific node given its identifier.
|
|
149
|
-
* It can also be used to remove focus if the input is `false`.
|
|
150
|
-
*/
|
|
151
|
-
focusOnNode: (nodeId: string | false) => void
|
|
152
|
-
|
|
153
|
-
setHoveredEdge: (edgeId: string | null) => void
|
|
154
|
-
|
|
155
|
-
setLastClickedNode: (nodeId: string | null) => void
|
|
156
|
-
setLastClickedEdge: (edgeId: string | null) => void
|
|
157
|
-
|
|
158
|
-
resetFocusAndLastClicked: () => void
|
|
159
|
-
|
|
160
|
-
getElement(id: Fqn): DiagramNode | null
|
|
161
|
-
triggerChangeElementStyle: (change: ViewChange.ChangeElementStyle) => void
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @returns true if there was pending save layout
|
|
165
|
-
*/
|
|
166
|
-
cancelSaveManualLayout: () => boolean
|
|
167
|
-
scheduleSaveManualLayout: () => void
|
|
168
|
-
triggerSaveManualLayout: () => void
|
|
169
|
-
|
|
170
|
-
triggerOnNavigateTo: (xynodeId: string, event: ReactMouseEvent) => void
|
|
171
|
-
fitDiagram: (duration?: number) => void
|
|
172
|
-
|
|
173
|
-
goBack: () => void
|
|
174
|
-
goForward: () => void
|
|
175
|
-
|
|
176
|
-
nextDynamicStep: (increment?: number) => void
|
|
177
|
-
activateWalkthrough: (step: EdgeId | DiagramFlowTypes.Edge) => void
|
|
178
|
-
stopWalkthrough: () => void
|
|
179
|
-
|
|
180
|
-
openOverlay: (overlay: NonNullable<DiagramState['activeOverlay']>) => void
|
|
181
|
-
closeOverlay: () => void
|
|
182
|
-
|
|
183
|
-
onInit: (xyflow: DiagramFlowTypes.XYFlowInstance) => void
|
|
184
|
-
onNodesChange: OnNodesChange<DiagramFlowTypes.Node>
|
|
185
|
-
onEdgesChange: OnEdgesChange<DiagramFlowTypes.Edge>
|
|
186
|
-
|
|
187
|
-
highlightByElementNotation: (notation: ElementNotation, onlyOfKind?: NodeKind) => void
|
|
188
|
-
|
|
189
|
-
resetEdgeControlPoints: () => void
|
|
190
|
-
align: (mode: AlignmentMode) => void
|
|
191
|
-
|
|
192
|
-
onOpenSourceView: () => void
|
|
193
|
-
}
|
|
194
|
-
>
|
|
195
|
-
|
|
196
|
-
const DEFAULT_PROPS: Except<
|
|
197
|
-
DiagramState,
|
|
198
|
-
'storeDevId' | 'navigationHistory' | RequiredKeysOf<DiagramInitialState> | ConditionalKeys<DiagramState, Function>
|
|
199
|
-
> = {
|
|
200
|
-
xyedges: [],
|
|
201
|
-
xynodes: [],
|
|
202
|
-
isDynamicView: false,
|
|
203
|
-
viewSyncDebounceTimeout: null,
|
|
204
|
-
initialized: false,
|
|
205
|
-
navigationHistoryIndex: 0,
|
|
206
|
-
viewportChanged: false,
|
|
207
|
-
activeOverlay: null,
|
|
208
|
-
activeWalkthrough: null,
|
|
209
|
-
focusedNodeId: null,
|
|
210
|
-
hoveredEdgeId: null,
|
|
211
|
-
lastClickedNodeId: null,
|
|
212
|
-
lastClickedEdgeId: null,
|
|
213
|
-
dimmed: new StringSet(),
|
|
214
|
-
lastOnNavigate: null
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const noReplace = false
|
|
218
|
-
|
|
219
|
-
let StoreDevId = 1
|
|
220
|
-
|
|
221
|
-
const EmptyStringSet: ReadonlySet<string> = new StringSet()
|
|
222
|
-
|
|
223
|
-
export function createDiagramStore(props: DiagramInitialState) {
|
|
224
|
-
const storeDevId = 'DiagramStore' + String(StoreDevId++).padStart(2, '0')
|
|
225
|
-
const {
|
|
226
|
-
xynodes,
|
|
227
|
-
xyedges
|
|
228
|
-
} = diagramViewToXYFlowData(props.view, {
|
|
229
|
-
where: props.whereFilter,
|
|
230
|
-
draggable: props.nodesDraggable,
|
|
231
|
-
selectable: props.nodesSelectable
|
|
232
|
-
})
|
|
233
|
-
return createWithEqualityFn<
|
|
234
|
-
DiagramState,
|
|
235
|
-
[
|
|
236
|
-
['zustand/subscribeWithSelector', never],
|
|
237
|
-
['zustand/devtools', never]
|
|
238
|
-
]
|
|
239
|
-
>(
|
|
240
|
-
subscribeWithSelector(
|
|
241
|
-
devtools(
|
|
242
|
-
(set, get) => ({
|
|
243
|
-
...DEFAULT_PROPS,
|
|
244
|
-
...(props as DiagramInitialState),
|
|
245
|
-
storeDevId,
|
|
246
|
-
isDynamicView: props.view.__ === 'dynamic',
|
|
247
|
-
xynodes,
|
|
248
|
-
xyedges,
|
|
249
|
-
navigationHistory: [{
|
|
250
|
-
viewId: props.view.id,
|
|
251
|
-
nodeId: null as Fqn | null
|
|
252
|
-
}],
|
|
253
|
-
navigationHistoryIndex: 0,
|
|
254
|
-
|
|
255
|
-
onNodesChange: (changes) => {
|
|
256
|
-
set({
|
|
257
|
-
xynodes: applyNodeChanges(changes, get().xynodes)
|
|
258
|
-
})
|
|
259
|
-
},
|
|
260
|
-
onEdgesChange: (changes) => {
|
|
261
|
-
set({
|
|
262
|
-
xyedges: applyEdgeChanges(changes, get().xyedges)
|
|
263
|
-
})
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
updateView: (nextView) => {
|
|
267
|
-
let {
|
|
268
|
-
viewSyncDebounceTimeout,
|
|
269
|
-
xyflow,
|
|
270
|
-
xystore,
|
|
271
|
-
dimmed,
|
|
272
|
-
whereFilter,
|
|
273
|
-
view: current,
|
|
274
|
-
lastOnNavigate,
|
|
275
|
-
navigationHistory,
|
|
276
|
-
navigationHistoryIndex,
|
|
277
|
-
focusedNodeId,
|
|
278
|
-
lastClickedNodeId,
|
|
279
|
-
lastClickedEdgeId,
|
|
280
|
-
activeWalkthrough,
|
|
281
|
-
activeOverlay,
|
|
282
|
-
nodesDraggable,
|
|
283
|
-
nodesSelectable,
|
|
284
|
-
hoveredEdgeId,
|
|
285
|
-
xyedges,
|
|
286
|
-
xynodes
|
|
287
|
-
} = get()
|
|
288
|
-
|
|
289
|
-
if (viewSyncDebounceTimeout !== null) {
|
|
290
|
-
clearTimeout(viewSyncDebounceTimeout)
|
|
291
|
-
viewSyncDebounceTimeout = null
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const isSameView = current.id === nextView.id
|
|
295
|
-
|
|
296
|
-
if (isSameView) {
|
|
297
|
-
const nodeIds = new StringSet(nextView.nodes.map((n) => n.id))
|
|
298
|
-
const edgeIds = new StringSet(nextView.edges.map((e) => e.id))
|
|
299
|
-
// Reset clicked/hovered node/edge if the node/edge is not in the new view
|
|
300
|
-
if (lastClickedNodeId && !nodeIds.has(lastClickedNodeId)) {
|
|
301
|
-
lastClickedNodeId = null
|
|
302
|
-
}
|
|
303
|
-
if (focusedNodeId && !nodeIds.has(focusedNodeId)) {
|
|
304
|
-
focusedNodeId = null
|
|
305
|
-
dimmed = EmptyStringSet
|
|
306
|
-
}
|
|
307
|
-
if (lastClickedEdgeId && !edgeIds.has(lastClickedEdgeId)) {
|
|
308
|
-
lastClickedEdgeId = null
|
|
309
|
-
}
|
|
310
|
-
if (hoveredEdgeId && !edgeIds.has(hoveredEdgeId)) {
|
|
311
|
-
hoveredEdgeId = null
|
|
312
|
-
}
|
|
313
|
-
if (activeWalkthrough && !edgeIds.has(activeWalkthrough.stepId)) {
|
|
314
|
-
activeWalkthrough = null
|
|
315
|
-
dimmed = EmptyStringSet
|
|
316
|
-
}
|
|
317
|
-
if (dimmed.size > 0) {
|
|
318
|
-
let nextDimmed = new StringSet([...dimmed].filter(id => nodeIds.has(id) || edgeIds.has(id)))
|
|
319
|
-
if (nextDimmed.size !== dimmed.size) {
|
|
320
|
-
dimmed = nextDimmed
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
} else {
|
|
324
|
-
// Reset lastOnNavigate if the view is not the source or target view
|
|
325
|
-
const stepCurrent = nonNullable(navigationHistory[navigationHistoryIndex])
|
|
326
|
-
if (stepCurrent.viewId !== nextView.id) {
|
|
327
|
-
navigationHistory = [
|
|
328
|
-
...navigationHistory.slice(0, navigationHistoryIndex + 1),
|
|
329
|
-
{
|
|
330
|
-
viewId: nextView.id,
|
|
331
|
-
nodeId: lastOnNavigate?.fromNode || null
|
|
332
|
-
}
|
|
333
|
-
]
|
|
334
|
-
navigationHistoryIndex = navigationHistory.length - 1
|
|
335
|
-
} else {
|
|
336
|
-
// We are navigating to the same view as in the history
|
|
337
|
-
if (stepCurrent.nodeId) {
|
|
338
|
-
lastOnNavigate ??= {
|
|
339
|
-
fromView: current.id,
|
|
340
|
-
toView: nextView.id,
|
|
341
|
-
fromNode: stepCurrent.nodeId
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (lastOnNavigate && lastOnNavigate.toView !== nextView.id) {
|
|
347
|
-
lastOnNavigate = null
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const elTo = lastOnNavigate && nextView.nodes.find(n => n.id === lastOnNavigate?.fromNode)
|
|
351
|
-
const xynodeFrom = elTo && xyflow.getInternalNode(elTo.id)
|
|
352
|
-
|
|
353
|
-
if (!lastOnNavigate || isNullish(elTo) || isNullish(xynodeFrom)) {
|
|
354
|
-
const zoom = xyflow.getZoom()
|
|
355
|
-
const { x, y } = getBBoxCenter(nextView.bounds)
|
|
356
|
-
xyflow.setCenter(x, y, { zoom })
|
|
357
|
-
lastOnNavigate = null
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
if (lastOnNavigate && !!elTo && !!xynodeFrom) {
|
|
361
|
-
const fromPos = xyflow.flowToScreenPosition({
|
|
362
|
-
x: xynodeFrom.internals.positionAbsolute.x, // + dimensions.width / 2,
|
|
363
|
-
y: xynodeFrom.internals.positionAbsolute.y // + dimensions.height / 2
|
|
364
|
-
}),
|
|
365
|
-
toPos = xyflow.flowToScreenPosition({
|
|
366
|
-
x: elTo.position[0], // + elFrom.width / 2,
|
|
367
|
-
y: elTo.position[1] // + elFrom.height / 2
|
|
368
|
-
}),
|
|
369
|
-
diff = {
|
|
370
|
-
x: toDomPrecision(fromPos.x - toPos.x),
|
|
371
|
-
y: toDomPrecision(fromPos.y - toPos.y)
|
|
372
|
-
}
|
|
373
|
-
xystore.getState().panBy(diff)
|
|
374
|
-
lastOnNavigate = null
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Reset hovered / clicked node/edge if the view is different
|
|
378
|
-
lastClickedEdgeId = null
|
|
379
|
-
lastClickedNodeId = null
|
|
380
|
-
hoveredEdgeId = null
|
|
381
|
-
focusedNodeId = null
|
|
382
|
-
activeWalkthrough = null
|
|
383
|
-
activeOverlay = null
|
|
384
|
-
dimmed = EmptyStringSet
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const update = diagramViewToXYFlowData(nextView, {
|
|
388
|
-
where: whereFilter,
|
|
389
|
-
draggable: nodesDraggable,
|
|
390
|
-
selectable: nodesSelectable
|
|
391
|
-
})
|
|
392
|
-
|
|
393
|
-
update.xynodes = update.xynodes.map((update) => {
|
|
394
|
-
const existing = xynodes.find(n => n.id === update.id)
|
|
395
|
-
if (
|
|
396
|
-
existing
|
|
397
|
-
&& existing.type === update.type
|
|
398
|
-
&& eq(existing.parentId ?? null, update.parentId ?? null)
|
|
399
|
-
) {
|
|
400
|
-
if (
|
|
401
|
-
existing.width === update.width
|
|
402
|
-
&& existing.height === update.height
|
|
403
|
-
&& eq(existing.hidden ?? false, update.hidden ?? false)
|
|
404
|
-
&& eq(existing.position, update.position)
|
|
405
|
-
&& eq(existing.data, update.data)
|
|
406
|
-
) {
|
|
407
|
-
return existing
|
|
408
|
-
}
|
|
409
|
-
return {
|
|
410
|
-
...existing,
|
|
411
|
-
...update
|
|
412
|
-
} as DiagramFlowTypes.Node
|
|
413
|
-
}
|
|
414
|
-
return update
|
|
415
|
-
})
|
|
416
|
-
// Merge with existing edges, but only if the view is the same
|
|
417
|
-
// and the edges have no layout drift
|
|
418
|
-
if (isSameView && !nextView.hasLayoutDrift) {
|
|
419
|
-
update.xyedges = update.xyedges.map((update): DiagramFlowTypes.Edge => {
|
|
420
|
-
const existing = xyedges.find(n => n.id === update.id)
|
|
421
|
-
if (existing) {
|
|
422
|
-
if (
|
|
423
|
-
eq(existing.hidden ?? false, update.hidden ?? false)
|
|
424
|
-
&& eq(existing.data.label, update.data.label)
|
|
425
|
-
&& eq(existing.data.controlPoints, update.data.controlPoints)
|
|
426
|
-
&& eq(existing.data.edge, update.data.edge)
|
|
427
|
-
) {
|
|
428
|
-
return existing
|
|
429
|
-
}
|
|
430
|
-
return {
|
|
431
|
-
...existing,
|
|
432
|
-
...update,
|
|
433
|
-
data: {
|
|
434
|
-
...existing.data,
|
|
435
|
-
...update.data
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
return update
|
|
440
|
-
})
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
set(
|
|
444
|
-
{
|
|
445
|
-
isDynamicView: nextView.__ === 'dynamic',
|
|
446
|
-
viewSyncDebounceTimeout,
|
|
447
|
-
view: nextView,
|
|
448
|
-
activeWalkthrough,
|
|
449
|
-
activeOverlay,
|
|
450
|
-
lastOnNavigate,
|
|
451
|
-
lastClickedNodeId,
|
|
452
|
-
lastClickedEdgeId,
|
|
453
|
-
focusedNodeId,
|
|
454
|
-
hoveredEdgeId,
|
|
455
|
-
navigationHistory,
|
|
456
|
-
navigationHistoryIndex,
|
|
457
|
-
dimmed,
|
|
458
|
-
xynodes: !isSameView || !shallowEqual(update.xynodes, xynodes) ? update.xynodes : xynodes,
|
|
459
|
-
xyedges: !isSameView || !shallowEqual(update.xyedges, xyedges) ? update.xyedges : xyedges
|
|
460
|
-
},
|
|
461
|
-
noReplace,
|
|
462
|
-
isSameView ? 'update-view [same]' : 'update-view [another]'
|
|
463
|
-
)
|
|
464
|
-
},
|
|
465
|
-
|
|
466
|
-
focusOnNode: (nodeId) => {
|
|
467
|
-
const { focusedNodeId, view, enableFocusMode } = get()
|
|
468
|
-
invariant(enableFocusMode, 'focus mode is not enabled')
|
|
469
|
-
if (nodeId === false) {
|
|
470
|
-
set(
|
|
471
|
-
{
|
|
472
|
-
activeWalkthrough: null,
|
|
473
|
-
activeOverlay: null,
|
|
474
|
-
focusedNodeId: null,
|
|
475
|
-
dimmed: EmptyStringSet
|
|
476
|
-
},
|
|
477
|
-
noReplace,
|
|
478
|
-
`unfocus`
|
|
479
|
-
)
|
|
480
|
-
return
|
|
481
|
-
}
|
|
482
|
-
if (nodeId !== focusedNodeId) {
|
|
483
|
-
const notDimmed = new StringSet([nodeId])
|
|
484
|
-
const dimmed = new StringSet()
|
|
485
|
-
for (const edge of view.edges) {
|
|
486
|
-
if (edge.source === nodeId || edge.target === nodeId) {
|
|
487
|
-
notDimmed.add(edge.source)
|
|
488
|
-
notDimmed.add(edge.target)
|
|
489
|
-
} else {
|
|
490
|
-
dimmed.add(edge.id)
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
for (const node of view.nodes) {
|
|
494
|
-
if (notDimmed.has(node.id)) {
|
|
495
|
-
continue
|
|
496
|
-
}
|
|
497
|
-
dimmed.add(node.id)
|
|
498
|
-
}
|
|
499
|
-
set(
|
|
500
|
-
{
|
|
501
|
-
activeWalkthrough: null,
|
|
502
|
-
activeOverlay: null,
|
|
503
|
-
focusedNodeId: nodeId,
|
|
504
|
-
dimmed
|
|
505
|
-
},
|
|
506
|
-
noReplace,
|
|
507
|
-
`focus on node: ${nodeId}`
|
|
508
|
-
)
|
|
509
|
-
}
|
|
510
|
-
},
|
|
511
|
-
|
|
512
|
-
setHoveredEdge: (edgeId) => {
|
|
513
|
-
if (edgeId !== get().hoveredEdgeId) {
|
|
514
|
-
set({ hoveredEdgeId: edgeId })
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
|
|
518
|
-
setLastClickedNode: (nodeId) => {
|
|
519
|
-
if (nodeId !== get().lastClickedNodeId) {
|
|
520
|
-
set({ lastClickedNodeId: nodeId })
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
|
|
524
|
-
setLastClickedEdge: (edgeId) => {
|
|
525
|
-
if (edgeId !== get().lastClickedEdgeId) {
|
|
526
|
-
set({ lastClickedEdgeId: edgeId })
|
|
527
|
-
}
|
|
528
|
-
},
|
|
529
|
-
|
|
530
|
-
resetFocusAndLastClicked: () => {
|
|
531
|
-
set(
|
|
532
|
-
{
|
|
533
|
-
activeWalkthrough: null,
|
|
534
|
-
activeOverlay: null,
|
|
535
|
-
focusedNodeId: null,
|
|
536
|
-
lastClickedNodeId: null,
|
|
537
|
-
lastClickedEdgeId: null,
|
|
538
|
-
dimmed: EmptyStringSet
|
|
539
|
-
},
|
|
540
|
-
noReplace,
|
|
541
|
-
'resetLastClicked'
|
|
542
|
-
)
|
|
543
|
-
get().xystore.getState().resetSelectedElements()
|
|
544
|
-
},
|
|
545
|
-
|
|
546
|
-
getElement: (fqn) => {
|
|
547
|
-
const { view } = get()
|
|
548
|
-
return view.nodes.find(({ id }) => id === fqn) ?? null
|
|
549
|
-
},
|
|
550
|
-
|
|
551
|
-
isEditable: () => {
|
|
552
|
-
const { readonly, onChange } = get()
|
|
553
|
-
return !readonly && !!onChange
|
|
554
|
-
},
|
|
555
|
-
|
|
556
|
-
triggerChangeElementStyle: (change) => {
|
|
557
|
-
if (DEV) {
|
|
558
|
-
console.debug('triggerChangeElementStyle', change)
|
|
559
|
-
}
|
|
560
|
-
const { view, updateView, onChange } = get()
|
|
561
|
-
|
|
562
|
-
// Style changes we already apply to the view
|
|
563
|
-
let hasChanges = false
|
|
564
|
-
const nodes = view.nodes.map(origin => {
|
|
565
|
-
if (!change.targets.includes(origin.id)) {
|
|
566
|
-
return origin
|
|
567
|
-
}
|
|
568
|
-
let element = origin
|
|
569
|
-
for (const [key, value] of entries(change.style)) {
|
|
570
|
-
switch (key) {
|
|
571
|
-
case 'shape':
|
|
572
|
-
if (value !== element.shape) {
|
|
573
|
-
element = {
|
|
574
|
-
...element,
|
|
575
|
-
shape: value
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
break
|
|
579
|
-
case 'color':
|
|
580
|
-
if (value !== element.color) {
|
|
581
|
-
element = {
|
|
582
|
-
...element,
|
|
583
|
-
color: value
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
break
|
|
587
|
-
case 'opacity':
|
|
588
|
-
if (value !== element.style?.opacity) {
|
|
589
|
-
element = {
|
|
590
|
-
...element,
|
|
591
|
-
style: {
|
|
592
|
-
...element.style,
|
|
593
|
-
opacity: value
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
break
|
|
598
|
-
case 'border':
|
|
599
|
-
if (value !== element.style?.border) {
|
|
600
|
-
element = {
|
|
601
|
-
...element,
|
|
602
|
-
style: {
|
|
603
|
-
...element.style,
|
|
604
|
-
border: value
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
break
|
|
609
|
-
default:
|
|
610
|
-
nonexhaustive(key)
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
if (element !== origin) {
|
|
614
|
-
hasChanges = true
|
|
615
|
-
return element
|
|
616
|
-
}
|
|
617
|
-
return origin
|
|
618
|
-
})
|
|
619
|
-
if (hasChanges) {
|
|
620
|
-
updateView({
|
|
621
|
-
...view,
|
|
622
|
-
nodes
|
|
623
|
-
})
|
|
624
|
-
}
|
|
625
|
-
// Trigger change event, even if there are no changes with local state
|
|
626
|
-
// but we maybe out of sync with the server
|
|
627
|
-
onChange?.({ change })
|
|
628
|
-
},
|
|
629
|
-
|
|
630
|
-
cancelSaveManualLayout: () => {
|
|
631
|
-
let { viewSyncDebounceTimeout } = get()
|
|
632
|
-
if (viewSyncDebounceTimeout !== null) {
|
|
633
|
-
clearTimeout(viewSyncDebounceTimeout)
|
|
634
|
-
set({ viewSyncDebounceTimeout: null })
|
|
635
|
-
return true
|
|
636
|
-
}
|
|
637
|
-
return false
|
|
638
|
-
},
|
|
639
|
-
|
|
640
|
-
triggerSaveManualLayout: () => {
|
|
641
|
-
const { xyflow, view, onChange, xystore, viewSyncDebounceTimeout } = get()
|
|
642
|
-
if (viewSyncDebounceTimeout !== null) {
|
|
643
|
-
clearTimeout(viewSyncDebounceTimeout)
|
|
644
|
-
set({ viewSyncDebounceTimeout: null })
|
|
645
|
-
}
|
|
646
|
-
const { nodeLookup } = xystore.getState()
|
|
647
|
-
const movedNodes = new StringSet()
|
|
648
|
-
let bounds = {
|
|
649
|
-
x: 0,
|
|
650
|
-
y: 0,
|
|
651
|
-
width: 1,
|
|
652
|
-
height: 1
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
const nodes = reduce([...nodeLookup.values()], (acc, node) => {
|
|
656
|
-
const dimensions = getNodeDimensions(node)
|
|
657
|
-
if (!isSamePoint(node.internals.positionAbsolute, node.data.element.position)) {
|
|
658
|
-
movedNodes.add(node.id)
|
|
659
|
-
}
|
|
660
|
-
const rect = acc[node.data.fqn] = {
|
|
661
|
-
isCompound: node.data.element.children.length > 0,
|
|
662
|
-
x: Math.floor(node.internals.positionAbsolute.x),
|
|
663
|
-
y: Math.floor(node.internals.positionAbsolute.y),
|
|
664
|
-
width: Math.ceil(dimensions.width),
|
|
665
|
-
height: Math.ceil(dimensions.height)
|
|
666
|
-
}
|
|
667
|
-
bounds = getBoundsOfRects(bounds, rect)
|
|
668
|
-
return acc
|
|
669
|
-
}, {} as ViewChange.SaveManualLayout['layout']['nodes'])
|
|
670
|
-
|
|
671
|
-
const edges = reduce(xyflow.getEdges(), (acc, { source, target, data }) => {
|
|
672
|
-
let controlPoints = data.controlPoints ?? []
|
|
673
|
-
const sourceOrTargetMoved = movedNodes.has(source) || movedNodes.has(target)
|
|
674
|
-
// If edge control points are not set, but the source or target node was moved
|
|
675
|
-
if (controlPoints.length === 0 && sourceOrTargetMoved) {
|
|
676
|
-
controlPoints = bezierControlPoints(data.edge)
|
|
677
|
-
}
|
|
678
|
-
if (data.edge.points.length === 0 && controlPoints.length === 0) {
|
|
679
|
-
return acc
|
|
680
|
-
}
|
|
681
|
-
const _updated: ViewChange.SaveManualLayout['layout']['edges'][string] = acc[data.edge.id] = {
|
|
682
|
-
points: data.edge.points
|
|
683
|
-
}
|
|
684
|
-
if (data.label?.bbox) {
|
|
685
|
-
_updated.labelBBox = data.label.bbox
|
|
686
|
-
}
|
|
687
|
-
if (data.edge.labelBBox) {
|
|
688
|
-
_updated.labelBBox ??= data.edge.labelBBox
|
|
689
|
-
}
|
|
690
|
-
if (hasAtLeast(controlPoints, 1)) {
|
|
691
|
-
_updated.controlPoints = controlPoints
|
|
692
|
-
}
|
|
693
|
-
if (!sourceOrTargetMoved && data.edge.dotpos) {
|
|
694
|
-
_updated.dotpos = data.edge.dotpos
|
|
695
|
-
}
|
|
696
|
-
const allX = [
|
|
697
|
-
...data.edge.points.map(p => p[0]),
|
|
698
|
-
...controlPoints.map(p => p.x),
|
|
699
|
-
...(_updated.labelBBox ? [_updated.labelBBox.x, _updated.labelBBox.x + _updated.labelBBox.width] : [])
|
|
700
|
-
]
|
|
701
|
-
const allY = [
|
|
702
|
-
...data.edge.points.map(p => p[1]),
|
|
703
|
-
...controlPoints.map(p => p.y),
|
|
704
|
-
...(_updated.labelBBox ? [_updated.labelBBox.y, _updated.labelBBox.y + _updated.labelBBox.height] : [])
|
|
705
|
-
]
|
|
706
|
-
const rect = boxToRect({
|
|
707
|
-
x: Math.floor(Math.min(...allX)),
|
|
708
|
-
y: Math.floor(Math.min(...allY)),
|
|
709
|
-
x2: Math.ceil(Math.max(...allX)),
|
|
710
|
-
y2: Math.ceil(Math.max(...allY))
|
|
711
|
-
})
|
|
712
|
-
bounds = getBoundsOfRects(bounds, rect)
|
|
713
|
-
return acc
|
|
714
|
-
}, {} as ViewChange.SaveManualLayout['layout']['edges'])
|
|
715
|
-
|
|
716
|
-
const change: ViewChange.SaveManualLayout = {
|
|
717
|
-
op: 'save-manual-layout',
|
|
718
|
-
layout: {
|
|
719
|
-
hash: view.hash,
|
|
720
|
-
autoLayout: view.autoLayout,
|
|
721
|
-
nodes,
|
|
722
|
-
edges,
|
|
723
|
-
...bounds
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
if (DEV) {
|
|
728
|
-
console.debug('triggerSaveManualLayout', change)
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
// If new view bounds are outside of the diagram bounds, update the view bounds
|
|
732
|
-
// and update edges, as
|
|
733
|
-
if (!isInside(bounds, view.bounds)) {
|
|
734
|
-
set(
|
|
735
|
-
{
|
|
736
|
-
view: {
|
|
737
|
-
...view,
|
|
738
|
-
bounds
|
|
739
|
-
}
|
|
740
|
-
},
|
|
741
|
-
noReplace,
|
|
742
|
-
'update view bounds'
|
|
743
|
-
)
|
|
744
|
-
}
|
|
745
|
-
onChange?.({ change })
|
|
746
|
-
},
|
|
747
|
-
scheduleSaveManualLayout: () => {
|
|
748
|
-
clearTimeout(get().viewSyncDebounceTimeout ?? undefined)
|
|
749
|
-
set(
|
|
750
|
-
{
|
|
751
|
-
viewSyncDebounceTimeout: setTimeout(() => {
|
|
752
|
-
get().triggerSaveManualLayout()
|
|
753
|
-
}, 1000) as any as number // explicit typecast to number to suppress TS error in astro build
|
|
754
|
-
},
|
|
755
|
-
noReplace,
|
|
756
|
-
'debounce sync state'
|
|
757
|
-
)
|
|
758
|
-
},
|
|
759
|
-
|
|
760
|
-
triggerOnNavigateTo: (xynodeId, event) => {
|
|
761
|
-
const { view, xynodes, onNavigateTo, cancelSaveManualLayout } = get()
|
|
762
|
-
if (!onNavigateTo) {
|
|
763
|
-
return
|
|
764
|
-
}
|
|
765
|
-
const xynode = xynodes.find(({ id }) => id === xynodeId)
|
|
766
|
-
invariant(xynode, `xynode not found: ${xynodeId}`)
|
|
767
|
-
const element = xynode.data.element
|
|
768
|
-
invariant(element?.navigateTo, `node is not navigable: ${xynodeId}`)
|
|
769
|
-
cancelSaveManualLayout()
|
|
770
|
-
set(
|
|
771
|
-
{
|
|
772
|
-
lastClickedNodeId: xynodeId,
|
|
773
|
-
lastOnNavigate: {
|
|
774
|
-
fromView: view.id,
|
|
775
|
-
toView: element.navigateTo,
|
|
776
|
-
fromNode: element.id
|
|
777
|
-
}
|
|
778
|
-
},
|
|
779
|
-
noReplace,
|
|
780
|
-
'triggerOnNavigateTo'
|
|
781
|
-
)
|
|
782
|
-
onNavigateTo(
|
|
783
|
-
element.navigateTo,
|
|
784
|
-
event,
|
|
785
|
-
element as DiagramNodeWithNavigate
|
|
786
|
-
)
|
|
787
|
-
},
|
|
788
|
-
|
|
789
|
-
goBack: () => {
|
|
790
|
-
const { navigationHistory, navigationHistoryIndex, onNavigateTo } = get()
|
|
791
|
-
const { viewId, nodeId } = nonNullable(navigationHistory[navigationHistoryIndex])
|
|
792
|
-
const stepBack = (navigationHistoryIndex > 0 && navigationHistory[navigationHistoryIndex - 1]) || null
|
|
793
|
-
if (stepBack && onNavigateTo) {
|
|
794
|
-
set(
|
|
795
|
-
{
|
|
796
|
-
lastClickedEdgeId: null,
|
|
797
|
-
lastClickedNodeId: null,
|
|
798
|
-
navigationHistoryIndex: navigationHistoryIndex - 1,
|
|
799
|
-
lastOnNavigate: nodeId
|
|
800
|
-
? {
|
|
801
|
-
fromView: viewId,
|
|
802
|
-
toView: stepBack.viewId,
|
|
803
|
-
fromNode: nodeId as Fqn
|
|
804
|
-
}
|
|
805
|
-
: null
|
|
806
|
-
},
|
|
807
|
-
noReplace,
|
|
808
|
-
'goBack'
|
|
809
|
-
)
|
|
810
|
-
onNavigateTo(stepBack.viewId)
|
|
811
|
-
}
|
|
812
|
-
},
|
|
813
|
-
goForward: () => {
|
|
814
|
-
const { navigationHistory, navigationHistoryIndex, onNavigateTo } = get()
|
|
815
|
-
const { viewId } = nonNullable(navigationHistory[navigationHistoryIndex])
|
|
816
|
-
const stepForward = navigationHistoryIndex < navigationHistory.length - 1
|
|
817
|
-
? navigationHistory[navigationHistoryIndex + 1]
|
|
818
|
-
: null
|
|
819
|
-
if (stepForward && onNavigateTo) {
|
|
820
|
-
set(
|
|
821
|
-
{
|
|
822
|
-
lastClickedEdgeId: null,
|
|
823
|
-
lastClickedNodeId: null,
|
|
824
|
-
navigationHistoryIndex: navigationHistoryIndex + 1,
|
|
825
|
-
lastOnNavigate: stepForward.nodeId
|
|
826
|
-
? {
|
|
827
|
-
fromView: viewId,
|
|
828
|
-
toView: stepForward.viewId,
|
|
829
|
-
fromNode: stepForward.nodeId as Fqn
|
|
830
|
-
}
|
|
831
|
-
: null
|
|
832
|
-
},
|
|
833
|
-
noReplace,
|
|
834
|
-
'goForward'
|
|
835
|
-
)
|
|
836
|
-
onNavigateTo(stepForward.viewId)
|
|
837
|
-
}
|
|
838
|
-
},
|
|
839
|
-
|
|
840
|
-
onOpenSourceView: () => {
|
|
841
|
-
const { view, onOpenSource } = get()
|
|
842
|
-
onOpenSource?.({
|
|
843
|
-
view: view.id
|
|
844
|
-
})
|
|
845
|
-
},
|
|
846
|
-
|
|
847
|
-
openOverlay: (overlay) => {
|
|
848
|
-
if (eq(overlay, get().activeOverlay)) {
|
|
849
|
-
return
|
|
850
|
-
}
|
|
851
|
-
if ('elementDetails' in overlay) {
|
|
852
|
-
const diagramNode = get().view.nodes.find(({ id }) => id === overlay.elementDetails)
|
|
853
|
-
if (!diagramNode || !diagramNode.modelRef) {
|
|
854
|
-
get().closeOverlay()
|
|
855
|
-
return
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
set(
|
|
860
|
-
{
|
|
861
|
-
activeWalkthrough: null,
|
|
862
|
-
activeOverlay: overlay
|
|
863
|
-
},
|
|
864
|
-
noReplace,
|
|
865
|
-
'openOverlay'
|
|
866
|
-
)
|
|
867
|
-
},
|
|
868
|
-
closeOverlay: () => {
|
|
869
|
-
if (get().activeOverlay !== null) {
|
|
870
|
-
set(
|
|
871
|
-
{
|
|
872
|
-
activeOverlay: null
|
|
873
|
-
},
|
|
874
|
-
noReplace,
|
|
875
|
-
'closeOverlay'
|
|
876
|
-
)
|
|
877
|
-
}
|
|
878
|
-
},
|
|
879
|
-
|
|
880
|
-
fitDiagram: (duration = 500) => {
|
|
881
|
-
const { fitViewPadding, view, xystore } = get()
|
|
882
|
-
const { width, height, panZoom, transform } = xystore.getState()
|
|
883
|
-
|
|
884
|
-
const bounds = view.bounds
|
|
885
|
-
const maxZoom = Math.max(1, transform[2])
|
|
886
|
-
const viewport = getViewportForBounds(bounds, width, height, MinZoom, maxZoom, fitViewPadding)
|
|
887
|
-
panZoom?.setViewport(viewport, duration > 0 ? { duration } : undefined)
|
|
888
|
-
},
|
|
889
|
-
|
|
890
|
-
nextDynamicStep: (increment = 1) => {
|
|
891
|
-
const { activeWalkthrough, xyedges, activateWalkthrough } = get()
|
|
892
|
-
const stepId = activeWalkthrough?.stepId
|
|
893
|
-
let nextStep
|
|
894
|
-
if (stepId) {
|
|
895
|
-
const currentIndex = xyedges.findIndex(({ id }) => id === stepId)
|
|
896
|
-
const nextIndex = currentIndex + increment
|
|
897
|
-
nextStep = xyedges[nextIndex]
|
|
898
|
-
} else {
|
|
899
|
-
nextStep = first(xyedges)
|
|
900
|
-
}
|
|
901
|
-
if (nextStep) {
|
|
902
|
-
activateWalkthrough(nextStep.data.edge.id)
|
|
903
|
-
return
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
|
|
907
|
-
activateWalkthrough: (step: EdgeId | DiagramFlowTypes.Edge) => {
|
|
908
|
-
const stepId = typeof step === 'string' ? step : step.data.edge.id
|
|
909
|
-
invariant(isStepEdgeId(stepId), `stepId ${stepId} is not a step edge id`)
|
|
910
|
-
let {
|
|
911
|
-
isDynamicView,
|
|
912
|
-
xyflow,
|
|
913
|
-
xyedges,
|
|
914
|
-
xystore,
|
|
915
|
-
fitViewPadding,
|
|
916
|
-
activeWalkthrough
|
|
917
|
-
} = get()
|
|
918
|
-
invariant(isDynamicView, 'view is not dynamic')
|
|
919
|
-
const edge = typeof step === 'string' ? xyedges.find(({ id }) => id === stepId) : step
|
|
920
|
-
invariant(edge, `edge not found: ${stepId}`)
|
|
921
|
-
const currentIndex = xyedges.findIndex(({ id }) => id === stepId)
|
|
922
|
-
activeWalkthrough = {
|
|
923
|
-
stepId,
|
|
924
|
-
hasPrevious: currentIndex > 0,
|
|
925
|
-
hasNext: currentIndex < xyedges.length - 1,
|
|
926
|
-
parallelPrefix: getParallelStepsPrefix(stepId)
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
const dimmed = new StringSet(
|
|
930
|
-
xyedges
|
|
931
|
-
.filter(({ id }) =>
|
|
932
|
-
id !== stepId
|
|
933
|
-
&& !(activeWalkthrough.parallelPrefix && id.startsWith(activeWalkthrough.parallelPrefix))
|
|
934
|
-
)
|
|
935
|
-
.map(({ id }) => id)
|
|
936
|
-
)
|
|
937
|
-
const selected = [] as DiagramFlowTypes.Node[]
|
|
938
|
-
for (const n of xyflow.getNodes()) {
|
|
939
|
-
if (n.id === edge.source || n.id === edge.target) {
|
|
940
|
-
selected.push(n)
|
|
941
|
-
continue
|
|
942
|
-
}
|
|
943
|
-
dimmed.add(n.id)
|
|
944
|
-
}
|
|
945
|
-
const { fitView, transform } = xystore.getState()
|
|
946
|
-
fitView({
|
|
947
|
-
duration: 400,
|
|
948
|
-
includeHiddenNodes: true,
|
|
949
|
-
maxZoom: Math.max(1, transform[2]),
|
|
950
|
-
minZoom: MinZoom,
|
|
951
|
-
padding: Math.max(fitViewPadding, 0.2),
|
|
952
|
-
nodes: selected
|
|
953
|
-
})
|
|
954
|
-
set(
|
|
955
|
-
{
|
|
956
|
-
focusedNodeId: null,
|
|
957
|
-
activeWalkthrough,
|
|
958
|
-
dimmed
|
|
959
|
-
},
|
|
960
|
-
noReplace,
|
|
961
|
-
'activateWalkthrough'
|
|
962
|
-
)
|
|
963
|
-
},
|
|
964
|
-
|
|
965
|
-
stopWalkthrough: () => {
|
|
966
|
-
if (get().activeWalkthrough !== null) {
|
|
967
|
-
set(
|
|
968
|
-
{
|
|
969
|
-
activeWalkthrough: null,
|
|
970
|
-
focusedNodeId: null,
|
|
971
|
-
dimmed: EmptyStringSet
|
|
972
|
-
},
|
|
973
|
-
noReplace,
|
|
974
|
-
'stopWalkthrough'
|
|
975
|
-
)
|
|
976
|
-
get().fitDiagram()
|
|
977
|
-
}
|
|
978
|
-
},
|
|
979
|
-
|
|
980
|
-
onInit: (instance) => {
|
|
981
|
-
const { xyflow, initialized, fitViewEnabled, fitDiagram } = get()
|
|
982
|
-
if (!initialized || xyflow !== instance) {
|
|
983
|
-
if (fitViewEnabled) {
|
|
984
|
-
fitDiagram(0)
|
|
985
|
-
}
|
|
986
|
-
set(
|
|
987
|
-
{
|
|
988
|
-
xyflow: instance,
|
|
989
|
-
initialized: true
|
|
990
|
-
},
|
|
991
|
-
noReplace,
|
|
992
|
-
'onInit'
|
|
993
|
-
)
|
|
994
|
-
}
|
|
995
|
-
},
|
|
996
|
-
|
|
997
|
-
highlightByElementNotation: (notation: ElementNotation, onlyOfKind?: NodeKind) => {
|
|
998
|
-
const { xynodes, xyedges } = get()
|
|
999
|
-
const dimmed = new StringSet(map(xyedges, prop('id')))
|
|
1000
|
-
xynodes.forEach(({ id, data }) => {
|
|
1001
|
-
const node = data.element
|
|
1002
|
-
if (
|
|
1003
|
-
node.shape !== notation.shape || node.color !== notation.color || !notation.kinds.includes(node.kind)
|
|
1004
|
-
|| (onlyOfKind && node.kind !== onlyOfKind)
|
|
1005
|
-
) {
|
|
1006
|
-
dimmed.add(id)
|
|
1007
|
-
}
|
|
1008
|
-
})
|
|
1009
|
-
set({ dimmed }, noReplace, 'highlightByElementNotation')
|
|
1010
|
-
},
|
|
1011
|
-
|
|
1012
|
-
resetEdgeControlPoints: () => {
|
|
1013
|
-
const { xyflow, scheduleSaveManualLayout, xynodes, xyedges } = get()
|
|
1014
|
-
|
|
1015
|
-
xyedges.forEach(edge => {
|
|
1016
|
-
xyflow.updateEdgeData(edge.id, {
|
|
1017
|
-
controlPoints: getControlPointForEdge(edge)
|
|
1018
|
-
})
|
|
1019
|
-
})
|
|
1020
|
-
|
|
1021
|
-
scheduleSaveManualLayout()
|
|
1022
|
-
|
|
1023
|
-
function getNodeCenter(node: DiagramFlowTypes.Node, nodes: DiagramFlowTypes.Node[]) {
|
|
1024
|
-
const dimensions = vector({ x: node.width || 0, y: node.height || 0 })
|
|
1025
|
-
let position = vector(node.position)
|
|
1026
|
-
.add(dimensions.mul(0.5))
|
|
1027
|
-
|
|
1028
|
-
let currentNode = node
|
|
1029
|
-
do {
|
|
1030
|
-
const parent = currentNode.parentId && nodes.find(x => x.id == currentNode.parentId)
|
|
1031
|
-
|
|
1032
|
-
if (!parent) {
|
|
1033
|
-
break
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
currentNode = parent
|
|
1037
|
-
position = position.add(parent.position)
|
|
1038
|
-
} while (true)
|
|
1039
|
-
|
|
1040
|
-
return position
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
function getControlPointForEdge(edge: DiagramFlowTypes.Edge): XYPoint[] {
|
|
1044
|
-
const source = xynodes.find(x => x.id == edge.source)
|
|
1045
|
-
const target = xynodes.find(x => x.id == edge.target)
|
|
1046
|
-
if (!source || !target) {
|
|
1047
|
-
return []
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
const sourceCenter = getNodeCenter(source, xynodes)
|
|
1051
|
-
const targetCenter = getNodeCenter(target, xynodes)
|
|
1052
|
-
|
|
1053
|
-
if (!sourceCenter || !targetCenter) {
|
|
1054
|
-
return []
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
// Edge is a loop
|
|
1058
|
-
if(source == target) {
|
|
1059
|
-
const loopSize = 80
|
|
1060
|
-
const centerOfTopBoundary = new VectorImpl(0, source.height || 0)
|
|
1061
|
-
.mul(-0.5)
|
|
1062
|
-
.add(sourceCenter)
|
|
1063
|
-
|
|
1064
|
-
return [
|
|
1065
|
-
centerOfTopBoundary.add(new VectorImpl(-loopSize / 2.5, -loopSize)),
|
|
1066
|
-
centerOfTopBoundary.add(new VectorImpl(loopSize / 2.5, -loopSize))
|
|
1067
|
-
]
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
const sourceToTargetVector = targetCenter.sub(sourceCenter)
|
|
1071
|
-
const sourceBorderPoint = getBorderPointOnVector(source, sourceCenter, sourceToTargetVector)
|
|
1072
|
-
const targetBorderPoint = getBorderPointOnVector(target, targetCenter, sourceToTargetVector.mul(-1))
|
|
1073
|
-
|
|
1074
|
-
return [sourceBorderPoint.add(targetBorderPoint.sub(sourceBorderPoint).mul(0.3))]
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
function getBorderPointOnVector(node: DiagramFlowTypes.Node, nodeCenter: Vector, v: Vector) {
|
|
1078
|
-
const xScale = (node.width || 0) / 2 / v.x
|
|
1079
|
-
const yScale = (node.height || 0) / 2 / v.y
|
|
1080
|
-
|
|
1081
|
-
const scale = Math.min(Math.abs(xScale), Math.abs(yScale))
|
|
1082
|
-
|
|
1083
|
-
return vector(v).mul(scale).add(nodeCenter)
|
|
1084
|
-
}
|
|
1085
|
-
},
|
|
1086
|
-
align: align(get)
|
|
1087
|
-
} satisfies DiagramState),
|
|
1088
|
-
{
|
|
1089
|
-
name: `${storeDevId} - ${props.view.id}`,
|
|
1090
|
-
enabled: DEV
|
|
1091
|
-
}
|
|
1092
|
-
)
|
|
1093
|
-
),
|
|
1094
|
-
shallow
|
|
1095
|
-
)
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
export type DiagramZustandStore = ReturnType<typeof createDiagramStore>
|
|
1099
|
-
export type DiagramStoreApi = Readonly<Pick<DiagramZustandStore, 'getState' | 'setState' | 'subscribe'>>
|