All 16 managers now receive ManagerRegistry instance through constructor instead of calling ManagerRegistry.getInstance(). This enables each BimEngine instance to have its own isolated set of managers. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { BimDialog } from '../components/dialog';
|
|
import type { DialogOptions } from '../components/dialog/index.type';
|
|
import type { ThemeConfig } from '../themes/types';
|
|
import { themeManager } from '../services/theme';
|
|
import { BaseManager } from '../core/base-manager';
|
|
import { ManagerRegistry } from '../core/manager-registry';
|
|
|
|
export class DialogManager extends BaseManager {
|
|
private container: HTMLElement;
|
|
private activeDialogs: BimDialog[] = [];
|
|
|
|
constructor(container: HTMLElement, registry: ManagerRegistry) {
|
|
super(registry);
|
|
this.container = container;
|
|
}
|
|
|
|
public create(options: Omit<DialogOptions, 'container'>): BimDialog {
|
|
const dialog = new BimDialog({
|
|
container: this.container,
|
|
...options,
|
|
onClose: () => {
|
|
this.activeDialogs = this.activeDialogs.filter(d => d !== dialog);
|
|
if (options.onClose) options.onClose();
|
|
}
|
|
});
|
|
|
|
dialog.setTheme(themeManager.getTheme());
|
|
this.activeDialogs.push(dialog);
|
|
return dialog;
|
|
}
|
|
|
|
public updateTheme(theme: ThemeConfig) {
|
|
this.activeDialogs.forEach(dialog => {
|
|
if (dialog.setTheme) {
|
|
dialog.setTheme(theme);
|
|
}
|
|
});
|
|
}
|
|
|
|
public destroy() {
|
|
this.activeDialogs.forEach(d => d.destroy());
|
|
this.activeDialogs = [];
|
|
super.destroy();
|
|
}
|
|
}
|