mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-19 22:09:37 +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>
23 lines
742 B
TypeScript
23 lines
742 B
TypeScript
import type {
|
|
InputSpec as InputSpecV2,
|
|
MultiSelectInputSpec
|
|
} from '@/schemas/nodeDef/nodeDefSchemaV2'
|
|
import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets'
|
|
|
|
import type { LGraphNode } from '../../lib/litegraph/src/litegraph'
|
|
import type { IMultiSelectWidget } from '../../lib/litegraph/src/types/widgets'
|
|
|
|
export const useMultiSelectWidget = (): ComfyWidgetConstructorV2 => {
|
|
return (node: LGraphNode, inputSpec: InputSpecV2): IMultiSelectWidget => {
|
|
const { name, options = {} } = inputSpec as MultiSelectInputSpec
|
|
|
|
const widget = node.addWidget('multiselect', name, [], () => {}, {
|
|
serialize: true,
|
|
values: options.values || [],
|
|
...options
|
|
}) as IMultiSelectWidget
|
|
|
|
return widget
|
|
}
|
|
}
|