@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
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { Fqn } from '@likec4/core'
|
|
2
|
+
import { IconFileSymlink, IconId, IconTransform, IconZoomScan } from '@tabler/icons-react'
|
|
3
|
+
import { useCallback } from 'react'
|
|
4
|
+
import { useDiagramState, useDiagramStoreApi } from '../../hooks'
|
|
5
|
+
import { type ActionButtonProps, ActionButton } from './ActionButton'
|
|
6
|
+
|
|
7
|
+
export type NodeActionButtonProps = Omit<ActionButtonProps, 'onClick' | 'IconComponent' | 'tooltipLabel'> & {
|
|
8
|
+
fqn: Fqn
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Browse Relationships
|
|
12
|
+
|
|
13
|
+
export const BrowseRelationshipsButton = ({
|
|
14
|
+
fqn,
|
|
15
|
+
...props
|
|
16
|
+
}: NodeActionButtonProps) => {
|
|
17
|
+
const {
|
|
18
|
+
openOverlay,
|
|
19
|
+
} = useDiagramState(s => ({
|
|
20
|
+
openOverlay: s.openOverlay,
|
|
21
|
+
}))
|
|
22
|
+
|
|
23
|
+
const onBrowseRelationships = useCallback((e: React.MouseEvent) => {
|
|
24
|
+
e.stopPropagation()
|
|
25
|
+
openOverlay({ relationshipsOf: fqn })
|
|
26
|
+
}, [openOverlay, fqn])
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ActionButton
|
|
30
|
+
{...props}
|
|
31
|
+
onClick={onBrowseRelationships}
|
|
32
|
+
IconComponent={IconTransform}
|
|
33
|
+
tooltipLabel="Browse relationships"
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Navigate to
|
|
39
|
+
// It triggers the onNavigateTo event from the xynode (node should have a navigateTo property)
|
|
40
|
+
export type NavigateToButtonProps = Omit<ActionButtonProps, 'onClick' | 'IconComponent' | 'tooltipLabel'> & {
|
|
41
|
+
xynodeId: string
|
|
42
|
+
}
|
|
43
|
+
export const NavigateToButton = ({
|
|
44
|
+
xynodeId,
|
|
45
|
+
...props
|
|
46
|
+
}: NavigateToButtonProps) => {
|
|
47
|
+
const store = useDiagramStoreApi()
|
|
48
|
+
|
|
49
|
+
const onNavigateTo = useCallback((e: React.MouseEvent) => {
|
|
50
|
+
e.stopPropagation()
|
|
51
|
+
store.getState().triggerOnNavigateTo(xynodeId, e)
|
|
52
|
+
}, [store, xynodeId])
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ActionButton
|
|
56
|
+
{...props}
|
|
57
|
+
onClick={onNavigateTo}
|
|
58
|
+
IconComponent={IconZoomScan}
|
|
59
|
+
tooltipLabel="Open scoped view"
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Open details
|
|
65
|
+
const VariantsDetailsBtn = {
|
|
66
|
+
idle: {
|
|
67
|
+
'--ai-bg': 'var(--ai-bg-idle)',
|
|
68
|
+
scale: 1,
|
|
69
|
+
opacity: 0.5,
|
|
70
|
+
originX: 0.45,
|
|
71
|
+
originY: 0.55,
|
|
72
|
+
},
|
|
73
|
+
selected: {},
|
|
74
|
+
hovered: {
|
|
75
|
+
scale: 1.2,
|
|
76
|
+
opacity: 0.7,
|
|
77
|
+
},
|
|
78
|
+
'hovered:details': {
|
|
79
|
+
scale: 1.44,
|
|
80
|
+
opacity: 1,
|
|
81
|
+
},
|
|
82
|
+
'tap:details': {
|
|
83
|
+
scale: 1.15,
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
VariantsDetailsBtn['selected'] = VariantsDetailsBtn['hovered']
|
|
87
|
+
|
|
88
|
+
export const OpenDetailsButton = ({
|
|
89
|
+
fqn,
|
|
90
|
+
...props
|
|
91
|
+
}: NodeActionButtonProps) => {
|
|
92
|
+
const {
|
|
93
|
+
openOverlay,
|
|
94
|
+
} = useDiagramState(s => ({
|
|
95
|
+
openOverlay: s.openOverlay,
|
|
96
|
+
}))
|
|
97
|
+
|
|
98
|
+
const onOpenDetails = useCallback((e: React.MouseEvent) => {
|
|
99
|
+
e.stopPropagation()
|
|
100
|
+
openOverlay({ elementDetails: fqn })
|
|
101
|
+
}, [openOverlay, fqn])
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<ActionButton
|
|
105
|
+
variants={VariantsDetailsBtn}
|
|
106
|
+
onClick={onOpenDetails}
|
|
107
|
+
IconComponent={IconId}
|
|
108
|
+
tooltipLabel="Open details"
|
|
109
|
+
data-animate-target="details"
|
|
110
|
+
{...props}
|
|
111
|
+
/>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Open element source
|
|
116
|
+
|
|
117
|
+
export const OpenSourceButton = ({
|
|
118
|
+
fqn,
|
|
119
|
+
...props
|
|
120
|
+
}: NodeActionButtonProps) => {
|
|
121
|
+
const diagramApi = useDiagramStoreApi()
|
|
122
|
+
|
|
123
|
+
const onOpenSource = useCallback((e: React.MouseEvent) => {
|
|
124
|
+
e.stopPropagation()
|
|
125
|
+
diagramApi.getState().onOpenSource?.({
|
|
126
|
+
element: fqn,
|
|
127
|
+
})
|
|
128
|
+
}, [diagramApi, fqn])
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<ActionButton
|
|
132
|
+
{...props}
|
|
133
|
+
onClick={onOpenSource}
|
|
134
|
+
IconComponent={IconFileSymlink}
|
|
135
|
+
tooltipLabel="Open source"
|
|
136
|
+
/>
|
|
137
|
+
)
|
|
138
|
+
}
|
package/src/hooks/useXYFlow.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { useInternalNode, useNodesData, useReactFlow, useStore, useStoreApi } from '@xyflow/react'
|
|
2
2
|
import { deepEqual, shallowEqual } from 'fast-equals'
|
|
3
3
|
import { useCallback } from 'react'
|
|
4
|
-
import type {
|
|
4
|
+
import type { DiagramFlowTypes } from '../xyflow/types'
|
|
5
5
|
|
|
6
|
-
export const useXYFlow = useReactFlow<
|
|
6
|
+
export const useXYFlow = useReactFlow<DiagramFlowTypes.Node, DiagramFlowTypes.Edge>
|
|
7
7
|
|
|
8
|
-
export const useXYNodesData = useNodesData<
|
|
9
|
-
export const useXYInternalNode = useInternalNode<
|
|
8
|
+
export const useXYNodesData = useNodesData<DiagramFlowTypes.Node>
|
|
9
|
+
export const useXYInternalNode = useInternalNode<DiagramFlowTypes.Node>
|
|
10
10
|
|
|
11
11
|
export function useXYStore<StateSlice = unknown>(
|
|
12
|
-
selector: (state: XYFlowState) => StateSlice,
|
|
12
|
+
selector: (state: DiagramFlowTypes.XYFlowState) => StateSlice,
|
|
13
13
|
equalityFn?: (a: StateSlice, b: StateSlice) => boolean
|
|
14
14
|
): StateSlice {
|
|
15
15
|
return useStore(
|
|
@@ -17,15 +17,15 @@ export function useXYStore<StateSlice = unknown>(
|
|
|
17
17
|
equalityFn ?? shallowEqual
|
|
18
18
|
)
|
|
19
19
|
}
|
|
20
|
-
export const useXYStoreApi = useStoreApi<
|
|
20
|
+
export const useXYStoreApi = useStoreApi<DiagramFlowTypes.Node, DiagramFlowTypes.Edge>
|
|
21
21
|
export type XYStoreApi = ReturnType<typeof useXYStoreApi>
|
|
22
22
|
|
|
23
|
-
export function useXYEdgesData(edgeIds: string[]): Pick<
|
|
23
|
+
export function useXYEdgesData(edgeIds: string[]): Pick<DiagramFlowTypes.Edge, 'id' | 'data'>[] {
|
|
24
24
|
const ids = edgeIds.join(',')
|
|
25
25
|
const edgesData = useXYStore(
|
|
26
26
|
useCallback(
|
|
27
27
|
(s) => {
|
|
28
|
-
const data = [] as Pick<
|
|
28
|
+
const data = [] as Pick<DiagramFlowTypes.Edge, 'id' | 'data'>[]
|
|
29
29
|
for (const id of edgeIds) {
|
|
30
30
|
const edge = s.edgeLookup.get(id)
|
|
31
31
|
if (edge) {
|
package/src/index.ts
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import '@xyflow/react/dist/style.css'
|
|
2
2
|
|
|
3
3
|
export { LikeC4Diagram } from './LikeC4Diagram'
|
|
4
|
+
export type { LikeC4DiagramProps } from './LikeC4Diagram'
|
|
5
|
+
|
|
4
6
|
export {
|
|
5
7
|
useLikeC4DiagramView,
|
|
8
|
+
useLikeC4ElementModel,
|
|
9
|
+
useLikeC4ElementsTree,
|
|
6
10
|
useLikeC4Model,
|
|
7
11
|
useLikeC4View,
|
|
8
12
|
useLikeC4ViewModel,
|
|
9
|
-
useLikeC4Views
|
|
10
|
-
} from './likec4model
|
|
13
|
+
useLikeC4Views,
|
|
14
|
+
} from './likec4model'
|
|
11
15
|
export { LikeC4ModelProvider } from './LikeC4ModelProvider'
|
|
12
|
-
export { StaticLikeC4Diagram } from './StaticLikeC4Diagram'
|
|
13
16
|
|
|
14
17
|
export { useSetState } from './hooks/useSetState'
|
|
15
18
|
export { useUpdateEffect } from './hooks/useUpdateEffect'
|
|
16
|
-
export
|
|
19
|
+
export { vars, xyvars } from './theme-vars'
|
|
20
|
+
|
|
17
21
|
export type * from './LikeC4Diagram.props'
|
|
18
|
-
|
|
19
|
-
export type * from './StaticLikeC4Diagram'
|
|
22
|
+
|
|
20
23
|
export type * from './xyflow/types'
|
|
24
|
+
|
|
25
|
+
export { StaticLikeC4Diagram } from './StaticLikeC4Diagram'
|
|
26
|
+
export type { StaticLikeC4DiagramProps } from './StaticLikeC4Diagram'
|
package/src/likec4model/index.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
useLikeC4ElementsTree,
|
|
3
|
+
} from './useLikeC4ElementsTree'
|
|
4
|
+
export {
|
|
5
|
+
useLikeC4CurrentViewModel,
|
|
6
|
+
useLikeC4DiagramView,
|
|
7
|
+
useLikeC4ElementModel,
|
|
8
|
+
useLikeC4Model,
|
|
9
|
+
useLikeC4View,
|
|
10
|
+
useLikeC4ViewModel,
|
|
11
|
+
useLikeC4Views,
|
|
12
|
+
} from './useLikeC4Model'
|
|
@@ -11,8 +11,10 @@ import {
|
|
|
11
11
|
ViewportPortal
|
|
12
12
|
} from '@xyflow/react'
|
|
13
13
|
import { memo, useEffect } from 'react'
|
|
14
|
+
import { only } from 'remeda'
|
|
14
15
|
import { useDiagramStoreApi } from '../../hooks/useDiagramState'
|
|
15
|
-
import type {
|
|
16
|
+
import type { SharedFlowTypes } from '../shared/xyflow/_types'
|
|
17
|
+
import type { EdgeDetailsFlowTypes } from './_types'
|
|
16
18
|
import { SelectEdge } from './SelectEdge'
|
|
17
19
|
import * as css from './SelectEdge.css'
|
|
18
20
|
import { useLayoutedEdgeDetails, ZIndexes } from './use-layouted-edge-details'
|
|
@@ -28,7 +30,7 @@ const edgeTypes = {
|
|
|
28
30
|
relation: RelationshipEdge
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
const resetDimmedAndHovered = (xyflow: ReactFlowInstance<
|
|
33
|
+
const resetDimmedAndHovered = (xyflow: ReactFlowInstance<SharedFlowTypes.Node, EdgeDetailsFlowTypes.Edge>) => {
|
|
32
34
|
xyflow.setEdges(edges =>
|
|
33
35
|
edges.map(edge => ({
|
|
34
36
|
...edge,
|
|
@@ -49,12 +51,12 @@ const resetDimmedAndHovered = (xyflow: ReactFlowInstance<XYFlowTypes.Node, XYFlo
|
|
|
49
51
|
dimmed: false,
|
|
50
52
|
hovered: false
|
|
51
53
|
}
|
|
52
|
-
}) as
|
|
54
|
+
}) as SharedFlowTypes.Node
|
|
53
55
|
)
|
|
54
56
|
)
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
const animateEdge = (node:
|
|
59
|
+
const animateEdge = (node: SharedFlowTypes.Node, animated = true) => (edges: EdgeDetailsFlowTypes.Edge[]) => {
|
|
58
60
|
return edges.map(edge => {
|
|
59
61
|
const isConnected = edge.source === node.id || edge.target === node.id || isAncestor(node.id, edge.source)
|
|
60
62
|
|| isAncestor(node.id, edge.target)
|
|
@@ -78,8 +80,8 @@ export const EdgeDetailsXYFlow = memo<{ edgeId: EdgeId }>(function EdgeDetailsXY
|
|
|
78
80
|
|
|
79
81
|
const boundsRef = useSyncedRef(bounds)
|
|
80
82
|
|
|
81
|
-
const xyflow = useReactFlow<
|
|
82
|
-
const xystore = useStoreApi<
|
|
83
|
+
const xyflow = useReactFlow<SharedFlowTypes.Node, EdgeDetailsFlowTypes.Edge>()
|
|
84
|
+
const xystore = useStoreApi<SharedFlowTypes.Node, EdgeDetailsFlowTypes.Edge>()
|
|
83
85
|
|
|
84
86
|
const fitview = useDebouncedCallback(
|
|
85
87
|
() => {
|
|
@@ -115,8 +117,8 @@ export const EdgeDetailsXYFlow = memo<{ edgeId: EdgeId }>(function EdgeDetailsXY
|
|
|
115
117
|
|
|
116
118
|
return (
|
|
117
119
|
<ReactFlow
|
|
118
|
-
defaultEdges={[] as
|
|
119
|
-
defaultNodes={[] as
|
|
120
|
+
defaultEdges={[] as EdgeDetailsFlowTypes.Edge[]}
|
|
121
|
+
defaultNodes={[] as SharedFlowTypes.Node[]}
|
|
120
122
|
nodeTypes={nodeTypes}
|
|
121
123
|
edgeTypes={edgeTypes}
|
|
122
124
|
defaultMarkerColor="var(--xy-edge-stroke)"
|
|
@@ -168,7 +170,7 @@ export const EdgeDetailsXYFlow = memo<{ edgeId: EdgeId }>(function EdgeDetailsXY
|
|
|
168
170
|
...n.data,
|
|
169
171
|
dimmed: n.id !== edge.source && n.id !== edge.target
|
|
170
172
|
}
|
|
171
|
-
} as
|
|
173
|
+
} as SharedFlowTypes.Node))
|
|
172
174
|
)
|
|
173
175
|
}}
|
|
174
176
|
onEdgeMouseLeave={() => {
|
|
@@ -194,9 +196,13 @@ export const EdgeDetailsXYFlow = memo<{ edgeId: EdgeId }>(function EdgeDetailsXY
|
|
|
194
196
|
// }}
|
|
195
197
|
onEdgeClick={(e, edge) => {
|
|
196
198
|
e.stopPropagation()
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
// edge-details only ever deals with edges that represent only one relation
|
|
200
|
+
let relationId = only(edge.data.relations)?.id
|
|
201
|
+
if (relationId) {
|
|
202
|
+
diagramStore.getState().onOpenSource?.({
|
|
203
|
+
relation: relationId
|
|
204
|
+
})
|
|
205
|
+
}
|
|
200
206
|
}}
|
|
201
207
|
// onEdgeClick={(e, edge) => {
|
|
202
208
|
// e.stopPropagation()
|
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { SetRequired } from 'type-fest'
|
|
1
|
+
import type { AddEdgeData } from '../../utils/types'
|
|
2
|
+
import type { SharedFlowTypes } from '../shared/xyflow/_types'
|
|
4
3
|
|
|
5
|
-
export namespace
|
|
6
|
-
type NodeProps = {
|
|
7
|
-
fqn: Fqn
|
|
8
|
-
element: Pick<ComputedNode, 'color' | 'title' | 'description' | 'shape' | 'kind'>
|
|
9
|
-
ports: {
|
|
10
|
-
in: string[]
|
|
11
|
-
out: string[]
|
|
12
|
-
}
|
|
13
|
-
navigateTo: ViewId | null
|
|
14
|
-
hovered?: boolean
|
|
15
|
-
/**
|
|
16
|
-
* Whether the node is dimmed
|
|
17
|
-
* 'immediate' means that the node is dimmed without delay
|
|
18
|
-
*/
|
|
19
|
-
dimmed?: 'immediate' | boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type ElementNode = SetRequired<ReactFlowNode<NodeProps, 'element'>, 'type'>
|
|
23
|
-
|
|
24
|
-
export type CompoundNode = SetRequired<ReactFlowNode<NodeProps, 'compound'>, 'type'>
|
|
4
|
+
export namespace EdgeDetailsFlowTypes {
|
|
25
5
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// relation: Relation
|
|
34
|
-
navigateTo: ViewId | null
|
|
35
|
-
hovered?: boolean
|
|
36
|
-
dimmed?: boolean
|
|
37
|
-
}
|
|
38
|
-
type: 'relation'
|
|
6
|
+
/**
|
|
7
|
+
* Data that is exclusive to the edge-details overlay. It will be merged into the edge types
|
|
8
|
+
* provided by SharedFlowTypes.
|
|
9
|
+
*/
|
|
10
|
+
type EdgeDetailsEdgeData = {
|
|
11
|
+
technology: string | null
|
|
12
|
+
description: string | null
|
|
39
13
|
}
|
|
40
14
|
|
|
41
|
-
|
|
15
|
+
// Extend the edge types provided by SharedFlowTypes with EdgeDetailsEdgeData
|
|
16
|
+
|
|
17
|
+
export type Edge = AddEdgeData<SharedFlowTypes.Edge, EdgeDetailsEdgeData>
|
|
42
18
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import dagre, { type GraphLabel, type Label } from '@dagrejs/dagre'
|
|
2
2
|
import {
|
|
3
|
+
type AbstractRelation,
|
|
3
4
|
compareFqnHierarchically,
|
|
4
5
|
compareRelations,
|
|
5
6
|
type DiagramEdge,
|
|
@@ -16,7 +17,8 @@ import { useMemo } from 'react'
|
|
|
16
17
|
import { filter, first, forEach, isTruthy, map, pipe, prop, reverse, sort, sortBy, takeWhile } from 'remeda'
|
|
17
18
|
import { useDiagramState } from '../../hooks/useDiagramState'
|
|
18
19
|
import { useLikeC4Model } from '../../likec4model'
|
|
19
|
-
import type {
|
|
20
|
+
import type { SharedFlowTypes } from '../shared/xyflow/_types'
|
|
21
|
+
import type { EdgeDetailsFlowTypes } from './_types'
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* All constants related to the layout
|
|
@@ -67,16 +69,16 @@ function createGraph() {
|
|
|
67
69
|
type Context = {
|
|
68
70
|
g: dagre.graphlib.Graph
|
|
69
71
|
diagramNodes: Map<Fqn, DiagramNode>
|
|
70
|
-
xynodes: Map<Fqn,
|
|
72
|
+
xynodes: Map<Fqn, SharedFlowTypes.NonEmptyNode>
|
|
71
73
|
edge: DiagramEdge
|
|
72
|
-
edges:
|
|
74
|
+
edges: EdgeDetailsFlowTypes.Edge[]
|
|
73
75
|
}
|
|
74
76
|
const sized = (height: number = Sizes.hodeHeight) => ({
|
|
75
77
|
width: Sizes.nodeWidth,
|
|
76
78
|
height
|
|
77
79
|
})
|
|
78
80
|
|
|
79
|
-
const graphId = (node:
|
|
81
|
+
const graphId = (node: SharedFlowTypes.Node) => ({
|
|
80
82
|
id: node.id,
|
|
81
83
|
port: node.type === 'compound' ? `${node.id}::port` : node.id,
|
|
82
84
|
body: `${node.id}`,
|
|
@@ -86,7 +88,7 @@ const graphId = (node: XYFlowTypes.Node) => ({
|
|
|
86
88
|
function nodeData(
|
|
87
89
|
element: LikeC4Model.Element,
|
|
88
90
|
ctx: Context
|
|
89
|
-
):
|
|
91
|
+
): SharedFlowTypes.OverlayNodeData {
|
|
90
92
|
// We try to inherit style from existing diagram node
|
|
91
93
|
let diagramNode = ctx.diagramNodes.get(element.id)
|
|
92
94
|
|
|
@@ -117,10 +119,10 @@ function nodeData(
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
function createNode(
|
|
120
|
-
nodeType:
|
|
122
|
+
nodeType: SharedFlowTypes.NonEmptyNode['type'],
|
|
121
123
|
element: LikeC4Model.Element,
|
|
122
124
|
ctx: Context
|
|
123
|
-
):
|
|
125
|
+
): SharedFlowTypes.Node {
|
|
124
126
|
let node = ctx.xynodes.get(element.id)
|
|
125
127
|
if (node) {
|
|
126
128
|
return node
|
|
@@ -135,7 +137,7 @@ function createNode(
|
|
|
135
137
|
found => found ? createNode('compound', found, ctx) : null
|
|
136
138
|
)
|
|
137
139
|
|
|
138
|
-
const xynode:
|
|
140
|
+
const xynode: SharedFlowTypes.NonEmptyNode = {
|
|
139
141
|
type: nodeType,
|
|
140
142
|
id: element.id,
|
|
141
143
|
position: { x: 0, y: 0 },
|
|
@@ -181,7 +183,7 @@ function createNode(
|
|
|
181
183
|
* And return a function to get node bounds for xyflow
|
|
182
184
|
*/
|
|
183
185
|
function applyDagreLayout(g: dagre.graphlib.Graph) {
|
|
184
|
-
type NodeBounds = Required<Pick<
|
|
186
|
+
type NodeBounds = Required<Pick<SharedFlowTypes.Node, 'position' | 'width' | 'height'>>
|
|
185
187
|
dagre.layout(g)
|
|
186
188
|
return function nodeBounds(nodeId: string, relativeTo?: string): NodeBounds {
|
|
187
189
|
const { x, y, width, height } = g.node(nodeId)
|
|
@@ -215,8 +217,8 @@ function layout(
|
|
|
215
217
|
): {
|
|
216
218
|
view: DiagramView
|
|
217
219
|
edge: DiagramEdge
|
|
218
|
-
nodes:
|
|
219
|
-
edges:
|
|
220
|
+
nodes: SharedFlowTypes.Node[]
|
|
221
|
+
edges: EdgeDetailsFlowTypes.Edge[]
|
|
220
222
|
bounds: { x: number; y: number; width: number; height: number }
|
|
221
223
|
} {
|
|
222
224
|
const edge = view.edges.find(e => e.id === edgeId)
|
|
@@ -231,7 +233,7 @@ function layout(
|
|
|
231
233
|
return {
|
|
232
234
|
source: relation.source.id,
|
|
233
235
|
target: relation.target.id,
|
|
234
|
-
relation: relation.$relationship
|
|
236
|
+
relation: relation.$relationship as AbstractRelation
|
|
235
237
|
}
|
|
236
238
|
})
|
|
237
239
|
.sort(compareRelations)
|
|
@@ -272,7 +274,7 @@ function layout(
|
|
|
272
274
|
target.data.ports.in.push(source.id)
|
|
273
275
|
|
|
274
276
|
g.setEdge(graphId(source).port, graphId(target).port)
|
|
275
|
-
const edge:
|
|
277
|
+
const edge: EdgeDetailsFlowTypes.Edge = {
|
|
276
278
|
id: relation.id,
|
|
277
279
|
type: 'relation',
|
|
278
280
|
source: source.id,
|
|
@@ -280,7 +282,7 @@ function layout(
|
|
|
280
282
|
sourceHandle: target.id,
|
|
281
283
|
targetHandle: source.id,
|
|
282
284
|
data: {
|
|
283
|
-
|
|
285
|
+
relations: [relation],
|
|
284
286
|
navigateTo: relation.navigateTo ?? null,
|
|
285
287
|
technology: relation.technology ?? null,
|
|
286
288
|
description: relation.description ?? null
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { Text as MantineText } from '@mantine/core'
|
|
2
1
|
import { Handle, type NodeProps, Position } from '@xyflow/react'
|
|
3
2
|
import clsx from 'clsx'
|
|
4
3
|
import { m } from 'framer-motion'
|
|
5
|
-
import type {
|
|
4
|
+
import type { SharedFlowTypes } from '../../shared/xyflow/_types'
|
|
6
5
|
import * as css from './styles.css'
|
|
6
|
+
import { Text } from '../../../controls/Text'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
component: 'div'
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
type CompoundNodeProps = NodeProps<XYFlowTypes.CompoundNode>
|
|
8
|
+
type CompoundNodeProps = NodeProps<SharedFlowTypes.CompoundNode>
|
|
13
9
|
|
|
14
10
|
export function CompoundNode({
|
|
15
11
|
data: {
|
|
@@ -71,10 +67,6 @@ export function CompoundNode({
|
|
|
71
67
|
top: `${16 + 20 * i}px`
|
|
72
68
|
}} />
|
|
73
69
|
))}
|
|
74
|
-
{
|
|
75
|
-
/* <Handle type="target" position={Position.Left}/>
|
|
76
|
-
<Handle type="source" position={Position.Right}/> */
|
|
77
|
-
}
|
|
78
70
|
</>
|
|
79
71
|
)
|
|
80
72
|
}
|
|
@@ -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'
|
|
@@ -7,8 +7,9 @@ import { type DiagramState, useDiagramState } from '../../../hooks'
|
|
|
7
7
|
import { ElementShapeSvg } from '../../../xyflow/nodes/element/ElementShapeSvg'
|
|
8
8
|
import { stopPropagation } from '../../../xyflow/utils'
|
|
9
9
|
import { useOverlayDialog } from '../../OverlayContext'
|
|
10
|
-
import type {
|
|
10
|
+
import type { SharedFlowTypes } from '../../shared/xyflow/_types'
|
|
11
11
|
import * as css from './styles.css'
|
|
12
|
+
import { Text } from '../../../controls/Text'
|
|
12
13
|
|
|
13
14
|
const Action = ActionIcon.withProps({
|
|
14
15
|
className: 'nodrag nopan ' + css.navigateBtn,
|
|
@@ -18,11 +19,7 @@ const Action = ActionIcon.withProps({
|
|
|
18
19
|
onPointerDownCapture: stopPropagation
|
|
19
20
|
})
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
component: 'div'
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
type ElementNodeProps = NodeProps<XYFlowTypes.ElementNode>
|
|
22
|
+
type ElementNodeProps = NodeProps<SharedFlowTypes.ElementNode>
|
|
26
23
|
|
|
27
24
|
function selector(s: DiagramState) {
|
|
28
25
|
return {
|
|
@@ -150,10 +147,6 @@ export function ElementNode({
|
|
|
150
147
|
top: `${15 + (i + 1) * ((h - 30) / (ports.in.length + 1))}px`
|
|
151
148
|
}} />
|
|
152
149
|
))}
|
|
153
|
-
{
|
|
154
|
-
/* <Handle type="target" position={Position.Left} />
|
|
155
|
-
<Handle type="source" position={Position.Right} /> */
|
|
156
|
-
}
|
|
157
150
|
</>
|
|
158
151
|
)
|
|
159
152
|
}
|
|
@@ -5,15 +5,15 @@ import clsx from 'clsx'
|
|
|
5
5
|
import { useDiagramState } from '../../../hooks/useDiagramState'
|
|
6
6
|
import { stopPropagation } from '../../../xyflow/utils'
|
|
7
7
|
import { useOverlayDialog } from '../../OverlayContext'
|
|
8
|
-
import
|
|
8
|
+
import * as css from '../../shared/xyflow/RelationshipEdge.css'
|
|
9
|
+
import type { EdgeDetailsFlowTypes } from '../_types'
|
|
9
10
|
import { ZIndexes } from '../use-layouted-edge-details'
|
|
10
|
-
import * as css from './styles.css'
|
|
11
11
|
|
|
12
12
|
export function RelationshipEdge({
|
|
13
13
|
data,
|
|
14
14
|
label,
|
|
15
15
|
...props
|
|
16
|
-
}: EdgeProps<
|
|
16
|
+
}: EdgeProps<EdgeDetailsFlowTypes.Edge>) {
|
|
17
17
|
const overlay = useOverlayDialog()
|
|
18
18
|
const onNavigateTo = useDiagramState(s => s.onNavigateTo)
|
|
19
19
|
const [edgePath, labelX, labelY] = getBezierPath(props)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { globalStyle, style } from '@vanilla-extract/css'
|
|
2
|
-
import { mantine,
|
|
3
|
-
import { mixColor } from '../../Overlays.css'
|
|
2
|
+
import { mantine, vars } from '../../../theme-vars'
|
|
4
3
|
|
|
5
4
|
export const elementNode = style({
|
|
6
5
|
width: '100%',
|
|
@@ -84,63 +83,6 @@ export const cssShapeSvg = style({
|
|
|
84
83
|
zIndex: -1
|
|
85
84
|
})
|
|
86
85
|
|
|
87
|
-
const DimmedTransitionDelay = '400ms'
|
|
88
|
-
|
|
89
|
-
export const edgeContainer = style({
|
|
90
|
-
opacity: 1,
|
|
91
|
-
transition: transitions.fast,
|
|
92
|
-
vars: {
|
|
93
|
-
[xyvars.edge.stroke]: vars.relation.lineColor,
|
|
94
|
-
[xyvars.edge.strokeSelected]: `color-mix(in srgb, ${vars.relation.lineColor}, ${mixColor} 35%)`,
|
|
95
|
-
[xyvars.edge.labelColor]: `color-mix(in srgb, ${vars.relation.labelColor}, rgba(255 255 255 / 0.85) 50%)`,
|
|
96
|
-
[xyvars.edge.labelBgColor]: `color-mix(in srgb, ${vars.relation.labelBgColor}, transparent 20%)`
|
|
97
|
-
},
|
|
98
|
-
selectors: {
|
|
99
|
-
[`&[data-edge-dimmed='true']`]: {
|
|
100
|
-
opacity: 0.2,
|
|
101
|
-
transitionDelay: DimmedTransitionDelay
|
|
102
|
-
},
|
|
103
|
-
[`&[data-edge-dimmed='immediate']`]: {
|
|
104
|
-
opacity: 0.2
|
|
105
|
-
},
|
|
106
|
-
[`${whereDark} &`]: {
|
|
107
|
-
vars: {
|
|
108
|
-
[xyvars.edge.labelBgColor]: `color-mix(in srgb, ${vars.relation.labelBgColor}, transparent 50%)`
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
export const edgeLabel = style([edgeContainer, {
|
|
115
|
-
padding: '2px 5px',
|
|
116
|
-
fontFamily: vars.likec4.font,
|
|
117
|
-
position: 'absolute',
|
|
118
|
-
cursor: 'pointer',
|
|
119
|
-
width: 'fit-content',
|
|
120
|
-
color: xyvars.edge.labelColor,
|
|
121
|
-
backgroundColor: xyvars.edge.labelBgColor,
|
|
122
|
-
borderRadius: 4,
|
|
123
|
-
// everything inside EdgeLabelRenderer has no pointer events by default
|
|
124
|
-
// if you have an interactive element, set pointer-events: all
|
|
125
|
-
pointerEvents: 'all',
|
|
126
|
-
textWrap: 'pretty',
|
|
127
|
-
whiteSpace: 'preserve-breaks'
|
|
128
|
-
}])
|
|
129
|
-
|
|
130
|
-
export const edgeLabelText = style({
|
|
131
|
-
textAlign: 'center',
|
|
132
|
-
whiteSpaceCollapse: 'preserve-breaks',
|
|
133
|
-
fontSize: mantine.fontSizes.md,
|
|
134
|
-
lineHeight: mantine.lineHeights.xs
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
export const edgeLabelTechnology = style({
|
|
138
|
-
textAlign: 'center',
|
|
139
|
-
whiteSpaceCollapse: 'preserve-breaks',
|
|
140
|
-
fontSize: mantine.fontSizes.sm,
|
|
141
|
-
lineHeight: 1
|
|
142
|
-
})
|
|
143
|
-
|
|
144
86
|
export const navigateBtnBox = style({
|
|
145
87
|
zIndex: 100,
|
|
146
88
|
position: 'absolute',
|