Files
bim_engine/dist/index.d.ts

449 lines
11 KiB
TypeScript
Raw Normal View History

/**
*
*
*/
declare class BimDialog {
private element;
private options;
private container;
private header;
private contentArea;
private _isDestroyed;
/**
*
* @param options
*/
constructor(options: DialogOptions);
/**
* DOM
*/
private createDom;
/**
*
*/
private setSize;
/**
*
*/
private init;
/**
*
*/
private initPosition;
/**
*
*/
private initDrag;
/**
*
*/
private initResize;
/**
*
* @param content HTML
*/
setContent(content: HTMLElement | string): void;
/**
*
*/
close(): void;
}
/**
* BimEngine
*
*/
2025-12-03 12:00:46 +08:00
export declare class BimEngine {
/** 主容器元素 */
2025-12-03 12:00:46 +08:00
private container;
/** 内部包装器元素,用于承载所有 UI 组件 */
private wrapper;
/** 工具栏管理器实例 */
toolbar: ToolbarManager | null;
/** 弹窗管理器实例 */
dialog: DialogManager | null;
/**
*
* @param container ID
*/
2025-12-03 12:00:46 +08:00
constructor(container: HTMLElement | string);
/**
*
* DOM
*/
2025-12-03 12:00:46 +08:00
private init;
/**
*
* DOM
*/
destroy(): void;
}
/**
*
*/
declare interface ButtonConfig {
/** 唯一标识 */
id: string;
/** 按钮类型:普通按钮或菜单按钮 */
type: ButtonType;
/** 按钮显示文字 */
label: string;
/** SVG 图标(内联 SVG 字符串) */
icon?: string;
/** 是否保持激活状态(默认 false */
keepActive?: boolean;
/** 是否禁用 */
disabled?: boolean;
/** 点击回调函数 */
onClick?: (button: OptButton) => void;
/** 子按钮配置(可选,用于菜单按钮) */
children?: ButtonConfig[];
/** 所属组ID */
groupId?: string;
/** 父按钮ID如果是子按钮则必填 */
parentId?: string;
}
/**
*
*/
export declare interface ButtonGroup {
/** 组 ID */
id: string;
/** 组内按钮列表 */
buttons: OptButton[];
}
declare type ButtonType = 'button' | 'menu';
/**
*
*/
export declare interface ClickPayload {
/** 被点击的按钮对象 */
button: OptButton;
/** 触发的动作类型 */
action: 'activate' | 'deactivate' | 'trigger';
/** 当前激活状态 */
isActive?: boolean;
}
/**
*
*/
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;
/**
*
* @param container
*/
constructor(container: HTMLElement);
/**
*
* @param options container使
* @returns BimDialog
*/
create(options: Omit<DialogOptions, 'container'>): BimDialog;
/**
*
*
*/
showInfoDialog(): 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;
/** 弹窗唯一标识 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;
};
/**
*
*
*/
export declare class OptBtnGroups {
/** 挂载容器 */
private container;
/** 组件配置选项 */
private options;
/** 按钮组列表,按顺序存储 */
private groups;
/** 当前处于激活状态的按钮 ID 集合 */
private activeBtnIds;
/** 按钮 DOM 元素的引用映射,方便快速查找 */
private btnRefs;
/** 当<><E5BD93>显示的下拉菜单元素 */
private dropdownElement;
/** 鼠标悬停计时器,用于处理菜单显示的防抖 */
private hoverTimeout;
/** 默认图标 SVG */
private readonly DEFAULT_ICON;
/**
*
* @param options
*/
constructor(options: OptBtnGroupsOptions);
/**
*
*/
private initContainer;
/**
* CSS
*/
private applyStyles;
/**
*
* @param colors
*/
setColors(colors: ToolbarColors): void;
/**
*
* @param groupId ID
* @param beforeGroupId <EFBFBD><EFBFBD><EFBFBD>
*/
addGroup(groupId: string, beforeGroupId?: string): void;
/**
*
* @param config groupId parentId
*/
addButton(config: ButtonConfig): void;
/**
*
*/
private findButton;
/**
*
*/
init(): Promise<void>;
/**
*
*/
render(): void;
/**
*
*/
private renderGroup;
/**
*
*/
private renderButton;
/**
*
*/
private handleClick;
/**
*
*/
private handleSubClick;
/**
*
*/
private handleMouseEnter;
/**
*
*/
private handleMouseLeave;
/**
*
*/
private showDropdown;
/**
*
*/
private renderDropdownItem;
/**
*
*/
private closeDropdown;
/**
*
*/
private updateButtonState;
/**
* SVG
*/
private getIcon;
/**
*
* @param buttonId ID
* @param visible
*/
updateButtonVisibility(buttonId: string, visible: boolean): void;
/**
*
* @param show
*/
setShowLabel(show: boolean): void;
/**
* ()
* @param color CSS
*/
setBackgroundColor(color: string): void;
/**
*
*/
private isVisible;
/**
*
*/
destroy(): void;
}
/**
* OptBtnGroups
*/
export declare interface OptBtnGroupsOptions extends ToolbarColors {
/** 容器元素或 ID */
container: HTMLElement | string;
/** 是否显示标签 */
showLabel?: boolean;
/** 按钮可见性配置 Map */
visibility?: Record<string, boolean>;
}
/**
* 使
*/
export declare interface OptButton extends ButtonConfig {
/** 内部使用的子按钮列表 */
children?: OptButton[];
2025-12-03 12:00:46 +08:00
}
/**
*
*/
declare interface ToolbarColors {
/** 工具栏背景颜色 */
backgroundColor?: string;
/** 按钮默认背景颜色 */
btnBackgroundColor?: string;
/** 按钮 Hover 背景颜色 */
btnHoverColor?: string;
/** 按钮激活状态背景颜色 */
btnActiveColor?: string;
/** 图标默认颜色 */
iconColor?: string;
/** 图标激活/Hover 颜色 */
iconActiveColor?: string;
/** 文字默认颜色 */
textColor?: string;
/** 文字激活/Hover 颜色 */
textActiveColor?: string;
}
/**
*
*
*/
declare class ToolbarManager {
/** 内部工具栏组件实例 */
private optBtnGroups;
/** 工具栏挂载的容器 */
private container;
/**
*
* @param container
*/
constructor(container: HTMLElement);
/**
*
*/
private init;
/**
*
* @param groupId ID
* @param beforeGroupId ()
*/
addGroup(groupId: string, beforeGroupId?: string): void;
/**
*
* @param config
*/
addButton(config: ButtonConfig): void;
/**
*
* @param buttonId ID
* @param visible
*/
setButtonVisibility(buttonId: string, visible: boolean): void;
/**
*
* @param show
*/
setShowLabel(show: boolean): void;
/**
*
* @param visible
*/
setVisible(visible: boolean): void;
/**
*
* @param color CSS
*/
setBackgroundColor(color: string): void;
/**
*
* @param colors
*/
setColors(colors: ToolbarColors): void;
/**
*
*/
destroy(): void;
}
2025-12-03 12:00:46 +08:00
export { }