@octanejs/xyflow 0.1.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/LICENSE +21 -0
- package/README.md +26 -0
- package/package.json +69 -0
- package/src/additional-components/Background/Background.tsrx +144 -0
- package/src/additional-components/Background/Patterns.tsrx +32 -0
- package/src/additional-components/Background/index.tsrx +2 -0
- package/src/additional-components/Background/types.ts +60 -0
- package/src/additional-components/Controls/ControlButton.tsrx +34 -0
- package/src/additional-components/Controls/Controls.tsrx +148 -0
- package/src/additional-components/Controls/Icons/FitView.tsrx +7 -0
- package/src/additional-components/Controls/Icons/Lock.tsrx +7 -0
- package/src/additional-components/Controls/Icons/Minus.tsrx +5 -0
- package/src/additional-components/Controls/Icons/Plus.tsrx +5 -0
- package/src/additional-components/Controls/Icons/Unlock.tsrx +7 -0
- package/src/additional-components/Controls/index.tsrx +3 -0
- package/src/additional-components/Controls/types.ts +68 -0
- package/src/additional-components/EdgeToolbar/EdgeToolbar.tsrx +79 -0
- package/src/additional-components/EdgeToolbar/index.tsrx +2 -0
- package/src/additional-components/EdgeToolbar/types.ts +14 -0
- package/src/additional-components/MiniMap/MiniMap.tsrx +249 -0
- package/src/additional-components/MiniMap/MiniMapNode.tsrx +43 -0
- package/src/additional-components/MiniMap/MiniMapNodes.tsrx +136 -0
- package/src/additional-components/MiniMap/index.ts +3 -0
- package/src/additional-components/MiniMap/types.ts +139 -0
- package/src/additional-components/NodeResizer/NodeResizeControl.tsrx +250 -0
- package/src/additional-components/NodeResizer/NodeResizer.tsrx +102 -0
- package/src/additional-components/NodeResizer/index.ts +4 -0
- package/src/additional-components/NodeResizer/types.ts +122 -0
- package/src/additional-components/NodeToolbar/NodeToolbar.tsrx +141 -0
- package/src/additional-components/NodeToolbar/NodeToolbarPortal.tsrx +17 -0
- package/src/additional-components/NodeToolbar/index.tsrx +2 -0
- package/src/additional-components/NodeToolbar/types.ts +32 -0
- package/src/additional-components/index.ts +6 -0
- package/src/components/A11yDescriptions/index.tsrx +58 -0
- package/src/components/Attribution/index.tsrx +31 -0
- package/src/components/BatchProvider/index.tsrx +122 -0
- package/src/components/BatchProvider/types.ts +7 -0
- package/src/components/BatchProvider/useQueue.ts +62 -0
- package/src/components/ConnectionLine/index.tsrx +140 -0
- package/src/components/EdgeLabelRenderer/index.tsrx +62 -0
- package/src/components/EdgeWrapper/EdgeUpdateAnchors.tsrx +151 -0
- package/src/components/EdgeWrapper/index.tsrx +274 -0
- package/src/components/EdgeWrapper/utils.ts +26 -0
- package/src/components/Edges/BaseEdge.tsrx +76 -0
- package/src/components/Edges/BezierEdge.tsrx +94 -0
- package/src/components/Edges/EdgeAnchor.tsrx +54 -0
- package/src/components/Edges/EdgeText.tsrx +97 -0
- package/src/components/Edges/SimpleBezierEdge.tsrx +150 -0
- package/src/components/Edges/SmoothStepEdge.tsrx +96 -0
- package/src/components/Edges/StepEdge.tsrx +55 -0
- package/src/components/Edges/StraightEdge.tsrx +81 -0
- package/src/components/Edges/index.ts +11 -0
- package/src/components/Handle/index.tsrx +314 -0
- package/src/components/NodeWrapper/index.tsrx +259 -0
- package/src/components/NodeWrapper/useNodeObserver.ts +79 -0
- package/src/components/NodeWrapper/utils.tsrx +40 -0
- package/src/components/Nodes/DefaultNode.tsrx +17 -0
- package/src/components/Nodes/GroupNode.tsrx +3 -0
- package/src/components/Nodes/InputNode.tsrx +13 -0
- package/src/components/Nodes/OutputNode.tsrx +13 -0
- package/src/components/Nodes/utils.ts +45 -0
- package/src/components/NodesSelection/index.tsrx +103 -0
- package/src/components/Panel/index.tsrx +34 -0
- package/src/components/ReactFlowProvider/index.tsrx +128 -0
- package/src/components/SelectionListener/index.tsrx +73 -0
- package/src/components/StoreUpdater/index.tsrx +173 -0
- package/src/components/UserSelection/index.tsrx +27 -0
- package/src/components/ViewportPortal/index.tsrx +42 -0
- package/src/container/EdgeRenderer/MarkerDefinitions.tsrx +87 -0
- package/src/container/EdgeRenderer/MarkerSymbols.tsrx +60 -0
- package/src/container/EdgeRenderer/index.tsrx +98 -0
- package/src/container/FlowRenderer/index.tsrx +146 -0
- package/src/container/GraphView/index.tsrx +212 -0
- package/src/container/GraphView/useNodeOrEdgeTypesWarning.ts +39 -0
- package/src/container/GraphView/useStylesLoadedWarning.ts +26 -0
- package/src/container/NodeRenderer/index.tsrx +103 -0
- package/src/container/NodeRenderer/useResizeObserver.ts +38 -0
- package/src/container/Pane/index.tsrx +397 -0
- package/src/container/ReactFlow/Wrapper.tsrx +66 -0
- package/src/container/ReactFlow/index.tsrx +352 -0
- package/src/container/ReactFlow/init-values.ts +4 -0
- package/src/container/Viewport/index.tsrx +52 -0
- package/src/container/ZoomPane/index.tsrx +159 -0
- package/src/contexts/HandleConfigContext.tsrx +38 -0
- package/src/contexts/NodeIdContext.ts +39 -0
- package/src/contexts/StoreContext.ts +8 -0
- package/src/custom.d.ts +13 -0
- package/src/hooks/slot.ts +22 -0
- package/src/hooks/useColorModeClass.ts +50 -0
- package/src/hooks/useConnection.ts +69 -0
- package/src/hooks/useDrag.ts +95 -0
- package/src/hooks/useEdges.ts +32 -0
- package/src/hooks/useGlobalKeyHandler.ts +55 -0
- package/src/hooks/useHandleConnections.ts +77 -0
- package/src/hooks/useInternalNode.ts +47 -0
- package/src/hooks/useIsomorphicLayoutEffect.ts +5 -0
- package/src/hooks/useKeyPress.ts +217 -0
- package/src/hooks/useMoveSelectedNodes.ts +82 -0
- package/src/hooks/useNodeConnections.ts +86 -0
- package/src/hooks/useNodes.ts +33 -0
- package/src/hooks/useNodesData.ts +66 -0
- package/src/hooks/useNodesEdgesState.ts +138 -0
- package/src/hooks/useNodesInitialized.ts +74 -0
- package/src/hooks/useOnEdgesChangeMiddleware.ts +46 -0
- package/src/hooks/useOnInitHandler.ts +27 -0
- package/src/hooks/useOnNodesChangeMiddleware.ts +46 -0
- package/src/hooks/useOnSelectionChange.ts +78 -0
- package/src/hooks/useOnViewportChange.ts +68 -0
- package/src/hooks/useReactFlow.ts +347 -0
- package/src/hooks/useResizeHandler.ts +54 -0
- package/src/hooks/useStore.ts +58 -0
- package/src/hooks/useUpdateNodeInternals.ts +73 -0
- package/src/hooks/useViewport.ts +48 -0
- package/src/hooks/useViewportHelper.ts +103 -0
- package/src/hooks/useViewportSync.ts +33 -0
- package/src/hooks/useVisibleEdgeIds.ts +52 -0
- package/src/hooks/useVisibleNodeIds.ts +36 -0
- package/src/index.ts +151 -0
- package/src/react-shim.ts +93 -0
- package/src/store/index.ts +516 -0
- package/src/store/initialState.ts +162 -0
- package/src/styles/base.css +516 -0
- package/src/styles/style.css +648 -0
- package/src/styles/utils.ts +9 -0
- package/src/types/component-props.ts +716 -0
- package/src/types/edges.ts +312 -0
- package/src/types/general.ts +239 -0
- package/src/types/index.ts +6 -0
- package/src/types/instance.ts +265 -0
- package/src/types/nodes.ts +144 -0
- package/src/types/store.ts +198 -0
- package/src/utils/changes.ts +329 -0
- package/src/utils/edges.ts +34 -0
- package/src/utils/general.ts +72 -0
- package/src/utils/index.ts +3 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useMemo } from 'octane';
|
|
2
|
+
import { resolveHookSlot, subSlot } from './slot';
|
|
3
|
+
import {
|
|
4
|
+
pointToRendererPoint,
|
|
5
|
+
getViewportForBounds,
|
|
6
|
+
type XYPosition,
|
|
7
|
+
rendererPointToPoint,
|
|
8
|
+
SnapGrid,
|
|
9
|
+
} from '@xyflow/system';
|
|
10
|
+
|
|
11
|
+
import { useStoreApi } from '../hooks/useStore';
|
|
12
|
+
import type { ViewportHelperFunctions } from '../types';
|
|
13
|
+
|
|
14
|
+
const useViewportHelper = (...rest: [slot?: symbol]): ViewportHelperFunctions => {
|
|
15
|
+
const slot = resolveHookSlot(rest);
|
|
16
|
+
const store = useStoreApi(subSlot(slot, 'store'));
|
|
17
|
+
|
|
18
|
+
return useMemo<ViewportHelperFunctions>(
|
|
19
|
+
function buildViewportHelper() {
|
|
20
|
+
return {
|
|
21
|
+
zoomIn: async function zoomIn(options) {
|
|
22
|
+
const { panZoom } = store.getState();
|
|
23
|
+
return panZoom ? panZoom.scaleBy(1.2, options) : false;
|
|
24
|
+
},
|
|
25
|
+
zoomOut: async function zoomOut(options) {
|
|
26
|
+
const { panZoom } = store.getState();
|
|
27
|
+
return panZoom ? panZoom.scaleBy(1 / 1.2, options) : false;
|
|
28
|
+
},
|
|
29
|
+
zoomTo: async function zoomTo(zoomLevel, options) {
|
|
30
|
+
const { panZoom } = store.getState();
|
|
31
|
+
return panZoom ? panZoom.scaleTo(zoomLevel, options) : false;
|
|
32
|
+
},
|
|
33
|
+
getZoom: function getZoom() {
|
|
34
|
+
return store.getState().transform[2];
|
|
35
|
+
},
|
|
36
|
+
setViewport: async function setViewport(viewport, options) {
|
|
37
|
+
const {
|
|
38
|
+
transform: [tX, tY, tZoom],
|
|
39
|
+
panZoom,
|
|
40
|
+
} = store.getState();
|
|
41
|
+
if (!panZoom) return false;
|
|
42
|
+
await panZoom.setViewport(
|
|
43
|
+
{
|
|
44
|
+
x: viewport.x ?? tX,
|
|
45
|
+
y: viewport.y ?? tY,
|
|
46
|
+
zoom: viewport.zoom ?? tZoom,
|
|
47
|
+
},
|
|
48
|
+
options,
|
|
49
|
+
);
|
|
50
|
+
return true;
|
|
51
|
+
},
|
|
52
|
+
getViewport: function getViewport() {
|
|
53
|
+
const [x, y, zoom] = store.getState().transform;
|
|
54
|
+
return { x, y, zoom };
|
|
55
|
+
},
|
|
56
|
+
setCenter: async function setCenter(x, y, options) {
|
|
57
|
+
return store.getState().setCenter(x, y, options);
|
|
58
|
+
},
|
|
59
|
+
fitBounds: async function fitBounds(bounds, options) {
|
|
60
|
+
const { width, height, minZoom, maxZoom, panZoom } = store.getState();
|
|
61
|
+
const viewport = getViewportForBounds(
|
|
62
|
+
bounds,
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
minZoom,
|
|
66
|
+
maxZoom,
|
|
67
|
+
options?.padding ?? 0.1,
|
|
68
|
+
);
|
|
69
|
+
if (!panZoom) return false;
|
|
70
|
+
await panZoom.setViewport(viewport, {
|
|
71
|
+
duration: options?.duration,
|
|
72
|
+
ease: options?.ease,
|
|
73
|
+
interpolate: options?.interpolate,
|
|
74
|
+
});
|
|
75
|
+
return true;
|
|
76
|
+
},
|
|
77
|
+
screenToFlowPosition: function screenToFlowPosition(
|
|
78
|
+
clientPosition: XYPosition,
|
|
79
|
+
options: { snapToGrid?: boolean; snapGrid?: SnapGrid } = {},
|
|
80
|
+
) {
|
|
81
|
+
const { transform, snapGrid, snapToGrid, domNode } = store.getState();
|
|
82
|
+
if (!domNode) return clientPosition;
|
|
83
|
+
const { x: domX, y: domY } = domNode.getBoundingClientRect();
|
|
84
|
+
const correctedPosition = { x: clientPosition.x - domX, y: clientPosition.y - domY };
|
|
85
|
+
const _snapGrid = options.snapGrid ?? snapGrid;
|
|
86
|
+
const _snapToGrid = options.snapToGrid ?? snapToGrid;
|
|
87
|
+
return pointToRendererPoint(correctedPosition, transform, _snapToGrid, _snapGrid);
|
|
88
|
+
},
|
|
89
|
+
flowToScreenPosition: function flowToScreenPosition(flowPosition: XYPosition) {
|
|
90
|
+
const { transform, domNode } = store.getState();
|
|
91
|
+
if (!domNode) return flowPosition;
|
|
92
|
+
const { x: domX, y: domY } = domNode.getBoundingClientRect();
|
|
93
|
+
const rendererPosition = rendererPointToPoint(flowPosition, transform);
|
|
94
|
+
return { x: rendererPosition.x + domX, y: rendererPosition.y + domY };
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
[store],
|
|
99
|
+
subSlot(slot, 'helper'),
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default useViewportHelper;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect } from 'octane';
|
|
2
|
+
import { resolveHookSlot } from './slot';
|
|
3
|
+
import type { Viewport } from '@xyflow/system';
|
|
4
|
+
|
|
5
|
+
import { useStore, useStoreApi } from './useStore';
|
|
6
|
+
import type { ReactFlowState } from '../types';
|
|
7
|
+
|
|
8
|
+
const selector = (state: ReactFlowState) => state.panZoom?.syncViewport;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook for syncing the viewport with the panzoom instance.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
* @param viewport
|
|
15
|
+
*/
|
|
16
|
+
export function useViewportSync(viewport?: Viewport, ...rest: [slot?: symbol]) {
|
|
17
|
+
const slot = resolveHookSlot(rest);
|
|
18
|
+
const syncViewport = useStore(selector, undefined, slot);
|
|
19
|
+
const store = useStoreApi(slot);
|
|
20
|
+
|
|
21
|
+
useEffect(
|
|
22
|
+
function syncViewportEffect() {
|
|
23
|
+
if (viewport) {
|
|
24
|
+
syncViewport?.(viewport);
|
|
25
|
+
store.setState({ transform: [viewport.x, viewport.y, viewport.zoom] });
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
[viewport, syncViewport],
|
|
29
|
+
slot,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useCallback } from 'octane';
|
|
2
|
+
import { shallow } from '@octanejs/zustand/shallow';
|
|
3
|
+
import { isEdgeVisible } from '@xyflow/system';
|
|
4
|
+
|
|
5
|
+
import { useStore } from './useStore';
|
|
6
|
+
import { resolveHookSlot } from './slot';
|
|
7
|
+
import { type ReactFlowState } from '../types';
|
|
8
|
+
|
|
9
|
+
export function useVisibleEdgeIds(onlyRenderVisible: boolean, ...rest: [slot?: symbol]): string[] {
|
|
10
|
+
const slot = resolveHookSlot(rest);
|
|
11
|
+
const edgeIds = useStore(
|
|
12
|
+
useCallback(
|
|
13
|
+
function selectVisibleEdgeIds(s: ReactFlowState) {
|
|
14
|
+
if (!onlyRenderVisible) {
|
|
15
|
+
return s.edges.map(function mapEdgeId(edge) {
|
|
16
|
+
return edge.id;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const visibleEdgeIds: string[] = [];
|
|
21
|
+
|
|
22
|
+
if (s.width && s.height) {
|
|
23
|
+
for (const edge of s.edges) {
|
|
24
|
+
const sourceNode = s.nodeLookup.get(edge.source);
|
|
25
|
+
const targetNode = s.nodeLookup.get(edge.target);
|
|
26
|
+
|
|
27
|
+
if (
|
|
28
|
+
sourceNode &&
|
|
29
|
+
targetNode &&
|
|
30
|
+
isEdgeVisible({
|
|
31
|
+
sourceNode,
|
|
32
|
+
targetNode,
|
|
33
|
+
width: s.width,
|
|
34
|
+
height: s.height,
|
|
35
|
+
transform: s.transform,
|
|
36
|
+
})
|
|
37
|
+
) {
|
|
38
|
+
visibleEdgeIds.push(edge.id);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return visibleEdgeIds;
|
|
44
|
+
},
|
|
45
|
+
[onlyRenderVisible],
|
|
46
|
+
),
|
|
47
|
+
shallow,
|
|
48
|
+
slot,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return edgeIds;
|
|
52
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback } from 'octane';
|
|
2
|
+
import { resolveHookSlot } from './slot';
|
|
3
|
+
import { shallow } from '@octanejs/zustand/shallow';
|
|
4
|
+
import { getNodesInside } from '@xyflow/system';
|
|
5
|
+
|
|
6
|
+
import { useStore } from './useStore';
|
|
7
|
+
import type { Node, ReactFlowState } from '../types';
|
|
8
|
+
|
|
9
|
+
const selector = (onlyRenderVisible: boolean) => (s: ReactFlowState) => {
|
|
10
|
+
return onlyRenderVisible
|
|
11
|
+
? getNodesInside<Node>(
|
|
12
|
+
s.nodeLookup,
|
|
13
|
+
{ x: 0, y: 0, width: s.width, height: s.height },
|
|
14
|
+
s.transform,
|
|
15
|
+
true,
|
|
16
|
+
).map((node) => node.id)
|
|
17
|
+
: Array.from(s.nodeLookup.keys());
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hook for getting the visible node ids from the store.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
* @param onlyRenderVisible
|
|
25
|
+
* @returns array with visible node ids
|
|
26
|
+
*/
|
|
27
|
+
export function useVisibleNodeIds(onlyRenderVisible: boolean, ...rest: [slot?: symbol]) {
|
|
28
|
+
const slot = resolveHookSlot(rest);
|
|
29
|
+
const nodeIds = useStore(
|
|
30
|
+
useCallback(selector(onlyRenderVisible), [onlyRenderVisible]),
|
|
31
|
+
shallow,
|
|
32
|
+
slot,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return nodeIds;
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export { default as ReactFlow } from './container/ReactFlow/index.tsrx';
|
|
2
|
+
export { Handle, type HandleProps } from './components/Handle/index.tsrx';
|
|
3
|
+
export { EdgeText } from './components/Edges/EdgeText.tsrx';
|
|
4
|
+
export { StraightEdge } from './components/Edges/StraightEdge.tsrx';
|
|
5
|
+
export { StepEdge } from './components/Edges/StepEdge.tsrx';
|
|
6
|
+
export { BezierEdge } from './components/Edges/BezierEdge.tsrx';
|
|
7
|
+
export { SimpleBezierEdge, getSimpleBezierPath } from './components/Edges/SimpleBezierEdge.tsrx';
|
|
8
|
+
export { SmoothStepEdge } from './components/Edges/SmoothStepEdge.tsrx';
|
|
9
|
+
export { BaseEdge } from './components/Edges/BaseEdge.tsrx';
|
|
10
|
+
export { ReactFlowProvider } from './components/ReactFlowProvider/index.tsrx';
|
|
11
|
+
export { Panel, type PanelProps } from './components/Panel/index.tsrx';
|
|
12
|
+
export {
|
|
13
|
+
EdgeLabelRenderer,
|
|
14
|
+
type EdgeLabelRendererProps,
|
|
15
|
+
} from './components/EdgeLabelRenderer/index.tsrx';
|
|
16
|
+
export { ViewportPortal } from './components/ViewportPortal/index.tsrx';
|
|
17
|
+
|
|
18
|
+
export { useReactFlow } from './hooks/useReactFlow';
|
|
19
|
+
export { useUpdateNodeInternals } from './hooks/useUpdateNodeInternals';
|
|
20
|
+
export { useNodes } from './hooks/useNodes';
|
|
21
|
+
export { useEdges } from './hooks/useEdges';
|
|
22
|
+
export { useViewport } from './hooks/useViewport';
|
|
23
|
+
export { useKeyPress } from './hooks/useKeyPress';
|
|
24
|
+
export { useNodesState, useEdgesState } from './hooks/useNodesEdgesState';
|
|
25
|
+
export { useStore, useStoreApi } from './hooks/useStore';
|
|
26
|
+
export { useOnViewportChange, type UseOnViewportChangeOptions } from './hooks/useOnViewportChange';
|
|
27
|
+
export {
|
|
28
|
+
useOnSelectionChange,
|
|
29
|
+
type UseOnSelectionChangeOptions,
|
|
30
|
+
} from './hooks/useOnSelectionChange';
|
|
31
|
+
export { useNodesInitialized, type UseNodesInitializedOptions } from './hooks/useNodesInitialized';
|
|
32
|
+
export { useHandleConnections } from './hooks/useHandleConnections';
|
|
33
|
+
export { useNodeConnections } from './hooks/useNodeConnections';
|
|
34
|
+
export { useNodesData } from './hooks/useNodesData';
|
|
35
|
+
export { useConnection } from './hooks/useConnection';
|
|
36
|
+
export { useInternalNode } from './hooks/useInternalNode';
|
|
37
|
+
export { useNodeId } from './contexts/NodeIdContext';
|
|
38
|
+
|
|
39
|
+
export { experimental_useOnNodesChangeMiddleware } from './hooks/useOnNodesChangeMiddleware';
|
|
40
|
+
export { experimental_useOnEdgesChangeMiddleware } from './hooks/useOnEdgesChangeMiddleware';
|
|
41
|
+
|
|
42
|
+
export { applyNodeChanges, applyEdgeChanges } from './utils/changes';
|
|
43
|
+
export { isNode, isEdge } from './utils/general';
|
|
44
|
+
|
|
45
|
+
export * from './additional-components';
|
|
46
|
+
|
|
47
|
+
export * from './types';
|
|
48
|
+
|
|
49
|
+
// system types
|
|
50
|
+
export {
|
|
51
|
+
type Align,
|
|
52
|
+
type SmoothStepPathOptions,
|
|
53
|
+
type BezierPathOptions,
|
|
54
|
+
ConnectionLineType,
|
|
55
|
+
type EdgeMarker,
|
|
56
|
+
type EdgeMarkerType,
|
|
57
|
+
MarkerType,
|
|
58
|
+
type OnMove,
|
|
59
|
+
type OnMoveStart,
|
|
60
|
+
type OnMoveEnd,
|
|
61
|
+
type Connection,
|
|
62
|
+
ConnectionMode,
|
|
63
|
+
type OnConnectStartParams,
|
|
64
|
+
type OnConnectStart,
|
|
65
|
+
type OnConnect,
|
|
66
|
+
type OnConnectEnd,
|
|
67
|
+
type Viewport,
|
|
68
|
+
type SnapGrid,
|
|
69
|
+
PanOnScrollMode,
|
|
70
|
+
type ViewportHelperFunctionOptions,
|
|
71
|
+
type SetCenterOptions,
|
|
72
|
+
type FitBoundsOptions,
|
|
73
|
+
type PanelPosition,
|
|
74
|
+
type ProOptions,
|
|
75
|
+
SelectionMode,
|
|
76
|
+
type SelectionRect,
|
|
77
|
+
type OnError,
|
|
78
|
+
type NodeOrigin,
|
|
79
|
+
type OnSelectionDrag,
|
|
80
|
+
Position,
|
|
81
|
+
type XYPosition,
|
|
82
|
+
type XYZPosition,
|
|
83
|
+
type Dimensions,
|
|
84
|
+
type Rect,
|
|
85
|
+
type Box,
|
|
86
|
+
type Transform,
|
|
87
|
+
type CoordinateExtent,
|
|
88
|
+
type ColorMode,
|
|
89
|
+
type ColorModeClass,
|
|
90
|
+
type HandleType,
|
|
91
|
+
type ShouldResize,
|
|
92
|
+
type OnResizeStart,
|
|
93
|
+
type OnResize,
|
|
94
|
+
type OnResizeEnd,
|
|
95
|
+
type ControlPosition,
|
|
96
|
+
type ControlLinePosition,
|
|
97
|
+
ResizeControlVariant,
|
|
98
|
+
type ResizeParams,
|
|
99
|
+
type ResizeParamsWithDirection,
|
|
100
|
+
type ResizeDragEvent,
|
|
101
|
+
type NodeChange,
|
|
102
|
+
type NodeDimensionChange,
|
|
103
|
+
type NodePositionChange,
|
|
104
|
+
type NodeSelectionChange,
|
|
105
|
+
type NodeRemoveChange,
|
|
106
|
+
type NodeAddChange,
|
|
107
|
+
type NodeReplaceChange,
|
|
108
|
+
type EdgeChange,
|
|
109
|
+
type EdgeSelectionChange,
|
|
110
|
+
type EdgeRemoveChange,
|
|
111
|
+
type EdgeAddChange,
|
|
112
|
+
type EdgeReplaceChange,
|
|
113
|
+
type KeyCode,
|
|
114
|
+
type ConnectionState,
|
|
115
|
+
type FinalConnectionState,
|
|
116
|
+
type ConnectionInProgress,
|
|
117
|
+
type NoConnection,
|
|
118
|
+
type NodeConnection,
|
|
119
|
+
type OnReconnect,
|
|
120
|
+
type AriaLabelConfig,
|
|
121
|
+
type SetCenter,
|
|
122
|
+
type SetViewport,
|
|
123
|
+
type FitBounds,
|
|
124
|
+
type HandleConnection,
|
|
125
|
+
type ZIndexMode,
|
|
126
|
+
type NodeHandle,
|
|
127
|
+
type UseNodeConnectionsParams,
|
|
128
|
+
} from '@xyflow/system';
|
|
129
|
+
|
|
130
|
+
// we need this workaround to prevent a duplicate identifier error
|
|
131
|
+
import { type Handle as HandleBound } from '@xyflow/system';
|
|
132
|
+
export type Handle = HandleBound;
|
|
133
|
+
|
|
134
|
+
// system utils
|
|
135
|
+
export {
|
|
136
|
+
type GetBezierPathParams,
|
|
137
|
+
getBezierEdgeCenter,
|
|
138
|
+
getBezierPath,
|
|
139
|
+
getEdgeCenter,
|
|
140
|
+
type GetSmoothStepPathParams,
|
|
141
|
+
getSmoothStepPath,
|
|
142
|
+
type GetStraightPathParams,
|
|
143
|
+
getStraightPath,
|
|
144
|
+
getViewportForBounds,
|
|
145
|
+
getNodesBounds,
|
|
146
|
+
getIncomers,
|
|
147
|
+
getOutgoers,
|
|
148
|
+
getConnectedEdges,
|
|
149
|
+
} from '@xyflow/system';
|
|
150
|
+
|
|
151
|
+
export { addEdge, reconnectEdge } from './utils/edges';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ComponentBody, OctaneNode } from 'octane';
|
|
2
|
+
import type { Octane as OctaneJSXRuntime } from 'octane/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
export type { OctaneNode as ReactNode, OctaneNode };
|
|
5
|
+
|
|
6
|
+
export type CSSProperties = Exclude<
|
|
7
|
+
OctaneJSXRuntime.JSX.IntrinsicElements['div']['style'],
|
|
8
|
+
string | undefined
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
export type RefObject<T> = { current: T | null };
|
|
12
|
+
export type Ref<T> = OctaneJSXRuntime.Ref<T>;
|
|
13
|
+
export type RefAttributes<T> = { ref?: Ref<T> };
|
|
14
|
+
export type PropsWithoutRef<P> = P;
|
|
15
|
+
|
|
16
|
+
export type FC<P = Record<string, unknown>> = ComponentBody<P> & { displayName?: string };
|
|
17
|
+
export type ComponentType<P = Record<string, unknown>> = FC<P>;
|
|
18
|
+
|
|
19
|
+
type NativeEvent<T extends Element, E extends Event> = E & { readonly currentTarget: T };
|
|
20
|
+
|
|
21
|
+
export type MouseEvent<
|
|
22
|
+
T extends Element = Element,
|
|
23
|
+
E extends globalThis.MouseEvent = globalThis.MouseEvent,
|
|
24
|
+
> = NativeEvent<T, E>;
|
|
25
|
+
export type TouchEvent<
|
|
26
|
+
T extends Element = Element,
|
|
27
|
+
E extends globalThis.TouchEvent = globalThis.TouchEvent,
|
|
28
|
+
> = NativeEvent<T, E>;
|
|
29
|
+
export type KeyboardEvent<
|
|
30
|
+
T extends Element = Element,
|
|
31
|
+
E extends globalThis.KeyboardEvent = globalThis.KeyboardEvent,
|
|
32
|
+
> = NativeEvent<T, E>;
|
|
33
|
+
export type PointerEvent<
|
|
34
|
+
T extends Element = Element,
|
|
35
|
+
E extends globalThis.PointerEvent = globalThis.PointerEvent,
|
|
36
|
+
> = NativeEvent<T, E>;
|
|
37
|
+
export type WheelEvent<
|
|
38
|
+
T extends Element = Element,
|
|
39
|
+
E extends globalThis.WheelEvent = globalThis.WheelEvent,
|
|
40
|
+
> = NativeEvent<T, E>;
|
|
41
|
+
export type UIEvent<
|
|
42
|
+
T extends Element = Element,
|
|
43
|
+
E extends globalThis.UIEvent = globalThis.UIEvent,
|
|
44
|
+
> = NativeEvent<T, E>;
|
|
45
|
+
export type EventHandler<E extends Event> = (event: E) => void;
|
|
46
|
+
export type MouseEventHandler<T extends Element = Element> = EventHandler<MouseEvent<T>>;
|
|
47
|
+
|
|
48
|
+
export type HTMLAttributes<T extends Element = Element> = Partial<{
|
|
49
|
+
id: string;
|
|
50
|
+
class: string;
|
|
51
|
+
className: string;
|
|
52
|
+
title: string;
|
|
53
|
+
style: CSSProperties;
|
|
54
|
+
role: string;
|
|
55
|
+
tabIndex: number;
|
|
56
|
+
'aria-label': string;
|
|
57
|
+
'aria-hidden': boolean | 'true' | 'false';
|
|
58
|
+
draggable: boolean;
|
|
59
|
+
onClick: (event: MouseEvent<T>) => void;
|
|
60
|
+
onContextMenu: (event: MouseEvent<T>) => void;
|
|
61
|
+
onDoubleClick: (event: MouseEvent<T>) => void;
|
|
62
|
+
onMouseDown: (event: MouseEvent<T>) => void;
|
|
63
|
+
onMouseMove: (event: MouseEvent<T>) => void;
|
|
64
|
+
onMouseUp: (event: MouseEvent<T>) => void;
|
|
65
|
+
onMouseEnter: (event: MouseEvent<T>) => void;
|
|
66
|
+
onMouseLeave: (event: MouseEvent<T>) => void;
|
|
67
|
+
onWheel: (event: WheelEvent<T>) => void;
|
|
68
|
+
onKeyDown: (event: KeyboardEvent<T>) => void;
|
|
69
|
+
onKeyUp: (event: KeyboardEvent<T>) => void;
|
|
70
|
+
onFocus: (event: FocusEvent) => void;
|
|
71
|
+
onBlur: (event: FocusEvent) => void;
|
|
72
|
+
onScroll: (event: UIEvent<T>) => void;
|
|
73
|
+
onPointerDown: (event: PointerEvent<T>) => void;
|
|
74
|
+
onTouchStart: (event: TouchEvent<T>) => void;
|
|
75
|
+
children: OctaneNode;
|
|
76
|
+
}>;
|
|
77
|
+
|
|
78
|
+
export type DOMAttributes<T extends Element = Element> = HTMLAttributes<T>;
|
|
79
|
+
export type SVGAttributes<T extends Element = Element> = HTMLAttributes<T>;
|
|
80
|
+
export type ButtonHTMLAttributes<T extends HTMLButtonElement = HTMLButtonElement> =
|
|
81
|
+
HTMLAttributes<T> &
|
|
82
|
+
Partial<{
|
|
83
|
+
disabled: boolean;
|
|
84
|
+
name: string;
|
|
85
|
+
type: 'button' | 'reset' | 'submit';
|
|
86
|
+
value: string | number;
|
|
87
|
+
}>;
|
|
88
|
+
export type AriaRole = string;
|
|
89
|
+
export type ReactMouseEvent<T extends Element = Element> = MouseEvent<T>;
|
|
90
|
+
export type ReactTouchEvent<T extends Element = Element> = TouchEvent<T>;
|
|
91
|
+
export type Dispatch<A> = (value: A) => void;
|
|
92
|
+
export type SetStateAction<S> = S | ((previous: S) => S);
|
|
93
|
+
export type ForwardedRef<T> = ((instance: T | null) => void) | { current: T | null } | null;
|