@likec4/diagram 1.19.2 → 1.20.1
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 -86
- 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 +24 -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 -8
- 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/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 +23 -20
- 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 +125 -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 -18
- 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 -227
- 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 -209
- 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,699 +0,0 @@
|
|
|
1
|
-
import dagre, { type EdgeConfig, type GraphLabel } from '@dagrejs/dagre'
|
|
2
|
-
import {
|
|
3
|
-
compareByFqnHierarchically,
|
|
4
|
-
compareNatural,
|
|
5
|
-
compareRelations,
|
|
6
|
-
type DiagramNode,
|
|
7
|
-
type DiagramView,
|
|
8
|
-
type Fqn,
|
|
9
|
-
invariant,
|
|
10
|
-
isAncestor,
|
|
11
|
-
type LikeC4Model,
|
|
12
|
-
nonNullable,
|
|
13
|
-
parentFqn,
|
|
14
|
-
type RelationId
|
|
15
|
-
} from '@likec4/core'
|
|
16
|
-
import { MarkerType } from '@xyflow/system'
|
|
17
|
-
import { useMemo } from 'react'
|
|
18
|
-
import {
|
|
19
|
-
filter,
|
|
20
|
-
find,
|
|
21
|
-
first,
|
|
22
|
-
flatMap,
|
|
23
|
-
forEach,
|
|
24
|
-
forEachObj,
|
|
25
|
-
groupBy,
|
|
26
|
-
isNonNullish,
|
|
27
|
-
isTruthy,
|
|
28
|
-
map,
|
|
29
|
-
mapToObj,
|
|
30
|
-
only,
|
|
31
|
-
pipe,
|
|
32
|
-
prop,
|
|
33
|
-
reduce,
|
|
34
|
-
reverse,
|
|
35
|
-
sort,
|
|
36
|
-
sortBy,
|
|
37
|
-
takeWhile,
|
|
38
|
-
tap
|
|
39
|
-
} from 'remeda'
|
|
40
|
-
import { useLikeC4Model } from '../../likec4model'
|
|
41
|
-
import type { RelationshipsOfFlowTypes } from './_types'
|
|
42
|
-
|
|
43
|
-
const columns = ['incomers', 'subjects', 'outgoers'] as const
|
|
44
|
-
type ColumnKey = typeof columns[number]
|
|
45
|
-
|
|
46
|
-
// const graphColumn = <C extends 'incomers' | 'subjects' | 'outgoers'>(c: C) => ({
|
|
47
|
-
// name: c,
|
|
48
|
-
// id: `__${c}`,
|
|
49
|
-
// anchor: `__${c}::anchor`
|
|
50
|
-
// })
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* All constants related to the layout
|
|
54
|
-
*/
|
|
55
|
-
const Sizes = {
|
|
56
|
-
dagre: {
|
|
57
|
-
ranksep: 60,
|
|
58
|
-
nodesep: 35,
|
|
59
|
-
edgesep: 25
|
|
60
|
-
} satisfies GraphLabel,
|
|
61
|
-
edgeLabel: {
|
|
62
|
-
width: 120,
|
|
63
|
-
height: 10,
|
|
64
|
-
minlen: 1,
|
|
65
|
-
weight: 1
|
|
66
|
-
} satisfies EdgeConfig,
|
|
67
|
-
|
|
68
|
-
emptyNodeOffset: 120,
|
|
69
|
-
|
|
70
|
-
nodeWidth: 320,
|
|
71
|
-
hodeHeight: 180,
|
|
72
|
-
|
|
73
|
-
// Spacer between elements in a compound node
|
|
74
|
-
// 0 means no spacer
|
|
75
|
-
spacerHeight: 0,
|
|
76
|
-
|
|
77
|
-
compound: {
|
|
78
|
-
labelHeight: 1,
|
|
79
|
-
paddingTop: 50,
|
|
80
|
-
paddingBottom: 32
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const ZIndexes = {
|
|
85
|
-
empty: 2,
|
|
86
|
-
compound: 2,
|
|
87
|
-
edge: 3,
|
|
88
|
-
element: 4,
|
|
89
|
-
|
|
90
|
-
max: 5
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function createGraph() {
|
|
94
|
-
const g = new dagre.graphlib.Graph({
|
|
95
|
-
directed: true,
|
|
96
|
-
compound: true
|
|
97
|
-
})
|
|
98
|
-
g.setGraph({
|
|
99
|
-
...Sizes.dagre,
|
|
100
|
-
rankdir: 'LR'
|
|
101
|
-
})
|
|
102
|
-
g.setDefaultEdgeLabel(() => ({ ...Sizes.edgeLabel }))
|
|
103
|
-
g.setDefaultNodeLabel(() => ({}))
|
|
104
|
-
|
|
105
|
-
// columns.reduce((prev, column) => {
|
|
106
|
-
// const c = graphColumn(column)
|
|
107
|
-
// g.setNode(c.id, {})
|
|
108
|
-
// g.setNode(c.anchor, { width: 40, height: 2 })
|
|
109
|
-
// g.setParent(c.anchor, c.id)
|
|
110
|
-
// if (prev) {
|
|
111
|
-
// g.setEdge(prev, c.anchor, {
|
|
112
|
-
// width: 0
|
|
113
|
-
// })
|
|
114
|
-
// }
|
|
115
|
-
// return c.anchor
|
|
116
|
-
// }, null as string | null)
|
|
117
|
-
|
|
118
|
-
return g
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
type Context = {
|
|
122
|
-
scope: 'global' | 'view'
|
|
123
|
-
g: dagre.graphlib.Graph
|
|
124
|
-
subjectId: Fqn
|
|
125
|
-
diagramNodes: Map<Fqn, DiagramNode>
|
|
126
|
-
subjectElement: LikeC4Model.Element
|
|
127
|
-
// likec4model: LikeC4Model
|
|
128
|
-
// subject: XYFlowTypes.ElementNode
|
|
129
|
-
// Model
|
|
130
|
-
// subject: LikeC4ModelElement
|
|
131
|
-
connected: {
|
|
132
|
-
incomers: Set<Fqn>
|
|
133
|
-
subjects: Set<Fqn>
|
|
134
|
-
outgoers: Set<Fqn>
|
|
135
|
-
}
|
|
136
|
-
columns: {
|
|
137
|
-
incomers: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
138
|
-
subjects: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
139
|
-
outgoers: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
140
|
-
}
|
|
141
|
-
edges: RelationshipsOfFlowTypes.Edge[]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const sized = (height: number = Sizes.hodeHeight) => ({
|
|
145
|
-
width: Sizes.nodeWidth,
|
|
146
|
-
height
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
const graphId = (node: RelationshipsOfFlowTypes.Node) => ({
|
|
150
|
-
id: node.id,
|
|
151
|
-
port: node.type === 'compound' ? `${node.id}::port` : node.id,
|
|
152
|
-
body: `${node.id}`,
|
|
153
|
-
spacer: `${node.id}:spacer`
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
function nodeData(
|
|
157
|
-
element: LikeC4Model.Element,
|
|
158
|
-
ctx: Context
|
|
159
|
-
): Omit<RelationshipsOfFlowTypes.NonEmptyNode['data'], 'column'> {
|
|
160
|
-
// We try to inherit style from existing diagram node
|
|
161
|
-
let diagramNode = ctx.diagramNodes.get(element.id)
|
|
162
|
-
|
|
163
|
-
// Ansector separetely, because we want to inherit
|
|
164
|
-
// color from it if there is no diagram node
|
|
165
|
-
const ancestor = diagramNode ?? (ctx.scope === 'view'
|
|
166
|
-
? pipe(
|
|
167
|
-
element.ancestors().toArray(),
|
|
168
|
-
map(ancestor => ctx.diagramNodes.get(ancestor.id)),
|
|
169
|
-
filter(isTruthy),
|
|
170
|
-
first()
|
|
171
|
-
)
|
|
172
|
-
: undefined)
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
fqn: element.id,
|
|
176
|
-
existsInCurrentView: ctx.diagramNodes.has(element.id),
|
|
177
|
-
element: {
|
|
178
|
-
kind: element.kind,
|
|
179
|
-
title: diagramNode?.title ?? element.title,
|
|
180
|
-
description: diagramNode?.description ?? element.description,
|
|
181
|
-
color: diagramNode?.color ?? ancestor?.color ?? element.color,
|
|
182
|
-
shape: diagramNode?.shape ?? element.shape
|
|
183
|
-
},
|
|
184
|
-
navigateTo: diagramNode?.navigateTo ?? element.defaultView?.id ?? null,
|
|
185
|
-
ports: {
|
|
186
|
-
in: [],
|
|
187
|
-
out: []
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function createEmptyNode(
|
|
193
|
-
column: ColumnKey,
|
|
194
|
-
ctx: Context
|
|
195
|
-
): RelationshipsOfFlowTypes.EmptyNode {
|
|
196
|
-
const id = `${column}__empty` as Fqn
|
|
197
|
-
const xynodes = ctx.columns[column]
|
|
198
|
-
let node = xynodes.get(id)
|
|
199
|
-
if (node) {
|
|
200
|
-
invariant(node.type === 'empty', 'Node is not empty')
|
|
201
|
-
return node
|
|
202
|
-
}
|
|
203
|
-
const xynode: RelationshipsOfFlowTypes.EmptyNode = {
|
|
204
|
-
type: 'empty',
|
|
205
|
-
id,
|
|
206
|
-
position: { x: 0, y: 0 },
|
|
207
|
-
data: {
|
|
208
|
-
column,
|
|
209
|
-
existsInCurrentView: true
|
|
210
|
-
},
|
|
211
|
-
zIndex: ZIndexes.empty
|
|
212
|
-
}
|
|
213
|
-
xynodes.set(id, xynode)
|
|
214
|
-
const k = graphId(xynode)
|
|
215
|
-
|
|
216
|
-
const emptyContainer = id + '__container'
|
|
217
|
-
ctx.g.setNode(emptyContainer, {})
|
|
218
|
-
ctx.g.setNode(k.id, {
|
|
219
|
-
width: Sizes.nodeWidth - 20,
|
|
220
|
-
height: Sizes.hodeHeight
|
|
221
|
-
})
|
|
222
|
-
ctx.g.setParent(k.id, emptyContainer)
|
|
223
|
-
return xynode
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function createNode(
|
|
227
|
-
column: ColumnKey,
|
|
228
|
-
nodeType: Exclude<RelationshipsOfFlowTypes.Node['type'], 'empty'>,
|
|
229
|
-
element: LikeC4Model.Element,
|
|
230
|
-
ctx: Context,
|
|
231
|
-
depth: number = 0
|
|
232
|
-
): RelationshipsOfFlowTypes.ElementNode | RelationshipsOfFlowTypes.CompoundNode {
|
|
233
|
-
const xynodes = ctx.columns[column]
|
|
234
|
-
let node = xynodes.get(element.id)
|
|
235
|
-
if (node) {
|
|
236
|
-
invariant(node.type !== 'empty', `Unexpected empty Node type ${element.id}: ${node.type}, expect ${nodeType}`)
|
|
237
|
-
if (node.type === 'element' && nodeType === 'compound') {
|
|
238
|
-
throw new Error(`Unexpected Node type ${element.id}: ${node.type}, expect ${nodeType}`)
|
|
239
|
-
}
|
|
240
|
-
return node
|
|
241
|
-
}
|
|
242
|
-
const g = ctx.g
|
|
243
|
-
|
|
244
|
-
// Create parent node
|
|
245
|
-
const parent = pipe(
|
|
246
|
-
element.ancestors().toArray(),
|
|
247
|
-
takeWhile(ancestor => !isAncestor(ancestor.id, ctx.subjectId)),
|
|
248
|
-
find(ancestor =>
|
|
249
|
-
ctx.diagramNodes.has(ancestor.id) || ctx.connected[column].has(ancestor.id)
|
|
250
|
-
|| (ctx.scope === 'global' && ctx.subjectElement.ascendingSiblings().some(s => s.id === ancestor.id))
|
|
251
|
-
),
|
|
252
|
-
found => found ? createNode(column, 'compound', found, ctx, depth + 2) : null
|
|
253
|
-
)
|
|
254
|
-
|
|
255
|
-
const xynode: RelationshipsOfFlowTypes.NonEmptyNode = {
|
|
256
|
-
type: nodeType,
|
|
257
|
-
id: `${column}::${element.id}`,
|
|
258
|
-
position: { x: 0, y: 0 },
|
|
259
|
-
data: {
|
|
260
|
-
...nodeData(element, ctx),
|
|
261
|
-
column
|
|
262
|
-
},
|
|
263
|
-
zIndex: ZIndexes[nodeType],
|
|
264
|
-
...(!!parent && { parentId: parent.id })
|
|
265
|
-
}
|
|
266
|
-
xynodes.set(element.id, xynode)
|
|
267
|
-
// There is one-to-one mapping between XYFlow node and dagre node
|
|
268
|
-
// Compound node has two nodes: body and port (for edges)
|
|
269
|
-
|
|
270
|
-
const k = graphId(xynode)
|
|
271
|
-
|
|
272
|
-
g.setNode(k.id, sized())
|
|
273
|
-
if (xynode.type === 'compound') {
|
|
274
|
-
g.setNode(k.port, {
|
|
275
|
-
width: Sizes.nodeWidth - Sizes.dagre.ranksep,
|
|
276
|
-
height: Sizes.compound.labelHeight
|
|
277
|
-
})
|
|
278
|
-
g.setParent(k.port, k.id)
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if (parent) {
|
|
282
|
-
parent.data.depth = Math.min(Math.max(parent.data.depth ?? 0, depth + 1), 6)
|
|
283
|
-
g.setParent(k.id, graphId(parent).body)
|
|
284
|
-
}
|
|
285
|
-
return xynode
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Apply dagre layout to the graph
|
|
290
|
-
* And return a function to get node bounds for xyflow
|
|
291
|
-
*/
|
|
292
|
-
function applyDagreLayout(g: dagre.graphlib.Graph) {
|
|
293
|
-
type NodeBounds = Required<Pick<RelationshipsOfFlowTypes.Node, 'position' | 'width' | 'height'>>
|
|
294
|
-
dagre.layout(g)
|
|
295
|
-
return function nodeBounds(nodeId: string): NodeBounds {
|
|
296
|
-
const { x, y, width, height } = g.node(nodeId)
|
|
297
|
-
return {
|
|
298
|
-
position: {
|
|
299
|
-
x: x - Math.round(width / 2),
|
|
300
|
-
y: y - Math.round(height / 2)
|
|
301
|
-
},
|
|
302
|
-
width,
|
|
303
|
-
height
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function addEdge(
|
|
309
|
-
ctx: Context,
|
|
310
|
-
props: {
|
|
311
|
-
existsInCurrentView: boolean
|
|
312
|
-
source: string
|
|
313
|
-
target: string
|
|
314
|
-
relations: RelationshipsOfFlowTypes.Edge['data']['relations']
|
|
315
|
-
}
|
|
316
|
-
) {
|
|
317
|
-
const { source, target, relations, existsInCurrentView } = props
|
|
318
|
-
const ids = relations.map(r => r.id).join('_')
|
|
319
|
-
const label = only(relations)?.title ?? 'untitled'
|
|
320
|
-
|
|
321
|
-
const isMultiple = relations.length > 1
|
|
322
|
-
const edge: RelationshipsOfFlowTypes.Edge = {
|
|
323
|
-
id: `rel${ctx.edges.length + 1}_${ids}`,
|
|
324
|
-
type: 'relation',
|
|
325
|
-
source,
|
|
326
|
-
target,
|
|
327
|
-
sourceHandle: target,
|
|
328
|
-
targetHandle: source,
|
|
329
|
-
data: {
|
|
330
|
-
existsInCurrentView: existsInCurrentView,
|
|
331
|
-
relations
|
|
332
|
-
},
|
|
333
|
-
label: isMultiple ? `${relations.length} relationships` : label,
|
|
334
|
-
zIndex: ZIndexes.edge,
|
|
335
|
-
markerEnd: {
|
|
336
|
-
type: MarkerType.ArrowClosed,
|
|
337
|
-
width: isMultiple ? 7 : 9
|
|
338
|
-
},
|
|
339
|
-
style: {
|
|
340
|
-
strokeWidth: isMultiple ? 5 : 2.8,
|
|
341
|
-
strokeDasharray: isMultiple ? undefined : '5, 5'
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
ctx.edges.push(edge)
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function findNodeOrFirstAncestor<N>(fqn: Fqn, nodes: Map<Fqn, N>) {
|
|
348
|
-
let node = nodes.get(fqn)
|
|
349
|
-
let parent: Fqn | null = fqn
|
|
350
|
-
while (!node && !!(parent = parentFqn(parent))) {
|
|
351
|
-
node = nodes.get(parent)
|
|
352
|
-
}
|
|
353
|
-
return node
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function layout(
|
|
357
|
-
subjectId: Fqn,
|
|
358
|
-
view: DiagramView,
|
|
359
|
-
likec4model: LikeC4Model,
|
|
360
|
-
scope: 'global' | 'view'
|
|
361
|
-
): {
|
|
362
|
-
viewIncludesSubject: boolean
|
|
363
|
-
notIncludedRelations: number
|
|
364
|
-
subject: LikeC4Model.Element
|
|
365
|
-
nodes: RelationshipsOfFlowTypes.Node[]
|
|
366
|
-
edges: RelationshipsOfFlowTypes.Edge[]
|
|
367
|
-
bounds: {
|
|
368
|
-
x: number
|
|
369
|
-
y: number
|
|
370
|
-
width: number
|
|
371
|
-
height: number
|
|
372
|
-
}
|
|
373
|
-
} {
|
|
374
|
-
const diagramNodes = new Map(view.nodes.map(n => [n.id, n]))
|
|
375
|
-
const subjectElement = likec4model.element(subjectId)
|
|
376
|
-
|
|
377
|
-
const viewIncludesSubject = diagramNodes.has(subjectId)
|
|
378
|
-
|
|
379
|
-
const viewRelationships = new Set(
|
|
380
|
-
view.edges.flatMap(e => e.relations)
|
|
381
|
-
)
|
|
382
|
-
// Relations that are not included in the view
|
|
383
|
-
const notIncludedRelations = new Set<RelationId>()
|
|
384
|
-
|
|
385
|
-
if (!viewIncludesSubject) {
|
|
386
|
-
// Reset scope to global if subject is not in the view
|
|
387
|
-
scope = 'global'
|
|
388
|
-
} else {
|
|
389
|
-
forEach([
|
|
390
|
-
...subjectElement.incoming().map(r => r.id),
|
|
391
|
-
...subjectElement.outgoing().map(r => r.id)
|
|
392
|
-
], (relationId) => {
|
|
393
|
-
if (!viewRelationships.has(relationId)) {
|
|
394
|
-
notIncludedRelations.add(relationId)
|
|
395
|
-
}
|
|
396
|
-
})
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
let relationships
|
|
400
|
-
|
|
401
|
-
if (scope === 'global') {
|
|
402
|
-
relationships = {
|
|
403
|
-
incoming: subjectElement.incoming().map(r => r.$relationship).toArray(),
|
|
404
|
-
outgoing: subjectElement.outgoing().map(r => r.$relationship).toArray()
|
|
405
|
-
}
|
|
406
|
-
} else {
|
|
407
|
-
const subjectViewModel = likec4model.view(view.id).node(subjectId)
|
|
408
|
-
relationships = {
|
|
409
|
-
incoming: subjectViewModel.incoming()
|
|
410
|
-
.flatMap(c => c.relationships('model').map(r => r.$relationship))
|
|
411
|
-
.toArray(),
|
|
412
|
-
outgoing: subjectViewModel.outgoing()
|
|
413
|
-
.flatMap(c => c.relationships('model').map(r => r.$relationship))
|
|
414
|
-
.toArray()
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
const g = createGraph()
|
|
419
|
-
|
|
420
|
-
const ctx: Context = {
|
|
421
|
-
scope,
|
|
422
|
-
g,
|
|
423
|
-
diagramNodes,
|
|
424
|
-
subjectElement,
|
|
425
|
-
subjectId,
|
|
426
|
-
connected: {
|
|
427
|
-
incomers: new Set<Fqn>(),
|
|
428
|
-
outgoers: new Set<Fqn>(),
|
|
429
|
-
subjects: new Set<Fqn>([subjectId])
|
|
430
|
-
},
|
|
431
|
-
columns: {
|
|
432
|
-
incomers: new Map(),
|
|
433
|
-
subjects: new Map(),
|
|
434
|
-
outgoers: new Map()
|
|
435
|
-
},
|
|
436
|
-
edges: []
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
relationships.incoming.forEach(incoming => {
|
|
440
|
-
ctx.connected.incomers.add(incoming.source)
|
|
441
|
-
ctx.connected.subjects.add(incoming.target)
|
|
442
|
-
})
|
|
443
|
-
relationships.outgoing.forEach(outgoing => {
|
|
444
|
-
ctx.connected.subjects.add(outgoing.source)
|
|
445
|
-
ctx.connected.outgoers.add(outgoing.target)
|
|
446
|
-
})
|
|
447
|
-
|
|
448
|
-
if (viewIncludesSubject) {
|
|
449
|
-
const subjectViewModel = likec4model.view(view.id).node(subjectId)
|
|
450
|
-
subjectViewModel.incomers().forEach(incomer => {
|
|
451
|
-
ctx.connected.incomers.add(incomer.id)
|
|
452
|
-
})
|
|
453
|
-
subjectViewModel.outgoers().forEach(outgoer => {
|
|
454
|
-
ctx.connected.outgoers.add(outgoer.id)
|
|
455
|
-
})
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
// Created nodes per column
|
|
459
|
-
columns.forEach(column => {
|
|
460
|
-
pipe(
|
|
461
|
-
[...ctx.connected[column].values()],
|
|
462
|
-
map(id => likec4model.element(id)),
|
|
463
|
-
sort((a, b) => -1 * compareNatural(a.title, b.title)),
|
|
464
|
-
sort(compareByFqnHierarchically),
|
|
465
|
-
reverse(),
|
|
466
|
-
forEach(element => {
|
|
467
|
-
createNode(column, 'element', element, ctx)
|
|
468
|
-
})
|
|
469
|
-
)
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
pipe(
|
|
473
|
-
[
|
|
474
|
-
// Process incoming
|
|
475
|
-
{
|
|
476
|
-
sources: ctx.columns.incomers,
|
|
477
|
-
targets: ctx.columns.subjects,
|
|
478
|
-
relationships: relationships.incoming.sort(compareRelations).reverse()
|
|
479
|
-
},
|
|
480
|
-
// Process outgoing
|
|
481
|
-
{
|
|
482
|
-
sources: ctx.columns.subjects,
|
|
483
|
-
targets: ctx.columns.outgoers,
|
|
484
|
-
relationships: relationships.outgoing.sort(compareRelations).reverse()
|
|
485
|
-
}
|
|
486
|
-
],
|
|
487
|
-
/**
|
|
488
|
-
* We select relationships, sources and targets
|
|
489
|
-
* If sourece or target of the relationship is not found - take first ancestor
|
|
490
|
-
*/
|
|
491
|
-
flatMap(({ sources, targets, relationships }) => {
|
|
492
|
-
return relationships.map(relation => {
|
|
493
|
-
const source = findNodeOrFirstAncestor(relation.source, sources)
|
|
494
|
-
if (!source || source.type === 'empty') {
|
|
495
|
-
return null
|
|
496
|
-
}
|
|
497
|
-
const target = findNodeOrFirstAncestor(relation.target, targets)
|
|
498
|
-
if (!target || target.type === 'empty') {
|
|
499
|
-
return null
|
|
500
|
-
}
|
|
501
|
-
return ({
|
|
502
|
-
relation,
|
|
503
|
-
source,
|
|
504
|
-
target,
|
|
505
|
-
existsInCurrentView: viewRelationships.has(relation.id),
|
|
506
|
-
id: `${source.id}:${target.id}`
|
|
507
|
-
})
|
|
508
|
-
})
|
|
509
|
-
}),
|
|
510
|
-
filter(isNonNullish),
|
|
511
|
-
// Group relations with saame source and target - make them one edge
|
|
512
|
-
groupBy(prop('id')),
|
|
513
|
-
forEachObj((grouped) => {
|
|
514
|
-
const { source, target } = grouped[0]
|
|
515
|
-
const relations = map(grouped, g => g.relation)
|
|
516
|
-
|
|
517
|
-
source.data.ports.out.push(target.id)
|
|
518
|
-
target.data.ports.in.push(source.id)
|
|
519
|
-
|
|
520
|
-
const isAnyCompound = source.type === 'compound' || target.type === 'compound'
|
|
521
|
-
|
|
522
|
-
g.setEdge(graphId(source).port, graphId(target).port, {
|
|
523
|
-
...Sizes.edgeLabel
|
|
524
|
-
// weight: isAnyCompound ? 1 : 2
|
|
525
|
-
})
|
|
526
|
-
|
|
527
|
-
addEdge(ctx, {
|
|
528
|
-
// if view does not include subject - do not highlight
|
|
529
|
-
existsInCurrentView: !viewIncludesSubject || grouped.every(g => g.existsInCurrentView),
|
|
530
|
-
source: source.id,
|
|
531
|
-
target: target.id,
|
|
532
|
-
relations
|
|
533
|
-
})
|
|
534
|
-
})
|
|
535
|
-
)
|
|
536
|
-
|
|
537
|
-
// Create empty nodes if there are no incomers or outgoers
|
|
538
|
-
const subjectPort = graphId(ctx.columns.subjects.get(subjectId)!).port
|
|
539
|
-
|
|
540
|
-
if (ctx.columns.incomers.size == 0) {
|
|
541
|
-
const source = createEmptyNode('incomers', ctx)
|
|
542
|
-
g.setEdge(graphId(source).port, subjectPort)
|
|
543
|
-
}
|
|
544
|
-
if (ctx.columns.outgoers.size == 0) {
|
|
545
|
-
const target = createEmptyNode('outgoers', ctx)
|
|
546
|
-
g.setEdge(subjectPort, graphId(target).port)
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// Grow nodes with more than 2 ports
|
|
550
|
-
for (const subject of ctx.columns.subjects.values()) {
|
|
551
|
-
if (subject.type !== 'element') {
|
|
552
|
-
continue
|
|
553
|
-
}
|
|
554
|
-
const subjectPortsCount = Math.max(subject.data.ports.in.length, subject.data.ports.out.length)
|
|
555
|
-
if (subjectPortsCount > 2) {
|
|
556
|
-
g.node(subject.id).height = Sizes.hodeHeight + (subjectPortsCount - 3) * 14
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
//
|
|
561
|
-
const dagreBounds = applyDagreLayout(ctx.g)
|
|
562
|
-
|
|
563
|
-
const xynodes = [
|
|
564
|
-
...ctx.columns.incomers.values(),
|
|
565
|
-
...ctx.columns.subjects.values(),
|
|
566
|
-
...ctx.columns.outgoers.values()
|
|
567
|
-
]
|
|
568
|
-
|
|
569
|
-
// Calculate bounds for all nodes except compounds
|
|
570
|
-
// We shrink compounds to fit their children
|
|
571
|
-
const _calculatedNodeBounds = pipe(
|
|
572
|
-
xynodes,
|
|
573
|
-
filter(n => n.type !== 'compound'),
|
|
574
|
-
mapToObj(n => [n.id, dagreBounds(n.id)])
|
|
575
|
-
)
|
|
576
|
-
|
|
577
|
-
function nodeBounds(nodeId: string): ReturnType<typeof dagreBounds> {
|
|
578
|
-
return _calculatedNodeBounds[nodeId] ??= pipe(
|
|
579
|
-
xynodes,
|
|
580
|
-
filter(n => n.parentId === nodeId),
|
|
581
|
-
map(n => nodeBounds(n.id)),
|
|
582
|
-
tap(bounds => {
|
|
583
|
-
invariant(bounds.length > 0, `Node ${nodeId} has no nested nodes`)
|
|
584
|
-
}),
|
|
585
|
-
reduce((acc, bounds) => {
|
|
586
|
-
return {
|
|
587
|
-
minY: Math.min(acc.minY, bounds.position.y),
|
|
588
|
-
maxY: Math.max(acc.maxY, bounds.position.y + bounds.height)
|
|
589
|
-
}
|
|
590
|
-
}, { minY: Infinity, maxY: -Infinity }),
|
|
591
|
-
({ minY, maxY }) => {
|
|
592
|
-
const {
|
|
593
|
-
position: { x },
|
|
594
|
-
width
|
|
595
|
-
} = dagreBounds(nodeId)
|
|
596
|
-
minY = minY - Sizes.compound.paddingTop
|
|
597
|
-
maxY = maxY + Sizes.compound.paddingBottom
|
|
598
|
-
|
|
599
|
-
return {
|
|
600
|
-
position: {
|
|
601
|
-
x,
|
|
602
|
-
y: minY
|
|
603
|
-
},
|
|
604
|
-
width,
|
|
605
|
-
height: maxY - minY
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
)
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// update xynodes
|
|
612
|
-
for (const node of xynodes) {
|
|
613
|
-
const { position, width, height } = nodeBounds(node.id)
|
|
614
|
-
node.width = width
|
|
615
|
-
node.height = height
|
|
616
|
-
node.position = position
|
|
617
|
-
if (node.parentId) {
|
|
618
|
-
const parentPos = nodeBounds(node.parentId).position
|
|
619
|
-
node.position = {
|
|
620
|
-
x: position.x - parentPos.x,
|
|
621
|
-
y: position.y - parentPos.y
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// Sort ports in subject vertically
|
|
627
|
-
const sortedPorts = (ports: string[]) => {
|
|
628
|
-
return pipe(
|
|
629
|
-
ports,
|
|
630
|
-
map(port => {
|
|
631
|
-
return {
|
|
632
|
-
port,
|
|
633
|
-
topY: nodeBounds(port).position.y
|
|
634
|
-
}
|
|
635
|
-
}),
|
|
636
|
-
sortBy(prop('topY')),
|
|
637
|
-
map(prop('port'))
|
|
638
|
-
)
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
for (const node of xynodes) {
|
|
642
|
-
// Grow empty nodes to fill the space
|
|
643
|
-
if (node.type === 'empty') {
|
|
644
|
-
const subjectBounds = nodeBounds(nonNullable(ctx.columns.subjects.get(subjectId), 'Subject node is missing').id)
|
|
645
|
-
node.height = Math.min(subjectBounds.height, 300)
|
|
646
|
-
node.position.y = subjectBounds.position.y + subjectBounds.height / 2 - node.height / 2
|
|
647
|
-
if (node.data.column === 'incomers') {
|
|
648
|
-
node.width = subjectBounds.position.x - Sizes.emptyNodeOffset - node.position.x
|
|
649
|
-
} else {
|
|
650
|
-
const rightX = node.position.x + node.width!
|
|
651
|
-
node.position.x = subjectBounds.position.x + subjectBounds.width + Sizes.emptyNodeOffset
|
|
652
|
-
node.width = rightX - node.position.x
|
|
653
|
-
}
|
|
654
|
-
continue
|
|
655
|
-
}
|
|
656
|
-
// Sort ports by their position
|
|
657
|
-
if (node.data.ports.in.length > 1) {
|
|
658
|
-
node.data.ports.in = sortedPorts(node.data.ports.in)
|
|
659
|
-
}
|
|
660
|
-
if (node.data.ports.out.length > 1) {
|
|
661
|
-
node.data.ports.out = sortedPorts(node.data.ports.out)
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
return {
|
|
666
|
-
viewIncludesSubject,
|
|
667
|
-
notIncludedRelations: notIncludedRelations.size,
|
|
668
|
-
subject: subjectElement,
|
|
669
|
-
edges: ctx.edges,
|
|
670
|
-
nodes: xynodes,
|
|
671
|
-
bounds: {
|
|
672
|
-
x: 0,
|
|
673
|
-
y: 0,
|
|
674
|
-
width: g.graph().width ?? 100,
|
|
675
|
-
height: g.graph().height ?? 100
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
export function useLayoutedRelationships(
|
|
681
|
-
subjectId: Fqn,
|
|
682
|
-
view: DiagramView,
|
|
683
|
-
scope: 'global' | 'view'
|
|
684
|
-
) {
|
|
685
|
-
const likec4model = useLikeC4Model(true)
|
|
686
|
-
return useMemo(() =>
|
|
687
|
-
layout(
|
|
688
|
-
subjectId,
|
|
689
|
-
view,
|
|
690
|
-
likec4model,
|
|
691
|
-
scope
|
|
692
|
-
), [
|
|
693
|
-
subjectId,
|
|
694
|
-
view,
|
|
695
|
-
likec4model,
|
|
696
|
-
layout,
|
|
697
|
-
scope
|
|
698
|
-
])
|
|
699
|
-
}
|