@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.
Files changed (173) hide show
  1. package/bundle/{chunk-DHvr-RGh.js → chunk-BZV0K82k.js} +870 -900
  2. package/bundle/custom.js +64 -56
  3. package/bundle/index.js +3565 -3327
  4. package/dist/LikeC4Diagram.props.d.ts +5 -5
  5. package/dist/LikeC4Styles.js +17 -15
  6. package/dist/StaticLikeC4Diagram.d.ts +1 -1
  7. package/dist/StaticLikeC4Diagram.js +3 -0
  8. package/dist/base/BaseXYFlow.d.ts +1 -1
  9. package/dist/base/BaseXYFlow.js +25 -27
  10. package/dist/base/const.d.ts +4 -4
  11. package/dist/base/const.js +5 -4
  12. package/dist/base/primitives/MarkdownBlock.js +4 -1
  13. package/dist/base/primitives/compound/CompoundActionButton.js +27 -42
  14. package/dist/base/primitives/compound/CompoundDetailsButton.js +23 -48
  15. package/dist/base/primitives/compound/CompoundNodeContainer.js +16 -48
  16. package/dist/base/primitives/compound/CompoundTitle.js +5 -80
  17. package/dist/base/primitives/compound/actionbtns.css.js +1 -13
  18. package/dist/base/primitives/customEdge.d.ts +1 -1
  19. package/dist/base/primitives/customNode.d.ts +4 -4
  20. package/dist/base/primitives/customNode.js +7 -7
  21. package/dist/base/primitives/edge/EdgeLabel.d.ts +5 -4
  22. package/dist/base/primitives/edge/EdgeLabel.js +39 -21
  23. package/dist/base/primitives/edge/EdgeLabelContainer.js +11 -23
  24. package/dist/base/primitives/edge/edge.css.js +19 -11
  25. package/dist/base/primitives/element/ElementShape.js +38 -18
  26. package/dist/base/primitives/element/ElementTags.js +7 -4
  27. package/dist/base/primitives/element/ElementTitle.js +10 -2
  28. package/dist/base/types.d.ts +17 -21
  29. package/dist/bundle/LikeC4View.d.ts +2 -2
  30. package/dist/bundle/LikeC4View.js +4 -1
  31. package/dist/bundle/LikeC4View.props.d.ts +2 -2
  32. package/dist/bundle/ReactLikeC4.d.ts +3 -3
  33. package/dist/bundle/custom.js +2 -1
  34. package/dist/bundle/index.js +2 -1
  35. package/dist/components/Link.js +3 -2
  36. package/dist/context/ReduceGraphics.js +2 -5
  37. package/dist/context/RootContainer.js +1 -5
  38. package/dist/custom/customNodes.d.ts +32 -26
  39. package/dist/custom/customNodes.js +12 -8
  40. package/dist/custom/hooks.d.ts +2 -1
  41. package/dist/custom/index.js +2 -1
  42. package/dist/globals.css.js +1 -1
  43. package/dist/hooks/index.d.ts +1 -1
  44. package/dist/hooks/useDiagram.d.ts +18 -1
  45. package/dist/hooks/useDiagram.js +18 -2
  46. package/dist/hooks/useXYFlow.d.ts +40 -21
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +2 -1
  49. package/dist/likec4diagram/DiagramUI.js +5 -2
  50. package/dist/likec4diagram/DiagramXYFlow.js +9 -9
  51. package/dist/likec4diagram/custom/edges/RelationshipEdge.d.ts +3 -3
  52. package/dist/likec4diagram/custom/edges/RelationshipEdge.js +27 -44
  53. package/dist/likec4diagram/custom/index.js +3 -3
  54. package/dist/likec4diagram/custom/nodes/nodes.d.ts +8 -6
  55. package/dist/likec4diagram/custom/nodes/nodes.js +13 -14
  56. package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +3 -2
  57. package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +2 -2
  58. package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +2 -0
  59. package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +441 -0
  60. package/dist/likec4diagram/relationship-popover/actor.d.ts +177 -0
  61. package/dist/likec4diagram/relationship-popover/actor.js +155 -0
  62. package/dist/likec4diagram/relationship-popover/styles.css.d.ts +2 -0
  63. package/dist/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.js → relationship-popover/styles.css.js} +4 -17
  64. package/dist/likec4diagram/useLayoutConstraints.js +0 -1
  65. package/dist/likec4model/useLikeC4ElementsTree.js +1 -1
  66. package/dist/likec4model/useLikeC4Project.js +15 -1
  67. package/dist/navigationpanel/NavigationPanelDropdown.js +1 -2
  68. package/dist/navigationpanel/actor.js +1 -2
  69. package/dist/navigationpanel/controls/NavigationButtons.js +1 -5
  70. package/dist/navigationpanel/controls/ViewDetailsCard.js +2 -0
  71. package/dist/overlays/element-details/actor.d.ts +564 -8
  72. package/dist/overlays/overlay/Overlay.css.d.ts +1 -1
  73. package/dist/overlays/relationship-details/actor.d.ts +3 -1
  74. package/dist/overlays/relationship-details/hooks.d.ts +19 -1
  75. package/dist/overlays/relationship-details/layout-to-xyflow.js +0 -1
  76. package/dist/overlays/relationship-details/layout.js +1 -2
  77. package/dist/overlays/relationships-browser/actor.d.ts +26 -2
  78. package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +16 -0
  79. package/dist/overlays/relationships-browser/custom/nodeTypes.js +18 -8
  80. package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -1
  81. package/dist/search/components/_shared.css.d.ts +1 -1
  82. package/dist/state/DiagramActorProvider.js +2 -19
  83. package/dist/state/assign.js +24 -10
  84. package/dist/state/diagram-machine.d.ts +149 -474
  85. package/dist/state/diagram-machine.js +94 -54
  86. package/dist/state/types.d.ts +1 -1
  87. package/dist/styles-min.css +1 -1
  88. package/dist/styles-xyflow.css +1 -1
  89. package/dist/styles.css +1 -1
  90. package/dist/styles.css2.js +1 -1
  91. package/dist/utils/index.d.ts +2 -1
  92. package/dist/utils/roundDpr.d.ts +1 -0
  93. package/dist/utils/roundDpr.js +20 -0
  94. package/dist/utils/xyflow.d.ts +0 -1
  95. package/dist/utils/xyflow.js +1 -7
  96. package/package.json +16 -15
  97. package/panda.buildinfo.json +91 -156
  98. package/src/LikeC4Diagram.props.ts +5 -5
  99. package/src/LikeC4Styles.tsx +22 -14
  100. package/src/StaticLikeC4Diagram.tsx +3 -0
  101. package/src/base/BaseXYFlow.tsx +26 -29
  102. package/src/base/const.ts +5 -4
  103. package/src/base/primitives/MarkdownBlock.tsx +6 -1
  104. package/src/base/primitives/compound/CompoundActionButton.tsx +31 -43
  105. package/src/base/primitives/compound/CompoundDetailsButton.tsx +26 -48
  106. package/src/base/primitives/compound/CompoundNodeContainer.tsx +15 -43
  107. package/src/base/primitives/compound/CompoundTitle.tsx +4 -76
  108. package/src/base/primitives/compound/actionbtns.css.ts +0 -12
  109. package/src/base/primitives/customEdge.ts +1 -1
  110. package/src/base/primitives/customNode.tsx +20 -24
  111. package/src/base/primitives/edge/EdgeLabel.tsx +23 -8
  112. package/src/base/primitives/edge/EdgeLabelContainer.tsx +9 -21
  113. package/src/base/primitives/edge/edge.css.ts +19 -11
  114. package/src/base/primitives/element/ElementShape.tsx +40 -18
  115. package/src/base/primitives/element/ElementTags.tsx +7 -4
  116. package/src/base/primitives/element/ElementTitle.tsx +23 -11
  117. package/src/base/types.ts +21 -25
  118. package/src/bundle/LikeC4View.props.ts +2 -2
  119. package/src/bundle/LikeC4View.tsx +8 -5
  120. package/src/bundle/ReactLikeC4.tsx +3 -3
  121. package/src/components/Link.tsx +3 -2
  122. package/src/context/RootContainer.tsx +1 -5
  123. package/src/context/TagStylesContext.tsx +2 -0
  124. package/src/custom/{customNodes.tsx → customNodes.ts} +58 -52
  125. package/src/custom/hooks.ts +7 -0
  126. package/src/globals.css +58 -5
  127. package/src/hooks/index.ts +1 -1
  128. package/src/hooks/useDiagram.ts +39 -5
  129. package/src/hooks/useXYFlow.ts +3 -1
  130. package/src/index.ts +1 -0
  131. package/src/likec4diagram/DiagramUI.tsx +3 -0
  132. package/src/likec4diagram/DiagramXYFlow.tsx +9 -11
  133. package/src/likec4diagram/custom/edges/RelationshipEdge.tsx +25 -49
  134. package/src/likec4diagram/custom/index.ts +5 -4
  135. package/src/likec4diagram/custom/nodes/nodes.tsx +13 -11
  136. package/src/likec4diagram/custom/nodes/toolbar/CompoundToolbar.tsx +3 -2
  137. package/src/likec4diagram/relationship-popover/RelationshipPopover.tsx +535 -0
  138. package/src/likec4diagram/relationship-popover/actor.ts +192 -0
  139. package/src/likec4diagram/{custom/edges/RelationshipsDropdownMenu.css.ts → relationship-popover/styles.css.ts} +3 -19
  140. package/src/likec4diagram/useLayoutConstraints.ts +0 -1
  141. package/src/likec4model/useLikeC4ElementsTree.ts +1 -1
  142. package/src/navigationpanel/NavigationPanelDropdown.tsx +1 -2
  143. package/src/navigationpanel/actor.ts +2 -2
  144. package/src/navigationpanel/controls/NavigationButtons.tsx +1 -5
  145. package/src/navigationpanel/controls/ViewDetailsCard.tsx +2 -0
  146. package/src/overlays/relationship-details/layout-to-xyflow.ts +0 -1
  147. package/src/overlays/relationship-details/layout.ts +4 -3
  148. package/src/overlays/relationships-browser/custom/nodeTypes.tsx +22 -8
  149. package/src/overlays/relationships-browser/useViewToNodesEdges.ts +0 -1
  150. package/src/state/DiagramActorProvider.tsx +2 -20
  151. package/src/state/assign.ts +24 -10
  152. package/src/state/diagram-machine.ts +101 -53
  153. package/src/state/types.ts +4 -1
  154. package/src/utils/index.ts +2 -1
  155. package/src/utils/roundDpr.ts +27 -0
  156. package/src/utils/xyflow.ts +0 -7
  157. package/dist/base/primitives/compound/CompoundNodeContainer.css.d.ts +0 -35
  158. package/dist/base/primitives/compound/CompoundNodeContainer.css.js +0 -132
  159. package/dist/base/primitives/edge/EdgeLabel.css.d.ts +0 -7
  160. package/dist/base/primitives/edge/EdgeLabel.css.js +0 -57
  161. package/dist/base/primitives/element/ElementShape.css.d.ts +0 -6
  162. package/dist/base/primitives/element/ElementShape.css.js +0 -107
  163. package/dist/likec4diagram/custom/edges/NotePopover.css.js +0 -21
  164. package/dist/likec4diagram/custom/edges/NotePopover.js +0 -91
  165. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.css.d.ts +0 -5
  166. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.d.ts +0 -13
  167. package/dist/likec4diagram/custom/edges/RelationshipsDropdownMenu.js +0 -215
  168. package/dist/likec4diagram/custom/index.d.ts +0 -62
  169. package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +0 -10
  170. package/src/base/primitives/compound/CompoundNodeContainer.css.ts +0 -138
  171. package/src/base/primitives/edge/EdgeLabel.css.ts +0 -64
  172. package/src/base/primitives/element/ElementShape.css.ts +0 -112
  173. package/src/likec4diagram/custom/edges/RelationshipsDropdownMenu.tsx +0 -281
@@ -0,0 +1,441 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { autoUpdate, computePosition, offset, autoPlacement, size, hide } from '@floating-ui/dom';
3
+ import { nameFromFqn } from '@likec4/core';
4
+ import { cx, css } from '@likec4/styles/css';
5
+ import { VStack, styled, HStack, Box } from '@likec4/styles/jsx';
6
+ import { bleed } from '@likec4/styles/patterns';
7
+ import { Portal, ScrollAreaAutosize, Button, Divider, Space, Text, TooltipGroup, Tooltip as Tooltip$1, ActionIcon } from '@mantine/core';
8
+ import { useActorRef, useSelector } from '@xstate/react';
9
+ import { shallowEqual } from 'fast-equals';
10
+ import { memo, useCallback, useRef, useState, useEffect, Fragment as Fragment$1, forwardRef } from 'react';
11
+ import { pipe, map, filter, isTruthy, partition, clamp } from 'remeda';
12
+ import { Link } from '../../components/Link.js';
13
+ import { useDiagramEventHandlers } from '../../context/DiagramEventHandlers.js';
14
+ import { useEnabledFeatures } from '../../context/DiagramFeatures.js';
15
+ import { useDiagram, useDiagramContext, useOnDiagramEvent } from '../../hooks/useDiagram.js';
16
+ import { useMantinePortalProps } from '../../hooks/useMantinePortalProps.js';
17
+ import { useUpdateEffect } from '../../hooks/useUpdateEffect.js';
18
+ import { useXYStore } from '../../hooks/useXYFlow.js';
19
+ import { findDiagramEdge, findDiagramNode } from '../../state/utils.js';
20
+ import { RelationshipPopoverActorLogic } from './actor.js';
21
+ import { endpoint, title } from './styles.css.js';
22
+ import { useLikeC4Model } from '../../likec4model/useLikeC4Model.js';
23
+ import { roundDpr } from '../../utils/roundDpr.js';
24
+ import IconArrowRight from '../../node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js';
25
+ import IconZoomScan from '../../node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js';
26
+ import IconFileSymlink from '../../node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js';
27
+ import { MarkdownBlock } from '../../base/primitives/MarkdownBlock.js';
28
+
29
+ function selectDiagramContext(c) {
30
+ let selected = null;
31
+ for (const edge of c.xyedges) {
32
+ if (edge.selected) {
33
+ if (selected) {
34
+ selected = null;
35
+ break;
36
+ }
37
+ selected = edge.data.id;
38
+ }
39
+ }
40
+ return {
41
+ viewId: c.view.id,
42
+ selected
43
+ };
44
+ }
45
+ const RelationshipPopover = memo(() => {
46
+ const actorRef = useActorRef(RelationshipPopoverActorLogic);
47
+ const diagram = useDiagram();
48
+ const { viewId, selected } = useDiagramContext(selectDiagramContext);
49
+ const openedEdgeId = useSelector(actorRef, (s) => s.hasTag("opened") ? s.context.edgeId : null);
50
+ useUpdateEffect(() => {
51
+ actorRef.send({ type: "close" });
52
+ }, [viewId]);
53
+ useOnDiagramEvent("edgeMouseEnter", ({ edge }) => {
54
+ actorRef.send({ type: "xyedge.mouseEnter", edgeId: edge.data.id });
55
+ });
56
+ useOnDiagramEvent("edgeMouseLeave", () => {
57
+ actorRef.send({ type: "xyedge.mouseLeave" });
58
+ });
59
+ useOnDiagramEvent("edgeEditingStarted", () => {
60
+ actorRef.send({ type: "close" });
61
+ });
62
+ useOnDiagramEvent("walkthroughStarted", () => {
63
+ actorRef.send({ type: "close" });
64
+ });
65
+ useUpdateEffect(() => {
66
+ if (selected) {
67
+ actorRef.send({ type: "xyedge.select", edgeId: selected });
68
+ } else {
69
+ actorRef.send({ type: "xyedge.unselect" });
70
+ }
71
+ }, [selected]);
72
+ const onMouseEnter = useCallback((event) => {
73
+ if (!openedEdgeId) {
74
+ return;
75
+ }
76
+ actorRef.send({ type: "dropdown.mouseEnter" });
77
+ const edge = diagram.findEdge(openedEdgeId);
78
+ if (edge && !edge.data.hovered) {
79
+ diagram.send({ type: "xyflow.edgeMouseEnter", edge, event });
80
+ }
81
+ }, [actorRef, diagram, openedEdgeId]);
82
+ const onMouseLeave = useCallback((event) => {
83
+ if (!openedEdgeId) {
84
+ return;
85
+ }
86
+ actorRef.send({ type: "dropdown.mouseLeave" });
87
+ const edge = diagram.findEdge(openedEdgeId);
88
+ if (edge?.data.hovered) {
89
+ diagram.send({ type: "xyflow.edgeMouseLeave", edge, event });
90
+ }
91
+ }, [actorRef, diagram, openedEdgeId]);
92
+ const { diagramEdge, sourceNode, targetNode } = useDiagramContext(
93
+ (ctx) => {
94
+ const diagramEdge2 = openedEdgeId ? findDiagramEdge(ctx, openedEdgeId) : null;
95
+ const sourceNode2 = diagramEdge2 ? findDiagramNode(ctx, diagramEdge2.source) : null;
96
+ const targetNode2 = diagramEdge2 ? findDiagramNode(ctx, diagramEdge2.target) : null;
97
+ return {
98
+ diagramEdge: diagramEdge2,
99
+ sourceNode: sourceNode2,
100
+ targetNode: targetNode2
101
+ };
102
+ },
103
+ shallowEqual,
104
+ [openedEdgeId]
105
+ );
106
+ if (!diagramEdge || !sourceNode || !targetNode) {
107
+ return null;
108
+ }
109
+ return /* @__PURE__ */ jsx(
110
+ RelationshipPopoverInternal,
111
+ {
112
+ viewId,
113
+ diagramEdge,
114
+ sourceNode,
115
+ targetNode,
116
+ onMouseEnter,
117
+ onMouseLeave
118
+ }
119
+ );
120
+ });
121
+ const getEdgeLabelElement = (edgeId, container) => {
122
+ return container?.querySelector(`.likec4-edge-label[data-edge-id="${edgeId}"]`) ?? null;
123
+ };
124
+ const selectTransform = (s) => roundDpr(s.transform[0]) + " " + roundDpr(s.transform[1]) + " " + s.transform[2].toFixed(3);
125
+ const RelationshipPopoverInternal = ({
126
+ viewId,
127
+ diagramEdge,
128
+ sourceNode,
129
+ targetNode,
130
+ onMouseEnter,
131
+ onMouseLeave
132
+ }) => {
133
+ const ref = useRef(null);
134
+ const { enableNavigateTo, enableVscode } = useEnabledFeatures();
135
+ const { onOpenSource } = useDiagramEventHandlers();
136
+ const { portalProps } = useMantinePortalProps();
137
+ const [referenceEl, setReferenceEl] = useState(null);
138
+ const viewport = useXYStore(selectTransform);
139
+ useEffect(() => {
140
+ setReferenceEl(getEdgeLabelElement(diagramEdge.id, portalProps?.target));
141
+ }, [diagramEdge, viewport]);
142
+ useEffect(() => {
143
+ const reference = referenceEl;
144
+ const popper = ref.current;
145
+ if (!reference || !popper) {
146
+ return;
147
+ }
148
+ let wasCanceled = false;
149
+ const update = () => {
150
+ computePosition(reference, popper, {
151
+ placement: "bottom",
152
+ middleware: [
153
+ offset(2),
154
+ autoPlacement({
155
+ padding: 16,
156
+ allowedPlacements: [
157
+ "bottom-start",
158
+ "bottom-end",
159
+ "top-start",
160
+ "top-end",
161
+ "right-start",
162
+ "right-end",
163
+ "left-start",
164
+ "left-end"
165
+ ]
166
+ }),
167
+ size({
168
+ padding: 16,
169
+ apply({ availableHeight, availableWidth, elements }) {
170
+ if (wasCanceled) {
171
+ return;
172
+ }
173
+ Object.assign(elements.floating.style, {
174
+ maxWidth: `${clamp(roundDpr(availableWidth), { min: 150, max: 400 })}px`,
175
+ maxHeight: `${clamp(roundDpr(availableHeight), { min: 0, max: 500 })}px`
176
+ });
177
+ }
178
+ }),
179
+ hide({
180
+ padding: 16
181
+ })
182
+ ]
183
+ }).then(({ x, y, middlewareData }) => {
184
+ if (wasCanceled) {
185
+ return;
186
+ }
187
+ popper.style.transform = `translate(${roundDpr(x)}px, ${roundDpr(y)}px)`;
188
+ popper.style.visibility = middlewareData.hide?.referenceHidden ? "hidden" : "visible";
189
+ });
190
+ };
191
+ const cleanup = autoUpdate(reference, popper, update);
192
+ return () => {
193
+ wasCanceled = true;
194
+ cleanup();
195
+ };
196
+ }, [referenceEl]);
197
+ const likec4model = useLikeC4Model();
198
+ const diagram = useDiagram();
199
+ const [direct, nested] = pipe(
200
+ diagramEdge.relations,
201
+ map((id) => {
202
+ try {
203
+ return likec4model.relationship(id);
204
+ } catch (e) {
205
+ console.error(
206
+ `View is cached and likec4model missing relationship ${id} from ${sourceNode.id} -> ${targetNode.id}`,
207
+ e
208
+ );
209
+ return null;
210
+ }
211
+ }),
212
+ filter(isTruthy),
213
+ partition((r) => r.source.id === sourceNode.id && r.target.id === targetNode.id)
214
+ );
215
+ if (direct.length === 0 && nested.length === 0) {
216
+ console.error("No relationships found diagram edge", {
217
+ diagramEdge,
218
+ sourceNode,
219
+ targetNode
220
+ });
221
+ return null;
222
+ }
223
+ const navigateTo = enableNavigateTo ? (viewId2) => {
224
+ diagram.navigateTo(viewId2);
225
+ } : void 0;
226
+ const renderRelationship = (relationship, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
227
+ index > 0 && /* @__PURE__ */ jsx(Divider, {}),
228
+ /* @__PURE__ */ jsx(
229
+ Relationship,
230
+ {
231
+ viewId,
232
+ relationship,
233
+ sourceNode,
234
+ targetNode,
235
+ edge: diagramEdge,
236
+ onNavigateTo: navigateTo,
237
+ ...onOpenSource && enableVscode && {
238
+ onOpenSource: () => onOpenSource({ relation: relationship.id })
239
+ }
240
+ }
241
+ )
242
+ ] }, relationship.id);
243
+ return /* @__PURE__ */ jsx(Portal, { ...portalProps, children: /* @__PURE__ */ jsx(
244
+ ScrollAreaAutosize,
245
+ {
246
+ ref,
247
+ onMouseEnter,
248
+ onMouseLeave,
249
+ type: "auto",
250
+ scrollbars: "y",
251
+ scrollbarSize: 6,
252
+ styles: {
253
+ viewport: {
254
+ overscrollBehavior: "contain",
255
+ minWidth: 150
256
+ }
257
+ },
258
+ className: cx(
259
+ "react-flow__panel nowheel nopan nodrag",
260
+ css({
261
+ layerStyle: "likec4.dropdown",
262
+ p: "0",
263
+ pointerEvents: "all",
264
+ position: "absolute",
265
+ top: "0",
266
+ left: "0",
267
+ width: "max-content",
268
+ cursor: "default"
269
+ })
270
+ ),
271
+ children: /* @__PURE__ */ jsxs(
272
+ VStack,
273
+ {
274
+ css: {
275
+ gap: "3.5",
276
+ padding: "4",
277
+ paddingTop: "2.5"
278
+ },
279
+ children: [
280
+ /* @__PURE__ */ jsx(
281
+ Button,
282
+ {
283
+ variant: "default",
284
+ color: "gray",
285
+ size: "compact-xs",
286
+ style: {
287
+ alignSelf: "flex-start",
288
+ fontWeight: 500,
289
+ ["--button-fz"]: "var(--font-sizes-xxs)"
290
+ },
291
+ onClick: (e) => {
292
+ e.stopPropagation();
293
+ diagram.openRelationshipDetails(diagramEdge.id);
294
+ },
295
+ children: "browse relationships"
296
+ }
297
+ ),
298
+ direct.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
299
+ /* @__PURE__ */ jsx(Divider, { label: /* @__PURE__ */ jsx(Label, { children: "direct relationships" }), labelPosition: "left" }),
300
+ direct.map(renderRelationship)
301
+ ] }),
302
+ nested.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
303
+ direct.length > 0 && /* @__PURE__ */ jsx(Space, {}),
304
+ /* @__PURE__ */ jsx(Divider, { label: /* @__PURE__ */ jsx(Label, { children: "resolved from nested" }), labelPosition: "left" }),
305
+ nested.map(renderRelationship)
306
+ ] })
307
+ ]
308
+ }
309
+ )
310
+ }
311
+ ) });
312
+ };
313
+ const Relationship = forwardRef(({
314
+ viewId,
315
+ relationship: r,
316
+ edge,
317
+ sourceNode,
318
+ targetNode,
319
+ onNavigateTo,
320
+ onOpenSource
321
+ }, ref) => {
322
+ const sourceId = getShortId(r, r.source.id, sourceNode);
323
+ const targetId = getShortId(r, r.target.id, targetNode);
324
+ const navigateTo = onNavigateTo && r.navigateTo?.id !== viewId ? r.navigateTo?.id : void 0;
325
+ const links = r.links;
326
+ return /* @__PURE__ */ jsxs(
327
+ VStack,
328
+ {
329
+ ref,
330
+ className: bleed({
331
+ block: "2",
332
+ inline: "2",
333
+ paddingBlock: "2",
334
+ paddingInline: "2",
335
+ gap: "1",
336
+ rounded: "sm",
337
+ backgroundColor: {
338
+ _hover: {
339
+ base: "mantine.colors.gray[1]",
340
+ _dark: "mantine.colors.dark[5]/70"
341
+ }
342
+ }
343
+ }),
344
+ children: [
345
+ /* @__PURE__ */ jsxs(HStack, { gap: "0.5", children: [
346
+ /* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": sourceNode.color, className: endpoint, children: sourceId }),
347
+ /* @__PURE__ */ jsx(IconArrowRight, { stroke: 2.5, size: "11px", opacity: 0.65 }),
348
+ /* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": targetNode.color, className: endpoint, children: targetId }),
349
+ /* @__PURE__ */ jsxs(TooltipGroup, { openDelay: 100, children: [
350
+ navigateTo && /* @__PURE__ */ jsx(Tooltip, { label: "Open dynamic view", children: /* @__PURE__ */ jsx(
351
+ ActionIcon,
352
+ {
353
+ size: "sm",
354
+ radius: "sm",
355
+ variant: "default",
356
+ onClick: (event) => {
357
+ event.stopPropagation();
358
+ onNavigateTo?.(navigateTo);
359
+ },
360
+ style: {
361
+ alignSelf: "flex-end"
362
+ },
363
+ role: "button",
364
+ children: /* @__PURE__ */ jsx(IconZoomScan, { size: "80%", stroke: 2 })
365
+ }
366
+ ) }),
367
+ onOpenSource && /* @__PURE__ */ jsx(Tooltip, { label: "Open source", children: /* @__PURE__ */ jsx(
368
+ ActionIcon,
369
+ {
370
+ size: "sm",
371
+ radius: "sm",
372
+ variant: "default",
373
+ onClick: (event) => {
374
+ event.stopPropagation();
375
+ onOpenSource();
376
+ },
377
+ role: "button",
378
+ children: /* @__PURE__ */ jsx(IconFileSymlink, { size: "80%", stroke: 2 })
379
+ }
380
+ ) })
381
+ ] })
382
+ ] }),
383
+ /* @__PURE__ */ jsx(Box, { className: title, children: r.title || "untitled" }),
384
+ r.kind && /* @__PURE__ */ jsxs(HStack, { gap: "2", children: [
385
+ /* @__PURE__ */ jsx(Label, { children: "kind" }),
386
+ /* @__PURE__ */ jsx(Text, { size: "xs", className: css({ userSelect: "all" }), children: r.kind })
387
+ ] }),
388
+ r.technology && /* @__PURE__ */ jsxs(HStack, { gap: "2", children: [
389
+ /* @__PURE__ */ jsx(Label, { children: "technology" }),
390
+ /* @__PURE__ */ jsx(Text, { size: "xs", className: css({ userSelect: "all" }), children: r.technology })
391
+ ] }),
392
+ r.description.nonEmpty && /* @__PURE__ */ jsxs(Fragment, { children: [
393
+ /* @__PURE__ */ jsx(Label, { children: "description" }),
394
+ /* @__PURE__ */ jsx(
395
+ Box,
396
+ {
397
+ css: {
398
+ paddingLeft: "2.5",
399
+ py: "1.5",
400
+ borderLeft: "2px dotted",
401
+ borderLeftColor: {
402
+ base: "mantine.colors.gray[3]",
403
+ _dark: "mantine.colors.dark[4]"
404
+ }
405
+ },
406
+ children: /* @__PURE__ */ jsx(MarkdownBlock, { value: r.description, fontSize: "sm" })
407
+ }
408
+ )
409
+ ] }),
410
+ links.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
411
+ /* @__PURE__ */ jsx(Label, { children: "links" }),
412
+ /* @__PURE__ */ jsx(HStack, { gap: "1", flexWrap: "wrap", children: links.map((link) => /* @__PURE__ */ jsx(Link, { size: "sm", value: link }, link.url)) })
413
+ ] })
414
+ ]
415
+ }
416
+ );
417
+ });
418
+ const Label = styled("span", {
419
+ base: {
420
+ display: "inline-block",
421
+ fontSize: "xxs",
422
+ fontWeight: 500,
423
+ userSelect: "none",
424
+ lineHeight: "[1.11]",
425
+ color: "mantine.colors.dimmed"
426
+ }
427
+ });
428
+ const Tooltip = Tooltip$1.withProps({
429
+ color: "dark",
430
+ fz: "xs",
431
+ label: "",
432
+ children: null,
433
+ offset: 8,
434
+ withinPortal: false
435
+ });
436
+ function getShortId(r, actualEndpointId, diagramNode) {
437
+ const diagramNodeId = r.isDeploymentRelation() ? diagramNode.id : diagramNode.modelRef || "";
438
+ return nameFromFqn(diagramNodeId) + actualEndpointId.slice(diagramNodeId.length);
439
+ }
440
+
441
+ export { RelationshipPopover };
@@ -0,0 +1,177 @@
1
+ import { EdgeId } from '@likec4/core/types';
2
+ import { ActorLogicFrom, ActorRefFrom, SnapshotFrom, StateMachine, Values, NonReducibleUnknown, EventObject, MetaObject } from 'xstate';
3
+ export type RelationshipPopoverActorEvent = {
4
+ type: 'xyedge.mouseEnter';
5
+ edgeId: EdgeId;
6
+ } | {
7
+ type: 'xyedge.mouseLeave';
8
+ } | {
9
+ type: 'xyedge.select';
10
+ edgeId: EdgeId;
11
+ } | {
12
+ type: 'xyedge.unselect';
13
+ } | {
14
+ type: 'close';
15
+ } | {
16
+ type: 'dropdown.mouseEnter';
17
+ } | {
18
+ type: 'dropdown.mouseLeave';
19
+ };
20
+ export interface RelationshipPopoverActorContext {
21
+ edgeId: EdgeId | null;
22
+ /**
23
+ * True if the edge was selected
24
+ */
25
+ edgeSelected: boolean;
26
+ /**
27
+ * The timeout for opening the popover
28
+ * If it was closed recently (<1.5s), it will be 300ms
29
+ * Otherwise, it will be 800ms
30
+ */
31
+ openTimeout: number;
32
+ }
33
+ declare const _actorLogic: StateMachine<RelationshipPopoverActorContext, RelationshipPopoverActorEvent, {}, never, Values<{
34
+ "update edgeId": {
35
+ type: "update edgeId";
36
+ params: NonReducibleUnknown;
37
+ };
38
+ "increase open timeout": {
39
+ type: "increase open timeout";
40
+ params: NonReducibleUnknown;
41
+ };
42
+ "decrease open timeout": {
43
+ type: "decrease open timeout";
44
+ params: NonReducibleUnknown;
45
+ };
46
+ "reset edgeId": {
47
+ type: "reset edgeId";
48
+ params: NonReducibleUnknown;
49
+ };
50
+ }>, Values<{
51
+ "edge was selected": {
52
+ type: "edge was selected";
53
+ params: unknown;
54
+ };
55
+ "edge was hovered": {
56
+ type: "edge was hovered";
57
+ params: unknown;
58
+ };
59
+ }>, "open timeout" | "close timeout" | "long idle", "idle" | "opening" | {
60
+ active: "hovered" | "opened" | "closing";
61
+ }, "opened", NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, {
62
+ readonly id: "breadcrumbs";
63
+ readonly context: () => {
64
+ edgeId: null;
65
+ edgeSelected: false;
66
+ openTimeout: number;
67
+ };
68
+ readonly initial: "idle";
69
+ readonly on: {
70
+ readonly close: {
71
+ readonly target: "#idle";
72
+ readonly actions: readonly ["reset edgeId", "increase open timeout"];
73
+ };
74
+ };
75
+ readonly states: {
76
+ readonly idle: {
77
+ readonly id: "idle";
78
+ readonly on: {
79
+ readonly 'xyedge.mouseEnter': {
80
+ readonly target: "opening";
81
+ readonly actions: "update edgeId";
82
+ };
83
+ readonly 'xyedge.select': {
84
+ readonly target: "active";
85
+ readonly actions: "update edgeId";
86
+ };
87
+ };
88
+ readonly after: {
89
+ readonly 'long idle': {
90
+ readonly actions: "increase open timeout";
91
+ };
92
+ };
93
+ };
94
+ readonly opening: {
95
+ readonly on: {
96
+ readonly 'xyedge.mouseLeave': {
97
+ readonly target: "idle";
98
+ };
99
+ readonly 'xyedge.select': {
100
+ readonly target: "active";
101
+ readonly actions: "update edgeId";
102
+ };
103
+ };
104
+ readonly after: {
105
+ readonly 'open timeout': {
106
+ readonly actions: "decrease open timeout";
107
+ readonly target: "active";
108
+ };
109
+ };
110
+ };
111
+ readonly active: {
112
+ readonly tags: readonly ["opened"];
113
+ readonly initial: "opened";
114
+ readonly exit: "reset edgeId";
115
+ readonly on: {
116
+ readonly 'xyedge.unselect': {
117
+ readonly target: "idle";
118
+ readonly actions: "increase open timeout";
119
+ };
120
+ readonly 'xyedge.select': {
121
+ readonly actions: "update edgeId";
122
+ };
123
+ };
124
+ readonly states: {
125
+ readonly opened: {
126
+ readonly on: {
127
+ readonly 'dropdown.mouseEnter': {
128
+ readonly target: "hovered";
129
+ };
130
+ readonly 'xyedge.mouseLeave': {
131
+ readonly guard: "edge was hovered";
132
+ readonly target: "closing";
133
+ };
134
+ };
135
+ };
136
+ readonly hovered: {
137
+ readonly on: {
138
+ readonly 'dropdown.mouseLeave': readonly [{
139
+ readonly guard: "edge was selected";
140
+ readonly target: "opened";
141
+ }, {
142
+ readonly target: "closing";
143
+ }];
144
+ };
145
+ };
146
+ readonly closing: {
147
+ readonly on: {
148
+ readonly 'xyedge.mouseEnter': {
149
+ readonly guard: "edge was hovered";
150
+ readonly target: "opened";
151
+ readonly actions: "update edgeId";
152
+ };
153
+ readonly 'xyedge.select': {
154
+ readonly target: "opened";
155
+ readonly actions: "update edgeId";
156
+ };
157
+ readonly 'dropdown.mouseEnter': {
158
+ readonly target: "hovered";
159
+ };
160
+ };
161
+ readonly after: {
162
+ readonly 'close timeout': {
163
+ readonly target: "#idle";
164
+ };
165
+ };
166
+ };
167
+ };
168
+ };
169
+ };
170
+ }>;
171
+ export interface RelationshipPopoverActorLogic extends ActorLogicFrom<typeof _actorLogic> {
172
+ }
173
+ export declare const RelationshipPopoverActorLogic: RelationshipPopoverActorLogic;
174
+ export type RelationshipPopoverActorSnapshot = SnapshotFrom<RelationshipPopoverActorLogic>;
175
+ export interface RelationshipPopoverActorRef extends ActorRefFrom<RelationshipPopoverActorLogic> {
176
+ }
177
+ export {};