@whitesev/pops 2.0.2 → 2.0.4

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 (38) hide show
  1. package/dist/index.amd.js +217 -328
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +217 -328
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +217 -328
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +217 -328
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +217 -328
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +217 -328
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/Pops.d.ts +3 -3
  14. package/dist/types/src/components/searchSuggestion/indexType.d.ts +1 -1
  15. package/dist/types/src/handler/PopsElementHandler.d.ts +4 -4
  16. package/dist/types/src/types/event.d.ts +3 -3
  17. package/dist/types/src/types/mask.d.ts +1 -1
  18. package/dist/types/src/utils/PopsInstanceUtils.d.ts +3 -3
  19. package/package.json +1 -1
  20. package/src/Pops.ts +1 -1
  21. package/src/components/alert/index.ts +13 -20
  22. package/src/components/confirm/index.ts +10 -20
  23. package/src/components/drawer/index.ts +11 -26
  24. package/src/components/folder/index.ts +11 -20
  25. package/src/components/iframe/index.ts +14 -23
  26. package/src/components/loading/index.ts +10 -9
  27. package/src/components/panel/PanelHandleContentDetails.ts +14 -36
  28. package/src/components/panel/index.ts +7 -11
  29. package/src/components/prompt/index.ts +16 -23
  30. package/src/components/rightClickMenu/index.ts +9 -7
  31. package/src/components/searchSuggestion/index.ts +8 -13
  32. package/src/components/searchSuggestion/indexType.ts +1 -1
  33. package/src/handler/PopsElementHandler.ts +33 -72
  34. package/src/handler/PopsHandler.ts +9 -11
  35. package/src/types/event.d.ts +3 -3
  36. package/src/types/mask.d.ts +1 -1
  37. package/src/utils/PopsDOMUtils.ts +21 -19
  38. package/src/utils/PopsInstanceUtils.ts +120 -96
@@ -268,24 +268,29 @@ export const PopsInstanceUtils = {
268
268
  animElement: HTMLElement,
269
269
  maskElement: HTMLElement
270
270
  ) {
271
- let popsElement =
272
- animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
273
- if (popsType === "drawer") {
274
- let drawerConfig = config as Required<PopsDrawerDetails>;
275
- setTimeout(() => {
276
- maskElement.style.setProperty("display", "none");
277
- if (["top", "bottom"].includes(drawerConfig.direction)) {
278
- popsElement.style.setProperty("height", "0");
279
- } else if (["left", "right"].includes(drawerConfig.direction)) {
280
- popsElement.style.setProperty("width", "0");
281
- } else {
282
- console.error("未知direction:", drawerConfig.direction);
283
- }
284
- }, drawerConfig.closeDelay);
285
- } else {
286
- layerConfigList.forEach((layerConfigItem) => {
287
- if (layerConfigItem.guid === guid) {
271
+ return new Promise<void>((resolve) => {
272
+ let popsElement =
273
+ animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
274
+ if (popsType === "drawer") {
275
+ let drawerConfig = config as Required<PopsDrawerDetails>;
276
+ setTimeout(() => {
277
+ maskElement.style.setProperty("display", "none");
278
+ if (["top", "bottom"].includes(drawerConfig.direction)) {
279
+ popsElement.style.setProperty("height", "0");
280
+ } else if (["left", "right"].includes(drawerConfig.direction)) {
281
+ popsElement.style.setProperty("width", "0");
282
+ } else {
283
+ console.error("未知direction:", drawerConfig.direction);
284
+ }
285
+ resolve();
286
+ }, drawerConfig.closeDelay);
287
+ } else {
288
+ let findLayerIns = layerConfigList.find(
289
+ (layerConfigItem) => layerConfigItem.guid === guid
290
+ );
291
+ if (findLayerIns) {
288
292
  /* 存在动画 */
293
+ let layerConfigItem = findLayerIns;
289
294
  layerConfigItem.animElement.style.width = "100%";
290
295
  layerConfigItem.animElement.style.height = "100%";
291
296
  (layerConfigItem.animElement.style as any)["animation-name"] =
@@ -295,6 +300,9 @@ export const PopsInstanceUtils = {
295
300
  (layerConfigItem.animElement.style as any)["animation-name"]
296
301
  )
297
302
  ) {
303
+ /**
304
+ * 动画结束的回调
305
+ */
298
306
  function animationendCallBack() {
299
307
  layerConfigItem.animElement.style.display = "none";
300
308
  if (layerConfigItem.maskElement) {
@@ -308,6 +316,7 @@ export const PopsInstanceUtils = {
308
316
  capture: true,
309
317
  }
310
318
  );
319
+ resolve();
311
320
  }
312
321
  popsDOMUtils.on(
313
322
  layerConfigItem.animElement,
@@ -322,14 +331,13 @@ export const PopsInstanceUtils = {
322
331
  if (layerConfigItem.maskElement) {
323
332
  layerConfigItem.maskElement.style.display = "none";
324
333
  }
325
- }
326
334
 
327
- return;
335
+ resolve();
336
+ }
328
337
  }
329
- });
330
- }
338
+ }
339
+ });
331
340
  },
332
-
333
341
  /**
334
342
  * 显示
335
343
  * @param popsType
@@ -353,27 +361,32 @@ export const PopsInstanceUtils = {
353
361
  | PopsPanelDetails
354
362
  | PopsFolderDetails,
355
363
  animElement: HTMLElement,
356
- maskElement: HTMLElement
364
+ maskElement?: HTMLElement
357
365
  ) {
358
- let popsElement =
359
- animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
360
- if (popsType === "drawer") {
361
- let drawerConfig = config as PopsDrawerDetails;
362
- setTimeout(() => {
363
- maskElement.style.setProperty("display", "");
364
- let direction = drawerConfig.direction!;
365
- let size = drawerConfig.size!.toString();
366
- if (["top", "bottom"].includes(direction)) {
367
- popsElement.style.setProperty("height", size);
368
- } else if (["left", "right"].includes(direction)) {
369
- popsElement.style.setProperty("width", size);
370
- } else {
371
- console.error("未知direction:", direction);
372
- }
373
- }, drawerConfig.openDelay);
374
- } else {
375
- layerConfigList.forEach((layerConfigItem) => {
376
- if (layerConfigItem.guid === guid) {
366
+ return new Promise<void>((resolve) => {
367
+ let popsElement =
368
+ animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
369
+ if (popsType === "drawer") {
370
+ let drawerConfig = config as PopsDrawerDetails;
371
+ setTimeout(() => {
372
+ popsDOMUtils.css(maskElement!, "display", "");
373
+ let direction = drawerConfig.direction!;
374
+ let size = drawerConfig.size!.toString();
375
+ if (["top", "bottom"].includes(direction)) {
376
+ popsElement.style.setProperty("height", size);
377
+ } else if (["left", "right"].includes(direction)) {
378
+ popsElement.style.setProperty("width", size);
379
+ } else {
380
+ console.error("未知direction:", direction);
381
+ }
382
+ resolve();
383
+ }, drawerConfig.openDelay);
384
+ } else {
385
+ let findLayerIns = layerConfigList.find(
386
+ (layerConfigItem) => layerConfigItem.guid === guid
387
+ );
388
+ if (findLayerIns) {
389
+ let layerConfigItem = findLayerIns;
377
390
  layerConfigItem.animElement.style.width = "";
378
391
  layerConfigItem.animElement.style.height = "";
379
392
  (layerConfigItem.animElement.style as any)["animation-name"] =
@@ -385,10 +398,9 @@ export const PopsInstanceUtils = {
385
398
  (layerConfigItem.animElement.style as any)["animation-name"]
386
399
  )
387
400
  ) {
388
- layerConfigItem.animElement.style.display = "";
389
- if (layerConfigItem.maskElement) {
390
- layerConfigItem.maskElement.style.display = "";
391
- }
401
+ /**
402
+ * 动画结束的回调
403
+ */
392
404
  function animationendCallBack() {
393
405
  popsDOMUtils.off(
394
406
  layerConfigItem.animElement,
@@ -398,6 +410,11 @@ export const PopsInstanceUtils = {
398
410
  capture: true,
399
411
  }
400
412
  );
413
+ resolve();
414
+ }
415
+ layerConfigItem.animElement.style.display = "";
416
+ if (layerConfigItem.maskElement) {
417
+ layerConfigItem.maskElement.style.display = "";
401
418
  }
402
419
  popsDOMUtils.on(
403
420
  layerConfigItem.animElement,
@@ -412,11 +429,11 @@ export const PopsInstanceUtils = {
412
429
  if (layerConfigItem.maskElement) {
413
430
  layerConfigItem.maskElement.style.display = "";
414
431
  }
432
+ resolve();
415
433
  }
416
434
  }
417
- return;
418
- });
419
- }
435
+ }
436
+ });
420
437
  },
421
438
  /**
422
439
  * 关闭
@@ -441,61 +458,68 @@ export const PopsInstanceUtils = {
441
458
  | PopsFolderDetails,
442
459
  animElement: HTMLElement
443
460
  ) {
444
- let popsElement =
445
- animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
446
- let drawerConfig = config as Required<PopsDrawerDetails>;
447
- /**
448
- * 动画结束事件
449
- */
450
- function transitionendEvent() {
451
- function closeCallBack(event: Event) {
452
- if ((event as TransitionEvent).propertyName !== "transform") {
453
- return;
461
+ return new Promise<void>((resolve) => {
462
+ let popsElement =
463
+ animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
464
+ let drawerConfig = config as Required<PopsDrawerDetails>;
465
+ /**
466
+ * 动画结束事件
467
+ */
468
+ function transitionendEvent() {
469
+ /**
470
+ * 弹窗已关闭的回调
471
+ */
472
+ function closeCallBack(event: Event) {
473
+ if ((event as TransitionEvent).propertyName !== "transform") {
474
+ return;
475
+ }
476
+ popsDOMUtils.off(
477
+ popsElement,
478
+ popsDOMUtils.getTransitionEndNameList(),
479
+ void 0,
480
+ closeCallBack
481
+ );
482
+ PopsInstanceUtils.removeInstance([layerConfigList], guid);
483
+ resolve();
454
484
  }
455
- popsDOMUtils.off(
485
+ /* 监听过渡结束 */
486
+ popsDOMUtils.on(
456
487
  popsElement,
457
488
  popsDOMUtils.getTransitionEndNameList(),
458
- void 0,
459
489
  closeCallBack
460
490
  );
461
- PopsInstanceUtils.removeInstance([layerConfigList], guid);
462
- }
463
- /* 监听过渡结束 */
464
- popsDOMUtils.on(
465
- popsElement,
466
- popsDOMUtils.getTransitionEndNameList(),
467
- closeCallBack
468
- );
469
- let popsTransForm = getComputedStyle(popsElement).transform;
470
- if (popsTransForm !== "none") {
471
- popsDOMUtils.trigger(
472
- popsElement,
473
- popsDOMUtils.getTransitionEndNameList(),
474
- void 0,
475
- true
476
- );
477
- return;
491
+ let popsTransForm = getComputedStyle(popsElement).transform;
492
+ if (popsTransForm !== "none") {
493
+ popsDOMUtils.trigger(
494
+ popsElement,
495
+ popsDOMUtils.getTransitionEndNameList(),
496
+ void 0,
497
+ true
498
+ );
499
+ return;
500
+ }
501
+ if (["top"].includes(drawerConfig.direction)) {
502
+ popsElement.style.setProperty("transform", "translateY(-100%)");
503
+ } else if (["bottom"].includes(drawerConfig.direction)) {
504
+ popsElement.style.setProperty("transform", "translateY(100%)");
505
+ } else if (["left"].includes(drawerConfig.direction)) {
506
+ popsElement.style.setProperty("transform", "translateX(-100%)");
507
+ } else if (["right"].includes(drawerConfig.direction)) {
508
+ popsElement.style.setProperty("transform", "translateX(100%)");
509
+ } else {
510
+ console.error("未知direction:", drawerConfig.direction);
511
+ }
478
512
  }
479
- if (["top"].includes(drawerConfig.direction)) {
480
- popsElement.style.setProperty("transform", "translateY(-100%)");
481
- } else if (["bottom"].includes(drawerConfig.direction)) {
482
- popsElement.style.setProperty("transform", "translateY(100%)");
483
- } else if (["left"].includes(drawerConfig.direction)) {
484
- popsElement.style.setProperty("transform", "translateX(-100%)");
485
- } else if (["right"].includes(drawerConfig.direction)) {
486
- popsElement.style.setProperty("transform", "translateX(100%)");
513
+
514
+ if (popsType === "drawer") {
515
+ setTimeout(() => {
516
+ transitionendEvent();
517
+ }, drawerConfig.closeDelay);
487
518
  } else {
488
- console.error("未知direction:", drawerConfig.direction);
519
+ PopsInstanceUtils.removeInstance([layerConfigList], guid);
520
+ resolve();
489
521
  }
490
- }
491
-
492
- if (popsType === "drawer") {
493
- setTimeout(() => {
494
- transitionendEvent();
495
- }, drawerConfig.closeDelay);
496
- } else {
497
- PopsInstanceUtils.removeInstance([layerConfigList], guid);
498
- }
522
+ });
499
523
  },
500
524
  /**
501
525
  * 拖拽元素