@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,659 @@
1
+ import type { PopsAlertDetails } from "../components/alert/indexType";
2
+ import type { PopsConfirmDetails } from "../components/confirm/indexType";
3
+ import type { PopsDrawerDetails } from "../components/drawer/indexType";
4
+ import type { PopsFolderDetails } from "../components/folder/indexType";
5
+ import type { PopsIframeDetails } from "../components/iframe/indexType";
6
+ import type { PopsLoadingDetails } from "../components/loading/indexType";
7
+ import type { PopsPanelDetails } from "../components/panel/indexType";
8
+ import type { PopsPromptDetails } from "../components/prompt/indexType";
9
+ import { PopsCore } from "../Core";
10
+ import { pops } from "../Pops";
11
+ import { PopsEventDetails, PopsHandlerEventDetails } from "../types/event";
12
+ import { PopsLayerCommonConfig } from "../types/layer";
13
+ import type {
14
+ PopsAllDetails,
15
+ PopsLayerMode,
16
+ PopsMode,
17
+ PopsType,
18
+ } from "../types/main";
19
+ import { popsDOMUtils } from "../utils/PopsDOMUtils";
20
+ import { PopsInstanceUtils } from "../utils/PopsInstanceUtils";
21
+ import { popsUtils } from "../utils/PopsUtils";
22
+
23
+ export const PopsHandler = {
24
+ /**
25
+ * 创建shadow
26
+ */
27
+ handlerShadow() {
28
+ let $shadowContainer = document.createElement("div");
29
+ $shadowContainer.className = "pops-shadow-container";
30
+ let $shadowRoot = $shadowContainer.attachShadow({ mode: "open" });
31
+ return {
32
+ $shadowContainer,
33
+ $shadowRoot,
34
+ };
35
+ },
36
+ /**
37
+ * 处理初始化
38
+ * @param $shadowRoot 所在的shadowRoot
39
+ * @param cssText 添加进ShadowRoot的CSS
40
+ */
41
+ handleInit($shadowRoot?: ShadowRoot, cssText?: string | string[]) {
42
+ pops.init();
43
+ if (!arguments.length) {
44
+ return;
45
+ }
46
+ if (Array.isArray(cssText)) {
47
+ for (let index = 0; index < cssText.length; index++) {
48
+ this.handleInit($shadowRoot, cssText[index]);
49
+ }
50
+ } else {
51
+ let $css = popsDOMUtils.createElement(
52
+ "style",
53
+ {
54
+ innerHTML: cssText,
55
+ },
56
+ {
57
+ "data-type": "PopsHandler.handleInit",
58
+ }
59
+ );
60
+ $shadowRoot!.appendChild($css);
61
+ }
62
+ },
63
+ /**
64
+ * 处理遮罩层
65
+ * @param details 传递的配置
66
+ */
67
+ handleMask(
68
+ details = {} as {
69
+ type:
70
+ | "alert"
71
+ | "confirm"
72
+ | "prompt"
73
+ | "loading"
74
+ | "iframe"
75
+ | "drawer"
76
+ | "folder"
77
+ | "panel";
78
+ guid: string;
79
+ config:
80
+ | Required<PopsAlertDetails>
81
+ | Required<PopsLoadingDetails>
82
+ | Required<PopsIframeDetails>
83
+ | Required<PopsDrawerDetails>
84
+ | Required<PopsPanelDetails>
85
+ | Required<PopsFolderDetails>;
86
+ animElement: HTMLElement;
87
+ maskHTML: string;
88
+ }
89
+ ): {
90
+ maskElement: HTMLDivElement;
91
+ } {
92
+ let result = {
93
+ maskElement: popsUtils.parseTextToDOM<HTMLDivElement>(details.maskHTML),
94
+ };
95
+ let isMaskClick = false;
96
+ /**
97
+ * 点击其它区域的事件
98
+ * @param event
99
+ */
100
+ function clickEvent(event: MouseEvent | PointerEvent) {
101
+ popsDOMUtils.preventEvent(event);
102
+ // 获取该类型实例存储列表
103
+ let targetLayer = pops.config.layer[details.type];
104
+ function originalRun() {
105
+ if (details.config.mask!.clickEvent!.toClose) {
106
+ /* 关闭 */
107
+ PopsInstanceUtils.close(
108
+ details.type,
109
+ targetLayer,
110
+ details.guid,
111
+ details.config,
112
+ details.animElement
113
+ );
114
+ } else if (details.config.mask!.clickEvent!.toHide) {
115
+ /* 隐藏 */
116
+ PopsInstanceUtils.hide(
117
+ details.type,
118
+ targetLayer,
119
+ details.guid,
120
+ details.config,
121
+ details.animElement,
122
+ result.maskElement
123
+ );
124
+ }
125
+ }
126
+ if (typeof details.config.mask.clickCallBack === "function") {
127
+ details.config.mask.clickCallBack(originalRun, details.config);
128
+ } else {
129
+ originalRun();
130
+ }
131
+ return false;
132
+ }
133
+ function isAnimElement(element: HTMLDivElement) {
134
+ return Boolean(
135
+ element?.localName?.toLowerCase() === "div" &&
136
+ element.className &&
137
+ element.className === "pops-anim" &&
138
+ element.hasAttribute("anim")
139
+ );
140
+ }
141
+ if (
142
+ details.config.mask.clickEvent!.toClose ||
143
+ details.config.mask.clickEvent!.toHide
144
+ ) {
145
+ /* 判断按下的元素是否是pops-anim */
146
+ popsDOMUtils.on(
147
+ details.animElement,
148
+ ["touchstart", "mousedown"],
149
+ void 0,
150
+ (event) => {
151
+ isMaskClick = isAnimElement(
152
+ event.composedPath()[0] as HTMLDivElement
153
+ );
154
+ }
155
+ );
156
+ /* 如果有动画层,在动画层上监听点击事件 */
157
+ popsDOMUtils.on<MouseEvent | PointerEvent>(
158
+ details.animElement,
159
+ "click",
160
+ void 0,
161
+ (event) => {
162
+ if (
163
+ isAnimElement(event.composedPath()[0] as HTMLDivElement) &&
164
+ isMaskClick
165
+ ) {
166
+ return clickEvent(event);
167
+ }
168
+ }
169
+ );
170
+ /* 在遮罩层监听点击事件 */
171
+ /* 如果有动画层,那么该点击事件触发不了 */
172
+ popsDOMUtils.on<MouseEvent | PointerEvent>(
173
+ result.maskElement,
174
+ "click",
175
+ void 0,
176
+ (event) => {
177
+ isMaskClick = true;
178
+ clickEvent(event);
179
+ }
180
+ );
181
+ }
182
+ return result;
183
+ },
184
+ /**
185
+ * 处理获取元素
186
+ * @param {HTMLDivElement} animElement
187
+ * @param type
188
+ */
189
+ handleQueryElement(animElement: HTMLDivElement, type: PopsType) {
190
+ return {
191
+ /**
192
+ * 主元素
193
+ */
194
+ popsElement:
195
+ animElement.querySelector<HTMLDivElement>(".pops[type-value")!,
196
+ /**
197
+ * 确认按钮
198
+ */
199
+ btnOkElement: animElement.querySelector<HTMLDivElement>(
200
+ `.pops-${type}-btn-ok`
201
+ )!,
202
+ /**
203
+ * 取消按钮
204
+ */
205
+ btnCancelElement: animElement.querySelector<HTMLDivElement>(
206
+ `.pops-${type}-btn-cancel`
207
+ )!,
208
+ /**
209
+ * 其它按钮
210
+ */
211
+ btnOtherElement: animElement.querySelector<HTMLDivElement>(
212
+ `.pops-${type}-btn-other`
213
+ )!,
214
+ /**
215
+ * 标题元素
216
+ */
217
+ titleElement: animElement.querySelector<HTMLDivElement>(
218
+ `.pops-${type}-title`
219
+ )!,
220
+ /**
221
+ * 输入框元素
222
+ */
223
+ inputElement: animElement.querySelector<HTMLTextAreaElement>(
224
+ `.pops-${type}-content textarea[pops]`
225
+ )
226
+ ? animElement.querySelector<HTMLTextAreaElement>(
227
+ `.pops-${type}-content textarea[pops]`
228
+ )!
229
+ : animElement.querySelector<HTMLInputElement>(
230
+ `.pops-${type}-content input[pops]`
231
+ )!,
232
+ /**
233
+ * 顶部按钮控制层元素
234
+ */
235
+ headerControlsElement: animElement.querySelector<HTMLDivElement>(
236
+ ".pops-header-controls"
237
+ )!,
238
+ /**
239
+ * iframe元素
240
+ */
241
+ iframeElement:
242
+ animElement.querySelector<HTMLIFrameElement>("iframe[pops]")!,
243
+ /**
244
+ * 加载中元素
245
+ */
246
+ loadingElement:
247
+ animElement.querySelector<HTMLDivElement>(".pops-loading")!,
248
+ /**
249
+ * 内容元素
250
+ */
251
+ contentElement: animElement.querySelector<HTMLDivElement>(
252
+ `.pops-${type}-content`
253
+ )!,
254
+ /**
255
+ * 内容侧边栏容器元素
256
+ */
257
+ contentAsideElement: animElement.querySelector<HTMLDivElement>(
258
+ `.pops-${type}-content aside.pops-${type}-aside`
259
+ )!,
260
+ /**
261
+ * 内容主要区域容器元素
262
+ */
263
+ contentSectionContainerElement: animElement.querySelector<HTMLDivElement>(
264
+ `.pops-${type}-content section.pops-${type}-container`
265
+ )!,
266
+ /**
267
+ * 内容加载中元素
268
+ */
269
+ contentLoadingElement: animElement.querySelector<HTMLDivElement>(
270
+ `.pops-${type}-content-global-loading`
271
+ )!,
272
+ /**
273
+ * 顶部缩小按钮
274
+ */
275
+ headerMinBtnElement: animElement.querySelector<HTMLDivElement>(
276
+ ".pops-header-control[type='min']"
277
+ )!,
278
+ /**
279
+ * 顶部放大按钮
280
+ */
281
+ headerMaxBtnElement: animElement.querySelector<HTMLDivElement>(
282
+ ".pops-header-control[type='max']"
283
+ )!,
284
+ /**
285
+ * 顶部恢复原样按钮
286
+ */
287
+ headerMiseBtnElement: animElement.querySelector<HTMLDivElement>(
288
+ ".pops-header-control[type='mise']"
289
+ )!,
290
+ /**
291
+ * 顶部关闭按钮
292
+ */
293
+ headerCloseBtnElement: animElement.querySelector<HTMLDivElement>(
294
+ ".pops-header-control[type='close']"
295
+ )!,
296
+ /**
297
+ * 文件夹列表元素
298
+ */
299
+ folderListElement:
300
+ animElement.querySelector<HTMLDivElement>(".pops-folder-list")!,
301
+ /**
302
+ * 文件夹列表顶部元素
303
+ */
304
+ folderListHeaderElement: animElement.querySelector<HTMLDivElement>(
305
+ ".pops-folder-list .pops-folder-list-table__header-div"
306
+ )!,
307
+ /**
308
+ * 文件夹列表行元素
309
+ */
310
+ folderListHeaderRowElement:
311
+ animElement.querySelector<HTMLTableRowElement>(
312
+ ".pops-folder-list .pops-folder-list-table__header-div .pops-folder-list-table__header-row"
313
+ )!,
314
+ /**
315
+ * 文件夹列表tbody元素
316
+ */
317
+ folderListBodyElement: animElement.querySelector<HTMLTableElement>(
318
+ ".pops-folder-list .pops-folder-list-table__body-div tbody"
319
+ )!,
320
+ /**
321
+ * 文件夹列表primary元素
322
+ */
323
+ folderFileListBreadcrumbPrimaryElement:
324
+ animElement.querySelector<HTMLDivElement>(
325
+ ".pops-folder-list .pops-folder-file-list-breadcrumb-primary"
326
+ )!,
327
+ /**
328
+ * 文件夹排序按钮-文件名
329
+ */
330
+ folderListSortFileNameElement: animElement.querySelector<HTMLDivElement>(
331
+ '.pops-folder-list-table__sort[data-sort="fileName"]'
332
+ )!,
333
+ /**
334
+ * 文件夹排序按钮-修改时间
335
+ */
336
+ folderListSortLatestTimeElement:
337
+ animElement.querySelector<HTMLDivElement>(
338
+ '.pops-folder-list-table__sort[data-sort="latestTime"]'
339
+ )!,
340
+ /**
341
+ * 文件夹排序按钮-文件大小
342
+ */
343
+ folderListSortFileSizeElement: animElement.querySelector<HTMLDivElement>(
344
+ '.pops-folder-list-table__sort[data-sort="fileSize"]'
345
+ )!,
346
+ };
347
+ },
348
+ /**
349
+ * 获取事件配置
350
+ * @param guid
351
+ * @param $shadowContainer
352
+ * @param $shadowRoot
353
+ * @param mode 当前弹窗类型
354
+ * @param animElement 动画层
355
+ * @param popsElement 主元素
356
+ * @param maskElement 遮罩层
357
+ * @param config 当前配置
358
+ */
359
+ handleEventDetails(
360
+ guid: string,
361
+ $shadowContainer: HTMLDivElement,
362
+ $shadowRoot: ShadowRoot,
363
+ mode: PopsLayerMode,
364
+ animElement: HTMLDivElement,
365
+ popsElement: HTMLDivElement,
366
+ maskElement: HTMLDivElement,
367
+ config:
368
+ | PopsAlertDetails
369
+ | PopsDrawerDetails
370
+ | PopsPromptDetails
371
+ | PopsConfirmDetails
372
+ | PopsIframeDetails
373
+ | PopsLoadingDetails
374
+ | PopsPanelDetails
375
+ | PopsFolderDetails
376
+ ): PopsEventDetails {
377
+ return {
378
+ $shadowContainer: $shadowContainer,
379
+ $shadowRoot: $shadowRoot,
380
+ element: animElement,
381
+ animElement: animElement,
382
+ popsElement: popsElement,
383
+ maskElement: maskElement,
384
+ mode: mode,
385
+ guid: guid,
386
+ close() {
387
+ PopsInstanceUtils.close(
388
+ mode,
389
+ pops.config.layer[mode],
390
+ guid,
391
+ config,
392
+ animElement
393
+ );
394
+ },
395
+ hide() {
396
+ PopsInstanceUtils.hide(
397
+ mode,
398
+ pops.config.layer[mode],
399
+ guid,
400
+ config,
401
+ animElement,
402
+ maskElement
403
+ );
404
+ },
405
+ show() {
406
+ PopsInstanceUtils.show(
407
+ mode,
408
+ pops.config.layer[mode],
409
+ guid,
410
+ config,
411
+ animElement,
412
+ maskElement
413
+ );
414
+ },
415
+ };
416
+ },
417
+ /**
418
+ * 获取loading的事件配置
419
+ * @param guid
420
+ * @param mode 当前弹窗类型
421
+ * @param animElement 动画层
422
+ * @param popsElement 主元素
423
+ * @param maskElement 遮罩层
424
+ * @param config 当前配置
425
+ */
426
+ handleLoadingEventDetails(
427
+ guid: string,
428
+ mode: "loading",
429
+ animElement: HTMLDivElement,
430
+ popsElement: HTMLDivElement,
431
+ maskElement: HTMLDivElement,
432
+ config:
433
+ | PopsAlertDetails
434
+ | PopsDrawerDetails
435
+ | PopsPromptDetails
436
+ | PopsConfirmDetails
437
+ | PopsIframeDetails
438
+ | PopsLoadingDetails
439
+ | PopsPanelDetails
440
+ | PopsFolderDetails
441
+ ): Omit<PopsEventDetails, "$shadowContainer" | "$shadowRoot"> {
442
+ return {
443
+ element: animElement,
444
+ animElement: animElement,
445
+ popsElement: popsElement,
446
+ maskElement: maskElement,
447
+ mode: mode,
448
+ guid: guid,
449
+ close() {
450
+ PopsInstanceUtils.close(
451
+ mode,
452
+ pops.config.layer[mode],
453
+ guid,
454
+ config,
455
+ animElement
456
+ );
457
+ },
458
+ hide() {
459
+ PopsInstanceUtils.hide(
460
+ mode,
461
+ pops.config.layer[mode],
462
+ guid,
463
+ config,
464
+ animElement,
465
+ maskElement
466
+ );
467
+ },
468
+ show() {
469
+ PopsInstanceUtils.show(
470
+ mode,
471
+ pops.config.layer[mode],
472
+ guid,
473
+ config,
474
+ animElement,
475
+ maskElement
476
+ );
477
+ },
478
+ };
479
+ },
480
+ /**
481
+ * 处理返回的配置,针对popsHandler.handleEventDetails
482
+ */
483
+ handleResultDetails(details: any): {
484
+ $shadowContainer: HTMLDivElement;
485
+ $shadowRoot: ShadowRoot;
486
+ animElement: HTMLElement;
487
+ popsElement: HTMLElement;
488
+ maskElement: HTMLElement;
489
+ close: () => void;
490
+ hide: () => void;
491
+ show: () => void;
492
+ } {
493
+ let resultDetails = Object.assign({}, details);
494
+ popsUtils.delete(resultDetails, "type");
495
+ popsUtils.delete(resultDetails, "function");
496
+ return resultDetails;
497
+ },
498
+ /**
499
+ * 处理点击事件
500
+ * @param type 当前按钮类型
501
+ * @param $btn 按钮元素
502
+ * @param eventDetails 事件配置,由popsHandler.handleEventDetails创建的
503
+ * @param callback 点击回调
504
+ */
505
+ handleClickEvent(
506
+ type: "cancel" | "close" | "ok" | "other",
507
+ $btn: HTMLElement,
508
+ eventDetails: PopsEventDetails,
509
+ callback: (
510
+ details: PopsHandlerEventDetails,
511
+ event: PointerEvent | MouseEvent
512
+ ) => void
513
+ ) {
514
+ popsDOMUtils.on<PointerEvent | MouseEvent>(
515
+ $btn,
516
+ "click",
517
+ (event) => {
518
+ let extraParam = {
519
+ type: type,
520
+ };
521
+ callback(Object.assign(eventDetails, extraParam), event);
522
+ },
523
+ {
524
+ capture: true,
525
+ }
526
+ );
527
+ },
528
+ /**
529
+ * 全局监听键盘事件
530
+ * @param keyName 键名|键值
531
+ * @param otherKeyList 组合按键,数组类型,包含ctrl、shift、alt和meta(win键或mac的cmd键)
532
+ * @param callback 回调函数
533
+ */
534
+ handleKeyboardEvent(
535
+ keyName: string | number,
536
+ otherKeyList: string[] = [],
537
+ callback: (event: KeyboardEvent) => void
538
+ ) {
539
+ let keyboardEvent = function (event: KeyboardEvent) {
540
+ let _keyName = event.code || event.key;
541
+ let _keyValue = event.charCode || event.keyCode || event.which;
542
+ if (otherKeyList.includes("ctrl") && !event.ctrlKey) {
543
+ return;
544
+ }
545
+ if (otherKeyList.includes("alt") && !event.altKey) {
546
+ return;
547
+ }
548
+ if (otherKeyList.includes("meta") && !event.metaKey) {
549
+ return;
550
+ }
551
+ if (otherKeyList.includes("shift") && !event.shiftKey) {
552
+ return;
553
+ }
554
+ if (typeof keyName === "string" && keyName === _keyName) {
555
+ callback && callback(event);
556
+ } else if (typeof keyName === "number" && keyName === _keyValue) {
557
+ callback && callback(event);
558
+ }
559
+ };
560
+ popsDOMUtils.on(PopsCore.globalThis, "keydown", keyboardEvent, {
561
+ capture: true,
562
+ });
563
+ return {
564
+ removeKeyboardEvent() {
565
+ popsDOMUtils.off(globalThis, "keydown", keyboardEvent, {
566
+ capture: true,
567
+ });
568
+ },
569
+ };
570
+ },
571
+ /**
572
+ * 处理prompt的点击事件
573
+ * @param type 触发事件类型
574
+ * @param inputElement 输入框
575
+ * @param $btn 按钮元素
576
+ * @param eventDetails 事件配置,由popsHandler.handleEventDetails创建的
577
+ * @param callback 点击回调
578
+ */
579
+ handlePromptClickEvent(
580
+ type: "ok" | "close" | "cancel" | "other",
581
+ inputElement: HTMLInputElement | HTMLTextAreaElement,
582
+ $btn: HTMLElement,
583
+ eventDetails: PopsEventDetails,
584
+ callback: (
585
+ details: PopsEventDetails & {
586
+ type: any;
587
+ text: string;
588
+ },
589
+ event: MouseEvent | PointerEvent
590
+ ) => void
591
+ ) {
592
+ popsDOMUtils.on<MouseEvent | PointerEvent>(
593
+ $btn,
594
+ "click",
595
+ (event) => {
596
+ // 额外参数
597
+ let extraParam = {
598
+ type: type,
599
+ text: inputElement.value,
600
+ };
601
+ callback(Object.assign(eventDetails, extraParam), event);
602
+ },
603
+ {
604
+ capture: true,
605
+ }
606
+ );
607
+ },
608
+ /**
609
+ * 处理config.only
610
+ * @param type 当前弹窗类型
611
+ * @param config 配置
612
+ */
613
+ handleOnly<T extends Required<PopsAllDetails[keyof PopsAllDetails]>>(
614
+ type: PopsMode,
615
+ config: T
616
+ ): T {
617
+ if (config.only) {
618
+ if (
619
+ type === "loading" ||
620
+ type === "tooltip" ||
621
+ type === "rightClickMenu"
622
+ ) {
623
+ PopsInstanceUtils.removeInstance(
624
+ [(pops.config.layer as any)[type]],
625
+ "",
626
+ true
627
+ );
628
+ } else {
629
+ PopsInstanceUtils.removeInstance(
630
+ [
631
+ pops.config.layer.alert,
632
+ pops.config.layer.confirm,
633
+ pops.config.layer.prompt,
634
+ pops.config.layer.iframe,
635
+ pops.config.layer.drawer,
636
+ pops.config.layer.folder,
637
+ pops.config.layer.panel,
638
+ ],
639
+ "",
640
+ true
641
+ );
642
+ }
643
+ } else {
644
+ const { zIndex: maxZIndex } = PopsInstanceUtils.getPopsMaxZIndex(
645
+ config.zIndex + 100
646
+ );
647
+ config.zIndex = maxZIndex;
648
+ }
649
+ return config;
650
+ },
651
+ /**
652
+ * 处理把已创建的元素保存到内部环境中
653
+ * @param type 当前弹窗类型
654
+ * @param value
655
+ */
656
+ handlePush(type: PopsLayerMode, value: PopsLayerCommonConfig) {
657
+ pops.config.layer[type].push(value);
658
+ },
659
+ };
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
2
+ <path
3
+ d="M609.408 149.376 277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"></path>
4
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
2
+ <path
3
+ d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"></path>
4
+ </svg>
@@ -0,0 +1,14 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ viewBox="0 0 1024 1024"
4
+ xml:space="preserve">
5
+ <path
6
+ d="M938.67 512.01c0-44.59-6.82-87.6-19.54-128H682.67a212.372 212.372 0 0 1 42.67 128c.06 38.71-10.45 76.7-30.42 109.87l-182.91 316.8c235.65-.01 426.66-191.02 426.66-426.67z"
7
+ fill="currentColor"></path>
8
+ <path
9
+ d="M576.79 401.63a127.92 127.92 0 0 0-63.56-17.6c-22.36-.22-44.39 5.43-63.89 16.38s-35.79 26.82-47.25 46.02a128.005 128.005 0 0 0-2.16 127.44l1.24 2.13a127.906 127.906 0 0 0 46.36 46.61 127.907 127.907 0 0 0 63.38 17.44c22.29.2 44.24-5.43 63.68-16.33a127.94 127.94 0 0 0 47.16-45.79v-.01l1.11-1.92a127.984 127.984 0 0 0 .29-127.46 127.957 127.957 0 0 0-46.36-46.91z"
10
+ fill="currentColor"></path>
11
+ <path
12
+ d="M394.45 333.96A213.336 213.336 0 0 1 512 298.67h369.58A426.503 426.503 0 0 0 512 85.34a425.598 425.598 0 0 0-171.74 35.98 425.644 425.644 0 0 0-142.62 102.22l118.14 204.63a213.397 213.397 0 0 1 78.67-94.21zM512.01 938.68H512zM414.76 701.95a213.284 213.284 0 0 1-89.54-86.81L142.48 298.6c-36.35 62.81-57.13 135.68-57.13 213.42 0 203.81 142.93 374.22 333.95 416.55h.04l118.19-204.71a213.315 213.315 0 0 1-122.77-21.91z"
13
+ fill="currentColor"></path>
14
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
2
+ <path
3
+ fill="currentColor"
4
+ d="m466.752 512-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248z"></path>
5
+ <path
6
+ fill="currentColor"
7
+ d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"></path>
8
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
2
+ <path
3
+ fill="currentColor"
4
+ d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path>
5
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
2
+ <path
3
+ fill="currentColor"
4
+ d="M320 256a64 64 0 0 0-64 64v384a64 64 0 0 0 64 64h384a64 64 0 0 0 64-64V320a64 64 0 0 0-64-64H320zm0-64h384a128 128 0 0 1 128 128v384a128 128 0 0 1-128 128H320a128 128 0 0 1-128-128V320a128 128 0 0 1 128-128z"></path>
5
+ <path
6
+ fill="currentColor"
7
+ d="M512 64a32 32 0 0 1 32 32v128h-64V96a32 32 0 0 1 32-32zm160 0a32 32 0 0 1 32 32v128h-64V96a32 32 0 0 1 32-32zm-320 0a32 32 0 0 1 32 32v128h-64V96a32 32 0 0 1 32-32zm160 896a32 32 0 0 1-32-32V800h64v128a32 32 0 0 1-32 32zm160 0a32 32 0 0 1-32-32V800h64v128a32 32 0 0 1-32 32zm-320 0a32 32 0 0 1-32-32V800h64v128a32 32 0 0 1-32 32zM64 512a32 32 0 0 1 32-32h128v64H96a32 32 0 0 1-32-32zm0-160a32 32 0 0 1 32-32h128v64H96a32 32 0 0 1-32-32zm0 320a32 32 0 0 1 32-32h128v64H96a32 32 0 0 1-32-32zm896-160a32 32 0 0 1-32 32H800v-64h128a32 32 0 0 1 32 32zm0-160a32 32 0 0 1-32 32H800v-64h128a32 32 0 0 1 32 32zm0 320a32 32 0 0 1-32 32H800v-64h128a32 32 0 0 1 32 32z"></path>
8
+ </svg>