feat(svelte): add Provider
This commit is contained in:
@@ -2,8 +2,17 @@
|
||||
import { setContext } from 'svelte';
|
||||
|
||||
import { createStore, key } from '$lib/store';
|
||||
import type { SvelteFlowProviderProps } from './types';
|
||||
|
||||
const store = createStore();
|
||||
type $$Props = SvelteFlowProviderProps;
|
||||
|
||||
export let nodes: $$Props['nodes'];
|
||||
export let edges: $$Props['edges'];
|
||||
|
||||
const store = createStore({
|
||||
nodes,
|
||||
edges,
|
||||
});
|
||||
|
||||
setContext(key, {
|
||||
getStore: () => store
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { SvelteFlowProps } from '$lib/container/SvelteFlow/types';
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
export type SvelteFlowProviderProps = Pick<
|
||||
SvelteFlowProps,
|
||||
'nodes' | 'edges' | 'fitView' | 'nodeTypes'
|
||||
>;
|
||||
import type { Edge } from '$lib/types';
|
||||
import type { createNodes } from '$lib/utils';
|
||||
|
||||
export type SvelteFlowProviderProps = {
|
||||
nodes: ReturnType<typeof createNodes>;
|
||||
edges: Writable<Edge[]>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user