Merge branch 'xyflow' of github.com:wbkd/react-flow into xyflow
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
'subflows',
|
||||
'usesvelteflow',
|
||||
'useupdatenodeinternals',
|
||||
'validation'
|
||||
'validation',
|
||||
'custom-connection-line'
|
||||
];
|
||||
|
||||
const onChange = (event: Event) => {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import { SvelteFlow } from '@xyflow/svelte';
|
||||
import { Background, BackgroundVariant, type Edge, type Node } from '@xyflow/svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
import CustomNode from './CustomNode.svelte';
|
||||
import ConnectionLine from './ConnectionLine.svelte';
|
||||
|
||||
import '@xyflow/svelte/dist/style.css';
|
||||
|
||||
const nodeTypes = {
|
||||
custom: CustomNode
|
||||
};
|
||||
|
||||
const nodes = writable<Node[]>([
|
||||
{
|
||||
id: 'connectionline-1',
|
||||
type: 'custom',
|
||||
data: { label: 'Node 1' },
|
||||
position: { x: 250, y: 5 }
|
||||
}
|
||||
]);
|
||||
|
||||
const edges = writable<Edge[]>([]);
|
||||
</script>
|
||||
|
||||
<div style="height:100vh;">
|
||||
<SvelteFlow {nodeTypes} {nodes} {edges} fitView>
|
||||
<ConnectionLine slot="connectionLine" />
|
||||
<Background variant={BackgroundVariant.Lines} />
|
||||
</SvelteFlow>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -0,0 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { useConnection } from '@xyflow/svelte';
|
||||
|
||||
const connection = useConnection();
|
||||
</script>
|
||||
|
||||
{#if $connection.path}
|
||||
<path d={$connection.path} fill="none" stroke={$connection.startHandle?.handleId} />
|
||||
{/if}
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { Handle, Position, type NodeProps } from '@xyflow/svelte';
|
||||
|
||||
type $$Props = NodeProps;
|
||||
|
||||
export let isConnectable: $$Props['isConnectable'];
|
||||
|
||||
const DEFAULT_HANDLE_STYLE = 'width: 10px; height: 10px; bottom: -5px;';
|
||||
</script>
|
||||
|
||||
<div style="background: #DDD; padding: 25px">
|
||||
<div>Node</div>
|
||||
<Handle
|
||||
type="source"
|
||||
id="red"
|
||||
position={Position.Bottom}
|
||||
style={DEFAULT_HANDLE_STYLE + 'left: 15%; background: red;'}
|
||||
{isConnectable}
|
||||
/>
|
||||
<Handle
|
||||
type="source"
|
||||
position={Position.Bottom}
|
||||
id="blue"
|
||||
style={DEFAULT_HANDLE_STYLE + 'left: 50%; background: blue;'}
|
||||
{isConnectable}
|
||||
/>
|
||||
<Handle
|
||||
type="source"
|
||||
position={Position.Bottom}
|
||||
id="orange"
|
||||
style={DEFAULT_HANDLE_STYLE + 'left: 85%; background: orange;'}
|
||||
{isConnectable}
|
||||
/>
|
||||
</div>
|
||||
Reference in New Issue
Block a user