@whitesev/pops 3.2.1 → 3.3.0

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 (127) hide show
  1. package/README.md +249 -249
  2. package/dist/index.amd.js +736 -948
  3. package/dist/index.amd.js.map +1 -1
  4. package/dist/index.amd.min.js +1 -1
  5. package/dist/index.amd.min.js.map +1 -1
  6. package/dist/index.cjs.js +736 -948
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.cjs.min.js +1 -1
  9. package/dist/index.cjs.min.js.map +1 -1
  10. package/dist/index.esm.js +736 -948
  11. package/dist/index.esm.js.map +1 -1
  12. package/dist/index.esm.min.js +1 -1
  13. package/dist/index.esm.min.js.map +1 -1
  14. package/dist/index.iife.js +736 -948
  15. package/dist/index.iife.js.map +1 -1
  16. package/dist/index.iife.min.js +1 -1
  17. package/dist/index.iife.min.js.map +1 -1
  18. package/dist/index.system.js +736 -948
  19. package/dist/index.system.js.map +1 -1
  20. package/dist/index.system.min.js +1 -1
  21. package/dist/index.system.min.js.map +1 -1
  22. package/dist/index.umd.js +736 -948
  23. package/dist/index.umd.js.map +1 -1
  24. package/dist/index.umd.min.js +1 -1
  25. package/dist/index.umd.min.js.map +1 -1
  26. package/dist/types/src/PopsCore.d.ts +15 -7
  27. package/dist/types/src/components/folder/types/index.d.ts +43 -13
  28. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +313 -313
  29. package/dist/types/src/types/animation.d.ts +19 -19
  30. package/dist/types/src/types/button.d.ts +94 -94
  31. package/dist/types/src/types/components.d.ts +211 -211
  32. package/dist/types/src/types/event.d.ts +43 -43
  33. package/dist/types/src/types/global.d.ts +31 -31
  34. package/dist/types/src/types/icon.d.ts +32 -32
  35. package/dist/types/src/types/inst.d.ts +28 -28
  36. package/dist/types/src/types/main.d.ts +66 -66
  37. package/dist/types/src/types/mask.d.ts +52 -52
  38. package/dist/types/src/types/position.d.ts +60 -60
  39. package/package.json +28 -27
  40. package/src/Pops.ts +206 -206
  41. package/src/PopsAnimation.ts +32 -32
  42. package/src/PopsCSS.ts +54 -54
  43. package/src/PopsCore.ts +53 -37
  44. package/src/PopsIcon.ts +95 -95
  45. package/src/PopsInst.ts +21 -21
  46. package/src/components/alert/defaultConfig.ts +62 -62
  47. package/src/components/alert/index.ts +163 -163
  48. package/src/components/alert/types/index.ts +23 -23
  49. package/src/components/confirm/defaultConfig.ts +90 -90
  50. package/src/components/confirm/index.ts +165 -165
  51. package/src/components/confirm/types/index.ts +13 -17
  52. package/src/components/drawer/defaultConfig.ts +89 -89
  53. package/src/components/drawer/index.css +37 -37
  54. package/src/components/drawer/index.ts +245 -245
  55. package/src/components/drawer/types/index.ts +62 -61
  56. package/src/components/folder/defaultConfig.ts +151 -151
  57. package/src/components/folder/folderIcon.ts +28 -28
  58. package/src/components/folder/index.css +303 -303
  59. package/src/components/folder/index.ts +953 -932
  60. package/src/components/folder/types/index.ts +143 -110
  61. package/src/components/iframe/defaultConfig.ts +60 -60
  62. package/src/components/iframe/index.css +76 -76
  63. package/src/components/iframe/index.ts +331 -331
  64. package/src/components/iframe/types/index.ts +96 -96
  65. package/src/components/loading/defaultConfig.ts +29 -29
  66. package/src/components/loading/index.css +66 -66
  67. package/src/components/loading/index.ts +101 -101
  68. package/src/components/loading/types/index.ts +36 -34
  69. package/src/components/panel/css/components-select.css +84 -84
  70. package/src/components/panel/defaultConfig.ts +868 -868
  71. package/src/components/panel/handlerComponents.ts +3993 -3993
  72. package/src/components/panel/index.css +1403 -1403
  73. package/src/components/panel/index.ts +221 -221
  74. package/src/components/panel/types/components-button.ts +56 -56
  75. package/src/components/panel/types/components-common.ts +73 -73
  76. package/src/components/panel/types/components-container.ts +25 -25
  77. package/src/components/panel/types/components-deepMenu.ts +64 -64
  78. package/src/components/panel/types/components-input.ts +90 -90
  79. package/src/components/panel/types/components-own.ts +16 -16
  80. package/src/components/panel/types/components-select.ts +169 -169
  81. package/src/components/panel/types/components-selectMultiple.ts +105 -104
  82. package/src/components/panel/types/components-slider.ts +55 -55
  83. package/src/components/panel/types/components-switch.ts +33 -33
  84. package/src/components/panel/types/components-textarea.ts +45 -45
  85. package/src/components/panel/types/index.ts +244 -244
  86. package/src/components/prompt/defaultConfig.ts +94 -94
  87. package/src/components/prompt/index.css +34 -34
  88. package/src/components/prompt/index.ts +187 -215
  89. package/src/components/prompt/types/index.ts +57 -56
  90. package/src/components/rightClickMenu/defaultConfig.ts +103 -103
  91. package/src/components/rightClickMenu/index.css +115 -115
  92. package/src/components/rightClickMenu/index.ts +662 -662
  93. package/src/components/rightClickMenu/types/index.ts +145 -143
  94. package/src/components/searchSuggestion/defaultConfig.ts +63 -63
  95. package/src/components/searchSuggestion/index.ts +813 -813
  96. package/src/components/searchSuggestion/types/index.ts +244 -242
  97. package/src/components/tooltip/defaultConfig.ts +33 -33
  98. package/src/components/tooltip/index.css +199 -199
  99. package/src/components/tooltip/index.ts +617 -617
  100. package/src/components/tooltip/types/index.ts +123 -121
  101. package/src/config/CommonCSSClassName.ts +17 -17
  102. package/src/config/GlobalConfig.ts +63 -63
  103. package/src/css/animation.css +987 -987
  104. package/src/css/button.css +551 -551
  105. package/src/css/common.css +54 -54
  106. package/src/css/index.css +253 -253
  107. package/src/css/ninePalaceGridPosition.css +50 -50
  108. package/src/css/scrollbar.css +22 -22
  109. package/src/handler/PopsElementHandler.ts +303 -303
  110. package/src/handler/PopsHandler.ts +611 -611
  111. package/src/types/PopsDOMUtilsEventType.d.ts +313 -313
  112. package/src/types/animation.d.ts +19 -19
  113. package/src/types/button.d.ts +94 -94
  114. package/src/types/components.d.ts +211 -211
  115. package/src/types/event.d.ts +43 -43
  116. package/src/types/global.d.ts +31 -31
  117. package/src/types/icon.d.ts +32 -32
  118. package/src/types/inst.d.ts +28 -28
  119. package/src/types/main.d.ts +66 -66
  120. package/src/types/mask.d.ts +52 -52
  121. package/src/types/position.d.ts +60 -60
  122. package/src/utils/PopsDOMUtils.ts +2483 -2483
  123. package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -4
  124. package/src/utils/PopsInstanceUtils.ts +714 -714
  125. package/src/utils/PopsMathUtils.ts +71 -71
  126. package/src/utils/PopsSafeUtils.ts +22 -22
  127. package/src/utils/PopsUtils.ts +391 -421
@@ -1,94 +1,94 @@
1
- import type { PopsPromptConfig } from "./types/index";
2
-
3
- export const PopsPromptDefaultConfig = (): DeepRequired<PopsPromptConfig> => {
4
- return {
5
- title: {
6
- text: "默认标题",
7
- position: "left",
8
- html: false,
9
- style: "",
10
- },
11
- content: {
12
- text: "",
13
- select: false,
14
- password: false,
15
- row: false,
16
- focus: true,
17
- placeholder: "默认提示",
18
- style: "",
19
- },
20
- btn: {
21
- merge: false,
22
- mergeReverse: false,
23
- reverse: false,
24
- position: "flex-end",
25
- ok: {
26
- enable: true,
27
- size: void 0 as any,
28
- icon: void 0 as any,
29
- rightIcon: false,
30
- iconIsLoading: false,
31
- text: "确定",
32
- type: "success",
33
- callback(eventConfig) {
34
- eventConfig.close();
35
- },
36
- },
37
- cancel: {
38
- enable: true,
39
- size: void 0 as any,
40
- icon: void 0 as any,
41
- rightIcon: false,
42
- iconIsLoading: false,
43
- text: "关闭",
44
- type: "default",
45
- callback(eventConfig) {
46
- eventConfig.close();
47
- },
48
- },
49
- other: {
50
- enable: false,
51
- size: void 0 as any,
52
- icon: void 0 as any,
53
- rightIcon: false,
54
- iconIsLoading: false,
55
- text: "其它按钮",
56
- type: "default",
57
- callback(eventConfig) {
58
- eventConfig.close();
59
- },
60
- },
61
- close: {
62
- enable: true,
63
- callback(eventConfig) {
64
- eventConfig.close();
65
- },
66
- },
67
- },
68
- useShadowRoot: true,
69
- class: "",
70
- only: false,
71
- width: window.innerWidth < 550 ? "88vw" : "350px",
72
- height: window.innerHeight < 450 ? "70vh" : "200px",
73
- position: "center",
74
- animation: "pops-anim-fadein-zoom",
75
- zIndex: 10000,
76
- mask: {
77
- enable: false,
78
- clickEvent: {
79
- toClose: false,
80
- toHide: false,
81
- },
82
- clickCallBack: null,
83
- },
84
- drag: false,
85
- dragLimit: true,
86
- dragExtraDistance: 3,
87
- dragMoveCallBack() {},
88
- dragEndCallBack() {},
89
- forbiddenScroll: false,
90
-
91
- style: null,
92
- beforeAppendToPageCallBack() {},
93
- };
94
- };
1
+ import type { PopsPromptConfig } from "./types/index";
2
+
3
+ export const PopsPromptDefaultConfig = (): DeepRequired<PopsPromptConfig> => {
4
+ return {
5
+ title: {
6
+ text: "默认标题",
7
+ position: "left",
8
+ html: false,
9
+ style: "",
10
+ },
11
+ content: {
12
+ text: "",
13
+ select: false,
14
+ password: false,
15
+ row: false,
16
+ focus: true,
17
+ placeholder: "默认提示",
18
+ style: "",
19
+ },
20
+ btn: {
21
+ merge: false,
22
+ mergeReverse: false,
23
+ reverse: false,
24
+ position: "flex-end",
25
+ ok: {
26
+ enable: true,
27
+ size: void 0 as any,
28
+ icon: void 0 as any,
29
+ rightIcon: false,
30
+ iconIsLoading: false,
31
+ text: "确定",
32
+ type: "success",
33
+ callback(eventConfig) {
34
+ eventConfig.close();
35
+ },
36
+ },
37
+ cancel: {
38
+ enable: true,
39
+ size: void 0 as any,
40
+ icon: void 0 as any,
41
+ rightIcon: false,
42
+ iconIsLoading: false,
43
+ text: "关闭",
44
+ type: "default",
45
+ callback(eventConfig) {
46
+ eventConfig.close();
47
+ },
48
+ },
49
+ other: {
50
+ enable: false,
51
+ size: void 0 as any,
52
+ icon: void 0 as any,
53
+ rightIcon: false,
54
+ iconIsLoading: false,
55
+ text: "其它按钮",
56
+ type: "default",
57
+ callback(eventConfig) {
58
+ eventConfig.close();
59
+ },
60
+ },
61
+ close: {
62
+ enable: true,
63
+ callback(eventConfig) {
64
+ eventConfig.close();
65
+ },
66
+ },
67
+ },
68
+ useShadowRoot: true,
69
+ class: "",
70
+ only: false,
71
+ width: window.innerWidth < 550 ? "88vw" : "350px",
72
+ height: window.innerHeight < 450 ? "70vh" : "200px",
73
+ position: "center",
74
+ animation: "pops-anim-fadein-zoom",
75
+ zIndex: 10000,
76
+ mask: {
77
+ enable: false,
78
+ clickEvent: {
79
+ toClose: false,
80
+ toHide: false,
81
+ },
82
+ clickCallBack: null,
83
+ },
84
+ drag: false,
85
+ dragLimit: true,
86
+ dragExtraDistance: 3,
87
+ dragMoveCallBack() {},
88
+ dragEndCallBack() {},
89
+ forbiddenScroll: false,
90
+
91
+ style: null,
92
+ beforeAppendToPageCallBack() {},
93
+ };
94
+ };
@@ -1,34 +1,34 @@
1
- .pops[type-value="prompt"] {
2
- --input-color: #000000;
3
- --input-bg-color: none;
4
- --input-placeholder-color: #a1a4ac;
5
- }
6
- .pops[type-value="prompt"] input[pops],
7
- .pops[type-value="prompt"] textarea[pops] {
8
- width: 100%;
9
- height: 100%;
10
- outline: 0;
11
- border: 0;
12
- color: var(--input-color);
13
- background-color: var(--input-bg-color);
14
- }
15
-
16
- .pops[type-value="prompt"] input[pops] {
17
- padding: 5px 10px;
18
- }
19
- .pops[type-value="prompt"] textarea[pops] {
20
- padding: 5px 10px;
21
- resize: none;
22
- }
23
-
24
- .pops[type-value="prompt"] input[pops]::placeholder,
25
- .pops[type-value="prompt"] textarea[pops]::placeholder {
26
- color: var(--input-placeholder-color);
27
- }
28
- @media (prefers-color-scheme: dark) {
29
- .pops[type-value="prompt"] {
30
- --input-color: #ffffff;
31
- --input-bg-color: #333333;
32
- --input-placeholder-color: #8d9095;
33
- }
34
- }
1
+ .pops[type-value="prompt"] {
2
+ --input-color: #000000;
3
+ --input-bg-color: none;
4
+ --input-placeholder-color: #a1a4ac;
5
+ }
6
+ .pops[type-value="prompt"] input[pops],
7
+ .pops[type-value="prompt"] textarea[pops] {
8
+ width: 100%;
9
+ height: 100%;
10
+ outline: 0;
11
+ border: 0;
12
+ color: var(--input-color);
13
+ background-color: var(--input-bg-color);
14
+ }
15
+
16
+ .pops[type-value="prompt"] input[pops] {
17
+ padding: 5px 10px;
18
+ }
19
+ .pops[type-value="prompt"] textarea[pops] {
20
+ padding: 5px 10px;
21
+ resize: none;
22
+ }
23
+
24
+ .pops[type-value="prompt"] input[pops]::placeholder,
25
+ .pops[type-value="prompt"] textarea[pops]::placeholder {
26
+ color: var(--input-placeholder-color);
27
+ }
28
+ @media (prefers-color-scheme: dark) {
29
+ .pops[type-value="prompt"] {
30
+ --input-color: #ffffff;
31
+ --input-bg-color: #333333;
32
+ --input-placeholder-color: #8d9095;
33
+ }
34
+ }
@@ -1,215 +1,187 @@
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 { PopsPromptDefaultConfig } from "./defaultConfig";
10
- import type { PopsPromptConfig } from "./types/index";
11
-
12
- export const PopsPrompt = {
13
- init(__config__: PopsPromptConfig) {
14
- const guid = popsUtils.getRandomGUID();
15
- // 设置当前类型
16
- const popsType: PopsType = "prompt";
17
-
18
- let config = PopsPromptDefaultConfig();
19
- config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
20
- config = popsUtils.assign(config, __config__);
21
- config = PopsHandler.handleOnly(popsType, config);
22
-
23
- const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
24
- PopsHandler.handleInit($shadowRoot, [
25
- {
26
- name: "index",
27
- css: PopsCSS.index,
28
- },
29
- {
30
- name: "ninePalaceGridPosition",
31
- css: PopsCSS.ninePalaceGridPosition,
32
- },
33
- {
34
- name: "scrollbar",
35
- css: PopsCSS.scrollbar,
36
- },
37
- {
38
- name: "button",
39
- css: PopsCSS.button,
40
- },
41
- {
42
- name: "anim",
43
- css: PopsCSS.anim,
44
- },
45
- {
46
- name: "common",
47
- css: PopsCSS.common,
48
- },
49
- {
50
- name: "promptCSS",
51
- css: PopsCSS.promptCSS,
52
- },
53
- ]);
54
-
55
- // 先把z-index提取出来
56
- const zIndex = PopsHandler.handleZIndex(config.zIndex);
57
- const maskHTML = PopsElementHandler.createMask(guid, zIndex);
58
-
59
- const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
60
- const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
61
- const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
62
- const { contentPStyle } = PopsElementHandler.createContentStyle(popsType, config);
63
- const animHTML = PopsElementHandler.createAnim(
64
- guid,
65
- popsType,
66
- config,
67
- /*html*/ `
68
- <div class="pops-title pops-${popsType}-title" style="text-align: ${
69
- config.title.position
70
- };${headerStyle}">${
71
- config.title.html
72
- ? config.title.text
73
- : `<p pops class="pops-${popsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
74
- }${headerBtnHTML}</div>
75
- <div class="pops-content pops-${popsType}-content" style="${contentPStyle}">${
76
- config.content.row
77
- ? '<textarea name="pops-input-text" pops="" placeholder="' +
78
- config.content.placeholder +
79
- '"></textarea>'
80
- : '<input name="pops-input-text" pops="" placeholder="' +
81
- config.content.placeholder +
82
- '" type="' +
83
- (config.content.password ? "password" : "text") +
84
- '">'
85
- }</div>${bottomBtnHTML}`,
86
- bottomBtnHTML,
87
- zIndex
88
- );
89
- /**
90
- * 弹窗的主元素,包括动画层
91
- */
92
-
93
- const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
94
-
95
- const {
96
- $pops: $pops,
97
- $input: $input,
98
- $headerBtnClose: $btnClose,
99
- $btnOk: $btnOk,
100
- $btnCancel: $btnCancel,
101
- $btnOther: $btnOther,
102
- $title: $title,
103
- } = PopsHandler.handleQueryElement($anim, popsType);
104
- /**
105
- * 遮罩层元素
106
- */
107
- let $mask: HTMLDivElement | undefined = void 0;
108
-
109
- /**
110
- * 已创建的元素列表
111
- */
112
- const $elList: HTMLElement[] = [$anim];
113
-
114
- if (config.mask.enable) {
115
- // 启用遮罩层
116
- const handleMask = PopsHandler.handleMask({
117
- type: popsType,
118
- guid: guid,
119
- config: config,
120
- animElement: $anim,
121
- maskHTML: maskHTML,
122
- });
123
- $mask = handleMask.maskElement;
124
- $elList.push($mask);
125
- }
126
- const evtConfig = PopsHandler.handleEventConfig(
127
- config,
128
- guid,
129
- $shadowContainer,
130
- $shadowRoot,
131
- popsType,
132
- $anim,
133
- $pops,
134
- $mask
135
- );
136
- const result = PopsHandler.handleResultConfig(evtConfig);
137
- // 输入框赋值初始值
138
-
139
- $input.value = config.content.text;
140
- PopsHandler.handlePromptClickEvent(
141
- "close",
142
- $input,
143
- $btnClose,
144
- evtConfig,
145
-
146
- config.btn.close.callback
147
- );
148
-
149
- PopsHandler.handlePromptClickEvent(
150
- "ok",
151
- $input,
152
- $btnOk,
153
- evtConfig,
154
-
155
- config.btn.ok.callback
156
- );
157
- PopsHandler.handlePromptClickEvent(
158
- "cancel",
159
- $input,
160
- $btnCancel,
161
- evtConfig,
162
-
163
- config.btn.cancel.callback
164
- );
165
-
166
- PopsHandler.handlePromptClickEvent(
167
- "other",
168
- $input,
169
- $btnOther,
170
- evtConfig,
171
-
172
- config.btn.other.callback
173
- );
174
- // 创建到页面中
175
-
176
- popsDOMUtils.append($shadowRoot, $elList);
177
- if (typeof config.beforeAppendToPageCallBack === "function") {
178
- config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
179
- }
180
-
181
- popsDOMUtils.appendBody($shadowContainer);
182
- if ($mask != null) {
183
- $anim.after($mask);
184
- }
185
- PopsHandler.handlePush(popsType, {
186
- guid: guid,
187
- $anim: $anim,
188
- $pops: $pops!,
189
- $mask: $mask!,
190
- $shadowContainer: $shadowContainer,
191
- $shadowRoot: $shadowRoot,
192
- config: config,
193
- destory: result.close,
194
- });
195
- // 拖拽
196
- if (config.drag) {
197
- PopsInstanceUtils.drag($pops!, {
198
- dragElement: $title!,
199
- limit: config.dragLimit,
200
- extraDistance: config.dragExtraDistance,
201
- moveCallBack: config.dragMoveCallBack,
202
- endCallBack: config.dragEndCallBack,
203
- });
204
- }
205
- // 设置自动获取焦点
206
- if (config.content.focus) {
207
- $input.focus();
208
- }
209
- // 设置自动选中所有文字
210
- if (config.content.select) {
211
- $input.select();
212
- }
213
- return result;
214
- },
215
- };
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 { PopsPromptDefaultConfig } from "./defaultConfig";
10
+ import type { PopsPromptConfig } from "./types/index";
11
+
12
+ export const PopsPrompt = {
13
+ init(__config__: PopsPromptConfig) {
14
+ const guid = popsUtils.getRandomGUID();
15
+ // 设置当前类型
16
+ const popsType: PopsType = "prompt";
17
+
18
+ let config = PopsPromptDefaultConfig();
19
+ config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
20
+ config = popsUtils.assign(config, __config__);
21
+ config = PopsHandler.handleOnly(popsType, config);
22
+
23
+ const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
24
+ PopsHandler.handleInit($shadowRoot, [
25
+ {
26
+ name: "index",
27
+ css: PopsCSS.index,
28
+ },
29
+ {
30
+ name: "ninePalaceGridPosition",
31
+ css: PopsCSS.ninePalaceGridPosition,
32
+ },
33
+ {
34
+ name: "scrollbar",
35
+ css: PopsCSS.scrollbar,
36
+ },
37
+ {
38
+ name: "button",
39
+ css: PopsCSS.button,
40
+ },
41
+ {
42
+ name: "anim",
43
+ css: PopsCSS.anim,
44
+ },
45
+ {
46
+ name: "common",
47
+ css: PopsCSS.common,
48
+ },
49
+ {
50
+ name: "promptCSS",
51
+ css: PopsCSS.promptCSS,
52
+ },
53
+ ]);
54
+
55
+ // 先把z-index提取出来
56
+ const zIndex = PopsHandler.handleZIndex(config.zIndex);
57
+ const maskHTML = PopsElementHandler.createMask(guid, zIndex);
58
+
59
+ const headerBtnHTML = PopsElementHandler.createHeader(popsType, config);
60
+ const bottomBtnHTML = PopsElementHandler.createBottom(popsType, config);
61
+ const { headerStyle, headerPStyle } = PopsElementHandler.createHeaderStyle(popsType, config);
62
+ const { contentPStyle } = PopsElementHandler.createContentStyle(popsType, config);
63
+ const animHTML = PopsElementHandler.createAnim(
64
+ guid,
65
+ popsType,
66
+ config,
67
+ /*html*/ `
68
+ <div class="pops-title pops-${popsType}-title" style="text-align: ${
69
+ config.title.position
70
+ };${headerStyle}">${
71
+ config.title.html
72
+ ? config.title.text
73
+ : `<p pops class="pops-${popsType}-title-text" style="${headerPStyle}">${config.title.text}</p>`
74
+ }${headerBtnHTML}</div>
75
+ <div class="pops-content pops-${popsType}-content" style="${contentPStyle}">${
76
+ config.content.row
77
+ ? '<textarea name="pops-input-text" pops="" placeholder="' +
78
+ config.content.placeholder +
79
+ '"></textarea>'
80
+ : '<input name="pops-input-text" pops="" placeholder="' +
81
+ config.content.placeholder +
82
+ '" type="' +
83
+ (config.content.password ? "password" : "text") +
84
+ '">'
85
+ }</div>${bottomBtnHTML}`,
86
+ bottomBtnHTML,
87
+ zIndex
88
+ );
89
+ /**
90
+ * 弹窗的主元素,包括动画层
91
+ */
92
+
93
+ const $anim = PopsElementHandler.parseElement<HTMLDivElement>(animHTML);
94
+
95
+ const {
96
+ $pops: $pops,
97
+ $input: $input,
98
+ $headerBtnClose: $btnClose,
99
+ $btnOk: $btnOk,
100
+ $btnCancel: $btnCancel,
101
+ $btnOther: $btnOther,
102
+ $title: $title,
103
+ } = PopsHandler.handleQueryElement($anim, popsType);
104
+ /**
105
+ * 遮罩层元素
106
+ */
107
+ let $mask: HTMLDivElement | undefined = void 0;
108
+
109
+ /**
110
+ * 已创建的元素列表
111
+ */
112
+ const $elList: HTMLElement[] = [$anim];
113
+
114
+ if (config.mask.enable) {
115
+ // 启用遮罩层
116
+ const handleMask = PopsHandler.handleMask({
117
+ type: popsType,
118
+ guid: guid,
119
+ config: config,
120
+ animElement: $anim,
121
+ maskHTML: maskHTML,
122
+ });
123
+ $mask = handleMask.maskElement;
124
+ $elList.push($mask);
125
+ }
126
+ const evtConfig = PopsHandler.handleEventConfig(
127
+ config,
128
+ guid,
129
+ $shadowContainer,
130
+ $shadowRoot,
131
+ popsType,
132
+ $anim,
133
+ $pops,
134
+ $mask
135
+ );
136
+ const result = PopsHandler.handleResultConfig(evtConfig);
137
+ // 输入框赋值初始值
138
+
139
+ $input.value = config.content.text;
140
+ PopsHandler.handlePromptClickEvent("close", $input, $btnClose, evtConfig, config.btn.close.callback);
141
+
142
+ PopsHandler.handlePromptClickEvent("ok", $input, $btnOk, evtConfig, config.btn.ok.callback);
143
+ PopsHandler.handlePromptClickEvent("cancel", $input, $btnCancel, evtConfig, config.btn.cancel.callback);
144
+
145
+ PopsHandler.handlePromptClickEvent("other", $input, $btnOther, evtConfig, config.btn.other.callback);
146
+ // 创建到页面中
147
+
148
+ popsDOMUtils.append($shadowRoot, $elList);
149
+ if (typeof config.beforeAppendToPageCallBack === "function") {
150
+ config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
151
+ }
152
+
153
+ popsDOMUtils.appendBody($shadowContainer);
154
+ if ($mask != null) {
155
+ $anim.after($mask);
156
+ }
157
+ PopsHandler.handlePush(popsType, {
158
+ guid: guid,
159
+ $anim: $anim,
160
+ $pops: $pops!,
161
+ $mask: $mask!,
162
+ $shadowContainer: $shadowContainer,
163
+ $shadowRoot: $shadowRoot,
164
+ config: config,
165
+ destory: result.close,
166
+ });
167
+ // 拖拽
168
+ if (config.drag) {
169
+ PopsInstanceUtils.drag($pops!, {
170
+ dragElement: $title!,
171
+ limit: config.dragLimit,
172
+ extraDistance: config.dragExtraDistance,
173
+ moveCallBack: config.dragMoveCallBack,
174
+ endCallBack: config.dragEndCallBack,
175
+ });
176
+ }
177
+ // 设置自动获取焦点
178
+ if (config.content.focus) {
179
+ $input.focus();
180
+ }
181
+ // 设置自动选中所有文字
182
+ if (config.content.select) {
183
+ $input.select();
184
+ }
185
+ return result;
186
+ },
187
+ };