@likec4/diagram 1.36.1 → 1.37.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-DSORWspW.js} +1008 -988
  2. package/bundle/custom.js +64 -56
  3. package/bundle/index.js +3539 -3315
  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 +11 -10
  97. package/panda.buildinfo.json +90 -155
  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
@@ -1,21 +0,0 @@
1
- import { css } from '@likec4/styles/css';
2
-
3
- const edgeNoteCloseButton = css({
4
- position: "absolute",
5
- top: "[1px]",
6
- right: "[1px]",
7
- zIndex: 9
8
- });
9
- const edgeNoteText = css({
10
- userSelect: "all",
11
- textAlign: "left",
12
- whiteSpaceCollapse: "preserve-breaks",
13
- textWrap: "pretty",
14
- lineHeight: 1.25,
15
- "--text-fz": "{fontSizes.sm}",
16
- md: {
17
- "--text-fz": "{fontSizes.md}"
18
- }
19
- });
20
-
21
- export { edgeNoteCloseButton, edgeNoteText };
@@ -1,91 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Popover, PopoverTarget, PopoverDropdown, Stack, ScrollAreaAutosize, Text, CloseButton, Group, Button } from '@mantine/core';
3
- import { useDebouncedEffect } from '@react-hookz/web';
4
- import { useState } from 'react';
5
- import { isTruthy, isNonNull } from 'remeda';
6
- import { useDiagramContext, useDiagram } from '../../../hooks/useDiagram.js';
7
- import { edgeNoteText, edgeNoteCloseButton } from './NotePopover.css.js';
8
- import { useMantinePortalProps } from '../../../hooks/useMantinePortalProps.js';
9
- import { stopPropagation } from '../../../utils/xyflow.js';
10
-
11
- const NotePopover = ({ notes, children }) => {
12
- const {
13
- isActive,
14
- isParallel,
15
- hasNext,
16
- hasPrevious
17
- } = useDiagramContext((s) => ({
18
- isActive: isNonNull(s.activeWalkthrough),
19
- isParallel: isTruthy(s.activeWalkthrough?.parallelPrefix),
20
- hasNext: s.xyedges.findIndex((e) => e.id === s.activeWalkthrough?.stepId) < s.xyedges.length - 1,
21
- hasPrevious: s.xyedges.findIndex((e) => e.id === s.activeWalkthrough?.stepId) > 0
22
- }));
23
- const diagram = useDiagram();
24
- const [isOpened, setIsOpened] = useState(false);
25
- const portalProps = useMantinePortalProps();
26
- useDebouncedEffect(
27
- () => {
28
- setIsOpened(true);
29
- },
30
- [],
31
- 300
32
- );
33
- return /* @__PURE__ */ jsxs(
34
- Popover,
35
- {
36
- shadow: "xs",
37
- offset: 16,
38
- opened: isOpened,
39
- closeOnClickOutside: false,
40
- ...portalProps,
41
- children: [
42
- /* @__PURE__ */ jsx(PopoverTarget, { children }),
43
- /* @__PURE__ */ jsxs(
44
- PopoverDropdown,
45
- {
46
- component: Stack,
47
- p: "xs",
48
- onPointerDownCapture: stopPropagation,
49
- onClick: stopPropagation,
50
- onDoubleClick: stopPropagation,
51
- children: [
52
- /* @__PURE__ */ jsx(ScrollAreaAutosize, { miw: 180, maw: 450, mah: 350, type: "scroll", mx: "auto", mt: 2, children: /* @__PURE__ */ jsx(Text, { component: "div", className: edgeNoteText, p: 4, children: notes }) }),
53
- /* @__PURE__ */ jsx(
54
- CloseButton,
55
- {
56
- size: "xs",
57
- className: edgeNoteCloseButton,
58
- onClick: () => setIsOpened(false)
59
- }
60
- ),
61
- (hasPrevious || hasNext) && /* @__PURE__ */ jsxs(Group, { gap: 0, justify: hasPrevious ? "flex-start" : "flex-end", children: [
62
- hasPrevious && /* @__PURE__ */ jsx(
63
- Button,
64
- {
65
- variant: "subtle",
66
- radius: "xs",
67
- size: "compact-xs",
68
- onClick: () => diagram.walkthroughStep("previous"),
69
- children: "back"
70
- }
71
- ),
72
- hasNext && /* @__PURE__ */ jsx(
73
- Button,
74
- {
75
- variant: "subtle",
76
- radius: "xs",
77
- size: "compact-xs",
78
- onClick: () => diagram.walkthroughStep("next"),
79
- children: "next"
80
- }
81
- )
82
- ] })
83
- ]
84
- }
85
- )
86
- ]
87
- }
88
- );
89
- };
90
-
91
- export { NotePopover };
@@ -1,5 +0,0 @@
1
- export declare const menuDropdown: string;
2
- export declare const menuItemRelationship: string;
3
- export declare const endpoint: string;
4
- export declare const title: string;
5
- export declare const arrowFromTo: string;
@@ -1,13 +0,0 @@
1
- import { EdgeId } from '@likec4/core';
2
- import { PropsWithChildren, ForwardRefExoticComponent, RefAttributes, MemoExoticComponent } from 'react';
3
- import { TooltipProps } from '@mantine/core';
4
- export declare const Tooltip: ForwardRefExoticComponent< TooltipProps & RefAttributes<HTMLDivElement> & {
5
- component?: any;
6
- renderRoot?: (props: Record<string, any>) => React.ReactNode;
7
- }>;
8
- export declare const RelationshipsDropdownMenu: MemoExoticComponent<({ edgeId, source, target, disabled, children, }: PropsWithChildren<{
9
- edgeId: EdgeId;
10
- source: string;
11
- target: string;
12
- disabled?: boolean | undefined;
13
- }>) => import("react/jsx-runtime").JSX.Element>;
@@ -1,215 +0,0 @@
1
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
- import { nameFromFqn } from '@likec4/core';
3
- import { cx } from '@likec4/styles/css';
4
- import { Menu, MenuTarget, MenuDropdown, MenuLabel, MenuDivider, Box, ActionIcon, MenuItem, Stack, Group, Text, TooltipGroup, Space, Tooltip as Tooltip$1 } from '@mantine/core';
5
- import { memo, useCallback, Fragment as Fragment$1, forwardRef } from 'react';
6
- import { pipe, map, filter, isTruthy, partition } from 'remeda';
7
- import { Link } from '../../../components/Link.js';
8
- import { useDiagramContext, useDiagram } from '../../../hooks/useDiagram.js';
9
- import { findDiagramNode, findDiagramEdge } from '../../../state/utils.js';
10
- import { menuDropdown, endpoint, title, menuItemRelationship } from './RelationshipsDropdownMenu.css.js';
11
- import { useLikeC4Model } from '../../../likec4model/useLikeC4Model.js';
12
- import { useMantinePortalProps } from '../../../hooks/useMantinePortalProps.js';
13
- import IconInfoCircle from '../../../node_modules/.pnpm/@tabler_icons-react@3.34.1_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js';
14
- import { useEnabledFeatures, IfEnabled } from '../../../context/DiagramFeatures.js';
15
- import { useDiagramEventHandlers } from '../../../context/DiagramEventHandlers.js';
16
- 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';
17
- 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';
18
- 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';
19
-
20
- const stopPropagation = (e) => e.stopPropagation();
21
- const Tooltip = Tooltip$1.withProps({
22
- color: "gray",
23
- fz: "xs",
24
- openDelay: 300,
25
- closeDelay: 150,
26
- label: "",
27
- children: null,
28
- offset: 8,
29
- withinPortal: false
30
- });
31
- const RelationshipsDropdownMenu = memo(({
32
- edgeId,
33
- source,
34
- target,
35
- disabled = false,
36
- children
37
- }) => {
38
- const { diagramEdge, sourceNode, targetNode } = useDiagramContext(
39
- (ctx) => ({
40
- diagramEdge: findDiagramEdge(ctx, edgeId),
41
- sourceNode: findDiagramNode(ctx, source),
42
- targetNode: findDiagramNode(ctx, target)
43
- }),
44
- void 0,
45
- [edgeId, source, target]
46
- );
47
- const likec4model = useLikeC4Model();
48
- const diagram = useDiagram();
49
- const portalProps = useMantinePortalProps();
50
- const onClickOpenOverlay = useCallback((e) => {
51
- e.stopPropagation();
52
- diagram.openRelationshipDetails(edgeId);
53
- }, [edgeId]);
54
- if (!diagramEdge || !sourceNode || !targetNode) {
55
- return /* @__PURE__ */ jsx(Fragment, { children });
56
- }
57
- const [direct, nested] = pipe(
58
- diagramEdge.relations,
59
- map((id) => {
60
- try {
61
- return likec4model.findRelationship(id);
62
- } catch (e) {
63
- console.error(
64
- `View is cached and likec4model missing relationship ${id} from ${sourceNode.id} -> ${targetNode.id}`,
65
- e
66
- );
67
- return null;
68
- }
69
- }),
70
- filter(isTruthy),
71
- partition((r) => r.source.id === sourceNode.id && r.target.id === targetNode.id)
72
- );
73
- const renderRelationship = (relationship, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
74
- index > 0 && /* @__PURE__ */ jsx(MenuDivider, { opacity: 0.65 }),
75
- /* @__PURE__ */ jsx(
76
- MenuItem,
77
- {
78
- onClick: onClickOpenOverlay,
79
- component: Relationship,
80
- relationship,
81
- sourceNode,
82
- targetNode,
83
- edge: diagramEdge
84
- }
85
- )
86
- ] }, relationship.id);
87
- if (direct.length + nested.length === 0) {
88
- return /* @__PURE__ */ jsx(Fragment, { children });
89
- }
90
- return /* @__PURE__ */ jsxs(
91
- Menu,
92
- {
93
- trigger: "click-hover",
94
- openDelay: 300,
95
- closeDelay: 450,
96
- closeOnClickOutside: true,
97
- clickOutsideEvents: ["pointerdown", "mousedown", "click"],
98
- closeOnEscape: true,
99
- keepMounted: false,
100
- closeOnItemClick: false,
101
- disabled,
102
- position: "bottom-start",
103
- middlewares: { size: { padding: 8 } },
104
- ...portalProps,
105
- children: [
106
- /* @__PURE__ */ jsx(MenuTarget, { children }),
107
- /* @__PURE__ */ jsxs(
108
- MenuDropdown,
109
- {
110
- className: menuDropdown,
111
- onPointerDownCapture: stopPropagation,
112
- onPointerDown: stopPropagation,
113
- onClick: stopPropagation,
114
- children: [
115
- direct.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
116
- /* @__PURE__ */ jsx(MenuLabel, { children: "direct relationships" }),
117
- direct.map(renderRelationship)
118
- ] }),
119
- nested.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
120
- direct.length > 0 && /* @__PURE__ */ jsx(MenuDivider, {}),
121
- /* @__PURE__ */ jsx(MenuLabel, { children: "resolved from nested" }),
122
- nested.map(renderRelationship)
123
- ] }),
124
- /* @__PURE__ */ jsx(Box, { pos: "absolute", top: 5, right: 6, children: /* @__PURE__ */ jsx(
125
- ActionIcon,
126
- {
127
- size: 24,
128
- variant: "subtle",
129
- onClick: onClickOpenOverlay,
130
- children: /* @__PURE__ */ jsx(IconInfoCircle, { style: { width: "70%" } })
131
- }
132
- ) })
133
- ]
134
- }
135
- )
136
- ]
137
- }
138
- );
139
- });
140
- const Relationship = forwardRef(({
141
- className,
142
- relationship: r,
143
- edge,
144
- sourceNode,
145
- targetNode,
146
- ...props
147
- }, ref) => {
148
- const diagram = useDiagram();
149
- const { enableNavigateTo } = useEnabledFeatures();
150
- const { onOpenSource } = useDiagramEventHandlers();
151
- const viewId = diagram.currentView.id;
152
- const sourceId = getShortId(r, r.source.id, sourceNode);
153
- const targetId = getShortId(r, r.target.id, targetNode);
154
- const navigateTo = enableNavigateTo && r.navigateTo?.id !== viewId ? r.navigateTo?.id : void 0;
155
- const links = r.links;
156
- return /* @__PURE__ */ jsxs(Stack, { ref, className: cx(menuItemRelationship, className), ...props, children: [
157
- /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
158
- /* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": sourceNode.color, className: endpoint, children: sourceId }),
159
- /* @__PURE__ */ jsx(IconArrowRight, { stroke: 2.5, size: "11px", opacity: 0.65 }),
160
- /* @__PURE__ */ jsx(Text, { component: "div", "data-likec4-color": targetNode.color, className: endpoint, children: targetId }),
161
- (navigateTo || !!onOpenSource) && /* @__PURE__ */ jsxs(TooltipGroup, { openDelay: 100, children: [
162
- /* @__PURE__ */ jsx(Space, { w: "xs" }),
163
- navigateTo && /* @__PURE__ */ jsx(Tooltip, { label: "Open dynamic view", children: /* @__PURE__ */ jsx(
164
- ActionIcon,
165
- {
166
- className: cx("nodrag nopan"),
167
- size: "sm",
168
- radius: "sm",
169
- variant: "default",
170
- onPointerDownCapture: stopPropagation,
171
- onClick: (event) => {
172
- event.stopPropagation();
173
- diagram.navigateTo(navigateTo);
174
- },
175
- role: "button",
176
- children: /* @__PURE__ */ jsx(IconZoomScan, { size: "80%", stroke: 2 })
177
- }
178
- ) }),
179
- /* @__PURE__ */ jsx(IfEnabled, { feature: "Vscode", children: /* @__PURE__ */ jsx(Tooltip, { label: "Open source", children: /* @__PURE__ */ jsx(
180
- ActionIcon,
181
- {
182
- className: cx("nodrag nopan"),
183
- size: "sm",
184
- radius: "sm",
185
- variant: "default",
186
- onPointerDownCapture: stopPropagation,
187
- onClick: (event) => {
188
- event.stopPropagation();
189
- diagram.openSource({ relation: r.id });
190
- },
191
- role: "button",
192
- children: /* @__PURE__ */ jsx(IconFileSymlink, { size: "80%", stroke: 2 })
193
- }
194
- ) }) })
195
- ] })
196
- ] }),
197
- /* @__PURE__ */ jsx(Box, { className: title, children: r.title || "untitled" }),
198
- r.description.nonEmpty && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: r.description.text }),
199
- links.length > 0 && /* @__PURE__ */ jsx(
200
- Stack,
201
- {
202
- gap: 3,
203
- justify: "stretch",
204
- align: "stretch",
205
- children: links.map((link) => /* @__PURE__ */ jsx(Link, { size: "sm", value: link }, link.url))
206
- }
207
- )
208
- ] });
209
- });
210
- function getShortId(r, actualEndpointId, diagramNode) {
211
- const diagramNodeId = r.isDeploymentRelation() ? diagramNode.id : diagramNode.modelRef || "";
212
- return nameFromFqn(diagramNodeId) + actualEndpointId.slice(diagramNodeId.length);
213
- }
214
-
215
- export { RelationshipsDropdownMenu, Tooltip };
@@ -1,62 +0,0 @@
1
- import { Types } from '../types';
2
- import { MemoExoticComponent, FunctionComponent, CSSProperties, ReactNode } from 'react';
3
- import { NodeProps } from '../../base';
4
- import { Position, XYPosition } from '@xyflow/system';
5
- import { EdgeData, Dimmed } from '../../base/types.Base';
6
- import { EdgeId, NonEmptyArray, Point, Color, RelationshipArrowType, RelationshipLineType, BBox, ViewId, MarkdownOrString } from '@likec4/core';
7
- export declare const BuiltinNodes: {
8
- element: MemoExoticComponent<(props: NodeProps<Types.ElementNodeData, "element">) => import("react/jsx-runtime").JSX.Element>;
9
- deployment: MemoExoticComponent<(props: NodeProps<Types.DeploymentElementNodeData, "deployment">) => import("react/jsx-runtime").JSX.Element>;
10
- 'compound-element': MemoExoticComponent<(props: NodeProps<Types.CompoundElementNodeData, "compound-element">) => import("react/jsx-runtime").JSX.Element>;
11
- 'compound-deployment': MemoExoticComponent<(props: NodeProps<Types.CompoundDeploymentNodeData, "compound-deployment">) => import("react/jsx-runtime").JSX.Element>;
12
- 'view-group': MemoExoticComponent<(props: NodeProps<Types.ViewGroupNodeData, "view-group">) => import("react/jsx-runtime").JSX.Element>;
13
- };
14
- export declare const edgeTypes: {
15
- relationship: FunctionComponent<{
16
- id: string;
17
- selected?: boolean;
18
- selectable?: boolean;
19
- deletable?: boolean;
20
- style?: CSSProperties;
21
- animated?: boolean;
22
- source: string;
23
- target: string;
24
- sourceX: number;
25
- sourceY: number;
26
- targetX: number;
27
- targetY: number;
28
- sourcePosition: Position;
29
- targetPosition: Position;
30
- label?: ReactNode;
31
- labelStyle?: CSSProperties;
32
- labelShowBg?: boolean;
33
- labelBgStyle?: CSSProperties;
34
- labelBgPadding?: [number, number];
35
- labelBgBorderRadius?: number;
36
- sourceHandleId?: string | null;
37
- targetHandleId?: string | null;
38
- markerStart?: string;
39
- markerEnd?: string;
40
- pathOptions?: any;
41
- interactionWidth?: number;
42
- data: EdgeData & {
43
- hovered?: boolean;
44
- active?: boolean;
45
- dimmed?: Dimmed;
46
- id: EdgeId;
47
- label: string | null;
48
- points: NonEmptyArray<Point>;
49
- color: Color | undefined;
50
- head: RelationshipArrowType | undefined;
51
- line: RelationshipLineType | undefined;
52
- dir: "forward" | "back" | "both" | undefined;
53
- technology: string | undefined;
54
- tail: RelationshipArrowType | undefined;
55
- labelBBox: BBox | null | undefined;
56
- navigateTo: ViewId<string> | null | undefined;
57
- notes: MarkdownOrString | undefined;
58
- labelXY: XYPosition | null;
59
- controlPoints: XYPosition[] | undefined | null;
60
- };
61
- }>;
62
- };
@@ -1,10 +0,0 @@
1
- import { NodeProps } from '../../../base';
2
- import { RelationshipDetailsTypes } from '../_types';
3
- import { MemoExoticComponent } from 'react';
4
- export declare const ElementNode: MemoExoticComponent<(props: NodeProps<RelationshipDetailsTypes.ElementNodeData, string>) => import("react/jsx-runtime").JSX.Element>;
5
- export declare const CompoundNode: MemoExoticComponent<(props: NodeProps<RelationshipDetailsTypes.CompoundNodeData, string>) => import("react/jsx-runtime").JSX.Element>;
6
- type ElementPortsProps = NodeProps<Pick<RelationshipDetailsTypes.ElementNodeData, 'ports' | 'height'>>;
7
- export declare const ElementPorts: ({ data: { ports, height: h } }: ElementPortsProps) => import("react/jsx-runtime").JSX.Element;
8
- type CompoundPortsProps = NodeProps<Pick<RelationshipDetailsTypes.CompoundNodeData, 'ports'>>;
9
- export declare const CompoundPorts: ({ data }: CompoundPortsProps) => import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,138 +0,0 @@
1
- import { css, sva } from '@likec4/styles/css'
2
-
3
- export const borderWidth = {
4
- var: '--_border-width',
5
- ref: 'var(--_border-width, 2px)',
6
- } as const
7
-
8
- export const borderRadius = {
9
- var: '--_border-radius',
10
- ref: 'var(--_border-radius, 4px)',
11
- } as const
12
-
13
- export const compoundOpacity = {
14
- var: '--_compound-opacity',
15
- ref: 'var(--_compound-opacity, 1)',
16
- } as const
17
-
18
- export const borderOpacityPercent = {
19
- var: '--_border-opacity-percent',
20
- ref: 'var(--_border-opacity-percent, 100%)',
21
- } as const
22
-
23
- const root = css.raw({
24
- position: 'relative',
25
- width: '100%',
26
- height: '100%',
27
- padding: '0',
28
- margin: '0',
29
- border: 'transparent',
30
- pointerEvents: 'none',
31
- _before: {
32
- borderRadius: borderRadius.ref,
33
- content: '" "',
34
- position: 'absolute',
35
- top: '0',
36
- left: '0',
37
- width: '100%',
38
- height: '100%',
39
- border: 'transparent',
40
- background: 'var(--likec4-palette-fill)',
41
- backgroundClip: 'padding-box',
42
- transitionDelay: '.075ms',
43
- },
44
- _noReduceGraphics: {
45
- _before: {
46
- transition: `all {durations.slow} {easings.inOut}`,
47
- },
48
- '&[data-likec4-hovered=\'true\']': {
49
- _before: {
50
- transitionDelay: '.2s',
51
- transitionTimingFunction: 'in',
52
- },
53
- },
54
- },
55
- '&:is([data-compound-transparent])': {
56
- _before: {
57
- opacity: compoundOpacity.ref,
58
- borderWidth: `calc(${borderWidth.ref} - 1px)`,
59
- },
60
- },
61
- })
62
-
63
- const compoundBorder = css.raw({
64
- borderRadius: borderRadius.ref,
65
- padding: '0',
66
- margin: '0',
67
- transition: `all 250ms {easings.inOut}`,
68
- cursor: 'default',
69
- position: 'absolute',
70
- top: '0',
71
- left: '0',
72
- width: '100%',
73
- height: '100%',
74
- pointerEvents: 'none',
75
- background: 'transparent',
76
- borderStyle: 'dashed',
77
- borderWidth: `[${borderWidth.ref}]`,
78
- borderColor: `[color-mix(in srgb, var(--likec4-palette-stroke) ${borderOpacityPercent.ref}, transparent)]`,
79
- })
80
-
81
- const indicatorSvg = css.raw({
82
- position: 'absolute',
83
- top: '0',
84
- left: '0',
85
- width: '100%',
86
- height: '100%',
87
- pointerEvents: 'none',
88
- overflow: 'visible',
89
- visibility: 'hidden',
90
- _whenFocused: {
91
- visibility: 'visible',
92
- },
93
- _whenSelected: {
94
- visibility: 'visible',
95
- },
96
- _whenPanning: {
97
- display: 'none',
98
- },
99
- })
100
-
101
- const indicatorRect = css.raw({
102
- stroke: `[color-mix(in srgb, var(--likec4-palette-stroke) 60%, var(--likec4-palette-hiContrast))]`,
103
- strokeWidth: '4',
104
- fill: '[none]',
105
- animationStyle: 'indicator',
106
- _light: {
107
- stroke: `[color-mix(in srgb, var(--likec4-palette-stroke) 80%, var(--likec4-palette-hiContrast))]`,
108
- },
109
- })
110
-
111
- export const compound = sva({
112
- slots: ['root', 'compoundBorder', 'indicatorSvg', 'indicatorRect'],
113
- className: 'compound-container',
114
- base: {
115
- root,
116
- compoundBorder,
117
- indicatorSvg,
118
- indicatorRect,
119
- },
120
- variants: {
121
- isTransparent: {
122
- false: {
123
- root: {
124
- _before: {
125
- boxShadow: {
126
- _noReduceGraphics: '0 4px 10px 0.5px rgba(0,0,0,0.1) , 0 2px 2px -1px rgba(0,0,0,0.4)',
127
- _whenSelected: 'none',
128
- _whenPanning: 'none !important',
129
- },
130
- },
131
- },
132
- },
133
- true: {
134
- root: {},
135
- },
136
- },
137
- },
138
- })
@@ -1,64 +0,0 @@
1
- import { css, sva } from '@likec4/styles/css'
2
-
3
- const labelBorderRadius = '4px'
4
-
5
- export const edgeNoteCloseButton = css({
6
- position: 'absolute',
7
- top: '1',
8
- right: '1',
9
- })
10
-
11
- export const edgeNoteText = css({
12
- userSelect: 'all',
13
- textAlign: 'left',
14
- whiteSpaceCollapse: 'preserve-breaks',
15
- textWrap: 'pretty',
16
- lineHeight: '1.25',
17
- '--text-fz': '{fontSizes.sm}',
18
- md: {
19
- '--text-fz': '{fontSizes.md}',
20
- },
21
- })
22
-
23
- export const translate = {
24
- var: '--edge-translate',
25
- ref: `var(--edge-translate)`,
26
- } as const
27
-
28
- export const edgeLabelContainer = css({
29
- top: '0',
30
- left: '0',
31
- position: 'absolute',
32
- pointerEvents: 'all',
33
- cursor: 'pointer',
34
- width: 'auto',
35
- height: 'auto',
36
- background: '[var(--xy-edge-label-background-color)]',
37
- color: '[var(--xy-edge-label-color)]',
38
- border: '0px solid transparent',
39
-
40
- borderRadius: labelBorderRadius,
41
-
42
- transform: `${translate.ref}`,
43
- transition: 'fast',
44
-
45
- '&:is([data-likec4-hovered=\'true\'])': {
46
- transition: `all 190ms {easings.inOut}`,
47
- transform: `var(--edge-translate, translate(0px, 0px)) scale(1.12)`,
48
- transitionDelay: '100ms',
49
- },
50
-
51
- _noReduceGraphics: {
52
- mixBlendMode: {
53
- _dark: 'plus-lighter',
54
- _light: 'screen',
55
- },
56
- },
57
-
58
- _smallZoom: {
59
- display: 'none',
60
- },
61
- _reduceGraphicsOnPan: {
62
- display: 'none',
63
- },
64
- })