mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-01 19:51:54 +00:00
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Benjamin Lu <benceruleanlu@proton.me> Co-authored-by: github-actions <github-actions@github.com>
22 lines
728 B
TypeScript
22 lines
728 B
TypeScript
import type {
|
|
FileUploadInputSpec,
|
|
InputSpec as InputSpecV2
|
|
} from '@/schemas/nodeDef/nodeDefSchemaV2'
|
|
import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets'
|
|
|
|
import type { LGraphNode } from '../../lib/litegraph/src/litegraph'
|
|
import type { IFileUploadWidget } from '../../lib/litegraph/src/types/widgets'
|
|
|
|
export const useFileUploadWidget = (): ComfyWidgetConstructorV2 => {
|
|
return (node: LGraphNode, inputSpec: InputSpecV2): IFileUploadWidget => {
|
|
const { name, options = {} } = inputSpec as FileUploadInputSpec
|
|
|
|
const widget = node.addWidget('fileupload', name, '', () => {}, {
|
|
serialize: true,
|
|
...(options as Record<string, unknown>)
|
|
}) as IFileUploadWidget
|
|
|
|
return widget
|
|
}
|
|
}
|