mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-07-17 01:07:56 +00:00
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.
39 lines
1002 B
TypeScript
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))
|
|
}
|
|
}
|