@whitesev/pops 4.0.2 → 4.1.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 (76) hide show
  1. package/dist/index.amd.js +227 -141
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.amd.min.js +1 -1
  4. package/dist/index.amd.min.js.map +1 -1
  5. package/dist/index.cjs.js +227 -141
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/index.cjs.min.js +1 -1
  8. package/dist/index.cjs.min.js.map +1 -1
  9. package/dist/index.esm.js +227 -141
  10. package/dist/index.esm.js.map +1 -1
  11. package/dist/index.esm.min.js +1 -1
  12. package/dist/index.esm.min.js.map +1 -1
  13. package/dist/index.iife.js +227 -141
  14. package/dist/index.iife.js.map +1 -1
  15. package/dist/index.iife.min.js +1 -1
  16. package/dist/index.iife.min.js.map +1 -1
  17. package/dist/index.system.js +227 -141
  18. package/dist/index.system.js.map +1 -1
  19. package/dist/index.system.min.js +1 -1
  20. package/dist/index.system.min.js.map +1 -1
  21. package/dist/index.umd.js +227 -141
  22. package/dist/index.umd.js.map +1 -1
  23. package/dist/index.umd.min.js +1 -1
  24. package/dist/index.umd.min.js.map +1 -1
  25. package/dist/types/src/Pops.d.ts +109 -10
  26. package/dist/types/src/components/loading/types/index.d.ts +1 -1
  27. package/dist/types/src/components/panel/index.d.ts +3 -2
  28. package/dist/types/src/components/rightClickMenu/types/index.d.ts +1 -1
  29. package/dist/types/src/components/searchSuggestion/types/index.d.ts +1 -1
  30. package/dist/types/src/components/tooltip/index.d.ts +82 -1
  31. package/dist/types/src/components/tooltip/types/index.d.ts +1 -1
  32. package/dist/types/src/config/GlobalConfig.d.ts +3 -3
  33. package/dist/types/src/event/EventEmiter.d.ts +7 -1
  34. package/dist/types/src/handler/PopsInstHandler.d.ts +4 -4
  35. package/dist/types/src/types/EventEmitter.d.ts +21 -0
  36. package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +1 -1
  37. package/dist/types/src/types/components.d.ts +15 -18
  38. package/dist/types/src/types/global.d.ts +2 -0
  39. package/dist/types/src/utils/PopsDOMUtils.d.ts +14 -2
  40. package/dist/types/src/utils/PopsUtils.d.ts +20 -15
  41. package/package.json +1 -1
  42. package/src/Pops.ts +3 -0
  43. package/src/components/alert/defaultConfig.ts +1 -1
  44. package/src/components/alert/index.ts +1 -1
  45. package/src/components/confirm/defaultConfig.ts +1 -1
  46. package/src/components/confirm/index.ts +1 -1
  47. package/src/components/drawer/defaultConfig.ts +1 -1
  48. package/src/components/drawer/index.ts +2 -1
  49. package/src/components/folder/defaultConfig.ts +1 -1
  50. package/src/components/folder/index.ts +1 -1
  51. package/src/components/iframe/defaultConfig.ts +1 -1
  52. package/src/components/iframe/index.ts +10 -6
  53. package/src/components/loading/defaultConfig.ts +1 -0
  54. package/src/components/loading/index.ts +10 -10
  55. package/src/components/loading/types/index.ts +1 -4
  56. package/src/components/panel/defaultConfig.ts +1 -1
  57. package/src/components/panel/index.ts +3 -2
  58. package/src/components/prompt/defaultConfig.ts +1 -1
  59. package/src/components/prompt/index.ts +1 -1
  60. package/src/components/rightClickMenu/defaultConfig.ts +1 -1
  61. package/src/components/rightClickMenu/index.ts +1 -1
  62. package/src/components/rightClickMenu/types/index.ts +1 -1
  63. package/src/components/searchSuggestion/defaultConfig.ts +1 -0
  64. package/src/components/searchSuggestion/index.ts +1 -1
  65. package/src/components/searchSuggestion/types/index.ts +1 -1
  66. package/src/components/tooltip/defaultConfig.ts +1 -1
  67. package/src/components/tooltip/index.ts +1 -1
  68. package/src/components/tooltip/types/index.ts +1 -1
  69. package/src/event/EventEmiter.ts +15 -14
  70. package/src/handler/PopsInstHandler.ts +64 -47
  71. package/src/types/EventEmitter.d.ts +21 -0
  72. package/src/types/PopsDOMUtilsEventType.d.ts +1 -1
  73. package/src/types/components.d.ts +15 -18
  74. package/src/types/global.d.ts +2 -0
  75. package/src/utils/PopsDOMUtils.ts +32 -2
  76. package/src/utils/PopsUtils.ts +94 -67
package/dist/index.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const version = "4.0.2";
3
+ const version = "4.1.0";
4
4
 
5
5
  const GlobalConfig = {
6
6
  config: {},
@@ -59,15 +59,16 @@ const GlobalConfig = {
59
59
  };
60
60
 
61
61
  class EventEmiter {
62
- #type;
63
- #data = new Map();
62
+ [Symbol.toStringTag] = "EventEmiter";
63
+ type;
64
+ data = new Map();
64
65
  constructor(type) {
65
- this.#type = type;
66
+ this.type = type;
66
67
  }
67
68
  on(eventName, callback) {
68
- const eventList = this.#data.get(eventName) ?? [];
69
- eventList.push({ type: this.#type, time: Date.now(), callback: callback });
70
- this.#data.set(eventName, eventList);
69
+ const eventList = this.data.get(eventName) ?? [];
70
+ eventList.push({ type: this.type, time: Date.now(), callback: callback });
71
+ this.data.set(eventName, eventList);
71
72
  return {
72
73
  off: () => {
73
74
  this.off(eventName, callback);
@@ -78,7 +79,7 @@ class EventEmiter {
78
79
  };
79
80
  }
80
81
  off(eventName, callback) {
81
- const eventList = this.#data.get(eventName) ?? [];
82
+ const eventList = this.data.get(eventName) ?? [];
82
83
  let isOffSuccess = false;
83
84
  for (let index = eventList.length - 1; index >= 0; index--) {
84
85
  if (eventList[index].callback === callback) {
@@ -88,27 +89,27 @@ class EventEmiter {
88
89
  }
89
90
  if (eventList.length === 0) {
90
91
  // empty
91
- this.#data.delete(eventName);
92
+ this.data.delete(eventName);
92
93
  }
93
94
  else {
94
95
  if (isOffSuccess) {
95
96
  // update
96
- this.#data.set(eventName, eventList);
97
+ this.data.set(eventName, eventList);
97
98
  }
98
99
  }
99
100
  }
100
101
  async emit(eventName, ...args) {
101
- const eventList = this.#data.get(eventName) ?? [];
102
+ const eventList = this.data.get(eventName) ?? [];
102
103
  for (const item of eventList) {
103
104
  await item.callback(...args);
104
105
  }
105
106
  }
106
107
  offAll(eventName) {
107
108
  if (typeof eventName === "string") {
108
- this.#data.delete(eventName);
109
+ this.data.delete(eventName);
109
110
  }
110
111
  else {
111
- this.#data.clear();
112
+ this.data.clear();
112
113
  }
113
114
  }
114
115
  /**
@@ -116,10 +117,10 @@ class EventEmiter {
116
117
  */
117
118
  getAllEvents(eventName) {
118
119
  if (typeof eventName === "string") {
119
- return this.#data.get(eventName);
120
+ return this.data.get(eventName);
120
121
  }
121
122
  else {
122
- return Array.from(this.#data.values());
123
+ return Array.from(this.data.values());
123
124
  }
124
125
  }
125
126
  }
@@ -430,7 +431,8 @@ class PopsUtils {
430
431
  if (typeof sourceValue === "object" &&
431
432
  sourceValue != null &&
432
433
  keyName in target &&
433
- !UtilsContext.isDOM(sourceValue)) {
434
+ !UtilsContext.isDOM(sourceValue) &&
435
+ !(sourceValue instanceof EventEmiter)) {
434
436
  // 源端的值是object类型,且不是元素节点
435
437
  // 如果是数组,那此数组中有值,清空旧的数组再赋值
436
438
  let childObjectValue;
@@ -446,7 +448,7 @@ class PopsUtils {
446
448
  Reflect.set(target, keyName, childObjectValue);
447
449
  }
448
450
  else {
449
- /* 直接赋值 */
451
+ // 直接赋值
450
452
  Reflect.set(target, keyName, sourceValue);
451
453
  }
452
454
  }
@@ -636,33 +638,31 @@ class PopsUtils {
636
638
  if (typeof deviation !== "number" || Number.isNaN(deviation)) {
637
639
  deviation = 10;
638
640
  }
639
- const leftTop = {
640
- x: globalThis.innerWidth * (1 / 8),
641
- y: globalThis.innerHeight * (1 / 8),
642
- };
643
- const leftBottom = {
644
- x: globalThis.innerWidth * (1 / 8),
645
- y: globalThis.innerHeight * (7 / 8),
646
- };
647
- const rightTop = {
648
- x: globalThis.innerWidth * (7 / 8),
649
- y: globalThis.innerHeight * (1 / 8),
650
- };
651
- const rightBottom = {
652
- x: globalThis.innerWidth * (7 / 8),
653
- y: globalThis.innerHeight * (7 / 8),
654
- };
655
- const center = {
656
- x: globalThis.innerWidth / 2,
657
- y: globalThis.innerHeight / 2,
658
- };
659
- const delayHandlerElementPostionList = [
660
- leftTop,
661
- leftBottom,
662
- rightTop,
663
- rightBottom,
664
- center,
665
- ];
641
+ /** 坐标偏移 */
642
+ const positionDistance = 10;
643
+ const defaultCalcPostion = [];
644
+ const maxPostionX = globalThis.innerWidth;
645
+ const maxPostionY = globalThis.innerHeight;
646
+ const gridXCount = 8;
647
+ const gridYCount = 8;
648
+ for (let i = 0; i < gridXCount; i++) {
649
+ for (let j = 0; j < gridYCount; j++) {
650
+ const positionX = globalThis.innerWidth * (i / gridXCount) + positionDistance;
651
+ const positionY = globalThis.innerHeight * (j / gridYCount) + positionDistance;
652
+ const position = {
653
+ x: positionX,
654
+ y: positionY,
655
+ };
656
+ if (position.x > maxPostionX) {
657
+ position.x = maxPostionX;
658
+ }
659
+ if (position.y > maxPostionY) {
660
+ position.y = maxPostionY;
661
+ }
662
+ defaultCalcPostion.push(position);
663
+ }
664
+ }
665
+ const delayHandlerElementPostionList = defaultCalcPostion;
666
666
  if ($el) {
667
667
  delayHandlerElementPostionList.length = 0;
668
668
  if (Array.isArray($el)) {
@@ -674,61 +674,79 @@ class PopsUtils {
674
674
  }
675
675
  const positionInfoList = delayHandlerElementPostionList
676
676
  .map((position) => {
677
- let positionNode;
677
+ let $position;
678
678
  let positionX;
679
679
  let positionY;
680
680
  if (position instanceof HTMLElement) {
681
- positionNode = position;
681
+ $position = position;
682
682
  const nodeRect = position.getBoundingClientRect();
683
683
  positionX = nodeRect.x + nodeRect.width / 2;
684
684
  positionY = nodeRect.y + nodeRect.height / 2;
685
685
  }
686
686
  else {
687
- positionNode = document.elementFromPoint(position.x, position.y);
687
+ $position = document.elementFromPoint(position.x, position.y);
688
688
  positionX = position.x;
689
689
  positionY = position.y;
690
690
  }
691
- const shadowRoot = positionNode?.shadowRoot;
691
+ const shadowRoot = $position?.shadowRoot;
692
692
  if (shadowRoot) {
693
- positionNode = shadowRoot.elementFromPoint(positionX, positionY);
693
+ // 处理ShadowRoot
694
+ $position = shadowRoot.elementFromPoint(positionX, positionY);
694
695
  }
695
- if (positionNode instanceof HTMLStyleElement)
696
- return;
697
- if (positionNode instanceof HTMLScriptElement)
698
- return;
699
- if (positionNode instanceof HTMLMetaElement)
700
- return;
701
- if (positionNode instanceof HTMLHeadElement)
702
- return;
703
- if (!(positionNode instanceof HTMLElement))
696
+ if (!($position instanceof HTMLElement))
704
697
  return;
705
- let parent = positionNode;
698
+ let $parent = $position;
706
699
  let zIndex = 0;
707
- let maxZIndexNode = null;
708
- while (parent) {
709
- const nodeStyle = globalThis.getComputedStyle(parent);
700
+ let $maxZIndexNode = null;
701
+ let rect = {
702
+ x: 0,
703
+ y: 0,
704
+ width: 0,
705
+ height: 0,
706
+ top: 0,
707
+ right: 0,
708
+ bottom: 0,
709
+ left: 0,
710
+ };
711
+ while ($parent) {
712
+ const nodeStyle = globalThis.getComputedStyle($parent);
710
713
  const nodeZIndex = parseInt(nodeStyle.zIndex);
711
714
  if (nodeStyle.position !== "static" && !isNaN(nodeZIndex)) {
712
715
  if (nodeZIndex > zIndex) {
713
716
  zIndex = nodeZIndex;
714
- maxZIndexNode = parent;
715
- }
716
- }
717
- parent = parent.parentElement;
717
+ $maxZIndexNode = $parent;
718
+ }
719
+ }
720
+ $parent = $parent.parentElement;
721
+ }
722
+ if ($maxZIndexNode) {
723
+ const maxRect = $maxZIndexNode.getBoundingClientRect();
724
+ rect = {
725
+ x: maxRect.x,
726
+ y: maxRect.y,
727
+ width: maxRect.width,
728
+ height: maxRect.height,
729
+ top: maxRect.top,
730
+ right: maxRect.right,
731
+ bottom: maxRect.bottom,
732
+ left: maxRect.left,
733
+ };
718
734
  }
719
735
  return {
720
- /** 处理了偏移量后的z-index值 */
736
+ /** 计算偏移量后的z-index值 */
721
737
  zIndex: zIndex + deviation,
722
- /** 原始z-index值 */
738
+ /** 获取到的最大的z-index值 */
723
739
  originZIndex: zIndex,
724
740
  /** 拥有最大z-index的元素 */
725
- node: maxZIndexNode,
741
+ node: $maxZIndexNode,
726
742
  /** 目标坐标元素 */
727
- positionNode: positionNode,
728
- /** x坐标 */
743
+ positionNode: $position,
744
+ /** 目标x坐标 */
729
745
  positionX: positionX,
730
- /** y坐标 */
746
+ /** 目标y坐标 */
731
747
  positionY: positionY,
748
+ /** node位置信息 */
749
+ rect,
732
750
  };
733
751
  })
734
752
  .filter((it) => it != null);
@@ -779,10 +797,17 @@ const PopsSafeUtils = {
779
797
  const PopsCommonCSSClassName = {
780
798
  flexCenter: "pops-flex-items-center",
781
799
  flexYCenter: "pops-flex-y-center",
800
+ flexXCenter: "pops-flex-x-center",
782
801
  hide: "pops-hide",
783
802
  hideImportant: "pops-hide-important",
803
+ noBorder: "pops-no-border",
804
+ noBorderImportant: "pops-no-border-important",
784
805
  userSelectNone: "pops-user-select-none",
785
- textIsDisabled: "pops-text-is-disabled"};
806
+ lineHeightCenter: "pops-line-height-center",
807
+ widthFill: "pops-width-fill",
808
+ textIsDisabled: "pops-text-is-disabled",
809
+ textIsDisabledImportant: "pops-text-is-disabled-important",
810
+ };
786
811
 
787
812
  class PopsDOMUtilsEvent {
788
813
  on(element, eventType, selector, callback, option) {
@@ -1682,6 +1707,35 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
1682
1707
  getTransitionEndNameList() {
1683
1708
  return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
1684
1709
  }
1710
+ /**
1711
+ * 是否是隐藏状态
1712
+ *
1713
+ * 检测以下项:
1714
+ *
1715
+ * + `display`: none
1716
+ * + `visibility`: hidden
1717
+ * + `opacity`: 0
1718
+ * + `使用了pops的自定义的隐藏class类`
1719
+ * @param $el 需要检测的元素
1720
+ */
1721
+ isHide($el) {
1722
+ let flag = false;
1723
+ if (this.containsClassName($el, PopsCommonCSSClassName.hide) ||
1724
+ this.containsClassName($el, PopsCommonCSSClassName.hideImportant)) {
1725
+ flag = true;
1726
+ }
1727
+ else {
1728
+ if ($el instanceof HTMLElement) {
1729
+ const style = $el.style;
1730
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
1731
+ }
1732
+ if (!flag) {
1733
+ const style = globalThis.getComputedStyle($el);
1734
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
1735
+ }
1736
+ }
1737
+ return flag;
1738
+ }
1685
1739
  /**
1686
1740
  * 实现jQuery中的$().offset();
1687
1741
  * @param element
@@ -3190,7 +3244,7 @@ const PopsInstHandler = {
3190
3244
  return totalInstConfigList;
3191
3245
  },
3192
3246
  /**
3193
- * 隐藏
3247
+ * 显示
3194
3248
  * @param popsType
3195
3249
  * @param instConfigList
3196
3250
  * @param guid
@@ -3198,24 +3252,34 @@ const PopsInstHandler = {
3198
3252
  * @param $anim
3199
3253
  * @param $mask
3200
3254
  */
3201
- hide(config, popsType, instConfigList, guid, $anim, $mask) {
3255
+ show(config, popsType, instConfigList, guid, $anim, $mask) {
3202
3256
  // oxlint-disable-next-line no-async-promise-executor
3203
3257
  return new Promise(async (resolve) => {
3204
3258
  const $pops = $anim.querySelector(".pops[type-value]");
3205
3259
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3206
3260
  if (fintInst) {
3207
- // 存在实例
3261
+ // 由于是隐蔽状态
3262
+ // 先设置好动画状态
3263
+ // 再显示,会自执行动画
3264
+ const checkVisible = () => {
3265
+ if (!popsDOMUtils.isHide($anim)) {
3266
+ return true;
3267
+ }
3268
+ else {
3269
+ return false;
3270
+ }
3271
+ };
3208
3272
  const startAnim = async () => {
3209
3273
  if (popsType === "drawer") {
3210
3274
  // drawer是抽屉
3211
3275
  // 单独处理动画
3212
3276
  const drawerConfig = config;
3213
- await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3277
+ await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3214
3278
  if ($mask) {
3215
- popsDOMUtils.css($mask, "display", "none");
3279
+ popsDOMUtils.css($mask, "display", "");
3216
3280
  }
3217
3281
  const direction = drawerConfig.direction;
3218
- const size = "0";
3282
+ const size = drawerConfig.size.toString();
3219
3283
  if (["top", "bottom"].includes(direction)) {
3220
3284
  $pops.style.setProperty("height", size);
3221
3285
  }
@@ -3223,26 +3287,26 @@ const PopsInstHandler = {
3223
3287
  $pops.style.setProperty("width", size);
3224
3288
  }
3225
3289
  else {
3226
- console.error("未知direction: ", direction);
3290
+ console.error("未知direction", direction);
3227
3291
  }
3228
3292
  }
3229
3293
  else {
3230
- instConfigItem.$anim.style.width = "100%";
3231
- instConfigItem.$anim.style.height = "100%";
3232
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
3294
+ instConfigItem.$anim.style.width = "";
3295
+ instConfigItem.$anim.style.height = "";
3296
+ Reflect.set(instConfigItem.$anim.style, "animation-name", animName);
3233
3297
  }
3234
- };
3235
- const endCallback = () => {
3236
- instConfigItem.$anim.style.display = "none";
3298
+ instConfigItem.$anim.style.display = "";
3237
3299
  if (instConfigItem.$mask) {
3238
- instConfigItem.$mask.style.display = "none";
3300
+ instConfigItem.$mask.style.display = "";
3239
3301
  }
3240
- fintInst.emitter.emit("pops:hide", instConfigItem);
3302
+ };
3303
+ const endCallback = () => {
3304
+ fintInst.emitter.emit("pops:show", instConfigItem);
3241
3305
  };
3242
3306
  const instConfigItem = fintInst;
3243
- fintInst.emitter.emit("pops:before-hide", instConfigItem);
3244
- await startAnim();
3245
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3307
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3308
+ fintInst.emitter.emit("pops:before-show", instConfigItem);
3309
+ if (checkVisible() && PopsAnimation.hasAnim(animName)) {
3246
3310
  /**
3247
3311
  * 动画结束的回调
3248
3312
  */
@@ -3253,22 +3317,23 @@ const PopsInstHandler = {
3253
3317
  };
3254
3318
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3255
3319
  capture: true,
3256
- once: true,
3257
3320
  });
3321
+ await startAnim();
3258
3322
  }
3259
3323
  else {
3324
+ await startAnim();
3260
3325
  endCallback();
3261
3326
  resolve();
3262
3327
  }
3263
3328
  }
3264
3329
  else {
3265
- console.error("hide-error: 该实例未存储");
3330
+ console.error("show-error: 该实例未存储");
3266
3331
  resolve();
3267
3332
  }
3268
3333
  });
3269
3334
  },
3270
3335
  /**
3271
- * 显示
3336
+ * 隐藏
3272
3337
  * @param popsType
3273
3338
  * @param instConfigList
3274
3339
  * @param guid
@@ -3276,23 +3341,35 @@ const PopsInstHandler = {
3276
3341
  * @param $anim
3277
3342
  * @param $mask
3278
3343
  */
3279
- show(config, popsType, instConfigList, guid, $anim, $mask) {
3344
+ hide(config, popsType, instConfigList, guid, $anim, $mask) {
3280
3345
  // oxlint-disable-next-line no-async-promise-executor
3281
3346
  return new Promise(async (resolve) => {
3282
3347
  const $pops = $anim.querySelector(".pops[type-value]");
3283
3348
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3284
3349
  if (fintInst) {
3350
+ // 由于是已显示状态
3351
+ // 先执行动画
3352
+ // 再隐藏
3353
+ // 存在实例
3354
+ const checkVisible = () => {
3355
+ if (!popsDOMUtils.isHide($anim)) {
3356
+ return true;
3357
+ }
3358
+ else {
3359
+ return false;
3360
+ }
3361
+ };
3285
3362
  const startAnim = async () => {
3286
3363
  if (popsType === "drawer") {
3287
3364
  // drawer是抽屉
3288
3365
  // 单独处理动画
3289
3366
  const drawerConfig = config;
3290
- await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3367
+ await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3291
3368
  if ($mask) {
3292
- popsDOMUtils.css($mask, "display", "");
3369
+ popsDOMUtils.css($mask, "display", "none");
3293
3370
  }
3294
3371
  const direction = drawerConfig.direction;
3295
- const size = drawerConfig.size.toString();
3372
+ const size = "0";
3296
3373
  if (["top", "bottom"].includes(direction)) {
3297
3374
  $pops.style.setProperty("height", size);
3298
3375
  }
@@ -3300,26 +3377,27 @@ const PopsInstHandler = {
3300
3377
  $pops.style.setProperty("width", size);
3301
3378
  }
3302
3379
  else {
3303
- console.error("未知direction", direction);
3380
+ console.error("未知direction: ", direction);
3304
3381
  }
3305
3382
  }
3306
3383
  else {
3307
- instConfigItem.$anim.style.width = "";
3308
- instConfigItem.$anim.style.height = "";
3309
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim").replace("-reverse", ""));
3384
+ instConfigItem.$anim.style.width = "100%";
3385
+ instConfigItem.$anim.style.height = "100%";
3386
+ Reflect.set(instConfigItem.$anim.style, "animation-name", reverseAnimName);
3310
3387
  }
3311
3388
  };
3312
3389
  const endCallback = () => {
3313
- instConfigItem.$anim.style.display = "";
3390
+ instConfigItem.$anim.style.display = "none";
3314
3391
  if (instConfigItem.$mask) {
3315
- instConfigItem.$mask.style.display = "";
3392
+ instConfigItem.$mask.style.display = "none";
3316
3393
  }
3317
- fintInst.emitter.emit("pops:show", instConfigItem);
3394
+ fintInst.emitter.emit("pops:hide", instConfigItem);
3318
3395
  };
3319
3396
  const instConfigItem = fintInst;
3320
- fintInst.emitter.emit("pops:before-show", instConfigItem);
3321
- await startAnim();
3322
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3397
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3398
+ const reverseAnimName = animName + "-reverse";
3399
+ fintInst.emitter.emit("pops:before-hide", instConfigItem);
3400
+ if (!checkVisible() && PopsAnimation.hasAnim(reverseAnimName)) {
3323
3401
  /**
3324
3402
  * 动画结束的回调
3325
3403
  */
@@ -3330,15 +3408,18 @@ const PopsInstHandler = {
3330
3408
  };
3331
3409
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3332
3410
  capture: true,
3411
+ once: true,
3333
3412
  });
3413
+ await startAnim();
3334
3414
  }
3335
3415
  else {
3416
+ await startAnim();
3336
3417
  endCallback();
3337
3418
  resolve();
3338
3419
  }
3339
3420
  }
3340
3421
  else {
3341
- console.error("show-error: 该实例未存储");
3422
+ console.error("hide-error: 该实例未存储");
3342
3423
  resolve();
3343
3424
  }
3344
3425
  });
@@ -3378,7 +3459,7 @@ const PopsInstHandler = {
3378
3459
  await new Promise(async (resolve) => {
3379
3460
  const $pops = $anim.querySelector(".pops[type-value]");
3380
3461
  const drawerConfig = config;
3381
- const start = () => {
3462
+ const startAnim = () => {
3382
3463
  /**
3383
3464
  * 弹窗已关闭的回调
3384
3465
  */
@@ -3419,7 +3500,7 @@ const PopsInstHandler = {
3419
3500
  };
3420
3501
  if (popsType === "drawer") {
3421
3502
  await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3422
- start();
3503
+ startAnim();
3423
3504
  }
3424
3505
  else {
3425
3506
  await PopsInstHandler.removeInstance([instConfigList], guid);
@@ -4170,8 +4251,8 @@ const PopsAlertDefaultConfig = () => {
4170
4251
  style: null,
4171
4252
  lightStyle: null,
4172
4253
  darkStyle: null,
4173
- beforeAppendToPageCallBack() { },
4174
4254
  stopKeyDownEventPropagation: true,
4255
+ emitter: null,
4175
4256
  };
4176
4257
  };
4177
4258
 
@@ -4180,11 +4261,11 @@ const PopsAlert = {
4180
4261
  const guid = popsUtils.getRandomGUID();
4181
4262
  // 设置当前类型
4182
4263
  const popsType = "alert";
4183
- const emitter = new EventEmiter(popsType);
4184
4264
  let config = PopsAlertDefaultConfig();
4185
4265
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4186
4266
  config = popsUtils.assign(config, __config__);
4187
4267
  config = PopsHandler.handleOnly(popsType, config);
4268
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4188
4269
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4189
4270
  PopsHandler.handleInit($shadowRoot, [
4190
4271
  {
@@ -4378,8 +4459,8 @@ const PopsConfirmDefaultConfig = () => {
4378
4459
  style: null,
4379
4460
  lightStyle: null,
4380
4461
  darkStyle: null,
4381
- beforeAppendToPageCallBack() { },
4382
4462
  stopKeyDownEventPropagation: true,
4463
+ emitter: null,
4383
4464
  };
4384
4465
  };
4385
4466
 
@@ -4388,11 +4469,11 @@ const PopsConfirm = {
4388
4469
  const guid = popsUtils.getRandomGUID();
4389
4470
  // 设置当前类型
4390
4471
  const popsType = "confirm";
4391
- const emitter = new EventEmiter(popsType);
4392
4472
  let config = PopsConfirmDefaultConfig();
4393
4473
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4394
4474
  config = popsUtils.assign(config, __config__);
4395
4475
  config = PopsHandler.handleOnly(popsType, config);
4476
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4396
4477
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4397
4478
  PopsHandler.handleInit($shadowRoot, [
4398
4479
  {
@@ -4585,9 +4666,9 @@ const PopsDrawerDefaultConfig = () => {
4585
4666
  style: null,
4586
4667
  lightStyle: null,
4587
4668
  darkStyle: null,
4588
- beforeAppendToPageCallBack() { },
4589
4669
  forbiddenScroll: false,
4590
4670
  stopKeyDownEventPropagation: true,
4671
+ emitter: null,
4591
4672
  };
4592
4673
  };
4593
4674
 
@@ -4596,11 +4677,11 @@ const PopsDrawer = {
4596
4677
  const guid = popsUtils.getRandomGUID();
4597
4678
  // 设置当前类型
4598
4679
  const popsType = "drawer";
4599
- const emitter = new EventEmiter(popsType);
4600
4680
  let config = PopsDrawerDefaultConfig();
4601
4681
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4602
4682
  config = popsUtils.assign(config, __config__);
4603
4683
  config = PopsHandler.handleOnly(popsType, config);
4684
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4604
4685
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4605
4686
  PopsHandler.handleInit($shadowRoot, [
4606
4687
  {
@@ -4811,6 +4892,7 @@ const PopsLoadingDefaultConfig = () => {
4811
4892
  darkStyle: null,
4812
4893
  addIndexCSS: true,
4813
4894
  stopKeyDownEventPropagation: true,
4895
+ emitter: null,
4814
4896
  };
4815
4897
  };
4816
4898
 
@@ -4818,19 +4900,19 @@ const PopsLoading = {
4818
4900
  init(__config__) {
4819
4901
  const guid = popsUtils.getRandomGUID();
4820
4902
  // 设置当前类型
4821
- const PopsType = "loading";
4822
- const emitter = new EventEmiter(PopsType);
4903
+ const popsType = "loading";
4823
4904
  let config = PopsLoadingDefaultConfig();
4824
4905
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4825
4906
  config = popsUtils.assign(config, __config__);
4826
- config = PopsHandler.handleOnly(PopsType, config);
4907
+ config = PopsHandler.handleOnly(popsType, config);
4908
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4827
4909
  // 先把z-index提取出来
4828
4910
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4829
4911
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4830
4912
  const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
4831
- const animHTML = PopsElementHandler.createAnim(guid, PopsType, config,
4913
+ const animHTML = PopsElementHandler.createAnim(guid, popsType, config,
4832
4914
  /*html*/ `
4833
- <div class="pops-content pops-${PopsType}-content">${config.addIndexCSS
4915
+ <div class="pops-content pops-${popsType}-content">${config.addIndexCSS
4834
4916
  ? /*html*/ `
4835
4917
  <style data-model-name="index">${PopsCSS.index}</style>
4836
4918
  <style data-model-name="anim">${PopsCSS.anim}</style>
@@ -4841,13 +4923,13 @@ const PopsLoading = {
4841
4923
  ${PopsCSS.loadingCSS}
4842
4924
  </style>
4843
4925
  ${config.style != null ? `<style>${config.style}</style>` : ""}
4844
- <p pops class="pops-${PopsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
4926
+ <p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
4845
4927
  </div>`, "", zIndex);
4846
4928
  /**
4847
4929
  * 弹窗的主元素,包括动画层
4848
4930
  */
4849
4931
  const $anim = PopsElementHandler.parseElement(animHTML);
4850
- const { $pops: $pops } = PopsHandler.handleQueryElement($anim, PopsType);
4932
+ const { $pops: $pops } = PopsHandler.handleQueryElement($anim, popsType);
4851
4933
  /**
4852
4934
  * 遮罩层元素
4853
4935
  */
@@ -4859,7 +4941,7 @@ const PopsLoading = {
4859
4941
  if (config.mask.enable) {
4860
4942
  // 创建遮罩层
4861
4943
  const handleMask = PopsHandler.handleMask({
4862
- type: PopsType,
4944
+ type: popsType,
4863
4945
  guid: guid,
4864
4946
  config: config,
4865
4947
  animElement: $anim,
@@ -4868,12 +4950,12 @@ const PopsLoading = {
4868
4950
  $mask = handleMask.maskElement;
4869
4951
  $elList.push($mask);
4870
4952
  }
4871
- const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
4953
+ const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, popsType, $anim, $pops, emitter, $mask);
4872
4954
  popsDOMUtils.append(config.$parent, $elList);
4873
4955
  if ($mask != null) {
4874
4956
  $anim.after($mask);
4875
4957
  }
4876
- PopsHandler.handlePush(PopsType, {
4958
+ PopsHandler.handlePush(popsType, {
4877
4959
  $shadowContainer: $pops,
4878
4960
  $shadowRoot: $pops,
4879
4961
  guid: guid,
@@ -5042,8 +5124,8 @@ const PopsFolderDefaultConfig = () => {
5042
5124
  style: null,
5043
5125
  lightStyle: null,
5044
5126
  darkStyle: null,
5045
- beforeAppendToPageCallBack() { },
5046
5127
  stopKeyDownEventPropagation: true,
5128
+ emitter: null,
5047
5129
  };
5048
5130
  };
5049
5131
 
@@ -5080,11 +5162,11 @@ const PopsFolder = {
5080
5162
  const guid = popsUtils.getRandomGUID();
5081
5163
  // 设置当前类型
5082
5164
  const popsType = "folder";
5083
- const emitter = new EventEmiter(popsType);
5084
5165
  let config = PopsFolderDefaultConfig();
5085
5166
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
5086
5167
  config = popsUtils.assign(config, __config__);
5087
5168
  config = PopsHandler.handleOnly(popsType, config);
5169
+ const emitter = config.emitter ?? new EventEmiter(popsType);
5088
5170
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
5089
5171
  PopsHandler.handleInit($shadowRoot, [
5090
5172
  {
@@ -6007,8 +6089,8 @@ const PopsIframeDefaultConfig = () => {
6007
6089
  style: null,
6008
6090
  lightStyle: null,
6009
6091
  darkStyle: null,
6010
- beforeAppendToPageCallBack() { },
6011
6092
  stopKeyDownEventPropagation: true,
6093
+ emitter: null,
6012
6094
  };
6013
6095
  };
6014
6096
 
@@ -6017,7 +6099,6 @@ const PopsIframe = {
6017
6099
  const guid = popsUtils.getRandomGUID();
6018
6100
  // 设置当前类型
6019
6101
  const popsType = "iframe";
6020
- const emitter = new EventEmiter(popsType);
6021
6102
  let config = PopsIframeDefaultConfig();
6022
6103
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
6023
6104
  config = popsUtils.assign(config, __config__);
@@ -6025,6 +6106,8 @@ const PopsIframe = {
6025
6106
  throw new TypeError("config.url must not be null.");
6026
6107
  }
6027
6108
  config = PopsHandler.handleOnly(popsType, config);
6109
+ const emitter = config.emitter ??
6110
+ new EventEmiter(popsType);
6028
6111
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
6029
6112
  PopsHandler.handleInit($shadowRoot, [
6030
6113
  {
@@ -6052,7 +6135,7 @@ const PopsIframe = {
6052
6135
  css: PopsCSS.iframeCSS,
6053
6136
  },
6054
6137
  ]);
6055
- const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
6138
+ const maskExtraStyle = config.animation != null && config.animation != "" && config.animation ? "position:absolute;" : "";
6056
6139
  // 先把z-index提取出来
6057
6140
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
6058
6141
  const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
@@ -7133,9 +7216,9 @@ const PopsPanelDefaultConfig = () => {
7133
7216
  style: null,
7134
7217
  lightStyle: null,
7135
7218
  darkStyle: null,
7136
- beforeAppendToPageCallBack() { },
7137
7219
  stopKeyDownEventPropagation: true,
7138
7220
  listenEscapeKeyUpToExitDeepMenu: true,
7221
+ emitter: null,
7139
7222
  };
7140
7223
  };
7141
7224
 
@@ -7247,7 +7330,7 @@ const PopsTooltipDefaultConfig = () => {
7247
7330
  style: "",
7248
7331
  lightStyle: null,
7249
7332
  darkStyle: null,
7250
- beforeAppendToPageCallBack() { },
7333
+ emitter: null,
7251
7334
  };
7252
7335
  };
7253
7336
 
@@ -7715,7 +7798,6 @@ const PopsTooltip = {
7715
7798
  const guid = popsUtils.getRandomGUID();
7716
7799
  // 设置当前类型
7717
7800
  const popsType = "tooltip";
7718
- const emitter = new EventEmiter(popsType);
7719
7801
  let config = PopsTooltipDefaultConfig();
7720
7802
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
7721
7803
  config = popsUtils.assign(config, __config__);
@@ -7732,6 +7814,7 @@ const PopsTooltip = {
7732
7814
  config.onShowEventName += ` ${it}`;
7733
7815
  });
7734
7816
  }
7817
+ const emitter = config.emitter ?? new EventEmiter(popsType);
7735
7818
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
7736
7819
  PopsHandler.handleInit($shadowRoot, [
7737
7820
  {
@@ -11597,11 +11680,11 @@ const PopsPanel = {
11597
11680
  const guid = popsUtils.getRandomGUID();
11598
11681
  // 设置当前类型
11599
11682
  const popsType = "panel";
11600
- const emitter = new EventEmiter(popsType);
11601
11683
  let config = PopsPanelDefaultConfig();
11602
11684
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11603
11685
  config = popsUtils.assign(config, __config__);
11604
11686
  config = PopsHandler.handleOnly(popsType, config);
11687
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11605
11688
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11606
11689
  PopsHandler.handleInit($shadowRoot, [
11607
11690
  {
@@ -11851,8 +11934,8 @@ const PopsPromptDefaultConfig = () => {
11851
11934
  style: null,
11852
11935
  lightStyle: null,
11853
11936
  darkStyle: null,
11854
- beforeAppendToPageCallBack() { },
11855
11937
  stopKeyDownEventPropagation: true,
11938
+ emitter: null,
11856
11939
  };
11857
11940
  };
11858
11941
 
@@ -11861,11 +11944,11 @@ const PopsPrompt = {
11861
11944
  const guid = popsUtils.getRandomGUID();
11862
11945
  // 设置当前类型
11863
11946
  const popsType = "prompt";
11864
- const emitter = new EventEmiter(popsType);
11865
11947
  let config = PopsPromptDefaultConfig();
11866
11948
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11867
11949
  config = popsUtils.assign(config, __config__);
11868
11950
  config = PopsHandler.handleOnly(popsType, config);
11951
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11869
11952
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11870
11953
  PopsHandler.handleInit($shadowRoot, [
11871
11954
  {
@@ -12086,10 +12169,10 @@ const PopsRightClickMenuDefaultConfig = () => {
12086
12169
  style: null,
12087
12170
  lightStyle: null,
12088
12171
  darkStyle: null,
12089
- beforeAppendToPageCallBack() { },
12090
12172
  limitPositionXInView: true,
12091
12173
  limitPositionYInView: true,
12092
12174
  beforeShowCallBack() { },
12175
+ emitter: null,
12093
12176
  };
12094
12177
  };
12095
12178
 
@@ -12098,11 +12181,11 @@ const PopsRightClickMenu = {
12098
12181
  const guid = popsUtils.getRandomGUID();
12099
12182
  // 设置当前类型
12100
12183
  const popsType = "rightClickMenu";
12101
- const emitter = new EventEmiter(popsType);
12102
12184
  let config = PopsRightClickMenuDefaultConfig();
12103
12185
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12104
12186
  config = popsUtils.assign(config, __config__);
12105
12187
  config = PopsHandler.handleOnly(popsType, config);
12188
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12106
12189
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12107
12190
  PopsHandler.handleInit($shadowRoot, [
12108
12191
  {
@@ -12724,6 +12807,7 @@ const PopsSearchSuggestionDefaultConfig = () => {
12724
12807
  style: "",
12725
12808
  lightStyle: null,
12726
12809
  darkStyle: null,
12810
+ emitter: null,
12727
12811
  };
12728
12812
  };
12729
12813
 
@@ -12732,7 +12816,6 @@ const PopsSearchSuggestion = {
12732
12816
  const guid = popsUtils.getRandomGUID();
12733
12817
  // 设置当前类型
12734
12818
  const popsType = "searchSuggestion";
12735
- const emitter = new EventEmiter(popsType);
12736
12819
  let config = PopsSearchSuggestionDefaultConfig();
12737
12820
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12738
12821
  config = popsUtils.assign(config, __config__);
@@ -12740,6 +12823,7 @@ const PopsSearchSuggestion = {
12740
12823
  if (config.$inputTarget == null) {
12741
12824
  config.$inputTarget = config.$target;
12742
12825
  }
12826
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12743
12827
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12744
12828
  PopsHandler.handleInit($shadowRoot, [
12745
12829
  {
@@ -13624,6 +13708,8 @@ class Pops {
13624
13708
  PopsAnimation,
13625
13709
  /** 事件类 */
13626
13710
  EventEmiter,
13711
+ /** 通用的CSS类名 */
13712
+ PopsCommonCSSClassName,
13627
13713
  };
13628
13714
  init() { }
13629
13715
  /**