Spaces:
Running
Running
File size: 1,009 Bytes
c1a1d02 c470835 39a1d35 c1a1d02 b7a4f8b c1a1d02 aa0792f c470835 39a1d35 c1a1d02 39a1d35 d43f961 b7a4f8b c470835 b7a4f8b c1a1d02 b5a8a95 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 |
<script lang="ts">
import { getContext } from 'svelte';
import { type NodeProps, useNodes } 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'];
$: 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;
}
$: params = $nodes && data?.params ? Object.entries(data.params) : [];
const nodes = useNodes(); // We don't properly get updates to "data". This is a hack.
$: props = $nodes && $$props;
</script>
<LynxKiteNode {...props}>
{#each params as [name, value]}
<NodeParameter
{name}
{value}
meta={metaParams?.[name]}
onChange={(value) => setParam(name, value)}
/>
{/each}
<slot />
</LynxKiteNode>
|