@likec4/diagram 1.18.0 → 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 +34 -27
- package/src/LikeC4Diagram.tsx +4 -4
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +39 -90
- 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/useXYFlow.ts +8 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
- package/src/overlays/edge-details/_types.ts +13 -37
- package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
- 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 +35 -37
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +6 -6
- 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 +25 -18
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
- 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 +1 -64
- package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
- package/src/xyflow/nodes/element/element.css.ts +0 -57
- package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +9 -9
- package/src/xyflow/useXYFlowEvents.ts +13 -30
- package/src/xyflow/utils.ts +2 -2
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { delay, type DiagramView, type Fqn, isAncestor
|
|
1
|
+
import { type AbstractRelation, delay, type DiagramView, type Fqn, isAncestor } from '@likec4/core'
|
|
2
2
|
import { useId } from '@mantine/hooks'
|
|
3
3
|
import { useDebouncedCallback, useDeepCompareEffect, useSyncedRef } from '@react-hookz/web'
|
|
4
4
|
import {
|
|
@@ -19,7 +19,7 @@ import { isNullish, map, omit, only, prop, setPath, unique } from 'remeda'
|
|
|
19
19
|
import { useUpdateEffect } from '../../hooks'
|
|
20
20
|
import { centerXYInternalNode } from '../../xyflow/utils'
|
|
21
21
|
import { cssReactflowMarker } from '../Overlays.css'
|
|
22
|
-
import type {
|
|
22
|
+
import type { RelationshipsOfFlowTypes } from './_types'
|
|
23
23
|
import { ZIndexes } from './use-layouted-relationships'
|
|
24
24
|
import { CompoundNode } from './xyflow/CompoundNode'
|
|
25
25
|
import { ElementNode } from './xyflow/ElementNode'
|
|
@@ -38,10 +38,10 @@ const edgeTypes = {
|
|
|
38
38
|
/**
|
|
39
39
|
* Root node in 'subjects' column
|
|
40
40
|
*/
|
|
41
|
-
const findRootSubject = (nodes:
|
|
42
|
-
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))
|
|
43
43
|
|
|
44
|
-
const resetDimmedAndHovered = (xyflow: ReactFlowInstance<
|
|
44
|
+
const resetDimmedAndHovered = (xyflow: ReactFlowInstance<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>) => {
|
|
45
45
|
xyflow.setEdges(edges =>
|
|
46
46
|
edges.map(edge => ({
|
|
47
47
|
...edge,
|
|
@@ -62,12 +62,12 @@ const resetDimmedAndHovered = (xyflow: ReactFlowInstance<XYFlowTypes.Node, XYFlo
|
|
|
62
62
|
dimmed: false,
|
|
63
63
|
hovered: false
|
|
64
64
|
}
|
|
65
|
-
}) as
|
|
65
|
+
}) as RelationshipsOfFlowTypes.Node
|
|
66
66
|
)
|
|
67
67
|
)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const animateEdge = (node:
|
|
70
|
+
const animateEdge = (node: RelationshipsOfFlowTypes.Node, animated = true) => (edges: RelationshipsOfFlowTypes.Edge[]) => {
|
|
71
71
|
return edges.map(edge => {
|
|
72
72
|
const isConnected = edge.source === node.id || edge.target === node.id || isAncestor(node.id, edge.source)
|
|
73
73
|
|| isAncestor(node.id, edge.target)
|
|
@@ -78,10 +78,10 @@ const animateEdge = (node: XYFlowTypes.Node, animated = true) => (edges: XYFlowT
|
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
const onlyOneUnique = <T extends keyof
|
|
82
|
-
data:
|
|
81
|
+
const onlyOneUnique = <T extends keyof AbstractRelation>(
|
|
82
|
+
data: RelationshipsOfFlowTypes.Edge['data'],
|
|
83
83
|
property: T
|
|
84
|
-
):
|
|
84
|
+
): AbstractRelation[T] | undefined => {
|
|
85
85
|
return only(unique(map(data.relations, prop(property))))
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -89,8 +89,8 @@ type RelationshipsXYFlowProps =
|
|
|
89
89
|
& PropsWithChildren<{
|
|
90
90
|
subjectId: Fqn
|
|
91
91
|
view: DiagramView
|
|
92
|
-
nodes:
|
|
93
|
-
edges:
|
|
92
|
+
nodes: RelationshipsOfFlowTypes.Node[]
|
|
93
|
+
edges: RelationshipsOfFlowTypes.Edge[]
|
|
94
94
|
bounds: {
|
|
95
95
|
x: number
|
|
96
96
|
y: number
|
|
@@ -100,7 +100,7 @@ type RelationshipsXYFlowProps =
|
|
|
100
100
|
viewportPadding?: number | undefined
|
|
101
101
|
}>
|
|
102
102
|
& Pick<
|
|
103
|
-
ReactFlowProps<
|
|
103
|
+
ReactFlowProps<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>,
|
|
104
104
|
| 'onNodeClick'
|
|
105
105
|
| 'elementsSelectable'
|
|
106
106
|
| 'maxZoom'
|
|
@@ -122,10 +122,10 @@ function RelationshipsXYFlowWrapped({
|
|
|
122
122
|
}: RelationshipsXYFlowProps) {
|
|
123
123
|
const id = useId()
|
|
124
124
|
|
|
125
|
-
const lastClickedNodeRef = useRef<
|
|
125
|
+
const lastClickedNodeRef = useRef<RelationshipsOfFlowTypes.NonEmptyNode | null>(null)
|
|
126
126
|
|
|
127
|
-
const xyflow = useReactFlow<
|
|
128
|
-
const xystore = useStoreApi<
|
|
127
|
+
const xyflow = useReactFlow<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>()
|
|
128
|
+
const xystore = useStoreApi<RelationshipsOfFlowTypes.Node, RelationshipsOfFlowTypes.Edge>()
|
|
129
129
|
|
|
130
130
|
const [zoomOnDoubleClick, setZoomOnDoubleClick] = useState(true)
|
|
131
131
|
|
|
@@ -183,7 +183,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
183
183
|
|
|
184
184
|
// If subject node is the same, don't animate
|
|
185
185
|
if (currentSubjectNode && nextSubjectNode?.data.fqn === currentSubjectNode.data.fqn) {
|
|
186
|
-
setNodes(map(nodes, setPath(['data', '
|
|
186
|
+
setNodes(map(nodes, setPath(['data', 'entering'], false)))
|
|
187
187
|
setEdges(edges)
|
|
188
188
|
fitview()
|
|
189
189
|
return
|
|
@@ -227,7 +227,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
227
227
|
dimmed: n.data.column === 'subjects' ? 'immediate' : false
|
|
228
228
|
}
|
|
229
229
|
// hidden: n.data.column === 'subjects'
|
|
230
|
-
} as
|
|
230
|
+
} as RelationshipsOfFlowTypes.Node
|
|
231
231
|
}
|
|
232
232
|
// Move existing node
|
|
233
233
|
return {
|
|
@@ -242,7 +242,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
242
242
|
leaving: false,
|
|
243
243
|
dimmed: false
|
|
244
244
|
}
|
|
245
|
-
} as
|
|
245
|
+
} as RelationshipsOfFlowTypes.Node
|
|
246
246
|
}))
|
|
247
247
|
setEdges(_edges.map(e => ({
|
|
248
248
|
...e,
|
|
@@ -282,7 +282,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
282
282
|
isCancelled = true
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
setNodes(map(nodes, setPath(['data', '
|
|
285
|
+
setNodes(map(nodes, setPath(['data', 'entering'], false)))
|
|
286
286
|
setEdges(edges)
|
|
287
287
|
fitview()
|
|
288
288
|
return undefined
|
|
@@ -291,8 +291,8 @@ function RelationshipsXYFlowWrapped({
|
|
|
291
291
|
return (
|
|
292
292
|
<ReactFlow
|
|
293
293
|
id={id}
|
|
294
|
-
defaultEdges={[] as
|
|
295
|
-
defaultNodes={[] as
|
|
294
|
+
defaultEdges={[] as RelationshipsOfFlowTypes.Edge[]}
|
|
295
|
+
defaultNodes={[] as RelationshipsOfFlowTypes.Node[]}
|
|
296
296
|
nodeTypes={nodeTypes}
|
|
297
297
|
edgeTypes={edgeTypes}
|
|
298
298
|
defaultMarkerColor="var(--likec4-relation-lineColor)"
|
|
@@ -344,7 +344,7 @@ function RelationshipsXYFlowWrapped({
|
|
|
344
344
|
...n.data,
|
|
345
345
|
dimmed: n.id !== edge.source && n.id !== edge.target
|
|
346
346
|
}
|
|
347
|
-
} as
|
|
347
|
+
} as RelationshipsOfFlowTypes.Node))
|
|
348
348
|
)
|
|
349
349
|
}}
|
|
350
350
|
onEdgeMouseLeave={() => {
|
|
@@ -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
|
}
|
|
@@ -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]
|
|
@@ -134,11 +134,11 @@ type Context = {
|
|
|
134
134
|
outgoers: Set<Fqn>
|
|
135
135
|
}
|
|
136
136
|
columns: {
|
|
137
|
-
incomers: Map<Fqn,
|
|
138
|
-
subjects: Map<Fqn,
|
|
139
|
-
outgoers: Map<Fqn,
|
|
137
|
+
incomers: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
138
|
+
subjects: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
139
|
+
outgoers: Map<Fqn, RelationshipsOfFlowTypes.Node>
|
|
140
140
|
}
|
|
141
|
-
edges:
|
|
141
|
+
edges: RelationshipsOfFlowTypes.Edge[]
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
const sized = (height: number = Sizes.hodeHeight) => ({
|
|
@@ -146,7 +146,7 @@ const sized = (height: number = Sizes.hodeHeight) => ({
|
|
|
146
146
|
height
|
|
147
147
|
})
|
|
148
148
|
|
|
149
|
-
const graphId = (node:
|
|
149
|
+
const graphId = (node: RelationshipsOfFlowTypes.Node) => ({
|
|
150
150
|
id: node.id,
|
|
151
151
|
port: node.type === 'compound' ? `${node.id}::port` : node.id,
|
|
152
152
|
body: `${node.id}`,
|
|
@@ -156,7 +156,7 @@ const graphId = (node: XYFlowTypes.Node) => ({
|
|
|
156
156
|
function nodeData(
|
|
157
157
|
element: LikeC4Model.Element,
|
|
158
158
|
ctx: Context
|
|
159
|
-
): Omit<
|
|
159
|
+
): Omit<RelationshipsOfFlowTypes.NonEmptyNode['data'], 'column'> {
|
|
160
160
|
// We try to inherit style from existing diagram node
|
|
161
161
|
let diagramNode = ctx.diagramNodes.get(element.id)
|
|
162
162
|
|
|
@@ -183,8 +183,8 @@ function nodeData(
|
|
|
183
183
|
},
|
|
184
184
|
navigateTo: diagramNode?.navigateTo ?? element.defaultView?.id ?? null,
|
|
185
185
|
ports: {
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
in: [],
|
|
187
|
+
out: []
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -192,7 +192,7 @@ function nodeData(
|
|
|
192
192
|
function createEmptyNode(
|
|
193
193
|
column: ColumnKey,
|
|
194
194
|
ctx: Context
|
|
195
|
-
):
|
|
195
|
+
): RelationshipsOfFlowTypes.EmptyNode {
|
|
196
196
|
const id = `${column}__empty` as Fqn
|
|
197
197
|
const xynodes = ctx.columns[column]
|
|
198
198
|
let node = xynodes.get(id)
|
|
@@ -200,12 +200,13 @@ function createEmptyNode(
|
|
|
200
200
|
invariant(node.type === 'empty', 'Node is not empty')
|
|
201
201
|
return node
|
|
202
202
|
}
|
|
203
|
-
const xynode:
|
|
203
|
+
const xynode: RelationshipsOfFlowTypes.EmptyNode = {
|
|
204
204
|
type: 'empty',
|
|
205
205
|
id,
|
|
206
206
|
position: { x: 0, y: 0 },
|
|
207
207
|
data: {
|
|
208
|
-
column
|
|
208
|
+
column,
|
|
209
|
+
existsInCurrentView: true
|
|
209
210
|
},
|
|
210
211
|
zIndex: ZIndexes.empty
|
|
211
212
|
}
|
|
@@ -224,11 +225,11 @@ function createEmptyNode(
|
|
|
224
225
|
|
|
225
226
|
function createNode(
|
|
226
227
|
column: ColumnKey,
|
|
227
|
-
nodeType: Exclude<
|
|
228
|
+
nodeType: Exclude<RelationshipsOfFlowTypes.Node['type'], 'empty'>,
|
|
228
229
|
element: LikeC4Model.Element,
|
|
229
230
|
ctx: Context,
|
|
230
231
|
depth: number = 0
|
|
231
|
-
):
|
|
232
|
+
): RelationshipsOfFlowTypes.ElementNode | RelationshipsOfFlowTypes.CompoundNode {
|
|
232
233
|
const xynodes = ctx.columns[column]
|
|
233
234
|
let node = xynodes.get(element.id)
|
|
234
235
|
if (node) {
|
|
@@ -251,7 +252,7 @@ function createNode(
|
|
|
251
252
|
found => found ? createNode(column, 'compound', found, ctx, depth + 2) : null
|
|
252
253
|
)
|
|
253
254
|
|
|
254
|
-
const xynode:
|
|
255
|
+
const xynode: RelationshipsOfFlowTypes.NonEmptyNode = {
|
|
255
256
|
type: nodeType,
|
|
256
257
|
id: `${column}::${element.id}`,
|
|
257
258
|
position: { x: 0, y: 0 },
|
|
@@ -289,7 +290,7 @@ function createNode(
|
|
|
289
290
|
* And return a function to get node bounds for xyflow
|
|
290
291
|
*/
|
|
291
292
|
function applyDagreLayout(g: dagre.graphlib.Graph) {
|
|
292
|
-
type NodeBounds = Required<Pick<
|
|
293
|
+
type NodeBounds = Required<Pick<RelationshipsOfFlowTypes.Node, 'position' | 'width' | 'height'>>
|
|
293
294
|
dagre.layout(g)
|
|
294
295
|
return function nodeBounds(nodeId: string): NodeBounds {
|
|
295
296
|
const { x, y, width, height } = g.node(nodeId)
|
|
@@ -307,18 +308,18 @@ function applyDagreLayout(g: dagre.graphlib.Graph) {
|
|
|
307
308
|
function addEdge(
|
|
308
309
|
ctx: Context,
|
|
309
310
|
props: {
|
|
310
|
-
|
|
311
|
+
existsInCurrentView: boolean
|
|
311
312
|
source: string
|
|
312
313
|
target: string
|
|
313
|
-
relations:
|
|
314
|
+
relations: RelationshipsOfFlowTypes.Edge['data']['relations']
|
|
314
315
|
}
|
|
315
316
|
) {
|
|
316
|
-
const { source, target, relations,
|
|
317
|
+
const { source, target, relations, existsInCurrentView } = props
|
|
317
318
|
const ids = relations.map(r => r.id).join('_')
|
|
318
319
|
const label = only(relations)?.title ?? 'untitled'
|
|
319
320
|
|
|
320
321
|
const isMultiple = relations.length > 1
|
|
321
|
-
const edge:
|
|
322
|
+
const edge: RelationshipsOfFlowTypes.Edge = {
|
|
322
323
|
id: `rel${ctx.edges.length + 1}_${ids}`,
|
|
323
324
|
type: 'relation',
|
|
324
325
|
source,
|
|
@@ -326,7 +327,7 @@ function addEdge(
|
|
|
326
327
|
sourceHandle: target,
|
|
327
328
|
targetHandle: source,
|
|
328
329
|
data: {
|
|
329
|
-
|
|
330
|
+
existsInCurrentView: existsInCurrentView,
|
|
330
331
|
relations
|
|
331
332
|
},
|
|
332
333
|
label: isMultiple ? `${relations.length} relationships` : label,
|
|
@@ -361,8 +362,8 @@ function layout(
|
|
|
361
362
|
viewIncludesSubject: boolean
|
|
362
363
|
notIncludedRelations: number
|
|
363
364
|
subject: LikeC4Model.Element
|
|
364
|
-
nodes:
|
|
365
|
-
edges:
|
|
365
|
+
nodes: RelationshipsOfFlowTypes.Node[]
|
|
366
|
+
edges: RelationshipsOfFlowTypes.Edge[]
|
|
366
367
|
bounds: {
|
|
367
368
|
x: number
|
|
368
369
|
y: number
|
|
@@ -372,6 +373,7 @@ function layout(
|
|
|
372
373
|
} {
|
|
373
374
|
const diagramNodes = new Map(view.nodes.map(n => [n.id, n]))
|
|
374
375
|
const subjectElement = likec4model.element(subjectId)
|
|
376
|
+
|
|
375
377
|
const viewIncludesSubject = diagramNodes.has(subjectId)
|
|
376
378
|
|
|
377
379
|
const viewRelationships = new Set(
|
|
@@ -500,7 +502,7 @@ function layout(
|
|
|
500
502
|
relation,
|
|
501
503
|
source,
|
|
502
504
|
target,
|
|
503
|
-
|
|
505
|
+
existsInCurrentView: viewRelationships.has(relation.id),
|
|
504
506
|
id: `${source.id}:${target.id}`
|
|
505
507
|
})
|
|
506
508
|
})
|
|
@@ -512,14 +514,8 @@ function layout(
|
|
|
512
514
|
const { source, target } = grouped[0]
|
|
513
515
|
const relations = map(grouped, g => g.relation)
|
|
514
516
|
|
|
515
|
-
source.data.ports.
|
|
516
|
-
|
|
517
|
-
type: 'out'
|
|
518
|
-
})
|
|
519
|
-
target.data.ports.left.push({
|
|
520
|
-
id: source.id,
|
|
521
|
-
type: 'in'
|
|
522
|
-
})
|
|
517
|
+
source.data.ports.out.push(target.id)
|
|
518
|
+
target.data.ports.in.push(source.id)
|
|
523
519
|
|
|
524
520
|
const isAnyCompound = source.type === 'compound' || target.type === 'compound'
|
|
525
521
|
|
|
@@ -530,7 +526,7 @@ function layout(
|
|
|
530
526
|
|
|
531
527
|
addEdge(ctx, {
|
|
532
528
|
// if view does not include subject - do not highlight
|
|
533
|
-
|
|
529
|
+
existsInCurrentView: !viewIncludesSubject || grouped.every(g => g.existsInCurrentView),
|
|
534
530
|
source: source.id,
|
|
535
531
|
target: target.id,
|
|
536
532
|
relations
|
|
@@ -555,7 +551,7 @@ function layout(
|
|
|
555
551
|
if (subject.type !== 'element') {
|
|
556
552
|
continue
|
|
557
553
|
}
|
|
558
|
-
const subjectPortsCount = Math.max(subject.data.ports.
|
|
554
|
+
const subjectPortsCount = Math.max(subject.data.ports.in.length, subject.data.ports.out.length)
|
|
559
555
|
if (subjectPortsCount > 2) {
|
|
560
556
|
g.node(subject.id).height = Sizes.hodeHeight + (subjectPortsCount - 3) * 14
|
|
561
557
|
}
|
|
@@ -628,13 +624,13 @@ function layout(
|
|
|
628
624
|
}
|
|
629
625
|
|
|
630
626
|
// Sort ports in subject vertically
|
|
631
|
-
const sortedPorts = (ports:
|
|
627
|
+
const sortedPorts = (ports: string[]) => {
|
|
632
628
|
return pipe(
|
|
633
629
|
ports,
|
|
634
630
|
map(port => {
|
|
635
631
|
return {
|
|
636
632
|
port,
|
|
637
|
-
topY: nodeBounds(port
|
|
633
|
+
topY: nodeBounds(port).position.y
|
|
638
634
|
}
|
|
639
635
|
}),
|
|
640
636
|
sortBy(prop('topY')),
|
|
@@ -658,11 +654,11 @@ function layout(
|
|
|
658
654
|
continue
|
|
659
655
|
}
|
|
660
656
|
// Sort ports by their position
|
|
661
|
-
if (node.data.ports.
|
|
662
|
-
node.data.ports.
|
|
657
|
+
if (node.data.ports.in.length > 1) {
|
|
658
|
+
node.data.ports.in = sortedPorts(node.data.ports.in)
|
|
663
659
|
}
|
|
664
|
-
if (node.data.ports.
|
|
665
|
-
node.data.ports.
|
|
660
|
+
if (node.data.ports.out.length > 1) {
|
|
661
|
+
node.data.ports.out = sortedPorts(node.data.ports.out)
|
|
666
662
|
}
|
|
667
663
|
}
|
|
668
664
|
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { Text as MantineText } from '@mantine/core'
|
|
2
1
|
import { Handle, type NodeProps, Position, useStore } from '@xyflow/react'
|
|
3
2
|
import clsx from 'clsx'
|
|
4
3
|
import { deepEqual, shallowEqual } from 'fast-equals'
|
|
5
4
|
import { m } from 'framer-motion'
|
|
6
5
|
import { memo, useCallback } from 'react'
|
|
7
|
-
import type {
|
|
6
|
+
import type { RelationshipsOfFlowTypes } from '../_types'
|
|
8
7
|
import * as css from './styles.css'
|
|
8
|
+
import { Text } from '../../../controls/Text'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
component: 'div'
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
type CompoundNodeProps = NodeProps<XYFlowTypes.CompoundNode>
|
|
10
|
+
type CompoundNodeProps = NodeProps<RelationshipsOfFlowTypes.CompoundNode>
|
|
15
11
|
|
|
16
12
|
export const CompoundNode = memo<CompoundNodeProps>(({
|
|
17
13
|
id,
|
|
@@ -20,7 +16,7 @@ export const CompoundNode = memo<CompoundNodeProps>(({
|
|
|
20
16
|
ports,
|
|
21
17
|
layoutId = id,
|
|
22
18
|
leaving = false,
|
|
23
|
-
|
|
19
|
+
entering = true,
|
|
24
20
|
...data
|
|
25
21
|
},
|
|
26
22
|
width = 200,
|
|
@@ -61,7 +57,7 @@ export const CompoundNode = memo<CompoundNodeProps>(({
|
|
|
61
57
|
layoutId={layoutId}
|
|
62
58
|
data-compound-depth={data.depth ?? 1}
|
|
63
59
|
data-likec4-color={element.color}
|
|
64
|
-
initial={(layoutId === id &&
|
|
60
|
+
initial={(layoutId === id && entering)
|
|
65
61
|
? {
|
|
66
62
|
...scale(-20),
|
|
67
63
|
opacity: 0,
|
|
@@ -99,22 +95,22 @@ export const CompoundNode = memo<CompoundNodeProps>(({
|
|
|
99
95
|
{element.title}
|
|
100
96
|
</Text>
|
|
101
97
|
</m.div>
|
|
102
|
-
{ports.
|
|
98
|
+
{ports.in.map((id, i) => (
|
|
103
99
|
<Handle
|
|
104
100
|
key={id}
|
|
105
101
|
id={id}
|
|
106
|
-
type=
|
|
102
|
+
type="target"
|
|
107
103
|
position={Position.Left}
|
|
108
104
|
style={{
|
|
109
105
|
visibility: 'hidden',
|
|
110
106
|
top: `${20 * (i + 1)}px`
|
|
111
107
|
}} />
|
|
112
108
|
))}
|
|
113
|
-
{ports.
|
|
109
|
+
{ports.out.map((id, i) => (
|
|
114
110
|
<Handle
|
|
115
111
|
key={id}
|
|
116
112
|
id={id}
|
|
117
|
-
type=
|
|
113
|
+
type="source"
|
|
118
114
|
position={Position.Right}
|
|
119
115
|
style={{
|
|
120
116
|
visibility: 'hidden',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionIcon, Box, Group
|
|
1
|
+
import { ActionIcon, Box, Group } from '@mantine/core'
|
|
2
2
|
import { IconFileSymlink, IconTransform, IconZoomScan } from '@tabler/icons-react'
|
|
3
3
|
import { Handle, type NodeProps, Position } from '@xyflow/react'
|
|
4
4
|
import clsx from 'clsx'
|
|
@@ -9,8 +9,9 @@ import { type DiagramState, useDiagramState } from '../../../hooks'
|
|
|
9
9
|
import { ElementShapeSvg } from '../../../xyflow/nodes/element/ElementShapeSvg'
|
|
10
10
|
import { stopPropagation } from '../../../xyflow/utils'
|
|
11
11
|
import { useOverlayDialog } from '../../OverlayContext'
|
|
12
|
-
import type {
|
|
12
|
+
import type { RelationshipsOfFlowTypes } from '../_types'
|
|
13
13
|
import * as css from './styles.css'
|
|
14
|
+
import { Text } from '../../../controls/Text'
|
|
14
15
|
|
|
15
16
|
const Action = ActionIcon.withProps({
|
|
16
17
|
className: 'nodrag nopan ' + css.navigateBtn,
|
|
@@ -20,11 +21,7 @@ const Action = ActionIcon.withProps({
|
|
|
20
21
|
onPointerDownCapture: stopPropagation
|
|
21
22
|
})
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
component: 'div'
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
type ElementNodeProps = NodeProps<XYFlowTypes.ElementNode>
|
|
24
|
+
type ElementNodeProps = NodeProps<RelationshipsOfFlowTypes.ElementNode>
|
|
28
25
|
|
|
29
26
|
function selector(s: DiagramState) {
|
|
30
27
|
return {
|
|
@@ -42,7 +39,7 @@ export const ElementNode = memo<ElementNodeProps>(({
|
|
|
42
39
|
navigateTo,
|
|
43
40
|
layoutId = id,
|
|
44
41
|
leaving = false,
|
|
45
|
-
|
|
42
|
+
entering = true,
|
|
46
43
|
...data
|
|
47
44
|
},
|
|
48
45
|
selectable = true,
|
|
@@ -82,7 +79,7 @@ export const ElementNode = memo<ElementNodeProps>(({
|
|
|
82
79
|
])}
|
|
83
80
|
layoutId={layoutId}
|
|
84
81
|
data-likec4-color={element.color}
|
|
85
|
-
initial={(layoutId === id &&
|
|
82
|
+
initial={(layoutId === id && entering)
|
|
86
83
|
? {
|
|
87
84
|
...scale(-20),
|
|
88
85
|
opacity: 0,
|
|
@@ -168,26 +165,26 @@ export const ElementNode = memo<ElementNodeProps>(({
|
|
|
168
165
|
)}
|
|
169
166
|
</Group>
|
|
170
167
|
</m.div>
|
|
171
|
-
{ports.
|
|
168
|
+
{ports.in.map((id, i) => (
|
|
172
169
|
<Handle
|
|
173
170
|
key={id}
|
|
174
171
|
id={id}
|
|
175
|
-
type=
|
|
172
|
+
type="target"
|
|
176
173
|
position={Position.Left}
|
|
177
174
|
style={{
|
|
178
175
|
visibility: 'hidden',
|
|
179
|
-
top: `${15 + (i + 1) * ((h - 30) / (ports.
|
|
176
|
+
top: `${15 + (i + 1) * ((h - 30) / (ports.in.length + 1))}px`
|
|
180
177
|
}} />
|
|
181
178
|
))}
|
|
182
|
-
{ports.
|
|
179
|
+
{ports.out.map((id, i) => (
|
|
183
180
|
<Handle
|
|
184
181
|
key={id}
|
|
185
182
|
id={id}
|
|
186
|
-
type=
|
|
183
|
+
type="source"
|
|
187
184
|
position={Position.Right}
|
|
188
185
|
style={{
|
|
189
186
|
visibility: 'hidden',
|
|
190
|
-
top: `${15 + (i + 1) * ((h - 30) / (ports.
|
|
187
|
+
top: `${15 + (i + 1) * ((h - 30) / (ports.out.length + 1))}px`
|
|
191
188
|
}} />
|
|
192
189
|
))}
|
|
193
190
|
</>
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { Box
|
|
1
|
+
import { Box } from '@mantine/core'
|
|
2
2
|
import { type NodeProps } from '@xyflow/react'
|
|
3
|
-
import type {
|
|
3
|
+
import type { RelationshipsOfFlowTypes } from '../_types'
|
|
4
4
|
import * as css from './styles.css'
|
|
5
|
+
import { Text } from '../../../controls/Text'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
component: 'div'
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
type EmptyNodeProps = NodeProps<XYFlowTypes.EmptyNode>
|
|
7
|
+
type EmptyNodeProps = NodeProps<RelationshipsOfFlowTypes.EmptyNode>
|
|
11
8
|
|
|
12
9
|
export function EmptyNode({
|
|
13
10
|
data: {
|