@avis-studio/engine 0.0.0-stage → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +193 -2
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/a11y/focus.d.ts +60 -0
- package/dist/a11y/focus.js +222 -0
- package/dist/a11y/index.d.ts +2 -0
- package/dist/a11y/index.js +4 -0
- package/dist/a11y/semantics.d.ts +37 -0
- package/dist/a11y/semantics.js +88 -0
- package/dist/commands/builtins.d.ts +88 -0
- package/dist/commands/builtins.js +362 -0
- package/dist/commands/command.d.ts +23 -0
- package/dist/commands/command.js +20 -0
- package/dist/commands/draft.d.ts +33 -0
- package/dist/commands/draft.js +96 -0
- package/dist/commands/history.d.ts +34 -0
- package/dist/commands/history.js +80 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.js +6 -0
- package/dist/commands/patch.d.ts +24 -0
- package/dist/commands/patch.js +44 -0
- package/dist/commands/transaction.d.ts +16 -0
- package/dist/commands/transaction.js +39 -0
- package/dist/core/diagnostics.d.ts +23 -0
- package/dist/core/diagnostics.js +23 -0
- package/dist/core/disposable.d.ts +14 -0
- package/dist/core/disposable.js +51 -0
- package/dist/core/engine.d.ts +108 -0
- package/dist/core/engine.js +323 -0
- package/dist/core/event-bus.d.ts +10 -0
- package/dist/core/event-bus.js +33 -0
- package/dist/core/ids.d.ts +13 -0
- package/dist/core/ids.js +6 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +7 -0
- package/dist/core/plugin.d.ts +20 -0
- package/dist/core/plugin.js +47 -0
- package/dist/core/services.d.ts +14 -0
- package/dist/core/services.js +20 -0
- package/dist/devtools/index.d.ts +1 -0
- package/dist/devtools/index.js +2 -0
- package/dist/devtools/panel.d.ts +39 -0
- package/dist/devtools/panel.js +100 -0
- package/dist/dom/a11y-layer.d.ts +32 -0
- package/dist/dom/a11y-layer.js +358 -0
- package/dist/dom/anchor.d.ts +34 -0
- package/dist/dom/anchor.js +35 -0
- package/dist/dom/index.d.ts +6 -0
- package/dist/dom/index.js +8 -0
- package/dist/dom/menu.d.ts +24 -0
- package/dist/dom/menu.js +122 -0
- package/dist/dom/overlays.d.ts +29 -0
- package/dist/dom/overlays.js +82 -0
- package/dist/dom/paint/collect.d.ts +8 -0
- package/dist/dom/paint/collect.js +589 -0
- package/dist/dom/paint/css.d.ts +86 -0
- package/dist/dom/paint/css.js +526 -0
- package/dist/dom/paint/draw.d.ts +16 -0
- package/dist/dom/paint/draw.js +413 -0
- package/dist/dom/paint/ghost.d.ts +2 -0
- package/dist/dom/paint/ghost.js +8 -0
- package/dist/dom/paint/index.d.ts +6 -0
- package/dist/dom/paint/index.js +9 -0
- package/dist/dom/paint/text.d.ts +26 -0
- package/dist/dom/paint/text.js +209 -0
- package/dist/dom/paint/types.d.ts +174 -0
- package/dist/dom/paint/types.js +7 -0
- package/dist/dom/paint/watch.d.ts +10 -0
- package/dist/dom/paint/watch.js +109 -0
- package/dist/dom/position.d.ts +37 -0
- package/dist/dom/position.js +125 -0
- package/dist/dom/text-editor.d.ts +27 -0
- package/dist/dom/text-editor.js +128 -0
- package/dist/events/event.d.ts +122 -0
- package/dist/events/event.js +130 -0
- package/dist/events/eventer.d.ts +24 -0
- package/dist/events/eventer.js +83 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.js +3 -0
- package/dist/events/interaction.d.ts +43 -0
- package/dist/events/interaction.js +203 -0
- package/dist/geometry/anchors.d.ts +14 -0
- package/dist/geometry/anchors.js +13 -0
- package/dist/geometry/bounds.d.ts +16 -0
- package/dist/geometry/bounds.js +42 -0
- package/dist/geometry/curves.d.ts +39 -0
- package/dist/geometry/curves.js +68 -0
- package/dist/geometry/index.d.ts +6 -0
- package/dist/geometry/index.js +6 -0
- package/dist/geometry/matrix.d.ts +22 -0
- package/dist/geometry/matrix.js +56 -0
- package/dist/geometry/spaces.d.ts +22 -0
- package/dist/geometry/spaces.js +28 -0
- package/dist/geometry/vec2.d.ts +12 -0
- package/dist/geometry/vec2.js +10 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +22 -0
- package/dist/interaction/behaviors.d.ts +10 -0
- package/dist/interaction/behaviors.js +744 -0
- package/dist/interaction/controller.d.ts +180 -0
- package/dist/interaction/controller.js +269 -0
- package/dist/interaction/hit-test.d.ts +45 -0
- package/dist/interaction/hit-test.js +119 -0
- package/dist/interaction/index.d.ts +4 -0
- package/dist/interaction/index.js +7 -0
- package/dist/interaction/web-input.d.ts +13 -0
- package/dist/interaction/web-input.js +172 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +2 -0
- package/dist/layout/layout.d.ts +27 -0
- package/dist/layout/layout.js +266 -0
- package/dist/react/canvas/graph.d.ts +83 -0
- package/dist/react/canvas/graph.js +89 -0
- package/dist/react/canvas/hooks.d.ts +42 -0
- package/dist/react/canvas/hooks.js +78 -0
- package/dist/react/canvas/index.d.ts +35 -0
- package/dist/react/canvas/index.js +8 -0
- package/dist/react/components.d.ts +55 -0
- package/dist/react/components.js +197 -0
- package/dist/react/context.d.ts +4 -0
- package/dist/react/context.js +9 -0
- package/dist/react/flow/api/LICENSE +21 -0
- package/dist/react/flow/api/externals.d.ts +12 -0
- package/dist/react/flow/api/react/additional-components/Background/Background.d.ts +7 -0
- package/dist/react/flow/api/react/additional-components/Background/Patterns.d.ts +17 -0
- package/dist/react/flow/api/react/additional-components/Background/index.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/Background/types.d.ts +25 -0
- package/dist/react/flow/api/react/additional-components/Controls/ControlButton.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/Controls/Controls.d.ts +7 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/FitView.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Lock.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Minus.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Plus.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/Icons/Unlock.d.ts +1 -0
- package/dist/react/flow/api/react/additional-components/Controls/index.d.ts +3 -0
- package/dist/react/flow/api/react/additional-components/Controls/types.d.ts +20 -0
- package/dist/react/flow/api/react/additional-components/EdgeToolbar/EdgeToolbar.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/EdgeToolbar/index.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/EdgeToolbar/types.d.ts +6 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/MiniMap.d.ts +8 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNode.d.ts +4 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/MiniMapNodes.d.ts +5 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/index.d.ts +3 -0
- package/dist/react/flow/api/react/additional-components/MiniMap/types.d.ts +44 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizeControl.d.ts +5 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/NodeResizer.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/index.d.ts +3 -0
- package/dist/react/flow/api/react/additional-components/NodeResizer/types.d.ts +32 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbar.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/NodeToolbarPortal.d.ts +4 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/index.d.ts +2 -0
- package/dist/react/flow/api/react/additional-components/NodeToolbar/types.d.ts +9 -0
- package/dist/react/flow/api/react/additional-components/index.d.ts +6 -0
- package/dist/react/flow/api/react/components/A11yDescriptions/index.d.ts +7 -0
- package/dist/react/flow/api/react/components/Attribution/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/BatchProvider/index.d.ts +10 -0
- package/dist/react/flow/api/react/components/BatchProvider/types.d.ts +6 -0
- package/dist/react/flow/api/react/components/BatchProvider/useQueue.d.ts +2 -0
- package/dist/react/flow/api/react/components/ConnectionLine/index.d.ts +11 -0
- package/dist/react/flow/api/react/components/EdgeLabelRenderer/index.d.ts +5 -0
- package/dist/react/flow/api/react/components/EdgeWrapper/EdgeUpdateAnchors.d.ts +14 -0
- package/dist/react/flow/api/react/components/EdgeWrapper/index.d.ts +5 -0
- package/dist/react/flow/api/react/components/EdgeWrapper/utils.d.ts +11 -0
- package/dist/react/flow/api/react/components/Edges/BaseEdge.d.ts +2 -0
- package/dist/react/flow/api/react/components/Edges/BezierEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/EdgeAnchor.d.ts +13 -0
- package/dist/react/flow/api/react/components/Edges/EdgeText.d.ts +7 -0
- package/dist/react/flow/api/react/components/Edges/SimpleBezierEdge.d.ts +20 -0
- package/dist/react/flow/api/react/components/Edges/SmoothStepEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/StepEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/StraightEdge.d.ts +4 -0
- package/dist/react/flow/api/react/components/Edges/index.d.ts +5 -0
- package/dist/react/flow/api/react/components/Handle/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/NodeWrapper/index.d.ts +4 -0
- package/dist/react/flow/api/react/components/NodeWrapper/useNodeObserver.d.ts +7 -0
- package/dist/react/flow/api/react/components/NodeWrapper/utils.d.ts +8 -0
- package/dist/react/flow/api/react/components/Nodes/DefaultNode.d.ts +2 -0
- package/dist/react/flow/api/react/components/Nodes/GroupNode.d.ts +1 -0
- package/dist/react/flow/api/react/components/Nodes/InputNode.d.ts +2 -0
- package/dist/react/flow/api/react/components/Nodes/OutputNode.d.ts +2 -0
- package/dist/react/flow/api/react/components/Nodes/utils.d.ts +12 -0
- package/dist/react/flow/api/react/components/NodesSelection/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/Panel/index.d.ts +8 -0
- package/dist/react/flow/api/react/components/ReactFlowProvider/index.d.ts +20 -0
- package/dist/react/flow/api/react/components/SelectionListener/index.d.ts +6 -0
- package/dist/react/flow/api/react/components/StoreUpdater/index.d.ts +67 -0
- package/dist/react/flow/api/react/components/UserSelection/index.d.ts +1 -0
- package/dist/react/flow/api/react/components/ViewportPortal/index.d.ts +4 -0
- package/dist/react/flow/api/react/container/EdgeRenderer/MarkerDefinitions.d.ts +9 -0
- package/dist/react/flow/api/react/container/EdgeRenderer/MarkerSymbols.d.ts +8 -0
- package/dist/react/flow/api/react/container/EdgeRenderer/index.d.ts +12 -0
- package/dist/react/flow/api/react/container/FlowRenderer/index.d.ts +13 -0
- package/dist/react/flow/api/react/container/GraphView/index.d.ts +10 -0
- package/dist/react/flow/api/react/container/GraphView/useNodeOrEdgeTypesWarning.d.ts +3 -0
- package/dist/react/flow/api/react/container/GraphView/useStylesLoadedWarning.d.ts +1 -0
- package/dist/react/flow/api/react/container/NodeRenderer/index.d.ts +9 -0
- package/dist/react/flow/api/react/container/NodeRenderer/useResizeObserver.d.ts +1 -0
- package/dist/react/flow/api/react/container/Pane/index.d.ts +10 -0
- package/dist/react/flow/api/react/container/ReactFlow/Wrapper.d.ts +19 -0
- package/dist/react/flow/api/react/container/ReactFlow/index.d.ts +3 -0
- package/dist/react/flow/api/react/container/ReactFlow/init-values.d.ts +3 -0
- package/dist/react/flow/api/react/container/Viewport/index.d.ts +6 -0
- package/dist/react/flow/api/react/container/ZoomPane/index.d.ts +7 -0
- package/dist/react/flow/api/react/contexts/HandleConfigContext.d.ts +11 -0
- package/dist/react/flow/api/react/contexts/NodeIdContext.d.ts +5 -0
- package/dist/react/flow/api/react/contexts/StoreContext.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useColorModeClass.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useConnection.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useDrag.d.ts +12 -0
- package/dist/react/flow/api/react/hooks/useEdges.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useGlobalKeyHandler.d.ts +5 -0
- package/dist/react/flow/api/react/hooks/useHandleConnections.d.ts +10 -0
- package/dist/react/flow/api/react/hooks/useInternalNode.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useKeyPress.d.ts +7 -0
- package/dist/react/flow/api/react/hooks/useMoveSelectedNodes.d.ts +5 -0
- package/dist/react/flow/api/react/hooks/useNodeConnections.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useNodes.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useNodesData.d.ts +4 -0
- package/dist/react/flow/api/react/hooks/useNodesEdgesState.d.ts +12 -0
- package/dist/react/flow/api/react/hooks/useNodesInitialized.d.ts +4 -0
- package/dist/react/flow/api/react/hooks/useOnEdgesChangeMiddleware.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useOnInitHandler.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useOnNodesChangeMiddleware.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useOnSelectionChange.d.ts +5 -0
- package/dist/react/flow/api/react/hooks/useOnViewportChange.d.ts +7 -0
- package/dist/react/flow/api/react/hooks/useReactFlow.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useResizeHandler.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useStore.d.ts +8 -0
- package/dist/react/flow/api/react/hooks/useUpdateNodeInternals.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useViewport.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useViewportHelper.d.ts +3 -0
- package/dist/react/flow/api/react/hooks/useViewportSync.d.ts +2 -0
- package/dist/react/flow/api/react/hooks/useVisibleEdgeIds.d.ts +1 -0
- package/dist/react/flow/api/react/hooks/useVisibleNodeIds.d.ts +1 -0
- package/dist/react/flow/api/react/index.d.ts +41 -0
- package/dist/react/flow/api/react/store/index.d.ts +18 -0
- package/dist/react/flow/api/react/store/initialState.d.ts +18 -0
- package/dist/react/flow/api/react/styles/utils.d.ts +2 -0
- package/dist/react/flow/api/react/types/component-props.d.ts +127 -0
- package/dist/react/flow/api/react/types/edges.d.ts +111 -0
- package/dist/react/flow/api/react/types/general.d.ts +53 -0
- package/dist/react/flow/api/react/types/index.d.ts +6 -0
- package/dist/react/flow/api/react/types/instance.d.ts +64 -0
- package/dist/react/flow/api/react/types/nodes.d.ts +41 -0
- package/dist/react/flow/api/react/types/store.d.ts +114 -0
- package/dist/react/flow/api/react/utils/changes.d.ts +15 -0
- package/dist/react/flow/api/react/utils/edges.d.ts +3 -0
- package/dist/react/flow/api/react/utils/general.d.ts +5 -0
- package/dist/react/flow/api/react/utils/index.d.ts +3 -0
- package/dist/react/flow/api/system/constants.d.ts +43 -0
- package/dist/react/flow/api/system/index.d.ts +8 -0
- package/dist/react/flow/api/system/types/changes.d.ts +48 -0
- package/dist/react/flow/api/system/types/edges.d.ts +72 -0
- package/dist/react/flow/api/system/types/general.d.ts +175 -0
- package/dist/react/flow/api/system/types/handles.d.ts +21 -0
- package/dist/react/flow/api/system/types/index.d.ts +7 -0
- package/dist/react/flow/api/system/types/nodes.d.ts +89 -0
- package/dist/react/flow/api/system/types/panzoom.d.ts +58 -0
- package/dist/react/flow/api/system/types/utils.d.ts +46 -0
- package/dist/react/flow/api/system/utils/attribution.d.ts +1 -0
- package/dist/react/flow/api/system/utils/connections.d.ts +4 -0
- package/dist/react/flow/api/system/utils/dom.d.ts +20 -0
- package/dist/react/flow/api/system/utils/edge-toolbar.d.ts +1 -0
- package/dist/react/flow/api/system/utils/edges/bezier-edge.d.ts +40 -0
- package/dist/react/flow/api/system/utils/edges/general.d.ts +44 -0
- package/dist/react/flow/api/system/utils/edges/index.d.ts +5 -0
- package/dist/react/flow/api/system/utils/edges/positions.d.ts +16 -0
- package/dist/react/flow/api/system/utils/edges/smoothstep-edge.d.ts +21 -0
- package/dist/react/flow/api/system/utils/edges/straight-edge.d.ts +13 -0
- package/dist/react/flow/api/system/utils/general.d.ts +56 -0
- package/dist/react/flow/api/system/utils/graph.d.ts +45 -0
- package/dist/react/flow/api/system/utils/index.d.ts +12 -0
- package/dist/react/flow/api/system/utils/marker.d.ts +8 -0
- package/dist/react/flow/api/system/utils/node-toolbar.d.ts +2 -0
- package/dist/react/flow/api/system/utils/shallow-node-data.d.ts +4 -0
- package/dist/react/flow/api/system/utils/store.d.ts +33 -0
- package/dist/react/flow/api/system/utils/types.d.ts +7 -0
- package/dist/react/flow/api/system/xydrag/XYDrag.d.ts +56 -0
- package/dist/react/flow/api/system/xydrag/index.d.ts +1 -0
- package/dist/react/flow/api/system/xydrag/utils.d.ts +22 -0
- package/dist/react/flow/api/system/xyhandle/XYHandle.d.ts +2 -0
- package/dist/react/flow/api/system/xyhandle/index.d.ts +1 -0
- package/dist/react/flow/api/system/xyhandle/types.d.ts +49 -0
- package/dist/react/flow/api/system/xyhandle/utils.d.ts +9 -0
- package/dist/react/flow/api/system/xyminimap/index.d.ts +27 -0
- package/dist/react/flow/api/system/xypanzoom/XYPanZoom.d.ts +11 -0
- package/dist/react/flow/api/system/xypanzoom/eventhandler.d.ts +45 -0
- package/dist/react/flow/api/system/xypanzoom/filter.d.ts +15 -0
- package/dist/react/flow/api/system/xypanzoom/index.d.ts +1 -0
- package/dist/react/flow/api/system/xypanzoom/utils.d.ts +8 -0
- package/dist/react/flow/api/system/xyresizer/XYResizer.d.ts +51 -0
- package/dist/react/flow/api/system/xyresizer/index.d.ts +2 -0
- package/dist/react/flow/api/system/xyresizer/types.d.ts +26 -0
- package/dist/react/flow/api/system/xyresizer/utils.d.ts +41 -0
- package/dist/react/flow/components.d.ts +148 -0
- package/dist/react/flow/components.js +526 -0
- package/dist/react/flow/configuration.d.ts +6 -0
- package/dist/react/flow/configuration.js +27 -0
- package/dist/react/flow/drag.d.ts +14 -0
- package/dist/react/flow/drag.js +273 -0
- package/dist/react/flow/extras.d.ts +155 -0
- package/dist/react/flow/extras.js +317 -0
- package/dist/react/flow/handle.d.ts +21 -0
- package/dist/react/flow/handle.js +149 -0
- package/dist/react/flow/hooks.d.ts +47 -0
- package/dist/react/flow/hooks.js +131 -0
- package/dist/react/flow/index.d.ts +78 -0
- package/dist/react/flow/index.js +73 -0
- package/dist/react/flow/queries.d.ts +20 -0
- package/dist/react/flow/queries.js +30 -0
- package/dist/react/flow/react-flow.d.ts +73 -0
- package/dist/react/flow/react-flow.js +1445 -0
- package/dist/react/flow/resize.d.ts +30 -0
- package/dist/react/flow/resize.js +49 -0
- package/dist/react/flow/store.d.ts +412 -0
- package/dist/react/flow/store.js +713 -0
- package/dist/react/flow/style.css +630 -0
- package/dist/react/flow/style.css.d.ts +2 -0
- package/dist/react/flow/system.d.ts +146 -0
- package/dist/react/flow/system.js +300 -0
- package/dist/react/flow/types.d.ts +131 -0
- package/dist/react/flow/types.js +1 -0
- package/dist/react/flow/utils.d.ts +77 -0
- package/dist/react/flow/utils.js +285 -0
- package/dist/react/hooks.d.ts +14 -0
- package/dist/react/hooks.js +44 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +5 -0
- package/dist/render/backend.d.ts +26 -0
- package/dist/render/backend.js +5 -0
- package/dist/render/canvas2d/backend.d.ts +7 -0
- package/dist/render/canvas2d/backend.js +122 -0
- package/dist/render/canvas2d/index.d.ts +1 -0
- package/dist/render/canvas2d/index.js +2 -0
- package/dist/render/color.d.ts +9 -0
- package/dist/render/color.js +69 -0
- package/dist/render/commands.d.ts +69 -0
- package/dist/render/commands.js +1 -0
- package/dist/render/display-list.d.ts +65 -0
- package/dist/render/display-list.js +316 -0
- package/dist/render/images.d.ts +35 -0
- package/dist/render/images.js +83 -0
- package/dist/render/index.d.ts +14 -0
- package/dist/render/index.js +16 -0
- package/dist/render/painters.d.ts +35 -0
- package/dist/render/painters.js +109 -0
- package/dist/render/renderer.d.ts +70 -0
- package/dist/render/renderer.js +162 -0
- package/dist/render/scene-index.d.ts +21 -0
- package/dist/render/scene-index.js +64 -0
- package/dist/render/text.d.ts +8 -0
- package/dist/render/text.js +100 -0
- package/dist/render/theme.d.ts +21 -0
- package/dist/render/theme.js +33 -0
- package/dist/render/ui.d.ts +63 -0
- package/dist/render/ui.js +188 -0
- package/dist/render/webgl2/atlas.d.ts +36 -0
- package/dist/render/webgl2/atlas.js +93 -0
- package/dist/render/webgl2/backend.d.ts +19 -0
- package/dist/render/webgl2/backend.js +338 -0
- package/dist/render/webgl2/index.d.ts +2 -0
- package/dist/render/webgl2/index.js +3 -0
- package/dist/render/webgl2/shaders.d.ts +6 -0
- package/dist/render/webgl2/shaders.js +112 -0
- package/dist/render/webgpu/index.d.ts +1 -0
- package/dist/render/webgpu/index.js +3 -0
- package/dist/scene/builtins.d.ts +25 -0
- package/dist/scene/builtins.js +60 -0
- package/dist/scene/dirty.d.ts +11 -0
- package/dist/scene/dirty.js +10 -0
- package/dist/scene/index.d.ts +5 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/record.d.ts +40 -0
- package/dist/scene/record.js +12 -0
- package/dist/scene/scene-graph.d.ts +58 -0
- package/dist/scene/scene-graph.js +178 -0
- package/dist/scene/schema.d.ts +27 -0
- package/dist/scene/schema.js +32 -0
- package/dist/sdk/create-avis.d.ts +109 -0
- package/dist/sdk/create-avis.js +162 -0
- package/dist/sdk/index.d.ts +1 -0
- package/dist/sdk/index.js +2 -0
- package/dist/serialization/format.d.ts +46 -0
- package/dist/serialization/format.js +20 -0
- package/dist/serialization/index.d.ts +3 -0
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/migrate.d.ts +7 -0
- package/dist/serialization/migrate.js +54 -0
- package/dist/serialization/serialize.d.ts +10 -0
- package/dist/serialization/serialize.js +114 -0
- package/dist/state/index.d.ts +2 -0
- package/dist/state/index.js +2 -0
- package/dist/state/selector.d.ts +6 -0
- package/dist/state/selector.js +29 -0
- package/dist/state/store.d.ts +91 -0
- package/dist/state/store.js +102 -0
- package/dist/style/computed.d.ts +84 -0
- package/dist/style/computed.js +296 -0
- package/dist/style/index.d.ts +6 -0
- package/dist/style/index.js +8 -0
- package/dist/style/style-engine.d.ts +33 -0
- package/dist/style/style-engine.js +113 -0
- package/dist/style/tokens.d.ts +49 -0
- package/dist/style/tokens.js +142 -0
- package/dist/style/utilities.d.ts +34 -0
- package/dist/style/utilities.js +341 -0
- package/dist/style/values.d.ts +30 -0
- package/dist/style/values.js +361 -0
- package/dist/style/variants.d.ts +38 -0
- package/dist/style/variants.js +55 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +1 -0
- package/dist/sync/save-queue.d.ts +24 -0
- package/dist/sync/save-queue.js +88 -0
- package/dist/wasm/index.d.ts +2 -0
- package/dist/wasm/index.js +2 -0
- package/dist/wasm/load.d.ts +7 -0
- package/dist/wasm/load.js +47 -0
- package/dist/wasm/pkg/avis_engine_wasm.d.ts +84 -0
- package/dist/wasm/pkg/avis_engine_wasm.js +339 -0
- package/dist/wasm/pkg/avis_engine_wasm_bg.wasm +0 -0
- package/dist/wasm/reference.d.ts +38 -0
- package/dist/wasm/reference.js +174 -0
- package/package.json +76 -4
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { expandResizeBounds, resizeRect } from "./resize.js";
|
|
3
|
+
/*
|
|
4
|
+
* React Flow's components on the compatibility layer, with its DOM and
|
|
5
|
+
* classes: Handle, NodeToolbar, NodeResizer, Panel, Background, MiniMap,
|
|
6
|
+
* EdgeLabelRenderer, ViewportPortal and BaseEdge.
|
|
7
|
+
*/
|
|
8
|
+
import { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
10
|
+
import { NodeIdContext, StoreContext, useStore } from "./hooks.js";
|
|
11
|
+
import { onHandlePointerDown } from "./handle.js";
|
|
12
|
+
import { getPointerPosition, isValidHandle } from "./system.js";
|
|
13
|
+
import { addEdge } from "./utils.js";
|
|
14
|
+
const IDLE = {
|
|
15
|
+
connectingFrom: false,
|
|
16
|
+
connectingTo: false,
|
|
17
|
+
clickConnecting: false,
|
|
18
|
+
isPossibleEndHandle: true,
|
|
19
|
+
connectionInProcess: false,
|
|
20
|
+
clickConnectionInProcess: false,
|
|
21
|
+
valid: false,
|
|
22
|
+
};
|
|
23
|
+
export function Handle({ type = "source", position = "top", id = null, isConnectable = true, isConnectableStart = true, isConnectableEnd = true, onConnect, isValidConnection, className, children, onMouseDown, onTouchStart, ...rest }) {
|
|
24
|
+
const store = useContext(StoreContext);
|
|
25
|
+
const nodeId = useContext(NodeIdContext);
|
|
26
|
+
const handleId = id || null;
|
|
27
|
+
const isTarget = type === "target";
|
|
28
|
+
const connectOnClick = useStore((s) => s.connectOnClick) ?? true;
|
|
29
|
+
const rfId = useStore((s) => s.rfId);
|
|
30
|
+
const noDrag = useStore(s => s.noDragClassName ?? "nodrag");
|
|
31
|
+
const noPan = useStore(s => s.noPanClassName ?? "nopan");
|
|
32
|
+
// xyflow's connectingSelector.
|
|
33
|
+
const state = useStore((s) => {
|
|
34
|
+
const { connectionClickStartHandle: clickHandle, connectionMode, connection } = s;
|
|
35
|
+
const { fromHandle, toHandle, isValid } = connection;
|
|
36
|
+
if (!fromHandle && !clickHandle)
|
|
37
|
+
return IDLE;
|
|
38
|
+
const connectingTo = toHandle?.nodeId === nodeId && toHandle?.id === handleId && toHandle?.type === type;
|
|
39
|
+
return {
|
|
40
|
+
connectingFrom: fromHandle?.nodeId === nodeId && fromHandle?.id === handleId && fromHandle?.type === type,
|
|
41
|
+
connectingTo,
|
|
42
|
+
clickConnecting: clickHandle?.nodeId === nodeId && clickHandle?.id === handleId && clickHandle?.type === type,
|
|
43
|
+
isPossibleEndHandle: connectionMode === "strict" ? fromHandle?.type !== type : nodeId !== fromHandle?.nodeId || handleId !== fromHandle?.id,
|
|
44
|
+
connectionInProcess: !!fromHandle,
|
|
45
|
+
clickConnectionInProcess: !!clickHandle,
|
|
46
|
+
valid: connectingTo && Boolean(isValid),
|
|
47
|
+
};
|
|
48
|
+
}, (a, b) => Object.keys(a).every((k) => a[k] === b[k]));
|
|
49
|
+
const onConnectExtended = (params) => {
|
|
50
|
+
const { defaultEdgeOptions, onConnect: onConnectAction, hasDefaultEdges } = store.getState();
|
|
51
|
+
const edgeParams = { ...defaultEdgeOptions, ...params };
|
|
52
|
+
if (hasDefaultEdges) {
|
|
53
|
+
const { edges, setEdges } = store.getState();
|
|
54
|
+
setEdges(addEdge(edgeParams, edges));
|
|
55
|
+
}
|
|
56
|
+
onConnectAction?.(edgeParams);
|
|
57
|
+
onConnect?.(edgeParams);
|
|
58
|
+
};
|
|
59
|
+
const validate = (connection) => isValidConnection?.(connection) ??
|
|
60
|
+
(store.getState().isValidConnection?.(connection) ?? true);
|
|
61
|
+
const onPointerDown = (event) => {
|
|
62
|
+
if (!nodeId)
|
|
63
|
+
return;
|
|
64
|
+
const mouse = "clientX" in event.nativeEvent;
|
|
65
|
+
if (isConnectable && isConnectableStart && ((mouse && event.button === 0) || !mouse)) {
|
|
66
|
+
onHandlePointerDown(event.nativeEvent, {
|
|
67
|
+
store,
|
|
68
|
+
handleDomNode: event.currentTarget,
|
|
69
|
+
nodeId,
|
|
70
|
+
handleId,
|
|
71
|
+
isTarget,
|
|
72
|
+
onConnect: onConnectExtended,
|
|
73
|
+
isValidConnection: validate,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (mouse)
|
|
77
|
+
onMouseDown?.(event);
|
|
78
|
+
else
|
|
79
|
+
onTouchStart?.(event);
|
|
80
|
+
};
|
|
81
|
+
const onClick = (event) => {
|
|
82
|
+
const s = store.getState();
|
|
83
|
+
const clickStart = s.connectionClickStartHandle;
|
|
84
|
+
if (!nodeId || (!clickStart && !isConnectableStart))
|
|
85
|
+
return;
|
|
86
|
+
if (!clickStart) {
|
|
87
|
+
;
|
|
88
|
+
s.onClickConnectStart?.(event.nativeEvent, { nodeId, handleId, handleType: type });
|
|
89
|
+
store.setState({ connectionClickStartHandle: { nodeId, type, id: handleId } });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const doc = event.target.getRootNode?.() ?? document;
|
|
93
|
+
const { connection, isValid } = isValidHandle(event.nativeEvent, {
|
|
94
|
+
handle: { nodeId, id: handleId, type },
|
|
95
|
+
connectionMode: s.connectionMode,
|
|
96
|
+
fromNodeId: clickStart.nodeId,
|
|
97
|
+
fromHandleId: clickStart.id || null,
|
|
98
|
+
fromType: clickStart.type,
|
|
99
|
+
isValidConnection: (c) => isValidConnection?.(c) ?? (s.isValidConnection?.(c) ?? true),
|
|
100
|
+
doc,
|
|
101
|
+
flowId: s.rfId,
|
|
102
|
+
nodeLookup: s.nodeLookup,
|
|
103
|
+
});
|
|
104
|
+
if (isValid && connection)
|
|
105
|
+
onConnectExtended(connection);
|
|
106
|
+
const { inProgress: _inProgress, ...clone } = s.connection;
|
|
107
|
+
void _inProgress;
|
|
108
|
+
s.onClickConnectEnd?.(event, { ...clone, toPosition: clone.toHandle ? clone.toHandle.position : null });
|
|
109
|
+
store.setState({ connectionClickStartHandle: null });
|
|
110
|
+
};
|
|
111
|
+
const classes = [
|
|
112
|
+
"avis-flow__handle",
|
|
113
|
+
`avis-flow__handle-${position}`,
|
|
114
|
+
noDrag,
|
|
115
|
+
noPan,
|
|
116
|
+
className ?? "",
|
|
117
|
+
isTarget ? "target" : "source",
|
|
118
|
+
isConnectable ? "connectable" : "",
|
|
119
|
+
isConnectableStart ? "connectablestart" : "",
|
|
120
|
+
isConnectableEnd ? "connectableend" : "",
|
|
121
|
+
state.clickConnecting ? "clickconnecting" : "",
|
|
122
|
+
state.connectingFrom ? "connectingfrom" : "",
|
|
123
|
+
state.connectingTo ? "connectingto" : "",
|
|
124
|
+
state.valid ? "valid" : "",
|
|
125
|
+
isConnectable &&
|
|
126
|
+
(!state.connectionInProcess || state.isPossibleEndHandle) &&
|
|
127
|
+
(state.connectionInProcess || state.clickConnectionInProcess ? isConnectableEnd : isConnectableStart)
|
|
128
|
+
? "connectionindicator"
|
|
129
|
+
: "",
|
|
130
|
+
]
|
|
131
|
+
.filter(Boolean)
|
|
132
|
+
.join(" ");
|
|
133
|
+
return (_jsx("div", { "data-handleid": handleId, "data-nodeid": nodeId ?? undefined, "data-handlepos": position, "data-id": `${rfId}-${nodeId}-${handleId}-${type}`, className: classes, onMouseDown: onPointerDown, onTouchStart: onPointerDown, onClick: connectOnClick ? onClick : undefined, ...rest, children: children }));
|
|
134
|
+
}
|
|
135
|
+
/** React Flow's panel: a corner or edge of the canvas. */
|
|
136
|
+
export function Panel({ position = "top-left", className, style, children, ...rest }) {
|
|
137
|
+
return (_jsx("div", { className: `avis-flow__panel ${position.split("-").join(" ")}${className ? ` ${className}` : ""}`, style: style, ...rest, children: children }));
|
|
138
|
+
}
|
|
139
|
+
const renderer = (s) => s.domNode?.querySelector(".avis-flow__renderer") ?? null;
|
|
140
|
+
/** DOM above (or beside) a node, in screen space, as React Flow's NodeToolbar. */
|
|
141
|
+
export function NodeToolbar({ nodeId, isVisible, position = "top", offset = 10, align = "center", className, style, children, ...rest }) {
|
|
142
|
+
const contextId = useContext(NodeIdContext);
|
|
143
|
+
const ids = useMemo(() => (nodeId === undefined ? (contextId ? [contextId] : []) : Array.isArray(nodeId) ? nodeId : [nodeId]), [nodeId, contextId]);
|
|
144
|
+
const key = ids.join(" ");
|
|
145
|
+
const nodes = useStore((s) => ids.map((id) => s.nodeLookup.get(id)).filter(Boolean), (a, b) => a.length === b.length && a.every((n, i) => n === b[i]));
|
|
146
|
+
const selectedCount = useStore((s) => s.selectedNodeCount);
|
|
147
|
+
const transform = useStore((s) => s.transform);
|
|
148
|
+
const portal = useStore(renderer);
|
|
149
|
+
const visible = typeof isVisible === "boolean" ? isVisible : nodes.length === 1 && Boolean(nodes[0]?.selected) && selectedCount === 1;
|
|
150
|
+
if (!visible || !portal || !nodes.length)
|
|
151
|
+
return null;
|
|
152
|
+
let minX = Infinity;
|
|
153
|
+
let minY = Infinity;
|
|
154
|
+
let maxX = -Infinity;
|
|
155
|
+
let maxY = -Infinity;
|
|
156
|
+
let z = 0;
|
|
157
|
+
for (const node of nodes) {
|
|
158
|
+
const { x, y } = node.internals.positionAbsolute;
|
|
159
|
+
minX = Math.min(minX, x);
|
|
160
|
+
minY = Math.min(minY, y);
|
|
161
|
+
maxX = Math.max(maxX, x + (node.measured.width ?? 0));
|
|
162
|
+
maxY = Math.max(maxY, y + (node.measured.height ?? 0));
|
|
163
|
+
z = Math.max(z, node.internals.z);
|
|
164
|
+
}
|
|
165
|
+
const [tx, ty, zoom] = transform;
|
|
166
|
+
const rect = { x: minX * zoom + tx, y: minY * zoom + ty, width: (maxX - minX) * zoom, height: (maxY - minY) * zoom };
|
|
167
|
+
// xyflow's getNodeToolbarTransform.
|
|
168
|
+
let x;
|
|
169
|
+
let y = rect.y - offset;
|
|
170
|
+
let shiftX;
|
|
171
|
+
let shiftY = -100;
|
|
172
|
+
const alongX = align === "start" ? rect.x : align === "end" ? rect.x + rect.width : rect.x + rect.width / 2;
|
|
173
|
+
const alongY = align === "start" ? rect.y : align === "end" ? rect.y + rect.height : rect.y + rect.height / 2;
|
|
174
|
+
const alignShift = align === "start" ? 0 : align === "end" ? -100 : -50;
|
|
175
|
+
switch (position) {
|
|
176
|
+
case "bottom":
|
|
177
|
+
x = alongX;
|
|
178
|
+
y = rect.y + rect.height + offset;
|
|
179
|
+
shiftX = alignShift;
|
|
180
|
+
shiftY = 0;
|
|
181
|
+
break;
|
|
182
|
+
case "left":
|
|
183
|
+
x = rect.x - offset;
|
|
184
|
+
y = alongY;
|
|
185
|
+
shiftX = -100;
|
|
186
|
+
shiftY = alignShift;
|
|
187
|
+
break;
|
|
188
|
+
case "right":
|
|
189
|
+
x = rect.x + rect.width + offset;
|
|
190
|
+
y = alongY;
|
|
191
|
+
shiftX = 0;
|
|
192
|
+
shiftY = alignShift;
|
|
193
|
+
break;
|
|
194
|
+
default:
|
|
195
|
+
x = alongX;
|
|
196
|
+
shiftX = alignShift;
|
|
197
|
+
}
|
|
198
|
+
return createPortal(_jsx("div", { className: `avis-flow__node-toolbar${className ? ` ${className}` : ""}`, "data-id": key, style: { position: "absolute", transform: `translate(${x}px, ${y}px) translate(${shiftX}%, ${shiftY}%)`, zIndex: z + 1, ...style }, ...rest, children: children }), portal);
|
|
199
|
+
}
|
|
200
|
+
const LINES = ["top", "right", "bottom", "left"];
|
|
201
|
+
const CORNERS = ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
202
|
+
/** Resize lines and corners inside a node (React Flow's NodeResizer, XYResizer). */
|
|
203
|
+
export function NodeResizer({ nodeId, isVisible = true, minWidth = 10, minHeight = 10, maxWidth = Number.MAX_VALUE, maxHeight = Number.MAX_VALUE, color, handleClassName, handleStyle, lineClassName, lineStyle, keepAspectRatio = false, onResizeStart, onResize, onResizeEnd, controls, autoScale = true, resizeDirection, shouldResize, }) {
|
|
204
|
+
const contextId = useContext(NodeIdContext);
|
|
205
|
+
const id = nodeId ?? contextId;
|
|
206
|
+
const store = useContext(StoreContext);
|
|
207
|
+
const zoom = useStore((s) => s.transform[2]);
|
|
208
|
+
const noDrag = useStore(s => s.noDragClassName ?? "nodrag");
|
|
209
|
+
const active = useRef(undefined);
|
|
210
|
+
useEffect(() => () => active.current?.(), []);
|
|
211
|
+
useEffect(() => { if (!isVisible)
|
|
212
|
+
active.current?.(); }, [isVisible]);
|
|
213
|
+
if (!isVisible || !id)
|
|
214
|
+
return null;
|
|
215
|
+
const start = (control) => (event) => {
|
|
216
|
+
if (event.button !== 0)
|
|
217
|
+
return;
|
|
218
|
+
event.stopPropagation();
|
|
219
|
+
active.current?.();
|
|
220
|
+
const s = store.getState(), node = s.nodeLookup.get(id);
|
|
221
|
+
if (!node)
|
|
222
|
+
return;
|
|
223
|
+
const initial = { ...node.position, width: node.measured.width ?? 0, height: node.measured.height ?? 0 };
|
|
224
|
+
const nodeOrigin = node.origin ?? s.nodeOrigin ?? [0, 0];
|
|
225
|
+
const containerBounds = s.domNode?.getBoundingClientRect() ?? null;
|
|
226
|
+
const pointer = getPointerPosition(event.nativeEvent, { transform: s.transform, snapGrid: s.snapGrid, snapToGrid: s.snapToGrid, containerBounds });
|
|
227
|
+
const target = event.currentTarget, view = target.ownerDocument.defaultView;
|
|
228
|
+
const children = [...s.nodeLookup.values()].filter(n => n.parentId === id);
|
|
229
|
+
const initialWorld = { ...node.internals.positionAbsolute };
|
|
230
|
+
const lockedBoxes = children.filter(child => child.extent === "parent" || child.expandParent).map(child => {
|
|
231
|
+
const origin = child.origin ?? s.nodeOrigin ?? [0, 0];
|
|
232
|
+
const width = child.measured.width ?? 0, height = child.measured.height ?? 0;
|
|
233
|
+
const x = initial.x - initial.width * nodeOrigin[0] + child.position.x - width * origin[0];
|
|
234
|
+
const y = initial.y - initial.height * nodeOrigin[1] + child.position.y - height * origin[1];
|
|
235
|
+
return { x, y, width, height };
|
|
236
|
+
});
|
|
237
|
+
const childExtent = lockedBoxes.length ? [
|
|
238
|
+
[Math.min(...lockedBoxes.map(rect => rect.x)), Math.min(...lockedBoxes.map(rect => rect.y))],
|
|
239
|
+
[Math.max(...lockedBoxes.map(rect => rect.x + rect.width)), Math.max(...lockedBoxes.map(rect => rect.y + rect.height))],
|
|
240
|
+
] : undefined;
|
|
241
|
+
const pointerId = event.pointerId;
|
|
242
|
+
let last = { ...initial, direction: [0, 0] };
|
|
243
|
+
let done = false;
|
|
244
|
+
const resizeEvent = (sourceEvent, type, rect = last) => ({ type, sourceEvent, x: rect.x, y: rect.y, dx: rect.x - last.x, dy: rect.y - last.y, subject: initial, identifier: pointerId, active: type === "end" ? 0 : 1 });
|
|
245
|
+
onResizeStart?.(resizeEvent(event.nativeEvent, "start"), initial);
|
|
246
|
+
s.triggerNodeChanges([{ type: "dimensions", id, resizing: true }]);
|
|
247
|
+
const move = (e) => {
|
|
248
|
+
if (done || e.pointerId !== pointerId)
|
|
249
|
+
return;
|
|
250
|
+
const state = store.getState();
|
|
251
|
+
const currentPointer = getPointerPosition(e, { transform: state.transform, snapGrid: state.snapGrid, snapToGrid: state.snapToGrid, containerBounds });
|
|
252
|
+
const parent = node.parentId ? state.nodeLookup.get(node.parentId) : undefined;
|
|
253
|
+
const extent = node.extent === "parent" && parent && !node.expandParent ? [[0, 0], [parent.measured.width ?? Infinity, parent.measured.height ?? Infinity]] : Array.isArray(node.extent) ? node.extent : undefined;
|
|
254
|
+
const next = resizeRect(initial, { x: currentPointer.xSnapped - pointer.xSnapped, y: currentPointer.ySnapped - pointer.ySnapped }, control, {
|
|
255
|
+
minWidth, minHeight, maxWidth, maxHeight, keepAspectRatio, resizeDirection, origin: nodeOrigin,
|
|
256
|
+
extent, childExtent,
|
|
257
|
+
});
|
|
258
|
+
const topLeft = { x: next.x - next.width * nodeOrigin[0], y: next.y - next.height * nodeOrigin[1] };
|
|
259
|
+
if (node.extent === "parent" && !node.expandParent && parent && (topLeft.x < 0 || topLeft.y < 0 || topLeft.x + next.width > (parent.measured.width ?? Infinity) || topLeft.y + next.height > (parent.measured.height ?? Infinity)))
|
|
260
|
+
return;
|
|
261
|
+
const shiftX = topLeft.x - (initial.x - initial.width * nodeOrigin[0]);
|
|
262
|
+
const shiftY = topLeft.y - (initial.y - initial.height * nodeOrigin[1]);
|
|
263
|
+
if (children.some(child => child.extent === "parent" && (child.position.x - shiftX < 0 || child.position.y - shiftY < 0 || child.position.x - shiftX + (child.measured.width ?? 0) > next.width || child.position.y - shiftY + (child.measured.height ?? 0) > next.height)))
|
|
264
|
+
return;
|
|
265
|
+
const parentChanges = [];
|
|
266
|
+
if (node.expandParent && parent) {
|
|
267
|
+
const before = { ...parent.internals.positionAbsolute, width: parent.measured.width ?? 0, height: parent.measured.height ?? 0 };
|
|
268
|
+
const world = { x: initialWorld.x + shiftX, y: initialWorld.y + shiftY, width: next.width, height: next.height };
|
|
269
|
+
const expanded = expandResizeBounds(before, world);
|
|
270
|
+
const parentOrigin = parent.origin ?? state.nodeOrigin ?? [0, 0];
|
|
271
|
+
const dx = expanded.x - before.x, dy = expanded.y - before.y;
|
|
272
|
+
next.x = world.x - expanded.x + next.width * nodeOrigin[0];
|
|
273
|
+
next.y = world.y - expanded.y + next.height * nodeOrigin[1];
|
|
274
|
+
if (dx || dy || expanded.width !== before.width || expanded.height !== before.height) {
|
|
275
|
+
parentChanges.push({ type: "position", id: parent.id, position: { x: parent.position.x + dx + (expanded.width - before.width) * parentOrigin[0], y: parent.position.y + dy + (expanded.height - before.height) * parentOrigin[1] } });
|
|
276
|
+
parentChanges.push({ type: "dimensions", id: parent.id, dimensions: { width: expanded.width, height: expanded.height }, setAttributes: true });
|
|
277
|
+
for (const sibling of state.nodeLookup.values())
|
|
278
|
+
if (sibling.parentId === parent.id && sibling.id !== id && (dx || dy))
|
|
279
|
+
parentChanges.push({ type: "position", id: sibling.id, position: { x: sibling.position.x - dx, y: sibling.position.y - dy } });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const callbackEvent = resizeEvent(e, "drag", next);
|
|
283
|
+
if (next.x === last.x && next.y === last.y && next.width === last.width && next.height === last.height)
|
|
284
|
+
return;
|
|
285
|
+
next.direction = [Math.sign(next.width - last.width) * (control.includes("left") ? -1 : 1) || 0, Math.sign(next.height - last.height) * (control.includes("top") ? -1 : 1) || 0];
|
|
286
|
+
if (shouldResize && !shouldResize(callbackEvent, next))
|
|
287
|
+
return;
|
|
288
|
+
last = next;
|
|
289
|
+
const changes = [
|
|
290
|
+
{ type: "position", id, position: { x: next.x, y: next.y } },
|
|
291
|
+
{ type: "dimensions", id, dimensions: { width: next.width, height: next.height }, resizing: true, setAttributes: true },
|
|
292
|
+
];
|
|
293
|
+
for (const child of children)
|
|
294
|
+
if (shiftX || shiftY)
|
|
295
|
+
changes.push({ type: "position", id: child.id, position: { x: child.position.x - shiftX, y: child.position.y - shiftY } });
|
|
296
|
+
state.triggerNodeChanges([...parentChanges, ...changes]);
|
|
297
|
+
onResize?.(callbackEvent, next);
|
|
298
|
+
};
|
|
299
|
+
const finish = (e) => {
|
|
300
|
+
if (done || e.pointerId !== pointerId)
|
|
301
|
+
return;
|
|
302
|
+
done = true;
|
|
303
|
+
view.removeEventListener("pointermove", move);
|
|
304
|
+
view.removeEventListener("pointerup", finish);
|
|
305
|
+
view.removeEventListener("pointercancel", finish);
|
|
306
|
+
view.removeEventListener("blur", cancel);
|
|
307
|
+
view.removeEventListener("keydown", escape, true);
|
|
308
|
+
target.removeEventListener("lostpointercapture", finish);
|
|
309
|
+
if (target.hasPointerCapture(pointerId))
|
|
310
|
+
target.releasePointerCapture(pointerId);
|
|
311
|
+
active.current = undefined;
|
|
312
|
+
store.getState().triggerNodeChanges([{ type: "dimensions", id, dimensions: { width: last.width, height: last.height }, resizing: false, setAttributes: true }]);
|
|
313
|
+
onResizeEnd?.(resizeEvent(e, "end"), { x: last.x, y: last.y, width: last.width, height: last.height });
|
|
314
|
+
};
|
|
315
|
+
const cancel = () => finish(event.nativeEvent);
|
|
316
|
+
const escape = (e) => { if (e.key === "Escape")
|
|
317
|
+
cancel(); };
|
|
318
|
+
active.current = cancel;
|
|
319
|
+
target.setPointerCapture(pointerId);
|
|
320
|
+
view.addEventListener("pointermove", move);
|
|
321
|
+
view.addEventListener("pointerup", finish);
|
|
322
|
+
view.addEventListener("pointercancel", finish);
|
|
323
|
+
view.addEventListener("blur", cancel);
|
|
324
|
+
view.addEventListener("keydown", escape, true);
|
|
325
|
+
target.addEventListener("lostpointercapture", finish);
|
|
326
|
+
};
|
|
327
|
+
const scale = autoScale ? Math.max(1 / zoom, 1) : 1;
|
|
328
|
+
const items = controls ?? [...LINES.map(position => ({ position, variant: "line" })), ...CORNERS.map(position => ({ position, variant: "handle" }))];
|
|
329
|
+
return _jsx(_Fragment, { children: items.map(control => {
|
|
330
|
+
const line = control.variant === "line";
|
|
331
|
+
return _jsx("div", { className: `avis-flow__resize-control ${noDrag} ${control.position.replace("-", " ")} ${line ? "line" : "handle"}${control.className ? ` ${control.className}` : line ? lineClassName ? ` ${lineClassName}` : "" : handleClassName ? ` ${handleClassName}` : ""}`, style: { ...(color ? line ? { borderColor: color } : { backgroundColor: color } : {}), ...(!line ? { transform: `translate(-50%, -50%) scale(${scale})` } : {}), touchAction: "none", ...(line ? lineStyle : handleStyle), ...control.style }, onPointerDown: start(control.position), children: control.children }, `${control.variant}-${control.position}`);
|
|
332
|
+
}) });
|
|
333
|
+
}
|
|
334
|
+
let backgrounds = 0;
|
|
335
|
+
/** React Flow's background pattern, moving with the viewport (ported from
|
|
336
|
+
* @xyflow/react's Background, MIT): colours go through its CSS variables. */
|
|
337
|
+
export function Background({ id, variant = "dots", gap = 20, size, color, bgColor, lineWidth = 1, offset = 0, className, patternClassName, style }) {
|
|
338
|
+
const [uid] = useState(() => `bg-${++backgrounds}`);
|
|
339
|
+
const transform = useStore((s) => s.transform);
|
|
340
|
+
const patternSize = size || (variant === "cross" ? 6 : 1);
|
|
341
|
+
const dots = variant === "dots";
|
|
342
|
+
const cross = variant === "cross";
|
|
343
|
+
const [gx, gy] = Array.isArray(gap) ? gap : [gap, gap];
|
|
344
|
+
const scaledGap = [gx * transform[2] || 1, gy * transform[2] || 1];
|
|
345
|
+
const scaledSize = patternSize * transform[2];
|
|
346
|
+
const [ox, oy] = Array.isArray(offset) ? offset : [offset, offset];
|
|
347
|
+
const dims = cross ? [scaledSize, scaledSize] : scaledGap;
|
|
348
|
+
const shift = [ox * transform[2] + dims[0] / 2, oy * transform[2] + dims[1] / 2];
|
|
349
|
+
const patternId = `pattern-${uid}${id ?? ""}`;
|
|
350
|
+
const vars = { "--xy-background-color-props": bgColor, "--xy-background-pattern-color-props": color };
|
|
351
|
+
return (_jsxs("svg", { className: `avis-flow__background${className ? ` ${className}` : ""}`, style: { ...style, position: "absolute", width: "100%", height: "100%", top: 0, left: 0, ...vars }, "data-testid": "rf__background", children: [_jsx("pattern", { id: patternId, x: transform[0] % scaledGap[0], y: transform[1] % scaledGap[1], width: scaledGap[0], height: scaledGap[1], patternUnits: "userSpaceOnUse", patternTransform: `translate(-${shift[0]},-${shift[1]})`, children: dots ? (_jsx("circle", { cx: scaledSize / 2, cy: scaledSize / 2, r: scaledSize / 2, className: `avis-flow__background-pattern dots${patternClassName ? ` ${patternClassName}` : ""}` })) : (_jsx("path", { strokeWidth: lineWidth, d: `M${dims[0] / 2} 0 V${dims[1]} M0 ${dims[1] / 2} H${dims[0]}`, className: `avis-flow__background-pattern ${variant}${patternClassName ? ` ${patternClassName}` : ""}` })) }), _jsx("rect", { x: "0", y: "0", width: "100%", height: "100%", fill: `url(#${patternId})` })] }));
|
|
352
|
+
}
|
|
353
|
+
const attr = (value, fallback) => (typeof value === "function" ? value : () => (value ?? fallback));
|
|
354
|
+
function MiniMapRect({ id, x, y, width, height, style, color, strokeColor, strokeWidth, className, borderRadius, shapeRendering, selected, onClick }) {
|
|
355
|
+
const st = (style ?? {});
|
|
356
|
+
const fill = color || st.background || st.backgroundColor;
|
|
357
|
+
return (_jsx("rect", { className: `avis-flow__minimap-node${selected ? " selected" : ""}${className ? ` ${className}` : ""}`, x: x, y: y, rx: borderRadius, ry: borderRadius, width: width, height: height, style: { fill, stroke: strokeColor, strokeWidth: strokeWidth }, shapeRendering: shapeRendering, onClick: onClick ? (event) => onClick(event, id) : undefined }));
|
|
358
|
+
}
|
|
359
|
+
/** React Flow's MiniMap (ported, MIT): every node as a rect, the view as a mask; drag pans, wheel zooms. */
|
|
360
|
+
export function MiniMap({ style, className, nodeStrokeColor, nodeColor, nodeClassName = "", nodeBorderRadius = 5, nodeStrokeWidth, nodeComponent, bgColor, maskColor, maskStrokeColor, maskStrokeWidth, position = "bottom-right", onClick, onNodeClick, pannable = false, zoomable = false, ariaLabel, inversePan, zoomStep = 1, offsetScale = 5, }) {
|
|
361
|
+
const store = useContext(StoreContext);
|
|
362
|
+
const svg = useRef(null);
|
|
363
|
+
const transform = useStore((s) => s.transform);
|
|
364
|
+
const flowWidth = useStore((s) => s.width);
|
|
365
|
+
const flowHeight = useStore((s) => s.height);
|
|
366
|
+
const rfId = useStore((s) => s.rfId);
|
|
367
|
+
const lookup = useStore((s) => s.nodeLookup);
|
|
368
|
+
useStore((s) => s.nodes);
|
|
369
|
+
const viewBB = { x: -transform[0] / transform[2], y: -transform[1] / transform[2], width: flowWidth / transform[2], height: flowHeight / transform[2] };
|
|
370
|
+
let bx = Infinity;
|
|
371
|
+
let by = Infinity;
|
|
372
|
+
let bx2 = -Infinity;
|
|
373
|
+
let by2 = -Infinity;
|
|
374
|
+
for (const node of lookup.values()) {
|
|
375
|
+
if (node.hidden)
|
|
376
|
+
continue;
|
|
377
|
+
const w = node.measured.width ?? node.width ?? node.initialWidth ?? 0;
|
|
378
|
+
const h = node.measured.height ?? node.height ?? node.initialHeight ?? 0;
|
|
379
|
+
const p = node.internals.positionAbsolute;
|
|
380
|
+
bx = Math.min(bx, p.x);
|
|
381
|
+
by = Math.min(by, p.y);
|
|
382
|
+
bx2 = Math.max(bx2, p.x + w);
|
|
383
|
+
by2 = Math.max(by2, p.y + h);
|
|
384
|
+
}
|
|
385
|
+
const boundingRect = Number.isFinite(bx)
|
|
386
|
+
? (() => {
|
|
387
|
+
const x = Math.min(bx, viewBB.x);
|
|
388
|
+
const y = Math.min(by, viewBB.y);
|
|
389
|
+
return { x, y, width: Math.max(bx2, viewBB.x + viewBB.width) - x, height: Math.max(by2, viewBB.y + viewBB.height) - y };
|
|
390
|
+
})()
|
|
391
|
+
: viewBB;
|
|
392
|
+
const elementWidth = style?.width ?? 200;
|
|
393
|
+
const elementHeight = style?.height ?? 150;
|
|
394
|
+
const viewScale = Math.max(boundingRect.width / elementWidth, boundingRect.height / elementHeight);
|
|
395
|
+
const viewWidth = viewScale * elementWidth;
|
|
396
|
+
const viewHeight = viewScale * elementHeight;
|
|
397
|
+
const offset = offsetScale * viewScale;
|
|
398
|
+
const x = boundingRect.x - (viewWidth - boundingRect.width) / 2 - offset;
|
|
399
|
+
const y = boundingRect.y - (viewHeight - boundingRect.height) / 2 - offset;
|
|
400
|
+
const width = viewWidth + offset * 2;
|
|
401
|
+
const height = viewHeight + offset * 2;
|
|
402
|
+
const labelledBy = `avis-flow__minimap-desc-${rfId}`;
|
|
403
|
+
const viewScaleRef = useRef(viewScale);
|
|
404
|
+
useLayoutEffect(() => {
|
|
405
|
+
viewScaleRef.current = viewScale;
|
|
406
|
+
});
|
|
407
|
+
// XYMinimap: a drag on the minimap pans the flow, the wheel zooms it.
|
|
408
|
+
useEffect(() => {
|
|
409
|
+
const el = svg.current;
|
|
410
|
+
if (!el)
|
|
411
|
+
return;
|
|
412
|
+
let start = null;
|
|
413
|
+
const down = (event) => {
|
|
414
|
+
if (event.button !== 0)
|
|
415
|
+
return;
|
|
416
|
+
start = [event.clientX, event.clientY];
|
|
417
|
+
window.addEventListener("mousemove", move);
|
|
418
|
+
window.addEventListener("mouseup", up);
|
|
419
|
+
};
|
|
420
|
+
const move = (event) => {
|
|
421
|
+
if (!start || !pannable)
|
|
422
|
+
return;
|
|
423
|
+
const [tx, ty, k] = store.getState().transform;
|
|
424
|
+
const delta = [event.clientX - start[0], event.clientY - start[1]];
|
|
425
|
+
start = [event.clientX, event.clientY];
|
|
426
|
+
const moveScale = viewScaleRef.current * Math.max(k, Math.log(k)) * (inversePan ? -1 : 1);
|
|
427
|
+
void store.getState().panZoom?.setViewport({ x: tx - delta[0] * moveScale, y: ty - delta[1] * moveScale, zoom: k });
|
|
428
|
+
};
|
|
429
|
+
const up = () => {
|
|
430
|
+
start = null;
|
|
431
|
+
window.removeEventListener("mousemove", move);
|
|
432
|
+
window.removeEventListener("mouseup", up);
|
|
433
|
+
};
|
|
434
|
+
const wheel = (event) => {
|
|
435
|
+
if (!zoomable)
|
|
436
|
+
return;
|
|
437
|
+
event.preventDefault();
|
|
438
|
+
const [, , k] = store.getState().transform;
|
|
439
|
+
const factor = event.ctrlKey && /Mac/.test(navigator.platform) ? 10 : 1;
|
|
440
|
+
const delta = -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 0.002) * zoomStep;
|
|
441
|
+
void store.getState().panZoom?.scaleTo(k * 2 ** (delta * factor));
|
|
442
|
+
};
|
|
443
|
+
el.addEventListener("mousedown", down);
|
|
444
|
+
el.addEventListener("wheel", wheel, { passive: false });
|
|
445
|
+
return () => {
|
|
446
|
+
el.removeEventListener("mousedown", down);
|
|
447
|
+
el.removeEventListener("wheel", wheel);
|
|
448
|
+
up();
|
|
449
|
+
};
|
|
450
|
+
}, [store, pannable, zoomable, inversePan, zoomStep]);
|
|
451
|
+
const colorOf = attr(nodeColor, undefined);
|
|
452
|
+
const strokeOf = attr(nodeStrokeColor, undefined);
|
|
453
|
+
const classOf = attr(nodeClassName, "");
|
|
454
|
+
const Node = (nodeComponent ?? MiniMapRect);
|
|
455
|
+
const shapeRendering = typeof window === "undefined" || "chrome" in window ? "crispEdges" : "geometricPrecision";
|
|
456
|
+
const defaultLabel = useStore(s => s.ariaLabelConfig["minimap.ariaLabel"]);
|
|
457
|
+
const label = ariaLabel === undefined ? defaultLabel : ariaLabel;
|
|
458
|
+
const vars = {
|
|
459
|
+
"--xy-minimap-background-color-props": typeof bgColor === "string" ? bgColor : undefined,
|
|
460
|
+
"--xy-minimap-mask-background-color-props": typeof maskColor === "string" ? maskColor : undefined,
|
|
461
|
+
"--xy-minimap-mask-stroke-color-props": typeof maskStrokeColor === "string" ? maskStrokeColor : undefined,
|
|
462
|
+
"--xy-minimap-mask-stroke-width-props": typeof maskStrokeWidth === "number" ? maskStrokeWidth * viewScale : undefined,
|
|
463
|
+
"--xy-minimap-node-background-color-props": typeof nodeColor === "string" ? nodeColor : undefined,
|
|
464
|
+
"--xy-minimap-node-stroke-color-props": typeof nodeStrokeColor === "string" ? nodeStrokeColor : undefined,
|
|
465
|
+
"--xy-minimap-node-stroke-width-props": typeof nodeStrokeWidth === "number" ? nodeStrokeWidth : undefined,
|
|
466
|
+
};
|
|
467
|
+
return (_jsx(Panel, { position: position, style: { ...style, ...vars }, className: `avis-flow__minimap${className ? ` ${className}` : ""}`, "data-testid": "rf__minimap", children: _jsxs("svg", { width: elementWidth, height: elementHeight, viewBox: `${x} ${y} ${width} ${height}`, className: "avis-flow__minimap-svg", role: "img", "aria-labelledby": labelledBy, ref: svg, onClick: onClick
|
|
468
|
+
? (event) => {
|
|
469
|
+
const m = svg.current?.getScreenCTM()?.inverse();
|
|
470
|
+
const p = m ? new DOMPoint(event.clientX, event.clientY).matrixTransform(m) : { x: 0, y: 0 };
|
|
471
|
+
onClick(event, { x: p.x, y: p.y });
|
|
472
|
+
}
|
|
473
|
+
: undefined, children: [label ? _jsx("title", { id: labelledBy, children: label }) : null, [...lookup.values()].map((node) => {
|
|
474
|
+
const user = node.internals.userNode;
|
|
475
|
+
const w = user.measured?.width ?? user.width ?? user.initialWidth ?? 0;
|
|
476
|
+
const h = user.measured?.height ?? user.height ?? user.initialHeight ?? 0;
|
|
477
|
+
if (user.hidden || !w || !h)
|
|
478
|
+
return null;
|
|
479
|
+
return (_jsx(Node, { id: node.id, x: node.internals.positionAbsolute.x, y: node.internals.positionAbsolute.y, width: w, height: h, style: user.style, selected: !!user.selected, className: classOf(user), color: colorOf(user), borderRadius: nodeBorderRadius, strokeColor: strokeOf(user), strokeWidth: nodeStrokeWidth, shapeRendering: shapeRendering, onClick: onNodeClick ? (event, id) => onNodeClick(event, store.getState().nodeLookup.get(id).internals.userNode) : undefined }, node.id));
|
|
480
|
+
}), _jsx("path", { className: "avis-flow__minimap-mask", d: `M${x - offset},${y - offset}h${width + offset * 2}v${height + offset * 2}h${-width - offset * 2}z
|
|
481
|
+
M${viewBB.x},${viewBB.y}h${viewBB.width}v${viewBB.height}h${-viewBB.width}z`, fillRule: "evenodd", pointerEvents: "none" })] }) }));
|
|
482
|
+
}
|
|
483
|
+
/** A layer of the flow's DOM, found from the store's root (one stable selector per layer). */
|
|
484
|
+
const layers = new Map();
|
|
485
|
+
const layer = (selector) => {
|
|
486
|
+
let pick = layers.get(selector);
|
|
487
|
+
if (!pick) {
|
|
488
|
+
pick = (s) => s.domNode?.querySelector(selector) ?? null;
|
|
489
|
+
layers.set(selector, pick);
|
|
490
|
+
}
|
|
491
|
+
return pick;
|
|
492
|
+
};
|
|
493
|
+
/** Renders HTML at edge positions (in the viewport's layer). */
|
|
494
|
+
export function EdgeLabelRenderer({ children }) {
|
|
495
|
+
const target = useStore(layer(".avis-flow__edgelabel-renderer"));
|
|
496
|
+
return target ? createPortal(children, target) : null;
|
|
497
|
+
}
|
|
498
|
+
/** Renders in world space, moving with the viewport. */
|
|
499
|
+
export function ViewportPortal({ children }) {
|
|
500
|
+
const target = useStore(layer(".avis-flow__viewport-portal"));
|
|
501
|
+
return target ? createPortal(children, target) : null;
|
|
502
|
+
}
|
|
503
|
+
/** React Flow's EdgeText: an SVG label with an optional background, centred on (x, y). */
|
|
504
|
+
export function EdgeText({ x, y, label, labelStyle, labelShowBg = true, labelBgStyle, labelBgPadding = [2, 4], labelBgBorderRadius = 2, children, className, ...rest }) {
|
|
505
|
+
const [box, setBox] = useState({ x: 1, y: 0, width: 0, height: 0 });
|
|
506
|
+
const ref = useRef(null);
|
|
507
|
+
useEffect(() => {
|
|
508
|
+
if (!ref.current)
|
|
509
|
+
return;
|
|
510
|
+
const b = ref.current.getBBox();
|
|
511
|
+
setBox({ x: b.x, y: b.y, width: b.width, height: b.height });
|
|
512
|
+
}, [label]);
|
|
513
|
+
if (!label)
|
|
514
|
+
return null;
|
|
515
|
+
return (_jsxs("g", { transform: `translate(${x - box.width / 2} ${y - box.height / 2})`, className: `avis-flow__edge-textwrapper${className ? ` ${className}` : ""}`, visibility: box.width ? "visible" : "hidden", ...rest, children: [labelShowBg ? (_jsx("rect", { width: box.width + 2 * labelBgPadding[0], x: -labelBgPadding[0], y: -labelBgPadding[1], height: box.height + 2 * labelBgPadding[1], className: "avis-flow__edge-textbg", style: labelBgStyle, rx: labelBgBorderRadius, ry: labelBgBorderRadius })) : null, _jsx("text", { className: "avis-flow__edge-text", y: box.height / 2, dy: "0.3em", ref: ref, style: labelStyle, children: label }), children] }));
|
|
516
|
+
}
|
|
517
|
+
const isNumeric = (n) => typeof n === "number" && !Number.isNaN(n) && Number.isFinite(n);
|
|
518
|
+
/** React Flow's BaseEdge: the path (with every other prop on it), a wide invisible hit path, and the label. */
|
|
519
|
+
export function BaseEdge({ path, labelX, labelY, label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding, labelBgBorderRadius, interactionWidth = 20, ...props }) {
|
|
520
|
+
return (_jsxs(_Fragment, { children: [_jsx("path", { ...props, d: path, fill: "none", className: `avis-flow__edge-path${props.className ? ` ${props.className}` : ""}` }), interactionWidth ? _jsx("path", { d: path, fill: "none", strokeOpacity: 0, strokeWidth: interactionWidth, className: "avis-flow__edge-interaction" }) : null, label && isNumeric(labelX) && isNumeric(labelY) ? (_jsx(EdgeText, { x: labelX, y: labelY, label: label, labelStyle: labelStyle, labelShowBg: labelShowBg, labelBgStyle: labelBgStyle, labelBgPadding: labelBgPadding, labelBgBorderRadius: labelBgBorderRadius })) : null] }));
|
|
521
|
+
}
|
|
522
|
+
/** Keeps a NodeResizer-like effect simple for nodes that re-measure. */
|
|
523
|
+
export function useNodeRemeasure(id) {
|
|
524
|
+
const store = useContext(StoreContext);
|
|
525
|
+
useLayoutEffect(() => store.getState().updateNodeInternals([id]), [store, id]);
|
|
526
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AriaLabelConfig } from "./api/system/constants.js";
|
|
2
|
+
import type { FlowStore } from "./store.js";
|
|
3
|
+
export declare const defaultAriaLabels: AriaLabelConfig;
|
|
4
|
+
/** Match an actual class token (custom class names may contain CSS punctuation). */
|
|
5
|
+
export declare function hasClassWithin(target: Element | null, className: string, root: Element): boolean;
|
|
6
|
+
export declare function reportFlowError(store: FlowStore, code: string, message: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const defaultAriaLabels = {
|
|
2
|
+
"node.a11yDescription.default": "Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.",
|
|
3
|
+
"node.a11yDescription.keyboardDisabled": "Press enter or space to select a node. Press delete to remove it and escape to cancel.",
|
|
4
|
+
"node.a11yDescription.ariaLiveMessage": ({ direction, x, y }) => `Moved selected node ${direction}. New position, x: ${x}, y: ${y}`,
|
|
5
|
+
"edge.a11yDescription.default": "Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.",
|
|
6
|
+
"controls.ariaLabel": "Control Panel", "controls.zoomIn.ariaLabel": "Zoom In", "controls.zoomOut.ariaLabel": "Zoom Out",
|
|
7
|
+
"controls.fitView.ariaLabel": "Fit View", "controls.interactive.ariaLabel": "Toggle Interactivity",
|
|
8
|
+
"minimap.ariaLabel": "Mini Map", "handle.ariaLabel": "Handle",
|
|
9
|
+
};
|
|
10
|
+
/** Match an actual class token (custom class names may contain CSS punctuation). */
|
|
11
|
+
export function hasClassWithin(target, className, root) {
|
|
12
|
+
for (let el = target; el; el = el.parentElement) {
|
|
13
|
+
if (el.classList.contains(className))
|
|
14
|
+
return true;
|
|
15
|
+
if (el === root)
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
export function reportFlowError(store, code, message) {
|
|
21
|
+
const state = store.getState();
|
|
22
|
+
const handler = state.onError;
|
|
23
|
+
if (handler)
|
|
24
|
+
handler(code, message);
|
|
25
|
+
else if (state.debug)
|
|
26
|
+
console.warn(`[AVIS Flow ${code}] ${message}`);
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FlowStore } from "./store.js";
|
|
2
|
+
export type DragOptions = {
|
|
3
|
+
domNode: HTMLElement;
|
|
4
|
+
nodeId?: string;
|
|
5
|
+
isSelectable?: boolean;
|
|
6
|
+
noDragClassName?: string;
|
|
7
|
+
handleSelector?: string;
|
|
8
|
+
nodeClickDistance?: number;
|
|
9
|
+
onNodeMouseDown?: (id: string) => void;
|
|
10
|
+
onDragStart?: () => void;
|
|
11
|
+
onDragStop?: () => void;
|
|
12
|
+
};
|
|
13
|
+
/** Attaches dragging to an element; returns the cleanup. */
|
|
14
|
+
export declare function attachDrag(store: FlowStore, options: DragOptions): () => void;
|