@whitesev/pops
Version:
弹窗库,包含了alert、confirm、prompt、drawer、folder、loading、iframe、panel、tooltip、searchSuggestion、rightClickMenu组件
251 lines (250 loc) • 9.28 kB
TypeScript
import type { PopsAlertConfig } from "../components/alert/types";
import type { PopsConfirmConfig } from "../components/confirm/types";
import type { PopsDrawerConfig } from "../components/drawer/types";
import type { PopsFolderConfig } from "../components/folder/types";
import type { PopsIframeConfig } from "../components/iframe/types";
import type { PopsLoadingConfig } from "../components/loading/types";
import type { PopsPanelConfig } from "../components/panel/types";
import type { PopsPromptConfig } from "../components/prompt/types/index";
import type { EventEmiter } from "../event/EventEmiter";
import type { PopsGeneralConfig } from "../types/components";
import type { PopsEventConfig, PopsHandlerEventConfig } from "../types/event";
import type { CustomEventMap } from "../types/EventEmitter";
import type { PopsInstGeneralConfig } from "../types/inst";
import type { PopsInstStoreType, PopsSupportAnimConfigType, PopsSupportOnlyConfig, PopsType } from "../types/main";
export declare const PopsHandler: {
/**
* 创建shadow
*/
handlerShadow(config: Pick<PopsGeneralConfig, "useShadowRoot" | "stopKeyDownEventPropagation">): {
$shadowContainer: HTMLDivElement;
$shadowRoot: HTMLElement | ShadowRoot;
};
/**
* 处理初始化
* @param $styleParent style元素的父元素
* @param css 添加进ShadowRoot的CSS
*/
handleInit($styleParent?: ShadowRoot | HTMLElement, css?: string | string[] | {
name?: string;
css: string;
}[]): void;
/**
* 处理遮罩层
*
* + 设置遮罩层的点击事件
* @param config 传递的配置
*/
handleMask(config?: {
type: "alert" | "confirm" | "prompt" | "loading" | "iframe" | "drawer" | "folder" | "panel";
guid: string;
config: Required<PopsAlertConfig> | Required<PopsLoadingConfig> | Required<PopsIframeConfig> | Required<PopsDrawerConfig> | Required<PopsPanelConfig> | Required<PopsFolderConfig>;
animElement: HTMLElement;
maskHTML: string;
}): {
maskElement: HTMLDivElement;
};
/**
* 处理获取元素
* @param animElement
* @param type
*/
handleQueryElement(animElement: HTMLDivElement, type: PopsSupportAnimConfigType): {
/**
* 主元素
*/
$pops: HTMLDivElement;
/**
* 确认按钮
*/
$btnOk: HTMLDivElement;
/**
* 取消按钮
*/
$btnCancel: HTMLDivElement;
/**
* 其它按钮
*/
$btnOther: HTMLDivElement;
/**
* 标题元素
*/
$title: HTMLDivElement;
/**
* 输入框元素
*/
$input: HTMLInputElement | HTMLTextAreaElement;
/**
* 顶部按钮控制层元素
*/
$headerControls: HTMLDivElement;
/**
* iframe元素
*/
$iframe: HTMLIFrameElement;
/**
* 加载中元素
*/
$loading: HTMLDivElement;
/**
* 内容元素
*/
$content: HTMLDivElement;
/**
* panel的右侧容器元素
*/
$panelRightSectionWrapper: HTMLDivElement;
/**
* panel侧边栏容器元素
*/
$panelLeftAside: HTMLDivElement;
/**
* panel主要区域容器元素
*/
$panelContentSectionContainer: HTMLDivElement;
/**
* panel底部区域
*/
$panelBottomWrapper: HTMLElement;
/**
* panel底部区域容器
*/
$panelBottomContainer: HTMLElement;
/**
* panel底部区域左侧容器
*/
$panelBottomLeftContainer: HTMLElement;
/**
* panel底部区域右侧容器
*/
$panelBottomRightContainer: HTMLElement;
/**
* 内容加载中元素
*/
$contentLoading: HTMLDivElement;
/**
* 顶部缩小按钮
*/
$headerBtnMin: HTMLDivElement;
/**
* 顶部放大按钮
*/
$headerBtnMax: HTMLDivElement;
/**
* 顶部恢复原样按钮
*/
$headerBtnMise: HTMLDivElement;
/**
* 顶部关闭按钮
*/
$headerBtnClose: HTMLDivElement;
/**
* 文件夹列表元素
*/
$folderList: HTMLDivElement;
/**
* 文件夹列表顶部元素
*/
$folderHeaderNav: HTMLDivElement;
/**
* 文件夹列表行元素
*/
$folderHeaderRow: HTMLTableRowElement;
/**
* 文件夹列表tbody元素
*/
$folderTbody: HTMLTableElement;
/**
* 文件夹列表primary元素
*/
$folderHeaderBreadcrumbPrimary: HTMLDivElement;
/**
* 文件夹排序按钮-文件名
*/
$folderSortFileName: HTMLDivElement;
/**
* 文件夹排序按钮-修改时间
*/
$folderSortLatestTime: HTMLDivElement;
/**
* 文件夹排序按钮-文件大小
*/
$folderSortFileSize: HTMLDivElement;
};
/**
* 获取事件配置
* @param guid
* @param $shadowContainer
* @param $shadowRoot
* @param type 当前弹窗类型
* @param $anim 动画层
* @param $pops 主元素
* @param $mask 遮罩层
* @param config 当前配置
*/
handleEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, guid: string, $shadowContainer: HTMLDivElement, $shadowRoot: ShadowRoot | HTMLElement, type: PopsInstStoreType, $anim: HTMLDivElement, $pops: HTMLDivElement, emitter: E, $mask?: HTMLDivElement): PopsEventConfig<E>;
/**
* 获取loading的事件配置
* @param guid
* @param type 当前弹窗类型
* @param $anim 动画层
* @param $pops 主元素
* @param $mask 遮罩层
* @param config 当前配置
*/
handleLoadingEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, guid: string, type: "loading", $anim: HTMLDivElement, $pops: HTMLDivElement, emitter: E, $mask?: HTMLDivElement): Omit<PopsEventConfig<E>, "$shadowContainer" | "$shadowRoot">;
/**
* 处理返回的配置,针对popsHandler.handleEventConfig
* @param config 配置
*/
handleResultConfig<T>(config: T): Omit<T, "type" | "function">;
/**
* 处理点击事件
* @param type 当前按钮类型
* @param $btn 按钮元素
* @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
* @param callback 点击回调
*/
handleClickEvent<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(type: PopsHandlerEventConfig<E>["type"], $btn: HTMLElement, eventConfig: PopsEventConfig<E>, callback?: (details: PopsHandlerEventConfig<E>, event: PointerEvent | MouseEvent) => void): import("../types/PopsDOMUtilsEventType").PopsDOMUtilsAddEventListenerResult | undefined;
/**
* 全局监听键盘事件
* @param keyName 键名|键值
* @param otherKeyList 组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
* @param callback 回调函数
*/
handleKeyboardEvent(keyName: string | number, otherKeyList: string[] | undefined, callback: (event: KeyboardEvent) => void): import("../types/PopsDOMUtilsEventType").PopsDOMUtilsAddEventListenerResult;
/**
* 处理prompt的点击事件
* @param type 触发事件类型
* @param inputElement 输入框
* @param $btn 按钮元素
* @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
* @param callback 点击回调
*/
handlePromptClickEvent<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(type: PopsHandlerEventConfig<E>["type"], inputElement: HTMLInputElement | HTMLTextAreaElement, $btn: HTMLElement, eventConfig: PopsEventConfig<E>, callback: (details: PopsEventConfig<E> & {
type: any;
text: string;
}, event: MouseEvent | PointerEvent) => void): void;
/**
* 获取数值
* @param target
*/
getTargerOrFunctionValue<T>(target: T | (() => T)): T;
/**
* 处理config.only
* @param type 当前弹窗类型
* @param config 配置
*/
handleOnly<T extends Required<PopsSupportOnlyConfig[keyof PopsSupportOnlyConfig]>>(type: PopsType, config: T): T;
/**
* 处理z-index
* @param config 配置
*/
handleZIndex<T extends Required<PopsSupportOnlyConfig[keyof PopsSupportOnlyConfig]>>(config: T): T;
/**
* 处理把已创建的元素保存到内部环境中
* @param type 当前弹窗类型
* @param value
*/
handlePush(type: PopsInstStoreType, value: PopsInstGeneralConfig): void;
};