@likec4/diagram 1.17.1 → 1.19.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/LICENSE +1 -1
- package/dist/LikeC4CustomColors.d.ts +7 -0
- package/dist/LikeC4CustomColors.js +30 -0
- package/dist/LikeC4Diagram.css.d.ts +5 -0
- package/dist/LikeC4Diagram.css.js +13 -0
- package/dist/LikeC4Diagram.d.ts +6 -0
- package/dist/LikeC4Diagram.js +194 -0
- package/dist/LikeC4Diagram.props.d.ts +166 -0
- package/dist/LikeC4ModelProvider.d.ts +9 -0
- package/dist/LikeC4ModelProvider.js +12 -0
- package/dist/LikeC4Search.css.d.ts +1 -0
- package/dist/LikeC4Search.css.js +5 -0
- package/dist/LikeC4Search.d.ts +2 -0
- package/dist/LikeC4Search.js +96 -0
- package/dist/StaticLikeC4Diagram.d.ts +3 -0
- package/dist/StaticLikeC4Diagram.js +41 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/controls/Text.d.ts +2 -0
- package/dist/controls/Text.js +7 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
- package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
- package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
- package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
- package/dist/controls/action-buttons/ActionButton.css.js +5 -0
- package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
- package/dist/controls/action-buttons/ActionButton.js +66 -0
- package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
- package/dist/controls/action-buttons/ActionButtons.js +99 -0
- package/dist/globals.css.d.ts +1 -0
- package/dist/globals.css.js +92 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useDiagramState.d.ts +6 -0
- package/dist/hooks/useDiagramState.js +27 -0
- package/dist/hooks/useMantinePortalProps.d.ts +9 -0
- package/dist/hooks/useMantinePortalProps.js +9 -0
- package/dist/hooks/useSetState.d.ts +2 -0
- package/dist/hooks/useSetState.js +19 -0
- package/dist/hooks/useUpdateEffect.d.ts +4 -0
- package/dist/hooks/useUpdateEffect.js +32 -0
- package/dist/hooks/useXYFlow.d.ts +270 -0
- package/dist/hooks/useXYFlow.js +20 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25 -0
- package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
- package/dist/likec4model/LikeC4ModelContext.js +5 -0
- package/dist/likec4model/index.d.ts +2 -0
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
- package/dist/likec4model/useLikeC4Model.d.ts +20 -0
- package/dist/likec4model/useLikeC4Model.js +55 -0
- package/dist/overlays/OverlayContext.d.ts +10 -0
- package/dist/overlays/OverlayContext.js +9 -0
- package/dist/overlays/Overlays.css.d.ts +3 -0
- package/dist/overlays/Overlays.css.js +7 -0
- package/dist/overlays/Overlays.d.ts +2 -0
- package/dist/overlays/Overlays.js +137 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
- package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
- package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
- package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
- package/dist/overlays/edge-details/SelectEdge.js +129 -0
- package/dist/overlays/edge-details/_types.d.ts +14 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
- package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
- package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
- package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
- package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
- package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
- package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
- package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
- package/dist/overlays/element-details/TabPanelStructure.js +91 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
- package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
- package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
- package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
- package/dist/overlays/relationships-of/SelectElement.js +126 -0
- package/dist/overlays/relationships-of/_types.d.ts +28 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
- package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
- package/dist/state/DiagramContext.d.ts +1609 -0
- package/dist/state/DiagramContext.js +101 -0
- package/dist/state/aligners.d.ts +42 -0
- package/dist/state/aligners.js +349 -0
- package/dist/state/diagram-to-xyflow.d.ts +11 -0
- package/dist/state/diagram-to-xyflow.js +113 -0
- package/dist/state/diagramStore.d.ts +1705 -0
- package/dist/state/diagramStore.js +808 -0
- package/dist/state/diagramStore.layout.d.ts +4 -0
- package/dist/state/diagramStore.layout.js +56 -0
- package/dist/style.css +1 -0
- package/dist/theme-vars.css.d.ts +72 -0
- package/dist/theme-vars.css.js +6 -0
- package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
- package/dist/theme-vars.d.ts +3 -0
- package/dist/theme-vars.js +5 -0
- package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
- package/dist/ui/DiagramTitlePanel.css.js +11 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.js +159 -0
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
- package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/DynamicViewWalkthrough.js +156 -0
- package/dist/ui/EnsureMantine.d.ts +7 -0
- package/dist/ui/EnsureMantine.js +14 -0
- package/dist/ui/FramerMotionConfig.d.ts +2 -0
- package/dist/ui/FramerMotionConfig.js +14 -0
- package/dist/ui/Link.d.ts +4 -0
- package/dist/ui/Link.js +36 -0
- package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
- package/dist/ui/notation/NotationPanel.css.js +16 -0
- package/dist/ui/notation/NotationPanel.d.ts +1 -0
- package/dist/ui/notation/NotationPanel.js +250 -0
- package/dist/ui/notation/index.d.ts +1 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
- package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
- package/dist/ui/top-left/TopLeftPanel.js +211 -0
- package/dist/ui/top-left/_shared.d.ts +7 -0
- package/dist/ui/top-left/_shared.js +22 -0
- package/dist/ui/top-left/styles.css.d.ts +8 -0
- package/dist/ui/top-left/styles.css.js +17 -0
- package/dist/utils/types.d.ts +8 -0
- package/dist/utils/vector.d.ts +24 -0
- package/dist/utils/vector.js +55 -0
- package/dist/xyflow/EdgeMarkers.d.ts +12 -0
- package/dist/xyflow/EdgeMarkers.js +192 -0
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
- package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
- package/dist/xyflow/XYFlow.d.ts +8 -0
- package/dist/xyflow/XYFlow.js +145 -0
- package/dist/xyflow/XYFlowBackground.d.ts +10 -0
- package/dist/xyflow/XYFlowBackground.js +25 -0
- package/dist/xyflow/XYFlowInner.d.ts +8 -0
- package/dist/xyflow/XYFlowInner.js +41 -0
- package/dist/xyflow/const.d.ts +7 -0
- package/dist/xyflow/const.js +12 -0
- package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
- package/dist/xyflow/edges/EdgeLabel.js +160 -0
- package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
- package/dist/xyflow/edges/RelationshipEdge.js +443 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
- package/dist/xyflow/edges/edges.css.d.ts +17 -0
- package/dist/xyflow/edges/edges.css.js +37 -0
- package/dist/xyflow/edges/utils.d.ts +16 -0
- package/dist/xyflow/edges/utils.js +24 -0
- package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
- package/dist/xyflow/nodes/AnimateVariants.js +123 -0
- package/dist/xyflow/nodes/Node.css.d.ts +3 -0
- package/dist/xyflow/nodes/Node.css.js +9 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
- package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
- package/dist/xyflow/nodes/compound/index.d.ts +1 -0
- package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
- package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.js +190 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
- package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
- package/dist/xyflow/nodes/element/element.css.js +31 -0
- package/dist/xyflow/nodes/element/index.d.ts +1 -0
- package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
- package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
- package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
- package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
- package/dist/xyflow/types.d.ts +36 -0
- package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
- package/dist/xyflow/useLayoutConstraints.js +226 -0
- package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
- package/dist/xyflow/useXYFlowEvents.js +275 -0
- package/dist/xyflow/utils.d.ts +22 -0
- package/dist/xyflow/utils.js +72 -0
- package/package.json +40 -31
- package/src/LikeC4Diagram.props.ts +21 -12
- package/src/LikeC4Diagram.tsx +8 -10
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +45 -93
- package/src/controls/Text.ts +5 -0
- package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
- package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
- package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
- package/src/controls/action-buttons/ActionButton.css.ts +29 -0
- package/src/controls/action-buttons/ActionButton.tsx +66 -0
- package/src/controls/action-buttons/ActionButtons.tsx +138 -0
- package/src/hooks/useDiagramState.ts +8 -3
- package/src/hooks/useXYFlow.ts +9 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/likec4model/useLikeC4ElementsTree.ts +6 -13
- package/src/likec4model/useLikeC4Model.ts +21 -11
- package/src/overlays/Overlays.tsx +96 -63
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -10
- package/src/overlays/edge-details/_types.ts +13 -33
- package/src/overlays/edge-details/use-layouted-edge-details.ts +35 -26
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +8 -13
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +7 -7
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/element-details/ElementDetailsCard.tsx +91 -78
- package/src/overlays/element-details/TabPanelDeployments.css.ts +69 -0
- package/src/overlays/element-details/TabPanelDeployments.tsx +217 -0
- package/src/overlays/element-details/TabPanelRelationships.tsx +8 -9
- package/src/overlays/element-details/TabPanelStructure.tsx +10 -10
- package/src/overlays/relationships-of/RelationshipsOverlay.tsx +1 -1
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +26 -34
- package/src/overlays/relationships-of/SelectElement.tsx +2 -2
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +54 -59
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +10 -16
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +24 -21
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -15
- package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
- package/src/overlays/shared/xyflow/_types.ts +87 -0
- package/src/state/diagram-to-xyflow.ts +6 -7
- package/src/state/diagramStore.layout.ts +3 -4
- package/src/state/diagramStore.ts +63 -48
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +7 -34
- package/src/ui/Link.tsx +40 -0
- package/src/ui/notation/NotationPanel.tsx +4 -2
- package/src/ui/top-left/ChangeAutoLayoutButton.tsx +2 -2
- package/src/ui/top-left/TopLeftPanel.tsx +5 -5
- package/src/utils/types.ts +6 -0
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
- package/src/xyflow/XYFlow.tsx +2 -2
- package/src/xyflow/edges/EdgeLabel.tsx +26 -19
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +23 -10
- package/src/xyflow/edges/edges.css.ts +68 -74
- package/src/xyflow/edges/utils.ts +6 -6
- package/src/xyflow/nodes/AnimateVariants.ts +143 -0
- package/src/xyflow/nodes/Node.css.ts +44 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +27 -75
- package/src/xyflow/nodes/compound/CompoundNode.tsx +82 -163
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +73 -252
- package/src/xyflow/nodes/element/element.css.ts +40 -64
- package/src/xyflow/nodes/shared/ElementIcon.tsx +1 -1
- package/src/xyflow/nodes/shared/Toolbar.tsx +51 -35
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +10 -10
- package/src/xyflow/useXYFlowEvents.ts +31 -35
- package/src/xyflow/utils.ts +2 -2
- package/src/ui/OptionsPanel.css.ts +0 -9
- package/src/ui/OptionsPanel.tsx +0 -70
- package/src/ui/options/EdgeOptions.tsx +0 -142
- package/src/ui/options/NodeOptions.tsx +0 -362
- package/src/xyflow/nodes/element/ElementDetails.css.ts +0 -101
- package/src/xyflow/nodes/element/ElementDetails.tsx +0 -393
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -7,27 +7,27 @@ import * as css from './TabPanelStructure.css'
|
|
|
7
7
|
interface ElementTreeNodeData {
|
|
8
8
|
label: ReactNode
|
|
9
9
|
value: string
|
|
10
|
-
element: LikeC4Model.
|
|
10
|
+
element: LikeC4Model.Element
|
|
11
11
|
type: 'ancestor' | 'current' | 'descedant'
|
|
12
12
|
children: TreeNodeData[]
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
interface MessageNodeData {
|
|
15
|
+
export interface MessageNodeData {
|
|
16
16
|
label: ReactNode
|
|
17
17
|
value: string
|
|
18
18
|
type: 'message'
|
|
19
19
|
children: TreeNodeData[]
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
type TreeNodeData = ElementTreeNodeData | MessageNodeData
|
|
22
|
+
export type TreeNodeData = ElementTreeNodeData | MessageNodeData
|
|
23
23
|
|
|
24
|
-
type
|
|
25
|
-
element: LikeC4Model.
|
|
24
|
+
type TabPanelStructureProps = {
|
|
25
|
+
element: LikeC4Model.Element
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const ElementLabel = ({
|
|
28
|
+
export const ElementLabel = ({
|
|
29
29
|
element
|
|
30
|
-
}: { element: LikeC4Model.
|
|
30
|
+
}: { element: LikeC4Model.Element; type: 'ancestor' | 'current' | 'descedant' }) => (
|
|
31
31
|
<Box className={css.elementLabel}>
|
|
32
32
|
<Text component="div" fz={'sm'} fw={'500'}>{element.title}</Text>
|
|
33
33
|
</Box>
|
|
@@ -38,9 +38,9 @@ const ElementLabel = ({
|
|
|
38
38
|
// }: RenderTreeNodePayload) => {
|
|
39
39
|
// }
|
|
40
40
|
|
|
41
|
-
export function
|
|
41
|
+
export function TabPanelStructure({
|
|
42
42
|
element
|
|
43
|
-
}:
|
|
43
|
+
}: TabPanelStructureProps) {
|
|
44
44
|
const tree = useTree({
|
|
45
45
|
multiple: false
|
|
46
46
|
})
|
|
@@ -60,7 +60,7 @@ export function TabElementStructure({
|
|
|
60
60
|
value: element.id,
|
|
61
61
|
element,
|
|
62
62
|
type: 'current',
|
|
63
|
-
children: element.children().map((child): TreeNodeData => ({
|
|
63
|
+
children: [...element.children()].map((child): TreeNodeData => ({
|
|
64
64
|
label: <ElementLabel type="descedant" element={child} />,
|
|
65
65
|
value: child.id,
|
|
66
66
|
element: child,
|
|
@@ -93,7 +93,7 @@ export const RelationshipsOverlay = memo<{ subjectId: Fqn }>(function Relationsh
|
|
|
93
93
|
<Box flex={'1 0 auto'}>
|
|
94
94
|
<SelectElement
|
|
95
95
|
scope={scope}
|
|
96
|
-
subject={subject
|
|
96
|
+
subject={subject.$element}
|
|
97
97
|
onSelect={fqn =>
|
|
98
98
|
overlay.openOverlay({
|
|
99
99
|
relationshipsOf: fqn
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { delay, type DiagramView, type Fqn, isAncestor
|
|
2
|
-
import {
|
|
3
|
-
import { useId, useLocalStorage, useStateHistory } from '@mantine/hooks'
|
|
1
|
+
import { type AbstractRelation, delay, type DiagramView, type Fqn, isAncestor } from '@likec4/core'
|
|
2
|
+
import { useId } from '@mantine/hooks'
|
|
4
3
|
import { useDebouncedCallback, useDeepCompareEffect, useSyncedRef } from '@react-hookz/web'
|
|
5
|
-
import { IconArrowLeft, IconArrowRight } from '@tabler/icons-react'
|
|
6
4
|
import {
|
|
7
|
-
Background,
|
|
8
|
-
BackgroundVariant,
|
|
9
5
|
getViewportForBounds,
|
|
10
|
-
Panel,
|
|
11
6
|
ReactFlow,
|
|
12
7
|
type ReactFlowInstance,
|
|
13
8
|
type ReactFlowProps,
|
|
@@ -19,16 +14,13 @@ import {
|
|
|
19
14
|
useStoreApi
|
|
20
15
|
} from '@xyflow/react'
|
|
21
16
|
import { getNodeDimensions } from '@xyflow/system'
|
|
22
|
-
import {
|
|
17
|
+
import { type PropsWithChildren, useRef, useState } from 'react'
|
|
23
18
|
import { isNullish, map, omit, only, prop, setPath, unique } from 'remeda'
|
|
24
19
|
import { useUpdateEffect } from '../../hooks'
|
|
25
|
-
import { useDiagramStoreApi } from '../../hooks/useDiagramState'
|
|
26
20
|
import { centerXYInternalNode } from '../../xyflow/utils'
|
|
27
|
-
import { useOverlayDialog } from '../OverlayContext'
|
|
28
21
|
import { cssReactflowMarker } from '../Overlays.css'
|
|
29
|
-
import type {
|
|
30
|
-
import {
|
|
31
|
-
import { useLayoutedRelationships, ZIndexes } from './use-layouted-relationships'
|
|
22
|
+
import type { RelationshipsOfFlowTypes } from './_types'
|
|
23
|
+
import { ZIndexes } from './use-layouted-relationships'
|
|
32
24
|
import { CompoundNode } from './xyflow/CompoundNode'
|
|
33
25
|
import { ElementNode } from './xyflow/ElementNode'
|
|
34
26
|
import { EmptyNode } from './xyflow/EmptyNode'
|
|
@@ -46,10 +38,10 @@ const edgeTypes = {
|
|
|
46
38
|
/**
|
|
47
39
|
* Root node in 'subjects' column
|
|
48
40
|
*/
|
|
49
|
-
const findRootSubject = (nodes:
|
|
50
|
-
nodes.find((n): n is
|
|
41
|
+
const findRootSubject = (nodes: RelationshipsOfFlowTypes.Node[]) =>
|
|
42
|
+
nodes.find((n): n is RelationshipsOfFlowTypes.ElementNode => n.data.column === 'subjects' && isNullish(n.parentId))
|
|
51
43
|
|
|
52
|
-
const resetDimmedAndHovered = (xyflow: ReactFlowInstance<
|
|
44
|
+
const resetDimmedAndHovered = (xyflow: ReactFlowInstance<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>) => {
|
|
53
45
|
xyflow.setEdges(edges =>
|
|
54
46
|
edges.map(edge => ({
|
|
55
47
|
...edge,
|
|
@@ -70,12 +62,12 @@ const resetDimmedAndHovered = (xyflow: ReactFlowInstance<XYFlowTypes.Node, XYFlo
|
|
|
70
62
|
dimmed: false,
|
|
71
63
|
hovered: false
|
|
72
64
|
}
|
|
73
|
-
}) as
|
|
65
|
+
}) as RelationshipsOfFlowTypes.Node
|
|
74
66
|
)
|
|
75
67
|
)
|
|
76
68
|
}
|
|
77
69
|
|
|
78
|
-
const animateEdge = (node:
|
|
70
|
+
const animateEdge = (node: RelationshipsOfFlowTypes.Node, animated = true) => (edges: RelationshipsOfFlowTypes.Edge[]) => {
|
|
79
71
|
return edges.map(edge => {
|
|
80
72
|
const isConnected = edge.source === node.id || edge.target === node.id || isAncestor(node.id, edge.source)
|
|
81
73
|
|| isAncestor(node.id, edge.target)
|
|
@@ -86,10 +78,10 @@ const animateEdge = (node: XYFlowTypes.Node, animated = true) => (edges: XYFlowT
|
|
|
86
78
|
})
|
|
87
79
|
}
|
|
88
80
|
|
|
89
|
-
const onlyOneUnique = <T extends keyof
|
|
90
|
-
data:
|
|
81
|
+
const onlyOneUnique = <T extends keyof AbstractRelation>(
|
|
82
|
+
data: RelationshipsOfFlowTypes.Edge['data'],
|
|
91
83
|
property: T
|
|
92
|
-
):
|
|
84
|
+
): AbstractRelation[T] | undefined => {
|
|
93
85
|
return only(unique(map(data.relations, prop(property))))
|
|
94
86
|
}
|
|
95
87
|
|
|
@@ -97,8 +89,8 @@ type RelationshipsXYFlowProps =
|
|
|
97
89
|
& PropsWithChildren<{
|
|
98
90
|
subjectId: Fqn
|
|
99
91
|
view: DiagramView
|
|
100
|
-
nodes:
|
|
101
|
-
edges:
|
|
92
|
+
nodes: RelationshipsOfFlowTypes.Node[]
|
|
93
|
+
edges: RelationshipsOfFlowTypes.Edge[]
|
|
102
94
|
bounds: {
|
|
103
95
|
x: number
|
|
104
96
|
y: number
|
|
@@ -108,7 +100,7 @@ type RelationshipsXYFlowProps =
|
|
|
108
100
|
viewportPadding?: number | undefined
|
|
109
101
|
}>
|
|
110
102
|
& Pick<
|
|
111
|
-
ReactFlowProps<
|
|
103
|
+
ReactFlowProps<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>,
|
|
112
104
|
| 'onNodeClick'
|
|
113
105
|
| 'elementsSelectable'
|
|
114
106
|
| 'maxZoom'
|
|
@@ -130,10 +122,10 @@ function RelationshipsXYFlowWrapped({
|
|
|
130
122
|
}: RelationshipsXYFlowProps) {
|
|
131
123
|
const id = useId()
|
|
132
124
|
|
|
133
|
-
const lastClickedNodeRef = useRef<
|
|
125
|
+
const lastClickedNodeRef = useRef<RelationshipsOfFlowTypes.NonEmptyNode | null>(null)
|
|
134
126
|
|
|
135
|
-
const xyflow = useReactFlow<
|
|
136
|
-
const xystore = useStoreApi<
|
|
127
|
+
const xyflow = useReactFlow<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>()
|
|
128
|
+
const xystore = useStoreApi<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>()
|
|
137
129
|
|
|
138
130
|
const [zoomOnDoubleClick, setZoomOnDoubleClick] = useState(true)
|
|
139
131
|
|
|
@@ -191,7 +183,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
191
183
|
|
|
192
184
|
// If subject node is the same, don't animate
|
|
193
185
|
if (currentSubjectNode && nextSubjectNode?.data.fqn === currentSubjectNode.data.fqn) {
|
|
194
|
-
setNodes(map(nodes, setPath(['data', '
|
|
186
|
+
setNodes(map(nodes, setPath(['data', 'entering'], false)))
|
|
195
187
|
setEdges(edges)
|
|
196
188
|
fitview()
|
|
197
189
|
return
|
|
@@ -235,7 +227,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
235
227
|
dimmed: n.data.column === 'subjects' ? 'immediate' : false
|
|
236
228
|
}
|
|
237
229
|
// hidden: n.data.column === 'subjects'
|
|
238
|
-
} as
|
|
230
|
+
} as RelationshipsOfFlowTypes.Node
|
|
239
231
|
}
|
|
240
232
|
// Move existing node
|
|
241
233
|
return {
|
|
@@ -250,7 +242,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
250
242
|
leaving: false,
|
|
251
243
|
dimmed: false
|
|
252
244
|
}
|
|
253
|
-
} as
|
|
245
|
+
} as RelationshipsOfFlowTypes.Node
|
|
254
246
|
}))
|
|
255
247
|
setEdges(_edges.map(e => ({
|
|
256
248
|
...e,
|
|
@@ -290,7 +282,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
290
282
|
isCancelled = true
|
|
291
283
|
}
|
|
292
284
|
}
|
|
293
|
-
setNodes(map(nodes, setPath(['data', '
|
|
285
|
+
setNodes(map(nodes, setPath(['data', 'entering'], false)))
|
|
294
286
|
setEdges(edges)
|
|
295
287
|
fitview()
|
|
296
288
|
return undefined
|
|
@@ -299,8 +291,8 @@ function RelationshipsXYFlowWrapped({
|
|
|
299
291
|
return (
|
|
300
292
|
<ReactFlow
|
|
301
293
|
id={id}
|
|
302
|
-
defaultEdges={[] as
|
|
303
|
-
defaultNodes={[] as
|
|
294
|
+
defaultEdges={[] as RelationshipsOfFlowTypes.Edge[]}
|
|
295
|
+
defaultNodes={[] as RelationshipsOfFlowTypes.Node[]}
|
|
304
296
|
nodeTypes={nodeTypes}
|
|
305
297
|
edgeTypes={edgeTypes}
|
|
306
298
|
defaultMarkerColor="var(--likec4-relation-lineColor)"
|
|
@@ -352,7 +344,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
352
344
|
...n.data,
|
|
353
345
|
dimmed: n.id !== edge.source && n.id !== edge.target
|
|
354
346
|
}
|
|
355
|
-
} as
|
|
347
|
+
} as RelationshipsOfFlowTypes.Node))
|
|
356
348
|
)
|
|
357
349
|
}}
|
|
358
350
|
onEdgeMouseLeave={() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ancestorsFqn, type Element, type Fqn, type
|
|
1
|
+
import { ancestorsFqn, type Element, type Fqn, type ViewId } from '@likec4/core'
|
|
2
2
|
import {
|
|
3
3
|
ActionIcon,
|
|
4
4
|
Box,
|
|
@@ -25,7 +25,7 @@ export const SelectElement = ({
|
|
|
25
25
|
onSelect
|
|
26
26
|
}: {
|
|
27
27
|
subject: Element
|
|
28
|
-
viewId:
|
|
28
|
+
viewId: ViewId
|
|
29
29
|
scope: 'global' | 'view'
|
|
30
30
|
onSelect: (id: Fqn) => void
|
|
31
31
|
}) => {
|
|
@@ -1,78 +1,40 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Node as ReactFlowNode,
|
|
6
|
-
ReactFlowInstance
|
|
7
|
-
} from '@xyflow/react'
|
|
8
|
-
import type { SetRequired } from 'type-fest'
|
|
1
|
+
import type { AddEdgeData, AddNodeData } from '../../utils/types'
|
|
2
|
+
import type { SharedFlowTypes } from '../shared/xyflow/_types'
|
|
3
|
+
|
|
4
|
+
export namespace RelationshipsOfFlowTypes {
|
|
9
5
|
|
|
10
|
-
export namespace XYFlowTypes {
|
|
11
6
|
/**
|
|
12
|
-
*
|
|
7
|
+
* Data that is exclusive to the relationships-of overlay. It will be merged into the node types
|
|
8
|
+
* provided by SharedFlowTypes.
|
|
13
9
|
*/
|
|
14
|
-
|
|
15
|
-
id: string
|
|
16
|
-
type: 'in' | 'out'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type NodeProps = {
|
|
10
|
+
type RelationshipsOfNodeData = {
|
|
20
11
|
depth?: number
|
|
21
12
|
column: 'incomers' | 'subjects' | 'outgoers'
|
|
22
|
-
fqn: Fqn
|
|
23
13
|
existsInCurrentView: boolean
|
|
24
|
-
element: Pick<ComputedNode, 'color' | 'title' | 'description' | 'shape' | 'kind'>
|
|
25
|
-
ports: {
|
|
26
|
-
left: Port[]
|
|
27
|
-
right: Port[]
|
|
28
|
-
}
|
|
29
|
-
navigateTo: ViewID | null
|
|
30
|
-
hovered?: boolean
|
|
31
14
|
layoutId?: string
|
|
32
|
-
leaving?: boolean
|
|
33
|
-
/**
|
|
34
|
-
* @default true
|
|
35
|
-
*/
|
|
36
|
-
initialAnimation?: boolean
|
|
37
|
-
/**
|
|
38
|
-
* Whether the node is dimmed
|
|
39
|
-
* 'immediate' means that the node is dimmed without delay
|
|
40
|
-
*/
|
|
41
|
-
dimmed?: 'immediate' | boolean
|
|
42
15
|
}
|
|
43
16
|
|
|
44
|
-
|
|
17
|
+
// Extend the node types provided by SharedFlowTypes with RelationshipsOfNodeData
|
|
18
|
+
|
|
19
|
+
export type ElementNode = AddNodeData<SharedFlowTypes.ElementNode, RelationshipsOfNodeData>
|
|
45
20
|
|
|
46
|
-
export type CompoundNode =
|
|
21
|
+
export type CompoundNode = AddNodeData<SharedFlowTypes.CompoundNode, RelationshipsOfNodeData>
|
|
47
22
|
|
|
48
23
|
export type NonEmptyNode = ElementNode | CompoundNode
|
|
49
24
|
|
|
50
|
-
export type EmptyNode =
|
|
51
|
-
ReactFlowNode<{
|
|
52
|
-
column: 'incomers' | 'subjects' | 'outgoers'
|
|
53
|
-
hovered?: boolean
|
|
54
|
-
dimmed?: boolean
|
|
55
|
-
/**
|
|
56
|
-
* @default true
|
|
57
|
-
*/
|
|
58
|
-
initialAnimation?: boolean
|
|
59
|
-
}, 'empty'>,
|
|
60
|
-
'type'
|
|
61
|
-
>
|
|
25
|
+
export type EmptyNode = AddNodeData<SharedFlowTypes.EmptyNode, RelationshipsOfNodeData>
|
|
62
26
|
|
|
63
27
|
export type Node = NonEmptyNode | EmptyNode
|
|
64
28
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
type: 'relation'
|
|
29
|
+
/**
|
|
30
|
+
* Data that is exclusive to the relationships-of overlay. It will be merged into the edge types
|
|
31
|
+
* provided by SharedFlowTypes.
|
|
32
|
+
*/
|
|
33
|
+
type RelationshipsOfEdgeData = {
|
|
34
|
+
existsInCurrentView: boolean
|
|
73
35
|
}
|
|
74
36
|
|
|
75
|
-
|
|
37
|
+
// Extend the edge types provided by SharedFlowTypes with RelationshipsOfEdgeData
|
|
76
38
|
|
|
77
|
-
export type
|
|
39
|
+
export type Edge = AddEdgeData<SharedFlowTypes.Edge, RelationshipsOfEdgeData>
|
|
78
40
|
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type LikeC4Model,
|
|
12
12
|
nonNullable,
|
|
13
13
|
parentFqn,
|
|
14
|
-
type
|
|
14
|
+
type RelationId
|
|
15
15
|
} from '@likec4/core'
|
|
16
16
|
import { MarkerType } from '@xyflow/system'
|
|
17
17
|
import { useMemo } from 'react'
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
tap
|
|
39
39
|
} from 'remeda'
|
|
40
40
|
import { useLikeC4Model } from '../../likec4model'
|
|
41
|
-
import type {
|
|
41
|
+
import type { RelationshipsOfFlowTypes } from './_types'
|
|
42
42
|
|
|
43
43
|
const columns = ['incomers', 'subjects', 'outgoers'] as const
|
|
44
44
|
type ColumnKey = typeof columns[number]
|
|
@@ -118,15 +118,12 @@ function createGraph() {
|
|
|
118
118
|
return g
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
type LikeC4ModelElement = LikeC4Model.ElementModel
|
|
122
|
-
// type LikeC4ModelElement = LikeC4ViewModel.Element
|
|
123
|
-
|
|
124
121
|
type Context = {
|
|
125
122
|
scope: 'global' | 'view'
|
|
126
123
|
g: dagre.graphlib.Graph
|
|
127
124
|
subjectId: Fqn
|
|
128
125
|
diagramNodes: Map<Fqn, DiagramNode>
|
|
129
|
-
subjectElement:
|
|
126
|
+
subjectElement: LikeC4Model.Element
|
|
130
127
|
// likec4model: LikeC4Model
|
|
131
128
|
// subject: XYFlowTypes.ElementNode
|
|
132
129
|
// Model
|
|
@@ -137,11 +134,11 @@ type Context = {
|
|
|
137
134
|
outgoers: Set<Fqn>
|
|
138
135
|
}
|
|
139
136
|
columns: {
|
|
140
|
-
incomers: Map<Fqn,
|
|
141
|
-
subjects: Map<Fqn,
|
|
142
|
-
outgoers: Map<Fqn,
|
|
137
|
+
incomers: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
138
|
+
subjects: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
139
|
+
outgoers: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
143
140
|
}
|
|
144
|
-
edges:
|
|
141
|
+
edges: RelationshipsOfFlowTypes.Edge[]
|
|
145
142
|
}
|
|
146
143
|
|
|
147
144
|
const sized = (height: number = Sizes.hodeHeight) => ({
|
|
@@ -149,7 +146,7 @@ const sized = (height: number = Sizes.hodeHeight) => ({
|
|
|
149
146
|
height
|
|
150
147
|
})
|
|
151
148
|
|
|
152
|
-
const graphId = (node:
|
|
149
|
+
const graphId = (node: RelationshipsOfFlowTypes.Node) => ({
|
|
153
150
|
id: node.id,
|
|
154
151
|
port: node.type === 'compound' ? `${node.id}::port` : node.id,
|
|
155
152
|
body: `${node.id}`,
|
|
@@ -157,9 +154,9 @@ const graphId = (node: XYFlowTypes.Node) => ({
|
|
|
157
154
|
})
|
|
158
155
|
|
|
159
156
|
function nodeData(
|
|
160
|
-
element: LikeC4Model.
|
|
157
|
+
element: LikeC4Model.Element,
|
|
161
158
|
ctx: Context
|
|
162
|
-
): Omit<
|
|
159
|
+
): Omit<RelationshipsOfFlowTypes.NonEmptyNode['data'], 'column'> {
|
|
163
160
|
// We try to inherit style from existing diagram node
|
|
164
161
|
let diagramNode = ctx.diagramNodes.get(element.id)
|
|
165
162
|
|
|
@@ -167,7 +164,7 @@ function nodeData(
|
|
|
167
164
|
// color from it if there is no diagram node
|
|
168
165
|
const ancestor = diagramNode ?? (ctx.scope === 'view'
|
|
169
166
|
? pipe(
|
|
170
|
-
element.ancestors(),
|
|
167
|
+
element.ancestors().toArray(),
|
|
171
168
|
map(ancestor => ctx.diagramNodes.get(ancestor.id)),
|
|
172
169
|
filter(isTruthy),
|
|
173
170
|
first()
|
|
@@ -180,14 +177,14 @@ function nodeData(
|
|
|
180
177
|
element: {
|
|
181
178
|
kind: element.kind,
|
|
182
179
|
title: diagramNode?.title ?? element.title,
|
|
183
|
-
description: diagramNode?.description ?? element.
|
|
180
|
+
description: diagramNode?.description ?? element.description,
|
|
184
181
|
color: diagramNode?.color ?? ancestor?.color ?? element.color,
|
|
185
182
|
shape: diagramNode?.shape ?? element.shape
|
|
186
183
|
},
|
|
187
|
-
navigateTo: diagramNode?.navigateTo ??
|
|
184
|
+
navigateTo: diagramNode?.navigateTo ?? element.defaultView?.id ?? null,
|
|
188
185
|
ports: {
|
|
189
|
-
|
|
190
|
-
|
|
186
|
+
in: [],
|
|
187
|
+
out: []
|
|
191
188
|
}
|
|
192
189
|
}
|
|
193
190
|
}
|
|
@@ -195,7 +192,7 @@ function nodeData(
|
|
|
195
192
|
function createEmptyNode(
|
|
196
193
|
column: ColumnKey,
|
|
197
194
|
ctx: Context
|
|
198
|
-
):
|
|
195
|
+
): RelationshipsOfFlowTypes.EmptyNode {
|
|
199
196
|
const id = `${column}__empty` as Fqn
|
|
200
197
|
const xynodes = ctx.columns[column]
|
|
201
198
|
let node = xynodes.get(id)
|
|
@@ -203,12 +200,13 @@ function createEmptyNode(
|
|
|
203
200
|
invariant(node.type === 'empty', 'Node is not empty')
|
|
204
201
|
return node
|
|
205
202
|
}
|
|
206
|
-
const xynode:
|
|
203
|
+
const xynode: RelationshipsOfFlowTypes.EmptyNode = {
|
|
207
204
|
type: 'empty',
|
|
208
205
|
id,
|
|
209
206
|
position: { x: 0, y: 0 },
|
|
210
207
|
data: {
|
|
211
|
-
column
|
|
208
|
+
column,
|
|
209
|
+
existsInCurrentView: true
|
|
212
210
|
},
|
|
213
211
|
zIndex: ZIndexes.empty
|
|
214
212
|
}
|
|
@@ -227,11 +225,11 @@ function createEmptyNode(
|
|
|
227
225
|
|
|
228
226
|
function createNode(
|
|
229
227
|
column: ColumnKey,
|
|
230
|
-
nodeType: Exclude<
|
|
231
|
-
element: LikeC4Model.
|
|
228
|
+
nodeType: Exclude<RelationshipsOfFlowTypes.Node['type'], 'empty'>,
|
|
229
|
+
element: LikeC4Model.Element,
|
|
232
230
|
ctx: Context,
|
|
233
231
|
depth: number = 0
|
|
234
|
-
):
|
|
232
|
+
): RelationshipsOfFlowTypes.ElementNode | RelationshipsOfFlowTypes.CompoundNode {
|
|
235
233
|
const xynodes = ctx.columns[column]
|
|
236
234
|
let node = xynodes.get(element.id)
|
|
237
235
|
if (node) {
|
|
@@ -245,7 +243,7 @@ function createNode(
|
|
|
245
243
|
|
|
246
244
|
// Create parent node
|
|
247
245
|
const parent = pipe(
|
|
248
|
-
element.ancestors(),
|
|
246
|
+
element.ancestors().toArray(),
|
|
249
247
|
takeWhile(ancestor => !isAncestor(ancestor.id, ctx.subjectId)),
|
|
250
248
|
find(ancestor =>
|
|
251
249
|
ctx.diagramNodes.has(ancestor.id) || ctx.connected[column].has(ancestor.id)
|
|
@@ -254,7 +252,7 @@ function createNode(
|
|
|
254
252
|
found => found ? createNode(column, 'compound', found, ctx, depth + 2) : null
|
|
255
253
|
)
|
|
256
254
|
|
|
257
|
-
const xynode:
|
|
255
|
+
const xynode: RelationshipsOfFlowTypes.NonEmptyNode = {
|
|
258
256
|
type: nodeType,
|
|
259
257
|
id: `${column}::${element.id}`,
|
|
260
258
|
position: { x: 0, y: 0 },
|
|
@@ -292,7 +290,7 @@ function createNode(
|
|
|
292
290
|
* And return a function to get node bounds for xyflow
|
|
293
291
|
*/
|
|
294
292
|
function applyDagreLayout(g: dagre.graphlib.Graph) {
|
|
295
|
-
type NodeBounds = Required<Pick<
|
|
293
|
+
type NodeBounds = Required<Pick<RelationshipsOfFlowTypes.Node, 'position' | 'width' | 'height'>>
|
|
296
294
|
dagre.layout(g)
|
|
297
295
|
return function nodeBounds(nodeId: string): NodeBounds {
|
|
298
296
|
const { x, y, width, height } = g.node(nodeId)
|
|
@@ -310,18 +308,18 @@ function applyDagreLayout(g: dagre.graphlib.Graph) {
|
|
|
310
308
|
function addEdge(
|
|
311
309
|
ctx: Context,
|
|
312
310
|
props: {
|
|
313
|
-
|
|
311
|
+
existsInCurrentView: boolean
|
|
314
312
|
source: string
|
|
315
313
|
target: string
|
|
316
|
-
relations:
|
|
314
|
+
relations: RelationshipsOfFlowTypes.Edge['data']['relations']
|
|
317
315
|
}
|
|
318
316
|
) {
|
|
319
|
-
const { source, target, relations,
|
|
317
|
+
const { source, target, relations, existsInCurrentView } = props
|
|
320
318
|
const ids = relations.map(r => r.id).join('_')
|
|
321
319
|
const label = only(relations)?.title ?? 'untitled'
|
|
322
320
|
|
|
323
321
|
const isMultiple = relations.length > 1
|
|
324
|
-
const edge:
|
|
322
|
+
const edge: RelationshipsOfFlowTypes.Edge = {
|
|
325
323
|
id: `rel${ctx.edges.length + 1}_${ids}`,
|
|
326
324
|
type: 'relation',
|
|
327
325
|
source,
|
|
@@ -329,7 +327,7 @@ function addEdge(
|
|
|
329
327
|
sourceHandle: target,
|
|
330
328
|
targetHandle: source,
|
|
331
329
|
data: {
|
|
332
|
-
|
|
330
|
+
existsInCurrentView: existsInCurrentView,
|
|
333
331
|
relations
|
|
334
332
|
},
|
|
335
333
|
label: isMultiple ? `${relations.length} relationships` : label,
|
|
@@ -363,9 +361,9 @@ function layout(
|
|
|
363
361
|
): {
|
|
364
362
|
viewIncludesSubject: boolean
|
|
365
363
|
notIncludedRelations: number
|
|
366
|
-
subject:
|
|
367
|
-
nodes:
|
|
368
|
-
edges:
|
|
364
|
+
subject: LikeC4Model.Element
|
|
365
|
+
nodes: RelationshipsOfFlowTypes.Node[]
|
|
366
|
+
edges: RelationshipsOfFlowTypes.Edge[]
|
|
369
367
|
bounds: {
|
|
370
368
|
x: number
|
|
371
369
|
y: number
|
|
@@ -375,13 +373,14 @@ function layout(
|
|
|
375
373
|
} {
|
|
376
374
|
const diagramNodes = new Map(view.nodes.map(n => [n.id, n]))
|
|
377
375
|
const subjectElement = likec4model.element(subjectId)
|
|
376
|
+
|
|
378
377
|
const viewIncludesSubject = diagramNodes.has(subjectId)
|
|
379
378
|
|
|
380
379
|
const viewRelationships = new Set(
|
|
381
380
|
view.edges.flatMap(e => e.relations)
|
|
382
381
|
)
|
|
383
382
|
// Relations that are not included in the view
|
|
384
|
-
const notIncludedRelations = new Set<
|
|
383
|
+
const notIncludedRelations = new Set<RelationId>()
|
|
385
384
|
|
|
386
385
|
if (!viewIncludesSubject) {
|
|
387
386
|
// Reset scope to global if subject is not in the view
|
|
@@ -401,16 +400,18 @@ function layout(
|
|
|
401
400
|
|
|
402
401
|
if (scope === 'global') {
|
|
403
402
|
relationships = {
|
|
404
|
-
incoming: subjectElement.incoming().map(r => r
|
|
405
|
-
outgoing: subjectElement.outgoing().map(r => r
|
|
403
|
+
incoming: subjectElement.incoming().map(r => r.$relationship).toArray(),
|
|
404
|
+
outgoing: subjectElement.outgoing().map(r => r.$relationship).toArray()
|
|
406
405
|
}
|
|
407
406
|
} else {
|
|
408
|
-
const subjectViewModel = likec4model.view(view.id).
|
|
407
|
+
const subjectViewModel = likec4model.view(view.id).node(subjectId)
|
|
409
408
|
relationships = {
|
|
410
409
|
incoming: subjectViewModel.incoming()
|
|
411
|
-
.flatMap(c => c.relationships().map(r => r
|
|
410
|
+
.flatMap(c => c.relationships('model').map(r => r.$relationship))
|
|
411
|
+
.toArray(),
|
|
412
412
|
outgoing: subjectViewModel.outgoing()
|
|
413
|
-
.flatMap(c => c.relationships().map(r => r
|
|
413
|
+
.flatMap(c => c.relationships('model').map(r => r.$relationship))
|
|
414
|
+
.toArray()
|
|
414
415
|
}
|
|
415
416
|
}
|
|
416
417
|
|
|
@@ -445,7 +446,7 @@ function layout(
|
|
|
445
446
|
})
|
|
446
447
|
|
|
447
448
|
if (viewIncludesSubject) {
|
|
448
|
-
const subjectViewModel = likec4model.view(view.id).
|
|
449
|
+
const subjectViewModel = likec4model.view(view.id).node(subjectId)
|
|
449
450
|
subjectViewModel.incomers().forEach(incomer => {
|
|
450
451
|
ctx.connected.incomers.add(incomer.id)
|
|
451
452
|
})
|
|
@@ -501,7 +502,7 @@ function layout(
|
|
|
501
502
|
relation,
|
|
502
503
|
source,
|
|
503
504
|
target,
|
|
504
|
-
|
|
505
|
+
existsInCurrentView: viewRelationships.has(relation.id),
|
|
505
506
|
id: `${source.id}:${target.id}`
|
|
506
507
|
})
|
|
507
508
|
})
|
|
@@ -513,14 +514,8 @@ function layout(
|
|
|
513
514
|
const { source, target } = grouped[0]
|
|
514
515
|
const relations = map(grouped, g => g.relation)
|
|
515
516
|
|
|
516
|
-
source.data.ports.
|
|
517
|
-
|
|
518
|
-
type: 'out'
|
|
519
|
-
})
|
|
520
|
-
target.data.ports.left.push({
|
|
521
|
-
id: source.id,
|
|
522
|
-
type: 'in'
|
|
523
|
-
})
|
|
517
|
+
source.data.ports.out.push(target.id)
|
|
518
|
+
target.data.ports.in.push(source.id)
|
|
524
519
|
|
|
525
520
|
const isAnyCompound = source.type === 'compound' || target.type === 'compound'
|
|
526
521
|
|
|
@@ -531,7 +526,7 @@ function layout(
|
|
|
531
526
|
|
|
532
527
|
addEdge(ctx, {
|
|
533
528
|
// if view does not include subject - do not highlight
|
|
534
|
-
|
|
529
|
+
existsInCurrentView: !viewIncludesSubject || grouped.every(g => g.existsInCurrentView),
|
|
535
530
|
source: source.id,
|
|
536
531
|
target: target.id,
|
|
537
532
|
relations
|
|
@@ -556,7 +551,7 @@ function layout(
|
|
|
556
551
|
if (subject.type !== 'element') {
|
|
557
552
|
continue
|
|
558
553
|
}
|
|
559
|
-
const subjectPortsCount = Math.max(subject.data.ports.
|
|
554
|
+
const subjectPortsCount = Math.max(subject.data.ports.in.length, subject.data.ports.out.length)
|
|
560
555
|
if (subjectPortsCount > 2) {
|
|
561
556
|
g.node(subject.id).height = Sizes.hodeHeight + (subjectPortsCount - 3) * 14
|
|
562
557
|
}
|
|
@@ -629,13 +624,13 @@ function layout(
|
|
|
629
624
|
}
|
|
630
625
|
|
|
631
626
|
// Sort ports in subject vertically
|
|
632
|
-
const sortedPorts = (ports:
|
|
627
|
+
const sortedPorts = (ports: string[]) => {
|
|
633
628
|
return pipe(
|
|
634
629
|
ports,
|
|
635
630
|
map(port => {
|
|
636
631
|
return {
|
|
637
632
|
port,
|
|
638
|
-
topY: nodeBounds(port
|
|
633
|
+
topY: nodeBounds(port).position.y
|
|
639
634
|
}
|
|
640
635
|
}),
|
|
641
636
|
sortBy(prop('topY')),
|
|
@@ -659,11 +654,11 @@ function layout(
|
|
|
659
654
|
continue
|
|
660
655
|
}
|
|
661
656
|
// Sort ports by their position
|
|
662
|
-
if (node.data.ports.
|
|
663
|
-
node.data.ports.
|
|
657
|
+
if (node.data.ports.in.length > 1) {
|
|
658
|
+
node.data.ports.in = sortedPorts(node.data.ports.in)
|
|
664
659
|
}
|
|
665
|
-
if (node.data.ports.
|
|
666
|
-
node.data.ports.
|
|
660
|
+
if (node.data.ports.out.length > 1) {
|
|
661
|
+
node.data.ports.out = sortedPorts(node.data.ports.out)
|
|
667
662
|
}
|
|
668
663
|
}
|
|
669
664
|
|