From 0f50dbae87cee04eb52f24ab89ba635c957c274f Mon Sep 17 00:00:00 2001 From: space-nuko <24979496+space-nuko@users.noreply.github.com> Date: Mon, 8 May 2023 18:08:28 -0500 Subject: [PATCH] Image upload widget --- package.json | 2 + pnpm-lock.yaml | 6 + src/lib/components/AccordionContainer.svelte | 3 +- src/lib/components/BlockContainer.svelte | 3 +- src/lib/components/ComfyApp.ts | 3 +- src/lib/components/TabsContainer.svelte | 3 +- .../components/gradio/app/UploadText.svelte | 38 +++ src/lib/nodes/ComfyActionNodes.ts | 16 +- src/lib/nodes/ComfyImageCacheNode.ts | 9 +- src/lib/nodes/ComfyWidgetNodes.ts | 55 ++++- src/lib/notify.ts | 8 +- src/lib/stores/layoutState.ts | 30 +-- src/lib/widgets/ComboWidget.svelte | 1 - src/lib/widgets/GalleryWidget.svelte | 20 +- src/lib/widgets/ImageUploadWidget.svelte | 231 ++++++++++++++++++ 15 files changed, 380 insertions(+), 48 deletions(-) create mode 100644 src/lib/components/gradio/app/UploadText.svelte create mode 100644 src/lib/widgets/ImageUploadWidget.svelte diff --git a/package.json b/package.json index 219d603..1199f9f 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,11 @@ "@gradio/atoms": "workspace:*", "@gradio/button": "workspace:*", "@gradio/client": "workspace:*", + "@gradio/file": "workspace:*", "@gradio/form": "workspace:*", "@gradio/gallery": "workspace:*", "@gradio/icons": "workspace:*", + "@gradio/image": "workspace:*", "@gradio/tabs": "workspace:*", "@gradio/theme": "workspace:*", "@gradio/upload": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7ce7654..00d8ec4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,6 +16,9 @@ importers: '@gradio/client': specifier: workspace:* version: link:gradio/client/js + '@gradio/file': + specifier: workspace:* + version: link:gradio/js/file '@gradio/form': specifier: workspace:* version: link:gradio/js/form @@ -25,6 +28,9 @@ importers: '@gradio/icons': specifier: workspace:* version: link:gradio/js/icons + '@gradio/image': + specifier: workspace:* + version: link:gradio/js/image '@gradio/tabs': specifier: workspace:* version: link:gradio/js/tabs diff --git a/src/lib/components/AccordionContainer.svelte b/src/lib/components/AccordionContainer.svelte index 64ff363..8cd307a 100644 --- a/src/lib/components/AccordionContainer.svelte +++ b/src/lib/components/AccordionContainer.svelte @@ -78,7 +78,7 @@
{#if item[SHADOW_ITEM_MARKER_PROPERTY_NAME]} @@ -183,6 +183,7 @@ .animation-wrapper { position: relative; flex-grow: 100; + flex-basis: 0; } .handle-widget:hover { diff --git a/src/lib/components/BlockContainer.svelte b/src/lib/components/BlockContainer.svelte index 10520f3..09172c9 100644 --- a/src/lib/components/BlockContainer.svelte +++ b/src/lib/components/BlockContainer.svelte @@ -80,7 +80,7 @@
{#if item[SHADOW_ITEM_MARKER_PROPERTY_NAME]} @@ -238,6 +238,7 @@ .animation-wrapper { position: relative; flex-grow: 100; + flex-basis: 0; } .handle-hidden { diff --git a/src/lib/components/ComfyApp.ts b/src/lib/components/ComfyApp.ts index e957273..589b18c 100644 --- a/src/lib/components/ComfyApp.ts +++ b/src/lib/components/ComfyApp.ts @@ -715,7 +715,8 @@ export default class ComfyApp { comfyInput.config.values = def["input"]["required"][comfyInput.name][0]; const inputNode = node.getInputNode(index) - if (inputNode && "doAutoConfig" in inputNode) { + if (inputNode && "doAutoConfig" in inputNode && comfyInput.widgetNodeType === inputNode.type) { + console.debug("[ComfyApp] Reconfiguring combo widget", inputNode.type, comfyInput.config.values) const comfyComboNode = inputNode as nodes.ComfyComboNode; comfyComboNode.doAutoConfig(comfyInput) if (!comfyInput.config.values.includes(get(comfyComboNode.value))) { diff --git a/src/lib/components/TabsContainer.svelte b/src/lib/components/TabsContainer.svelte index 1f163be..22925fe 100644 --- a/src/lib/components/TabsContainer.svelte +++ b/src/lib/components/TabsContainer.svelte @@ -92,7 +92,7 @@
+ style={item?.attrs?.style || ""}>