mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-21 23:34:31 +00:00
@@ -45,6 +45,7 @@ export type IWidget =
|
||||
| IComboWidget
|
||||
| ICustomWidget
|
||||
| ISliderWidget
|
||||
| IButtonWidget
|
||||
|
||||
export interface IBooleanWidget extends IBaseWidget {
|
||||
type?: "toggle"
|
||||
@@ -74,10 +75,16 @@ export type IStringWidgetType = IStringWidget["type"] | IMultilineStringWidget["
|
||||
|
||||
/** A widget with a string value */
|
||||
export interface IStringWidget extends IBaseWidget {
|
||||
type?: "string" | "text" | "button"
|
||||
type?: "string" | "text"
|
||||
value: string
|
||||
}
|
||||
|
||||
export interface IButtonWidget extends IBaseWidget {
|
||||
type?: "button"
|
||||
value: undefined
|
||||
clicked: boolean
|
||||
}
|
||||
|
||||
/** A widget with a string value and a multiline text input */
|
||||
export interface IMultilineStringWidget<TElement extends HTMLElement = HTMLTextAreaElement> extends
|
||||
IBaseWidget {
|
||||
@@ -117,7 +124,6 @@ export interface IBaseWidget<TElement extends HTMLElement = HTMLElement> {
|
||||
options: IWidgetOptions
|
||||
marker?: number
|
||||
label?: string
|
||||
clicked?: boolean
|
||||
name?: string
|
||||
/** Widget type (see {@link TWidgetType}) */
|
||||
type?: TWidgetType
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import type { IStringWidget, IWidgetOptions } from "@/types/widgets"
|
||||
import type { IButtonWidget, IWidgetOptions } from "@/types/widgets"
|
||||
import { BaseWidget } from "./BaseWidget"
|
||||
import type { LGraphNode } from "@/LGraphNode"
|
||||
import type { CanvasMouseEvent } from "@/types/events"
|
||||
import type { LGraphCanvas } from "@/LGraphCanvas"
|
||||
|
||||
export class ButtonWidget extends BaseWidget implements IStringWidget {
|
||||
// IStringWidget properties
|
||||
export class ButtonWidget extends BaseWidget implements IButtonWidget {
|
||||
// IButtonWidget properties
|
||||
declare type: "button"
|
||||
declare value: string
|
||||
declare options: IWidgetOptions<boolean>
|
||||
declare clicked: boolean
|
||||
declare value: undefined
|
||||
|
||||
constructor(widget: IStringWidget) {
|
||||
constructor(widget: IButtonWidget) {
|
||||
super(widget)
|
||||
this.type = "button"
|
||||
this.value = widget.value ?? ""
|
||||
this.clicked = widget.clicked ?? false
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ export class TextWidget extends BaseWidget implements IStringWidget {
|
||||
|
||||
constructor(widget: IStringWidget) {
|
||||
super(widget)
|
||||
this.type = widget.type as "text" | "string"
|
||||
this.type = widget.type ?? "string"
|
||||
this.value = widget.value?.toString() ?? ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user