@likec4/diagram 1.42.1 → 1.44.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 +6198 -4860
- package/dist/LikeC4Diagram.d.ts +1 -1
- package/dist/LikeC4Diagram.js +15 -12
- package/dist/LikeC4Diagram.props.d.ts +28 -14
- package/dist/LikeC4ProjectsProvider.js +1 -1
- package/dist/LikeC4View.d.ts +28 -4
- package/dist/LikeC4View.js +28 -17
- package/dist/ReactLikeC4.d.ts +1 -1
- package/dist/ReactLikeC4.js +5 -7
- package/dist/StaticLikeC4Diagram.js +2 -2
- 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/const.d.ts +1 -1
- package/dist/base/const.js +1 -1
- package/dist/base/index.d.ts +6 -2
- package/dist/base/types.d.ts +1 -28
- package/dist/base/updateEdges.js +4 -3
- package/dist/base/updateNodes.js +3 -2
- package/dist/base-primitives/compound/CompoundActionButton.js +1 -1
- package/dist/base-primitives/compound/CompoundDetailsButton.js +1 -1
- 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 +4 -0
- package/dist/base-primitives/edge/EdgeLabel.d.ts +1 -0
- 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 +9 -5
- package/dist/base-primitives/element/ElementActionButtons.d.ts +3 -2
- package/dist/base-primitives/element/ElementActionButtons.js +1 -1
- package/dist/base-primitives/element/ElementDetailsButton.js +2 -5
- package/dist/base-primitives/element/ElementNodeContainer.css.js +15 -27
- 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 +24 -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 +2 -18
- package/dist/context/index.d.ts +1 -1
- package/dist/custom/customNodes.js +3 -2
- package/dist/custom/hooks.d.ts +1 -1
- package/dist/custom/index.d.ts +1 -1
- package/dist/custom/index.js +4 -4
- package/dist/editor/LikeC4EditorContext.d.ts +21 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +2 -1
- 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 +60 -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 +54 -51
- package/dist/likec4diagram/convert-to-xyflow.d.ts +0 -1
- package/dist/likec4diagram/custom/edges/RelationshipEdge.js +249 -220
- package/dist/likec4diagram/custom/edges/SequenceStepEdge.js +7 -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/ElementNodeDrifts.d.ts +4 -0
- package/dist/likec4diagram/custom/nodes/ElementNodeDrifts.js +46 -0
- package/dist/likec4diagram/custom/nodes/SequenceActorNode.js +4 -1
- package/dist/likec4diagram/custom/nodes/nodes.d.ts +9 -1
- package/dist/likec4diagram/custom/nodes/nodes.js +13 -9
- 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 +5 -7
- package/dist/likec4diagram/state/DiagramActorProvider.d.ts +3 -2
- package/dist/likec4diagram/state/DiagramActorProvider.js +96 -70
- package/dist/likec4diagram/state/assign.d.ts +4 -2
- package/dist/likec4diagram/state/assign.js +39 -103
- package/dist/likec4diagram/state/createViewChange.d.ts +3 -0
- package/dist/likec4diagram/state/createViewChange.js +90 -0
- package/dist/likec4diagram/state/diagram-api.d.ts +113 -0
- package/dist/likec4diagram/state/diagram-api.js +134 -0
- package/dist/likec4diagram/state/hotkeyActor.d.ts +7 -0
- package/dist/likec4diagram/state/hotkeyActor.js +17 -1
- package/dist/likec4diagram/state/machine.actions.d.ts +2099 -0
- package/dist/likec4diagram/state/machine.actions.js +735 -0
- package/dist/likec4diagram/state/machine.d.ts +3717 -0
- package/dist/likec4diagram/state/machine.js +141 -0
- package/dist/likec4diagram/state/machine.setup.d.ts +284 -0
- package/dist/likec4diagram/state/machine.setup.js +71 -0
- package/dist/likec4diagram/state/machine.state.initializing.d.ts +183 -0
- package/dist/likec4diagram/state/machine.state.initializing.js +55 -0
- package/dist/likec4diagram/state/machine.state.navigating.d.ts +117 -0
- package/dist/likec4diagram/state/machine.state.navigating.js +45 -0
- package/dist/likec4diagram/state/machine.state.ready.d.ts +3666 -0
- package/dist/likec4diagram/state/machine.state.ready.js +437 -0
- package/dist/likec4diagram/state/syncManualLayoutActor.d.ts +220 -63
- package/dist/likec4diagram/state/syncManualLayoutActor.js +218 -143
- package/dist/likec4diagram/state/types.d.ts +4 -7
- package/dist/likec4diagram/state/utils.d.ts +4 -2
- package/dist/likec4diagram/state/utils.js +4 -1
- package/dist/likec4diagram/types.d.ts +6 -1
- 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.js +10 -12
- package/dist/likec4diagram/useLayoutConstraints.d.ts +10 -5
- package/dist/likec4diagram/useLayoutConstraints.js +225 -54
- package/dist/likec4diagram/xyflow-diagram/diagram-view.d.ts +0 -1
- package/dist/likec4diagram/xyflow-diagram/diagram-view.js +15 -15
- package/dist/navigationpanel/NavigationPanel.js +11 -7
- 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 +11 -7
- package/dist/navigationpanel/actor.js +5 -4
- 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 +19 -16
- 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 +10 -10
- package/dist/navigationpanel/walkthrough/DynamicViewControls.js +31 -14
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.d.ts +2 -1
- package/dist/navigationpanel/walkthrough/WalkthroughPanel.js +66 -49
- 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.js +18 -88
- package/dist/overlays/element-details/MetadataValue.d.ts +9 -0
- package/dist/overlays/element-details/MetadataValue.js +261 -0
- 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 +3 -2
- package/dist/overlays/overlaysActor.d.ts +304 -62
- package/dist/overlays/overlaysActor.js +132 -131
- package/dist/overlays/relationship-details/RelationshipDetails.js +4 -3
- package/dist/overlays/relationship-details/SelectEdge.js +2 -2
- package/dist/overlays/relationship-details/actor.d.ts +14 -2
- package/dist/overlays/relationship-details/actor.js +23 -5
- 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/relationships-browser/RelationshipsBrowser.js +6 -4
- package/dist/overlays/relationships-browser/SelectElement.js +2 -2
- package/dist/overlays/relationships-browser/actor.d.ts +239 -173
- package/dist/overlays/relationships-browser/actor.js +132 -110
- package/dist/overlays/relationships-browser/const.d.ts +3 -3
- package/dist/overlays/relationships-browser/const.js +3 -3
- 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/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/shadowroot/ShadowRoot.js +53 -12
- package/dist/shadowroot/styles.css.d.ts +0 -4
- package/dist/shadowroot/styles.css.js +1 -41
- package/dist/styles.css2.js +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/vector.d.ts +78 -21
- package/dist/utils/vector.js +91 -24
- package/dist/utils/view-bounds.d.ts +8 -0
- package/dist/utils/view-bounds.js +57 -0
- package/dist/utils/xyflow.d.ts +49 -7
- package/dist/utils/xyflow.js +63 -11
- package/package.json +28 -27
- package/panda.buildinfo.json +140 -83
- 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 {
|
|
3
|
+
import { useRafEffect } from '@react-hookz/web';
|
|
5
4
|
import { EdgeLabelRenderer } from '@xyflow/react';
|
|
6
|
-
import {
|
|
7
|
-
import { useState, useRef, useEffect } from 'react';
|
|
8
|
-
import { isTruthy, first, last } from 'remeda';
|
|
5
|
+
import { useState, useRef } from 'react';
|
|
9
6
|
import { ZIndexes } from '../../../base/const.js';
|
|
10
7
|
import { useEnabledFeatures } from '../../../context/DiagramFeatures.js';
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
8
|
+
import { useCallbackRef } from '../../../hooks/useCallbackRef.js';
|
|
9
|
+
import '@xstate/react';
|
|
10
|
+
import 'fast-equals';
|
|
11
|
+
import { useDiagram } from '../../../hooks/safeContext.js';
|
|
12
|
+
import { useUpdateEffect } from '../../../hooks/useUpdateEffect.js';
|
|
13
|
+
import { useXYFlow, useXYStoreApi } from '../../../hooks/useXYFlow.js';
|
|
14
|
+
import { isSamePoint } from '../../../utils/xyflow.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,244 @@ 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 xyflowStore = useXYStoreApi();
|
|
29
34
|
const xyflow = useXYFlow();
|
|
30
35
|
const diagram = useDiagram();
|
|
31
36
|
const {
|
|
32
37
|
enableNavigateTo,
|
|
33
|
-
|
|
38
|
+
enableReadOnly
|
|
34
39
|
} = useEnabledFeatures();
|
|
40
|
+
const enabledEditing = !enableReadOnly;
|
|
35
41
|
const {
|
|
36
42
|
id,
|
|
37
|
-
source,
|
|
38
|
-
sourceX,
|
|
39
|
-
sourceY,
|
|
40
|
-
target,
|
|
41
|
-
targetX,
|
|
42
|
-
targetY,
|
|
43
43
|
selected = false,
|
|
44
44
|
data: {
|
|
45
|
-
id: edgeId,
|
|
46
|
-
points,
|
|
47
45
|
hovered = false,
|
|
48
46
|
active = false,
|
|
49
47
|
labelBBox,
|
|
50
48
|
labelXY,
|
|
51
49
|
...data
|
|
52
|
-
}
|
|
53
|
-
style = {}
|
|
50
|
+
}
|
|
54
51
|
} = props;
|
|
55
52
|
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
|
-
}
|
|
53
|
+
const {
|
|
54
|
+
controlPoints,
|
|
55
|
+
setControlPoints,
|
|
56
|
+
insertControlPoint
|
|
57
|
+
} = useControlPoints(props);
|
|
58
|
+
let edgePath = useRelationshipEdgePath({
|
|
59
|
+
props,
|
|
60
|
+
controlPoints,
|
|
61
|
+
isControlPointDragging
|
|
62
|
+
});
|
|
82
63
|
let labelX = labelBBox?.x ?? 0, labelY = labelBBox?.y ?? 0;
|
|
83
64
|
const [labelPos, setLabelPos] = useState({
|
|
84
65
|
x: labelXY?.x ?? labelX,
|
|
85
66
|
y: labelXY?.y ?? labelY
|
|
86
67
|
});
|
|
68
|
+
useUpdateEffect(() => {
|
|
69
|
+
setLabelPos({
|
|
70
|
+
x: labelX,
|
|
71
|
+
y: labelY
|
|
72
|
+
});
|
|
73
|
+
}, [labelX, labelY]);
|
|
87
74
|
const svgPathRef = useRef(null);
|
|
88
|
-
|
|
75
|
+
useRafEffect(() => {
|
|
89
76
|
const path = svgPathRef.current;
|
|
90
|
-
if (!path) return;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
y: roundDpr(dompoint.y)
|
|
95
|
-
};
|
|
96
|
-
setLabelPos((current) => isSamePoint(current, point) ? current : point);
|
|
97
|
-
}, [edgePath]);
|
|
98
|
-
useDebouncedEffect(
|
|
99
|
-
() => {
|
|
100
|
-
if (!labelBBox || labelBBox.x === labelPos.x && labelBBox.y === labelPos.y) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
diagram.updateEdgeData(id, {
|
|
104
|
-
labelXY: {
|
|
105
|
-
x: labelPos.x,
|
|
106
|
-
y: labelPos.y
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
[labelPos],
|
|
111
|
-
50,
|
|
112
|
-
300
|
|
113
|
-
);
|
|
114
|
-
if (isModified || isControlPointDragging) {
|
|
77
|
+
if (!path || !isControlPointDragging) return;
|
|
78
|
+
setLabelPos(getEdgeCenter(path));
|
|
79
|
+
}, [edgePath, isControlPointDragging]);
|
|
80
|
+
if (isControlPointDragging) {
|
|
115
81
|
labelX = labelPos.x;
|
|
116
82
|
labelY = labelPos.y;
|
|
117
83
|
}
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
84
|
+
const updateEdgeData = useCallbackRef((controlPoints2) => {
|
|
85
|
+
const point = svgPathRef.current ? getEdgeCenter(svgPathRef.current) : null;
|
|
86
|
+
if (labelBBox && point) {
|
|
87
|
+
diagram.updateEdgeData(id, {
|
|
88
|
+
controlPoints: controlPoints2,
|
|
89
|
+
labelBBox: {
|
|
90
|
+
...labelBBox,
|
|
91
|
+
...point
|
|
92
|
+
},
|
|
93
|
+
labelXY: point
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
diagram.updateEdgeData(id, { controlPoints: controlPoints2 });
|
|
97
|
+
}
|
|
98
|
+
diagram.stopEditing(true);
|
|
99
|
+
setIsControlPointDragging(false);
|
|
100
|
+
});
|
|
101
|
+
const onControlPointerStartMove = useCallbackRef(() => {
|
|
102
|
+
diagram.startEditing("edge");
|
|
103
|
+
setIsControlPointDragging(true);
|
|
104
|
+
});
|
|
105
|
+
const onControlPointerCancelMove = useCallbackRef(() => {
|
|
106
|
+
diagram.stopEditing();
|
|
107
|
+
setIsControlPointDragging(false);
|
|
108
|
+
});
|
|
109
|
+
const onControlPointerFinishMove = useCallbackRef((points) => {
|
|
110
|
+
setControlPoints(points);
|
|
111
|
+
requestAnimationFrame(() => {
|
|
112
|
+
updateEdgeData(points);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
const onControlPointerDelete = useCallbackRef((points) => {
|
|
116
|
+
diagram.startEditing("edge");
|
|
117
|
+
setIsControlPointDragging(true);
|
|
118
|
+
setControlPoints(points);
|
|
119
|
+
requestAnimationFrame(() => {
|
|
120
|
+
updateEdgeData(points);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
const onEdgePointerDown = useCallbackRef((e) => {
|
|
124
|
+
if (e.pointerType !== "mouse") {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (e.button !== 2) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
122
130
|
e.stopPropagation();
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
diagram.startEditing("edge");
|
|
133
|
+
const newControlPoints = insertControlPoint(
|
|
134
|
+
xyflow.screenToFlowPosition(
|
|
135
|
+
{
|
|
136
|
+
x: e.clientX,
|
|
137
|
+
y: e.clientY
|
|
138
|
+
},
|
|
139
|
+
{ snapToGrid: false }
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
diagram.updateEdgeData(id, { controlPoints: newControlPoints });
|
|
143
|
+
diagram.stopEditing(true);
|
|
144
|
+
});
|
|
145
|
+
if (isControlPointDragging && !props.data.hovered) {
|
|
146
|
+
props = {
|
|
147
|
+
...props,
|
|
148
|
+
data: {
|
|
149
|
+
...props.data,
|
|
150
|
+
hovered: true
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
+
/* @__PURE__ */ jsxs(EdgeContainer, { ...props, className: cx(isControlPointDragging && controlDragging), children: [
|
|
156
|
+
/* @__PURE__ */ jsx(
|
|
157
|
+
EdgePath,
|
|
158
|
+
{
|
|
159
|
+
edgeProps: props,
|
|
160
|
+
svgPath: edgePath,
|
|
161
|
+
ref: svgPathRef,
|
|
162
|
+
isDragging: isControlPointDragging,
|
|
163
|
+
...enabledEditing && {
|
|
164
|
+
onEdgePointerDown
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
labelBBox && /* @__PURE__ */ jsx(
|
|
169
|
+
EdgeLabelContainer,
|
|
170
|
+
{
|
|
171
|
+
edgeProps: props,
|
|
172
|
+
labelPosition: { x: labelX, y: labelY },
|
|
173
|
+
children: /* @__PURE__ */ jsx(
|
|
174
|
+
EdgeLabel,
|
|
175
|
+
{
|
|
176
|
+
pointerEvents: enabledEditing ? "none" : "all",
|
|
177
|
+
edgeProps: props,
|
|
178
|
+
children: !enabledEditing && navigateTo && /* @__PURE__ */ jsx(
|
|
179
|
+
EdgeActionButton,
|
|
180
|
+
{
|
|
181
|
+
onClick: (e) => {
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
diagram.navigateTo(navigateTo);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
] }),
|
|
192
|
+
enabledEditing && controlPoints.length > 0 && (selected || active || hovered || isControlPointDragging) && /* @__PURE__ */ jsx(
|
|
193
|
+
ControlPoints,
|
|
194
|
+
{
|
|
195
|
+
edgeProps: props,
|
|
196
|
+
controlPoints,
|
|
197
|
+
onMove: setControlPoints,
|
|
198
|
+
onStartMove: onControlPointerStartMove,
|
|
199
|
+
onCancelMove: onControlPointerCancelMove,
|
|
200
|
+
onFinishMove: onControlPointerFinishMove,
|
|
201
|
+
onDelete: onControlPointerDelete,
|
|
202
|
+
zIndex: ZIndexes.Element + 500
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] });
|
|
206
|
+
});
|
|
207
|
+
RelationshipEdge.displayName = "RelationshipEdge";
|
|
208
|
+
function ControlPoints({
|
|
209
|
+
edgeProps,
|
|
210
|
+
controlPoints,
|
|
211
|
+
onMove,
|
|
212
|
+
onStartMove,
|
|
213
|
+
onCancelMove,
|
|
214
|
+
onFinishMove,
|
|
215
|
+
onDelete,
|
|
216
|
+
zIndex
|
|
217
|
+
}) {
|
|
218
|
+
const xyflowStore = useXYStoreApi();
|
|
219
|
+
const xyflow = useXYFlow();
|
|
220
|
+
const edgeId = edgeProps.data.id;
|
|
221
|
+
const onLmbControlPointerDown = (index, e, domNode) => {
|
|
123
222
|
let hasMoved = false;
|
|
124
223
|
let pointer = { x: e.clientX, y: e.clientY };
|
|
224
|
+
let animationFrameId = null;
|
|
225
|
+
let cp = controlPoints;
|
|
125
226
|
const onPointerMove = (e2) => {
|
|
126
227
|
const clientPoint = {
|
|
127
228
|
x: e2.clientX,
|
|
128
229
|
y: e2.clientY
|
|
129
230
|
};
|
|
130
231
|
if (!isSamePoint(pointer, clientPoint)) {
|
|
131
|
-
setIsControlPointDragging(true);
|
|
132
232
|
if (!hasMoved) {
|
|
133
|
-
diagram.send({ type: "xyflow.edgeEditingStarted", edge: props.data });
|
|
134
233
|
hasMoved = true;
|
|
234
|
+
onStartMove();
|
|
135
235
|
}
|
|
136
236
|
pointer = clientPoint;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
x:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
237
|
+
animationFrameId ??= requestAnimationFrame(() => {
|
|
238
|
+
animationFrameId = null;
|
|
239
|
+
cp = cp.slice();
|
|
240
|
+
const { x, y } = xyflow.screenToFlowPosition(pointer, { snapToGrid: false });
|
|
241
|
+
cp[index] = {
|
|
242
|
+
x: Math.round(x),
|
|
243
|
+
y: Math.round(y)
|
|
244
|
+
};
|
|
245
|
+
onMove(cp);
|
|
145
246
|
});
|
|
146
247
|
}
|
|
147
248
|
e2.stopPropagation();
|
|
148
249
|
};
|
|
149
250
|
const onPointerUp = (e2) => {
|
|
251
|
+
e2.stopPropagation();
|
|
150
252
|
domNode.removeEventListener("pointermove", onPointerMove, {
|
|
151
253
|
capture: true
|
|
152
254
|
});
|
|
255
|
+
domNode.removeEventListener("click", stopAndPrevent, {
|
|
256
|
+
capture: true
|
|
257
|
+
});
|
|
153
258
|
if (hasMoved) {
|
|
154
|
-
|
|
259
|
+
onFinishMove(cp);
|
|
260
|
+
} else {
|
|
261
|
+
onCancelMove();
|
|
155
262
|
}
|
|
156
|
-
if (hasMoved || wasCanceled) {
|
|
157
|
-
diagram.scheduleSaveManualLayout();
|
|
158
|
-
}
|
|
159
|
-
setIsControlPointDragging(false);
|
|
160
|
-
};
|
|
161
|
-
const onClick = (e2) => {
|
|
162
|
-
e2.stopPropagation();
|
|
163
|
-
e2.preventDefault();
|
|
164
263
|
};
|
|
165
264
|
domNode.addEventListener("pointermove", onPointerMove, {
|
|
166
265
|
capture: true
|
|
@@ -169,148 +268,78 @@ const RelationshipEdge = memoEdge((props) => {
|
|
|
169
268
|
once: true,
|
|
170
269
|
capture: true
|
|
171
270
|
});
|
|
172
|
-
domNode.addEventListener("click",
|
|
271
|
+
domNode.addEventListener("click", stopAndPrevent, {
|
|
173
272
|
capture: true,
|
|
174
273
|
once: true
|
|
175
274
|
});
|
|
176
275
|
};
|
|
177
|
-
const onRmbControlPointerDown = (index, e
|
|
276
|
+
const onRmbControlPointerDown = (index, e) => {
|
|
178
277
|
if (controlPoints.length <= 1) {
|
|
179
278
|
return;
|
|
180
279
|
}
|
|
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
280
|
e.stopPropagation();
|
|
281
|
+
e.preventDefault();
|
|
282
|
+
const newControlPoints = controlPoints.slice();
|
|
283
|
+
newControlPoints.splice(index, 1);
|
|
284
|
+
setTimeout(() => {
|
|
285
|
+
onDelete(newControlPoints);
|
|
286
|
+
}, 10);
|
|
195
287
|
};
|
|
196
|
-
const onControlPointerDown = (
|
|
197
|
-
const { domNode } = xyflowStore.getState();
|
|
288
|
+
const onControlPointerDown = useCallbackRef((e) => {
|
|
289
|
+
const { domNode, addSelectedEdges } = xyflowStore.getState();
|
|
198
290
|
if (!domNode || e.pointerType !== "mouse") {
|
|
199
291
|
return;
|
|
200
292
|
}
|
|
293
|
+
const index = parseFloat(e.currentTarget.getAttribute("data-control-point-index") || "");
|
|
294
|
+
if (isNaN(index)) {
|
|
295
|
+
throw new Error("data-control-point-index is not a number");
|
|
296
|
+
}
|
|
201
297
|
switch (e.button) {
|
|
202
|
-
case 0:
|
|
298
|
+
case 0: {
|
|
299
|
+
e.stopPropagation();
|
|
300
|
+
addSelectedEdges([edgeId]);
|
|
203
301
|
onLmbControlPointerDown(index, e, domNode);
|
|
204
302
|
break;
|
|
303
|
+
}
|
|
205
304
|
case 2:
|
|
206
|
-
onRmbControlPointerDown(index, e
|
|
305
|
+
onRmbControlPointerDown(index, e);
|
|
207
306
|
break;
|
|
208
307
|
}
|
|
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,
|
|
308
|
+
});
|
|
309
|
+
return /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx(
|
|
310
|
+
EdgeContainer,
|
|
311
|
+
{
|
|
312
|
+
component: "svg",
|
|
313
|
+
className: controlPointsContainer,
|
|
314
|
+
...edgeProps,
|
|
315
|
+
style: {
|
|
316
|
+
...edgeProps.style,
|
|
317
|
+
zIndex
|
|
318
|
+
},
|
|
319
|
+
children: /* @__PURE__ */ jsx(
|
|
320
|
+
"g",
|
|
262
321
|
{
|
|
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,
|
|
322
|
+
onContextMenu: stopAndPrevent,
|
|
323
|
+
children: controlPoints.map((p, i) => /* @__PURE__ */ jsx(
|
|
324
|
+
"circle",
|
|
271
325
|
{
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
326
|
+
"data-control-point-index": i,
|
|
327
|
+
onPointerDownCapture: onControlPointerDown,
|
|
328
|
+
className: cx("nodrag nopan", controlPoint),
|
|
329
|
+
cx: p.x,
|
|
330
|
+
cy: p.y,
|
|
331
|
+
r: 3
|
|
332
|
+
},
|
|
333
|
+
"controlPoints" + edgeId + "#" + i
|
|
334
|
+
))
|
|
278
335
|
}
|
|
279
336
|
)
|
|
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
|
-
});
|
|
337
|
+
}
|
|
338
|
+
) });
|
|
339
|
+
}
|
|
340
|
+
const stopAndPrevent = (e) => {
|
|
341
|
+
e.stopPropagation();
|
|
342
|
+
e.preventDefault();
|
|
343
|
+
};
|
|
315
344
|
|
|
316
345
|
export { RelationshipEdge };
|
|
@@ -1,6 +1,10 @@
|
|
|
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';
|
|
4
8
|
import { EdgeContainer } from '../../../base-primitives/edge/EdgeContainer.js';
|
|
5
9
|
import { EdgePath } from '../../../base-primitives/edge/EdgePath.js';
|
|
6
10
|
import { EdgeLabelContainer } from '../../../base-primitives/edge/EdgeLabelContainer.js';
|
|
@@ -9,6 +13,7 @@ import { EdgeActionButton } from '../../../base-primitives/edge/EdgeActionButton
|
|
|
9
13
|
|
|
10
14
|
const LABEL_OFFSET = 16;
|
|
11
15
|
function SequenceStepEdge(props) {
|
|
16
|
+
const { enableNavigateTo } = useEnabledFeatures();
|
|
12
17
|
const diagram = useDiagram();
|
|
13
18
|
const { navigateTo } = props.data;
|
|
14
19
|
const isSelfLoop = props.source === props.target;
|
|
@@ -54,7 +59,7 @@ function SequenceStepEdge(props) {
|
|
|
54
59
|
y: props.sourceY + (!isSelfLoop ? LABEL_OFFSET : 0),
|
|
55
60
|
translate: isBack ? "translate(-100%, 0)" : void 0
|
|
56
61
|
},
|
|
57
|
-
children: /* @__PURE__ */ jsx(EdgeLabel, { edgeProps: props, children: navigateTo && /* @__PURE__ */ jsx(
|
|
62
|
+
children: /* @__PURE__ */ jsx(EdgeLabel, { edgeProps: props, children: enableNavigateTo && navigateTo && /* @__PURE__ */ jsx(
|
|
58
63
|
EdgeActionButton,
|
|
59
64
|
{
|
|
60
65
|
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
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { deepEqual } from 'fast-equals';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useCallbackRef } from '../../../hooks/useCallbackRef.js';
|
|
4
|
+
import { useUpdateEffect } from '../../../hooks/useUpdateEffect.js';
|
|
5
|
+
import { vector } from '../../../utils/vector.js';
|
|
6
|
+
import { bezierControlPoints } from '../../../utils/xyflow.js';
|
|
7
|
+
|
|
8
|
+
function useControlPoints({
|
|
9
|
+
sourceX,
|
|
10
|
+
sourceY,
|
|
11
|
+
targetX,
|
|
12
|
+
targetY,
|
|
13
|
+
data
|
|
14
|
+
}) {
|
|
15
|
+
const [controlPoints, setControlPoints] = useState(
|
|
16
|
+
() => data.controlPoints ?? bezierControlPoints(data.points)
|
|
17
|
+
);
|
|
18
|
+
useUpdateEffect(() => {
|
|
19
|
+
const next = data.controlPoints ?? bezierControlPoints(data.points);
|
|
20
|
+
setControlPoints((prev) => deepEqual(prev, next) ? prev : next);
|
|
21
|
+
}, [
|
|
22
|
+
data.controlPoints?.map((p) => `${p.x},${p.y}`).join("|") ?? "",
|
|
23
|
+
data.points.map((p) => `${p[0]},${p[1]}`).join("|")
|
|
24
|
+
]);
|
|
25
|
+
const insertControlPoint = useCallbackRef(({ x, y }) => {
|
|
26
|
+
const sourceV = vector(sourceX, sourceY);
|
|
27
|
+
const targetV = vector(targetX, targetY);
|
|
28
|
+
const points = [
|
|
29
|
+
data.dir === "back" ? targetV : sourceV,
|
|
30
|
+
...controlPoints.map(vector) || [],
|
|
31
|
+
data.dir === "back" ? sourceV : targetV
|
|
32
|
+
];
|
|
33
|
+
const newPointV = vector(Math.round(x), Math.round(y));
|
|
34
|
+
let insertionIndex = 0;
|
|
35
|
+
let minDistance = Infinity;
|
|
36
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
37
|
+
const a = points[i], b = points[i + 1], fromCurrentToNext = b.subtract(a), fromCurrentToNew = newPointV.subtract(a), fromNextToNew = newPointV.subtract(b);
|
|
38
|
+
if (fromCurrentToNext.dot(fromCurrentToNew) * fromCurrentToNext.dot(fromNextToNew) < 0) {
|
|
39
|
+
const distanceToEdge = Math.abs(fromCurrentToNext.cross(fromCurrentToNew).length() / fromCurrentToNext.length());
|
|
40
|
+
if (distanceToEdge < minDistance) {
|
|
41
|
+
minDistance = distanceToEdge;
|
|
42
|
+
insertionIndex = i;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const newControlPoints = controlPoints.slice();
|
|
47
|
+
newControlPoints.splice(insertionIndex, 0, { x: newPointV.x, y: newPointV.y });
|
|
48
|
+
setControlPoints(newControlPoints);
|
|
49
|
+
return newControlPoints;
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
controlPoints,
|
|
53
|
+
setControlPoints,
|
|
54
|
+
insertControlPoint
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { useControlPoints };
|