@whitesev/pops 4.0.2 → 4.2.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 (84) hide show
  1. package/dist/index.amd.js +363 -275
  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 +363 -275
  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 +363 -275
  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 +363 -275
  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 +363 -275
  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 +363 -275
  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 +116 -16
  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/types/mask.d.ts +6 -6
  40. package/dist/types/src/utils/PopsDOMUtils.d.ts +2 -2
  41. package/dist/types/src/utils/PopsInstanceUtils.d.ts +22 -0
  42. package/dist/types/src/utils/PopsUtils.d.ts +21 -16
  43. package/package.json +1 -1
  44. package/src/Pops.ts +11 -11
  45. package/src/components/alert/defaultConfig.ts +1 -1
  46. package/src/components/alert/index.ts +1 -1
  47. package/src/components/confirm/defaultConfig.ts +1 -1
  48. package/src/components/confirm/index.ts +1 -1
  49. package/src/components/drawer/defaultConfig.ts +1 -1
  50. package/src/components/drawer/index.ts +2 -1
  51. package/src/components/folder/defaultConfig.ts +1 -1
  52. package/src/components/folder/index.ts +1 -1
  53. package/src/components/iframe/defaultConfig.ts +1 -1
  54. package/src/components/iframe/index.ts +10 -6
  55. package/src/components/loading/defaultConfig.ts +1 -0
  56. package/src/components/loading/index.ts +10 -10
  57. package/src/components/loading/types/index.ts +1 -4
  58. package/src/components/panel/defaultConfig.ts +1 -1
  59. package/src/components/panel/handlerComponents.ts +4 -4
  60. package/src/components/panel/index.ts +3 -2
  61. package/src/components/prompt/defaultConfig.ts +1 -1
  62. package/src/components/prompt/index.ts +1 -1
  63. package/src/components/rightClickMenu/defaultConfig.ts +1 -1
  64. package/src/components/rightClickMenu/index.ts +1 -1
  65. package/src/components/rightClickMenu/types/index.ts +1 -1
  66. package/src/components/searchSuggestion/defaultConfig.ts +1 -0
  67. package/src/components/searchSuggestion/index.ts +1 -1
  68. package/src/components/searchSuggestion/types/index.ts +1 -1
  69. package/src/components/tooltip/defaultConfig.ts +1 -1
  70. package/src/components/tooltip/index.ts +1 -1
  71. package/src/components/tooltip/types/index.ts +1 -1
  72. package/src/event/EventEmiter.ts +15 -14
  73. package/src/handler/PopsHandler.ts +9 -21
  74. package/src/handler/PopsInstHandler.ts +65 -47
  75. package/src/types/EventEmitter.d.ts +21 -0
  76. package/src/types/PopsDOMUtilsEventType.d.ts +1 -1
  77. package/src/types/components.d.ts +15 -18
  78. package/src/types/global.d.ts +2 -0
  79. package/src/types/mask.d.ts +6 -6
  80. package/src/utils/PopsDOMUtils.ts +6 -3
  81. package/src/utils/PopsInstanceUtils.ts +50 -0
  82. package/src/utils/PopsUtils.ts +95 -68
  83. package/dist/types/src/utils/PopsDOMUtilsEventsConfig.d.ts +0 -4
  84. package/src/utils/PopsDOMUtilsEventsConfig.ts +0 -4
@@ -1,7 +1,7 @@
1
1
  var pops = (function () {
2
2
  'use strict';
3
3
 
4
- const version = "4.0.2";
4
+ const version = "4.2.0";
5
5
 
6
6
  const GlobalConfig = {
7
7
  config: {},
@@ -60,15 +60,16 @@ var pops = (function () {
60
60
  };
61
61
 
62
62
  class EventEmiter {
63
- #type;
64
- #data = new Map();
63
+ [Symbol.toStringTag] = "EventEmiter";
64
+ type;
65
+ data = new Map();
65
66
  constructor(type) {
66
- this.#type = type;
67
+ this.type = type;
67
68
  }
68
69
  on(eventName, callback) {
69
- const eventList = this.#data.get(eventName) ?? [];
70
- eventList.push({ type: this.#type, time: Date.now(), callback: callback });
71
- this.#data.set(eventName, eventList);
70
+ const eventList = this.data.get(eventName) ?? [];
71
+ eventList.push({ type: this.type, time: Date.now(), callback: callback });
72
+ this.data.set(eventName, eventList);
72
73
  return {
73
74
  off: () => {
74
75
  this.off(eventName, callback);
@@ -79,7 +80,7 @@ var pops = (function () {
79
80
  };
80
81
  }
81
82
  off(eventName, callback) {
82
- const eventList = this.#data.get(eventName) ?? [];
83
+ const eventList = this.data.get(eventName) ?? [];
83
84
  let isOffSuccess = false;
84
85
  for (let index = eventList.length - 1; index >= 0; index--) {
85
86
  if (eventList[index].callback === callback) {
@@ -89,27 +90,27 @@ var pops = (function () {
89
90
  }
90
91
  if (eventList.length === 0) {
91
92
  // empty
92
- this.#data.delete(eventName);
93
+ this.data.delete(eventName);
93
94
  }
94
95
  else {
95
96
  if (isOffSuccess) {
96
97
  // update
97
- this.#data.set(eventName, eventList);
98
+ this.data.set(eventName, eventList);
98
99
  }
99
100
  }
100
101
  }
101
102
  async emit(eventName, ...args) {
102
- const eventList = this.#data.get(eventName) ?? [];
103
+ const eventList = this.data.get(eventName) ?? [];
103
104
  for (const item of eventList) {
104
105
  await item.callback(...args);
105
106
  }
106
107
  }
107
108
  offAll(eventName) {
108
109
  if (typeof eventName === "string") {
109
- this.#data.delete(eventName);
110
+ this.data.delete(eventName);
110
111
  }
111
112
  else {
112
- this.#data.clear();
113
+ this.data.clear();
113
114
  }
114
115
  }
115
116
  /**
@@ -117,10 +118,10 @@ var pops = (function () {
117
118
  */
118
119
  getAllEvents(eventName) {
119
120
  if (typeof eventName === "string") {
120
- return this.#data.get(eventName);
121
+ return this.data.get(eventName);
121
122
  }
122
123
  else {
123
- return Array.from(this.#data.values());
124
+ return Array.from(this.data.values());
124
125
  }
125
126
  }
126
127
  }
@@ -244,11 +245,6 @@ var pops = (function () {
244
245
  },
245
246
  };
246
247
 
247
- /**
248
- * 存储在元素属性上的事件名
249
- */
250
- const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
251
-
252
248
  const OriginPrototype = {
253
249
  Object: {
254
250
  defineProperty: Object.defineProperty,
@@ -298,31 +294,31 @@ var pops = (function () {
298
294
  },
299
295
  };
300
296
 
301
- let t$1 = class t{constructor(){this.__map={};}beforeEach(t){this.__interceptor=t;}on(t,i){const s=Array.isArray(t)?t:[t];for(const t of s){this.__map[t]=this.__map[t]||[];const s=this.__map[t];s&&s.push(i);}return this}emit(t,i,s){ void 0!==this.__interceptor?this.__interceptor(t,(()=>{this.__emit(t,i),s&&s();})):(this.__emit(t,i),s&&s());}__emit(t,i){const s=this.__map[t];if(Array.isArray(s)&&(null==s?void 0:s.length))for(const _ of s)_(i,t);this.event=i;}off(t,i){const s=this.__map[t];if(void 0!==s)if(void 0===i)delete this.__map[t];else {const t=s.findIndex((t=>t===i));s.splice(t,1);}}destroy(){this.__map={};}};
297
+ const n$1="clientX",e$2="clientY",t$1=16,c$3="start",o$1="move",s$1="cancel",u$3="end",a$2="left",i$3="right",r$4="up",d$1="down",m$2={4:"start",5:"move",1:"end",3:"cancel"};function v$1(n){return m$2[n]}function b(n,e,t){const c={1:{0:{move:4},4:{move:5,end:1,cancel:3},5:{move:5,end:1,cancel:3}},0:{4:{move:2,end:1,cancel:3},5:{start:2,move:2,end:1,cancel:3}}}[Number(n)][e];return void 0!==c&&c[t]||0}function g$1(n){[1,3,2].includes(n.state)&&(n.state=0);}function h$3(n){return [5,1,3].includes(n)}function j(n){if(n.disabled)return n.state=0,true}function O(n,e){return Object.assign(Object.assign(Object.assign({},n),e),{state:0,disabled:false})}function p$3(n){return Math.round(100*n)/100}
302
298
 
303
- const n$1="clientX",e$2="clientY",t=16,c$3="start",o$1="move",s$1="cancel",u$3="end",a$2="left",i$3="right",r$4="up",d$1="down",m$2={4:"start",5:"move",1:"end",3:"cancel"};function v$1(n){return m$2[n]}function b(n,e,t){const c={1:{0:{move:4},4:{move:5,end:1,cancel:3},5:{move:5,end:1,cancel:3}},0:{4:{move:2,end:1,cancel:3},5:{start:2,move:2,end:1,cancel:3}}}[Number(n)][e];return void 0!==c&&c[t]||0}function g$1(n){[1,3,2].includes(n.state)&&(n.state=0);}function h$3(n){return [5,1,3].includes(n)}function j(n){if(n.disabled)return n.state=0,true}function O(n,e){return Object.assign(Object.assign(Object.assign({},n),e),{state:0,disabled:false})}function p$3(n){return Math.round(100*n)/100}
299
+ var x=r=>Math.sqrt(r.x*r.x+r.y*r.y),y=(r,a)=>r.x*a.x+r.y*a.y,e$1=(r,a)=>{var t=x(r)*x(a);if(0===t)return 0;var h=y(r,a)/t;return h>1&&(h=1),Math.acos(h)},n=(r,a)=>r.x*a.y-a.x*r.y,o=r=>r/Math.PI*180,s=(r,a)=>{var t=e$1(r,a);return n(r,a)>0&&(t*=-1),o(t)},u$2=(x,y)=>{if(0!==x||0!==y)return Math.abs(x)>=Math.abs(y)?0<x?i$3:a$2:0<y?d$1:r$4};
304
300
 
305
- function r$3(){let t,o,i,r,a=0;return function(u){if(t=o,void 0!==u){a=Number.MAX_SAFE_INTEGER>a?++a:1;const h=function(t,o){const{phase:i,points:r,changedPoints:a,nativeEvent:u}=t,h=r.length,p=c$3===i,g=u$3===i&&0===h||s$1===i,l=Date.now(),{x:d,y:m}=c$2(r)||c$2(a),{currentTarget:v}=u;return Object.assign(t,{id:o,x:d,y:m,timestamp:l,isStart:p,isEnd:g,pointLength:h,currentTarget:v,getOffset(t=v){const e=t.getBoundingClientRect();return {x:d-Math.round(e.left),y:m-Math.round(e.top)}}})}(u,a);o=h;const{isStart:p,pointLength:g}=h;return p&&(i=h,t=void 0,r=1<g?h:void 0),Object.assign(Object.assign({},h),{prevInput:t,startMultiInput:r,startInput:i})}}}function c$2(t){const{length:e}=t;if(0<e){if(1===e){const{clientX:e,clientY:n}=t[0];return {x:Math.round(e),y:Math.round(n)}}const n=t.reduce(((t,e)=>(t.x+=e[n$1],t.y+=e[e$2],t)),{x:0,y:0});return {x:Math.round(n.x/e),y:Math.round(n.y/e)}}}function a$1(t,e,n,s){const o={};for(const t in n)["target","currentTarget","type"].includes(t)||(o[t]=n[t]);let i;return document.createEvent?(i=document.createEvent("HTMLEvents"),i.initEvent(t,null==s?void 0:s.bubbles,null==s?void 0:s.cancelable)):i=new Event(t,s),Object.assign(i,o,{match:()=>n.targets&&0<n.targets.length&&n.targets.every((t=>i.currentTarget.contains(t)))}),e.dispatchEvent(i)}function u$2(t,e){const{preventDefault:n}=e;return s=n,"[object Function]"===Object.prototype.toString.call(s)?n(t):!!n;var s;}const h$2=["touchstart","touchmove","touchend","touchcancel","mousedown"],p$2=["mousemove","mouseup"];const g={domEvents:{bubbles:true,cancelable:true},preventDefault:t=>{if(t.target&&"tagName"in t.target){const{tagName:e}=t.target;return !/^(?:INPUT|TEXTAREA|BUTTON|SELECT)$/.test(e)}return false}};let l$1 = class l extends t$1{constructor(t,e){super(),this.v="2.1.3",this.__computeFunctionList=[],this.__computeFunctionCreatorList=[],this.__pluginContexts=[],this.__isIgnoreMouse=false,this.el=t,this.c={},this.__options=Object.assign(Object.assign({},g),e);const n=function(t){const e=r$3();return function(n){const s=[],o=[];Array.from(n.touches).forEach((({clientX:e,clientY:n,target:i})=>{(null==t?void 0:t.contains(i))&&(s.push(i),o.push({clientX:e,clientY:n,target:i}));}));const i=Array.from(n.changedTouches).map((({clientX:t,clientY:e,target:n})=>({clientX:t,clientY:e,target:n})));return e({phase:n.type.replace("touch",""),changedPoints:i,points:o,nativeEvent:n,target:n.target,targets:s})}}(this.el),s=function(){let t,e=false,n=null;const s=r$3();return function(o){const{clientX:i,clientY:r,type:c,button:a,target:u}=o;let h,p=[{clientX:i,clientY:r,target:u}];if("mousedown"===c&&0===a)n=u,e=true,h="start";else {if(!e)return;"mousemove"===c?h="move":"mouseup"===c&&(p=[],h="end",e=false);}const g=t||[{clientX:i,clientY:r,target:u}];if(t=[{clientX:i,clientY:r,target:u}],void 0!==h)return s({phase:h,changedPoints:g,points:p,target:n,targets:[n],nativeEvent:o})}}();if(this.__inputCreatorMap={touchstart:n,touchmove:n,touchend:n,touchcancel:n,mousedown:s,mousemove:s,mouseup:s},this.on("at:after",(t=>{const{target:e,__type:n}=t,{domEvents:s}=this.__options;s&&void 0!==this.el&&e&&(a$1(n,e,t,s),a$1("at:after",e,t,s));})),void 0!==t){t.style.webkitTapHighlightColor="rgba(0,0,0,0)";let e=false;try{const t={};Object.defineProperty(t,"passive",{get(){e=!0;}}),window.addEventListener("_",(()=>{}),t);}catch(t){}this.on("u",function(t,e,n){return h$2.forEach((s=>{t.addEventListener(s,e,n);})),p$2.forEach((t=>{window.addEventListener(t,e,n);})),()=>{h$2.forEach((n=>{t.removeEventListener(n,e);})),p$2.forEach((t=>{window.removeEventListener(t,e);}));}}(t,this.catchEvent.bind(this),false===this.__options.preventDefault&&e?{passive:true}:{passive:false}));}}use(t,e){this.__pluginContexts.push(t(this,e));}catchEvent(t){const e=this.__inputCreatorMap[t.type](t);if(void 0!==e){const n=()=>t.stopPropagation(),s=()=>t.stopImmediatePropagation(),o=()=>t.preventDefault();if(u$2(t,this.__options))o();else if("touchstart"===t.type?this.__isIgnoreMouse=true:"touchmove"===t.type&&(this.__isIgnoreMouse=false),this.__isIgnoreMouse&&t.type.startsWith("mouse"))return void("mouseup"===t.type&&(this.__isIgnoreMouse=false));this.emit("input",e),this.emit2(`at:${e.phase}`,e,{});const i={};this.__computeFunctionList.forEach((t=>{const n=t(e,i);if(void 0!==n)for(const t in n)i[t]=n[t];})),this.emit("computed",Object.assign(Object.assign(Object.assign({},e),i),{stopPropagation:n,stopImmediatePropagation:s,preventDefault:o}));}}compute(t,e){for(const e of t)this.__computeFunctionCreatorList.includes(e)||(this.__computeFunctionCreatorList.push(e),this.__computeFunctionList.push(e()));this.on("computed",e);}beforeEach(t){super.beforeEach(((e,n)=>{var s;(null===(s=this.c)||void 0===s?void 0:s.name)?t(e,n):n();}));}get(t){return this.__pluginContexts.find((e=>t===e.name))}set(t){this.__options=Object.assign(Object.assign({},this.__options),t);}emit2(t,e,n){this.c=n,this.emit(t,Object.assign(Object.assign({},e),{type:t}),(()=>{this.emit("at:after",Object.assign(Object.assign({},e),{name:t,__type:t}));}));}destroy(){this.emit("u"),super.destroy();}};
301
+ function p$2(){let n=0,e=0;return function(o,r){const{prevVecotr:i,startVecotr:a,activeVecotr:c}=r;return c&&(e=Math.round(s(c,i)),n=Math.round(s(c,a))),{angle:n,deltaAngle:e}}}function d(){return function(t){const{prevInput:e}=t;let o$1=0,r=0,i=0;if(void 0!==e&&(o$1=t.x-e.x,r=t.y-e.y,0!==o$1||0!==r)){const t=Math.sqrt(Math.pow(o$1,2)+Math.pow(r,2));i=Math.round(o(Math.acos(Math.abs(o$1)/t)));}return {deltaX:o$1,deltaY:r,deltaXYAngle:i}}}function h$2(){let t,n=0,u=0,s=0,p=0,d=0;return function(h){const{phase:l,startInput:f}=h;return c$3===l?(n=0,u=0,s=0,p=0,d=0):o$1===l&&(n=Math.round(h.points[0][n$1]-f.points[0][n$1]),u=Math.round(h.points[0][e$2]-f.points[0][e$2]),s=Math.abs(n),p=Math.abs(u),d=Math.round(x({x:s,y:p})),t=u$2(n,u)),{displacementX:n,displacementY:u,distanceX:s,distanceY:p,distance:d,overallDirection:t}}}function l$1(){let t=1;return function(n,o){let r=1;const{prevVecotr:i,startVecotr:a,activeVecotr:c}=o;return c&&(r=p$3(x(c)/x(i)),t=p$3(x(c)/x(a))),{scale:t,deltaScale:r}}}function f(){let t,n,e=0,r=0,i=0,a=0;return function(c){if(void 0!==c){n=n||c.startInput;const u=c.timestamp-n.timestamp;if(t$1<u){const s=c.x-n.x,p=c.y-n.y;i=Math.round(s/u*100)/100,a=Math.round(p/u*100)/100,e=Math.abs(i),r=Math.abs(a),t=u$2(s,p),n=c;}}return {velocityX:e,velocityY:r,speedX:i,speedY:a,direction:t}}}function M(){let t=0;return function(n){const{phase:e}=n;return c$3===e&&(t=n.pointLength),{maxPointLength:t}}}function v(t){return {x:t.points[1][n$1]-t.points[0][n$1],y:t.points[1][e$2]-t.points[0][e$2]}}function m$1(){let t,n,e;return function(o){const{prevInput:r,startMultiInput:i}=o;return void 0!==i&&void 0!==r&&o.id!==i.id&&1<r.pointLength&&1<o.pointLength?(t=v(i),n=v(r),e=v(o)):e=void 0,{startVecotr:t,prevVecotr:n,activeVecotr:e}}}
306
302
 
307
- var x=r=>Math.sqrt(r.x*r.x+r.y*r.y),y=(r,a)=>r.x*a.x+r.y*a.y,e$1=(r,a)=>{var t=x(r)*x(a);if(0===t)return 0;var h=y(r,a)/t;return h>1&&(h=1),Math.acos(h)},n=(r,a)=>r.x*a.y-a.x*r.y,o=r=>r/Math.PI*180,s=(r,a)=>{var t=e$1(r,a);return n(r,a)>0&&(t*=-1),o(t)},u$1=(x,y)=>{if(0!==x||0!==y)return Math.abs(x)>=Math.abs(y)?0<x?i$3:a$2:0<y?d$1:r$4};
303
+ const m={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250};function r$3(r,s){const c=O(m,s);let p,u,x$1,T=0;function f(){T=0,p=void 0,u=void 0;}return r.compute([h$2,M],(t=>{if(j(c))return;const{phase:i,x:o,y:m}=t;u$3===i&&(c.state=0,!function(){const{startInput:e,pointLength:n,timestamp:a}=t,i=a-e.timestamp,{distance:o,maxPointLength:m}=t;return m===c.pointLength&&0===n&&c.maxDistance>=o&&c.maxPressTime>i}()?(f(),c.state=2):(clearTimeout(x$1),function(t,e){if(void 0!==p){const n=x({x:t.x-p.x,y:t.y-p.y});return p=t,e.maxDistanceFromPrevTap>=n}return p=t,true}({x:o,y:m},c)&&function(t){const e=performance.now();if(void 0===u)return u=e,true;{const n=e-u;return u=e,n<t}}(c.waitNextTapTime)?T++:T=1,0==T%c.tapTimes?(c.state=1,r.emit2(c.name,t,c),f()):x$1=setTimeout((()=>{c.state=2,f();}),c.waitNextTapTime)));})),c}
308
304
 
309
- function p$1(){let n=0,e=0;return function(o,r){const{prevVecotr:i,startVecotr:a,activeVecotr:c}=r;return c&&(e=Math.round(s(c,i)),n=Math.round(s(c,a))),{angle:n,deltaAngle:e}}}function d(){return function(t){const{prevInput:e}=t;let o$1=0,r=0,i=0;if(void 0!==e&&(o$1=t.x-e.x,r=t.y-e.y,0!==o$1||0!==r)){const t=Math.sqrt(Math.pow(o$1,2)+Math.pow(r,2));i=Math.round(o(Math.acos(Math.abs(o$1)/t)));}return {deltaX:o$1,deltaY:r,deltaXYAngle:i}}}function h$1(){let t,n=0,u=0,s=0,p=0,d=0;return function(h){const{phase:l,startInput:f}=h;return c$3===l?(n=0,u=0,s=0,p=0,d=0):o$1===l&&(n=Math.round(h.points[0][n$1]-f.points[0][n$1]),u=Math.round(h.points[0][e$2]-f.points[0][e$2]),s=Math.abs(n),p=Math.abs(u),d=Math.round(x({x:s,y:p})),t=u$1(n,u)),{displacementX:n,displacementY:u,distanceX:s,distanceY:p,distance:d,overallDirection:t}}}function l(){let t=1;return function(n,o){let r=1;const{prevVecotr:i,startVecotr:a,activeVecotr:c}=o;return c&&(r=p$3(x(c)/x(i)),t=p$3(x(c)/x(a))),{scale:t,deltaScale:r}}}function f(){let t$1,n,e=0,r=0,i=0,a=0;return function(c){if(void 0!==c){n=n||c.startInput;const u=c.timestamp-n.timestamp;if(t<u){const s=c.x-n.x,p=c.y-n.y;i=Math.round(s/u*100)/100,a=Math.round(p/u*100)/100,e=Math.abs(i),r=Math.abs(a),t$1=u$1(s,p),n=c;}}return {velocityX:e,velocityY:r,speedX:i,speedY:a,direction:t$1}}}function M(){let t=0;return function(n){const{phase:e}=n;return c$3===e&&(t=n.pointLength),{maxPointLength:t}}}function v(t){return {x:t.points[1][n$1]-t.points[0][n$1],y:t.points[1][e$2]-t.points[0][e$2]}}function m$1(){let t,n,e;return function(o){const{prevInput:r,startMultiInput:i}=o;return void 0!==i&&void 0!==r&&o.id!==i.id&&1<r.pointLength&&1<o.pointLength?(t=v(i),n=v(r),e=v(o)):e=void 0,{startVecotr:t,prevVecotr:n,activeVecotr:e}}}
305
+ function e(e){e.use(r$3,{name:"doubletap",tapTimes:2});const a=e.get("doubletap");let o;return e.beforeEach(((t,e)=>{"tap"===t?(clearTimeout(o),o=setTimeout((()=>{[0,2].includes(a.state)&&e();}),300)):e();})),a}
310
306
 
311
- const m={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250};function r$2(r,s){const c=O(m,s);let p,u,x$1,T=0;function f(){T=0,p=void 0,u=void 0;}return r.compute([h$1,M],(t=>{if(j(c))return;const{phase:i,x:o,y:m}=t;u$3===i&&(c.state=0,!function(){const{startInput:e,pointLength:n,timestamp:a}=t,i=a-e.timestamp,{distance:o,maxPointLength:m}=t;return m===c.pointLength&&0===n&&c.maxDistance>=o&&c.maxPressTime>i}()?(f(),c.state=2):(clearTimeout(x$1),function(t,e){if(void 0!==p){const n=x({x:t.x-p.x,y:t.y-p.y});return p=t,e.maxDistanceFromPrevTap>=n}return p=t,true}({x:o,y:m},c)&&function(t){const e=performance.now();if(void 0===u)return u=e,true;{const n=e-u;return u=e,n<t}}(c.waitNextTapTime)?T++:T=1,0==T%c.tapTimes?(c.state=1,r.emit2(c.name,t,c),f()):x$1=setTimeout((()=>{c.state=2,f();}),c.waitNextTapTime)));})),c}
307
+ class t{constructor(){this.__map={};}beforeEach(t){this.__interceptor=t;}on(t,i){const s=Array.isArray(t)?t:[t];for(const t of s){this.__map[t]=this.__map[t]||[];const s=this.__map[t];s&&s.push(i);}return this}emit(t,i,s){ void 0!==this.__interceptor?this.__interceptor(t,(()=>{this.__emit(t,i),s&&s();})):(this.__emit(t,i),s&&s());}__emit(t,i){const s=this.__map[t];if(Array.isArray(s)&&(null==s?void 0:s.length))for(const _ of s)_(i,t);this.event=i;}off(t,i){const s=this.__map[t];if(void 0!==s)if(void 0===i)delete this.__map[t];else {const t=s.findIndex((t=>t===i));s.splice(t,1);}}destroy(){this.__map={};}}
312
308
 
313
- const p={name:"pan",threshold:10,pointLength:1};function u(u,d$1){const f$1=O(p,d$1);return u.compute([f,h$1,d],(t=>{if(g$1(f$1),j(f$1))return;const c=function(){const{pointLength:e,distance:n}=t;return f$1.pointLength===e&&f$1.threshold<=n}();if(f$1.state=b(c,f$1.state,t.phase),c||h$3(f$1.state)){const{name:e}=f$1;u.emit2(e,t,f$1),u.emit2(e+v$1(f$1.state),t,f$1),![u$3,s$1].includes(t.phase)&&t.direction&&u.emit2(e+t.direction,t,f$1);}})),f$1}
309
+ function r$2(){let t,o,i,r,a=0;return function(u){if(t=o,void 0!==u){a=Number.MAX_SAFE_INTEGER>a?++a:1;const h=function(t,o){const{phase:i,points:r,changedPoints:a,nativeEvent:u}=t,h=r.length,p=c$3===i,g=u$3===i&&0===h||s$1===i,l=Date.now(),{x:d,y:m}=c$2(r)||c$2(a),{currentTarget:v}=u;return Object.assign(t,{id:o,x:d,y:m,timestamp:l,isStart:p,isEnd:g,pointLength:h,currentTarget:v,getOffset(t=v){const e=t.getBoundingClientRect();return {x:d-Math.round(e.left),y:m-Math.round(e.top)}}})}(u,a);o=h;const{isStart:p,pointLength:g}=h;return p&&(i=h,t=void 0,r=1<g?h:void 0),Object.assign(Object.assign({},h),{prevInput:t,startMultiInput:r,startInput:i})}}}function c$2(t){const{length:e}=t;if(0<e){if(1===e){const{clientX:e,clientY:n}=t[0];return {x:Math.round(e),y:Math.round(n)}}const n=t.reduce(((t,e)=>(t.x+=e[n$1],t.y+=e[e$2],t)),{x:0,y:0});return {x:Math.round(n.x/e),y:Math.round(n.y/e)}}}function a$1(t,e,n,s){const o={};for(const t in n)["target","currentTarget","type"].includes(t)||(o[t]=n[t]);let i;return document.createEvent?(i=document.createEvent("HTMLEvents"),i.initEvent(t,null==s?void 0:s.bubbles,null==s?void 0:s.cancelable)):i=new Event(t,s),Object.assign(i,o,{match:()=>n.targets&&0<n.targets.length&&n.targets.every((t=>i.currentTarget.contains(t)))}),e.dispatchEvent(i)}function u$1(t,e){const{preventDefault:n}=e;return s=n,"[object Function]"===Object.prototype.toString.call(s)?n(t):!!n;var s;}const h$1=["touchstart","touchmove","touchend","touchcancel","mousedown"],p$1=["mousemove","mouseup"];const g={domEvents:{bubbles:true,cancelable:true},preventDefault:t=>{if(t.target&&"tagName"in t.target){const{tagName:e}=t.target;return !/^(?:INPUT|TEXTAREA|BUTTON|SELECT)$/.test(e)}return false}};class l extends t{constructor(t,e){super(),this.v="2.1.3",this.__computeFunctionList=[],this.__computeFunctionCreatorList=[],this.__pluginContexts=[],this.__isIgnoreMouse=false,this.el=t,this.c={},this.__options=Object.assign(Object.assign({},g),e);const n=function(t){const e=r$2();return function(n){const s=[],o=[];Array.from(n.touches).forEach((({clientX:e,clientY:n,target:i})=>{(null==t?void 0:t.contains(i))&&(s.push(i),o.push({clientX:e,clientY:n,target:i}));}));const i=Array.from(n.changedTouches).map((({clientX:t,clientY:e,target:n})=>({clientX:t,clientY:e,target:n})));return e({phase:n.type.replace("touch",""),changedPoints:i,points:o,nativeEvent:n,target:n.target,targets:s})}}(this.el),s=function(){let t,e=false,n=null;const s=r$2();return function(o){const{clientX:i,clientY:r,type:c,button:a,target:u}=o;let h,p=[{clientX:i,clientY:r,target:u}];if("mousedown"===c&&0===a)n=u,e=true,h="start";else {if(!e)return;"mousemove"===c?h="move":"mouseup"===c&&(p=[],h="end",e=false);}const g=t||[{clientX:i,clientY:r,target:u}];if(t=[{clientX:i,clientY:r,target:u}],void 0!==h)return s({phase:h,changedPoints:g,points:p,target:n,targets:[n],nativeEvent:o})}}();if(this.__inputCreatorMap={touchstart:n,touchmove:n,touchend:n,touchcancel:n,mousedown:s,mousemove:s,mouseup:s},this.on("at:after",(t=>{const{target:e,__type:n}=t,{domEvents:s}=this.__options;s&&void 0!==this.el&&e&&(a$1(n,e,t,s),a$1("at:after",e,t,s));})),void 0!==t){t.style.webkitTapHighlightColor="rgba(0,0,0,0)";let e=false;try{const t={};Object.defineProperty(t,"passive",{get(){e=!0;}}),window.addEventListener("_",(()=>{}),t);}catch(t){}this.on("u",function(t,e,n){return h$1.forEach((s=>{t.addEventListener(s,e,n);})),p$1.forEach((t=>{window.addEventListener(t,e,n);})),()=>{h$1.forEach((n=>{t.removeEventListener(n,e);})),p$1.forEach((t=>{window.removeEventListener(t,e);}));}}(t,this.catchEvent.bind(this),false===this.__options.preventDefault&&e?{passive:true}:{passive:false}));}}use(t,e){this.__pluginContexts.push(t(this,e));}catchEvent(t){const e=this.__inputCreatorMap[t.type](t);if(void 0!==e){const n=()=>t.stopPropagation(),s=()=>t.stopImmediatePropagation(),o=()=>t.preventDefault();if(u$1(t,this.__options))o();else if("touchstart"===t.type?this.__isIgnoreMouse=true:"touchmove"===t.type&&(this.__isIgnoreMouse=false),this.__isIgnoreMouse&&t.type.startsWith("mouse"))return void("mouseup"===t.type&&(this.__isIgnoreMouse=false));this.emit("input",e),this.emit2(`at:${e.phase}`,e,{});const i={};this.__computeFunctionList.forEach((t=>{const n=t(e,i);if(void 0!==n)for(const t in n)i[t]=n[t];})),this.emit("computed",Object.assign(Object.assign(Object.assign({},e),i),{stopPropagation:n,stopImmediatePropagation:s,preventDefault:o}));}}compute(t,e){for(const e of t)this.__computeFunctionCreatorList.includes(e)||(this.__computeFunctionCreatorList.push(e),this.__computeFunctionList.push(e()));this.on("computed",e);}beforeEach(t){super.beforeEach(((e,n)=>{var s;(null===(s=this.c)||void 0===s?void 0:s.name)?t(e,n):n();}));}get(t){return this.__pluginContexts.find((e=>t===e.name))}set(t){this.__options=Object.assign(Object.assign({},this.__options),t);}emit2(t,e,n){this.c=n,this.emit(t,Object.assign(Object.assign({},e),{type:t}),(()=>{this.emit("at:after",Object.assign(Object.assign({},e),{name:t,__type:t}));}));}destroy(){this.emit("u"),super.destroy();}}
314
310
 
315
- const c$1={name:"swipe",threshold:10,velocity:.3,pointLength:1};function a(a,r){const s=O(c$1,r);return a.compute([h$1,f,M],(t=>{if(s.state=0,!s.disabled&&function(){if(u$3!==t.phase)return false;const{velocityX:o,velocityY:n,distance:i,maxPointLength:c}=t;return c===s.pointLength&&0===t.points.length&&s.threshold<i&&s.velocity<Math.max(o,n)}()){const{name:e}=s;s.state=1,a.emit2(e,t,s),a.emit2(e+t.direction,t,s);}})),s}
311
+ const p={name:"pan",threshold:10,pointLength:1};function u(u,d$1){const f$1=O(p,d$1);return u.compute([f,h$2,d],(t=>{if(g$1(f$1),j(f$1))return;const c=function(){const{pointLength:e,distance:n}=t;return f$1.pointLength===e&&f$1.threshold<=n}();if(f$1.state=b(c,f$1.state,t.phase),c||h$3(f$1.state)){const{name:e}=f$1;u.emit2(e,t,f$1),u.emit2(e+v$1(f$1.state),t,f$1),![u$3,s$1].includes(t.phase)&&t.direction&&u.emit2(e+t.direction,t,f$1);}})),f$1}
316
312
 
317
- const r$1={name:"press",pointLength:1,maxDistance:9,minPressTime:251};function c(c,u){const p=O(r$1,u);let f=0;return c.compute([h$1],(t=>{if(j(p))return;const{phase:o,startInput:r,pointLength:u}=t;if(c$3===o&&p.pointLength===u)g$1(p),clearTimeout(f),f=setTimeout((()=>{p.state=1,c.emit2(p.name,t,p);}),p.minPressTime);else if(u$3===o&&1===p.state)c.emit2(`${p.name}${r$4}`,t,p);else if(1!==p.state){const e=t.timestamp-r.timestamp;(!function(){const{distance:e}=t;return e&&p.maxDistance>e}()||p.minPressTime>e&&[u$3,s$1].includes(o))&&(clearTimeout(f),p.state=2);}})),p}
313
+ const c$1={name:"swipe",threshold:10,velocity:.3,pointLength:1};function a(a,r){const s=O(c$1,r);return a.compute([h$2,f,M],(t=>{if(s.state=0,!s.disabled&&function(){if(u$3!==t.phase)return false;const{velocityX:o,velocityY:n,distance:i,maxPointLength:c}=t;return c===s.pointLength&&0===t.points.length&&s.threshold<i&&s.velocity<Math.max(o,n)}()){const{name:e}=s;s.state=1,a.emit2(e,t,s),a.emit2(e+t.direction,t,s);}})),s}
318
314
 
319
- const i$2={name:"pinch",threshold:0,pointLength:2};function r(r,m){const p=O(i$2,m);return r.compute([m$1,l],(t=>{if(g$1(p),j(p))return;const c=function(){const{pointLength:e,scale:n,deltaScale:o,phase:a}=t;return p.pointLength===e&&p.threshold<Math.abs(n-1)}();p.state=b(c,p.state,t.phase);const{name:h}=p;if(c||h$3(p.state)){r.emit2(h,t,p);const{deltaScale:e}=t;1!==e&&r.emit2(h+(1<e?"in":"out"),t,p);}const i=v$1(p.state);i&&r.emit2(h+i,t,p);})),p}
315
+ const r$1={name:"press",pointLength:1,maxDistance:9,minPressTime:251};function c(c,u){const p=O(r$1,u);let f=0;return c.compute([h$2],(t=>{if(j(p))return;const{phase:o,startInput:r,pointLength:u}=t;if(c$3===o&&p.pointLength===u)g$1(p),clearTimeout(f),f=setTimeout((()=>{p.state=1,c.emit2(p.name,t,p);}),p.minPressTime);else if(u$3===o&&1===p.state)c.emit2(`${p.name}${r$4}`,t,p);else if(1!==p.state){const e=t.timestamp-r.timestamp;(!function(){const{distance:e}=t;return e&&p.maxDistance>e}()||p.minPressTime>e&&[u$3,s$1].includes(o))&&(clearTimeout(f),p.state=2);}})),p}
320
316
 
321
- const h={name:"rotate",threshold:0,pointLength:2};function i$1(i,m){const u=O(h,m);return i.compute([m$1,p$1],(t=>{if(j(u))return;g$1(u);const r=function(){const{pointLength:e,angle:n}=t;return u.pointLength===e&&u.threshold<Math.abs(n)}();u.state=b(r,u.state,t.phase);const{name:c}=u;(r||h$3(u.state))&&i.emit2(c,t,u);const h=v$1(u.state);h&&i.emit2(c+h,t,u);})),u}
317
+ const i$2={name:"pinch",threshold:0,pointLength:2};function r(r,m){const p=O(i$2,m);return r.compute([m$1,l$1],(t=>{if(g$1(p),j(p))return;const c=function(){const{pointLength:e,scale:n,deltaScale:o,phase:a}=t;return p.pointLength===e&&p.threshold<Math.abs(n-1)}();p.state=b(c,p.state,t.phase);const{name:h}=p;if(c||h$3(p.state)){r.emit2(h,t,p);const{deltaScale:e}=t;1!==e&&r.emit2(h+(1<e?"in":"out"),t,p);}const i=v$1(p.state);i&&r.emit2(h+i,t,p);})),p}
322
318
 
323
- function e(e){e.use(r$2,{name:"doubletap",tapTimes:2});const a=e.get("doubletap");let o;return e.beforeEach(((t,e)=>{"tap"===t?(clearTimeout(o),o=setTimeout((()=>{[0,2].includes(a.state)&&e();}),300)):e();})),a}
319
+ const h={name:"rotate",threshold:0,pointLength:2};function i$1(i,m){const u=O(h,m);return i.compute([m$1,p$2],(t=>{if(j(u))return;g$1(u);const r=function(){const{pointLength:e,angle:n}=t;return u.pointLength===e&&u.threshold<Math.abs(n)}();u.state=b(r,u.state,t.phase);const{name:c}=u;(r||h$3(u.state))&&i.emit2(c,t,u);const h=v$1(u.state);h&&i.emit2(c+h,t,u);})),u}
324
320
 
325
- class i extends l$1{constructor(t,u$1){super(t,u$1),this.use(r$2),this.use(u),this.use(a),this.use(c),this.use(r),this.use(i$1);}}i.STATE_POSSIBLE=0,i.STATE_START=4,i.STATE_MOVE=5,i.STATE_END=1,i.STATE_CANCELLED=3,i.STATE_FAILED=2,i.STATE_RECOGNIZED=1,i.tap=r$2,i.pan=u,i.swipe=a,i.press=c,i.rotate=i$1,i.pinch=r,i.doubletap=e;
321
+ class i extends l{constructor(t,u$1){super(t,u$1),this.use(r$3),this.use(u),this.use(a),this.use(c),this.use(r),this.use(i$1);}}i.STATE_POSSIBLE=0,i.STATE_START=4,i.STATE_MOVE=5,i.STATE_END=1,i.STATE_CANCELLED=3,i.STATE_FAILED=2,i.STATE_RECOGNIZED=1,i.tap=r$3,i.pan=u,i.swipe=a,i.press=c,i.rotate=i$1,i.pinch=r,i.doubletap=e;
326
322
 
327
323
  class PopsUtils {
328
324
  /**
@@ -431,7 +427,8 @@ var pops = (function () {
431
427
  if (typeof sourceValue === "object" &&
432
428
  sourceValue != null &&
433
429
  keyName in target &&
434
- !UtilsContext.isDOM(sourceValue)) {
430
+ !UtilsContext.isDOM(sourceValue) &&
431
+ !(sourceValue instanceof EventEmiter)) {
435
432
  // 源端的值是object类型,且不是元素节点
436
433
  // 如果是数组,那此数组中有值,清空旧的数组再赋值
437
434
  let childObjectValue;
@@ -447,7 +444,7 @@ var pops = (function () {
447
444
  Reflect.set(target, keyName, childObjectValue);
448
445
  }
449
446
  else {
450
- /* 直接赋值 */
447
+ // 直接赋值
451
448
  Reflect.set(target, keyName, sourceValue);
452
449
  }
453
450
  }
@@ -637,33 +634,31 @@ var pops = (function () {
637
634
  if (typeof deviation !== "number" || Number.isNaN(deviation)) {
638
635
  deviation = 10;
639
636
  }
640
- const leftTop = {
641
- x: globalThis.innerWidth * (1 / 8),
642
- y: globalThis.innerHeight * (1 / 8),
643
- };
644
- const leftBottom = {
645
- x: globalThis.innerWidth * (1 / 8),
646
- y: globalThis.innerHeight * (7 / 8),
647
- };
648
- const rightTop = {
649
- x: globalThis.innerWidth * (7 / 8),
650
- y: globalThis.innerHeight * (1 / 8),
651
- };
652
- const rightBottom = {
653
- x: globalThis.innerWidth * (7 / 8),
654
- y: globalThis.innerHeight * (7 / 8),
655
- };
656
- const center = {
657
- x: globalThis.innerWidth / 2,
658
- y: globalThis.innerHeight / 2,
659
- };
660
- const delayHandlerElementPostionList = [
661
- leftTop,
662
- leftBottom,
663
- rightTop,
664
- rightBottom,
665
- center,
666
- ];
637
+ /** 坐标偏移 */
638
+ const positionDistance = 10;
639
+ const defaultCalcPostion = [];
640
+ const maxPostionX = globalThis.innerWidth;
641
+ const maxPostionY = globalThis.innerHeight;
642
+ const gridXCount = 8;
643
+ const gridYCount = 8;
644
+ for (let i = 0; i < gridXCount; i++) {
645
+ for (let j = 0; j < gridYCount; j++) {
646
+ const positionX = globalThis.innerWidth * (i / gridXCount) + positionDistance;
647
+ const positionY = globalThis.innerHeight * (j / gridYCount) + positionDistance;
648
+ const position = {
649
+ x: positionX,
650
+ y: positionY,
651
+ };
652
+ if (position.x > maxPostionX) {
653
+ position.x = maxPostionX;
654
+ }
655
+ if (position.y > maxPostionY) {
656
+ position.y = maxPostionY;
657
+ }
658
+ defaultCalcPostion.push(position);
659
+ }
660
+ }
661
+ const delayHandlerElementPostionList = defaultCalcPostion;
667
662
  if ($el) {
668
663
  delayHandlerElementPostionList.length = 0;
669
664
  if (Array.isArray($el)) {
@@ -675,61 +670,79 @@ var pops = (function () {
675
670
  }
676
671
  const positionInfoList = delayHandlerElementPostionList
677
672
  .map((position) => {
678
- let positionNode;
673
+ let $position;
679
674
  let positionX;
680
675
  let positionY;
681
676
  if (position instanceof HTMLElement) {
682
- positionNode = position;
677
+ $position = position;
683
678
  const nodeRect = position.getBoundingClientRect();
684
679
  positionX = nodeRect.x + nodeRect.width / 2;
685
680
  positionY = nodeRect.y + nodeRect.height / 2;
686
681
  }
687
682
  else {
688
- positionNode = document.elementFromPoint(position.x, position.y);
683
+ $position = document.elementFromPoint(position.x, position.y);
689
684
  positionX = position.x;
690
685
  positionY = position.y;
691
686
  }
692
- const shadowRoot = positionNode?.shadowRoot;
687
+ const shadowRoot = $position?.shadowRoot;
693
688
  if (shadowRoot) {
694
- positionNode = shadowRoot.elementFromPoint(positionX, positionY);
689
+ // 处理ShadowRoot
690
+ $position = shadowRoot.elementFromPoint(positionX, positionY);
695
691
  }
696
- if (positionNode instanceof HTMLStyleElement)
697
- return;
698
- if (positionNode instanceof HTMLScriptElement)
699
- return;
700
- if (positionNode instanceof HTMLMetaElement)
701
- return;
702
- if (positionNode instanceof HTMLHeadElement)
703
- return;
704
- if (!(positionNode instanceof HTMLElement))
692
+ if (!($position instanceof HTMLElement))
705
693
  return;
706
- let parent = positionNode;
694
+ let $parent = $position;
707
695
  let zIndex = 0;
708
- let maxZIndexNode = null;
709
- while (parent) {
710
- const nodeStyle = globalThis.getComputedStyle(parent);
696
+ let $maxZIndexNode = null;
697
+ let rect = {
698
+ x: 0,
699
+ y: 0,
700
+ width: 0,
701
+ height: 0,
702
+ top: 0,
703
+ right: 0,
704
+ bottom: 0,
705
+ left: 0,
706
+ };
707
+ while ($parent) {
708
+ const nodeStyle = globalThis.getComputedStyle($parent);
711
709
  const nodeZIndex = parseInt(nodeStyle.zIndex);
712
710
  if (nodeStyle.position !== "static" && !isNaN(nodeZIndex)) {
713
711
  if (nodeZIndex > zIndex) {
714
712
  zIndex = nodeZIndex;
715
- maxZIndexNode = parent;
716
- }
717
- }
718
- parent = parent.parentElement;
713
+ $maxZIndexNode = $parent;
714
+ }
715
+ }
716
+ $parent = $parent.parentElement;
717
+ }
718
+ if ($maxZIndexNode) {
719
+ const maxRect = $maxZIndexNode.getBoundingClientRect();
720
+ rect = {
721
+ x: maxRect.x,
722
+ y: maxRect.y,
723
+ width: maxRect.width,
724
+ height: maxRect.height,
725
+ top: maxRect.top,
726
+ right: maxRect.right,
727
+ bottom: maxRect.bottom,
728
+ left: maxRect.left,
729
+ };
719
730
  }
720
731
  return {
721
- /** 处理了偏移量后的z-index值 */
732
+ /** 计算偏移量后的z-index值 */
722
733
  zIndex: zIndex + deviation,
723
- /** 原始z-index值 */
734
+ /** 获取到的最大的z-index值 */
724
735
  originZIndex: zIndex,
725
736
  /** 拥有最大z-index的元素 */
726
- node: maxZIndexNode,
737
+ node: $maxZIndexNode,
727
738
  /** 目标坐标元素 */
728
- positionNode: positionNode,
729
- /** x坐标 */
739
+ positionNode: $position,
740
+ /** 目标x坐标 */
730
741
  positionX: positionX,
731
- /** y坐标 */
742
+ /** 目标y坐标 */
732
743
  positionY: positionY,
744
+ /** node位置信息 */
745
+ rect,
733
746
  };
734
747
  })
735
748
  .filter((it) => it != null);
@@ -780,11 +793,22 @@ var pops = (function () {
780
793
  const PopsCommonCSSClassName = {
781
794
  flexCenter: "pops-flex-items-center",
782
795
  flexYCenter: "pops-flex-y-center",
796
+ flexXCenter: "pops-flex-x-center",
783
797
  hide: "pops-hide",
784
798
  hideImportant: "pops-hide-important",
799
+ noBorder: "pops-no-border",
800
+ noBorderImportant: "pops-no-border-important",
785
801
  userSelectNone: "pops-user-select-none",
786
- textIsDisabled: "pops-text-is-disabled"};
802
+ lineHeightCenter: "pops-line-height-center",
803
+ widthFill: "pops-width-fill",
804
+ textIsDisabled: "pops-text-is-disabled",
805
+ textIsDisabledImportant: "pops-text-is-disabled-important",
806
+ };
787
807
 
808
+ /**
809
+ * 存储在元素属性上的事件名
810
+ */
811
+ const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
788
812
  class PopsDOMUtilsEvent {
789
813
  on(element, eventType, selector, callback, option) {
790
814
  /**
@@ -3129,6 +3153,134 @@ var pops = (function () {
3129
3153
  tooltip: [],
3130
3154
  };
3131
3155
 
3156
+ const PopsInstanceUtils = {
3157
+ /**
3158
+ * 获取pops所有弹窗中的最大的z-index
3159
+ * @param deviation
3160
+ */
3161
+ getPopsMaxZIndex(deviation = 1) {
3162
+ deviation = Number.isNaN(deviation) ? 1 : deviation;
3163
+ // 最大值 2147483647
3164
+ // const browserMaxZIndex = Math.pow(2, 31) - 1;
3165
+ // 比较值 2000000000
3166
+ const maxZIndex = 2 * Math.pow(10, 9);
3167
+ // 当前页面最大的z-index
3168
+ let zIndex = 0;
3169
+ // 当前的最大z-index的元素,调试使用
3170
+ let maxZIndexNode = null;
3171
+ Object.keys(PopsInstData).forEach((instKeyName) => {
3172
+ const instData = PopsInstData[instKeyName];
3173
+ for (let index = 0; index < instData.length; index++) {
3174
+ const inst = instData[index];
3175
+ // 不对position为static和display为none的元素进行获取它们的z-index
3176
+ const $elList = [inst.$anim, inst.$pops, inst.$mask].filter((it) => it instanceof HTMLElement);
3177
+ const nodeZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint($elList);
3178
+ const maxNodeZIndexInfo = nodeZIndexInfoList[0];
3179
+ if (maxNodeZIndexInfo) {
3180
+ const nodeZIndex = maxNodeZIndexInfo.zIndex;
3181
+ if (nodeZIndex > zIndex) {
3182
+ zIndex = nodeZIndex;
3183
+ maxZIndexNode = maxNodeZIndexInfo.node || maxNodeZIndexInfo.positionNode;
3184
+ }
3185
+ }
3186
+ }
3187
+ });
3188
+ zIndex += deviation;
3189
+ const isOverMaxZIndex = zIndex >= maxZIndex;
3190
+ if (isOverMaxZIndex) {
3191
+ // 超出z-index最大值
3192
+ zIndex = maxZIndex;
3193
+ }
3194
+ return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
3195
+ },
3196
+ /**
3197
+ * 排序数组
3198
+ * @param getBeforeValueFun
3199
+ * @param getAfterValueFun
3200
+ * @param sortByDesc 排序是否降序,默认降序
3201
+ */
3202
+ sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
3203
+ if (typeof sortByDesc !== "boolean") {
3204
+ throw new TypeError("参数 sortByDesc 必须为boolean类型");
3205
+ }
3206
+ if (getBeforeValueFun == null || getAfterValueFun == null) {
3207
+ throw new Error("获取前面的值或后面的值的方法不能为空");
3208
+ }
3209
+ return function (after_obj, before_obj) {
3210
+ const beforeValue = getBeforeValueFun(before_obj); // 前
3211
+ const afterValue = getAfterValueFun(after_obj); // 后
3212
+ if (sortByDesc) {
3213
+ if (afterValue > beforeValue) {
3214
+ return -1;
3215
+ }
3216
+ else if (afterValue < beforeValue) {
3217
+ return 1;
3218
+ }
3219
+ else {
3220
+ return 0;
3221
+ }
3222
+ }
3223
+ else {
3224
+ if (afterValue < beforeValue) {
3225
+ return -1;
3226
+ }
3227
+ else if (afterValue > beforeValue) {
3228
+ return 1;
3229
+ }
3230
+ else {
3231
+ return 0;
3232
+ }
3233
+ }
3234
+ };
3235
+ },
3236
+ /**
3237
+ * 是否是隐藏状态
3238
+ *
3239
+ * 检测以下项:
3240
+ *
3241
+ * + `display`: none
3242
+ * + `visibility`: hidden
3243
+ * + `opacity`: 0
3244
+ * + `使用了pops的自定义的隐藏class类`
3245
+ * @param $el 需要检测的元素
3246
+ */
3247
+ isHide($el) {
3248
+ let flag = false;
3249
+ if ($el?.classList?.contains(PopsCommonCSSClassName.hide) ||
3250
+ $el?.classList?.contains(PopsCommonCSSClassName.hideImportant)) {
3251
+ flag = true;
3252
+ }
3253
+ else {
3254
+ if ($el instanceof HTMLElement) {
3255
+ const style = $el.style;
3256
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
3257
+ }
3258
+ if (!flag) {
3259
+ const style = globalThis.getComputedStyle($el);
3260
+ flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
3261
+ }
3262
+ }
3263
+ return flag;
3264
+ },
3265
+ /**
3266
+ * 判断元素是否是在`.pops`内
3267
+ * @param $el 目标元素
3268
+ */
3269
+ isNodeInPopsNode($el) {
3270
+ return !!($el.closest(".pops") || $el.matches(".pops"));
3271
+ },
3272
+ /**
3273
+ * 判断是否是`.pops-anim`元素
3274
+ * @param $el 目标元素
3275
+ */
3276
+ isAnimNode($el) {
3277
+ return !!($el?.localName?.toLowerCase() === "div" &&
3278
+ $el.className &&
3279
+ $el.className === "pops-anim" &&
3280
+ $el.hasAttribute("anim"));
3281
+ },
3282
+ };
3283
+
3132
3284
  const PopsInstHandler = {
3133
3285
  /**
3134
3286
  * 删除配置中对应的对象
@@ -3191,7 +3343,7 @@ var pops = (function () {
3191
3343
  return totalInstConfigList;
3192
3344
  },
3193
3345
  /**
3194
- * 隐藏
3346
+ * 显示
3195
3347
  * @param popsType
3196
3348
  * @param instConfigList
3197
3349
  * @param guid
@@ -3199,24 +3351,34 @@ var pops = (function () {
3199
3351
  * @param $anim
3200
3352
  * @param $mask
3201
3353
  */
3202
- hide(config, popsType, instConfigList, guid, $anim, $mask) {
3354
+ show(config, popsType, instConfigList, guid, $anim, $mask) {
3203
3355
  // oxlint-disable-next-line no-async-promise-executor
3204
3356
  return new Promise(async (resolve) => {
3205
3357
  const $pops = $anim.querySelector(".pops[type-value]");
3206
3358
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3207
3359
  if (fintInst) {
3208
- // 存在实例
3360
+ // 由于是隐蔽状态
3361
+ // 先设置好动画状态
3362
+ // 再显示,会自执行动画
3363
+ const checkVisible = () => {
3364
+ if (!PopsInstanceUtils.isHide($anim)) {
3365
+ return true;
3366
+ }
3367
+ else {
3368
+ return false;
3369
+ }
3370
+ };
3209
3371
  const startAnim = async () => {
3210
3372
  if (popsType === "drawer") {
3211
3373
  // drawer是抽屉
3212
3374
  // 单独处理动画
3213
3375
  const drawerConfig = config;
3214
- await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3376
+ await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3215
3377
  if ($mask) {
3216
- popsDOMUtils.css($mask, "display", "none");
3378
+ popsDOMUtils.css($mask, "display", "");
3217
3379
  }
3218
3380
  const direction = drawerConfig.direction;
3219
- const size = "0";
3381
+ const size = drawerConfig.size.toString();
3220
3382
  if (["top", "bottom"].includes(direction)) {
3221
3383
  $pops.style.setProperty("height", size);
3222
3384
  }
@@ -3224,26 +3386,26 @@ var pops = (function () {
3224
3386
  $pops.style.setProperty("width", size);
3225
3387
  }
3226
3388
  else {
3227
- console.error("未知direction: ", direction);
3389
+ console.error("未知direction", direction);
3228
3390
  }
3229
3391
  }
3230
3392
  else {
3231
- instConfigItem.$anim.style.width = "100%";
3232
- instConfigItem.$anim.style.height = "100%";
3233
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim") + "-reverse");
3393
+ instConfigItem.$anim.style.width = "";
3394
+ instConfigItem.$anim.style.height = "";
3395
+ Reflect.set(instConfigItem.$anim.style, "animation-name", animName);
3234
3396
  }
3235
- };
3236
- const endCallback = () => {
3237
- instConfigItem.$anim.style.display = "none";
3397
+ instConfigItem.$anim.style.display = "";
3238
3398
  if (instConfigItem.$mask) {
3239
- instConfigItem.$mask.style.display = "none";
3399
+ instConfigItem.$mask.style.display = "";
3240
3400
  }
3241
- fintInst.emitter.emit("pops:hide", instConfigItem);
3401
+ };
3402
+ const endCallback = () => {
3403
+ fintInst.emitter.emit("pops:show", instConfigItem);
3242
3404
  };
3243
3405
  const instConfigItem = fintInst;
3244
- fintInst.emitter.emit("pops:before-hide", instConfigItem);
3245
- await startAnim();
3246
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3406
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3407
+ fintInst.emitter.emit("pops:before-show", instConfigItem);
3408
+ if (checkVisible() && PopsAnimation.hasAnim(animName)) {
3247
3409
  /**
3248
3410
  * 动画结束的回调
3249
3411
  */
@@ -3254,22 +3416,23 @@ var pops = (function () {
3254
3416
  };
3255
3417
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3256
3418
  capture: true,
3257
- once: true,
3258
3419
  });
3420
+ await startAnim();
3259
3421
  }
3260
3422
  else {
3423
+ await startAnim();
3261
3424
  endCallback();
3262
3425
  resolve();
3263
3426
  }
3264
3427
  }
3265
3428
  else {
3266
- console.error("hide-error: 该实例未存储");
3429
+ console.error("show-error: 该实例未存储");
3267
3430
  resolve();
3268
3431
  }
3269
3432
  });
3270
3433
  },
3271
3434
  /**
3272
- * 显示
3435
+ * 隐藏
3273
3436
  * @param popsType
3274
3437
  * @param instConfigList
3275
3438
  * @param guid
@@ -3277,23 +3440,35 @@ var pops = (function () {
3277
3440
  * @param $anim
3278
3441
  * @param $mask
3279
3442
  */
3280
- show(config, popsType, instConfigList, guid, $anim, $mask) {
3443
+ hide(config, popsType, instConfigList, guid, $anim, $mask) {
3281
3444
  // oxlint-disable-next-line no-async-promise-executor
3282
3445
  return new Promise(async (resolve) => {
3283
3446
  const $pops = $anim.querySelector(".pops[type-value]");
3284
3447
  const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
3285
3448
  if (fintInst) {
3449
+ // 由于是已显示状态
3450
+ // 先执行动画
3451
+ // 再隐藏
3452
+ // 存在实例
3453
+ const checkVisible = () => {
3454
+ if (!PopsInstanceUtils.isHide($anim)) {
3455
+ return true;
3456
+ }
3457
+ else {
3458
+ return false;
3459
+ }
3460
+ };
3286
3461
  const startAnim = async () => {
3287
3462
  if (popsType === "drawer") {
3288
3463
  // drawer是抽屉
3289
3464
  // 单独处理动画
3290
3465
  const drawerConfig = config;
3291
- await popsUtils.sleep(drawerConfig.openDelay ?? 0);
3466
+ await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3292
3467
  if ($mask) {
3293
- popsDOMUtils.css($mask, "display", "");
3468
+ popsDOMUtils.css($mask, "display", "none");
3294
3469
  }
3295
3470
  const direction = drawerConfig.direction;
3296
- const size = drawerConfig.size.toString();
3471
+ const size = "0";
3297
3472
  if (["top", "bottom"].includes(direction)) {
3298
3473
  $pops.style.setProperty("height", size);
3299
3474
  }
@@ -3301,26 +3476,27 @@ var pops = (function () {
3301
3476
  $pops.style.setProperty("width", size);
3302
3477
  }
3303
3478
  else {
3304
- console.error("未知direction", direction);
3479
+ console.error("未知direction: ", direction);
3305
3480
  }
3306
3481
  }
3307
3482
  else {
3308
- instConfigItem.$anim.style.width = "";
3309
- instConfigItem.$anim.style.height = "";
3310
- Reflect.set(instConfigItem.$anim.style, "animation-name", instConfigItem.$anim.getAttribute("anim").replace("-reverse", ""));
3483
+ instConfigItem.$anim.style.width = "100%";
3484
+ instConfigItem.$anim.style.height = "100%";
3485
+ Reflect.set(instConfigItem.$anim.style, "animation-name", reverseAnimName);
3311
3486
  }
3312
3487
  };
3313
3488
  const endCallback = () => {
3314
- instConfigItem.$anim.style.display = "";
3489
+ instConfigItem.$anim.style.display = "none";
3315
3490
  if (instConfigItem.$mask) {
3316
- instConfigItem.$mask.style.display = "";
3491
+ instConfigItem.$mask.style.display = "none";
3317
3492
  }
3318
- fintInst.emitter.emit("pops:show", instConfigItem);
3493
+ fintInst.emitter.emit("pops:hide", instConfigItem);
3319
3494
  };
3320
3495
  const instConfigItem = fintInst;
3321
- fintInst.emitter.emit("pops:before-show", instConfigItem);
3322
- await startAnim();
3323
- if (PopsAnimation.hasAnim(Reflect.get(instConfigItem.$anim.style, "animation-name"))) {
3496
+ const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
3497
+ const reverseAnimName = animName + "-reverse";
3498
+ fintInst.emitter.emit("pops:before-hide", instConfigItem);
3499
+ if (!checkVisible() && PopsAnimation.hasAnim(reverseAnimName)) {
3324
3500
  /**
3325
3501
  * 动画结束的回调
3326
3502
  */
@@ -3331,15 +3507,18 @@ var pops = (function () {
3331
3507
  };
3332
3508
  const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
3333
3509
  capture: true,
3510
+ once: true,
3334
3511
  });
3512
+ await startAnim();
3335
3513
  }
3336
3514
  else {
3515
+ await startAnim();
3337
3516
  endCallback();
3338
3517
  resolve();
3339
3518
  }
3340
3519
  }
3341
3520
  else {
3342
- console.error("show-error: 该实例未存储");
3521
+ console.error("hide-error: 该实例未存储");
3343
3522
  resolve();
3344
3523
  }
3345
3524
  });
@@ -3379,7 +3558,7 @@ var pops = (function () {
3379
3558
  await new Promise(async (resolve) => {
3380
3559
  const $pops = $anim.querySelector(".pops[type-value]");
3381
3560
  const drawerConfig = config;
3382
- const start = () => {
3561
+ const startAnim = () => {
3383
3562
  /**
3384
3563
  * 弹窗已关闭的回调
3385
3564
  */
@@ -3420,7 +3599,7 @@ var pops = (function () {
3420
3599
  };
3421
3600
  if (popsType === "drawer") {
3422
3601
  await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
3423
- start();
3602
+ startAnim();
3424
3603
  }
3425
3604
  else {
3426
3605
  await PopsInstHandler.removeInstance([instConfigList], guid);
@@ -3700,11 +3879,11 @@ var pops = (function () {
3700
3879
  * 点击其它区域的事件
3701
3880
  * @param event
3702
3881
  */
3703
- function clickEvent(event) {
3882
+ const clickEvent = (event) => {
3704
3883
  popsDOMUtils.preventEvent(event);
3705
3884
  // 获取该类型实例存储列表
3706
3885
  const targetInst = PopsInstData[config.type];
3707
- function originalRun() {
3886
+ const continueExec = () => {
3708
3887
  if (config.config.mask.clickEvent.toClose) {
3709
3888
  // 关闭
3710
3889
  return PopsInstHandler.close(config.config, config.type, targetInst, config.guid, config.animElement);
@@ -3713,37 +3892,26 @@ var pops = (function () {
3713
3892
  // 隐藏
3714
3893
  return PopsInstHandler.hide(config.config, config.type, targetInst, config.guid, config.animElement, result.maskElement);
3715
3894
  }
3716
- }
3895
+ };
3717
3896
  if (typeof config.config.mask.clickCallBack === "function") {
3718
- config.config.mask.clickCallBack(originalRun, config.config);
3897
+ config.config.mask.clickCallBack(continueExec, config.config);
3719
3898
  }
3720
3899
  else {
3721
- originalRun();
3900
+ continueExec();
3722
3901
  }
3723
3902
  return false;
3724
- }
3903
+ };
3725
3904
  // 判断是否启用了遮罩层点击动作
3726
3905
  if (config.config.mask.clickEvent.toClose || config.config.mask.clickEvent.toHide) {
3727
- /**
3728
- * 判断点击的元素是否是动画层的元素
3729
- * @param element
3730
- * @returns
3731
- */
3732
- function isAnimElement(element) {
3733
- return Boolean(element?.localName?.toLowerCase() === "div" &&
3734
- element.className &&
3735
- element.className === "pops-anim" &&
3736
- element.hasAttribute("anim"));
3737
- }
3738
3906
  // 判断按下的元素是否是pops-anim
3739
3907
  popsDOMUtils.on(config.animElement, "pointerup", (event) => {
3740
3908
  const $click = event.composedPath()[0];
3741
- isMaskClick = isAnimElement($click);
3909
+ isMaskClick = PopsInstanceUtils.isAnimNode($click);
3742
3910
  });
3743
3911
  // 如果有动画层,在动画层上监听点击事件
3744
3912
  popsDOMUtils.on(config.animElement, "click", (event) => {
3745
3913
  const $click = event.composedPath()[0];
3746
- if (isMaskClick && isAnimElement($click)) {
3914
+ if (isMaskClick && PopsInstanceUtils.isAnimNode($click)) {
3747
3915
  return clickEvent(event);
3748
3916
  }
3749
3917
  });
@@ -4171,8 +4339,8 @@ var pops = (function () {
4171
4339
  style: null,
4172
4340
  lightStyle: null,
4173
4341
  darkStyle: null,
4174
- beforeAppendToPageCallBack() { },
4175
4342
  stopKeyDownEventPropagation: true,
4343
+ emitter: null,
4176
4344
  };
4177
4345
  };
4178
4346
 
@@ -4181,11 +4349,11 @@ var pops = (function () {
4181
4349
  const guid = popsUtils.getRandomGUID();
4182
4350
  // 设置当前类型
4183
4351
  const popsType = "alert";
4184
- const emitter = new EventEmiter(popsType);
4185
4352
  let config = PopsAlertDefaultConfig();
4186
4353
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4187
4354
  config = popsUtils.assign(config, __config__);
4188
4355
  config = PopsHandler.handleOnly(popsType, config);
4356
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4189
4357
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4190
4358
  PopsHandler.handleInit($shadowRoot, [
4191
4359
  {
@@ -4379,8 +4547,8 @@ var pops = (function () {
4379
4547
  style: null,
4380
4548
  lightStyle: null,
4381
4549
  darkStyle: null,
4382
- beforeAppendToPageCallBack() { },
4383
4550
  stopKeyDownEventPropagation: true,
4551
+ emitter: null,
4384
4552
  };
4385
4553
  };
4386
4554
 
@@ -4389,11 +4557,11 @@ var pops = (function () {
4389
4557
  const guid = popsUtils.getRandomGUID();
4390
4558
  // 设置当前类型
4391
4559
  const popsType = "confirm";
4392
- const emitter = new EventEmiter(popsType);
4393
4560
  let config = PopsConfirmDefaultConfig();
4394
4561
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4395
4562
  config = popsUtils.assign(config, __config__);
4396
4563
  config = PopsHandler.handleOnly(popsType, config);
4564
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4397
4565
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4398
4566
  PopsHandler.handleInit($shadowRoot, [
4399
4567
  {
@@ -4586,9 +4754,9 @@ var pops = (function () {
4586
4754
  style: null,
4587
4755
  lightStyle: null,
4588
4756
  darkStyle: null,
4589
- beforeAppendToPageCallBack() { },
4590
4757
  forbiddenScroll: false,
4591
4758
  stopKeyDownEventPropagation: true,
4759
+ emitter: null,
4592
4760
  };
4593
4761
  };
4594
4762
 
@@ -4597,11 +4765,11 @@ var pops = (function () {
4597
4765
  const guid = popsUtils.getRandomGUID();
4598
4766
  // 设置当前类型
4599
4767
  const popsType = "drawer";
4600
- const emitter = new EventEmiter(popsType);
4601
4768
  let config = PopsDrawerDefaultConfig();
4602
4769
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4603
4770
  config = popsUtils.assign(config, __config__);
4604
4771
  config = PopsHandler.handleOnly(popsType, config);
4772
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4605
4773
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
4606
4774
  PopsHandler.handleInit($shadowRoot, [
4607
4775
  {
@@ -4812,6 +4980,7 @@ var pops = (function () {
4812
4980
  darkStyle: null,
4813
4981
  addIndexCSS: true,
4814
4982
  stopKeyDownEventPropagation: true,
4983
+ emitter: null,
4815
4984
  };
4816
4985
  };
4817
4986
 
@@ -4819,19 +4988,19 @@ var pops = (function () {
4819
4988
  init(__config__) {
4820
4989
  const guid = popsUtils.getRandomGUID();
4821
4990
  // 设置当前类型
4822
- const PopsType = "loading";
4823
- const emitter = new EventEmiter(PopsType);
4991
+ const popsType = "loading";
4824
4992
  let config = PopsLoadingDefaultConfig();
4825
4993
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
4826
4994
  config = popsUtils.assign(config, __config__);
4827
- config = PopsHandler.handleOnly(PopsType, config);
4995
+ config = PopsHandler.handleOnly(popsType, config);
4996
+ const emitter = config.emitter ?? new EventEmiter(popsType);
4828
4997
  // 先把z-index提取出来
4829
4998
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
4830
4999
  const maskHTML = PopsElementHandler.createMask(guid, zIndex);
4831
5000
  const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
4832
- const animHTML = PopsElementHandler.createAnim(guid, PopsType, config,
5001
+ const animHTML = PopsElementHandler.createAnim(guid, popsType, config,
4833
5002
  /*html*/ `
4834
- <div class="pops-content pops-${PopsType}-content">${config.addIndexCSS
5003
+ <div class="pops-content pops-${popsType}-content">${config.addIndexCSS
4835
5004
  ? /*html*/ `
4836
5005
  <style data-model-name="index">${PopsCSS.index}</style>
4837
5006
  <style data-model-name="anim">${PopsCSS.anim}</style>
@@ -4842,13 +5011,13 @@ var pops = (function () {
4842
5011
  ${PopsCSS.loadingCSS}
4843
5012
  </style>
4844
5013
  ${config.style != null ? `<style>${config.style}</style>` : ""}
4845
- <p pops class="pops-${PopsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
5014
+ <p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
4846
5015
  </div>`, "", zIndex);
4847
5016
  /**
4848
5017
  * 弹窗的主元素,包括动画层
4849
5018
  */
4850
5019
  const $anim = PopsElementHandler.parseElement(animHTML);
4851
- const { $pops: $pops } = PopsHandler.handleQueryElement($anim, PopsType);
5020
+ const { $pops: $pops } = PopsHandler.handleQueryElement($anim, popsType);
4852
5021
  /**
4853
5022
  * 遮罩层元素
4854
5023
  */
@@ -4860,7 +5029,7 @@ var pops = (function () {
4860
5029
  if (config.mask.enable) {
4861
5030
  // 创建遮罩层
4862
5031
  const handleMask = PopsHandler.handleMask({
4863
- type: PopsType,
5032
+ type: popsType,
4864
5033
  guid: guid,
4865
5034
  config: config,
4866
5035
  animElement: $anim,
@@ -4869,12 +5038,12 @@ var pops = (function () {
4869
5038
  $mask = handleMask.maskElement;
4870
5039
  $elList.push($mask);
4871
5040
  }
4872
- const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, PopsType, $anim, $pops, emitter, $mask);
5041
+ const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, popsType, $anim, $pops, emitter, $mask);
4873
5042
  popsDOMUtils.append(config.$parent, $elList);
4874
5043
  if ($mask != null) {
4875
5044
  $anim.after($mask);
4876
5045
  }
4877
- PopsHandler.handlePush(PopsType, {
5046
+ PopsHandler.handlePush(popsType, {
4878
5047
  $shadowContainer: $pops,
4879
5048
  $shadowRoot: $pops,
4880
5049
  guid: guid,
@@ -5043,8 +5212,8 @@ var pops = (function () {
5043
5212
  style: null,
5044
5213
  lightStyle: null,
5045
5214
  darkStyle: null,
5046
- beforeAppendToPageCallBack() { },
5047
5215
  stopKeyDownEventPropagation: true,
5216
+ emitter: null,
5048
5217
  };
5049
5218
  };
5050
5219
 
@@ -5081,11 +5250,11 @@ var pops = (function () {
5081
5250
  const guid = popsUtils.getRandomGUID();
5082
5251
  // 设置当前类型
5083
5252
  const popsType = "folder";
5084
- const emitter = new EventEmiter(popsType);
5085
5253
  let config = PopsFolderDefaultConfig();
5086
5254
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
5087
5255
  config = popsUtils.assign(config, __config__);
5088
5256
  config = PopsHandler.handleOnly(popsType, config);
5257
+ const emitter = config.emitter ?? new EventEmiter(popsType);
5089
5258
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
5090
5259
  PopsHandler.handleInit($shadowRoot, [
5091
5260
  {
@@ -6008,8 +6177,8 @@ var pops = (function () {
6008
6177
  style: null,
6009
6178
  lightStyle: null,
6010
6179
  darkStyle: null,
6011
- beforeAppendToPageCallBack() { },
6012
6180
  stopKeyDownEventPropagation: true,
6181
+ emitter: null,
6013
6182
  };
6014
6183
  };
6015
6184
 
@@ -6018,7 +6187,6 @@ var pops = (function () {
6018
6187
  const guid = popsUtils.getRandomGUID();
6019
6188
  // 设置当前类型
6020
6189
  const popsType = "iframe";
6021
- const emitter = new EventEmiter(popsType);
6022
6190
  let config = PopsIframeDefaultConfig();
6023
6191
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
6024
6192
  config = popsUtils.assign(config, __config__);
@@ -6026,6 +6194,8 @@ var pops = (function () {
6026
6194
  throw new TypeError("config.url must not be null.");
6027
6195
  }
6028
6196
  config = PopsHandler.handleOnly(popsType, config);
6197
+ const emitter = config.emitter ??
6198
+ new EventEmiter(popsType);
6029
6199
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
6030
6200
  PopsHandler.handleInit($shadowRoot, [
6031
6201
  {
@@ -6053,7 +6223,7 @@ var pops = (function () {
6053
6223
  css: PopsCSS.iframeCSS,
6054
6224
  },
6055
6225
  ]);
6056
- const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
6226
+ const maskExtraStyle = config.animation != null && config.animation != "" && config.animation ? "position:absolute;" : "";
6057
6227
  // 先把z-index提取出来
6058
6228
  const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
6059
6229
  const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
@@ -7134,9 +7304,9 @@ var pops = (function () {
7134
7304
  style: null,
7135
7305
  lightStyle: null,
7136
7306
  darkStyle: null,
7137
- beforeAppendToPageCallBack() { },
7138
7307
  stopKeyDownEventPropagation: true,
7139
7308
  listenEscapeKeyUpToExitDeepMenu: true,
7309
+ emitter: null,
7140
7310
  };
7141
7311
  };
7142
7312
 
@@ -7248,7 +7418,7 @@ var pops = (function () {
7248
7418
  style: "",
7249
7419
  lightStyle: null,
7250
7420
  darkStyle: null,
7251
- beforeAppendToPageCallBack() { },
7421
+ emitter: null,
7252
7422
  };
7253
7423
  };
7254
7424
 
@@ -7716,7 +7886,6 @@ var pops = (function () {
7716
7886
  const guid = popsUtils.getRandomGUID();
7717
7887
  // 设置当前类型
7718
7888
  const popsType = "tooltip";
7719
- const emitter = new EventEmiter(popsType);
7720
7889
  let config = PopsTooltipDefaultConfig();
7721
7890
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
7722
7891
  config = popsUtils.assign(config, __config__);
@@ -7733,6 +7902,7 @@ var pops = (function () {
7733
7902
  config.onShowEventName += ` ${it}`;
7734
7903
  });
7735
7904
  }
7905
+ const emitter = config.emitter ?? new EventEmiter(popsType);
7736
7906
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
7737
7907
  PopsHandler.handleInit($shadowRoot, [
7738
7908
  {
@@ -9647,12 +9817,12 @@ var pops = (function () {
9647
9817
  },
9648
9818
  mask: {
9649
9819
  enable: true,
9650
- clickCallBack(originalRun) {
9820
+ clickCallBack(continueExec) {
9651
9821
  const ret = dialogCloseCallback();
9652
9822
  if (typeof ret === "boolean" && !ret) {
9653
9823
  return;
9654
9824
  }
9655
- originalRun();
9825
+ continueExec();
9656
9826
  },
9657
9827
  clickEvent: {
9658
9828
  toClose: true,
@@ -10864,8 +11034,8 @@ var pops = (function () {
10864
11034
  },
10865
11035
  mask: {
10866
11036
  enable: true,
10867
- clickCallBack(originalRun) {
10868
- originalRun();
11037
+ clickCallBack(continueExec) {
11038
+ continueExec();
10869
11039
  dialogCloseCallback();
10870
11040
  },
10871
11041
  clickEvent: {
@@ -11598,11 +11768,11 @@ var pops = (function () {
11598
11768
  const guid = popsUtils.getRandomGUID();
11599
11769
  // 设置当前类型
11600
11770
  const popsType = "panel";
11601
- const emitter = new EventEmiter(popsType);
11602
11771
  let config = PopsPanelDefaultConfig();
11603
11772
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11604
11773
  config = popsUtils.assign(config, __config__);
11605
11774
  config = PopsHandler.handleOnly(popsType, config);
11775
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11606
11776
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11607
11777
  PopsHandler.handleInit($shadowRoot, [
11608
11778
  {
@@ -11852,8 +12022,8 @@ var pops = (function () {
11852
12022
  style: null,
11853
12023
  lightStyle: null,
11854
12024
  darkStyle: null,
11855
- beforeAppendToPageCallBack() { },
11856
12025
  stopKeyDownEventPropagation: true,
12026
+ emitter: null,
11857
12027
  };
11858
12028
  };
11859
12029
 
@@ -11862,11 +12032,11 @@ var pops = (function () {
11862
12032
  const guid = popsUtils.getRandomGUID();
11863
12033
  // 设置当前类型
11864
12034
  const popsType = "prompt";
11865
- const emitter = new EventEmiter(popsType);
11866
12035
  let config = PopsPromptDefaultConfig();
11867
12036
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
11868
12037
  config = popsUtils.assign(config, __config__);
11869
12038
  config = PopsHandler.handleOnly(popsType, config);
12039
+ const emitter = config.emitter ?? new EventEmiter(popsType);
11870
12040
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
11871
12041
  PopsHandler.handleInit($shadowRoot, [
11872
12042
  {
@@ -12087,10 +12257,10 @@ var pops = (function () {
12087
12257
  style: null,
12088
12258
  lightStyle: null,
12089
12259
  darkStyle: null,
12090
- beforeAppendToPageCallBack() { },
12091
12260
  limitPositionXInView: true,
12092
12261
  limitPositionYInView: true,
12093
12262
  beforeShowCallBack() { },
12263
+ emitter: null,
12094
12264
  };
12095
12265
  };
12096
12266
 
@@ -12099,11 +12269,11 @@ var pops = (function () {
12099
12269
  const guid = popsUtils.getRandomGUID();
12100
12270
  // 设置当前类型
12101
12271
  const popsType = "rightClickMenu";
12102
- const emitter = new EventEmiter(popsType);
12103
12272
  let config = PopsRightClickMenuDefaultConfig();
12104
12273
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12105
12274
  config = popsUtils.assign(config, __config__);
12106
12275
  config = PopsHandler.handleOnly(popsType, config);
12276
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12107
12277
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12108
12278
  PopsHandler.handleInit($shadowRoot, [
12109
12279
  {
@@ -12725,6 +12895,7 @@ var pops = (function () {
12725
12895
  style: "",
12726
12896
  lightStyle: null,
12727
12897
  darkStyle: null,
12898
+ emitter: null,
12728
12899
  };
12729
12900
  };
12730
12901
 
@@ -12733,7 +12904,6 @@ var pops = (function () {
12733
12904
  const guid = popsUtils.getRandomGUID();
12734
12905
  // 设置当前类型
12735
12906
  const popsType = "searchSuggestion";
12736
- const emitter = new EventEmiter(popsType);
12737
12907
  let config = PopsSearchSuggestionDefaultConfig();
12738
12908
  config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
12739
12909
  config = popsUtils.assign(config, __config__);
@@ -12741,6 +12911,7 @@ var pops = (function () {
12741
12911
  if (config.$inputTarget == null) {
12742
12912
  config.$inputTarget = config.$target;
12743
12913
  }
12914
+ const emitter = config.emitter ?? new EventEmiter(popsType);
12744
12915
  const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
12745
12916
  PopsHandler.handleInit($shadowRoot, [
12746
12917
  {
@@ -13509,93 +13680,12 @@ var pops = (function () {
13509
13680
  },
13510
13681
  };
13511
13682
 
13512
- const PopsInstanceUtils = {
13513
- /**
13514
- * 获取pops所有弹窗中的最大的z-index
13515
- * @param deviation
13516
- */
13517
- getPopsMaxZIndex(deviation = 1) {
13518
- deviation = Number.isNaN(deviation) ? 1 : deviation;
13519
- // 最大值 2147483647
13520
- // const browserMaxZIndex = Math.pow(2, 31) - 1;
13521
- // 比较值 2000000000
13522
- const maxZIndex = 2 * Math.pow(10, 9);
13523
- // 当前页面最大的z-index
13524
- let zIndex = 0;
13525
- // 当前的最大z-index的元素,调试使用
13526
- let maxZIndexNode = null;
13527
- Object.keys(PopsInstData).forEach((instKeyName) => {
13528
- const instData = PopsInstData[instKeyName];
13529
- for (let index = 0; index < instData.length; index++) {
13530
- const inst = instData[index];
13531
- // 不对position为static和display为none的元素进行获取它们的z-index
13532
- const $elList = [inst.$anim, inst.$pops, inst.$mask].filter((it) => it instanceof HTMLElement);
13533
- const nodeZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint($elList);
13534
- const maxNodeZIndexInfo = nodeZIndexInfoList[0];
13535
- if (maxNodeZIndexInfo) {
13536
- const nodeZIndex = maxNodeZIndexInfo.zIndex;
13537
- if (nodeZIndex > zIndex) {
13538
- zIndex = nodeZIndex;
13539
- maxZIndexNode = maxNodeZIndexInfo.node || maxNodeZIndexInfo.positionNode;
13540
- }
13541
- }
13542
- }
13543
- });
13544
- zIndex += deviation;
13545
- const isOverMaxZIndex = zIndex >= maxZIndex;
13546
- if (isOverMaxZIndex) {
13547
- // 超出z-index最大值
13548
- zIndex = maxZIndex;
13549
- }
13550
- return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
13551
- },
13552
- /**
13553
- * 排序数组
13554
- * @param getBeforeValueFun
13555
- * @param getAfterValueFun
13556
- * @param sortByDesc 排序是否降序,默认降序
13557
- */
13558
- sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
13559
- if (typeof sortByDesc !== "boolean") {
13560
- throw new TypeError("参数 sortByDesc 必须为boolean类型");
13561
- }
13562
- if (getBeforeValueFun == null || getAfterValueFun == null) {
13563
- throw new Error("获取前面的值或后面的值的方法不能为空");
13564
- }
13565
- return function (after_obj, before_obj) {
13566
- const beforeValue = getBeforeValueFun(before_obj); // 前
13567
- const afterValue = getAfterValueFun(after_obj); // 后
13568
- if (sortByDesc) {
13569
- if (afterValue > beforeValue) {
13570
- return -1;
13571
- }
13572
- else if (afterValue < beforeValue) {
13573
- return 1;
13574
- }
13575
- else {
13576
- return 0;
13577
- }
13578
- }
13579
- else {
13580
- if (afterValue < beforeValue) {
13581
- return -1;
13582
- }
13583
- else if (afterValue > beforeValue) {
13584
- return 1;
13585
- }
13586
- else {
13587
- return 0;
13588
- }
13589
- }
13590
- };
13591
- },
13592
- };
13593
-
13594
13683
  class Pops {
13595
13684
  /** 配置 */
13596
13685
  config = {
13597
13686
  /** 版本号 */
13598
13687
  version: version,
13688
+ /** 样式配置 */
13599
13689
  cssText: PopsCSS,
13600
13690
  /** icon图标的svg代码 */
13601
13691
  iconSVG: PopsIcon.$data,
@@ -13603,12 +13693,9 @@ var pops = (function () {
13603
13693
  animation: PopsAnimation.$data,
13604
13694
  /** 存储已创建的元素 */
13605
13695
  instData: PopsInstData,
13606
- /** 禁止滚动 */
13607
- forbiddenScroll: {
13608
- event(event) {
13609
- return popsDOMUtils.preventEvent(event);
13610
- },
13611
- },
13696
+ };
13697
+ /** 导出的函数 */
13698
+ fn = {
13612
13699
  /** pops使用的工具类 */
13613
13700
  Utils: popsUtils,
13614
13701
  /** pops使用的DOM工具类 */
@@ -13618,15 +13705,16 @@ var pops = (function () {
13618
13705
  /** pops处理float类型使用的工具类 */
13619
13706
  MathFloatUtils: PopsMathFloatUtils,
13620
13707
  /** 实例处理函数 */
13621
- PopsInstHandler,
13708
+ InstHandler: PopsInstHandler,
13622
13709
  /** pops.panel中用于处理各个类型的工具 */
13623
- PanelHandlerComponents,
13710
+ PanelHandlerComponents: PanelHandlerComponents,
13624
13711
  /** pops.panel中的动画 */
13625
- PopsAnimation,
13712
+ Animation: PopsAnimation,
13626
13713
  /** 事件类 */
13627
- EventEmiter,
13714
+ EventEmiter: EventEmiter,
13715
+ /** 通用的CSS类名 */
13716
+ CommonCSSClassName: PopsCommonCSSClassName,
13628
13717
  };
13629
- init() { }
13630
13718
  /**
13631
13719
  * 释放原有的pops控制权
13632
13720
  * @example