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

68 lines
1.8 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';
import { BaseManager } from '../core/base-manager';
import { ManagerRegistry } from '../core/manager-registry';
/**
*
*
*/
export class ButtonGroupManager extends BaseManager {
/** 按钮组映射表 */
2025-12-08 10:02:24 +08:00
private groups: Map<string, BimButtonGroup> = new Map();
/** 容器元素 */
private container: HTMLElement;
constructor(container: HTMLElement, registry: ManagerRegistry) {
super(registry);
this.container = container;
}
/**
*
* @param id ID
* @param options
* @returns
*/
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,
registry: this.registry,
...options
});
2025-12-08 10:02:24 +08:00
group.init();
2025-12-08 10:02:24 +08:00
this.groups.set(id, group);
return group;
}
/**
*
* @param id ID
* @returns
*/
2025-12-08 10:02:24 +08:00
public get(id: string): BimButtonGroup | undefined {
return this.groups.get(id);
}
/**
*
* @param theme
*/
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();
super.destroy();
}
}