@whitesev/pops 3.3.5 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +13099 -12934
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +752 -587
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +752 -587
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +13100 -12935
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +13103 -12938
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +13102 -12937
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Pops.d.ts +131 -77
- package/dist/types/src/PopsAnimation.d.ts +33 -0
- package/dist/types/src/PopsIcon.d.ts +1 -1
- package/dist/types/src/components/alert/index.d.ts +3 -1
- package/dist/types/src/components/confirm/index.d.ts +3 -1
- package/dist/types/src/components/drawer/index.d.ts +3 -1
- package/dist/types/src/components/folder/index.d.ts +3 -1
- package/dist/types/src/components/iframe/index.d.ts +6 -1
- package/dist/types/src/components/iframe/types/index.d.ts +4 -2
- package/dist/types/src/components/loading/index.d.ts +3 -1
- package/dist/types/src/components/panel/handlerComponents.d.ts +4 -1
- package/dist/types/src/components/panel/index.d.ts +2 -16
- package/dist/types/src/components/panel/types/index.d.ts +7 -2
- package/dist/types/src/components/prompt/index.d.ts +3 -1
- package/dist/types/src/components/searchSuggestion/index.d.ts +4 -1
- package/dist/types/src/components/tooltip/index.d.ts +5 -1
- package/dist/types/src/config/GlobalConfig.d.ts +63 -23
- package/dist/types/src/event/EventEmiter.d.ts +33 -0
- package/dist/types/src/handler/PopsHandler.d.ts +16 -11
- package/dist/types/src/handler/PopsInstHandler.d.ts +67 -0
- package/dist/types/src/types/EventEmitter.d.ts +18 -0
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +4 -0
- package/dist/types/src/types/button.d.ts +2 -1
- package/dist/types/src/types/event.d.ts +6 -2
- package/dist/types/src/types/inst.d.ts +4 -4
- package/dist/types/src/utils/PopsDOMUtils.d.ts +0 -16
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +1 -89
- package/dist/types/src/utils/PopsUtils.d.ts +57 -0
- package/package.json +3 -3
- package/src/Pops.ts +7 -2
- package/src/PopsAnimation.ts +126 -0
- package/src/components/alert/index.ts +9 -9
- package/src/components/confirm/index.ts +9 -9
- package/src/components/drawer/index.ts +12 -9
- package/src/components/folder/index.ts +9 -8
- package/src/components/iframe/index.ts +18 -12
- package/src/components/iframe/types/index.ts +10 -8
- package/src/components/loading/index.ts +12 -6
- package/src/components/panel/defaultConfig.ts +1 -0
- package/src/components/panel/handlerComponents.ts +41 -111
- package/src/components/panel/index.ts +34 -28
- package/src/components/panel/types/index.ts +7 -2
- package/src/components/prompt/index.ts +9 -8
- package/src/components/rightClickMenu/index.ts +17 -14
- package/src/components/searchSuggestion/index.ts +5 -1
- package/src/components/tooltip/index.ts +20 -10
- package/src/config/GlobalConfig.ts +21 -14
- package/src/css/index.css +2 -0
- package/src/event/EventEmiter.ts +95 -0
- package/src/handler/PopsElementHandler.ts +8 -6
- package/src/handler/PopsHandler.ts +65 -48
- package/src/handler/PopsInstHandler.ts +557 -0
- package/src/types/EventEmitter.d.ts +18 -0
- package/src/types/PopsDOMUtilsEventType.d.ts +4 -0
- package/src/types/button.d.ts +2 -1
- package/src/types/event.d.ts +6 -2
- package/src/types/inst.d.ts +4 -4
- package/src/utils/PopsDOMUtils.ts +1 -40
- package/src/utils/PopsInstanceUtils.ts +10 -639
- package/src/utils/PopsUtils.ts +194 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PopsGeneralConfig, PopsDragConfig } from "../types/components";
|
|
2
|
-
type
|
|
2
|
+
type NullOrFunctionReturnType<T> = null | undefined | IFunction<T>;
|
|
3
3
|
type GlobalConfigOption = {
|
|
4
|
-
style?:
|
|
5
|
-
zIndex?:
|
|
4
|
+
style?: NullOrFunctionReturnType<string>;
|
|
5
|
+
zIndex?: NullOrFunctionReturnType<number | string>;
|
|
6
6
|
} & Partial<PopsGeneralConfig> & Partial<PopsDragConfig>;
|
|
7
7
|
export declare const GlobalConfig: {
|
|
8
8
|
config: GlobalConfigOption;
|
|
@@ -14,26 +14,66 @@ export declare const GlobalConfig: {
|
|
|
14
14
|
* 获取全局配置
|
|
15
15
|
*/
|
|
16
16
|
getGlobalConfig(): {
|
|
17
|
-
style?:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
style?: {
|
|
18
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
19
|
+
} | Omit<(IFunction<string> & string) | null | undefined, "zIndex"> | undefined;
|
|
20
|
+
zIndex?: {
|
|
21
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
22
|
+
} | Omit<((IFunction<string | number> | null) & IFunction<number>) | undefined, "zIndex"> | undefined;
|
|
23
|
+
useShadowRoot?: {
|
|
24
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
25
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
26
|
+
class?: {
|
|
27
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
28
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
29
|
+
only?: {
|
|
30
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
31
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
32
|
+
width?: {
|
|
33
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
34
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
35
|
+
height?: {
|
|
36
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
37
|
+
} | Omit<string | undefined, "zIndex"> | undefined;
|
|
38
|
+
position?: {
|
|
39
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
40
|
+
} | Omit<import("../types/position").PopsPosition | undefined, "zIndex"> | undefined;
|
|
41
|
+
animation?: {
|
|
42
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
43
|
+
} | Omit<import("../types/animation").PopsAnimation | undefined, "zIndex"> | undefined;
|
|
44
|
+
mask?: {
|
|
45
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
46
|
+
} | Omit<import("../types/mask").PopsMaskConfig | undefined, "zIndex"> | undefined;
|
|
47
|
+
forbiddenScroll?: {
|
|
48
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
49
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
50
|
+
lightStyle?: {
|
|
51
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
52
|
+
} | Omit<string | null | undefined, "zIndex"> | undefined;
|
|
53
|
+
darkStyle?: {
|
|
54
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
55
|
+
} | Omit<string | null | undefined, "zIndex"> | undefined;
|
|
56
|
+
stopKeyDownEventPropagation?: {
|
|
57
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
58
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
59
|
+
beforeAppendToPageCallBack?: {
|
|
60
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
61
|
+
} | Omit<(($shadowRoot: ShadowRoot | HTMLElement, $shadowContainer: HTMLDivElement) => void) | undefined, "zIndex"> | undefined;
|
|
62
|
+
drag?: {
|
|
63
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
64
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
65
|
+
dragLimit?: {
|
|
66
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
67
|
+
} | Omit<boolean | undefined, "zIndex"> | undefined;
|
|
68
|
+
dragExtraDistance?: {
|
|
69
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
70
|
+
} | Omit<number | undefined, "zIndex"> | undefined;
|
|
71
|
+
dragMoveCallBack?: {
|
|
72
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
73
|
+
} | Omit<((moveElement: HTMLElement, left: number, top: number) => void) | undefined, "zIndex"> | undefined;
|
|
74
|
+
dragEndCallBack?: {
|
|
75
|
+
zIndex: GlobalConfigOption["zIndex"];
|
|
76
|
+
} | Omit<((moveElement: HTMLElement, left: number, top: number) => void) | undefined, "zIndex"> | undefined;
|
|
37
77
|
};
|
|
38
78
|
};
|
|
39
79
|
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { EventMap, CustomEventMap } from "../types/EventEmitter";
|
|
2
|
+
import type { PopsType } from "../types/main";
|
|
3
|
+
declare class EventEmiter<T extends CustomEventMap = CustomEventMap> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(type: PopsType);
|
|
6
|
+
on<P extends keyof EventMap>(eventName: P, callback: EventMap[P]): {
|
|
7
|
+
off: () => IPromise<void>;
|
|
8
|
+
emit: (...args: Parameters<T[P]>) => IPromise<void>;
|
|
9
|
+
};
|
|
10
|
+
on<P extends keyof T>(eventName: P, callback: T[P]): {
|
|
11
|
+
off: () => IPromise<void>;
|
|
12
|
+
emit: (...args: Parameters<T[P]>) => IPromise<void>;
|
|
13
|
+
};
|
|
14
|
+
off<P extends keyof EventMap>(eventName: P, callback: EventMap[P]): IPromise<void>;
|
|
15
|
+
off<P extends keyof T>(eventName: P, callback: T[P]): IPromise<void>;
|
|
16
|
+
emit<P extends keyof T>(eventName: P, ...args: Parameters<T[P]>): IPromise<void>;
|
|
17
|
+
emit<P extends keyof EventMap>(eventName: P, ...args: Parameters<EventMap[P]>): IPromise<void>;
|
|
18
|
+
offAll<P extends keyof EventMap>(eventName?: P): IPromise<void>;
|
|
19
|
+
offAll<P extends keyof T>(eventName?: P): IPromise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* 获取所有添加的事件
|
|
22
|
+
*/
|
|
23
|
+
getAllEvents(eventName?: string): {
|
|
24
|
+
type: PopsType;
|
|
25
|
+
time: number;
|
|
26
|
+
callback: (...args: any[]) => IPromise<void>;
|
|
27
|
+
}[] | {
|
|
28
|
+
type: PopsType;
|
|
29
|
+
time: number;
|
|
30
|
+
callback: (...args: any[]) => IPromise<void>;
|
|
31
|
+
}[][] | undefined;
|
|
32
|
+
}
|
|
33
|
+
export { EventEmiter };
|
|
@@ -6,10 +6,12 @@ import type { PopsIframeConfig } from "../components/iframe/types";
|
|
|
6
6
|
import type { PopsLoadingConfig } from "../components/loading/types";
|
|
7
7
|
import type { PopsPanelConfig } from "../components/panel/types";
|
|
8
8
|
import type { PopsPromptConfig } from "../components/prompt/types/index";
|
|
9
|
+
import type { EventEmiter } from "../event/EventEmiter";
|
|
9
10
|
import type { PopsGeneralConfig } from "../types/components";
|
|
10
11
|
import type { PopsEventConfig, PopsHandlerEventConfig } from "../types/event";
|
|
12
|
+
import type { CustomEventMap } from "../types/EventEmitter";
|
|
11
13
|
import type { PopsInstGeneralConfig } from "../types/inst";
|
|
12
|
-
import type { PopsInstStoreType,
|
|
14
|
+
import type { PopsInstStoreType, PopsSupportAnimConfigType, PopsSupportOnlyConfig, PopsType } from "../types/main";
|
|
13
15
|
export declare const PopsHandler: {
|
|
14
16
|
/**
|
|
15
17
|
* 创建shadow
|
|
@@ -180,7 +182,7 @@ export declare const PopsHandler: {
|
|
|
180
182
|
* @param $mask 遮罩层
|
|
181
183
|
* @param config 当前配置
|
|
182
184
|
*/
|
|
183
|
-
handleEventConfig(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, guid: string, $shadowContainer: HTMLDivElement, $shadowRoot: ShadowRoot | HTMLElement, type: PopsInstStoreType, $anim: HTMLDivElement, $pops: HTMLDivElement, $mask?: HTMLDivElement): PopsEventConfig
|
|
185
|
+
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>;
|
|
184
186
|
/**
|
|
185
187
|
* 获取loading的事件配置
|
|
186
188
|
* @param guid
|
|
@@ -190,7 +192,7 @@ export declare const PopsHandler: {
|
|
|
190
192
|
* @param $mask 遮罩层
|
|
191
193
|
* @param config 当前配置
|
|
192
194
|
*/
|
|
193
|
-
handleLoadingEventConfig(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, guid: string, type: "loading", $anim: HTMLDivElement, $pops: HTMLDivElement, $mask?: HTMLDivElement): Omit<PopsEventConfig
|
|
195
|
+
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">;
|
|
194
196
|
/**
|
|
195
197
|
* 处理返回的配置,针对popsHandler.handleEventConfig
|
|
196
198
|
* @param config 配置
|
|
@@ -203,16 +205,14 @@ export declare const PopsHandler: {
|
|
|
203
205
|
* @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
|
|
204
206
|
* @param callback 点击回调
|
|
205
207
|
*/
|
|
206
|
-
handleClickEvent(type: PopsHandlerEventConfig["type"], $btn: HTMLElement, eventConfig: PopsEventConfig
|
|
208
|
+
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;
|
|
207
209
|
/**
|
|
208
210
|
* 全局监听键盘事件
|
|
209
211
|
* @param keyName 键名|键值
|
|
210
212
|
* @param otherKeyList 组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
|
|
211
213
|
* @param callback 回调函数
|
|
212
214
|
*/
|
|
213
|
-
handleKeyboardEvent(keyName: string | number, otherKeyList: string[] | undefined, callback: (event: KeyboardEvent) => void):
|
|
214
|
-
removeKeyboardEvent(): void;
|
|
215
|
-
};
|
|
215
|
+
handleKeyboardEvent(keyName: string | number, otherKeyList: string[] | undefined, callback: (event: KeyboardEvent) => void): import("../types/PopsDOMUtilsEventType").PopsDOMUtilsAddEventListenerResult;
|
|
216
216
|
/**
|
|
217
217
|
* 处理prompt的点击事件
|
|
218
218
|
* @param type 触发事件类型
|
|
@@ -221,21 +221,26 @@ export declare const PopsHandler: {
|
|
|
221
221
|
* @param eventConfig 事件配置,由popsHandler.handleEventConfig创建的
|
|
222
222
|
* @param callback 点击回调
|
|
223
223
|
*/
|
|
224
|
-
handlePromptClickEvent(type: PopsHandlerEventConfig["type"], inputElement: HTMLInputElement | HTMLTextAreaElement, $btn: HTMLElement, eventConfig: PopsEventConfig
|
|
224
|
+
handlePromptClickEvent<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>>(type: PopsHandlerEventConfig<E>["type"], inputElement: HTMLInputElement | HTMLTextAreaElement, $btn: HTMLElement, eventConfig: PopsEventConfig<E>, callback: (details: PopsEventConfig<E> & {
|
|
225
225
|
type: any;
|
|
226
226
|
text: string;
|
|
227
227
|
}, event: MouseEvent | PointerEvent) => void): void;
|
|
228
228
|
/**
|
|
229
|
-
*
|
|
230
|
-
* @param
|
|
229
|
+
* 获取数值
|
|
230
|
+
* @param target
|
|
231
231
|
*/
|
|
232
|
-
|
|
232
|
+
getTargerOrFunctionValue<T>(target: T | (() => T)): T;
|
|
233
233
|
/**
|
|
234
234
|
* 处理config.only
|
|
235
235
|
* @param type 当前弹窗类型
|
|
236
236
|
* @param config 配置
|
|
237
237
|
*/
|
|
238
238
|
handleOnly<T extends Required<PopsSupportOnlyConfig[keyof PopsSupportOnlyConfig]>>(type: PopsType, config: T): T;
|
|
239
|
+
/**
|
|
240
|
+
* 处理z-index
|
|
241
|
+
* @param config 配置
|
|
242
|
+
*/
|
|
243
|
+
handleZIndex<T extends Required<PopsSupportOnlyConfig[keyof PopsSupportOnlyConfig]>>(config: T): T;
|
|
239
244
|
/**
|
|
240
245
|
* 处理把已创建的元素保存到内部环境中
|
|
241
246
|
* @param type 当前弹窗类型
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { PopsAlertConfig } from "../components/alert/types";
|
|
2
|
+
import type { PopsConfirmConfig } from "../components/confirm/types";
|
|
3
|
+
import type { PopsDrawerConfig } from "../components/drawer/types";
|
|
4
|
+
import type { PopsFolderConfig } from "../components/folder/types";
|
|
5
|
+
import type { PopsIframeConfig } from "../components/iframe/types";
|
|
6
|
+
import type { PopsLoadingConfig } from "../components/loading/types";
|
|
7
|
+
import type { PopsPanelConfig } from "../components/panel/types";
|
|
8
|
+
import type { PopsPromptConfig } from "../components/prompt/types";
|
|
9
|
+
import type { PopsInstGeneralConfig } from "../types/inst";
|
|
10
|
+
import type { PopsInstStoreType } from "../types/main";
|
|
11
|
+
export declare const PopsInstHandler: {
|
|
12
|
+
/**
|
|
13
|
+
* 删除配置中对应的对象
|
|
14
|
+
* @param totalInstConfigList 配置实例列表
|
|
15
|
+
* @param guid 唯一标识
|
|
16
|
+
* @param isAll 是否全部删除
|
|
17
|
+
*/
|
|
18
|
+
removeInstance(totalInstConfigList: PopsInstGeneralConfig[][], guid?: string, isAll?: boolean): Promise<PopsInstGeneralConfig[][]>;
|
|
19
|
+
/**
|
|
20
|
+
* 隐藏
|
|
21
|
+
* @param popsType
|
|
22
|
+
* @param instConfigList
|
|
23
|
+
* @param guid
|
|
24
|
+
* @param config
|
|
25
|
+
* @param $anim
|
|
26
|
+
* @param $mask
|
|
27
|
+
*/
|
|
28
|
+
hide(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: PopsInstStoreType, instConfigList: PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* 显示
|
|
31
|
+
* @param popsType
|
|
32
|
+
* @param instConfigList
|
|
33
|
+
* @param guid
|
|
34
|
+
* @param config
|
|
35
|
+
* @param $anim
|
|
36
|
+
* @param $mask
|
|
37
|
+
*/
|
|
38
|
+
show(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: PopsInstStoreType, instConfigList: PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* 关闭
|
|
41
|
+
* @param popsType
|
|
42
|
+
* @param instConfigList
|
|
43
|
+
* @param guid
|
|
44
|
+
* @param config
|
|
45
|
+
* @param $anim
|
|
46
|
+
*/
|
|
47
|
+
close(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: string, instConfigList: PopsInstGeneralConfig[], guid: string, $anim: HTMLElement): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* 拖拽元素
|
|
50
|
+
* 说明:
|
|
51
|
+
* + 元素的position为absolute或者fixed
|
|
52
|
+
* + 会为元素的
|
|
53
|
+
* @param $move 需要拖拽的元素
|
|
54
|
+
* @param options 配置
|
|
55
|
+
*/
|
|
56
|
+
drag($move: HTMLElement, options: {
|
|
57
|
+
dragElement: HTMLElement;
|
|
58
|
+
limit: boolean;
|
|
59
|
+
emitClick?: boolean;
|
|
60
|
+
extraDistance: number;
|
|
61
|
+
container?: Window | typeof globalThis | HTMLElement;
|
|
62
|
+
startCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
63
|
+
moveCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
64
|
+
endCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
65
|
+
preventEvent?: (event: TouchEvent | PointerEvent) => boolean;
|
|
66
|
+
}): void;
|
|
67
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PopsInstGeneralConfig } from "./inst";
|
|
2
|
+
|
|
3
|
+
export type EventMap = {
|
|
4
|
+
"pops:before-show": (config: PopsInstGeneralConfig) => IPromise<void>;
|
|
5
|
+
"pops:show": (config: PopsInstGeneralConfig) => IPromise<void>;
|
|
6
|
+
"pops:before-hide": (config: PopsInstGeneralConfig) => IPromise<void>;
|
|
7
|
+
"pops:hide": (config: PopsInstGeneralConfig) => IPromise<void>;
|
|
8
|
+
"pops:before-destory": (config: PopsInstGeneralConfig) => IPromise<void>;
|
|
9
|
+
"pops:destory": () => IPromise<void>;
|
|
10
|
+
"pops:before-append-to-page": (
|
|
11
|
+
$shadowRoot: ShadowRoot | HTMLElement,
|
|
12
|
+
$shadowContainer: HTMLDivElement
|
|
13
|
+
) => IPromise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type CustomEventMap = {
|
|
17
|
+
[K in string]: (...args: any[]) => IPromise<void>;
|
|
18
|
+
};
|
|
@@ -34,6 +34,10 @@ export type PopsDOMUtils_MouseEventType = keyof PopsDOMUtils_MouseEvent;
|
|
|
34
34
|
*/
|
|
35
35
|
export interface PopsDOMUtils_KeyboardEvent {
|
|
36
36
|
keydown: KeyboardEvent;
|
|
37
|
+
/**
|
|
38
|
+
* @link https://developer.mozilla.org/zh-CN/docs/Web/API/Element/keypress_event
|
|
39
|
+
* @deprecated
|
|
40
|
+
*/
|
|
37
41
|
keypress: KeyboardEvent;
|
|
38
42
|
keyup: KeyboardEvent;
|
|
39
43
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EventEmiter } from "../event/EventEmiter";
|
|
1
2
|
import type { PopsEventConfig, PopsHandlerEventConfig } from "./event";
|
|
2
3
|
import type { PopsIconType } from "./icon";
|
|
3
4
|
|
|
@@ -63,7 +64,7 @@ export interface PopsGlobalButtonConfig<T = object> {
|
|
|
63
64
|
*
|
|
64
65
|
* 如果传入该值,那么将不会自动关闭弹窗
|
|
65
66
|
*/
|
|
66
|
-
callback(eventConfig: PopsHandlerEventConfig & T, event: PointerEvent | MouseEvent): void;
|
|
67
|
+
callback(eventConfig: PopsHandlerEventConfig<EventEmiter> & T, event: PointerEvent | MouseEvent): void;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { EventEmiter } from "../event/EventEmiter";
|
|
2
|
+
import type { CustomEventMap } from "./EventEmitter";
|
|
1
3
|
import type { PopsType } from "./main";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* 事件配置
|
|
5
7
|
*/
|
|
6
|
-
export interface PopsEventConfig {
|
|
8
|
+
export interface PopsEventConfig<E extends EventEmiter<CustomEventMap> = EventEmiter<CustomEventMap>> {
|
|
7
9
|
/** 最外层包裹的元素 */
|
|
8
10
|
$shadowContainer: HTMLDivElement;
|
|
9
11
|
/** ShadowRoot */
|
|
@@ -20,6 +22,8 @@ export interface PopsEventConfig {
|
|
|
20
22
|
mode: PopsType;
|
|
21
23
|
/** 唯一id */
|
|
22
24
|
guid: string;
|
|
25
|
+
/** 事件发送器 */
|
|
26
|
+
emitter: E;
|
|
23
27
|
/**
|
|
24
28
|
* 关闭弹窗
|
|
25
29
|
*/
|
|
@@ -37,7 +41,7 @@ export interface PopsEventConfig {
|
|
|
37
41
|
/**
|
|
38
42
|
* 处理过的事件配置
|
|
39
43
|
*/
|
|
40
|
-
export interface PopsHandlerEventConfig extends PopsEventConfig {
|
|
44
|
+
export interface PopsHandlerEventConfig<E extends EventEmiter<CustomEventMap>> extends PopsEventConfig<E> {
|
|
41
45
|
/** 当前按钮类型 */
|
|
42
46
|
type: "cancel" | "close" | "ok" | "other";
|
|
43
47
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EventEmiter } from "../event/EventEmiter";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* config实例配置
|
|
3
5
|
*/
|
|
@@ -19,10 +21,8 @@ export interface PopsInstGeneralConfig extends PopsInstConfig {
|
|
|
19
21
|
$shadowContainer: HTMLDivElement;
|
|
20
22
|
/** shadow容器的shandowRoot */
|
|
21
23
|
$shadowRoot: ShadowRoot | HTMLElement;
|
|
22
|
-
/** 移除实例前的回调函数 */
|
|
23
|
-
beforeRemoveCallBack?: (instCommonConfig: PopsInstGeneralConfig) => void;
|
|
24
24
|
/** 配置 */
|
|
25
25
|
config: any;
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** 事件发送器 */
|
|
27
|
+
emitter: EventEmiter;
|
|
28
28
|
}
|
|
@@ -289,22 +289,6 @@ declare class PopsDOMUtilsEvent {
|
|
|
289
289
|
* })
|
|
290
290
|
*/
|
|
291
291
|
onKeydown(target: HTMLElement | Window | typeof globalThis | string, handler: (event: PopsDOMUtils_Event["keydown"]) => void, option?: boolean | AddEventListenerOptions): PopsDOMUtilsAddEventListenerResult | undefined;
|
|
292
|
-
/**
|
|
293
|
-
* 当按键按下时触发事件
|
|
294
|
-
* keydown - > keypress - > keyup
|
|
295
|
-
* @param target 目标
|
|
296
|
-
* @param handler 事件处理函数
|
|
297
|
-
* @param option 配置
|
|
298
|
-
* @example
|
|
299
|
-
* // 监听a.xx元素的按键按下
|
|
300
|
-
* DOMUtils.keypress(document.querySelector("a.xx"),()=>{
|
|
301
|
-
* console.log("按键按下");
|
|
302
|
-
* })
|
|
303
|
-
* DOMUtils.keypress("a.xx",()=>{
|
|
304
|
-
* console.log("按键按下");
|
|
305
|
-
* })
|
|
306
|
-
*/
|
|
307
|
-
onKeypress(target: HTMLElement | Window | typeof globalThis | string, handler: (event: PopsDOMUtils_Event["keypress"]) => void, option?: boolean | AddEventListenerOptions): PopsDOMUtilsAddEventListenerResult | undefined;
|
|
308
292
|
/**
|
|
309
293
|
* 阻止事件传递
|
|
310
294
|
*
|
|
@@ -1,101 +1,13 @@
|
|
|
1
|
-
import type { PopsAlertConfig } from "../components/alert/types";
|
|
2
|
-
import type { PopsConfirmConfig } from "../components/confirm/types";
|
|
3
|
-
import type { PopsDrawerConfig } from "../components/drawer/types";
|
|
4
|
-
import type { PopsFolderConfig } from "../components/folder/types";
|
|
5
|
-
import type { PopsIframeConfig } from "../components/iframe/types";
|
|
6
|
-
import type { PopsLoadingConfig } from "../components/loading/types";
|
|
7
|
-
import type { PopsPanelConfig } from "../components/panel/types";
|
|
8
|
-
import type { PopsPromptConfig } from "../components/prompt/types/index";
|
|
9
|
-
import type { PopsInstGeneralConfig } from "../types/inst";
|
|
10
|
-
import type { PopsInstStoreType } from "../types/main";
|
|
11
1
|
export declare const PopsInstanceUtils: {
|
|
12
|
-
/**
|
|
13
|
-
* 获取页面中最大的z-index的元素信息
|
|
14
|
-
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
15
|
-
* @param node 进行判断的元素,默认是document
|
|
16
|
-
* @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
|
|
17
|
-
* @example
|
|
18
|
-
* Utils.getMaxZIndexNodeInfo();
|
|
19
|
-
* > {
|
|
20
|
-
* node: ...,
|
|
21
|
-
* zIndex: 1001
|
|
22
|
-
* }
|
|
23
|
-
**/
|
|
24
|
-
getMaxZIndexNodeInfo(deviation?: number, target?: Element | ShadowRoot | Document, ignoreCallBack?: ($ele: Element | HTMLElement | ShadowRoot) => boolean | void): {
|
|
25
|
-
node: Element;
|
|
26
|
-
zIndex: number;
|
|
27
|
-
};
|
|
28
2
|
/**
|
|
29
3
|
* 获取pops所有弹窗中的最大的z-index
|
|
30
4
|
* @param deviation
|
|
31
5
|
*/
|
|
32
6
|
getPopsMaxZIndex(deviation?: number): {
|
|
33
7
|
zIndex: number;
|
|
34
|
-
animElement:
|
|
8
|
+
animElement: HTMLElement | null;
|
|
35
9
|
isOverMaxZIndex: boolean;
|
|
36
10
|
};
|
|
37
|
-
/**
|
|
38
|
-
* 获取页面中最大的z-index
|
|
39
|
-
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
40
|
-
* @example
|
|
41
|
-
* getMaxZIndex();
|
|
42
|
-
* > 1001
|
|
43
|
-
**/
|
|
44
|
-
getMaxZIndex(deviation?: number): number;
|
|
45
|
-
/**
|
|
46
|
-
* 删除配置中对应的对象
|
|
47
|
-
* @param totalInstConfigList 配置实例列表
|
|
48
|
-
* @param guid 唯一标识
|
|
49
|
-
* @param isAll 是否全部删除
|
|
50
|
-
*/
|
|
51
|
-
removeInstance(totalInstConfigList: PopsInstGeneralConfig[][], guid?: string, isAll?: boolean): Promise<PopsInstGeneralConfig[][]>;
|
|
52
|
-
/**
|
|
53
|
-
* 隐藏
|
|
54
|
-
* @param popsType
|
|
55
|
-
* @param instConfigList
|
|
56
|
-
* @param guid
|
|
57
|
-
* @param config
|
|
58
|
-
* @param $anim
|
|
59
|
-
* @param $mask
|
|
60
|
-
*/
|
|
61
|
-
hide(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: PopsInstStoreType, instConfigList: PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* 显示
|
|
64
|
-
* @param popsType
|
|
65
|
-
* @param instConfigList
|
|
66
|
-
* @param guid
|
|
67
|
-
* @param config
|
|
68
|
-
* @param $anim
|
|
69
|
-
* @param $mask
|
|
70
|
-
*/
|
|
71
|
-
show(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: PopsInstStoreType, instConfigList: PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* 关闭
|
|
74
|
-
* @param popsType
|
|
75
|
-
* @param instConfigList
|
|
76
|
-
* @param guid
|
|
77
|
-
* @param config
|
|
78
|
-
* @param $anim
|
|
79
|
-
*/
|
|
80
|
-
close(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: string, instConfigList: PopsInstGeneralConfig[], guid: string, $anim: HTMLElement): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* 拖拽元素
|
|
83
|
-
* 说明:
|
|
84
|
-
* + 元素的position为absolute或者fixed
|
|
85
|
-
* + 会为元素的
|
|
86
|
-
* @param $move 需要拖拽的元素
|
|
87
|
-
* @param options 配置
|
|
88
|
-
*/
|
|
89
|
-
drag($move: HTMLElement, options: {
|
|
90
|
-
dragElement: HTMLElement;
|
|
91
|
-
limit: boolean;
|
|
92
|
-
emitClick?: boolean;
|
|
93
|
-
extraDistance: number;
|
|
94
|
-
container?: Window | typeof globalThis | HTMLElement;
|
|
95
|
-
moveCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
96
|
-
endCallBack?: (moveElement: HTMLElement, left: number, top: number) => void;
|
|
97
|
-
preventEvent?: (event: TouchEvent | PointerEvent) => boolean;
|
|
98
|
-
}): void;
|
|
99
11
|
/**
|
|
100
12
|
* 排序数组
|
|
101
13
|
* @param getBeforeValueFun
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import AnyTouch from "any-touch";
|
|
2
2
|
import doubletap from "@any-touch/doubletap";
|
|
3
3
|
declare class PopsUtils {
|
|
4
|
+
/**
|
|
5
|
+
* 超时时间
|
|
6
|
+
*/
|
|
7
|
+
sleep(timeout: number): Promise<unknown>;
|
|
4
8
|
/**
|
|
5
9
|
* 判断是否是window,例如window、self、globalThis
|
|
6
10
|
* @param target
|
|
@@ -151,6 +155,59 @@ declare class PopsUtils {
|
|
|
151
155
|
* 覆盖对象中的数组新值
|
|
152
156
|
*/
|
|
153
157
|
setArray<T>(target: T, key: keyof T, newArr: any[]): void;
|
|
158
|
+
/**
|
|
159
|
+
* 获取页面的坐标中最大的z-index的元素信息
|
|
160
|
+
*
|
|
161
|
+
* 其中坐标为
|
|
162
|
+
*
|
|
163
|
+
* + 左上角(宽: 1/8,高: 1/8)
|
|
164
|
+
* + 右上角(宽: 7/8,高: 1/8)
|
|
165
|
+
* + 左下角(宽: 1/8,高: 7/8)
|
|
166
|
+
* + 右下角(宽: 7/8,高: 7/8)
|
|
167
|
+
* + 中间(宽: 1/2,高: 1/2)
|
|
168
|
+
* @param $el 仅检测目标元素最大的z-index(自动往上层找)
|
|
169
|
+
* @param deviation 将对所有获取到的z-index处理偏移量(增加或减少),默认为10
|
|
170
|
+
*/
|
|
171
|
+
getMaxZIndexNodeInfoFromPoint($el?: IFunction<HTMLElement | HTMLElement[]>, deviation?: number): {
|
|
172
|
+
/** 处理了偏移量后的z-index值 */
|
|
173
|
+
zIndex: number;
|
|
174
|
+
/** 原始z-index值 */
|
|
175
|
+
originZIndex: number;
|
|
176
|
+
/** 拥有最大z-index的元素 */
|
|
177
|
+
node: HTMLElement | null;
|
|
178
|
+
/** 目标坐标元素 */
|
|
179
|
+
positionNode: HTMLElement;
|
|
180
|
+
/** x坐标 */
|
|
181
|
+
positionX: number;
|
|
182
|
+
/** y坐标 */
|
|
183
|
+
positionY: number;
|
|
184
|
+
}[];
|
|
185
|
+
/**
|
|
186
|
+
* 获取页面的坐标中最大的z-index的元素信息
|
|
187
|
+
*
|
|
188
|
+
* 其中坐标为
|
|
189
|
+
*
|
|
190
|
+
* + 左上角(宽: 1/8,高: 1/8)
|
|
191
|
+
* + 右上角(宽: 7/8,高: 1/8)
|
|
192
|
+
* + 左下角(宽: 1/8,高: 7/8)
|
|
193
|
+
* + 右下角(宽: 7/8,高: 7/8)
|
|
194
|
+
* + 中间(宽: 1/2,高: 1/2)
|
|
195
|
+
* @param deviation 将对所有获取到的z-index处理偏移量(增加或减少)
|
|
196
|
+
*/
|
|
197
|
+
getMaxZIndexNodeInfoFromPoint(deviation: IFunction<number>): {
|
|
198
|
+
/** 处理了偏移量后的z-index值 */
|
|
199
|
+
zIndex: number;
|
|
200
|
+
/** 原始z-index值 */
|
|
201
|
+
originZIndex: number;
|
|
202
|
+
/** 拥有最大z-index的元素 */
|
|
203
|
+
node: HTMLElement | null;
|
|
204
|
+
/** 目标坐标元素 */
|
|
205
|
+
positionNode: HTMLElement;
|
|
206
|
+
/** x坐标 */
|
|
207
|
+
positionX: number;
|
|
208
|
+
/** y坐标 */
|
|
209
|
+
positionY: number;
|
|
210
|
+
}[];
|
|
154
211
|
}
|
|
155
212
|
declare const popsUtils: PopsUtils;
|
|
156
213
|
export { popsUtils };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whitesev/pops",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "弹窗库,包含了alert、confirm、prompt、drawer、folder、loading、iframe、panel、tooltip、searchSuggestion、rightClickMenu组件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ScriptCat",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"eslint-plugin-compat": "^6.0.2",
|
|
58
58
|
"eslint-plugin-prettier": "^5.5.4",
|
|
59
59
|
"globals": "^16.5.0",
|
|
60
|
-
"oxfmt": "^0.
|
|
61
|
-
"oxlint": "1.
|
|
60
|
+
"oxfmt": "^0.36.0",
|
|
61
|
+
"oxlint": "1.51.0",
|
|
62
62
|
"rollup": "^4.54.0",
|
|
63
63
|
"rollup-plugin-clear": "^2.0.7",
|
|
64
64
|
"rollup-plugin-import-css": "^4.1.2",
|
package/src/Pops.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { version } from "../package.json";
|
|
1
2
|
import { PopsAlert } from "./components/alert";
|
|
2
3
|
import type { PopsAlertConfig } from "./components/alert/types";
|
|
3
4
|
import { PopsConfirm } from "./components/confirm";
|
|
@@ -22,6 +23,7 @@ import type { PopsSearchSuggestionConfig } from "./components/searchSuggestion/t
|
|
|
22
23
|
import { PopsTooltip } from "./components/tooltip";
|
|
23
24
|
import type { PopsToolTipConfig } from "./components/tooltip/types/index";
|
|
24
25
|
import { GlobalConfig } from "./config/GlobalConfig";
|
|
26
|
+
import { EventEmiter } from "./event/EventEmiter";
|
|
25
27
|
import { PopsAnimation } from "./PopsAnimation";
|
|
26
28
|
import { PopsCore } from "./PopsCore";
|
|
27
29
|
import { PopsCSS } from "./PopsCSS";
|
|
@@ -31,7 +33,6 @@ import { popsDOMUtils } from "./utils/PopsDOMUtils";
|
|
|
31
33
|
import { PopsInstanceUtils } from "./utils/PopsInstanceUtils";
|
|
32
34
|
import { PopsMathFloatUtils } from "./utils/PopsMathUtils";
|
|
33
35
|
import { popsUtils } from "./utils/PopsUtils";
|
|
34
|
-
import { version } from "../package.json";
|
|
35
36
|
|
|
36
37
|
class Pops {
|
|
37
38
|
/** 配置 */
|
|
@@ -60,7 +61,11 @@ class Pops {
|
|
|
60
61
|
/** pops处理float类型使用的工具类 */
|
|
61
62
|
MathFloatUtils: PopsMathFloatUtils,
|
|
62
63
|
/** pops.panel中用于处理各个类型的工具 */
|
|
63
|
-
PanelHandlerComponents
|
|
64
|
+
PanelHandlerComponents,
|
|
65
|
+
/** pops.panel中的动画 */
|
|
66
|
+
PopsAnimation,
|
|
67
|
+
/** 事件类 */
|
|
68
|
+
EventEmiter,
|
|
64
69
|
};
|
|
65
70
|
init() {}
|
|
66
71
|
/**
|