@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.umd.js CHANGED
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.pops = factory());
5
5
  })(this, (function () { 'use strict';
6
6
 
7
- const version = "4.0.2";
7
+ const version = "4.1.0";
8
8
 
9
9
  const GlobalConfig = {
10
10
  config: {},
@@ -63,15 +63,16 @@
63
63
  };
64
64
 
65
65
  class EventEmiter {
66
- #type;
67
- #data = new Map();
66
+ [Symbol.toStringTag] = "EventEmiter";
67
+ type;
68
+ data = new Map();
68
69
  constructor(type) {
69
- this.#type = type;
70
+ this.type = type;
70
71
  }
71
72
  on(eventName, callback) {
72
- const eventList = this.#data.get(eventName) ?? [];
73
- eventList.push({ type: this.#type, time: Date.now(), callback: callback });
74
- this.#data.set(eventName, eventList);
73
+ const eventList = this.data.get(eventName) ?? [];
74
+ eventList.push({ type: this.type, time: Date.now(), callback: callback });
75
+ this.data.set(eventName, eventList);
75
76
  return {
76
77
  off: () => {
77
78
  this.off(eventName, callback);
@@ -82,7 +83,7 @@
82
83
  };
83
84
  }
84
85
  off(eventName, callback) {
85
- const eventList = this.#data.get(eventName) ?? [];
86
+ const eventList = this.data.get(eventName) ?? [];
86
87
  let isOffSuccess = false;
87
88
  for (let index = eventList.length - 1; index >= 0; index--) {
88
89
  if (eventList[index].callback === callback) {
@@ -92,27 +93,27 @@
92
93
  }
93
94
  if (eventList.length === 0) {
94
95
  // empty
95
- this.#data.delete(eventName);
96
+ this.data.delete(eventName);
96
97
  }
97
98
  else {
98
99
  if (isOffSuccess) {
99
100
  // update
100
- this.#data.set(eventName, eventList);
101
+ this.data.set(eventName, eventList);
101
102
  }
102
103
  }
103
104
  }
104
105
  async emit(eventName, ...args) {
105
- const eventList = this.#data.get(eventName) ?? [];
106
+ const eventList = this.data.get(eventName) ?? [];
106
107
  for (const item of eventList) {
107
108
  await item.callback(...args);
108
109
  }
109
110
  }
110
111
  offAll(eventName) {
111
112
  if (typeof eventName === "string") {
112
- this.#data.delete(eventName);
113
+ this.data.delete(eventName);
113
114
  }
114
115
  else {
115
- this.#data.clear();
116
+ this.data.clear();
116
117
  }
117
118
  }
118
119
  /**
@@ -120,10 +121,10 @@
120
121
  */
121
122
  getAllEvents(eventName) {
122
123
  if (typeof eventName === "string") {
123
- return this.#data.get(eventName);
124
+ return this.data.get(eventName);
124
125
  }
125
126
  else {
126
- return Array.from(this.#data.values());
127
+ return Array.from(this.data.values());
127
128
  }
128
129
  }
129
130
  }
@@ -434,7 +435,8 @@
434
435
  if (typeof sourceValue === "object" &&
435
436
  sourceValue != null &&
436
437
  keyName in target &&
437
- !UtilsContext.isDOM(sourceValue)) {
438
+ !UtilsContext.isDOM(sourceValue) &&
439
+ !(sourceValue instanceof EventEmiter)) {
438
440
  // 源端的值是object类型,且不是元素节点
439
441
  // 如果是数组,那此数组中有值,清空旧的数组再赋值
440
442
  let childObjectValue;
@@ -450,7 +452,7 @@
450
452
  Reflect.set(target, keyName, childObjectValue);
451
453
  }
452
454
  else {
453
- /* 直接赋值 */
455
+ // 直接赋值
454
456
  Reflect.set(target, keyName, sourceValue);
455
457
  }
456
458
  }
@@ -640,33 +642,31 @@
640
642
  if (typeof deviation !== "number" || Number.isNaN(deviation)) {
641
643
  deviation = 10;
642
644
  }
643
- const leftTop = {
644
- x: globalThis.innerWidth * (1 / 8),
645
- y: globalThis.innerHeight * (1 / 8),
646
- };
647
- const leftBottom = {
648
- x: globalThis.innerWidth * (1 / 8),
649
- y: globalThis.innerHeight * (7 / 8),
650
- };
651
- const rightTop = {
652
- x: globalThis.innerWidth * (7 / 8),
653
- y: globalThis.innerHeight * (1 / 8),
654
- };
655
- const rightBottom = {
656
- x: globalThis.innerWidth * (7 / 8),
657
- y: globalThis.innerHeight * (7 / 8),
658
- };
659
- const center = {
660
- x: globalThis.innerWidth / 2,
661
- y: globalThis.innerHeight / 2,
662
- };
663
- const delayHandlerElementPostionList = [
664
- leftTop,
665
- leftBottom,
666
- rightTop,
667
- rightBottom,
668
- center,
669
- ];
645
+ /** 坐标偏移 */
646
+ const positionDistance = 10;
647
+ const defaultCalcPostion = [];
648
+ const maxPostionX = globalThis.innerWidth;
649
+ const maxPostionY = globalThis.innerHeight;
650
+ const gridXCount = 8;
651
+ const gridYCount = 8;
652
+ for (let i = 0; i < gridXCount; i++) {
653
+ for (let j = 0; j < gridYCount; j++) {
654
+ const positionX = globalThis.innerWidth * (i / gridXCount) + positionDistance;
655
+ const positionY = globalThis.innerHeight * (j / gridYCount) + positionDistance;
656
+ const position = {
657
+ x: positionX,
658
+ y: positionY,
659
+ };
660
+ if (position.x > maxPostionX) {
661
+ position.x = maxPostionX;
662
+ }
663
+ if (position.y > maxPostionY) {
664
+ position.y = maxPostionY;
665
+ }
666
+ defaultCalcPostion.push(position);
667
+ }
668
+ }
669
+ const delayHandlerElementPostionList = defaultCalcPostion;
670
670
  if ($el) {
671
671
  delayHandlerElementPostionList.length = 0;
672
672
  if (Array.isArray($el)) {
@@ -678,61 +678,79 @@
678
678
  }
679
679
  const positionInfoList = delayHandlerElementPostionList
680
680
  .map((position) => {
681
- let positionNode;
681
+ let $position;
682
682
  let positionX;
683
683
  let positionY;
684
684
  if (position instanceof HTMLElement) {
685
- positionNode = position;
685
+ $position = position;
686
686
  const nodeRect = position.getBoundingClientRect();
687
687
  positionX = nodeRect.x + nodeRect.width / 2;
688
688
  positionY = nodeRect.y + nodeRect.height / 2;
689
689
  }
690
690
  else {
691
- positionNode = document.elementFromPoint(position.x, position.y);
691
+ $position = document.elementFromPoint(position.x, position.y);
692
692
  positionX = position.x;
693
693
  positionY = position.y;
694
694
  }
695
- const shadowRoot = positionNode?.shadowRoot;
695
+ const shadowRoot = $position?.shadowRoot;
696
696
  if (shadowRoot) {
697
- positionNode = shadowRoot.elementFromPoint(positionX, positionY);
697
+ // 处理ShadowRoot
698
+ $position = shadowRoot.elementFromPoint(positionX, positionY);
698
699
  }
699
- if (positionNode instanceof HTMLStyleElement)
700
- return;
701
- if (positionNode instanceof HTMLScriptElement)
702
- return;
703
- if (positionNode instanceof HTMLMetaElement)
704
- return;
705
- if (positionNode instanceof HTMLHeadElement)
706
- return;
707
- if (!(positionNode instanceof HTMLElement))
700
+ if (!($position instanceof HTMLElement))
708
701
  return;
709
- let parent = positionNode;
702
+ let $parent = $position;
710
703
  let zIndex = 0;
711
- let maxZIndexNode = null;
712
- while (parent) {
713
- const nodeStyle = globalThis.getComputedStyle(parent);
704
+ let $maxZIndexNode = null;
705
+ let rect = {
706
+ x: 0,
707
+ y: 0,
708
+ width: 0,
709
+ height: 0,
710
+ top: 0,
711
+ right: 0,
712
+ bottom: 0,
713
+ left: 0,
714
+ };
715
+ while ($parent) {
716
+ const nodeStyle = globalThis.getComputedStyle($parent);
714
717
  const nodeZIndex = parseInt(nodeStyle.zIndex);
715
718
  if (nodeStyle.position !== "static" && !isNaN(nodeZIndex)) {
716
719
  if (nodeZIndex > zIndex) {
717
720
  zIndex = nodeZIndex;
718
- maxZIndexNode = parent;
719
- }
720
- }
721
- parent = parent.parentElement;
721
+ $maxZIndexNode = $parent;
722
+ }
723
+ }
724
+ $parent = $parent.parentElement;
725
+ }
726
+ if ($maxZIndexNode) {
727
+ const maxRect = $maxZIndexNode.getBoundingClientRect();
728
+ rect = {
729
+ x: maxRect.x,
730
+ y: maxRect.y,
731
+ width: maxRect.width,
732
+ height: maxRect.height,
733
+ top: maxRect.top,
734
+ right: maxRect.right,
735
+ bottom: maxRect.bottom,
736
+ left: maxRect.left,
737
+ };
722
738
  }
723
739
  return {
724
- /** 处理了偏移量后的z-index值 */
740
+ /** 计算偏移量后的z-index值 */
725
741
  zIndex: zIndex + deviation,
726
- /** 原始z-index值 */
742
+ /** 获取到的最大的z-index值 */
727
743
  originZIndex: zIndex,
728
744
  /** 拥有最大z-index的元素 */
729
- node: maxZIndexNode,
745
+ node: $maxZIndexNode,
730
746
  /** 目标坐标元素 */
731
- positionNode: positionNode,
732
- /** x坐标 */
747
+ positionNode: $position,
748
+ /** 目标x坐标 */
733
749
  positionX: positionX,
734
- /** y坐标 */
750
+ /** 目标y坐标 */
735
751
  positionY: positionY,
752
+ /** node位置信息 */
753
+ rect,
736
754
  };
737
755
  })
738
756
  .filter((it) => it != null);
@@ -783,10 +801,17 @@
783
801
  const PopsCommonCSSClassName = {
784
802
  flexCenter: "pops-flex-items-center",
785
803
  flexYCenter: "pops-flex-y-center",
804
+ flexXCenter: "pops-flex-x-center",
786
805
  hide: "pops-hide",
787
806
  hideImportant: "pops-hide-important",
807
+ noBorder: "pops-no-border",
808
+ noBorderImportant: "pops-no-border-important",
788
809
  userSelectNone: "pops-user-select-none",
789
- textIsDisabled: "pops-text-is-disabled"};
810
+ lineHeightCenter: "pops-line-height-center",
811
+ widthFill: "pops-width-fill",
812
+ textIsDisabled: "pops-text-is-disabled",
813
+ textIsDisabledImportant: "pops-text-is-disabled-important",
814
+ };
790
815
 
791
816
  class PopsDOMUtilsEvent {
792
817
  on(element, eventType, selector, callback, option) {
@@ -1686,6 +1711,35 @@
1686
1711
  getTransitionEndNameList() {
1687
1712
  return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
1688
1713
  }
1714
+ /**
1715
+ * 是否是隐藏状态
1716
+ *
1717
+ * 检测以下项:
1718
+ *
1719
+ * + `display`: none
1720
+ * + `visibility`: hidden
1721
+ * + `opacity`: 0
1722
+ * + `使用了pops的自定义的隐藏class类`
1723
+ * @param $el 需要检测的元素
1724
+ */
1725
+ isHide($el) {
1726
+ let flag = false;
1727
+ if (this.containsClassName($el, PopsCommonCSSClassName.hide) ||
1728
+ this.containsClassName($el, PopsCommonCSSClassName.hideImportant)) {
1729
+ flag = true;
1730
+ }
1731
+ else {
1732
+ if ($el instanceof HTMLElement) {
1733
+ const style = $el.style;
1734
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
1735
+ }
1736
+ if (!flag) {
1737
+ const style = globalThis.getComputedStyle($el);
1738
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
1739
+ }
1740
+ }
1741
+ return flag;
1742
+ }
1689
1743
  /**
1690
1744
  * 实现jQuery中的$().offset();
1691
1745
  * @param element
@@ -3194,7 +3248,7 @@
3194
3248
  return totalInstConfigList;
3195
3249
  },
3196
3250
  /**
3197
- * 隐藏
3251
+ * 显示
3198
3252
  * @param popsType
3199
3253
  * @param instConfigList
3200
3254
  * @param guid
@@ -3202,24 +3256,34 @@
3202
3256
  * @param $anim
3203
3257
  * @param $mask
3204
3258
  */
3205
- hide(config, popsType, instConfigList, guid, $anim, $mask) {
3259
+ show(config, popsType, instConfigList, guid, $anim, $mask) {
3206
3260
  // oxlint-disable-next-line no-async-promise-executor
3207
3261
  return new Promise(async (resolve) => {
3208
3262
  const $pops = $anim.querySelector(".pops[type-value]");
3209
3263
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3210
3264
  if (fintInst) {
3211
- // 存在实例
3265
+ // 由于是隐蔽状态
3266
+ // 先设置好动画状态
3267
+ // 再显示,会自执行动画
3268
+ const checkVisible = () => {
3269
+ if (!popsDOMUtils.isHide($anim)) {
3270
+ return true;
3271
+ }
3272
+ else {
3273
+ return false;
3274
+ }
3275
+ };
3212
3276
  const startAnim = async () => {
3213
3277
  if (popsType === "drawer") {
3214
3278
  // drawer是抽屉
3215
3279
  // 单独处理动画
3216
3280
  const drawerConfig = config;
3217
- await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3281
+ await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3218
3282
  if ($mask) {
3219
- popsDOMUtils.css($mask, "display", "none");
3283
+ popsDOMUtils.css($mask, "display", "");
3220
3284
  }
3221
3285
  const direction = drawerConfig.direction;
3222
- const size = "0";
3286
+ const size = drawerConfig.size.toString();
3223
3287
  if (["top", "bottom"].includes(direction)) {
3224
3288
  $pops.style.setProperty("height", size);
3225
3289
  }
@@ -3227,26 +3291,26 @@
3227
3291
  $pops.style.setProperty("width", size);
3228
3292
  }
3229
3293
  else {
3230
- console.error("未知direction: ", direction);
3294
+ console.error("未知direction", direction);
3231
3295
  }
3232
3296
  }
3233
3297
  else {
3234
- instConfigItem.$anim.style.width = "100%";
3235
- instConfigItem.$anim.style.height = "100%";
3236
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
3298
+ instConfigItem.$anim.style.width = "";
3299
+ instConfigItem.$anim.style.height = "";
3300
+ Reflect.set(instConfigItem.$anim.style, "animation-name", animName);
3237
3301
  }
3238
- };
3239
- const endCallback = () => {
3240
- instConfigItem.$anim.style.display = "none";
3302
+ instConfigItem.$anim.style.display = "";
3241
3303
  if (instConfigItem.$mask) {
3242
- instConfigItem.$mask.style.display = "none";
3304
+ instConfigItem.$mask.style.display = "";
3243
3305
  }
3244
- fintInst.emitter.emit("pops:hide", instConfigItem);
3306
+ };
3307
+ const endCallback = () => {
3308
+ fintInst.emitter.emit("pops:show", instConfigItem);
3245
3309
  };
3246
3310
  const instConfigItem = fintInst;
3247
- fintInst.emitter.emit("pops:before-hide", instConfigItem);
3248
- await startAnim();
3249
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3311
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3312
+ fintInst.emitter.emit("pops:before-show", instConfigItem);
3313
+ if (checkVisible() && PopsAnimation.hasAnim(animName)) {
3250
3314
  /**
3251
3315
  * 动画结束的回调
3252
3316
  */
@@ -3257,22 +3321,23 @@
3257
3321
  };
3258
3322
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3259
3323
  capture: true,
3260
- once: true,
3261
3324
  });
3325
+ await startAnim();
3262
3326
  }
3263
3327
  else {
3328
+ await startAnim();
3264
3329
  endCallback();
3265
3330
  resolve();
3266
3331
  }
3267
3332
  }
3268
3333
  else {
3269
- console.error("hide-error: 该实例未存储");
3334
+ console.error("show-error: 该实例未存储");
3270
3335
  resolve();
3271
3336
  }
3272
3337
  });
3273
3338
  },
3274
3339
  /**
3275
- * 显示
3340
+ * 隐藏
3276
3341
  * @param popsType
3277
3342
  * @param instConfigList
3278
3343
  * @param guid
@@ -3280,23 +3345,35 @@
3280
3345
  * @param $anim
3281
3346
  * @param $mask
3282
3347
  */
3283
- show(config, popsType, instConfigList, guid, $anim, $mask) {
3348
+ hide(config, popsType, instConfigList, guid, $anim, $mask) {
3284
3349
  // oxlint-disable-next-line no-async-promise-executor
3285
3350
  return new Promise(async (resolve) => {
3286
3351
  const $pops = $anim.querySelector(".pops[type-value]");
3287
3352
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3288
3353
  if (fintInst) {
3354
+ // 由于是已显示状态
3355
+ // 先执行动画
3356
+ // 再隐藏
3357
+ // 存在实例
3358
+ const checkVisible = () => {
3359
+ if (!popsDOMUtils.isHide($anim)) {
3360
+ return true;
3361
+ }
3362
+ else {
3363
+ return false;
3364
+ }
3365
+ };
3289
3366
  const startAnim = async () => {
3290
3367
  if (popsType === "drawer") {
3291
3368
  // drawer是抽屉
3292
3369
  // 单独处理动画
3293
3370
  const drawerConfig = config;
3294
- await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3371
+ await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3295
3372
  if ($mask) {
3296
- popsDOMUtils.css($mask, "display", "");
3373
+ popsDOMUtils.css($mask, "display", "none");
3297
3374
  }
3298
3375
  const direction = drawerConfig.direction;
3299
- const size = drawerConfig.size.toString();
3376
+ const size = "0";
3300
3377
  if (["top", "bottom"].includes(direction)) {
3301
3378
  $pops.style.setProperty("height", size);
3302
3379
  }
@@ -3304,26 +3381,27 @@
3304
3381
  $pops.style.setProperty("width", size);
3305
3382
  }
3306
3383
  else {
3307
- console.error("未知direction", direction);
3384
+ console.error("未知direction: ", direction);
3308
3385
  }
3309
3386
  }
3310
3387
  else {
3311
- instConfigItem.$anim.style.width = "";
3312
- instConfigItem.$anim.style.height = "";
3313
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim").replace("-reverse", ""));
3388
+ instConfigItem.$anim.style.width = "100%";
3389
+ instConfigItem.$anim.style.height = "100%";
3390
+ Reflect.set(instConfigItem.$anim.style, "animation-name", reverseAnimName);
3314
3391
  }
3315
3392
  };
3316
3393
  const endCallback = () => {
3317
- instConfigItem.$anim.style.display = "";
3394
+ instConfigItem.$anim.style.display = "none";
3318
3395
  if (instConfigItem.$mask) {
3319
- instConfigItem.$mask.style.display = "";
3396
+ instConfigItem.$mask.style.display = "none";
3320
3397
  }
3321
- fintInst.emitter.emit("pops:show", instConfigItem);
3398
+ fintInst.emitter.emit("pops:hide", instConfigItem);
3322
3399
  };
3323
3400
  const instConfigItem = fintInst;
3324
- fintInst.emitter.emit("pops:before-show", instConfigItem);
3325
- await startAnim();
3326
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3401
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3402
+ const reverseAnimName = animName + "-reverse";
3403
+ fintInst.emitter.emit("pops:before-hide", instConfigItem);
3404
+ if (!checkVisible() && PopsAnimation.hasAnim(reverseAnimName)) {
3327
3405
  /**
3328
3406
  * 动画结束的回调
3329
3407
  */
@@ -3334,15 +3412,18 @@
3334
3412
  };
3335
3413
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3336
3414
  capture: true,
3415
+ once: true,
3337
3416
  });
3417
+ await startAnim();
3338
3418
  }
3339
3419
  else {
3420
+ await startAnim();
3340
3421
  endCallback();
3341
3422
  resolve();
3342
3423
  }
3343
3424
  }
3344
3425
  else {
3345
- console.error("show-error: 该实例未存储");
3426
+ console.error("hide-error: 该实例未存储");
3346
3427
  resolve();
3347
3428
  }
3348
3429
  });
@@ -3382,7 +3463,7 @@
3382
3463
  await new Promise(async (resolve) => {
3383
3464
  const $pops = $anim.querySelector(".pops[type-value]");
3384
3465
  const drawerConfig = config;
3385
- const start = () => {
3466
+ const startAnim = () => {
3386
3467
  /**
3387
3468
  * 弹窗已关闭的回调
3388
3469
  */
@@ -3423,7 +3504,7 @@
3423
3504
  };
3424
3505
  if (popsType === "drawer") {
3425
3506
  await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3426
- start();
3507
+ startAnim();
3427
3508
  }
3428
3509
  else {
3429
3510
  await PopsInstHandler.removeInstance([instConfigList], guid);
@@ -4174,8 +4255,8 @@
4174
4255
  style: null,
4175
4256
  lightStyle: null,
4176
4257
  darkStyle: null,
4177
- beforeAppendToPageCallBack() { },
4178
4258
  stopKeyDownEventPropagation: true,
4259
+ emitter: null,
4179
4260
  };
4180
4261
  };
4181
4262
 
@@ -4184,11 +4265,11 @@
4184
4265
  const guid = popsUtils.getRandomGUID();
4185
4266
  // 设置当前类型
4186
4267
  const popsType = "alert";
4187
- const emitter = new EventEmiter(popsType);
4188
4268
  let config = PopsAlertDefaultConfig();
4189
4269
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4190
4270
  config = popsUtils.assign(config, __config__);
4191
4271
  config = PopsHandler.handleOnly(popsType, config);
4272
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4192
4273
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4193
4274
  PopsHandler.handleInit($shadowRoot, [
4194
4275
  {
@@ -4382,8 +4463,8 @@
4382
4463
  style: null,
4383
4464
  lightStyle: null,
4384
4465
  darkStyle: null,
4385
- beforeAppendToPageCallBack() { },
4386
4466
  stopKeyDownEventPropagation: true,
4467
+ emitter: null,
4387
4468
  };
4388
4469
  };
4389
4470
 
@@ -4392,11 +4473,11 @@
4392
4473
  const guid = popsUtils.getRandomGUID();
4393
4474
  // 设置当前类型
4394
4475
  const popsType = "confirm";
4395
- const emitter = new EventEmiter(popsType);
4396
4476
  let config = PopsConfirmDefaultConfig();
4397
4477
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4398
4478
  config = popsUtils.assign(config, __config__);
4399
4479
  config = PopsHandler.handleOnly(popsType, config);
4480
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4400
4481
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4401
4482
  PopsHandler.handleInit($shadowRoot, [
4402
4483
  {
@@ -4589,9 +4670,9 @@
4589
4670
  style: null,
4590
4671
  lightStyle: null,
4591
4672
  darkStyle: null,
4592
- beforeAppendToPageCallBack() { },
4593
4673
  forbiddenScroll: false,
4594
4674
  stopKeyDownEventPropagation: true,
4675
+ emitter: null,
4595
4676
  };
4596
4677
  };
4597
4678
 
@@ -4600,11 +4681,11 @@
4600
4681
  const guid = popsUtils.getRandomGUID();
4601
4682
  // 设置当前类型
4602
4683
  const popsType = "drawer";
4603
- const emitter = new EventEmiter(popsType);
4604
4684
  let config = PopsDrawerDefaultConfig();
4605
4685
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4606
4686
  config = popsUtils.assign(config, __config__);
4607
4687
  config = PopsHandler.handleOnly(popsType, config);
4688
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4608
4689
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4609
4690
  PopsHandler.handleInit($shadowRoot, [
4610
4691
  {
@@ -4815,6 +4896,7 @@
4815
4896
  darkStyle: null,
4816
4897
  addIndexCSS: true,
4817
4898
  stopKeyDownEventPropagation: true,
4899
+ emitter: null,
4818
4900
  };
4819
4901
  };
4820
4902
 
@@ -4822,19 +4904,19 @@
4822
4904
  init(__config__) {
4823
4905
  const guid = popsUtils.getRandomGUID();
4824
4906
  // 设置当前类型
4825
- const PopsType = "loading";
4826
- const emitter = new EventEmiter(PopsType);
4907
+ const popsType = "loading";
4827
4908
  let config = PopsLoadingDefaultConfig();
4828
4909
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4829
4910
  config = popsUtils.assign(config, __config__);
4830
- config = PopsHandler.handleOnly(PopsType, config);
4911
+ config = PopsHandler.handleOnly(popsType, config);
4912
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4831
4913
  // 先把z-index提取出来
4832
4914
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4833
4915
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4834
4916
  const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
4835
- const animHTML = PopsElementHandler.createAnim(guid, PopsType, config,
4917
+ const animHTML = PopsElementHandler.createAnim(guid, popsType, config,
4836
4918
  /*html*/ `
4837
- <div class="pops-content pops-${PopsType}-content">${config.addIndexCSS
4919
+ <div class="pops-content pops-${popsType}-content">${config.addIndexCSS
4838
4920
  ? /*html*/ `
4839
4921
  <style data-model-name="index">${PopsCSS.index}</style>
4840
4922
  <style data-model-name="anim">${PopsCSS.anim}</style>
@@ -4845,13 +4927,13 @@
4845
4927
  ${PopsCSS.loadingCSS}
4846
4928
  </style>
4847
4929
  ${config.style != null ? `<style>${config.style}</style>` : ""}
4848
- <p pops class="pops-${PopsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
4930
+ <p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
4849
4931
  </div>`, "", zIndex);
4850
4932
  /**
4851
4933
  * 弹窗的主元素,包括动画层
4852
4934
  */
4853
4935
  const $anim = PopsElementHandler.parseElement(animHTML);
4854
- const { $pops: $pops } = PopsHandler.handleQueryElement($anim, PopsType);
4936
+ const { $pops: $pops } = PopsHandler.handleQueryElement($anim, popsType);
4855
4937
  /**
4856
4938
  * 遮罩层元素
4857
4939
  */
@@ -4863,7 +4945,7 @@
4863
4945
  if (config.mask.enable) {
4864
4946
  // 创建遮罩层
4865
4947
  const handleMask = PopsHandler.handleMask({
4866
- type: PopsType,
4948
+ type: popsType,
4867
4949
  guid: guid,
4868
4950
  config: config,
4869
4951
  animElement: $anim,
@@ -4872,12 +4954,12 @@
4872
4954
  $mask = handleMask.maskElement;
4873
4955
  $elList.push($mask);
4874
4956
  }
4875
- const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
4957
+ const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, popsType, $anim, $pops, emitter, $mask);
4876
4958
  popsDOMUtils.append(config.$parent, $elList);
4877
4959
  if ($mask != null) {
4878
4960
  $anim.after($mask);
4879
4961
  }
4880
- PopsHandler.handlePush(PopsType, {
4962
+ PopsHandler.handlePush(popsType, {
4881
4963
  $shadowContainer: $pops,
4882
4964
  $shadowRoot: $pops,
4883
4965
  guid: guid,
@@ -5046,8 +5128,8 @@
5046
5128
  style: null,
5047
5129
  lightStyle: null,
5048
5130
  darkStyle: null,
5049
- beforeAppendToPageCallBack() { },
5050
5131
  stopKeyDownEventPropagation: true,
5132
+ emitter: null,
5051
5133
  };
5052
5134
  };
5053
5135
 
@@ -5084,11 +5166,11 @@
5084
5166
  const guid = popsUtils.getRandomGUID();
5085
5167
  // 设置当前类型
5086
5168
  const popsType = "folder";
5087
- const emitter = new EventEmiter(popsType);
5088
5169
  let config = PopsFolderDefaultConfig();
5089
5170
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
5090
5171
  config = popsUtils.assign(config, __config__);
5091
5172
  config = PopsHandler.handleOnly(popsType, config);
5173
+ const emitter = config.emitter ?? new EventEmiter(popsType);
5092
5174
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
5093
5175
  PopsHandler.handleInit($shadowRoot, [
5094
5176
  {
@@ -6011,8 +6093,8 @@
6011
6093
  style: null,
6012
6094
  lightStyle: null,
6013
6095
  darkStyle: null,
6014
- beforeAppendToPageCallBack() { },
6015
6096
  stopKeyDownEventPropagation: true,
6097
+ emitter: null,
6016
6098
  };
6017
6099
  };
6018
6100
 
@@ -6021,7 +6103,6 @@
6021
6103
  const guid = popsUtils.getRandomGUID();
6022
6104
  // 设置当前类型
6023
6105
  const popsType = "iframe";
6024
- const emitter = new EventEmiter(popsType);
6025
6106
  let config = PopsIframeDefaultConfig();
6026
6107
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
6027
6108
  config = popsUtils.assign(config, __config__);
@@ -6029,6 +6110,8 @@
6029
6110
  throw new TypeError("config.url must not be null.");
6030
6111
  }
6031
6112
  config = PopsHandler.handleOnly(popsType, config);
6113
+ const emitter = config.emitter ??
6114
+ new EventEmiter(popsType);
6032
6115
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
6033
6116
  PopsHandler.handleInit($shadowRoot, [
6034
6117
  {
@@ -6056,7 +6139,7 @@
6056
6139
  css: PopsCSS.iframeCSS,
6057
6140
  },
6058
6141
  ]);
6059
- const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
6142
+ const maskExtraStyle = config.animation != null && config.animation != "" && config.animation ? "position:absolute;" : "";
6060
6143
  // 先把z-index提取出来
6061
6144
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
6062
6145
  const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
@@ -7137,9 +7220,9 @@
7137
7220
  style: null,
7138
7221
  lightStyle: null,
7139
7222
  darkStyle: null,
7140
- beforeAppendToPageCallBack() { },
7141
7223
  stopKeyDownEventPropagation: true,
7142
7224
  listenEscapeKeyUpToExitDeepMenu: true,
7225
+ emitter: null,
7143
7226
  };
7144
7227
  };
7145
7228
 
@@ -7251,7 +7334,7 @@
7251
7334
  style: "",
7252
7335
  lightStyle: null,
7253
7336
  darkStyle: null,
7254
- beforeAppendToPageCallBack() { },
7337
+ emitter: null,
7255
7338
  };
7256
7339
  };
7257
7340
 
@@ -7719,7 +7802,6 @@
7719
7802
  const guid = popsUtils.getRandomGUID();
7720
7803
  // 设置当前类型
7721
7804
  const popsType = "tooltip";
7722
- const emitter = new EventEmiter(popsType);
7723
7805
  let config = PopsTooltipDefaultConfig();
7724
7806
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
7725
7807
  config = popsUtils.assign(config, __config__);
@@ -7736,6 +7818,7 @@
7736
7818
  config.onShowEventName += ` ${it}`;
7737
7819
  });
7738
7820
  }
7821
+ const emitter = config.emitter ?? new EventEmiter(popsType);
7739
7822
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
7740
7823
  PopsHandler.handleInit($shadowRoot, [
7741
7824
  {
@@ -11601,11 +11684,11 @@
11601
11684
  const guid = popsUtils.getRandomGUID();
11602
11685
  // 设置当前类型
11603
11686
  const popsType = "panel";
11604
- const emitter = new EventEmiter(popsType);
11605
11687
  let config = PopsPanelDefaultConfig();
11606
11688
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11607
11689
  config = popsUtils.assign(config, __config__);
11608
11690
  config = PopsHandler.handleOnly(popsType, config);
11691
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11609
11692
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11610
11693
  PopsHandler.handleInit($shadowRoot, [
11611
11694
  {
@@ -11855,8 +11938,8 @@
11855
11938
  style: null,
11856
11939
  lightStyle: null,
11857
11940
  darkStyle: null,
11858
- beforeAppendToPageCallBack() { },
11859
11941
  stopKeyDownEventPropagation: true,
11942
+ emitter: null,
11860
11943
  };
11861
11944
  };
11862
11945
 
@@ -11865,11 +11948,11 @@
11865
11948
  const guid = popsUtils.getRandomGUID();
11866
11949
  // 设置当前类型
11867
11950
  const popsType = "prompt";
11868
- const emitter = new EventEmiter(popsType);
11869
11951
  let config = PopsPromptDefaultConfig();
11870
11952
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11871
11953
  config = popsUtils.assign(config, __config__);
11872
11954
  config = PopsHandler.handleOnly(popsType, config);
11955
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11873
11956
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11874
11957
  PopsHandler.handleInit($shadowRoot, [
11875
11958
  {
@@ -12090,10 +12173,10 @@
12090
12173
  style: null,
12091
12174
  lightStyle: null,
12092
12175
  darkStyle: null,
12093
- beforeAppendToPageCallBack() { },
12094
12176
  limitPositionXInView: true,
12095
12177
  limitPositionYInView: true,
12096
12178
  beforeShowCallBack() { },
12179
+ emitter: null,
12097
12180
  };
12098
12181
  };
12099
12182
 
@@ -12102,11 +12185,11 @@
12102
12185
  const guid = popsUtils.getRandomGUID();
12103
12186
  // 设置当前类型
12104
12187
  const popsType = "rightClickMenu";
12105
- const emitter = new EventEmiter(popsType);
12106
12188
  let config = PopsRightClickMenuDefaultConfig();
12107
12189
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12108
12190
  config = popsUtils.assign(config, __config__);
12109
12191
  config = PopsHandler.handleOnly(popsType, config);
12192
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12110
12193
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12111
12194
  PopsHandler.handleInit($shadowRoot, [
12112
12195
  {
@@ -12728,6 +12811,7 @@
12728
12811
  style: "",
12729
12812
  lightStyle: null,
12730
12813
  darkStyle: null,
12814
+ emitter: null,
12731
12815
  };
12732
12816
  };
12733
12817
 
@@ -12736,7 +12820,6 @@
12736
12820
  const guid = popsUtils.getRandomGUID();
12737
12821
  // 设置当前类型
12738
12822
  const popsType = "searchSuggestion";
12739
- const emitter = new EventEmiter(popsType);
12740
12823
  let config = PopsSearchSuggestionDefaultConfig();
12741
12824
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12742
12825
  config = popsUtils.assign(config, __config__);
@@ -12744,6 +12827,7 @@
12744
12827
  if (config.$inputTarget == null) {
12745
12828
  config.$inputTarget = config.$target;
12746
12829
  }
12830
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12747
12831
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12748
12832
  PopsHandler.handleInit($shadowRoot, [
12749
12833
  {
@@ -13628,6 +13712,8 @@
13628
13712
  PopsAnimation,
13629
13713
  /** 事件类 */
13630
13714
  EventEmiter,
13715
+ /** 通用的CSS类名 */
13716
+ PopsCommonCSSClassName,
13631
13717
  };
13632
13718
  init() { }
13633
13719
  /**