2024-03-14 16:55:11 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import Checkbox from "$lib/elements/Checkbox.svelte";
|
|
|
|
import Float from "$lib/elements/Float.svelte";
|
|
|
|
import Integer from "$lib/elements/Integer.svelte";
|
|
|
|
import Select from "$lib/elements/Select.svelte";
|
|
|
|
import type { Node, NodeInput } from "$lib/types";
|
2024-03-20 01:40:42 +01:00
|
|
|
import { getGraphManager } from "../graph/context";
|
2024-03-14 16:55:11 +01:00
|
|
|
|
|
|
|
export let node: Node;
|
|
|
|
export let input: NodeInput;
|
|
|
|
export let id: string;
|
|
|
|
|
2024-03-19 16:41:15 +01:00
|
|
|
const graph = getGraphManager();
|
|
|
|
|
2024-03-14 16:55:11 +01:00
|
|
|
let value = node?.props?.[id] ?? input.value;
|
|
|
|
|
2024-03-19 16:41:15 +01:00
|
|
|
$: if (node?.props?.[id] !== value) {
|
|
|
|
node.props = { ...node.props, [id]: value };
|
|
|
|
graph.execute();
|
2024-03-14 16:55:11 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2024-03-19 16:41:15 +01:00
|
|
|
<label for="asd">{id}</label>
|
2024-03-14 16:55:11 +01:00
|
|
|
{#if input.type === "float"}
|
|
|
|
<Float bind:value />
|
|
|
|
{:else if input.type === "integer"}
|
|
|
|
<Integer bind:value />
|
|
|
|
{:else if input.type === "boolean"}
|
|
|
|
<Checkbox bind:value />
|
|
|
|
{:else if input.type === "select"}
|
|
|
|
<Select options={input.options} bind:value />
|
|
|
|
{/if}
|