@whitesev/pops 1.4.0 → 1.5.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 (105) hide show
  1. package/dist/index.amd.js.map +1 -1
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.iife.js.map +1 -1
  5. package/dist/index.system.js.map +1 -1
  6. package/dist/index.umd.js.map +1 -1
  7. package/package.json +50 -48
  8. package/src/Config.ts +3 -0
  9. package/src/Core.ts +45 -0
  10. package/src/Pops.ts +340 -0
  11. package/src/components/alert/index.css +45 -0
  12. package/src/components/alert/index.ts +216 -0
  13. package/src/components/alert/indexType.ts +30 -0
  14. package/src/components/confirm/index.css +45 -0
  15. package/src/components/confirm/index.ts +264 -0
  16. package/src/components/confirm/indexType.ts +17 -0
  17. package/src/components/drawer/index.css +47 -0
  18. package/src/components/drawer/index.ts +338 -0
  19. package/src/components/drawer/indexType.ts +53 -0
  20. package/src/components/folder/folderIcon.ts +28 -0
  21. package/src/components/folder/index.css +291 -0
  22. package/src/components/folder/index.ts +1111 -0
  23. package/src/components/folder/indexType.ts +87 -0
  24. package/src/components/iframe/index.css +90 -0
  25. package/src/components/iframe/index.ts +415 -0
  26. package/src/components/iframe/indexType.ts +144 -0
  27. package/src/components/loading/index.css +60 -0
  28. package/src/components/loading/index.ts +123 -0
  29. package/src/components/loading/indexType.ts +31 -0
  30. package/src/components/panel/buttonType.ts +60 -0
  31. package/src/components/panel/commonType.ts +50 -0
  32. package/src/components/panel/deepMenuType.ts +59 -0
  33. package/src/components/panel/formsType.ts +32 -0
  34. package/src/components/panel/index.css +754 -0
  35. package/src/components/panel/index.ts +2435 -0
  36. package/src/components/panel/indexType.ts +107 -0
  37. package/src/components/panel/inputType.ts +65 -0
  38. package/src/components/panel/ownType.ts +28 -0
  39. package/src/components/panel/selectType.ts +80 -0
  40. package/src/components/panel/sliderType.ts +59 -0
  41. package/src/components/panel/switchType.ts +43 -0
  42. package/src/components/panel/textareaType.ts +54 -0
  43. package/src/components/prompt/index.css +60 -0
  44. package/src/components/prompt/index.ts +293 -0
  45. package/src/components/prompt/indexType.ts +47 -0
  46. package/src/components/rightClickMenu/index.ts +729 -0
  47. package/src/components/rightClickMenu/indexType.ts +89 -0
  48. package/src/components/searchSuggestion/index.css +0 -0
  49. package/src/components/searchSuggestion/index.ts +656 -0
  50. package/src/components/searchSuggestion/indexType.ts +238 -0
  51. package/src/components/tooltip/index.css +171 -0
  52. package/src/components/tooltip/index.ts +358 -0
  53. package/src/components/tooltip/indexType.ts +95 -0
  54. package/src/css/animation.css +2240 -0
  55. package/src/css/button.css +290 -0
  56. package/src/css/common.css +24 -0
  57. package/src/css/index.css +135 -0
  58. package/src/css/ninePalaceGridPosition.css +50 -0
  59. package/src/css/scrollbar.css +18 -0
  60. package/src/handler/PopsElementHandler.ts +353 -0
  61. package/src/handler/PopsHandler.ts +659 -0
  62. package/src/svg/arrowLeft.svg +4 -0
  63. package/src/svg/arrowRight.svg +4 -0
  64. package/src/svg/chromeFilled.svg +14 -0
  65. package/src/svg/circleClose.svg +8 -0
  66. package/src/svg/close.svg +5 -0
  67. package/src/svg/cpu.svg +8 -0
  68. package/src/svg/delete.svg +5 -0
  69. package/src/svg/documentCopy.svg +5 -0
  70. package/src/svg/edit.svg +8 -0
  71. package/src/svg/eleme.svg +5 -0
  72. package/src/svg/elemePlus.svg +5 -0
  73. package/src/svg/headset.svg +5 -0
  74. package/src/svg/hide.svg +8 -0
  75. package/src/svg/keyboard.svg +8 -0
  76. package/src/svg/loading.svg +5 -0
  77. package/src/svg/max.svg +5 -0
  78. package/src/svg/min.svg +5 -0
  79. package/src/svg/mise.svg +5 -0
  80. package/src/svg/monitor.svg +5 -0
  81. package/src/svg/next.svg +5 -0
  82. package/src/svg/picture.svg +8 -0
  83. package/src/svg/prev.svg +5 -0
  84. package/src/svg/search.svg +5 -0
  85. package/src/svg/share.svg +5 -0
  86. package/src/svg/upload.svg +5 -0
  87. package/src/svg/videoPause.svg +5 -0
  88. package/src/svg/videoPlay.svg +5 -0
  89. package/src/svg/view.svg +5 -0
  90. package/src/types/PopsDOMUtilsEventType.d.ts +246 -0
  91. package/src/types/animation.d.ts +19 -0
  92. package/src/types/button.d.ts +226 -0
  93. package/src/types/components.d.ts +197 -0
  94. package/src/types/event.d.ts +62 -0
  95. package/src/types/global.d.ts +11 -0
  96. package/src/types/icon.d.ts +32 -0
  97. package/src/types/layer.d.ts +20 -0
  98. package/src/types/main.d.ts +136 -0
  99. package/src/types/mask.d.ts +35 -0
  100. package/src/types/position.d.ts +60 -0
  101. package/src/utils/AnyTouch.js +1394 -0
  102. package/src/utils/PopsDOMUtils.ts +2013 -0
  103. package/src/utils/PopsInstanceUtils.ts +685 -0
  104. package/src/utils/PopsMathUtils.ts +77 -0
  105. package/src/utils/PopsUtils.ts +380 -0
@@ -0,0 +1,353 @@
1
+ import type { PopsAlertDetails } from "../components/alert/indexType";
2
+ import type { PopsConfirmDetails } from "../components/confirm/indexType";
3
+ import type { PopsIframeDetails } from "../components/iframe/indexType";
4
+ import { pops } from "../Pops";
5
+ import type { PopsIcon } from "../types/icon";
6
+ import type {
7
+ PopsSupportAnim,
8
+ PopsSupportBottomBtn,
9
+ PopsSupportContent,
10
+ PopsSupportHeaderTitle,
11
+ PopsTypeSupportAnim,
12
+ PopsTypeSupportBottomBtn,
13
+ PopsTypeSupportContent,
14
+ PopsTypeSupportHeaderTitle,
15
+ } from "../types/main";
16
+ import { popsUtils } from "../utils/PopsUtils";
17
+
18
+ export const PopsElementHandler = {
19
+ /**
20
+ * 获取遮罩层HTML
21
+ * @param guid
22
+ * @param zIndex z-index
23
+ * @param style
24
+ */
25
+ getMaskHTML(guid: string, zIndex: number = 101, style = ""): string {
26
+ zIndex = zIndex - 100;
27
+ return `<div class="pops-mask" data-guid="${guid}" style="z-index:${zIndex};${style}"></div>`;
28
+ },
29
+ /**
30
+ * 获取动画层HTML
31
+ * @param guid
32
+ * @param type
33
+ * @param config
34
+ * @param html
35
+ * @param bottomBtnHTML
36
+ */
37
+ getAnimHTML(
38
+ guid: string,
39
+ type: PopsTypeSupportAnim,
40
+ config: PopsSupportAnim[keyof PopsSupportAnim],
41
+ html = "",
42
+ bottomBtnHTML = ""
43
+ ) {
44
+ let __config = config as PopsAlertDetails;
45
+ let popsAnimStyle = "";
46
+ let popsStyle = "";
47
+ let popsPosition = __config.position || "";
48
+ if (config.zIndex != null) {
49
+ popsAnimStyle += `z-index: ${config.zIndex};`;
50
+ popsStyle += `z-index: ${config.zIndex};`;
51
+ }
52
+ if (__config.width != null) {
53
+ popsStyle += `width: ${__config.width};`;
54
+ }
55
+ if (__config.height != null) {
56
+ popsStyle += `height: ${__config.height};`;
57
+ }
58
+ let hasBottomBtn = bottomBtnHTML.trim() === "" ? false : true;
59
+ return `<div
60
+ class="pops-anim"
61
+ anim="${__config.animation || ""}"
62
+ style="${popsAnimStyle};"
63
+ data-guid="${guid}">
64
+ ${
65
+ config.style != null
66
+ ? `<style tyle="text/css">${config.style}</style>`
67
+ : ""
68
+ }
69
+ <div
70
+ class="pops ${config.class || ""}"
71
+ data-bottom-btn="${hasBottomBtn}"
72
+ type-value="${type}"
73
+ style="${popsStyle}"
74
+ position="${popsPosition}"
75
+ data-guid="${guid}">
76
+ ${html}
77
+ </div>
78
+ </div>`;
79
+ },
80
+ /**
81
+ * 获取顶部按钮层HTML
82
+ * @param type
83
+ * @param config
84
+ */
85
+ getHeaderBtnHTML(
86
+ type: PopsTypeSupportHeaderTitle,
87
+ config: PopsSupportHeaderTitle[keyof PopsSupportHeaderTitle]
88
+ ): string {
89
+ if (!config.btn) {
90
+ return "";
91
+ }
92
+ let __config_confirm = config as PopsConfirmDetails;
93
+ if (type !== "iframe" && !__config_confirm.btn?.close?.enable) {
94
+ return "";
95
+ }
96
+ let resultHTML = "";
97
+ // let btnStyle = "";
98
+ let closeHTML = "";
99
+ let __config_iframe = config as PopsIframeDetails;
100
+ if (type === "iframe" && __config_iframe.topRightButton?.trim() !== "") {
101
+ /* iframe的 */
102
+ let topRightButtonHTML = "";
103
+ __config_iframe.topRightButton.split("|").forEach((item: string) => {
104
+ item = item.toLowerCase();
105
+ topRightButtonHTML += `
106
+ <button class="pops-header-control" type="${item}">
107
+ <i class="pops-icon">${
108
+ (pops.config.iconSVG as any)[item]
109
+ }</i>
110
+ </button>`;
111
+ });
112
+ resultHTML = `
113
+ <div class="pops-header-controls" data-margin>
114
+ ${topRightButtonHTML}
115
+ </div>`;
116
+ } else {
117
+ if (__config_confirm.btn?.close?.enable) {
118
+ closeHTML = `
119
+ <div class="pops-header-controls">
120
+ <button class="pops-header-control" type="close" data-header>
121
+ <i class="pops-icon">${pops.config.iconSVG["close"]}</i>
122
+ </button>
123
+ </div>`;
124
+ }
125
+ resultHTML = closeHTML;
126
+ }
127
+
128
+ return resultHTML;
129
+ },
130
+ /**
131
+ * 获取底部按钮层HTML
132
+ * @param type
133
+ * @param config
134
+ */
135
+ getBottomBtnHTML(
136
+ type: PopsTypeSupportBottomBtn,
137
+ config: PopsSupportBottomBtn[keyof PopsSupportBottomBtn]
138
+ ): string {
139
+ if (!config.btn) {
140
+ // 未设置btn参数
141
+ return "";
142
+ }
143
+ let __config_confirm = config as Required<PopsConfirmDetails>;
144
+ if (
145
+ !(
146
+ config.btn?.ok?.enable ||
147
+ __config_confirm.btn?.cancel?.enable ||
148
+ __config_confirm.btn?.other?.enable
149
+ )
150
+ ) {
151
+ // 确定、取消、其它按钮都未启用直接返回
152
+ return "";
153
+ }
154
+ let btnStyle = "";
155
+ let resultHTML = "";
156
+ let okHTML = "";
157
+ let cancelHTML = "";
158
+ let ohterHTML = "";
159
+
160
+ if (config.btn.position) {
161
+ btnStyle += `justify-content: ${config.btn.position};`;
162
+ }
163
+
164
+ if (__config_confirm.btn.reverse) {
165
+ btnStyle += "flex-direction: row-reverse;";
166
+ }
167
+ if (config.btn?.ok?.enable) {
168
+ /* 处理确定按钮的尺寸问题 */
169
+ let okButtonSizeClassName = "";
170
+ if (config.btn.ok.size === "large") {
171
+ okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
172
+ } else if (config.btn.ok.size === "small") {
173
+ okButtonSizeClassName = "pops-button-" + config.btn.ok.size;
174
+ }
175
+ let okIconHTML = "";
176
+ let okIcon = __config_confirm.btn.ok!.icon! as PopsIcon | string;
177
+ if (okIcon !== "") {
178
+ // 判断图标是否是svg库内的
179
+ let iconHTML = "";
180
+ if (okIcon in pops.config.iconSVG) {
181
+ iconHTML = pops.config.iconSVG[okIcon as PopsIcon];
182
+ } else {
183
+ iconHTML = okIcon;
184
+ }
185
+ iconHTML = iconHTML || "";
186
+ okIconHTML = `
187
+ <i class="pops-bottom-icon" is-loading="${config.btn.ok.iconIsLoading}">
188
+ ${iconHTML}
189
+ </i>`;
190
+ }
191
+ okHTML = `
192
+ <button
193
+ class="pops-${type}-btn-ok ${okButtonSizeClassName}"
194
+ type="${__config_confirm.btn.ok?.type}"
195
+ data-has-icon="${(__config_confirm.btn.ok!.icon || "") !== ""}"
196
+ data-rightIcon="${__config_confirm.btn.ok?.rightIcon}"
197
+ >
198
+ ${okIconHTML}
199
+ <span>${config.btn.ok.text}</span>
200
+ </button>`;
201
+ }
202
+
203
+ if (__config_confirm.btn?.cancel?.enable) {
204
+ /* 处理取消按钮的尺寸问题 */
205
+ let cancelButtonSizeClassName = "";
206
+
207
+ if (__config_confirm.btn.cancel.size === "large") {
208
+ cancelButtonSizeClassName =
209
+ "pops-button-" + __config_confirm.btn.cancel.size;
210
+ } else if (__config_confirm.btn.cancel.size === "small") {
211
+ cancelButtonSizeClassName =
212
+ "pops-button-" + __config_confirm.btn.cancel.size;
213
+ }
214
+ let cancelIconHTML = "";
215
+ let cancelIcon = __config_confirm.btn.cancel!.icon as PopsIcon | string;
216
+ if (cancelIcon !== "") {
217
+ let iconHTML = "";
218
+ // 判断图标是否是svg库内的
219
+ if (cancelIcon in pops.config.iconSVG) {
220
+ iconHTML = pops.config.iconSVG[cancelIcon as PopsIcon];
221
+ } else {
222
+ iconHTML = cancelIcon;
223
+ }
224
+ iconHTML = iconHTML || "";
225
+ cancelIconHTML = `
226
+ <i class="pops-bottom-icon" is-loading="${__config_confirm.btn.cancel.iconIsLoading}">
227
+ ${iconHTML}
228
+ </i>`;
229
+ }
230
+ cancelHTML = `
231
+ <button
232
+ class="pops-${type}-btn-cancel ${cancelButtonSizeClassName}"
233
+ type="${__config_confirm.btn.cancel.type}"
234
+ data-has-icon="${(__config_confirm.btn.cancel.icon || "") !== ""}"
235
+ data-rightIcon="${__config_confirm.btn.cancel.rightIcon}"
236
+ >
237
+ ${cancelIconHTML}
238
+ <span>${__config_confirm.btn.cancel.text}</span>
239
+ </button>`;
240
+ }
241
+
242
+ if (__config_confirm.btn?.other?.enable) {
243
+ /* 处理其它按钮的尺寸问题 */
244
+ let otherButtonSizeClassName = "";
245
+
246
+ if (__config_confirm.btn.other.size === "large") {
247
+ otherButtonSizeClassName =
248
+ "pops-button-" + __config_confirm.btn.other.size;
249
+ } else if (__config_confirm.btn.other.size === "small") {
250
+ otherButtonSizeClassName =
251
+ "pops-button-" + __config_confirm.btn.other.size;
252
+ }
253
+ let otherIconHTML = "";
254
+ let otherIcon = __config_confirm.btn.other!.icon as PopsIcon | string;
255
+ if (otherIcon !== "") {
256
+ let iconHTML = "";
257
+ // 判断图标是否是svg库内的
258
+ if (otherIcon in pops.config.iconSVG) {
259
+ iconHTML = pops.config.iconSVG[otherIcon as PopsIcon];
260
+ } else {
261
+ otherIcon;
262
+ }
263
+ iconHTML = iconHTML || "";
264
+ otherIconHTML = `
265
+ <i class="pops-bottom-icon" is-loading="${__config_confirm.btn.other.iconIsLoading}">
266
+ ${iconHTML}
267
+ </i>`;
268
+ }
269
+ ohterHTML = `
270
+ <button
271
+ class="pops-${type}-btn-other ${otherButtonSizeClassName}"
272
+ type="${__config_confirm.btn.other.type}"
273
+ data-has-icon="${(__config_confirm.btn.other.icon || "") !== ""}"
274
+ data-rightIcon="${__config_confirm.btn.other.rightIcon}"
275
+ >
276
+ ${otherIconHTML}
277
+ <span>${__config_confirm.btn.other.text}</span>
278
+ </button>`;
279
+ }
280
+
281
+ if (__config_confirm.btn.merge) {
282
+ let flexStyle = "display: flex;";
283
+ if (__config_confirm.btn.mergeReverse) {
284
+ flexStyle += "flex-direction: row-reverse;";
285
+ } else {
286
+ flexStyle += "flex-direction: row;";
287
+ }
288
+ resultHTML = `
289
+ <div class="pops-${type}-btn" style="${btnStyle}">
290
+ ${ohterHTML}
291
+ <div
292
+ class="pops-${type}-btn-merge"
293
+ style="${flexStyle}">
294
+ ${okHTML}
295
+ ${cancelHTML}
296
+ </div>
297
+ </div>
298
+ `;
299
+ } else {
300
+ resultHTML = `
301
+ <div class="pops-${type}-btn" style="${btnStyle}">
302
+ ${okHTML}
303
+ ${cancelHTML}
304
+ ${ohterHTML}
305
+ </div>
306
+ `;
307
+ }
308
+ return resultHTML;
309
+ },
310
+ /**
311
+ * 获取标题style
312
+ * @param type
313
+ * @param config
314
+ */
315
+
316
+ getHeaderStyle(
317
+ type: PopsTypeSupportHeaderTitle,
318
+ config: PopsSupportHeaderTitle[keyof PopsSupportHeaderTitle]
319
+ ) {
320
+ return {
321
+ headerStyle: config?.title?.html ? config?.title?.style || "" : "",
322
+
323
+ headerPStyle: config?.title?.html ? "" : config?.title?.style || "",
324
+ };
325
+ },
326
+ /**
327
+ * 获取内容style
328
+ * @param type
329
+ * @param config
330
+ */
331
+
332
+ getContentStyle(
333
+ type: PopsTypeSupportContent,
334
+ config: PopsSupportContent[keyof PopsSupportContent]
335
+ ) {
336
+ return {
337
+ contentStyle: (config?.content as any)?.html
338
+ ? config?.content?.style || ""
339
+ : "",
340
+
341
+ contentPStyle: (config?.content as any)?.html
342
+ ? ""
343
+ : config?.content?.style || "",
344
+ };
345
+ },
346
+ /**
347
+ * 将html转换成元素
348
+ * @param html
349
+ */
350
+ parseElement<T extends HTMLElement>(html: string): T {
351
+ return popsUtils.parseTextToDOM(html);
352
+ },
353
+ };