Files
bim_engine/dist/index.d.ts

590 lines
15 KiB
TypeScript
Raw Normal View History

/**
* (BimButtonGroup)
*/
export declare class BimButtonGroup implements IBimComponent {
private container;
private options;
private groups;
private activeBtnIds;
private btnRefs;
private dropdownElement;
private hoverTimeout;
private customColors;
private unsubscribeLocale;
private unsubscribeTheme;
private readonly DEFAULT_ICON;
constructor(options: ButtonGroupOptions);
private initContainer;
private updatePosition;
/**
*
*/
private applyStyles;
/**
*
*
*/
setTheme(theme: ThemeConfig): void;
/**
*
* setTheme
*/
setColors(colors: ButtonGroupColors): void;
init(): Promise<void>;
setLocales(): void;
addGroup(groupId: string, beforeGroupId?: string): void;
addButton(config: ButtonConfig): void;
private findButton;
render(): void;
private renderGroup;
private renderButton;
private handleClick;
private handleMouseEnter;
private handleMouseLeave;
private showDropdown;
private renderDropdownItem;
private closeDropdown;
private updateButtonState;
private getIcon;
updateButtonVisibility(id: string, visible: boolean): void;
setShowLabel(show: boolean): void;
private updateLabelsVisibility;
private findButtonById;
setBackgroundColor(color: string): void;
private isVisible;
destroy(): void;
}
/**
*
*
*/
declare class BimDialog implements IBimComponent {
private element;
private options;
private container;
private header;
private contentArea;
private _isDestroyed;
private _isInitialized;
private unsubscribeTheme;
private unsubscribeLocale;
2025-12-04 18:39:07 +08:00
private rafId;
/**
*
* @param options
*/
constructor(options: DialogOptions);
/**
*
* @param theme
*/
setTheme(theme: ThemeConfig): void;
/**
* ()
*/
init(): void;
setLocales(): void;
/**
* DOM
*/
private createDom;
/**
*
*/
private setSize;
/**
*
*/
private initPosition;
/**
2025-12-04 18:39:07 +08:00
* ( + )
*/
private initDrag;
/**
2025-12-04 18:39:07 +08:00
* ( + )
*/
private initResize;
/**
*
* @param content HTML
*/
setContent(content: HTMLElement | string): void;
/**
*
*/
close(): void;
/**
* ()
*/
destroy(): void;
}
2025-12-03 12:00:46 +08:00
export declare class BimEngine {
private container;
private wrapper;
private topLeftGroup;
toolbar: ToolbarManager | null;
buttonGroup: ButtonGroupManager | null;
dialog: DialogManager | null;
2025-12-04 18:39:07 +08:00
engine: EngineManager | null;
get localeManager(): LocaleManager;
get themeManager(): ThemeManager;
constructor(container: HTMLElement | string, options?: {
locale?: LocaleType;
theme?: ThemeType;
});
setLocale(locale: LocaleType): void;
getLocale(): LocaleType;
setTheme(theme: 'dark' | 'light'): void;
setCustomTheme(theme: ThemeConfig): void;
2025-12-03 12:00:46 +08:00
private init;
2025-12-04 18:39:07 +08:00
/**
* 3D
* 使 demo.html
* @param options
*/
initEngine(options?: Omit<EngineOptions, 'container'>): boolean;
private updateTheme;
destroy(): void;
}
/** 按钮内部文字图标排列 */
declare type ButtonAlign = 'vertical' | 'horizontal';
/** 按钮配置 */
declare interface ButtonConfig {
id: string;
type: ButtonType;
label: string;
icon?: string;
keepActive?: boolean;
disabled?: boolean;
onClick?: (button: OptButton) => void;
children?: ButtonConfig[];
groupId?: string;
parentId?: string;
/** 按钮内部图标文字排列 (默认 vertical即图标在上) */
align?: ButtonAlign;
/** 图标大小 (正方形,单位 px默认 32) */
iconSize?: number;
/** 按钮最小宽度 (单位 px默认 50) */
minWidth?: number;
}
export declare interface ButtonGroup {
id: string;
buttons: OptButton[];
}
declare interface ButtonGroupColors {
backgroundColor?: string;
btnBackgroundColor?: string;
btnHoverColor?: string;
btnActiveColor?: string;
iconColor?: string;
iconActiveColor?: string;
textColor?: string;
textActiveColor?: string;
}
/**
*
*
*/
declare class ButtonGroupManager {
private activeGroups;
private container;
constructor(container: HTMLElement);
/**
*
*/
create(options: Omit<ButtonGroupOptions, 'container'>): BimButtonGroup;
updateTheme(theme: ThemeConfig): void;
refresh(): void;
destroy(): void;
}
export declare interface ButtonGroupOptions extends ButtonGroupColors {
container: HTMLElement | string;
/** 屏幕位置 (如 top-left) */
position?: GroupPosition;
/** 按钮组排列方向 (默认 row) */
direction?: GroupDirection;
/** 按钮内部图标文字排列 (默认 vertical) */
align?: ButtonAlign;
/** 菜单展开方向 */
expand?: ExpandDirection;
showLabel?: boolean;
visibility?: Record<string, boolean>;
className?: string;
}
declare type ButtonType = 'button' | 'menu';
export declare interface ClickPayload {
button: OptButton;
action: 'activate' | 'deactivate' | 'trigger';
isActive?: boolean;
}
2025-12-04 18:39:07 +08:00
export declare function createEngine(r) {
const e = r.version || "v1";
switch (e) {
case "v2":
return new Uc(r);
case "v1":
return new L_(r);
:
return console.warn(`Version '${e}' not found. Falling back to v2.`), new Uc(r);
}
}
/**
*
*/
declare interface DialogColors {
/** 窗体背景颜色,默认 rgba(17, 17, 17, 0.95) */
backgroundColor?: string;
/** 标题栏背景颜色,默认 #2a2a2a */
headerBackgroundColor?: string;
/** 标题文字颜色,默认 #fff */
titleColor?: string;
/** 内容文字颜色,默认 #ccc */
textColor?: string;
/** 边框颜色,默认 #444 */
borderColor?: string;
}
/**
*
*
*/
declare class DialogManager {
/** 弹窗挂载的父容器 */
private container;
/** 活跃的弹窗实例列表 */
private activeDialogs;
/**
*
* @param container
*/
constructor(container: HTMLElement);
/**
*
* @param options container使
* @returns BimDialog
*/
create(options: Omit<DialogOptions, 'container'>): BimDialog;
/**
*
*
*/
showInfoDialog(): void;
/**
*
* @param theme
*/
updateTheme(theme: ThemeConfig): void;
}
/**
*
*/
declare interface DialogOptions extends DialogColors {
/** 弹窗挂载的父容器 */
container: HTMLElement;
/** 弹窗标题 */
title?: string;
/** 弹窗内容,支持 HTML 字符串或 HTMLElement */
content?: HTMLElement | string;
/** 弹窗宽度,数字(像素)或字符串(如 '50%' */
width?: number | string;
/** 弹窗高度 */
height?: number | string;
/** 弹窗位置 */
position?: DialogPosition;
/** 是否可拖拽 */
draggable?: boolean;
/** 是否可调整大小 */
resizable?: boolean;
/** 最小宽度限制 */
minWidth?: number;
/** 最小高度限制 */
minHeight?: number;
/** 关闭时的回调函数 */
onClose?: () => void;
/** 打开时的回调函数 */
onOpen?: () => void;
/** 弹窗唯一标识 ID (可选) */
id?: string;
}
/**
*
* 'center', 'top-left'
* { x, y }
*/
declare type DialogPosition = 'center' | 'top-left' | 'top-center' | 'top-right' | 'left-center' | 'right-center' | 'bottom-left' | 'bottom-center' | 'bottom-right' | {
x: number;
y: number;
};
2025-12-04 18:39:07 +08:00
/**
* 3D
* Engine BimEngine API
* initialize()
*/
declare class EngineManager {
/** 3D 引擎挂载的父容器 */
private container;
/** 3D 引擎组件实例 */
private engine;
/**
*
* @param container 3D
*/
constructor(container: HTMLElement);
/**
* 3D
* @param options 使
* @returns
*/
initialize(options?: Omit<EngineOptions, 'container'>): boolean;
/**
* 3D
*/
isInitialized(): boolean;
/**
* 3D
* @param url URL
* @param options
*/
loadModel(url: string, options?: ModelLoadOptions): void;
/**
* 3D
* API
*/
getEngine(): any;
/**
* 3D
*/
destroy(): void;
}
/**
*
* Engine
*/
export declare interface EngineOptions {
/** 容器元素 */
container: HTMLElement;
/** 背景颜色(十六进制数字,如 0x333333 */
backgroundColor?: number;
/** WebGL 版本 */
version?: 'v1' | 'v2';
/** 是否显示性能统计 */
showStats?: boolean;
/** 是否显示视图立方体 */
showViewCube?: boolean;
}
/** 二级菜单展开方向 */
declare type ExpandDirection = 'up' | 'down' | 'left' | 'right';
/** 按钮组排列方向 (Flex-direction) */
declare type GroupDirection = 'row' | 'column';
/** 弹窗/按钮组位置 */
declare type GroupPosition = 'center' | 'top-left' | 'top-center' | 'top-right' | 'left-center' | 'right-center' | 'bottom-left' | 'bottom-center' | 'bottom-right' | {
x: number;
y: number;
} | 'static';
/**
* BIM
* UI
*/
declare interface IBimComponent {
/**
*
* DOM
*
*/
init(): void | Promise<void>;
/**
*
* ThemeConfig CSS
*/
setTheme(theme: ThemeConfig): void;
/**
*
*/
setLocales(): void;
/**
*
* DOM
*/
destroy(): void;
}
declare type LocaleChangeListener = (locale: LocaleType) => void;
/**
*
*/
declare class LocaleManager {
private currentLocale;
private messages;
private listeners;
constructor();
/**
*
*/
getLocale(): LocaleType;
/**
*
*/
setLocale(locale: LocaleType): void;
/**
*
*/
t(key: string): string;
/**
*
*/
subscribe(listener: LocaleChangeListener): () => void;
private notifyListeners;
}
/**
*
*/
declare type LocaleType = 'zh-CN' | 'en-US';
2025-12-04 18:39:07 +08:00
/**
*
*
*/
export declare interface ModelLoadOptions {
/** 模型初始位置 [x, y, z] */
position?: [number, number, number];
/** 模型初始旋转 [x, y, z](弧度) */
rotation?: [number, number, number];
/** 模型初始缩放 [x, y, z] */
scale?: [number, number, number];
/** 模型 ID可选如果不提供则自动生成 */
id?: string;
}
export declare interface OptButton extends ButtonConfig {
children?: OptButton[];
2025-12-03 12:00:46 +08:00
}
declare type ThemeChangeListener = (theme: ThemeConfig) => void;
/**
*
*
*/
declare interface ThemeConfig {
/** 主题名称 */
name: string;
/** 品牌色/主色 */
primary: string;
/** 主色悬停/激活态 */
primaryHover: string;
/** 基础背景色 (应用整体背景) */
background: string;
/** 面板背景色 (工具栏、弹窗背景) */
panelBackground: string;
/** 主要文字颜色 */
textPrimary: string;
/** 次要文字颜色 */
textSecondary: string;
/** 边框/分割线颜色 */
border: string;
/** 图标默认颜色 */
icon: string;
/** 图标激活颜色 */
iconActive: string;
/** 交互组件背景 (如按钮默认背景) */
componentBackground: string;
/** 交互组件悬停背景 */
componentHover: string;
/** 交互组件激活背景 */
componentActive: string;
}
/**
* ()
*/
declare class ThemeManager {
private currentTheme;
private listeners;
constructor();
/**
*
*/
getTheme(): ThemeConfig;
/**
*
* @param themeName 'dark' | 'light'
*/
setTheme(themeName: 'dark' | 'light'): void;
/**
*
* @param theme
*/
setCustomTheme(theme: ThemeConfig): void;
/**
*
*/
private applyTheme;
/**
*
*/
subscribe(listener: ThemeChangeListener): () => void;
private notifyListeners;
}
/**
*
*/
declare type ThemeType = 'dark' | 'light' | 'custom';
/**
* (Toolbar)
* BimButtonGroup
*/
export declare class Toolbar extends BimButtonGroup {
/**
*
*/
init(): Promise<void>;
}
/**
* (ToolbarManager)
*
*/
declare class ToolbarManager {
private toolbar;
private toolbarContainer;
private container;
constructor(container: HTMLElement);
private init;
updateTheme(theme: ThemeConfig): void;
refresh(): void;
destroy(): void;
addGroup(groupId: string, beforeGroupId?: string): void;
addButton(config: ButtonConfig): void;
setButtonVisibility(id: string, v: boolean): void;
setShowLabel(show: boolean): void;
setVisible(visible: boolean): void;
setBackgroundColor(color: string): void;
setColors(colors: ButtonGroupColors): void;
}
2025-12-03 12:00:46 +08:00
export { }