Files
ComfyBox/src/lib/widgets/TextWidget.svelte
space-nuko 890c839b4d temp
2023-05-02 14:58:02 -07:00

40 lines
1.1 KiB
Svelte

<script lang="ts">
import type { WidgetUIStateStore } from "$lib/stores/nodeState";
import { TextBox } from "@gradio/form";
import type { ComfyComboNode } from "$lib/nodes/index";
import { type WidgetLayout } from "$lib/stores/layoutState";
import { get, type Writable } from "svelte/store";
export let widget: WidgetLayout | null = null;
let node: ComfyComboNode | null = null;
let nodeValue: Writable<string> | null = null;
let itemValue: WidgetUIStateStore | null = null;
$: if(widget) {
node = widget.node as ComfyComboNode
nodeValue = node.value;
};
</script>
<div class="wrapper gr-textbox">
{#if node !== null && nodeValue !== null}
<TextBox
bind:value={$itemValue}
label={widget.attrs.title}
lines={node.properties.multiline ? 5 : 1}
max_lines={node.properties.multiline ? 5 : 1}
show_label={true}
on:change
on:submit
on:blur
on:select
/>
{/if}
</div>
<style>
.wrapper {
padding: 2px;
width: 100%;
}
</style>