@likec4/diagram 1.17.1 → 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 +40 -31
- package/src/LikeC4Diagram.props.ts +21 -12
- package/src/LikeC4Diagram.tsx +8 -10
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +45 -93
- 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/useDiagramState.ts +8 -3
- package/src/hooks/useXYFlow.ts +9 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/likec4model/useLikeC4ElementsTree.ts +6 -13
- package/src/likec4model/useLikeC4Model.ts +21 -11
- package/src/overlays/Overlays.tsx +96 -63
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -10
- package/src/overlays/edge-details/_types.ts +13 -33
- package/src/overlays/edge-details/use-layouted-edge-details.ts +35 -26
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +8 -13
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +7 -7
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/element-details/ElementDetailsCard.tsx +91 -78
- package/src/overlays/element-details/TabPanelDeployments.css.ts +69 -0
- package/src/overlays/element-details/TabPanelDeployments.tsx +217 -0
- package/src/overlays/element-details/TabPanelRelationships.tsx +8 -9
- package/src/overlays/element-details/TabPanelStructure.tsx +10 -10
- package/src/overlays/relationships-of/RelationshipsOverlay.tsx +1 -1
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +26 -34
- package/src/overlays/relationships-of/SelectElement.tsx +2 -2
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +54 -59
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +10 -16
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +24 -21
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -15
- 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 +63 -48
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +7 -34
- package/src/ui/Link.tsx +40 -0
- package/src/ui/notation/NotationPanel.tsx +4 -2
- package/src/ui/top-left/ChangeAutoLayoutButton.tsx +2 -2
- package/src/ui/top-left/TopLeftPanel.tsx +5 -5
- 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 +26 -19
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +23 -10
- 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 +27 -75
- package/src/xyflow/nodes/compound/CompoundNode.tsx +82 -163
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +73 -252
- package/src/xyflow/nodes/element/element.css.ts +40 -64
- package/src/xyflow/nodes/shared/ElementIcon.tsx +1 -1
- package/src/xyflow/nodes/shared/Toolbar.tsx +51 -35
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +10 -10
- package/src/xyflow/useXYFlowEvents.ts +31 -35
- package/src/xyflow/utils.ts +2 -2
- package/src/ui/OptionsPanel.css.ts +0 -9
- package/src/ui/OptionsPanel.tsx +0 -70
- package/src/ui/options/EdgeOptions.tsx +0 -142
- package/src/ui/options/NodeOptions.tsx +0 -362
- package/src/xyflow/nodes/element/ElementDetails.css.ts +0 -101
- package/src/xyflow/nodes/element/ElementDetails.tsx +0 -393
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
const Open = (props) => /* @__PURE__ */ jsx(
|
|
3
|
+
"marker",
|
|
4
|
+
{
|
|
5
|
+
viewBox: "-4 -4 14 16",
|
|
6
|
+
refX: 5,
|
|
7
|
+
refY: 4,
|
|
8
|
+
markerWidth: "7",
|
|
9
|
+
markerHeight: "8",
|
|
10
|
+
preserveAspectRatio: "xMaxYMid meet",
|
|
11
|
+
orient: "auto-start-reverse",
|
|
12
|
+
...props,
|
|
13
|
+
children: /* @__PURE__ */ jsx(
|
|
14
|
+
"path",
|
|
15
|
+
{
|
|
16
|
+
d: "M0,0 L7,4 L0,8 L4,4 Z",
|
|
17
|
+
stroke: "context-stroke",
|
|
18
|
+
fill: "context-stroke",
|
|
19
|
+
strokeDasharray: 0,
|
|
20
|
+
strokeWidth: 1,
|
|
21
|
+
strokeLinecap: "round"
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
const Arrow = (props) => /* @__PURE__ */ jsx(
|
|
27
|
+
"marker",
|
|
28
|
+
{
|
|
29
|
+
viewBox: "-1 -1 12 10",
|
|
30
|
+
refX: 4,
|
|
31
|
+
refY: 3,
|
|
32
|
+
markerWidth: "8",
|
|
33
|
+
markerHeight: "6",
|
|
34
|
+
preserveAspectRatio: "xMaxYMid meet",
|
|
35
|
+
orient: "auto-start-reverse",
|
|
36
|
+
...props,
|
|
37
|
+
children: /* @__PURE__ */ jsx(
|
|
38
|
+
"path",
|
|
39
|
+
{
|
|
40
|
+
d: "M 0 0 L 8 3 L 0 6 L 1 3 z",
|
|
41
|
+
fill: "context-stroke",
|
|
42
|
+
strokeWidth: 0
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
const Crow = (props) => /* @__PURE__ */ jsx(
|
|
48
|
+
"marker",
|
|
49
|
+
{
|
|
50
|
+
viewBox: "-1 -1 12 12",
|
|
51
|
+
refX: 8,
|
|
52
|
+
refY: 4,
|
|
53
|
+
markerWidth: "8",
|
|
54
|
+
markerHeight: "8",
|
|
55
|
+
preserveAspectRatio: "xMaxYMid meet",
|
|
56
|
+
orient: "auto-start-reverse",
|
|
57
|
+
...props,
|
|
58
|
+
children: /* @__PURE__ */ jsx(
|
|
59
|
+
"path",
|
|
60
|
+
{
|
|
61
|
+
d: "M 8 0 L 0 4 L 8 8 M 8 4 L 0 4",
|
|
62
|
+
fill: "none",
|
|
63
|
+
strokeWidth: 1
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
const OArrow = (props) => /* @__PURE__ */ jsx(
|
|
69
|
+
"marker",
|
|
70
|
+
{
|
|
71
|
+
viewBox: "-1 -1 12 10",
|
|
72
|
+
refX: 4,
|
|
73
|
+
refY: 3,
|
|
74
|
+
markerWidth: "8",
|
|
75
|
+
markerHeight: "6",
|
|
76
|
+
preserveAspectRatio: "xMaxYMid meet",
|
|
77
|
+
orient: "auto-start-reverse",
|
|
78
|
+
...props,
|
|
79
|
+
children: /* @__PURE__ */ jsx(
|
|
80
|
+
"path",
|
|
81
|
+
{
|
|
82
|
+
d: "M 0 0 L 8 3 L 0 6 L 1 3 z",
|
|
83
|
+
stroke: "context-stroke",
|
|
84
|
+
fill: "var(--likec4-background-color)",
|
|
85
|
+
strokeWidth: 1.25,
|
|
86
|
+
strokeLinejoin: "miter",
|
|
87
|
+
strokeLinecap: "square"
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
const Diamond = (props) => /* @__PURE__ */ jsx(
|
|
93
|
+
"marker",
|
|
94
|
+
{
|
|
95
|
+
viewBox: "-4 -4 16 14",
|
|
96
|
+
refX: 5,
|
|
97
|
+
refY: 4,
|
|
98
|
+
markerWidth: "10",
|
|
99
|
+
markerHeight: "8",
|
|
100
|
+
preserveAspectRatio: "xMaxYMid meet",
|
|
101
|
+
orient: "auto-start-reverse",
|
|
102
|
+
...props,
|
|
103
|
+
children: /* @__PURE__ */ jsx(
|
|
104
|
+
"path",
|
|
105
|
+
{
|
|
106
|
+
d: "M5,0 L10,4 L5,8 L0,4 Z",
|
|
107
|
+
fill: "context-stroke",
|
|
108
|
+
strokeWidth: 0,
|
|
109
|
+
strokeLinecap: "round"
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
const ODiamond = (props) => /* @__PURE__ */ jsx(
|
|
115
|
+
"marker",
|
|
116
|
+
{
|
|
117
|
+
viewBox: "-4 -4 16 14",
|
|
118
|
+
refX: 6,
|
|
119
|
+
refY: 4,
|
|
120
|
+
markerWidth: "10",
|
|
121
|
+
markerHeight: "8",
|
|
122
|
+
preserveAspectRatio: "xMaxYMid meet",
|
|
123
|
+
orient: "auto-start-reverse",
|
|
124
|
+
...props,
|
|
125
|
+
children: /* @__PURE__ */ jsx(
|
|
126
|
+
"path",
|
|
127
|
+
{
|
|
128
|
+
d: "M5,0 L10,4 L5,8 L0,4 Z",
|
|
129
|
+
stroke: "context-stroke",
|
|
130
|
+
fill: "var(--likec4-background-color)",
|
|
131
|
+
strokeWidth: 1.25,
|
|
132
|
+
strokeLinecap: "round"
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
const Dot = (props) => /* @__PURE__ */ jsx(
|
|
138
|
+
"marker",
|
|
139
|
+
{
|
|
140
|
+
viewBox: "0 0 10 10",
|
|
141
|
+
refX: 4,
|
|
142
|
+
refY: 4,
|
|
143
|
+
markerWidth: "6",
|
|
144
|
+
markerHeight: "6",
|
|
145
|
+
...props,
|
|
146
|
+
children: /* @__PURE__ */ jsx(
|
|
147
|
+
"circle",
|
|
148
|
+
{
|
|
149
|
+
strokeWidth: 0,
|
|
150
|
+
fill: "context-stroke",
|
|
151
|
+
cx: 4,
|
|
152
|
+
cy: 4,
|
|
153
|
+
r: 3
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
const ODot = (props) => /* @__PURE__ */ jsx(
|
|
159
|
+
"marker",
|
|
160
|
+
{
|
|
161
|
+
viewBox: "0 0 10 10",
|
|
162
|
+
refX: 4,
|
|
163
|
+
refY: 4,
|
|
164
|
+
markerWidth: "6",
|
|
165
|
+
markerHeight: "6",
|
|
166
|
+
...props,
|
|
167
|
+
children: /* @__PURE__ */ jsx(
|
|
168
|
+
"circle",
|
|
169
|
+
{
|
|
170
|
+
strokeWidth: 1.25,
|
|
171
|
+
stroke: "context-stroke",
|
|
172
|
+
fill: "var(--likec4-background-color)",
|
|
173
|
+
cx: 4,
|
|
174
|
+
cy: 4,
|
|
175
|
+
r: 3
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
const EdgeMarkers = {
|
|
181
|
+
Arrow,
|
|
182
|
+
Crow,
|
|
183
|
+
OArrow,
|
|
184
|
+
Open,
|
|
185
|
+
Diamond,
|
|
186
|
+
ODiamond,
|
|
187
|
+
Dot,
|
|
188
|
+
ODot
|
|
189
|
+
};
|
|
190
|
+
export {
|
|
191
|
+
EdgeMarkers
|
|
192
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useDebouncedEffect } from "@react-hookz/web";
|
|
3
|
+
import { shallowEqual } from "fast-equals";
|
|
4
|
+
import { useState, useRef } from "react";
|
|
5
|
+
import { useDiagramState, useDiagramStoreApi } from "../hooks/useDiagramState.js";
|
|
6
|
+
import { useXYStore } from "../hooks/useXYFlow.js";
|
|
7
|
+
function selectXYFlowSize(state) {
|
|
8
|
+
return `${Math.round(state.width)}:${Math.round(state.height)}`;
|
|
9
|
+
}
|
|
10
|
+
function selectDiagramsize({ view, fitViewPadding }) {
|
|
11
|
+
return [
|
|
12
|
+
view.bounds.x,
|
|
13
|
+
view.bounds.y,
|
|
14
|
+
view.bounds.width,
|
|
15
|
+
view.bounds.height,
|
|
16
|
+
fitViewPadding
|
|
17
|
+
].map(Math.round).join(":");
|
|
18
|
+
}
|
|
19
|
+
function FitViewOnViewportResize({ diagramApi }) {
|
|
20
|
+
const xyflowsize = useXYStore(selectXYFlowSize);
|
|
21
|
+
const viewsize = useDiagramState(selectDiagramsize);
|
|
22
|
+
const dimensions = xyflowsize + viewsize;
|
|
23
|
+
const prevDimensionsRef = useRef(dimensions);
|
|
24
|
+
useDebouncedEffect(
|
|
25
|
+
() => {
|
|
26
|
+
const { focusedNodeId, fitDiagram } = diagramApi.getState();
|
|
27
|
+
if (focusedNodeId || prevDimensionsRef.current === dimensions) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
prevDimensionsRef.current = dimensions;
|
|
31
|
+
fitDiagram(250);
|
|
32
|
+
},
|
|
33
|
+
[dimensions, diagramApi],
|
|
34
|
+
250
|
|
35
|
+
);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function selector({ view, activeWalkthrough, viewportChanged, fitViewPadding }) {
|
|
39
|
+
return {
|
|
40
|
+
layoutId: view.id + "_" + view.autoLayout + "_" + fitViewPadding,
|
|
41
|
+
isActiveWalkthrough: !!activeWalkthrough,
|
|
42
|
+
viewportNotMoved: !viewportChanged
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function FitViewOnDiagramChange() {
|
|
46
|
+
const {
|
|
47
|
+
layoutId,
|
|
48
|
+
isActiveWalkthrough,
|
|
49
|
+
viewportNotMoved
|
|
50
|
+
} = useDiagramState(selector, shallowEqual);
|
|
51
|
+
const diagramApi = useDiagramStoreApi();
|
|
52
|
+
const [currentLayoutId, setCurrent] = useState(layoutId);
|
|
53
|
+
const requiresFit = layoutId !== currentLayoutId;
|
|
54
|
+
useDebouncedEffect(
|
|
55
|
+
() => {
|
|
56
|
+
if (layoutId === currentLayoutId) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
setCurrent(layoutId);
|
|
60
|
+
diagramApi.getState().fitDiagram(450);
|
|
61
|
+
},
|
|
62
|
+
[requiresFit, diagramApi],
|
|
63
|
+
50
|
|
64
|
+
);
|
|
65
|
+
if (viewportNotMoved && !isActiveWalkthrough && !requiresFit) {
|
|
66
|
+
return /* @__PURE__ */ jsx(FitViewOnViewportResize, { diagramApi });
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
FitViewOnDiagramChange
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SelectEdgesOnNodeFocus(): null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { nonNullable } from "@likec4/core";
|
|
2
|
+
import { useHotkeys } from "@mantine/hooks";
|
|
3
|
+
import { getBoundsOfRects, getViewportForBounds } from "@xyflow/system";
|
|
4
|
+
import { useDiagramStoreApi, useDiagramState } from "../hooks/useDiagramState.js";
|
|
5
|
+
import { MinZoom } from "./const.js";
|
|
6
|
+
import { nodeToRect } from "./utils.js";
|
|
7
|
+
import { useUpdateEffect } from "../hooks/useUpdateEffect.js";
|
|
8
|
+
function SelectEdgesOnNodeFocus() {
|
|
9
|
+
const diagramStore = useDiagramStoreApi();
|
|
10
|
+
const focusedNodeId = useDiagramState((s) => s.focusedNodeId);
|
|
11
|
+
useUpdateEffect(() => {
|
|
12
|
+
if (!focusedNodeId) {
|
|
13
|
+
diagramStore.getState().xystore.getState().resetSelectedElements();
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const container = diagramStore.getState().getContainer();
|
|
17
|
+
if (!container) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const edgeChanges = [];
|
|
21
|
+
const nodeChanges = [];
|
|
22
|
+
const {
|
|
23
|
+
edgeLookup,
|
|
24
|
+
nodeLookup,
|
|
25
|
+
panZoom,
|
|
26
|
+
transform,
|
|
27
|
+
triggerNodeChanges,
|
|
28
|
+
triggerEdgeChanges
|
|
29
|
+
} = diagramStore.getState().xystore.getState();
|
|
30
|
+
let focusBounds = nodeToRect(nonNullable(nodeLookup.get(focusedNodeId)));
|
|
31
|
+
for (const [, edge] of edgeLookup) {
|
|
32
|
+
if (edge.source === focusedNodeId || edge.target === focusedNodeId) {
|
|
33
|
+
const anotherNodeId = edge.source === focusedNodeId ? edge.target : edge.source;
|
|
34
|
+
const nd = nonNullable(nodeLookup.get(anotherNodeId));
|
|
35
|
+
focusBounds = getBoundsOfRects(focusBounds, nodeToRect(nd));
|
|
36
|
+
}
|
|
37
|
+
if (edge.selected) {
|
|
38
|
+
edgeChanges.push({
|
|
39
|
+
id: edge.id,
|
|
40
|
+
type: "select",
|
|
41
|
+
selected: false
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const [, node] of nodeLookup) {
|
|
46
|
+
if (node.selected && node.id !== focusedNodeId) {
|
|
47
|
+
nodeChanges.push({
|
|
48
|
+
id: node.id,
|
|
49
|
+
type: "select",
|
|
50
|
+
selected: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
nodeChanges.push({
|
|
55
|
+
id: focusedNodeId,
|
|
56
|
+
type: "select",
|
|
57
|
+
selected: true
|
|
58
|
+
});
|
|
59
|
+
if (edgeChanges.length > 0) {
|
|
60
|
+
triggerEdgeChanges(edgeChanges);
|
|
61
|
+
}
|
|
62
|
+
triggerNodeChanges(nodeChanges);
|
|
63
|
+
const { width, height } = container.getBoundingClientRect();
|
|
64
|
+
const maxZoom = Math.max(1, transform[2]);
|
|
65
|
+
const viewport = getViewportForBounds(
|
|
66
|
+
{
|
|
67
|
+
x: focusBounds.x - 16,
|
|
68
|
+
y: focusBounds.y - 16,
|
|
69
|
+
width: focusBounds.width + 32,
|
|
70
|
+
height: focusBounds.height + 32
|
|
71
|
+
},
|
|
72
|
+
width,
|
|
73
|
+
height,
|
|
74
|
+
MinZoom,
|
|
75
|
+
maxZoom,
|
|
76
|
+
0
|
|
77
|
+
);
|
|
78
|
+
panZoom == null ? void 0 : panZoom.setViewport(viewport, {
|
|
79
|
+
duration: 350
|
|
80
|
+
});
|
|
81
|
+
}, [focusedNodeId]);
|
|
82
|
+
useHotkeys(
|
|
83
|
+
focusedNodeId !== null ? [
|
|
84
|
+
["Escape", (e) => {
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
const { resetFocusAndLastClicked, fitDiagram } = diagramStore.getState();
|
|
87
|
+
resetFocusAndLastClicked();
|
|
88
|
+
fitDiagram();
|
|
89
|
+
}, { preventDefault: true }]
|
|
90
|
+
] : []
|
|
91
|
+
);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
SelectEdgesOnNodeFocus
|
|
96
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSSProperties, PropsWithChildren } from 'react';
|
|
2
|
+
type XYFlowWrapperProps = PropsWithChildren<{
|
|
3
|
+
colorMode?: 'system' | 'light' | 'dark';
|
|
4
|
+
className?: string | undefined;
|
|
5
|
+
style?: CSSProperties | undefined;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function XYFlow({ colorMode, className, children, style }: XYFlowWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useOnViewportChange, ReactFlow } from "@xyflow/react";
|
|
3
|
+
import { shallowEqual } from "fast-equals";
|
|
4
|
+
import "react";
|
|
5
|
+
import { useDiagramState } from "../hooks/useDiagramState.js";
|
|
6
|
+
import { useXYStoreApi } from "../hooks/useXYFlow.js";
|
|
7
|
+
import { MaxZoom, MinZoom } from "./const.js";
|
|
8
|
+
import { RelationshipEdge } from "./edges/RelationshipEdge.js";
|
|
9
|
+
import { useLayoutConstraints } from "./useLayoutConstraints.js";
|
|
10
|
+
import { useXYFlowEvents } from "./useXYFlowEvents.js";
|
|
11
|
+
import { ElementNodeMemo } from "./nodes/element/ElementNode.js";
|
|
12
|
+
import { CompoundNodeMemo } from "./nodes/compound/CompoundNode.js";
|
|
13
|
+
const nodeTypes = {
|
|
14
|
+
element: ElementNodeMemo,
|
|
15
|
+
compound: CompoundNodeMemo
|
|
16
|
+
};
|
|
17
|
+
const edgeTypes = {
|
|
18
|
+
relationship: RelationshipEdge
|
|
19
|
+
};
|
|
20
|
+
const selector = (s) => ({
|
|
21
|
+
nodes: s.xynodes,
|
|
22
|
+
edges: s.xyedges,
|
|
23
|
+
onInit: s.onInit,
|
|
24
|
+
onNodesChange: s.onNodesChange,
|
|
25
|
+
onEdgesChange: s.onEdgesChange,
|
|
26
|
+
nodesSelectable: s.nodesSelectable || s.focusedNodeId !== null,
|
|
27
|
+
nodesDraggable: s.nodesDraggable,
|
|
28
|
+
fitView: s.fitViewEnabled,
|
|
29
|
+
fitViewPadding: s.fitViewPadding,
|
|
30
|
+
// hasOnNavigateTo: !!s.onNavigateTo,
|
|
31
|
+
// hasOnNodeClick: !!s.onNodeClick,
|
|
32
|
+
hasOnNodeContextMenu: !!s.onNodeContextMenu,
|
|
33
|
+
hasOnCanvasContextMenu: !!s.onCanvasContextMenu,
|
|
34
|
+
hasOnEdgeContextMenu: !!s.onEdgeContextMenu,
|
|
35
|
+
hasOnEdgeClick: !!s.onEdgeClick,
|
|
36
|
+
zoomable: s.zoomable,
|
|
37
|
+
pannable: s.pannable,
|
|
38
|
+
// If fitView is not enabled
|
|
39
|
+
// And diagram starts with a negative x or y - we need to translate viewprot
|
|
40
|
+
translateX: s.fitViewEnabled ? 0 : -Math.min(s.view.bounds.x, 0),
|
|
41
|
+
translateY: s.fitViewEnabled ? 0 : -Math.min(s.view.bounds.y, 0)
|
|
42
|
+
});
|
|
43
|
+
function XYFlow({
|
|
44
|
+
colorMode = "system",
|
|
45
|
+
className,
|
|
46
|
+
children,
|
|
47
|
+
style
|
|
48
|
+
}) {
|
|
49
|
+
const xyflowApi = useXYStoreApi();
|
|
50
|
+
const {
|
|
51
|
+
nodes,
|
|
52
|
+
edges,
|
|
53
|
+
onInit,
|
|
54
|
+
onNodesChange,
|
|
55
|
+
onEdgesChange,
|
|
56
|
+
nodesSelectable,
|
|
57
|
+
nodesDraggable,
|
|
58
|
+
fitView,
|
|
59
|
+
fitViewPadding,
|
|
60
|
+
pannable,
|
|
61
|
+
zoomable,
|
|
62
|
+
hasOnNodeContextMenu,
|
|
63
|
+
hasOnCanvasContextMenu,
|
|
64
|
+
hasOnEdgeContextMenu,
|
|
65
|
+
translateX,
|
|
66
|
+
translateY
|
|
67
|
+
} = useDiagramState(selector, shallowEqual);
|
|
68
|
+
const layoutConstraints = useLayoutConstraints();
|
|
69
|
+
const {
|
|
70
|
+
onNodeContextMenu,
|
|
71
|
+
onPaneContextMenu,
|
|
72
|
+
onEdgeContextMenu,
|
|
73
|
+
...handlers
|
|
74
|
+
} = useXYFlowEvents();
|
|
75
|
+
useOnViewportChange({
|
|
76
|
+
onEnd: ({ x, y, zoom }) => {
|
|
77
|
+
const roundedX = Math.round(x), roundedY = Math.round(y);
|
|
78
|
+
if (x !== roundedX || y !== roundedY) {
|
|
79
|
+
xyflowApi.setState({ transform: [roundedX, roundedY, zoom] });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return /* @__PURE__ */ jsx(
|
|
84
|
+
ReactFlow,
|
|
85
|
+
{
|
|
86
|
+
className,
|
|
87
|
+
style,
|
|
88
|
+
...colorMode && { colorMode },
|
|
89
|
+
nodes,
|
|
90
|
+
edges,
|
|
91
|
+
onNodesChange,
|
|
92
|
+
onEdgesChange,
|
|
93
|
+
onInit,
|
|
94
|
+
nodeTypes,
|
|
95
|
+
edgeTypes,
|
|
96
|
+
zoomOnPinch: zoomable,
|
|
97
|
+
zoomOnScroll: !pannable && zoomable,
|
|
98
|
+
...!zoomable && {
|
|
99
|
+
zoomActivationKeyCode: null
|
|
100
|
+
},
|
|
101
|
+
zoomOnDoubleClick: false,
|
|
102
|
+
maxZoom: zoomable ? MaxZoom : 1,
|
|
103
|
+
minZoom: zoomable ? MinZoom : 1,
|
|
104
|
+
fitView: false,
|
|
105
|
+
fitViewOptions: {
|
|
106
|
+
minZoom: MinZoom,
|
|
107
|
+
maxZoom: 1,
|
|
108
|
+
padding: fitViewPadding,
|
|
109
|
+
includeHiddenNodes: true
|
|
110
|
+
},
|
|
111
|
+
...!fitView && {
|
|
112
|
+
viewport: {
|
|
113
|
+
x: translateX,
|
|
114
|
+
y: translateY,
|
|
115
|
+
zoom: 1
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
preventScrolling: zoomable || pannable,
|
|
119
|
+
defaultMarkerColor: "var(--xy-edge-stroke)",
|
|
120
|
+
noDragClassName: "nodrag",
|
|
121
|
+
noPanClassName: "nopan",
|
|
122
|
+
panOnScroll: pannable,
|
|
123
|
+
panOnDrag: pannable,
|
|
124
|
+
...!pannable && {
|
|
125
|
+
selectionKeyCode: null
|
|
126
|
+
},
|
|
127
|
+
elementsSelectable: nodesSelectable,
|
|
128
|
+
nodesFocusable: nodesDraggable || nodesSelectable,
|
|
129
|
+
edgesFocusable: false,
|
|
130
|
+
nodesDraggable,
|
|
131
|
+
...nodesDraggable && layoutConstraints,
|
|
132
|
+
nodeDragThreshold: 4,
|
|
133
|
+
elevateNodesOnSelect: false,
|
|
134
|
+
selectNodesOnDrag: false,
|
|
135
|
+
...hasOnNodeContextMenu && { onNodeContextMenu },
|
|
136
|
+
...hasOnCanvasContextMenu && { onPaneContextMenu },
|
|
137
|
+
...hasOnEdgeContextMenu && { onEdgeContextMenu },
|
|
138
|
+
...handlers,
|
|
139
|
+
children
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
export {
|
|
144
|
+
XYFlow
|
|
145
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BackgroundProps } from '@xyflow/react';
|
|
2
|
+
import { OverrideProperties } from 'type-fest';
|
|
3
|
+
export type XYBackgroundVariant = 'dots' | 'lines' | 'cross';
|
|
4
|
+
export type XYBackground = XYBackgroundVariant | OverrideProperties<BackgroundProps, {
|
|
5
|
+
variant: XYBackgroundVariant;
|
|
6
|
+
}>;
|
|
7
|
+
export type XYBackgroundProps = {
|
|
8
|
+
background: XYBackground;
|
|
9
|
+
};
|
|
10
|
+
export declare function XYFlowBackground({ background }: XYBackgroundProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { nonexhaustive } from "@likec4/core";
|
|
3
|
+
import { Background, BackgroundVariant } from "@xyflow/react";
|
|
4
|
+
function literalToEnum(value) {
|
|
5
|
+
switch (value) {
|
|
6
|
+
case "dots":
|
|
7
|
+
return BackgroundVariant.Dots;
|
|
8
|
+
case "lines":
|
|
9
|
+
return BackgroundVariant.Lines;
|
|
10
|
+
case "cross":
|
|
11
|
+
return BackgroundVariant.Cross;
|
|
12
|
+
default:
|
|
13
|
+
nonexhaustive(value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function XYFlowBackground({ background }) {
|
|
17
|
+
if (typeof background === "string") {
|
|
18
|
+
return /* @__PURE__ */ jsx(Background, { variant: literalToEnum(background), size: 2, gap: 20 });
|
|
19
|
+
}
|
|
20
|
+
const { variant, ...rest } = background;
|
|
21
|
+
return /* @__PURE__ */ jsx(Background, { variant: literalToEnum(variant), ...rest });
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
XYFlowBackground
|
|
25
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LikeC4DiagramProperties } from '../LikeC4Diagram.props';
|
|
2
|
+
import { NamedExoticComponent } from 'react';
|
|
3
|
+
type XYFlowInnerProps = {
|
|
4
|
+
background: NonNullable<LikeC4DiagramProperties['background']>;
|
|
5
|
+
showDiagramTitle: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const XYFlowInner: NamedExoticComponent<XYFlowInnerProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { deepEqual } from "fast-equals";
|
|
3
|
+
import { memo } from "react";
|
|
4
|
+
import { isNonNullish } from "remeda";
|
|
5
|
+
import { useDiagramState } from "../hooks/useDiagramState.js";
|
|
6
|
+
import DiagramTitlePanel from "../ui/DiagramTitlePanel.js";
|
|
7
|
+
import { DynamicViewWalkthrough } from "../ui/DynamicViewWalkthrough.js";
|
|
8
|
+
import { TopLeftPanel } from "../ui/top-left/TopLeftPanel.js";
|
|
9
|
+
import { XYFlowBackground } from "./XYFlowBackground.js";
|
|
10
|
+
import { NotationPanel } from "../ui/notation/NotationPanel.js";
|
|
11
|
+
const XYFlowInner = /* @__PURE__ */ memo(function XYFlowInnerR({
|
|
12
|
+
background,
|
|
13
|
+
showDiagramTitle
|
|
14
|
+
}) {
|
|
15
|
+
const {
|
|
16
|
+
showNotations,
|
|
17
|
+
isDynamicView,
|
|
18
|
+
showTopLeft,
|
|
19
|
+
isDynamicViewActive,
|
|
20
|
+
enableDynamicViewWalkthrough
|
|
21
|
+
} = useDiagramState((s) => ({
|
|
22
|
+
showNotations: s.showNotations,
|
|
23
|
+
isDynamicView: s.isDynamicView,
|
|
24
|
+
showTopLeft: s.controls || s.showNavigationButtons && !!s.onNavigateTo || !!s.onBurgerMenuClick,
|
|
25
|
+
enableDynamicViewWalkthrough: s.enableDynamicViewWalkthrough,
|
|
26
|
+
isDynamicViewActive: isNonNullish(s.activeWalkthrough)
|
|
27
|
+
}));
|
|
28
|
+
const isBgWithPattern = background !== "transparent" && background !== "solid";
|
|
29
|
+
const isDiagramTitleVisible = showDiagramTitle && !isDynamicViewActive;
|
|
30
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
isBgWithPattern && /* @__PURE__ */ jsx(XYFlowBackground, { background }),
|
|
32
|
+
showTopLeft && /* @__PURE__ */ jsx(TopLeftPanel, {}),
|
|
33
|
+
isDiagramTitleVisible && /* @__PURE__ */ jsx(DiagramTitlePanel, {}),
|
|
34
|
+
isDynamicView && enableDynamicViewWalkthrough && /* @__PURE__ */ jsx(DynamicViewWalkthrough, {}),
|
|
35
|
+
showNotations && /* @__PURE__ */ jsx(NotationPanel, {})
|
|
36
|
+
] });
|
|
37
|
+
}, deepEqual);
|
|
38
|
+
XYFlowInner.displayName = "XYFlowInner";
|
|
39
|
+
export {
|
|
40
|
+
XYFlowInner
|
|
41
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BoxProps } from '@mantine/core';
|
|
2
|
+
import { DiagramFlowTypes } from '../types';
|
|
3
|
+
export interface EdgeLabelProps extends Omit<BoxProps, 'label'> {
|
|
4
|
+
isDimmed: boolean;
|
|
5
|
+
edgeData: DiagramFlowTypes.DiagramEdgeData;
|
|
6
|
+
}
|
|
7
|
+
export declare const EdgeLabel: ({ isDimmed, edgeData: { label, edge, }, ...props }: EdgeLabelProps) => import("react/jsx-runtime").JSX.Element;
|