@whitesev/pops 4.1.0 → 4.2.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 +250 -227
- 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 +250 -227
- 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 +250 -227
- 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 +250 -227
- 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 +250 -227
- 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 +250 -227
- 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 +17 -16
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +3 -3
- package/dist/types/src/types/mask.d.ts +6 -6
- package/dist/types/src/utils/PopsDOMUtils.d.ts +6 -18
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +22 -0
- package/dist/types/src/utils/PopsUtils.d.ts +1 -1
- package/package.json +1 -1
- package/src/Pops.ts +9 -12
- package/src/components/panel/handlerComponents.ts +4 -4
- package/src/handler/PopsHandler.ts +9 -21
- package/src/handler/PopsInstHandler.ts +3 -2
- package/src/types/PopsDOMUtilsEventType.d.ts +3 -3
- package/src/types/mask.d.ts +6 -6
- package/src/utils/PopsDOMUtils.ts +105 -113
- package/src/utils/PopsInstanceUtils.ts +50 -0
- package/src/utils/PopsUtils.ts +2 -2
- package/dist/types/src/utils/PopsDOMUtilsEventsConfig.d.ts +0 -4
- package/src/utils/PopsDOMUtilsEventsConfig.ts +0 -4
package/dist/types/src/Pops.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare class Pops {
|
|
|
17
17
|
config: {
|
|
18
18
|
/** 版本号 */
|
|
19
19
|
version: string;
|
|
20
|
+
/** 样式配置 */
|
|
20
21
|
cssText: {
|
|
21
22
|
index: string;
|
|
22
23
|
ninePalaceGridPosition: string;
|
|
@@ -84,10 +85,9 @@ declare class Pops {
|
|
|
84
85
|
panel: import("./types/inst").PopsInstGeneralConfig[];
|
|
85
86
|
rightClickMenu: import("./types/inst").PopsInstGeneralConfig[];
|
|
86
87
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
88
|
+
};
|
|
89
|
+
/** 导出的函数 */
|
|
90
|
+
fn: {
|
|
91
91
|
/** pops使用的工具类 */
|
|
92
92
|
Utils: {
|
|
93
93
|
sleep(timeout: number): Promise<unknown>;
|
|
@@ -134,7 +134,6 @@ declare class Pops {
|
|
|
134
134
|
DOMUtils: {
|
|
135
135
|
getAnimationEndNameList(): string[];
|
|
136
136
|
getTransitionEndNameList(): string[];
|
|
137
|
-
isHide($el: Element): boolean;
|
|
138
137
|
offset(element: HTMLElement, calcScroll?: boolean): DOMRect;
|
|
139
138
|
width(element: HTMLElement | string | Window | Document | typeof globalThis, isShow?: boolean, parent?: HTMLElement | ShadowRoot): number;
|
|
140
139
|
height(element: HTMLElement | string | Window | Document | typeof globalThis, isShow?: boolean, parent?: HTMLElement | ShadowRoot): number;
|
|
@@ -186,10 +185,10 @@ declare class Pops {
|
|
|
186
185
|
on<T extends Event>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: string | string[], callback: (this: HTMLElement, event: T) => void, option?: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOption | boolean): import("./types/PopsDOMUtilsEventType").PopsDOMUtilsAddEventListenerResult;
|
|
187
186
|
on<T extends import("./types/PopsDOMUtilsEventType").PopsDOMUtils_EventType>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: T | T[], selector: string | string[] | undefined | null, callback: (this: HTMLElement, event: import("./types/PopsDOMUtilsEventType").PopsDOMUtils_Event[T], selectorTarget: HTMLElement) => void, option?: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOption | boolean): import("./types/PopsDOMUtilsEventType").PopsDOMUtilsAddEventListenerResult;
|
|
188
187
|
on<T extends Event>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: string | string[], selector: string | string[] | undefined | null, callback: (this: HTMLElement, event: T, selectorTarget: HTMLElement) => void, option?: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOption | boolean): import("./types/PopsDOMUtilsEventType").PopsDOMUtilsAddEventListenerResult;
|
|
189
|
-
off<T extends import("./types/PopsDOMUtilsEventType").PopsDOMUtils_EventType>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: T | T[], callback?: ((this:
|
|
190
|
-
off<T extends Event>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: string | string[], callback?: ((this:
|
|
191
|
-
off<T extends import("./types/PopsDOMUtilsEventType").PopsDOMUtils_EventType>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: T | T[], selector?: string | string[] | undefined | null, callback?: ((this:
|
|
192
|
-
off<T extends Event>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: string | string[], selector?: string | string[] | undefined | null, callback?: ((this:
|
|
188
|
+
off<T extends import("./types/PopsDOMUtilsEventType").PopsDOMUtils_EventType>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: T | T[], callback?: (<E extends HTMLElement = HTMLElement>(this: E, event: import("./types/PopsDOMUtilsEventType").PopsDOMUtils_Event[T]) => void) | undefined, option?: EventListenerOptions | boolean, filter?: (value: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
189
|
+
off<T extends Event>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: string | string[], callback?: (<E extends HTMLElement = HTMLElement>(this: E, event: T) => void) | undefined, option?: EventListenerOptions | boolean, filter?: (value: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
190
|
+
off<T extends import("./types/PopsDOMUtilsEventType").PopsDOMUtils_EventType>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: T | T[], selector?: string | string[] | undefined | null, callback?: (<E extends HTMLElement = HTMLElement>(this: E, event: import("./types/PopsDOMUtilsEventType").PopsDOMUtils_Event[T], $selector: E) => void) | undefined, option?: EventListenerOptions | boolean, filter?: (value: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
191
|
+
off<T extends Event>(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType: string | string[], selector?: string | string[] | undefined | null, callback?: (<E extends HTMLElement = HTMLElement>(this: E, event: T, $selector: E) => void) | undefined, option?: EventListenerOptions | boolean, filter?: (value: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
193
192
|
offAll(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType?: string): void;
|
|
194
193
|
offAll(element: import("./types/PopsDOMUtilsEventType").PopsDOMUtilsElementEventType, eventType?: import("./types/PopsDOMUtilsEventType").PopsDOMUtils_EventType | import("./types/PopsDOMUtilsEventType").PopsDOMUtils_EventType[]): void;
|
|
195
194
|
onReady<T extends (...args: any[]) => any>(callback: T): void;
|
|
@@ -203,13 +202,13 @@ declare class Pops {
|
|
|
203
202
|
onKeydown(target: HTMLElement | Window | typeof globalThis | string, handler: (event: import("./types/PopsDOMUtilsEventType").PopsDOMUtils_Event["keydown"]) => void, option?: boolean | AddEventListenerOptions): import("./types/PopsDOMUtilsEventType").PopsDOMUtilsAddEventListenerResult | undefined;
|
|
204
203
|
preventEvent(event: Event): false;
|
|
205
204
|
preventEvent<T extends boolean>(event: Event, onlyStopPropagation: T): T extends true ? void : false;
|
|
206
|
-
preventEvent($el:
|
|
205
|
+
preventEvent($el: Element | Document | ShadowRoot, eventNameList: string | string[], option?: {
|
|
207
206
|
capture?: boolean;
|
|
208
207
|
onlyStopPropagation?: boolean;
|
|
209
208
|
}): {
|
|
210
209
|
off(): void;
|
|
211
210
|
};
|
|
212
|
-
preventEvent($el:
|
|
211
|
+
preventEvent($el: Element | Document | ShadowRoot, eventNameList: string | string[], selector: string | string[] | null | undefined, option?: {
|
|
213
212
|
capture?: boolean;
|
|
214
213
|
onlyStopPropagation?: boolean;
|
|
215
214
|
}): {
|
|
@@ -230,7 +229,10 @@ declare class Pops {
|
|
|
230
229
|
animElement: HTMLElement | null;
|
|
231
230
|
isOverMaxZIndex: boolean;
|
|
232
231
|
};
|
|
233
|
-
sortElementListByProperty<T, R>(getBeforeValueFun: (value: T) => R, getAfterValueFun: (value: T) => R, sortByDesc?: boolean): (after_obj: T, before_obj: T
|
|
232
|
+
sortElementListByProperty<T, R>(getBeforeValueFun: (value: T) => R, getAfterValueFun: (value: T) => R, sortByDesc?: boolean): (after_obj: T, before_obj: T) => 1 | 0 | -1;
|
|
233
|
+
isHide($el: Element): boolean;
|
|
234
|
+
isNodeInPopsNode($el: Element): boolean;
|
|
235
|
+
isAnimNode($el: Element): boolean;
|
|
234
236
|
};
|
|
235
237
|
/** pops处理float类型使用的工具类 */
|
|
236
238
|
MathFloatUtils: {
|
|
@@ -240,7 +242,7 @@ declare class Pops {
|
|
|
240
242
|
division(number1: number, number2: number): number;
|
|
241
243
|
};
|
|
242
244
|
/** 实例处理函数 */
|
|
243
|
-
|
|
245
|
+
InstHandler: {
|
|
244
246
|
removeInstance(totalInstConfigList: import("./types/inst").PopsInstGeneralConfig[][], guid?: string, isAll?: boolean): Promise<import("./types/inst").PopsInstGeneralConfig[][]>;
|
|
245
247
|
show(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: import("./types/main").PopsInstStoreType, instConfigList: import("./types/inst").PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
246
248
|
hide(config: PopsAlertConfig | PopsDrawerConfig | PopsPromptConfig | PopsConfirmConfig | PopsIframeConfig | PopsLoadingConfig | PopsPanelConfig | PopsFolderConfig, popsType: import("./types/main").PopsInstStoreType, instConfigList: import("./types/inst").PopsInstGeneralConfig[], guid: string, $anim: HTMLElement, $mask?: HTMLElement): Promise<void>;
|
|
@@ -710,7 +712,7 @@ declare class Pops {
|
|
|
710
712
|
onAsideItemClick($asideItem: HTMLElement, asideConfig: import("./components/panel/types").PopsPanelContentConfig): void;
|
|
711
713
|
};
|
|
712
714
|
/** pops.panel中的动画 */
|
|
713
|
-
|
|
715
|
+
Animation: {
|
|
714
716
|
$data: {
|
|
715
717
|
[key: string]: CSSKeyframesRule;
|
|
716
718
|
};
|
|
@@ -732,7 +734,7 @@ declare class Pops {
|
|
|
732
734
|
/** 事件类 */
|
|
733
735
|
EventEmiter: typeof EventEmiter;
|
|
734
736
|
/** 通用的CSS类名 */
|
|
735
|
-
|
|
737
|
+
CommonCSSClassName: {
|
|
736
738
|
flexCenter: string;
|
|
737
739
|
flexYCenter: string;
|
|
738
740
|
flexXCenter: string;
|
|
@@ -747,7 +749,6 @@ declare class Pops {
|
|
|
747
749
|
textIsDisabledImportant: string;
|
|
748
750
|
};
|
|
749
751
|
};
|
|
750
|
-
init(): void;
|
|
751
752
|
/**
|
|
752
753
|
* 释放原有的pops控制权
|
|
753
754
|
* @example
|
|
@@ -209,9 +209,9 @@ export type PopsDOMUtils_EventType = keyof PopsDOMUtils_Event;
|
|
|
209
209
|
*/
|
|
210
210
|
export declare interface PopsDOMUtilsEventListenerOptionsAttribute {
|
|
211
211
|
/**
|
|
212
|
-
* DOMUtils的
|
|
212
|
+
* DOMUtils的handlerCallBack,元素上的监听事件就是它,移除事件时也需要传入这个函数
|
|
213
213
|
*/
|
|
214
|
-
|
|
214
|
+
handlerCallBack: (event: Event, $selector?: HTMLElement) => void;
|
|
215
215
|
/**
|
|
216
216
|
* 属性配置
|
|
217
217
|
*/
|
|
@@ -219,7 +219,7 @@ export declare interface PopsDOMUtilsEventListenerOptionsAttribute {
|
|
|
219
219
|
/**
|
|
220
220
|
* 用户添加的事件
|
|
221
221
|
*/
|
|
222
|
-
|
|
222
|
+
callback: (event: Event, $selector?: HTMLElement) => void;
|
|
223
223
|
/**
|
|
224
224
|
* 子元素选择器
|
|
225
225
|
*/
|
|
@@ -16,28 +16,28 @@ export interface PopsMaskConfig {
|
|
|
16
16
|
*/
|
|
17
17
|
enable?: boolean;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* 点击事件配置
|
|
20
20
|
*/
|
|
21
21
|
clickEvent?: {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* (可选)点击遮罩层是否触发关闭事件,默认false
|
|
24
24
|
* @default false
|
|
25
25
|
*/
|
|
26
26
|
toClose?: boolean;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* (可选)点击遮罩层是否触发隐藏事件,默认false
|
|
29
29
|
* @default false
|
|
30
30
|
*/
|
|
31
31
|
toHide?: boolean;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* 遮罩层自定义的点击事件
|
|
35
|
-
* @param originalRun 当toClose为true,它是关闭弹窗,当toHide为true,它是隐藏弹窗
|
|
36
|
-
* @param config 配置信息
|
|
37
35
|
*/
|
|
38
36
|
clickCallBack?:
|
|
39
37
|
| ((
|
|
40
|
-
|
|
38
|
+
/** 当toClose为true,它是关闭弹窗,当toHide为true,它是隐藏弹窗 */
|
|
39
|
+
continueExec: () => void | Promise<void>,
|
|
40
|
+
/** 配置信息 */
|
|
41
41
|
config:
|
|
42
42
|
| PopsAlertConfig
|
|
43
43
|
| PopsDrawerConfig
|
|
@@ -101,7 +101,7 @@ declare class PopsDOMUtilsEvent {
|
|
|
101
101
|
* DOMUtils.off(document.querySelector("a.xx"),"click")
|
|
102
102
|
* DOMUtils.off("a.xx","click")
|
|
103
103
|
*/
|
|
104
|
-
off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback?: (this:
|
|
104
|
+
off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback?: <E extends HTMLElement = HTMLElement>(this: E, event: PopsDOMUtils_Event[T]) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
105
105
|
/**
|
|
106
106
|
* 取消绑定事件
|
|
107
107
|
* @param element 需要取消绑定的元素|元素数组
|
|
@@ -115,7 +115,7 @@ declare class PopsDOMUtilsEvent {
|
|
|
115
115
|
* DOMUtils.off(document.querySelector("a.xx"),"click")
|
|
116
116
|
* DOMUtils.off("a.xx","click")
|
|
117
117
|
*/
|
|
118
|
-
off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback?: (this:
|
|
118
|
+
off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback?: <E extends HTMLElement = HTMLElement>(this: E, event: T) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
119
119
|
/**
|
|
120
120
|
* 取消绑定事件
|
|
121
121
|
* @param element 需要取消绑定的元素|元素数组
|
|
@@ -130,7 +130,7 @@ declare class PopsDOMUtilsEvent {
|
|
|
130
130
|
* DOMUtils.off(document.querySelector("a.xx"),"click tap hover")
|
|
131
131
|
* DOMUtils.off("a.xx",["click","tap","hover"])
|
|
132
132
|
*/
|
|
133
|
-
off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector?: string | string[] | undefined | null, callback?: (this:
|
|
133
|
+
off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector?: string | string[] | undefined | null, callback?: <E extends HTMLElement = HTMLElement>(this: E, event: PopsDOMUtils_Event[T], $selector: E) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
134
134
|
/**
|
|
135
135
|
* 取消绑定事件
|
|
136
136
|
* @param element 需要取消绑定的元素|元素数组
|
|
@@ -145,7 +145,7 @@ declare class PopsDOMUtilsEvent {
|
|
|
145
145
|
* DOMUtils.off(document.querySelector("a.xx"),"click tap hover")
|
|
146
146
|
* DOMUtils.off("a.xx",["click","tap","hover"])
|
|
147
147
|
*/
|
|
148
|
-
off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], selector?: string | string[] | undefined | null, callback?: (this:
|
|
148
|
+
off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], selector?: string | string[] | undefined | null, callback?: <E extends HTMLElement = HTMLElement>(this: E, event: T, $selector: E) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
|
|
149
149
|
/**
|
|
150
150
|
* 取消绑定所有的事件
|
|
151
151
|
* @param element 需要取消绑定的元素|元素数组
|
|
@@ -325,7 +325,7 @@ declare class PopsDOMUtilsEvent {
|
|
|
325
325
|
* onlyStopPropagation: true,
|
|
326
326
|
* })
|
|
327
327
|
*/
|
|
328
|
-
preventEvent($el:
|
|
328
|
+
preventEvent($el: Element | Document | ShadowRoot, eventNameList: string | string[], option?: {
|
|
329
329
|
/** (可选)是否捕获,默认false */
|
|
330
330
|
capture?: boolean;
|
|
331
331
|
/** (可选)是否仅阻止事件的传播,默认false,不调用`.preventDefault()` */
|
|
@@ -352,7 +352,7 @@ declare class PopsDOMUtilsEvent {
|
|
|
352
352
|
* onlyStopPropagation: true,
|
|
353
353
|
* })
|
|
354
354
|
*/
|
|
355
|
-
preventEvent($el:
|
|
355
|
+
preventEvent($el: Element | Document | ShadowRoot, eventNameList: string | string[], selector: string | string[] | null | undefined, option?: {
|
|
356
356
|
/** (可选)是否捕获,默认false */
|
|
357
357
|
capture?: boolean;
|
|
358
358
|
/** (可选)是否仅阻止事件的传播,默认false,不调用`.preventDefault()` */
|
|
@@ -453,18 +453,6 @@ declare class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
453
453
|
getAnimationEndNameList(): string[];
|
|
454
454
|
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
455
455
|
getTransitionEndNameList(): string[];
|
|
456
|
-
/**
|
|
457
|
-
* 是否是隐藏状态
|
|
458
|
-
*
|
|
459
|
-
* 检测以下项:
|
|
460
|
-
*
|
|
461
|
-
* + `display`: none
|
|
462
|
-
* + `visibility`: hidden
|
|
463
|
-
* + `opacity`: 0
|
|
464
|
-
* + `使用了pops的自定义的隐藏class类`
|
|
465
|
-
* @param $el 需要检测的元素
|
|
466
|
-
*/
|
|
467
|
-
isHide($el: Element): boolean;
|
|
468
456
|
/**
|
|
469
457
|
* 实现jQuery中的$().offset();
|
|
470
458
|
* @param element
|
|
@@ -15,4 +15,26 @@ export declare const PopsInstanceUtils: {
|
|
|
15
15
|
* @param sortByDesc 排序是否降序,默认降序
|
|
16
16
|
*/
|
|
17
17
|
sortElementListByProperty<T, R>(getBeforeValueFun: (value: T) => R, getAfterValueFun: (value: T) => R, sortByDesc?: boolean): (after_obj: T, before_obj: T) => 1 | 0 | -1;
|
|
18
|
+
/**
|
|
19
|
+
* 是否是隐藏状态
|
|
20
|
+
*
|
|
21
|
+
* 检测以下项:
|
|
22
|
+
*
|
|
23
|
+
* + `display`: none
|
|
24
|
+
* + `visibility`: hidden
|
|
25
|
+
* + `opacity`: 0
|
|
26
|
+
* + `使用了pops的自定义的隐藏class类`
|
|
27
|
+
* @param $el 需要检测的元素
|
|
28
|
+
*/
|
|
29
|
+
isHide($el: Element): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 判断元素是否是在`.pops`内
|
|
32
|
+
* @param $el 目标元素
|
|
33
|
+
*/
|
|
34
|
+
isNodeInPopsNode($el: Element): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 判断是否是`.pops-anim`元素
|
|
37
|
+
* @param $el 目标元素
|
|
38
|
+
*/
|
|
39
|
+
isAnimNode($el: Element): boolean;
|
|
18
40
|
};
|
package/package.json
CHANGED
package/src/Pops.ts
CHANGED
|
@@ -41,6 +41,7 @@ class Pops {
|
|
|
41
41
|
config = {
|
|
42
42
|
/** 版本号 */
|
|
43
43
|
version: version,
|
|
44
|
+
/** 样式配置 */
|
|
44
45
|
cssText: PopsCSS,
|
|
45
46
|
/** icon图标的svg代码 */
|
|
46
47
|
iconSVG: PopsIcon.$data,
|
|
@@ -48,12 +49,9 @@ class Pops {
|
|
|
48
49
|
animation: PopsAnimation.$data,
|
|
49
50
|
/** 存储已创建的元素 */
|
|
50
51
|
instData: PopsInstData,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return popsDOMUtils.preventEvent(event);
|
|
55
|
-
},
|
|
56
|
-
},
|
|
52
|
+
};
|
|
53
|
+
/** 导出的函数 */
|
|
54
|
+
fn = {
|
|
57
55
|
/** pops使用的工具类 */
|
|
58
56
|
Utils: popsUtils,
|
|
59
57
|
/** pops使用的DOM工具类 */
|
|
@@ -63,17 +61,16 @@ class Pops {
|
|
|
63
61
|
/** pops处理float类型使用的工具类 */
|
|
64
62
|
MathFloatUtils: PopsMathFloatUtils,
|
|
65
63
|
/** 实例处理函数 */
|
|
66
|
-
PopsInstHandler,
|
|
64
|
+
InstHandler: PopsInstHandler,
|
|
67
65
|
/** pops.panel中用于处理各个类型的工具 */
|
|
68
|
-
PanelHandlerComponents,
|
|
66
|
+
PanelHandlerComponents: PanelHandlerComponents,
|
|
69
67
|
/** pops.panel中的动画 */
|
|
70
|
-
PopsAnimation,
|
|
68
|
+
Animation: PopsAnimation,
|
|
71
69
|
/** 事件类 */
|
|
72
|
-
EventEmiter,
|
|
70
|
+
EventEmiter: EventEmiter,
|
|
73
71
|
/** 通用的CSS类名 */
|
|
74
|
-
PopsCommonCSSClassName,
|
|
72
|
+
CommonCSSClassName: PopsCommonCSSClassName,
|
|
75
73
|
};
|
|
76
|
-
init() {}
|
|
77
74
|
/**
|
|
78
75
|
* 释放原有的pops控制权
|
|
79
76
|
* @example
|
|
@@ -1963,12 +1963,12 @@ export const PanelHandlerComponents = () => {
|
|
|
1963
1963
|
},
|
|
1964
1964
|
mask: {
|
|
1965
1965
|
enable: true,
|
|
1966
|
-
clickCallBack(
|
|
1966
|
+
clickCallBack(continueExec) {
|
|
1967
1967
|
const ret = dialogCloseCallback();
|
|
1968
1968
|
if (typeof ret === "boolean" && !ret) {
|
|
1969
1969
|
return;
|
|
1970
1970
|
}
|
|
1971
|
-
|
|
1971
|
+
continueExec();
|
|
1972
1972
|
},
|
|
1973
1973
|
clickEvent: {
|
|
1974
1974
|
toClose: true,
|
|
@@ -3171,8 +3171,8 @@ export const PanelHandlerComponents = () => {
|
|
|
3171
3171
|
},
|
|
3172
3172
|
mask: {
|
|
3173
3173
|
enable: true,
|
|
3174
|
-
clickCallBack(
|
|
3175
|
-
|
|
3174
|
+
clickCallBack(continueExec) {
|
|
3175
|
+
continueExec();
|
|
3176
3176
|
dialogCloseCallback();
|
|
3177
3177
|
},
|
|
3178
3178
|
clickEvent: {
|
|
@@ -16,6 +16,7 @@ import type { CustomEventMap } from "../types/EventEmitter";
|
|
|
16
16
|
import type { PopsInstGeneralConfig } from "../types/inst";
|
|
17
17
|
import type { PopsInstStoreType, PopsSupportAnimConfigType, PopsSupportOnlyConfig, PopsType } from "../types/main";
|
|
18
18
|
import { popsDOMUtils } from "../utils/PopsDOMUtils";
|
|
19
|
+
import { PopsInstanceUtils } from "../utils/PopsInstanceUtils";
|
|
19
20
|
import { popsUtils } from "../utils/PopsUtils";
|
|
20
21
|
import { PopsInstHandler } from "./PopsInstHandler";
|
|
21
22
|
|
|
@@ -154,11 +155,11 @@ export const PopsHandler = {
|
|
|
154
155
|
* 点击其它区域的事件
|
|
155
156
|
* @param event
|
|
156
157
|
*/
|
|
157
|
-
|
|
158
|
+
const clickEvent = (event: MouseEvent | PointerEvent) => {
|
|
158
159
|
popsDOMUtils.preventEvent(event);
|
|
159
160
|
// 获取该类型实例存储列表
|
|
160
161
|
const targetInst = PopsInstData[config.type];
|
|
161
|
-
|
|
162
|
+
const continueExec = () => {
|
|
162
163
|
if (config.config.mask!.clickEvent!.toClose) {
|
|
163
164
|
// 关闭
|
|
164
165
|
return PopsInstHandler.close(config.config, config.type, targetInst, config.guid, config.animElement);
|
|
@@ -173,38 +174,25 @@ export const PopsHandler = {
|
|
|
173
174
|
result.maskElement
|
|
174
175
|
);
|
|
175
176
|
}
|
|
176
|
-
}
|
|
177
|
+
};
|
|
177
178
|
if (typeof config.config.mask.clickCallBack === "function") {
|
|
178
|
-
config.config.mask.clickCallBack(
|
|
179
|
+
config.config.mask.clickCallBack(continueExec, config.config);
|
|
179
180
|
} else {
|
|
180
|
-
|
|
181
|
+
continueExec();
|
|
181
182
|
}
|
|
182
183
|
return false;
|
|
183
|
-
}
|
|
184
|
+
};
|
|
184
185
|
// 判断是否启用了遮罩层点击动作
|
|
185
186
|
if (config.config.mask.clickEvent!.toClose || config.config.mask.clickEvent!.toHide) {
|
|
186
|
-
/**
|
|
187
|
-
* 判断点击的元素是否是动画层的元素
|
|
188
|
-
* @param element
|
|
189
|
-
* @returns
|
|
190
|
-
*/
|
|
191
|
-
function isAnimElement(element: HTMLElement) {
|
|
192
|
-
return Boolean(
|
|
193
|
-
element?.localName?.toLowerCase() === "div" &&
|
|
194
|
-
element.className &&
|
|
195
|
-
element.className === "pops-anim" &&
|
|
196
|
-
element.hasAttribute("anim")
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
187
|
// 判断按下的元素是否是pops-anim
|
|
200
188
|
popsDOMUtils.on(config.animElement, "pointerup", (event) => {
|
|
201
189
|
const $click = event.composedPath()[0] as HTMLElement;
|
|
202
|
-
isMaskClick =
|
|
190
|
+
isMaskClick = PopsInstanceUtils.isAnimNode($click);
|
|
203
191
|
});
|
|
204
192
|
// 如果有动画层,在动画层上监听点击事件
|
|
205
193
|
popsDOMUtils.on<MouseEvent | PointerEvent>(config.animElement, "click", (event) => {
|
|
206
194
|
const $click = event.composedPath()[0] as HTMLElement;
|
|
207
|
-
if (isMaskClick &&
|
|
195
|
+
if (isMaskClick && PopsInstanceUtils.isAnimNode($click)) {
|
|
208
196
|
return clickEvent(event);
|
|
209
197
|
}
|
|
210
198
|
});
|
|
@@ -14,6 +14,7 @@ import { PopsInstData } from "../PopsInst";
|
|
|
14
14
|
import type { PopsInstGeneralConfig } from "../types/inst";
|
|
15
15
|
import type { PopsInstStoreType } from "../types/main";
|
|
16
16
|
import { popsDOMUtils } from "../utils/PopsDOMUtils";
|
|
17
|
+
import { PopsInstanceUtils } from "../utils/PopsInstanceUtils";
|
|
17
18
|
import { popsUtils } from "../utils/PopsUtils";
|
|
18
19
|
|
|
19
20
|
export const PopsInstHandler = {
|
|
@@ -117,7 +118,7 @@ export const PopsInstHandler = {
|
|
|
117
118
|
// 先设置好动画状态
|
|
118
119
|
// 再显示,会自执行动画
|
|
119
120
|
const checkVisible = () => {
|
|
120
|
-
if (!
|
|
121
|
+
if (!PopsInstanceUtils.isHide($anim)) {
|
|
121
122
|
return true;
|
|
122
123
|
} else {
|
|
123
124
|
return false;
|
|
@@ -221,7 +222,7 @@ export const PopsInstHandler = {
|
|
|
221
222
|
// 再隐藏
|
|
222
223
|
// 存在实例
|
|
223
224
|
const checkVisible = () => {
|
|
224
|
-
if (!
|
|
225
|
+
if (!PopsInstanceUtils.isHide($anim)) {
|
|
225
226
|
return true;
|
|
226
227
|
} else {
|
|
227
228
|
return false;
|
|
@@ -209,9 +209,9 @@ export type PopsDOMUtils_EventType = keyof PopsDOMUtils_Event;
|
|
|
209
209
|
*/
|
|
210
210
|
export declare interface PopsDOMUtilsEventListenerOptionsAttribute {
|
|
211
211
|
/**
|
|
212
|
-
* DOMUtils的
|
|
212
|
+
* DOMUtils的handlerCallBack,元素上的监听事件就是它,移除事件时也需要传入这个函数
|
|
213
213
|
*/
|
|
214
|
-
|
|
214
|
+
handlerCallBack: (event: Event, $selector?: HTMLElement) => void;
|
|
215
215
|
/**
|
|
216
216
|
* 属性配置
|
|
217
217
|
*/
|
|
@@ -219,7 +219,7 @@ export declare interface PopsDOMUtilsEventListenerOptionsAttribute {
|
|
|
219
219
|
/**
|
|
220
220
|
* 用户添加的事件
|
|
221
221
|
*/
|
|
222
|
-
|
|
222
|
+
callback: (event: Event, $selector?: HTMLElement) => void;
|
|
223
223
|
/**
|
|
224
224
|
* 子元素选择器
|
|
225
225
|
*/
|
package/src/types/mask.d.ts
CHANGED
|
@@ -16,28 +16,28 @@ export interface PopsMaskConfig {
|
|
|
16
16
|
*/
|
|
17
17
|
enable?: boolean;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* 点击事件配置
|
|
20
20
|
*/
|
|
21
21
|
clickEvent?: {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* (可选)点击遮罩层是否触发关闭事件,默认false
|
|
24
24
|
* @default false
|
|
25
25
|
*/
|
|
26
26
|
toClose?: boolean;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* (可选)点击遮罩层是否触发隐藏事件,默认false
|
|
29
29
|
* @default false
|
|
30
30
|
*/
|
|
31
31
|
toHide?: boolean;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* 遮罩层自定义的点击事件
|
|
35
|
-
* @param originalRun 当toClose为true,它是关闭弹窗,当toHide为true,它是隐藏弹窗
|
|
36
|
-
* @param config 配置信息
|
|
37
35
|
*/
|
|
38
36
|
clickCallBack?:
|
|
39
37
|
| ((
|
|
40
|
-
|
|
38
|
+
/** 当toClose为true,它是关闭弹窗,当toHide为true,它是隐藏弹窗 */
|
|
39
|
+
continueExec: () => void | Promise<void>,
|
|
40
|
+
/** 配置信息 */
|
|
41
41
|
config:
|
|
42
42
|
| PopsAlertConfig
|
|
43
43
|
| PopsDrawerConfig
|