@whitesev/pops 2.0.10 → 2.0.12

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.
Files changed (57) hide show
  1. package/dist/index.amd.js +4695 -4403
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +4695 -4403
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +4695 -4403
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +4695 -4403
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +4695 -4403
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +4695 -4403
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +66 -42
  14. package/dist/types/src/PopsAnimation.d.ts +14 -0
  15. package/dist/types/src/PopsCSS.d.ts +34 -0
  16. package/dist/types/src/PopsIcon.d.ts +25 -0
  17. package/dist/types/src/PopsLayer.d.ts +3 -0
  18. package/dist/types/src/components/panel/buttonType.d.ts +2 -2
  19. package/dist/types/src/components/rightClickMenu/index.d.ts +2 -3
  20. package/dist/types/src/components/rightClickMenu/indexType.d.ts +4 -3
  21. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +19 -6
  22. package/dist/types/src/types/button.d.ts +3 -3
  23. package/dist/types/src/types/icon.d.ts +1 -1
  24. package/dist/types/src/utils/PopsDOMUtils.d.ts +120 -26
  25. package/dist/types/src/utils/PopsInstanceUtils.d.ts +0 -6
  26. package/dist/types/src/utils/PopsUtils.d.ts +5 -6
  27. package/package.json +1 -1
  28. package/src/Pops.ts +12 -152
  29. package/src/PopsAnimation.ts +32 -0
  30. package/src/PopsCSS.ts +51 -0
  31. package/src/PopsIcon.ts +93 -0
  32. package/src/PopsLayer.ts +17 -0
  33. package/src/components/alert/index.ts +8 -8
  34. package/src/components/confirm/index.ts +8 -8
  35. package/src/components/drawer/index.ts +8 -8
  36. package/src/components/folder/index.ts +15 -15
  37. package/src/components/iframe/index.ts +9 -12
  38. package/src/components/loading/index.ts +5 -5
  39. package/src/components/panel/PanelHandleContentDetails.ts +28 -25
  40. package/src/components/panel/buttonType.ts +2 -2
  41. package/src/components/panel/config.ts +4 -0
  42. package/src/components/panel/index.css +33 -0
  43. package/src/components/panel/index.ts +9 -9
  44. package/src/components/prompt/index.ts +8 -8
  45. package/src/components/rightClickMenu/config.ts +7 -7
  46. package/src/components/rightClickMenu/index.ts +41 -29
  47. package/src/components/rightClickMenu/indexType.ts +5 -3
  48. package/src/components/searchSuggestion/index.ts +5 -5
  49. package/src/components/tooltip/index.ts +5 -5
  50. package/src/handler/PopsElementHandler.ts +17 -17
  51. package/src/handler/PopsHandler.ts +22 -19
  52. package/src/types/PopsDOMUtilsEventType.d.ts +19 -6
  53. package/src/types/button.d.ts +3 -3
  54. package/src/types/icon.d.ts +1 -1
  55. package/src/utils/PopsDOMUtils.ts +568 -170
  56. package/src/utils/PopsInstanceUtils.ts +13 -31
  57. package/src/utils/PopsUtils.ts +7 -16
@@ -1,5 +1,4 @@
1
- import type { ParseHTMLReturnType, PopsDOMUtilsCreateElementAttributesMap } from "../types/PopsDOMUtilsEventType";
2
- import type { PopsDOMUtils_Event, PopsDOMUtils_EventType, PopsDOMUtilsElementEventType, PopsDOMUtilsEventListenerOptionsAttribute } from "../types/PopsDOMUtilsEventType";
1
+ import type { ParseHTMLReturnType, PopsDOMUtils_EventType, PopsDOMUtilsCreateElementAttributesMap, PopsDOMUtilsEventListenerOption, PopsDOMUtilsEventListenerOptionsAttribute, PopsDOMUtils_Event, PopsDOMUtilsElementEventType } from "../types/PopsDOMUtilsEventType";
3
2
  declare class PopsDOMUtilsEvent {
4
3
  /**
5
4
  * 绑定事件
@@ -19,8 +18,7 @@ declare class PopsDOMUtilsEvent {
19
18
  * console.log("事件触发",event)
20
19
  * })
21
20
  */
22
- on(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback: (event: Event) => void, option?: boolean | AddEventListenerOptions): void;
23
- on<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions): void;
21
+ on<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback: (this: HTMLElement, event: PopsDOMUtils_Event[T]) => void, option?: PopsDOMUtilsEventListenerOption | boolean): void;
24
22
  /**
25
23
  * 绑定事件
26
24
  * @param element 需要绑定的元素|元素数组|window
@@ -39,7 +37,7 @@ declare class PopsDOMUtilsEvent {
39
37
  * console.log("事件触发",event)
40
38
  * })
41
39
  */
42
- on<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string, callback: (event: T) => void, option?: boolean | AddEventListenerOptions): void;
40
+ on<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback: (this: HTMLElement, event: T) => void, option?: PopsDOMUtilsEventListenerOption | boolean): void;
43
41
  /**
44
42
  * 绑定事件
45
43
  * @param element 需要绑定的元素|元素数组|window
@@ -52,20 +50,19 @@ declare class PopsDOMUtilsEvent {
52
50
  * + passive 表示事件监听器是否不会调用preventDefault()。默认为false
53
51
  * @example
54
52
  * // 监听元素a.xx的click、tap、hover事件
55
- * DOMUtils.on(document.querySelector("a.xx"),"click tap hover",(event)=>{
56
- * console.log("事件触发",event)
53
+ * DOMUtils.on(document.querySelector("a.xx"),"click tap hover",(event, selectorTarget)=>{
54
+ * console.log("事件触发", event, selectorTarget)
57
55
  * })
58
- * DOMUtils.on("a.xx",["click","tap","hover"],(event)=>{
59
- * console.log("事件触发",event)
56
+ * DOMUtils.on("a.xx",["click","tap","hover"],(event, selectorTarget)=>{
57
+ * console.log("事件触发", event, selectorTarget)
60
58
  * })
61
59
  * @example
62
60
  * // 监听全局document下的子元素a.xx的click事件
63
- * DOMUtils.on(document,"click tap hover","a.xx",(event)=>{
64
- * console.log("事件触发",event)
61
+ * DOMUtils.on(document,"click tap hover","a.xx",(event, selectorTarget)=>{
62
+ * console.log("事件触发", event, selectorTarget)
65
63
  * })
66
64
  */
67
- on<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector: string | undefined | null, callback: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions): void;
68
- on<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], selector: string | undefined | null, callback: (event: T) => void, option?: boolean | AddEventListenerOptions): void;
65
+ on<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector: string | string[] | undefined | null, callback: (this: HTMLElement, event: PopsDOMUtils_Event[T], selectorTarget: HTMLElement) => void, option?: PopsDOMUtilsEventListenerOption | boolean): void;
69
66
  /**
70
67
  * 绑定事件
71
68
  * @param element 需要绑定的元素|元素数组|window
@@ -78,19 +75,19 @@ declare class PopsDOMUtilsEvent {
78
75
  * + passive 表示事件监听器是否不会调用preventDefault()。默认为false
79
76
  * @example
80
77
  * // 监听元素a.xx的click、tap、hover事件
81
- * DOMUtils.on(document.querySelector("a.xx"),"click tap hover",(event)=>{
82
- * console.log("事件触发",event)
78
+ * DOMUtils.on(document.querySelector("a.xx"),"click tap hover",(event, selectorTarget)=>{
79
+ * console.log("事件触发", event, selectorTarget)
83
80
  * })
84
- * DOMUtils.on("a.xx",["click","tap","hover"],(event)=>{
85
- * console.log("事件触发",event)
81
+ * DOMUtils.on("a.xx",["click","tap","hover"],(event, selectorTarget)=>{
82
+ * console.log("事件触发", event, selectorTarget)
86
83
  * })
87
84
  * @example
88
85
  * // 监听全局document下的子元素a.xx的click事件
89
- * DOMUtils.on(document,"click tap hover","a.xx",(event)=>{
90
- * console.log("事件触发",event)
86
+ * DOMUtils.on(document,"click tap hover","a.xx",(event, selectorTarget)=>{
87
+ * console.log("事件触发", event, selectorTarget)
91
88
  * })
92
89
  */
93
- on<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string, selector: string | undefined | null, callback: (event: T) => void, option?: boolean | AddEventListenerOptions): void;
90
+ on<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], selector: string | string[] | undefined | null, callback: (this: HTMLElement, event: T, selectorTarget: HTMLElement) => void, option?: PopsDOMUtilsEventListenerOption | boolean): void;
94
91
  /**
95
92
  * 取消绑定事件
96
93
  * @param element 需要取消绑定的元素|元素数组
@@ -100,12 +97,11 @@ declare class PopsDOMUtilsEvent {
100
97
  * + capture 如果在添加事件监听器时指定了useCapture为true,则在移除事件监听器时也必须指定为true
101
98
  * @param filter (可选)过滤函数,对元素属性上的事件进行过滤出想要删除的事件
102
99
  * @example
103
- * // 取消监听元素a.xxclick事件
100
+ * // 取消监听元素a.xx所有的click事件
104
101
  * DOMUtils.off(document.querySelector("a.xx"),"click")
105
102
  * DOMUtils.off("a.xx","click")
106
103
  */
107
- off(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback?: (event: Event) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
108
- off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback?: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
104
+ off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], callback?: (this: HTMLElement, event: PopsDOMUtils_Event[T]) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
109
105
  /**
110
106
  * 取消绑定事件
111
107
  * @param element 需要取消绑定的元素|元素数组
@@ -119,7 +115,7 @@ declare class PopsDOMUtilsEvent {
119
115
  * DOMUtils.off(document.querySelector("a.xx"),"click")
120
116
  * DOMUtils.off("a.xx","click")
121
117
  */
122
- off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string, callback?: (event: T) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
118
+ off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], callback?: (this: HTMLElement, event: T) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
123
119
  /**
124
120
  * 取消绑定事件
125
121
  * @param element 需要取消绑定的元素|元素数组
@@ -134,7 +130,7 @@ declare class PopsDOMUtilsEvent {
134
130
  * DOMUtils.off(document.querySelector("a.xx"),"click tap hover")
135
131
  * DOMUtils.off("a.xx",["click","tap","hover"])
136
132
  */
137
- off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector?: string | undefined, callback?: (event: PopsDOMUtils_Event[T]) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
133
+ off<T extends PopsDOMUtils_EventType>(element: PopsDOMUtilsElementEventType, eventType: T | T[], selector?: string | string[] | undefined | null, callback?: (this: HTMLElement, event: PopsDOMUtils_Event[T], selectorTarget: HTMLElement) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
138
134
  /**
139
135
  * 取消绑定事件
140
136
  * @param element 需要取消绑定的元素|元素数组
@@ -149,7 +145,7 @@ declare class PopsDOMUtilsEvent {
149
145
  * DOMUtils.off(document.querySelector("a.xx"),"click tap hover")
150
146
  * DOMUtils.off("a.xx",["click","tap","hover"])
151
147
  */
152
- off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], selector?: string | undefined, callback?: (event: T) => void, option?: boolean | AddEventListenerOptions, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
148
+ off<T extends Event>(element: PopsDOMUtilsElementEventType, eventType: string | string[], selector?: string | string[] | undefined | null, callback?: (this: HTMLElement, event: T, selectorTarget: HTMLElement) => void, option?: EventListenerOptions | boolean, filter?: (value: PopsDOMUtilsEventListenerOptionsAttribute, index: number, array: PopsDOMUtilsEventListenerOptionsAttribute[]) => boolean): void;
153
149
  /**
154
150
  * 取消绑定所有的事件
155
151
  * @param element 需要取消绑定的元素|元素数组
@@ -331,6 +327,92 @@ declare class PopsDOMUtilsEvent {
331
327
  * Utils.preventEvent(event);
332
328
  */
333
329
  preventEvent(element: HTMLElement, eventNameList?: string | string[], capture?: boolean): boolean;
330
+ /**
331
+ * 选择器,可使用以下的额外语法
332
+ *
333
+ * + :contains([text]) 作用: 找到包含指定文本内容的指定元素
334
+ * + :empty 作用:找到既没有文本内容也没有子元素的指定元素
335
+ * + :regexp([text]) 作用: 找到符合正则表达式的内容的指定元素
336
+ * @param selector 选择器
337
+ * @example
338
+ * DOMUtils.selector("div:contains('测试')")
339
+ * > div.xxx
340
+ * @example
341
+ * DOMUtils.selector("div:empty")
342
+ * > div.xxx
343
+ * @example
344
+ * DOMUtils.selector("div:regexp('^xxxx$')")
345
+ * > div.xxx
346
+ */
347
+ selector<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | undefined;
348
+ selector<E extends Element = Element>(selector: string): E | undefined;
349
+ /**
350
+ * 选择器,可使用以下的额外语法
351
+ *
352
+ * + :contains([text]) 作用: 找到包含指定文本内容的指定元素
353
+ * + :empty 作用:找到既没有文本内容也没有子元素的指定元素
354
+ * + :regexp([text]) 作用: 找到符合正则表达式的内容的指定元素
355
+ * @param selector 选择器
356
+ * @example
357
+ * DOMUtils.selectorAll("div:contains('测试')")
358
+ * > [div.xxx]
359
+ * @example
360
+ * DOMUtils.selectorAll("div:empty")
361
+ * > [div.xxx]
362
+ * @example
363
+ * DOMUtils.selectorAll("div:regexp('^xxxx$')")
364
+ * > [div.xxx]
365
+ * @example
366
+ * DOMUtils.selectorAll("div:regexp(/^xxx/ig)")
367
+ * > [div.xxx]
368
+ */
369
+ selectorAll<K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K][];
370
+ selectorAll<E extends Element = Element>(selector: string): E[];
371
+ /**
372
+ * 匹配元素,可使用以下的额外语法
373
+ *
374
+ * + :contains([text]) 作用: 找到包含指定文本内容的指定元素
375
+ * + :empty 作用:找到既没有文本内容也没有子元素的指定元素
376
+ * + :regexp([text]) 作用: 找到符合正则表达式的内容的指定元素
377
+ * @param $el 元素
378
+ * @param selector 选择器
379
+ * @example
380
+ * DOMUtils.matches("div:contains('测试')")
381
+ * > true
382
+ * @example
383
+ * DOMUtils.matches("div:empty")
384
+ * > true
385
+ * @example
386
+ * DOMUtils.matches("div:regexp('^xxxx$')")
387
+ * > true
388
+ * @example
389
+ * DOMUtils.matches("div:regexp(/^xxx/ig)")
390
+ * > false
391
+ */
392
+ matches($el: HTMLElement | Element | null | undefined, selector: string): boolean;
393
+ /**
394
+ * 根据选择器获取上层元素,可使用以下的额外语法
395
+ *
396
+ * + :contains([text]) 作用: 找到包含指定文本内容的指定元素
397
+ * + :empty 作用:找到既没有文本内容也没有子元素的指定元素
398
+ * + :regexp([text]) 作用: 找到符合正则表达式的内容的指定元素
399
+ * @param $el 元素
400
+ * @param selector 选择器
401
+ * @example
402
+ * DOMUtils.closest("div:contains('测试')")
403
+ * > div.xxx
404
+ * @example
405
+ * DOMUtils.closest("div:empty")
406
+ * > div.xxx
407
+ * @example
408
+ * DOMUtils.closest("div:regexp('^xxxx$')")
409
+ * > div.xxxx
410
+ * @example
411
+ * DOMUtils.closest("div:regexp(/^xxx/ig)")
412
+ * > null
413
+ */
414
+ closest<K extends keyof HTMLElementTagNameMap>($el: HTMLElement | Element, selector: string): HTMLElementTagNameMap[K] | null;
415
+ closest<E extends Element = Element>($el: HTMLElement | Element, selector: string): E | null;
334
416
  }
335
417
  declare class PopsDOMUtils extends PopsDOMUtilsEvent {
336
418
  /** 获取 animationend 在各个浏览器的兼容名 */
@@ -520,6 +602,12 @@ declare class PopsDOMUtils extends PopsDOMUtilsEvent {
520
602
  }) | string,
521
603
  /** 自定义属性 */
522
604
  attributes?: PopsDOMUtilsCreateElementAttributesMap): HTMLElementTagNameMap[K];
605
+ /**
606
+ * 字符串转HTMLElement
607
+ * @param elementString
608
+ * @returns
609
+ */
610
+ parseTextToDOM<R extends HTMLElement>(elementString: string): R;
523
611
  /**
524
612
  * 获取文字的位置信息
525
613
  * @param input 输入框
@@ -635,6 +723,12 @@ declare class PopsDOMUtils extends PopsDOMUtilsEvent {
635
723
  * DOMUtils.after("a.xx","'<b class="xx"></b>")
636
724
  * */
637
725
  after(element: HTMLElement | Element | string, content: HTMLElement | string): void;
726
+ /**
727
+ * 获取CSS Rule
728
+ * @param sheet
729
+ * @returns
730
+ */
731
+ getKeyFrames(sheet: CSSStyleSheet): {};
638
732
  }
639
733
  declare const popsDOMUtils: PopsDOMUtils;
640
734
  export { popsDOMUtils };
@@ -42,12 +42,6 @@ export declare const PopsInstanceUtils: {
42
42
  * > 1001
43
43
  **/
44
44
  getMaxZIndex(deviation?: number): number;
45
- /**
46
- * 获取CSS Rule
47
- * @param sheet
48
- * @returns
49
- */
50
- getKeyFrames(sheet: CSSStyleSheet): {};
51
45
  /**
52
46
  * 删除配置中对应的对象
53
47
  * @param moreLayerConfigList 配置实例列表
@@ -42,12 +42,6 @@ declare class PopsUtils {
42
42
  * 生成uuid
43
43
  */
44
44
  getRandomGUID(): string;
45
- /**
46
- * 字符串转HTMLElement
47
- * @param elementString
48
- * @returns
49
- */
50
- parseTextToDOM<R extends HTMLElement>(elementString: string): R;
51
45
  /**
52
46
  * 判断元素/页面中是否包含该元素
53
47
  * @param target 需要判断的元素
@@ -119,6 +113,11 @@ declare class PopsUtils {
119
113
  **/
120
114
  formatByteToSize<T extends boolean>(byteSize: number | string, addType?: T): T extends true ? string : number;
121
115
  AnyTouch: () => typeof AnyTouch;
116
+ /**
117
+ * 通过navigator.userAgent判断是否是手机访问
118
+ * @param userAgent
119
+ */
120
+ isPhone(userAgent?: string): boolean;
122
121
  /**
123
122
  * 自动使用 Worker 执行 setTimeout
124
123
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/pops",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "弹窗库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/Pops.ts CHANGED
@@ -1,57 +1,11 @@
1
1
  import { popsDOMUtils } from "./utils/PopsDOMUtils";
2
2
  import { PopsInstanceUtils } from "./utils/PopsInstanceUtils";
3
3
  import { popsUtils } from "./utils/PopsUtils";
4
- import indexCSS from "./css/index.css";
5
- import ninePalaceGridPositionCSS from "./css/ninePalaceGridPosition.css";
6
- import scrollbarCSS from "./css/scrollbar.css";
7
- import buttonCSS from "./css/button.css";
8
- import commonCSS from "./css/common.css";
9
- import animCSS from "./css/animation.css";
10
- import alertCSS from "./components/alert/index.css";
11
- import confirmCSS from "./components/confirm/index.css";
12
- import promptCSS from "./components/prompt/index.css";
13
- import loadingCSS from "./components/loading/index.css";
14
- import iframeCSS from "./components/iframe/index.css";
15
- import tooltipCSS from "./components/tooltip/index.css";
16
- import drawerCSS from "./components/drawer/index.css";
17
- import folderCSS from "./components/folder/index.css";
18
- import panelCSS from "./components/panel/index.css";
19
- import rightClickMenuCSS from "./components/rightClickMenu/index.css";
20
- import SVG_min from "./svg/min.svg";
21
- import SVG_mise from "./svg/mise.svg";
22
- import SVG_max from "./svg/max.svg";
23
- import SVG_close from "./svg/close.svg";
24
- import SVG_edit from "./svg/edit.svg";
25
- import SVG_share from "./svg/share.svg";
26
- import SVG_delete from "./svg/delete.svg";
27
- import SVG_search from "./svg/search.svg";
28
- import SVG_upload from "./svg/upload.svg";
29
- import SVG_loading from "./svg/loading.svg";
30
- import SVG_next from "./svg/next.svg";
31
- import SVG_prev from "./svg/prev.svg";
32
- import SVG_eleme from "./svg/eleme.svg";
33
- import SVG_elemePlus from "./svg/elemePlus.svg";
34
- import SVG_chromeFilled from "./svg/chromeFilled.svg";
35
- import SVG_cpu from "./svg/cpu.svg";
36
- import SVG_videoPlay from "./svg/videoPlay.svg";
37
- import SVG_videoPause from "./svg/videoPause.svg";
38
- import SVG_headset from "./svg/headset.svg";
39
- import SVG_monitor from "./svg/monitor.svg";
40
- import SVG_documentCopy from "./svg/documentCopy.svg";
41
- import SVG_picture from "./svg/picture.svg";
42
- import SVG_circleClose from "./svg/circleClose.svg";
43
- import SVG_view from "./svg/view.svg";
44
- import SVG_hide from "./svg/hide.svg";
45
- import SVG_keyboard from "./svg/keyboard.svg";
46
- import SVG_arrowRight from "./svg/arrowRight.svg";
47
- import SVG_arrowLeft from "./svg/arrowLeft.svg";
48
4
  import { PopsCore } from "./Core";
49
- import { PopsLayerMode } from "./types/main";
50
5
  import { PopsAlert } from "./components/alert";
51
6
  import type { PopsAlertDetails } from "./components/alert/indexType";
52
7
  import { PopsConfirm } from "./components/confirm";
53
8
  import type { PopsConfirmDetails } from "./components/confirm/indexType";
54
- import type { PopsLayerCommonConfig } from "./types/layer";
55
9
  import type { PopsPromptDetails } from "./components/prompt/indexType";
56
10
  import { PopsPrompt } from "./components/prompt";
57
11
  import type { PopsLoadingDetails } from "./components/loading/indexType";
@@ -67,108 +21,29 @@ import type { PopsPanelDetails } from "./components/panel/indexType";
67
21
  import { PopsPanel } from "./components/panel";
68
22
  import { PopsRightClickMenu } from "./components/rightClickMenu";
69
23
  import type { PopsRightClickMenuDetails } from "./components/rightClickMenu/indexType";
70
- import type { PopsIcon } from "./types/icon";
71
24
  import type { PopsSearchSuggestionDetails } from "./components/searchSuggestion/indexType";
72
25
  import { PopsSearchSuggestion } from "./components/searchSuggestion";
73
26
  import { PopsMathFloatUtils } from "./utils/PopsMathUtils";
74
27
  import { PanelHandleContentDetails } from "./components/panel/PanelHandleContentDetails";
75
28
  import { GlobalConfig } from "./GlobalConfig";
76
29
  import { PopsTooltip } from "./components/tooltip";
77
- import { PopsSafeUtils } from "./utils/PopsSafeUtils";
30
+ import { PopsCSS } from "./PopsCSS";
31
+ import { PopsIcon } from "./PopsIcon";
32
+ import { PopsLayer } from "./PopsLayer";
33
+ import { PopsAnimation } from "./PopsAnimation";
78
34
 
79
35
  class Pops {
80
36
  /** 配置 */
81
37
  config = {
82
38
  /** 版本号 */
83
- version: "2025.5.26",
84
- cssText: {
85
- /** 主CSS */
86
- index: indexCSS,
87
- /** 九宫格位置CSS */
88
- ninePalaceGridPosition: ninePalaceGridPositionCSS,
89
- /** 滚动条CSS */
90
- scrollbar: scrollbarCSS,
91
- /** 按钮CSS */
92
- button: buttonCSS,
93
- /** 通用的CSS */
94
- common: commonCSS,
95
- /** 动画 */
96
- anim: animCSS,
97
- /** pops.alert */
98
- alertCSS: alertCSS,
99
- /** pops.cponfirm */
100
- confirmCSS: confirmCSS,
101
- /** pops.prompt */
102
- promptCSS: promptCSS,
103
- /** pops.loading */
104
- loadingCSS: loadingCSS,
105
- /** pops.iframe */
106
- iframeCSS: iframeCSS,
107
- /** pops.tooltip */
108
- tooltipCSS: tooltipCSS,
109
- /** pops.drawer */
110
- drawerCSS: drawerCSS,
111
- /** pops.folder */
112
- folderCSS: folderCSS,
113
- /** pops.folder */
114
- panelCSS: panelCSS,
115
- /** pops.rightClickMenu */
116
- rightClickMenu: rightClickMenuCSS,
117
- },
39
+ version: "2025.6.6",
40
+ cssText: PopsCSS,
118
41
  /** icon图标的svg代码 */
119
- iconSVG: {
120
- min: SVG_min,
121
- mise: SVG_mise,
122
- max: SVG_max,
123
- close: SVG_close,
124
- edit: SVG_edit,
125
- share: SVG_share,
126
- delete: SVG_delete,
127
- search: SVG_search,
128
- upload: SVG_upload,
129
- loading: SVG_loading,
130
- next: SVG_next,
131
- prev: SVG_prev,
132
- eleme: SVG_eleme,
133
- elemePlus: SVG_elemePlus,
134
- chromeFilled: SVG_chromeFilled,
135
- cpu: SVG_cpu,
136
- videoPlay: SVG_videoPlay,
137
- videoPause: SVG_videoPause,
138
- headset: SVG_headset,
139
- monitor: SVG_monitor,
140
- documentCopy: SVG_documentCopy,
141
- picture: SVG_picture,
142
- circleClose: SVG_circleClose,
143
- view: SVG_view,
144
- hide: SVG_hide,
145
- keyboard: SVG_keyboard,
146
- arrowRight: SVG_arrowRight,
147
- arrowLeft: SVG_arrowLeft,
148
- } as {
149
- [key in PopsIcon]: string;
150
- },
42
+ iconSVG: PopsIcon.$data,
151
43
  /** 当前已配置的动画@keyframes名字映射(初始化时生成) */
152
- animation: {} as {
153
- [key: string]: CSSKeyframesRule;
154
- },
155
- /** 是否初始化 */
156
- isInit: false,
44
+ animation: PopsAnimation.$data,
157
45
  /** 存储已创建的元素 */
158
- layer: {
159
- alert: [],
160
- confirm: [],
161
- prompt: [],
162
- loading: [],
163
- iframe: [],
164
- tooltip: [],
165
- drawer: [],
166
- folder: [],
167
- panel: [],
168
- rightClickMenu: [],
169
- } as {
170
- [key in PopsLayerMode]: PopsLayerCommonConfig[];
171
- },
46
+ layer: PopsLayer,
172
47
  /** 禁止滚动 */
173
48
  forbiddenScroll: {
174
49
  event(event: Event) {
@@ -186,22 +61,7 @@ class Pops {
186
61
  /** pops.panel中用于处理各个类型的工具 */
187
62
  panelHandleContentUtils: PanelHandleContentDetails,
188
63
  };
189
- init() {
190
- if (!this.config.isInit) {
191
- /* 处理获取当前所有的动画名 */
192
- this.config.isInit = true;
193
- let animationStyle = document.createElement("style");
194
- PopsSafeUtils.setSafeHTML(animationStyle, this.config.cssText.anim);
195
- popsDOMUtils.appendHead(animationStyle);
196
- this.config.animation = null as any;
197
- this.config.animation = PopsInstanceUtils.getKeyFrames(
198
- animationStyle.sheet!
199
- );
200
- popsUtils.setTimeout(() => {
201
- animationStyle.remove();
202
- }, 50);
203
- }
204
- }
64
+ init() {}
205
65
  /**
206
66
  * 释放原有的pops控制权
207
67
  * @example
@@ -224,8 +84,8 @@ class Pops {
224
84
  * 通过navigator.userAgent判断是否是手机访问
225
85
  * @param userAgent
226
86
  */
227
- isPhone(userAgent = PopsCore.globalThis.navigator.userAgent): boolean {
228
- return Boolean(/(iPhone|iPad|iPod|iOS|Android)/i.test(userAgent));
87
+ isPhone(userAgent?: string) {
88
+ return popsUtils.isPhone(userAgent);
229
89
  }
230
90
  /**
231
91
  * 为所有弹窗设置全局属性
@@ -0,0 +1,32 @@
1
+ import { PopsCSS } from "./PopsCSS";
2
+ import { popsDOMUtils } from "./utils/PopsDOMUtils";
3
+ import { PopsSafeUtils } from "./utils/PopsSafeUtils";
4
+ import { popsUtils } from "./utils/PopsUtils";
5
+
6
+ export const PopsAnimation = {
7
+ $data: {} as { [key: string]: CSSKeyframesRule },
8
+ $flag: {
9
+ /** 是否初始化 */
10
+ isInit: false,
11
+ },
12
+ init() {
13
+ if (!this.$flag.isInit) {
14
+ this.$flag.isInit = true;
15
+ /* 处理获取当前所有的动画名 */
16
+ let animationStyle = document.createElement("style");
17
+ PopsSafeUtils.setSafeHTML(animationStyle, PopsCSS.anim);
18
+ popsDOMUtils.appendHead(animationStyle);
19
+ this.$data = null as any;
20
+ this.$data = popsDOMUtils.getKeyFrames(animationStyle.sheet!);
21
+ popsUtils.setTimeout(() => {
22
+ animationStyle.remove();
23
+ }, 50);
24
+ }
25
+ },
26
+ /**
27
+ * 判断是否存在某个动画名
28
+ */
29
+ hasAnim(name: string) {
30
+ return this.$data.hasOwnProperty(name);
31
+ },
32
+ };
package/src/PopsCSS.ts ADDED
@@ -0,0 +1,51 @@
1
+ import indexCSS from "./css/index.css";
2
+ import ninePalaceGridPositionCSS from "./css/ninePalaceGridPosition.css";
3
+ import scrollbarCSS from "./css/scrollbar.css";
4
+ import buttonCSS from "./css/button.css";
5
+ import commonCSS from "./css/common.css";
6
+ import animCSS from "./css/animation.css";
7
+ import alertCSS from "./components/alert/index.css";
8
+ import confirmCSS from "./components/confirm/index.css";
9
+ import promptCSS from "./components/prompt/index.css";
10
+ import loadingCSS from "./components/loading/index.css";
11
+ import iframeCSS from "./components/iframe/index.css";
12
+ import tooltipCSS from "./components/tooltip/index.css";
13
+ import drawerCSS from "./components/drawer/index.css";
14
+ import folderCSS from "./components/folder/index.css";
15
+ import panelCSS from "./components/panel/index.css";
16
+ import rightClickMenuCSS from "./components/rightClickMenu/index.css";
17
+
18
+ export const PopsCSS = {
19
+ /** 主CSS */
20
+ index: indexCSS,
21
+ /** 九宫格位置CSS */
22
+ ninePalaceGridPosition: ninePalaceGridPositionCSS,
23
+ /** 滚动条CSS */
24
+ scrollbar: scrollbarCSS,
25
+ /** 按钮CSS */
26
+ button: buttonCSS,
27
+ /** 通用的CSS */
28
+ common: commonCSS,
29
+ /** 动画 */
30
+ anim: animCSS,
31
+ /** pops.alert */
32
+ alertCSS: alertCSS,
33
+ /** pops.cponfirm */
34
+ confirmCSS: confirmCSS,
35
+ /** pops.prompt */
36
+ promptCSS: promptCSS,
37
+ /** pops.loading */
38
+ loadingCSS: loadingCSS,
39
+ /** pops.iframe */
40
+ iframeCSS: iframeCSS,
41
+ /** pops.tooltip */
42
+ tooltipCSS: tooltipCSS,
43
+ /** pops.drawer */
44
+ drawerCSS: drawerCSS,
45
+ /** pops.folder */
46
+ folderCSS: folderCSS,
47
+ /** pops.folder */
48
+ panelCSS: panelCSS,
49
+ /** pops.rightClickMenu */
50
+ rightClickMenu: rightClickMenuCSS,
51
+ };