162 lines
4.3 KiB
TypeScript
162 lines
4.3 KiB
TypeScript
export type GetTextCallback = (key: string, defaultValue?: string | null) => string;
|
|
|
|
export interface LanguageResource {
|
|
[key: string]: string | undefined | GetTextCallback;
|
|
r: GetTextCallback;
|
|
}
|
|
|
|
export interface OptionParamBase {
|
|
getText?: GetTextCallback;
|
|
}
|
|
|
|
export interface NotifyOption {
|
|
message: string | HTMLElement;
|
|
parent?: HTMLElement;
|
|
title?: string;
|
|
type?: "success" | "warning" | "error";
|
|
persistent?: boolean;
|
|
timeout?: number;
|
|
onDismissed?: (auto?: boolean) => void;
|
|
}
|
|
|
|
export interface PopupRectParam {
|
|
collapsed?: boolean;
|
|
left?: number;
|
|
top?: number;
|
|
width?: number;
|
|
height?: number;
|
|
}
|
|
|
|
export interface Popup {
|
|
constructor(opts?: PopupOptions): void;
|
|
|
|
get container(): HTMLElement;
|
|
|
|
get title(): string;
|
|
set title(title: string);
|
|
|
|
get loading(): boolean;
|
|
set loading(flag: boolean);
|
|
|
|
get rect(): PopupRectParam | null;
|
|
set rect(r: PopupRectParam);
|
|
|
|
close(result?: any, animation?: boolean): void;
|
|
create(): HTMLDivElement;
|
|
show(parent?: HTMLElement, hidden?: boolean): Promise<HTMLElement> | undefined;
|
|
}
|
|
|
|
export interface PopupButton {
|
|
className?: string;
|
|
tabIndex?: number;
|
|
key: string;
|
|
text: string;
|
|
isPrimary?: boolean;
|
|
trigger: (this: Popup) => boolean | Promise<boolean>;
|
|
}
|
|
|
|
export interface PopupOptions {
|
|
/** 弹出框内容,可以是文本或者 html 元素 */
|
|
content: string | HTMLElement;
|
|
/** 弹出框标题,可以是文本或者 html 元素 */
|
|
title: string | HTMLElement;
|
|
|
|
/** 是否持久化显示 */
|
|
persistent?: boolean;
|
|
/** 是否包含遮罩层,默认为 `true` */
|
|
mask?: boolean;
|
|
/** 遮罩层 z-index */
|
|
zIndex?: number;
|
|
/** 是否在获取焦点时修改 z-index */
|
|
changeZIndex?: boolean;
|
|
/** 是否允许关闭 */
|
|
closable?: boolean;
|
|
/** 是否允许移动 */
|
|
movable?: boolean;
|
|
/** 是否允许修改大小 */
|
|
resizable?: boolean;
|
|
/** 最小宽度,默认 200 */
|
|
minWidth?: number;
|
|
/** 最小高度,默认 200 */
|
|
minHeight?: number;
|
|
/** 是否允许弹出框收折 */
|
|
collapsable?: boolean;
|
|
/** 弹出框的按钮定义集合 */
|
|
buttons?: PopupButton[];
|
|
|
|
/**
|
|
* 遮罩层显示或者隐藏时的回调函数
|
|
* @param this 当前 popup 对象
|
|
* @param masking 显示或隐藏遮罩层
|
|
*/
|
|
onMasking?: (this: Popup, masking: boolean) => void;
|
|
/**
|
|
* 移动结束时的回调函数
|
|
* @param this 当前 popup 对象
|
|
*/
|
|
onMoveEnded?: (this: Popup) => void;
|
|
/**
|
|
* 修改大小开始时的回调函数
|
|
* @param this 当前 popup 对象
|
|
*/
|
|
onResizeStarted?: (this: Popup) => void;
|
|
/**
|
|
* 修改大小中的回调函数
|
|
* @param this 当前 popup 对象
|
|
* @param x 坐标 x
|
|
* @param y 坐标 y
|
|
* @param width 当前宽度
|
|
* @param height 当前高度
|
|
*/
|
|
onResizing?: (this: Popup, x: number, y: number, width: number, height: number) => void;
|
|
/**
|
|
* 修改大小结束时的回调函数
|
|
* @param this 当前 popup 对象
|
|
*/
|
|
onResizeEnded?: (this: Popup) => void;
|
|
/**
|
|
* 弹出框关闭时的回调函数
|
|
*/
|
|
resolve?: (this: Popup, result: { result: any, popup: Popup }) => void;
|
|
}
|
|
|
|
/**
|
|
* 复选框选项
|
|
*/
|
|
export interface CheckboxOptions {
|
|
/** 样式类名 */
|
|
className?: string;
|
|
/** 是否可用 */
|
|
enabled?: boolean;
|
|
/** html 名称 */
|
|
name?: string;
|
|
/** 焦点索引 */
|
|
tabIndex?: number;
|
|
/** 是否为 switch 样式 */
|
|
switch?: boolean;
|
|
/** 样式分类 */
|
|
type?: "fa-light" | "fa-regular" | "fa-solid";
|
|
/** 标签 */
|
|
label?: string | HTMLElement;
|
|
/** 标签提示文本 */
|
|
title?: string;
|
|
/** 是否已选中 */
|
|
checked?: boolean;
|
|
/** 是否处于中间状态 */
|
|
indeterminate?: boolean;
|
|
/** 图片高度 */
|
|
imageHeight?: number;
|
|
/** 选中时显示的元素 */
|
|
checkedNode?: HTMLElement;
|
|
/** 未选中时显示的元素 */
|
|
uncheckedNode?: HTMLElement;
|
|
/** 自定义 html 属性 */
|
|
customAttributes?: { [key: string]: string };
|
|
/**
|
|
* 复选框选择状态改变时触发
|
|
* @param this 当前复选框对应的 HtmlInput 元素
|
|
* @param ev 选择事件对象
|
|
*/
|
|
onchange?: (this: HTMLInputElement, ev: Event) => any;
|
|
}
|