feat(svelte): ssr
This commit is contained in:
@@ -116,6 +116,8 @@
|
||||
class:parent={isParent}
|
||||
style:z-index={zIndex}
|
||||
style:transform="translate({positionOrigin?.x ?? 0}px, {positionOrigin?.y ?? 0}px)"
|
||||
style:width={node.dimensions?.width && `${node.dimensions?.width}px`}
|
||||
style:height={node.dimensions?.height && `${node.dimensions?.height}px`}
|
||||
{style}
|
||||
on:click={onSelectNodeHandler}
|
||||
on:mouseenter={(event) => dispatch('nodemouseenter', { node, event })}
|
||||
|
||||
@@ -2,8 +2,14 @@
|
||||
import { onDestroy, 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'] = undefined;
|
||||
export let edges: $$Props['edges'] = undefined;
|
||||
|
||||
const store = createStore({ nodes, edges });
|
||||
|
||||
setContext(key, {
|
||||
getStore: () => store
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { Edge, Node } from '$lib/types';
|
||||
|
||||
export type SvelteFlowProviderProps = {
|
||||
nodes?: Node[];
|
||||
edges?: Edge[];
|
||||
};
|
||||
Reference in New Issue
Block a user