Spaces:
Running
Running
File size: 1,039 Bytes
c1a1d02 c470835 c1a1d02 b7a4f8b c1a1d02 c470835 aa0792f c470835 d43f961 c1a1d02 3d534f4 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 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>
|