Spaces:
Running
Running
File size: 1,039 Bytes
c1a1d02 7fcb083 c1a1d02 801415b c1a1d02 7fcb083 abb1488 7fcb083 31d7b86 c1a1d02 3d534f4 31d7b86 801415b 7fcb083 801415b c1a1d02 a6b7675 c1a1d02 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<script lang="ts">
import { getContext } from 'svelte';
import { type NodeProps, useSvelteFlow, useUpdateNodeInternals } from '@xyflow/svelte';
import LynxKiteNode from './LynxKiteNode.svelte';
import NodeParameter from './NodeParameter.svelte';
type $$Props = NodeProps;
export let id: $$Props['id'];
export let data: $$Props['data'];
const { updateNodeData } = useSvelteFlow();
const updateNodeInternals = useUpdateNodeInternals();
$: metaParams = data.meta?.params;
$: store = getContext('LynxKite store');
function setParam(name, newValue) {
const i = $store.workspace.nodes.findIndex((n) => n.id === id);
$store.workspace.nodes[i].data.params[name] = newValue;
updateNodeInternals();
}
$: params = data?.params ? Object.entries(data.params) : [];
</script>
<LynxKiteNode {...$$props}>
{#each params as [name, value]}
<NodeParameter
{name}
{value}
meta={metaParams?.[name]}
onChange={(value) => setParam(name, value)}
/>
{/each}
<slot />
</LynxKiteNode>
|