@likec4/diagram 1.18.0 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/LikeC4CustomColors.d.ts +7 -0
- package/dist/LikeC4CustomColors.js +30 -0
- package/dist/LikeC4Diagram.css.d.ts +5 -0
- package/dist/LikeC4Diagram.css.js +13 -0
- package/dist/LikeC4Diagram.d.ts +6 -0
- package/dist/LikeC4Diagram.js +194 -0
- package/dist/LikeC4Diagram.props.d.ts +166 -0
- package/dist/LikeC4ModelProvider.d.ts +9 -0
- package/dist/LikeC4ModelProvider.js +12 -0
- package/dist/LikeC4Search.css.d.ts +1 -0
- package/dist/LikeC4Search.css.js +5 -0
- package/dist/LikeC4Search.d.ts +2 -0
- package/dist/LikeC4Search.js +96 -0
- package/dist/StaticLikeC4Diagram.d.ts +3 -0
- package/dist/StaticLikeC4Diagram.js +41 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/controls/Text.d.ts +2 -0
- package/dist/controls/Text.js +7 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.d.ts +1 -0
- package/dist/controls/action-button-bar/ActionButtonBar.css.js +5 -0
- package/dist/controls/action-button-bar/ActionButtonBar.d.ts +9 -0
- package/dist/controls/action-button-bar/ActionButtonBar.js +100 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.d.ts +10 -0
- package/dist/controls/action-button-bar/useActionButtonBarCtx.js +9 -0
- package/dist/controls/action-buttons/ActionButton.css.d.ts +1 -0
- package/dist/controls/action-buttons/ActionButton.css.js +5 -0
- package/dist/controls/action-buttons/ActionButton.d.ts +9 -0
- package/dist/controls/action-buttons/ActionButton.js +66 -0
- package/dist/controls/action-buttons/ActionButtons.d.ts +12 -0
- package/dist/controls/action-buttons/ActionButtons.js +99 -0
- package/dist/globals.css.d.ts +1 -0
- package/dist/globals.css.js +92 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useDiagramState.d.ts +6 -0
- package/dist/hooks/useDiagramState.js +27 -0
- package/dist/hooks/useMantinePortalProps.d.ts +9 -0
- package/dist/hooks/useMantinePortalProps.js +9 -0
- package/dist/hooks/useSetState.d.ts +2 -0
- package/dist/hooks/useSetState.js +19 -0
- package/dist/hooks/useUpdateEffect.d.ts +4 -0
- package/dist/hooks/useUpdateEffect.js +32 -0
- package/dist/hooks/useXYFlow.d.ts +270 -0
- package/dist/hooks/useXYFlow.js +20 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25 -0
- package/dist/likec4model/LikeC4ModelContext.d.ts +3 -0
- package/dist/likec4model/LikeC4ModelContext.js +5 -0
- package/dist/likec4model/index.d.ts +2 -0
- package/dist/likec4model/useLikeC4ElementsTree.d.ts +12 -0
- package/dist/likec4model/useLikeC4ElementsTree.js +25 -0
- package/dist/likec4model/useLikeC4Model.d.ts +20 -0
- package/dist/likec4model/useLikeC4Model.js +55 -0
- package/dist/overlays/OverlayContext.d.ts +10 -0
- package/dist/overlays/OverlayContext.js +9 -0
- package/dist/overlays/Overlays.css.d.ts +3 -0
- package/dist/overlays/Overlays.css.js +7 -0
- package/dist/overlays/Overlays.d.ts +2 -0
- package/dist/overlays/Overlays.js +137 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.d.ts +5 -0
- package/dist/overlays/edge-details/EdgeDetailsXYFlow.js +185 -0
- package/dist/overlays/edge-details/SelectEdge.css.d.ts +7 -0
- package/dist/overlays/edge-details/SelectEdge.css.js +17 -0
- package/dist/overlays/edge-details/SelectEdge.d.ts +5 -0
- package/dist/overlays/edge-details/SelectEdge.js +129 -0
- package/dist/overlays/edge-details/_types.d.ts +14 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.d.ts +21 -0
- package/dist/overlays/edge-details/use-layouted-edge-details.js +270 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/CompoundNode.js +76 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.d.ts +5 -0
- package/dist/overlays/edge-details/xyflow/ElementNode.js +159 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/edge-details/xyflow/RelationshipEdge.js +84 -0
- package/dist/overlays/edge-details/xyflow/styles.css.d.ts +9 -0
- package/dist/overlays/edge-details/xyflow/styles.css.js +21 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.d.ts +16 -0
- package/dist/overlays/element-details/ElementDetailsCard.css.js +33 -0
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +7 -0
- package/dist/overlays/element-details/ElementDetailsCard.js +484 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.d.ts +4 -0
- package/dist/overlays/element-details/TabPanelDeployments.css.js +11 -0
- package/dist/overlays/element-details/TabPanelDeployments.d.ts +7 -0
- package/dist/overlays/element-details/TabPanelDeployments.js +173 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.d.ts +5 -0
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -0
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +8 -0
- package/dist/overlays/element-details/TabPanelRelationships.js +157 -0
- package/dist/overlays/element-details/TabPanelStructure.css.d.ts +2 -0
- package/dist/overlays/element-details/TabPanelStructure.css.js +7 -0
- package/dist/overlays/element-details/TabPanelStructure.d.ts +25 -0
- package/dist/overlays/element-details/TabPanelStructure.js +91 -0
- package/dist/overlays/index.d.ts +1 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.d.ts +5 -0
- package/dist/overlays/relationships-of/RelationshipsOverlay.js +193 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.d.ts +19 -0
- package/dist/overlays/relationships-of/RelationshipsXYFlow.js +290 -0
- package/dist/overlays/relationships-of/SelectElement.css.d.ts +2 -0
- package/dist/overlays/relationships-of/SelectElement.css.js +7 -0
- package/dist/overlays/relationships-of/SelectElement.d.ts +7 -0
- package/dist/overlays/relationships-of/SelectElement.js +126 -0
- package/dist/overlays/relationships-of/_types.d.ts +28 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.d.ts +22 -0
- package/dist/overlays/relationships-of/use-layouted-relationships.js +496 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/CompoundNode.js +120 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.d.ts +6 -0
- package/dist/overlays/relationships-of/xyflow/ElementNode.js +194 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.d.ts +5 -0
- package/dist/overlays/relationships-of/xyflow/EmptyNode.js +18 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.d.ts +3 -0
- package/dist/overlays/relationships-of/xyflow/RelationshipEdge.js +123 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.d.ts +14 -0
- package/dist/overlays/relationships-of/xyflow/styles.css.js +24 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.d.ts +4 -0
- package/dist/overlays/shared/xyflow/RelationshipEdge.css.js +12 -0
- package/dist/overlays/shared/xyflow/_types.d.ts +77 -0
- package/dist/state/DiagramContext.d.ts +1609 -0
- package/dist/state/DiagramContext.js +101 -0
- package/dist/state/aligners.d.ts +42 -0
- package/dist/state/aligners.js +349 -0
- package/dist/state/diagram-to-xyflow.d.ts +11 -0
- package/dist/state/diagram-to-xyflow.js +113 -0
- package/dist/state/diagramStore.d.ts +1705 -0
- package/dist/state/diagramStore.js +808 -0
- package/dist/state/diagramStore.layout.d.ts +4 -0
- package/dist/state/diagramStore.layout.js +56 -0
- package/dist/style.css +1 -0
- package/dist/theme-vars.css.d.ts +72 -0
- package/dist/theme-vars.css.js +6 -0
- package/dist/theme-vars.css.ts.vanilla.css.js +1 -0
- package/dist/theme-vars.d.ts +3 -0
- package/dist/theme-vars.js +5 -0
- package/dist/ui/DiagramTitlePanel.css.d.ts +4 -0
- package/dist/ui/DiagramTitlePanel.css.js +11 -0
- package/dist/ui/DiagramTitlePanel.d.ts +1 -0
- package/dist/ui/DiagramTitlePanel.js +159 -0
- package/dist/ui/DynamicViewWalkthrough.css.d.ts +4 -0
- package/dist/ui/DynamicViewWalkthrough.css.js +11 -0
- package/dist/ui/DynamicViewWalkthrough.d.ts +1 -0
- package/dist/ui/DynamicViewWalkthrough.js +156 -0
- package/dist/ui/EnsureMantine.d.ts +7 -0
- package/dist/ui/EnsureMantine.js +14 -0
- package/dist/ui/FramerMotionConfig.d.ts +2 -0
- package/dist/ui/FramerMotionConfig.js +14 -0
- package/dist/ui/Link.d.ts +4 -0
- package/dist/ui/Link.js +36 -0
- package/dist/ui/notation/NotationPanel.css.d.ts +6 -0
- package/dist/ui/notation/NotationPanel.css.js +16 -0
- package/dist/ui/notation/NotationPanel.d.ts +1 -0
- package/dist/ui/notation/NotationPanel.js +250 -0
- package/dist/ui/notation/index.d.ts +1 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.d.ts +2 -0
- package/dist/ui/top-left/ChangeAutoLayoutButton.js +159 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.d.ts +2 -0
- package/dist/ui/top-left/ManualLayoutToolsButton.js +137 -0
- package/dist/ui/top-left/TopLeftPanel.d.ts +4 -0
- package/dist/ui/top-left/TopLeftPanel.js +211 -0
- package/dist/ui/top-left/_shared.d.ts +7 -0
- package/dist/ui/top-left/_shared.js +22 -0
- package/dist/ui/top-left/styles.css.d.ts +8 -0
- package/dist/ui/top-left/styles.css.js +17 -0
- package/dist/utils/types.d.ts +8 -0
- package/dist/utils/vector.d.ts +24 -0
- package/dist/utils/vector.js +55 -0
- package/dist/xyflow/EdgeMarkers.d.ts +12 -0
- package/dist/xyflow/EdgeMarkers.js +192 -0
- package/dist/xyflow/FitviewOnDiagramChange.d.ts +4 -0
- package/dist/xyflow/FitviewOnDiagramChange.js +72 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.d.ts +1 -0
- package/dist/xyflow/SelectEdgesOnNodeFocus.js +96 -0
- package/dist/xyflow/XYFlow.d.ts +8 -0
- package/dist/xyflow/XYFlow.js +145 -0
- package/dist/xyflow/XYFlowBackground.d.ts +10 -0
- package/dist/xyflow/XYFlowBackground.js +25 -0
- package/dist/xyflow/XYFlowInner.d.ts +8 -0
- package/dist/xyflow/XYFlowInner.js +41 -0
- package/dist/xyflow/const.d.ts +7 -0
- package/dist/xyflow/const.js +12 -0
- package/dist/xyflow/edges/EdgeLabel.d.ts +7 -0
- package/dist/xyflow/edges/EdgeLabel.js +160 -0
- package/dist/xyflow/edges/RelationshipEdge.d.ts +6 -0
- package/dist/xyflow/edges/RelationshipEdge.js +443 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.d.ts +4 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.css.js +11 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.d.ts +13 -0
- package/dist/xyflow/edges/RelationshipsDropdownMenu.js +211 -0
- package/dist/xyflow/edges/edges.css.d.ts +17 -0
- package/dist/xyflow/edges/edges.css.js +37 -0
- package/dist/xyflow/edges/utils.d.ts +16 -0
- package/dist/xyflow/edges/utils.js +24 -0
- package/dist/xyflow/nodes/AnimateVariants.d.ts +1313 -0
- package/dist/xyflow/nodes/AnimateVariants.js +123 -0
- package/dist/xyflow/nodes/Node.css.d.ts +3 -0
- package/dist/xyflow/nodes/Node.css.js +9 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.d.ts +14 -0
- package/dist/xyflow/nodes/compound/CompoundNode.css.js +27 -0
- package/dist/xyflow/nodes/compound/CompoundNode.d.ts +6 -0
- package/dist/xyflow/nodes/compound/CompoundNode.js +216 -0
- package/dist/xyflow/nodes/compound/index.d.ts +1 -0
- package/dist/xyflow/nodes/element/ElementLink.css.d.ts +3 -0
- package/dist/xyflow/nodes/element/ElementLink.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.d.ts +6 -0
- package/dist/xyflow/nodes/element/ElementNode.js +190 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.d.ts +17 -0
- package/dist/xyflow/nodes/element/ElementShapeSvg.js +175 -0
- package/dist/xyflow/nodes/element/element.css.d.ts +18 -0
- package/dist/xyflow/nodes/element/element.css.js +31 -0
- package/dist/xyflow/nodes/element/index.d.ts +1 -0
- package/dist/xyflow/nodes/shared/ElementIcon.d.ts +8 -0
- package/dist/xyflow/nodes/shared/ElementIcon.js +38 -0
- package/dist/xyflow/nodes/shared/Toolbar.d.ts +9 -0
- package/dist/xyflow/nodes/shared/Toolbar.js +436 -0
- package/dist/xyflow/types.d.ts +36 -0
- package/dist/xyflow/useLayoutConstraints.d.ts +42 -0
- package/dist/xyflow/useLayoutConstraints.js +226 -0
- package/dist/xyflow/useXYFlowEvents.d.ts +160 -0
- package/dist/xyflow/useXYFlowEvents.js +275 -0
- package/dist/xyflow/utils.d.ts +22 -0
- package/dist/xyflow/utils.js +72 -0
- package/package.json +34 -27
- package/src/LikeC4Diagram.tsx +4 -4
- package/src/LikeC4Search.css.ts +12 -0
- package/src/LikeC4Search.tsx +39 -90
- package/src/controls/Text.ts +5 -0
- package/src/controls/action-button-bar/ActionButtonBar.css.ts +13 -0
- package/src/controls/action-button-bar/ActionButtonBar.tsx +138 -0
- package/src/controls/action-button-bar/useActionButtonBarCtx.ts +13 -0
- package/src/controls/action-buttons/ActionButton.css.ts +29 -0
- package/src/controls/action-buttons/ActionButton.tsx +66 -0
- package/src/controls/action-buttons/ActionButtons.tsx +138 -0
- package/src/hooks/useXYFlow.ts +8 -8
- package/src/index.ts +12 -6
- package/src/likec4model/index.ts +12 -2
- package/src/overlays/edge-details/EdgeDetailsXYFlow.tsx +18 -12
- package/src/overlays/edge-details/_types.ts +13 -37
- package/src/overlays/edge-details/use-layouted-edge-details.ts +16 -14
- package/src/overlays/edge-details/xyflow/CompoundNode.tsx +3 -11
- package/src/overlays/edge-details/xyflow/ElementNode.tsx +4 -11
- package/src/overlays/edge-details/xyflow/RelationshipEdge.tsx +3 -3
- package/src/overlays/edge-details/xyflow/styles.css.ts +1 -59
- package/src/overlays/relationships-of/RelationshipsXYFlow.tsx +23 -23
- package/src/overlays/relationships-of/_types.ts +20 -58
- package/src/overlays/relationships-of/use-layouted-relationships.ts +36 -40
- package/src/overlays/relationships-of/xyflow/CompoundNode.tsx +9 -13
- package/src/overlays/relationships-of/xyflow/ElementNode.tsx +12 -15
- package/src/overlays/relationships-of/xyflow/EmptyNode.tsx +4 -7
- package/src/overlays/relationships-of/xyflow/RelationshipEdge.tsx +16 -14
- package/src/overlays/shared/xyflow/RelationshipEdge.css.ts +60 -0
- package/src/overlays/shared/xyflow/_types.ts +87 -0
- package/src/state/diagram-to-xyflow.ts +6 -7
- package/src/state/diagramStore.layout.ts +3 -4
- package/src/state/diagramStore.ts +35 -37
- package/src/theme-vars.css.ts +81 -0
- package/src/theme-vars.ts +8 -81
- package/src/ui/DiagramTitlePanel.tsx +6 -6
- package/src/utils/types.ts +6 -0
- package/src/xyflow/SelectEdgesOnNodeFocus.tsx +3 -3
- package/src/xyflow/XYFlow.tsx +2 -2
- package/src/xyflow/edges/EdgeLabel.tsx +25 -18
- package/src/xyflow/edges/RelationshipEdge.tsx +5 -3
- package/src/xyflow/edges/RelationshipsDropdownMenu.tsx +3 -3
- package/src/xyflow/edges/edges.css.ts +68 -74
- package/src/xyflow/edges/utils.ts +6 -6
- package/src/xyflow/nodes/AnimateVariants.ts +143 -0
- package/src/xyflow/nodes/Node.css.ts +44 -0
- package/src/xyflow/nodes/compound/CompoundNode.css.ts +1 -64
- package/src/xyflow/nodes/compound/CompoundNode.tsx +69 -182
- package/src/xyflow/nodes/element/ElementLink.tsx +2 -3
- package/src/xyflow/nodes/element/ElementNode.tsx +64 -266
- package/src/xyflow/nodes/element/element.css.ts +0 -57
- package/src/xyflow/nodes/shared/Toolbar.tsx +30 -30
- package/src/xyflow/types.ts +48 -51
- package/src/xyflow/useLayoutConstraints.ts +9 -9
- package/src/xyflow/useXYFlowEvents.ts +13 -30
- package/src/xyflow/utils.ts +2 -2
- package/src/xyflow/nodes/use-animate-variants.tsx +0 -64
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { nonNullable } from "@likec4/core";
|
|
3
|
+
import { Box, Button, Badge, ButtonGroup } from "@mantine/core";
|
|
4
|
+
import { useHotkeys } from "@mantine/hooks";
|
|
5
|
+
import { IconPlayerPlayFilled, IconPlayerSkipBackFilled, IconPlayerStopFilled, IconPlayerSkipForwardFilled } from "@tabler/icons-react";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
8
|
+
import { isNonNull, isTruthy, first } from "remeda";
|
|
9
|
+
import { parallelStateFrame, container, buttons, btn } from "./DynamicViewWalkthrough.css.js";
|
|
10
|
+
import { useXYStore } from "../hooks/useXYFlow.js";
|
|
11
|
+
import { useDiagramState, useDiagramStoreApi } from "../hooks/useDiagramState.js";
|
|
12
|
+
function DynamicViewWalkthrough() {
|
|
13
|
+
const isMobile = useXYStore((s) => s.width <= 750);
|
|
14
|
+
const {
|
|
15
|
+
nextDynamicStep,
|
|
16
|
+
stopDynamicView,
|
|
17
|
+
isActive,
|
|
18
|
+
isParallel,
|
|
19
|
+
hasNext,
|
|
20
|
+
hasPrevious
|
|
21
|
+
} = useDiagramState((s) => {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
return {
|
|
24
|
+
nextDynamicStep: s.nextDynamicStep,
|
|
25
|
+
stopDynamicView: s.stopWalkthrough,
|
|
26
|
+
isActive: isNonNull(s.activeWalkthrough),
|
|
27
|
+
isParallel: isTruthy((_a = s.activeWalkthrough) == null ? void 0 : _a.parallelPrefix),
|
|
28
|
+
hasNext: ((_b = s.activeWalkthrough) == null ? void 0 : _b.hasNext) ?? false,
|
|
29
|
+
hasPrevious: ((_c = s.activeWalkthrough) == null ? void 0 : _c.hasPrevious) ?? false
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
const diagramApi = useDiagramStoreApi();
|
|
33
|
+
useHotkeys(
|
|
34
|
+
isActive ? [
|
|
35
|
+
["ArrowLeft", () => nextDynamicStep(-1)],
|
|
36
|
+
["ArrowRight", () => nextDynamicStep()],
|
|
37
|
+
["Escape", (e) => {
|
|
38
|
+
e.stopImmediatePropagation();
|
|
39
|
+
stopDynamicView();
|
|
40
|
+
}, { preventDefault: true }]
|
|
41
|
+
] : [
|
|
42
|
+
["ArrowLeft", () => nextDynamicStep()],
|
|
43
|
+
["ArrowRight", () => nextDynamicStep()]
|
|
44
|
+
]
|
|
45
|
+
);
|
|
46
|
+
const buttonProps = {
|
|
47
|
+
className: btn,
|
|
48
|
+
size: isMobile ? "compact-md" : "lg",
|
|
49
|
+
radius: isMobile ? "lg" : "xl"
|
|
50
|
+
};
|
|
51
|
+
const startWalkthrough = (e) => {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
const {
|
|
54
|
+
xyedges,
|
|
55
|
+
activateWalkthrough
|
|
56
|
+
} = diagramApi.getState();
|
|
57
|
+
const firstEdge = nonNullable(first(xyedges), "expected at least one edge");
|
|
58
|
+
activateWalkthrough(firstEdge.data.edge.id);
|
|
59
|
+
};
|
|
60
|
+
const nextStep = (increment = 1) => (e) => {
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
nextDynamicStep(increment);
|
|
63
|
+
};
|
|
64
|
+
return /* @__PURE__ */ jsxs(AnimatePresence, { children: [
|
|
65
|
+
isParallel && /* @__PURE__ */ jsx(
|
|
66
|
+
Box,
|
|
67
|
+
{
|
|
68
|
+
layout: true,
|
|
69
|
+
component: m.div,
|
|
70
|
+
initial: { opacity: 0 },
|
|
71
|
+
animate: { opacity: 1 },
|
|
72
|
+
exit: { opacity: 0 },
|
|
73
|
+
className: clsx("react-flow__panel", parallelStateFrame)
|
|
74
|
+
},
|
|
75
|
+
"parallel-frame"
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ jsxs(
|
|
78
|
+
Box,
|
|
79
|
+
{
|
|
80
|
+
className: clsx("react-flow__panel", container),
|
|
81
|
+
onClick: (e) => e.stopPropagation(),
|
|
82
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
83
|
+
children: [
|
|
84
|
+
!isActive && /* @__PURE__ */ jsx(
|
|
85
|
+
Button,
|
|
86
|
+
{
|
|
87
|
+
...buttonProps,
|
|
88
|
+
className: clsx(buttons, btn),
|
|
89
|
+
rightSection: /* @__PURE__ */ jsx(IconPlayerPlayFilled, {}),
|
|
90
|
+
onClick: startWalkthrough,
|
|
91
|
+
px: "xl",
|
|
92
|
+
children: "Start"
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
isParallel && /* @__PURE__ */ jsx(
|
|
96
|
+
Badge,
|
|
97
|
+
{
|
|
98
|
+
component: m.div,
|
|
99
|
+
initial: { opacity: 0.05, transform: "translateY(20px)" },
|
|
100
|
+
animate: { opacity: 1, transform: "translateY(0)" },
|
|
101
|
+
exit: {
|
|
102
|
+
opacity: 0,
|
|
103
|
+
transform: "translateY(20px)"
|
|
104
|
+
},
|
|
105
|
+
variant: "gradient",
|
|
106
|
+
size: isMobile ? "xs" : "md",
|
|
107
|
+
gradient: { from: "red", to: "orange", deg: 90 },
|
|
108
|
+
radius: "sm",
|
|
109
|
+
children: "parallel"
|
|
110
|
+
},
|
|
111
|
+
"parallel-badge"
|
|
112
|
+
),
|
|
113
|
+
isActive && /* @__PURE__ */ jsxs(ButtonGroup, { className: buttons, children: [
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
Button,
|
|
116
|
+
{
|
|
117
|
+
...buttonProps,
|
|
118
|
+
pl: "lg",
|
|
119
|
+
disabled: !hasPrevious,
|
|
120
|
+
onClick: nextStep(-1),
|
|
121
|
+
children: /* @__PURE__ */ jsx(IconPlayerSkipBackFilled, {})
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsxs(
|
|
125
|
+
Button,
|
|
126
|
+
{
|
|
127
|
+
...buttonProps,
|
|
128
|
+
px: hasNext ? "md" : "xl",
|
|
129
|
+
onClick: (e) => {
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
stopDynamicView();
|
|
132
|
+
},
|
|
133
|
+
children: [
|
|
134
|
+
hasNext && /* @__PURE__ */ jsx(IconPlayerStopFilled, {}),
|
|
135
|
+
!hasNext && "End"
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
hasNext && /* @__PURE__ */ jsx(
|
|
140
|
+
Button,
|
|
141
|
+
{
|
|
142
|
+
...buttonProps,
|
|
143
|
+
pr: "lg",
|
|
144
|
+
onClick: nextStep(),
|
|
145
|
+
children: /* @__PURE__ */ jsx(IconPlayerSkipForwardFilled, {})
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
] })
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
DynamicViewWalkthrough
|
|
156
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
type EnsureMantineProps = PropsWithChildren<{}>;
|
|
3
|
+
export declare function EnsureMantine({ children }: EnsureMantineProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare namespace EnsureMantine {
|
|
5
|
+
var displayName: string;
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { MantineContext } from "@mantine/core";
|
|
3
|
+
import { useContext } from "react";
|
|
4
|
+
function EnsureMantine({ children }) {
|
|
5
|
+
const mantineCtx = useContext(MantineContext);
|
|
6
|
+
if (!mantineCtx) {
|
|
7
|
+
throw new Error("LikeC4Diagram must be a child of MantineProvider");
|
|
8
|
+
}
|
|
9
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
10
|
+
}
|
|
11
|
+
EnsureMantine.displayName = "EnsureMantine";
|
|
12
|
+
export {
|
|
13
|
+
EnsureMantine
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMantineStyleNonce } from "@mantine/core";
|
|
3
|
+
import { useId } from "@mantine/hooks";
|
|
4
|
+
import { LazyMotion, domMax, MotionConfig, LayoutGroup } from "framer-motion";
|
|
5
|
+
import "react";
|
|
6
|
+
const FramerMotionConfig = ({ children }) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const layoutId = useId();
|
|
9
|
+
const nonce = (_a = useMantineStyleNonce()) == null ? void 0 : _a();
|
|
10
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(MotionConfig, { reducedMotion: "user", ...nonce && { nonce }, children: /* @__PURE__ */ jsx(LayoutGroup, { id: layoutId, children }) }) });
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
FramerMotionConfig
|
|
14
|
+
};
|
package/dist/ui/Link.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Group, Box, Anchor, CopyButton, Button } from "@mantine/core";
|
|
3
|
+
function Link({ link }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Group, { wrap: "nowrap", align: "center", gap: "sm", children: [
|
|
5
|
+
/* @__PURE__ */ jsx(Box, { flex: "1", style: { overflow: "hidden" }, children: /* @__PURE__ */ jsx(
|
|
6
|
+
Anchor,
|
|
7
|
+
{
|
|
8
|
+
href: link.url,
|
|
9
|
+
target: "_blank",
|
|
10
|
+
fz: "xs",
|
|
11
|
+
truncate: "end",
|
|
12
|
+
display: "inline-block",
|
|
13
|
+
w: "100%",
|
|
14
|
+
onClick: (e) => e.stopPropagation(),
|
|
15
|
+
children: link.title || link.url
|
|
16
|
+
}
|
|
17
|
+
) }),
|
|
18
|
+
/* @__PURE__ */ jsx(CopyButton, { value: link.url, children: ({ copied, copy }) => /* @__PURE__ */ jsx(
|
|
19
|
+
Button,
|
|
20
|
+
{
|
|
21
|
+
size: "compact-xs",
|
|
22
|
+
fz: "10",
|
|
23
|
+
variant: "light",
|
|
24
|
+
onClick: (e) => {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
copy();
|
|
27
|
+
},
|
|
28
|
+
color: copied ? "teal" : "gray",
|
|
29
|
+
children: copied ? "copied" : "copy"
|
|
30
|
+
}
|
|
31
|
+
) })
|
|
32
|
+
] }, link.url) });
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
Link
|
|
36
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
var container = "_1ncdyfa0";
|
|
4
|
+
var card = "_1ncdyfa1";
|
|
5
|
+
var tabPanel = "_1ncdyfa2";
|
|
6
|
+
var elementNotation = "_1ncdyfa3";
|
|
7
|
+
var shapeSvg = "_1ncdyfa4";
|
|
8
|
+
var shapeBadge = "_1ncdyfa5";
|
|
9
|
+
export {
|
|
10
|
+
card,
|
|
11
|
+
container,
|
|
12
|
+
elementNotation,
|
|
13
|
+
shapeBadge,
|
|
14
|
+
shapeSvg,
|
|
15
|
+
tabPanel
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function NotationPanel(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@likec4/core";
|
|
3
|
+
import { Tooltip, ThemeIcon, ActionIcon, Paper, Tabs, TabsList, TabsTab, TabsPanel, ScrollAreaAutosize, Stack, Card, Group, Box, Badge, Text } from "@mantine/core";
|
|
4
|
+
import { useLocalStorage } from "@mantine/hooks";
|
|
5
|
+
import { IconAlertTriangle, IconHelpCircle, IconArrowDownRight } from "@tabler/icons-react";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { AnimatePresence, m } from "framer-motion";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { ceil, isNonNullish, isNullish } from "remeda";
|
|
10
|
+
import { useDiagramState, useDiagramStoreApi } from "../../hooks/useDiagramState.js";
|
|
11
|
+
import { useMantinePortalProps } from "../../hooks/useMantinePortalProps.js";
|
|
12
|
+
import { ElementShapeSvg } from "../../xyflow/nodes/element/ElementShapeSvg.js";
|
|
13
|
+
import { container, card, tabPanel, elementNotation, shapeSvg, shapeBadge } from "./NotationPanel.css.js";
|
|
14
|
+
import { vars } from "../../theme-vars.css.js";
|
|
15
|
+
import { useXYStore } from "../../hooks/useXYFlow.js";
|
|
16
|
+
const ElementNotation = ({ value }) => {
|
|
17
|
+
const {
|
|
18
|
+
title,
|
|
19
|
+
color = "primary",
|
|
20
|
+
shape = "rectangle"
|
|
21
|
+
} = value;
|
|
22
|
+
const [onlyKind, setOnlyKind] = useState(null);
|
|
23
|
+
const diagramStore = useDiagramStoreApi();
|
|
24
|
+
const w = 300;
|
|
25
|
+
const h = 200;
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
Card,
|
|
28
|
+
{
|
|
29
|
+
shadow: "none",
|
|
30
|
+
px: "xs",
|
|
31
|
+
py: "sm",
|
|
32
|
+
className: elementNotation,
|
|
33
|
+
mod: {
|
|
34
|
+
"data-likec4-color": color
|
|
35
|
+
},
|
|
36
|
+
onMouseEnter: () => {
|
|
37
|
+
setOnlyKind(null);
|
|
38
|
+
diagramStore.getState().highlightByElementNotation(value);
|
|
39
|
+
},
|
|
40
|
+
onMouseLeave: () => {
|
|
41
|
+
setOnlyKind(null);
|
|
42
|
+
diagramStore.setState({ dimmed: /* @__PURE__ */ new Set() });
|
|
43
|
+
},
|
|
44
|
+
children: /* @__PURE__ */ jsxs(
|
|
45
|
+
Group,
|
|
46
|
+
{
|
|
47
|
+
gap: "sm",
|
|
48
|
+
align: "stretch",
|
|
49
|
+
wrap: "nowrap",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
Box,
|
|
53
|
+
{
|
|
54
|
+
flex: "0 0 70px",
|
|
55
|
+
style: {
|
|
56
|
+
width: 70,
|
|
57
|
+
height: ceil(70 * (h / w), 0)
|
|
58
|
+
},
|
|
59
|
+
children: /* @__PURE__ */ jsx(
|
|
60
|
+
"svg",
|
|
61
|
+
{
|
|
62
|
+
className: clsx(
|
|
63
|
+
shapeSvg
|
|
64
|
+
),
|
|
65
|
+
viewBox: `0 0 ${w} ${h}`,
|
|
66
|
+
children: /* @__PURE__ */ jsx(
|
|
67
|
+
ElementShapeSvg,
|
|
68
|
+
{
|
|
69
|
+
shape,
|
|
70
|
+
w,
|
|
71
|
+
h
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ jsxs(Stack, { gap: 4, flex: 1, children: [
|
|
79
|
+
/* @__PURE__ */ jsx(Group, { gap: 4, flex: "0 0 auto", children: value.kinds.map((kind) => /* @__PURE__ */ jsx(
|
|
80
|
+
Badge,
|
|
81
|
+
{
|
|
82
|
+
className: shapeBadge,
|
|
83
|
+
onMouseEnter: () => {
|
|
84
|
+
setOnlyKind(kind);
|
|
85
|
+
diagramStore.getState().highlightByElementNotation(value, kind);
|
|
86
|
+
},
|
|
87
|
+
onMouseLeave: () => {
|
|
88
|
+
setOnlyKind(null);
|
|
89
|
+
diagramStore.getState().highlightByElementNotation(value);
|
|
90
|
+
},
|
|
91
|
+
opacity: isNonNullish(onlyKind) && onlyKind !== kind ? 0.25 : 1,
|
|
92
|
+
color: isNonNullish(onlyKind) && onlyKind !== kind ? "gray" : vars.element.fill,
|
|
93
|
+
children: kind
|
|
94
|
+
},
|
|
95
|
+
kind
|
|
96
|
+
)) }),
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
Text,
|
|
99
|
+
{
|
|
100
|
+
component: "div",
|
|
101
|
+
fz: "sm",
|
|
102
|
+
fw: 500,
|
|
103
|
+
lh: "1.25",
|
|
104
|
+
style: {
|
|
105
|
+
textWrap: "pretty"
|
|
106
|
+
},
|
|
107
|
+
children: title
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
] })
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
const selector = (s) => {
|
|
118
|
+
var _a;
|
|
119
|
+
return {
|
|
120
|
+
id: s.view.id,
|
|
121
|
+
notations: ((_a = s.view.notation) == null ? void 0 : _a.elements) ?? [],
|
|
122
|
+
isVisible: isNullish(s.focusedNodeId ?? s.activeWalkthrough)
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
function NotationPanel() {
|
|
126
|
+
const height = useXYStore((s) => s.height);
|
|
127
|
+
const {
|
|
128
|
+
id,
|
|
129
|
+
notations,
|
|
130
|
+
isVisible
|
|
131
|
+
} = useDiagramState(selector);
|
|
132
|
+
const [isCollapsed, setCollapsed] = useLocalStorage({
|
|
133
|
+
key: "notation-webview-collapsed",
|
|
134
|
+
defaultValue: true
|
|
135
|
+
});
|
|
136
|
+
const hasNotations = notations.length > 0;
|
|
137
|
+
const portalProps = useMantinePortalProps();
|
|
138
|
+
return /* @__PURE__ */ jsxs(AnimatePresence, { children: [
|
|
139
|
+
!hasNotations && isVisible && /* @__PURE__ */ jsx(
|
|
140
|
+
m.div,
|
|
141
|
+
{
|
|
142
|
+
initial: { opacity: 0.75, translateX: "50%" },
|
|
143
|
+
animate: { opacity: 1, translateX: 0 },
|
|
144
|
+
exit: {
|
|
145
|
+
translateX: "100%",
|
|
146
|
+
opacity: 0.6
|
|
147
|
+
},
|
|
148
|
+
className: clsx("react-flow__panel", container),
|
|
149
|
+
children: /* @__PURE__ */ jsx(Tooltip, { label: "View has no notations", color: "orange", ...portalProps, children: /* @__PURE__ */ jsx(
|
|
150
|
+
ThemeIcon,
|
|
151
|
+
{
|
|
152
|
+
size: "lg",
|
|
153
|
+
variant: "light",
|
|
154
|
+
color: "orange",
|
|
155
|
+
radius: "md",
|
|
156
|
+
children: /* @__PURE__ */ jsx(IconAlertTriangle, {})
|
|
157
|
+
}
|
|
158
|
+
) })
|
|
159
|
+
},
|
|
160
|
+
"empty"
|
|
161
|
+
),
|
|
162
|
+
hasNotations && isVisible && isCollapsed && /* @__PURE__ */ jsx(
|
|
163
|
+
m.div,
|
|
164
|
+
{
|
|
165
|
+
initial: { opacity: 0.75, translateX: "50%" },
|
|
166
|
+
animate: { opacity: 1, translateX: 0 },
|
|
167
|
+
exit: {
|
|
168
|
+
translateX: "100%",
|
|
169
|
+
opacity: 0.6
|
|
170
|
+
},
|
|
171
|
+
className: clsx("react-flow__panel", container),
|
|
172
|
+
children: /* @__PURE__ */ jsx(Tooltip, { label: "Show notation", color: "dark", fz: "xs", ...portalProps, children: /* @__PURE__ */ jsx(
|
|
173
|
+
ActionIcon,
|
|
174
|
+
{
|
|
175
|
+
size: "lg",
|
|
176
|
+
variant: "default",
|
|
177
|
+
color: "gray",
|
|
178
|
+
radius: "md",
|
|
179
|
+
onClick: () => setCollapsed(false),
|
|
180
|
+
children: /* @__PURE__ */ jsx(IconHelpCircle, { stroke: 1.5 })
|
|
181
|
+
}
|
|
182
|
+
) })
|
|
183
|
+
},
|
|
184
|
+
"collapsed"
|
|
185
|
+
),
|
|
186
|
+
hasNotations && isVisible && !isCollapsed && /* @__PURE__ */ jsx(
|
|
187
|
+
m.div,
|
|
188
|
+
{
|
|
189
|
+
initial: {
|
|
190
|
+
opacity: 0.75,
|
|
191
|
+
// translateX: '50%',
|
|
192
|
+
scale: 0.2
|
|
193
|
+
},
|
|
194
|
+
animate: { opacity: 1, scale: 1 },
|
|
195
|
+
exit: {
|
|
196
|
+
opacity: 0,
|
|
197
|
+
scale: 0.25
|
|
198
|
+
},
|
|
199
|
+
className: clsx("react-flow__panel", container),
|
|
200
|
+
style: {
|
|
201
|
+
transformOrigin: "bottom right"
|
|
202
|
+
},
|
|
203
|
+
children: /* @__PURE__ */ jsx(
|
|
204
|
+
Paper,
|
|
205
|
+
{
|
|
206
|
+
radius: "sm",
|
|
207
|
+
withBorder: true,
|
|
208
|
+
shadow: "lg",
|
|
209
|
+
className: card,
|
|
210
|
+
children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "first", radius: "xs", children: [
|
|
211
|
+
/* @__PURE__ */ jsxs(TabsList, { children: [
|
|
212
|
+
/* @__PURE__ */ jsx(
|
|
213
|
+
ActionIcon,
|
|
214
|
+
{
|
|
215
|
+
size: "md",
|
|
216
|
+
variant: "subtle",
|
|
217
|
+
color: "gray",
|
|
218
|
+
ml: 2,
|
|
219
|
+
style: {
|
|
220
|
+
alignSelf: "center"
|
|
221
|
+
},
|
|
222
|
+
onClick: () => setCollapsed(true),
|
|
223
|
+
children: /* @__PURE__ */ jsx(IconArrowDownRight, { stroke: 2 })
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ jsx(TabsTab, { value: "first", fz: "xs", children: "Elements" }),
|
|
227
|
+
/* @__PURE__ */ jsx(TabsTab, { value: "second", fz: "xs", disabled: true, children: "Relationships" })
|
|
228
|
+
] }),
|
|
229
|
+
/* @__PURE__ */ jsx(TabsPanel, { value: "first", className: tabPanel, hidden: isCollapsed, children: /* @__PURE__ */ jsx(
|
|
230
|
+
ScrollAreaAutosize,
|
|
231
|
+
{
|
|
232
|
+
viewportProps: {
|
|
233
|
+
style: {
|
|
234
|
+
maxHeight: `min(40vh, ${Math.max(height - 60, 50)}px)`
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
children: /* @__PURE__ */ jsx(Stack, { gap: 0, children: notations.map((n, i) => /* @__PURE__ */ jsx(ElementNotation, { value: n }, i)) })
|
|
238
|
+
}
|
|
239
|
+
) })
|
|
240
|
+
] })
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
},
|
|
244
|
+
id
|
|
245
|
+
)
|
|
246
|
+
] });
|
|
247
|
+
}
|
|
248
|
+
export {
|
|
249
|
+
NotationPanel
|
|
250
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NotationPanel as default } from './NotationPanel';
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popover, PopoverTarget, PopoverDropdown, Box, FloatingIndicator, Text, Flex, UnstyledButton } from "@mantine/core";
|
|
3
|
+
import { useHover, useUncontrolled, clampUseMovePosition, useMove, useMergedRef } from "@mantine/hooks";
|
|
4
|
+
import { useDebouncedCallback } from "@react-hookz/web";
|
|
5
|
+
import { IconLayoutDashboard } from "@tabler/icons-react";
|
|
6
|
+
import { useState, forwardRef } from "react";
|
|
7
|
+
import { useDiagramStoreApi, useDiagramState } from "../../hooks/useDiagramState.js";
|
|
8
|
+
import { Tooltip, ActionIcon } from "./_shared.js";
|
|
9
|
+
import { autolayoutIndicator, autolayoutButton, spacingSliderBody, spacingSliderThumb } from "./styles.css.js";
|
|
10
|
+
const selector = (state) => ({
|
|
11
|
+
viewId: state.view.id,
|
|
12
|
+
autoLayout: state.view.autoLayout
|
|
13
|
+
});
|
|
14
|
+
const ChangeAutoLayoutButton = (props) => {
|
|
15
|
+
const store = useDiagramStoreApi();
|
|
16
|
+
const [rootRef, setRootRef] = useState(null);
|
|
17
|
+
const [controlsRefs, setControlsRefs] = useState({});
|
|
18
|
+
const {
|
|
19
|
+
autoLayout,
|
|
20
|
+
viewId
|
|
21
|
+
} = useDiagramState(selector);
|
|
22
|
+
const { ref, hovered: isSpacingHovered } = useHover();
|
|
23
|
+
const setControlRef = (name) => (node) => {
|
|
24
|
+
controlsRefs[name] = node;
|
|
25
|
+
setControlsRefs(controlsRefs);
|
|
26
|
+
};
|
|
27
|
+
const setAutoLayout = (direction) => (event) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
(_b = (_a = store.getState()).onChange) == null ? void 0 : _b.call(_a, {
|
|
31
|
+
change: {
|
|
32
|
+
op: "change-autolayout",
|
|
33
|
+
layout: {
|
|
34
|
+
...autoLayout,
|
|
35
|
+
direction
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const setSpacing = (nodeSep, rankSep) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
store.setState({
|
|
43
|
+
viewportChanged: false
|
|
44
|
+
});
|
|
45
|
+
(_b = (_a = store.getState()).onChange) == null ? void 0 : _b.call(_a, {
|
|
46
|
+
change: {
|
|
47
|
+
op: "change-autolayout",
|
|
48
|
+
layout: {
|
|
49
|
+
...autoLayout,
|
|
50
|
+
nodeSep,
|
|
51
|
+
rankSep
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ jsxs(
|
|
57
|
+
Popover,
|
|
58
|
+
{
|
|
59
|
+
position: "right-start",
|
|
60
|
+
clickOutsideEvents: [
|
|
61
|
+
"pointerdown"
|
|
62
|
+
],
|
|
63
|
+
radius: "xs",
|
|
64
|
+
shadow: "lg",
|
|
65
|
+
offset: {
|
|
66
|
+
mainAxis: 10
|
|
67
|
+
},
|
|
68
|
+
...props,
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsx(PopoverTarget, { children: /* @__PURE__ */ jsx(Tooltip, { label: "Change Auto Layout", children: /* @__PURE__ */ jsx(ActionIcon, { children: /* @__PURE__ */ jsx(IconLayoutDashboard, {}) }) }) }),
|
|
71
|
+
/* @__PURE__ */ jsx(PopoverDropdown, { className: "likec4-top-left-panel", p: 8, pt: 6, opacity: isSpacingHovered ? 0.6 : 1, children: /* @__PURE__ */ jsxs(Box, { pos: "relative", ref: setRootRef, children: [
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
FloatingIndicator,
|
|
74
|
+
{
|
|
75
|
+
target: controlsRefs[autoLayout.direction],
|
|
76
|
+
parent: rootRef,
|
|
77
|
+
className: autolayoutIndicator
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ jsx(Box, { mb: 10, children: /* @__PURE__ */ jsx(Text, { inline: true, fz: "xs", c: "dimmed", fw: 500, children: "Auto layout:" }) }),
|
|
81
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", justify: "stretch", maw: 160, children: [
|
|
82
|
+
/* @__PURE__ */ jsx(UnstyledButton, { className: autolayoutButton, ref: setControlRef("TB"), onClick: setAutoLayout("TB"), children: "Top-Bottom" }),
|
|
83
|
+
/* @__PURE__ */ jsx(UnstyledButton, { className: autolayoutButton, ref: setControlRef("BT"), onClick: setAutoLayout("BT"), children: "Bottom-Top" }),
|
|
84
|
+
/* @__PURE__ */ jsx(UnstyledButton, { className: autolayoutButton, ref: setControlRef("LR"), onClick: setAutoLayout("LR"), children: "Left-Right" }),
|
|
85
|
+
/* @__PURE__ */ jsx(UnstyledButton, { className: autolayoutButton, ref: setControlRef("RL"), onClick: setAutoLayout("RL"), children: "Right-Left" })
|
|
86
|
+
] }),
|
|
87
|
+
/* @__PURE__ */ jsx(Box, { my: 10, children: /* @__PURE__ */ jsx(Text, { inline: true, fz: "xs", c: "dimmed", fw: 500, children: "Spacing:" }) }),
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
SpacingSliders,
|
|
90
|
+
{
|
|
91
|
+
ref,
|
|
92
|
+
isVertical: autoLayout.direction === "TB" || autoLayout.direction === "BT",
|
|
93
|
+
nodeSep: autoLayout.nodeSep,
|
|
94
|
+
rankSep: autoLayout.rankSep,
|
|
95
|
+
onChange: setSpacing
|
|
96
|
+
},
|
|
97
|
+
viewId
|
|
98
|
+
)
|
|
99
|
+
] }) })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
const MAX_SPACING = 400;
|
|
105
|
+
const SpacingSliders = forwardRef(({
|
|
106
|
+
isVertical,
|
|
107
|
+
nodeSep,
|
|
108
|
+
rankSep,
|
|
109
|
+
onChange
|
|
110
|
+
}, _ref) => {
|
|
111
|
+
if (!isVertical) {
|
|
112
|
+
[nodeSep, rankSep] = [rankSep, nodeSep];
|
|
113
|
+
}
|
|
114
|
+
const propagateChange = useDebouncedCallback(
|
|
115
|
+
({ x, y }) => {
|
|
116
|
+
if (!isVertical) {
|
|
117
|
+
[x, y] = [y, x];
|
|
118
|
+
}
|
|
119
|
+
onChange(Math.round(x * MAX_SPACING), Math.round(y * MAX_SPACING));
|
|
120
|
+
},
|
|
121
|
+
[onChange, isVertical],
|
|
122
|
+
250,
|
|
123
|
+
2e3
|
|
124
|
+
);
|
|
125
|
+
const [value, setValue] = useUncontrolled({
|
|
126
|
+
defaultValue: clampUseMovePosition({
|
|
127
|
+
x: (nodeSep ?? 100) / MAX_SPACING,
|
|
128
|
+
y: (rankSep ?? 120) / MAX_SPACING
|
|
129
|
+
}),
|
|
130
|
+
onChange: propagateChange
|
|
131
|
+
});
|
|
132
|
+
const { ref } = useMove(setValue);
|
|
133
|
+
let nodeSepValue = Math.round(value.x * MAX_SPACING);
|
|
134
|
+
let rankSepValue = Math.round(value.y * MAX_SPACING);
|
|
135
|
+
if (!isVertical) {
|
|
136
|
+
[nodeSepValue, rankSepValue] = [rankSepValue, nodeSepValue];
|
|
137
|
+
}
|
|
138
|
+
const mergedRef = useMergedRef(ref, _ref);
|
|
139
|
+
return /* @__PURE__ */ jsxs(Box, { ref: mergedRef, className: spacingSliderBody, pt: "100%", children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
Box,
|
|
142
|
+
{
|
|
143
|
+
className: spacingSliderThumb,
|
|
144
|
+
style: {
|
|
145
|
+
left: `${value.x * 100}%`,
|
|
146
|
+
top: `${value.y * 100}%`
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsx(Box, { pos: "absolute", left: 2, bottom: 2, children: /* @__PURE__ */ jsxs(Text, { component: "div", fz: 8, c: "dimmed", fw: 500, children: [
|
|
151
|
+
rankSepValue,
|
|
152
|
+
", ",
|
|
153
|
+
nodeSepValue
|
|
154
|
+
] }) })
|
|
155
|
+
] });
|
|
156
|
+
});
|
|
157
|
+
export {
|
|
158
|
+
ChangeAutoLayoutButton
|
|
159
|
+
};
|