Files
bim_engine/src/managers/button-group-manager.ts

47 lines
1.3 KiB
TypeScript
Raw Normal View History

import { BimButtonGroup } from '../components/button-group';
import type { ButtonGroupOptions } from '../components/button-group/index.type';
import type { ThemeConfig } from '../themes/types';
2025-12-08 10:02:24 +08:00
import { BimComponent } from '../core/component';
import type { BimEngine } from '../bim-engine';
/**
2025-12-08 10:02:24 +08:00
* (ButtonGroupManager)
*
*/
2025-12-08 10:02:24 +08:00
export class ButtonGroupManager extends BimComponent {
private groups: Map<string, BimButtonGroup> = new Map();
private container: HTMLElement;
2025-12-08 10:02:24 +08:00
constructor(engine: BimEngine, container: HTMLElement) {
super(engine);
this.container = container;
}
2025-12-08 10:02:24 +08:00
public create(id: string, options: Omit<ButtonGroupOptions, 'container'>): BimButtonGroup {
const group = new BimButtonGroup({
2025-12-08 10:02:24 +08:00
container: this.container,
...options
});
2025-12-08 10:02:24 +08:00
// @ts-ignore
group.setEngine(this.engine);
group.init();
2025-12-08 10:02:24 +08:00
this.groups.set(id, group);
return group;
}
2025-12-08 10:02:24 +08:00
public get(id: string): BimButtonGroup | undefined {
return this.groups.get(id);
}
2025-12-08 10:02:24 +08:00
public updateTheme(theme: ThemeConfig) {
this.groups.forEach(group => group.setTheme(theme));
}
public destroy() {
2025-12-08 10:02:24 +08:00
this.groups.forEach(group => group.destroy());
this.groups.clear();
}
}