Files
ComfyUI_frontend/src/lib/litegraph/src/widgets/SelectButtonWidget.ts
DrJKL b8b6f51b3a refactor(subgraph): address review nits on promotion + migration
- proxyWidgetMigration: switch repairValue/migratePreview to exhaustive
  switches with a shared `assertUnreachablePlan(plan: never)` helper so
  adding a new Plan kind triggers a TS error at the dispatcher.
- previewExposureStore: drop unused `moveExposure` action (and its
  tests); document deferred Object.freeze hardening at getExposures.
- usePromotedPreviews: drop optional chaining on
  nodeOutputStore.getNode*ByExecutionId methods (always defined).
- BaseWidget: drop the unused `_suppressPromotedOutline` parameter on
  `getOutlineColor` and the `suppressPromotedOutline` field on
  `DrawWidgetOptions`; remove all 14 call sites.
- SubgraphNodeWidget.vue: switch to tuple-form `defineEmits<{ ... }>()`.
- LGraph: rewrite the `proxyWidgetMigrationFlush` JSDoc to cite the
  real reason for late binding (the migration module's transitive
  workbench imports, not PreviewExposureStore); mark both
  `proxyWidgetMigrationFlush` and `autoExposePreviewNodes` `@internal`.
- proxyWidgetMigration tests: update assertions to verify behavior
  (host inputs, exposures, quarantine entries) now that
  `flushProxyWidgetMigration` returns void.

Amp-Thread-ID: https://ampcode.com/threads/T-019e2812-d683-710e-946f-9ddb9018ff5a
Co-authored-by: Amp <amp@ampcode.com>
2026-05-14 13:28:00 -07:00

50 lines
1.3 KiB
TypeScript

import { t } from '@/i18n'
import type { ISelectButtonWidget } from '../types/widgets'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for selecting from a group of buttons
* This is a widget that only has a Vue widgets implementation
*/
export class SelectButtonWidget
extends BaseWidget<ISelectButtonWidget>
implements ISelectButtonWidget
{
override type = 'selectbutton' as const
drawWidget(ctx: CanvasRenderingContext2D, options: DrawWidgetOptions): void {
const { width } = options
const { y, height } = this
const { fillStyle, strokeStyle, textAlign, textBaseline, font } = ctx
ctx.fillStyle = this.background_color
ctx.fillRect(15, y, width - 30, height)
ctx.strokeStyle = this.getOutlineColor()
ctx.strokeRect(15, y, width - 30, height)
ctx.fillStyle = this.text_color
ctx.font = '11px monospace'
ctx.textAlign = 'center'
ctx.textBaseline = 'middle'
const text = `SelectButton: ${t('widgets.node2only')}`
ctx.fillText(text, width / 2, y + height / 2)
Object.assign(ctx, {
fillStyle,
strokeStyle,
textAlign,
textBaseline,
font
})
}
onClick(_options: WidgetEventOptions): void {
// This is a widget that only has a Vue widgets implementation
}
}