@whitesev/pops 4.0.1 → 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 +229 -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 +229 -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 +229 -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 +229 -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 +229 -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 +229 -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 +126 -9
  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 +6 -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.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "4.0.1";
1
+ const version = "4.1.0";
2
2
 
3
3
  const GlobalConfig = {
4
4
  config: {},
@@ -57,15 +57,16 @@ const GlobalConfig = {
57
57
  };
58
58
 
59
59
  class EventEmiter {
60
- #type;
61
- #data = new Map();
60
+ [Symbol.toStringTag] = "EventEmiter";
61
+ type;
62
+ data = new Map();
62
63
  constructor(type) {
63
- this.#type = type;
64
+ this.type = type;
64
65
  }
65
66
  on(eventName, callback) {
66
- const eventList = this.#data.get(eventName) ?? [];
67
- eventList.push({ type: this.#type, time: Date.now(), callback: callback });
68
- this.#data.set(eventName, eventList);
67
+ const eventList = this.data.get(eventName) ?? [];
68
+ eventList.push({ type: this.type, time: Date.now(), callback: callback });
69
+ this.data.set(eventName, eventList);
69
70
  return {
70
71
  off: () => {
71
72
  this.off(eventName, callback);
@@ -76,7 +77,7 @@ class EventEmiter {
76
77
  };
77
78
  }
78
79
  off(eventName, callback) {
79
- const eventList = this.#data.get(eventName) ?? [];
80
+ const eventList = this.data.get(eventName) ?? [];
80
81
  let isOffSuccess = false;
81
82
  for (let index = eventList.length - 1; index >= 0; index--) {
82
83
  if (eventList[index].callback === callback) {
@@ -86,27 +87,27 @@ class EventEmiter {
86
87
  }
87
88
  if (eventList.length === 0) {
88
89
  // empty
89
- this.#data.delete(eventName);
90
+ this.data.delete(eventName);
90
91
  }
91
92
  else {
92
93
  if (isOffSuccess) {
93
94
  // update
94
- this.#data.set(eventName, eventList);
95
+ this.data.set(eventName, eventList);
95
96
  }
96
97
  }
97
98
  }
98
99
  async emit(eventName, ...args) {
99
- const eventList = this.#data.get(eventName) ?? [];
100
+ const eventList = this.data.get(eventName) ?? [];
100
101
  for (const item of eventList) {
101
102
  await item.callback(...args);
102
103
  }
103
104
  }
104
105
  offAll(eventName) {
105
106
  if (typeof eventName === "string") {
106
- this.#data.delete(eventName);
107
+ this.data.delete(eventName);
107
108
  }
108
109
  else {
109
- this.#data.clear();
110
+ this.data.clear();
110
111
  }
111
112
  }
112
113
  /**
@@ -114,10 +115,10 @@ class EventEmiter {
114
115
  */
115
116
  getAllEvents(eventName) {
116
117
  if (typeof eventName === "string") {
117
- return this.#data.get(eventName);
118
+ return this.data.get(eventName);
118
119
  }
119
120
  else {
120
- return Array.from(this.#data.values());
121
+ return Array.from(this.data.values());
121
122
  }
122
123
  }
123
124
  }
@@ -428,7 +429,8 @@ class PopsUtils {
428
429
  if (typeof sourceValue === "object" &&
429
430
  sourceValue != null &&
430
431
  keyName in target &&
431
- !UtilsContext.isDOM(sourceValue)) {
432
+ !UtilsContext.isDOM(sourceValue) &&
433
+ !(sourceValue instanceof EventEmiter)) {
432
434
  // 源端的值是object类型,且不是元素节点
433
435
  // 如果是数组,那此数组中有值,清空旧的数组再赋值
434
436
  let childObjectValue;
@@ -444,7 +446,7 @@ class PopsUtils {
444
446
  Reflect.set(target, keyName, childObjectValue);
445
447
  }
446
448
  else {
447
- /* 直接赋值 */
449
+ // 直接赋值
448
450
  Reflect.set(target, keyName, sourceValue);
449
451
  }
450
452
  }
@@ -634,33 +636,31 @@ class PopsUtils {
634
636
  if (typeof deviation !== "number" || Number.isNaN(deviation)) {
635
637
  deviation = 10;
636
638
  }
637
- const leftTop = {
638
- x: globalThis.innerWidth * (1 / 8),
639
- y: globalThis.innerHeight * (1 / 8),
640
- };
641
- const leftBottom = {
642
- x: globalThis.innerWidth * (1 / 8),
643
- y: globalThis.innerHeight * (7 / 8),
644
- };
645
- const rightTop = {
646
- x: globalThis.innerWidth * (7 / 8),
647
- y: globalThis.innerHeight * (1 / 8),
648
- };
649
- const rightBottom = {
650
- x: globalThis.innerWidth * (7 / 8),
651
- y: globalThis.innerHeight * (7 / 8),
652
- };
653
- const center = {
654
- x: globalThis.innerWidth / 2,
655
- y: globalThis.innerHeight / 2,
656
- };
657
- const delayHandlerElementPostionList = [
658
- leftTop,
659
- leftBottom,
660
- rightTop,
661
- rightBottom,
662
- center,
663
- ];
639
+ /** 坐标偏移 */
640
+ const positionDistance = 10;
641
+ const defaultCalcPostion = [];
642
+ const maxPostionX = globalThis.innerWidth;
643
+ const maxPostionY = globalThis.innerHeight;
644
+ const gridXCount = 8;
645
+ const gridYCount = 8;
646
+ for (let i = 0; i < gridXCount; i++) {
647
+ for (let j = 0; j < gridYCount; j++) {
648
+ const positionX = globalThis.innerWidth * (i / gridXCount) + positionDistance;
649
+ const positionY = globalThis.innerHeight * (j / gridYCount) + positionDistance;
650
+ const position = {
651
+ x: positionX,
652
+ y: positionY,
653
+ };
654
+ if (position.x > maxPostionX) {
655
+ position.x = maxPostionX;
656
+ }
657
+ if (position.y > maxPostionY) {
658
+ position.y = maxPostionY;
659
+ }
660
+ defaultCalcPostion.push(position);
661
+ }
662
+ }
663
+ const delayHandlerElementPostionList = defaultCalcPostion;
664
664
  if ($el) {
665
665
  delayHandlerElementPostionList.length = 0;
666
666
  if (Array.isArray($el)) {
@@ -672,61 +672,79 @@ class PopsUtils {
672
672
  }
673
673
  const positionInfoList = delayHandlerElementPostionList
674
674
  .map((position) => {
675
- let positionNode;
675
+ let $position;
676
676
  let positionX;
677
677
  let positionY;
678
678
  if (position instanceof HTMLElement) {
679
- positionNode = position;
679
+ $position = position;
680
680
  const nodeRect = position.getBoundingClientRect();
681
681
  positionX = nodeRect.x + nodeRect.width / 2;
682
682
  positionY = nodeRect.y + nodeRect.height / 2;
683
683
  }
684
684
  else {
685
- positionNode = document.elementFromPoint(position.x, position.y);
685
+ $position = document.elementFromPoint(position.x, position.y);
686
686
  positionX = position.x;
687
687
  positionY = position.y;
688
688
  }
689
- const shadowRoot = positionNode?.shadowRoot;
689
+ const shadowRoot = $position?.shadowRoot;
690
690
  if (shadowRoot) {
691
- positionNode = shadowRoot.elementFromPoint(positionX, positionY);
691
+ // 处理ShadowRoot
692
+ $position = shadowRoot.elementFromPoint(positionX, positionY);
692
693
  }
693
- if (positionNode instanceof HTMLStyleElement)
694
- return;
695
- if (positionNode instanceof HTMLScriptElement)
696
- return;
697
- if (positionNode instanceof HTMLMetaElement)
698
- return;
699
- if (positionNode instanceof HTMLHeadElement)
700
- return;
701
- if (!(positionNode instanceof HTMLElement))
694
+ if (!($position instanceof HTMLElement))
702
695
  return;
703
- let parent = positionNode;
696
+ let $parent = $position;
704
697
  let zIndex = 0;
705
- let maxZIndexNode = null;
706
- while (parent) {
707
- const nodeStyle = globalThis.getComputedStyle(parent);
698
+ let $maxZIndexNode = null;
699
+ let rect = {
700
+ x: 0,
701
+ y: 0,
702
+ width: 0,
703
+ height: 0,
704
+ top: 0,
705
+ right: 0,
706
+ bottom: 0,
707
+ left: 0,
708
+ };
709
+ while ($parent) {
710
+ const nodeStyle = globalThis.getComputedStyle($parent);
708
711
  const nodeZIndex = parseInt(nodeStyle.zIndex);
709
712
  if (nodeStyle.position !== "static" && !isNaN(nodeZIndex)) {
710
713
  if (nodeZIndex > zIndex) {
711
714
  zIndex = nodeZIndex;
712
- maxZIndexNode = parent;
713
- }
714
- }
715
- parent = parent.parentElement;
715
+ $maxZIndexNode = $parent;
716
+ }
717
+ }
718
+ $parent = $parent.parentElement;
719
+ }
720
+ if ($maxZIndexNode) {
721
+ const maxRect = $maxZIndexNode.getBoundingClientRect();
722
+ rect = {
723
+ x: maxRect.x,
724
+ y: maxRect.y,
725
+ width: maxRect.width,
726
+ height: maxRect.height,
727
+ top: maxRect.top,
728
+ right: maxRect.right,
729
+ bottom: maxRect.bottom,
730
+ left: maxRect.left,
731
+ };
716
732
  }
717
733
  return {
718
- /** 处理了偏移量后的z-index值 */
734
+ /** 计算偏移量后的z-index值 */
719
735
  zIndex: zIndex + deviation,
720
- /** 原始z-index值 */
736
+ /** 获取到的最大的z-index值 */
721
737
  originZIndex: zIndex,
722
738
  /** 拥有最大z-index的元素 */
723
- node: maxZIndexNode,
739
+ node: $maxZIndexNode,
724
740
  /** 目标坐标元素 */
725
- positionNode: positionNode,
726
- /** x坐标 */
741
+ positionNode: $position,
742
+ /** 目标x坐标 */
727
743
  positionX: positionX,
728
- /** y坐标 */
744
+ /** 目标y坐标 */
729
745
  positionY: positionY,
746
+ /** node位置信息 */
747
+ rect,
730
748
  };
731
749
  })
732
750
  .filter((it) => it != null);
@@ -777,10 +795,17 @@ const PopsSafeUtils = {
777
795
  const PopsCommonCSSClassName = {
778
796
  flexCenter: "pops-flex-items-center",
779
797
  flexYCenter: "pops-flex-y-center",
798
+ flexXCenter: "pops-flex-x-center",
780
799
  hide: "pops-hide",
781
800
  hideImportant: "pops-hide-important",
801
+ noBorder: "pops-no-border",
802
+ noBorderImportant: "pops-no-border-important",
782
803
  userSelectNone: "pops-user-select-none",
783
- textIsDisabled: "pops-text-is-disabled"};
804
+ lineHeightCenter: "pops-line-height-center",
805
+ widthFill: "pops-width-fill",
806
+ textIsDisabled: "pops-text-is-disabled",
807
+ textIsDisabledImportant: "pops-text-is-disabled-important",
808
+ };
784
809
 
785
810
  class PopsDOMUtilsEvent {
786
811
  on(element, eventType, selector, callback, option) {
@@ -1680,6 +1705,35 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
1680
1705
  getTransitionEndNameList() {
1681
1706
  return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
1682
1707
  }
1708
+ /**
1709
+ * 是否是隐藏状态
1710
+ *
1711
+ * 检测以下项:
1712
+ *
1713
+ * + `display`: none
1714
+ * + `visibility`: hidden
1715
+ * + `opacity`: 0
1716
+ * + `使用了pops的自定义的隐藏class类`
1717
+ * @param $el 需要检测的元素
1718
+ */
1719
+ isHide($el) {
1720
+ let flag = false;
1721
+ if (this.containsClassName($el, PopsCommonCSSClassName.hide) ||
1722
+ this.containsClassName($el, PopsCommonCSSClassName.hideImportant)) {
1723
+ flag = true;
1724
+ }
1725
+ else {
1726
+ if ($el instanceof HTMLElement) {
1727
+ const style = $el.style;
1728
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
1729
+ }
1730
+ if (!flag) {
1731
+ const style = globalThis.getComputedStyle($el);
1732
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
1733
+ }
1734
+ }
1735
+ return flag;
1736
+ }
1683
1737
  /**
1684
1738
  * 实现jQuery中的$().offset();
1685
1739
  * @param element
@@ -3188,7 +3242,7 @@ const PopsInstHandler = {
3188
3242
  return totalInstConfigList;
3189
3243
  },
3190
3244
  /**
3191
- * 隐藏
3245
+ * 显示
3192
3246
  * @param popsType
3193
3247
  * @param instConfigList
3194
3248
  * @param guid
@@ -3196,24 +3250,34 @@ const PopsInstHandler = {
3196
3250
  * @param $anim
3197
3251
  * @param $mask
3198
3252
  */
3199
- hide(config, popsType, instConfigList, guid, $anim, $mask) {
3253
+ show(config, popsType, instConfigList, guid, $anim, $mask) {
3200
3254
  // oxlint-disable-next-line no-async-promise-executor
3201
3255
  return new Promise(async (resolve) => {
3202
3256
  const $pops = $anim.querySelector(".pops[type-value]");
3203
3257
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3204
3258
  if (fintInst) {
3205
- // 存在实例
3259
+ // 由于是隐蔽状态
3260
+ // 先设置好动画状态
3261
+ // 再显示,会自执行动画
3262
+ const checkVisible = () => {
3263
+ if (!popsDOMUtils.isHide($anim)) {
3264
+ return true;
3265
+ }
3266
+ else {
3267
+ return false;
3268
+ }
3269
+ };
3206
3270
  const startAnim = async () => {
3207
3271
  if (popsType === "drawer") {
3208
3272
  // drawer是抽屉
3209
3273
  // 单独处理动画
3210
3274
  const drawerConfig = config;
3211
- await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3275
+ await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3212
3276
  if ($mask) {
3213
- popsDOMUtils.css($mask, "display", "none");
3277
+ popsDOMUtils.css($mask, "display", "");
3214
3278
  }
3215
3279
  const direction = drawerConfig.direction;
3216
- const size = "0";
3280
+ const size = drawerConfig.size.toString();
3217
3281
  if (["top", "bottom"].includes(direction)) {
3218
3282
  $pops.style.setProperty("height", size);
3219
3283
  }
@@ -3221,26 +3285,26 @@ const PopsInstHandler = {
3221
3285
  $pops.style.setProperty("width", size);
3222
3286
  }
3223
3287
  else {
3224
- console.error("未知direction: ", direction);
3288
+ console.error("未知direction", direction);
3225
3289
  }
3226
3290
  }
3227
3291
  else {
3228
- instConfigItem.$anim.style.width = "100%";
3229
- instConfigItem.$anim.style.height = "100%";
3230
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
3292
+ instConfigItem.$anim.style.width = "";
3293
+ instConfigItem.$anim.style.height = "";
3294
+ Reflect.set(instConfigItem.$anim.style, "animation-name", animName);
3231
3295
  }
3232
- };
3233
- const endCallback = () => {
3234
- instConfigItem.$anim.style.display = "none";
3296
+ instConfigItem.$anim.style.display = "";
3235
3297
  if (instConfigItem.$mask) {
3236
- instConfigItem.$mask.style.display = "none";
3298
+ instConfigItem.$mask.style.display = "";
3237
3299
  }
3238
- fintInst.emitter.emit("pops:hide", instConfigItem);
3300
+ };
3301
+ const endCallback = () => {
3302
+ fintInst.emitter.emit("pops:show", instConfigItem);
3239
3303
  };
3240
3304
  const instConfigItem = fintInst;
3241
- fintInst.emitter.emit("pops:before-hide", instConfigItem);
3242
- await startAnim();
3243
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3305
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3306
+ fintInst.emitter.emit("pops:before-show", instConfigItem);
3307
+ if (checkVisible() && PopsAnimation.hasAnim(animName)) {
3244
3308
  /**
3245
3309
  * 动画结束的回调
3246
3310
  */
@@ -3251,22 +3315,23 @@ const PopsInstHandler = {
3251
3315
  };
3252
3316
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3253
3317
  capture: true,
3254
- once: true,
3255
3318
  });
3319
+ await startAnim();
3256
3320
  }
3257
3321
  else {
3322
+ await startAnim();
3258
3323
  endCallback();
3259
3324
  resolve();
3260
3325
  }
3261
3326
  }
3262
3327
  else {
3263
- console.error("hide-error: 该实例未存储");
3328
+ console.error("show-error: 该实例未存储");
3264
3329
  resolve();
3265
3330
  }
3266
3331
  });
3267
3332
  },
3268
3333
  /**
3269
- * 显示
3334
+ * 隐藏
3270
3335
  * @param popsType
3271
3336
  * @param instConfigList
3272
3337
  * @param guid
@@ -3274,23 +3339,35 @@ const PopsInstHandler = {
3274
3339
  * @param $anim
3275
3340
  * @param $mask
3276
3341
  */
3277
- show(config, popsType, instConfigList, guid, $anim, $mask) {
3342
+ hide(config, popsType, instConfigList, guid, $anim, $mask) {
3278
3343
  // oxlint-disable-next-line no-async-promise-executor
3279
3344
  return new Promise(async (resolve) => {
3280
3345
  const $pops = $anim.querySelector(".pops[type-value]");
3281
3346
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3282
3347
  if (fintInst) {
3348
+ // 由于是已显示状态
3349
+ // 先执行动画
3350
+ // 再隐藏
3351
+ // 存在实例
3352
+ const checkVisible = () => {
3353
+ if (!popsDOMUtils.isHide($anim)) {
3354
+ return true;
3355
+ }
3356
+ else {
3357
+ return false;
3358
+ }
3359
+ };
3283
3360
  const startAnim = async () => {
3284
3361
  if (popsType === "drawer") {
3285
3362
  // drawer是抽屉
3286
3363
  // 单独处理动画
3287
3364
  const drawerConfig = config;
3288
- await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3365
+ await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3289
3366
  if ($mask) {
3290
- popsDOMUtils.css($mask, "display", "");
3367
+ popsDOMUtils.css($mask, "display", "none");
3291
3368
  }
3292
3369
  const direction = drawerConfig.direction;
3293
- const size = drawerConfig.size.toString();
3370
+ const size = "0";
3294
3371
  if (["top", "bottom"].includes(direction)) {
3295
3372
  $pops.style.setProperty("height", size);
3296
3373
  }
@@ -3298,26 +3375,27 @@ const PopsInstHandler = {
3298
3375
  $pops.style.setProperty("width", size);
3299
3376
  }
3300
3377
  else {
3301
- console.error("未知direction", direction);
3378
+ console.error("未知direction: ", direction);
3302
3379
  }
3303
3380
  }
3304
3381
  else {
3305
- instConfigItem.$anim.style.width = "";
3306
- instConfigItem.$anim.style.height = "";
3307
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim").replace("-reverse", ""));
3382
+ instConfigItem.$anim.style.width = "100%";
3383
+ instConfigItem.$anim.style.height = "100%";
3384
+ Reflect.set(instConfigItem.$anim.style, "animation-name", reverseAnimName);
3308
3385
  }
3309
3386
  };
3310
3387
  const endCallback = () => {
3311
- instConfigItem.$anim.style.display = "";
3388
+ instConfigItem.$anim.style.display = "none";
3312
3389
  if (instConfigItem.$mask) {
3313
- instConfigItem.$mask.style.display = "";
3390
+ instConfigItem.$mask.style.display = "none";
3314
3391
  }
3315
- fintInst.emitter.emit("pops:show", instConfigItem);
3392
+ fintInst.emitter.emit("pops:hide", instConfigItem);
3316
3393
  };
3317
3394
  const instConfigItem = fintInst;
3318
- fintInst.emitter.emit("pops:before-show", instConfigItem);
3319
- await startAnim();
3320
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3395
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3396
+ const reverseAnimName = animName + "-reverse";
3397
+ fintInst.emitter.emit("pops:before-hide", instConfigItem);
3398
+ if (!checkVisible() && PopsAnimation.hasAnim(reverseAnimName)) {
3321
3399
  /**
3322
3400
  * 动画结束的回调
3323
3401
  */
@@ -3328,15 +3406,18 @@ const PopsInstHandler = {
3328
3406
  };
3329
3407
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3330
3408
  capture: true,
3409
+ once: true,
3331
3410
  });
3411
+ await startAnim();
3332
3412
  }
3333
3413
  else {
3414
+ await startAnim();
3334
3415
  endCallback();
3335
3416
  resolve();
3336
3417
  }
3337
3418
  }
3338
3419
  else {
3339
- console.error("show-error: 该实例未存储");
3420
+ console.error("hide-error: 该实例未存储");
3340
3421
  resolve();
3341
3422
  }
3342
3423
  });
@@ -3376,7 +3457,7 @@ const PopsInstHandler = {
3376
3457
  await new Promise(async (resolve) => {
3377
3458
  const $pops = $anim.querySelector(".pops[type-value]");
3378
3459
  const drawerConfig = config;
3379
- const start = () => {
3460
+ const startAnim = () => {
3380
3461
  /**
3381
3462
  * 弹窗已关闭的回调
3382
3463
  */
@@ -3417,7 +3498,7 @@ const PopsInstHandler = {
3417
3498
  };
3418
3499
  if (popsType === "drawer") {
3419
3500
  await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3420
- start();
3501
+ startAnim();
3421
3502
  }
3422
3503
  else {
3423
3504
  await PopsInstHandler.removeInstance([instConfigList], guid);
@@ -4168,8 +4249,8 @@ const PopsAlertDefaultConfig = () => {
4168
4249
  style: null,
4169
4250
  lightStyle: null,
4170
4251
  darkStyle: null,
4171
- beforeAppendToPageCallBack() { },
4172
4252
  stopKeyDownEventPropagation: true,
4253
+ emitter: null,
4173
4254
  };
4174
4255
  };
4175
4256
 
@@ -4178,11 +4259,11 @@ const PopsAlert = {
4178
4259
  const guid = popsUtils.getRandomGUID();
4179
4260
  // 设置当前类型
4180
4261
  const popsType = "alert";
4181
- const emitter = new EventEmiter(popsType);
4182
4262
  let config = PopsAlertDefaultConfig();
4183
4263
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4184
4264
  config = popsUtils.assign(config, __config__);
4185
4265
  config = PopsHandler.handleOnly(popsType, config);
4266
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4186
4267
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4187
4268
  PopsHandler.handleInit($shadowRoot, [
4188
4269
  {
@@ -4376,8 +4457,8 @@ const PopsConfirmDefaultConfig = () => {
4376
4457
  style: null,
4377
4458
  lightStyle: null,
4378
4459
  darkStyle: null,
4379
- beforeAppendToPageCallBack() { },
4380
4460
  stopKeyDownEventPropagation: true,
4461
+ emitter: null,
4381
4462
  };
4382
4463
  };
4383
4464
 
@@ -4386,11 +4467,11 @@ const PopsConfirm = {
4386
4467
  const guid = popsUtils.getRandomGUID();
4387
4468
  // 设置当前类型
4388
4469
  const popsType = "confirm";
4389
- const emitter = new EventEmiter(popsType);
4390
4470
  let config = PopsConfirmDefaultConfig();
4391
4471
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4392
4472
  config = popsUtils.assign(config, __config__);
4393
4473
  config = PopsHandler.handleOnly(popsType, config);
4474
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4394
4475
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4395
4476
  PopsHandler.handleInit($shadowRoot, [
4396
4477
  {
@@ -4583,9 +4664,9 @@ const PopsDrawerDefaultConfig = () => {
4583
4664
  style: null,
4584
4665
  lightStyle: null,
4585
4666
  darkStyle: null,
4586
- beforeAppendToPageCallBack() { },
4587
4667
  forbiddenScroll: false,
4588
4668
  stopKeyDownEventPropagation: true,
4669
+ emitter: null,
4589
4670
  };
4590
4671
  };
4591
4672
 
@@ -4594,11 +4675,11 @@ const PopsDrawer = {
4594
4675
  const guid = popsUtils.getRandomGUID();
4595
4676
  // 设置当前类型
4596
4677
  const popsType = "drawer";
4597
- const emitter = new EventEmiter(popsType);
4598
4678
  let config = PopsDrawerDefaultConfig();
4599
4679
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4600
4680
  config = popsUtils.assign(config, __config__);
4601
4681
  config = PopsHandler.handleOnly(popsType, config);
4682
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4602
4683
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4603
4684
  PopsHandler.handleInit($shadowRoot, [
4604
4685
  {
@@ -4809,6 +4890,7 @@ const PopsLoadingDefaultConfig = () => {
4809
4890
  darkStyle: null,
4810
4891
  addIndexCSS: true,
4811
4892
  stopKeyDownEventPropagation: true,
4893
+ emitter: null,
4812
4894
  };
4813
4895
  };
4814
4896
 
@@ -4816,19 +4898,19 @@ const PopsLoading = {
4816
4898
  init(__config__) {
4817
4899
  const guid = popsUtils.getRandomGUID();
4818
4900
  // 设置当前类型
4819
- const PopsType = "loading";
4820
- const emitter = new EventEmiter(PopsType);
4901
+ const popsType = "loading";
4821
4902
  let config = PopsLoadingDefaultConfig();
4822
4903
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4823
4904
  config = popsUtils.assign(config, __config__);
4824
- config = PopsHandler.handleOnly(PopsType, config);
4905
+ config = PopsHandler.handleOnly(popsType, config);
4906
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4825
4907
  // 先把z-index提取出来
4826
4908
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4827
4909
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4828
4910
  const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
4829
- const animHTML = PopsElementHandler.createAnim(guid, PopsType, config,
4911
+ const animHTML = PopsElementHandler.createAnim(guid, popsType, config,
4830
4912
  /*html*/ `
4831
- <div class="pops-content pops-${PopsType}-content">${config.addIndexCSS
4913
+ <div class="pops-content pops-${popsType}-content">${config.addIndexCSS
4832
4914
  ? /*html*/ `
4833
4915
  <style data-model-name="index">${PopsCSS.index}</style>
4834
4916
  <style data-model-name="anim">${PopsCSS.anim}</style>
@@ -4839,13 +4921,13 @@ const PopsLoading = {
4839
4921
  ${PopsCSS.loadingCSS}
4840
4922
  </style>
4841
4923
  ${config.style != null ? `<style>${config.style}</style>` : ""}
4842
- <p pops class="pops-${PopsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
4924
+ <p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
4843
4925
  </div>`, "", zIndex);
4844
4926
  /**
4845
4927
  * 弹窗的主元素,包括动画层
4846
4928
  */
4847
4929
  const $anim = PopsElementHandler.parseElement(animHTML);
4848
- const { $pops: $pops } = PopsHandler.handleQueryElement($anim, PopsType);
4930
+ const { $pops: $pops } = PopsHandler.handleQueryElement($anim, popsType);
4849
4931
  /**
4850
4932
  * 遮罩层元素
4851
4933
  */
@@ -4857,7 +4939,7 @@ const PopsLoading = {
4857
4939
  if (config.mask.enable) {
4858
4940
  // 创建遮罩层
4859
4941
  const handleMask = PopsHandler.handleMask({
4860
- type: PopsType,
4942
+ type: popsType,
4861
4943
  guid: guid,
4862
4944
  config: config,
4863
4945
  animElement: $anim,
@@ -4866,12 +4948,12 @@ const PopsLoading = {
4866
4948
  $mask = handleMask.maskElement;
4867
4949
  $elList.push($mask);
4868
4950
  }
4869
- const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
4951
+ const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, popsType, $anim, $pops, emitter, $mask);
4870
4952
  popsDOMUtils.append(config.$parent, $elList);
4871
4953
  if ($mask != null) {
4872
4954
  $anim.after($mask);
4873
4955
  }
4874
- PopsHandler.handlePush(PopsType, {
4956
+ PopsHandler.handlePush(popsType, {
4875
4957
  $shadowContainer: $pops,
4876
4958
  $shadowRoot: $pops,
4877
4959
  guid: guid,
@@ -5040,8 +5122,8 @@ const PopsFolderDefaultConfig = () => {
5040
5122
  style: null,
5041
5123
  lightStyle: null,
5042
5124
  darkStyle: null,
5043
- beforeAppendToPageCallBack() { },
5044
5125
  stopKeyDownEventPropagation: true,
5126
+ emitter: null,
5045
5127
  };
5046
5128
  };
5047
5129
 
@@ -5078,11 +5160,11 @@ const PopsFolder = {
5078
5160
  const guid = popsUtils.getRandomGUID();
5079
5161
  // 设置当前类型
5080
5162
  const popsType = "folder";
5081
- const emitter = new EventEmiter(popsType);
5082
5163
  let config = PopsFolderDefaultConfig();
5083
5164
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
5084
5165
  config = popsUtils.assign(config, __config__);
5085
5166
  config = PopsHandler.handleOnly(popsType, config);
5167
+ const emitter = config.emitter ?? new EventEmiter(popsType);
5086
5168
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
5087
5169
  PopsHandler.handleInit($shadowRoot, [
5088
5170
  {
@@ -6005,8 +6087,8 @@ const PopsIframeDefaultConfig = () => {
6005
6087
  style: null,
6006
6088
  lightStyle: null,
6007
6089
  darkStyle: null,
6008
- beforeAppendToPageCallBack() { },
6009
6090
  stopKeyDownEventPropagation: true,
6091
+ emitter: null,
6010
6092
  };
6011
6093
  };
6012
6094
 
@@ -6015,7 +6097,6 @@ const PopsIframe = {
6015
6097
  const guid = popsUtils.getRandomGUID();
6016
6098
  // 设置当前类型
6017
6099
  const popsType = "iframe";
6018
- const emitter = new EventEmiter(popsType);
6019
6100
  let config = PopsIframeDefaultConfig();
6020
6101
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
6021
6102
  config = popsUtils.assign(config, __config__);
@@ -6023,6 +6104,8 @@ const PopsIframe = {
6023
6104
  throw new TypeError("config.url must not be null.");
6024
6105
  }
6025
6106
  config = PopsHandler.handleOnly(popsType, config);
6107
+ const emitter = config.emitter ??
6108
+ new EventEmiter(popsType);
6026
6109
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
6027
6110
  PopsHandler.handleInit($shadowRoot, [
6028
6111
  {
@@ -6050,7 +6133,7 @@ const PopsIframe = {
6050
6133
  css: PopsCSS.iframeCSS,
6051
6134
  },
6052
6135
  ]);
6053
- const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
6136
+ const maskExtraStyle = config.animation != null && config.animation != "" && config.animation ? "position:absolute;" : "";
6054
6137
  // 先把z-index提取出来
6055
6138
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
6056
6139
  const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
@@ -7131,9 +7214,9 @@ const PopsPanelDefaultConfig = () => {
7131
7214
  style: null,
7132
7215
  lightStyle: null,
7133
7216
  darkStyle: null,
7134
- beforeAppendToPageCallBack() { },
7135
7217
  stopKeyDownEventPropagation: true,
7136
7218
  listenEscapeKeyUpToExitDeepMenu: true,
7219
+ emitter: null,
7137
7220
  };
7138
7221
  };
7139
7222
 
@@ -7245,7 +7328,7 @@ const PopsTooltipDefaultConfig = () => {
7245
7328
  style: "",
7246
7329
  lightStyle: null,
7247
7330
  darkStyle: null,
7248
- beforeAppendToPageCallBack() { },
7331
+ emitter: null,
7249
7332
  };
7250
7333
  };
7251
7334
 
@@ -7713,7 +7796,6 @@ const PopsTooltip = {
7713
7796
  const guid = popsUtils.getRandomGUID();
7714
7797
  // 设置当前类型
7715
7798
  const popsType = "tooltip";
7716
- const emitter = new EventEmiter(popsType);
7717
7799
  let config = PopsTooltipDefaultConfig();
7718
7800
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
7719
7801
  config = popsUtils.assign(config, __config__);
@@ -7730,6 +7812,7 @@ const PopsTooltip = {
7730
7812
  config.onShowEventName += ` ${it}`;
7731
7813
  });
7732
7814
  }
7815
+ const emitter = config.emitter ?? new EventEmiter(popsType);
7733
7816
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
7734
7817
  PopsHandler.handleInit($shadowRoot, [
7735
7818
  {
@@ -11595,11 +11678,11 @@ const PopsPanel = {
11595
11678
  const guid = popsUtils.getRandomGUID();
11596
11679
  // 设置当前类型
11597
11680
  const popsType = "panel";
11598
- const emitter = new EventEmiter(popsType);
11599
11681
  let config = PopsPanelDefaultConfig();
11600
11682
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11601
11683
  config = popsUtils.assign(config, __config__);
11602
11684
  config = PopsHandler.handleOnly(popsType, config);
11685
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11603
11686
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11604
11687
  PopsHandler.handleInit($shadowRoot, [
11605
11688
  {
@@ -11849,8 +11932,8 @@ const PopsPromptDefaultConfig = () => {
11849
11932
  style: null,
11850
11933
  lightStyle: null,
11851
11934
  darkStyle: null,
11852
- beforeAppendToPageCallBack() { },
11853
11935
  stopKeyDownEventPropagation: true,
11936
+ emitter: null,
11854
11937
  };
11855
11938
  };
11856
11939
 
@@ -11859,11 +11942,11 @@ const PopsPrompt = {
11859
11942
  const guid = popsUtils.getRandomGUID();
11860
11943
  // 设置当前类型
11861
11944
  const popsType = "prompt";
11862
- const emitter = new EventEmiter(popsType);
11863
11945
  let config = PopsPromptDefaultConfig();
11864
11946
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11865
11947
  config = popsUtils.assign(config, __config__);
11866
11948
  config = PopsHandler.handleOnly(popsType, config);
11949
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11867
11950
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11868
11951
  PopsHandler.handleInit($shadowRoot, [
11869
11952
  {
@@ -12084,10 +12167,10 @@ const PopsRightClickMenuDefaultConfig = () => {
12084
12167
  style: null,
12085
12168
  lightStyle: null,
12086
12169
  darkStyle: null,
12087
- beforeAppendToPageCallBack() { },
12088
12170
  limitPositionXInView: true,
12089
12171
  limitPositionYInView: true,
12090
12172
  beforeShowCallBack() { },
12173
+ emitter: null,
12091
12174
  };
12092
12175
  };
12093
12176
 
@@ -12096,11 +12179,11 @@ const PopsRightClickMenu = {
12096
12179
  const guid = popsUtils.getRandomGUID();
12097
12180
  // 设置当前类型
12098
12181
  const popsType = "rightClickMenu";
12099
- const emitter = new EventEmiter(popsType);
12100
12182
  let config = PopsRightClickMenuDefaultConfig();
12101
12183
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12102
12184
  config = popsUtils.assign(config, __config__);
12103
12185
  config = PopsHandler.handleOnly(popsType, config);
12186
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12104
12187
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12105
12188
  PopsHandler.handleInit($shadowRoot, [
12106
12189
  {
@@ -12722,6 +12805,7 @@ const PopsSearchSuggestionDefaultConfig = () => {
12722
12805
  style: "",
12723
12806
  lightStyle: null,
12724
12807
  darkStyle: null,
12808
+ emitter: null,
12725
12809
  };
12726
12810
  };
12727
12811
 
@@ -12730,7 +12814,6 @@ const PopsSearchSuggestion = {
12730
12814
  const guid = popsUtils.getRandomGUID();
12731
12815
  // 设置当前类型
12732
12816
  const popsType = "searchSuggestion";
12733
- const emitter = new EventEmiter(popsType);
12734
12817
  let config = PopsSearchSuggestionDefaultConfig();
12735
12818
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12736
12819
  config = popsUtils.assign(config, __config__);
@@ -12738,6 +12821,7 @@ const PopsSearchSuggestion = {
12738
12821
  if (config.$inputTarget == null) {
12739
12822
  config.$inputTarget = config.$target;
12740
12823
  }
12824
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12741
12825
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12742
12826
  PopsHandler.handleInit($shadowRoot, [
12743
12827
  {
@@ -13614,12 +13698,16 @@ class Pops {
13614
13698
  InstanceUtils: PopsInstanceUtils,
13615
13699
  /** pops处理float类型使用的工具类 */
13616
13700
  MathFloatUtils: PopsMathFloatUtils,
13701
+ /** 实例处理函数 */
13702
+ PopsInstHandler,
13617
13703
  /** pops.panel中用于处理各个类型的工具 */
13618
13704
  PanelHandlerComponents,
13619
13705
  /** pops.panel中的动画 */
13620
13706
  PopsAnimation,
13621
13707
  /** 事件类 */
13622
13708
  EventEmiter,
13709
+ /** 通用的CSS类名 */
13710
+ PopsCommonCSSClassName,
13623
13711
  };
13624
13712
  init() { }
13625
13713
  /**