@emuanalytics/flow-rdf-ui 4.2.0 → 4.3.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/README.md +58 -0
- package/THIRD_PARTY_NOTICES.md +220 -0
- package/dist/components/alert/alert.component.mjs +3 -0
- package/dist/components/animation/animation.component.mjs +1 -0
- package/dist/components/autocomplete/autocomplete.component.mjs +38 -14
- package/dist/components/avatar/avatar.component.mjs +3 -0
- package/dist/components/badge/badge.component.mjs +1 -0
- package/dist/components/base-control/base-control.component.mjs +3 -0
- package/dist/components/breadcrumb/breadcrumb.component.mjs +3 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.component.mjs +1 -0
- package/dist/components/busy-overlay/busy-overlay.component.mjs +3 -0
- package/dist/components/button/button.component.mjs +4 -0
- package/dist/components/button-group/button-group.component.mjs +1 -0
- package/dist/components/calendar/calendar.component.mjs +6 -0
- package/dist/components/card/card.component.mjs +1 -0
- package/dist/components/carousel/carousel.component.mjs +3 -0
- package/dist/components/carousel-item/carousel-item.component.mjs +1 -0
- package/dist/components/chart/chart.component.mjs +1 -0
- package/dist/components/chart/chartjs-plugins/luxon.adapter.mjs +78 -0
- package/dist/components/chart/chartjs-support.mjs +2 -0
- package/dist/components/checkbox/checkbox.component.mjs +3 -0
- package/dist/components/checkbox-group/checkbox-group.component.mjs +3 -0
- package/dist/components/color-mapper/color-mapper.component.mjs +21 -0
- package/dist/components/color-picker/color-picker.component.mjs +8 -0
- package/dist/components/color-stop/color-stop.component.mjs +17 -0
- package/dist/components/date-time-picker/date-time-picker.component.mjs +6 -0
- package/dist/components/details/details.component.mjs +3 -0
- package/dist/components/diagram/diagram-panel.styles.mjs +44 -0
- package/dist/components/diagram/diagram-tokens.styles.mjs +148 -0
- package/dist/components/diagram/diagram.component.mjs +355 -0
- package/dist/components/diagram/diagram.mjs +5 -0
- package/dist/components/diagram/diagram.styles.mjs +95 -0
- package/dist/components/diagram-background/diagram-background.component.mjs +163 -0
- package/dist/components/diagram-background/diagram-background.mjs +5 -0
- package/dist/components/diagram-background/diagram-background.styles.mjs +58 -0
- package/dist/components/diagram-base-edge/diagram-base-edge.component.mjs +326 -0
- package/dist/components/diagram-base-edge/diagram-base-edge.mjs +5 -0
- package/dist/components/diagram-base-edge/diagram-base-edge.styles.mjs +147 -0
- package/dist/components/diagram-base-node/diagram-base-node.component.mjs +84 -0
- package/dist/components/diagram-base-node/diagram-base-node.mjs +5 -0
- package/dist/components/diagram-base-node/diagram-base-node.styles.mjs +37 -0
- package/dist/components/diagram-edge/diagram-edge.component.mjs +56 -0
- package/dist/components/diagram-edge/diagram-edge.mjs +5 -0
- package/dist/components/diagram-edge/diagram-edge.styles.mjs +37 -0
- package/dist/components/diagram-edge-label/diagram-edge-label.component.mjs +202 -0
- package/dist/components/diagram-edge-label/diagram-edge-label.mjs +5 -0
- package/dist/components/diagram-edge-label/diagram-edge-label.styles.mjs +54 -0
- package/dist/components/diagram-marker/diagram-marker.component.mjs +84 -0
- package/dist/components/diagram-marker/diagram-marker.mjs +5 -0
- package/dist/components/diagram-marker/diagram-marker.styles.mjs +9 -0
- package/dist/components/diagram-minimap/diagram-minimap.component.mjs +298 -0
- package/dist/components/diagram-minimap/diagram-minimap.mjs +5 -0
- package/dist/components/diagram-minimap/diagram-minimap.styles.mjs +83 -0
- package/dist/components/diagram-node/diagram-node-template.styles.mjs +36 -0
- package/dist/components/diagram-node/diagram-node.component.mjs +183 -0
- package/dist/components/diagram-node/diagram-node.mjs +6 -0
- package/dist/components/diagram-node/diagram-node.styles.mjs +29 -0
- package/dist/components/diagram-palette-item/diagram-palette-item.component.mjs +168 -0
- package/dist/components/diagram-palette-item/diagram-palette-item.mjs +5 -0
- package/dist/components/diagram-palette-item/diagram-palette-item.styles.mjs +20 -0
- package/dist/components/diagram-palette-item-preview/diagram-palette-item-preview.component.mjs +245 -0
- package/dist/components/diagram-palette-item-preview/diagram-palette-item-preview.mjs +6 -0
- package/dist/components/diagram-palette-item-preview/diagram-palette-item-preview.styles.mjs +41 -0
- package/dist/components/diagram-port/diagram-port.component.mjs +273 -0
- package/dist/components/diagram-port/diagram-port.mjs +5 -0
- package/dist/components/diagram-port/diagram-port.styles.mjs +116 -0
- package/dist/components/diagram-resize-adornment/diagram-resize-adornment.component.mjs +124 -0
- package/dist/components/diagram-resize-adornment/diagram-resize-adornment.mjs +5 -0
- package/dist/components/diagram-resize-adornment/diagram-resize-adornment.styles.mjs +136 -0
- package/dist/components/diagram-rotate-adornment/diagram-rotate-adornment.component.mjs +125 -0
- package/dist/components/diagram-rotate-adornment/diagram-rotate-adornment.mjs +5 -0
- package/dist/components/diagram-rotate-adornment/diagram-rotate-adornment.styles.mjs +65 -0
- package/dist/components/diagram-zoom-controls/diagram-zoom-controls.component.mjs +158 -0
- package/dist/components/diagram-zoom-controls/diagram-zoom-controls.mjs +5 -0
- package/dist/components/diagram-zoom-controls/diagram-zoom-controls.styles.mjs +66 -0
- package/dist/components/dialog/dialog.component.mjs +4 -0
- package/dist/components/divider/divider.component.mjs +1 -0
- package/dist/components/drawer/drawer.component.mjs +3 -0
- package/dist/components/dropdown/dropdown.component.mjs +2 -1
- package/dist/components/form-group/form-group.component.mjs +1 -0
- package/dist/components/gauge/gauge.component.mjs +6 -0
- package/dist/components/icon/icon.component.mjs +1 -0
- package/dist/components/icon/library.system.mjs +2 -0
- package/dist/components/icon-button/icon-button.component.mjs +5 -0
- package/dist/components/input/input.component.mjs +5 -0
- package/dist/components/list/list.component.mjs +1 -0
- package/dist/components/list-item/list-item.component.mjs +17 -0
- package/dist/components/map/map.component.mjs +3 -0
- package/dist/components/map/map.styles.mjs +10 -0
- package/dist/components/menu/menu.component.mjs +1 -0
- package/dist/components/menu-item/menu-item.component.mjs +3 -0
- package/dist/components/menu-label/menu-label.component.mjs +1 -0
- package/dist/components/mutation-observer/mutation-observer.component.mjs +1 -0
- package/dist/components/option/option.component.mjs +2 -1
- package/dist/components/panel/panel.component.mjs +85 -1
- package/dist/components/panel/panel.styles.mjs +29 -0
- package/dist/components/panel-header/panel-header.component.mjs +3 -0
- package/dist/components/popup/popup.component.mjs +1 -0
- package/dist/components/progress-bar/progress-bar.component.mjs +1 -0
- package/dist/components/progress-ring/progress-ring.component.mjs +1 -0
- package/dist/components/query-builder/query-builder.component.mjs +27 -0
- package/dist/components/radio/radio.component.mjs +3 -0
- package/dist/components/radio-group/radio-group.component.mjs +3 -0
- package/dist/components/range/range.component.mjs +9 -0
- package/dist/components/resize-observer/resize-observer.component.mjs +1 -0
- package/dist/components/scroll-view/scroll-view.component.mjs +1 -0
- package/dist/components/select/select.component.mjs +3 -5
- package/dist/components/split-view/split-view-layout-registry.mjs +44 -0
- package/dist/components/split-view/split-view-layout.mjs +607 -0
- package/dist/components/split-view/split-view.component.mjs +502 -468
- package/dist/components/split-view/split-view.styles.mjs +25 -0
- package/dist/components/split-view-divider/split-view-divider.component.mjs +2 -53
- package/dist/components/split-view-divider/split-view-divider.styles.mjs +28 -16
- package/dist/components/split-view-pane/split-view-pane.component.mjs +197 -18
- package/dist/components/split-view-pane/split-view-pane.styles.mjs +52 -0
- package/dist/components/split-view-toggle-button/split-view-toggle-button.component.mjs +5 -0
- package/dist/components/stepper/stepper.component.mjs +1 -0
- package/dist/components/stepper-panel/stepper-panel.component.mjs +1 -0
- package/dist/components/switch/switch.component.mjs +3 -0
- package/dist/components/tab/tab.component.mjs +4 -0
- package/dist/components/tab-group/tab-group.component.mjs +176 -6
- package/dist/components/tab-group/tab-group.styles.mjs +44 -0
- package/dist/components/tab-panel/tab-panel.component.mjs +1 -0
- package/dist/components/tag/tag.component.mjs +2 -1
- package/dist/components/textarea/textarea.component.mjs +1 -0
- package/dist/components/timer/ticker.mjs +7 -0
- package/dist/components/timer/timer.component.mjs +44 -3
- package/dist/components/timer/timer.styles.mjs +6 -2
- package/dist/components/tool-button/tool-button.component.mjs +4 -0
- package/dist/components/tool-button-group/tool-button-group.component.mjs +3 -0
- package/dist/components/tooltip/tooltip.component.mjs +3 -0
- package/dist/components/tree/tree.component.mjs +1 -0
- package/dist/components/tree-item/tree-item.component.mjs +5 -0
- package/dist/components/visually-hidden/visually-hidden.component.mjs +1 -0
- package/dist/custom-elements.json +11803 -5676
- package/dist/diagram/api/diagram-api-base.mjs +16 -0
- package/dist/diagram/api/diagram-api.mjs +399 -0
- package/dist/diagram/api/diagram-clipboard-api.mjs +52 -0
- package/dist/diagram/api/diagram-groups-api.mjs +46 -0
- package/dist/diagram/api/diagram-model-api.mjs +447 -0
- package/dist/diagram/api/diagram-nodes-api.mjs +61 -0
- package/dist/diagram/api/diagram-selection-api.mjs +56 -0
- package/dist/diagram/api/diagram-viewport-api.mjs +169 -0
- package/dist/diagram/api/emit-with-measurement-option.mjs +21 -0
- package/dist/diagram/input/box-selection-controller.mjs +104 -0
- package/dist/diagram/input/context-menu-controller.mjs +196 -0
- package/dist/diagram/input/cursor-position-tracker-controller.mjs +18 -0
- package/dist/diagram/input/input-controller.mjs +31 -0
- package/dist/diagram/input/keyboard-actions/moving-action.mjs +27 -0
- package/dist/diagram/input/keyboard-actions/panning-action.mjs +27 -0
- package/dist/diagram/input/keyboard-actions/paste-action.mjs +17 -0
- package/dist/diagram/input/keyboard-actions/zoom-action.mjs +30 -0
- package/dist/diagram/input/keyboard-inputs-controller.mjs +121 -0
- package/dist/diagram/input/linking-controller.mjs +127 -0
- package/dist/diagram/input/linking-events.mjs +61 -0
- package/dist/diagram/input/manual-linking.mjs +101 -0
- package/dist/diagram/input/mobile-box-selection-controller.mjs +133 -0
- package/dist/diagram/input/mobile-panning-controller.mjs +114 -0
- package/dist/diagram/input/mobile-zooming-controller.mjs +110 -0
- package/dist/diagram/input/object-selection-controller.mjs +152 -0
- package/dist/diagram/input/palette-drop-controller.mjs +92 -0
- package/dist/diagram/input/panning-controller.mjs +147 -0
- package/dist/diagram/input/pointer-move-selection-controller.mjs +191 -0
- package/dist/diagram/input/relinking-gesture.mjs +182 -0
- package/dist/diagram/input/resize-controller.mjs +122 -0
- package/dist/diagram/input/rotate-controller.mjs +126 -0
- package/dist/diagram/input/zooming-wheel-controller.mjs +55 -0
- package/dist/diagram/minimap/minimap-calculations.mjs +83 -0
- package/dist/diagram/minimap/minimap-navigation-controller.mjs +150 -0
- package/dist/diagram/minimap/minimap-node-cache.mjs +19 -0
- package/dist/diagram/minimap/minimap-strategies.mjs +44 -0
- package/dist/diagram/model/diagram-model-adapter.mjs +97 -0
- package/dist/diagram/model/initialize-model.mjs +31 -0
- package/dist/diagram/model/strip-runtime-properties.mjs +30 -0
- package/dist/diagram/runtime/attribute-converters.mjs +11 -0
- package/dist/diagram/runtime/batched-resize-observer.mjs +168 -0
- package/dist/diagram/runtime/box-selection-provider.mjs +9 -0
- package/dist/diagram/runtime/context.mjs +132 -0
- package/dist/diagram/runtime/contexts.mjs +8 -0
- package/dist/diagram/runtime/cursor-position-tracker.mjs +20 -0
- package/dist/diagram/runtime/default-edge-templates.mjs +21 -0
- package/dist/diagram/runtime/default-node-templates.mjs +20 -0
- package/dist/diagram/runtime/diagram-reference.mjs +126 -0
- package/dist/diagram/runtime/diagram-runtime.mjs +214 -0
- package/dist/diagram/runtime/dom-input-events-router.mjs +88 -0
- package/dist/diagram/runtime/environment.mjs +59 -0
- package/dist/diagram/runtime/event-bridge.mjs +31 -0
- package/dist/diagram/runtime/flow-offset.mjs +45 -0
- package/dist/diagram/runtime/group-highlighted.mjs +25 -0
- package/dist/diagram/runtime/hidden.mjs +147 -0
- package/dist/diagram/runtime/lit-renderer.mjs +33 -0
- package/dist/diagram/runtime/marker-registry.mjs +108 -0
- package/dist/diagram/runtime/middlewares.mjs +14 -0
- package/dist/diagram/runtime/model-owner.mjs +11 -0
- package/dist/diagram/runtime/node-selected.mjs +25 -0
- package/dist/diagram/runtime/observable.mjs +205 -0
- package/dist/diagram/runtime/palette-drag.mjs +56 -0
- package/dist/diagram/runtime/port-hover.mjs +27 -0
- package/dist/diagram/runtime/port-registry.mjs +87 -0
- package/dist/diagram/runtime/resize-processor.mjs +207 -0
- package/dist/diagram/runtime/template-resolver.mjs +98 -0
- package/dist/diagram/runtime/touch-events-state.mjs +52 -0
- package/dist/diagram/utilities.mjs +27 -0
- package/dist/diagram-core/action-state-manager/action-state-manager.mjs +238 -0
- package/dist/diagram-core/batch-processor/batch-processor.mjs +144 -0
- package/dist/diagram-core/command-handler/command-handler.mjs +62 -0
- package/dist/diagram-core/command-handler/commands/add-to-group.mjs +32 -0
- package/dist/diagram-core/command-handler/commands/add-update-delete.mjs +196 -0
- package/dist/diagram-core/command-handler/commands/centering.mjs +73 -0
- package/dist/diagram-core/command-handler/commands/copy-paste.mjs +223 -0
- package/dist/diagram-core/command-handler/commands/cut.mjs +9 -0
- package/dist/diagram-core/command-handler/commands/delete-selection.mjs +32 -0
- package/dist/diagram-core/command-handler/commands/detach-on-node-delete.mjs +77 -0
- package/dist/diagram-core/command-handler/commands/highlight-group.mjs +45 -0
- package/dist/diagram-core/command-handler/commands/index.mjs +88 -0
- package/dist/diagram-core/command-handler/commands/init.mjs +11 -0
- package/dist/diagram-core/command-handler/commands/linking/cancel-linking.mjs +26 -0
- package/dist/diagram-core/command-handler/commands/linking/finish-linking-to-position.mjs +33 -0
- package/dist/diagram-core/command-handler/commands/linking/finish-linking.mjs +108 -0
- package/dist/diagram-core/command-handler/commands/linking/finish-relinking.mjs +91 -0
- package/dist/diagram-core/command-handler/commands/linking/linking-gesture.mjs +13 -0
- package/dist/diagram-core/command-handler/commands/linking/move-temporary-edge.mjs +98 -0
- package/dist/diagram-core/command-handler/commands/linking/start-linking-from-position.mjs +23 -0
- package/dist/diagram-core/command-handler/commands/linking/start-linking.mjs +47 -0
- package/dist/diagram-core/command-handler/commands/linking/start-relinking.mjs +51 -0
- package/dist/diagram-core/command-handler/commands/linking/utils.mjs +103 -0
- package/dist/diagram-core/command-handler/commands/move-nodes-lifecycle.mjs +14 -0
- package/dist/diagram-core/command-handler/commands/move-viewport.mjs +48 -0
- package/dist/diagram-core/command-handler/commands/move.mjs +90 -0
- package/dist/diagram-core/command-handler/commands/remove-from-group.mjs +22 -0
- package/dist/diagram-core/command-handler/commands/resize-node-lifecycle.mjs +14 -0
- package/dist/diagram-core/command-handler/commands/resize-node.mjs +214 -0
- package/dist/diagram-core/command-handler/commands/rotate-node-lifecycle.mjs +14 -0
- package/dist/diagram-core/command-handler/commands/rotate-node.mjs +53 -0
- package/dist/diagram-core/command-handler/commands/selection.mjs +69 -0
- package/dist/diagram-core/command-handler/commands/z-order.mjs +125 -0
- package/dist/diagram-core/command-handler/commands/zoom-to-fit.mjs +118 -0
- package/dist/diagram-core/command-handler/commands/zoom.mjs +26 -0
- package/dist/diagram-core/edge-routing-manager/edge-routing-manager.mjs +253 -0
- package/dist/diagram-core/edge-routing-manager/resolve-label-position.mjs +13 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/bezier-routing.mjs +73 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-path.mjs +24 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-point-at-distance.mjs +37 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-point-on-path.mjs +33 -0
- package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-points.mjs +31 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-path.mjs +56 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-point-at-distance.mjs +12 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-point-on-path.mjs +38 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-points.mjs +26 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/orthogonal-routing.mjs +69 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/get-offset-point.mjs +14 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-bottom.mjs +104 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-left.mjs +91 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-right.mjs +88 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints-from-top.mjs +168 -0
- package/dist/diagram-core/edge-routing-manager/routings/orthogonal/utils/pathpoints/get-pathpoints.mjs +23 -0
- package/dist/diagram-core/edge-routing-manager/routings/polyline/compute-polyline-point-at-distance.mjs +12 -0
- package/dist/diagram-core/edge-routing-manager/routings/polyline/compute-polyline-point-on-path.mjs +41 -0
- package/dist/diagram-core/edge-routing-manager/routings/polyline/polyline-routing.mjs +81 -0
- package/dist/diagram-core/edge-routing-manager/utils/linear-segment-utils.mjs +27 -0
- package/dist/diagram-core/edge-routing-manager/utils/normalize-distance.mjs +6 -0
- package/dist/diagram-core/event-manager/event-manager.mjs +164 -0
- package/dist/diagram-core/flow-config/default-flow-config.mjs +143 -0
- package/dist/diagram-core/flow-core.mjs +541 -0
- package/dist/diagram-core/input-events/handlers/box-selection/box-selection.handler.mjs +69 -0
- package/dist/diagram-core/input-events/handlers/cancel-interaction/cancel-interaction.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/copy/copy.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/cut/cut.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/delete-selection/delete-selection.handler.mjs +9 -0
- package/dist/diagram-core/input-events/handlers/event-handler.mjs +29 -0
- package/dist/diagram-core/input-events/handlers/keyboard-move-selection/keyboard-move-selection.handler.mjs +130 -0
- package/dist/diagram-core/input-events/handlers/keyboard-panning/keyboard-panning.handler.mjs +31 -0
- package/dist/diagram-core/input-events/handlers/linking/linking.handler.mjs +77 -0
- package/dist/diagram-core/input-events/handlers/movable-selection.mjs +26 -0
- package/dist/diagram-core/input-events/handlers/palette-drop/palette-drop.handler.mjs +20 -0
- package/dist/diagram-core/input-events/handlers/panning/panning-handler-factory.mjs +8 -0
- package/dist/diagram-core/input-events/handlers/panning/panning.handler.mjs +41 -0
- package/dist/diagram-core/input-events/handlers/panning/virtualized-panning.handler.mjs +77 -0
- package/dist/diagram-core/input-events/handlers/paste/paste.handler.mjs +17 -0
- package/dist/diagram-core/input-events/handlers/pointer-move-selection/pointer-move-selection.handler.mjs +220 -0
- package/dist/diagram-core/input-events/handlers/redo/redo.handler.mjs +14 -0
- package/dist/diagram-core/input-events/handlers/relinking/relinking.handler.mjs +62 -0
- package/dist/diagram-core/input-events/handlers/resize/resize.handler.mjs +174 -0
- package/dist/diagram-core/input-events/handlers/rotate/rotate.handler.mjs +107 -0
- package/dist/diagram-core/input-events/handlers/select/select.handler.mjs +42 -0
- package/dist/diagram-core/input-events/handlers/select-all/select-all.handler.mjs +10 -0
- package/dist/diagram-core/input-events/handlers/undo/undo.handler.mjs +14 -0
- package/dist/diagram-core/input-events/handlers/wheel-panning/wheel-panning.handler.mjs +25 -0
- package/dist/diagram-core/input-events/handlers/zooming/zooming.handler.mjs +28 -0
- package/dist/diagram-core/input-events/input-events.router.mjs +75 -0
- package/dist/diagram-core/interaction-coordinator/interaction-coordinator.mjs +75 -0
- package/dist/diagram-core/label-batch-processor/label-batch-processor.mjs +19 -0
- package/dist/diagram-core/math/angle-between-points/angle-between-points.mjs +5 -0
- package/dist/diagram-core/math/angle-to-side/angle-to-side.mjs +27 -0
- package/dist/diagram-core/math/calculate-edge-panning-force/calculate-edge-panning-force.mjs +34 -0
- package/dist/diagram-core/math/clamp/clamp.mjs +5 -0
- package/dist/diagram-core/math/distance-between-points/distance-between-points.mjs +5 -0
- package/dist/diagram-core/math/ng-diagram-math.mjs +25 -0
- package/dist/diagram-core/math/normalize-angle/normalize-angle.mjs +5 -0
- package/dist/diagram-core/math/snap-angle/snap-angle.mjs +43 -0
- package/dist/diagram-core/math/snap-number/snap-number.mjs +3 -0
- package/dist/diagram-core/math/snap-point/snap-point.mjs +8 -0
- package/dist/diagram-core/math/subtract-points/subtract-points.mjs +5 -0
- package/dist/diagram-core/measurement-tracker/measurement-tracker.mjs +182 -0
- package/dist/diagram-core/middleware-manager/middleware-executor.mjs +246 -0
- package/dist/diagram-core/middleware-manager/middleware-manager.mjs +93 -0
- package/dist/diagram-core/middleware-manager/middlewares/edges-routing/edges-routing.mjs +149 -0
- package/dist/diagram-core/middleware-manager/middlewares/edges-routing/get-edge-points.mjs +93 -0
- package/dist/diagram-core/middleware-manager/middlewares/edges-routing/get-source-target-positions.mjs +90 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/clipboard-paste.emitter.mjs +34 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/diagram-init.emitter.mjs +190 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/edge-draw-ended.emitter.mjs +51 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/edge-drawn.emitter.mjs +35 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/edge-relink.emitter.mjs +58 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/group-membership-changed.emitter.mjs +49 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/node-drag-lifecycle.emitter.mjs +54 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/node-resize-lifecycle.emitter.mjs +44 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/node-rotate-lifecycle.emitter.mjs +44 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/palette-item-dropped.emitter.mjs +26 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-changed.emitter.mjs +61 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-gesture-ended.emitter.mjs +32 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-moved.emitter.mjs +57 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-removed.emitter.mjs +40 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/selection-rotated.emitter.mjs +33 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/size-changed.emitter.mjs +33 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/emitters/viewport-changed.emitter.mjs +19 -0
- package/dist/diagram-core/middleware-manager/middlewares/event-emitter/event-emitter.middleware.mjs +69 -0
- package/dist/diagram-core/middleware-manager/middlewares/hidden-computation/hidden-computation.mjs +66 -0
- package/dist/diagram-core/middleware-manager/middlewares/internal-id-assignment/internal-id-assignment.mjs +24 -0
- package/dist/diagram-core/middleware-manager/middlewares/logger/logger.mjs +18 -0
- package/dist/diagram-core/middleware-manager/middlewares/measured-bounds-assignment/is-node-fully-measured.mjs +20 -0
- package/dist/diagram-core/middleware-manager/middlewares/measured-bounds-assignment/measured-bounds-assignment.mjs +59 -0
- package/dist/diagram-core/middleware-manager/middlewares/measurement-tracking/measurement-tracking.middleware.mjs +55 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/assign-edges-z-index.mjs +12 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/assign-node-z-index.mjs +61 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/create-group-children-map.mjs +14 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/initialize-z-index.mjs +30 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/utils/sort-children.mjs +36 -0
- package/dist/diagram-core/middleware-manager/middlewares/z-index-assignment/z-index-assignment.mjs +240 -0
- package/dist/diagram-core/middleware-manager/pass-settlement.mjs +68 -0
- package/dist/diagram-core/model-lookup/model-lookup.mjs +394 -0
- package/dist/diagram-core/port-batch-processor/port-batch-processor.mjs +20 -0
- package/dist/diagram-core/render-strategy/base-render-strategy.mjs +26 -0
- package/dist/diagram-core/render-strategy/direct/direct-render-strategy.mjs +33 -0
- package/dist/diagram-core/render-strategy/render-performance-logger.mjs +42 -0
- package/dist/diagram-core/render-strategy/virtualized/idle-render-scheduler.mjs +43 -0
- package/dist/diagram-core/render-strategy/virtualized/result-cache.mjs +63 -0
- package/dist/diagram-core/render-strategy/virtualized/viewport-utils.mjs +40 -0
- package/dist/diagram-core/render-strategy/virtualized/virtualized-render-strategy.mjs +91 -0
- package/dist/diagram-core/render-strategy/virtualized/visible-elements-resolver.mjs +120 -0
- package/dist/diagram-core/render-strategy/virtualized/zoom-tracker.mjs +38 -0
- package/dist/diagram-core/set.polyfill.mjs +24 -0
- package/dist/diagram-core/shortcut-manager/default-shortcuts.mjs +99 -0
- package/dist/diagram-core/shortcut-manager/shortcut-manager.mjs +140 -0
- package/dist/diagram-core/spatial-hash/collision-detection.mjs +74 -0
- package/dist/diagram-core/spatial-hash/spatial-hash.mjs +161 -0
- package/dist/diagram-core/spatial-hash/utils.mjs +92 -0
- package/dist/diagram-core/transaction-manager/transaction-context.mjs +40 -0
- package/dist/diagram-core/transaction-manager/transaction-manager.mjs +94 -0
- package/dist/diagram-core/transaction-manager/transaction.mjs +179 -0
- package/dist/diagram-core/types/edge.interface.mjs +3 -0
- package/dist/diagram-core/types/node.interface.mjs +3 -0
- package/dist/diagram-core/types/utils.mjs +3 -0
- package/dist/diagram-core/updater/init-updater/init-state.mjs +356 -0
- package/dist/diagram-core/updater/init-updater/init-updater.mjs +275 -0
- package/dist/diagram-core/updater/init-updater/late-arrival-queue.mjs +71 -0
- package/dist/diagram-core/updater/init-updater/stability-detector.mjs +63 -0
- package/dist/diagram-core/updater/internal-updater/internal-updater.mjs +166 -0
- package/dist/diagram-core/utils/change-generation.mjs +13 -0
- package/dist/diagram-core/utils/compute-floating-edge-side.mjs +35 -0
- package/dist/diagram-core/utils/constants.mjs +3 -0
- package/dist/diagram-core/utils/dangling-edges.mjs +89 -0
- package/dist/diagram-core/utils/deep-merge.mjs +22 -0
- package/dist/diagram-core/utils/dimensions.mjs +52 -0
- package/dist/diagram-core/utils/get-node-border-intersection.mjs +99 -0
- package/dist/diagram-core/utils/get-port-flow-position.mjs +55 -0
- package/dist/diagram-core/utils/group-size.mjs +32 -0
- package/dist/diagram-core/utils/is-group.mjs +5 -0
- package/dist/diagram-core/utils/measurement-validation.mjs +11 -0
- package/dist/diagram-core/utils/object-properties.mjs +22 -0
- package/dist/diagram-core/utils/rects-points-sizes.mjs +148 -0
- package/dist/diagram-core/utils/relinking.mjs +6 -0
- package/dist/diagram-core/utils/semaphore.mjs +43 -0
- package/dist/diagram-core/utils/snap-node-position.mjs +11 -0
- package/dist/diagram-core/utils/sort-nodes-by-z-index.mjs +22 -0
- package/dist/diagram-core/visibility/effective-visibility.mjs +28 -0
- package/dist/diagram-core/visibility/template-visibility-registry.mjs +87 -0
- package/dist/index.d.mts +13416 -3794
- package/dist/index.d.ts +13416 -3794
- package/dist/index.mjs +34 -0
- package/dist/internal/content-size.mjs +14 -0
- package/dist/internal/custom-boolean-converter.mjs +18 -0
- package/dist/internal/flow-ui-rdf-element.mjs +57 -5
- package/dist/package.json.mjs +1 -1
- package/dist/utilities/register-components.mjs +77 -142
- package/dist/vscode.html-custom-data.json +460 -187
- package/package.json +16 -8
- package/themes/dark.css +2 -0
- package/themes/dark.styles.js +2 -0
- package/themes/light.css +2 -0
- package/themes/light.styles.js +2 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { calculatePartsBounds } from '../../utils/dimensions.mjs';
|
|
2
|
+
|
|
3
|
+
const INVALID_ZOOM_TO_FIT_SCALE_ERROR = (scale) => `[ngDiagram] Invalid scale calculated in zoom-to-fit: ${scale}
|
|
4
|
+
|
|
5
|
+
Scale must be a positive finite number.
|
|
6
|
+
|
|
7
|
+
Documentation: https://www.ngdiagram.dev/docs/intro/coordinate-system/#viewport-and-scaling`;
|
|
8
|
+
const VIRTUALIZATION_WARNING = `[ngDiagram] zoomToFit is disabled when virtualization is enabled.
|
|
9
|
+
|
|
10
|
+
When virtualization is active, only visible nodes and edges are rendered for performance reasons.
|
|
11
|
+
Zoom to fit requires all elements to be available for calculating bounds, which conflicts with virtualization.
|
|
12
|
+
|
|
13
|
+
To use zoomToFit, disable virtualization in your config:
|
|
14
|
+
virtualization: { enabled: false }`;
|
|
15
|
+
const normalizePadding = (padding, defaultPadding) => {
|
|
16
|
+
if (typeof padding === "number") {
|
|
17
|
+
return { top: padding, right: padding, bottom: padding, left: padding };
|
|
18
|
+
}
|
|
19
|
+
switch (padding.length) {
|
|
20
|
+
case 2:
|
|
21
|
+
return { top: padding[0], right: padding[1], bottom: padding[0], left: padding[1] };
|
|
22
|
+
case 3:
|
|
23
|
+
return { top: padding[0], right: padding[1], bottom: padding[2], left: padding[1] };
|
|
24
|
+
case 4:
|
|
25
|
+
return { top: padding[0], right: padding[1], bottom: padding[2], left: padding[3] };
|
|
26
|
+
default:
|
|
27
|
+
return { top: defaultPadding, right: defaultPadding, bottom: defaultPadding, left: defaultPadding };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const filterTargetElements = (nodes, edges, nodeIds, edgeIds) => {
|
|
31
|
+
const targetNodeIds = nodeIds?.length ? new Set(nodeIds) : void 0;
|
|
32
|
+
const targetNodes = targetNodeIds ? nodes.filter((node) => targetNodeIds.has(node.id)) : nodes;
|
|
33
|
+
let targetEdges;
|
|
34
|
+
if (edgeIds?.length) {
|
|
35
|
+
targetEdges = edges.filter((edge) => edgeIds.includes(edge.id));
|
|
36
|
+
} else if (targetNodeIds) {
|
|
37
|
+
targetEdges = edges.filter((edge) => targetNodeIds.has(edge.source) && targetNodeIds.has(edge.target));
|
|
38
|
+
} else {
|
|
39
|
+
targetEdges = edges;
|
|
40
|
+
}
|
|
41
|
+
return { targetNodes, targetEdges };
|
|
42
|
+
};
|
|
43
|
+
const calculateOptimalScale = (contentWidth, contentHeight, availableWidth, availableHeight, minScale, maxScale) => {
|
|
44
|
+
const scaleX = availableWidth / contentWidth;
|
|
45
|
+
const scaleY = availableHeight / contentHeight;
|
|
46
|
+
const scale = Math.min(scaleX, scaleY);
|
|
47
|
+
return Math.max(minScale, Math.min(maxScale, scale));
|
|
48
|
+
};
|
|
49
|
+
const calculateViewportPosition = (bounds, viewport, padding, scale) => {
|
|
50
|
+
const contentCenterX = bounds.x + bounds.width / 2;
|
|
51
|
+
const contentCenterY = bounds.y + bounds.height / 2;
|
|
52
|
+
const centerOffsetX = (padding.left - padding.right) / 2;
|
|
53
|
+
const centerOffsetY = (padding.top - padding.bottom) / 2;
|
|
54
|
+
return {
|
|
55
|
+
x: viewport.width / 2 - contentCenterX * scale + centerOffsetX,
|
|
56
|
+
y: viewport.height / 2 - contentCenterY * scale + centerOffsetY
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const isValidViewport = (viewport) => {
|
|
60
|
+
return !!viewport.width && !!viewport.height && viewport.width > 0 && viewport.height > 0;
|
|
61
|
+
};
|
|
62
|
+
const zoomToFit = async (commandHandler, { nodeIds, edgeIds, padding }) => {
|
|
63
|
+
if (commandHandler.flowCore.isVirtualizationActive) {
|
|
64
|
+
console.warn(VIRTUALIZATION_WARNING);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const { nodes, edges, metadata } = commandHandler.flowCore.getState();
|
|
68
|
+
const { viewport } = metadata;
|
|
69
|
+
if (!isValidViewport(viewport)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const viewportWidth = viewport.width;
|
|
73
|
+
const viewportHeight = viewport.height;
|
|
74
|
+
const defaultPadding = commandHandler.flowCore.config.zoom.zoomToFit.padding;
|
|
75
|
+
const effectivePadding = padding ?? defaultPadding;
|
|
76
|
+
const { targetNodes, targetEdges } = filterTargetElements(nodes, edges, nodeIds, edgeIds);
|
|
77
|
+
const bounds = calculatePartsBounds(targetNodes, targetEdges);
|
|
78
|
+
if (!bounds) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const defaultPaddingValue = Array.isArray(defaultPadding) ? defaultPadding[0] : defaultPadding;
|
|
82
|
+
const pad = normalizePadding(effectivePadding, defaultPaddingValue);
|
|
83
|
+
const availableWidth = viewportWidth - pad.left - pad.right;
|
|
84
|
+
const availableHeight = viewportHeight - pad.top - pad.bottom;
|
|
85
|
+
if (availableWidth <= 0 || availableHeight <= 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const { min, max } = commandHandler.flowCore.config.zoom;
|
|
89
|
+
const newScale = calculateOptimalScale(bounds.width, bounds.height, availableWidth, availableHeight, min, max);
|
|
90
|
+
if (newScale <= 0 || !isFinite(newScale) || isNaN(newScale)) {
|
|
91
|
+
console.error(INVALID_ZOOM_TO_FIT_SCALE_ERROR(newScale));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const { x: newX, y: newY } = calculateViewportPosition(
|
|
95
|
+
bounds,
|
|
96
|
+
{ width: viewportWidth, height: viewportHeight },
|
|
97
|
+
pad,
|
|
98
|
+
newScale
|
|
99
|
+
);
|
|
100
|
+
if (viewport.x === newX && viewport.y === newY && viewport.scale === newScale) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
await commandHandler.flowCore.applyUpdate(
|
|
104
|
+
{
|
|
105
|
+
metadataUpdate: {
|
|
106
|
+
viewport: {
|
|
107
|
+
...viewport,
|
|
108
|
+
x: newX,
|
|
109
|
+
y: newY,
|
|
110
|
+
scale: newScale
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"zoomToFit"
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export { zoomToFit };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const INVALID_ZOOM_SCALE_ERROR = (scale) => `[ngDiagram] Invalid zoom scale: ${scale}
|
|
2
|
+
|
|
3
|
+
Scale must be a positive finite number.
|
|
4
|
+
|
|
5
|
+
Documentation: https://www.ngdiagram.dev/docs/intro/coordinate-system/#viewport-and-scaling`;
|
|
6
|
+
const zoom = async (commandHandler, { x, y, scale }) => {
|
|
7
|
+
const { metadata } = commandHandler.flowCore.getState();
|
|
8
|
+
if (scale <= 0 || !isFinite(scale) || isNaN(scale)) {
|
|
9
|
+
console.error(INVALID_ZOOM_SCALE_ERROR(scale));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const { min, max } = commandHandler.flowCore.config.zoom;
|
|
13
|
+
if (scale < min || scale > max) {
|
|
14
|
+
console.warn(`Zoom scale ${scale} is out of bounds [${min}, ${max}]`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (x === metadata.viewport.x && y === metadata.viewport.y && scale === metadata.viewport.scale) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
await commandHandler.flowCore.applyUpdate(
|
|
21
|
+
{ metadataUpdate: { viewport: { ...metadata.viewport, x, y, scale } } },
|
|
22
|
+
"zoom"
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { zoom };
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { BezierRouting } from './routings/bezier/bezier-routing.mjs';
|
|
2
|
+
import { OrthogonalRouting } from './routings/orthogonal/orthogonal-routing.mjs';
|
|
3
|
+
import { PolylineRouting } from './routings/polyline/polyline-routing.mjs';
|
|
4
|
+
import { computeLinearSegmentLengths, interpolateAlongLinearSegments } from './utils/linear-segment-utils.mjs';
|
|
5
|
+
import { normalizeDistance } from './utils/normalize-distance.mjs';
|
|
6
|
+
|
|
7
|
+
const ROUTING_MUST_HAVE_NAME_WARNING = `[ngDiagram] Routing must have a non-empty name property. Registration skipped.
|
|
8
|
+
|
|
9
|
+
To fix this:
|
|
10
|
+
\u2022 Ensure your EdgeRouting implementation has a 'name' property
|
|
11
|
+
\u2022 The name should be a non-empty string
|
|
12
|
+
|
|
13
|
+
Documentation: https://www.ngdiagram.dev/docs/guides/edges/routing/
|
|
14
|
+
`;
|
|
15
|
+
const ROUTING_NOT_FOUND_WARNING = (name, registeredRoutings, fallback) => `[ngDiagram] Routing '${name}' is not registered. Falling back to '${fallback}' routing.
|
|
16
|
+
|
|
17
|
+
Available routings: ${registeredRoutings.join(", ")}
|
|
18
|
+
|
|
19
|
+
To fix this:
|
|
20
|
+
\u2022 Register the routing using NgDiagramService.registerRouting()
|
|
21
|
+
\u2022 Or use one of the available routings listed above
|
|
22
|
+
|
|
23
|
+
Documentation: https://www.ngdiagram.dev/docs/guides/edges/routing/
|
|
24
|
+
`;
|
|
25
|
+
const CANNOT_SET_DEFAULT_ROUTING_WARNING = (name, registeredRoutings) => `[ngDiagram] Cannot set default routing to '${name}': routing not registered. Default routing unchanged.
|
|
26
|
+
|
|
27
|
+
Available routings: ${registeredRoutings.join(", ")}
|
|
28
|
+
|
|
29
|
+
To fix this:
|
|
30
|
+
\u2022 First register the routing using NgDiagramService.registerRouting()
|
|
31
|
+
\u2022 Then set it as default
|
|
32
|
+
|
|
33
|
+
Documentation: https://www.ngdiagram.dev/docs/guides/edges/routing/
|
|
34
|
+
`;
|
|
35
|
+
class EdgeRoutingManager {
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new EdgeRoutingManager and registers built-in routings.
|
|
38
|
+
*
|
|
39
|
+
* @param defaultEdgeRouting - The routing to use when none is specified (defaults to `'orthogonal'`)
|
|
40
|
+
* @param getRoutingConfiguration - Function returning the current routing configuration
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
constructor(defaultEdgeRouting, getRoutingConfiguration) {
|
|
45
|
+
this.routings = /* @__PURE__ */ new Map();
|
|
46
|
+
this.defaultRouting = defaultEdgeRouting || "orthogonal";
|
|
47
|
+
this.getRoutingConfig = getRoutingConfiguration || (() => ({}));
|
|
48
|
+
this.registerRouting(new OrthogonalRouting());
|
|
49
|
+
this.registerRouting(new BezierRouting());
|
|
50
|
+
this.registerRouting(new PolylineRouting());
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Registers (or replaces) a routing implementation.
|
|
54
|
+
*
|
|
55
|
+
* @param routing - The routing instance to register. Its name must be non-empty.
|
|
56
|
+
*/
|
|
57
|
+
registerRouting(routing) {
|
|
58
|
+
if (!routing.name) {
|
|
59
|
+
console.warn(ROUTING_MUST_HAVE_NAME_WARNING);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.routings.set(routing.name, routing);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Unregisters a routing by name.
|
|
66
|
+
*
|
|
67
|
+
* @param name - The routing name to remove
|
|
68
|
+
*/
|
|
69
|
+
unregisterRouting(name) {
|
|
70
|
+
this.routings.delete(name);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Gets a routing implementation by name.
|
|
74
|
+
*
|
|
75
|
+
* @param name - The routing name to look up
|
|
76
|
+
* @returns The routing implementation or `undefined` if not registered
|
|
77
|
+
*/
|
|
78
|
+
getRouting(name) {
|
|
79
|
+
return this.routings.get(name);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Gets all registered routing names.
|
|
83
|
+
*
|
|
84
|
+
* @returns An array of registered routing names (built-in and custom)
|
|
85
|
+
*/
|
|
86
|
+
getRegisteredRoutings() {
|
|
87
|
+
return Array.from(this.routings.keys());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Checks whether a routing is registered.
|
|
91
|
+
*
|
|
92
|
+
* @param name - The routing name to check
|
|
93
|
+
* @returns `true` if registered; otherwise `false`
|
|
94
|
+
*/
|
|
95
|
+
hasRouting(name) {
|
|
96
|
+
return this.routings.has(name);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Computes the routed points for an edge using the specified routing algorithm.
|
|
100
|
+
*
|
|
101
|
+
* @param routingName - The routing to use. If omitted or undefined, the default routing is used.
|
|
102
|
+
* @param context - The routing context containing source/target nodes, ports, edge data, etc.
|
|
103
|
+
* @returns The computed polyline as an array of points
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const points = routingManager.computePoints('orthogonal', {
|
|
108
|
+
* sourceNode: node1,
|
|
109
|
+
* targetNode: node2,
|
|
110
|
+
* sourcePosition: { x: 100, y: 50 },
|
|
111
|
+
* targetPosition: { x: 300, y: 200 },
|
|
112
|
+
* edge: edge
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
computePoints(routingName, context) {
|
|
117
|
+
const name = routingName || this.defaultRouting;
|
|
118
|
+
let routing = this.routings.get(name);
|
|
119
|
+
if (!routing) {
|
|
120
|
+
const fallback = this.defaultRouting;
|
|
121
|
+
console.warn(ROUTING_NOT_FOUND_WARNING(name, this.getRegisteredRoutings(), fallback));
|
|
122
|
+
routing = this.routings.get(fallback);
|
|
123
|
+
if (!routing) {
|
|
124
|
+
return [context.sourcePoint, context.targetPoint].filter((p) => !!p);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return routing.computePoints(context, this.getRoutingConfig());
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Computes an SVG path string for the given points using the specified routing.
|
|
131
|
+
*
|
|
132
|
+
* @param routingName - The routing to use. If omitted or undefined, the default routing is used.
|
|
133
|
+
* @param points - The points to convert into an SVG path string
|
|
134
|
+
* @returns An SVG path string suitable for the `d` attribute of an SVG `<path>` element
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const points = [{ x: 0, y: 0 }, { x: 100, y: 100 }, { x: 200, y: 100 }];
|
|
139
|
+
* const path = routingManager.computePath('polyline', points);
|
|
140
|
+
* // Returns: "M 0 0 L 100 100 L 200 100"
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
computePath(routingName, points) {
|
|
144
|
+
const name = routingName || this.defaultRouting;
|
|
145
|
+
let routing = this.routings.get(name);
|
|
146
|
+
if (!routing) {
|
|
147
|
+
const fallback = this.defaultRouting;
|
|
148
|
+
console.warn(ROUTING_NOT_FOUND_WARNING(name, this.getRegisteredRoutings(), fallback));
|
|
149
|
+
routing = this.routings.get(fallback);
|
|
150
|
+
if (!routing) {
|
|
151
|
+
if (points.length === 0)
|
|
152
|
+
return "";
|
|
153
|
+
return `M ${points[0].x},${points[0].y}`;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return routing.computeSvgPath(points, this.getRoutingConfig());
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Computes a point along the path at a given percentage.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* If the selected routing implements `computePointOnPath`, it will be used.
|
|
163
|
+
* Otherwise, falls back to linear interpolation between the first and last points.
|
|
164
|
+
*
|
|
165
|
+
* @param routingName - The routing to use. If omitted or undefined, the default routing is used.
|
|
166
|
+
* @param points - The path points
|
|
167
|
+
* @param percentage - Position along the path in range [0, 1] where 0 = start, 1 = end
|
|
168
|
+
* @returns The interpolated point on the path
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* const points = [{ x: 0, y: 0 }, { x: 100, y: 100 }];
|
|
173
|
+
* const midpoint = routingManager.computePointOnPath('polyline', points, 0.5);
|
|
174
|
+
* // Returns: { x: 50, y: 50 }
|
|
175
|
+
* const quarterPoint = routingManager.computePointOnPath('polyline', points, 0.25);
|
|
176
|
+
* // Returns: { x: 25, y: 25 }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
computePointOnPath(routingName, points, percentage) {
|
|
180
|
+
const name = routingName || this.defaultRouting;
|
|
181
|
+
let routing = this.routings.get(name);
|
|
182
|
+
if (!routing) {
|
|
183
|
+
const fallback = this.defaultRouting;
|
|
184
|
+
console.warn(ROUTING_NOT_FOUND_WARNING(name, this.getRegisteredRoutings(), fallback));
|
|
185
|
+
routing = this.routings.get(fallback);
|
|
186
|
+
}
|
|
187
|
+
if (routing?.computePointOnPath) {
|
|
188
|
+
return routing.computePointOnPath(points, percentage);
|
|
189
|
+
}
|
|
190
|
+
if (points.length < 2)
|
|
191
|
+
return points[0] || { x: 0, y: 0 };
|
|
192
|
+
const startPoint = points[0];
|
|
193
|
+
const endPoint = points[points.length - 1];
|
|
194
|
+
const x = startPoint.x + (endPoint.x - startPoint.x) * percentage;
|
|
195
|
+
const y = startPoint.y + (endPoint.y - startPoint.y) * percentage;
|
|
196
|
+
return { x, y };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Computes a point along the path at a given pixel distance from the start.
|
|
200
|
+
*
|
|
201
|
+
* @remarks
|
|
202
|
+
* If the selected routing implements `computePointAtDistance`, it will be used.
|
|
203
|
+
* Otherwise, falls back to segment-based distance traversal along the points array.
|
|
204
|
+
* Negative values measure from the end of the path.
|
|
205
|
+
*
|
|
206
|
+
* @param routingName - The routing to use. If omitted, the default routing is used.
|
|
207
|
+
* @param points - The path points
|
|
208
|
+
* @param distancePx - Distance in pixels (positive = from start, negative = from end)
|
|
209
|
+
* @returns The point on the path at the given distance
|
|
210
|
+
*/
|
|
211
|
+
computePointAtDistance(routingName, points, distancePx) {
|
|
212
|
+
const name = routingName || this.defaultRouting;
|
|
213
|
+
let routing = this.routings.get(name);
|
|
214
|
+
if (!routing) {
|
|
215
|
+
const fallback = this.defaultRouting;
|
|
216
|
+
console.warn(ROUTING_NOT_FOUND_WARNING(name, this.getRegisteredRoutings(), fallback));
|
|
217
|
+
routing = this.routings.get(fallback);
|
|
218
|
+
}
|
|
219
|
+
if (routing?.computePointAtDistance) {
|
|
220
|
+
return routing.computePointAtDistance(points, distancePx);
|
|
221
|
+
}
|
|
222
|
+
return computeFallbackPointAtDistance(points, distancePx);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Sets the default routing to use for all edges when no specific routing is specified.
|
|
226
|
+
*
|
|
227
|
+
* @param name - The routing name to set as default
|
|
228
|
+
*/
|
|
229
|
+
setDefaultRouting(name) {
|
|
230
|
+
if (!this.routings.has(name)) {
|
|
231
|
+
console.warn(CANNOT_SET_DEFAULT_ROUTING_WARNING(name, this.getRegisteredRoutings()));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
this.defaultRouting = name;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Gets the current default routing name.
|
|
238
|
+
*
|
|
239
|
+
* @returns The name of the current default routing
|
|
240
|
+
*/
|
|
241
|
+
getDefaultRouting() {
|
|
242
|
+
return this.defaultRouting;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const computeFallbackPointAtDistance = (points, distancePx) => {
|
|
246
|
+
if (points.length < 2)
|
|
247
|
+
return points[0] || { x: 0, y: 0 };
|
|
248
|
+
const { lengths, totalLength } = computeLinearSegmentLengths(points);
|
|
249
|
+
const targetLength = normalizeDistance(distancePx, totalLength);
|
|
250
|
+
return interpolateAlongLinearSegments(points, lengths, targetLength);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export { EdgeRoutingManager };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const resolveLabelPosition = (positionOnEdge, edgeRouting, points, routingManager) => {
|
|
2
|
+
if (typeof positionOnEdge === "string") {
|
|
3
|
+
const normalizedPosition = positionOnEdge.trim();
|
|
4
|
+
if (normalizedPosition.endsWith("px")) {
|
|
5
|
+
const px = parseFloat(normalizedPosition);
|
|
6
|
+
return routingManager.computePointAtDistance(edgeRouting, points, px);
|
|
7
|
+
}
|
|
8
|
+
return routingManager.computePointOnPath(edgeRouting, points, parseFloat(normalizedPosition));
|
|
9
|
+
}
|
|
10
|
+
return routingManager.computePointOnPath(edgeRouting, points, positionOnEdge);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { resolveLabelPosition };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { computeBezierPath } from './compute-bezier-path.mjs';
|
|
2
|
+
import { computeBezierPointAtDistance } from './compute-bezier-point-at-distance.mjs';
|
|
3
|
+
import { computeBezierPointOnPath } from './compute-bezier-point-on-path.mjs';
|
|
4
|
+
import { computeBezierPoints } from './compute-bezier-points.mjs';
|
|
5
|
+
|
|
6
|
+
const CONTROL_POINT_OFFSET_FALLBACK = 100;
|
|
7
|
+
class BezierRouting {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.name = "bezier";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Computes the control points for a cubic Bézier curve.
|
|
13
|
+
*
|
|
14
|
+
* @param context - The routing context. See {@link EdgeRoutingContext}.
|
|
15
|
+
* @param [config] - Optional routing configuration. See {@link EdgeRoutingConfiguration}.
|
|
16
|
+
* Uses `config.bezier.bezierControlOffset` when provided; defaults to `100`.
|
|
17
|
+
* @returns An array of {@link Point} representing the Bézier points
|
|
18
|
+
* (usually 4 points: start, control1, control2, end).
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const pts = routing.computePoints(ctx, { bezier: { bezierControlOffset: 80 } });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
computePoints(context, config) {
|
|
26
|
+
const { sourcePoint, targetPoint } = context;
|
|
27
|
+
const bezierControlOffset = config?.bezier?.bezierControlOffset ?? CONTROL_POINT_OFFSET_FALLBACK;
|
|
28
|
+
return computeBezierPoints(sourcePoint, targetPoint, bezierControlOffset);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generates an SVG `d` path string for a cubic Bézier curve.
|
|
32
|
+
*
|
|
33
|
+
* @param points - The Bézier points produced by {@link BezierRouting.computePoints}.
|
|
34
|
+
* @returns An SVG path string suitable for an `<path>` element's `d` attribute.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const d = routing.computeSvgPath(points);
|
|
39
|
+
* // e.g. "M x0,y0 C x1,y1 x2,y2 x3,y3"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
computeSvgPath(points) {
|
|
43
|
+
return computeBezierPath(points);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets a point on the Bézier curve at the given percentage.
|
|
47
|
+
*
|
|
48
|
+
* @param points - The Bézier points (start, control1, control2, end).
|
|
49
|
+
* @param percentage - Position along the path in `[0, 1]` (0 = start, 1 = end).
|
|
50
|
+
* @returns The interpolated {@link Point} along the curve.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const mid = routing.computePointOnPath(points, 0.5); // ~curve midpoint
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
computePointOnPath(points, percentage) {
|
|
58
|
+
return computeBezierPointOnPath(points, percentage);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets a point on the Bézier curve at a given pixel distance from the start,
|
|
62
|
+
* using arc-length parameterization.
|
|
63
|
+
*
|
|
64
|
+
* @param points - The Bézier points (start, control1, control2, end).
|
|
65
|
+
* @param distancePx - Distance in pixels (positive = from start, negative = from end).
|
|
66
|
+
* @returns The {@link Point} at the given distance along the curve.
|
|
67
|
+
*/
|
|
68
|
+
computePointAtDistance(points, distancePx) {
|
|
69
|
+
return computeBezierPointAtDistance(points, distancePx);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { BezierRouting };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const computeBezierPath = (points) => {
|
|
2
|
+
if (!points || points.length === 0) {
|
|
3
|
+
return "";
|
|
4
|
+
}
|
|
5
|
+
if (points.length === 1) {
|
|
6
|
+
return `M ${points[0].x},${points[0].y}`;
|
|
7
|
+
}
|
|
8
|
+
if (points.length === 2) {
|
|
9
|
+
return `M ${points[0].x},${points[0].y} L ${points[1].x},${points[1].y}`;
|
|
10
|
+
}
|
|
11
|
+
if (points.length === 3) {
|
|
12
|
+
return `M ${points[0].x},${points[0].y} Q ${points[1].x},${points[1].y} ${points[2].x},${points[2].y}`;
|
|
13
|
+
}
|
|
14
|
+
if (points.length === 4) {
|
|
15
|
+
return `M ${points[0].x},${points[0].y} C ${points[1].x},${points[1].y} ${points[2].x},${points[2].y} ${points[3].x},${points[3].y}`;
|
|
16
|
+
}
|
|
17
|
+
const path = [`M ${points[0].x},${points[0].y}`];
|
|
18
|
+
for (let i = 1; i < points.length; i++) {
|
|
19
|
+
path.push(`L ${points[i].x},${points[i].y}`);
|
|
20
|
+
}
|
|
21
|
+
return path.join(" ");
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { computeBezierPath };
|
package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-point-at-distance.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { normalizeDistance } from '../../utils/normalize-distance.mjs';
|
|
2
|
+
import { computeBezierPointOnPath } from './compute-bezier-point-on-path.mjs';
|
|
3
|
+
|
|
4
|
+
const NUM_SAMPLES = 100;
|
|
5
|
+
const computeBezierPointAtDistance = (points, distancePx) => {
|
|
6
|
+
if (points.length < 2)
|
|
7
|
+
return points[0] || { x: 0, y: 0 };
|
|
8
|
+
const samples = [{ t: 0, length: 0 }];
|
|
9
|
+
let prevPoint = computeBezierPointOnPath(points, 0);
|
|
10
|
+
let totalLength = 0;
|
|
11
|
+
for (let i = 1; i <= NUM_SAMPLES; i++) {
|
|
12
|
+
const t2 = i / NUM_SAMPLES;
|
|
13
|
+
const currPoint = computeBezierPointOnPath(points, t2);
|
|
14
|
+
totalLength += Math.hypot(currPoint.x - prevPoint.x, currPoint.y - prevPoint.y);
|
|
15
|
+
samples.push({ t: t2, length: totalLength });
|
|
16
|
+
prevPoint = currPoint;
|
|
17
|
+
}
|
|
18
|
+
const targetLength = normalizeDistance(distancePx, totalLength);
|
|
19
|
+
let lo = 0;
|
|
20
|
+
let hi = NUM_SAMPLES;
|
|
21
|
+
while (lo < hi) {
|
|
22
|
+
const mid = lo + hi >> 1;
|
|
23
|
+
if (samples[mid].length < targetLength) {
|
|
24
|
+
lo = mid + 1;
|
|
25
|
+
} else {
|
|
26
|
+
hi = mid;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const seg0 = samples[Math.max(0, lo - 1)];
|
|
30
|
+
const seg1 = samples[lo];
|
|
31
|
+
const segLength = seg1.length - seg0.length;
|
|
32
|
+
const frac = segLength > 0 ? (targetLength - seg0.length) / segLength : 0;
|
|
33
|
+
const t = seg0.t + (seg1.t - seg0.t) * frac;
|
|
34
|
+
return computeBezierPointOnPath(points, t);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { computeBezierPointAtDistance };
|
package/dist/diagram-core/edge-routing-manager/routings/bezier/compute-bezier-point-on-path.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NgDiagramMath } from '../../../math/ng-diagram-math.mjs';
|
|
2
|
+
|
|
3
|
+
const computeBezierPointOnPath = (points, percentage) => {
|
|
4
|
+
if (points.length < 2)
|
|
5
|
+
return points[0] || { x: 0, y: 0 };
|
|
6
|
+
const t = NgDiagramMath.clamp({ min: 0, value: percentage, max: 1 });
|
|
7
|
+
if (points.length === 2) {
|
|
8
|
+
const [p02, p12] = points;
|
|
9
|
+
const x2 = p02.x + (p12.x - p02.x) * t;
|
|
10
|
+
const y2 = p02.y + (p12.y - p02.y) * t;
|
|
11
|
+
return { x: x2, y: y2 };
|
|
12
|
+
}
|
|
13
|
+
if (points.length === 3) {
|
|
14
|
+
const [p02, p12, p22] = points;
|
|
15
|
+
const oneMinusT2 = 1 - t;
|
|
16
|
+
const oneMinusTSquared2 = oneMinusT2 * oneMinusT2;
|
|
17
|
+
const tSquared2 = t * t;
|
|
18
|
+
const x2 = oneMinusTSquared2 * p02.x + 2 * oneMinusT2 * t * p12.x + tSquared2 * p22.x;
|
|
19
|
+
const y2 = oneMinusTSquared2 * p02.y + 2 * oneMinusT2 * t * p12.y + tSquared2 * p22.y;
|
|
20
|
+
return { x: x2, y: y2 };
|
|
21
|
+
}
|
|
22
|
+
const [p0, p1, p2, p3] = points;
|
|
23
|
+
const oneMinusT = 1 - t;
|
|
24
|
+
const oneMinusTSquared = oneMinusT * oneMinusT;
|
|
25
|
+
const oneMinusTCubed = oneMinusTSquared * oneMinusT;
|
|
26
|
+
const tSquared = t * t;
|
|
27
|
+
const tCubed = tSquared * t;
|
|
28
|
+
const x = oneMinusTCubed * p0.x + 3 * oneMinusTSquared * t * p1.x + 3 * oneMinusT * tSquared * p2.x + tCubed * p3.x;
|
|
29
|
+
const y = oneMinusTCubed * p0.y + 3 * oneMinusTSquared * t * p1.y + 3 * oneMinusT * tSquared * p2.y + tCubed * p3.y;
|
|
30
|
+
return { x, y };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { computeBezierPointOnPath };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const getControlPointOffset = (position, offset) => {
|
|
2
|
+
switch (position.side) {
|
|
3
|
+
case "right":
|
|
4
|
+
return { x: position.x + offset, y: position.y };
|
|
5
|
+
case "left":
|
|
6
|
+
return { x: position.x - offset, y: position.y };
|
|
7
|
+
case "bottom":
|
|
8
|
+
return { x: position.x, y: position.y + offset };
|
|
9
|
+
case "top":
|
|
10
|
+
return { x: position.x, y: position.y - offset };
|
|
11
|
+
default:
|
|
12
|
+
return { x: position.x + offset, y: position.y };
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const computeBezierPoints = (source, target, bezierControlOffset = 100) => {
|
|
16
|
+
if (!source || !target)
|
|
17
|
+
return [];
|
|
18
|
+
const sourceControlPoint = getControlPointOffset(source, Math.abs(bezierControlOffset));
|
|
19
|
+
const targetControlPoint = getControlPointOffset(target, Math.abs(bezierControlOffset));
|
|
20
|
+
const sourcePoint = {
|
|
21
|
+
x: source.x,
|
|
22
|
+
y: source.y
|
|
23
|
+
};
|
|
24
|
+
const targetPoint = {
|
|
25
|
+
x: target.x,
|
|
26
|
+
y: target.y
|
|
27
|
+
};
|
|
28
|
+
return [sourcePoint, sourceControlPoint, targetControlPoint, targetPoint];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { computeBezierPoints };
|
package/dist/diagram-core/edge-routing-manager/routings/orthogonal/compute-orthogonal-path.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const computeOrthogonalPath = (points = [], maxRadius = 16) => {
|
|
2
|
+
if (points.length === 0)
|
|
3
|
+
return "";
|
|
4
|
+
if (points.length === 1)
|
|
5
|
+
return `M ${points[0].x},${points[0].y}`;
|
|
6
|
+
if (points.length === 2) {
|
|
7
|
+
return `M ${points[0].x},${points[0].y} L ${points[1].x},${points[1].y}`;
|
|
8
|
+
}
|
|
9
|
+
const source = points[0];
|
|
10
|
+
const middle = points.slice(1, -1);
|
|
11
|
+
const target = points[points.length - 1];
|
|
12
|
+
const pathArray = middle.map((point, index) => {
|
|
13
|
+
const prevPoint = points[index];
|
|
14
|
+
const nextPoint = points[index + 2];
|
|
15
|
+
const dx = nextPoint.x - prevPoint.x;
|
|
16
|
+
const dy = nextPoint.y - prevPoint.y;
|
|
17
|
+
const radius = Math.min(Math.abs(dx) / 2, Math.abs(dy) / 2, maxRadius);
|
|
18
|
+
const isPreviousPointToTheLeft = prevPoint.x < point.x;
|
|
19
|
+
const isPreviousPointToTheRight = prevPoint.x > point.x;
|
|
20
|
+
const isPreviousPointBelow = prevPoint.y > point.y;
|
|
21
|
+
const isPreviousPointAbove = prevPoint.y < point.y;
|
|
22
|
+
const isNextPointToTheLeft = nextPoint.x < point.x;
|
|
23
|
+
const isNextPointToTheRight = nextPoint.x > point.x;
|
|
24
|
+
const isNextPointBelow = nextPoint.y > point.y;
|
|
25
|
+
const isNextPointAbove = nextPoint.y < point.y;
|
|
26
|
+
const isXCloseToPrevPoint = Math.abs(prevPoint.x - point.x) <= 1;
|
|
27
|
+
const isYCloseToPrevPoint = Math.abs(prevPoint.y - point.y) <= 1;
|
|
28
|
+
const isXCloseToNextPoint = Math.abs(nextPoint.x - point.x) <= 1;
|
|
29
|
+
const isYCloseToNextPoint = Math.abs(nextPoint.y - point.y) <= 1;
|
|
30
|
+
if (middle.length <= 2 && (isXCloseToPrevPoint && isYCloseToPrevPoint || isXCloseToNextPoint && isYCloseToNextPoint)) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
const isVerticalLine = prevPoint.x === point.x && point.x === nextPoint.x;
|
|
34
|
+
const isHorizontalLine = prevPoint.y === point.y && point.y === nextPoint.y;
|
|
35
|
+
if (isHorizontalLine) {
|
|
36
|
+
return `L${point.x + (isPreviousPointToTheRight ? radius : -radius)},${point.y}`;
|
|
37
|
+
}
|
|
38
|
+
if (isVerticalLine) {
|
|
39
|
+
return `L${point.x},${point.y + (isPreviousPointAbove ? -radius : radius)}`;
|
|
40
|
+
}
|
|
41
|
+
const rotateClockwise = isPreviousPointToTheLeft && isNextPointBelow || isPreviousPointToTheRight && isNextPointAbove || isPreviousPointAbove && isNextPointToTheLeft || isPreviousPointBelow && isNextPointToTheRight;
|
|
42
|
+
const isVertical = prevPoint.x === point.x;
|
|
43
|
+
if (isVertical) {
|
|
44
|
+
const lineSegment = `L${point.x},${point.y + (isPreviousPointAbove ? -radius : radius)}`;
|
|
45
|
+
const arcSegment = `A${radius},${radius},0,0,${rotateClockwise ? 1 : 0},${point.x + (isNextPointToTheRight ? radius : -radius)},${point.y}`;
|
|
46
|
+
return `${lineSegment} ${arcSegment}`;
|
|
47
|
+
} else {
|
|
48
|
+
const lineSegment = `L${point.x + (isPreviousPointToTheRight ? radius : -radius)},${point.y}`;
|
|
49
|
+
const arcSegment = `A${radius},${radius},0,0,${rotateClockwise ? 1 : 0},${point.x},${point.y + (isNextPointAbove ? -radius : radius)}`;
|
|
50
|
+
return `${lineSegment} ${arcSegment}`;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return `M ${source.x},${source.y} ${pathArray.join(" ")} L ${target.x},${target.y}`;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export { computeOrthogonalPath };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { computeLinearSegmentLengths, interpolateAlongLinearSegments } from '../../utils/linear-segment-utils.mjs';
|
|
2
|
+
import { normalizeDistance } from '../../utils/normalize-distance.mjs';
|
|
3
|
+
|
|
4
|
+
const computeOrthogonalPointAtDistance = (points, distancePx) => {
|
|
5
|
+
if (points.length < 2)
|
|
6
|
+
return points[0] || { x: 0, y: 0 };
|
|
7
|
+
const { lengths, totalLength } = computeLinearSegmentLengths(points);
|
|
8
|
+
const targetLength = normalizeDistance(distancePx, totalLength);
|
|
9
|
+
return interpolateAlongLinearSegments(points, lengths, targetLength);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { computeOrthogonalPointAtDistance };
|