@likec4/diagram 1.57.0 → 1.59.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/dist/LikeC4Diagram.js +1 -1
- package/dist/LikeC4Diagram.props.d.ts +1 -1
- package/dist/LikeC4Styles.js +1 -1
- package/dist/LikeC4View.js +2 -2
- package/dist/ReactLikeC4.d.ts +1 -1
- package/dist/base/Base.d.ts +3 -2
- package/dist/base/Base.js +14 -26
- package/dist/base/BaseXYFlow.d.ts +2 -1
- package/dist/base/BaseXYFlow.js +63 -4
- package/dist/base/keyboardZoom.d.ts +3 -0
- package/dist/base/keyboardZoom.js +20 -0
- package/dist/base/updateEdges.js +7 -16
- package/dist/base/updateNodes.js +3 -9
- package/dist/base-primitives/Markdown.d.ts +1 -1
- package/dist/base-primitives/NodeHandles.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundActionButton.js +5 -2
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +2 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +5 -2
- package/dist/base-primitives/compound/CompoundNodeContainer.d.ts +1 -1
- package/dist/base-primitives/compound/CompoundTitle.d.ts +7 -1
- package/dist/base-primitives/compound/CompoundTitle.js +2 -1
- package/dist/base-primitives/compound/actionbtns.css.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +2 -1
- package/dist/base-primitives/edge/EdgeActionButton.js +2 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +4 -2
- package/dist/base-primitives/edge/EdgeLabel.d.ts +2 -0
- package/dist/base-primitives/edge/EdgeLabel.js +2 -5
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeMarkers.d.ts +8 -8
- package/dist/base-primitives/element/ElementActionButtons.d.ts +2 -1
- package/dist/base-primitives/element/ElementActionButtons.js +4 -1
- package/dist/base-primitives/element/ElementData.d.ts +4 -2
- package/dist/base-primitives/element/ElementData.js +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +2 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +5 -2
- package/dist/base-primitives/element/ElementNodeContainer.js +1 -1
- package/dist/base-primitives/element/ElementShape.d.ts +1 -1
- package/dist/base-primitives/element/ElementShape.js +3 -0
- package/dist/base-primitives/element/ElementTags.d.ts +1 -1
- package/dist/base-primitives/element/ElementTags.js +1 -3
- package/dist/components/ErrorFallback.d.ts +2 -2
- package/dist/components/ErrorFallback.js +3 -5
- package/dist/components/Link.js +6 -6
- package/dist/components/NavigationPanel.d.ts +2 -2
- package/dist/components/NavigationPanel.js +1 -1
- package/dist/components/PortalToContainer.d.ts +1 -1
- package/dist/components/RootContainer.d.ts +1 -1
- package/dist/components/SearchControl.css.js +11 -11
- package/dist/components/SearchControl.d.ts +2 -2
- package/dist/components/ViewNotFound.d.ts +2 -2
- package/dist/context/CurrentViewModelProvider.d.ts +1 -1
- package/dist/context/DefaultMantineProvider.d.ts +1 -1
- package/dist/context/DiagramEventHandlers.d.ts +1 -1
- package/dist/context/EnsureMantine.d.ts +1 -1
- package/dist/context/FramerMotionConfig.d.ts +3 -3
- package/dist/context/FramerMotionConfig.js +2 -2
- package/dist/context/IconRenderer.d.ts +2 -2
- package/dist/context/IconRenderer.js +32 -12
- package/dist/context/LikeC4ModelContext.d.ts +1 -1
- package/dist/context/TagStylesContext.d.ts +4 -3
- package/dist/context/TagStylesContext.js +20 -22
- package/dist/custom/index.d.ts +1 -0
- package/dist/custom/index.js +3 -2
- package/dist/editor/LikeC4EditorProvider.d.ts +2 -2
- package/dist/editor/actor/actions.d.ts +74 -15
- package/dist/editor/actor/actions.js +91 -25
- package/dist/editor/actor/hotkey.d.ts +1 -1
- package/dist/editor/actor/hotkey.js +7 -0
- package/dist/editor/actor/machine.d.ts +4 -6
- package/dist/editor/actor/machine.js +1 -0
- package/dist/editor/actor/setup.d.ts +25 -4
- package/dist/editor/actor/setup.js +8 -6
- package/dist/editor/actor/state.editor.d.ts +64 -14
- package/dist/editor/actor/state.editor.js +12 -11
- package/dist/editor/actor/state.sync-queue.d.ts +283 -91
- package/dist/editor/actor/state.sync-queue.js +93 -56
- package/dist/editor/actor/types.d.ts +6 -1
- package/dist/editor/actor/types.js +1 -1
- package/dist/editor/useEditorActorLogic.js +14 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/safeContext.d.ts +156 -3
- package/dist/hooks/safeContext.js +60 -12
- package/dist/hooks/useCurrentViewModel.js +1 -1
- package/dist/hooks/useDiagram.d.ts +8 -0
- package/dist/hooks/useDiagram.js +9 -2
- package/dist/hooks/useEditorActor.d.ts +5 -0
- package/dist/hooks/useEditorActor.js +4 -3
- package/dist/hooks/useLikeC4ElementsTree.js +1 -1
- package/dist/hooks/useLikeC4Model.js +1 -1
- package/dist/hooks/useXYFlow.d.ts +1 -0
- package/dist/hooks/useXYFlow.js +5 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -2
- package/dist/likec4diagram/DiagramUI.d.ts +1 -1
- package/dist/likec4diagram/DiagramUI.js +19 -6
- package/dist/likec4diagram/DiagramXYFlow.js +54 -17
- package/dist/likec4diagram/convert-to-xyflow.d.ts +3 -5
- package/dist/likec4diagram/convert-to-xyflow.js +29 -10
- package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +140 -18
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.d.ts +1 -1
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +11 -4
- package/dist/likec4diagram/custom/edges/edges.css.d.ts +1 -0
- package/dist/likec4diagram/custom/edges/edges.css.js +6 -2
- package/dist/likec4diagram/custom/index.d.ts +2 -1
- package/dist/likec4diagram/custom/index.js +5 -3
- package/dist/likec4diagram/custom/nodes/CompoundActions.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +1 -0
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +4 -4
- package/dist/likec4diagram/custom/nodes/ElementActions.js +13 -3
- package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/NodeNotes.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/NodeNotes.js +0 -4
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +32 -19
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.d.ts +2 -0
- package/dist/likec4diagram/custom/nodes/SequenceSubFlow.js +234 -0
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +7 -7
- package/dist/likec4diagram/custom/nodes/nodes.js +20 -5
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +3 -3
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.d.ts +2 -2
- package/dist/likec4diagram/custom/nodes/toolbar/Toolbar.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +3 -3
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +1 -1
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.d.ts +1 -1
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +15 -14
- package/dist/likec4diagram/relationship-popover/components.d.ts +2 -2
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +1 -1
- package/dist/likec4diagram/state/DiagramActorProvider.js +11 -20
- package/dist/likec4diagram/state/aligners.js +1 -1
- package/dist/likec4diagram/state/assign.d.ts +1 -1
- package/dist/likec4diagram/state/assign.js +1 -1
- package/dist/likec4diagram/state/createViewChange.js +2 -1
- package/dist/likec4diagram/state/diagram-api.d.ts +18 -10
- package/dist/likec4diagram/state/diagram-api.js +333 -229
- package/dist/likec4diagram/state/machine.actions.d.ts +1026 -332
- package/dist/likec4diagram/state/machine.actions.js +118 -46
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +123 -51
- package/dist/likec4diagram/state/machine.actions.layout.js +40 -33
- package/dist/likec4diagram/state/machine.d.ts +154 -16
- package/dist/likec4diagram/state/machine.js +5 -41
- package/dist/likec4diagram/state/machine.setup.d.ts +84 -19
- package/dist/likec4diagram/state/machine.setup.js +65 -12
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +59 -33
- package/dist/likec4diagram/state/machine.state.navigating.js +7 -3
- package/dist/likec4diagram/state/machine.state.ready.d.ts +1540 -476
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +294 -53
- package/dist/likec4diagram/state/machine.state.ready.focused.js +3 -3
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +264 -73
- package/dist/likec4diagram/state/machine.state.ready.idle.js +31 -6
- package/dist/likec4diagram/state/machine.state.ready.js +22 -16
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +23 -9
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +288 -84
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +135 -66
- package/dist/likec4diagram/state/types.d.ts +4 -2
- package/dist/likec4diagram/state/utils.d.ts +7 -0
- package/dist/likec4diagram/state/utils.js +36 -34
- package/dist/likec4diagram/types.d.ts +49 -3
- package/dist/likec4diagram/ui/FloatingSequenceActors.d.ts +6 -0
- package/dist/likec4diagram/ui/FloatingSequenceActors.js +155 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +1 -1
- package/dist/likec4diagram/ui/LayoutDriftFrame.js +2 -2
- package/dist/likec4diagram/ui/index.d.ts +2 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -5
- package/dist/likec4diagram/ui/notation/NotationPanel.d.ts +1 -1
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.d.ts +2 -0
- package/dist/likec4diagram/ui/sequence-outline/SequenceOutlinePanel.js +519 -0
- package/dist/likec4diagram/ui/sequence-outline/state.d.ts +36 -0
- package/dist/likec4diagram/ui/sequence-outline/state.js +55 -0
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +1 -1
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +116 -62
- package/dist/likec4diagram/xyflow-sequence/_types.d.ts +55 -5
- package/dist/likec4diagram/xyflow-sequence/const.d.ts +5 -5
- package/dist/likec4diagram/xyflow-sequence/const.js +4 -4
- package/dist/likec4diagram/xyflow-sequence/layouter.d.ts +30 -6
- package/dist/likec4diagram/xyflow-sequence/layouter.js +561 -0
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.d.ts → sequence-view-to-xy.d.ts} +8 -2
- package/dist/likec4diagram/xyflow-sequence/{sequence-layout.js → sequence-view-to-xy.js} +112 -14
- package/dist/likec4diagram/xyflow-sequence/sequence-view.d.ts +2 -7
- package/dist/likec4diagram/xyflow-sequence/sequence-view.js +144 -0
- package/dist/likec4diagram/xyflow-sequence/utils.d.ts +9 -1
- package/dist/likec4diagram/xyflow-sequence/utils.js +96 -0
- package/dist/navigationpanel/NavigationPanel.d.ts +5 -2
- package/dist/navigationpanel/NavigationPanel.js +58 -59
- package/dist/navigationpanel/NavigationPanelControls.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.d.ts +1 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +47 -40
- package/dist/navigationpanel/_common.d.ts +2 -2
- package/dist/navigationpanel/_common.js +2 -2
- package/dist/navigationpanel/actor.actions.d.ts +19 -0
- package/dist/navigationpanel/actor.actions.js +45 -0
- package/dist/navigationpanel/actor.d.ts +34 -96
- package/dist/navigationpanel/actor.js +21 -84
- package/dist/navigationpanel/actor.setup.d.ts +98 -0
- package/dist/navigationpanel/actor.setup.js +31 -0
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/DriftsSummary.d.ts +1 -1
- package/dist/navigationpanel/comparepanel/DriftsSummary.js +4 -5
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +1 -1
- package/dist/navigationpanel/controls/DetailsControls.d.ts +1 -1
- package/dist/navigationpanel/controls/DetailsControls.js +7 -8
- package/dist/navigationpanel/controls/LayoutWarning.d.ts +1 -1
- package/dist/navigationpanel/controls/LogoButton.d.ts +1 -1
- package/dist/navigationpanel/controls/NavigationButtons.d.ts +1 -1
- package/dist/navigationpanel/controls/OpenSource.d.ts +1 -1
- package/dist/navigationpanel/controls/SearchControl.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +1 -1
- package/dist/navigationpanel/editorpanel/CenterCamera.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/EditorPanel.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/styles.js +8 -8
- package/dist/navigationpanel/hooks.d.ts +20 -5
- package/dist/navigationpanel/hooks.js +4 -18
- package/dist/navigationpanel/styles.css.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +2 -2
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +5 -5
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +23 -25
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +1 -1
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +5 -5
- package/dist/overlays/Overlays.d.ts +4 -2
- package/dist/overlays/Overlays.js +10 -10
- package/dist/overlays/element-details/ElementDetails.d.ts +1 -1
- package/dist/overlays/element-details/ElementDetailsCard.css.js +17 -17
- package/dist/overlays/element-details/ElementDetailsCard.d.ts +1 -1
- package/dist/overlays/element-details/MetadataValue.d.ts +2 -2
- package/dist/overlays/element-details/MetadataValue.js +15 -15
- package/dist/overlays/element-details/TabPanelDeployments.css.js +5 -5
- package/dist/overlays/element-details/TabPanelRelationships.css.js +11 -11
- package/dist/overlays/element-details/TabPanelRelationships.d.ts +1 -1
- package/dist/overlays/element-details/TabPanelRelationships.js +1 -1
- package/dist/overlays/element-details/TabPanelStructure.css.js +2 -2
- package/dist/overlays/element-details/TabPanelStructure.d.ts +2 -2
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/element-details/actor.d.ts +2 -3
- package/dist/overlays/hooks.d.ts +28 -0
- package/dist/overlays/hooks.js +5 -0
- package/dist/overlays/overlay/Overlay.js +34 -25
- package/dist/overlays/overlaysActor.js +0 -1
- package/dist/overlays/relationship-details/RelationshipDetails.d.ts +1 -1
- package/dist/overlays/relationship-details/SelectEdge.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.d.ts +4 -4
- package/dist/overlays/relationship-details/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationship-details/layout.js +1 -1
- package/dist/overlays/relationships-browser/RelationshipsBrowser.d.ts +1 -1
- package/dist/overlays/relationships-browser/SelectElement.css.js +2 -2
- package/dist/overlays/relationships-browser/SelectElement.d.ts +1 -1
- package/dist/overlays/relationships-browser/actor.js +79 -78
- package/dist/overlays/relationships-browser/custom/ElementActions.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/EmptyNode.d.ts +1 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.d.ts +4 -4
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +1 -1
- package/dist/overlays/relationships-browser/hooks.js +1 -1
- package/dist/overlays/relationships-browser/layout.js +2 -2
- package/dist/projects-overview/ProjectsOverview.d.ts +1 -1
- package/dist/projects-overview/actor.js +4 -4
- package/dist/projects-overview/custom/nodeTypes.d.ts +1 -1
- package/dist/projects-overview/panel/ProjectsOverviewPanel.d.ts +1 -1
- package/dist/search/Search.d.ts +1 -1
- package/dist/search/Search.js +1 -1
- package/dist/search/XStateSearchAdapter.d.ts +1 -1
- package/dist/search/components/ElementsColumn.css.js +2 -2
- package/dist/search/components/ElementsColumn.d.ts +1 -1
- package/dist/search/components/PickView.d.ts +1 -1
- package/dist/search/components/SearchByTags.d.ts +1 -1
- package/dist/search/components/SearchInput.d.ts +1 -1
- package/dist/search/components/ViewsColum.d.ts +3 -3
- package/dist/search/components/ViewsColum.js +1 -1
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/components/_shared.css.js +23 -23
- package/dist/search/components/styles.css.js +4 -4
- package/dist/shadowroot/ShadowRoot.d.ts +2 -3
- package/dist/shadowroot/ShadowRoot.js +95 -41
- package/dist/shadowroot/index.d.ts +1 -0
- package/dist/styles2.js +1 -1
- package/dist/utils/defineActors.d.ts +21 -0
- package/dist/utils/defineActors.js +13 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -4
- package/dist/utils/readableText.d.ts +11 -0
- package/dist/utils/readableText.js +18 -0
- package/package.json +30 -43
- package/panda.buildinfo.json +271 -295
- package/styles-min.css +1 -1
- package/styles-xyflow.css +1 -1
- package/styles.css +1 -1
- package/adhoc-editor/package.json +0 -4
- package/dist/adhoc-editor/EditorPanel.d.ts +0 -1
- package/dist/adhoc-editor/EditorPanel.js +0 -106
- package/dist/adhoc-editor/ElementsTree.d.ts +0 -2
- package/dist/adhoc-editor/ElementsTree.js +0 -112
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.d.ts +0 -4
- package/dist/adhoc-editor/LikeC4AdHocViewEditor.js +0 -83
- package/dist/adhoc-editor/components/Tree.d.ts +0 -48
- package/dist/adhoc-editor/components/Tree.js +0 -213
- package/dist/adhoc-editor/hooks.d.ts +0 -14
- package/dist/adhoc-editor/hooks.js +0 -34
- package/dist/adhoc-editor/index.d.ts +0 -2
- package/dist/adhoc-editor/index.js +0 -2
- package/dist/adhoc-editor/state/ActorProvider.d.ts +0 -5
- package/dist/adhoc-editor/state/ActorProvider.js +0 -37
- package/dist/adhoc-editor/state/actor.d.ts +0 -13
- package/dist/adhoc-editor/state/actor.editor.d.ts +0 -56
- package/dist/adhoc-editor/state/actor.editor.js +0 -167
- package/dist/adhoc-editor/state/actor.js +0 -14
- package/dist/adhoc-editor/state/actor.layouter.d.ts +0 -51
- package/dist/adhoc-editor/state/actor.layouter.js +0 -54
- package/dist/adhoc-editor/state/actor.types.d.ts +0 -63
- package/dist/adhoc-editor/state/actor.types.js +0 -25
- package/dist/adhoc-editor/state/panel.d.ts +0 -95
- package/dist/adhoc-editor/state/panel.js +0 -124
- package/dist/adhoc-editor/state/utils.d.ts +0 -17
- package/dist/adhoc-editor/state/utils.js +0 -25
- package/dist/adhoc-editor/useElementsTree.d.ts +0 -18
- package/dist/adhoc-editor/useElementsTree.js +0 -98
- package/dist/adhoc-editor/viewrules/ViewRulesPanel.d.ts +0 -6
- package/dist/shadowroot/styles.css.d.ts +0 -12
- package/dist/shadowroot/styles.css.js +0 -59
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { selectDiagramActor, useDiagramSnapshot } from "./useDiagram.js";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import "@mantine/hooks";
|
|
4
5
|
//#region src/hooks/useEditorActor.ts
|
|
5
6
|
var select = selectDiagramActor((s) => {
|
|
6
7
|
return s.children.editor ?? null;
|
|
@@ -12,8 +13,8 @@ function useEditorActorStateHasTag(tag) {
|
|
|
12
13
|
const editorActor = useEditorActorRef();
|
|
13
14
|
const [hasTag, setHasTag] = useState(() => editorActor?.getSnapshot().hasTag(tag) ?? false);
|
|
14
15
|
useEffect(() => {
|
|
15
|
-
const subscription = editorActor?.subscribe((
|
|
16
|
-
setHasTag(
|
|
16
|
+
const subscription = editorActor?.select((s) => s.hasTag(tag)).subscribe((hasTag) => {
|
|
17
|
+
setHasTag(hasTag);
|
|
17
18
|
});
|
|
18
19
|
return () => {
|
|
19
20
|
subscription?.unsubscribe();
|
|
@@ -23,4 +24,4 @@ function useEditorActorStateHasTag(tag) {
|
|
|
23
24
|
return hasTag;
|
|
24
25
|
}
|
|
25
26
|
//#endregion
|
|
26
|
-
export { useEditorActorStateHasTag };
|
|
27
|
+
export { useEditorActorRef, useEditorActorStateHasTag };
|
|
@@ -4,6 +4,7 @@ export type XYFlowInstance = ReactFlowInstance<Types.AnyNode, Types.AnyEdge>;
|
|
|
4
4
|
export declare function useXYFlow(): XYFlowInstance;
|
|
5
5
|
export type XYStoreState = ReactFlowState<Types.AnyNode, Types.AnyEdge>;
|
|
6
6
|
export declare function useXYStore<StateSlice = unknown>(selector: (state: XYStoreState) => StateSlice, equalityFn?: (a: NoInfer<StateSlice>, b: NoInfer<StateSlice>) => boolean): StateSlice;
|
|
7
|
+
export declare function selectXYStore<StateSlice = unknown>(selector: (state: XYStoreState) => StateSlice): (state: XYStoreState) => StateSlice;
|
|
7
8
|
export declare function useXYStoreApi(): XYStoreApi;
|
|
8
9
|
export type XYStoreApi = {
|
|
9
10
|
getState: () => XYStoreState;
|
package/dist/hooks/useXYFlow.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { useCallbackRef } from "./useCallbackRef.js";
|
|
3
2
|
import { useCallback } from "react";
|
|
4
3
|
import { useReactFlow, useStore, useStoreApi } from "@xyflow/react";
|
|
5
4
|
import { shallowEqual } from "fast-equals";
|
|
@@ -8,7 +7,10 @@ function useXYFlow() {
|
|
|
8
7
|
return useReactFlow();
|
|
9
8
|
}
|
|
10
9
|
function useXYStore(selector, equalityFn) {
|
|
11
|
-
return useStore(
|
|
10
|
+
return useStore(selector, equalityFn ?? shallowEqual);
|
|
11
|
+
}
|
|
12
|
+
function selectXYStore(selector) {
|
|
13
|
+
return selector;
|
|
12
14
|
}
|
|
13
15
|
function useXYStoreApi() {
|
|
14
16
|
return useStoreApi();
|
|
@@ -21,4 +23,4 @@ function useIsZoomTooSmall() {
|
|
|
21
23
|
return useStore(selectZoom);
|
|
22
24
|
}
|
|
23
25
|
//#endregion
|
|
24
|
-
export { useCurrentZoomAtLeast, useIsZoomTooSmall, useXYFlow, useXYStore, useXYStoreApi };
|
|
26
|
+
export { selectXYStore, useCurrentZoomAtLeast, useIsZoomTooSmall, useXYFlow, useXYStore, useXYStoreApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { LikeC4ModelProvider, type LikeC4ModelProviderProps, } from './LikeC4Mod
|
|
|
5
5
|
export { LikeC4EditorProvider, type LikeC4EditorProviderProps, } from './editor/LikeC4EditorProvider';
|
|
6
6
|
export { createLikeC4Editor, type LikeC4EditorCallbacks, } from './editor/LikeC4EditorCallbacks';
|
|
7
7
|
export { LikeC4ProjectsProvider, type LikeC4ProjectsProviderProps, } from './LikeC4ProjectsProvider';
|
|
8
|
-
export { type DiagramApi, type DiagramContext, useDiagram, useDiagramContext, useOnDiagramEvent, } from './hooks/useDiagram';
|
|
8
|
+
export { type DiagramApi, type DiagramContext, selectDiagramContext, selectDiagramSnapshot, useDiagram, useDiagramContext, useDiagramSelector, useOnDiagramEvent, } from './hooks/useDiagram';
|
|
9
9
|
export { useLikeC4Model, useLikeC4Specification, useLikeC4ViewModel, } from './hooks/useLikeC4Model';
|
|
10
10
|
export { type CurrentViewModel, useCurrentViewModel, useOptionalCurrentViewModel, } from './hooks/useCurrentViewModel';
|
|
11
11
|
export { useChangeLikeC4Project, useHasProjects, useLikeC4Project, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext, } from './hooks/useLikeC4Project';
|
|
@@ -22,3 +22,5 @@ export { LikeC4ProjectsOverview, type LikeC4ProjectsOverviewProps, } from './Lik
|
|
|
22
22
|
export { normalizeSearch, SearchContext, type SearchContextValue, useSearchContext, } from './search/SearchContext';
|
|
23
23
|
export { bodyCss as searchBodyCss, dialogCss as searchDialogCss, SearchPanelContent, } from './search/Search';
|
|
24
24
|
export { SearchControl } from './components/SearchControl';
|
|
25
|
+
export { DefaultMantineProvider } from './context/DefaultMantineProvider';
|
|
26
|
+
export { FramerMotionConfig } from './context/FramerMotionConfig';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { IconRendererProvider } from "./context/IconRenderer.js";
|
|
2
2
|
import { useUpdateEffect } from "./hooks/useUpdateEffect.js";
|
|
3
|
-
import {
|
|
3
|
+
import { DefaultMantineProvider } from "./context/DefaultMantineProvider.js";
|
|
4
|
+
import { FramerMotionConfig } from "./context/FramerMotionConfig.js";
|
|
5
|
+
import { selectDiagramContext, selectDiagramSnapshot, useDiagram, useDiagramSelector } from "./hooks/safeContext.js";
|
|
4
6
|
import { useDiagramContext, useOnDiagramEvent } from "./hooks/useDiagram.js";
|
|
5
7
|
import { useCurrentView, useCurrentViewId } from "./hooks/useCurrentView.js";
|
|
6
8
|
import { useOptionalCurrentViewModel } from "./context/LikeC4ModelContext.js";
|
|
@@ -21,4 +23,4 @@ import { LikeC4View } from "./LikeC4View.js";
|
|
|
21
23
|
import { ReactLikeC4 } from "./ReactLikeC4.js";
|
|
22
24
|
import { LikeC4ProjectsOverview } from "./LikeC4ProjectsOverview.js";
|
|
23
25
|
import { SearchControl } from "./components/SearchControl.js";
|
|
24
|
-
export { IconRendererProvider, LikeC4Diagram, LikeC4EditorProvider, LikeC4ModelProvider, LikeC4ProjectsOverview, LikeC4ProjectsProvider, LikeC4View, ReactLikeC4, SearchContext, SearchControl, SearchPanelContent, StaticLikeC4Diagram, createLikeC4Editor, normalizeSearch, pickViewBounds, bodyCss as searchBodyCss, dialogCss as searchDialogCss, useChangeLikeC4Project, useCurrentView, useCurrentViewId, useCurrentViewModel, useDiagram, useDiagramContext, useHasProjects, useLikeC4Model, useLikeC4Project, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext, useLikeC4Specification, useLikeC4Styles, useLikeC4ViewModel, useOnDiagramEvent, useOptionalCurrentViewModel, useSearchContext, useUpdateEffect };
|
|
26
|
+
export { DefaultMantineProvider, FramerMotionConfig, IconRendererProvider, LikeC4Diagram, LikeC4EditorProvider, LikeC4ModelProvider, LikeC4ProjectsOverview, LikeC4ProjectsProvider, LikeC4View, ReactLikeC4, SearchContext, SearchControl, SearchPanelContent, StaticLikeC4Diagram, createLikeC4Editor, normalizeSearch, pickViewBounds, bodyCss as searchBodyCss, dialogCss as searchDialogCss, selectDiagramContext, selectDiagramSnapshot, useChangeLikeC4Project, useCurrentView, useCurrentViewId, useCurrentViewModel, useDiagram, useDiagramContext, useDiagramSelector, useHasProjects, useLikeC4Model, useLikeC4Project, useLikeC4ProjectId, useLikeC4Projects, useLikeC4ProjectsContext, useLikeC4Specification, useLikeC4Styles, useLikeC4ViewModel, useOnDiagramEvent, useOptionalCurrentViewModel, useSearchContext, useUpdateEffect };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MemoExoticComponent } from 'react';
|
|
2
|
-
export declare const LikeC4DiagramUI: MemoExoticComponent<() => import("react
|
|
2
|
+
export declare const LikeC4DiagramUI: MemoExoticComponent<() => import("react").JSX.Element>;
|
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { useEnabledFeatures } from "../context/DiagramFeatures.js";
|
|
3
|
-
import {
|
|
3
|
+
import { selectDiagramSnapshot, useDiagramSelector } from "../hooks/safeContext.js";
|
|
4
4
|
import { ErrorBoundary } from "../components/ErrorFallback.js";
|
|
5
5
|
import { NavigationPanel } from "../navigationpanel/NavigationPanel.js";
|
|
6
6
|
import { Overlays } from "../overlays/Overlays.js";
|
|
7
7
|
import { Search } from "../search/Search.js";
|
|
8
8
|
import { RelationshipPopover } from "./relationship-popover/RelationshipPopover.js";
|
|
9
|
+
import { FloatingSequenceActors } from "./ui/FloatingSequenceActors.js";
|
|
9
10
|
import { LayoutDriftFrame } from "./ui/LayoutDriftFrame.js";
|
|
10
11
|
import { NotationPanel } from "./ui/notation/NotationPanel.js";
|
|
12
|
+
import { SequenceOutlinePanel } from "./ui/sequence-outline/SequenceOutlinePanel.js";
|
|
11
13
|
import { memo, useCallback } from "react";
|
|
12
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
15
|
import { useRerender } from "@react-hookz/web";
|
|
16
|
+
import { hasProp, isDynamicView } from "@likec4/core";
|
|
14
17
|
//#region src/likec4diagram/DiagramUI.tsx
|
|
15
|
-
var selectChildren =
|
|
18
|
+
var selectChildren = selectDiagramSnapshot((s) => ({
|
|
16
19
|
overlays: s.children.overlays ?? null,
|
|
17
|
-
search: s.children.search ?? null
|
|
20
|
+
search: s.children.search ?? null,
|
|
21
|
+
navigation: s.children.navigationPanel ?? null,
|
|
22
|
+
...isDynamicView(s.context.view) ? {
|
|
23
|
+
isSequenceView: s.context.dynamicViewVariant === "sequence",
|
|
24
|
+
isActiveWalkthrough: s.context.dynamicViewVariant === "sequence" && !!s.context.activeWalkthrough && hasProp(s.context.view, "flow")
|
|
25
|
+
} : {
|
|
26
|
+
isSequenceView: false,
|
|
27
|
+
hasSequenceFlow: false,
|
|
28
|
+
isActiveWalkthrough: false
|
|
29
|
+
}
|
|
18
30
|
}));
|
|
19
31
|
var LikeC4DiagramUI = memo(() => {
|
|
20
32
|
const { enableControls, enableNotations, enableSearch, enableRelationshipDetails, enableReadOnly, enableCompareWithLatest } = useEnabledFeatures();
|
|
21
33
|
const rerender = useRerender();
|
|
22
|
-
const actors =
|
|
34
|
+
const { isSequenceView, isActiveWalkthrough, ...actors } = useDiagramSelector(selectChildren);
|
|
23
35
|
return /* @__PURE__ */ jsxs(ErrorBoundary, {
|
|
24
36
|
onReset: useCallback(() => {
|
|
25
|
-
console.warn("DiagramUI: resetting error boundary and rerendering...");
|
|
26
37
|
rerender();
|
|
27
38
|
}, []),
|
|
28
39
|
children: [
|
|
29
|
-
|
|
40
|
+
isSequenceView && /* @__PURE__ */ jsx(FloatingSequenceActors, { isActiveWalkthrough }),
|
|
41
|
+
isActiveWalkthrough && /* @__PURE__ */ jsx(SequenceOutlinePanel, {}),
|
|
42
|
+
enableControls && actors.navigation && !isActiveWalkthrough && /* @__PURE__ */ jsx(NavigationPanel, { actorRef: actors.navigation }),
|
|
30
43
|
actors.overlays && /* @__PURE__ */ jsx(Overlays, { overlaysActorRef: actors.overlays }),
|
|
31
44
|
enableNotations && /* @__PURE__ */ jsx(NotationPanel, {}),
|
|
32
45
|
enableSearch && actors.search && /* @__PURE__ */ jsx(Search, { searchActorRef: actors.search }),
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import "../_virtual/_rolldown/runtime.js";
|
|
1
|
+
import { __name } from "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { useCallbackRef as useCallbackRef$1 } from "../hooks/useCallbackRef.js";
|
|
3
3
|
import { depsShallowEqual, useUpdateEffect as useUpdateEffect$1 } from "../hooks/useUpdateEffect.js";
|
|
4
|
+
import { MinZoom } from "../base/const.js";
|
|
4
5
|
import { BaseXYFlow } from "../base/BaseXYFlow.js";
|
|
5
6
|
import { useRootContainer } from "../context/RootContainerContext.js";
|
|
6
7
|
import { useDiagramEventHandlers } from "../context/DiagramEventHandlers.js";
|
|
7
|
-
import { useDiagram } from "../hooks/safeContext.js";
|
|
8
|
-
import { selectDiagramActor, useDiagramSnapshot } from "../hooks/useDiagram.js";
|
|
8
|
+
import { selectDiagramSnapshot, useDiagram, useDiagramSelector } from "../hooks/safeContext.js";
|
|
9
9
|
import { viewBounds } from "./state/utils.js";
|
|
10
10
|
import { deriveToggledFeatures } from "./state/machine.setup.js";
|
|
11
11
|
import { BuiltinEdges, BuiltinNodes } from "./custom/index.js";
|
|
12
12
|
import { useLayoutConstraints } from "./useLayoutConstraints.js";
|
|
13
13
|
import { cx } from "@likec4/styles/css";
|
|
14
|
-
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import { useCustomCompareMemo } from "@react-hookz/web";
|
|
16
|
+
import { Controls } from "@xyflow/react";
|
|
17
|
+
import { shallowEqual } from "fast-equals";
|
|
16
18
|
import { isEmpty } from "remeda";
|
|
17
19
|
import { nonNullable } from "@likec4/core";
|
|
18
20
|
import { useDebouncedCallback as useDebouncedCallback$1, useTimeout } from "@mantine/hooks";
|
|
@@ -28,7 +30,8 @@ var builtinNodes = {
|
|
|
28
30
|
"compound-deployment": BuiltinNodes.CompoundDeploymentNode,
|
|
29
31
|
"view-group": BuiltinNodes.ViewGroupNode,
|
|
30
32
|
"seq-actor": BuiltinNodes.SequenceActorNode,
|
|
31
|
-
"seq-parallel": BuiltinNodes.SequenceParallelArea
|
|
33
|
+
"seq-parallel": BuiltinNodes.SequenceParallelArea,
|
|
34
|
+
"seq-subflow": BuiltinNodes.SequenceSubflowArea
|
|
32
35
|
};
|
|
33
36
|
function prepareNodeTypes(nodeTypes) {
|
|
34
37
|
if (!nodeTypes || isEmpty(nodeTypes)) return builtinNodes;
|
|
@@ -39,7 +42,8 @@ function prepareNodeTypes(nodeTypes) {
|
|
|
39
42
|
"compound-deployment": nodeTypes.compoundDeployment ?? builtinNodes["compound-deployment"],
|
|
40
43
|
"view-group": nodeTypes.viewGroup ?? builtinNodes["view-group"],
|
|
41
44
|
"seq-actor": nodeTypes.seqActor ?? builtinNodes["seq-actor"],
|
|
42
|
-
"seq-parallel": nodeTypes.seqParallel ?? builtinNodes["seq-parallel"]
|
|
45
|
+
"seq-parallel": nodeTypes.seqParallel ?? builtinNodes["seq-parallel"],
|
|
46
|
+
"seq-subflow": nodeTypes.seqSubflow ?? builtinNodes["seq-subflow"]
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
var viewportToTopLeft = (ctx) => {
|
|
@@ -50,10 +54,12 @@ var viewportToTopLeft = (ctx) => {
|
|
|
50
54
|
zoom: 1
|
|
51
55
|
};
|
|
52
56
|
};
|
|
53
|
-
var selectXYProps =
|
|
57
|
+
var selectXYProps = selectDiagramSnapshot(({ context: ctx, children }) => {
|
|
54
58
|
const { enableReadOnly } = deriveToggledFeatures(ctx);
|
|
55
|
-
const
|
|
56
|
-
|
|
59
|
+
const editorSnapshot = enableReadOnly ? null : children.editor?.getSnapshot();
|
|
60
|
+
const isNotEditingEdge = enableReadOnly || editorSnapshot?.context.editing?.subject !== "edge";
|
|
61
|
+
const isEditorBusy = editorSnapshot?.hasTag("busy") ?? false;
|
|
62
|
+
let nodesDraggable = !enableReadOnly && ctx.nodesDraggable && !isEditorBusy;
|
|
57
63
|
if (ctx.dynamicViewVariant === "sequence" && ctx.view._type === "dynamic") nodesDraggable = false;
|
|
58
64
|
return {
|
|
59
65
|
enableReadOnly,
|
|
@@ -63,15 +69,18 @@ var selectXYProps = selectDiagramActor(({ context: ctx, children }) => {
|
|
|
63
69
|
pannable: ctx.pannable,
|
|
64
70
|
zoomable: ctx.zoomable,
|
|
65
71
|
nodesDraggable,
|
|
66
|
-
nodesSelectable: ctx.nodesSelectable && isNotEditingEdge,
|
|
72
|
+
nodesSelectable: ctx.nodesSelectable && isNotEditingEdge && !isEditorBusy,
|
|
67
73
|
fitViewPadding: ctx.fitViewPadding,
|
|
68
74
|
enableFitView: ctx.features.enableFitView,
|
|
75
|
+
enableControls: ctx.features.enableControls && ctx.features.enableFitView,
|
|
69
76
|
...!ctx.features.enableFitView && { viewport: viewportToTopLeft(ctx) }
|
|
70
77
|
};
|
|
78
|
+
}, ({ nodes: aNodes, edges: aEdges, ...a }, { nodes: bNodes, edges: bEdges, ...b }) => {
|
|
79
|
+
return shallowEqual(a, b) && shallowEqual(aNodes, bNodes) && shallowEqual(aEdges, bEdges);
|
|
71
80
|
});
|
|
72
81
|
function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, children, renderNodes }) {
|
|
73
82
|
const diagram = useDiagram();
|
|
74
|
-
let { enableReadOnly, initialized, nodes, edges, enableFitView, nodesDraggable, nodesSelectable, ...props } =
|
|
83
|
+
let { enableReadOnly, initialized, nodes, edges, enableFitView, nodesDraggable, nodesSelectable, enableControls, ...props } = useDiagramSelector(selectXYProps);
|
|
75
84
|
const { onNodeContextMenu, onCanvasContextMenu, onEdgeContextMenu, onNodeClick, onEdgeClick, onCanvasClick, onCanvasDblClick } = useDiagramEventHandlers();
|
|
76
85
|
const { reducedGraphics, $panning } = useRootContainer();
|
|
77
86
|
const isReducedGraphics = reducedGraphics;
|
|
@@ -79,13 +88,14 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
79
88
|
const $isPanning = $panning;
|
|
80
89
|
const isPanning = useTimeout(() => {
|
|
81
90
|
$isPanning.set(true);
|
|
82
|
-
}, isReducedGraphics ? 200 :
|
|
91
|
+
}, isReducedGraphics ? 200 : 1e3);
|
|
83
92
|
const notPanning = useDebouncedCallback$1(() => {
|
|
84
93
|
isPanning.clear();
|
|
85
94
|
$isPanning.set(false);
|
|
86
95
|
}, 200);
|
|
87
96
|
const onMove = useCallbackRef$1((event) => {
|
|
88
97
|
if (!event) {
|
|
98
|
+
$isPanning.set(false);
|
|
89
99
|
isPanning.clear();
|
|
90
100
|
return;
|
|
91
101
|
}
|
|
@@ -93,7 +103,11 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
93
103
|
else notPanning();
|
|
94
104
|
});
|
|
95
105
|
const onMoveEnd = useCallbackRef$1((event, viewport) => {
|
|
96
|
-
if (event)
|
|
106
|
+
if (!event) {
|
|
107
|
+
$isPanning.set(false);
|
|
108
|
+
isPanning.clear();
|
|
109
|
+
notPanning.cancel();
|
|
110
|
+
} else notPanning();
|
|
97
111
|
diagram.send({
|
|
98
112
|
type: "xyflow.viewportMoved",
|
|
99
113
|
viewport,
|
|
@@ -107,7 +121,7 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
107
121
|
useUpdateEffect$1(() => {
|
|
108
122
|
console.warn("renderNodes changed - this might degrade performance");
|
|
109
123
|
}, [nodeTypes]);
|
|
110
|
-
return /* @__PURE__ */
|
|
124
|
+
return /* @__PURE__ */ jsxs(BaseXYFlow, {
|
|
111
125
|
nodes,
|
|
112
126
|
edges,
|
|
113
127
|
className: cx(initialized ? "initialized" : "not-initialized"),
|
|
@@ -128,6 +142,7 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
128
142
|
background: initialized ? background : "transparent",
|
|
129
143
|
fitView: false,
|
|
130
144
|
onNodeClick: useCallbackRef$1((e, node) => {
|
|
145
|
+
if (e.isPropagationStopped()) return;
|
|
131
146
|
e.stopPropagation();
|
|
132
147
|
diagram.send({
|
|
133
148
|
type: "xyflow.nodeClick",
|
|
@@ -136,6 +151,7 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
136
151
|
onNodeClick?.(diagram.findDiagramNode(node.id), e);
|
|
137
152
|
}),
|
|
138
153
|
onEdgeClick: useCallbackRef$1((e, edge) => {
|
|
154
|
+
if (e.isPropagationStopped()) return;
|
|
139
155
|
e.stopPropagation();
|
|
140
156
|
diagram.send({
|
|
141
157
|
type: "xyflow.edgeClick",
|
|
@@ -144,12 +160,21 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
144
160
|
onEdgeClick?.(diagram.findDiagramEdge(edge.id), e);
|
|
145
161
|
}),
|
|
146
162
|
onEdgeDoubleClick: useCallbackRef$1((e, edge) => {
|
|
163
|
+
if (e.isPropagationStopped()) return;
|
|
147
164
|
e.stopPropagation();
|
|
148
165
|
diagram.send({
|
|
149
166
|
type: "xyflow.edgeDoubleClick",
|
|
150
167
|
edge
|
|
151
168
|
});
|
|
152
169
|
}),
|
|
170
|
+
onDelete: useCallbackRef$1(({ nodes, edges }) => {
|
|
171
|
+
if (enableReadOnly) return;
|
|
172
|
+
diagram.editorActor().send({
|
|
173
|
+
type: "delete.nodes-edges",
|
|
174
|
+
nodeIds: nodes.map((node) => node.data.id),
|
|
175
|
+
edgeIds: edges.map((edge) => edge.data.id)
|
|
176
|
+
});
|
|
177
|
+
}),
|
|
153
178
|
onPaneClick: useCallbackRef$1((e) => {
|
|
154
179
|
e.stopPropagation();
|
|
155
180
|
diagram.send({ type: "xyflow.paneClick" });
|
|
@@ -200,8 +225,8 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
200
225
|
});
|
|
201
226
|
}),
|
|
202
227
|
onNodeContextMenu: useCallbackRef$1((event, node) => {
|
|
203
|
-
const diagramNode =
|
|
204
|
-
onNodeContextMenu?.(diagramNode, event);
|
|
228
|
+
const diagramNode = diagram.findDiagramNode(node.data.id);
|
|
229
|
+
if (diagramNode) onNodeContextMenu?.(diagramNode, event);
|
|
205
230
|
}),
|
|
206
231
|
onEdgeContextMenu: useCallbackRef$1((event, edge) => {
|
|
207
232
|
const diagramEdge = nonNullable(diagram.findDiagramEdge(edge.id), `diagramEdge ${edge.id} not found`);
|
|
@@ -211,13 +236,25 @@ function LikeC4DiagramXYFlow({ background = "dots", reactFlowProps = {}, childre
|
|
|
211
236
|
...enableFitView && { onViewportResize },
|
|
212
237
|
nodesDraggable,
|
|
213
238
|
nodesSelectable,
|
|
239
|
+
nodesFocusable: true,
|
|
240
|
+
edgesFocusable: true,
|
|
214
241
|
elevateEdgesOnSelect: !enableReadOnly,
|
|
215
242
|
zIndexMode: "manual",
|
|
216
243
|
...nodesDraggable && layoutConstraints,
|
|
217
244
|
...props,
|
|
218
245
|
...reactFlowProps,
|
|
219
|
-
children
|
|
246
|
+
children: [enableControls && /* @__PURE__ */ jsx(Controls$1, { padding: props.fitViewPadding }), children]
|
|
220
247
|
});
|
|
221
248
|
}
|
|
249
|
+
var Controls$1 = /* @__PURE__ */ __name(({ padding }) => /* @__PURE__ */ jsx(Controls, {
|
|
250
|
+
showInteractive: false,
|
|
251
|
+
fitViewOptions: {
|
|
252
|
+
padding,
|
|
253
|
+
minZoom: MinZoom,
|
|
254
|
+
maxZoom: 1,
|
|
255
|
+
duration: 350
|
|
256
|
+
},
|
|
257
|
+
position: "bottom-left"
|
|
258
|
+
}), "Controls");
|
|
222
259
|
//#endregion
|
|
223
260
|
export { LikeC4DiagramXYFlow };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LayoutedView, ViewId } from '@likec4/core/types';
|
|
2
|
+
import { DiagramContext } from './state/types';
|
|
2
3
|
import { Types } from './types';
|
|
3
|
-
type ConvertToXYFlowInput = {
|
|
4
|
+
type ConvertToXYFlowInput = Pick<DiagramContext, 'view' | 'where' | 'dynamicViewVariant' | 'collapsedSequenceFlows'> & {
|
|
4
5
|
currentViewId: ViewId | undefined;
|
|
5
|
-
view: LayoutedView;
|
|
6
|
-
where: WhereOperator | null;
|
|
7
|
-
dynamicViewVariant: DynamicViewDisplayVariant;
|
|
8
6
|
};
|
|
9
7
|
export declare function convertToXYFlow({ dynamicViewVariant, ...params }: ConvertToXYFlowInput): {
|
|
10
8
|
view: LayoutedView;
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { diagramToXY } from "./xyflow-diagram/diagram-view.js";
|
|
3
|
-
import { sequenceLayoutToXY } from "./xyflow-sequence/sequence-
|
|
3
|
+
import { sequenceLayoutToXY } from "./xyflow-sequence/sequence-view-to-xy.js";
|
|
4
4
|
//#region src/likec4diagram/convert-to-xyflow.ts
|
|
5
5
|
function convertToXYFlow({ dynamicViewVariant, ...params }) {
|
|
6
6
|
const view = params.view;
|
|
7
7
|
const isDynamic = view._type === "dynamic";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
if (isDynamic && dynamicViewVariant !== "sequence") {
|
|
9
|
+
const { xynodes, xyedges } = diagramToXY(params);
|
|
10
|
+
return {
|
|
11
|
+
view: view.variant !== "diagram" ? {
|
|
12
|
+
...view,
|
|
13
|
+
variant: "diagram"
|
|
14
|
+
} : view,
|
|
15
|
+
xynodes,
|
|
16
|
+
xyedges
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (isDynamic && dynamicViewVariant === "sequence") {
|
|
20
|
+
const { xynodes, xyedges, layout } = sequenceLayoutToXY({
|
|
21
|
+
view,
|
|
22
|
+
currentViewId: params.currentViewId,
|
|
23
|
+
collapsedFlows: params.collapsedSequenceFlows
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
view: {
|
|
27
|
+
...view,
|
|
28
|
+
sequenceLayout: layout,
|
|
29
|
+
variant: dynamicViewVariant
|
|
30
|
+
},
|
|
31
|
+
xynodes,
|
|
32
|
+
xyedges
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const { xynodes, xyedges } = diagramToXY(params);
|
|
17
36
|
return {
|
|
18
37
|
view,
|
|
19
38
|
xynodes,
|
|
@@ -3,4 +3,4 @@ export type EdgeDriftsProps = {
|
|
|
3
3
|
edgeProps: Types.EdgeProps;
|
|
4
4
|
svgPath: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function EdgeDrifts({ edgeProps: { data }, svgPath, }: EdgeDriftsProps): import("react
|
|
6
|
+
export declare function EdgeDrifts({ edgeProps: { data }, svgPath, }: EdgeDriftsProps): import("react").JSX.Element | null;
|
|
@@ -13,7 +13,7 @@ import { EdgeLabelContainer } from "../../../base-primitives/edge/EdgeLabelConta
|
|
|
13
13
|
import { EdgePath } from "../../../base-primitives/edge/EdgePath.js";
|
|
14
14
|
import { memoEdge } from "../../../base-primitives/memoEdge.js";
|
|
15
15
|
import { EdgeDrifts } from "./EdgeDrifts.js";
|
|
16
|
-
import { controlPoint, controlPointsContainer } from "./edges.css.js";
|
|
16
|
+
import { controlPoint, controlPointsContainer, labelDraggable } from "./edges.css.js";
|
|
17
17
|
import { useControlPoints } from "./useControlPoints.js";
|
|
18
18
|
import { useRelationshipEdgePath } from "./useRelationshipEdgePath.js";
|
|
19
19
|
import { css, cx } from "@likec4/styles/css";
|
|
@@ -21,6 +21,7 @@ import { useRef, useState } from "react";
|
|
|
21
21
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
22
22
|
import { useRafEffect } from "@react-hookz/web";
|
|
23
23
|
import { EdgeLabelRenderer } from "@xyflow/react";
|
|
24
|
+
import { isNumber } from "remeda";
|
|
24
25
|
//#region src/likec4diagram/custom/edges/RelationshipEdge.tsx
|
|
25
26
|
var getEdgeCenter = (path) => {
|
|
26
27
|
const dompoint = path.getPointAtLength(path.getTotalLength() * .5);
|
|
@@ -33,7 +34,11 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
33
34
|
const [isControlPointDragging, setIsControlPointDragging] = useState(false);
|
|
34
35
|
const isControlPointDraggingRef = useRef(isControlPointDragging);
|
|
35
36
|
isControlPointDraggingRef.current = isControlPointDragging;
|
|
37
|
+
const [isLabelDragging, setIsLabelDragging] = useState(false);
|
|
38
|
+
const isLabelDraggingRef = useRef(isLabelDragging);
|
|
39
|
+
isLabelDraggingRef.current = isLabelDragging;
|
|
36
40
|
const xyflow = useXYFlow();
|
|
41
|
+
const xyflowStore = useXYStoreApi();
|
|
37
42
|
const diagram = useDiagram();
|
|
38
43
|
const { enableNavigateTo, enableReadOnly, enableCompareWithLatest } = useEnabledFeatures();
|
|
39
44
|
const enabledEditing = !enableReadOnly;
|
|
@@ -52,32 +57,58 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
52
57
|
y: labelXY?.y ?? labelY
|
|
53
58
|
}, isSamePoint);
|
|
54
59
|
useUpdateEffect$1(() => {
|
|
55
|
-
if (isControlPointDraggingRef.current) return;
|
|
60
|
+
if (isControlPointDraggingRef.current || isLabelDraggingRef.current) return;
|
|
56
61
|
setLabelPos({
|
|
57
62
|
x: labelX,
|
|
58
63
|
y: labelY
|
|
59
64
|
});
|
|
60
65
|
}, [labelX, labelY]);
|
|
61
66
|
const svgPathRef = useRef(null);
|
|
67
|
+
const labelOffsetRef = useRef({
|
|
68
|
+
x: 0,
|
|
69
|
+
y: 0
|
|
70
|
+
});
|
|
71
|
+
const captureLabelOffset = useCallbackRef(() => {
|
|
72
|
+
const path = svgPathRef.current;
|
|
73
|
+
if (data.isLabelCustomized && path && labelBBox) {
|
|
74
|
+
const center = getEdgeCenter(path);
|
|
75
|
+
labelOffsetRef.current = {
|
|
76
|
+
x: labelBBox.x - center.x,
|
|
77
|
+
y: labelBBox.y - center.y
|
|
78
|
+
};
|
|
79
|
+
} else labelOffsetRef.current = {
|
|
80
|
+
x: 0,
|
|
81
|
+
y: 0
|
|
82
|
+
};
|
|
83
|
+
});
|
|
62
84
|
useRafEffect(() => {
|
|
63
85
|
const path = svgPathRef.current;
|
|
64
86
|
if (!path || !isControlPointDragging) return;
|
|
65
|
-
|
|
87
|
+
const center = getEdgeCenter(path);
|
|
88
|
+
const offset = labelOffsetRef.current;
|
|
89
|
+
setLabelPos({
|
|
90
|
+
x: center.x + offset.x,
|
|
91
|
+
y: center.y + offset.y
|
|
92
|
+
});
|
|
66
93
|
}, [edgePath, isControlPointDragging]);
|
|
67
94
|
const updateEdgeData = useCallbackRef((controlPoints) => {
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
95
|
+
const center = labelBBox && svgPathRef.current ? getEdgeCenter(svgPathRef.current) : null;
|
|
96
|
+
if (center) {
|
|
97
|
+
const offset = labelOffsetRef.current;
|
|
98
|
+
diagram.updateEdgeData(id, {
|
|
99
|
+
controlPoints,
|
|
100
|
+
labelBBox: {
|
|
101
|
+
...labelBBox,
|
|
102
|
+
x: center.x + offset.x,
|
|
103
|
+
y: center.y + offset.y
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} else diagram.updateEdgeData(id, { controlPoints });
|
|
77
107
|
diagram.stopEditing(true);
|
|
78
108
|
setIsControlPointDragging(false);
|
|
79
109
|
});
|
|
80
110
|
const onControlPointerStartMove = useCallbackRef(() => {
|
|
111
|
+
captureLabelOffset();
|
|
81
112
|
diagram.startEditing("edge");
|
|
82
113
|
setIsControlPointDragging(true);
|
|
83
114
|
});
|
|
@@ -92,6 +123,7 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
92
123
|
});
|
|
93
124
|
});
|
|
94
125
|
const onControlPointerDelete = useCallbackRef((points) => {
|
|
126
|
+
captureLabelOffset();
|
|
95
127
|
diagram.startEditing("edge");
|
|
96
128
|
setIsControlPointDragging(true);
|
|
97
129
|
setControlPoints(points);
|
|
@@ -115,6 +147,86 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
115
147
|
diagram.updateEdgeData(id, { controlPoints: newControlPoints });
|
|
116
148
|
diagram.stopEditing(true);
|
|
117
149
|
});
|
|
150
|
+
const updateLabelPosition = useCallbackRef((pos) => {
|
|
151
|
+
if (labelBBox) diagram.updateEdgeData(id, {
|
|
152
|
+
labelBBox: {
|
|
153
|
+
...labelBBox,
|
|
154
|
+
x: pos.x,
|
|
155
|
+
y: pos.y
|
|
156
|
+
},
|
|
157
|
+
isLabelCustomized: true
|
|
158
|
+
});
|
|
159
|
+
diagram.stopEditing(true);
|
|
160
|
+
setIsLabelDragging(false);
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* Handle pointer down on the edge label to drag it to a custom position.
|
|
164
|
+
* Mirrors the control-point LMB drag.
|
|
165
|
+
*/
|
|
166
|
+
const onLabelPointerDown = useCallbackRef((e) => {
|
|
167
|
+
if (e.pointerType !== "mouse" || e.button !== 0 || !labelBBox || isControlPointDraggingRef.current) return;
|
|
168
|
+
const { domNode, edges, addSelectedEdges, unselectNodesAndEdges } = xyflowStore.getState();
|
|
169
|
+
if (!domNode) return;
|
|
170
|
+
e.stopPropagation();
|
|
171
|
+
if (!selected) {
|
|
172
|
+
unselectNodesAndEdges({ edges: edges.filter((ed) => ed.selected && ed.id !== id) });
|
|
173
|
+
addSelectedEdges([id]);
|
|
174
|
+
}
|
|
175
|
+
let hasMoved = false;
|
|
176
|
+
const initialPoint = {
|
|
177
|
+
x: e.clientX,
|
|
178
|
+
y: e.clientY
|
|
179
|
+
};
|
|
180
|
+
const clientPoint = { ...initialPoint };
|
|
181
|
+
const flowStart = xyflow.screenToFlowPosition(initialPoint, { snapToGrid: false });
|
|
182
|
+
const grab = {
|
|
183
|
+
x: flowStart.x - labelBBox.x,
|
|
184
|
+
y: flowStart.y - labelBBox.y
|
|
185
|
+
};
|
|
186
|
+
let pos = {
|
|
187
|
+
x: labelBBox.x,
|
|
188
|
+
y: labelBBox.y
|
|
189
|
+
};
|
|
190
|
+
let animationFrameId = null;
|
|
191
|
+
const onPointerMove = (ev) => {
|
|
192
|
+
clientPoint.x = ev.clientX;
|
|
193
|
+
clientPoint.y = ev.clientY;
|
|
194
|
+
if (!isSamePoint(initialPoint, clientPoint)) {
|
|
195
|
+
if (!hasMoved) {
|
|
196
|
+
hasMoved = true;
|
|
197
|
+
diagram.startEditing("edge");
|
|
198
|
+
setIsLabelDragging(true);
|
|
199
|
+
}
|
|
200
|
+
animationFrameId ??= requestAnimationFrame(() => {
|
|
201
|
+
animationFrameId = null;
|
|
202
|
+
const { x, y } = xyflow.screenToFlowPosition(clientPoint, { snapToGrid: false });
|
|
203
|
+
pos = {
|
|
204
|
+
x: Math.round(x - grab.x),
|
|
205
|
+
y: Math.round(y - grab.y)
|
|
206
|
+
};
|
|
207
|
+
setLabelPos(pos);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
ev.stopPropagation();
|
|
211
|
+
};
|
|
212
|
+
const onPointerUp = (ev) => {
|
|
213
|
+
ev.stopPropagation();
|
|
214
|
+
domNode.removeEventListener("pointermove", onPointerMove, { capture: true });
|
|
215
|
+
if (animationFrameId !== null) cancelAnimationFrame(animationFrameId);
|
|
216
|
+
if (hasMoved) {
|
|
217
|
+
domNode.addEventListener("click", stopAndPrevent, {
|
|
218
|
+
capture: true,
|
|
219
|
+
once: true
|
|
220
|
+
});
|
|
221
|
+
updateLabelPosition(pos);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
domNode.addEventListener("pointermove", onPointerMove, { capture: true });
|
|
225
|
+
domNode.addEventListener("pointerup", onPointerUp, {
|
|
226
|
+
once: true,
|
|
227
|
+
capture: true
|
|
228
|
+
});
|
|
229
|
+
});
|
|
118
230
|
if (isControlPointDragging && !props.data.hovered) props = {
|
|
119
231
|
...props,
|
|
120
232
|
data: {
|
|
@@ -122,6 +234,10 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
122
234
|
hovered: true
|
|
123
235
|
}
|
|
124
236
|
};
|
|
237
|
+
const sequenceStepData = isNumber(props.data.stepnum) ? {
|
|
238
|
+
isSequenceStep: true,
|
|
239
|
+
stepNum: props.data.stepnum
|
|
240
|
+
} : void 0;
|
|
125
241
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(EdgeContainer, {
|
|
126
242
|
...props,
|
|
127
243
|
className: css({ "& .react-flow__edge-interaction": { cursor: enabledEditing && selected ? "copy" : void 0 } }),
|
|
@@ -139,17 +255,23 @@ var RelationshipEdge = memoEdge((props) => {
|
|
|
139
255
|
}),
|
|
140
256
|
labelBBox && /* @__PURE__ */ jsx(EdgeLabelContainer, {
|
|
141
257
|
edgeProps: props,
|
|
142
|
-
labelPosition: isControlPointDragging ? labelPos : {
|
|
258
|
+
labelPosition: isControlPointDragging || isLabelDragging ? labelPos : {
|
|
143
259
|
x: labelX,
|
|
144
260
|
y: labelY
|
|
145
261
|
},
|
|
262
|
+
...enabledEditing && { onPointerDown: onLabelPointerDown },
|
|
146
263
|
children: /* @__PURE__ */ jsx(EdgeLabel, {
|
|
147
|
-
pointerEvents:
|
|
264
|
+
pointerEvents: "all",
|
|
265
|
+
className: enabledEditing ? labelDraggable : void 0,
|
|
266
|
+
...sequenceStepData,
|
|
148
267
|
edgeProps: props,
|
|
149
|
-
children: navigateTo && /* @__PURE__ */ jsx(EdgeActionButton, {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
268
|
+
children: navigateTo && /* @__PURE__ */ jsx(EdgeActionButton, {
|
|
269
|
+
ariaLabel: "Navigate to view",
|
|
270
|
+
onClick: (e) => {
|
|
271
|
+
e.stopPropagation();
|
|
272
|
+
diagram.navigateTo(navigateTo);
|
|
273
|
+
}
|
|
274
|
+
})
|
|
153
275
|
})
|
|
154
276
|
})
|
|
155
277
|
]
|