@likec4/diagram 1.43.0 → 1.45.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/bundle/index.js +14727 -13166
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +14 -9
- package/dist/LikeC4Diagram.props.d.ts +25 -15
- package/dist/LikeC4ProjectsProvider.js +1 -1
- package/dist/LikeC4Styles.js +0 -3
- package/dist/LikeC4View.d.ts +8 -3
- package/dist/LikeC4View.js +29 -14
- package/dist/ReactLikeC4.d.ts +2 -2
- package/dist/ReactLikeC4.js +2 -2
- package/dist/StaticLikeC4Diagram.js +1 -1
- package/dist/_virtual/_commonjsHelpers.js +3 -0
- package/dist/_virtual/assign-dea9f7c8.cjs.js +3 -0
- package/dist/_virtual/log-ec8d4df4.cjs.js +3 -0
- package/dist/_virtual/raise-da5b247f.cjs.js +3 -0
- package/dist/_virtual/xstate-actions.cjs.js +5 -0
- package/dist/_virtual/xstate-actions.cjs2.js +3 -0
- package/dist/_virtual/xstate-dev.cjs.js +3 -0
- package/dist/_virtual/xstate-guards.cjs.js +5 -0
- package/dist/_virtual/xstate-guards.cjs2.js +3 -0
- package/dist/base/Background.d.ts +2 -1
- package/dist/base/Background.js +11 -2
- package/dist/base/Base.d.ts +28 -0
- package/dist/base/BaseXYFlow.d.ts +5 -5
- package/dist/base/BaseXYFlow.js +38 -44
- package/dist/base/index.d.ts +6 -2
- package/dist/base/types.d.ts +1 -28
- package/dist/base/updateEdges.js +25 -14
- package/dist/base/updateNodes.d.ts +14 -0
- package/dist/base/updateNodes.js +51 -17
- package/dist/base-primitives/Markdown.d.ts +30 -4
- package/dist/base-primitives/Markdown.js +3 -2
- package/dist/base-primitives/compound/CompoundActionButton.d.ts +3 -2
- package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.d.ts +3 -2
- package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
- package/dist/base-primitives/edge/EdgeActionButton.d.ts +3 -2
- package/dist/base-primitives/edge/EdgeActionButton.js +1 -1
- package/dist/base-primitives/edge/EdgeContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeContainer.js +8 -1
- package/dist/base-primitives/edge/EdgeLabel.d.ts +3 -2
- package/dist/base-primitives/edge/EdgeLabel.js +2 -0
- package/dist/base-primitives/edge/EdgeLabelContainer.d.ts +1 -1
- package/dist/base-primitives/edge/EdgeLabelContainer.js +4 -0
- package/dist/base-primitives/edge/EdgePath.d.ts +4 -0
- package/dist/base-primitives/edge/EdgePath.js +29 -5
- package/dist/base-primitives/element/ElementActionButtons.d.ts +6 -4
- package/dist/base-primitives/element/ElementActionButtons.js +3 -3
- package/dist/base-primitives/element/ElementData.d.ts +3 -3
- package/dist/base-primitives/element/ElementData.js +13 -7
- package/dist/base-primitives/element/ElementDetailsButton.d.ts +3 -2
- package/dist/base-primitives/element/ElementDetailsButton.js +5 -5
- package/dist/base-primitives/element/ElementNodeContainer.css.js +15 -27
- package/dist/base-primitives/element/ElementShape.js +5 -5
- package/dist/base-primitives/element/ElementTags.d.ts +6 -4
- package/dist/base-primitives/element/ElementTags.js +2 -1
- package/dist/base-primitives/memoEdge.js +4 -2
- package/dist/base-primitives/memoNode.d.ts +1 -1
- package/dist/base-primitives/memoNode.js +3 -3
- package/dist/components/ErrorFallback.js +52 -35
- package/dist/components/Link.js +2 -2
- package/dist/context/DiagramEventHandlers.js +2 -1
- package/dist/context/DiagramFeatures.d.ts +25 -6
- package/dist/context/DiagramFeatures.js +28 -56
- package/dist/context/IconRenderer.js +6 -6
- package/dist/context/LikeC4ModelContext.js +3 -10
- package/dist/context/TagStylesContext.js +3 -19
- package/dist/context/index.d.ts +1 -1
- package/dist/custom/customNodes.js +3 -2
- package/dist/custom/hooks.d.ts +3 -3
- package/dist/custom/index.d.ts +1 -1
- package/dist/custom/index.js +5 -5
- package/dist/editor/LikeC4EditorContext.d.ts +21 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/safeContext.d.ts +6 -3
- package/dist/hooks/safeContext.js +10 -3
- package/dist/hooks/useCallbackRef.d.ts +1 -0
- package/dist/hooks/useCallbackRef.js +13 -0
- package/dist/hooks/useCurrentView.d.ts +11 -0
- package/dist/hooks/{useCurrentViewId.js → useCurrentView.js} +7 -3
- package/dist/hooks/useCurrentViewModel.js +4 -1
- package/dist/hooks/useDiagram.d.ts +7 -113
- package/dist/hooks/useDiagram.js +7 -127
- package/dist/hooks/useDiagramCompareLayout.d.ts +35 -0
- package/dist/hooks/useDiagramCompareLayout.js +65 -0
- package/dist/hooks/useLikeC4Project.d.ts +6 -1
- package/dist/hooks/useLikeC4Project.js +14 -2
- package/dist/hooks/useMediaPrint.d.ts +6 -0
- package/dist/hooks/useUpdateEffect.js +2 -4
- package/dist/hooks/useXYFlow.d.ts +1 -0
- package/dist/hooks/useXYFlow.js +4 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/dist/likec4diagram/DiagramUI.js +14 -7
- package/dist/likec4diagram/DiagramXYFlow.d.ts +2 -2
- package/dist/likec4diagram/DiagramXYFlow.js +60 -52
- package/dist/likec4diagram/convert-to-xyflow.d.ts +0 -1
- package/dist/likec4diagram/custom/edges/EdgeDrifts.d.ts +6 -0
- package/dist/likec4diagram/custom/edges/EdgeDrifts.js +38 -0
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +256 -217
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +9 -2
- package/dist/likec4diagram/custom/edges/edges.css.js +3 -4
- package/dist/likec4diagram/custom/edges/useControlPoints.d.ts +8 -0
- package/dist/likec4diagram/custom/edges/useControlPoints.js +58 -0
- package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.d.ts +7 -0
- package/dist/likec4diagram/custom/edges/useRelationshipEdgePath.js +60 -0
- package/dist/likec4diagram/custom/edges/utils.d.ts +0 -12
- package/dist/likec4diagram/custom/nodes/CompoundActions.js +4 -1
- package/dist/likec4diagram/custom/nodes/ElementActions.d.ts +2 -1
- package/dist/likec4diagram/custom/nodes/ElementActions.js +15 -10
- package/dist/likec4diagram/custom/nodes/NodeDrifts.d.ts +6 -0
- package/dist/likec4diagram/custom/nodes/NodeDrifts.js +50 -0
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +7 -2
- package/dist/likec4diagram/custom/nodes/index.d.ts +1 -0
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +9 -1
- package/dist/likec4diagram/custom/nodes/nodes.js +74 -29
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.d.ts +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/ColorButton.js +1 -1
- package/dist/likec4diagram/custom/nodes/toolbar/CompoundToolbar.js +2 -1
- package/dist/likec4diagram/custom/nodes/toolbar/ElementToolbar.js +4 -3
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.d.ts +1 -11
- package/dist/likec4diagram/custom/nodes/toolbar/_shared.js +7 -51
- package/dist/likec4diagram/custom/nodes/toolbar/types.d.ts +5 -0
- package/dist/likec4diagram/custom/nodes/toolbar/types.js +7 -0
- package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.d.ts +8 -0
- package/dist/likec4diagram/custom/nodes/toolbar/useHandlers.js +44 -0
- package/dist/likec4diagram/relationship-popover/RelationshipPopover.js +8 -10
- package/dist/likec4diagram/relationship-popover/actor.d.ts +1 -1
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +4 -3
- package/dist/likec4diagram/state/DiagramActorProvider.js +95 -70
- package/dist/likec4diagram/state/assign.d.ts +13 -7
- package/dist/likec4diagram/state/assign.js +43 -282
- package/dist/likec4diagram/state/createViewChange.d.ts +3 -0
- package/dist/likec4diagram/state/createViewChange.js +79 -0
- package/dist/likec4diagram/state/diagram-api.d.ts +109 -0
- package/dist/likec4diagram/state/diagram-api.js +126 -0
- package/dist/likec4diagram/state/machine.actions.d.ts +1783 -0
- package/dist/likec4diagram/state/machine.actions.js +644 -0
- package/dist/likec4diagram/state/machine.actions.layout.d.ts +579 -0
- package/dist/likec4diagram/state/machine.actions.layout.js +129 -0
- package/dist/likec4diagram/state/machine.d.ts +22 -0
- package/dist/likec4diagram/state/machine.js +127 -0
- package/dist/likec4diagram/state/machine.setup.d.ts +327 -0
- package/dist/likec4diagram/state/machine.setup.js +93 -0
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +208 -0
- package/dist/likec4diagram/state/machine.state.initializing.js +55 -0
- package/dist/likec4diagram/state/machine.state.navigating.d.ts +14 -0
- package/dist/likec4diagram/state/machine.state.navigating.js +178 -0
- package/dist/likec4diagram/state/machine.state.ready.d.ts +3131 -0
- package/dist/likec4diagram/state/machine.state.ready.focused.d.ts +386 -0
- package/dist/likec4diagram/state/machine.state.ready.focused.js +85 -0
- package/dist/likec4diagram/state/machine.state.ready.idle.d.ts +474 -0
- package/dist/likec4diagram/state/machine.state.ready.idle.js +96 -0
- package/dist/likec4diagram/state/machine.state.ready.js +262 -0
- package/dist/likec4diagram/state/machine.state.ready.printing.d.ts +128 -0
- package/dist/likec4diagram/state/machine.state.ready.printing.js +40 -0
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.d.ts +511 -0
- package/dist/likec4diagram/state/machine.state.ready.walkthrough.js +177 -0
- package/dist/likec4diagram/state/mediaPrintActor.d.ts +12 -0
- package/dist/likec4diagram/state/mediaPrintActor.js +18 -0
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +31 -108
- package/dist/likec4diagram/state/syncManualLayoutActor.js +278 -142
- package/dist/likec4diagram/state/types.d.ts +7 -12
- package/dist/likec4diagram/state/utils.d.ts +19 -4
- package/dist/likec4diagram/state/utils.js +47 -4
- package/dist/likec4diagram/types.d.ts +8 -8
- package/dist/likec4diagram/ui/LayoutDriftFrame.d.ts +2 -0
- package/dist/likec4diagram/ui/LayoutDriftFrame.js +66 -0
- package/dist/likec4diagram/ui/index.d.ts +1 -0
- package/dist/likec4diagram/ui/notation/NotationPanel.css.js +5 -2
- package/dist/likec4diagram/ui/notation/NotationPanel.js +5 -4
- package/dist/likec4diagram/useLayoutConstraints.d.ts +10 -5
- package/dist/likec4diagram/useLayoutConstraints.js +237 -61
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +0 -1
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +14 -17
- package/dist/likec4diagram/xyflow-sequence/sequence-layout.js +11 -8
- package/dist/navigationpanel/NavigationPanel.js +16 -8
- package/dist/navigationpanel/NavigationPanelControls.d.ts +2 -1
- package/dist/navigationpanel/NavigationPanelControls.js +23 -17
- package/dist/navigationpanel/NavigationPanelDropdown.d.ts +2 -1
- package/dist/navigationpanel/NavigationPanelDropdown.js +62 -42
- package/dist/navigationpanel/_common.d.ts +1 -1
- package/dist/navigationpanel/_common.js +4 -2
- package/dist/navigationpanel/actor.d.ts +9 -205
- package/dist/navigationpanel/actor.js +6 -5
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.d.ts +3 -0
- package/dist/navigationpanel/comparepanel/CompareActionsMenu.js +59 -0
- package/dist/navigationpanel/comparepanel/ComparePanel.d.ts +2 -0
- package/dist/navigationpanel/comparepanel/ComparePanel.js +42 -0
- package/dist/navigationpanel/comparepanel/ComparePanelControls.d.ts +1 -0
- package/dist/navigationpanel/comparepanel/ComparePanelControls.js +60 -0
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.d.ts +5 -0
- package/dist/navigationpanel/comparepanel/LayoutTypeSwitcher.js +38 -0
- package/dist/navigationpanel/comparepanel/index.d.ts +1 -0
- package/dist/navigationpanel/controls/{ViewDetailsCard.d.ts → DetailsControls.d.ts} +1 -1
- package/dist/navigationpanel/controls/{ViewDetailsCard.js → DetailsControls.js} +18 -14
- package/dist/navigationpanel/controls/LayoutWarning.d.ts +2 -0
- package/dist/navigationpanel/controls/LayoutWarning.js +102 -0
- package/dist/navigationpanel/controls/NavigationButtons.js +4 -3
- package/dist/navigationpanel/controls/OpenSource.js +2 -2
- package/dist/navigationpanel/controls/SearchControl.d.ts +2 -1
- package/dist/navigationpanel/controls/SearchControl.js +15 -17
- package/dist/navigationpanel/controls/ToggleReadonly.d.ts +1 -1
- package/dist/navigationpanel/controls/ToggleReadonly.js +26 -18
- package/dist/navigationpanel/controls/index.d.ts +2 -1
- package/dist/navigationpanel/dropdown/ProjectsMenu.d.ts +2 -2
- package/dist/navigationpanel/dropdown/ProjectsMenu.js +5 -5
- package/dist/navigationpanel/editorpanel/CenterCamera.js +5 -2
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.d.ts +1 -1
- package/dist/navigationpanel/editorpanel/ChangeAutoLayoutButton.js +21 -20
- package/dist/navigationpanel/editorpanel/EditorPanel.js +3 -3
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.d.ts +2 -2
- package/dist/navigationpanel/editorpanel/ManualLayoutToolsButton.js +16 -13
- package/dist/navigationpanel/editorpanel/ToggleReadonly.d.ts +1 -0
- package/dist/navigationpanel/editorpanel/ToggleReadonly.js +15 -0
- package/dist/navigationpanel/styles.css.d.ts +2 -2
- package/dist/navigationpanel/styles.css.js +4 -4
- package/dist/navigationpanel/walkthrough/ActiveWalkthroughControls.js +14 -8
- package/dist/navigationpanel/walkthrough/DynamicViewControls.d.ts +66 -66
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +31 -14
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +2 -1
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +68 -50
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/actions/dist/xstate-actions.cjs.js +37 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dev/dist/xstate-dev.cjs.js +59 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/assign-dea9f7c8.cjs.js +140 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/log-ec8d4df4.cjs.js +401 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/dist/raise-da5b247f.cjs.js +2716 -0
- package/dist/node_modules/.pnpm/xstate@5.24.0_patch_hash_3a1bd6d012ec67bf6e38a00c3226d1be77089442f83aeb6e424b00ca2a11d21c/node_modules/xstate/guards/dist/xstate-guards.cjs.js +26 -0
- package/dist/overlays/element-details/ElementDetails.js +7 -7
- package/dist/overlays/element-details/ElementDetailsCard.css.js +3 -3
- package/dist/overlays/element-details/ElementDetailsCard.js +7 -5
- package/dist/overlays/element-details/MetadataValue.d.ts +2 -1
- package/dist/overlays/element-details/MetadataValue.js +2 -2
- package/dist/overlays/element-details/TabPanelDeployments.js +6 -4
- package/dist/overlays/element-details/TabPanelRelationships.js +3 -3
- package/dist/overlays/element-details/TabPanelStructure.js +1 -1
- package/dist/overlays/element-details/actor.d.ts +8 -82
- package/dist/overlays/element-details/actor.js +0 -8
- package/dist/overlays/overlay/Overlay.js +10 -10
- package/dist/overlays/overlaysActor.d.ts +7 -150
- package/dist/overlays/overlaysActor.js +183 -161
- package/dist/overlays/relationship-details/RelationshipDetails.js +4 -3
- package/dist/overlays/relationship-details/SelectEdge.js +2 -2
- package/dist/overlays/relationship-details/_types.d.ts +3 -4
- package/dist/overlays/relationship-details/actor.d.ts +6 -550
- package/dist/overlays/relationship-details/actor.js +18 -3
- package/dist/overlays/relationship-details/custom/ElementActions.js +8 -5
- package/dist/overlays/relationship-details/custom/edgeTypes.js +4 -1
- package/dist/overlays/relationship-details/custom/nodeTypes.js +4 -1
- package/dist/overlays/relationship-details/hooks.js +1 -1
- package/dist/overlays/relationship-details/layout-to-xyflow.js +3 -5
- package/dist/overlays/relationship-details/layout.d.ts +3 -3
- package/dist/overlays/relationship-details/layout.js +4 -4
- package/dist/overlays/relationships-browser/RelationshipsBrowser.js +6 -4
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/_types.d.ts +2 -3
- package/dist/overlays/relationships-browser/actor.d.ts +7 -673
- package/dist/overlays/relationships-browser/actor.js +132 -110
- package/dist/overlays/relationships-browser/custom/ElementActions.js +44 -37
- package/dist/overlays/relationships-browser/custom/edgeTypes.js +4 -1
- package/dist/overlays/relationships-browser/custom/nodeTypes.js +4 -1
- package/dist/overlays/relationships-browser/hooks.js +7 -6
- package/dist/overlays/relationships-browser/layout.d.ts +2 -2
- package/dist/overlays/relationships-browser/layout.js +3 -3
- package/dist/overlays/relationships-browser/useViewToNodesEdges.js +0 -3
- package/dist/overlays/types.d.ts +12 -13
- package/dist/search/Search.js +2 -1
- package/dist/search/components/ElementsColumn.js +5 -3
- package/dist/search/components/PickView.js +1 -1
- package/dist/search/components/SearchByTags.js +21 -44
- package/dist/search/components/SearchInput.js +1 -1
- package/dist/search/components/ViewsColum.js +6 -4
- package/dist/search/components/_shared.css.d.ts +1 -1
- package/dist/search/searchActor.d.ts +3 -66
- package/dist/shadowroot/ShadowRoot.d.ts +5 -7
- package/dist/shadowroot/ShadowRoot.js +8 -6
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/vector.d.ts +83 -21
- package/dist/utils/vector.js +98 -24
- package/dist/utils/view-bounds.d.ts +8 -0
- package/dist/utils/view-bounds.js +58 -0
- package/dist/utils/xyflow.d.ts +52 -8
- package/dist/utils/xyflow.js +31 -11
- package/package.json +26 -24
- package/panda.buildinfo.json +124 -71
- package/styles-min.css +1 -1
- package/styles.css +1 -1
- package/dist/hooks/useCurrentViewId.d.ts +0 -6
- package/dist/likec4diagram/custom/edges/utils.js +0 -23
- package/dist/likec4diagram/state/diagram-machine.d.ts +0 -2590
- package/dist/likec4diagram/state/diagram-machine.js +0 -1180
- package/dist/navigationpanel/editorpanel/LayoutDriftNotification.d.ts +0 -1
- package/dist/navigationpanel/editorpanel/LayoutDriftNotification.js +0 -56
- package/dist/utils/get-view-bounds.d.ts +0 -3
- package/dist/utils/get-view-bounds.js +0 -14
- /package/dist/base/{types.js → Base.js} +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/createReactComponent.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconAlertTriangle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowDownRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowLeft.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconBolt.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconBrowser.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCheck.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronDown.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronLeft.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCopy.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconCylinder.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconDeviceMobile.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconDirectionSignFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconExternalLink.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSymlink.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFocusCentered.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconFolderFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconHelpCircle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconId.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconInfoCircle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignBottom.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignCenter.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignLeft.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignMiddle.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignRight.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutAlignTop.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutBoardSplit.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutCollage.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLayoutDashboard.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLink.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLock.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconLockOpen2.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerPlayFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipBackFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerSkipForwardFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconPlayerStopFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconRectangularPrism.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconReorder.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconRouteOff.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconSearch.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconSelector.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconStack2.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconStarFilled.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconTarget.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconTransform.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconUser.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconX.js +0 -0
- /package/dist/node_modules/.pnpm/{@tabler_icons-react@3.35.0_react@19.1.1 → @tabler_icons-react@3.35.0_react@19.2.0}/node_modules/@tabler/icons-react/dist/esm/icons/IconZoomScan.js +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { nonNullable } from '@likec4/core';
|
|
3
2
|
import { cx } from '@likec4/styles/css';
|
|
4
|
-
import { useDebouncedEffect } from '@react-hookz/web';
|
|
5
3
|
import { EdgeLabelRenderer } from '@xyflow/react';
|
|
6
|
-
import { line, curveCatmullRomOpen } from 'd3-shape';
|
|
7
4
|
import { useState, useRef, useEffect } from 'react';
|
|
8
|
-
import { isTruthy, first, last } from 'remeda';
|
|
9
5
|
import { ZIndexes } from '../../../base/const.js';
|
|
10
6
|
import { useEnabledFeatures } from '../../../context/DiagramFeatures.js';
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
7
|
+
import { useCallbackRef } from '../../../hooks/useCallbackRef.js';
|
|
8
|
+
import '@xstate/react';
|
|
9
|
+
import 'fast-equals';
|
|
10
|
+
import { useDiagram } from '../../../hooks/safeContext.js';
|
|
11
|
+
import { useUpdateEffect } from '../../../hooks/useUpdateEffect.js';
|
|
12
|
+
import { useXYFlow, useXYStoreApi } from '../../../hooks/useXYFlow.js';
|
|
13
|
+
import { isSamePoint } from '../../../utils/xyflow.js';
|
|
14
|
+
import { EdgeDrifts } from './EdgeDrifts.js';
|
|
16
15
|
import { controlDragging, controlPointsContainer, controlPoint } from './edges.css.js';
|
|
17
|
-
import {
|
|
16
|
+
import { useControlPoints } from './useControlPoints.js';
|
|
17
|
+
import { useRelationshipEdgePath } from './useRelationshipEdgePath.js';
|
|
18
18
|
import { memoEdge } from '../../../base-primitives/memoEdge.js';
|
|
19
19
|
import { EdgeContainer } from '../../../base-primitives/edge/EdgeContainer.js';
|
|
20
20
|
import { EdgePath } from '../../../base-primitives/edge/EdgePath.js';
|
|
@@ -22,145 +22,254 @@ import { EdgeLabelContainer } from '../../../base-primitives/edge/EdgeLabelConta
|
|
|
22
22
|
import { EdgeLabel } from '../../../base-primitives/edge/EdgeLabel.js';
|
|
23
23
|
import { EdgeActionButton } from '../../../base-primitives/edge/EdgeActionButton.js';
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const getEdgeCenter = (path) => {
|
|
26
|
+
const dompoint = path.getPointAtLength(path.getTotalLength() * 0.5);
|
|
27
|
+
return {
|
|
28
|
+
x: Math.round(dompoint.x),
|
|
29
|
+
y: Math.round(dompoint.y)
|
|
30
|
+
};
|
|
31
|
+
};
|
|
26
32
|
const RelationshipEdge = memoEdge((props) => {
|
|
27
33
|
const [isControlPointDragging, setIsControlPointDragging] = useState(false);
|
|
28
|
-
const
|
|
34
|
+
const isControlPointDraggingRef = useRef(isControlPointDragging);
|
|
35
|
+
isControlPointDraggingRef.current = isControlPointDragging;
|
|
29
36
|
const xyflow = useXYFlow();
|
|
30
37
|
const diagram = useDiagram();
|
|
31
38
|
const {
|
|
32
39
|
enableNavigateTo,
|
|
33
|
-
|
|
40
|
+
enableReadOnly,
|
|
41
|
+
enableCompareWithLatest
|
|
34
42
|
} = useEnabledFeatures();
|
|
43
|
+
const enabledEditing = !enableReadOnly;
|
|
35
44
|
const {
|
|
36
45
|
id,
|
|
37
|
-
source,
|
|
38
|
-
sourceX,
|
|
39
|
-
sourceY,
|
|
40
|
-
target,
|
|
41
|
-
targetX,
|
|
42
|
-
targetY,
|
|
43
46
|
selected = false,
|
|
44
47
|
data: {
|
|
45
|
-
id: edgeId,
|
|
46
|
-
points,
|
|
47
48
|
hovered = false,
|
|
48
49
|
active = false,
|
|
49
50
|
labelBBox,
|
|
50
51
|
labelXY,
|
|
51
52
|
...data
|
|
52
|
-
}
|
|
53
|
-
style = {}
|
|
53
|
+
}
|
|
54
54
|
} = props;
|
|
55
55
|
const navigateTo = enableNavigateTo ? data.navigateTo : void 0;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
targetCenterPos,
|
|
67
|
-
getNodeIntersectionFromCenterToPoint(targetNode, first(controlPoints) ?? sourceCenterPos, nodeMargin),
|
|
68
|
-
...controlPoints,
|
|
69
|
-
getNodeIntersectionFromCenterToPoint(sourceNode, last(controlPoints) ?? targetCenterPos, nodeMargin),
|
|
70
|
-
sourceCenterPos
|
|
71
|
-
] : [
|
|
72
|
-
sourceCenterPos,
|
|
73
|
-
getNodeIntersectionFromCenterToPoint(sourceNode, first(controlPoints) ?? targetCenterPos, nodeMargin),
|
|
74
|
-
...controlPoints,
|
|
75
|
-
getNodeIntersectionFromCenterToPoint(targetNode, last(controlPoints) ?? sourceCenterPos, nodeMargin),
|
|
76
|
-
targetCenterPos
|
|
77
|
-
];
|
|
78
|
-
edgePath = nonNullable(curve(points2));
|
|
79
|
-
} else {
|
|
80
|
-
edgePath = bezierPath(points);
|
|
81
|
-
}
|
|
56
|
+
const {
|
|
57
|
+
controlPoints,
|
|
58
|
+
setControlPoints,
|
|
59
|
+
insertControlPoint
|
|
60
|
+
} = useControlPoints(props);
|
|
61
|
+
let edgePath = useRelationshipEdgePath({
|
|
62
|
+
props,
|
|
63
|
+
controlPoints,
|
|
64
|
+
isControlPointDragging
|
|
65
|
+
});
|
|
82
66
|
let labelX = labelBBox?.x ?? 0, labelY = labelBBox?.y ?? 0;
|
|
83
67
|
const [labelPos, setLabelPos] = useState({
|
|
84
68
|
x: labelXY?.x ?? labelX,
|
|
85
69
|
y: labelXY?.y ?? labelY
|
|
86
70
|
});
|
|
71
|
+
useUpdateEffect(() => {
|
|
72
|
+
if (isControlPointDraggingRef.current) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const next = {
|
|
76
|
+
x: labelX,
|
|
77
|
+
y: labelY
|
|
78
|
+
};
|
|
79
|
+
setLabelPos((current) => isSamePoint(current, next) ? current : next);
|
|
80
|
+
}, [labelX, labelY]);
|
|
87
81
|
const svgPathRef = useRef(null);
|
|
88
82
|
useEffect(() => {
|
|
89
83
|
const path = svgPathRef.current;
|
|
90
|
-
if (!path) return;
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}, [edgePath]);
|
|
98
|
-
useDebouncedEffect(
|
|
99
|
-
() => {
|
|
100
|
-
if (!labelBBox || labelBBox.x === labelPos.x && labelBBox.y === labelPos.y) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
84
|
+
if (!path || !isControlPointDragging) return;
|
|
85
|
+
const next = getEdgeCenter(path);
|
|
86
|
+
setLabelPos((current) => isSamePoint(current, next) ? current : next);
|
|
87
|
+
}, [edgePath, isControlPointDragging]);
|
|
88
|
+
const updateEdgeData = useCallbackRef((controlPoints2) => {
|
|
89
|
+
const point = svgPathRef.current ? getEdgeCenter(svgPathRef.current) : null;
|
|
90
|
+
if (labelBBox && point) {
|
|
103
91
|
diagram.updateEdgeData(id, {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
controlPoints: controlPoints2,
|
|
93
|
+
labelBBox: {
|
|
94
|
+
...labelBBox,
|
|
95
|
+
...point
|
|
107
96
|
}
|
|
108
97
|
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
98
|
+
} else {
|
|
99
|
+
diagram.updateEdgeData(id, { controlPoints: controlPoints2 });
|
|
100
|
+
}
|
|
101
|
+
diagram.stopEditing(true);
|
|
102
|
+
setIsControlPointDragging(false);
|
|
103
|
+
});
|
|
104
|
+
const onControlPointerStartMove = useCallbackRef(() => {
|
|
105
|
+
diagram.startEditing("edge");
|
|
106
|
+
setIsControlPointDragging(true);
|
|
107
|
+
});
|
|
108
|
+
const onControlPointerCancelMove = useCallbackRef(() => {
|
|
109
|
+
diagram.stopEditing();
|
|
110
|
+
setIsControlPointDragging(false);
|
|
111
|
+
});
|
|
112
|
+
const onControlPointerFinishMove = useCallbackRef((points) => {
|
|
113
|
+
setControlPoints(points);
|
|
114
|
+
requestAnimationFrame(() => {
|
|
115
|
+
updateEdgeData(points);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const onControlPointerDelete = useCallbackRef((points) => {
|
|
119
|
+
diagram.startEditing("edge");
|
|
120
|
+
setIsControlPointDragging(true);
|
|
121
|
+
setControlPoints(points);
|
|
122
|
+
requestAnimationFrame(() => {
|
|
123
|
+
updateEdgeData(points);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
const onEdgePointerDown = useCallbackRef((e) => {
|
|
127
|
+
if (e.pointerType !== "mouse") {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (e.button !== 2) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
e.stopPropagation();
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
diagram.startEditing("edge");
|
|
136
|
+
const newControlPoints = insertControlPoint(
|
|
137
|
+
xyflow.screenToFlowPosition(
|
|
138
|
+
{
|
|
139
|
+
x: e.clientX,
|
|
140
|
+
y: e.clientY
|
|
141
|
+
},
|
|
142
|
+
{ snapToGrid: false }
|
|
143
|
+
)
|
|
144
|
+
);
|
|
145
|
+
diagram.updateEdgeData(id, { controlPoints: newControlPoints });
|
|
146
|
+
diagram.stopEditing(true);
|
|
147
|
+
});
|
|
148
|
+
if (isControlPointDragging && !props.data.hovered) {
|
|
149
|
+
props = {
|
|
150
|
+
...props,
|
|
151
|
+
data: {
|
|
152
|
+
...props.data,
|
|
153
|
+
hovered: true
|
|
154
|
+
}
|
|
155
|
+
};
|
|
117
156
|
}
|
|
157
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
158
|
+
/* @__PURE__ */ jsxs(EdgeContainer, { ...props, className: cx(isControlPointDragging && controlDragging), children: [
|
|
159
|
+
/* @__PURE__ */ jsx(
|
|
160
|
+
EdgePath,
|
|
161
|
+
{
|
|
162
|
+
edgeProps: props,
|
|
163
|
+
svgPath: edgePath,
|
|
164
|
+
ref: svgPathRef,
|
|
165
|
+
isDragging: isControlPointDragging,
|
|
166
|
+
...enabledEditing && {
|
|
167
|
+
onEdgePointerDown
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
enableCompareWithLatest && /* @__PURE__ */ jsx(
|
|
172
|
+
EdgeDrifts,
|
|
173
|
+
{
|
|
174
|
+
edgeProps: props,
|
|
175
|
+
svgPath: edgePath
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
labelBBox && /* @__PURE__ */ jsx(
|
|
179
|
+
EdgeLabelContainer,
|
|
180
|
+
{
|
|
181
|
+
edgeProps: props,
|
|
182
|
+
labelPosition: isControlPointDragging ? labelPos : { x: labelX, y: labelY },
|
|
183
|
+
children: /* @__PURE__ */ jsx(
|
|
184
|
+
EdgeLabel,
|
|
185
|
+
{
|
|
186
|
+
pointerEvents: enabledEditing ? "none" : "all",
|
|
187
|
+
edgeProps: props,
|
|
188
|
+
children: !enabledEditing && navigateTo && /* @__PURE__ */ jsx(
|
|
189
|
+
EdgeActionButton,
|
|
190
|
+
{
|
|
191
|
+
onClick: (e) => {
|
|
192
|
+
e.stopPropagation();
|
|
193
|
+
diagram.navigateTo(navigateTo);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] }),
|
|
202
|
+
enabledEditing && controlPoints.length > 0 && (selected || active || hovered || isControlPointDragging) && /* @__PURE__ */ jsx(
|
|
203
|
+
ControlPoints,
|
|
204
|
+
{
|
|
205
|
+
edgeProps: props,
|
|
206
|
+
controlPoints,
|
|
207
|
+
onMove: setControlPoints,
|
|
208
|
+
onStartMove: onControlPointerStartMove,
|
|
209
|
+
onCancelMove: onControlPointerCancelMove,
|
|
210
|
+
onFinishMove: onControlPointerFinishMove,
|
|
211
|
+
onDelete: onControlPointerDelete,
|
|
212
|
+
zIndex: ZIndexes.Element + 500
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
] });
|
|
216
|
+
});
|
|
217
|
+
RelationshipEdge.displayName = "RelationshipEdge";
|
|
218
|
+
function ControlPoints({
|
|
219
|
+
edgeProps,
|
|
220
|
+
controlPoints,
|
|
221
|
+
onMove,
|
|
222
|
+
onStartMove,
|
|
223
|
+
onCancelMove,
|
|
224
|
+
onFinishMove,
|
|
225
|
+
onDelete,
|
|
226
|
+
zIndex
|
|
227
|
+
}) {
|
|
228
|
+
const xyflowStore = useXYStoreApi();
|
|
229
|
+
const xyflow = useXYFlow();
|
|
230
|
+
const edgeId = edgeProps.data.id;
|
|
118
231
|
const onLmbControlPointerDown = (index, e, domNode) => {
|
|
119
|
-
const { addSelectedEdges } = xyflowStore.getState();
|
|
120
|
-
addSelectedEdges([id]);
|
|
121
|
-
const wasCanceled = diagram.cancelSaveManualLayout();
|
|
122
|
-
e.stopPropagation();
|
|
123
232
|
let hasMoved = false;
|
|
124
233
|
let pointer = { x: e.clientX, y: e.clientY };
|
|
234
|
+
let animationFrameId = null;
|
|
235
|
+
let cp = controlPoints;
|
|
125
236
|
const onPointerMove = (e2) => {
|
|
126
237
|
const clientPoint = {
|
|
127
238
|
x: e2.clientX,
|
|
128
239
|
y: e2.clientY
|
|
129
240
|
};
|
|
130
241
|
if (!isSamePoint(pointer, clientPoint)) {
|
|
131
|
-
setIsControlPointDragging(true);
|
|
132
242
|
if (!hasMoved) {
|
|
133
|
-
diagram.send({ type: "xyflow.edgeEditingStarted", edge: props.data });
|
|
134
243
|
hasMoved = true;
|
|
244
|
+
onStartMove();
|
|
135
245
|
}
|
|
136
246
|
pointer = clientPoint;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
x:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
247
|
+
animationFrameId ??= requestAnimationFrame(() => {
|
|
248
|
+
animationFrameId = null;
|
|
249
|
+
cp = cp.slice();
|
|
250
|
+
const { x, y } = xyflow.screenToFlowPosition(pointer, { snapToGrid: false });
|
|
251
|
+
cp[index] = {
|
|
252
|
+
x: Math.round(x),
|
|
253
|
+
y: Math.round(y)
|
|
254
|
+
};
|
|
255
|
+
onMove(cp);
|
|
145
256
|
});
|
|
146
257
|
}
|
|
147
258
|
e2.stopPropagation();
|
|
148
259
|
};
|
|
149
260
|
const onPointerUp = (e2) => {
|
|
261
|
+
e2.stopPropagation();
|
|
150
262
|
domNode.removeEventListener("pointermove", onPointerMove, {
|
|
151
263
|
capture: true
|
|
152
264
|
});
|
|
265
|
+
domNode.removeEventListener("click", stopAndPrevent, {
|
|
266
|
+
capture: true
|
|
267
|
+
});
|
|
153
268
|
if (hasMoved) {
|
|
154
|
-
|
|
269
|
+
onFinishMove(cp);
|
|
270
|
+
} else {
|
|
271
|
+
onCancelMove();
|
|
155
272
|
}
|
|
156
|
-
if (hasMoved || wasCanceled) {
|
|
157
|
-
diagram.scheduleSaveManualLayout();
|
|
158
|
-
}
|
|
159
|
-
setIsControlPointDragging(false);
|
|
160
|
-
};
|
|
161
|
-
const onClick = (e2) => {
|
|
162
|
-
e2.stopPropagation();
|
|
163
|
-
e2.preventDefault();
|
|
164
273
|
};
|
|
165
274
|
domNode.addEventListener("pointermove", onPointerMove, {
|
|
166
275
|
capture: true
|
|
@@ -169,148 +278,78 @@ const RelationshipEdge = memoEdge((props) => {
|
|
|
169
278
|
once: true,
|
|
170
279
|
capture: true
|
|
171
280
|
});
|
|
172
|
-
domNode.addEventListener("click",
|
|
281
|
+
domNode.addEventListener("click", stopAndPrevent, {
|
|
173
282
|
capture: true,
|
|
174
283
|
once: true
|
|
175
284
|
});
|
|
176
285
|
};
|
|
177
|
-
const onRmbControlPointerDown = (index, e
|
|
286
|
+
const onRmbControlPointerDown = (index, e) => {
|
|
178
287
|
if (controlPoints.length <= 1) {
|
|
179
288
|
return;
|
|
180
289
|
}
|
|
181
|
-
const onPointerUp = (e2) => {
|
|
182
|
-
const newControlPoints = controlPoints.slice();
|
|
183
|
-
newControlPoints.splice(index, 1);
|
|
184
|
-
e2.stopPropagation();
|
|
185
|
-
setTimeout(() => {
|
|
186
|
-
diagram.updateEdgeData(id, { controlPoints: newControlPoints });
|
|
187
|
-
diagram.scheduleSaveManualLayout();
|
|
188
|
-
}, 10);
|
|
189
|
-
};
|
|
190
|
-
domNode.addEventListener("pointerup", onPointerUp, {
|
|
191
|
-
once: true,
|
|
192
|
-
capture: true
|
|
193
|
-
});
|
|
194
290
|
e.stopPropagation();
|
|
291
|
+
e.preventDefault();
|
|
292
|
+
const newControlPoints = controlPoints.slice();
|
|
293
|
+
newControlPoints.splice(index, 1);
|
|
294
|
+
setTimeout(() => {
|
|
295
|
+
onDelete(newControlPoints);
|
|
296
|
+
}, 10);
|
|
195
297
|
};
|
|
196
|
-
const onControlPointerDown = (
|
|
197
|
-
const { domNode } = xyflowStore.getState();
|
|
298
|
+
const onControlPointerDown = useCallbackRef((e) => {
|
|
299
|
+
const { domNode, addSelectedEdges } = xyflowStore.getState();
|
|
198
300
|
if (!domNode || e.pointerType !== "mouse") {
|
|
199
301
|
return;
|
|
200
302
|
}
|
|
303
|
+
const index = parseFloat(e.currentTarget.getAttribute("data-control-point-index") || "");
|
|
304
|
+
if (isNaN(index)) {
|
|
305
|
+
throw new Error("data-control-point-index is not a number");
|
|
306
|
+
}
|
|
201
307
|
switch (e.button) {
|
|
202
|
-
case 0:
|
|
308
|
+
case 0: {
|
|
309
|
+
e.stopPropagation();
|
|
310
|
+
addSelectedEdges([edgeId]);
|
|
203
311
|
onLmbControlPointerDown(index, e, domNode);
|
|
204
312
|
break;
|
|
313
|
+
}
|
|
205
314
|
case 2:
|
|
206
|
-
onRmbControlPointerDown(index, e
|
|
315
|
+
onRmbControlPointerDown(index, e);
|
|
207
316
|
break;
|
|
208
317
|
}
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
];
|
|
223
|
-
let pointer = { x: e.clientX, y: e.clientY };
|
|
224
|
-
const newPoint = vector(xyflow.screenToFlowPosition(pointer, { snapToGrid: false }));
|
|
225
|
-
let insertionIndex = 0;
|
|
226
|
-
let minDistance = Infinity;
|
|
227
|
-
for (let i = 0; i < points2.length - 1; i++) {
|
|
228
|
-
const a = points2[i], b = points2[i + 1], fromCurrentToNext = b.sub(a), fromCurrentToNew = newPoint.sub(a), fromNextToNew = newPoint.sub(b);
|
|
229
|
-
if (fromCurrentToNext.dot(fromCurrentToNew) * fromCurrentToNext.dot(fromNextToNew) < 0) {
|
|
230
|
-
const distanceToEdge = Math.abs(fromCurrentToNext.cross(fromCurrentToNew).abs() / fromCurrentToNext.abs());
|
|
231
|
-
if (distanceToEdge < minDistance) {
|
|
232
|
-
minDistance = distanceToEdge;
|
|
233
|
-
insertionIndex = i;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
const newControlPoints = controlPoints.slice() || [];
|
|
238
|
-
newControlPoints.splice(insertionIndex, 0, newPoint);
|
|
239
|
-
diagram.updateEdgeData(id, { controlPoints: newControlPoints });
|
|
240
|
-
diagram.scheduleSaveManualLayout();
|
|
241
|
-
e.stopPropagation();
|
|
242
|
-
};
|
|
243
|
-
let zIndex = ZIndexes.Edge;
|
|
244
|
-
if (hovered || active) {
|
|
245
|
-
zIndex = ZIndexes.Element + 1;
|
|
246
|
-
}
|
|
247
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
248
|
-
/* @__PURE__ */ jsxs(EdgeContainer, { ...props, className: cx(isControlPointDragging && controlDragging), children: [
|
|
249
|
-
/* @__PURE__ */ jsx(
|
|
250
|
-
EdgePath,
|
|
251
|
-
{
|
|
252
|
-
edgeProps: props,
|
|
253
|
-
svgPath: edgePath,
|
|
254
|
-
ref: svgPathRef,
|
|
255
|
-
...enableEdgeEditing && {
|
|
256
|
-
onEdgePointerDown
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
),
|
|
260
|
-
/* @__PURE__ */ jsx(
|
|
261
|
-
EdgeLabelContainer,
|
|
318
|
+
});
|
|
319
|
+
return /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx(
|
|
320
|
+
EdgeContainer,
|
|
321
|
+
{
|
|
322
|
+
component: "svg",
|
|
323
|
+
className: controlPointsContainer,
|
|
324
|
+
...edgeProps,
|
|
325
|
+
style: {
|
|
326
|
+
...edgeProps.style,
|
|
327
|
+
zIndex
|
|
328
|
+
},
|
|
329
|
+
children: /* @__PURE__ */ jsx(
|
|
330
|
+
"g",
|
|
262
331
|
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
y: labelY,
|
|
267
|
-
translate: isModified ? "translate(-50%, 0)" : void 0
|
|
268
|
-
},
|
|
269
|
-
children: /* @__PURE__ */ jsx(EdgeLabel, { edgeProps: props, children: navigateTo && /* @__PURE__ */ jsx(
|
|
270
|
-
EdgeActionButton,
|
|
332
|
+
onContextMenu: stopAndPrevent,
|
|
333
|
+
children: controlPoints.map((p, i) => /* @__PURE__ */ jsx(
|
|
334
|
+
"circle",
|
|
271
335
|
{
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
336
|
+
"data-control-point-index": i,
|
|
337
|
+
onPointerDownCapture: onControlPointerDown,
|
|
338
|
+
className: cx("nodrag nopan", controlPoint),
|
|
339
|
+
cx: p.x,
|
|
340
|
+
cy: p.y,
|
|
341
|
+
r: 3
|
|
342
|
+
},
|
|
343
|
+
"controlPoints" + edgeId + "#" + i
|
|
344
|
+
))
|
|
278
345
|
}
|
|
279
346
|
)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
style: {
|
|
288
|
-
...style,
|
|
289
|
-
zIndex
|
|
290
|
-
},
|
|
291
|
-
children: /* @__PURE__ */ jsx(
|
|
292
|
-
"g",
|
|
293
|
-
{
|
|
294
|
-
onContextMenu: (e) => {
|
|
295
|
-
e.preventDefault();
|
|
296
|
-
e.stopPropagation();
|
|
297
|
-
},
|
|
298
|
-
children: controlPoints.map((p, i) => /* @__PURE__ */ jsx(
|
|
299
|
-
"circle",
|
|
300
|
-
{
|
|
301
|
-
onPointerDown: (e) => onControlPointerDown(i, e),
|
|
302
|
-
className: cx("nodrag nopan", controlPoint),
|
|
303
|
-
cx: Math.round(p.x),
|
|
304
|
-
cy: Math.round(p.y),
|
|
305
|
-
r: 3
|
|
306
|
-
},
|
|
307
|
-
"controlPoints" + edgeId + "#" + i
|
|
308
|
-
))
|
|
309
|
-
}
|
|
310
|
-
)
|
|
311
|
-
}
|
|
312
|
-
) })
|
|
313
|
-
] });
|
|
314
|
-
});
|
|
347
|
+
}
|
|
348
|
+
) });
|
|
349
|
+
}
|
|
350
|
+
const stopAndPrevent = (e) => {
|
|
351
|
+
e.stopPropagation();
|
|
352
|
+
e.preventDefault();
|
|
353
|
+
};
|
|
315
354
|
|
|
316
355
|
export { RelationshipEdge };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { getSmoothStepPath } from '@xyflow/system';
|
|
3
|
-
import {
|
|
3
|
+
import { useEnabledFeatures } from '../../../context/DiagramFeatures.js';
|
|
4
|
+
import '@xstate/react';
|
|
5
|
+
import 'fast-equals';
|
|
6
|
+
import 'react';
|
|
7
|
+
import { useDiagram } from '../../../hooks/safeContext.js';
|
|
8
|
+
import { EdgeDrifts } from './EdgeDrifts.js';
|
|
4
9
|
import { EdgeContainer } from '../../../base-primitives/edge/EdgeContainer.js';
|
|
5
10
|
import { EdgePath } from '../../../base-primitives/edge/EdgePath.js';
|
|
6
11
|
import { EdgeLabelContainer } from '../../../base-primitives/edge/EdgeLabelContainer.js';
|
|
@@ -9,6 +14,7 @@ import { EdgeActionButton } from '../../../base-primitives/edge/EdgeActionButton
|
|
|
9
14
|
|
|
10
15
|
const LABEL_OFFSET = 16;
|
|
11
16
|
function SequenceStepEdge(props) {
|
|
17
|
+
const { enableNavigateTo, enableCompareWithLatest } = useEnabledFeatures();
|
|
12
18
|
const diagram = useDiagram();
|
|
13
19
|
const { navigateTo } = props.data;
|
|
14
20
|
const isSelfLoop = props.source === props.target;
|
|
@@ -45,6 +51,7 @@ function SequenceStepEdge(props) {
|
|
|
45
51
|
svgPath: path
|
|
46
52
|
}
|
|
47
53
|
),
|
|
54
|
+
enableCompareWithLatest && /* @__PURE__ */ jsx(EdgeDrifts, { edgeProps: props, svgPath: path }),
|
|
48
55
|
/* @__PURE__ */ jsx(
|
|
49
56
|
EdgeLabelContainer,
|
|
50
57
|
{
|
|
@@ -54,7 +61,7 @@ function SequenceStepEdge(props) {
|
|
|
54
61
|
y: props.sourceY + (!isSelfLoop ? LABEL_OFFSET : 0),
|
|
55
62
|
translate: isBack ? "translate(-100%, 0)" : void 0
|
|
56
63
|
},
|
|
57
|
-
children: /* @__PURE__ */ jsx(EdgeLabel, { edgeProps: props, children: navigateTo && /* @__PURE__ */ jsx(
|
|
64
|
+
children: /* @__PURE__ */ jsx(EdgeLabel, { edgeProps: props, children: enableNavigateTo && navigateTo && /* @__PURE__ */ jsx(
|
|
58
65
|
EdgeActionButton,
|
|
59
66
|
{
|
|
60
67
|
onClick: (e) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { css } from '@likec4/styles/css';
|
|
2
2
|
|
|
3
|
-
const isSelected = ".react-flow__edge.selected";
|
|
4
3
|
const controlPointsContainer = css({
|
|
5
4
|
overflow: "visible",
|
|
6
5
|
position: "absolute",
|
|
@@ -20,15 +19,15 @@ const controlPoint = css({
|
|
|
20
19
|
_hover: {
|
|
21
20
|
fillOpacity: 1,
|
|
22
21
|
stroke: "mantine.colors.primary.filledHover",
|
|
23
|
-
strokeWidth:
|
|
22
|
+
strokeWidth: 18,
|
|
24
23
|
transition: "stroke 100ms ease-out, stroke-width 100ms ease-out"
|
|
25
24
|
},
|
|
26
|
-
[`:where(
|
|
25
|
+
[`:where([data-likec4-selected='true'], [data-likec4-hovered='true']) &`]: {
|
|
27
26
|
visibility: "visible",
|
|
28
27
|
transition: "fill-opacity 150ms ease-out, stroke 150ms ease-out, stroke-width 150ms ease-out",
|
|
29
28
|
transitionDelay: "50ms",
|
|
30
29
|
fillOpacity: 1,
|
|
31
|
-
strokeWidth:
|
|
30
|
+
strokeWidth: 12
|
|
32
31
|
}
|
|
33
32
|
});
|
|
34
33
|
const controlDragging = css({
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { XYPosition } from '@xyflow/react';
|
|
2
|
+
import { Types } from '../../types';
|
|
3
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
export declare function useControlPoints({ sourceX, sourceY, targetX, targetY, data, }: Types.EdgeProps<'relationship'>): {
|
|
5
|
+
controlPoints: XYPosition[];
|
|
6
|
+
setControlPoints: Dispatch<SetStateAction<XYPosition[]>>;
|
|
7
|
+
insertControlPoint: ({ x, y }: XYPosition) => XYPosition[];
|
|
8
|
+
};
|