@likec4/diagram 1.36.1 → 1.38.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/bundle/{chunk-DHvr-RGh.js → chunk-BZV0K82k.js} +870 -900
- package/bundle/custom.js +64 -56
- package/bundle/index.js +3565 -3327
- package/dist/LikeC4Diagram.props.d.ts +5 -5
- package/dist/LikeC4Styles.js +17 -15
- package/dist/StaticLikeC4Diagram.d.ts +1 -1
- package/dist/StaticLikeC4Diagram.js +3 -0
- package/dist/base/BaseXYFlow.d.ts +1 -1
- package/dist/base/BaseXYFlow.js +25 -27
- package/dist/base/const.d.ts +4 -4
- package/dist/base/const.js +5 -4
- package/dist/base/primitives/MarkdownBlock.js +4 -1
- package/dist/base/primitives/compound/CompoundActionButton.js +27 -42
- package/dist/base/primitives/compound/CompoundDetailsButton.js +23 -48
- package/dist/base/primitives/compound/CompoundNodeContainer.js +16 -48
- package/dist/base/primitives/compound/CompoundTitle.js +5 -80
- package/dist/base/primitives/compound/actionbtns.css.js +1 -13
- package/dist/base/primitives/customEdge.d.ts +1 -1
- package/dist/base/primitives/customNode.d.ts +4 -4
- package/dist/base/primitives/customNode.js +7 -7
- package/dist/base/primitives/edge/EdgeLabel.d.ts +5 -4
- package/dist/base/primitives/edge/EdgeLabel.js +39 -21
- package/dist/base/primitives/edge/EdgeLabelContainer.js +11 -23
- package/dist/base/primitives/edge/edge.css.js +19 -11
- package/dist/base/primitives/element/ElementShape.js +38 -18
- package/dist/base/primitives/element/ElementTags.js +7 -4
- package/dist/base/primitives/element/ElementTitle.js +10 -2
- package/dist/base/types.d.ts +17 -21
- package/dist/bundle/LikeC4View.d.ts +2 -2
- package/dist/bundle/LikeC4View.js +4 -1
- package/dist/bundle/LikeC4View.props.d.ts +2 -2
- package/dist/bundle/ReactLikeC4.d.ts +3 -3
- package/dist/bundle/custom.js +2 -1
- package/dist/bundle/index.js +2 -1
- package/dist/components/Link.js +3 -2
- package/dist/context/ReduceGraphics.js +2 -5
- package/dist/context/RootContainer.js +1 -5
- package/dist/custom/customNodes.d.ts +32 -26
- package/dist/custom/customNodes.js +12 -8
- package/dist/custom/hooks.d.ts +2 -1
- package/dist/custom/index.js +2 -1
- package/dist/globals.css.js +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useDiagram.d.ts +18 -1
- package/dist/hooks/useDiagram.js +18 -2
- package/dist/hooks/useXYFlow.d.ts +40 -21
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/likec4diagram/DiagramUI.js +5 -2
- package/dist/likec4diagram/DiagramXYFlow.js +9 -9
- package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +27 -44
- package/dist/likec4diagram/custom/index.js +3 -3
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +8 -6
- package/dist/likec4diagram/custom/nodes/nodes.js +13 -14
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +3 -2
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +2 -2
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +2 -0
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +441 -0
- package/dist/likec4diagram/relationship-popover/actor.d.ts +177 -0
- package/dist/likec4diagram/relationship-popover/actor.js +155 -0
- package/dist/likec4diagram/relationship-popover/styles.css.d.ts +2 -0
- package/dist/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.js → relationship-popover/styles.css.js} +4 -17
- package/dist/likec4diagram/useLayoutConstraints.js +0 -1
- package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
- package/dist/likec4model/useLikeC4Project.js +15 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +1 -2
- package/dist/navigationpanel/actor.js +1 -2
- package/dist/navigationpanel/controls/NavigationButtons.js +1 -5
- package/dist/navigationpanel/controls/ViewDetailsCard.js +2 -0
- package/dist/overlays/element-details/actor.d.ts +564 -8
- package/dist/overlays/overlay/Overlay.css.d.ts +1 -1
- package/dist/overlays/relationship-details/actor.d.ts +3 -1
- package/dist/overlays/relationship-details/hooks.d.ts +19 -1
- package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -1
- package/dist/overlays/relationship-details/layout.js +1 -2
- package/dist/overlays/relationships-browser/actor.d.ts +26 -2
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +16 -0
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +18 -8
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -1
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/state/DiagramActorProvider.js +2 -19
- package/dist/state/assign.js +24 -10
- package/dist/state/diagram-machine.d.ts +149 -474
- package/dist/state/diagram-machine.js +94 -54
- package/dist/state/types.d.ts +1 -1
- package/dist/styles-min.css +1 -1
- package/dist/styles-xyflow.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/roundDpr.d.ts +1 -0
- package/dist/utils/roundDpr.js +20 -0
- package/dist/utils/xyflow.d.ts +0 -1
- package/dist/utils/xyflow.js +1 -7
- package/package.json +16 -15
- package/panda.buildinfo.json +91 -156
- package/src/LikeC4Diagram.props.ts +5 -5
- package/src/LikeC4Styles.tsx +22 -14
- package/src/StaticLikeC4Diagram.tsx +3 -0
- package/src/base/BaseXYFlow.tsx +26 -29
- package/src/base/const.ts +5 -4
- package/src/base/primitives/MarkdownBlock.tsx +6 -1
- package/src/base/primitives/compound/CompoundActionButton.tsx +31 -43
- package/src/base/primitives/compound/CompoundDetailsButton.tsx +26 -48
- package/src/base/primitives/compound/CompoundNodeContainer.tsx +15 -43
- package/src/base/primitives/compound/CompoundTitle.tsx +4 -76
- package/src/base/primitives/compound/actionbtns.css.ts +0 -12
- package/src/base/primitives/customEdge.ts +1 -1
- package/src/base/primitives/customNode.tsx +20 -24
- package/src/base/primitives/edge/EdgeLabel.tsx +23 -8
- package/src/base/primitives/edge/EdgeLabelContainer.tsx +9 -21
- package/src/base/primitives/edge/edge.css.ts +19 -11
- package/src/base/primitives/element/ElementShape.tsx +40 -18
- package/src/base/primitives/element/ElementTags.tsx +7 -4
- package/src/base/primitives/element/ElementTitle.tsx +23 -11
- package/src/base/types.ts +21 -25
- package/src/bundle/LikeC4View.props.ts +2 -2
- package/src/bundle/LikeC4View.tsx +8 -5
- package/src/bundle/ReactLikeC4.tsx +3 -3
- package/src/components/Link.tsx +3 -2
- package/src/context/RootContainer.tsx +1 -5
- package/src/context/TagStylesContext.tsx +2 -0
- package/src/custom/{customNodes.tsx → customNodes.ts} +58 -52
- package/src/custom/hooks.ts +7 -0
- package/src/globals.css +58 -5
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useDiagram.ts +39 -5
- package/src/hooks/useXYFlow.ts +3 -1
- package/src/index.ts +1 -0
- package/src/likec4diagram/DiagramUI.tsx +3 -0
- package/src/likec4diagram/DiagramXYFlow.tsx +9 -11
- package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +25 -49
- package/src/likec4diagram/custom/index.ts +5 -4
- package/src/likec4diagram/custom/nodes/nodes.tsx +13 -11
- package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +3 -2
- package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +535 -0
- package/src/likec4diagram/relationship-popover/actor.ts +192 -0
- package/src/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.ts → relationship-popover/styles.css.ts} +3 -19
- package/src/likec4diagram/useLayoutConstraints.ts +0 -1
- package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
- package/src/navigationpanel/NavigationPanelDropdown.tsx +1 -2
- package/src/navigationpanel/actor.ts +2 -2
- package/src/navigationpanel/controls/NavigationButtons.tsx +1 -5
- package/src/navigationpanel/controls/ViewDetailsCard.tsx +2 -0
- package/src/overlays/relationship-details/layout-to-xyflow.ts +0 -1
- package/src/overlays/relationship-details/layout.ts +4 -3
- package/src/overlays/relationships-browser/custom/nodeTypes.tsx +22 -8
- package/src/overlays/relationships-browser/useViewToNodesEdges.ts +0 -1
- package/src/state/DiagramActorProvider.tsx +2 -20
- package/src/state/assign.ts +24 -10
- package/src/state/diagram-machine.ts +101 -53
- package/src/state/types.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/roundDpr.ts +27 -0
- package/src/utils/xyflow.ts +0 -7
- package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -35
- package/dist/base/primitives/compound/CompoundNodeContainer.css.js +0 -132
- package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -7
- package/dist/base/primitives/edge/EdgeLabel.css.js +0 -57
- package/dist/base/primitives/element/ElementShape.css.d.ts +0 -6
- package/dist/base/primitives/element/ElementShape.css.js +0 -107
- package/dist/likec4diagram/custom/edges/NotePopover.css.js +0 -21
- package/dist/likec4diagram/custom/edges/NotePopover.js +0 -91
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.d.ts +0 -5
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.d.ts +0 -13
- package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +0 -215
- package/dist/likec4diagram/custom/index.d.ts +0 -62
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +0 -10
- package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -138
- package/src/base/primitives/edge/EdgeLabel.css.ts +0 -64
- package/src/base/primitives/element/ElementShape.css.ts +0 -112
- package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +0 -281
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { css, cx } from '@likec4/styles/css'
|
|
2
|
-
|
|
3
|
-
export const indicator = css({
|
|
4
|
-
_smallZoom: {
|
|
5
|
-
visibility: 'hidden',
|
|
6
|
-
},
|
|
7
|
-
stroke: 'var(--likec4-palette-loContrast)',
|
|
8
|
-
fill: '[none]',
|
|
9
|
-
|
|
10
|
-
strokeWidth: 8,
|
|
11
|
-
strokeOpacity: 0.8,
|
|
12
|
-
visibility: 'hidden',
|
|
13
|
-
pointerEvents: 'none',
|
|
14
|
-
_light: {
|
|
15
|
-
stroke: `[color-mix(in srgb, var(--likec4-palette-fill) 50%,rgb(121, 121, 121))]`,
|
|
16
|
-
},
|
|
17
|
-
_whenFocused: {
|
|
18
|
-
visibility: 'visible',
|
|
19
|
-
},
|
|
20
|
-
_groupFocusVisible: {
|
|
21
|
-
visibility: 'visible',
|
|
22
|
-
},
|
|
23
|
-
_whenSelected: {
|
|
24
|
-
animationStyle: 'indicator',
|
|
25
|
-
visibility: 'visible',
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export const fillElementFill = css({
|
|
30
|
-
fill: 'var(--likec4-palette-fill)',
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
export const fillElementStroke = css({
|
|
34
|
-
fill: 'var(--likec4-palette-stroke)',
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
export const fillMixStroke = css({
|
|
38
|
-
fill: '[color-mix(in srgb, var(--likec4-palette-stroke) 90%, var(--likec4-palette-fill))]',
|
|
39
|
-
'.shape-svg-multiple &': {
|
|
40
|
-
fill: 'var(--likec4-palette-fill)',
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
const shapeBase = css.raw({
|
|
45
|
-
top: '0',
|
|
46
|
-
left: '0',
|
|
47
|
-
position: 'absolute',
|
|
48
|
-
width: '100%',
|
|
49
|
-
height: '100%',
|
|
50
|
-
pointerEvents: 'none',
|
|
51
|
-
fill: 'var(--likec4-palette-fill)',
|
|
52
|
-
stroke: 'var(--likec4-palette-stroke)',
|
|
53
|
-
overflow: 'visible',
|
|
54
|
-
// zIndex is removed to improve rendering performance
|
|
55
|
-
// this forces to keep shape in the same layer as the node
|
|
56
|
-
// zIndex: -1,
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
export const shapeSvgMultiple = cx(
|
|
60
|
-
'shape-svg-multiple',
|
|
61
|
-
css(shapeBase, {
|
|
62
|
-
transformOrigin: {
|
|
63
|
-
base: '50% 50%',
|
|
64
|
-
_shapeQueue: '75% 25%',
|
|
65
|
-
_shapeCylinder: '50% 100%',
|
|
66
|
-
_shapeStorage: '50% 100%',
|
|
67
|
-
},
|
|
68
|
-
transform: 'translate(14px, 14px) perspective(300px) translateZ(-8px)',
|
|
69
|
-
filter: 'brightness(0.65) saturate(0.8)',
|
|
70
|
-
stroke: '[none]',
|
|
71
|
-
display: {
|
|
72
|
-
_smallZoom: 'none',
|
|
73
|
-
_reduceGraphicsOnPan: 'none',
|
|
74
|
-
_whenSelected: 'none',
|
|
75
|
-
_whenFocused: 'none',
|
|
76
|
-
},
|
|
77
|
-
}),
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
export const shapeSvg = css(shapeBase, {
|
|
81
|
-
transition: `fill 120ms linear, filter 130ms {easings.inOut}`,
|
|
82
|
-
transitionDelay: '0ms',
|
|
83
|
-
filter: `
|
|
84
|
-
drop-shadow(0 2px 1px rgba(0, 0, 0, 0.21))
|
|
85
|
-
drop-shadow(0 1px 1px color-mix(in srgb, var(--likec4-palette-stroke) 40%, transparent))
|
|
86
|
-
drop-shadow(0 5px 3px rgba(0, 0, 0, 0.1))
|
|
87
|
-
`,
|
|
88
|
-
_whenHovered: {
|
|
89
|
-
filter: `
|
|
90
|
-
drop-shadow(0 2px 1px rgba(0, 0, 0, 0.25))
|
|
91
|
-
drop-shadow(0 8px 3px rgba(0, 0, 0, 0.1))
|
|
92
|
-
drop-shadow(0 10px 10px rgba(0, 0, 0, 0.05))
|
|
93
|
-
`,
|
|
94
|
-
},
|
|
95
|
-
[`:where([data-likec4-level='true']) &`]: {
|
|
96
|
-
filter: `
|
|
97
|
-
drop-shadow(0 2px 1px rgba(0, 0, 0, 0.25))
|
|
98
|
-
drop-shadow(0 8px 3px rgba(0, 0, 0, 0.1))
|
|
99
|
-
drop-shadow(0 10px 10px rgba(0, 0, 0, 0.05))
|
|
100
|
-
`,
|
|
101
|
-
},
|
|
102
|
-
_whenSelected: {
|
|
103
|
-
filter: 'none',
|
|
104
|
-
},
|
|
105
|
-
_smallZoom: {
|
|
106
|
-
filter: 'none',
|
|
107
|
-
},
|
|
108
|
-
_whenPanning: {
|
|
109
|
-
transition: 'none',
|
|
110
|
-
filter: 'none',
|
|
111
|
-
},
|
|
112
|
-
})
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type DiagramEdge,
|
|
3
|
-
type DiagramNode,
|
|
4
|
-
type EdgeId,
|
|
5
|
-
nameFromFqn,
|
|
6
|
-
} from '@likec4/core'
|
|
7
|
-
import type { LikeC4Model } from '@likec4/core/model'
|
|
8
|
-
import { cx } from '@likec4/styles/css'
|
|
9
|
-
import {
|
|
10
|
-
type StackProps,
|
|
11
|
-
ActionIcon,
|
|
12
|
-
Box,
|
|
13
|
-
Group,
|
|
14
|
-
Menu,
|
|
15
|
-
MenuDivider,
|
|
16
|
-
MenuDropdown,
|
|
17
|
-
MenuItem,
|
|
18
|
-
MenuLabel,
|
|
19
|
-
MenuTarget,
|
|
20
|
-
Space,
|
|
21
|
-
Stack,
|
|
22
|
-
Text,
|
|
23
|
-
Tooltip as MantineTooltip,
|
|
24
|
-
TooltipGroup,
|
|
25
|
-
} from '@mantine/core'
|
|
26
|
-
import { IconArrowRight, IconFileSymlink, IconInfoCircle, IconZoomScan } from '@tabler/icons-react'
|
|
27
|
-
import { type MouseEventHandler, type PropsWithChildren, forwardRef, Fragment, memo, useCallback } from 'react'
|
|
28
|
-
import { filter, isTruthy, map, partition, pipe } from 'remeda'
|
|
29
|
-
import { Link } from '../../../components/Link'
|
|
30
|
-
import { IfEnabled, useDiagramEventHandlers, useEnabledFeatures } from '../../../context'
|
|
31
|
-
import { useMantinePortalProps } from '../../../hooks'
|
|
32
|
-
import { useDiagram, useDiagramContext } from '../../../hooks/useDiagram'
|
|
33
|
-
import { useLikeC4Model } from '../../../likec4model'
|
|
34
|
-
import { findDiagramEdge, findDiagramNode } from '../../../state/utils'
|
|
35
|
-
import * as styles from './RelationshipsDropdownMenu.css'
|
|
36
|
-
|
|
37
|
-
const stopPropagation: MouseEventHandler = (e) => e.stopPropagation()
|
|
38
|
-
|
|
39
|
-
export const Tooltip = MantineTooltip.withProps({
|
|
40
|
-
color: 'gray',
|
|
41
|
-
fz: 'xs',
|
|
42
|
-
openDelay: 300,
|
|
43
|
-
closeDelay: 150,
|
|
44
|
-
label: '',
|
|
45
|
-
children: null,
|
|
46
|
-
offset: 8,
|
|
47
|
-
withinPortal: false,
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
export const RelationshipsDropdownMenu = memo((
|
|
51
|
-
{
|
|
52
|
-
edgeId,
|
|
53
|
-
source,
|
|
54
|
-
target,
|
|
55
|
-
disabled = false,
|
|
56
|
-
children,
|
|
57
|
-
}: PropsWithChildren<{
|
|
58
|
-
edgeId: EdgeId
|
|
59
|
-
source: string
|
|
60
|
-
target: string
|
|
61
|
-
disabled?: boolean | undefined
|
|
62
|
-
}>,
|
|
63
|
-
) => {
|
|
64
|
-
const { diagramEdge, sourceNode, targetNode } = useDiagramContext(
|
|
65
|
-
ctx => ({
|
|
66
|
-
diagramEdge: findDiagramEdge(ctx, edgeId),
|
|
67
|
-
sourceNode: findDiagramNode(ctx, source),
|
|
68
|
-
targetNode: findDiagramNode(ctx, target),
|
|
69
|
-
}),
|
|
70
|
-
undefined,
|
|
71
|
-
[edgeId, source, target],
|
|
72
|
-
)
|
|
73
|
-
const likec4model = useLikeC4Model()
|
|
74
|
-
const diagram = useDiagram()
|
|
75
|
-
|
|
76
|
-
const portalProps = useMantinePortalProps()
|
|
77
|
-
const onClickOpenOverlay = useCallback((e: React.MouseEvent): void => {
|
|
78
|
-
e.stopPropagation()
|
|
79
|
-
diagram.openRelationshipDetails(edgeId)
|
|
80
|
-
}, [edgeId])
|
|
81
|
-
|
|
82
|
-
if (!diagramEdge || !sourceNode || !targetNode) {
|
|
83
|
-
return <>{children}</>
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// const { source, target } = diagramEdge
|
|
87
|
-
|
|
88
|
-
// invariant(sourceNode.type !== 'view-group', 'View group node cannot have relationships')
|
|
89
|
-
// invariant(targetNode.type !== 'view-group', 'View group node cannot have relationships')
|
|
90
|
-
|
|
91
|
-
const [direct, nested] = pipe(
|
|
92
|
-
diagramEdge.relations,
|
|
93
|
-
map(id => {
|
|
94
|
-
try {
|
|
95
|
-
return likec4model.findRelationship(id)
|
|
96
|
-
} catch (e) {
|
|
97
|
-
// View was cached, but likec4model based on new data
|
|
98
|
-
console.error(
|
|
99
|
-
`View is cached and likec4model missing relationship ${id} from ${sourceNode.id} -> ${targetNode.id}`,
|
|
100
|
-
e,
|
|
101
|
-
)
|
|
102
|
-
return null
|
|
103
|
-
}
|
|
104
|
-
}),
|
|
105
|
-
filter(isTruthy),
|
|
106
|
-
partition(r => r.source.id === sourceNode.id && r.target.id === targetNode.id),
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
const renderRelationship = (relationship: LikeC4Model.AnyRelation, index: number) => (
|
|
110
|
-
<Fragment key={relationship.id}>
|
|
111
|
-
{index > 0 && <MenuDivider opacity={0.65} />}
|
|
112
|
-
<MenuItem
|
|
113
|
-
onClick={onClickOpenOverlay}
|
|
114
|
-
component={Relationship}
|
|
115
|
-
relationship={relationship}
|
|
116
|
-
sourceNode={sourceNode}
|
|
117
|
-
targetNode={targetNode}
|
|
118
|
-
edge={diagramEdge} />
|
|
119
|
-
</Fragment>
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
if (direct.length + nested.length === 0) {
|
|
123
|
-
return <>{children}</>
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<Menu
|
|
128
|
-
trigger={'click-hover'}
|
|
129
|
-
openDelay={300}
|
|
130
|
-
closeDelay={450}
|
|
131
|
-
closeOnClickOutside
|
|
132
|
-
clickOutsideEvents={['pointerdown', 'mousedown', 'click']}
|
|
133
|
-
closeOnEscape
|
|
134
|
-
keepMounted={false}
|
|
135
|
-
closeOnItemClick={false}
|
|
136
|
-
disabled={disabled}
|
|
137
|
-
position="bottom-start"
|
|
138
|
-
middlewares={{ size: { padding: 8 } }}
|
|
139
|
-
{...portalProps}
|
|
140
|
-
>
|
|
141
|
-
<MenuTarget>
|
|
142
|
-
{children}
|
|
143
|
-
</MenuTarget>
|
|
144
|
-
<MenuDropdown
|
|
145
|
-
className={styles.menuDropdown}
|
|
146
|
-
onPointerDownCapture={stopPropagation}
|
|
147
|
-
onPointerDown={stopPropagation}
|
|
148
|
-
onClick={stopPropagation}
|
|
149
|
-
>
|
|
150
|
-
{direct.length > 0 && (
|
|
151
|
-
<>
|
|
152
|
-
<MenuLabel>direct relationships</MenuLabel>
|
|
153
|
-
{direct.map(renderRelationship)}
|
|
154
|
-
</>
|
|
155
|
-
)}
|
|
156
|
-
{nested.length > 0 && (
|
|
157
|
-
<>
|
|
158
|
-
{direct.length > 0 && <MenuDivider />}
|
|
159
|
-
<MenuLabel>resolved from nested</MenuLabel>
|
|
160
|
-
{nested.map(renderRelationship)}
|
|
161
|
-
</>
|
|
162
|
-
)}
|
|
163
|
-
<Box pos={'absolute'} top={5} right={6}>
|
|
164
|
-
<ActionIcon
|
|
165
|
-
size={24}
|
|
166
|
-
variant="subtle"
|
|
167
|
-
onClick={onClickOpenOverlay}
|
|
168
|
-
>
|
|
169
|
-
<IconInfoCircle style={{ width: '70%' }} />
|
|
170
|
-
</ActionIcon>
|
|
171
|
-
</Box>
|
|
172
|
-
</MenuDropdown>
|
|
173
|
-
</Menu>
|
|
174
|
-
)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
const Relationship = forwardRef<
|
|
178
|
-
HTMLDivElement,
|
|
179
|
-
StackProps & {
|
|
180
|
-
relationship: LikeC4Model.AnyRelation
|
|
181
|
-
edge: DiagramEdge
|
|
182
|
-
sourceNode: DiagramNode
|
|
183
|
-
targetNode: DiagramNode
|
|
184
|
-
}
|
|
185
|
-
>(({
|
|
186
|
-
className,
|
|
187
|
-
relationship: r,
|
|
188
|
-
edge,
|
|
189
|
-
sourceNode,
|
|
190
|
-
targetNode,
|
|
191
|
-
...props
|
|
192
|
-
}, ref) => {
|
|
193
|
-
const diagram = useDiagram()
|
|
194
|
-
const { enableNavigateTo } = useEnabledFeatures()
|
|
195
|
-
const { onOpenSource } = useDiagramEventHandlers()
|
|
196
|
-
const viewId = diagram.currentView.id
|
|
197
|
-
|
|
198
|
-
const sourceId = getShortId(r, r.source.id, sourceNode)
|
|
199
|
-
const targetId = getShortId(r, r.target.id, targetNode)
|
|
200
|
-
const navigateTo = enableNavigateTo && r.navigateTo?.id !== viewId ? r.navigateTo?.id : undefined
|
|
201
|
-
const links = r.links
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<Stack ref={ref} className={cx(styles.menuItemRelationship, className)} {...props}>
|
|
205
|
-
<Group gap={4}>
|
|
206
|
-
<Text component="div" data-likec4-color={sourceNode.color} className={styles.endpoint}>
|
|
207
|
-
{sourceId}
|
|
208
|
-
</Text>
|
|
209
|
-
<IconArrowRight stroke={2.5} size={'11px'} opacity={0.65} />
|
|
210
|
-
<Text component="div" data-likec4-color={targetNode.color} className={styles.endpoint}>
|
|
211
|
-
{targetId}
|
|
212
|
-
</Text>
|
|
213
|
-
{(navigateTo || !!onOpenSource) && (
|
|
214
|
-
<TooltipGroup openDelay={100}>
|
|
215
|
-
<Space w={'xs'} />
|
|
216
|
-
{navigateTo && (
|
|
217
|
-
<Tooltip label={'Open dynamic view'}>
|
|
218
|
-
<ActionIcon
|
|
219
|
-
className={cx('nodrag nopan')}
|
|
220
|
-
size={'sm'}
|
|
221
|
-
radius="sm"
|
|
222
|
-
variant="default"
|
|
223
|
-
onPointerDownCapture={stopPropagation}
|
|
224
|
-
onClick={event => {
|
|
225
|
-
event.stopPropagation()
|
|
226
|
-
diagram.navigateTo(navigateTo)
|
|
227
|
-
}}
|
|
228
|
-
role="button"
|
|
229
|
-
>
|
|
230
|
-
<IconZoomScan size="80%" stroke={2} />
|
|
231
|
-
</ActionIcon>
|
|
232
|
-
</Tooltip>
|
|
233
|
-
)}
|
|
234
|
-
<IfEnabled feature="Vscode">
|
|
235
|
-
<Tooltip label={'Open source'}>
|
|
236
|
-
<ActionIcon
|
|
237
|
-
className={cx('nodrag nopan')}
|
|
238
|
-
size={'sm'}
|
|
239
|
-
radius="sm"
|
|
240
|
-
variant="default"
|
|
241
|
-
onPointerDownCapture={stopPropagation}
|
|
242
|
-
onClick={event => {
|
|
243
|
-
event.stopPropagation()
|
|
244
|
-
diagram.openSource({ relation: r.id })
|
|
245
|
-
}}
|
|
246
|
-
role="button"
|
|
247
|
-
>
|
|
248
|
-
<IconFileSymlink size="80%" stroke={2} />
|
|
249
|
-
</ActionIcon>
|
|
250
|
-
</Tooltip>
|
|
251
|
-
</IfEnabled>
|
|
252
|
-
</TooltipGroup>
|
|
253
|
-
)}
|
|
254
|
-
</Group>
|
|
255
|
-
<Box className={styles.title}>{r.title || 'untitled'}</Box>
|
|
256
|
-
{r.description.nonEmpty && <Text size="xs" c="dimmed">{r.description.text}</Text>}
|
|
257
|
-
{links.length > 0 && (
|
|
258
|
-
<Stack
|
|
259
|
-
gap={3}
|
|
260
|
-
justify="stretch"
|
|
261
|
-
align="stretch">
|
|
262
|
-
{links.map((link) => <Link key={link.url} size="sm" value={link} />)}
|
|
263
|
-
</Stack>
|
|
264
|
-
)}
|
|
265
|
-
</Stack>
|
|
266
|
-
)
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
function getShortId(
|
|
270
|
-
r: LikeC4Model.AnyRelation,
|
|
271
|
-
actualEndpointId: string,
|
|
272
|
-
diagramNode: DiagramNode,
|
|
273
|
-
) {
|
|
274
|
-
const diagramNodeId = r.isDeploymentRelation()
|
|
275
|
-
// Relation defined in deployment model. Use id of the deployment node as is.
|
|
276
|
-
? diagramNode.id
|
|
277
|
-
// Relation defined in model. Get id of the model element
|
|
278
|
-
: diagramNode.modelRef || ''
|
|
279
|
-
|
|
280
|
-
return nameFromFqn(diagramNodeId) + actualEndpointId.slice(diagramNodeId.length)
|
|
281
|
-
}
|