@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
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
import { nonexhaustive, invariant, nonNullable, getBBoxCenter, getParallelStepsPrefix, DiagramNode } from "@likec4/core";
|
|
2
|
+
import { getViewportForBounds, applyNodeChanges, applyEdgeChanges } from "@xyflow/react";
|
|
3
|
+
import { nodeToRect } from "@xyflow/system";
|
|
4
|
+
import { hasAtLeast, first, clamp, prop } from "remeda";
|
|
5
|
+
import { setup, assertEvent, enqueueActions, and, or, assign, sendTo, spawnChild, stopChild, raise, cancel } from "xstate";
|
|
6
|
+
import { MinZoom } from "../../base/const.js";
|
|
7
|
+
import { AllDisabled } from "../../context/DiagramFeatures.js";
|
|
8
|
+
import { relationshipDetailsActor } from "../../overlays/relationship-details/actor.js";
|
|
9
|
+
import { relationshipsBrowserActor } from "../../overlays/relationships-browser/actor.js";
|
|
10
|
+
import { createLayoutConstraints } from "../useLayoutConstraints.js";
|
|
11
|
+
import { getAligner, toNodeRect } from "./aligners.js";
|
|
12
|
+
import { lastClickedNode, focusNodesEdges, unfocusNodesEdges, updateNavigationHistory, mergeXYNodesEdges, updateActiveWalkthrough, navigateBack, navigateForward, updateNodeData, updateEdgeData, resetEdgeControlPoints } from "./assign.js";
|
|
13
|
+
import { hotkeyActor } from "./hotkeyActor.js";
|
|
14
|
+
import { syncManualLayoutActor } from "./syncManualLayoutActor.js";
|
|
15
|
+
import { focusedBounds } from "./utils.js";
|
|
16
|
+
var DiagramContext;
|
|
17
|
+
((DiagramContext2) => {
|
|
18
|
+
function findDiagramNode(ctx, xynodeId) {
|
|
19
|
+
return ctx.view.nodes.find((n) => n.id === xynodeId) ?? null;
|
|
20
|
+
}
|
|
21
|
+
DiagramContext2.findDiagramNode = findDiagramNode;
|
|
22
|
+
function findDiagramEdge(ctx, xyedgeId) {
|
|
23
|
+
return ctx.view.edges.find((e) => e.id === xyedgeId) ?? null;
|
|
24
|
+
}
|
|
25
|
+
DiagramContext2.findDiagramEdge = findDiagramEdge;
|
|
26
|
+
})(DiagramContext || (DiagramContext = {}));
|
|
27
|
+
const diagramMachine = setup({
|
|
28
|
+
types: {
|
|
29
|
+
context: {},
|
|
30
|
+
input: {},
|
|
31
|
+
children: {},
|
|
32
|
+
events: {}
|
|
33
|
+
},
|
|
34
|
+
actors: {
|
|
35
|
+
hotkeyActor,
|
|
36
|
+
syncManualLayoutActor,
|
|
37
|
+
relationshipsBrowserActor,
|
|
38
|
+
relationshipDetailsActor
|
|
39
|
+
},
|
|
40
|
+
guards: {
|
|
41
|
+
"enabled: FitView": ({ context }) => context.features.enableFitView,
|
|
42
|
+
"enabled: FocusMode": ({ context }) => context.features.enableFocusMode,
|
|
43
|
+
"enabled: Readonly": ({ context }) => context.features.enableReadOnly,
|
|
44
|
+
"not readonly": ({ context }) => !context.features.enableReadOnly,
|
|
45
|
+
"is dynamic view": ({ context }) => context.view.__ === "dynamic",
|
|
46
|
+
"is another view": ({ context, event }) => {
|
|
47
|
+
assertEvent(event, ["update.view", "navigate.to"]);
|
|
48
|
+
if (event.type === "update.view") {
|
|
49
|
+
return context.view.id !== event.view.id;
|
|
50
|
+
}
|
|
51
|
+
if (event.type === "navigate.to") {
|
|
52
|
+
return context.view.id !== event.viewId;
|
|
53
|
+
}
|
|
54
|
+
nonexhaustive(event.type);
|
|
55
|
+
},
|
|
56
|
+
"click: selected node ": ({ event }) => {
|
|
57
|
+
assertEvent(event, "xyflow.nodeClick");
|
|
58
|
+
return event.node.selected === true;
|
|
59
|
+
},
|
|
60
|
+
"click: same node": ({ context, event }) => {
|
|
61
|
+
var _a;
|
|
62
|
+
assertEvent(event, "xyflow.nodeClick");
|
|
63
|
+
return ((_a = context.lastClickedNode) == null ? void 0 : _a.id) === event.node.id;
|
|
64
|
+
},
|
|
65
|
+
"click: focused node": ({ context, event }) => {
|
|
66
|
+
assertEvent(event, "xyflow.nodeClick");
|
|
67
|
+
return context.focusedNode === event.node.id;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
actions: {
|
|
71
|
+
"trigger:NavigateTo": (_, _params) => {
|
|
72
|
+
},
|
|
73
|
+
"trigger:OnChange": (_, _params) => {
|
|
74
|
+
},
|
|
75
|
+
"trigger:OpenSource": (_, _params) => {
|
|
76
|
+
},
|
|
77
|
+
"xyflow:fitDiagram": ({ context }, params) => {
|
|
78
|
+
const {
|
|
79
|
+
bounds = context.view.bounds,
|
|
80
|
+
duration = 450
|
|
81
|
+
} = params ?? {};
|
|
82
|
+
const { width, height, panZoom, transform } = context.xystore.getState();
|
|
83
|
+
const maxZoom = Math.max(1, transform[2]);
|
|
84
|
+
const viewport = getViewportForBounds(
|
|
85
|
+
bounds,
|
|
86
|
+
width,
|
|
87
|
+
height,
|
|
88
|
+
MinZoom,
|
|
89
|
+
maxZoom,
|
|
90
|
+
context.fitViewPadding
|
|
91
|
+
);
|
|
92
|
+
viewport.x = Math.round(viewport.x);
|
|
93
|
+
viewport.y = Math.round(viewport.y);
|
|
94
|
+
panZoom == null ? void 0 : panZoom.setViewport(viewport, duration > 0 ? { duration } : void 0);
|
|
95
|
+
},
|
|
96
|
+
"xyflow:setViewportCenter": ({ context }, params) => {
|
|
97
|
+
const { x, y } = params;
|
|
98
|
+
invariant(context.xyflow, "xyflow is not initialized");
|
|
99
|
+
const zoom = context.xyflow.getZoom();
|
|
100
|
+
context.xyflow.setCenter(Math.round(x), Math.round(y), { zoom });
|
|
101
|
+
},
|
|
102
|
+
"xyflow:setViewport": ({ context }, params) => {
|
|
103
|
+
const {
|
|
104
|
+
viewport,
|
|
105
|
+
duration = 350
|
|
106
|
+
} = params;
|
|
107
|
+
const { panZoom } = context.xystore.getState();
|
|
108
|
+
panZoom == null ? void 0 : panZoom.setViewport(viewport, duration > 0 ? { duration } : void 0);
|
|
109
|
+
},
|
|
110
|
+
"xyflow:alignNodeFromToAfterNavigate": ({ context }, params) => {
|
|
111
|
+
const xyflow = nonNullable(context.xyflow, "xyflow is not initialized");
|
|
112
|
+
const elFrom = xyflow.getInternalNode(params.fromNode);
|
|
113
|
+
if (!elFrom) return;
|
|
114
|
+
const fromPos = xyflow.flowToScreenPosition({
|
|
115
|
+
x: elFrom.internals.positionAbsolute.x,
|
|
116
|
+
// + dimensions.width / 2,
|
|
117
|
+
y: elFrom.internals.positionAbsolute.y
|
|
118
|
+
// + dimensions.height / 2
|
|
119
|
+
}), toPos = xyflow.flowToScreenPosition(params.toPosition), diff = {
|
|
120
|
+
x: Math.round(fromPos.x - toPos.x),
|
|
121
|
+
y: Math.round(fromPos.y - toPos.y)
|
|
122
|
+
};
|
|
123
|
+
context.xystore.getState().panBy(diff);
|
|
124
|
+
},
|
|
125
|
+
"layout.align": ({ context }, params) => {
|
|
126
|
+
const { mode } = params;
|
|
127
|
+
const { xystore } = context;
|
|
128
|
+
const { nodeLookup, parentLookup } = xystore.getState();
|
|
129
|
+
const selectedNodes = new Set(nodeLookup.values().filter((n) => n.selected).map((n) => n.id));
|
|
130
|
+
const nodesToAlign = [...selectedNodes.difference(new Set(parentLookup.keys()))];
|
|
131
|
+
if (!hasAtLeast(nodesToAlign, 2)) {
|
|
132
|
+
console.warn("At least 2 nodes must be selected to align");
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const constraints = createLayoutConstraints(xystore, nodesToAlign);
|
|
136
|
+
const aligner = getAligner(mode);
|
|
137
|
+
constraints.onMove((nodes) => {
|
|
138
|
+
aligner.computeLayout(nodes.map(({ node }) => toNodeRect(node)));
|
|
139
|
+
nodes.forEach(({ rect, node }) => {
|
|
140
|
+
rect.positionAbsolute = {
|
|
141
|
+
...rect.positionAbsolute,
|
|
142
|
+
...aligner.applyPosition(toNodeRect(node))
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}).createMachine({
|
|
149
|
+
initial: "initializing",
|
|
150
|
+
context: ({ input, self, spawn }) => ({
|
|
151
|
+
...input,
|
|
152
|
+
features: { ...AllDisabled },
|
|
153
|
+
initialized: false,
|
|
154
|
+
viewportChangedManually: false,
|
|
155
|
+
lastOnNavigate: null,
|
|
156
|
+
lastClickedNode: null,
|
|
157
|
+
focusedNode: null,
|
|
158
|
+
activeElementDetails: null,
|
|
159
|
+
viewportBeforeFocus: null,
|
|
160
|
+
navigationHistory: {
|
|
161
|
+
currentIndex: 0,
|
|
162
|
+
history: []
|
|
163
|
+
},
|
|
164
|
+
viewport: { x: 0, y: 0, zoom: 1 },
|
|
165
|
+
xyflow: null,
|
|
166
|
+
syncLayoutActorRef: spawn("syncManualLayoutActor", {
|
|
167
|
+
id: "syncLayout",
|
|
168
|
+
input: { parent: self, viewId: input.view.id }
|
|
169
|
+
}),
|
|
170
|
+
activeWalkthrough: null
|
|
171
|
+
}),
|
|
172
|
+
// entry: ({ spawn }) => spawn(layoutActor, { id: 'layout', input: { parent: self } }),
|
|
173
|
+
states: {
|
|
174
|
+
initializing: {
|
|
175
|
+
on: {
|
|
176
|
+
"xyflow.init": {
|
|
177
|
+
actions: enqueueActions(({ enqueue, check }) => {
|
|
178
|
+
enqueue.assign({
|
|
179
|
+
initialized: true,
|
|
180
|
+
xyflow: ({ event }) => event.instance,
|
|
181
|
+
navigationHistory: ({ context, event }) => ({
|
|
182
|
+
currentIndex: 0,
|
|
183
|
+
history: [{
|
|
184
|
+
viewId: context.view.id,
|
|
185
|
+
fromNode: null,
|
|
186
|
+
viewport: { ...event.instance.getViewport() }
|
|
187
|
+
}]
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
if (check("enabled: FitView")) {
|
|
191
|
+
enqueue({
|
|
192
|
+
type: "xyflow:fitDiagram",
|
|
193
|
+
params: { duration: 0 }
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}),
|
|
197
|
+
target: "idle"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
idle: {
|
|
202
|
+
id: "idle",
|
|
203
|
+
on: {
|
|
204
|
+
"xyflow.nodeClick": [
|
|
205
|
+
{
|
|
206
|
+
// TODO: xstate fails to infer the type of the guard
|
|
207
|
+
guard: and([
|
|
208
|
+
"enabled: FocusMode",
|
|
209
|
+
or([
|
|
210
|
+
"click: same node",
|
|
211
|
+
"click: selected node "
|
|
212
|
+
])
|
|
213
|
+
]),
|
|
214
|
+
actions: [
|
|
215
|
+
assign({
|
|
216
|
+
lastClickedNode,
|
|
217
|
+
focusedNode: ({ event }) => event.node.id
|
|
218
|
+
})
|
|
219
|
+
],
|
|
220
|
+
target: "focused"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
actions: assign({
|
|
224
|
+
lastClickedNode
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"xyflow.paneClick": {
|
|
229
|
+
actions: [
|
|
230
|
+
assign({
|
|
231
|
+
lastClickedNode: null
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
"xyflow.paneDblClick": {
|
|
236
|
+
actions: [
|
|
237
|
+
{ type: "xyflow:fitDiagram" },
|
|
238
|
+
{ type: "trigger:OpenSource", params: ({ context }) => ({ view: context.view.id }) }
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
"saveManualLayout.*": {
|
|
242
|
+
guard: "not readonly",
|
|
243
|
+
actions: sendTo((c) => c.context.syncLayoutActorRef, ({ event }) => {
|
|
244
|
+
if (event.type === "saveManualLayout.schedule") {
|
|
245
|
+
return { type: "sync" };
|
|
246
|
+
}
|
|
247
|
+
if (event.type === "saveManualLayout.cancel") {
|
|
248
|
+
return { type: "cancel" };
|
|
249
|
+
}
|
|
250
|
+
nonexhaustive(event);
|
|
251
|
+
})
|
|
252
|
+
},
|
|
253
|
+
"focus.node": {
|
|
254
|
+
guard: "enabled: FocusMode",
|
|
255
|
+
actions: assign({
|
|
256
|
+
focusedNode: ({ event }) => event.nodeId
|
|
257
|
+
}),
|
|
258
|
+
target: "focused"
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
focused: {
|
|
263
|
+
entry: [
|
|
264
|
+
assign((s) => ({
|
|
265
|
+
...focusNodesEdges(s),
|
|
266
|
+
viewportBeforeFocus: { ...s.context.viewport }
|
|
267
|
+
})),
|
|
268
|
+
spawnChild("hotkeyActor", { id: "hotkey" }),
|
|
269
|
+
{
|
|
270
|
+
type: "xyflow:fitDiagram",
|
|
271
|
+
params: focusedBounds
|
|
272
|
+
}
|
|
273
|
+
],
|
|
274
|
+
on: {
|
|
275
|
+
"xyflow.nodeClick": [
|
|
276
|
+
{
|
|
277
|
+
guard: "click: focused node",
|
|
278
|
+
target: "#idle"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
actions: [
|
|
282
|
+
assign({
|
|
283
|
+
lastClickedNode,
|
|
284
|
+
focusedNode: ({ event }) => event.node.id
|
|
285
|
+
}),
|
|
286
|
+
assign(focusNodesEdges),
|
|
287
|
+
{
|
|
288
|
+
type: "xyflow:fitDiagram",
|
|
289
|
+
params: focusedBounds
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
],
|
|
294
|
+
"focus.node": {
|
|
295
|
+
actions: [
|
|
296
|
+
assign({
|
|
297
|
+
focusedNode: ({ event }) => event.nodeId
|
|
298
|
+
}),
|
|
299
|
+
assign(focusNodesEdges),
|
|
300
|
+
{
|
|
301
|
+
type: "xyflow:fitDiagram",
|
|
302
|
+
params: focusedBounds
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
},
|
|
306
|
+
"key.esc": {
|
|
307
|
+
target: "idle"
|
|
308
|
+
},
|
|
309
|
+
"xyflow.paneClick": {
|
|
310
|
+
actions: assign({
|
|
311
|
+
lastClickedNode: null
|
|
312
|
+
}),
|
|
313
|
+
target: "idle"
|
|
314
|
+
},
|
|
315
|
+
"saveManualLayout.*": {
|
|
316
|
+
guard: "not readonly",
|
|
317
|
+
actions: sendTo((c) => c.context.syncLayoutActorRef, ({ event }) => {
|
|
318
|
+
if (event.type === "saveManualLayout.schedule") {
|
|
319
|
+
return { type: "sync" };
|
|
320
|
+
}
|
|
321
|
+
if (event.type === "saveManualLayout.cancel") {
|
|
322
|
+
return { type: "cancel" };
|
|
323
|
+
}
|
|
324
|
+
nonexhaustive(event);
|
|
325
|
+
})
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
exit: [
|
|
329
|
+
stopChild("hotkey"),
|
|
330
|
+
enqueueActions(({ enqueue, context }) => {
|
|
331
|
+
if (context.viewportBeforeFocus) {
|
|
332
|
+
enqueue({ type: "xyflow:setViewport", params: { viewport: context.viewportBeforeFocus } });
|
|
333
|
+
} else {
|
|
334
|
+
enqueue({ type: "xyflow:fitDiagram" });
|
|
335
|
+
}
|
|
336
|
+
enqueue.assign((s) => ({
|
|
337
|
+
...unfocusNodesEdges(s),
|
|
338
|
+
viewportBeforeFocus: null,
|
|
339
|
+
focusedNode: null
|
|
340
|
+
}));
|
|
341
|
+
})
|
|
342
|
+
]
|
|
343
|
+
},
|
|
344
|
+
overlay: {
|
|
345
|
+
entry: spawnChild("hotkeyActor", { id: "hotkey" }),
|
|
346
|
+
initial: "hole",
|
|
347
|
+
states: {
|
|
348
|
+
hole: {
|
|
349
|
+
target: "#idle"
|
|
350
|
+
},
|
|
351
|
+
elementDetails: {
|
|
352
|
+
guard: ({ context }) => context.activeElementDetails !== null,
|
|
353
|
+
entry: assign({
|
|
354
|
+
activeElementDetails: ({ context }) => {
|
|
355
|
+
const fqn = context.activeElementDetails.fqn;
|
|
356
|
+
const fromNode = context.activeElementDetails.fromNode;
|
|
357
|
+
if (fromNode) {
|
|
358
|
+
const internalNode = nonNullable(
|
|
359
|
+
context.xystore.getState().nodeLookup.get(fromNode),
|
|
360
|
+
"XY Internal Node not found"
|
|
361
|
+
);
|
|
362
|
+
const nodeRect = nodeToRect(internalNode);
|
|
363
|
+
const zoom = context.xyflow.getZoom();
|
|
364
|
+
const nodeRectScreen = {
|
|
365
|
+
...context.xyflow.flowToScreenPosition(nodeRect),
|
|
366
|
+
width: nodeRect.width * zoom,
|
|
367
|
+
height: nodeRect.height * zoom
|
|
368
|
+
};
|
|
369
|
+
return { fqn, fromNode, nodeRect, nodeRectScreen };
|
|
370
|
+
} else {
|
|
371
|
+
return { fqn, fromNode };
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}),
|
|
375
|
+
on: {
|
|
376
|
+
// Catch event and do nothing
|
|
377
|
+
"open.elementDetails": {
|
|
378
|
+
actions: assign({
|
|
379
|
+
activeElementDetails: ({ event, context }) => {
|
|
380
|
+
var _a;
|
|
381
|
+
return {
|
|
382
|
+
...context.activeElementDetails,
|
|
383
|
+
fqn: event.fqn,
|
|
384
|
+
fromNode: ((_a = context.activeElementDetails) == null ? void 0 : _a.fromNode) ?? null
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
},
|
|
389
|
+
"close.overlay": {
|
|
390
|
+
target: "#idle"
|
|
391
|
+
},
|
|
392
|
+
"key.esc": {
|
|
393
|
+
target: "#idle"
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
exit: assign({
|
|
397
|
+
activeElementDetails: null
|
|
398
|
+
})
|
|
399
|
+
},
|
|
400
|
+
relationshipsBrowser: {
|
|
401
|
+
invoke: {
|
|
402
|
+
id: "relationshipsBrowser",
|
|
403
|
+
src: "relationshipsBrowserActor",
|
|
404
|
+
input: ({ context, event }) => {
|
|
405
|
+
assertEvent(event, "open.relationshipsBrowser");
|
|
406
|
+
return {
|
|
407
|
+
subject: event.fqn,
|
|
408
|
+
scope: context.view
|
|
409
|
+
};
|
|
410
|
+
},
|
|
411
|
+
onDone: {
|
|
412
|
+
target: "#idle"
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
on: {
|
|
416
|
+
"open.relationshipsBrowser": {
|
|
417
|
+
actions: sendTo("relationshipsBrowser", ({ event }) => ({
|
|
418
|
+
type: "navigate.to",
|
|
419
|
+
subject: event.fqn
|
|
420
|
+
}))
|
|
421
|
+
},
|
|
422
|
+
"close.overlay": {
|
|
423
|
+
actions: sendTo("relationshipsBrowser", { type: "close" })
|
|
424
|
+
},
|
|
425
|
+
"key.esc": {
|
|
426
|
+
actions: sendTo("relationshipsBrowser", { type: "close" })
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
relationshipDetails: {
|
|
431
|
+
invoke: {
|
|
432
|
+
id: "relationshipDetails",
|
|
433
|
+
src: "relationshipDetailsActor",
|
|
434
|
+
input: ({ event, context }) => {
|
|
435
|
+
assertEvent(event, "open.relationshipDetails");
|
|
436
|
+
return {
|
|
437
|
+
edgeId: event.edgeId,
|
|
438
|
+
view: context.view
|
|
439
|
+
};
|
|
440
|
+
},
|
|
441
|
+
onDone: {
|
|
442
|
+
target: "#idle"
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
on: {
|
|
446
|
+
"close.overlay": {
|
|
447
|
+
actions: sendTo("relationshipDetails", { type: "close" })
|
|
448
|
+
},
|
|
449
|
+
"key.esc": {
|
|
450
|
+
actions: sendTo("relationshipDetails", { type: "close" })
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
on: {
|
|
456
|
+
// We received another view, close overlay and process event again
|
|
457
|
+
"update.view": {
|
|
458
|
+
guard: "is another view",
|
|
459
|
+
actions: raise(({ event }) => event, { delay: 50 }),
|
|
460
|
+
target: "#idle"
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
exit: [
|
|
464
|
+
stopChild("hotkey")
|
|
465
|
+
]
|
|
466
|
+
},
|
|
467
|
+
// Navigating to another view (after `navigateTo` event)
|
|
468
|
+
navigating: {
|
|
469
|
+
initial: "pending",
|
|
470
|
+
type: "compound",
|
|
471
|
+
states: {
|
|
472
|
+
pending: {
|
|
473
|
+
entry: enqueueActions(({ enqueue }) => {
|
|
474
|
+
enqueue.sendTo((c) => c.context.syncLayoutActorRef, { type: "stop" });
|
|
475
|
+
enqueue.stopChild("layout");
|
|
476
|
+
enqueue({
|
|
477
|
+
type: "trigger:NavigateTo",
|
|
478
|
+
params: ({ context }) => ({
|
|
479
|
+
viewId: nonNullable(context.lastOnNavigate, "Invalid state, lastOnNavigate is null").toView
|
|
480
|
+
})
|
|
481
|
+
});
|
|
482
|
+
}),
|
|
483
|
+
on: {
|
|
484
|
+
"update.view": {
|
|
485
|
+
actions: enqueueActions(({ enqueue, context, event }) => {
|
|
486
|
+
const { fromNode, toNode } = findCorrespondingNode(context, event);
|
|
487
|
+
if (fromNode && toNode) {
|
|
488
|
+
enqueue({
|
|
489
|
+
type: "xyflow:alignNodeFromToAfterNavigate",
|
|
490
|
+
params: {
|
|
491
|
+
fromNode: fromNode.id,
|
|
492
|
+
toPosition: {
|
|
493
|
+
x: toNode.position[0],
|
|
494
|
+
y: toNode.position[1]
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
} else {
|
|
499
|
+
enqueue({
|
|
500
|
+
type: "xyflow:setViewportCenter",
|
|
501
|
+
params: getBBoxCenter(event.view.bounds)
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
enqueue.assign(updateNavigationHistory);
|
|
505
|
+
enqueue.assign(mergeXYNodesEdges);
|
|
506
|
+
enqueue.raise({ type: "fitDiagram" }, { id: "fitDiagram", delay: 75 });
|
|
507
|
+
}),
|
|
508
|
+
target: "done"
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
done: {
|
|
513
|
+
type: "final"
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
onDone: {
|
|
517
|
+
target: "idle"
|
|
518
|
+
},
|
|
519
|
+
exit: assign({
|
|
520
|
+
syncLayoutActorRef: ({ self, context, spawn }) => spawn("syncManualLayoutActor", { id: "syncLayout", input: { parent: self, viewId: context.view.id } }),
|
|
521
|
+
lastOnNavigate: null
|
|
522
|
+
})
|
|
523
|
+
},
|
|
524
|
+
walkthrough: {
|
|
525
|
+
entry: [
|
|
526
|
+
spawnChild("hotkeyActor", { id: "hotkey" }),
|
|
527
|
+
assign({
|
|
528
|
+
viewportBeforeFocus: ({ context }) => context.viewport,
|
|
529
|
+
activeWalkthrough: ({ context, event }) => {
|
|
530
|
+
assertEvent(event, "walkthrough.start");
|
|
531
|
+
const stepId = event.stepId ?? first(context.xyedges).id;
|
|
532
|
+
return {
|
|
533
|
+
stepId,
|
|
534
|
+
parallelPrefix: getParallelStepsPrefix(stepId)
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
}),
|
|
538
|
+
assign(updateActiveWalkthrough),
|
|
539
|
+
{
|
|
540
|
+
type: "xyflow:fitDiagram",
|
|
541
|
+
params: focusedBounds
|
|
542
|
+
}
|
|
543
|
+
],
|
|
544
|
+
on: {
|
|
545
|
+
"key.esc": {
|
|
546
|
+
target: "idle"
|
|
547
|
+
},
|
|
548
|
+
"key.arrow.left": {
|
|
549
|
+
actions: raise({ type: "walkthrough.step", direction: "previous" })
|
|
550
|
+
},
|
|
551
|
+
"key.arrow.right": {
|
|
552
|
+
actions: raise({ type: "walkthrough.step", direction: "next" })
|
|
553
|
+
},
|
|
554
|
+
"walkthrough.step": {
|
|
555
|
+
actions: enqueueActions(({ enqueue, context, event }) => {
|
|
556
|
+
const { stepId } = context.activeWalkthrough;
|
|
557
|
+
const stepIndex = context.xyedges.findIndex((e) => e.id === stepId);
|
|
558
|
+
const nextStepIndex = clamp(event.direction === "next" ? stepIndex + 1 : stepIndex - 1, {
|
|
559
|
+
min: 0,
|
|
560
|
+
max: context.xyedges.length - 1
|
|
561
|
+
});
|
|
562
|
+
if (nextStepIndex === stepIndex) {
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const nextStepId = context.xyedges[nextStepIndex].id;
|
|
566
|
+
enqueue.assign({
|
|
567
|
+
activeWalkthrough: {
|
|
568
|
+
stepId: nextStepId,
|
|
569
|
+
parallelPrefix: getParallelStepsPrefix(nextStepId)
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
enqueue.assign(updateActiveWalkthrough);
|
|
573
|
+
enqueue({
|
|
574
|
+
type: "xyflow:fitDiagram",
|
|
575
|
+
params: focusedBounds
|
|
576
|
+
});
|
|
577
|
+
})
|
|
578
|
+
},
|
|
579
|
+
"walkthrough.end": {
|
|
580
|
+
target: "idle"
|
|
581
|
+
},
|
|
582
|
+
// We received another view, close overlay and process event again
|
|
583
|
+
"update.view": {
|
|
584
|
+
guard: "is another view",
|
|
585
|
+
actions: raise(({ event }) => event, { delay: 50 }),
|
|
586
|
+
target: "idle"
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
exit: enqueueActions(({ enqueue, context }) => {
|
|
590
|
+
enqueue.stopChild("hotkey");
|
|
591
|
+
if (context.viewportBeforeFocus) {
|
|
592
|
+
enqueue({ type: "xyflow:setViewport", params: { viewport: context.viewportBeforeFocus } });
|
|
593
|
+
} else {
|
|
594
|
+
enqueue({ type: "xyflow:fitDiagram" });
|
|
595
|
+
}
|
|
596
|
+
enqueue.assign((s) => ({
|
|
597
|
+
activeWalkthrough: null,
|
|
598
|
+
...unfocusNodesEdges(s),
|
|
599
|
+
viewportBeforeFocus: null
|
|
600
|
+
}));
|
|
601
|
+
})
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
on: {
|
|
605
|
+
"xyflow.applyNodeChages": {
|
|
606
|
+
actions: assign({
|
|
607
|
+
xynodes: ({ context, event }) => applyNodeChanges(event.changes, context.xynodes)
|
|
608
|
+
})
|
|
609
|
+
},
|
|
610
|
+
"xyflow.applyEdgeChages": {
|
|
611
|
+
actions: assign({
|
|
612
|
+
xyedges: ({ context, event }) => applyEdgeChanges(event.changes, context.xyedges)
|
|
613
|
+
})
|
|
614
|
+
},
|
|
615
|
+
"xyflow.viewportMoved": {
|
|
616
|
+
actions: assign({
|
|
617
|
+
viewportChangedManually: ({ event }) => event.manually,
|
|
618
|
+
viewport: ({ event }) => event.viewport
|
|
619
|
+
})
|
|
620
|
+
},
|
|
621
|
+
"fitDiagram": {
|
|
622
|
+
guard: "enabled: FitView",
|
|
623
|
+
actions: {
|
|
624
|
+
type: "xyflow:fitDiagram",
|
|
625
|
+
params: prop("event")
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
"navigate.to": {
|
|
629
|
+
guard: "is another view",
|
|
630
|
+
actions: [
|
|
631
|
+
assign({
|
|
632
|
+
lastOnNavigate: ({ context, event }) => ({
|
|
633
|
+
fromView: context.view.id,
|
|
634
|
+
toView: event.viewId,
|
|
635
|
+
fromNode: event.fromNode ?? null
|
|
636
|
+
})
|
|
637
|
+
})
|
|
638
|
+
],
|
|
639
|
+
target: ".navigating"
|
|
640
|
+
},
|
|
641
|
+
"navigate.back": {
|
|
642
|
+
guard: ({ context }) => context.navigationHistory.currentIndex > 0,
|
|
643
|
+
actions: assign(navigateBack),
|
|
644
|
+
target: ".navigating"
|
|
645
|
+
},
|
|
646
|
+
"navigate.forward": {
|
|
647
|
+
guard: ({ context }) => context.navigationHistory.currentIndex < context.navigationHistory.history.length - 1,
|
|
648
|
+
actions: assign(navigateForward),
|
|
649
|
+
target: ".navigating"
|
|
650
|
+
},
|
|
651
|
+
"update.view": {
|
|
652
|
+
actions: [
|
|
653
|
+
assign(updateNavigationHistory),
|
|
654
|
+
enqueueActions(({ enqueue, event, check, context }) => {
|
|
655
|
+
const isAnotherView = check("is another view");
|
|
656
|
+
if (isAnotherView) {
|
|
657
|
+
const viewId = event.view.id;
|
|
658
|
+
enqueue.sendTo((c) => c.context.syncLayoutActorRef, { type: "stop" });
|
|
659
|
+
enqueue.stopChild("layout");
|
|
660
|
+
enqueue.assign({
|
|
661
|
+
focusedNode: null,
|
|
662
|
+
syncLayoutActorRef: ({ self, spawn }) => spawn("syncManualLayoutActor", { id: "syncLayout", input: { parent: self, viewId } })
|
|
663
|
+
});
|
|
664
|
+
const { fromNode, toNode } = findCorrespondingNode(context, event);
|
|
665
|
+
if (fromNode && toNode) {
|
|
666
|
+
enqueue({
|
|
667
|
+
type: "xyflow:alignNodeFromToAfterNavigate",
|
|
668
|
+
params: {
|
|
669
|
+
fromNode: fromNode.id,
|
|
670
|
+
toPosition: {
|
|
671
|
+
x: toNode.position[0],
|
|
672
|
+
y: toNode.position[1]
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
} else {
|
|
677
|
+
enqueue({
|
|
678
|
+
type: "xyflow:setViewportCenter",
|
|
679
|
+
params: getBBoxCenter(event.view.bounds)
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
} else {
|
|
683
|
+
enqueue.sendTo((c) => c.context.syncLayoutActorRef, { type: "synced" });
|
|
684
|
+
}
|
|
685
|
+
if (isAnotherView || !context.viewportChangedManually) {
|
|
686
|
+
enqueue.raise({ type: "fitDiagram" }, { id: "fitDiagram", delay: 90 });
|
|
687
|
+
}
|
|
688
|
+
enqueue.assign(mergeXYNodesEdges);
|
|
689
|
+
enqueue.assign({
|
|
690
|
+
lastOnNavigate: null
|
|
691
|
+
});
|
|
692
|
+
})
|
|
693
|
+
]
|
|
694
|
+
},
|
|
695
|
+
"update.inputs": {
|
|
696
|
+
actions: assign(({ event }) => ({ ...event.inputs }))
|
|
697
|
+
},
|
|
698
|
+
"update.features": {
|
|
699
|
+
actions: assign({
|
|
700
|
+
features: ({ event }) => event.features
|
|
701
|
+
})
|
|
702
|
+
},
|
|
703
|
+
"update.nodeData": {
|
|
704
|
+
actions: assign(updateNodeData)
|
|
705
|
+
},
|
|
706
|
+
"update.edgeData": {
|
|
707
|
+
actions: assign(updateEdgeData)
|
|
708
|
+
},
|
|
709
|
+
"layout.align": {
|
|
710
|
+
guard: "not readonly",
|
|
711
|
+
actions: [
|
|
712
|
+
{ type: "layout.align", params: ({ event }) => ({ mode: event.mode }) },
|
|
713
|
+
raise({ type: "saveManualLayout.schedule" })
|
|
714
|
+
]
|
|
715
|
+
},
|
|
716
|
+
"layout.resetEdgeControlPoints": {
|
|
717
|
+
guard: "not readonly",
|
|
718
|
+
actions: [
|
|
719
|
+
assign(resetEdgeControlPoints),
|
|
720
|
+
raise({ type: "saveManualLayout.schedule" })
|
|
721
|
+
]
|
|
722
|
+
},
|
|
723
|
+
"xyflow.resized": {
|
|
724
|
+
guard: ({ context }) => context.features.enableFitView && !context.viewportChangedManually,
|
|
725
|
+
actions: [
|
|
726
|
+
cancel("fitDiagram"),
|
|
727
|
+
raise({ type: "fitDiagram" }, { id: "fitDiagram", delay: 200 })
|
|
728
|
+
]
|
|
729
|
+
},
|
|
730
|
+
"open.elementDetails": {
|
|
731
|
+
actions: assign({
|
|
732
|
+
activeElementDetails: ({ event, context }) => {
|
|
733
|
+
var _a;
|
|
734
|
+
return {
|
|
735
|
+
fqn: event.fqn,
|
|
736
|
+
fromNode: event.fromNode ?? ((_a = context.lastClickedNode) == null ? void 0 : _a.id) ?? null,
|
|
737
|
+
fromNodeScreenPosition: null
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
}),
|
|
741
|
+
target: ".overlay.elementDetails"
|
|
742
|
+
},
|
|
743
|
+
"open.relationshipDetails": {
|
|
744
|
+
target: ".overlay.relationshipDetails"
|
|
745
|
+
},
|
|
746
|
+
"open.relationshipsBrowser": {
|
|
747
|
+
target: ".overlay.relationshipsBrowser"
|
|
748
|
+
},
|
|
749
|
+
"open.source": {
|
|
750
|
+
actions: {
|
|
751
|
+
type: "trigger:OpenSource",
|
|
752
|
+
params: prop("event")
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
"walkthrough.start": {
|
|
756
|
+
guard: "is dynamic view",
|
|
757
|
+
target: ".walkthrough"
|
|
758
|
+
}
|
|
759
|
+
},
|
|
760
|
+
exit: [
|
|
761
|
+
stopChild("layout"),
|
|
762
|
+
stopChild("hotkey"),
|
|
763
|
+
assign({
|
|
764
|
+
xyflow: null,
|
|
765
|
+
xystore: null,
|
|
766
|
+
initialized: false,
|
|
767
|
+
syncLayoutActorRef: null
|
|
768
|
+
})
|
|
769
|
+
]
|
|
770
|
+
});
|
|
771
|
+
const nodeRef = (node) => DiagramNode.modelRef(node) ?? DiagramNode.deploymentRef(node);
|
|
772
|
+
function findCorrespondingNode(context, event) {
|
|
773
|
+
var _a;
|
|
774
|
+
const fromNodeId = (_a = context.lastOnNavigate) == null ? void 0 : _a.fromNode;
|
|
775
|
+
const fromNode = fromNodeId && context.view.nodes.find((n) => n.id === fromNodeId);
|
|
776
|
+
const fromRef = fromNode && nodeRef(fromNode);
|
|
777
|
+
const toNode = fromRef && event.view.nodes.find((n) => nodeRef(n) === fromRef);
|
|
778
|
+
return { fromNode, toNode };
|
|
779
|
+
}
|
|
780
|
+
export {
|
|
781
|
+
DiagramContext,
|
|
782
|
+
diagramMachine
|
|
783
|
+
};
|