@whitesev/pops 2.4.6 → 2.4.7

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 (142) hide show
  1. package/dist/index.amd.js +578 -571
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +578 -571
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +578 -571
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +578 -571
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +578 -571
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +578 -571
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +252 -252
  14. package/dist/types/src/types/animation.d.ts +19 -19
  15. package/dist/types/src/types/button.d.ts +187 -187
  16. package/dist/types/src/types/components.d.ts +210 -210
  17. package/dist/types/src/types/event.d.ts +63 -63
  18. package/dist/types/src/types/global.d.ts +25 -25
  19. package/dist/types/src/types/icon.d.ts +32 -32
  20. package/dist/types/src/types/inst.d.ts +24 -24
  21. package/dist/types/src/types/main.d.ts +111 -111
  22. package/dist/types/src/types/mask.d.ts +49 -49
  23. package/dist/types/src/types/position.d.ts +60 -60
  24. package/index.ts +3 -0
  25. package/package.json +4 -2
  26. package/src/Pops.ts +206 -0
  27. package/src/PopsAnimation.ts +32 -0
  28. package/src/PopsCSS.ts +51 -0
  29. package/src/PopsCore.ts +64 -0
  30. package/src/PopsIcon.ts +95 -0
  31. package/src/PopsInst.ts +21 -0
  32. package/src/components/alert/config.ts +62 -0
  33. package/src/components/alert/index.css +0 -0
  34. package/src/components/alert/index.ts +163 -0
  35. package/src/components/alert/types/index.ts +23 -0
  36. package/src/components/confirm/config.ts +90 -0
  37. package/src/components/confirm/index.css +0 -0
  38. package/src/components/confirm/index.ts +166 -0
  39. package/src/components/confirm/types/index.ts +17 -0
  40. package/src/components/drawer/config.ts +89 -0
  41. package/src/components/drawer/index.css +37 -0
  42. package/src/components/drawer/index.ts +237 -0
  43. package/src/components/drawer/types/index.ts +61 -0
  44. package/src/components/folder/config.ts +147 -0
  45. package/src/components/folder/folderIcon.ts +28 -0
  46. package/src/components/folder/index.css +303 -0
  47. package/src/components/folder/index.ts +929 -0
  48. package/src/components/folder/types/index.ts +97 -0
  49. package/src/components/iframe/config.ts +60 -0
  50. package/src/components/iframe/index.css +76 -0
  51. package/src/components/iframe/index.ts +334 -0
  52. package/src/components/iframe/types/index.ts +139 -0
  53. package/src/components/loading/config.ts +29 -0
  54. package/src/components/loading/index.css +66 -0
  55. package/src/components/loading/index.ts +99 -0
  56. package/src/components/loading/types/index.ts +34 -0
  57. package/src/components/panel/config.ts +519 -0
  58. package/src/components/panel/handlerComponents.ts +2900 -0
  59. package/src/components/panel/index.css +1222 -0
  60. package/src/components/panel/index.ts +207 -0
  61. package/src/components/panel/types/components-button.ts +68 -0
  62. package/src/components/panel/types/components-common.ts +50 -0
  63. package/src/components/panel/types/components-deepMenu.ts +84 -0
  64. package/src/components/panel/types/components-forms.ts +44 -0
  65. package/src/components/panel/types/components-input.ts +78 -0
  66. package/src/components/panel/types/components-own.ts +30 -0
  67. package/src/components/panel/types/components-select.ts +93 -0
  68. package/src/components/panel/types/components-selectMultiple.ts +130 -0
  69. package/src/components/panel/types/components-slider.ts +77 -0
  70. package/src/components/panel/types/components-switch.ts +56 -0
  71. package/src/components/panel/types/components-textarea.ts +68 -0
  72. package/src/components/panel/types/index.ts +177 -0
  73. package/src/components/prompt/config.ts +94 -0
  74. package/src/components/prompt/index.css +34 -0
  75. package/src/components/prompt/index.ts +216 -0
  76. package/src/components/prompt/types/index.ts +55 -0
  77. package/src/components/rightClickMenu/config.ts +98 -0
  78. package/src/components/rightClickMenu/index.css +112 -0
  79. package/src/components/rightClickMenu/index.ts +602 -0
  80. package/src/components/rightClickMenu/types/index.ts +97 -0
  81. package/src/components/searchSuggestion/config.ts +56 -0
  82. package/src/components/searchSuggestion/index.ts +856 -0
  83. package/src/components/searchSuggestion/types/index.ts +239 -0
  84. package/src/components/tooltip/config.ts +34 -0
  85. package/src/components/tooltip/index.css +199 -0
  86. package/src/components/tooltip/index.ts +604 -0
  87. package/src/components/tooltip/types/index.ts +117 -0
  88. package/src/config/CommonCSSClassName.ts +17 -0
  89. package/src/config/GlobalConfig.ts +63 -0
  90. package/src/css/animation.css +987 -0
  91. package/src/css/button.css +551 -0
  92. package/src/css/common.css +48 -0
  93. package/src/css/index.css +253 -0
  94. package/src/css/ninePalaceGridPosition.css +50 -0
  95. package/src/css/scrollbar.css +22 -0
  96. package/src/handler/PopsElementHandler.ts +304 -0
  97. package/src/handler/PopsHandler.ts +589 -0
  98. package/src/svg/arrowLeft.svg +4 -0
  99. package/src/svg/arrowRight.svg +4 -0
  100. package/src/svg/chromeFilled.svg +11 -0
  101. package/src/svg/circleClose.svg +8 -0
  102. package/src/svg/close.svg +5 -0
  103. package/src/svg/cpu.svg +8 -0
  104. package/src/svg/delete.svg +5 -0
  105. package/src/svg/documentCopy.svg +5 -0
  106. package/src/svg/edit.svg +8 -0
  107. package/src/svg/eleme.svg +5 -0
  108. package/src/svg/elemePlus.svg +5 -0
  109. package/src/svg/headset.svg +5 -0
  110. package/src/svg/hide.svg +8 -0
  111. package/src/svg/keyboard.svg +8 -0
  112. package/src/svg/loading.svg +5 -0
  113. package/src/svg/max.svg +5 -0
  114. package/src/svg/min.svg +5 -0
  115. package/src/svg/mise.svg +5 -0
  116. package/src/svg/monitor.svg +5 -0
  117. package/src/svg/next.svg +5 -0
  118. package/src/svg/picture.svg +8 -0
  119. package/src/svg/prev.svg +5 -0
  120. package/src/svg/search.svg +5 -0
  121. package/src/svg/share.svg +5 -0
  122. package/src/svg/upload.svg +5 -0
  123. package/src/svg/videoPause.svg +5 -0
  124. package/src/svg/videoPlay.svg +5 -0
  125. package/src/svg/view.svg +5 -0
  126. package/src/types/PopsDOMUtilsEventType.d.ts +252 -0
  127. package/src/types/animation.d.ts +19 -0
  128. package/src/types/button.d.ts +187 -0
  129. package/src/types/components.d.ts +210 -0
  130. package/src/types/event.d.ts +63 -0
  131. package/src/types/global.d.ts +25 -0
  132. package/src/types/icon.d.ts +32 -0
  133. package/src/types/inst.d.ts +24 -0
  134. package/src/types/main.d.ts +111 -0
  135. package/src/types/mask.d.ts +49 -0
  136. package/src/types/position.d.ts +60 -0
  137. package/src/utils/PopsDOMUtils.ts +2408 -0
  138. package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -0
  139. package/src/utils/PopsInstanceUtils.ts +688 -0
  140. package/src/utils/PopsMathUtils.ts +71 -0
  141. package/src/utils/PopsSafeUtils.ts +22 -0
  142. package/src/utils/PopsUtils.ts +406 -0
@@ -0,0 +1,23 @@
1
+ import type {
2
+ PopsTitleConfig,
3
+ PopsContentConfig,
4
+ PopsDragConfig,
5
+ PopsCommonConfig,
6
+ PopsButtonConfig,
7
+ } from "../../../types/components";
8
+ import type { PopsButtonDetails, PopsButtonDetailsAnyType } from "../../../types/button";
9
+
10
+ /**
11
+ * pops.alert
12
+ */
13
+ export interface PopsAlertDetails extends PopsTitleConfig, PopsContentConfig, PopsDragConfig, PopsCommonConfig {
14
+ /**
15
+ * 按钮配置
16
+ */
17
+ btn?: Partial<PopsButtonConfig["btn"]> & {
18
+ /**
19
+ * 确定按钮
20
+ */
21
+ ok?: Partial<PopsButtonDetails | PopsButtonDetailsAnyType>;
22
+ };
23
+ }
@@ -0,0 +1,90 @@
1
+ import type { PopsConfirmDetails } from "./types";
2
+
3
+ export const PopsConfirmConfig = (): DeepRequired<PopsConfirmDetails> => {
4
+ return {
5
+ title: {
6
+ text: "默认标题",
7
+ position: "left",
8
+ html: false,
9
+ style: "",
10
+ },
11
+ content: {
12
+ text: "默认内容",
13
+ html: false,
14
+ style: "",
15
+ },
16
+ btn: {
17
+ merge: false,
18
+ mergeReverse: false,
19
+ reverse: false,
20
+ position: "flex-end",
21
+ ok: {
22
+ enable: true,
23
+ size: void 0 as any,
24
+ icon: void 0 as any,
25
+ rightIcon: false,
26
+ iconIsLoading: false,
27
+ text: "确定",
28
+ type: "primary",
29
+ callback(detail: any) {
30
+ detail.close();
31
+ },
32
+ },
33
+ cancel: {
34
+ enable: true,
35
+ size: void 0 as any,
36
+ icon: void 0 as any,
37
+ rightIcon: false,
38
+ iconIsLoading: false,
39
+ text: "关闭",
40
+ type: "default",
41
+ callback(detail: any) {
42
+ detail.close();
43
+ },
44
+ },
45
+ other: {
46
+ enable: false,
47
+ size: void 0 as any,
48
+ icon: void 0 as any,
49
+ rightIcon: false,
50
+ iconIsLoading: false,
51
+ text: "其它按钮",
52
+ type: "default",
53
+ callback(detail: any) {
54
+ detail.close();
55
+ },
56
+ },
57
+ close: {
58
+ enable: true,
59
+ callback(detail: any) {
60
+ detail.close();
61
+ },
62
+ },
63
+ },
64
+ useShadowRoot: true,
65
+ class: "",
66
+ only: false,
67
+ width: window.innerWidth < 550 ? "88vw" : "350px",
68
+ height: window.innerHeight < 450 ? "70vh" : "200px",
69
+ position: "center",
70
+ animation: "pops-anim-fadein-zoom",
71
+ zIndex: 10000,
72
+ mask: {
73
+ enable: false,
74
+ clickEvent: {
75
+ toClose: false,
76
+ toHide: false,
77
+ },
78
+ clickCallBack: null,
79
+ },
80
+ drag: false,
81
+ dragLimit: true,
82
+ dragExtraDistance: 3,
83
+ dragMoveCallBack() {},
84
+ dragEndCallBack() {},
85
+ forbiddenScroll: false,
86
+
87
+ style: null,
88
+ beforeAppendToPageCallBack() {},
89
+ } as DeepRequired<PopsConfirmDetails>;
90
+ };
File without changes
@@ -0,0 +1,166 @@
1
+ import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
+ import { PopsHandler } from "../../handler/PopsHandler";
4
+ import { PopsCSS } from "../../PopsCSS";
5
+ import type { PopsType } from "../../types/main";
6
+ import { popsDOMUtils } from "../../utils/PopsDOMUtils";
7
+ import { PopsInstanceUtils } from "../../utils/PopsInstanceUtils";
8
+ import { popsUtils } from "../../utils/PopsUtils";
9
+ import { PopsConfirmConfig } from "./config";
10
+ import type { PopsConfirmDetails } from "./types";
11
+
12
+ export const PopsConfirm = {
13
+ init(details: PopsConfirmDetails) {
14
+ const guid = popsUtils.getRandomGUID();
15
+ // 设置当前类型
16
+ const popsType: PopsType = "confirm";
17
+ let config = PopsConfirmConfig();
18
+ config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
19
+ config = popsUtils.assign(config, details);
20
+ config = PopsHandler.handleOnly(popsType, config);
21
+
22
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
23
+ PopsHandler.handleInit($shadowRoot, [
24
+ {
25
+ name: "index",
26
+ css: PopsCSS.index,
27
+ },
28
+ {
29
+ name: "ninePalaceGridPosition",
30
+ css: PopsCSS.ninePalaceGridPosition,
31
+ },
32
+ {
33
+ name: "scrollbar",
34
+ css: PopsCSS.scrollbar,
35
+ },
36
+ {
37
+ name: "button",
38
+ css: PopsCSS.button,
39
+ },
40
+ {
41
+ name: "anim",
42
+ css: PopsCSS.anim,
43
+ },
44
+ {
45
+ name: "common",
46
+ css: PopsCSS.common,
47
+ },
48
+ {
49
+ name: "confirmCSS",
50
+ css: PopsCSS.confirmCSS,
51
+ },
52
+ ]);
53
+
54
+ // 先把z-index提取出来
55
+ const zIndex = PopsHandler.handleZIndex(config.zIndex);
56
+ const maskHTML = PopsElementHandler.createMask(guid, zIndex);
57
+
58
+ const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
59
+ const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
60
+ const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
61
+ const { contentStyle, contentPStyle } = PopsElementHandler.createContentStyle(popsType, config);
62
+ const animHTML = PopsElementHandler.createAnim(
63
+ guid,
64
+ popsType,
65
+ config,
66
+ /*html*/ `
67
+ <div class="pops-title pops-${popsType}-title" style="text-align: ${
68
+ config.title.position
69
+ };${headerStyle}">${
70
+ config.title.html
71
+ ? config.title.text
72
+ : `<p pops class="pops-${popsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
73
+ }${headerBtnHTML}</div>
74
+ <div class="pops-content pops-${popsType}-content" style="${contentStyle}">${
75
+ config.content.html
76
+ ? config.content.text
77
+ : `<p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>`
78
+ }</div>${bottomBtnHTML}`,
79
+ bottomBtnHTML,
80
+ zIndex
81
+ );
82
+ /**
83
+ * 弹窗的主元素,包括动画层
84
+ */
85
+ const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
86
+ const {
87
+ popsElement: $pops,
88
+ titleElement: $title,
89
+ headerCloseBtnElement: $btnClose,
90
+ btnOkElement: $btnOk,
91
+ btnCancelElement: $btnCancel,
92
+ btnOtherElement: $btnOther,
93
+ } = PopsHandler.handleQueryElement($anim, popsType);
94
+ /**
95
+ * 遮罩层元素
96
+ */
97
+ let $mask: HTMLDivElement | null = null;
98
+ /**
99
+ * 已创建的元素列表
100
+ */
101
+ const elementList: HTMLElement[] = [$anim];
102
+
103
+ if (config.mask.enable) {
104
+ // 启用遮罩层
105
+ const _handleMask_ = PopsHandler.handleMask({
106
+ type: popsType,
107
+ guid: guid,
108
+ config: config,
109
+ animElement: $anim,
110
+ maskHTML: maskHTML,
111
+ });
112
+ $mask = _handleMask_.maskElement;
113
+ elementList.push($mask);
114
+ }
115
+ const eventDetails = PopsHandler.handleEventDetails(
116
+ guid,
117
+ $shadowContainer,
118
+ $shadowRoot,
119
+ popsType,
120
+
121
+ $anim,
122
+ $pops!,
123
+ $mask!,
124
+ config
125
+ );
126
+ PopsHandler.handleClickEvent("close", $btnClose!, eventDetails, config.btn.close!.callback!);
127
+ PopsHandler.handleClickEvent("ok", $btnOk!, eventDetails!, config.btn.ok!.callback!);
128
+ PopsHandler.handleClickEvent("cancel", $btnCancel!, eventDetails, config.btn.cancel!.callback!);
129
+ PopsHandler.handleClickEvent("other", $btnOther!, eventDetails, config.btn.other!.callback!);
130
+
131
+ /* 创建到页面中 */
132
+
133
+ popsDOMUtils.append($shadowRoot, elementList);
134
+ if (typeof config.beforeAppendToPageCallBack === "function") {
135
+ config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
136
+ }
137
+
138
+ popsDOMUtils.appendBody($shadowContainer);
139
+ if ($mask != null) {
140
+ $anim.after($mask);
141
+ }
142
+ PopsHandler.handlePush(popsType, {
143
+ guid: guid,
144
+
145
+ animElement: $anim,
146
+
147
+ popsElement: $pops!,
148
+
149
+ maskElement: $mask!,
150
+ $shadowContainer: $shadowContainer,
151
+ $shadowRoot: $shadowRoot,
152
+ });
153
+ /* 拖拽 */
154
+ if (config.drag) {
155
+ PopsInstanceUtils.drag($pops!, {
156
+ dragElement: $title!,
157
+ limit: config.dragLimit,
158
+ extraDistance: config.dragExtraDistance,
159
+ moveCallBack: config.dragMoveCallBack,
160
+ endCallBack: config.dragEndCallBack,
161
+ });
162
+ }
163
+ const result = PopsHandler.handleResultDetails(eventDetails);
164
+ return result;
165
+ },
166
+ };
@@ -0,0 +1,17 @@
1
+ import type {
2
+ PopsTitleConfig,
3
+ PopsContentConfig,
4
+ PopsDragConfig,
5
+ PopsCommonConfig,
6
+ PopsMoreButtonConfig,
7
+ } from "../../../types/components";
8
+
9
+ /**
10
+ * pops.confirm
11
+ */
12
+ export interface PopsConfirmDetails
13
+ extends PopsTitleConfig,
14
+ PopsContentConfig,
15
+ PopsMoreButtonConfig,
16
+ PopsDragConfig,
17
+ PopsCommonConfig {}
@@ -0,0 +1,89 @@
1
+ import type { PopsDrawerDetails } from "./types";
2
+
3
+ export const PopsDrawerConfig = (): DeepRequired<PopsDrawerDetails> => {
4
+ return {
5
+ title: {
6
+ enable: true,
7
+ position: "center",
8
+ text: "默认标题",
9
+ html: false,
10
+ style: "",
11
+ },
12
+ content: {
13
+ text: "默认内容",
14
+ html: false,
15
+ style: "",
16
+ },
17
+ btn: {
18
+ merge: false,
19
+ mergeReverse: false,
20
+ reverse: false,
21
+ position: "flex-end",
22
+ ok: {
23
+ enable: true,
24
+ size: void 0 as any,
25
+ icon: void 0 as any,
26
+ rightIcon: false,
27
+ iconIsLoading: false,
28
+ text: "确定",
29
+ type: "primary",
30
+ callback(detail: any) {
31
+ detail.close();
32
+ },
33
+ },
34
+ cancel: {
35
+ enable: true,
36
+ size: void 0 as any,
37
+ icon: void 0 as any,
38
+ rightIcon: false,
39
+ iconIsLoading: false,
40
+ text: "关闭",
41
+ type: "default",
42
+ callback(detail: any) {
43
+ detail.close();
44
+ },
45
+ },
46
+ other: {
47
+ enable: false,
48
+ size: void 0 as any,
49
+ icon: void 0 as any,
50
+ rightIcon: false,
51
+ iconIsLoading: false,
52
+ text: "其它按钮",
53
+ type: "default",
54
+ callback(detail: any) {
55
+ detail.close();
56
+ },
57
+ },
58
+ close: {
59
+ enable: true,
60
+ callback(detail: any) {
61
+ detail.close();
62
+ },
63
+ },
64
+ },
65
+ mask: {
66
+ enable: true,
67
+ clickEvent: {
68
+ toClose: true,
69
+ toHide: false,
70
+ },
71
+ clickCallBack: null,
72
+ },
73
+ useShadowRoot: true,
74
+ class: "",
75
+ zIndex: 10000,
76
+ only: false,
77
+ direction: "right",
78
+ size: "30%",
79
+ lockScroll: false,
80
+ closeOnPressEscape: true,
81
+ openDelay: 0,
82
+ closeDelay: 0,
83
+ borderRadius: 0,
84
+
85
+ style: null,
86
+ beforeAppendToPageCallBack() {},
87
+ forbiddenScroll: false,
88
+ };
89
+ };
@@ -0,0 +1,37 @@
1
+ .pops[type-value="drawer"] {
2
+ position: fixed;
3
+ box-sizing: border-box;
4
+ display: flex;
5
+ flex-direction: column;
6
+ box-shadow:
7
+ 0px 16px 48px 16px rgba(0, 0, 0, 0.08),
8
+ 0px 12px 32px rgba(0, 0, 0, 0.12),
9
+ 0px 8px 16px -8px rgba(0, 0, 0, 0.16);
10
+ overflow: hidden;
11
+ transition: all 0.3s;
12
+ }
13
+
14
+ .pops[type-value="drawer"][direction="top"] {
15
+ width: 100%;
16
+ left: 0;
17
+ right: 0;
18
+ top: 0;
19
+ }
20
+ .pops[type-value="drawer"][direction="bottom"] {
21
+ width: 100%;
22
+ left: 0;
23
+ right: 0;
24
+ bottom: 0;
25
+ }
26
+ .pops[type-value="drawer"][direction="left"] {
27
+ height: 100%;
28
+ top: 0;
29
+ bottom: 0;
30
+ left: 0;
31
+ }
32
+ .pops[type-value="drawer"][direction="right"] {
33
+ height: 100%;
34
+ top: 0;
35
+ bottom: 0;
36
+ right: 0;
37
+ }
@@ -0,0 +1,237 @@
1
+ import { GlobalConfig } from "../../config/GlobalConfig";
2
+ import { PopsElementHandler } from "../../handler/PopsElementHandler";
3
+ import { PopsHandler } from "../../handler/PopsHandler";
4
+ import { PopsCSS } from "../../PopsCSS";
5
+ import type { PopsType } from "../../types/main";
6
+ import { popsDOMUtils } from "../../utils/PopsDOMUtils";
7
+ import { popsUtils } from "../../utils/PopsUtils";
8
+ import { PopsDrawerConfig } from "./config";
9
+ import type { PopsDrawerDetails } from "./types";
10
+
11
+ export const PopsDrawer = {
12
+ init(details: PopsDrawerDetails) {
13
+ const guid = popsUtils.getRandomGUID();
14
+ // 设置当前类型
15
+ const popsType: PopsType = "drawer";
16
+ let config = PopsDrawerConfig();
17
+ config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
18
+ config = popsUtils.assign(config, details);
19
+ config = PopsHandler.handleOnly(popsType, config);
20
+
21
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
22
+ PopsHandler.handleInit($shadowRoot, [
23
+ {
24
+ name: "index",
25
+ css: PopsCSS.index,
26
+ },
27
+ {
28
+ name: "ninePalaceGridPosition",
29
+ css: PopsCSS.ninePalaceGridPosition,
30
+ },
31
+ {
32
+ name: "scrollbar",
33
+ css: PopsCSS.scrollbar,
34
+ },
35
+ {
36
+ name: "button",
37
+ css: PopsCSS.button,
38
+ },
39
+ {
40
+ name: "anim",
41
+ css: PopsCSS.anim,
42
+ },
43
+ {
44
+ name: "common",
45
+ css: PopsCSS.common,
46
+ },
47
+ {
48
+ name: "drawerCSS",
49
+ css: PopsCSS.drawerCSS,
50
+ },
51
+ ]);
52
+
53
+ // 先把z-index提取出来
54
+ const zIndex = PopsHandler.handleZIndex(config.zIndex);
55
+ const maskHTML = PopsElementHandler.createMask(guid, zIndex);
56
+
57
+ const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
58
+ const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
59
+ const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
60
+ const { contentStyle, contentPStyle } = PopsElementHandler.createContentStyle(popsType, config);
61
+ const animHTML = PopsElementHandler.createAnim(
62
+ guid,
63
+ popsType,
64
+ config,
65
+ /*html*/ `
66
+ ${
67
+ config.title.enable
68
+ ? /*html*/ `<div class="pops-title pops-${popsType}-title" style="${headerStyle}">${
69
+ config.title.html
70
+ ? config.title.text
71
+ : /*html*/ `<p pops class="pops-${popsType}-title-text" style="width: 100%;text-align: ${config.title.position};${headerPStyle}">${config.title.text}</p>`
72
+ }${headerBtnHTML}</div>`
73
+ : ""
74
+ }
75
+ <div class="pops-content pops-${popsType}-content" style="${contentStyle}">${
76
+ config.content.html
77
+ ? config.content.text
78
+ : `<p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>`
79
+ }</div>${bottomBtnHTML}`,
80
+ bottomBtnHTML,
81
+ zIndex
82
+ );
83
+ /**
84
+ * 弹窗的主元素,包括动画层
85
+ */
86
+ const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
87
+ const { popsElement, headerCloseBtnElement, btnCancelElement, btnOkElement, btnOtherElement } =
88
+ PopsHandler.handleQueryElement($anim, popsType);
89
+ const $pops = popsElement!;
90
+ const $headerCloseBtn = headerCloseBtnElement!;
91
+ const $btnCancel = btnCancelElement!;
92
+ const $btnOk = btnOkElement!;
93
+ const $btnOther = btnOtherElement!;
94
+ /**
95
+ * 遮罩层元素
96
+ */
97
+ let $mask: HTMLDivElement | null = null;
98
+ /**
99
+ * 已创建的元素列表
100
+ */
101
+ const elementList: HTMLElement[] = [$anim];
102
+
103
+ if (config.mask.enable) {
104
+ const _handleMask_ = PopsHandler.handleMask({
105
+ type: popsType,
106
+ guid: guid,
107
+ config: config,
108
+ animElement: $anim,
109
+ maskHTML: maskHTML,
110
+ });
111
+ $mask = _handleMask_.maskElement;
112
+ elementList.push($mask);
113
+ }
114
+ const eventDetails = PopsHandler.handleEventDetails(
115
+ guid,
116
+ $shadowContainer,
117
+ $shadowRoot,
118
+ popsType,
119
+ $anim,
120
+ $pops,
121
+ $mask!,
122
+ config
123
+ );
124
+ /* 处理方向 */
125
+
126
+ $pops.setAttribute("direction", config.direction);
127
+
128
+ /* 处理border-radius */
129
+ /* 处理动画前的宽高 */
130
+ if (config.direction === "top") {
131
+ $pops.style.setProperty("height", "0");
132
+
133
+ $pops.style.setProperty("border-radius", `0px 0px ${config.borderRadius}px ${config.borderRadius}px`);
134
+ } else if (config.direction === "bottom") {
135
+ $pops.style.setProperty("height", "0");
136
+
137
+ $pops.style.setProperty("border-radius", `${config.borderRadius}px ${config.borderRadius}px 0px 0px`);
138
+ } else if (config.direction === "left") {
139
+ $pops.style.setProperty("width", "0");
140
+
141
+ $pops.style.setProperty("border-radius", `0px ${config.borderRadius}px 0px ${config.borderRadius}px`);
142
+ } else if (config.direction === "right") {
143
+ $pops.style.setProperty("width", "0");
144
+
145
+ $pops.style.setProperty("border-radius", `${config.borderRadius}px 0px ${config.borderRadius}px 0px`);
146
+ }
147
+
148
+ /* 按下Esc键触发关闭 */
149
+ if (config.closeOnPressEscape) {
150
+ PopsHandler.handleKeyboardEvent("Escape", [], function () {
151
+ eventDetails.close();
152
+ });
153
+ }
154
+ /* 待处理的点击事件列表 */
155
+ const needHandleClickEventList = [
156
+ {
157
+ type: "close",
158
+ ele: $headerCloseBtn,
159
+ },
160
+ {
161
+ type: "cancel",
162
+ ele: $btnCancel,
163
+ },
164
+ {
165
+ type: "ok",
166
+ ele: $btnOk,
167
+ },
168
+ {
169
+ type: "other",
170
+ ele: $btnOther,
171
+ },
172
+ ];
173
+ needHandleClickEventList.forEach((item) => {
174
+ PopsHandler.handleClickEvent(
175
+ item.type as "close" | "cancel" | "ok" | "other",
176
+ item.ele,
177
+ eventDetails,
178
+ (_eventDetails_) => {
179
+ if (typeof (config.btn as any)[item.type].callback === "function") {
180
+ (config.btn as any)[item.type].callback(_eventDetails_);
181
+ }
182
+ }
183
+ );
184
+ });
185
+
186
+ /* 先隐藏,然后根据config.openDelay来显示 */
187
+ elementList.forEach((element) => {
188
+ element.style.setProperty("display", "none");
189
+ if (["top"].includes(config.direction)) {
190
+ $pops.style.setProperty("height", config.size.toString());
191
+
192
+ $pops.style.setProperty("transform", "translateY(-100%)");
193
+ } else if (["bottom"].includes(config.direction)) {
194
+ $pops.style.setProperty("height", config.size.toString());
195
+
196
+ $pops.style.setProperty("transform", "translateY(100%)");
197
+ } else if (["left"].includes(config.direction)) {
198
+ $pops.style.setProperty("width", config.size.toString());
199
+
200
+ $pops.style.setProperty("transform", "translateX(-100%)");
201
+ } else if (["right"].includes(config.direction)) {
202
+ $pops.style.setProperty("width", config.size.toString());
203
+
204
+ $pops.style.setProperty("transform", "translateX(100%)");
205
+ }
206
+ element.style.setProperty("display", "");
207
+ });
208
+ /* 创建到页面中 */
209
+
210
+ popsDOMUtils.append($shadowRoot, elementList);
211
+ if (typeof config.beforeAppendToPageCallBack === "function") {
212
+ config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
213
+ }
214
+
215
+ popsDOMUtils.appendBody($shadowContainer);
216
+ popsUtils.setTimeout(() => {
217
+ popsUtils.setTimeout(() => {
218
+ $pops.style.setProperty("transform", "");
219
+ }, config.openDelay);
220
+ }, 50);
221
+
222
+ if ($mask != null) {
223
+ $anim.after($mask);
224
+ }
225
+
226
+ PopsHandler.handlePush(popsType, {
227
+ guid: guid,
228
+ animElement: $anim,
229
+ popsElement: $pops,
230
+ maskElement: $mask!,
231
+ $shadowContainer: $shadowContainer,
232
+ $shadowRoot: $shadowRoot,
233
+ });
234
+ const result = PopsHandler.handleResultDetails(eventDetails);
235
+ return result;
236
+ },
237
+ };