Files
ComfyUI_frontend/src/scripts/ui/components/buttonGroup.ts
huang47 2bb47e1a03 test: replay coverage PR for CodeRabbit canary
Apply the PR #13362 diff on top of the PR #13486 CodeRabbit path-instruction branch so CodeRabbit can review real changed test files before #13486 merges.

Verification: replayed the origin/pr-13362 commit range onto origin/pr-13486 with git cherry-pick --no-commit and no conflicts; parsed .coderabbit.yaml with Ruby YAML.load_file successfully; ran git diff --cached --check successfully.
2026-07-07 18:56:45 -07:00

39 lines
1002 B
TypeScript

import { $el } from '../../ui'
import { prop } from '../../utils'
import { ComfyButton } from './button'
export class ComfyButtonGroup {
element = $el('div.comfyui-button-group')
buttons: (HTMLElement | ComfyButton)[]
constructor(...buttons: (HTMLElement | ComfyButton)[]) {
this.buttons = prop(this, 'buttons', buttons, () => this.update())
}
insert(button: HTMLElement | ComfyButton, index: number) {
this.buttons.splice(index, 0, button)
this.update()
}
append(button: ComfyButton) {
this.buttons.push(button)
this.update()
}
remove(indexOrButton: ComfyButton | number) {
if (typeof indexOrButton !== 'number') {
indexOrButton = this.buttons.indexOf(indexOrButton)
}
if (indexOrButton > -1) {
const r = this.buttons.splice(indexOrButton, 1)
this.update()
return r
}
}
update() {
// @ts-expect-error fixme ts strict error
this.element.replaceChildren(...this.buttons.map((b) => b['element'] ?? b))
}
}