@whitesev/pops 3.2.1 → 3.2.2

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 (126) hide show
  1. package/README.md +249 -249
  2. package/dist/index.amd.js +702 -667
  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 +702 -667
  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 +702 -667
  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 +702 -667
  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 +702 -667
  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 +702 -667
  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/components/folder/types/index.d.ts +43 -13
  27. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +313 -313
  28. package/dist/types/src/types/animation.d.ts +19 -19
  29. package/dist/types/src/types/button.d.ts +94 -94
  30. package/dist/types/src/types/components.d.ts +211 -211
  31. package/dist/types/src/types/event.d.ts +43 -43
  32. package/dist/types/src/types/global.d.ts +31 -31
  33. package/dist/types/src/types/icon.d.ts +32 -32
  34. package/dist/types/src/types/inst.d.ts +28 -28
  35. package/dist/types/src/types/main.d.ts +66 -66
  36. package/dist/types/src/types/mask.d.ts +52 -52
  37. package/dist/types/src/types/position.d.ts +60 -60
  38. package/package.json +27 -25
  39. package/src/Pops.ts +206 -206
  40. package/src/PopsAnimation.ts +32 -32
  41. package/src/PopsCSS.ts +54 -54
  42. package/src/PopsCore.ts +37 -37
  43. package/src/PopsIcon.ts +95 -95
  44. package/src/PopsInst.ts +21 -21
  45. package/src/components/alert/defaultConfig.ts +62 -62
  46. package/src/components/alert/index.ts +163 -163
  47. package/src/components/alert/types/index.ts +23 -23
  48. package/src/components/confirm/defaultConfig.ts +90 -90
  49. package/src/components/confirm/index.ts +165 -165
  50. package/src/components/confirm/types/index.ts +13 -17
  51. package/src/components/drawer/defaultConfig.ts +89 -89
  52. package/src/components/drawer/index.css +37 -37
  53. package/src/components/drawer/index.ts +245 -245
  54. package/src/components/drawer/types/index.ts +62 -61
  55. package/src/components/folder/defaultConfig.ts +151 -151
  56. package/src/components/folder/folderIcon.ts +28 -28
  57. package/src/components/folder/index.css +303 -303
  58. package/src/components/folder/index.ts +953 -932
  59. package/src/components/folder/types/index.ts +143 -110
  60. package/src/components/iframe/defaultConfig.ts +60 -60
  61. package/src/components/iframe/index.css +76 -76
  62. package/src/components/iframe/index.ts +331 -331
  63. package/src/components/iframe/types/index.ts +96 -96
  64. package/src/components/loading/defaultConfig.ts +29 -29
  65. package/src/components/loading/index.css +66 -66
  66. package/src/components/loading/index.ts +101 -101
  67. package/src/components/loading/types/index.ts +36 -34
  68. package/src/components/panel/css/components-select.css +84 -84
  69. package/src/components/panel/defaultConfig.ts +868 -868
  70. package/src/components/panel/handlerComponents.ts +3993 -3993
  71. package/src/components/panel/index.css +1403 -1403
  72. package/src/components/panel/index.ts +221 -221
  73. package/src/components/panel/types/components-button.ts +56 -56
  74. package/src/components/panel/types/components-common.ts +73 -73
  75. package/src/components/panel/types/components-container.ts +25 -25
  76. package/src/components/panel/types/components-deepMenu.ts +64 -64
  77. package/src/components/panel/types/components-input.ts +90 -90
  78. package/src/components/panel/types/components-own.ts +16 -16
  79. package/src/components/panel/types/components-select.ts +169 -169
  80. package/src/components/panel/types/components-selectMultiple.ts +105 -104
  81. package/src/components/panel/types/components-slider.ts +55 -55
  82. package/src/components/panel/types/components-switch.ts +33 -33
  83. package/src/components/panel/types/components-textarea.ts +45 -45
  84. package/src/components/panel/types/index.ts +244 -244
  85. package/src/components/prompt/defaultConfig.ts +94 -94
  86. package/src/components/prompt/index.css +34 -34
  87. package/src/components/prompt/index.ts +187 -215
  88. package/src/components/prompt/types/index.ts +57 -56
  89. package/src/components/rightClickMenu/defaultConfig.ts +103 -103
  90. package/src/components/rightClickMenu/index.css +115 -115
  91. package/src/components/rightClickMenu/index.ts +662 -662
  92. package/src/components/rightClickMenu/types/index.ts +145 -143
  93. package/src/components/searchSuggestion/defaultConfig.ts +63 -63
  94. package/src/components/searchSuggestion/index.ts +813 -813
  95. package/src/components/searchSuggestion/types/index.ts +244 -242
  96. package/src/components/tooltip/defaultConfig.ts +33 -33
  97. package/src/components/tooltip/index.css +199 -199
  98. package/src/components/tooltip/index.ts +617 -617
  99. package/src/components/tooltip/types/index.ts +123 -121
  100. package/src/config/CommonCSSClassName.ts +17 -17
  101. package/src/config/GlobalConfig.ts +63 -63
  102. package/src/css/animation.css +987 -987
  103. package/src/css/button.css +551 -551
  104. package/src/css/common.css +54 -54
  105. package/src/css/index.css +253 -253
  106. package/src/css/ninePalaceGridPosition.css +50 -50
  107. package/src/css/scrollbar.css +22 -22
  108. package/src/handler/PopsElementHandler.ts +303 -303
  109. package/src/handler/PopsHandler.ts +611 -611
  110. package/src/types/PopsDOMUtilsEventType.d.ts +313 -313
  111. package/src/types/animation.d.ts +19 -19
  112. package/src/types/button.d.ts +94 -94
  113. package/src/types/components.d.ts +211 -211
  114. package/src/types/event.d.ts +43 -43
  115. package/src/types/global.d.ts +31 -31
  116. package/src/types/icon.d.ts +32 -32
  117. package/src/types/inst.d.ts +28 -28
  118. package/src/types/main.d.ts +66 -66
  119. package/src/types/mask.d.ts +52 -52
  120. package/src/types/position.d.ts +60 -60
  121. package/src/utils/PopsDOMUtils.ts +2483 -2483
  122. package/src/utils/PopsDOMUtilsEventsConfig.ts +4 -4
  123. package/src/utils/PopsInstanceUtils.ts +714 -714
  124. package/src/utils/PopsMathUtils.ts +71 -71
  125. package/src/utils/PopsSafeUtils.ts +22 -22
  126. package/src/utils/PopsUtils.ts +421 -421
@@ -1,303 +1,303 @@
1
- import type { PopsAlertConfig } from "../components/alert/types";
2
- import type { PopsConfirmConfig } from "../components/confirm/types";
3
- import type { PopsIframeConfig } from "../components/iframe/types";
4
- import type { PopsIconType } from "../types/icon";
5
- import type {
6
- PopsSupportAnimConfig,
7
- PopsSupportBottomButtonConfig,
8
- PopsSupportContentConfig,
9
- PopsSupportHeaderTitleConfig,
10
- PopsSupportAnimConfigType,
11
- PopsSupportBottomButtonConfigType,
12
- PopsSupportContentConfigType,
13
- PopsSupportHeaderTitleConfigType,
14
- } from "../types/main";
15
- import { PopsIcon } from "../PopsIcon";
16
- import { popsDOMUtils } from "../utils/PopsDOMUtils";
17
-
18
- export const PopsElementHandler = {
19
- /**
20
- * 获取遮罩层HTML
21
- * @param guid
22
- * @param zIndex z-index
23
- * @param style
24
- */
25
- createMask(guid: string, zIndex: number = 101, style = ""): string {
26
- zIndex = zIndex - 100;
27
- if (style.startsWith(";")) {
28
- style = style.replace(";", "");
29
- }
30
- return /*html*/ `<div class="pops-mask" data-guid="${guid}" style="z-index:${zIndex};${style}"></div>`;
31
- },
32
- /**
33
- * 获取动画层HTML
34
- * @param guid
35
- * @param type
36
- * @param config
37
- * @param html
38
- * @param bottomBtnHTML
39
- * @param zIndex
40
- */
41
- createAnim(
42
- guid: string,
43
- type: PopsSupportAnimConfigType,
44
- config: PopsSupportAnimConfig[keyof PopsSupportAnimConfig],
45
- html = "",
46
- bottomBtnHTML = "",
47
- zIndex: number
48
- ) {
49
- const __config = config as PopsAlertConfig;
50
- let popsAnimStyle = "";
51
- let popsStyle = "";
52
- const popsPosition = __config.position || "";
53
- if (config.zIndex != null) {
54
- popsAnimStyle += `z-index: ${zIndex};`;
55
- popsStyle += `z-index: ${zIndex};`;
56
- }
57
- if (__config.width != null) {
58
- popsStyle += `width: ${__config.width};`;
59
- }
60
- if (__config.height != null) {
61
- popsStyle += `height: ${__config.height};`;
62
- }
63
- const hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
64
- return /*html*/ `
65
- <div class="pops-anim" anim="${__config.animation || ""}" style="${popsAnimStyle}" data-guid="${guid}">${
66
- config.style != null ? `<style tyle="text/css">${config.style}</style>` : ""
67
- }
68
- <div class="pops ${
69
- config.class || ""
70
- }" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
71
- </div>`;
72
- },
73
- /**
74
- * 获取顶部按钮层HTML
75
- * @param type
76
- * @param config
77
- */
78
- createHeader(
79
- type: PopsSupportHeaderTitleConfigType,
80
- config: PopsSupportHeaderTitleConfig[keyof PopsSupportHeaderTitleConfig]
81
- ): string {
82
- if (!config.btn) {
83
- return "";
84
- }
85
- const confirm_config = config as PopsConfirmConfig;
86
- if (type !== "iframe" && !confirm_config.btn?.close?.enable) {
87
- return "";
88
- }
89
- let resultHTML = "";
90
- // let btnStyle = "";
91
- let closeHTML = "";
92
- const iframe_config = config as PopsIframeConfig;
93
- if (type === "iframe" && iframe_config.topRightButton?.trim() !== "") {
94
- // iframe的
95
- let topRightButtonHTML = "";
96
- iframe_config.topRightButton.split("|").forEach((item: string) => {
97
- // 最小化、最大化、窗口化、关闭按钮
98
- item = item.toLowerCase();
99
- topRightButtonHTML += /*html*/ `
100
- <button class="pops-header-control" type="button" data-type="${item}">
101
- <i class="pops-icon">${PopsIcon.getIcon(item)}</i>
102
- </button>`;
103
- });
104
- resultHTML = /*html*/ `
105
- <div class="pops-header-controls" data-margin>${topRightButtonHTML}</div>`;
106
- } else {
107
- if (confirm_config.btn?.close?.enable) {
108
- // 关闭按钮
109
- closeHTML = /*html*/ `
110
- <div class="pops-header-controls">
111
- <button class="pops-header-control" type="button" data-type="close" data-header>
112
- <i class="pops-icon">${PopsIcon.getIcon("close")}</i>
113
- </button>
114
- </div>`;
115
- }
116
- resultHTML = closeHTML;
117
- }
118
-
119
- return resultHTML;
120
- },
121
- /**
122
- * 获取标题style
123
- * @param type 弹窗类型
124
- * @param config 弹窗配置
125
- */
126
- createHeaderStyle(
127
- type: PopsSupportHeaderTitleConfigType,
128
- config: PopsSupportHeaderTitleConfig[keyof PopsSupportHeaderTitleConfig]
129
- ) {
130
- return {
131
- headerStyle: config?.title?.html ? config?.title?.style || "" : "",
132
- headerPStyle: config?.title?.html ? "" : config?.title?.style || "",
133
- };
134
- },
135
- /**
136
- * 获取底部按钮层HTML
137
- * @param type
138
- * @param config
139
- */
140
- createBottom(
141
- type: PopsSupportBottomButtonConfigType,
142
- config: Omit<PopsSupportBottomButtonConfig[keyof PopsSupportBottomButtonConfig], "content">
143
- ): string {
144
- if (config.btn == null) {
145
- // 未设置btn参数
146
- return "";
147
- }
148
- const confirm_config = config as Required<PopsConfirmConfig>;
149
- if (!(config.btn?.ok?.enable || confirm_config.btn?.cancel?.enable || confirm_config.btn?.other?.enable)) {
150
- // 确定、取消、其它按钮都未启用直接返回
151
- return "";
152
- }
153
- let btnStyle = "";
154
- let resultHTML = "";
155
- let okHTML = "";
156
- let cancelHTML = "";
157
- let ohterHTML = "";
158
-
159
- if (config.btn.position) {
160
- btnStyle += `justify-content: ${config.btn.position};`;
161
- }
162
-
163
- if (confirm_config.btn.reverse) {
164
- btnStyle += "flex-direction: row-reverse;";
165
- }
166
- if (config.btn?.ok?.enable) {
167
- // 处理确定按钮的尺寸问题
168
- let okButtonSizeClassName = "";
169
- if (config.btn.ok.size === "large") {
170
- okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
171
- } else if (config.btn.ok.size === "small") {
172
- okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
173
- }
174
- let okIconHTML = "";
175
- const okIcon = confirm_config.btn.ok!.icon! as PopsIconType | string;
176
- if (okIcon !== "") {
177
- // 判断图标是否是svg库内的
178
- let iconHTML = "";
179
- if (PopsIcon.hasIcon(okIcon)) {
180
- iconHTML = PopsIcon.getIcon(okIcon)!;
181
- } else {
182
- iconHTML = okIcon;
183
- }
184
- iconHTML = iconHTML || "";
185
- okIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${config.btn.ok.iconIsLoading}">${iconHTML}</i>`;
186
- }
187
- okHTML = /*html*/ `
188
- <button
189
- class="pops-${type}-btn-ok ${okButtonSizeClassName}"
190
- type="button"
191
- data-type="${confirm_config.btn.ok?.type}"
192
- data-has-icon="${(confirm_config.btn.ok!.icon || "") !== ""}"
193
- data-rightIcon="${confirm_config.btn.ok?.rightIcon}"
194
- >${okIconHTML}<span>${config.btn.ok.text}</span>
195
- </button>`;
196
- }
197
-
198
- if (confirm_config.btn?.cancel?.enable) {
199
- // 处理取消按钮的尺寸问题
200
- let cancelButtonSizeClassName = "";
201
-
202
- if (confirm_config.btn.cancel.size === "large") {
203
- cancelButtonSizeClassName = "pops-button-" + confirm_config.btn.cancel.size;
204
- } else if (confirm_config.btn.cancel.size === "small") {
205
- cancelButtonSizeClassName = "pops-button-" + confirm_config.btn.cancel.size;
206
- }
207
- let cancelIconHTML = "";
208
- const cancelIcon = confirm_config.btn.cancel!.icon as PopsIconType | string;
209
- if (cancelIcon !== "") {
210
- let iconHTML = "";
211
- // 判断图标是否是svg库内的
212
- if (PopsIcon.hasIcon(cancelIcon)) {
213
- iconHTML = PopsIcon.getIcon(cancelIcon)!;
214
- } else {
215
- iconHTML = cancelIcon;
216
- }
217
- iconHTML = iconHTML || "";
218
- cancelIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${confirm_config.btn.cancel.iconIsLoading}">${iconHTML}</i>`;
219
- }
220
- cancelHTML = /*html*/ `
221
- <button
222
- class="pops-${type}-btn-cancel ${cancelButtonSizeClassName}"
223
- type="button"
224
- data-type="${confirm_config.btn.cancel.type}"
225
- data-has-icon="${(confirm_config.btn.cancel.icon || "") !== ""}"
226
- data-rightIcon="${confirm_config.btn.cancel.rightIcon}"
227
- >${cancelIconHTML}<span>${confirm_config.btn.cancel.text}</span>
228
- </button>`;
229
- }
230
-
231
- if (confirm_config.btn?.other?.enable) {
232
- // 处理其它按钮的尺寸问题
233
- let otherButtonSizeClassName = "";
234
-
235
- if (confirm_config.btn.other.size === "large") {
236
- otherButtonSizeClassName = "pops-button-" + confirm_config.btn.other.size;
237
- } else if (confirm_config.btn.other.size === "small") {
238
- otherButtonSizeClassName = "pops-button-" + confirm_config.btn.other.size;
239
- }
240
- let otherIconHTML = "";
241
- const otherIcon = confirm_config.btn.other!.icon as PopsIconType | string;
242
- if (otherIcon !== "") {
243
- let iconHTML = "";
244
- // 判断图标是否是svg库内的
245
- if (PopsIcon.hasIcon(otherIcon)) {
246
- iconHTML = PopsIcon.getIcon(otherIcon)!;
247
- } else {
248
- otherIcon;
249
- }
250
- iconHTML = iconHTML || "";
251
- otherIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${confirm_config.btn.other.iconIsLoading}">${iconHTML}</i>`;
252
- }
253
- ohterHTML = /*html*/ `
254
- <button
255
- class="pops-${type}-btn-other ${otherButtonSizeClassName}"
256
- type="button"
257
- data-type="${confirm_config.btn.other.type}"
258
- data-has-icon="${(confirm_config.btn.other.icon || "") !== ""}"
259
- data-rightIcon="${confirm_config.btn.other.rightIcon}"
260
- >${otherIconHTML}<span>${confirm_config.btn.other.text}</span>
261
- </button>`;
262
- }
263
-
264
- if (confirm_config.btn.merge) {
265
- let flexStyle = "display: flex;";
266
- if (confirm_config.btn.mergeReverse) {
267
- flexStyle += "flex-direction: row-reverse;";
268
- } else {
269
- flexStyle += "flex-direction: row;";
270
- }
271
- resultHTML = /*html*/ `
272
- <div class="pops-botttom-btn-controls pops-${type}-btn" style="${btnStyle}">${ohterHTML}<div
273
- class="pops-${type}-btn-merge"
274
- style="${flexStyle}">${okHTML}${cancelHTML}</div>
275
- </div>
276
- `;
277
- } else {
278
- resultHTML = /*html*/ `<div class="pops-botttom-btn-controls pops-${type}-btn" style="${btnStyle}">${okHTML}${cancelHTML}${ohterHTML}</div>`;
279
- }
280
- return resultHTML;
281
- },
282
- /**
283
- * 获取内容style
284
- * @param type 弹窗类型
285
- * @param config 弹窗配置
286
- */
287
- createContentStyle(
288
- type: PopsSupportContentConfigType,
289
- config: PopsSupportContentConfig[keyof PopsSupportContentConfig]
290
- ) {
291
- return {
292
- contentStyle: (config?.content as any)?.html ? config?.content?.style || "" : "",
293
- contentPStyle: (config?.content as any)?.html ? "" : config?.content?.style || "",
294
- };
295
- },
296
- /**
297
- * 将html转换成元素
298
- * @param html
299
- */
300
- parseElement<T extends HTMLElement>(html: string): T {
301
- return popsDOMUtils.parseTextToDOM(html);
302
- },
303
- };
1
+ import type { PopsAlertConfig } from "../components/alert/types";
2
+ import type { PopsConfirmConfig } from "../components/confirm/types";
3
+ import type { PopsIframeConfig } from "../components/iframe/types";
4
+ import type { PopsIconType } from "../types/icon";
5
+ import type {
6
+ PopsSupportAnimConfig,
7
+ PopsSupportBottomButtonConfig,
8
+ PopsSupportContentConfig,
9
+ PopsSupportHeaderTitleConfig,
10
+ PopsSupportAnimConfigType,
11
+ PopsSupportBottomButtonConfigType,
12
+ PopsSupportContentConfigType,
13
+ PopsSupportHeaderTitleConfigType,
14
+ } from "../types/main";
15
+ import { PopsIcon } from "../PopsIcon";
16
+ import { popsDOMUtils } from "../utils/PopsDOMUtils";
17
+
18
+ export const PopsElementHandler = {
19
+ /**
20
+ * 获取遮罩层HTML
21
+ * @param guid
22
+ * @param zIndex z-index
23
+ * @param style
24
+ */
25
+ createMask(guid: string, zIndex: number = 101, style = ""): string {
26
+ zIndex = zIndex - 100;
27
+ if (style.startsWith(";")) {
28
+ style = style.replace(";", "");
29
+ }
30
+ return /*html*/ `<div class="pops-mask" data-guid="${guid}" style="z-index:${zIndex};${style}"></div>`;
31
+ },
32
+ /**
33
+ * 获取动画层HTML
34
+ * @param guid
35
+ * @param type
36
+ * @param config
37
+ * @param html
38
+ * @param bottomBtnHTML
39
+ * @param zIndex
40
+ */
41
+ createAnim(
42
+ guid: string,
43
+ type: PopsSupportAnimConfigType,
44
+ config: PopsSupportAnimConfig[keyof PopsSupportAnimConfig],
45
+ html = "",
46
+ bottomBtnHTML = "",
47
+ zIndex: number
48
+ ) {
49
+ const __config = config as PopsAlertConfig;
50
+ let popsAnimStyle = "";
51
+ let popsStyle = "";
52
+ const popsPosition = __config.position || "";
53
+ if (config.zIndex != null) {
54
+ popsAnimStyle += `z-index: ${zIndex};`;
55
+ popsStyle += `z-index: ${zIndex};`;
56
+ }
57
+ if (__config.width != null) {
58
+ popsStyle += `width: ${__config.width};`;
59
+ }
60
+ if (__config.height != null) {
61
+ popsStyle += `height: ${__config.height};`;
62
+ }
63
+ const hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
64
+ return /*html*/ `
65
+ <div class="pops-anim" anim="${__config.animation || ""}" style="${popsAnimStyle}" data-guid="${guid}">${
66
+ config.style != null ? `<style tyle="text/css">${config.style}</style>` : ""
67
+ }
68
+ <div class="pops ${
69
+ config.class || ""
70
+ }" data-bottom-btn="${hasBottomBtn}" type-value="${type}" style="${popsStyle}" position="${popsPosition}" data-guid="${guid}">${html}</div>
71
+ </div>`;
72
+ },
73
+ /**
74
+ * 获取顶部按钮层HTML
75
+ * @param type
76
+ * @param config
77
+ */
78
+ createHeader(
79
+ type: PopsSupportHeaderTitleConfigType,
80
+ config: PopsSupportHeaderTitleConfig[keyof PopsSupportHeaderTitleConfig]
81
+ ): string {
82
+ if (!config.btn) {
83
+ return "";
84
+ }
85
+ const confirm_config = config as PopsConfirmConfig;
86
+ if (type !== "iframe" && !confirm_config.btn?.close?.enable) {
87
+ return "";
88
+ }
89
+ let resultHTML = "";
90
+ // let btnStyle = "";
91
+ let closeHTML = "";
92
+ const iframe_config = config as PopsIframeConfig;
93
+ if (type === "iframe" && iframe_config.topRightButton?.trim() !== "") {
94
+ // iframe的
95
+ let topRightButtonHTML = "";
96
+ iframe_config.topRightButton.split("|").forEach((item: string) => {
97
+ // 最小化、最大化、窗口化、关闭按钮
98
+ item = item.toLowerCase();
99
+ topRightButtonHTML += /*html*/ `
100
+ <button class="pops-header-control" type="button" data-type="${item}">
101
+ <i class="pops-icon">${PopsIcon.getIcon(item)}</i>
102
+ </button>`;
103
+ });
104
+ resultHTML = /*html*/ `
105
+ <div class="pops-header-controls" data-margin>${topRightButtonHTML}</div>`;
106
+ } else {
107
+ if (confirm_config.btn?.close?.enable) {
108
+ // 关闭按钮
109
+ closeHTML = /*html*/ `
110
+ <div class="pops-header-controls">
111
+ <button class="pops-header-control" type="button" data-type="close" data-header>
112
+ <i class="pops-icon">${PopsIcon.getIcon("close")}</i>
113
+ </button>
114
+ </div>`;
115
+ }
116
+ resultHTML = closeHTML;
117
+ }
118
+
119
+ return resultHTML;
120
+ },
121
+ /**
122
+ * 获取标题style
123
+ * @param type 弹窗类型
124
+ * @param config 弹窗配置
125
+ */
126
+ createHeaderStyle(
127
+ type: PopsSupportHeaderTitleConfigType,
128
+ config: PopsSupportHeaderTitleConfig[keyof PopsSupportHeaderTitleConfig]
129
+ ) {
130
+ return {
131
+ headerStyle: config?.title?.html ? config?.title?.style || "" : "",
132
+ headerPStyle: config?.title?.html ? "" : config?.title?.style || "",
133
+ };
134
+ },
135
+ /**
136
+ * 获取底部按钮层HTML
137
+ * @param type
138
+ * @param config
139
+ */
140
+ createBottom(
141
+ type: PopsSupportBottomButtonConfigType,
142
+ config: Omit<PopsSupportBottomButtonConfig[keyof PopsSupportBottomButtonConfig], "content">
143
+ ): string {
144
+ if (config.btn == null) {
145
+ // 未设置btn参数
146
+ return "";
147
+ }
148
+ const confirm_config = config as Required<PopsConfirmConfig>;
149
+ if (!(config.btn?.ok?.enable || confirm_config.btn?.cancel?.enable || confirm_config.btn?.other?.enable)) {
150
+ // 确定、取消、其它按钮都未启用直接返回
151
+ return "";
152
+ }
153
+ let btnStyle = "";
154
+ let resultHTML = "";
155
+ let okHTML = "";
156
+ let cancelHTML = "";
157
+ let ohterHTML = "";
158
+
159
+ if (config.btn.position) {
160
+ btnStyle += `justify-content: ${config.btn.position};`;
161
+ }
162
+
163
+ if (confirm_config.btn.reverse) {
164
+ btnStyle += "flex-direction: row-reverse;";
165
+ }
166
+ if (config.btn?.ok?.enable) {
167
+ // 处理确定按钮的尺寸问题
168
+ let okButtonSizeClassName = "";
169
+ if (config.btn.ok.size === "large") {
170
+ okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
171
+ } else if (config.btn.ok.size === "small") {
172
+ okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
173
+ }
174
+ let okIconHTML = "";
175
+ const okIcon = confirm_config.btn.ok!.icon! as PopsIconType | string;
176
+ if (okIcon !== "") {
177
+ // 判断图标是否是svg库内的
178
+ let iconHTML = "";
179
+ if (PopsIcon.hasIcon(okIcon)) {
180
+ iconHTML = PopsIcon.getIcon(okIcon)!;
181
+ } else {
182
+ iconHTML = okIcon;
183
+ }
184
+ iconHTML = iconHTML || "";
185
+ okIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${config.btn.ok.iconIsLoading}">${iconHTML}</i>`;
186
+ }
187
+ okHTML = /*html*/ `
188
+ <button
189
+ class="pops-${type}-btn-ok ${okButtonSizeClassName}"
190
+ type="button"
191
+ data-type="${confirm_config.btn.ok?.type}"
192
+ data-has-icon="${(confirm_config.btn.ok!.icon || "") !== ""}"
193
+ data-rightIcon="${confirm_config.btn.ok?.rightIcon}"
194
+ >${okIconHTML}<span>${config.btn.ok.text}</span>
195
+ </button>`;
196
+ }
197
+
198
+ if (confirm_config.btn?.cancel?.enable) {
199
+ // 处理取消按钮的尺寸问题
200
+ let cancelButtonSizeClassName = "";
201
+
202
+ if (confirm_config.btn.cancel.size === "large") {
203
+ cancelButtonSizeClassName = "pops-button-" + confirm_config.btn.cancel.size;
204
+ } else if (confirm_config.btn.cancel.size === "small") {
205
+ cancelButtonSizeClassName = "pops-button-" + confirm_config.btn.cancel.size;
206
+ }
207
+ let cancelIconHTML = "";
208
+ const cancelIcon = confirm_config.btn.cancel!.icon as PopsIconType | string;
209
+ if (cancelIcon !== "") {
210
+ let iconHTML = "";
211
+ // 判断图标是否是svg库内的
212
+ if (PopsIcon.hasIcon(cancelIcon)) {
213
+ iconHTML = PopsIcon.getIcon(cancelIcon)!;
214
+ } else {
215
+ iconHTML = cancelIcon;
216
+ }
217
+ iconHTML = iconHTML || "";
218
+ cancelIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${confirm_config.btn.cancel.iconIsLoading}">${iconHTML}</i>`;
219
+ }
220
+ cancelHTML = /*html*/ `
221
+ <button
222
+ class="pops-${type}-btn-cancel ${cancelButtonSizeClassName}"
223
+ type="button"
224
+ data-type="${confirm_config.btn.cancel.type}"
225
+ data-has-icon="${(confirm_config.btn.cancel.icon || "") !== ""}"
226
+ data-rightIcon="${confirm_config.btn.cancel.rightIcon}"
227
+ >${cancelIconHTML}<span>${confirm_config.btn.cancel.text}</span>
228
+ </button>`;
229
+ }
230
+
231
+ if (confirm_config.btn?.other?.enable) {
232
+ // 处理其它按钮的尺寸问题
233
+ let otherButtonSizeClassName = "";
234
+
235
+ if (confirm_config.btn.other.size === "large") {
236
+ otherButtonSizeClassName = "pops-button-" + confirm_config.btn.other.size;
237
+ } else if (confirm_config.btn.other.size === "small") {
238
+ otherButtonSizeClassName = "pops-button-" + confirm_config.btn.other.size;
239
+ }
240
+ let otherIconHTML = "";
241
+ const otherIcon = confirm_config.btn.other!.icon as PopsIconType | string;
242
+ if (otherIcon !== "") {
243
+ let iconHTML = "";
244
+ // 判断图标是否是svg库内的
245
+ if (PopsIcon.hasIcon(otherIcon)) {
246
+ iconHTML = PopsIcon.getIcon(otherIcon)!;
247
+ } else {
248
+ otherIcon;
249
+ }
250
+ iconHTML = iconHTML || "";
251
+ otherIconHTML = /*html*/ `<i class="pops-bottom-icon" is-loading="${confirm_config.btn.other.iconIsLoading}">${iconHTML}</i>`;
252
+ }
253
+ ohterHTML = /*html*/ `
254
+ <button
255
+ class="pops-${type}-btn-other ${otherButtonSizeClassName}"
256
+ type="button"
257
+ data-type="${confirm_config.btn.other.type}"
258
+ data-has-icon="${(confirm_config.btn.other.icon || "") !== ""}"
259
+ data-rightIcon="${confirm_config.btn.other.rightIcon}"
260
+ >${otherIconHTML}<span>${confirm_config.btn.other.text}</span>
261
+ </button>`;
262
+ }
263
+
264
+ if (confirm_config.btn.merge) {
265
+ let flexStyle = "display: flex;";
266
+ if (confirm_config.btn.mergeReverse) {
267
+ flexStyle += "flex-direction: row-reverse;";
268
+ } else {
269
+ flexStyle += "flex-direction: row;";
270
+ }
271
+ resultHTML = /*html*/ `
272
+ <div class="pops-botttom-btn-controls pops-${type}-btn" style="${btnStyle}">${ohterHTML}<div
273
+ class="pops-${type}-btn-merge"
274
+ style="${flexStyle}">${okHTML}${cancelHTML}</div>
275
+ </div>
276
+ `;
277
+ } else {
278
+ resultHTML = /*html*/ `<div class="pops-botttom-btn-controls pops-${type}-btn" style="${btnStyle}">${okHTML}${cancelHTML}${ohterHTML}</div>`;
279
+ }
280
+ return resultHTML;
281
+ },
282
+ /**
283
+ * 获取内容style
284
+ * @param type 弹窗类型
285
+ * @param config 弹窗配置
286
+ */
287
+ createContentStyle(
288
+ type: PopsSupportContentConfigType,
289
+ config: PopsSupportContentConfig[keyof PopsSupportContentConfig]
290
+ ) {
291
+ return {
292
+ contentStyle: (config?.content as any)?.html ? config?.content?.style || "" : "",
293
+ contentPStyle: (config?.content as any)?.html ? "" : config?.content?.style || "",
294
+ };
295
+ },
296
+ /**
297
+ * 将html转换成元素
298
+ * @param html
299
+ */
300
+ parseElement<T extends HTMLElement>(html: string): T {
301
+ return popsDOMUtils.parseTextToDOM(html);
302
+ },
303
+ };