feat: migrate most of graph-manager to svelte-5
Some checks failed
Deploy to GitHub Pages / build_site (push) Failing after 2m44s

This commit is contained in:
2024-11-02 19:37:22 +01:00
parent fa659ab74e
commit 4f03f2af5a
21 changed files with 321 additions and 264 deletions

View File

@ -3,23 +3,33 @@
import { getGraphManager } from "../graph/context.js";
import { Input } from "@nodes/ui";
export let node: Node;
export let input: NodeInput;
export let id: string;
type Props = {
node: Node;
input: NodeInput;
id: string;
elementId?: string;
};
const {
node,
input,
id,
elementId = `input-${Math.random().toString(36).substring(7)}`,
}: Props = $props();
const graph = getGraphManager();
let value = node?.props?.[id] ?? input.value;
let value = $state(node?.props?.[id] ?? input.value);
export let elementId: string = `input-${Math.random().toString(36).substring(7)}`;
$: if (node?.props?.[id] !== value) {
node.props = { ...node.props, [id]: value };
if (graph) {
graph.save();
graph.execute();
$effect(() => {
if (value !== undefined && node?.props?.[id] !== value) {
node.props = { ...node.props, [id]: value };
if (graph) {
graph.save();
graph.execute();
}
}
}
});
</script>
<Input id="input-{elementId}" {input} bind:value />